|
@@ -55,8 +55,8 @@ this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matri
|
|
|
THREE.Projector=function(){function b(){var b=r[m]=r[m]||new THREE.RenderableVertex;m++;return b}function c(b,c){return c.z-b.z}function d(b,c){var d=0,f=1,e=b.z+b.w,j=c.z+c.w,h=-b.z+b.w,k=-c.z+c.w;return e>=0&&j>=0&&h>=0&&k>=0?!0:e<0&&j<0||h<0&&k<0?!1:(e<0?d=Math.max(d,e/(e-j)):j<0&&(f=Math.min(f,e/(e-j))),h<0?d=Math.max(d,h/(h-k)):k<0&&(f=Math.min(f,h/(h-k))),f<d?!1:(b.lerpSelf(c,d),c.lerpSelf(b,1-f),!0))}var e,j,h=[],k,m,r=[],p,u,n=[],s,v=[],B,y,E=[],C,xa,ya=[],pa=[],ra=[],fa=new THREE.Vector4,
|
|
|
F=new THREE.Vector4,w=new THREE.Matrix4,ia=new THREE.Matrix4,L=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ja=new THREE.Vector4,Y=new THREE.Vector4;this.projectVector=function(b,c){w.multiply(c.projectionMatrix,c.matrixWorldInverse);w.multiplyVector3(b);return b};this.unprojectVector=function(b,c){w.multiply(c.matrixWorld,THREE.Matrix4.makeInvert(c.projectionMatrix));w.multiplyVector3(b);return b};this.projectObjects=function(b,d,k){var f,
|
|
|
m;j=pa.length=0;f=b.objects;b=0;for(d=f.length;b<d;b++){m=f[b];var p;if(!(p=!m.visible))if(p=m instanceof THREE.Mesh)if(p=m.frustumCulled){a:{p=void 0;for(var r=m.matrixWorld,u=-m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)),n=0;n<6;n++)if(p=L[n].x*r.n14+L[n].y*r.n24+L[n].z*r.n34+L[n].w,p<=u){p=!1;break a}p=!0}p=!p}if(!p)p=h[j]=h[j]||new THREE.RenderableObject,j++,e=p,fa.copy(m.position),w.multiplyVector3(fa),e.object=m,e.z=fa.z,pa.push(e)}k&&pa.sort(c);return pa};
|
|
|
-this.projectScene=function(e,j,h){var f=j.near,pa=j.far,fa,va,T,Z,J,W,S,V,ga,P,sa,Ga,za,Ea,R,Aa,Ca;xa=y=s=u=ra.length=0;j.matrixAutoUpdate&&j.update(void 0,!0);e.update(void 0,!1,j);w.multiply(j.projectionMatrix,j.matrixWorldInverse);L[0].set(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);L[1].set(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);L[2].set(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);L[3].set(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);L[4].set(w.n41-w.n31,w.n42-w.n32,w.n43-
|
|
|
-w.n33,w.n44-w.n34);L[5].set(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);for(fa=0;fa<6;fa++)ga=L[fa],ga.divideScalar(Math.sqrt(ga.x*ga.x+ga.y*ga.y+ga.z*ga.z));ga=this.projectObjects(e,j,!0);e=0;for(fa=ga.length;e<fa;e++)if(P=ga[e].object,P.visible)if(sa=P.matrixWorld,Ga=P.matrixRotationWorld,za=P.materials,Ea=P.overdraw,m=0,P instanceof THREE.Mesh){R=P.geometry;Z=R.vertices;Aa=R.faces;R=R.faceVertexUvs;va=0;for(T=Z.length;va<T;va++)k=b(),k.positionWorld.copy(Z[va].position),sa.multiplyVector3(k.positionWorld),
|
|
|
+this.projectScene=function(e,j,h){var f=j.near,pa=j.far,fa,va,T,Z,J,W,S,V,wa,P,sa,Ga,za,Ea,R,Aa,Ca;xa=y=s=u=ra.length=0;j.matrixAutoUpdate&&j.update(void 0,!0);e.update(void 0,!1,j);w.multiply(j.projectionMatrix,j.matrixWorldInverse);L[0].set(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);L[1].set(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);L[2].set(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);L[3].set(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);L[4].set(w.n41-w.n31,w.n42-w.n32,w.n43-
|
|
|
+w.n33,w.n44-w.n34);L[5].set(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);for(fa=0;fa<6;fa++)wa=L[fa],wa.divideScalar(Math.sqrt(wa.x*wa.x+wa.y*wa.y+wa.z*wa.z));wa=this.projectObjects(e,j,!0);e=0;for(fa=wa.length;e<fa;e++)if(P=wa[e].object,P.visible)if(sa=P.matrixWorld,Ga=P.matrixRotationWorld,za=P.materials,Ea=P.overdraw,m=0,P instanceof THREE.Mesh){R=P.geometry;Z=R.vertices;Aa=R.faces;R=R.faceVertexUvs;va=0;for(T=Z.length;va<T;va++)k=b(),k.positionWorld.copy(Z[va].position),sa.multiplyVector3(k.positionWorld),
|
|
|
k.positionScreen.copy(k.positionWorld),w.multiplyVector4(k.positionScreen),k.positionScreen.x/=k.positionScreen.w,k.positionScreen.y/=k.positionScreen.w,k.visible=k.positionScreen.z>f&&k.positionScreen.z<pa;Z=0;for(va=Aa.length;Z<va;Z++){T=Aa[Z];if(T instanceof THREE.Face3)if(J=r[T.a],W=r[T.b],S=r[T.c],J.visible&&W.visible&&S.visible&&(P.doubleSided||P.flipSided!=(S.positionScreen.x-J.positionScreen.x)*(W.positionScreen.y-J.positionScreen.y)-(S.positionScreen.y-J.positionScreen.y)*(W.positionScreen.x-
|
|
|
J.positionScreen.x)<0))V=n[u]=n[u]||new THREE.RenderableFace3,u++,p=V,p.v1.copy(J),p.v2.copy(W),p.v3.copy(S);else continue;else if(T instanceof THREE.Face4)if(J=r[T.a],W=r[T.b],S=r[T.c],V=r[T.d],J.visible&&W.visible&&S.visible&&V.visible&&(P.doubleSided||P.flipSided!=((V.positionScreen.x-J.positionScreen.x)*(W.positionScreen.y-J.positionScreen.y)-(V.positionScreen.y-J.positionScreen.y)*(W.positionScreen.x-J.positionScreen.x)<0||(W.positionScreen.x-S.positionScreen.x)*(V.positionScreen.y-S.positionScreen.y)-
|
|
|
(W.positionScreen.y-S.positionScreen.y)*(V.positionScreen.x-S.positionScreen.x)<0)))Ca=v[s]=v[s]||new THREE.RenderableFace4,s++,p=Ca,p.v1.copy(J),p.v2.copy(W),p.v3.copy(S),p.v4.copy(V);else continue;p.normalWorld.copy(T.normal);Ga.multiplyVector3(p.normalWorld);p.centroidWorld.copy(T.centroid);sa.multiplyVector3(p.centroidWorld);p.centroidScreen.copy(p.centroidWorld);w.multiplyVector3(p.centroidScreen);S=T.vertexNormals;J=0;for(W=S.length;J<W;J++)V=p.vertexNormalsWorld[J],V.copy(S[J]),Ga.multiplyVector3(V);
|
|
@@ -201,11 +201,11 @@ f.vertexAttribPointer(b.skinWeight,4,f.FLOAT,!1,0,0));k instanceof THREE.Mesh?(j
|
|
|
f.LINE_STRIP:f.LINES,f.lineWidth(j.linewidth),f.drawArrays(k,0,h.__webglLineCount),M.data.drawCalls++):k instanceof THREE.ParticleSystem?(f.drawArrays(f.POINTS,0,h.__webglParticleCount),M.data.drawCalls++):k instanceof THREE.Ribbon&&(f.drawArrays(f.TRIANGLE_STRIP,0,h.__webglVertexCount),M.data.drawCalls++)}}function j(b,c,d){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=f.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=f.createBuffer();b.hasPos&&(f.bindBuffer(f.ARRAY_BUFFER,b.__webglVertexBuffer),
|
|
|
f.bufferData(f.ARRAY_BUFFER,b.positionArray,f.DYNAMIC_DRAW),f.enableVertexAttribArray(c.attributes.position),f.vertexAttribPointer(c.attributes.position,3,f.FLOAT,!1,0,0));if(b.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,b.__webglNormalBuffer);if(d==THREE.FlatShading){var e,h,j,k,m,H,p,r,n,q,u=b.count*3;for(q=0;q<u;q+=9)d=b.normalArray,e=d[q],h=d[q+1],j=d[q+2],k=d[q+3],H=d[q+4],r=d[q+5],m=d[q+6],p=d[q+7],n=d[q+8],e=(e+k+m)/3,h=(h+H+p)/3,j=(j+r+n)/3,d[q]=e,d[q+1]=h,d[q+2]=j,d[q+3]=e,d[q+4]=h,d[q+5]=j,d[q+
|
|
|
6]=e,d[q+7]=h,d[q+8]=j}f.bufferData(f.ARRAY_BUFFER,b.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(c.attributes.normal);f.vertexAttribPointer(c.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,b.count);b.count=0}function h(b){if(T!=b.doubleSided)b.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE),T=b.doubleSided;if(Z!=b.flipSided)b.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW),Z=b.flipSided}function k(b){W!=b&&(b?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST),W=b)}function m(b){S!=
|
|
|
-b&&(f.depthMask(b),S=b)}function r(b,c,d){V!=b&&(b?f.enable(f.POLYGON_OFFSET_FILL):f.disable(f.POLYGON_OFFSET_FILL),V=b);if(b&&(ga!=c||P!=d))f.polygonOffset(c,d),ga=c,P=d}function p(b){R[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);R[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);R[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);R[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);R[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);R[5].set(b.n41+b.n31,b.n42+
|
|
|
+b&&(f.depthMask(b),S=b)}function r(b,c,d){V!=b&&(b?f.enable(f.POLYGON_OFFSET_FILL):f.disable(f.POLYGON_OFFSET_FILL),V=b);if(b&&(wa!=c||P!=d))f.polygonOffset(c,d),wa=c,P=d}function p(b){R[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);R[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);R[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);R[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);R[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);R[5].set(b.n41+b.n31,b.n42+
|
|
|
b.n32,b.n43+b.n33,b.n44+b.n34);for(var c,b=0;b<6;b++)c=R[b],c.divideScalar(Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z))}function u(b){for(var c=b.matrixWorld,f=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),d=0;d<6;d++)if(b=R[d].x*c.n14+R[d].y*c.n24+R[d].z*c.n34+R[d].w,b<=f)return!1;return!0}function n(b,c){b.list[b.count]=c;b.count+=1}function s(b){var c,d,f=b.object,e=b.opaque,h=b.transparent;h.count=0;b=e.count=0;for(c=f.materials.length;b<c;b++)d=f.materials[b],d.transparent?
|
|
|
n(h,d):n(e,d)}function v(b){var c,d,f,e,h=b.object,j=b.buffer,k=b.opaque,m=b.transparent;m.count=0;b=k.count=0;for(f=h.materials.length;b<f;b++)if(c=h.materials[b],c instanceof THREE.MeshFaceMaterial){c=0;for(d=j.materials.length;c<d;c++)(e=j.materials[c])&&(e.transparent?n(m,e):n(k,e))}else(e=c)&&(e.transparent?n(m,e):n(k,e))}function B(b,c){return c.z-b.z}function y(b,c){var m,r,Ma,q=0,n,s,H,I,D=b.lights;qa||(qa=new THREE.Camera(M.shadowCameraFov,c.aspect,M.shadowCameraNear,M.shadowCameraFar));
|
|
|
m=0;for(r=D.length;m<r;m++)if(Ma=D[m],Ma instanceof THREE.SpotLight&&Ma.castShadow){M.shadowMap[q]||(M.shadowMap[q]=new THREE.WebGLRenderTarget(M.shadowMapWidth,M.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));Sa[q]||(Sa[q]=new THREE.Matrix4);n=M.shadowMap[q];s=Sa[q];qa.position.copy(Ma.position);qa.target.position.copy(Ma.target.position);qa.update(void 0,!0);b.update(void 0,!1,qa);s.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);s.multiplySelf(qa.projectionMatrix);
|
|
|
-s.multiplySelf(qa.matrixWorldInverse);qa.matrixWorldInverse.flattenToArray(Ta);qa.projectionMatrix.flattenToArray(Ca);Aa.multiply(qa.projectionMatrix,qa.matrixWorldInverse);p(Aa);M.initWebGLObjects(b);L(n);f.clearColor(1,1,1,1);M.clear();f.clearColor(wa.r,wa.g,wa.b,Ka);s=b.__webglObjects.length;Ma=b.__webglObjectsImmediate.length;for(n=0;n<s;n++)H=b.__webglObjects[n],I=H.object,I.visible&&I.castShadow?!(I instanceof THREE.Mesh)||!I.frustumCulled||u(I)?(I.matrixWorld.flattenToArray(I._objectMatrixArray),
|
|
|
+s.multiplySelf(qa.matrixWorldInverse);qa.matrixWorldInverse.flattenToArray(Ta);qa.projectionMatrix.flattenToArray(Ca);Aa.multiply(qa.projectionMatrix,qa.matrixWorldInverse);p(Aa);M.initWebGLObjects(b);L(n);f.clearColor(1,1,1,1);M.clear();f.clearColor(ga.r,ga.g,ga.b,Ka);s=b.__webglObjects.length;Ma=b.__webglObjectsImmediate.length;for(n=0;n<s;n++)H=b.__webglObjects[n],I=H.object,I.visible&&I.castShadow?!(I instanceof THREE.Mesh)||!I.frustumCulled||u(I)?(I.matrixWorld.flattenToArray(I._objectMatrixArray),
|
|
|
C(I,qa,!1),H.render=!0):H.render=!1:H.render=!1;k(!0);F(THREE.NormalBlending);for(n=0;n<s;n++)if(H=b.__webglObjects[n],H.render)I=H.object,buffer=H.buffer,h(I),H=I.customDepthMaterial?I.customDepthMaterial:I.geometry.morphTargets.length?Xa:Ua,e(qa,D,null,H,buffer,I);for(n=0;n<Ma;n++)H=b.__webglObjectsImmediate[n],I=H.object,I.visible&&I.castShadow&&(I.matrixAutoUpdate&&I.matrixWorld.flattenToArray(I._objectMatrixArray),C(I,qa,!1),h(I),program=d(qa,D,null,Ua,I),I.render(function(b){j(b,program,Ua.shading)}));
|
|
|
q++}}function E(b,c){var d,e,h;d=q.attributes;var j=q.uniforms,k=Ea/za,m,p=[],r=za*0.5,n=Ea*0.5,s=!0;f.useProgram(q.program);Va=q.program;W=J=-1;Ya||(f.enableVertexAttribArray(q.attributes.position),f.enableVertexAttribArray(q.attributes.uv),Ya=!0);f.disable(f.CULL_FACE);f.enable(f.BLEND);f.depthMask(!0);f.bindBuffer(f.ARRAY_BUFFER,q.vertexBuffer);f.vertexAttribPointer(d.position,2,f.FLOAT,!1,16,0);f.vertexAttribPointer(d.uv,2,f.FLOAT,!1,16,8);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,q.elementBuffer);
|
|
|
f.uniformMatrix4fv(j.projectionMatrix,!1,Ca);f.activeTexture(f.TEXTURE0);f.uniform1i(j.map,0);d=0;for(e=b.__webglSprites.length;d<e;d++)h=b.__webglSprites[d],h.useScreenCoordinates?h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(B);d=0;for(e=b.__webglSprites.length;d<e;d++)h=b.__webglSprites[d],h.material===void 0&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(f.uniform1i(j.useScreenCoordinates,
|
|
@@ -224,23 +224,23 @@ f.bindFramebuffer(f.FRAMEBUFFER,null)}var e,h;b?(c=c?b.__webglFramebuffer[b.acti
|
|
|
f.bindTexture(f.TEXTURE_2D,null))}function Y(b,c){var d;b=="fragment"?d=f.createShader(f.FRAGMENT_SHADER):b=="vertex"&&(d=f.createShader(f.VERTEX_SHADER));f.shaderSource(d,c);f.compileShader(d);if(!f.getShaderParameter(d,f.COMPILE_STATUS))return console.error(f.getShaderInfoLog(d)),console.error(c),null;return d}function ua(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;default:return f.LINEAR}}function Q(b){switch(b){case THREE.RepeatWrapping:return f.REPEAT;
|
|
|
case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return f.BYTE;
|
|
|
case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var M=this,f,Da=[],Va=
|
|
|
-null,va=null,T=null,Z=null,J=null,W=null,S=null,V=null,ga=null,P=null,sa=0,Ga=0,za=0,Ea=0,R=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Aa=new THREE.Matrix4,Ca=new Float32Array(16),Ta=new Float32Array(16),Ia=new THREE.Vector4,Wa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ja=b.canvas!==void 0?b.canvas:document.createElement("canvas"),ab=b.stencil!==void 0?
|
|
|
-b.stencil:!0,bb=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,cb=b.antialias!==void 0?b.antialias:!1,wa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ka=b.clearAlpha!==void 0?b.clearAlpha:0;_maxLights=b.maxLights!==void 0?b.maxLights:4;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=Ja;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=
|
|
|
+null,va=null,T=null,Z=null,J=null,W=null,S=null,V=null,wa=null,P=null,sa=0,Ga=0,za=0,Ea=0,R=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Aa=new THREE.Matrix4,Ca=new Float32Array(16),Ta=new Float32Array(16),Ia=new THREE.Vector4,Wa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ja=b.canvas!==void 0?b.canvas:document.createElement("canvas"),ab=b.stencil!==void 0?
|
|
|
+b.stencil:!0,bb=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,cb=b.antialias!==void 0?b.antialias:!1,ga=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ka=b.clearAlpha!==void 0?b.clearAlpha:0;_maxLights=b.maxLights!==void 0?b.maxLights:4;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=Ja;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=
|
|
|
1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var qa,Sa=[],b=THREE.ShaderLib.depthRGBA,Za=THREE.UniformsUtils.clone(b.uniforms),Ua=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Za}),Xa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Za,morphTargets:!0});Ua._shadowPass=!0;Xa._shadowPass=!0;try{if(!(f=Ja.getContext("experimental-webgl",
|
|
|
{antialias:cb,stencil:ab,preserveDrawingBuffer:bb})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+f.getParameter(f.VERSION)+" | "+f.getParameter(f.VENDOR)+" | "+f.getParameter(f.RENDERER)+" | "+f.getParameter(f.SHADING_LANGUAGE_VERSION))}catch(db){console.error(db)}f.clearColor(0,0,0,1);f.clearDepth(1);f.clearStencil(0);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);
|
|
|
-f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);f.clearColor(wa.r,wa.g,wa.b,Ka);this.context=f;var $a=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,q={};q.vertices=new Float32Array(16);q.faces=new Uint16Array(6);i=0;q.vertices[i++]=-1;q.vertices[i++]=-1;q.vertices[i++]=0;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=-1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=0;q.vertices[i++]=-1;q.vertices[i++]=1;q.vertices[i++]=0;i=q.vertices[i++]=
|
|
|
+f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);f.clearColor(ga.r,ga.g,ga.b,Ka);this.context=f;var $a=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,q={};q.vertices=new Float32Array(16);q.faces=new Uint16Array(6);i=0;q.vertices[i++]=-1;q.vertices[i++]=-1;q.vertices[i++]=0;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=-1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=0;q.vertices[i++]=-1;q.vertices[i++]=1;q.vertices[i++]=0;i=q.vertices[i++]=
|
|
|
0;q.faces[i++]=0;q.faces[i++]=1;q.faces[i++]=2;q.faces[i++]=0;q.faces[i++]=2;q.faces[i++]=3;q.vertexBuffer=f.createBuffer();q.elementBuffer=f.createBuffer();f.bindBuffer(f.ARRAY_BUFFER,q.vertexBuffer);f.bufferData(f.ARRAY_BUFFER,q.vertices,f.STATIC_DRAW);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,q.elementBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,q.faces,f.STATIC_DRAW);q.program=f.createProgram();f.attachShader(q.program,Y("fragment",THREE.ShaderLib.sprite.fragmentShader));f.attachShader(q.program,Y("vertex",
|
|
|
THREE.ShaderLib.sprite.vertexShader));f.linkProgram(q.program);q.attributes={};q.uniforms={};q.attributes.position=f.getAttribLocation(q.program,"position");q.attributes.uv=f.getAttribLocation(q.program,"uv");q.uniforms.uvOffset=f.getUniformLocation(q.program,"uvOffset");q.uniforms.uvScale=f.getUniformLocation(q.program,"uvScale");q.uniforms.rotation=f.getUniformLocation(q.program,"rotation");q.uniforms.scale=f.getUniformLocation(q.program,"scale");q.uniforms.alignment=f.getUniformLocation(q.program,
|
|
|
"alignment");q.uniforms.map=f.getUniformLocation(q.program,"map");q.uniforms.opacity=f.getUniformLocation(q.program,"opacity");q.uniforms.useScreenCoordinates=f.getUniformLocation(q.program,"useScreenCoordinates");q.uniforms.affectedByDistance=f.getUniformLocation(q.program,"affectedByDistance");q.uniforms.screenPosition=f.getUniformLocation(q.program,"screenPosition");q.uniforms.modelViewMatrix=f.getUniformLocation(q.program,"modelViewMatrix");q.uniforms.projectionMatrix=f.getUniformLocation(q.program,
|
|
|
-"projectionMatrix");var Ya=!1;this.setSize=function(b,c){Ja.width=b;Ja.height=c;this.setViewport(0,0,Ja.width,Ja.height)};this.setViewport=function(b,c,d,e){sa=b;Ga=c;za=d;Ea=e;f.viewport(sa,Ga,za,Ea)};this.setScissor=function(b,c,d,e){f.scissor(b,c,d,e)};this.enableScissorTest=function(b){b?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.setClearColorHex=function(b,c){wa.setHex(b);Ka=c;f.clearColor(wa.r,wa.g,wa.b,Ka)};this.setClearColor=function(b,c){wa.copy(b);Ka=c;f.clearColor(wa.r,wa.g,
|
|
|
-wa.b,Ka)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT|f.STENCIL_BUFFER_BIT)};this.getContext=function(){return f};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c=b.geometry.geometryGroups[g];f.deleteBuffer(c.__webglVertexBuffer);f.deleteBuffer(c.__webglNormalBuffer);f.deleteBuffer(c.__webglTangentBuffer);
|
|
|
-f.deleteBuffer(c.__webglColorBuffer);f.deleteBuffer(c.__webglUVBuffer);f.deleteBuffer(c.__webglUV2Buffer);f.deleteBuffer(c.__webglSkinVertexABuffer);f.deleteBuffer(c.__webglSkinVertexBBuffer);f.deleteBuffer(c.__webglSkinIndicesBuffer);f.deleteBuffer(c.__webglSkinWeightsBuffer);f.deleteBuffer(c.__webglFaceBuffer);f.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,e=c.numMorphTargets;d<e;d++)f.deleteBuffer(c.__webglMorphTargetsBuffers[d])}else if(b instanceof THREE.Ribbon)b=b.geometry,
|
|
|
-f.deleteBuffer(b.__webglVertexBuffer),f.deleteBuffer(b.__webglColorBuffer);else if(b instanceof THREE.Line)b=b.geometry,f.deleteBuffer(b.__webglVertexBuffer),f.deleteBuffer(b.__webglColorBuffer);else if(b instanceof THREE.ParticleSystem)b=b.geometry,f.deleteBuffer(b.__webglVertexBuffer),f.deleteBuffer(b.__webglColorBuffer)};this.deallocateTexture=function(b){if(b.__webglInit)b.__webglInit=!1,f.deleteTexture(b.__webglTexture)};this.initMaterial=function(b,c,d,e){var h,j,k;b instanceof THREE.MeshDepthMaterial?
|
|
|
-k="depth":b instanceof THREE.MeshNormalMaterial?k="normal":b instanceof THREE.MeshBasicMaterial?k="basic":b instanceof THREE.MeshLambertMaterial?k="lambert":b instanceof THREE.MeshPhongMaterial?k="phong":b instanceof THREE.LineBasicMaterial?k="basic":b instanceof THREE.ParticleBasicMaterial&&(k="particle_basic");if(k){var m=THREE.ShaderLib[k];b.uniforms=THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var p,r,n;p=n=m=0;for(r=c.length;p<r;p++)j=
|
|
|
-c[p],j instanceof THREE.SpotLight&&n++,j instanceof THREE.DirectionalLight&&n++,j instanceof THREE.PointLight&&m++;m+n<=_maxLights?p=n:(p=Math.ceil(_maxLights*n/(m+n)),m=_maxLights-p);j={directional:p,point:m};m=n=0;for(p=c.length;m<p;m++)r=c[m],r instanceof THREE.SpotLight&&r.castShadow&&n++;var q=50;if(e!==void 0&&e instanceof THREE.SkinnedMesh)q=e.bones.length;var s;a:{p=b.fragmentShader;r=b.vertexShader;var m=b.uniforms,c=b.attributes,d={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,
|
|
|
-fog:d,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:j.directional,maxPointLights:j.point,maxBones:q,shadowMapEnabled:this.shadowMapEnabled&&e.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:n,alphaTest:b.alphaTest},u,e=[];k?e.push(k):(e.push(p),e.push(r));for(u in d)e.push(u),e.push(d[u]);k=e.join();u=0;for(e=Da.length;u<e;u++)if(Da[u].code==
|
|
|
-k){s=Da[u].program;break a}u=f.createProgram();e=[$a?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,"#define MAX_BONES "+d.maxBones,d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.skinning?"#define USE_SKINNING":"",d.morphTargets?"#define USE_MORPHTARGETS":"",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapSoft?
|
|
|
-"#define SHADOWMAP_SOFT":"",d.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
|
|
|
+"projectionMatrix");var Ya=!1;this.setSize=function(b,c){Ja.width=b;Ja.height=c;this.setViewport(0,0,Ja.width,Ja.height)};this.setViewport=function(b,c,d,e){sa=b;Ga=c;za=d;Ea=e;f.viewport(sa,Ga,za,Ea)};this.setScissor=function(b,c,d,e){f.scissor(b,c,d,e)};this.enableScissorTest=function(b){b?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.setClearColorHex=function(b,c){ga.setHex(b);Ka=c;f.clearColor(ga.r,ga.g,ga.b,Ka)};this.setClearColor=function(b,c){ga.copy(b);Ka=c;f.clearColor(ga.r,ga.g,
|
|
|
+ga.b,Ka)};this.getClearColor=function(b){b.copy(ga)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT|f.STENCIL_BUFFER_BIT)};this.getContext=function(){return f};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c=b.geometry.geometryGroups[g];f.deleteBuffer(c.__webglVertexBuffer);f.deleteBuffer(c.__webglNormalBuffer);
|
|
|
+f.deleteBuffer(c.__webglTangentBuffer);f.deleteBuffer(c.__webglColorBuffer);f.deleteBuffer(c.__webglUVBuffer);f.deleteBuffer(c.__webglUV2Buffer);f.deleteBuffer(c.__webglSkinVertexABuffer);f.deleteBuffer(c.__webglSkinVertexBBuffer);f.deleteBuffer(c.__webglSkinIndicesBuffer);f.deleteBuffer(c.__webglSkinWeightsBuffer);f.deleteBuffer(c.__webglFaceBuffer);f.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,e=c.numMorphTargets;d<e;d++)f.deleteBuffer(c.__webglMorphTargetsBuffers[d])}else if(b instanceof
|
|
|
+THREE.Ribbon)b=b.geometry,f.deleteBuffer(b.__webglVertexBuffer),f.deleteBuffer(b.__webglColorBuffer);else if(b instanceof THREE.Line)b=b.geometry,f.deleteBuffer(b.__webglVertexBuffer),f.deleteBuffer(b.__webglColorBuffer);else if(b instanceof THREE.ParticleSystem)b=b.geometry,f.deleteBuffer(b.__webglVertexBuffer),f.deleteBuffer(b.__webglColorBuffer)};this.deallocateTexture=function(b){if(b.__webglInit)b.__webglInit=!1,f.deleteTexture(b.__webglTexture)};this.initMaterial=function(b,c,d,e){var h,j,k;
|
|
|
+b instanceof THREE.MeshDepthMaterial?k="depth":b instanceof THREE.MeshNormalMaterial?k="normal":b instanceof THREE.MeshBasicMaterial?k="basic":b instanceof THREE.MeshLambertMaterial?k="lambert":b instanceof THREE.MeshPhongMaterial?k="phong":b instanceof THREE.LineBasicMaterial?k="basic":b instanceof THREE.ParticleBasicMaterial&&(k="particle_basic");if(k){var m=THREE.ShaderLib[k];b.uniforms=THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var p,
|
|
|
+r,n;p=n=m=0;for(r=c.length;p<r;p++)j=c[p],j instanceof THREE.SpotLight&&n++,j instanceof THREE.DirectionalLight&&n++,j instanceof THREE.PointLight&&m++;m+n<=_maxLights?p=n:(p=Math.ceil(_maxLights*n/(m+n)),m=_maxLights-p);j={directional:p,point:m};m=n=0;for(p=c.length;m<p;m++)r=c[m],r instanceof THREE.SpotLight&&r.castShadow&&n++;var q=50;if(e!==void 0&&e instanceof THREE.SkinnedMesh)q=e.bones.length;var s;a:{p=b.fragmentShader;r=b.vertexShader;var m=b.uniforms,c=b.attributes,d={map:!!b.map,envMap:!!b.envMap,
|
|
|
+lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:d,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:j.directional,maxPointLights:j.point,maxBones:q,shadowMapEnabled:this.shadowMapEnabled&&e.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:n,alphaTest:b.alphaTest},u,e=[];k?e.push(k):(e.push(p),e.push(r));for(u in d)e.push(u),e.push(d[u]);
|
|
|
+k=e.join();u=0;for(e=Da.length;u<e;u++)if(Da[u].code==k){s=Da[u].program;break a}u=f.createProgram();e=[$a?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,"#define MAX_BONES "+d.maxBones,d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.skinning?"#define USE_SKINNING":"",d.morphTargets?"#define USE_MORPHTARGETS":
|
|
|
+"",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapSoft?"#define SHADOWMAP_SOFT":"",d.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
|
|
|
j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,d.alphaTest?"#define ALPHATEST "+d.alphaTest:"",d.fog?"#define USE_FOG":"",d.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapSoft?"#define SHADOWMAP_SOFT":
|
|
|
"",d.shadowMapSoft?"#define SHADOWMAP_WIDTH "+d.shadowMapWidth.toFixed(1):"",d.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+d.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");f.attachShader(u,Y("fragment",j+p));f.attachShader(u,Y("vertex",e+r));f.linkProgram(u);f.getProgramParameter(u,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(u,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");u.uniforms=
|
|
|
{};u.attributes={};var v,e=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(v in m)e.push(v);v=e;e=0;for(m=v.length;e<m;e++)p=v[e],u.uniforms[p]=f.getUniformLocation(u,p);e=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(v=0;v<d.maxMorphTargets;v++)e.push("morphTarget"+v);for(s in c)e.push(s);s=e;v=0;for(c=s.length;v<c;v++)d=
|