aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xjs/document/html-document.js69
-rw-r--r--js/helper-classes/RDGE/Materials/PulseMaterial.js2
-rw-r--r--js/helper-classes/RDGE/runtime/CanvasDataManager.js29
-rw-r--r--js/helper-classes/RDGE/runtime/RuntimeGeomObj.js3
-rw-r--r--js/helper-classes/RDGE/runtime/RuntimeMaterial.js22
5 files changed, 75 insertions, 50 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 7dd28385..f1b99866 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -185,9 +185,51 @@ exports.HTMLDocument = Montage.create(TextDocument, {
185 var elt = this.documentRoot; 185 var elt = this.documentRoot;
186 if (elt) 186 if (elt)
187 { 187 {
188 //console.log( "load canvas data: " , value ); 188 var loadForRuntime = true;
189 var cdm = new CanvasDataManager(); 189 if (loadForRuntime)
190 cdm.loadGLData(elt, value); 190 {
191 //console.log( "load canvas data: " , value );
192 var cdm = new CanvasDataManager();
193 cdm.loadGLData(elt, value, NJUtils);
194 }
195 else
196 {
197 var nWorlds= value.length;
198 for (var i=0; i<nWorlds; i++)
199 {
200 var importStr = value[i];
201 var startIndex = importStr.indexOf( "id: " );
202 if (startIndex >= 0)
203 {
204 var endIndex = importStr.indexOf( "\n", startIndex );
205 if (endIndex > 0)
206 {
207 var id = importStr.substring( startIndex+4, endIndex );
208 if (id)
209 {
210 var canvas = this.findCanvasWithID( id, elt );
211 if (canvas)
212 {
213 if (!canvas.elementModel)
214 {
215 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
216 }
217
218 if (canvas.elementModel)
219 {
220 if (canvas.elementModel.shapeModel.GLWorld)
221 canvas.elementModel.shapeModel.GLWorld.clearTree();
222
223 var world = new GLWorld( canvas );
224 canvas.elementModel.shapeModel.GLWorld = world;
225 world.import( importStr );
226 }
227 }
228 }
229 }
230 }
231 }
232 }
191 } 233 }
192 } 234 }
193 }, 235 },
@@ -219,6 +261,27 @@ exports.HTMLDocument = Montage.create(TextDocument, {
219 } 261 }
220 } 262 }
221 }, 263 },
264
265 /**
266 * search the DOM tree to find a canvas with the given id
267 */
268 findCanvasWithID: {
269 value: function( id, elt ) {
270 var cid = elt.getAttribute( "data-RDGE-id" );
271 if (cid == id) return elt;
272
273 if (elt.children)
274 {
275 var nKids = elt.children.length;
276 for (var i=0; i<nKids; i++)
277 {
278 var child = elt.children[i];
279 var foundElt = this.findCanvasWithID( id, child );
280 if (foundElt) return foundElt;
281 }
282 }
283 }
284 },
222 285
223 286
224 287
diff --git a/js/helper-classes/RDGE/Materials/PulseMaterial.js b/js/helper-classes/RDGE/Materials/PulseMaterial.js
index b0fbd998..e55798b7 100644
--- a/js/helper-classes/RDGE/Materials/PulseMaterial.js
+++ b/js/helper-classes/RDGE/Materials/PulseMaterial.js
@@ -187,7 +187,7 @@ function PulseMaterial()
187 exportStr += "name: " + this.getName() + "\n"; 187 exportStr += "name: " + this.getName() + "\n";
188 188
189 var texMapName = this._propValues[this._propNames[0]]; 189 var texMapName = this._propValues[this._propNames[0]];
190 exportStr += "texture: " + texMapName; 190 exportStr += "texture: " + texMapName + "\n";
191 191
192 // every material needs to terminate like this 192 // every material needs to terminate like this
193 exportStr += "endMaterial\n"; 193 exportStr += "endMaterial\n";
diff --git a/js/helper-classes/RDGE/runtime/CanvasDataManager.js b/js/helper-classes/RDGE/runtime/CanvasDataManager.js
index 46d944a1..efbfe4db 100644
--- a/js/helper-classes/RDGE/runtime/CanvasDataManager.js
+++ b/js/helper-classes/RDGE/runtime/CanvasDataManager.js
@@ -12,7 +12,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
12/////////////////////////////////////////////////////////////////////// 12///////////////////////////////////////////////////////////////////////
13function CanvasDataManager() 13function CanvasDataManager()
14{ 14{
15 this.loadGLData = function(root, valueArray) 15 this.loadGLData = function(root, valueArray, NinjaUtils)
16 { 16 {
17 var value = valueArray; 17 var value = valueArray;
18 var nWorlds = value.length; 18 var nWorlds = value.length;
@@ -29,32 +29,7 @@ function CanvasDataManager()
29 var canvas = this.findCanvasWithID( id, root ); 29 var canvas = this.findCanvasWithID( id, root );
30 if (canvas) 30 if (canvas)
31 { 31 {
32 //var loadForAuthoring = true; 32 var rt = new GLRuntime( canvas, importStr );
33 var index = importStr.indexOf( "scenedata: " );
34 //if (index >= 0) loadForAuthoring = false;
35 var loadForAuthoring = false;
36
37 if (loadForAuthoring)
38 {
39 if (!canvas.elementModel)
40 {
41 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
42 }
43
44 if (canvas.elementModel)
45 {
46 if (canvas.elementModel.shapeModel.GLWorld)
47 canvas.elementModel.shapeModel.GLWorld.clearTree();
48
49 var world = new GLWorld( canvas );
50 canvas.elementModel.shapeModel.GLWorld = world;
51 world.import( importStr );
52 }
53 }
54 else
55 {
56 var rt = new GLRuntime( canvas, importStr );
57 }
58 } 33 }
59 } 34 }
60 } 35 }
diff --git a/js/helper-classes/RDGE/runtime/RuntimeGeomObj.js b/js/helper-classes/RDGE/runtime/RuntimeGeomObj.js
index 253154f9..fd5bf3aa 100644
--- a/js/helper-classes/RDGE/runtime/RuntimeGeomObj.js
+++ b/js/helper-classes/RDGE/runtime/RuntimeGeomObj.js
@@ -83,7 +83,9 @@ function RuntimeGeomObj()
83 case "radialGradient": mat = new RuntimeRadialGradientMaterial(); break; 83 case "radialGradient": mat = new RuntimeRadialGradientMaterial(); break;
84 case "linearGradient": mat = new RuntimeLinearGradientMaterial(); break; 84 case "linearGradient": mat = new RuntimeLinearGradientMaterial(); break;
85 case "bumpMetal": mat = new RuntimeBumpMetalMaterial(); break; 85 case "bumpMetal": mat = new RuntimeBumpMetalMaterial(); break;
86 case "uber": mat = new RuntimeUberMaterial(); break;
86 87
88 case "deform":
87 case "water": 89 case "water":
88 case "tunnel": 90 case "tunnel":
89 case "reliefTunnel": 91 case "reliefTunnel":
@@ -94,6 +96,7 @@ function RuntimeGeomObj()
94 case "mandel": 96 case "mandel":
95 case "star": 97 case "star":
96 case "zinvert": 98 case "zinvert":
99 case "keleidoscope":
97 case "pulse": mat = new RuntimePulseMaterial(); break; 100 case "pulse": mat = new RuntimePulseMaterial(); break;
98 101
99 default: 102 default:
diff --git a/js/helper-classes/RDGE/runtime/RuntimeMaterial.js b/js/helper-classes/RDGE/runtime/RuntimeMaterial.js
index ceabbaa5..0f10cfbe 100644
--- a/js/helper-classes/RDGE/runtime/RuntimeMaterial.js
+++ b/js/helper-classes/RDGE/runtime/RuntimeMaterial.js
@@ -274,26 +274,10 @@ function RuntimeBumpMetalMaterial()
274 } 274 }
275 } 275 }
276 } 276 }
277
278 /*
279 this.update = function( time )
280 {
281 var material = this._materialNode;
282 if (material)
283 {
284 var technique = material.shaderProgram.default;
285 var renderer = g_Engine.getContext().renderer;
286 if (renderer && technique)
287 {
288 if (this._shader && this._shader.default)
289 this._shader.default.u_time.set( [this._time] );
290 this._time += this._dTime;
291 if (this._time > 200.0) this._time = 0.0;
292 }
293 }
294 }
295 */
296}