aboutsummaryrefslogtreecommitdiff
path: root/js/lib/rdge/materials/flat-material.js
diff options
context:
space:
mode:
authorValerio Virgillito2012-03-13 11:15:34 -0700
committerValerio Virgillito2012-03-13 11:15:34 -0700
commitf6b958360d82854bdaf51848e7fd715d1f633179 (patch)
tree80f6c08bb730089bdd3f26310df8d2363f9ba863 /js/lib/rdge/materials/flat-material.js
parentc24f58c10231c30d3a8a4c9fb9a4f395dd746180 (diff)
parent4d7b86f55c504ee4e8c2460cf6b60cb9a2cf18f0 (diff)
downloadninja-f6b958360d82854bdaf51848e7fd715d1f633179.tar.gz
Merge pull request #105 from joseeight/FileIO-Build-Candidate
File I/O adding webGL/canvas data functionality
Diffstat (limited to 'js/lib/rdge/materials/flat-material.js')
-rwxr-xr-xjs/lib/rdge/materials/flat-material.js41
1 files changed, 23 insertions, 18 deletions
diff --git a/js/lib/rdge/materials/flat-material.js b/js/lib/rdge/materials/flat-material.js
index be8bf2b8..97e4f646 100755
--- a/js/lib/rdge/materials/flat-material.js
+++ b/js/lib/rdge/materials/flat-material.js
@@ -36,19 +36,27 @@ var FlatMaterial = function FlatMaterial() {
36 // duplcate method requirde 36 // duplcate method requirde
37 this.dup = function() { return new FlatMaterial(); } ; 37 this.dup = function() { return new FlatMaterial(); } ;
38 38
39 this.init = function() 39 this.init = function( world )
40 { 40 {
41 // set up the shader 41 // save the world
42 this._shader = new jshader(); 42 if (world)
43 this._shader.def = flatShaderDef; 43 {
44 this._shader.init(); 44 this.setWorld( world );
45 45
46 // set the defaults 46 // set up the shader
47 this._shader.colorMe.color.set( this.getColor() ); 47 this._shader = new jshader();
48 48 this._shader.def = flatShaderDef;
49 // set up the material node 49 this._shader.init();
50 this._materialNode = createMaterialNode("flatMaterial"); 50
51 this._materialNode.setShader(this._shader); 51 // set the defaults
52 this._shader.colorMe.color.set( this.getColor() );
53
54 // set up the material node
55 this._materialNode = createMaterialNode("flatMaterial_" + world.generateUniqueNodeID() );
56 this._materialNode.setShader(this._shader);
57 }
58 else
59 throw new Error( "GLWorld not supplied to material initialization" );
52 }; 60 };
53 61
54 62
@@ -73,15 +81,12 @@ var FlatMaterial = function FlatMaterial() {
73 }; 81 };
74 /////////////////////////////////////////////////////////////////////// 82 ///////////////////////////////////////////////////////////////////////
75 83
76 this.export = function() { 84 this.export = function()
85 {
77 // this function should be overridden by subclasses 86 // this function should be overridden by subclasses
78 var exportStr = "material: " + this.getShaderName() + "\n"; 87 var exportStr = "material: " + this.getShaderName() + "\n";
79 exportStr += "name: " + this.getName() + "\n"; 88 exportStr += "name: " + this.getName() + "\n";
80 89 exportStr += "color: " + String(this._propValues["color"]) + "\n";
81 if (this._shader)
82 exportStr += "color: " + String(this._shader.colorMe.color) + "\n";
83 else
84 exportStr += "color: " + this.getColor() + "\n";
85 exportStr += "endMaterial\n"; 90 exportStr += "endMaterial\n";
86 91
87 return exportStr; 92 return exportStr;