aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/backup-delete/Materials/FlatMaterial.js
diff options
context:
space:
mode:
authorPushkar Joshi2012-03-13 11:24:35 -0700
committerPushkar Joshi2012-03-13 11:24:35 -0700
commit4ad1650f629e7e345eade52ed6dadc233b27cc45 (patch)
tree0e7b925f4dedf27f2684915e7e247e79c4a74aff /js/helper-classes/backup-delete/Materials/FlatMaterial.js
parent730c42e005b1ebd96448e3bc2dd700ffd8909cb5 (diff)
parent9f3307810541ca6f95d7ca6d1febe8afdcd2c101 (diff)
downloadninja-4ad1650f629e7e345eade52ed6dadc233b27cc45.tar.gz
Merge branch 'master' into pentool
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;