diff options
author | Jose Antonio Marquez Russo | 2012-02-23 15:28:23 -0800 |
---|---|---|
committer | Jose Antonio Marquez Russo | 2012-02-23 15:28:23 -0800 |
commit | 9a757cbbb19bba27a86060fd2d550a81f5ec71b4 (patch) | |
tree | f18c1eed05e296a1a5b7cbf57ebd2499f11529d8 | |
parent | ad7ae032bc55198e16a02dc75aa15303c033ea58 (diff) | |
parent | 26bb2894c29d4608e843de01829d352dd3d00823 (diff) | |
download | ninja-9a757cbbb19bba27a86060fd2d550a81f5ec71b4.tar.gz |
Merge pull request #17 from ericmueller/integration
Integration
-rwxr-xr-x | js/document/html-document.js | 41 | ||||
-rwxr-xr-x | js/helper-classes/3D/view-utils.js | 8 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLCircle.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLLine.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLRectangle.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLWorld.js | 29 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/rdge-compiled.js | 28 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/CanvasDataManager.js | 98 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/GLRuntime.js | 159 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/tools/rdge-compiled.js | 28 | ||||
-rwxr-xr-x | js/preloader/Preloader.js | 3 |
11 files changed, 317 insertions, 83 deletions
diff --git a/js/document/html-document.js b/js/document/html-document.js index eaf56146..6394e3ce 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js | |||
@@ -153,13 +153,13 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
153 | glData: { | 153 | glData: { |
154 | get: function() | 154 | get: function() |
155 | { | 155 | { |
156 | var elt = this.iframe; | ||
157 | var elt = this.iframe.contentWindow.document.getElementById("UserContent"); | 156 | var elt = this.iframe.contentWindow.document.getElementById("UserContent"); |
158 | this._glData = null; | 157 | this._glData = null; |
159 | if (elt) | 158 | if (elt) |
160 | { | 159 | { |
161 | this._glData = new Array(); | 160 | var cdm = new CanvasDataManager(); |
162 | this.collectGLData( elt, this._glData ); | 161 | this._glData = []; |
162 | cdm.collectGLData( elt, this._glData ); | ||
163 | } | 163 | } |
164 | 164 | ||
165 | return this._glData | 165 | return this._glData |
@@ -167,37 +167,12 @@ exports.HTMLDocument = Montage.create(TextDocument, { | |||
167 | 167 | ||
168 | set: function(value) | 168 | set: function(value) |
169 | { | 169 | { |
170 | var nWorlds = value.length; | 170 | var elt = this.iframe.contentWindow.document.getElementById("UserContent"); |
171 | for (var i=0; i<nWorlds; i++) | 171 | if (elt) |
172 | { | 172 | { |
173 | var importStr = value[i]; | 173 | console.log( "load canvas data: " + value ); |
174 | var startIndex = importStr.indexOf( "id: " ); | 174 | var cdm = new CanvasDataManager(); |
175 | if (startIndex >= 0) | 175 | cdm.loadGLData(elt, value); |
176 | { | ||
177 | var endIndex = importStr.indexOf( "\n", startIndex ); | ||
178 | if (endIndex > 0) | ||
179 | { | ||
180 | var id = importStr.substring( startIndex+4, endIndex ); | ||
181 | var canvas = this.iframe.contentWindow.document.getElementById( id ); | ||
182 | if (canvas) | ||
183 | { | ||
184 | if (!canvas.elementModel) | ||
185 | { | ||
186 | NJUtils.makeElementModel(canvas, "Canvas", "shape", true); | ||
187 | } | ||
188 | |||
189 | if (canvas.elementModel) | ||
190 | { | ||
191 | if (canvas.elementModel.shapeModel.GLWorld) | ||
192 | canvas.elementModel.shapeModel.GLWorld.clearTree(); | ||
193 | |||
194 | var world = new GLWorld( canvas ); | ||
195 | canvas.elementModel.shapeModel.GLWorld = world; | ||
196 | world.import( importStr ); | ||
197 | } | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | } | 176 | } |
202 | } | 177 | } |
203 | }, | 178 | }, |
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index a2fac34f..bedda8bf 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js | |||
@@ -1226,6 +1226,14 @@ exports.ViewUtils = Montage.create(Component, { | |||
1226 | } | 1226 | } |
1227 | }, | 1227 | }, |
1228 | 1228 | ||
1229 | getCurrentDocument: | ||
1230 | { | ||
1231 | value: function() | ||
1232 | { | ||
1233 | return snapManagerModule.SnapManager.application.ninja.currentDocument; | ||
1234 | } | ||
1235 | }, | ||
1236 | |||
1229 | setStageZoom: { | 1237 | setStageZoom: { |
1230 | value:function( globalPt, zoomFactor ) { | 1238 | value:function( globalPt, zoomFactor ) { |
1231 | var localPt; | 1239 | var localPt; |
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js index 5b32547e..712544c0 100755 --- a/js/helper-classes/RDGE/GLCircle.js +++ b/js/helper-classes/RDGE/GLCircle.js | |||
@@ -135,7 +135,7 @@ function GLCircle() | |||
135 | if (!world._useWebGL) return; | 135 | if (!world._useWebGL) return; |
136 | 136 | ||
137 | // make sure RDGE has the correct context | 137 | // make sure RDGE has the correct context |
138 | g_Engine.setContext( world.getCanvas().uuid ); | 138 | g_Engine.setContext( world.getCanvas().rdgeid ); |
139 | 139 | ||
140 | // create the gl buffer | 140 | // create the gl buffer |
141 | var gl = world.getGLContext(); | 141 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js index 0d815145..f715a43c 100755 --- a/js/helper-classes/RDGE/GLLine.js +++ b/js/helper-classes/RDGE/GLLine.js | |||
@@ -171,7 +171,7 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro | |||
171 | if (!world._useWebGL) return; | 171 | if (!world._useWebGL) return; |
172 | 172 | ||
173 | // make sure RDGE has the correct context | 173 | // make sure RDGE has the correct context |
174 | g_Engine.setContext( world.getCanvas().uuid ); | 174 | g_Engine.setContext( world.getCanvas().rdgeid ); |
175 | 175 | ||
176 | // create the gl buffer | 176 | // create the gl buffer |
177 | var gl = world.getGLContext(); | 177 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js index 5b6ff94f..3c1cb7dc 100755 --- a/js/helper-classes/RDGE/GLRectangle.js +++ b/js/helper-classes/RDGE/GLRectangle.js | |||
@@ -214,7 +214,7 @@ function GLRectangle() | |||
214 | if (!world._useWebGL) return; | 214 | if (!world._useWebGL) return; |
215 | 215 | ||
216 | // make sure RDGE has the correct context | 216 | // make sure RDGE has the correct context |
217 | g_Engine.setContext( world.getCanvas().uuid ); | 217 | g_Engine.setContext( world.getCanvas().rdgeid ); |
218 | 218 | ||
219 | // create the gl buffer | 219 | // create the gl buffer |
220 | var gl = world.getGLContext(); | 220 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index 1edd5cff..0addcadc 100755 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js | |||
@@ -136,13 +136,6 @@ function GLWorld( canvas, use3D ) | |||
136 | var camMat = Matrix.I(4); | 136 | var camMat = Matrix.I(4); |
137 | camMat[14] = this.getViewDistance(); | 137 | camMat[14] = this.getViewDistance(); |
138 | this.setCameraMat( camMat ); | 138 | this.setCameraMat( camMat ); |
139 | |||
140 | ////////////////////////////////////////// | ||
141 | // test call to SVG importer | ||
142 | // console.log( "***** SVG TEST *****" ); | ||
143 | // var svgImporter = new SVGParse( this ); | ||
144 | // svgImporter.importSVG(); | ||
145 | ////////////////////////////////////////// | ||
146 | 139 | ||
147 | // post-load processing of the scene | 140 | // post-load processing of the scene |
148 | this.init = function() | 141 | this.init = function() |
@@ -198,7 +191,9 @@ function GLWorld( canvas, use3D ) | |||
198 | this.myScene.addNode(lightTr); | 191 | this.myScene.addNode(lightTr); |
199 | 192 | ||
200 | // Add the scene to the engine - necessary if you want the engine to draw for you | 193 | // Add the scene to the engine - necessary if you want the engine to draw for you |
201 | g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); | 194 | //g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); |
195 | var name = this._canvas.getAttribute( "data-RDGE-id" ); | ||
196 | g_Engine.AddScene("myScene" + name, this.myScene); | ||
202 | } | 197 | } |
203 | 198 | ||
204 | // main code for handling user interaction and updating the scene | 199 | // main code for handling user interaction and updating the scene |
@@ -227,11 +222,11 @@ function GLWorld( canvas, use3D ) | |||
227 | } | 222 | } |
228 | 223 | ||
229 | // defining the draw function to control how the scene is rendered | 224 | // defining the draw function to control how the scene is rendered |
230 | this.draw = function() | 225 | this.draw = function() |
231 | { | 226 | { |
232 | if (this._useWebGL) | 227 | if (this._useWebGL) |
233 | { | 228 | { |
234 | g_Engine.setContext( this._canvas.uuid ); | 229 | g_Engine.setContext( this._canvas.rdgeid ); |
235 | var ctx = g_Engine.getContext(); | 230 | var ctx = g_Engine.getContext(); |
236 | var renderer = ctx.renderer; | 231 | var renderer = ctx.renderer; |
237 | if (renderer.unloadedTextureCount <= 0) | 232 | if (renderer.unloadedTextureCount <= 0) |
@@ -391,12 +386,10 @@ function GLWorld( canvas, use3D ) | |||
391 | if (this._useWebGL) | 386 | if (this._useWebGL) |
392 | { | 387 | { |
393 | rdgeStarted = true; | 388 | rdgeStarted = true; |
394 | this._canvas.rdgeid = this._canvas.uuid; | 389 | var id = this._canvas.getAttribute( "data-RDGE-id" ); |
390 | this._canvas.rdgeid = id; | ||
395 | g_Engine.registerCanvas(this._canvas, this); | 391 | g_Engine.registerCanvas(this._canvas, this); |
396 | RDGEStart( this._canvas ); | 392 | RDGEStart( this._canvas ); |
397 | |||
398 | //this._canvas.fpsTracker = new fpsTracker( '0' ); | ||
399 | //this._canvas.task = new RDGETask(this._canvas, false); | ||
400 | this._canvas.task.stop() | 393 | this._canvas.task.stop() |
401 | } | 394 | } |
402 | } | 395 | } |
@@ -765,7 +758,7 @@ GLWorld.prototype.render = function() | |||
765 | else | 758 | else |
766 | { | 759 | { |
767 | // console.log( "GLWorld.render, " + this._worldCount ); | 760 | // console.log( "GLWorld.render, " + this._worldCount ); |
768 | g_Engine.setContext( this._canvas.uuid ); | 761 | g_Engine.setContext( this._canvas.rdgeId ); |
769 | //this.draw(); | 762 | //this.draw(); |
770 | this.restartRenderLoop(); | 763 | this.restartRenderLoop(); |
771 | } | 764 | } |
@@ -821,7 +814,9 @@ GLWorld.prototype.getShapeFromPoint = function( offsetX, offsetY ) | |||
821 | GLWorld.prototype.export = function() | 814 | GLWorld.prototype.export = |