diff options
author | hwc487 | 2012-03-22 15:47:11 -0700 |
---|---|---|
committer | hwc487 | 2012-03-22 15:47:11 -0700 |
commit | e927e4702d7dbd4a878f6979b3f56b46758f93de (patch) | |
tree | e6bb8951374a6504bd6c745ce7233da5cd4869dc /js/helper-classes/RDGE | |
parent | 00cd98e49c959906d7c44bb6adcdef1f3d5148ae (diff) | |
parent | 31e924e1b8b8da8342b3ff2341c8284915486c0b (diff) | |
download | ninja-e927e4702d7dbd4a878f6979b3f56b46758f93de.tar.gz |
Merge branch 'integration' of github.com:ericmueller/ninja-internal into Textures
Diffstat (limited to 'js/helper-classes/RDGE')
-rwxr-xr-x | js/helper-classes/RDGE/rdge-compiled.js | 6 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/src/core/script/engine.js | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/js/helper-classes/RDGE/rdge-compiled.js b/js/helper-classes/RDGE/rdge-compiled.js index d1040d73..caf58147 100755 --- a/js/helper-classes/RDGE/rdge-compiled.js +++ b/js/helper-classes/RDGE/rdge-compiled.js | |||
@@ -235,15 +235,15 @@ input.onMouseMove=function(a){for(var b=0,f=input.eventHandlers.length;b<f;){if( | |||
235 | this.stateTop>0?this.stateTop-1:0;this.stateStack[this.stateTop]&&this.stateStack[this.stateTop].ReInit()};this.PopAll=function(){for(;this.stateStack[this.stateTop]!=null;)this.PopState()};this.tick=function(a){this.stateStack[this.stateTop]!=null&&(this.stateStack[this.stateTop].Update(a),this.stateStack[this.stateTop].Resize(),this.stateStack[this.stateTop].Draw())}};g_enableBenchmarks=!0; | 235 | this.stateTop>0?this.stateTop-1:0;this.stateStack[this.stateTop]&&this.stateStack[this.stateTop].ReInit()};this.PopAll=function(){for(;this.stateStack[this.stateTop]!=null;)this.PopState()};this.tick=function(a){this.stateStack[this.stateTop]!=null&&(this.stateStack[this.stateTop].Update(a),this.stateStack[this.stateTop].Resize(),this.stateStack[this.stateTop].Draw())}};g_enableBenchmarks=!0; |
236 | function Engine(){this._assetPath="assets/";this.sceneMap=[];this.stateTop=void 0;this.lastWindowWidth=window.innerWidth;this.lastWindowHeight=window.innerHeight;this.lightManager=this.defaultContext=null;clearColor=[0,0,0,0];panelObjectManager=new objectManager;this.initializeComplete=!1;this.RDGECanvas=null;this.canvasToRendererMap={};this.canvasNameToStateStack={};this.canvasCtxList=[];invalidObj=/([()]|function)/;isValidObj=function(a){return invalidObj.test(a)?(window.console.error("invalid object name passed to RDGE, "+ | 236 | function Engine(){this._assetPath="assets/";this.sceneMap=[];this.stateTop=void 0;this.lastWindowWidth=window.innerWidth;this.lastWindowHeight=window.innerHeight;this.lightManager=this.defaultContext=null;clearColor=[0,0,0,0];panelObjectManager=new objectManager;this.initializeComplete=!1;this.RDGECanvas=null;this.canvasToRendererMap={};this.canvasNameToStateStack={};this.canvasCtxList=[];invalidObj=/([()]|function)/;isValidObj=function(a){return invalidObj.test(a)?(window.console.error("invalid object name passed to RDGE, "+ |
237 | a+" - looks like a function"),!1):!0};contextDef=function(){this.startUpState=this.ctxStateManager=this.renderer=this.id=null;this.sceneGraphMap=[];this.currentScene=null;this.getScene=function(){return this.sceneGraphMap[this.currentScene]};this.debug={frameCounter:0,mat4CallCount:0}};this.ctxMan=contextManager=new objectManager;contextManager.currentCtx=null;contextManager._addObject=contextManager.addObject;contextManager.contextMap={};contextManager.addObject=function(a){this.contextMap[a.id]= | 237 | a+" - looks like a function"),!1):!0};contextDef=function(){this.startUpState=this.ctxStateManager=this.renderer=this.id=null;this.sceneGraphMap=[];this.currentScene=null;this.getScene=function(){return this.sceneGraphMap[this.currentScene]};this.debug={frameCounter:0,mat4CallCount:0}};this.ctxMan=contextManager=new objectManager;contextManager.currentCtx=null;contextManager._addObject=contextManager.addObject;contextManager.contextMap={};contextManager.addObject=function(a){this.contextMap[a.id]= |
238 | a;return this._addObject(a)};contextManager.start=function(){for(var a=this.objects.length,b=0;b<a;++b)contextManager.currentCtx=this.objects[b],this.objects[b].ctxStateManager.PushState(this.objects[b].startUpState)};contextManager.forEach=function(a){for(var b=this.objects.length,f=0;f<b;++f)a(this.objects[f])};this.getContext=function(a){return a?contextManager.contextMap[a]:contextManager.currentCtx};this.setContext=function(a){contextManager.currentCtx=contextManager.contextMap[a]};this.tickContext= | 238 | a;return this._addObject(a)};contextManager.start=function(){for(var a=this.objects.length,b=0;b<a;++b)contextManager.currentCtx=this.objects[b],this.objects[b].ctxStateManager.PushState(this.objects[b].startUpState)};contextManager.forEach=function(a){for(var b=this.objects.length,f=0;f<b;++f)a(this.objects[f])};this.getContext=function(a){return a?contextManager.contextMap[a]:contextManager.currentCtx};this.clearContext=function(a){contextManager.contextMap[a]=void 0};this.setContext=function(a){contextManager.currentCtx= |
239 | function(a){var b=contextManager.currentCtx;contextManager.currentCtx=contextManager.contextMap[a];this.objects[i].ctxStateManager.tick(dt);contextManager.currentCtx=b};this.remapAssetFolder=function(a){var b=a.indexOf("assets/"),f=a;b>=0&&(f=a.substr(b+7),f=this._assetPath+f);return f}} | 239 | contextManager.contextMap[a]};this.tickContext=function(a){var b=contextManager.currentCtx;contextManager.currentCtx=contextManager.contextMap[a];this.objects[i].ctxStateManager.tick(dt);contextManager.currentCtx=b};this.remapAssetFolder=function(a){var b=a.indexOf("assets/"),f=a;b>=0&&(f=a.substr(b+7),f=this._assetPath+f);return f}} |
240 | Engine.prototype.init=function(a,b,f){this.GlInit(f);globalParamFuncSet=function(a){this.data=a.data;this.type=a.type;this.set=function(a){for(var b=this.data?this.data.length:0,f=0;f<b;++f)this.data[f]=a[f]};this.get=function(){return this.data.length==void 0?this.data:this.data.slice()}};this.lightManager=new LightManager(rdgeGlobalParameters.rdge_lights);for(var g in rdgeGlobalParameters)if(g!="rdge_lights")rdgeGlobalParameters[g]=new globalParamFuncSet(rdgeGlobalParameters[g]);else{var a=rdgeGlobalParameters[g], | 240 | Engine.prototype.init=function(a,b,f){this.GlInit(f);globalParamFuncSet=function(a){this.data=a.data;this.type=a.type;this.set=function(a){for(var b=this.data?this.data.length:0,f=0;f<b;++f)this.data[f]=a[f]};this.get=function(){return this.data.length==void 0?this.data:this.data.slice()}};this.lightManager=new LightManager(rdgeGlobalParameters.rdge_lights);for(var g in rdgeGlobalParameters)if(g!="rdge_lights")rdgeGlobalParameters[g]=new globalParamFuncSet(rdgeGlobalParameters[g]);else{var a=rdgeGlobalParameters[g], |
241 | h;for(h in a)rdgeGlobalParameters[h]=new globalParamFuncSet(a[h])}this.lastWindowWidth=window.innerWidth;this.lastWindowHeight=window.innerHeight;this.defaultContext=new RenderContext;this.defaultContext.uniforms=[{name:"u_matAmbient",value:[0.02,0.02,0.02,1]},{name:"u_matDiffuse",value:[1,1,1,1]},{name:"u_matSpecular",value:[1,1,1,1]},{name:"u_matShininess",value:[128]},{name:"u_matEmission",value:[0,0,0,1]}];contextManager.start();this.initializeComplete=!0};Engine.prototype.Shutdown=function(){this.PopAll()}; | 241 | h;for(h in a)rdgeGlobalParameters[h]=new globalParamFuncSet(a[h])}this.lastWindowWidth=window.innerWidth;this.lastWindowHeight=window.innerHeight;this.defaultContext=new RenderContext;this.defaultContext.uniforms=[{name:"u_matAmbient",value:[0.02,0.02,0.02,1]},{name:"u_matDiffuse",value:[1,1,1,1]},{name:"u_matSpecular",value:[1,1,1,1]},{name:"u_matShininess",value:[128]},{name:"u_matEmission",value:[0,0,0,1]}];contextManager.start();this.initializeComplete=!0};Engine.prototype.Shutdown=function(){this.PopAll()}; |
242 | Engine.prototype.GlInit=function(){for(var a=document.getElementsByTagName("canvas"),b=a.length,f=0;f<b;++f){var g;a[f].getAttribute("rdge")=="true"&&(g=a[f],this.registerCanvas(g))}};Engine.prototype.loadScene=function(a){var b="assets_web/mesh/"+a+".json";contextManager.currentCtx.stateMan.currentState().name=="RunState"&&(contextManager.currentCtx.stateMan.PushState(contextManager.currentCtx.stateMan.RDGEInitState),contextManager.currentCtx.loadScene(b,a))};Engine.prototype.getScene=function(a){return contextManager.currentCtx.sceneGraphMap[a]}; | 242 | Engine.prototype.GlInit=function(){for(var a=document.getElementsByTagName("canvas"),b=a.length,f=0;f<b;++f){var g;a[f].getAttribute("rdge")=="true"&&(g=a[f],this.registerCanvas(g))}};Engine.prototype.loadScene=function(a){var b="assets_web/mesh/"+a+".json";contextManager.currentCtx.stateMan.currentState().name=="RunState"&&(contextManager.currentCtx.stateMan.PushState(contextManager.currentCtx.stateMan.RDGEInitState),contextManager.currentCtx.loadScene(b,a))};Engine.prototype.getScene=function(a){return contextManager.currentCtx.sceneGraphMap[a]}; |
243 | Engine.prototype.AddScene=function(a,b){contextManager.currentCtx.sceneGraphMap[a]=b;contextManager.currentCtx.currentScene=a};Engine.prototype.createRDGEPanel=function(){var a=new utilDbgPanel("tools","WebGL Viewer Settings");a.appendLabel("","");return panelObjectManager.addObject(a)};Engine.prototype.getRDGEPanel=function(a){return panelObjectManager.handleToObject(a)}; | 243 | Engine.prototype.AddScene=function(a,b){contextManager.currentCtx.sceneGraphMap[a]=b;contextManager.currentCtx.currentScene=a};Engine.prototype.createRDGEPanel=function(){var a=new utilDbgPanel("tools","WebGL Viewer Settings");a.appendLabel("","");return panelObjectManager.addObject(a)};Engine.prototype.getRDGEPanel=function(a){return panelObjectManager.handleToObject(a)}; |
244 | Engine.prototype.registerCanvas=function(a,b){if(!a||!this.getContext(a.rdgeid)){a.renderer=new _renderer(a);this.canvasToRendererMap[a.rdgeid]=a;a.renderer.id=a.rdgeid;var f=new stateManager,g=new contextDef;g.id=a.rdgeid;g.renderer=a.renderer;g.ctxStateManager=f;g.fpsTracker=new fpsTracker(a.rdgeid);g.renderer.mvMatrix=mat4.identity();g.renderer.invMvMatrix=mat4.identity();g.renderer.projectionMatrix=mat4.identity();g.renderer.normalMatrix=mat4.identity();a.rdgeCtxHandle=contextManager.addObject(g); | 244 | Engine.prototype.registerCanvas=function(a,b){if(!a||!this.getContext(a.rdgeid)){a.renderer=new _renderer(a);this.canvasToRendererMap[a.rdgeid]=a;a.renderer.id=a.rdgeid;var f=new stateManager,g=new contextDef;g.id=a.rdgeid;g.renderer=a.renderer;g.ctxStateManager=f;g.fpsTracker=new fpsTracker(a.rdgeid);g.renderer.mvMatrix=mat4.identity();g.renderer.invMvMatrix=mat4.identity();g.renderer.projectionMatrix=mat4.identity();g.renderer.normalMatrix=mat4.identity();a.rdgeCtxHandle=contextManager.addObject(g); |
245 | contextManager.currentCtx=g;var h;if(b)h=b;else{var l=a.getAttribute("rdgerun");if(l){if(!isValidObj(l))return;try{h=new (eval(l))}catch(n){window.console.error('The provided RDGE state object "'+l+'" is not defined')}}else h={},validateUserState(h)}l=a.getAttribute("rdgescene");f.RDGEInitState=new LoadState(h,g);f.RDGERunState=new RunState(h,g);validateUserState(h);l?(f.RDGEInitState.sceneName=l,f.PushState(f.RDGERunState,"noInit"),g.startUpState=f.RDGEInitState):g.startUpState=f.RDGERunState;this.initializeComplete&& | 245 | contextManager.currentCtx=g;var h;if(b)h=b;else{var l=a.getAttribute("rdgerun");if(l){if(!isValidObj(l))return;try{h=new (eval(l))}catch(n){window.console.error('The provided RDGE state object "'+l+'" is not defined')}}else h={},validateUserState(h)}l=a.getAttribute("rdgescene");f.RDGEInitState=new LoadState(h,g);f.RDGERunState=new RunState(h,g);validateUserState(h);l?(f.RDGEInitState.sceneName=l,f.PushState(f.RDGERunState,"noInit"),g.startUpState=f.RDGEInitState):g.startUpState=f.RDGERunState;this.initializeComplete&& |
246 | g.ctxStateManager.PushState(g.startUpState)}};Engine.prototype.unregisterCanvas=function(a){stat.closePage(a.rdgeid+"_fps");contextManager.removeObject(a.rdgeCtxHandle)};Engine.prototype.getCanvas=function(a){return this.canvasToRendererMap[a]};nodeIdGen={counter:0};nodeIdGen.getId=function(){return"gen_"+nodeIdGen.counter++};function createTransformNode(a){node={name:a};node.transformNodeTemplate=new transformNodeTemplate(node);return node}function createMaterialNode(a){node={name:a};node.materialNodeTemplate=new materialNodeTemplate(node);return node} | 246 | g.ctxStateManager.PushState(g.startUpState)}};Engine.prototype.unregisterCanvas=function(a){stat.closePage(a.rdgeid+"_fps");contextManager.removeObject(a.rdgeCtxHandle);this.clearContext(a.rdgeid)};Engine.prototype.getCanvas=function(a){return this.canvasToRendererMap[a]};nodeIdGen={counter:0};nodeIdGen.getId=function(){return"gen_"+nodeIdGen.counter++};function createTransformNode(a){node={name:a};node.transformNodeTemplate=new transformNodeTemplate(node);return node}function createMaterialNode(a){node={name:a};node.materialNodeTemplate=new materialNodeTemplate(node);return node} |
247 | function createMeshNode(a,b){meshNode={mesh:{},meshNodeTemplate:{}};var f=g_Engine.getContext().renderer;b.built||f.createPrimitive(b);var g=g_meshMan.getModelByName(a);if(g)f.buffers[g.primitive.buffersID]||f.createPrimitive(g.primitive);else return meshNode.mesh.meshNodeTemplate=new meshNodeTemplate(meshNode.mesh,b,a),g_meshMan.modelMap[a]=meshNode.mesh,meshNode;meshNode.mesh.meshNodeTemplate=new meshNodeTemplate(meshNode.mesh,g.primitive,a);return meshNode} | 247 | function createMeshNode(a,b){meshNode={mesh:{},meshNodeTemplate:{}};var f=g_Engine.getContext().renderer;b.built||f.createPrimitive(b);var g=g_meshMan.getModelByName(a);if(g)f.buffers[g.primitive.buffersID]||f.createPrimitive(g.primitive);else return meshNode.mesh.meshNodeTemplate=new meshNodeTemplate(meshNode.mesh,b,a),g_meshMan.modelMap[a]=meshNode.mesh,meshNode;meshNode.mesh.meshNodeTemplate=new meshNodeTemplate(meshNode.mesh,g.primitive,a);return meshNode} |
248 | function createLightNode(a){node={name:a};node.lightNodeTemplate=new lightNodeTemplate(node);return node}function createScreenQuadNode(){var a=createTransformNode();a.attachMeshNode("screenQuad",createScreenAlignedQuad());return a}function verifyTransformNode(a){if(a.transformNodeTemplate==void 0)a.transformNodeTemplate=new transformNodeTemplate(a)}function verifyMaterialNode(a){if(a.materialNodeTemplate==void 0)a.materialNodeTemplate=new materialNodeTemplate(a)} | 248 | function createLightNode(a){node={name:a};node.lightNodeTemplate=new lightNodeTemplate(node);return node}function createScreenQuadNode(){var a=createTransformNode();a.attachMeshNode("screenQuad",createScreenAlignedQuad());return a}function verifyTransformNode(a){if(a.transformNodeTemplate==void 0)a.transformNodeTemplate=new transformNodeTemplate(a)}function verifyMaterialNode(a){if(a.materialNodeTemplate==void 0)a.materialNodeTemplate=new materialNodeTemplate(a)} |
249 | function verifyLightNode(a){if(a.lightNodeTemplate==void 0)a.lightNodeTemplate=new lightNodeTemplate(a)} | 249 | function verifyLightNode(a){if(a.lightNodeTemplate==void 0)a.lightNodeTemplate=new lightNodeTemplate(a)} |
diff --git a/js/helper-classes/RDGE/src/core/script/engine.js b/js/helper-classes/RDGE/src/core/script/engine.js index f5724665..1341d032 100755 --- a/js/helper-classes/RDGE/src/core/script/engine.js +++ b/js/helper-classes/RDGE/src/core/script/engine.js | |||
@@ -214,6 +214,11 @@ function Engine() | |||
214 | return contextManager.contextMap[optCanvasID]; | 214 | return contextManager.contextMap[optCanvasID]; |
215 | } | 215 | } |
216 | } | 216 | } |
217 | |||
218 | this.clearContext = function( canvasID ) | ||
219 | { | ||
220 | contextManager.contextMap[canvasID] = undefined; | ||
221 | } | ||
217 | 222 | ||
218 | /* | 223 | /* |
219 | * give the contextID (canvas id) of the context to set | 224 | * give the contextID (canvas id) of the context to set |
@@ -488,7 +493,7 @@ Engine.prototype.registerCanvas = function(canvas, runState) { | |||
488 | Engine.prototype.unregisterCanvas = function(canvas) { | 493 | Engine.prototype.unregisterCanvas = function(canvas) { |
489 | stat.closePage(canvas.rdgeid + "_fps"); | 494 | stat.closePage(canvas.rdgeid + "_fps"); |
490 | contextManager.removeObject(canvas.rdgeCtxHandle); | 495 | contextManager.removeObject(canvas.rdgeCtxHandle); |
491 | 496 | this.clearContext( canvas.rdgeid ); | |
492 | } | 497 | } |
493 | 498 | ||
494 | Engine.prototype.getCanvas = function( id ) | 499 | Engine.prototype.getCanvas = function( id ) |