From 6c994c4b90023cecf4fd0caafb404b859fe28f54 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 6 Jun 2012 16:34:41 -0700 Subject: material cleanup and rearchitecture --- js/lib/geom/circle.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'js/lib/geom/circle.js') diff --git a/js/lib/geom/circle.js b/js/lib/geom/circle.js index b2709ce4..6627b4b7 100755 --- a/js/lib/geom/circle.js +++ b/js/lib/geom/circle.js @@ -57,16 +57,18 @@ exports.Circle = Object.create(GeomObj, { this.m_world = world; if(strokeMaterial) { - this._strokeMaterial = strokeMaterial; + this._strokeMaterial = strokeMaterial.dup(); } else { - this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); + this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } + if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); if(fillMaterial) { - this._fillMaterial = fillMaterial; + this._fillMaterial = fillMaterial.dup(); } else { - this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); + this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } + if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor ); } }, @@ -702,19 +704,23 @@ exports.Circle = Object.create(GeomObj, { var strokeMaterialName = jObj.strokeMat; var fillMaterialName = jObj.fillMat; - var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); + var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ).dup(); if (!strokeMat) { console.log( "object material not found in library: " + strokeMaterialName ); - strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); + strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } this._strokeMaterial = strokeMat; + if (this._strokeMaterial.hasProperty( 'color' )) + this._strokeMaterial.setProperty( 'color', this._strokeColor ); - var fillMat = MaterialsModel.getMaterial( fillMaterialName ); + var fillMat = MaterialsModel.getMaterial( fillMaterialName ).dup(); if (!fillMat) { console.log( "object material not found in library: " + fillMaterialName ); - fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); + fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); } this._fillMaterial = fillMat; + if (this._fillMaterial.hasProperty( 'color' )) + this._fillMaterial.setProperty( 'color', this._fillColor ); this.importMaterialsJSON( jObj.materials ); } -- cgit v1.2.3