From e87069b43027b6b1707bb065a1f331b600b5db58 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Tue, 6 Mar 2012 12:37:17 -0800 Subject: Authortime import of 2d & 3d canvases --- js/document/html-document.js | 9 +++++++-- js/helper-classes/RDGE/GLWorld.js | 31 ++++++++++++++----------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/js/document/html-document.js b/js/document/html-document.js index 2d7192b7..8722e223 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -220,9 +220,14 @@ exports.HTMLDocument = Montage.create(TextDocument, { if (canvas.elementModel.shapeModel.GLWorld) canvas.elementModel.shapeModel.GLWorld.clearTree(); - var world = new GLWorld( canvas ); - canvas.elementModel.shapeModel.GLWorld = world; + var index = importStr.indexOf( "webGL: " ); + var useWebGL = (index >= 0) + var world = new GLWorld( canvas, useWebGL ); world.import( importStr ); + canvas.elementModel.shapeModel.GLWorld = world; + + /////////////////////////// + //something.buildShapeModel( world ); // to come from Nivesh } } } diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index ce5f0516..c8bc4c1c 100755 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js @@ -905,27 +905,24 @@ GLWorld.prototype.import = function( importStr ) // determine if the data was written for export (no Ninja objects) // or for save/restore - var index = importStr.indexOf( "scenedata: " ); - if (index >= 0) + //var index = importStr.indexOf( "scenedata: " ); + var index = importStr.indexOf( "webGL: " ); + this._useWebGL = (index >= 0) + if (this._useWebGL) { - var rdgeStr = importStr.substr( index+11 ); - var endIndex = rdgeStr.indexOf( "endscene\n" ); - if (endIndex < 0) throw new Error( "ill-formed WebGL data" ); - var len = endIndex - index + 11; - rdgeStr = rdgeStr.substr( 0, endIndex ); - - this.myScene.importJSON( rdgeStr ); - - this.importObjects( importStr, this._rootNode ); + // start RDGE + rdgeStarted = true; + var id = this._canvas.getAttribute( "data-RDGE-id" ); + this._canvas.rdgeid = id; + g_Engine.registerCanvas(this._canvas, this); + RDGEStart( this._canvas ); + this._canvas.task.stop() } - else - { - // load the material library - //importStr = MaterialsLibrary.import( importStr ); - // import the objects - this.importObjects( importStr, this._rootNode ); + this.importObjects( importStr, this._rootNode ); + if (!this._useWebGL) + { // render using canvas 2D this.render(); } -- cgit v1.2.3