From 9fdbfe3ab750e8f6dae2ae80ebb6728a4b6c985d Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Tue, 3 Apr 2012 09:40:10 -0700 Subject: updated the rdge compiled version and its runtime, incremented rdge library version number --- assets/canvas-runtime.js | 199 ++++---- assets/rdge-compiled.js | 777 ++++++++++++++------------------ js/helper-classes/RDGE/rdge-compiled.js | 453 ++++++++----------- js/io/system/ninjalibrary.json | 2 +- 4 files changed, 616 insertions(+), 815 deletions(-) diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index f53a4ef6..b4563ea5 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js @@ -19,7 +19,7 @@ function initWebGl (rootElement, directory) { cvsDataMngr = new CanvasDataManager(); //Loading data to canvas(es) cvsDataMngr.loadGLData(rootElement, ninjaWebGlData.data, directory); -} +}; /////////////////////////////////////////////////////////////////////// // Class ShapeRuntime @@ -59,7 +59,7 @@ function CanvasDataManager() } } } - } + }; this.collectGLData = function( elt, dataArray ) { @@ -78,7 +78,7 @@ function CanvasDataManager() this.collectGLData( child, dataArray ); } } - } + }; this.findCanvasWithID = function( id, elt ) { @@ -95,8 +95,8 @@ function CanvasDataManager() if (foundElt) return foundElt; } } - } -} + }; +}; /////////////////////////////////////////////////////////////////////// // Class GLRuntime @@ -149,16 +149,16 @@ function GLRuntime( canvas, jObj, assetPath ) /////////////////////////////////////////////////////////////////////// // accessors /////////////////////////////////////////////////////////////////////// - this.getZNear = function() { return this._zNear; } - this.getZFar = function() { return this._zFar; } - this.getFOV = function() { return this._fov; } - this.getAspect = function() { return this._aspect; } - this.getViewDistance = function() { return this._viewDist; } + this.getZNear = function() { return this._zNear; }; + this.getZFar = function() { return this._zFar; }; + this.getFOV = function() { return this._fov; }; + this.getAspect = function() { return this._aspect; }; + this.getViewDistance = function() { return this._viewDist; }; - this.get2DContext = function() { return this._context; } + this.get2DContext = function() { return this._context; }; - this.getViewportWidth = function() { return this._canvas.width; } - this.getViewportHeight = function() { return this._canvas.height; } + this.getViewportWidth = function() { return this._canvas.width; }; + this.getViewportHeight = function() { return this._canvas.height; }; /////////////////////////////////////////////////////////////////////// // accessors @@ -188,20 +188,20 @@ function GLRuntime( canvas, jObj, assetPath ) this.importObjects( root ); this.render(); } - } + }; this.init = function() { - var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle), - ctx2 = g_Engine.getContext(); + var ctx1 = RDGE.globals.engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle), + ctx2 = RDGE.globals.engine.getContext(); if (ctx1 != ctx2) console.log( "***** different contexts *****" ); this.renderer = ctx1.renderer; // create a camera, set its perspective, and then point it at the origin - var cam = new camera(); + var cam = new RDGE.camera(); this._camera = cam; cam.setPerspective(this.getFOV(), this.getAspect(), this.getZNear(), this.getZFar()); - cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], vec3.up()); + cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], RDGE.vec3.up()); // make this camera the active camera this.renderer.cameraManager().setActiveCamera(cam); @@ -210,17 +210,17 @@ function GLRuntime( canvas, jObj, assetPath ) this.renderer.setClearColor([1.0, 1.0, 1.0, 0.0]); // create an empty scene graph - this.myScene = new SceneGraph(); + this.myScene = new RDGE.SceneGraph(); // load the scene graph data this.loadScene(); // Add the scene to the engine - necessary if you want the engine to draw for you var name = "myScene" + this._canvas.getAttribute( "data-RDGE-id" ); - g_Engine.AddScene(name, this.myScene); + RDGE.globals.engine.AddScene(name, this.myScene); this._initialized = true; - } + }; // main code for handling user interaction and updating the scene this.update = function(dt) @@ -233,7 +233,7 @@ function GLRuntime( canvas, jObj, assetPath ) this.elapsed += dt; // changed the global position uniform of light 0, another way to change behavior of a light - rdgeGlobalParameters.u_light0Pos.set( [5*Math.cos(this.elapsed), 5*Math.sin(this.elapsed), 20]); + RDGE.rdgeGlobalParameters.u_light0Pos.set( [5*Math.cos(this.elapsed), 5*Math.sin(this.elapsed), 20]); // orbit the light nodes around the boxes if (this.light ) this.light.setPosition([1.2*Math.cos(this.elapsed*2.0), 1.2*Math.sin(this.elapsed*2.0), 1.2*Math.cos(this.elapsed*2.0)]); @@ -244,7 +244,7 @@ function GLRuntime( canvas, jObj, assetPath ) // now update all the nodes in the scene this.myScene.update(dt); } - } + }; this.updateMaterials = function() { @@ -254,16 +254,16 @@ function GLRuntime( canvas, jObj, assetPath ) var mat = this._materials[i]; mat.update(); } - } + }; // defining the draw function to control how the scene is rendered this.draw = function() { if (this._initialized) { - g_Engine.setContext( this._canvas.rdgeid ); + RDGE.globals.engine.setContext( this._canvas.rdgeid ); - var ctx = g_Engine.getContext(); + var ctx = RDGE.globals.engine.getContext(); var renderer = ctx.renderer; if (renderer.unloadedTextureCount <= 0) { @@ -281,7 +281,7 @@ function GLRuntime( canvas, jObj, assetPath ) } } } - } + }; this.importObjects = function( jObj, parent ) { @@ -298,7 +298,7 @@ function GLRuntime( canvas, jObj, assetPath ) this.importObjects( child, gObj ); } } - } + }; this.importObject = function( jObj, parent ) { @@ -330,7 +330,7 @@ function GLRuntime( canvas, jObj, assetPath ) this.addObject( obj, parent ); return obj; - } + }; this.addObject = function( obj, parent ) { @@ -341,7 +341,7 @@ function GLRuntime( canvas, jObj, assetPath ) this._geomRoot = obj; else parent.addChild( obj ); - } + }; this.linkLights = function() { @@ -351,7 +351,7 @@ function GLRuntime( canvas, jObj, assetPath ) this.light = matNode.lightChannel[1]; this.light2 = matNode.lightChannel[2]; } - } + }; this.linkMaterials = function( obj ) { @@ -372,7 +372,7 @@ function GLRuntime( canvas, jObj, assetPath ) this._materials.push( mat ); } } - } + }; this.initMaterials = function() { @@ -382,7 +382,7 @@ function GLRuntime( canvas, jObj, assetPath ) var mat = this._materials[i]; mat.init( this ); } - } + }; this.remapAssetFolder = function( url ) { @@ -397,7 +397,7 @@ function GLRuntime( canvas, jObj, assetPath ) // return rtnPath; return url; - } + }; this.findMaterialNode = function( nodeName, node ) { @@ -419,7 +419,7 @@ function GLRuntime( canvas, jObj, assetPath ) if (rtnNode) return rtnNode; } } - } + }; this.render = function( obj ) { @@ -436,7 +436,7 @@ function GLRuntime( canvas, jObj, assetPath ) this.render( child ); } } - } + }; // start RDGE or load Canvas 2D objects if (jObj.scenedata) this._useWebGL = true; @@ -444,14 +444,14 @@ function GLRuntime( canvas, jObj, assetPath ) { var id = canvas.getAttribute( "data-RDGE-id" ); canvas.rdgeid = id; - g_Engine.registerCanvas(canvas, this); - RDGEStart( canvas ); + RDGE.globals.engine.registerCanvas(canvas, this); + RDGE.RDGEStart( canvas ); } else { this.loadScene(); } -} +}; /////////////////////////////////////////////////////////////////////// // Class RuntimeGeomObj @@ -485,10 +485,10 @@ function RuntimeGeomObj() // Property accessors /////////////////////////////////////////////////////////////////////// - this.geomType = function() { return this.GEOM_TYPE_UNDEFINED; } + this.geomType = function() { return this.GEOM_TYPE_UNDEFINED; }; - this.setWorld = function(w) { this._world = w; } - this.getWorld = function() { return this._world; } + this.setWorld = function(w) { this._world = w; }; + this.getWorld = function() { return this._world; }; /////////////////////////////////////////////////////////////////////// // Methods @@ -497,11 +497,11 @@ function RuntimeGeomObj() { if (!this._children) this._children = []; this._children.push( child ); - } + }; this.import = function() { - } + }; this.importMaterials = function(jObj) { @@ -553,7 +553,7 @@ function RuntimeGeomObj() this._materials.push( mat ); } } - } + }; //////////////////////////////////////////////////////////////////// // vector function @@ -571,7 +571,7 @@ function RuntimeGeomObj() rtnVec[i] = a[i] + b[i]; return rtnVec; - } + }; this.vecSubtract = function( dimen, a, b ) @@ -587,7 +587,7 @@ function RuntimeGeomObj() rtnVec[i] = a[i] - b[i]; return rtnVec; - } + }; this.vecDot = function( dimen, v0, v1 ) { @@ -601,7 +601,7 @@ function RuntimeGeomObj() sum += v0[i] * v1[i]; return sum; - } + }; this.vecMag = function( dimen, vec ) { @@ -609,7 +609,7 @@ function RuntimeGeomObj() for (var i=0; i 200.0) this._time = 0.0; } } - } -} + }; +}; function RuntimeRadialGradientMaterial() { @@ -1321,7 +1319,7 @@ function RuntimeRadialGradientMaterial() if (material) { var technique = material.shaderProgram.default; - var renderer = g_Engine.getContext().renderer; + var renderer = RDGE.globals.engine.getContext().renderer; if (renderer && technique) { if (this._shader && this._shader.default) @@ -1341,7 +1339,7 @@ function RuntimeRadialGradientMaterial() } } } - } + }; this.import = function( jObj ) { @@ -1356,9 +1354,8 @@ function RuntimeRadialGradientMaterial() if (this._angle !== undefined) this._angle = jObj.angle; - } - -} + }; +}; function RuntimeLinearGradientMaterial() { @@ -1371,7 +1368,7 @@ function RuntimeLinearGradientMaterial() // the only difference between linear & radial gradient is the existance of an angle for linear. this._angle = 0.0; -} +}; function RuntimeBumpMetalMaterial() { @@ -1393,7 +1390,7 @@ function RuntimeBumpMetalMaterial() this._diffuseTexture = jObj.diffuseTexture; this._specularTexture = jObj.specularTexture; this._normalTexture = jObj.normalMap; - } + }; this.init = function( world ) { @@ -1401,7 +1398,7 @@ function RuntimeBumpMetalMaterial() if (material) { var technique = material.shaderProgram.default; - var renderer = g_Engine.getContext().renderer; + var renderer = RDGE.globals.engine.getContext().renderer; if (renderer && technique) { if (this._shader && this._shader.default) @@ -1431,8 +1428,8 @@ function RuntimeBumpMetalMaterial() } } } - } -} + }; +}; function RuntimeUberMaterial() { @@ -1448,7 +1445,7 @@ function RuntimeUberMaterial() if (material) { var technique = material.shaderProgram.defaultTechnique; - var renderer = g_Engine.getContext().renderer; + var renderer = RDGE.globals.engine.getContext().renderer; if (renderer && technique) { if (this._shader && this._shader.defaultTechnique) @@ -1493,7 +1490,7 @@ function RuntimeUberMaterial() var uvTransform = [ 2.0, 0, 0, 0, 0, 2.0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 1]; technique.u_uvMatrix.set(uvTransform); - var renderer = g_Engine.getContext().renderer; + var renderer = RDGE.globals.engine.getContext().renderer; if (this._diffuseMap) { var tex = renderer.getTextureByName(this._diffuseMap, 'REPEAT'); @@ -1522,11 +1519,11 @@ function RuntimeUberMaterial() } } } - } + }; this.update = function( time ) { - } + }; this.import = function( jObj ) { @@ -1592,8 +1589,8 @@ function RuntimeUberMaterial() this._environmentMap = jObj['environmentMap']; if (this._environmentMap) this._environmentAmount = jObj['environmentAmount']; - } -} + }; +}; function RuntimePlasmaMaterial() { @@ -1604,13 +1601,13 @@ function RuntimePlasmaMaterial() this.init = function( ) { this.update(); - } + }; this.importJSON = function( jObj ) { this._speed = jObj.speed; this._dTime = jObj.dTime; - } + }; this.update = function( time ) { @@ -1618,7 +1615,7 @@ function RuntimePlasmaMaterial() if (material) { var technique = material.shaderProgram.default; - var renderer = g_Engine.getContext().renderer; + var renderer = RDGE.globals.engine.getContext().renderer; if (renderer && technique) { if (this._shader && this._shader.default) @@ -1627,7 +1624,7 @@ function RuntimePlasmaMaterial() if (this._time > 200.0) this._time = 0.0; } } - } -} + }; +}; diff --git a/assets/rdge-compiled.js b/assets/rdge-compiled.js index caf58147..66bf5a42 100755 --- a/assets/rdge-compiled.js +++ b/assets/rdge-compiled.js @@ -1,452 +1,329 @@ -vec2={string:function(a){return"{ "+a[0]+", "+a[1]+" }"},verify:function(a){return a==void 0||a.length==void 0||a.length<2?!1:typeof a[0]!="number"||typeof a[1]!="number"?!1:!0},copy:function(a){return a.length==void 0?[a,a]:[a[0],a[1]]},inplace_copy:function(a,b){a[0]=b[0];a[1]=b[1]},zero:function(){return[0,0]},up:function(){return[0,1]},right:function(){return[1,0]},add:function(a,b){return[a[0]+b[0],a[1]+b[1]]},sub:function(a,b){return[a[0]-b[0],a[1]-b[1]]},mul:function(a,b){return[a[0]*b[0], -a[1]*b[1]]},addMul:function(a,b,f){return f.length!=void 0&&f.length>=2?[a[0]+b[0]*f[0],a[1]+b[1]*f[1]]:[a[0]+b[0]*f,a[1]+b[1]*f]},scale:function(a,b){return b.length!=void 0&&b.length>=2?[a[0]*b[0],a[1]*b[1]]:[a[0]*b,a[1]*b]},negate:function(a){return[-a[0],-a[1]]},normalize:function(a){var b=Math.sqrt(a[0]*a[0],a[1]*a[1]);return Math.abs(1-b)>1.0E-4?(b=1/b,[a[0]*b,a[1]*b]):a},dot:function(a,b){return a[0]*b[0]+a[1]*b[1]},perp:function(a){return[a[1],-a[0]]},lengthSq:function(a){return a[0]*a[0]+ -a[1]*a[1]},length:function(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1])},min:function(a,b){return[Math.min(a[0],b[0]),Math.min(a[1],b[1])]},max:function(a,b){return[Math.max(a[0],b[0]),Math.max(a[1],b[1])]}};vec2.clamp=function(a,b,f){return vec2.min(f,vec2.max(a,b))};vec3={string:function(a){return"{ "+a[0]+", "+a[1]+", "+a[2]+" }"},verify:function(a){return a==void 0||a.length==void 0||a.length<3?!1:typeof a[0]!="number"||typeof a[1]!="number"||typeof a[2]!="number"?!1:!0},inplace_copy:function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2]},copy:function(a){return a.length==void 0?[a,a,a]:[a[0],a[1],a[2]]},translation:function(a){return[a[12],a[13],a[14]]},basisX:function(a){return[a[0],a[1],a[2]]},basisY:function(a){return[a[4],a[5],a[6]]},basisZ:function(a){return[a[8], -a[9],a[10]]},zero:function(){return[0,0,0]},up:function(){return[0,1,0]},forward:function(){return[0,0,1]},right:function(){return[1,0,0]},random:function(a,b){return[a[0]+(b[0]-a[0])*Math.random(),a[1]+(b[1]-a[1])*Math.random(),a[2]+(b[2]-a[2])*Math.random()]},xy:function(a){return[a[0],a[1]]},xz:function(a){return[a[0],a[2]]},add:function(a,b){return[a[0]+b[0],a[1]+b[1],a[2]+b[2]]},plusEqual:function(a,b){a[0]+=b[0];a[1]+=b[1];a[2]+=b[2]},sub:function(a,b){return[a[0]-b[0],a[1]-b[1],a[2]-b[2]]}, -mul:function(a,b){return[a[0]*b[0],a[1]*b[1],a[2]*b[2]]},addMul:function(a,b,f){return f.length!=void 0&&f.length>=3?[a[0]+b[0]*f[0],a[1]+b[1]*f[1],a[2]+b[2]*f[2]]:[a[0]+b[0]*f,a[1]+b[1]*f,a[2]+b[2]*f]},plusEqualMul:function(a,b,f){f.length!==void 0&&f.length>=3?(a[0]+=b[0]*f[0],a[1]+=b[1]*f[1],a[2]+=b[2]*f[2]):(a[0]+=b[0]*f,a[1]+=b[1]*f,a[2]+=b[2]*f)},scale:function(a,b){return b.length!==void 0&&b.length>=3?[a[0]*b[0],a[1]*b[1],a[2]*b[2]]:[a[0]*b,a[1]*b,a[2]*b]},inplace_scale:function(a,b){b.length!== -void 0&&b.length>=3?(a[0]*=b[0],a[1]*=b[1],a[2]*=b[2]):(a[0]*=b,a[1]*=b,a[2]*=b)},negate:function(a){return[-a[0],-a[1],-a[2]]},inplace_negate:function(a){a[0]=-a[0];a[1]=-a[1];a[2]=-a[2]},normalize:function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return Math.abs(1-b)>1.0E-4?(b=1/b,[a[0]*b,a[1]*b,a[2]*b]):a},cross:function(a,b){return[a[1]*b[2]-b[1]*a[2],a[2]*b[0]-b[2]*a[0],a[0]*b[1]-b[0]*a[1]]},dot:function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]},lengthSq:function(a){return a[0]*a[0]+ -a[1]*a[1]+a[2]*a[2]},length:function(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2])},distanceSq:function(a,b){var f=[a[0]-b[0],a[1]-b[1],a[2]-b[2]];return f[0]*f[0]+f[1]*f[1]+f[2]*f[2]},distance:function(a,b){var f=[a[0]-b[0],a[1]-b[1],a[2]-b[2]];return Math.sqrt(f[0]*f[0]+f[1]*f[1]+f[2]*f[2])}};vec3.angle=function(a,b){return Math.acos(vec3.dot(a,b))/(vec3.length(a)*vec3.length(b))};vec3.direction=function(a,b){return vec3.normalize(vec3.sub(b,a))}; -vec3.abs=function(a){return[Math.abs(a[0]),Math.abs(a[1]),Math.abs(a[2])]};vec3.min=function(a,b){return[Math.min(a[0],b[0]),Math.min(a[1],b[1]),Math.min(a[2],b[2])]};vec3.max=function(a,b){return[Math.max(a[0],b[0]),Math.max(a[1],b[1]),Math.max(a[2],b[2])]};vec3.clamp=function(a,b,f){return vec3.min(f,vec3.max(a,b))};vec3.equal=function(a,b,f){f||(f=0.0010);return vec3.distanceSq(a,b)=4?[a[0]+b[0]* -f[0],a[1]+b[1]*f[1],a[2]+b[2]*f[2],a[3]+b[3]*f[3]]:[a[0]+b[0]*f,a[1]+b[1]*f,a[2]+b[2]*f,a[3]+b[3]*f]},scale:function(a,b){return b.length!=void 0&&b.length>=4?[a[0]*b[0],a[1]*b[1],a[2]*b[2],a[3]*b[3]]:[a[0]*b,a[1]*b,a[2]*b,a[3]*b]},negate:function(a){return[-a[0],-a[1],-a[2],-a[3]]},dot:function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]},normalize:function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]);return Math.abs(1-b)>1.0E-4?(b=1/b,[a[0]*b,a[1]*b,a[2]*b,a[3]*b]):a},lengthSq:function(a){return a[0]* -a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]},length:function(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3])},abs:function(a){return[Math.abs(a[0]),Math.abs(a[1]),Math.abs(a[2]),Math.abs(a[3])]},min:function(a,b){return[Math.min(a[0],b[0]),Math.min(a[1],b[1]),Math.min(a[2],b[2]),Math.min(a[3],b[3])]},max:function(a,b){return[Math.max(a[0],b[0]),Math.max(a[1],b[1]),Math.max(a[2],b[2]),Math.min(a[3],b[3])]}};vec4.clamp=function(a,b,f){return vec4.min(f,vec4.max(a,b))}; -vec4.equal=function(a,b,f){f||(f=0.0010);return vec4.distanceSq(a,b)=4?b[3]:1;return[a[0]*f+a[4]*g+a[8]*h+a[12]*l,a[1]*f+a[5]*g+a[9]*h+a[13]*l,a[2]*f+a[6]*g+a[10]*h+a[14]*l,a[3]*f+a[7]*g+a[11]*h+a[15]*l]};mat4.transformVector=function(a,b){var a=mat4.inverse(a),f=b[0],g=b[1],h=b[2],l=b.length>=4?b[3]:0;return[a[0]*f+a[1]*g+a[2]*h+a[3]*l,a[4]*f+a[5]*g+a[6]*h+a[7]*l,a[8]*f+a[9]*g+a[10]*h+a[11]*l,a[12]*f+a[13]*g+a[14]*h+a[15]*l]}; -mat4.transformPoint4x3=function(a,b){var f=b[0],g=b[1],h=b[2];return[a[0]*f+a[4]*g+a[8]*h+a[12],a[1]*f+a[5]*g+a[9]*h+a[13],a[2]*f+a[6]*g+a[10]*h+a[14],1]};mat4.transformVector4x3=function(a,b){var a=mat4.inverse(a),f=b[0],g=b[1],h=b[2];return[a[0]*f+a[1]*g+a[2]*h,a[4]*f+a[5]*g+a[6]*h,a[8]*f+a[9]*g+a[10]*h,0]};mat4.getRow=function(a,b){b*=4;return[a[b],a[b+1],a[b+2],a[b+3]]};mat4.getCol=function(a,b){return[a[b],a[b+4],a[b+8],a[b+12]]}; -mat4.setRow=function(a,b,f){b*=4;a[b+0]=f[0];a[b+1]=f[1];a[b+2]=f[2];f.length>=4&&(a[b+3]=f[3]);return a};mat4.setCol=function(a,b,f){a[b+0]=f[0];a[b+4]=f[1];a[b+8]=f[2];f.length>=4&&(a[b+12]=f[3]);return a};mat4.rotate=function(a,b,f){return mat4.mul(a,mat4.angleAxis(b,f))};mat4.rotateX=function(a,b){return mat4.mul(a,mat4.angleAxis(b,vec3.basisX(a)))};mat4.rotateY=function(a,b){return mat4.mul(a,mat4.angleAxis(b,vec3.basisY(a)))};mat4.rotateZ=function(a,b){return mat4.mul(a,mat4.angleAxis(b,vec3.basisZ(a)))}; -mat4.scale=function(a,b){var f=mat4.identity();b.length==void 0&&(b=[b,b,b]);f[0]=b[0];f[5]=b[1];f[10]=b[2];return mat4.mul(a,f)};mat4.scaleX=function(a,b){return mat4.scale(a,[b,1,1])};mat4.scaleY=function(a,b){return mat4.scale(a,[1,b,1])};mat4.scaleZ=function(a,b){return mat4.scale(a,[1,1,b])};mat4.translate=function(a,b){matT=mat4.identity();matT[12]=b[0];matT[13]=b[1];matT[14]=b[2];return mat4.mul(a,matT)};mat4.translateX=function(a,b){return mat4.translate(a,[b,0,0])}; -mat4.translateY=function(a,b){return mat4.translate(a,[0,b,0])};mat4.translateZ=function(a,b){return mat4.translate(a,[0,0,b])};quat={string:function(a){return"{ "+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+" }"},verify:function(a){return a==void 0||a.length==void 0||a.length<4?!1:typeof a[0]!="number"||typeof a[1]!="number"||typeof a[2]!="number"||typeof a[3]!="number"?!1:!0},identity:function(){return[0,0,0,1]},add:function(a,b){return[a[0]+b[0],a[1]+b[1],a[2]+b[2],a[3]+b[3]]},sub:function(a,b){return[a[0]-b[0],a[1]-b[1],a[2]-b[2],a[3]-b[3]]},mul:function(a,b){return[a[3]*b[3]-a[0]*b[0]-a[1]*b[1]-a[2]*b[2],a[3]*b[0]+a[0]*b[3]+a[1]* -b[2]-a[2]*b[1],a[3]*b[1]-a[0]*b[2]+a[1]*b[3]+a[2]*b[0],a[3]*b[2]+a[0]*b[1]-a[1]*b[0]+a[2]*b[3]]},addMul:function(a,b,f){return f.length!=void 0&&f.length>=4?[a[0]+b[0]*f[0],a[1]+b[1]*f[1],a[2]+b[2]*f[2],a[3]+b[3]*f[3]]:[a[0]+b[0]*f,a[1]+b[1]*f,a[2]+b[2]*f,a[3]+b[3]*f]},scale:function(a,b){return b.length!=void 0&&b.length>=4?[a[0]*b[0],a[1]*a[1],a[2]*b[2],a[3]*b[3]]:[a[0]*b,a[1]*b,a[2]*b,a[3]*b]},lengthSq:function(a){return a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]},length:function(a){return Math.sqrt(a[0]* -a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3])},normalize:function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]);return Math.abs(1-b)>1.0E-4?(b=1/b,[a[0]*b,a[1]*b,a[2]*b,a[3]*b]):a},inverse:function(a){var b=vec4.lengthSq(a);return b>1.0E-5?(b=1/b,[a[0]*-b,a[1]*-b,a[2]*-b,a[3]]):a},dot:function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}};quat.applyRotation=function(a,b){return mat4.transformPoint(quat.toMatrix(a),b)}; -quat.lerp=function(a,b,f){return quat.normalize([a[0]+(b[0]-a[0])*f,a[1]+(b[1]-a[1])*f,a[2]+(b[2]-a[2])*f,a[3]+(b[3]-a[3])*f])};quat.slerp=function(a,b,f){var g=quat.dot(a,b);if(g>=0.9)return quat.lerp(a,b,f);var h=Math.sqrt(Math.abs(1-g*g));if(h<0.0010)return a;var g=g<0?-1:1,l=Math.asin(h),n=1/h,h=Math.sin((1-f)*l)*n,f=Math.sin(f*l)*n*g;quat.scale(a,h);quat.scale(b,f);return quat.normalize(quat.add(a,b))}; -quat.toMatrix=function(a){var b=2*a[0],f=2*a[1],g=2*a[2],h=b*a[3],l=f*a[3],n=g*a[3];b*=a[0];var o=f*a[0],p=g*a[0];f*=a[1];var q=g*a[1],a=g*a[2];return[1-(f+a),o+n,p-l,0,o-n,1-(b+a),q+h,0,p+l,q-h,1-(b+f),0,0,0,0,1]};var stat=function(){pages={};dlgId="";self=function(a,b,f,g,h){h==void 0&&(h=!0);category=!a?"default":a;pages[category]||(pages[category]=[]);pages[category].push(this);this.name=b;this.value=this.defValue=f;this.func=g;this.reset=h;this.reportInterval=500;stat.dirty=!0;stat.find=function(a,b){var f=pages[a];for(i=0;i'+a+"");g+="";for(a in pages)pages[a]&&(g+='
',g+="
");g+="";f.innerHTML=g;$("#stat_tabs").tabs();stat.dirty=!1}for(a in pages)f=document.getElementById(a),stat.report(f,a,b)};stat.report=function(a,b){b||(b="default");var f=pages[b];if(f){outputHTML='';var g=0;for(i=0;i', -outputHTML+=f[i].func?f[i].name+" : "+f[i].func(f[i].value):f[i].name+" : "+f[i].value,outputHTML+="",g++>=3&&(outputHTML+="",g=0),f[i].reset)f[i].value=f[i].defValue;outputHTML+="
";a.innerHTML=outputHTML}}};setInterval(function(){self.reportAll("RDGE_STATS")},500);return self}(); -dbCanvas=function(a,b){this.front=document.createElement("canvas");this.front.setAttribute("width",a);this.front.setAttribute("height",b);this.front.setAttribute("style","position:absolute; margin: 0.0em; padding: 0.0em;");this.front.ctx=this.front.getContext("2d");this.back=document.createElement("canvas");this.back.setAttribute("width",a);this.back.setAttribute("height",b);this.front.setAttribute("style","position:absolute; margin: 0.0em; padding: 0.0em;");this.back.ctx=this.back.getContext("2d"); -this.swap=function(){var a=this.front;this.front=this.back;this.back=a;this.front.style.visibility="visible";this.back.style.visibility="hidden"}};function getCanvasDimensions(a){var b={x:0,y:0};b.width=a.width;b.height=a.height;if(a.offsetParent){do b.x+=a.offsetLeft,b.y+=a.offsetTop;while(a=a.offsetParent)}return b} -graph2D=function(a,b,f,g,h,l,n){this.style=n||{bgcolor:"#000"};this.sampleRes=512;this.scale=1;this.rangeMin=h;this.rangeMax=l;this.offsetY=0;this.canvas=document.createElement("canvas");this.canvas.setAttribute("width",f);this.canvas.setAttribute("height",g-32);this.canvas.setAttribute("style","position:absolute; margin: 0.0em; padding: 0.0em;");o=this;this.onclick=function(a){for(var b=getCanvasDimensions(o.canvas),f=a.clientX-b.x,a=a.clientY-b.y,b=0;bg.x+g.w)&&!(a>g.y+g.h)&&!(athis.sampleRes&&b.samples.shift();b.samples.push(b.stat.value)}};this.draw=function(){var a=this.canvas,b=this.ctx,f=a.width,g=a.height,h=this.rangeMin*this.scale,l=1/(this.rangeMax*this.scale-h),n=16+Math.floor(this.tracked.length/4+0.5)* -16;b.fillStyle=this.style.bgcolor;b.strokeStyle=this.style.bgcolor;b.fillRect(0,0,f,g-n);for(a=0;athis.maxSamples&&this.samples.shift();this.timeStampMS= -a;for(var f=0,g=-1E10,a=1E10,h=this.samples.length-1;h>=0;)f+=this.samples[h],g=Math.max(g,this.samples[h]),a=Math.min(a,this.samples[h]),h--;f=this.samples.length>0?f/this.samples.length:0;f=f>0?1E3/f:0;g=g>0?1E3/g:0;a=a>0?1E3/a:0;h=this.samples[this.samples.length-1];this.fpsRaw.value=(h>0?1E3/h:0).toFixed(2);this.fpsAvg.value=f.toFixed(2);this.fpsMin.value=g.toFixed(2);this.fpsMax.value=a.toFixed(2)}};objectManager=function(){this.guidCounter=0;this.objects=[];this.numObjects=0;this.freelist=[];this.reset=function(){this.objects=[];this.freelist=[];this.guidCounter=0};this.validHandle=function(a){return this.handleToIndex(a)!=-1};this.handleToIndex=function(a){var b=a>>16&65535;return this.objects[b]!=null&&a==this.objects[b].handle?b:-1};this.handleToObject=function(a){a=this.handleToIndex(a);return a!=-1?this.objects[a]:null};this.addObject=function(a){var b=this.objects.length;this.freelist.length> -0&&(b=this.freelist.pop());if(++this.guidCounter>=65535)this.guidCounter=1;a.handle=b<<16|++this.guidCounter;this.objects[b]=a;return a.handle};this.removeObject=function(a){a=this.handleToIndex(a);if(a!=-1){if(this.objects[a].onremove!=void 0)this.objects[a].onremove();this.objects[a]=null;this.freelist.push(a)}}};rdgeGlobalParameters={u_projMatrix:{type:"mat4",data:mat4.identity()},u_mvMatrix:{type:"mat4",data:mat4.identity()},u_invMvMatrix:{type:"mat4",data:mat4.identity()},u_normalMatrix:{type:"mat4",data:mat4.identity()},u_worldMatrix:{type:"mat4",data:mat4.identity()},u_viewMatrix:{type:"mat4",data:mat4.identity()},u_invViewMatrix:{type:"mat4",data:mat4.identity()},u_invWorldMatrix:{type:"mat4",data:mat4.identity()},u_inv_viewport_width:{type:"float",data:[1]},u_inv_viewport_height:{type:"float",data:[1]}, -u_lightPos:{type:"vec3",data:[-20,50,20]},u_lightDiff:{type:"vec4",data:[0.8,0.8,0.8,1]},u_lightAmb:{type:"vec4",data:[1,1,1,1]},rdge_lights:{u_light0Pos:{type:"vec3",data:[-20,50,20]},u_light0Diff:{type:"vec4",data:[0.8,0.8,0.8,1]},u_light0Amb:{type:"vec4",data:[8.0E-4,8.0E-4,8.0E-4,1]},u_light0Spec:{type:"vec4",data:[1,1,1,1]},u_light1Pos:{type:"vec3",data:[0,0,0]},u_light1Diff:{type:"vec4",data:[0,0,0,0]},u_light1Amb:{type:"vec4",data:[0.5,0.5,0.5,1]},u_light1Spec:{type:"vec4",data:[1,1,1,1]}, -u_light2Pos:{type:"vec3",data:[0,0,0]},u_light2Diff:{type:"vec4",data:[0,0,0,1]},u_light2Amb:{type:"vec4",data:[0.5,0.5,0.5,1]},u_light2Spec:{type:"vec4",data:[1,1,1,1]},u_light3Pos:{type:"vec3",data:[0,0,0]},u_light3Diff:{type:"vec4",data:[0.8,0.8,0.8,1]},u_light3Amb:{type:"vec4",data:[0.5,0.5,0.5,1]},u_light3Spec:{type:"vec4",data:[1,1,1,1]}},colMap:{type:"tex2d",data:"assets/images/white.png"},u_matAmbient:{type:"vec4",data:[1,1,1,1]},u_matDiffuse:{type:"vec4",data:[1,1,1,1]},u_matSpecular:{type:"vec4", -data:[1,1,1,1]},u_matShininess:{type:"float",data:[128]},u_matEmission:{type:"float",data:[0,0,0,1]},u_frustumFarZ:{type:"float",data:[1E3]},u_shadowLightWorld:{type:"mat4",data:mat4.identity()},u_shadowBiasMatrix:{type:"mat4",data:mat4.identity()},u_vShadowLight:{type:"mat4",data:mat4.identity()},u_shadowBPV:{type:"mat4",data:mat4.identity()},u_farZ:{type:"float",data:[1E3]},u_shadowLightFarZ:{type:"float",data:[1E3]},u_cameraFTR:{type:"vec3",data:[0,0,0]}};g_renderStats={};g_renderStats.numDrawCalls=new stat("rendering","numDrawCalls",0,null,!1);g_renderStats.numTriangles=new stat("rendering","numTriangles",0,null,!1);g_renderStats.numVerts=new stat("rendering","numVerts",0,null,!1);g_renderStats.numPasses=new stat("rendering","numPasses",0,null,!1);g_renderStats.reset=function(){g_renderStats.numTriangles.value=0;g_renderStats.numDrawCalls.value=0;g_renderStats.numVerts.value=0;g_renderStats.numPasses.value=0}; -rdgeConstants={colorBuffer:16384,depthBuffer:256,stencilBuffer:1024,BUFFER_STATIC:0,BUFFER_DYNAMIC:1,BUFFER_STREAM:2,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,VS_ELEMENT_FLOAT4:4,VS_ELEMENT_POS:3,VS_ELEMENT_NORM:3,VS_ELEMENT_FLOAT3:3,VS_ELEMENT_FLOAT2:2,VS_ELEMENT_UV:2,VS_ELEMENT_FLOAT:1,MAX_ELEM_TYPES:7,BUFFER_STATIC:35040,BUFFER_DYNAMIC:35044,BUFFER_STREAM:35048, -MAX_MATERIAL_LIGHTS:4,categoryEnumeration:{BACKGROUND:0,OPAQUE:1,TRANSPARENT:2,ADDITIVE:3,TRANSLUCENT:4,FOREGROUND:5,MAX_CAT:6},nodeType:{TRNODE:0,MESHNODE:1,MATNODE:2,LIGHTNODE:3}};rdgeId=0;function getBufferID(){return rdgeId++} -_renderer=function(a){try{this.ctx=a.getContext("experimental-webgl",{preserveDrawingBuffer:!0});if(!this.ctx)this.ctx=a.getContext("webgl",{preserveDrawingBuffer:!0});if(!this.ctx)this.ctx=a.getContext("webkit-3d",{preserveDrawingBuffer:!0});if(!this.ctx)this.ctx=a.getContext("moz-webgl",{preserveDrawingBuffer:!0})}catch(b){}if(!this.ctx)return window.console.log("Could not create GL context"),null;this.ctx.viewport(0,0,a.width,a.height);this.console="console"in window?window.console:{log:function(){}}; +var RDGE=RDGE||{};RDGE.vec2={};RDGE.vec2.string=function(a){return"{ "+a[0]+", "+a[1]+" }"};RDGE.vec2.verify=function(a){return void 0==a||void 0==a.length||2>a.length||"number"!=typeof a[0]||"number"!=typeof a[1]?!1:!0};RDGE.vec2.copy=function(a){return void 0==a.length?[a,a]:[a[0],a[1]]};RDGE.vec2.inplace_copy=function(a,b){a[0]=b[0];a[1]=b[1]};RDGE.vec2.zero=function(){return[0,0]};RDGE.vec2.up=function(){return[0,1]};RDGE.vec2.right=function(){return[1,0]}; +RDGE.vec2.add=function(a,b){return[a[0]+b[0],a[1]+b[1]]};RDGE.vec2.sub=function(a,b){return[a[0]-b[0],a[1]-b[1]]};RDGE.vec2.mul=function(a,b){return[a[0]*b[0],a[1]*b[1]]};RDGE.vec2.addMul=function(a,b,c){return void 0!=c.length&&2<=c.length?[a[0]+b[0]*c[0],a[1]+b[1]*c[1]]:[a[0]+b[0]*c,a[1]+b[1]*c]};RDGE.vec2.scale=function(a,b){return void 0!=b.length&&2<=b.length?[a[0]*b[0],a[1]*b[1]]:[a[0]*b,a[1]*b]};RDGE.vec2.negate=function(a){return[-a[0],-a[1]]}; +RDGE.vec2.normalize=function(a){var b=Math.sqrt(a[0]*a[0],a[1]*a[1]);return 1.0E-4a.length||"number"!=typeof a[0]||"number"!=typeof a[1]||"number"!=typeof a[2]?!1:!0};RDGE.vec3.inplace_copy=function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2]};RDGE.vec3.copy=function(a){return void 0==a.length?[a,a,a]:[a[0],a[1],a[2]]};RDGE.vec3.translation=function(a){return[a[12],a[13],a[14]]}; +RDGE.vec3.basisX=function(a){return[a[0],a[1],a[2]]};RDGE.vec3.basisY=function(a){return[a[4],a[5],a[6]]};RDGE.vec3.basisZ=function(a){return[a[8],a[9],a[10]]};RDGE.vec3.zero=function(){return[0,0,0]};RDGE.vec3.up=function(){return[0,1,0]};RDGE.vec3.forward=function(){return[0,0,1]};RDGE.vec3.right=function(){return[1,0,0]};RDGE.vec3.random=function(a,b){return[a[0]+(b[0]-a[0])*Math.random(),a[1]+(b[1]-a[1])*Math.random(),a[2]+(b[2]-a[2])*Math.random()]};RDGE.vec3.xy=function(a){return[a[0],a[1]]}; +RDGE.vec3.xz=function(a){return[a[0],a[2]]};RDGE.vec3.add=function(a,b){return[a[0]+b[0],a[1]+b[1],a[2]+b[2]]};RDGE.vec3.plusEqual=function(a,b){a[0]+=b[0];a[1]+=b[1];a[2]+=b[2]};RDGE.vec3.sub=function(a,b){return[a[0]-b[0],a[1]-b[1],a[2]-b[2]]};RDGE.vec3.mul=function(a,b){return[a[0]*b[0],a[1]*b[1],a[2]*b[2]]};RDGE.vec3.addMul=function(a,b,c){return void 0!=c.length&&3<=c.length?[a[0]+b[0]*c[0],a[1]+b[1]*c[1],a[2]+b[2]*c[2]]:[a[0]+b[0]*c,a[1]+b[1]*c,a[2]+b[2]*c]}; +RDGE.vec3.plusEqualMul=function(a,b,c){void 0!==c.length&&3<=c.length?(a[0]+=b[0]*c[0],a[1]+=b[1]*c[1],a[2]+=b[2]*c[2]):(a[0]+=b[0]*c,a[1]+=b[1]*c,a[2]+=b[2]*c)};RDGE.vec3.scale=function(a,b){return void 0!==b.length&&3<=b.length?[a[0]*b[0],a[1]*b[1],a[2]*b[2]]:[a[0]*b,a[1]*b,a[2]*b]};RDGE.vec3.inplace_scale=function(a,b){void 0!==b.length&&3<=b.length?(a[0]*=b[0],a[1]*=b[1],a[2]*=b[2]):(a[0]*=b,a[1]*=b,a[2]*=b)};RDGE.vec3.negate=function(a){return[-a[0],-a[1],-a[2]]}; +RDGE.vec3.inplace_negate=function(a){a[0]=-a[0];a[1]=-a[1];a[2]=-a[2]};RDGE.vec3.normalize=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return 1.0E-4a.length||"number"!=typeof a[0]||"number"!=typeof a[1]||"number"!=typeof a[2]||"number"!=typeof a[3]?!1:!0};RDGE.vec4.inplace_copy=function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3]};RDGE.vec4.copy=function(a){return void 0==a.length?[a,a,a,a]:3==a.length?[a[0],a[1],a[2],1]:[a[0],a[1],a[2],a[3]]}; +RDGE.vec4.zero=function(){return[0,0,0,0]};RDGE.vec4.identity=function(){return[0,0,0,1]};RDGE.vec4.up=function(){return[0,1,0,0]};RDGE.vec4.forward=function(){return[0,0,1,0]};RDGE.vec4.right=function(){return[1,0,0,0]};RDGE.vec4.random=function(a,b){return[a[0]+(b[0]-a[0])*Math.random(),a[1]+(b[1]-a[1])*Math.random(),a[2]+(b[2]-a[2])*Math.random(),a[3]+(b[3]-a[3])*Math.random()]};RDGE.vec4.add=function(a,b){return[a[0]+b[0],a[1]+b[1],a[2]+b[2],a[3]+b[3]]}; +RDGE.vec4.sub=function(a,b){return[a[0]-b[0],a[1]-b[1],a[2]-b[2],a[3]-b[3]]};RDGE.vec4.mul=function(a,b){return[a[0]*b[0],a[1]*b[1],a[2]*b[2],a[3]*b[3]]};RDGE.vec4.addMul=function(a,b,c){return void 0!=c.length&&4<=c.length?[a[0]+b[0]*c[0],a[1]+b[1]*c[1],a[2]+b[2]*c[2],a[3]+b[3]*c[3]]:[a[0]+b[0]*c,a[1]+b[1]*c,a[2]+b[2]*c,a[3]+b[3]*c]};RDGE.vec4.scale=function(a,b){return void 0!=b.length&&4<=b.length?[a[0]*b[0],a[1]*b[1],a[2]*b[2],a[3]*b[3]]:[a[0]*b,a[1]*b,a[2]*b,a[3]*b]}; +RDGE.vec4.negate=function(a){return[-a[0],-a[1],-a[2],-a[3]]};RDGE.vec4.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]};RDGE.vec4.normalize=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]);return 1.0E-4a.length)return!1;for(var b=16;b--;)if("number"!=typeof a[b])return!1;return!0};RDGE.mat4.copy=function(a){return[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]]};RDGE.mat4.inplace_copy=function(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];a[3]=b[3];a[4]=b[4];a[5]=b[5];a[6]=b[6];a[7]=b[7];a[8]=b[8];a[9]=b[9];a[10]=b[10];a[11]=b[11];a[12]=b[12];a[13]=b[13];a[14]=b[14];a[15]=b[15]}; +RDGE.mat4.identity=function(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]};RDGE.mat4.zero=function(){return[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]};RDGE.mat4.basis=function(a,b,c,d){return null==d||void 0==d?[a[0],a[1],a[2],0,b[0],b[1],b[2],0,c[0],c[1],c[2],0,0,0,0,1]:[a[0],a[1],a[2],4==a.length?a[3]:0,b[0],b[1],b[2],4==b.length?b[3]:0,c[0],c[1],c[2],4==c.length?c[3]:0,d[0],d[1],d[2],4==d.length?d[3]:1]}; +RDGE.mat4.angleAxis=function(a,b){var a=a*(Math.PI/180),a=a/2,c=Math.sin(a),d=Math.cos(a),f=c*c;RDGE.vec3.normalize(b);0>=RDGE.vec3.lengthSq(b)&&(b=[0,0,0,1]);var g=RDGE.mat4.identity();if(1==b[0]&&0==b[1]&&0==b[2])g[5]=1-2*f,g[6]=2*c*d,g[9]=-2*c*d,g[10]=1-2*f;else if(0==b[0]&&1==b[1]&&0==b[2])g[0]=1-2*f,g[2]=-2*c*d,g[8]=2*c*d,g[10]=1-2*f;else if(0==b[0]&&0==b[1]&&1==b[2])g[0]=1-2*f,g[1]=2*c*d,g[4]=-2*c*d,g[5]=1-2*f;else{var h=b[0],l=b[1],m=b[2],n=h*h,p=l*l,o=m*m;g[0]=1-2*(p+o)*f;g[1]=2*(h*l*f+m* +c*d);g[2]=2*(h*m*f-l*c*d);g[4]=2*(l*h*f-m*c*d);g[5]=1-2*(o+n)*f;g[6]=2*(l*m*f+h*c*d);g[8]=2*(m*h*f+l*c*d);g[9]=2*(m*l*f-h*c*d);g[10]=1-2*(n+p)*f}return g};RDGE.mat4.lookAt=function(a,b,c){b=RDGE.vec3.normalize(RDGE.vec3.sub(a,b));1.0E-4>RDGE.vec3.length(b)&&(b=[0,0,1]);var c=RDGE.vec3.normalize(RDGE.vec3.cross(c,b)),d=RDGE.vec3.normalize(RDGE.vec3.cross(b,c)),f=RDGE.mat4.identity();RDGE.mat4.setRow(f,0,c);RDGE.mat4.setRow(f,1,d);RDGE.mat4.setRow(f,2,b);RDGE.mat4.setRow(f,3,a);return f}; +RDGE.mat4.frustum=function(a,b,c,d,f,g){var h=b-a,l=d-c,m=g-f,n=2*f,p=RDGE.mat4.zero();p[0]=n/h;p[5]=n/l;p[8]=(b+a)/h;p[9]=(d+c)/l;p[10]=-(g+f)/m;p[11]=-1;p[14]=-(n*g)/m;return p};RDGE.mat4.perspective=function(a,b,c,d){var a=Math.tan(a*Math.PI/360)*c,f=-a;return RDGE.mat4.frustum(b*f,b*a,f,a,c,d)};RDGE.mat4.orthographic=function(a,b,c,d,f,g){var h=(a+b)/(a-b),l=(c+d)/(c-d),m=(g+f)/(g-f),n=RDGE.mat4.zero();n[0]=2/(a-b);n[5]=2/(c-d);n[10]=-2/(g-f);n[12]=h;n[13]=l;n[14]=m;n[15]=1;return n}; +RDGE.mat4.mul=function(a,b){var c=a[0],d=a[1],f=a[2],g=a[3],h=a[4],l=a[5],m=a[6],n=a[7],p=a[8],o=a[9],q=a[10],r=a[11],u=a[12],s=a[13],w=a[14],v=a[15],x=b[0],z=b[1],A=b[2],y=b[3],B=b[4],C=b[5],D=b[6],E=b[7],F=b[8],G=b[9],H=b[10],I=b[11],J=b[12],K=b[13],L=b[14],M=b[15];return[c*x+d*B+f*F+g*J,c*z+d*C+f*G+g*K,c*A+d*D+f*H+g*L,c*y+d*E+f*I+g*M,h*x+l*B+m*F+n*J,h*z+l*C+m*G+n*K,h*A+l*D+m*H+n*L,h*y+l*E+m*I+n*M,p*x+o*B+q*F+r*J,p*z+o*C+q*G+r*K,p*A+o*D+q*H+r*L,p*y+o*E+q*I+r*M,u*x+s*B+w*F+v*J,u*z+s*C+w*G+v*K,u* +A+s*D+w*H+v*L,u*y+s*E+w*I+v*M]};RDGE.mat4.mul4x3=function(a,b){var c=a[0],d=a[1],f=a[2],g=a[4],h=a[5],l=a[6],m=a[8],n=a[9],p=a[10],o=a[12],q=a[13],r=a[14],u=b[0],s=b[1],w=b[2],v=b[4],x=b[5],z=b[6],A=b[8],y=b[9],B=b[10];return[c*u+d*v+f*A,c*s+d*x+f*y,c*w+d*z+f*B,0,g*u+h*v+l*A,g*s+h*x+l*y,g*w+h*z+l*B,0,m*u+n*v+p*A,m*s+n*x+p*y,m*w+n*z+p*B,0,o*u+q*v+r*A+b[12],o*s+q*x+r*y+b[13],o*w+q*z+r*B+b[14],1]};RDGE.mat4._det2x2=function(a,b,c,d){return a*d-b*c}; +RDGE.mat4._det3x3=function(a,b,c,d,f,g,h,l,m){return a*RDGE.mat4._det2x2(f,g,l,m)-d*RDGE.mat4._det2x2(b,c,l,m)+h*RDGE.mat4._det2x2(b,c,f,g)};RDGE.mat4._det4x4=function(a){var b=a[1],c=a[2],d=a[3],f=a[4],g=a[5],h=a[6],l=a[7],m=a[8],n=a[9],p=a[10],o=a[11],q=a[12],r=a[13],u=a[14],s=a[15];return a[0]*RDGE.mat4._det3x3(g,n,r,h,p,u,l,o,s)-b*RDGE.mat4._det3x3(f,m,q,h,p,u,l,o,s)+c*RDGE.mat4._det3x3(f,m,q,g,n,r,l,o,s)-d*RDGE.mat4._det3x3(f,m,q,g,n,r,h,p,u)}; +RDGE.mat4._adjoint=function(a){var b=a[0],c=a[1],d=a[2],f=a[3],g=a[4],h=a[5],l=a[6],m=a[7],n=a[8],p=a[9],o=a[10],q=a[11],r=a[12],u=a[13],s=a[14],a=a[15];return[RDGE.mat4._det3x3(h,p,u,l,o,s,m,q,a),-RDGE.mat4._det3x3(c,p,u,d,o,s,f,q,a),RDGE.mat4._det3x3(c,h,u,d,l,s,f,m,a),-RDGE.mat4._det3x3(c,h,p,d,l,o,f,m,q),-RDGE.mat4._det3x3(g,n,r,l,o,s,m,q,a),RDGE.mat4._det3x3(b,n,r,d,o,s,f,q,a),-RDGE.mat4._det3x3(b,g,r,d,l,s,f,m,a),RDGE.mat4._det3x3(b,g,n,d,l,o,f,m,q),RDGE.mat4._det3x3(g,n,r,h,p,u,m,q,a),-RDGE.mat4._det3x3(b, +n,r,c,p,u,f,q,a),RDGE.mat4._det3x3(b,g,r,c,h,u,f,m,a),-RDGE.mat4._det3x3(b,g,n,c,h,p,f,m,q),-RDGE.mat4._det3x3(g,n,r,h,p,u,l,o,s),RDGE.mat4._det3x3(b,n,r,c,p,u,d,o,s),-RDGE.mat4._det3x3(b,g,r,c,h,u,d,l,s),RDGE.mat4._det3x3(b,g,n,c,h,p,d,l,o)]};RDGE.mat4.inverse=function(a){var b=RDGE.mat4._det4x4(a);if(1.0E-8>Math.abs(b))return null;a=RDGE.mat4._adjoint(a);b=1/b;return[a[0]*b,a[1]*b,a[2]*b,a[3]*b,a[4]*b,a[5]*b,a[6]*b,a[7]*b,a[8]*b,a[9]*b,a[10]*b,a[11]*b,a[12]*b,a[13]*b,a[14]*b,a[15]*b]}; +RDGE.mat4.rigidInverse=function(a){out=RDGE.mat4.transpose3x3(a);out[12]=-RDGE.vec3.dot([out[0],out[4],out[8]],[a[12],a[13],a[14]]);out[13]=-RDGE.vec3.dot([out[1],out[5],out[9]],[a[12],a[13],a[14]]);out[14]=-RDGE.vec3.dot([out[2],out[6],out[10]],[a[12],a[13],a[14]]);return out};RDGE.mat4.transpose=function(a){return[a[0],a[4],a[8],a[12],a[1],a[5],a[9],a[13],a[2],a[6],a[10],a[14],a[3],a[7],a[11],a[15]]}; +RDGE.mat4.transpose3x3=function(a){return[a[0],a[4],a[8],a[3],a[1],a[5],a[9],a[7],a[2],a[6],a[10],a[11],a[12],a[13],a[14],a[15]]};RDGE.mat4.transformPoint=function(a,b){var c=b[0],d=b[1],f=b[2],g=4<=b.length?b[3]:1;return[a[0]*c+a[4]*d+a[8]*f+a[12]*g,a[1]*c+a[5]*d+a[9]*f+a[13]*g,a[2]*c+a[6]*d+a[10]*f+a[14]*g,a[3]*c+a[7]*d+a[11]*f+a[15]*g]}; +RDGE.mat4.transformVector=function(a,b){var a=RDGE.mat4.inverse(a),c=b[0],d=b[1],f=b[2],g=4<=b.length?b[3]:0;return[a[0]*c+a[1]*d+a[2]*f+a[3]*g,a[4]*c+a[5]*d+a[6]*f+a[7]*g,a[8]*c+a[9]*d+a[10]*f+a[11]*g,a[12]*c+a[13]*d+a[14]*f+a[15]*g]};RDGE.mat4.transformPoint4x3=function(a,b){var c=b[0],d=b[1],f=b[2];return[a[0]*c+a[4]*d+a[8]*f+a[12],a[1]*c+a[5]*d+a[9]*f+a[13],a[2]*c+a[6]*d+a[10]*f+a[14],1]}; +RDGE.mat4.transformVector4x3=function(a,b){var a=RDGE.mat4.inverse(a),c=b[0],d=b[1],f=b[2];return[a[0]*c+a[1]*d+a[2]*f,a[4]*c+a[5]*d+a[6]*f,a[8]*c+a[9]*d+a[10]*f,0]};RDGE.mat4.getRow=function(a,b){b*=4;return[a[b],a[b+1],a[b+2],a[b+3]]};RDGE.mat4.getCol=function(a,b){return[a[b],a[b+4],a[b+8],a[b+12]]};RDGE.mat4.setRow=function(a,b,c){b*=4;a[b+0]=c[0];a[b+1]=c[1];a[b+2]=c[2];4<=c.length&&(a[b+3]=c[3]);return a}; +RDGE.mat4.setCol=function(a,b,c){a[b+0]=c[0];a[b+4]=c[1];a[b+8]=c[2];4<=c.length&&(a[b+12]=c[3]);return a};RDGE.mat4.rotate=function(a,b,c){return RDGE.mat4.mul(a,RDGE.mat4.angleAxis(b,c))};RDGE.mat4.rotateX=function(a,b){return RDGE.mat4.mul(a,RDGE.mat4.angleAxis(b,RDGE.vec3.basisX(a)))};RDGE.mat4.rotateY=function(a,b){return RDGE.mat4.mul(a,RDGE.mat4.angleAxis(b,RDGE.vec3.basisY(a)))};RDGE.mat4.rotateZ=function(a,b){return RDGE.mat4.mul(a,RDGE.mat4.angleAxis(b,RDGE.vec3.basisZ(a)))}; +RDGE.mat4.scale=function(a,b){var c=RDGE.mat4.identity();void 0==b.length&&(b=[b,b,b]);c[0]=b[0];c[5]=b[1];c[10]=b[2];return RDGE.mat4.mul(a,c)};RDGE.mat4.scaleX=function(a,b){return RDGE.mat4.scale(a,[b,1,1])};RDGE.mat4.scaleY=function(a,b){return RDGE.mat4.scale(a,[1,b,1])};RDGE.mat4.scaleZ=function(a,b){return RDGE.mat4.scale(a,[1,1,b])};RDGE.mat4.translate=function(a,b){matT=RDGE.mat4.identity();matT[12]=b[0];matT[13]=b[1];matT[14]=b[2];return RDGE.mat4.mul(a,matT)}; +RDGE.mat4.translateX=function(a,b){return RDGE.mat4.translate(a,[b,0,0])};RDGE.mat4.translateY=function(a,b){return RDGE.mat4.translate(a,[0,b,0])};RDGE.mat4.translateZ=function(a,b){return RDGE.mat4.translate(a,[0,0,b])};RDGE=RDGE||{};RDGE.quat={};RDGE.quat.string=function(a){return"{ "+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+" }"};RDGE.quat.verify=function(a){return void 0==a||void 0==a.length||4>a.length||"number"!=typeof a[0]||"number"!=typeof a[1]||"number"!=typeof a[2]||"number"!=typeof a[3]?!1:!0};RDGE.quat.identity=function(){return[0,0,0,1]};RDGE.quat.add=function(a,b){return[a[0]+b[0],a[1]+b[1],a[2]+b[2],a[3]+b[3]]};RDGE.quat.sub=function(a,b){return[a[0]-b[0],a[1]-b[1],a[2]-b[2],a[3]-b[3]]}; +RDGE.quat.mul=function(a,b){return[a[3]*b[3]-a[0]*b[0]-a[1]*b[1]-a[2]*b[2],a[3]*b[0]+a[0]*b[3]+a[1]*b[2]-a[2]*b[1],a[3]*b[1]-a[0]*b[2]+a[1]*b[3]+a[2]*b[0],a[3]*b[2]+a[0]*b[1]-a[1]*b[0]+a[2]*b[3]]};RDGE.quat.addMul=function(a,b,c){return void 0!=c.length&&4<=c.length?[a[0]+b[0]*c[0],a[1]+b[1]*c[1],a[2]+b[2]*c[2],a[3]+b[3]*c[3]]:[a[0]+b[0]*c,a[1]+b[1]*c,a[2]+b[2]*c,a[3]+b[3]*c]}; +RDGE.quat.scale=function(a,b){return void 0!=b.length&&4<=b.length?[a[0]*b[0],a[1]*a[1],a[2]*b[2],a[3]*b[3]]:[a[0]*b,a[1]*b,a[2]*b,a[3]*b]};RDGE.quat.lengthSq=function(a){return a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]};RDGE.quat.length=function(a){return Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3])};RDGE.quat.normalize=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]+a[3]*a[3]);return 1.0E-4f)return a;var d=0>d?-1:1,g=Math.asin(f),h=1/f,f=Math.sin((1-c)*g)*h,c=Math.sin(c*g)*h*d;RDGE.quat.scale(a,f);RDGE.quat.scale(b,c);return RDGE.quat.normalize(RDGE.quat.add(a,b))}; +RDGE.quat.toMatrix=function(a){var b=2*a[0],c=2*a[1],d=2*a[2],f=b*a[3],g=c*a[3],h=d*a[3],b=b*a[0],l=c*a[0],m=d*a[0],c=c*a[1],n=d*a[1],a=d*a[2];return[1-(c+a),l+h,m-g,0,l-h,1-(b+a),n+f,0,m+g,n-f,1-(b+c),0,0,0,0,1]};RDGE=RDGE||{}; +RDGE.objectManager=function(){this.guidCounter=0;this.objects=[];this.numObjects=0;this.freelist=[];this.reset=function(){this.objects=[];this.freelist=[];this.guidCounter=0};this.validHandle=function(a){return-1!=this.handleToIndex(a)};this.handleToIndex=function(a){var b=a>>16&65535;return null!=this.objects[b]&&a==this.objects[b].handle?b:-1};this.handleToObject=function(a){a=this.handleToIndex(a);return-1!=a?this.objects[a]:null};this.addObject=function(a){var b=this.objects.length;0