diff options
author | Pushkar Joshi | 2012-02-28 14:01:05 -0800 |
---|---|---|
committer | Pushkar Joshi | 2012-02-28 14:01:05 -0800 |
commit | 63307c9abf120985d979a40a53a0598d3f0d5c5a (patch) | |
tree | 57d9cffd7aa0959ea31fe0fa2d89a9080198bcb3 /js/helper-classes/RDGE | |
parent | e1a65d0c2a13e12ee53be98c731616e35aa07a41 (diff) | |
parent | 7c9291a5bab4abd849547f8878f6fb962fc88250 (diff) | |
download | ninja-63307c9abf120985d979a40a53a0598d3f0d5c5a.tar.gz |
Merge branch 'master' into pentool
Conflicts:
manifest.json
Diffstat (limited to 'js/helper-classes/RDGE')
-rwxr-xr-x | js/helper-classes/RDGE/GLCircle.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLLine.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLRectangle.js | 2 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/GLWorld.js | 27 | ||||
-rwxr-xr-x | js/helper-classes/RDGE/rdge-compiled.js | 28 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/CanvasDataManager.js | 98 | ||||
-rw-r--r-- | js/helper-classes/RDGE/runtime/GLRuntime.js | 159 | ||||
-rw-r--r-- | js/helper-classes/RDGE/src/tools/rdge-compiled.js | 28 |
8 files changed, 297 insertions, 49 deletions
diff --git a/js/helper-classes/RDGE/GLCircle.js b/js/helper-classes/RDGE/GLCircle.js index 5b32547e..712544c0 100755 --- a/js/helper-classes/RDGE/GLCircle.js +++ b/js/helper-classes/RDGE/GLCircle.js | |||
@@ -135,7 +135,7 @@ function GLCircle() | |||
135 | if (!world._useWebGL) return; | 135 | if (!world._useWebGL) return; |
136 | 136 | ||
137 | // make sure RDGE has the correct context | 137 | // make sure RDGE has the correct context |
138 | g_Engine.setContext( world.getCanvas().uuid ); | 138 | g_Engine.setContext( world.getCanvas().rdgeid ); |
139 | 139 | ||
140 | // create the gl buffer | 140 | // create the gl buffer |
141 | var gl = world.getGLContext(); | 141 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLLine.js b/js/helper-classes/RDGE/GLLine.js index 0d815145..f715a43c 100755 --- a/js/helper-classes/RDGE/GLLine.js +++ b/js/helper-classes/RDGE/GLLine.js | |||
@@ -171,7 +171,7 @@ function GLLine( world, xOffset, yOffset, width, height, slope, strokeSize, stro | |||
171 | if (!world._useWebGL) return; | 171 | if (!world._useWebGL) return; |
172 | 172 | ||
173 | // make sure RDGE has the correct context | 173 | // make sure RDGE has the correct context |
174 | g_Engine.setContext( world.getCanvas().uuid ); | 174 | g_Engine.setContext( world.getCanvas().rdgeid ); |
175 | 175 | ||
176 | // create the gl buffer | 176 | // create the gl buffer |
177 | var gl = world.getGLContext(); | 177 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js index 5b6ff94f..3c1cb7dc 100755 --- a/js/helper-classes/RDGE/GLRectangle.js +++ b/js/helper-classes/RDGE/GLRectangle.js | |||
@@ -214,7 +214,7 @@ function GLRectangle() | |||
214 | if (!world._useWebGL) return; | 214 | if (!world._useWebGL) return; |
215 | 215 | ||
216 | // make sure RDGE has the correct context | 216 | // make sure RDGE has the correct context |
217 | g_Engine.setContext( world.getCanvas().uuid ); | 217 | g_Engine.setContext( world.getCanvas().rdgeid ); |
218 | 218 | ||
219 | // create the gl buffer | 219 | // create the gl buffer |
220 | var gl = world.getGLContext(); | 220 | var gl = world.getGLContext(); |
diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index 1edd5cff..64086bee 100755 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js | |||
@@ -136,13 +136,6 @@ function GLWorld( canvas, use3D ) | |||
136 | var camMat = Matrix.I(4); | 136 | var camMat = Matrix.I(4); |
137 | camMat[14] = this.getViewDistance(); | 137 | camMat[14] = this.getViewDistance(); |
138 | this.setCameraMat( camMat ); | 138 | this.setCameraMat( camMat ); |
139 | |||
140 | ////////////////////////////////////////// | ||
141 | // test call to SVG importer | ||
142 | // console.log( "***** SVG TEST *****" ); | ||
143 | // var svgImporter = new SVGParse( this ); | ||
144 | // svgImporter.importSVG(); | ||
145 | ////////////////////////////////////////// | ||
146 | 139 | ||
147 | // post-load processing of the scene | 140 | // post-load processing of the scene |
148 | this.init = function() | 141 | this.init = function() |
@@ -198,7 +191,9 @@ function GLWorld( canvas, use3D ) | |||
198 | this.myScene.addNode(lightTr); | 191 | this.myScene.addNode(lightTr); |
199 | 192 | ||
200 | // Add the scene to the engine - necessary if you want the engine to draw for you | 193 | // Add the scene to the engine - necessary if you want the engine to draw for you |
201 | g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); | 194 | //g_Engine.AddScene("myScene" + this._canvas.id, this.myScene); |
195 | var name = this._canvas.getAttribute( "data-RDGE-id" ); | ||
196 | g_Engine.AddScene("myScene" + name, this.myScene); | ||
202 | } | 197 | } |
203 | 198 | ||
204 | // main code for handling user interaction and updating the scene | 199 | // main code for handling user interaction and updating the scene |
@@ -227,11 +222,11 @@ function GLWorld( canvas, use3D ) | |||
227 | } | 222 | } |
228 | 223 | ||
229 | // defining the draw function to control how the scene is rendered | 224 | // defining the draw function to control how the scene is rendered |
230 | this.draw = function() | 225 | this.draw = function() |
231 | { | 226 | { |
232 | if (this._useWebGL) | 227 | if (this._useWebGL) |
233 | { | 228 | { |
234 | g_Engine.setContext( this._canvas.uuid ); | 229 | g_Engine.setContext( this._canvas.rdgeid ); |
235 | var ctx = g_Engine.getContext(); | 230 | var ctx = g_Engine.getContext(); |
236 | var renderer = ctx.renderer; | 231 | var renderer = ctx.renderer; |
237 | if (renderer.unloadedTextureCount <= 0) | 232 | if (renderer.unloadedTextureCount <= 0) |
@@ -391,12 +386,10 @@ function GLWorld( canvas, use3D ) | |||
391 | if (this._useWebGL) | 386 | if (this._useWebGL) |
392 | { | 387 | { |
393 | rdgeStarted = true; | 388 | rdgeStarted = true; |
394 | this._canvas.rdgeid = this._canvas.uuid; | 389 | var id = this._canvas.getAttribute( "data-RDGE-id" ); |
390 | this._canvas.rdgeid = id; | ||
395 | g_Engine.registerCanvas(this._canvas, this); | 391 | g_Engine.registerCanvas(this._canvas, this); |
396 | RDGEStart( this._canvas ); | 392 | RDGEStart( this._canvas ); |
397 | |||
398 | //this._canvas.fpsTracker = new fpsTracker( '0' ); | ||
399 | //this._canvas.task = new RDGETask(this._canvas, false); | ||
400 | this._canvas.task.stop() | 393 | this._canvas.task.stop() |
401 | } | 394 | } |
402 | } | 395 | } |
@@ -765,7 +758,7 @@ GLWorld.prototype.render = function() | |||
765 | else | 758 | else |
766 | { | 759 | { |
767 | // console.log( "GLWorld.render, " + this._worldCount ); | 760 | // console.log( "GLWorld.render, " + this._worldCount ); |
768 | g_Engine.setContext( this._canvas.uuid ); | 761 | g_Engine.setContext( this._canvas.rdgeId ); |
769 | //this.draw(); | 762 | //this.draw(); |
770 | this.restartRenderLoop(); | 763 | this.restartRenderLoop(); |
771 | } | 764 | } |
@@ -821,7 +814,9 @@ GLWorld.prototype.getShapeFromPoint = function( offsetX, offsetY ) | |||
821 | GLWorld.prototype.export = function() | 814 | GLWorld.prototype.export = function() |
822 | { | 815 | { |
823 | var exportStr = "GLWorld 1.0\n"; | 816 | var exportStr = "GLWorld 1.0\n"; |
824 | exportStr += "id: " + this._canvas.rdgeid + "\n"; | 817 | var id = this.getCanvas().getAttribute( "data-RDGE-id" ); |
818 | exportStr += "id: " + id + "\n"; | ||
819 | //exportStr += "id: " + this._canvas.rdgeid + "\n"; | ||
825 | exportStr += "fov: " + this._fov + "\n"; | 820 | exportStr += "fov: " + this._fov + "\n"; |
826 | exportStr += "zNear: " + this._zNear + "\n"; | 821 | exportStr += "zNear: " + this._zNear + "\n"; |
827 | exportStr += "zFar: " + this._zFar + "\n"; | 822 | exportStr += "zFar: " + this._zFar + "\n"; |
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 | |||
45 | 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> | 45 | 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> |
46 | 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]}, | 46 | 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]}, |
47 | 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]}, | 47 | 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]}, |
48 | 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"},envMap:{type:"tex2d",data:null},normalMap:{type:"tex2d",data:null},glowMap:{type:"tex2d",data:"assets/images/black.png"}, | 48 | 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", |
49 | u_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", | 49 | 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}; |
50 | 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}; | ||
51 | 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, | 50 | 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, |
52 | 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++} | 51 | 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++} |
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 | |||
251 | transformNodeTemplate=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+ | 250 | transformNodeTemplate=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; |
253 | this.parent.children.push({transformNode:a});this.parent=a}a.children.push({transformNode:this})}}}; | 252 | this.parent.children.push({transformNode:a});this.parent=a}a.children.push({transformNode:this})}}}; |
254 | materialNodeTemplate=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"), | 253 | materialNodeTemplate=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= |
255 | unit: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/"+ | 254 | g_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== |
256 | b);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= | 255 | a){this.uniforms[h].value=f;return |