From 9d3589feb0174c09d1c1bac405660f8900259c7d Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 22 Feb 2012 04:44:07 -0800 Subject: Adding bug fixes. --- js/helper-classes/RDGE/GLWorld.js | 45 +++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'js/helper-classes/RDGE/GLWorld.js') diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index c8327064..1edd5cff 100755 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js @@ -163,7 +163,7 @@ function GLWorld( canvas, use3D ) this.renderer.cameraManager().setActiveCamera(cam); // change clear color - this.renderer.setClearFlags(g_Engine.getContext().DEPTH_BUFFER_BIT); + //this.renderer.setClearFlags(g_Engine.getContext().DEPTH_BUFFER_BIT); this.renderer.setClearColor([1.0, 1.0, 1.0, 0.0]); //this.renderer.NinjaWorld = this; @@ -206,6 +206,7 @@ function GLWorld( canvas, use3D ) { if (!dt) dt = 0.2; + dt = 0.01; // use our own internal throttle this.elapsed += dt; if (this._useWebGL) @@ -232,39 +233,35 @@ function GLWorld( canvas, use3D ) { g_Engine.setContext( this._canvas.uuid ); var ctx = g_Engine.getContext(); - var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle); - if (ctx1 != ctx) - console.log( "***** different contexts (2) *****" ); - var aRenderer = ctx1.renderer; var renderer = ctx.renderer; - if (renderer != aRenderer) - { - console.log( "***** DIFFERENT RENDERERS *****" ); - renderer = aRenderer; - } - if (renderer.unloadedTextureCount <= 0) { renderer.disableCulling(); //console.log( "GLWorld.draw " + renderer._world._worldCount ); + renderer._clear(); this.myScene.render(); if (this._firstRender) { - this._firstRender = false; - - if (!this.hasAnimatedMaterials()) + if (this._canvas.task) { - //this.myScene.render(); - this._canvas.task.stop(); - //this._renderCount = 10; + this._firstRender = false; + + if (!this.hasAnimatedMaterials()) + { + this._canvas.task.stop(); + //this._renderCount = 10; + } } } else if (this._renderCount >= 0) { - this._renderCount--; - if (this._renderCount <= 0) - this._canvas.task.stop(); + if (this._canvas.task) + { + this._renderCount--; + if (this._renderCount <= 0) + this._canvas.task.stop(); + } } } } @@ -394,11 +391,9 @@ function GLWorld( canvas, use3D ) if (this._useWebGL) { rdgeStarted = true; - - this._canvas.rdgeid = this._canvas.uuid; - - g_Engine.registerCanvas(this._canvas, this); - RDGEStart( this._canvas ); + this._canvas.rdgeid = this._canvas.uuid; + g_Engine.registerCanvas(this._canvas, this); + RDGEStart( this._canvas ); //this._canvas.fpsTracker = new fpsTracker( '0' ); //this._canvas.task = new RDGETask(this._canvas, false); -- cgit v1.2.3 From 2bb869eb1c0b71e379f159eb0f95dfa168496d8d Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 22 Feb 2012 15:22:13 -0800 Subject: Runtime classes --- js/helper-classes/RDGE/GLWorld.js | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'js/helper-classes/RDGE/GLWorld.js') 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 ) var camMat = Matrix.I(4); camMat[14] = this.getViewDistance(); this.setCameraMat( camMat ); - - ////////////////////////////////////////// - // test call to SVG importer -// console.log( "***** SVG TEST *****" ); -// var svgImporter = new SVGParse( this ); -// svgImporter.importSVG(); - ////////////////////////////////////////// // post-load processing of the scene this.init = function() @@ -198,7 +191,9 @@ function GLWorld( canvas, use3D ) this.myScene.addNode(lightTr); // Add the scene to the engine - necessary if you want the engine to draw for you - g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); + //g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); + var name = this._canvas.getAttribute( "data-RDGE-id" ); + g_Engine.AddScene("myScene" + name, this.myScene); } // main code for handling user interaction and updating the scene @@ -227,11 +222,11 @@ function GLWorld( canvas, use3D ) } // defining the draw function to control how the scene is rendered - this.draw = function() + this.draw = function() { if (this._useWebGL) { - g_Engine.setContext( this._canvas.uuid ); + g_Engine.setContext( this._canvas.rdgeid ); var ctx = g_Engine.getContext(); var renderer = ctx.renderer; if (renderer.unloadedTextureCount <= 0) @@ -391,12 +386,10 @@ function GLWorld( canvas, use3D ) if (this._useWebGL) { rdgeStarted = true; - this._canvas.rdgeid = this._canvas.uuid; + var id = this._canvas.getAttribute( "data-RDGE-id" ); + this._canvas.rdgeid = id; g_Engine.registerCanvas(this._canvas, this); RDGEStart( this._canvas ); - - //this._canvas.fpsTracker = new fpsTracker( '0' ); - //this._canvas.task = new RDGETask(this._canvas, false); this._canvas.task.stop() } } @@ -765,7 +758,7 @@ GLWorld.prototype.render = function() else { // console.log( "GLWorld.render, " + this._worldCount ); - g_Engine.setContext( this._canvas.uuid ); + g_Engine.setContext( this._canvas.rdgeId ); //this.draw(); this.restartRenderLoop(); } @@ -821,7 +814,9 @@ GLWorld.prototype.getShapeFromPoint = function( offsetX, offsetY ) GLWorld.prototype.export = function() { var exportStr = "GLWorld 1.0\n"; - exportStr += "id: " + this._canvas.rdgeid + "\n"; + var id = this.getCanvas().getAttribute( "data-RDGE-id" ); + exportStr += "id: " + id + "\n"; + //exportStr += "id: " + this._canvas.rdgeid + "\n"; exportStr += "fov: " + this._fov + "\n"; exportStr += "zNear: " + this._zNear + "\n"; exportStr += "zFar: " + this._zFar + "\n"; @@ -829,7 +824,7 @@ GLWorld.prototype.export = function() // we need 2 export modes: One for save/restore, one for publish. // hardcoding for now - var exportForPublish = false; + var exportForPublish = true; exportStr += "publish: " + exportForPublish + "\n"; if (exportForPublish) -- cgit v1.2.3