aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/backup-delete/Materials/FlatMaterial.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-03-13 13:05:33 -0700
committerNivesh Rajbhandari2012-03-13 13:05:33 -0700
commit92fc2e3c4bca2edb04102431b4959aafe022f329 (patch)
treed48c090f71ed2cd6bd6ce38ff68c36ab69299985 /js/helper-classes/backup-delete/Materials/FlatMaterial.js
parentefb92cf52680d31f05fed3757e74862592cc2d4c (diff)
parentf56b8cf4d3316d250c0f0045fb78f0dbd5c56e94 (diff)
downloadninja-92fc2e3c4bca2edb04102431b4959aafe022f329.tar.gz
Merge branch 'refs/heads/ninja-internal' into ToolFixes
Diffstat (limited to 'js/helper-classes/backup-delete/Materials/FlatMaterial.js')
-rwxr-xr-xjs/helper-classes/backup-delete/Materials/FlatMaterial.js34
1 files changed, 19 insertions, 15 deletions
diff --git a/js/helper-classes/backup-delete/Materials/FlatMaterial.js b/js/helper-classes/backup-delete/Materials/FlatMaterial.js
index 570e7f9e..eb8970b8 100755
--- a/js/helper-classes/backup-delete/Materials/FlatMaterial.js
+++ b/js/helper-classes/backup-delete/Materials/FlatMaterial.js
@@ -40,19 +40,27 @@ function FlatMaterial()
40 // duplcate method requirde 40 // duplcate method requirde
41 this.dup = function() { return new FlatMaterial(); } ; 41 this.dup = function() { return new FlatMaterial(); } ;
42 42
43 this.init = function() 43 this.init = function( world )
44 { 44 {
45 // set up the shader 45 // save the world
46 this._shader = new jshader(); 46 if (world)
47 this._shader.def = flatShaderDef; 47 {
48 this._shader.init(); 48 this.setWorld( world );
49
50 // set up the shader
51 this._shader = new jshader();
52 this._shader.def = flatShaderDef;
53 this._shader.init();
49 54
50 // set the defaults 55 // set the defaults
51 this._shader.colorMe.color.set( this.getColor() ); 56 this._shader.colorMe.color.set( this.getColor() );
52 57
53 // set up the material node 58 // set up the material node
54 this._materialNode = createMaterialNode("flatMaterial"); 59 this._materialNode = createMaterialNode("flatMaterial_" + world.generateUniqueNodeID() );
55 this._materialNode.setShader(this._shader); 60 this._materialNode.setShader(this._shader);
61 }
62 else
63 throw new Error( "GLWorld not supplied to material initialization" );
56 }; 64 };
57 65
58 66
@@ -83,11 +91,7 @@ function FlatMaterial()
83 // this function should be overridden by subclasses 91 // this function should be overridden by subclasses
84 var exportStr = "material: " + this.getShaderName() + "\n"; 92 var exportStr = "material: " + this.getShaderName() + "\n";
85 exportStr += "name: " + this.getName() + "\n"; 93 exportStr += "name: " + this.getName() + "\n";
86 94 exportStr += "color: " + String(this._propValues["color"]) + "\n";
87 if (this._shader)
88 exportStr += "color: " + String(this._shader.colorMe.color) + "\n";
89 else
90 exportStr += "color: " + this.getColor() + "\n";
91 exportStr += "endMaterial\n"; 95 exportStr += "endMaterial\n";
92 96
93 return exportStr; 97 return exportStr;