diff options
Diffstat (limited to 'js/lib/geom/rectangle.js')
-rwxr-xr-x | js/lib/geom/rectangle.js | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/js/lib/geom/rectangle.js b/js/lib/geom/rectangle.js index 42d51e74..81a8556d 100755 --- a/js/lib/geom/rectangle.js +++ b/js/lib/geom/rectangle.js | |||
@@ -73,16 +73,19 @@ exports.Rectangle = Object.create(GeomObj, { | |||
73 | this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; | 73 | this._materialSpecular = [0.4, 0.4, 0.4, 1.0]; |
74 | 74 | ||
75 | if(strokeMaterial) { | 75 | if(strokeMaterial) { |
76 | this._strokeMaterial = strokeMaterial; | 76 | this._strokeMaterial = strokeMaterial.dup(); |
77 | } else { | 77 | } else { |
78 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | 78 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
79 | } | 79 | } |
80 | if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); | ||
81 | |||
80 | 82 | ||
81 | if(fillMaterial) { | 83 | if(fillMaterial) { |
82 | this._fillMaterial = fillMaterial; | 84 | this._fillMaterial = fillMaterial.dup(); |
83 | } else { | 85 | } else { |
84 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | 86 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
85 | } | 87 | } |
88 | if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor ); | ||
86 | } | 89 | } |
87 | }, | 90 | }, |
88 | 91 | ||
@@ -289,19 +292,23 @@ exports.Rectangle = Object.create(GeomObj, { | |||
289 | var strokeMaterialName = jObj.strokeMat; | 292 | var strokeMaterialName = jObj.strokeMat; |
290 | var fillMaterialName = jObj.fillMat; | 293 | var fillMaterialName = jObj.fillMat; |
291 | 294 | ||
292 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); | 295 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ).dup(); |
293 | if (!strokeMat) { | 296 | if (!strokeMat) { |
294 | console.log( "object material not found in library: " + strokeMaterialName ); | 297 | console.log( "object material not found in library: " + strokeMaterialName ); |
295 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | 298 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
296 | } | 299 | } |
297 | this._strokeMaterial = strokeMat; | 300 | this._strokeMaterial = strokeMat; |
301 | if (this._strokeMaterial.hasProperty( 'color' )) | ||
302 | this._strokeMaterial.setProperty( 'color', this._strokeColor ); | ||
298 | 303 | ||
299 | var fillMat = MaterialsModel.getMaterial( fillMaterialName ); | 304 | var fillMat = MaterialsModel.getMaterial( fillMaterialName ).dup(); |
300 | if (!fillMat) { | 305 | if (!fillMat) { |
301 | console.log( "object material not found in library: " + fillMaterialName ); | 306 | console.log( "object material not found in library: " + fillMaterialName ); |
302 | fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | 307 | fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
303 | } | 308 | } |
304 | this._fillMaterial = fillMat; | 309 | this._fillMaterial = fillMat; |
310 | if (this._fillMaterial.hasProperty( 'color' )) | ||
311 | this._fillMaterial.setProperty( 'color', this._fillColor ); | ||
305 | 312 | ||
306 | this.importMaterialsJSON( jObj.materials ); | 313 | this.importMaterialsJSON( jObj.materials ); |
307 | } | 314 | } |