aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorhwc4872012-03-06 12:37:17 -0800
committerhwc4872012-03-06 12:37:17 -0800
commite87069b43027b6b1707bb065a1f331b600b5db58 (patch)
treea897c648029016e2066292255fcb1da2f7e045bb /js
parent5e640e24c3b4658b8060cde837ae98dabd3ba5bf (diff)
downloadninja-e87069b43027b6b1707bb065a1f331b600b5db58.tar.gz
Authortime import of 2d & 3d canvases
Diffstat (limited to 'js')
-rwxr-xr-xjs/document/html-document.js9
-rwxr-xr-xjs/helper-classes/RDGE/GLWorld.js31
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, {
220 if (canvas.elementModel.shapeModel.GLWorld) 220 if (canvas.elementModel.shapeModel.GLWorld)
221 canvas.elementModel.shapeModel.GLWorld.clearTree(); 221 canvas.elementModel.shapeModel.GLWorld.clearTree();
222 222
223 var world = new GLWorld( canvas ); 223 var index = importStr.indexOf( "webGL: " );
224 canvas.elementModel.shapeModel.GLWorld = world; 224 var useWebGL = (index >= 0)
225 var world = new GLWorld( canvas, useWebGL );
225 world.import( importStr ); 226 world.import( importStr );
227 canvas.elementModel.shapeModel.GLWorld = world;
228
229 ///////////////////////////
230 //something.buildShapeModel( world ); // to come from Nivesh
226 } 231 }
227 } 232 }
228 } 233 }
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 )
905 905
906 // determine if the data was written for export (no Ninja objects) 906 // determine if the data was written for export (no Ninja objects)
907 // or for save/restore 907 // or for save/restore
908 var index = importStr.indexOf( "scenedata: " ); 908 //var index = importStr.indexOf( "scenedata: " );
909 if (index >= 0) 909 var index = importStr.indexOf( "webGL: " );
910 this._useWebGL = (index >= 0)
911 if (this._useWebGL)
910 { 912 {
911 var rdgeStr = importStr.substr( index+11 ); 913 // start RDGE
912 var endIndex = rdgeStr.indexOf( "endscene\n" ); 914 rdgeStarted = true;
913 if (endIndex < 0) throw new Error( "ill-formed WebGL data" ); 915 var id = this._canvas.getAttribute( "data-RDGE-id" );
914 var len = endIndex - index + 11; 916 this._canvas.rdgeid = id;
915 rdgeStr = rdgeStr.substr( 0, endIndex ); 917 g_Engine.registerCanvas(this._canvas, this);
916 918 RDGEStart( this._canvas );
917 this.myScene.importJSON( rdgeStr ); 919 this._canvas.task.stop()
918
919 this.importObjects( importStr, this._rootNode );
920 } 920 }
921 else
922 {
923 // load the material library
924 //importStr = MaterialsLibrary.import( importStr );
925 921
926 // import the objects 922 this.importObjects( importStr, this._rootNode );
927 this.importObjects( importStr, this._rootNode );
928 923
924 if (!this._useWebGL)
925 {
929 // render using canvas 2D 926 // render using canvas 2D
930 this.render(); 927 this.render();
931 } 928 }