aboutsummaryrefslogtreecommitdiff
path: root/js/document
diff options
context:
space:
mode:
Diffstat (limited to 'js/document')
-rwxr-xr-xjs/document/html-document.js68
1 files changed, 49 insertions, 19 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js
index bf03e38b..bb54874c 100755
--- a/js/document/html-document.js
+++ b/js/document/html-document.js
@@ -215,30 +215,59 @@ exports.HTMLDocument = Montage.create(TextDocument, {
215 */ 215 */
216 216
217 // /* 217 // /*
218 // get the data for the next canvas
218 var importStr = value[i]; 219 var importStr = value[i];
219 var jObj = JSON.parse( importStr ); 220
220 if (jObj) 221 // determine if it is the new (JSON) or old style format
222 var id = null;
223 var jObj = null;
224 var index = importStr.indexOf( ';' );
225 if ((importStr[0] === 'v') && (index < 24))
226 {
227 // JSON format. pull off the
228 importStr = importStr.substr( index+1 );
229 jObj = jObj = JSON.parse( importStr );
230 id = jObj.id;
231 }
232 else
221 { 233 {
222 var id = jObj.id; 234 var startIndex = importStr.indexOf( "id: " );
223 if (id) 235 if (startIndex >= 0) {
236 var endIndex = importStr.indexOf( "\n", startIndex );
237 if (endIndex > 0)
238 id = importStr.substring( startIndex+4, endIndex );
239 }
240 }
241
242 if (id != null)
243 {
244 var canvas = this.findCanvasWithID( id, elt );
245 if (canvas)
224 { 246 {
225 var canvas = this.findCanvasWithID( id, elt ); 247 if (!canvas.elementModel)
226 if (canvas) { 248 {
227 if (!canvas.elementModel) { 249 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
228 NJUtils.makeElementModel(canvas, "Canvas", "shape", true); 250 }
251 if (canvas.elementModel)
252 {
253 if (canvas.elementModel.shapeModel.GLWorld)
254 canvas.elementModel.shapeModel.GLWorld.clearTree();
255
256 if (jObj)
257 {
258 var useWebGL = jObj.webGL;
259 var world = new GLWorld( canvas, useWebGL );
260 world.importJSON( jObj );
229 } 261 }
230 if (canvas.elementModel) { 262 else
231 if (canvas.elementModel.shapeModel.GLWorld) { 263 {
232 canvas.elementModel.shapeModel.GLWorld.clearTree(); 264 var index = importStr.indexOf( "webGL: " );
233 } 265 var useWebGL = (index >= 0);
234 if (jObj) 266 var world = new GLWorld( canvas, useWebGL );
235 { 267 world.import( importStr );
236 var useWebGL = jObj.webGL;
237 var world = new GLWorld( canvas, useWebGL );
238 world.importJSON( jObj );
239 this.buildShapeModel( canvas.elementModel, world );
240 }
241 } 268 }
269
270 this.buildShapeModel( canvas.elementModel, world );
242 } 271 }
243 } 272 }
244 } 273 }
@@ -380,6 +409,7 @@ exports.HTMLDocument = Montage.create(TextDocument, {
380 if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld) 409 if (elt.elementModel && elt.elementModel.shapeModel && elt.elementModel.shapeModel.GLWorld)
381 { 410 {
382 var data = elt.elementModel.shapeModel.GLWorld.exportJSON(); 411 var data = elt.elementModel.shapeModel.GLWorld.exportJSON();
412 //var data = elt.elementModel.shapeModel.GLWorld.export();
383 dataArray.push( data ); 413 dataArray.push( data );
384 } 414 }
385 415