diff options
Diffstat (limited to 'js/lib/geom')
-rwxr-xr-x | js/lib/geom/circle.js | 18 | ||||
-rwxr-xr-x | js/lib/geom/geom-obj.js | 12 | ||||
-rwxr-xr-x | js/lib/geom/line.js | 11 | ||||
-rwxr-xr-x | js/lib/geom/rectangle.js | 28 |
4 files changed, 17 insertions, 52 deletions
diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index fec62308..d48bf98b 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js | |||
@@ -634,24 +634,6 @@ var Circle = function GLCircle() { | |||
634 | var strokeMaterialName = jObj.strokeMat; | 634 | var strokeMaterialName = jObj.strokeMat; |
635 | var fillMaterialName = jObj.fillMat; | 635 | var fillMaterialName = jObj.fillMat; |
636 | this.importMaterialsJSON( jObj.materials ); | 636 | this.importMaterialsJSON( jObj.materials ); |
637 | |||
638 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); | ||
639 | if (!strokeMat) { | ||
640 | console.log( "object material not found in library: " + strokeMaterialName ); | ||
641 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | ||
642 | } | ||
643 | else | ||
644 | strokeMat = strokeMat.dup(); | ||
645 | this._strokeMaterial = strokeMat; | ||
646 | |||
647 | var fillMat = MaterialsModel.getMaterial( fillMaterialName ); | ||
648 | if (!fillMat) { | ||
649 | console.log( "object material not found in library: " + fillMaterialName ); | ||
650 | fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | ||
651 | } | ||
652 | else | ||
653 | fillMat = fillMat.dup(); | ||
654 | this._fillMaterial = fillMat; | ||
655 | }; | 637 | }; |
656 | 638 | ||
657 | 639 | ||
diff --git a/js/lib/geom/geom-obj.js b/js/lib/geom/geom-obj.js index 63f71955..75b7808b 100755 --- a/js/lib/geom/geom-obj.js +++ b/js/lib/geom/geom-obj.js | |||
@@ -279,6 +279,11 @@ var GeomObj = function GLGeomObj() { | |||
279 | 279 | ||
280 | this.importMaterialsJSON = function( jObj ) | 280 | this.importMaterialsJSON = function( jObj ) |
281 | { | 281 | { |
282 | this._materialArray = []; | ||
283 | this._materialTypeArray = []; | ||
284 | |||
285 | if (!jObj) return; | ||
286 | |||
282 | var nMaterials = jObj.nMaterials; | 287 | var nMaterials = jObj.nMaterials; |
283 | var matArray = jObj.materials; | 288 | var matArray = jObj.materials; |
284 | for (var i=0; i<nMaterials; i++) | 289 | for (var i=0; i<nMaterials; i++) |
@@ -318,7 +323,14 @@ var GeomObj = function GLGeomObj() { | |||
318 | } | 323 | } |
319 | 324 | ||
320 | if (mat) | 325 | if (mat) |
326 | { | ||
321 | mat.importJSON( matObj ); | 327 | mat.importJSON( matObj ); |
328 | this._materialArray.push( mat ); | ||
329 | this._materialTypeArray.push( matObj.type ); | ||
330 | var type = matArray[i].type; | ||
331 | if (type == "fill") this._fillMaterial = mat; | ||
332 | else this._strokeMaterial = mat; | ||
333 | } | ||
322 | } | 334 | } |
323 | } | 335 | } |
324 | 336 | ||
diff --git a/js/lib/geom/line.js b/js/lib/geom/line.js index a706eb93..e839e229 100755 --- a/js/lib/geom/line.js +++ b/js/lib/geom/line.js | |||
@@ -137,16 +137,7 @@ var Line = function GLLine( world, xOffset, yOffset, width, height, slope, strok | |||
137 | this._strokeStyle = jObj.strokeStyle; | 137 | this._strokeStyle = jObj.strokeStyle; |
138 | this._strokeColor = jObj.strokeColor; | 138 | this._strokeColor = jObj.strokeColor; |
139 | var strokeMaterialName = jObj.strokeMat; | 139 | var strokeMaterialName = jObj.strokeMat; |
140 | 140 | this.importMaterialsJSON( jObj.materials ); | |
141 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); | ||
142 | if (!strokeMat) { | ||
143 | console.log( "object material not found in library: " + strokeMaterialName ); | ||
144 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | ||
145 | } | ||
146 | else | ||
147 | strokeMat = strokeMat.dup(); | ||
148 | this._strokeMaterial = strokeMat; | ||
149 | |||
150 | }; | 141 | }; |
151 | 142 | ||
152 | this.export = function() { | 143 | this.export = function() { |
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index c6bc2d88..38e428bd 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js | |||
@@ -78,8 +78,6 @@ var Rectangle = function GLRectangle() { | |||
78 | } else { | 78 | } else { |
79 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | 79 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); |
80 | } | 80 | } |
81 | |||
82 | this.exportMaterials(); | ||
83 | }; | 81 | }; |
84 | 82 | ||
85 | /////////////////////////////////////////////////////////////////////// | 83 | /////////////////////////////////////////////////////////////////////// |
@@ -291,24 +289,6 @@ var Rectangle = function GLRectangle() { | |||
291 | var strokeMaterialName = jObj.strokeMat; | 289 | var strokeMaterialName = jObj.strokeMat; |
292 | var fillMaterialName = jObj.fillMat; | 290 | var fillMaterialName = jObj.fillMat; |
293 | this.importMaterialsJSON( jObj.materials ); | 291 | this.importMaterialsJSON( jObj.materials ); |
294 | |||
295 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); | ||
296 | if (!strokeMat) { | ||
297 | console.log( "object material not found in library: " + strokeMaterialName ); | ||
298 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | ||
299 | } | ||
300 | else | ||
301 | strokeMat = strokeMat.dup(); | ||
302 | this._strokeMaterial = strokeMat; | ||
303 | |||
304 | var fillMat = MaterialsModel.getMaterial( fillMaterialName ); | ||
305 | if (!fillMat) { | ||
306 | console.log( "object material not found in library: " + fillMaterialName ); | ||
307 | fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | ||
308 | } | ||
309 | else | ||
310 | fillMat = fillMat.dup(); | ||
311 | this._fillMaterial = fillMat; | ||
312 | }; | 292 | }; |
313 | 293 | ||
314 | this.import = function( importStr ) { | 294 | this.import = function( importStr ) { |
@@ -430,10 +410,10 @@ var Rectangle = function GLRectangle() { | |||
430 | brRadius = -z*(r-l)/(2.0*zn)*brRadiusNDC; | 410 | brRadius = -z*(r-l)/(2.0*zn)*brRadiusNDC; |
431 | 411 | ||
432 | // stroke | 412 | // stroke |
433 | // var strokeMaterial = this.makeStrokeMaterial(); | 413 | var strokeMaterial = this.makeStrokeMaterial(); |
434 | // var strokePrim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius, strokeMaterial); | 414 | var strokePrim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius, strokeMaterial); |
435 | // this._primArray.push( strokePrim ); | 415 | this._primArray.push( strokePrim ); |
436 | // this._materialNodeArray.push( strokeMaterial.getMaterialNode() ); | 416 | this._materialNodeArray.push( strokeMaterial.getMaterialNode() ); |
437 | 417 | ||
438 | // fill | 418 | // fill |
439 | tlRadius -= strokeSize; if (tlRadius < 0) tlRadius = 0.0; | 419 | tlRadius -= strokeSize; if (tlRadius < 0) tlRadius = 0.0; |