aboutsummaryrefslogtreecommitdiff
path: root/js/helper-classes/RDGE
diff options
context:
space:
mode:
Diffstat (limited to 'js/helper-classes/RDGE')
-rwxr-xr-xjs/helper-classes/RDGE/rdge-compiled.js28
-rw-r--r--js/helper-classes/RDGE/runtime/CanvasDataManager.js98
-rw-r--r--js/helper-classes/RDGE/runtime/CanvasLoader.js72
-rw-r--r--js/helper-classes/RDGE/src/tools/rdge-compiled.js28
4 files changed, 124 insertions, 102 deletions
diff --git a/js/helper-classes/RDGE/rdge-compiled.js b/js/helper-classes/RDGE/rdge-compiled.js
index 4301200f..a211d17f 100755
--- a/js/helper-classes/RDGE/rdge-compiled.js
+++ b/js/helper-classes/RDGE/rdge-compiled.js
@@ -45,9 +45,8 @@ b.fillText(o.label,n+10,h+4);b.translate([-0.5,-0.5])};var o=this;setInterval(fu
45a;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> 45a;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>
460&&(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]}, 460&&(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]},
47u_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]}, 47u_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]},
48u_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"},envMap:{type:"tex2d",data:null},normalMap:{type:"tex2d",data:null},glowMap:{type:"tex2d",data:"assets/images/black.png"}, 48u_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",
49u_shadowDepthMap:{type:"tex2d",data:null},u_depthMap:{type:"tex2d",data:null},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", 49data:[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};
50data: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};
51rdgeConstants={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, 50rdgeConstants={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,
52MAX_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++} 51MAX_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++}
53_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(){}}; 52_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(){}};
@@ -251,11 +250,10 @@ function verifyLightNode(a){if(a.lightNodeTemplate==void 0)a.lightNodeTemplate=n
251transformNodeTemplate=function(a){if(!a.children)a.children=[];if(!a.local)a.local=mat4.identity();if(!a.world)a.world=mat4.identity();if(!a.id)a.id=nodeIdGen.getId();if(!a.name)a.name="xfrmNode"+a.id;if(!a.parent)a.parent=null;if(!a.meshes)a.meshes=[];if(!a.nodeType)a.nodeType=rdgeConstants.nodeType.TRNODE;a.attachMaterial=function(a){verifyMaterialNode(a);this.materialNode=a};a.attachMeshNode=function(b,f){typeof b=="string"&&(b=createMeshNode(b,f));if(a.materialNode==void 0)a.materialNode=createMaterialNode(a.name+ 250transformNodeTemplate=function(a){if(!a.children)a.children=[];if(!a.local)a.local=mat4.identity();if(!a.world)a.world=mat4.identity();if(!a.id)a.id=nodeIdGen.getId();if(!a.name)a.name="xfrmNode"+a.id;if(!a.parent)a.parent=null;if(!a.meshes)a.meshes=[];if(!a.nodeType)a.nodeType=rdgeConstants.nodeType.TRNODE;a.attachMaterial=function(a){verifyMaterialNode(a);this.materialNode=a};a.attachMeshNode=function(b,f){typeof b=="string"&&(b=createMeshNode(b,f));if(a.materialNode==void 0)a.materialNode=createMaterialNode(a.name+
252"|defMaterial");a.meshes.push({mesh:{name:b.mesh.attribs.name,id:b.mesh.attribs.id}})};a.insertAsChild=function(a){if(this!=a)verifyTransformNode(a),a.parent=this,this.children.push({transformNode:a})};a.insertAsParent=function(a){if(this!=a){verifyTransformNode(a);if(this.parent){for(var f=this.parent.children.length,g=0;g<f;++g)if(this.parent.children[g].transformNode!=void 0&&(tr=this.parent.children[g].transformNode,tr.id==this.id)){this.parent.children.splice(g,1);break}a.parent=this.parent; 251"|defMaterial");a.meshes.push({mesh:{name:b.mesh.attribs.name,id:b.mesh.attribs.id}})};a.insertAsChild=function(a){if(this!=a)verifyTransformNode(a),a.parent=this,this.children.push({transformNode:a})};a.insertAsParent=function(a){if(this!=a){verifyTransformNode(a);if(this.parent){for(var f=this.parent.children.length,g=0;g<f;++g)if(this.parent.children[g].transformNode!=void 0&&(tr=this.parent.children[g].transformNode,tr.id==this.id)){this.parent.children.splice(g,1);break}a.parent=this.parent;
253this.parent.children.push({transformNode:a});this.parent=a}a.children.push({transformNode:this})}}}; 252this.parent.children.push({transformNode:a});this.parent=a}a.children.push({transformNode:this})}}};
254materialNodeTemplate=function(a){TEX_DIF=0;TEX_SPEC=1;TEX_NORM=2;TEX_GLOW=3;if(!a.nodeType)a.nodeType=rdgeConstants.nodeType.MATNODE;MATERIAL_MAX_LIGHTS=rdgeConstants.MAX_MATERIAL_LIGHTS;if(!a.lightChannel)a.lightChannel=[null,null,null,null];if(!a.sortCategory)a.sortCategory=rdgeConstants.categoryEnumeration.OPAQUE;if(!a.id)a.id=nodeIdGen.getId();if(!a.name)a.name="matNode"+a.id;if(!a.textureList){var b=g_Engine.getContext().renderer;a.textureList=[{name:"colMap",handle:b.getTextureByName("assets/images/white"), 253materialNodeTemplate=function(a){TEX_DIF=0;TEX_SPEC=1;TEX_NORM=2;TEX_GLOW=3;if(!a.nodeType)a.nodeType=rdgeConstants.nodeType.MATNODE;MATERIAL_MAX_LIGHTS=rdgeConstants.MAX_MATERIAL_LIGHTS;if(!a.lightChannel)a.lightChannel=[null,null,null,null];if(!a.sortCategory)a.sortCategory=rdgeConstants.categoryEnumeration.OPAQUE;if(!a.id)a.id=nodeIdGen.getId();if(!a.name)a.name="matNode"+a.id;if(!a.textureList)g_Engine.getContext(),a.textureList=[];if(!a.uniforms)a.uniforms=[];a.setTexture=function(a,f){var g=
255unit:TEX_DIF,type:UNIFORMTYPE.TEXTURE2D},{name:"envMap",handle:b.getTextureByName("assets/images/material_paint"),unit:TEX_SPEC,type:UNIFORMTYPE.TEXTURE2D},{name:"normalMap",handle:b.getTextureByName("assets/images/blue"),unit:TEX_NORM,type:UNIFORMTYPE.TEXTURE2D},{name:"glowMap",handle:b.getTextureByName("assets/images/black"),unit:TEX_GLOW,type:UNIFORMTYPE.TEXTURE2D}]}if(!a.uniforms)a.uniforms=[];a.setTexture=function(a,b){var h=g_Engine.getContext().renderer;this.textureList[a].handle=h.getTextureByName("assets/images/"+ 254g_Engine.getContext().renderer;this.textureList[a].handle=g.getTextureByName("assets/images/"+f);this.textureList[a].unit=a;this.textureList[a].type=UNIFORMTYPE.TEXTURE2D};a.setDiffuseTexture=function(a){this.setTexture(TEX_DIF,a)};a.setSpecTexture=function(a){this.setTexture(TEX_SPEC,a)};a.setNormalTexture=function(a){this.setTexture(TEX_NORM,a)};a.setGlowTexture=function(a){this.setTexture(TEX_GLOW,a)};a.setUniform=function(a,f){for(var g=this.uniforms.length,h=0;h<g;++h)if(this.uniforms[h].name==
256b);this.textureList[a].unit=a;this.textureList[a].type=UNIFORMTYPE.TEXTURE2D};a.setDiffuseTexture=function(a){this.setTexture(TEX_DIF,a)};a.setSpecTexture=function(a){this.setTexture(TEX_SPEC,a)};a.setNormalTexture=function(a){this.setTexture(TEX_NORM,a)};a.setGlowTexture=function(a){this.setTexture(TEX_GLOW,a)};a.setUniform=function(a,b){for(var h=this.uniforms.length,l=0;l<h;++l)if(this.uniforms[l].name==a){this.uniforms[l].value=b;return}window.console.log("Could not find uniform: "+a)};a.setShader= 255a){this.uniforms[h].value=f;return}window.console.log("Could not find uniform: "+a)};a.setShader=function(a){this.shaderProgram=a};a.setSortCategory=function(b){a.sortCategory=b};a.enableLightChannel=function(b,f){verifyLightNode(f);if(typeof b=="object")for(var g=b.length,h=f.length!=void 0?f.length:0,l=0;l<g;++l)a.lightChannel[b]=h>0?f[Math.min(l,h-1)]:f;else b<MATERIAL_MAX_LIGHTS&&(a.lightChannel[b]=f)};a.disableLightChannel=function(b){if(typeof b!="object")for(var f=b.length,g=0;g<f;++g)MATERIAL_MAX_LIGHTS&&
257function(a){this.shaderProgram=a};a.setSortCategory=function(b){a.sortCategory=b};a.enableLightChannel=function(b,g){verifyLightNode(g);if(typeof b=="object")for(var h=b.length,l=g.length!=void 0?g.length:0,n=0;n<h;++n)a.lightChannel[b]=l>0?g[Math.min(n,l-1)]:g;else b<MATERIAL_MAX_LIGHTS&&(a.lightChannel[b]=g)};a.disableLightChannel=function(b){if(typeof b!="object")for(var g=b.length,h=0;h<g;++h)MATERIAL_MAX_LIGHTS&&(a.lightChannel[b[h]]=null);else b<MATERIAL_MAX_LIGHTS&&(a.lightChannel[b]=null)}; 256(a.lightChannel[b[g]]=null);else b<MATERIAL_MAX_LIGHTS&&(a.lightChannel[b]=null)};a.disableAllLights=function(){for(var b=0;b<MATERIAL_MAX_LIGHTS;++b)a.lightChannel[b]=null};a.toJSON=function(){var a={jsonExportName:"materialNode"},f;for(f in this)if(a[f]=this[f],f==="textureList")for(var g=a[f],h=0,l=g.length;h<l;++h)g[h].handle.image=g[h].handle.lookUpName;else f==="shaderProgram"&&typeof a[f]!="string"&&(a[f]=a[f].exportShader());return a}};
258a.disableAllLights=function(){for(var b=0;b<MATERIAL_MAX_LIGHTS;++b)a.lightChannel[b]=null};a.toJSON=function(){var a={jsonExportName:"materialNode"},b;for(b in this)if(a[b]=this[b],b==="textureList")for(var h=a[b],l=0,n=h.length;l<n;++l)h[l].handle.image=h[l].handle.lookUpName;else b==="shaderProgram"&&typeof a[b]!="string"&&(a[b]=a[b].exportShader());return a}};
259meshNodeTemplate=function(a,b,f){b.built||renderer.createPrimitive(b);if(!a.nodeType)a.nodeType=rdgeConstants.nodeType.MESHNODE;if(!a.attribs){var g=nodeIdGen.getId();a.attribs={id:g,indexCount:b.indexCount,name:f,vertCount:b.posCount};a.name=f}if(!a.bbox)a.bbox=new box;a.data=null;a.primitive=b;f=b.posCount;if(f>0){b=b.positions;for(g=0;g<f-2;)a.bbox.addVec3([b[g+0],b[g+1],b[g+2]]),g+=3}else window.console.error("mesh "+a.attribs.name+": bounding volume not created")}; 257meshNodeTemplate=function(a,b,f){b.built||renderer.createPrimitive(b);if(!a.nodeType)a.nodeType=rdgeConstants.nodeType.MESHNODE;if(!a.attribs){var g=nodeIdGen.getId();a.attribs={id:g,indexCount:b.indexCount,name:f,vertCount:b.posCount};a.name=f}if(!a.bbox)a.bbox=new box;a.data=null;a.primitive=b;f=b.posCount;if(f>0){b=b.positions;for(g=0;g<f-2;)a.bbox.addVec3([b[g+0],b[g+1],b[g+2]]),g+=3}else window.console.error("mesh "+a.attribs.name+": bounding volume not created")};
260lightNodeTemplate=function(a){if(!a.nodeType)a.nodeType=rdgeConstants.nodeType.LIGHTNODE;if(!a.id)a.id=nodeIdGen.getId();if(!a.name)a.name="light_"+a.id;if(!a.typeName)a.typeName="dir_light";if(!a.castShadow)a.castShadow=!1;if(!a.depthMapBias)a.depthMapBias=0.0179;if(!a.depthMapSize)a.depthMapSize=1024;if(!a.coneAngle)a.coneAngle=0.707;if(!a.penumbraAngle)a.coneAngle=0;if(!a.dropOff)a.coneAngle=0.025;if(!a.color)a.color=[1,1,1,1];if(!a.dir)a.dir=[1,-1,1];if(!a.links)a.links=[];if(!a.position)a.position= 258lightNodeTemplate=function(a){if(!a.nodeType)a.nodeType=rdgeConstants.nodeType.LIGHTNODE;if(!a.id)a.id=nodeIdGen.getId();if(!a.name)a.name="light_"+a.id;if(!a.typeName)a.typeName="dir_light";if(!a.castShadow)a.castShadow=!1;if(!a.depthMapBias)a.depthMapBias=0.0179;if(!a.depthMapSize)a.depthMapSize=1024;if(!a.coneAngle)a.coneAngle=0.707;if(!a.penumbraAngle)a.coneAngle=0;if(!a.dropOff)a.coneAngle=0.025;if(!a.color)a.color=[1,1,1,1];if(!a.dir)a.dir=[1,-1,1];if(!a.links)a.links=[];if(!a.position)a.position=
261[0,0,0];if(!a.lightDiffuse)a.lightDiffuse=[1,1,1,1];if(!a.lightAmbient)a.lightAmbient=[0.5,0.5,0.5,1];if(!a.lightSpecular)a.lightSpecular=[1,1,1,1];a.setPosition=function(a){for(var f=0;f<3;f++)this.position[f]=a[f]};a.setDiffuseColor=function(a){for(var f=0;f<4;f++)this.lightDiffuse[f]=a[f]};a.setAmbientColor=function(a){for(var f=0;f<4;f++)this.lightAmbient[f]=a[f]};a.setSpecularColor=function(a){for(var f=0;f<4;f++)this.lightSpecular[f]=a[f]}};var g_drawCount=0;g_enableFlyCam=!1;g_sceneStats={};g_sceneStats.nodesVisible=new stat("scenegraph","nodesVisible",0,null,!1);g_sceneStats.nodesCulled=new stat("scenegraph","nodesCulled",0,null,!1);g_sceneStats.nodesVisited=new stat("scenegraph","nodesVisited",0,null,!1);g_sceneStats.reset=function(){g_sceneStats.nodesVisible.value=0;g_sceneStats.nodesVisited.value=0;g_sceneStats.nodesCulled.value=0}; 259[0,0,0];if(!a.lightDiffuse)a.lightDiffuse=[1,1,1,1];if(!a.lightAmbient)a.lightAmbient=[0.5,0.5,0.5,1];if(!a.lightSpecular)a.lightSpecular=[1,1,1,1];a.setPosition=function(a){for(var f=0;f<3;f++)this.position[f]=a[f]};a.setDiffuseColor=function(a){for(var f=0;f<4;f++)this.lightDiffuse[f]=a[f]};a.setAmbientColor=function(a){for(var f=0;f<4;f++)this.lightAmbient[f]=a[f]};a.setSpecularColor=function(a){for(var f=0;f<4;f++)this.lightSpecular[f]=a[f]}};var g_drawCount=0;g_enableFlyCam=!1;g_sceneStats={};g_sceneStats.nodesVisible=new stat("scenegraph","nodesVisible",0,null,!1);g_sceneStats.nodesCulled=new stat("scenegraph","nodesCulled",0,null,!1);g_sceneStats.nodesVisited=new stat("scenegraph","nodesVisited",0,null,!1);g_sceneStats.reset=function(){g_sceneStats.nodesVisible.value=0;g_sceneStats.nodesVisited.value=0;g_sceneStats.nodesCulled.value=0};
@@ -366,8 +364,8 @@ sceneRequestDef=function(a,b){this.name=b;this.addr=a;this.requestComplete=this.
366function validateUserState(a){if(!a.init)a.init=function(){};if(!a.update)a.update=function(a){var f=g_Engine.getContext().currentScene,f=g_Engine.getScene(f);f!=null&&f.update(a)};if(!a.draw)a.draw=function(){var a=g_Engine.getContext().currentScene,a=g_Engine.getScene(a);a!=null&&a.render()};if(!a.resize)a.resize=function(){};if(!a.shutdown)a.shutdown=function(){};if(!a.onComplete)a.onComplete=function(){}} 364function validateUserState(a){if(!a.init)a.init=function(){};if(!a.update)a.update=function(a){var f=g_Engine.getContext().currentScene,f=g_Engine.getScene(f);f!=null&&f.update(a)};if(!a.draw)a.draw=function(){var a=g_Engine.getContext().currentScene,a=g_Engine.getScene(a);a!=null&&a.render()};if(!a.resize)a.resize=function(){};if(!a.shutdown)a.shutdown=function(){};if(!a.onComplete)a.onComplete=function(){}}
367function RDGEStart(a){var b=a;typeof a==="string"&&(b=document.getElementById(a));if(b)g_Engine.registerCanvas(b),b.task=new RDGETask(b,!0),g_shaderMan||(g_shaderMan=new ShaderManager),g_meshMan||(g_meshMan=new MeshManager),g_Engine.initializeComplete||g_Engine.init()}function RDGEStop(){RDGEShutdown!=void 0&&RDGEShutdown()}function IRuntime(){this.Shutdown=this.Draw=this.Update=this.Resize=this.ReInit=this.init=null}g_poolList=[]; 365function RDGEStart(a){var b=a;typeof a==="string"&&(b=document.getElementById(a));if(b)g_Engine.registerCanvas(b),b.task=new RDGETask(b,!0),g_shaderMan||(g_shaderMan=new ShaderManager),g_meshMan||(g_meshMan=new MeshManager),g_Engine.initializeComplete||g_Engine.init()}function RDGEStop(){RDGEShutdown!=void 0&&RDGEShutdown()}function IRuntime(){this.Shutdown=this.Draw=this.Update=this.Resize=this.ReInit=this.init=null}g_poolList=[];
368function ConnPoll(){for(var a=g_poolList.length,b=0;b<a;++b)g_poolList[b].Poll()}RDGERequestAnimationFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}(); 366function ConnPoll(){for(var a=g_poolList.length,b=0;b<a;++b)g_poolList[b].Poll()}RDGERequestAnimationFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}();
369RDGETask=function(){var a={};return function(b,f){this.id=b.rdgeid;this.lastTime=this.currTime=0;this.running=!1;this.context=null;if(b){this.context=g_Engine.ctxMan.handleToObject(b.rdgeCtxHandle);a[this.id]=function(){if(g.running)g.currTime=(new Date).getTime(),g.step((g.currTime-g.lastTime)/1E3),RDGERequestAnimationFrame(a[g.id],b),g.lastTime=g.currTime};this.start=function(){this.running=!0;this.lastTime=this.currTime=(new Date).getTime();a[this.id]()};this.stop=function(){this.running=!1};this.kill= 367RDGETask=function(){var a={};return function(b,f){this.id=b.rdgeid;this.lastTime=this.currTime=0;this.running=!1;this.context=null;if(b){this.context=g_Engine.ctxMan.handleToObject(b.rdgeCtxHandle);a[this.id]=function(){if(g.running)g.currTime=(new Date).getTime(),g.step((g.currTime-g.lastTime)/1E3),RDGERequestAnimationFrame(a[g.id],b),g.lastTime=g.currTime};this.start=function(){if(!this.running)this.running=!0,this.lastTime=this.currTime=(new Date).getTime(),a[this.id]()};this.stop=function(){this.running=
370function(){this.running=!1;a[this.id]=null};this.step=function(a){contextManager.currentCtx=this.context;this.context.fpsTracker.sample();this.context.ctxStateManager.tick(a)};var g=this;f&&g.start()}}}();var g_dbgPanel=null; 368!1};this.kill=function(){this.running=!1;a[this.id]=null};this.step=function(a){contextManager.currentCtx=this.context;this.context.fpsTracker.sample();this.context.ctxStateManager.tick(a)};var g=this;f&&g.start()}}}();var g_dbgPanel=null;
371function utilDbgPanel(a,b){this.id=a;this.root="#"+a;this.accordion=this.root+" .dbgpanel-accordion";this.categories={};this.counter=0;$(this.root).addClass("dbgpanel-outer ui-widget-content");$(this.root).draggable({handle:this.root,containment:"body"});$(this.root).resizable({minWidth:$(this.root).width(),minHeight:$(this.root).height()});$(this.root).append('<h3 class="dbgpanel-title">'+b+"</h3>");$(this.root).append('<div class="dbgpanel-accordion" />');$(this.accordion).accordion({clearStyle:!0})} 369function utilDbgPanel(a,b){this.id=a;this.root="#"+a;this.accordion=this.root+" .dbgpanel-accordion";this.categories={};this.counter=0;$(this.root).addClass("dbgpanel-outer ui-widget-content");$(this.root).draggable({handle:this.root,containment:"body"});$(this.root).resizable({minWidth:$(this.root).width(),minHeight:$(this.root).height()});$(this.root).append('<h3 class="dbgpanel-title">'+b+"</h3>");$(this.root).append('<div class="dbgpanel-accordion" />');$(this.accordion).accordion({clearStyle:!0})}
372utilDbgPanel.prototype.appendLabel=function(a,b){var f=this.getCategorySelector(a);$(f).append('<p class="dbgpanel-label">'+b+"</p>")}; 370utilDbgPanel.prototype.appendLabel=function(a,b){var f=this.getCategorySelector(a);$(f).append('<p class="dbgpanel-label">'+b+"</p>")};
373utilDbgPanel.prototype.appendBoolean=function(a,b,f,g){var a=this.getCategorySelector(a),h=this.getUniqueID();$(a).append('<div class="dbgpanel-button"><input type="checkbox" id="'+h+'"><label for="'+h+'" class="dbgpanel-button-label"/></div>');$("#"+h).prop("checked",b||b!=0);$("#"+h).button({label:f});$("#"+h).change(function(a){b=a.target.checked?typeof b=="number"?1:!0:typeof b=="number"?0:!1;g&&g(b)})}; 371utilDbgPanel.prototype.appendBoolean=function(a,b,f,g){var a=this.getCategorySelector(a),h=this.getUniqueID();$(a).append('<div class="dbgpanel-button"><input type="checkbox" id="'+h+'"><label for="'+h+'" class="dbgpanel-button-label"/></div>');$("#"+h).prop("checked",b||b!=0);$("#"+h).button({label:f});$("#"+h).change(function(a){b=a.target.checked?typeof b=="number"?1:!0:typeof b=="number"?0:!1;g&&g(b)})};
@@ -433,11 +431,11 @@ rdgeGlobalParameters =
433 "u_light3Amb": {'type': 'vec4', 'data': [0.5, 0.5, 0.5, 1.0]}, 431 "u_light3Amb": {'type': 'vec4', 'data': [0.5, 0.5, 0.5, 1.0]},
434 "u_light3Spec": {'type': 'vec4', 'data': [1.0, 1.0, 1.0, 1.0]}}, 432 "u_light3Spec": {'type': 'vec4', 'data': [1.0, 1.0, 1.0, 1.0]}},
435 "colMap": {'type': 'tex2d', 'data': "assets/images/white.png"}, 433 "colMap": {'type': 'tex2d', 'data': "assets/images/white.png"},
436 "envMap": {'type': 'tex2d', 'data': null}, 434 //"envMap": {'type': 'tex2d', 'data': null},
437 "normalMap": {'type': 'tex2d', 'data': null}, 435 //"normalMap": {'type': 'tex2d', 'data': null},
438 "glowMap": {'type': 'tex2d', 'data': "assets/images/black.png"}, 436 //"glowMap": {'type': 'tex2d', 'data': "assets/images/black.png"},
439 "u_shadowDepthMap": {'type': 'tex2d', 'data': null}, 437 //"u_shadowDepthMap": {'type': 'tex2d', 'data': null},
440 "u_depthMap": {'type': 'tex2d', 'data': null}, 438 //"u_depthMap": {'type': 'tex2d', 'data': null},
441 "u_matAmbient": {'type': 'vec4', 'data': [1.00,1.00,1.00, 1]}, 439 "u_matAmbient": {'type': 'vec4', 'data': [1.00,1.00,1.00, 1]},
442 "u_matDiffuse": {'type': 'vec4', 'data': [1.0, 1.0, 1.0, 1.0]}, 440 "u_matDiffuse": {'type': 'vec4', 'data': [1.0, 1.0, 1.0, 1.0]},
443 "u_matSpecular": {'type': 'vec4', 'data': [1.0, 1.0, 1.0, 1.0]}, 441 "u_matSpecular": {'type': 'vec4', 'data': [1.0, 1.0, 1.0, 1.0]},
diff --git a/js/helper-classes/RDGE/runtime/CanvasDataManager.js b/js/helper-classes/RDGE/runtime/CanvasDataManager.js
new file mode 100644
index 00000000..4985fc9a
--- /dev/null
+++ b/js/helper-classes/RDGE/runtime/CanvasDataManager.js
@@ -0,0 +1,98 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7
8
9///////////////////////////////////////////////////////////////////////
10// Class ShapeRuntime
11// Manages runtime shape display
12///////////////////////////////////////////////////////////////////////
13function CanvasDataManager()
14{
15 this.loadGLData = function(root, valueArray)
16 {
17 var value = valueArray;
18 var nWorlds = value.length;
19 for (var i=0; i<nWorlds; i++)
20 {
21 var importStr = value[i];
22 var startIndex = importStr.indexOf( "id: " );
23 if (startIndex >= 0)
24 {
25 var endIndex = importStr.indexOf( "\n", startIndex );
26 if (endIndex > 0)
27 {
28 var id = importStr.substring( startIndex+4, endIndex );
29 var canvas = this.findCanvasWithID( id, root );
30 if (canvas)
31 {
32 var loadForAuthoring = true;
33 var index = importStr.indexOf( "scenedata: " );
34 if (index >= 0) loadForAuthoring = false;
35
36 if (loadForAuthoring)
37 {
38 if (!canvas.elementModel)
39 {
40 NJUtils.makeElementModel(canvas, "Canvas", "shape", true);
41 }
42
43 if (canvas.elementModel)
44 {
45 if (canvas.elementModel.shapeModel.GLWorld)
46 canvas.elementModel.shapeModel.GLWorld.clearTree();
47
48 var world = new GLWorld( canvas );
49 canvas.elementModel.shapeModel.GLWorld = world;
50 world.import( importStr );
51 }
52