diff options
Diffstat (limited to 'js/helper-classes/RDGE/GLWorld.js')
-rwxr-xr-x | js/helper-classes/RDGE/GLWorld.js | 75 |
1 files changed, 47 insertions, 28 deletions
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index b86d9715..c8327064 100755 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js | |||
@@ -14,6 +14,7 @@ var fragmentShaderSource = ""; | |||
14 | var rdgeStarted = false; | 14 | var rdgeStarted = false; |
15 | 15 | ||
16 | var nodeCounter = 0; | 16 | var nodeCounter = 0; |
17 | var worldCounter = 0; | ||
17 | 18 | ||
18 | 19 | ||
19 | /////////////////////////////////////////////////////////////////////// | 20 | /////////////////////////////////////////////////////////////////////// |
@@ -70,6 +71,9 @@ function GLWorld( canvas, use3D ) | |||
70 | // no animated materials | 71 | // no animated materials |
71 | this._firstRender = true; | 72 | this._firstRender = true; |
72 | 73 | ||
74 | this._worldCount = worldCounter; | ||
75 | worldCounter++; | ||
76 | |||
73 | /////////////////////////////////////////////////////////////////////// | 77 | /////////////////////////////////////////////////////////////////////// |
74 | // Property accessors | 78 | // Property accessors |
75 | /////////////////////////////////////////////////////////////////////// | 79 | /////////////////////////////////////////////////////////////////////// |
@@ -147,6 +151,7 @@ function GLWorld( canvas, use3D ) | |||
147 | ctx2 = g_Engine.getContext(); | 151 | ctx2 = g_Engine.getContext(); |
148 | if (ctx1 != ctx2) console.log( "***** different contexts *****" ); | 152 | if (ctx1 != ctx2) console.log( "***** different contexts *****" ); |
149 | this.renderer = ctx1.renderer; | 153 | this.renderer = ctx1.renderer; |
154 | this.renderer._world = this; | ||
150 | 155 | ||
151 | // create a camera, set its perspective, and then point it at the origin | 156 | // create a camera, set its perspective, and then point it at the origin |
152 | var cam = new camera(); | 157 | var cam = new camera(); |
@@ -225,22 +230,24 @@ function GLWorld( canvas, use3D ) | |||
225 | { | 230 | { |
226 | if (this._useWebGL) | 231 | if (this._useWebGL) |
227 | { | 232 | { |
228 | if (this._allMapsLoaded) | 233 | g_Engine.setContext( this._canvas.uuid ); |
234 | var ctx = g_Engine.getContext(); | ||
235 | var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle); | ||
236 | if (ctx1 != ctx) | ||
237 | console.log( "***** different contexts (2) *****" ); | ||
238 | var aRenderer = ctx1.renderer; | ||
239 | var renderer = ctx.renderer; | ||
240 | if (renderer != aRenderer) | ||
241 | { | ||
242 | console.log( "***** DIFFERENT RENDERERS *****" ); | ||
243 | renderer = aRenderer; | ||
244 | } | ||
245 | |||
246 | if (renderer.unloadedTextureCount <= 0) | ||
229 | { | 247 | { |
230 | var ctx = g_Engine.getContext(); | ||
231 | //console.log( "RDGE state: " + ctx.ctxStateManager.currentState().name); | ||
232 | |||
233 | ///////////////////////////// | ||
234 | var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle); | ||
235 | if (ctx1 != ctx) console.log( "***** different contexts (2) *****" ); | ||
236 | var aRenderer = ctx1.renderer; | ||
237 | ////////////////////////////////////////// | ||
238 | |||
239 | var renderer = ctx.renderer; | ||
240 | if (renderer != aRenderer) console.log( "***** DIFFERENT RENDERERS *****" ); | ||
241 | renderer.disableCulling(); | 248 | renderer.disableCulling(); |
249 | //console.log( "GLWorld.draw " + renderer._world._worldCount ); | ||
242 | this.myScene.render(); | 250 | this.myScene.render(); |
243 | //console.log( "render" ); | ||
244 | 251 | ||
245 | if (this._firstRender) | 252 | if (this._firstRender) |
246 | { | 253 | { |
@@ -249,8 +256,8 @@ function GLWorld( canvas, use3D ) | |||
249 | if (!this.hasAnimatedMaterials()) | 256 | if (!this.hasAnimatedMaterials()) |
250 | { | 257 | { |
251 | //this.myScene.render(); | 258 | //this.myScene.render(); |
252 | //this._canvas.task.stop(); | 259 | this._canvas.task.stop(); |
253 | this._renderCount = 10; | 260 | //this._renderCount = 10; |
254 | } | 261 | } |
255 | } | 262 | } |
256 | else if (this._renderCount >= 0) | 263 | else if (this._renderCount >= 0) |
@@ -259,7 +266,6 @@ function GLWorld( canvas, use3D ) | |||
259 | if (this._renderCount <= 0) | 266 | if (this._renderCount <= 0) |
260 | this._canvas.task.stop(); | 267 | this._canvas.task.stop(); |
261 | } | 268 | } |
262 | |||
263 | } | 269 | } |
264 | } | 270 | } |
265 | else | 271 | else |
@@ -270,13 +276,13 @@ function GLWorld( canvas, use3D ) | |||
270 | 276 | ||
271 | this.onRunState = function() | 277 | this.onRunState = function() |
272 | { | 278 | { |
273 | console.log( "GLWorld.onRunState" ); | 279 | // console.log( "GLWorld.onRunState" ); |
274 | this.restartRenderLoop(); | 280 | this.restartRenderLoop(); |
275 | } | 281 | } |
276 | 282 | ||
277 | this.onLoadState = function() | 283 | this.onLoadState = function() |
278 | { | 284 | { |
279 | console.log( "GLWorld.onLoadState" ); | 285 | // console.log( "GLWorld.onLoadState" ); |
280 | } | 286 | } |
281 | 287 | ||
282 | this.textureToLoad = function( texture ) | 288 | this.textureToLoad = function( texture ) |
@@ -333,7 +339,7 @@ function GLWorld( canvas, use3D ) | |||
333 | 339 | ||
334 | this.textureLoadedCallback = function( name ) | 340 | this.textureLoadedCallback = function( name ) |
335 | { | 341 | { |
336 | console.log( "*** material texture loaded: " + name ); | 342 | // console.log( "*** material texture loaded: " + name ); |
337 | 343 | ||
338 | var world = this._world; | 344 | var world = this._world; |
339 | if (!world) | 345 | if (!world) |
@@ -389,10 +395,10 @@ function GLWorld( canvas, use3D ) | |||
389 | { | 395 | { |
390 | rdgeStarted = true; | 396 | rdgeStarted = true; |
391 | 397 | ||
392 | // TODO - temporary fix for RDGE id's | 398 | this._canvas.rdgeid = this._canvas.uuid; |
393 | this._canvas.id = "rdge_" + this._canvas.uuid; | 399 | |
394 | g_Engine.registerCanvas(this._canvas, this); | 400 | g_Engine.registerCanvas(this._canvas, this); |
395 | RDGEStart( this._canvas ); | 401 | RDGEStart( this._canvas ); |
396 | 402 | ||
397 | //this._canvas.fpsTracker = new fpsTracker( '0' ); | 403 | //this._canvas.fpsTracker = new fpsTracker( '0' ); |
398 | //this._canvas.task = new RDGETask(this._canvas, false); | 404 | //this._canvas.task = new RDGETask(this._canvas, false); |
@@ -508,16 +514,22 @@ GLWorld.prototype.addObject = function( obj ) | |||
508 | 514 | ||
509 | GLWorld.prototype.restartRenderLoop = function() | 515 | GLWorld.prototype.restartRenderLoop = function() |
510 | { | 516 | { |
511 | console.log( "restartRenderLoop" ); | 517 | //console.log( "restartRenderLoop" ); |
512 | 518 | ||
513 | this._firstRender = true; | 519 | this._firstRender = true; |
514 | this._renderCount = -1; | 520 | this._renderCount = -1; |
515 | if (this._canvas.task) | 521 | if (this._canvas.task) |
516 | { | 522 | { |
517 | if (this._allMapsLoaded) | 523 | if (this._allMapsLoaded) |
524 | { | ||
525 | //console.log( "starting task" ); | ||
518 | this._canvas.task.start(); | 526 | this._canvas.task.start(); |
527 | } | ||
519 | else | 528 | else |
529 | { | ||
530 | //console.log( "stopping task" ); | ||
520 | this._canvas.task.stop(); | 531 | this._canvas.task.stop(); |
532 | } | ||
521 | } | 533 | } |
522 | } | 534 | } |
523 | 535 | ||
@@ -757,7 +769,10 @@ GLWorld.prototype.render = function() | |||
757 | } | 769 | } |
758 | else | 770 | else |
759 | { | 771 | { |
760 | this.draw(); | 772 | // console.log( "GLWorld.render, " + this._worldCount ); |
773 | g_Engine.setContext( this._canvas.uuid ); | ||
774 | //this.draw(); | ||
775 | this.restartRenderLoop(); | ||
761 | } | 776 | } |
762 | } | 777 | } |
763 | 778 | ||
@@ -794,7 +809,7 @@ GLWorld.prototype.getShapeFromPoint = function( offsetX, offsetY ) | |||
794 | var go = this._geomRoot; | 809 | var go = this._geomRoot; |
795 | if(go.collidesWithPoint(x,y)) | 810 | if(go.collidesWithPoint(x,y)) |
796 | { | 811 | { |
797 | console.log("collision found"); | 812 | // console.log("collision found"); |
798 | return go; | 813 | return go; |
799 | } | 814 | } |
800 | while (go.getNext()) | 815 | while (go.getNext()) |
@@ -802,7 +817,7 @@ GLWorld.prototype.getShapeFromPoint = function( offsetX, offsetY ) | |||
802 | go = go.getNext(); | 817 | go = go.getNext(); |
803 | if(go.collidesWithPoint(x,y)) | 818 | if(go.collidesWithPoint(x,y)) |
804 | { | 819 | { |
805 | console.log("collision found"); | 820 | // console.log("collision found"); |
806 | return go; | 821 | return go; |
807 | } | 822 | } |
808 | } | 823 | } |
@@ -958,7 +973,11 @@ GLWorld.prototype.importObject = function( objStr, parentNode ) | |||
958 | obj.import( objStr ); | 973 | obj.import( objStr ); |
959 | break; | 974 | break; |
960 | 975 | ||
961 | case 3: // line - not implemented | 976 | case 3: // line |
977 | obj = new GLLine(); | ||
978 | obj.import( objStr ); | ||
979 | break; | ||
980 | |||
962 | default: | 981 | default: |
963 | throw new Error( "Unrecognized object type: " + type ); |