aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib')
-rw-r--r--js/lib/rdge/materials/pulse-material.js1
-rw-r--r--js/lib/rdge/materials/taper-material.js12
-rw-r--r--js/lib/rdge/materials/twist-vert-material.js53
-rw-r--r--js/lib/rdge/texture.js45
4 files changed, 20 insertions, 91 deletions
diff --git a/js/lib/rdge/materials/pulse-material.js b/js/lib/rdge/materials/pulse-material.js
index f7f6c7ae..276f7de6 100644
--- a/js/lib/rdge/materials/pulse-material.js
+++ b/js/lib/rdge/materials/pulse-material.js
@@ -308,7 +308,6 @@ var pulseMaterialDef =
308 } 308 }
309}; 309};
310 310
311// doing the inheritance here introtudes bugs. Local instance variables are overwritten in the base class
312//PulseMaterial.prototype = new Material(); 311//PulseMaterial.prototype = new Material();
313 312
314if (typeof exports === "object") { 313if (typeof exports === "object") {
diff --git a/js/lib/rdge/materials/taper-material.js b/js/lib/rdge/materials/taper-material.js
index 15b7b2b0..efba3807 100644
--- a/js/lib/rdge/materials/taper-material.js
+++ b/js/lib/rdge/materials/taper-material.js
@@ -4,15 +4,17 @@
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */ 5 </copyright> */
6 6
7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; 7var Material = require("js/lib/rdge/materials/material").Material;
8var Texture = require("js/lib/rdge/texture").Texture;
9
8/////////////////////////////////////////////////////////////////////// 10///////////////////////////////////////////////////////////////////////
9// Class GLMaterial 11// Class GLMaterial
10// RDGE representation of a material. 12// RDGE representation of a material.
11/////////////////////////////////////////////////////////////////////// 13///////////////////////////////////////////////////////////////////////
12function TaperMaterial() 14var TaperMaterial = function TaperMaterial()
13{ 15{
14 // initialize the inherited members 16 // initialize the inherited members
15 this.inheritedFrom = GLMaterial; 17 this.inheritedFrom = Material;
16 this.inheritedFrom(); 18 this.inheritedFrom();
17 19
18 /////////////////////////////////////////////////////////////////////// 20 ///////////////////////////////////////////////////////////////////////
@@ -250,3 +252,7 @@ taperShaderDef =
250 } 252 }
251}; 253};
252 254
255
256if (typeof exports === "object") {
257 exports.TaperMaterial = TaperMaterial;
258}
diff --git a/js/lib/rdge/materials/twist-vert-material.js b/js/lib/rdge/materials/twist-vert-material.js
index 802690a2..f093fbca 100644
--- a/js/lib/rdge/materials/twist-vert-material.js
+++ b/js/lib/rdge/materials/twist-vert-material.js
@@ -4,15 +4,17 @@
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */ 5 </copyright> */
6 6
7var MaterialParser = require("js/lib/rdge/materials/material-parser").MaterialParser; 7var Material = require("js/lib/rdge/materials/material").Material;
8var Texture = require("js/lib/rdge/texture").Texture;
9
8/////////////////////////////////////////////////////////////////////// 10///////////////////////////////////////////////////////////////////////
9// Class GLMaterial 11// Class GLMaterial
10// RDGE representation of a material. 12// RDGE representation of a material.
11/////////////////////////////////////////////////////////////////////// 13///////////////////////////////////////////////////////////////////////
12function TwistVertMaterial() 14var TwistVertMaterial = function TwistVertMaterial()
13{ 15{
14 // initialize the inherited members 16 // initialize the inherited members
15 this.inheritedFrom = GLMaterial; 17 this.inheritedFrom = Material;
16 this.inheritedFrom(); 18 this.inheritedFrom();
17 19
18 /////////////////////////////////////////////////////////////////////// 20 ///////////////////////////////////////////////////////////////////////
@@ -131,47 +133,6 @@ function TwistVertMaterial()
131 } 133 }
132 } 134 }
133 135
134 this.export = function()
135 {
136 // this function should be overridden by subclasses
137 var exportStr = "material: " + this.getShaderName() + "\n";
138 exportStr += "name: " + this.getName() + "\n";
139
140 if (this._shader)
141 exportStr += "color: " + String(this._shader.twistMe.color) + "\n";
142 else
143 exportStr += "color: " + this.getColor() + "\n";
144 exportStr += "endMaterial\n";
145
146 return exportStr;
147 }
148
149 this.import = function( importStr )
150 {
151 var pu = new MaterialParser( importStr );
152 var material = pu.nextValue( "material: " );
153 if (material != this.getShaderName()) throw new Error( "ill-formed material" );
154 this.setName( pu.nextValue( "name: ") );
155
156 var rtnStr;
157 try
158 {
159 var color = eval( "[" + pu.nextValue( "color: " ) + "]" );
160
161 this.setProperty( "color", color);
162
163 var endKey = "endMaterial\n";
164 var index = importStr.indexOf( endKey );
165 index += endKey.length;
166 rtnStr = importStr.substr( index );
167 }
168 catch (e)
169 {
170 throw new Error( "could not import material: " + importStr );
171 }
172
173 return rtnStr;
174 }
175 136
176 this.update = function( time ) 137 this.update = function( time )
177 { 138 {
@@ -277,3 +238,7 @@ twistVertShaderDef =
277 } 238 }
278}; 239};
279 240
241if (typeof exports === "object") {
242 exports.TwistVertMaterial = TwistVertMaterial;
243}
244
diff --git a/js/lib/rdge/texture.js b/js/lib/rdge/texture.js
index 2e76f2c0..d2f66efa 100644
--- a/js/lib/rdge/texture.js
+++ b/js/lib/rdge/texture.js
@@ -216,23 +216,7 @@ function Texture( dstWorld, texMapName, wrap, mips )
216 return; 216 return;
217 } 217 }
218 218
219 /* 219 // copy the source canvas to the context to be used in the texture
220 var srcCtx;
221 if (!this._is3D)
222 {
223 srcCtx = srcCanvas.getContext("2d");
224 imageData = srcCtx.getImageData( 0, 0, width, height );
225 renderCtx.putImageData( imageData, 0, 0 );
226 }
227 else
228 {
229 srcCtx = srcCanvas.getContext("experimental-webgl");
230 if (srcCtx)
231 {
232 renderCtx.drawImage(srcCanvas, 0, 0);
233 }
234 }
235 */
236 renderCtx.drawImage(srcCanvas, 0, 0); 220 renderCtx.drawImage(srcCanvas, 0, 0);
237 221
238 ///////////////// 222 /////////////////
@@ -240,7 +224,7 @@ function Texture( dstWorld, texMapName, wrap, mips )
240 renderer.commitTexture( tex ); 224 renderer.commitTexture( tex );
241 225
242 return tex; 226 return tex;
243} 227 }
244 228
245 this.isPowerOfTwo = function(x) 229 this.isPowerOfTwo = function(x)
246 { 230 {
@@ -278,31 +262,6 @@ function Texture( dstWorld, texMapName, wrap, mips )
278 } 262 }
279 } 263 }
280 264
281 /*
282 this.findWorld = function( id, elt )
283 {
284 if (elt.id && elt.id === id)
285 {
286 if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld)
287 {
288 var world = elt.elementModel.shapeModel.GLWorld;
289 return world;
290 }
291 }
292
293 if (elt.children)
294 {
295 var nKids = elt.children.length;
296 for (var i=0; i<nKids; i++)
297 {
298 var child = elt.children[i];
299 var world = this.findWorld( id, child );
300 if (world) return world;
301 }
302 }
303 }
304 */
305
306 // initialize the object 265 // initialize the object
307 this.init(); 266 this.init();
308} 267}