aboutsummaryrefslogtreecommitdiff
path: root/js/document/html-document.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/document/html-document.js')
-rwxr-xr-xjs/document/html-document.js73
1 files changed, 45 insertions, 28 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index 0dc26884..b9944d66 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -9,7 +9,6 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
9var Montage = require("montage/core/core").Montage, 9var Montage = require("montage/core/core").Montage,
10 TextDocument = require("js/document/text-document").TextDocument, 10 TextDocument = require("js/document/text-document").TextDocument,
11 NJUtils = require("js/lib/NJUtils").NJUtils, 11 NJUtils = require("js/lib/NJUtils").NJUtils,
12 CanvasDataManager = require("js/lib/rdge/runtime/CanvasDataManager").CanvasDataManager,
13 GLWorld = require("js/lib/drawing/world").World; 12 GLWorld = require("js/lib/drawing/world").World;
14//////////////////////////////////////////////////////////////////////// 13////////////////////////////////////////////////////////////////////////
15// 14//
@@ -195,9 +194,9 @@ exports.HTMLDocument = Montage.create(TextDocument, {
195 this._glData = null; 194 this._glData = null;
196 if (elt) 195 if (elt)
197 { 196 {
198 var cdm = new CanvasDataManager();
199 this._glData = []; 197 this._glData = [];
200 cdm.collectGLData( elt, this._glData ); 198 var path = "assets/";
199 this.collectGLData( elt, this._glData, path );
201 } 200 }
202 201
203 return this._glData; 202 return this._glData;
@@ -208,29 +207,47 @@ exports.HTMLDocument = Montage.create(TextDocument, {
208 var elt = this.documentRoot; 207 var elt = this.documentRoot;
209 if (elt) 208 if (elt)
210 { 209 {
211 var nWorlds= value.length; 210// var loadForRuntime = false;
212 for (var i=0; i<nWorlds; i++) { 211// if (loadForRuntime)
213 var importStr = value[i]; 212// {
214 var startIndex = importStr.indexOf("id: "); 213// var cdm = new CanvasDataManager();
215 if (startIndex >= 0) { 214// cdm.loadGLData(elt, value );
216 var endIndex = importStr.indexOf("\n", startIndex); 215// }
217 if (endIndex > 0) { 216// else
218 var id = importStr.substring( startIndex+4, endIndex); 217 {
219 if (id) { 218 var nWorlds= value.length;
220 var canvas = this.findCanvasWithID(id, elt); 219 for (var i=0; i<nWorlds; i++)
221 if (canvas) { 220 {
222 if (!canvas.elementModel) { 221 var importStr = value[i];
223 NJUtils.makeElementModel(canvas, "Canvas", "shape", true); 222 var startIndex = importStr.indexOf( "id: " );
224 } 223 if (startIndex >= 0)
225 if (canvas.elementModel) { 224 {
226 if (canvas.elementModel.shapeModel.GLWorld) { 225 var endIndex = importStr.indexOf( "\n", startIndex );
227 canvas.elementModel.shapeModel.GLWorld.clearTree(); 226 if (endIndex > 0)
227 {
228 var id = importStr.substring( startIndex+4, endIndex );
229 if (id)
230 {
231 var canvas = this.findCanvasWithID( id, elt );
232 if (canvas)
233 {
234 if (!canvas.elementModel)
235 {
236 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
237 }
238
239 if (canvas.elementModel)
240 {
241 if (canvas.elementModel.shapeModel.GLWorld)
242 canvas.elementModel.shapeModel.GLWorld.clearTree();
243
244 var index = importStr.indexOf( "webGL: " );
245 var useWebGL = (index >= 0)
246 var world = new GLWorld( canvas, useWebGL );
247 world.import( importStr );
248
249 this.buildShapeModel( canvas.elementModel, world );
228 } 250 }
229 var index = importStr.indexOf( "webGL: " );
230 var useWebGL = (index >= 0)
231 var world = new GLWorld(canvas, useWebGL);
232 world.import( importStr );
233 this.buildShapeModel(canvas.elementModel, world);
234 } 251 }
235 } 252 }
236 } 253 }
@@ -368,11 +385,11 @@ exports.HTMLDocument = Montage.create(TextDocument, {
368 385
369 386
370 collectGLData: { 387 collectGLData: {
371 value: function( elt, dataArray ) 388 value: function( elt, dataArray, imagePath )
372 { 389 {
373 if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) 390 if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld)
374 { 391 {
375 var data = elt.elementModel.shapeModel.GLWorld.export(); 392 var data = elt.elementModel.shapeModel.GLWorld.export( imagePath );
376 dataArray.push( data ); 393 dataArray.push( data );
377 } 394 }
378 395
@@ -382,7 +399,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
382 for (var i=0; i<nKids; i++) 399 for (var i=0; i<nKids; i++)
383 { 400 {
384 var child = elt.children[i]; 401 var child = elt.children[i];
385 this.collectGLData( child, dataArray ); 402 this.collectGLData( child, dataArray, imagePath );
386 } 403 }
387 } 404 }
388 } 405 }