From e065244ac75d1d0f25fd5c75cb58e714a13fe16b Mon Sep 17 00:00:00 2001 From: Jonathan Duran Date: Wed, 14 Mar 2012 08:59:17 -0700 Subject: Squashed commit of the following: merge master into timeline Signed-off-by: Jonathan Duran --- js/helper-classes/3D/draw-utils.js | 140 +++++------------ js/helper-classes/3D/math-utils.js | 5 +- js/helper-classes/3D/snap-manager.js | 12 +- js/helper-classes/RDGE/rdge-compiled.js | 64 ++++---- .../RDGE/runtime/CanvasDataManager.js | 98 ------------ js/helper-classes/RDGE/runtime/GLRuntime.js | 159 ------------------- js/helper-classes/RDGE/src/core/script/engine.js | 15 ++ js/helper-classes/RDGE/src/core/script/fx/ssao.js | 2 +- .../RDGE/src/core/script/init_state.js | 12 +- js/helper-classes/RDGE/src/core/script/jshader.js | 8 +- js/helper-classes/RDGE/src/core/script/renderer.js | 1 + .../RDGE/src/core/script/scenegraphNodes.js | 2 +- .../RDGE/src/core/script/utilities.js | 4 +- js/helper-classes/RDGE/src/tools/rdge-compiled.js | 64 ++++---- js/helper-classes/backup-delete/GLBrushStroke.js | 174 ++++++++++++++++++++- js/helper-classes/backup-delete/GLCircle.js | 3 +- js/helper-classes/backup-delete/GLGeomObj.js | 46 ++++++ js/helper-classes/backup-delete/GLRectangle.js | 2 + js/helper-classes/backup-delete/GLSubpath.js | 147 ++++++++++++++--- js/helper-classes/backup-delete/GLWorld.js | 71 +++++---- .../backup-delete/Materials/BumpMetalMaterial.js | 39 +++-- .../backup-delete/Materials/DeformMaterial.js | 2 +- .../backup-delete/Materials/FlatMaterial.js | 34 ++-- .../backup-delete/Materials/FlyMaterial.js | 2 +- .../backup-delete/Materials/JuliaMaterial.js | 2 +- .../Materials/KeleidoscopeMaterial.js | 2 +- .../Materials/LinearGradientMaterial.js | 2 +- .../backup-delete/Materials/MandelMaterial.js | 2 +- .../backup-delete/Materials/PlasmaMaterial.js | 2 +- .../backup-delete/Materials/PulseMaterial.js | 5 +- .../backup-delete/Materials/RadialBlurMaterial.js | 2 +- .../Materials/RadialGradientMaterial.js | 6 +- .../Materials/ReliefTunnelMaterial.js | 2 +- .../Materials/SquareTunnelMaterial.js | 2 +- .../backup-delete/Materials/StarMaterial.js | 2 +- .../backup-delete/Materials/TaperMaterial.js | 4 +- .../backup-delete/Materials/TunnelMaterial.js | 2 +- .../backup-delete/Materials/TwistMaterial.js | 2 +- .../backup-delete/Materials/TwistVertMaterial.js | 2 +- .../backup-delete/Materials/UberMaterial.js | 73 ++++++++- .../backup-delete/Materials/WaterMaterial.js | 4 +- .../backup-delete/Materials/ZInvertMaterial.js | 2 +- 42 files changed, 675 insertions(+), 549 deletions(-) delete mode 100644 js/helper-classes/RDGE/runtime/CanvasDataManager.js delete mode 100644 js/helper-classes/RDGE/runtime/GLRuntime.js (limited to 'js/helper-classes') diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index 63e7799a..1c00f7ea 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js @@ -139,8 +139,8 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { handleCloseDocument:{ value: function() { if(this.application.ninja.documentController._documents.length === 0){ - this._eltArray = []; - this._planesArray = []; + this._eltArray = null; + this._planesArray = null; } } }, @@ -721,8 +721,17 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { drawSelectionBounds : { value: function( eltArray ) { this._selectionCtr = null; + var len = eltArray.length, + i, + j, + bounds, + bounds3D, + pt, + tmpPt, + ssMat, + elt; - if (eltArray.length == 0) return; + if (len === 0) return; var context = this._drawingContext; if (!context) return; @@ -731,18 +740,19 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { context.lineWidth = 2; // handle the single element case - if (eltArray.length == 1) + // TODO - Currently, the stage draws its own selection bounds for single selection case + if (len === 1) { // single selection case //console.log( "single selection" ); - var elt = eltArray[0]; + elt = eltArray[0]; this.viewUtils.pushViewportObj( elt ); // get the element bounds in world space - var bounds3D = this.viewUtils.getElementViewBounds3D( elt ); - for (var j=0; j<4; j++) { + bounds3D = this.viewUtils.getElementViewBounds3D( elt ); + for (j=0; j<4; j++) { bounds3D[j] = this.viewUtils.localToGlobal( bounds3D[j], elt ); } @@ -766,19 +776,12 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { } else { - // the multiple selection case. - //console.log( "multiple selection" ); - - // we set the root to "the world". - var saveRoot = this.viewUtils.getRootElement(); - this.viewUtils.setRootElement( this.viewUtils.getStageElement() ); - // get the plane from the first element to compare against the other elements var flat = true; var plane = this.viewUtils.getElementPlane( eltArray[0] ); - for (var i=1; i 0) || (right > 0)) ? dark : light; context.beginPath(); if ((front > 0) || (right > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x1, y0, z1], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y1, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y0, z1], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y1, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -973,8 +937,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((right > 0) || (back > 0)) ? dark : light; context.beginPath(); if ((right > 0) || (back > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x1, y0, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y1, z0], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y0, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y1, z0], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -983,8 +945,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((back > 0) || (left > 0)) ? dark : light; context.beginPath(); if ((back > 0) || (left > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y0, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x0, y1, z0], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y0, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y1, z0], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -993,8 +953,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((left > 0) || (front > 0)) ? dark : light; context.beginPath(); if ((left > 0) || (front > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y0, z1], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x0, y1, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y0, z1], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y1, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1004,8 +962,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((front > 0) || (top > 0)) ? dark : light; context.beginPath(); if ((front > 0) || (top > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y0, z1], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y0, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y0, z1], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y0, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1014,8 +970,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((top > 0) || (back > 0)) ? dark : light; context.beginPath(); if ((top > 0) || (back > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y0, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y0, z0], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y0, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y0, z0], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1024,8 +978,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((back > 0) || (bottom > 0)) ? dark : light; context.beginPath(); if ((back > 0) || (bottom > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y1, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y1, z0], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y1, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y1, z0], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1034,8 +986,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((bottom > 0) || (front > 0)) ? dark : light; context.beginPath(); if ((bottom > 0) || (front > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y1, z1], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y1, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y1, z1], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y1, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1044,8 +994,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { // and the remaining lines - varying Z if ((top > 0) || (right > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x1, y0, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y0, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y0, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y0, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1054,8 +1002,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((right > 0) || (bottom > 0)) ? dark : light; context.beginPath(); if ((right > 0) || (bottom > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x1, y1, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x1, y1, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y1, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x1, y1, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1064,8 +1010,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((bottom > 0) || (left > 0)) ? dark : light; context.beginPath(); if ((bottom > 0) || (left > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y1, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x0, y1, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y1, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y1, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); @@ -1074,8 +1018,6 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { //context.strokeStyle = ((left > 0) || (top > 0)) ? dark : light; context.beginPath(); if ((left > 0) || (top > 0)) { context.beginPath(); -// p = this.viewUtils.localToGlobal( [x0, y0, z0], this._sourceSpaceElt ); context.moveTo( p[0], p[1] ); -// p = this.viewUtils.localToGlobal( [x0, y0, z1], this._sourceSpaceElt ); context.lineTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y0, z0], ssMat ); context.moveTo( p[0], p[1] ); p = this.viewUtils.localToGlobal2( [x0, y0, z1], ssMat ); context.lineTo( p[0], p[1] ); context.closePath(); context.stroke(); diff --git a/js/helper-classes/3D/math-utils.js b/js/helper-classes/3D/math-utils.js index 562a6e73..2f0283a9 100755 --- a/js/helper-classes/3D/math-utils.js +++ b/js/helper-classes/3D/math-utils.js @@ -729,7 +729,10 @@ var MathUtilsClass = exports.MathUtilsClass = Object.create(Object.prototype, { // the area of the polygon is the length of the normal var area = VecUtils.vecMag(3, normal ); if (this.fpSign(area) != 0) - vec3.scale(normal, 1.0/area); + { + //vec3.scale(normal, 1.0/area); + normal = VecUtils.vecNormalize(3, normal, 1.0); + } return normal; } diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index cf8a91db..1caacd00 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js @@ -1978,12 +1978,20 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { }, setupDragPlanes : { - value: function( hitRec ) { + value: function( hitRec, inGlobalMode ) { // get the location of the point in stage world space var elt = hitRec.getElt(); var localPt = hitRec.getLocalPoint(); var planeMat = hitRec.getPlaneMatrix(); - var stageWorldPt = viewUtils.postViewToStageWorld( MathUtils.transformPoint(localPt,planeMat), elt ); + var stageWorldPt; + if(inGlobalMode) + { + stageWorldPt = MathUtils.transformPoint(localPt,planeMat); + } + else + { + stageWorldPt = viewUtils.postViewToStageWorld( MathUtils.transformPoint(localPt,planeMat), elt ); + } /* // get a working plane parallel to the current working plane through the stage world point diff --git a/js/helper-classes/RDGE/rdge-compiled.js b/js/helper-classes/RDGE/rdge-compiled.js index a211d17f..d1040d73 100755 --- a/js/helper-classes/RDGE/rdge-compiled.js +++ b/js/helper-classes/RDGE/rdge-compiled.js @@ -54,14 +54,14 @@ this.ctx.clearColor(1,0,0,1);this.clearColor=[1,0,0,1];this.clearFlags=this.ctx. 5123;this.INT=5124;this.UNSIGNED_INT=5125;this.FLOAT=5126;this.VS_ELEMENT_FLOAT4=4;this.VS_ELEMENT_FLOAT3=this.VS_ELEMENT_NORM=this.VS_ELEMENT_POS=3;this.VS_ELEMENT_UV=this.VS_ELEMENT_FLOAT2=2;this.VS_ELEMENT_FLOAT=1;this.MAX_ELEM_TYPES=7;this.BUFFER_STATIC=35040;this.BUFFER_DYNAMIC=35044;this.BUFFER_STREAM=35048;this.MAX_MATERIAL_LIGHTS=4;this.usedTextureUnits=5;this.vpY=this.vpX=0;this.vpWidth=a.width;this.vpHeight=a.height;this.cameraMan=new cameraManager;this.buffers=[];this.cullBackFace=function(){this.ctx.cullFace(this.ctx.Back)}; this.cullFrontFace=function(){this.ctx.cullFace(this.ctx.FRONT)};this.disableCulling=function(){this.ctx.disable(this.ctx.CULL_FACE)};this.enableCulling=function(){this.ctx.enable(this.ctx.CULL_FACE)};this.enablePolyOffsetFill=function(){this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL)};this.disablePolyOffsetFill=function(){this.ctx.enable(this.ctx.POLYGON_OFFSET_FILL)};this.enablePointSprites=function(){};this.disablePointSprites=function(){};this.setClearColor=function(a){this.clearColor=a.slice(); this.ctx.clearColor(a[0],a[1],a[2],a[3])};this.setClearFlags=function(a){this.clearFlags=a};this._clear=function(){this.ctx.clear(this.clearFlags)};this.clear=function(a){this.ctx.clear(a)};this.flush=function(){this.ctx.flush()};this.setViewPort=function(a,b,h,l){this.vpX=a;this.vpY=b;this.vpWidth=h;this.vpHeight=l;this.ctx.viewport(this.vpX,this.vpY,this.vpWidth,this.vpHeight)};this.cameraManager=function(){return this.cameraMan};this.textureMap=[];this.rttMap=[];this.getTextureByName=function(a, -b,h){var l=a.split(".")[1],n=this.textureMap[a];n===void 0?(n=this.createTexture(a+(l?"":".png"),b,h),this.textureMap[a]=n,n.lookUpName=a,n.previouslyReferenced=!1):n.previouslyReferenced=!0;return n};this.unloadedTextureCount=0;_texparams=function(a,b){this.wrap=a;this.mips=b};this.createTexture=function(a,b,h){var l=this.ctx.createTexture();this.unloadedTextureCount++;b===void 0&&(b="CLAMP");h===void 0&&(h=!0);if(l)l.image=new Image,l.image.src=a,l.image.context=g_Engine.getContext(),l.texparams= -new _texparams(b,h),l.image.onload=function(){this.context.ctxStateManager.RDGEInitState.loadTexture(l);this.context.renderer.unloadedTextureCount--;l.callback&&l.callback(l);this.context.renderer.unloadedTextureCount<0&&console.log("more textures loaded then created...")},l.image.onerror=function(){this.context.renderer.unloadedTextureCount--;l.callback&&l.callback(l);this.context.renderer.unloadedTextureCount<0&&console.log("more textures loaded then created...")};return l};this.commitTexture=function(a){this.ctx.bindTexture(this.ctx.TEXTURE_2D, -a);this.ctx.texImage2D(this.ctx.TEXTURE_2D,0,this.ctx.RGBA,this.ctx.RGBA,this.ctx.UNSIGNED_BYTE,a.image);a.texparams.mips&&this.ctx.generateMipmap(this.ctx.TEXTURE_2D);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_MAG_FILTER,this.ctx.LINEAR);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_MIN_FILTER,a.texparams.mips?this.ctx.LINEAR_MIPMAP_LINEAR:this.ctx.LINEAR);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_WRAP_S,a.texparams.wrap==="REPEAT"?this.ctx.REPEAT: -this.ctx.CLAMP_TO_EDGE);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_WRAP_T,a.texparams.wrap==="REPEAT"?this.ctx.REPEAT:this.ctx.CLAMP_TO_EDGE);this.ctx.bindTexture(this.ctx.TEXTURE_2D,null)};this.verify=function(a){var b=this.ctx.getError();b!=0&&window.console.log("GLError ( "+a+") : "+b)};this.createRenderTargetTexture=function(a,b,h,l){var n=this.ctx,o=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,o);o.width=b;o.height=h;b=n.createTexture();n.bindTexture(n.TEXTURE_2D,b); -try{n.texImage2D(n.TEXTURE_2D,0,n.RGBA,o.width,o.height,0,n.RGBA,n.UNSIGNED_BYTE,null)}catch(p){h=new WebctxUnsignedByteArray(o.width*o.height*4),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,o.width,o.height,0,n.RGBA,n.UNSIGNED_BYTE,h)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,l?n.LINEAR_MIPMAP_NEAREST:n.LINEAR);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);l&& -n.generateMipmap(n.TEXTURE_2D);l=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,l);n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,o.width,o.height);n.getError(n.bindFramebuffer(n.FRAMEBUFFER,o));n.getError(n.bindRenderbuffer(n.RENDERBUFFER,l));n.getError(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,o.width,o.height));n.bindRenderbuffer(n.RENDERBUFFER,null);n.getError(n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,b,0));n.getError(n.framebufferRenderbuffer(n.FRAMEBUFFER, -n.DEPTH_ATTACHMENT,n.RENDERBUFFER,l));n.bindFramebuffer(n.FRAMEBUFFER,null);n.bindTexture(n.TEXTURE_2D,null);n.bindRenderbuffer(n.RENDERBUFFER,null);n.bindFramebuffer(n.FRAMEBUFFER,null);b.id="RT_"+nodeIdGen.getId();b.frameBuffer=o;this.textureMap[a]&&window.console.log("Notification: render target: "+a+" has overwritten an existing render target");return this.textureMap[a]=b};this.defaultShaderDefintion={shaders:{defaultVShader:"assets/shaders/test_vshader.glsl",defaultFShader:"assets/shaders/test_fshader.glsl"}, -techniques:{defaultTechnique:[{vshader:"defaultVShader",fshader:"defaultFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}}}; +b,h){var l=a.split(".")[1],l=l?"":".png",n=this.textureMap[a];n===void 0?(a=g_Engine.remapAssetFolder(a),n=this.createTexture(a+l,b,h),this.textureMap[a]=n,n.lookUpName=a,n.previouslyReferenced=!1):n.previouslyReferenced=!0;return n};this.unloadedTextureCount=0;_texparams=function(a,b){this.wrap=a;this.mips=b};this.createTexture=function(a,b,h){var l=this.ctx.createTexture();this.unloadedTextureCount++;b===void 0&&(b="CLAMP");h===void 0&&(h=!0);if(l)l.image=new Image,l.image.src=a,l.image.context= +g_Engine.getContext(),l.texparams=new _texparams(b,h),l.image.onload=function(){this.context.ctxStateManager.RDGEInitState.loadTexture(l);this.context.renderer.unloadedTextureCount--;l.callback&&l.callback(l);this.context.renderer.unloadedTextureCount<0&&console.log("more textures loaded then created...")},l.image.onerror=function(){this.context.renderer.unloadedTextureCount--;l.callback&&l.callback(l);this.context.renderer.unloadedTextureCount<0&&console.log("more textures loaded then created...")}; +return l};this.commitTexture=function(a){this.ctx.bindTexture(this.ctx.TEXTURE_2D,a);this.ctx.texImage2D(this.ctx.TEXTURE_2D,0,this.ctx.RGBA,this.ctx.RGBA,this.ctx.UNSIGNED_BYTE,a.image);a.texparams.mips&&this.ctx.generateMipmap(this.ctx.TEXTURE_2D);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_MAG_FILTER,this.ctx.LINEAR);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_MIN_FILTER,a.texparams.mips?this.ctx.LINEAR_MIPMAP_LINEAR:this.ctx.LINEAR);this.ctx.texParameteri(this.ctx.TEXTURE_2D, +this.ctx.TEXTURE_WRAP_S,a.texparams.wrap==="REPEAT"?this.ctx.REPEAT:this.ctx.CLAMP_TO_EDGE);this.ctx.texParameteri(this.ctx.TEXTURE_2D,this.ctx.TEXTURE_WRAP_T,a.texparams.wrap==="REPEAT"?this.ctx.REPEAT:this.ctx.CLAMP_TO_EDGE);this.ctx.bindTexture(this.ctx.TEXTURE_2D,null)};this.verify=function(a){var b=this.ctx.getError();b!=0&&window.console.log("GLError ( "+a+") : "+b)};this.createRenderTargetTexture=function(a,b,h,l){var n=this.ctx,o=n.createFramebuffer();n.bindFramebuffer(n.FRAMEBUFFER,o);o.width= +b;o.height=h;b=n.createTexture();n.bindTexture(n.TEXTURE_2D,b);try{n.texImage2D(n.TEXTURE_2D,0,n.RGBA,o.width,o.height,0,n.RGBA,n.UNSIGNED_BYTE,null)}catch(p){h=new WebctxUnsignedByteArray(o.width*o.height*4),n.texImage2D(n.TEXTURE_2D,0,n.RGBA,o.width,o.height,0,n.RGBA,n.UNSIGNED_BYTE,h)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,l?n.LINEAR_MIPMAP_NEAREST:n.LINEAR);n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE);n.texParameteri(n.TEXTURE_2D, +n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);l&&n.generateMipmap(n.TEXTURE_2D);l=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,l);n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,o.width,o.height);n.getError(n.bindFramebuffer(n.FRAMEBUFFER,o));n.getError(n.bindRenderbuffer(n.RENDERBUFFER,l));n.getError(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,o.width,o.height));n.bindRenderbuffer(n.RENDERBUFFER,null);n.getError(n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D, +b,0));n.getError(n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,l));n.bindFramebuffer(n.FRAMEBUFFER,null);n.bindTexture(n.TEXTURE_2D,null);n.bindRenderbuffer(n.RENDERBUFFER,null);n.bindFramebuffer(n.FRAMEBUFFER,null);b.id="RT_"+nodeIdGen.getId();b.frameBuffer=o;this.textureMap[a]&&window.console.log("Notification: render target: "+a+" has overwritten an existing render target");return this.textureMap[a]=b};this.defaultShaderDefintion={shaders:{defaultVShader:"assets/shaders/test_vshader.glsl", +defaultFShader:"assets/shaders/test_fshader.glsl"},techniques:{defaultTechnique:[{vshader:"defaultVShader",fshader:"defaultFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}}}; rdgeDefaultShaderDefintion={shaders:{defaultVShader:"assets/shaders/Basic.vert.glsl",defaultFShader:"assets/shaders/Basic.frag.glsl"},techniques:{defaultTechnique:[{vshader:"defaultVShader",fshader:"defaultFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}}; rdgeDepthMapShaderDef={shaders:{depthMapVShader:"assets/shaders/depthMap_vshader.glsl",depthMapFShader:"assets/shaders/depthMap_fshader.glsl"},techniques:{shadowDepthMap:[{vshader:"depthMapVShader",fshader:"depthMapFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}],depthMap:[{vshader:"depthMapVShader",fshader:"depthMapFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"},texcoord:{type:"vec2"}}, params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}};rdgeViewSpaceNormalsShader={shaders:{normalsVShader:"assets/shaders/norm_depth_vshader.glsl",normalsFShader:"assets/shaders/norm_depth_fshader.glsl"},techniques:{depthMapWNormal:[{vshader:"normalsVShader",fshader:"normalsFShader",attributes:{vert:{type:"vec3"},normal:{type:"vec3"}},params:{},states:{depthEnable:!0,blendEnable:!1,culling:!0,cullFace:"BACK"}}]}}; @@ -118,22 +118,22 @@ jshader=function(a){this.name=a;this.def=null;this.technique={};this.params={};t "mat4",paramTypeNameMapping[a.SAMPLER_2D]="tex2d",paramTypeNameMapping[a.SAMPLER_CUBE]="texCube";this.bindParameters=function(a){for(var f=a.defParamsList,g=a.lightParams,h=a.lightContext,l=f.length,n=0,o=Array(2),p=0,n=0;n");var f=this.def.shaders[a.vshader],g=this.def.shaders[a.fshader];this.ctx.useProgram(null);var h=null,l=null;f.indexOf("{")!=-1?l=f:(l=new XMLHttpRequest,l.open("GET",f,!1),l.send(null),l=l.responseText);h=this.buildShader(this.ctx.VERTEX_SHADER, -l);l=null;f.indexOf("{")!=-1?l=g:(l=new XMLHttpRequest,l.open("GET",g,!1),l.send(null),l=l.responseText);l=this.buildShader(this.ctx.FRAGMENT_SHADER,l);if(!h||!l)return null;this.compiledShaders[a.vshader]=h;this.compiledShaders[a.fshader]=l;f=this.ctx.createProgram();if(!f)return null;this.ctx.attachShader(f,h);this.ctx.attachShader(f,l);g=0;a.attribPairs=[];for(var n in a.attributes)a.attribPairs.push({loc:g,name:n}),this.ctx.bindAttribLocation(f,g++,n);this.ctx.linkProgram(f);return!this.ctx.getProgramParameter(f, -this.ctx.LINK_STATUS)?(a=this.ctx.getProgramInfoLog(f),window.console.log("Error in program linking:"+a),this.ctx.deleteProgram(f),this.ctx.deleteProgram(l),this.ctx.deleteProgram(h),null):f};this.setLightContext=function(a){for(t in this.technique)for(var f=this.technique.passes.length,g=0;g");var f=this.def.shaders[a.vshader],g=this.def.shaders[a.fshader];this.ctx.useProgram(null);var h=null,l=null;f.indexOf("{")!=-1? +l=f:(l=new XMLHttpRequest,l.open("GET",f,!1),l.send(null),l=l.responseText);h=this.buildShader(this.ctx.VERTEX_SHADER,l);l=null;f.indexOf("{")!=-1?l=g:(l=new XMLHttpRequest,l.open("GET",g,!1),l.send(null),l=l.responseText);l=this.buildShader(this.ctx.FRAGMENT_SHADER,l);if(!h||!l)return null;this.compiledShaders[a.vshader]=h;this.compiledShaders[a.fshader]=l;f=this.ctx.createProgram();if(!f)return null;this.ctx.attachShader(f,h);this.ctx.attachShader(f,l);g=0;a.attribPairs=[];for(var n in a.attributes)a.attribPairs.push({loc:g, +name:n}),this.ctx.bindAttribLocation(f,g++,n);this.ctx.linkProgram(f);return!this.ctx.getProgramParameter(f,this.ctx.LINK_STATUS)?(a=this.ctx.getProgramInfoLog(f),window.console.log("Error in program linking:"+a),this.ctx.deleteProgram(f),this.ctx.deleteProgram(l),this.ctx.deleteProgram(h),null):f};this.setLightContext=function(a){for(t in this.technique)for(var f=this.technique.passes.length,g=0;ge[0]+a)return!1;b=Math.abs(d[1]);if(Math.abs(m[1])>e[1]+b)return!1;f=Math.abs(d[2]);if(Math.abs(m[2])>e[2]+f)return!1;a+=1.192092896E-7;b+=1.192092896E-7;f+=1.192092896E-7;return Math.abs(m[1]*d[2]-m[2]*d[1])>e[1]*f+e[2]*b?!1:Math.abs(m[2]*d[0]-m[0]*d[2])>e[0]*f+e[2]*a?!1:Math.abs(m[0]*d[1]-m[1]* d[0])>e[0]*b+e[1]*a?!1:!0}function hitTest(a,b,f){for(var g=null,h=null,l=0;l