diff options
Diffstat (limited to 'js/helper-classes/RDGE/rdge-compiled.js')
-rwxr-xr-x | js/helper-classes/RDGE/rdge-compiled.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/js/helper-classes/RDGE/rdge-compiled.js b/js/helper-classes/RDGE/rdge-compiled.js index 66bf5a42..0bbcb05b 100755 --- a/js/helper-classes/RDGE/rdge-compiled.js +++ b/js/helper-classes/RDGE/rdge-compiled.js | |||
@@ -107,11 +107,11 @@ t);this.def[t]=null;break}for(var n in RDGE.rdgeGlobalParameters){l=new globalPa | |||
107 | 0,o;for(o in RDGE.globals.engine.lightManager.lightUniforms[m]){loc=this.ctx.getUniformLocation(h,o);if(loc!=null){this[t].passes[g].lightParams[m]||(this[t].passes[g].lightParams[m]=[]);this[t].passes[g].lightParams[m].push({loc:loc,name:o,dataIndex:p})}p++}}for(n in d[g].params)if(typeof d[g].params[n]!="string"){l=new paramType(this.ctx,n,d[g].params,h,t);this[t].passes[g].params[n]=l;this[t][n]=l}for(n in d[g].params)typeof d[g].params[n]=="string"&&(this[t][n]=this[t].passes[g].params[n]);g++}}for(t in a){f= | 107 | 0,o;for(o in RDGE.globals.engine.lightManager.lightUniforms[m]){loc=this.ctx.getUniformLocation(h,o);if(loc!=null){this[t].passes[g].lightParams[m]||(this[t].passes[g].lightParams[m]=[]);this[t].passes[g].lightParams[m].push({loc:loc,name:o,dataIndex:p})}p++}}for(n in d[g].params)if(typeof d[g].params[n]!="string"){l=new paramType(this.ctx,n,d[g].params,h,t);this[t].passes[g].params[n]=l;this[t][n]=l}for(n in d[g].params)typeof d[g].params[n]=="string"&&(this[t][n]=this[t].passes[g].params[n]);g++}}for(t in a){f= |
108 | this[t].passes.length;for(g=0;g<f;++g){this[t].passes[g].defParamsList=[];for(n in this[t].passes[g].params){d=this[t].passes[g].params[n];d.name=n;this[t].passes[g].paramsList.push(d)}for(n in this[t].passes[g].defParams){d=this[t].passes[g].defParams[n];d.name=n;this[t].passes[g].defParamsList.push(d)}}}this.setTechnique(c)};this.initLocalParameter=function(a,c){var d=this.def.techniques;for(t in d)for(var f=d[t],g=f.length,h=0;h<g;){var l=new paramType(this.ctx,a,c,f[h].program,t);if(l){f[h][a]= | 108 | this[t].passes.length;for(g=0;g<f;++g){this[t].passes[g].defParamsList=[];for(n in this[t].passes[g].params){d=this[t].passes[g].params[n];d.name=n;this[t].passes[g].paramsList.push(d)}for(n in this[t].passes[g].defParams){d=this[t].passes[g].defParams[n];d.name=n;this[t].passes[g].defParamsList.push(d)}}}this.setTechnique(c)};this.initLocalParameter=function(a,c){var d=this.def.techniques;for(t in d)for(var f=d[t],g=f.length,h=0;h<g;){var l=new paramType(this.ctx,a,c,f[h].program,t);if(l){f[h][a]= |
109 | l;if(!f[h].paramsList)f[h].paramsList=[];f[h].paramsList.push(l)}h++}};this.buildShader=function(a,c){var c="#define PC\n"+c,d=this.ctx.createShader(a);if(d==null){this.renderer.console.log("*** Error: unable to create shader '"+a+"'");return null}this.ctx.shaderSource(d,c);this.ctx.compileShader(d);if(!this.ctx.getShaderParameter(d,this.ctx.COMPILE_STATUS)){var f=this.ctx.getShaderInfoLog(d);window.console.error("*** Error compiling shader '"+a+"':"+f);this.ctx.deleteShader(d);return null}return d}; | 109 | l;if(!f[h].paramsList)f[h].paramsList=[];f[h].paramsList.push(l)}h++}};this.buildShader=function(a,c){var c="#define PC\n"+c,d=this.ctx.createShader(a);if(d==null){this.renderer.console.log("*** Error: unable to create shader '"+a+"'");return null}this.ctx.shaderSource(d,c);this.ctx.compileShader(d);if(!this.ctx.getShaderParameter(d,this.ctx.COMPILE_STATUS)){var f=this.ctx.getShaderInfoLog(d);window.console.error("*** Error compiling shader '"+a+"':"+f);this.ctx.deleteShader(d);return null}return d}; |
110 | this.buildProgram=function(a){window.console.log("building shader pair: <"+a.vshader+", "+a.fshader+">");var c=this.def.shaders[a.vshader],d=this.def.shaders[a.fshader];this.ctx.useProgram(null);var f=null,g=null;if(c.indexOf("{")!=-1)g=c;else{g=new XMLHttpRequest;g.open("GET",c,false);g.send(null);g=g.responseText}f=this.buildShader(this.ctx.VERTEX_SHADER,g);g=null;if(c.indexOf("{")!=-1)g=d;else{g=new XMLHttpRequest;g.open("GET",d,false);g.send(null);g=g.responseText}g=this.buildShader(this.ctx.FRAGMENT_SHADER, | 110 | this.buildProgram=function(a){window.console.log("building shader pair: <"+a.vshader+", "+a.fshader+">");var c=RDGE.globals.engine.remapAssetFolder(this.def.shaders[a.vshader]),d=RDGE.globals.engine.remapAssetFolder(this.def.shaders[a.fshader]);this.ctx.useProgram(null);var f=null,g=null;if(c.indexOf("{")!=-1)g=c;else{g=new XMLHttpRequest;g.open("GET",c,false);g.send(null);g=g.responseText}f=this.buildShader(this.ctx.VERTEX_SHADER,g);g=null;if(c.indexOf("{")!=-1)g=d;else{g=new XMLHttpRequest;g.open("GET", |
111 | g);if(!f||!g)return null;this.compiledShaders[a.vshader]=f;this.compiledShaders[a.fshader]=g;c=this.ctx.createProgram();if(!c)return null;this.ctx.attachShader(c,f);this.ctx.attachShader(c,g);d=0;a.attribPairs=[];for(var h in a.attributes){a.attribPairs.push({loc:d,name:h});this.ctx.bindAttribLocation(c,d++,h)}this.ctx.linkProgram(c);if(!this.ctx.getProgramParameter(c,this.ctx.LINK_STATUS)){a=this.ctx.getProgramInfoLog(c);window.console.log("Error in program linking:"+a);this.ctx.deleteProgram(c); | 111 | d,false);g.send(null);g=g.responseText}g=this.buildShader(this.ctx.FRAGMENT_SHADER,g);if(!f||!g)return null;this.compiledShaders[a.vshader]=f;this.compiledShaders[a.fshader]=g;c=this.ctx.createProgram();if(!c)return null;this.ctx.attachShader(c,f);this.ctx.attachShader(c,g);d=0;a.attribPairs=[];for(var h in a.attributes){a.attribPairs.push({loc:d,name:h});this.ctx.bindAttribLocation(c,d++,h)}this.ctx.linkProgram(c);if(!this.ctx.getProgramParameter(c,this.ctx.LINK_STATUS)){a=this.ctx.getProgramInfoLog(c); |
112 | this.ctx.deleteProgram(g);this.ctx.deleteProgram(f);return null}return c};this.setLightContext=function(a){for(t in this.technique)for(var c=this.technique.passes.length,d=0;d<c;++d)this.technique.passes[d].lightContext=a.slice()};this.setTextureContext=function(a){for(var c=this.technique.passes.length,d=null,f=0,g=a.length;f<g;++f)for(var h=0;h<c;++h){d=a[f];this.technique.passes[h].defParams[d.name]&&this.technique.passes[h].defParams[d.name].set(d.handle);this.technique.passes[h].params[d.name]&& | 112 | window.console.log("Error in program linking:"+a);this.ctx.deleteProgram(c);this.ctx.deleteProgram(g);this.ctx.deleteProgram(f);return null}return c};this.setLightContext=function(a){for(t in this.technique)for(var c=this.technique.passes.length,d=0;d<c;++d)this.technique.passes[d].lightContext=a.slice()};this.setTextureContext=function(a){for(var c=this.technique.passes.length,d=null,f=0,g=a.length;f<g;++f)for(var h=0;h<c;++h){d=a[f];this.technique.passes[h].defParams[d.name]&&this.technique.passes[h].defParams[d.name].set(d.handle); |
113 | this.technique.passes[h].params[d.name].set(d.data[0])}};this.setTechnique=function(a){if(this[a]!=void 0){this.technique=this[a];return true}this.ctx.console.log("Failed to set technique:"+a);return false};this.beginRenderState=function(a){var c=this.technique.passes[a].states;if(c!=void 0){if(c.depthEnable!=void 0?c.depthEnable:1){c.depthFunc&&this.ctx.depthFunc(this.ctx[c.depthFunc]);if(c.offset){this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL);this.ctx.polygonOffset(c.offset[0],c.offset[1])}c.depthWrite&& | 113 | this.technique.passes[h].params[d.name]&&this.technique.passes[h].params[d.name].set(d.data[0])}};this.setTechnique=function(a){if(this[a]!=void 0){this.technique=this[a];return true}this.ctx.console.log("Failed to set technique:"+a);return false};this.beginRenderState=function(a){var c=this.technique.passes[a].states;if(c!=void 0){if(c.depthEnable!=void 0?c.depthEnable:1){c.depthFunc&&this.ctx.depthFunc(this.ctx[c.depthFunc]);if(c.offset){this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL);this.ctx.polygonOffset(c.offset[0], |
114 | this.ctx.depthMask(c.depthWrite);c.depthRangeMin&&this.ctx.depthRange(c.depthRangeMin);c.depthRangeMax&&this.ctx.depthRange(c.depthRangeMax)}else{this.ctx.disable(this.ctx.DEPTH_TEST);this.ctx.depthFunc(this.ctx[c.depthFunc]);this.ctx.depthMask(true)}if(c.blendEnable!=void 0&&c.blendEnable){var d=c.srcBlend!=void 0?c.srcBlend:"ONE",f=c.dstBlend!=void 0?c.dstBlend:"ZERO";this.ctx.enable(this.ctx.BLEND);this.ctx.blendFunc(this.ctx[d],this.ctx[f])}c.culling&&(c.culling?this.ctx.enable(this.ctx.CULL_FACE): | 114 | c.offset[1])}c.depthWrite&&this.ctx.depthMask(c.depthWrite);c.depthRangeMin&&this.ctx.depthRange(c.depthRangeMin);c.depthRangeMax&&this.ctx.depthRange(c.depthRangeMax)}else{this.ctx.disable(this.ctx.DEPTH_TEST);this.ctx.depthFunc(this.ctx[c.depthFunc]);this.ctx.depthMask(true)}if(c.blendEnable!=void 0&&c.blendEnable){var d=c.srcBlend!=void 0?c.srcBlend:"ONE",f=c.dstBlend!=void 0?c.dstBlend:"ZERO";this.ctx.enable(this.ctx.BLEND);this.ctx.blendFunc(this.ctx[d],this.ctx[f])}c.culling&&(c.culling?this.ctx.enable(this.ctx.CULL_FACE): |
115 | this.ctx.disable(this.ctx.CULL_FACE));c.cullFace&&this.ctx.cullFace(this.ctx[c.cullFace]);c.pointsprite&&(c.pointsprite===true?this.renderer.enablePointSprites():this.renderer.disablePointSprites());this.resetRS=this.technique.passes[a].states.reset==void 0||this.technique.passes[a].states.reset==true}};this.endRenderState=function(){var a=this.ctx;if(this.resetRS){a.enable(this.ctx.DEPTH_TEST);a.disable(this.ctx.BLEND);a.depthFunc(this.ctx.LESS);a.disable(this.ctx.POLYGON_OFFSET_FILL);a.disable(this.ctx.CULL_FACE)}}; | 115 | this.ctx.disable(this.ctx.CULL_FACE));c.cullFace&&this.ctx.cullFace(this.ctx[c.cullFace]);c.pointsprite&&(c.pointsprite===true?this.renderer.enablePointSprites():this.renderer.disablePointSprites());this.resetRS=this.technique.passes[a].states.reset==void 0||this.technique.passes[a].states.reset==true}};this.endRenderState=function(){var a=this.ctx;if(this.resetRS){a.enable(this.ctx.DEPTH_TEST);a.disable(this.ctx.BLEND);a.depthFunc(this.ctx.LESS);a.disable(this.ctx.POLYGON_OFFSET_FILL);a.disable(this.ctx.CULL_FACE)}}; |
116 | this.begin=function(){this.currentPass=null;return this.def==null||this.technique==null?0:this.technique.passes.length};this.beginPass=function(a){this.currentPass=this.technique.passes[a];this.ctx.useProgram(this.currentPass.program);this.bindParameters(this.currentPass);this.beginRenderState(a);return this.currentPass};this.endPass=function(){this.endRenderState();this.ctx.useProgram(null)};this.end=function(){};this.exportShader=function(){for(t in this.def.techniques)for(var a=this[t].passes.length, | 116 | this.begin=function(){this.currentPass=null;return this.def==null||this.technique==null?0:this.technique.passes.length};this.beginPass=function(a){this.currentPass=this.technique.passes[a];this.ctx.useProgram(this.currentPass.program);this.bindParameters(this.currentPass);this.beginRenderState(a);return this.currentPass};this.endPass=function(){this.endRenderState();this.ctx.useProgram(null)};this.end=function(){};this.exportShader=function(){for(t in this.def.techniques)for(var a=this[t].passes.length, |
117 | c=0;c<a;++c){this[t].passes[c].paramsList=[];this[t].passes[c].defParamsList=[];for(var d in this[t].passes[c].params){var f=this.def.techniques[t][c];if(f&&this[t].passes[c].params[d].type!="tex2d"&&this[t].passes[c].params[d]!="texCube")f.params[d].data=this[t].passes[c].params[d].data}}return JSON.stringify(this.def)}};RDGE=RDGE||{};RDGE.jpassGeoSet={BACKGROUND:1,OPAQUE:2,TRANSPARENT:4,ADDITIVE:8,TRANSLUCENT:16,FOREGROUND:32,ALL:127,SCREEN_QUAD:128,SHADOW:256,MAXSETS:9}; | 117 | c=0;c<a;++c){this[t].passes[c].paramsList=[];this[t].passes[c].defParamsList=[];for(var d in this[t].passes[c].params){var f=this.def.techniques[t][c];if(f&&this[t].passes[c].params[d].type!="tex2d"&&this[t].passes[c].params[d]!="texCube")f.params[d].data=this[t].passes[c].params[d].data}}return JSON.stringify(this.def)}};RDGE=RDGE||{};RDGE.jpassGeoSet={BACKGROUND:1,OPAQUE:2,TRANSPARENT:4,ADDITIVE:8,TRANSLUCENT:16,FOREGROUND:32,ALL:127,SCREEN_QUAD:128,SHADOW:256,MAXSETS:9}; |
@@ -212,7 +212,7 @@ RDGE.stateManager=function(){this.stateStack=[];this.stateTop=void 0;this.RDGERu | |||
212 | RDGE.Engine=function(){this._assetPath="assets/";this.sceneMap=[];this.stateTop=void 0;this.lastWindowWidth=window.innerWidth;this.lastWindowHeight=window.innerHeight;this.lightManager=this.defaultContext=null;clearColor=[0,0,0,0];this.initializeComplete=!1;this.RDGECanvas=null;this.canvasToRendererMap={};this.canvasNameToStateStack={};this.canvasCtxList=[];invalidObj=/([()]|function)/;isValidObj=function(a){return invalidObj.test(a)?(window.console.error("invalid object name passed to RDGE, "+a+ | 212 | RDGE.Engine=function(){this._assetPath="assets/";this.sceneMap=[];this.stateTop=void 0;this.lastWindowWidth=window.innerWidth;this.lastWindowHeight=window.innerHeight;this.lightManager=this.defaultContext=null;clearColor=[0,0,0,0];this.initializeComplete=!1;this.RDGECanvas=null;this.canvasToRendererMap={};this.canvasNameToStateStack={};this.canvasCtxList=[];invalidObj=/([()]|function)/;isValidObj=function(a){return invalidObj.test(a)?(window.console.error("invalid object name passed to RDGE, "+a+ |
213 | " - looks like a function"),!1):!0};contextDef=function(){this.startUpState=this.ctxStateManager=this.renderer=this.id=null;this.sceneGraphMap=[];this.currentScene=null;this.getScene=function(){return this.sceneGraphMap[this.currentScene]};this.debug={frameCounter:0,mat4CallCount:0}};this.ctxMan=contextManager=new RDGE.objectManager;contextManager.currentCtx=null;contextManager._addObject=contextManager.addObject;contextManager.contextMap={};contextManager.addObject=function(a){this.contextMap[a.id]= | 213 | " - looks like a function"),!1):!0};contextDef=function(){this.startUpState=this.ctxStateManager=this.renderer=this.id=null;this.sceneGraphMap=[];this.currentScene=null;this.getScene=function(){return this.sceneGraphMap[this.currentScene]};this.debug={frameCounter:0,mat4CallCount:0}};this.ctxMan=contextManager=new RDGE.objectManager;contextManager.currentCtx=null;contextManager._addObject=contextManager.addObject;contextManager.contextMap={};contextManager.addObject=function(a){this.contextMap[a.id]= |
214 | a;return this._addObject(a)};contextManager.start=function(){for(var a=this.objects.length,b=0;b<a;++b)contextManager.currentCtx=this.objects[b],this.objects[b].ctxStateManager.PushState(this.objects[b].startUpState)};contextManager.forEach=function(a){for(var b=this.objects.length,c=0;c<b;++c)a(this.objects[c])};this.getContext=function(a){return a?contextManager.contextMap[a]:contextManager.currentCtx};this.clearContext=function(a){contextManager.contextMap[a]=void 0};this.setContext=function(a){contextManager.currentCtx= | 214 | a;return this._addObject(a)};contextManager.start=function(){for(var a=this.objects.length,b=0;b<a;++b)contextManager.currentCtx=this.objects[b],this.objects[b].ctxStateManager.PushState(this.objects[b].startUpState)};contextManager.forEach=function(a){for(var b=this.objects.length,c=0;c<b;++c)a(this.objects[c])};this.getContext=function(a){return a?contextManager.contextMap[a]:contextManager.currentCtx};this.clearContext=function(a){contextManager.contextMap[a]=void 0};this.setContext=function(a){contextManager.currentCtx= |
215 | contextManager.contextMap[a]};this.tickContext=function(a){var b=contextManager.currentCtx;contextManager.currentCtx=contextManager.contextMap[a];this.objects[i].ctxStateManager.tick(dt);contextManager.currentCtx=b};this.remapAssetFolder=function(a){var b=a.indexOf("assets/"),c=a;0<=b&&(c=a.substr(b+7),c=this._assetPath+c);return c}}; | 215 | contextManager.contextMap[a]};this.tickContext=function(a){var b=contextManager.currentCtx;contextManager.currentCtx=contextManager.contextMap[a];this.objects[i].ctxStateManager.tick(dt);contextManager.currentCtx=b};this.setAssetPath=function(a){this._assetPath=a.slice()};this.remapAssetFolder=function(a){var b=a.indexOf("assets/"),c=a;0<=b&&(c=a.substr(b+7),c=this._assetPath+c);return c}}; |
216 | RDGE.Engine.prototype.init=function(a,b,c){this.GlInit(c);globalParamFuncSet=function(a){this.data=a.data;this.type=a.type;this.set=function(a){for(var b=this.data?this.data.length:0,c=0;c<b;++c)this.data[c]=a[c]};this.get=function(){return void 0==this.data.length?this.data:this.data.slice()}};this.lightManager=new RDGE.LightManager(RDGE.rdgeGlobalParameters.rdge_lights);for(var d in RDGE.rdgeGlobalParameters)if("rdge_lights"!=d)RDGE.rdgeGlobalParameters[d]=new globalParamFuncSet(RDGE.rdgeGlobalParameters[d]); | 216 | RDGE.Engine.prototype.init=function(a,b,c){this.GlInit(c);globalParamFuncSet=function(a){this.data=a.data;this.type=a.type;this.set=function(a){for(var b=this.data?this.data.length:0,c=0;c<b;++c)this.data[c]=a[c]};this.get=function(){return void 0==this.data.length?this.data:this.data.slice()}};this.lightManager=new RDGE.LightManager(RDGE.rdgeGlobalParameters.rdge_lights);for(var d in RDGE.rdgeGlobalParameters)if("rdge_lights"!=d)RDGE.rdgeGlobalParameters[d]=new globalParamFuncSet(RDGE.rdgeGlobalParameters[d]); |
217 | else{var a=RDGE.rdgeGlobalParameters[d],f;for(f in a)RDGE.rdgeGlobalParameters[f]=new globalParamFuncSet(a[f])}this.lastWindowWidth=window.innerWidth;this.lastWindowHeight=window.innerHeight;this.defaultContext=new RDGE.RenderContext;this.defaultContext.uniforms=[{name:"u_matAmbient",value:[0.02,0.02,0.02,1]},{name:"u_matDiffuse",value:[1,1,1,1]},{name:"u_matSpecular",value:[1,1,1,1]},{name:"u_matShininess",value:[128]},{name:"u_matEmission",value:[0,0,0,1]}];contextManager.start();this.initializeComplete= | 217 | else{var a=RDGE.rdgeGlobalParameters[d],f;for(f in a)RDGE.rdgeGlobalParameters[f]=new globalParamFuncSet(a[f])}this.lastWindowWidth=window.innerWidth;this.lastWindowHeight=window.innerHeight;this.defaultContext=new RDGE.RenderContext;this.defaultContext.uniforms=[{name:"u_matAmbient",value:[0.02,0.02,0.02,1]},{name:"u_matDiffuse",value:[1,1,1,1]},{name:"u_matSpecular",value:[1,1,1,1]},{name:"u_matShininess",value:[128]},{name:"u_matEmission",value:[0,0,0,1]}];contextManager.start();this.initializeComplete= |
218 | !0};RDGE.Engine.prototype.Shutdown=function(){this.PopAll()};RDGE.Engine.prototype.GlInit=function(){for(var a=document.getElementsByTagName("canvas"),b=a.length,c=0;c<b;++c){var d;"true"==a[c].getAttribute("rdge")&&(d=a[c],this.registerCanvas(d))}}; | 218 | !0};RDGE.Engine.prototype.Shutdown=function(){this.PopAll()};RDGE.Engine.prototype.GlInit=function(){for(var a=document.getElementsByTagName("canvas"),b=a.length,c=0;c<b;++c){var d;"true"==a[c].getAttribute("rdge")&&(d=a[c],this.registerCanvas(d))}}; |