diff options
author | hwc487 | 2012-06-06 16:34:41 -0700 |
---|---|---|
committer | hwc487 | 2012-06-06 16:34:41 -0700 |
commit | 6c994c4b90023cecf4fd0caafb404b859fe28f54 (patch) | |
tree | 75a4d813441ca6a3eb529dc88a749776459bb76e /js/lib/geom/circle.js | |
parent | 920436977433ea55c01ce1e73895d1db0a6abac1 (diff) | |
download | ninja-6c994c4b90023cecf4fd0caafb404b859fe28f54.tar.gz |
material cleanup and rearchitecture
Diffstat (limited to 'js/lib/geom/circle.js')
-rwxr-xr-x | js/lib/geom/circle.js | 22 |
1 files changed, 14 insertions, 8 deletions
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, { | |||
57 | this.m_world = world; | 57 | this.m_world = world; |
58 | 58 | ||
59 | if(strokeMaterial) { | 59 | if(strokeMaterial) { |
60 | this._strokeMaterial = strokeMaterial; | 60 | this._strokeMaterial = strokeMaterial.dup(); |
61 | } else { | 61 | } else { |
62 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | 62 | this._strokeMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
63 | } | 63 | } |
64 | if (strokeColor && this._strokeMaterial.hasProperty( "color" )) this._strokeMaterial.setProperty( "color", this._strokeColor ); | ||
64 | 65 | ||
65 | if(fillMaterial) { | 66 | if(fillMaterial) { |
66 | this._fillMaterial = fillMaterial; | 67 | this._fillMaterial = fillMaterial.dup(); |
67 | } else { | 68 | } else { |
68 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | 69 | this._fillMaterial = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
69 | } | 70 | } |
71 | if (fillColor && this._fillMaterial.hasProperty( "color" )) this._fillMaterial.setProperty( "color", this._fillColor ); | ||
70 | } | 72 | } |
71 | }, | 73 | }, |
72 | 74 | ||
@@ -702,19 +704,23 @@ exports.Circle = Object.create(GeomObj, { | |||
702 | var strokeMaterialName = jObj.strokeMat; | 704 | var strokeMaterialName = jObj.strokeMat; |
703 | var fillMaterialName = jObj.fillMat; | 705 | var fillMaterialName = jObj.fillMat; |
704 | 706 | ||
705 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ); | 707 | var strokeMat = MaterialsModel.getMaterial( strokeMaterialName ).dup(); |
706 | if (!strokeMat) { | 708 | if (!strokeMat) { |
707 | console.log( "object material not found in library: " + strokeMaterialName ); | 709 | console.log( "object material not found in library: " + strokeMaterialName ); |
708 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | 710 | strokeMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
709 | } | 711 | } |
710 | this._strokeMaterial = strokeMat; | 712 | this._strokeMaterial = strokeMat; |
713 | if (this._strokeMaterial.hasProperty( 'color' )) | ||
714 | this._strokeMaterial.setProperty( 'color', this._strokeColor ); | ||
711 | 715 | ||
712 | var fillMat = MaterialsModel.getMaterial( fillMaterialName ); | 716 | var fillMat = MaterialsModel.getMaterial( fillMaterialName ).dup(); |
713 | if (!fillMat) { | 717 | if (!fillMat) { |
714 | console.log( "object material not found in library: " + fillMaterialName ); | 718 | console.log( "object material not found in library: " + fillMaterialName ); |
715 | fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ); | 719 | fillMat = MaterialsModel.getMaterial( MaterialsModel.getDefaultMaterialName() ).dup(); |
716 | } | 720 | } |
717 | this._fillMaterial = fillMat; | 721 | this._fillMaterial = fillMat; |
722 | if (this._fillMaterial.hasProperty( 'color' )) | ||
723 | this._fillMaterial.setProperty( 'color', this._fillColor ); | ||
718 | 724 | ||
719 | this.importMaterialsJSON( jObj.materials ); | 725 | this.importMaterialsJSON( jObj.materials ); |
720 | } | 726 | } |