diff options
Diffstat (limited to 'js/lib/rdge/materials/twist-vert-material.js')
-rw-r--r-- | js/lib/rdge/materials/twist-vert-material.js | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/js/lib/rdge/materials/twist-vert-material.js b/js/lib/rdge/materials/twist-vert-material.js index 1f7b06b1..9af1953d 100644 --- a/js/lib/rdge/materials/twist-vert-material.js +++ b/js/lib/rdge/materials/twist-vert-material.js | |||
@@ -46,8 +46,10 @@ function TwistVertMaterial() | |||
46 | // duplcate method requirde | 46 | // duplcate method requirde |
47 | this.dup = function() { return new TwistVertMaterial(); } | 47 | this.dup = function() { return new TwistVertMaterial(); } |
48 | 48 | ||
49 | this.init = function() | 49 | this.init = function( world ) |
50 | { | 50 | { |
51 | this.setWorld( world ); | ||
52 | |||
51 | // set up the shader | 53 | // set up the shader |
52 | this._shader = new RDGE.jshader(); | 54 | this._shader = new RDGE.jshader(); |
53 | this._shader.def = twistVertShaderDef; | 55 | this._shader.def = twistVertShaderDef; |
@@ -57,7 +59,7 @@ function TwistVertMaterial() | |||
57 | this._shader.twistMe.color.set( this.getColor() ); | 59 | this._shader.twistMe.color.set( this.getColor() ); |
58 | 60 | ||
59 | // set up the material node | 61 | // set up the material node |
60 | this._materialNode = RDGE.createMaterialNode("twistVertMaterial"); | 62 | this._materialNode = RDGE.createMaterialNode("twistVertMaterial" + "_" + world.generateUniqueNodeID()); |
61 | this._materialNode.setShader(this._shader); | 63 | this._materialNode.setShader(this._shader); |
62 | 64 | ||
63 | // initialize the twist vert properties | 65 | // initialize the twist vert properties |
@@ -100,6 +102,34 @@ function TwistVertMaterial() | |||
100 | } | 102 | } |
101 | /////////////////////////////////////////////////////////////////////// | 103 | /////////////////////////////////////////////////////////////////////// |
102 | 104 | ||
105 | this.exportJSON = function() | ||
106 | { | ||
107 | var jObj = | ||
108 | { | ||
109 | 'material' : this.getShaderName(), | ||
110 | 'name' : this.getName(), | ||
111 | 'color' : this._propValues["color"] | ||
112 | }; | ||
113 | |||
114 | return jObj; | ||
115 | } | ||
116 | |||
117 | this.importJSON = function( jObj ) | ||
118 | { | ||
119 | if (this.getShaderName() != jObj.material) throw new Error( "ill-formed material" ); | ||
120 | this.setName( jObj.name ); | ||
121 | |||
122 | try | ||
123 | { | ||
124 | var color = jObj.color; | ||
125 | this.setProperty( "color", color); | ||
126 | } | ||
127 | catch (e) | ||
128 | { | ||
129 | throw new Error( "could not import material: " + importStr ); | ||
130 | } | ||
131 | } | ||
132 | |||
103 | this.export = function() | 133 | this.export = function() |
104 | { | 134 | { |
105 | // this function should be overridden by subclasses | 135 | // this function should be overridden by subclasses |