|
@@ -254,26 +254,26 @@ h=i.value[h];i.array[g]=h.x;i.array[g+1]=h.y;i.array[g+2]=h.z;i.array[g+3]=h.w;g
|
|
|
m,b)}if(r){j=0;for(l=r.length;j<l;j++){i=r[j];if(i.needsUpdate||c.sortParticles){f.bindBuffer(f.ARRAY_BUFFER,i.buffer);f.bufferData(f.ARRAY_BUFFER,i.array,b)}}}}function h(a,b){return b.z-a.z}function k(a,b){return b[1]-a[1]}function m(a,b,c){if(a.length)for(var d=0,f=a.length;d<f;d++){ga=za=null;na=ca=Ha=Ba=nb=Xa=Ia=-1;ob=true;a[d].render(b,c,$b,ac);ga=za=null;na=ca=Ha=Ba=nb=Xa=Ia=-1;ob=true}}function j(a,b,c,d,f,e,g,h){var i,j,l,k;if(b){j=a.length-1;k=b=-1}else{j=0;b=a.length;k=1}for(var m=j;m!==
|
|
|
b;m=m+k){i=a[m];if(i.render){j=i.object;l=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;g&&E.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);E.setDepthTest(i.depthTest);E.setDepthWrite(i.depthWrite);q(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}E.setObjectFaces(j);l instanceof THREE.BufferGeometry?E.renderBufferDirect(d,f,e,i,l,j):E.renderBuffer(d,f,e,i,l,j)}}}function i(a,b,c,d,f,e,g){for(var i,h,j=0,l=a.length;j<l;j++){i=a[j];h=i.object;if(h.visible){if(g)i=g;else{i=
|
|
|
i[b];if(!i)continue;e&&E.setBlending(i.blending,i.blendEquation,i.blendSrc,i.blendDst);E.setDepthTest(i.depthTest);E.setDepthWrite(i.depthWrite);q(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}E.renderImmediateObject(c,d,f,i,h)}}}function p(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function l(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return true;return false}function v(a){for(var b in a.attributes)a.attributes[b].needsUpdate=false}function o(a,
|
|
|
-b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function r(a,b,c,d,e){if(!d.program||d.needsUpdate){d.program&&E.deallocateMaterial(d);E.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(E.maxMorphTargets);for(var g=0,i=E.maxMorphTargets;g<i;g++)e.__webglMorphTargetInfluences[g]=0}var h=false,g=d.program,i=g.uniforms,j=d.uniforms;
|
|
|
-if(g!==za){f.useProgram(g);za=g;h=true}if(d.id!==na){na=d.id;h=true}if(h||a!==ga){f.uniformMatrix4fv(i.projectionMatrix,false,a._projectionMatrixArray);a!==ga&&(ga=a)}if(h){if(c&&d.fog){j.fogColor.value=c.color;if(c instanceof THREE.Fog){j.fogNear.value=c.near;j.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(ob){for(var l,k=0,m=0,n=0,p,o,r,q=bc,v=q.directional.colors,s=
|
|
|
-q.directional.positions,w=q.point.colors,z=q.point.positions,H=q.point.distances,D=q.spot.colors,F=q.spot.positions,L=q.spot.distances,K=q.spot.directions,M=q.spot.angles,Q=q.spot.exponents,R=0,T=0,S=0,I=r=0,c=I=0,h=b.length;c<h;c++){l=b[c];if(!l.onlyShadow){p=l.color;o=l.intensity;r=l.distance;if(l instanceof THREE.AmbientLight)if(E.gammaInput){k=k+p.r*p.r;m=m+p.g*p.g;n=n+p.b*p.b}else{k=k+p.r;m=m+p.g;n=n+p.b}else if(l instanceof THREE.DirectionalLight){r=R*3;if(E.gammaInput){v[r]=p.r*p.r*o*o;v[r+
|
|
|
-1]=p.g*p.g*o*o;v[r+2]=p.b*p.b*o*o}else{v[r]=p.r*o;v[r+1]=p.g*o;v[r+2]=p.b*o}Ca.copy(l.matrixWorld.getPosition());Ca.subSelf(l.target.matrixWorld.getPosition());Ca.normalize();s[r]=Ca.x;s[r+1]=Ca.y;s[r+2]=Ca.z;R=R+1}else if(l instanceof THREE.PointLight){I=T*3;if(E.gammaInput){w[I]=p.r*p.r*o*o;w[I+1]=p.g*p.g*o*o;w[I+2]=p.b*p.b*o*o}else{w[I]=p.r*o;w[I+1]=p.g*o;w[I+2]=p.b*o}p=l.matrixWorld.getPosition();z[I]=p.x;z[I+1]=p.y;z[I+2]=p.z;H[T]=r;T=T+1}else if(l instanceof THREE.SpotLight){I=S*3;if(E.gammaInput){D[I]=
|
|
|
-p.r*p.r*o*o;D[I+1]=p.g*p.g*o*o;D[I+2]=p.b*p.b*o*o}else{D[I]=p.r*o;D[I+1]=p.g*o;D[I+2]=p.b*o}p=l.matrixWorld.getPosition();F[I]=p.x;F[I+1]=p.y;F[I+2]=p.z;L[S]=r;Ca.copy(p);Ca.subSelf(l.target.matrixWorld.getPosition());Ca.normalize();K[I]=Ca.x;K[I+1]=Ca.y;K[I+2]=Ca.z;M[S]=Math.cos(l.angle);Q[S]=l.exponent;S=S+1}}}c=R*3;for(h=v.length;c<h;c++)v[c]=0;c=T*3;for(h=w.length;c<h;c++)w[c]=0;c=S*3;for(h=D.length;c<h;c++)D[c]=0;q.directional.length=R;q.point.length=T;q.spot.length=S;q.ambient[0]=k;q.ambient[1]=
|
|
|
-m;q.ambient[2]=n;ob=false}c=bc;j.ambientLightColor.value=c.ambient;j.directionalLightColor.value=c.directional.colors;j.directionalLightDirection.value=c.directional.positions;j.pointLightColor.value=c.point.colors;j.pointLightPosition.value=c.point.positions;j.pointLightDistance.value=c.point.distances;j.spotLightColor.value=c.spot.colors;j.spotLightPosition.value=c.spot.positions;j.spotLightDistance.value=c.spot.distances;j.spotLightDirection.value=c.spot.directions;j.spotLightAngle.value=c.spot.angles;
|
|
|
-j.spotLightExponent.value=c.spot.exponents}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial){j.opacity.value=d.opacity;E.gammaInput?j.diffuse.value.copyGammaToLinear(d.color):j.diffuse.value=d.color;(j.map.texture=d.map)&&j.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y);j.lightMap.texture=d.lightMap;j.envMap.texture=d.envMap;j.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:
|
|
|
--1;j.reflectivity.value=d.reflectivity;j.refractionRatio.value=d.refractionRatio;j.combine.value=d.combine;j.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping}if(d instanceof THREE.LineBasicMaterial){j.diffuse.value=d.color;j.opacity.value=d.opacity}else if(d instanceof THREE.ParticleBasicMaterial){j.psColor.value=d.color;j.opacity.value=d.opacity;j.size.value=d.size;j.scale.value=G.height/2;j.map.texture=d.map}else if(d instanceof THREE.MeshPhongMaterial){j.shininess.value=
|
|
|
-d.shininess;if(E.gammaInput){j.ambient.value.copyGammaToLinear(d.ambient);j.emissive.value.copyGammaToLinear(d.emissive);j.specular.value.copyGammaToLinear(d.specular)}else{j.ambient.value=d.ambient;j.emissive.value=d.emissive;j.specular.value=d.specular}d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB)}else if(d instanceof THREE.MeshLambertMaterial){if(E.gammaInput){j.ambient.value.copyGammaToLinear(d.ambient);j.emissive.value.copyGammaToLinear(d.emissive)}else{j.ambient.value=d.ambient;j.emissive.value=
|
|
|
-d.emissive}d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB)}else if(d instanceof THREE.MeshDepthMaterial){j.mNear.value=a.near;j.mFar.value=a.far;j.opacity.value=d.opacity}else if(d instanceof THREE.MeshNormalMaterial)j.opacity.value=d.opacity;if(e.receiveShadow&&!d._shadowPass&&j.shadowMatrix){h=c=0;for(l=b.length;h<l;h++){k=b[h];if(k.castShadow&&(k instanceof THREE.SpotLight||k instanceof THREE.DirectionalLight&&!k.shadowCascade)){j.shadowMap.texture[c]=k.shadowMap;j.shadowMapSize.value[c]=k.shadowMapSize;
|
|
|
-j.shadowMatrix.value[c]=k.shadowMatrix;j.shadowDarkness.value[c]=k.shadowDarkness;j.shadowBias.value[c]=k.shadowBias;c++}}}b=d.uniformsList;j=0;for(c=b.length;j<c;j++)if(k=g.uniforms[b[j][1]]){h=b[j][0];m=h.type;l=h.value;switch(m){case "i":f.uniform1i(k,l);break;case "f":f.uniform1f(k,l);break;case "v2":f.uniform2f(k,l.x,l.y);break;case "v3":f.uniform3f(k,l.x,l.y,l.z);break;case "v4":f.uniform4f(k,l.x,l.y,l.z,l.w);break;case "c":f.uniform3f(k,l.r,l.g,l.b);break;case "fv1":f.uniform1fv(k,l);break;
|
|
|
-case "fv":f.uniform3fv(k,l);break;case "v2v":if(!h._array)h._array=new Float32Array(2*l.length);m=0;for(n=l.length;m<n;m++){q=m*2;h._array[q]=l[m].x;h._array[q+1]=l[m].y}f.uniform2fv(k,h._array);break;case "v3v":if(!h._array)h._array=new Float32Array(3*l.length);m=0;for(n=l.length;m<n;m++){q=m*3;h._array[q]=l[m].x;h._array[q+1]=l[m].y;h._array[q+2]=l[m].z}f.uniform3fv(k,h._array);break;case "v4v":if(!h._array)h._array=new Float32Array(4*l.length);m=0;for(n=l.length;m<n;m++){q=m*4;h._array[q]=l[m].x;
|
|
|
-h._array[q+1]=l[m].y;h._array[q+2]=l[m].z;h._array[q+3]=l[m].w}f.uniform4fv(k,h._array);break;case "m4":if(!h._array)h._array=new Float32Array(16);l.flattenToArray(h._array);f.uniformMatrix4fv(k,false,h._array);break;case "m4v":if(!h._array)h._array=new Float32Array(16*l.length);m=0;for(n=l.length;m<n;m++)l[m].flattenToArrayOffset(h._array,m*16);f.uniformMatrix4fv(k,false,h._array);break;case "t":f.uniform1i(k,l);k=h.texture;if(!k)continue;if(k.image instanceof Array&&k.image.length===6){h=k;if(h.image.length===
|
|
|
-6)if(h.needsUpdate){if(!h.image.__webglTextureCube)h.image.__webglTextureCube=f.createTexture();f.activeTexture(f.TEXTURE0+l);f.bindTexture(f.TEXTURE_CUBE_MAP,h.image.__webglTextureCube);l=[];for(k=0;k<6;k++){m=l;n=k;if(E.autoScaleCubemaps){q=h.image[k];s=Kc;if(!(q.width<=s&&q.height<=s)){w=Math.max(q.width,q.height);v=Math.floor(q.width*s/w);s=Math.floor(q.height*s/w);w=document.createElement("canvas");w.width=v;w.height=s;w.getContext("2d").drawImage(q,0,0,q.width,q.height,0,0,v,s);q=w}}else q=
|
|
|
-h.image[k];m[n]=q}k=l[0];m=(k.width&k.width-1)===0&&(k.height&k.height-1)===0;n=A(h.format);q=A(h.type);C(f.TEXTURE_CUBE_MAP,h,m);for(k=0;k<6;k++)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,n,n,q,l[k]);h.generateMipmaps&&m&&f.generateMipmap(f.TEXTURE_CUBE_MAP);h.needsUpdate=false;if(h.onUpdate)h.onUpdate()}else{f.activeTexture(f.TEXTURE0+l);f.bindTexture(f.TEXTURE_CUBE_MAP,h.image.__webglTextureCube)}}else if(k instanceof THREE.WebGLRenderTargetCube){h=k;f.activeTexture(f.TEXTURE0+l);f.bindTexture(f.TEXTURE_CUBE_MAP,
|
|
|
-h.__webglTexture)}else E.setTexture(k,l);break;case "tv":if(!h._array){h._array=[];m=0;for(n=h.texture.length;m<n;m++)h._array[m]=l+m}f.uniform1iv(k,h._array);m=0;for(n=h.texture.length;m<n;m++)(k=h.texture[m])&&E.setTexture(k,h._array[m])}}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&i.cameraPosition!==null){b=a.matrixWorld.getPosition();f.uniform3f(i.cameraPosition,b.x,b.y,b.z)}(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||
|
|
|
-d instanceof THREE.ShaderMaterial||d.skinning)&&i.viewMatrix!==null&&f.uniformMatrix4fv(i.viewMatrix,false,a._viewMatrixArray);d.skinning&&f.uniformMatrix4fv(i.boneGlobalMatrices,false,e.boneMatrices)}f.uniformMatrix4fv(i.modelViewMatrix,false,e._modelViewMatrix.elements);i.normalMatrix&&f.uniformMatrix3fv(i.normalMatrix,false,e._normalMatrix.elements);i.objectMatrix!==null&&f.uniformMatrix4fv(i.objectMatrix,false,e.matrixWorld.elements);return g}function w(a,b){a._modelViewMatrix.multiply(b.matrixWorldInverse,
|
|
|
-a.matrixWorld);a._normalMatrix.getInverse(a._modelViewMatrix);a._normalMatrix.transpose()}function q(a,b,c){if(sc!==a){a?f.enable(f.POLYGON_OFFSET_FILL):f.disable(f.POLYGON_OFFSET_FILL);sc=a}if(a&&(tc!==b||uc!==c)){f.polygonOffset(b,c);tc=b;uc=c}}function F(a,b){var c;a==="fragment"?c=f.createShader(f.FRAGMENT_SHADER):a==="vertex"&&(c=f.createShader(f.VERTEX_SHADER));f.shaderSource(c,b);f.compileShader(c);if(!f.getShaderParameter(c,f.COMPILE_STATUS)){console.error(f.getShaderInfoLog(c));console.error(b);
|
|
|
-return null}return c}function C(a,b,c){if(c){f.texParameteri(a,f.TEXTURE_WRAP_S,A(b.wrapS));f.texParameteri(a,f.TEXTURE_WRAP_T,A(b.wrapT));f.texParameteri(a,f.TEXTURE_MAG_FILTER,A(b.magFilter));f.texParameteri(a,f.TEXTURE_MIN_FILTER,A(b.minFilter))}else{f.texParameteri(a,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(a,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(a,f.TEXTURE_MAG_FILTER,K(b.magFilter));f.texParameteri(a,f.TEXTURE_MIN_FILTER,K(b.minFilter))}}function s(a,b){f.bindRenderbuffer(f.RENDERBUFFER,
|
|
|
-a);if(b.depthBuffer&&!b.stencilBuffer){f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_COMPONENT16,b.width,b.height);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,a)}else if(b.depthBuffer&&b.stencilBuffer){f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_STENCIL,b.width,b.height);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,a)}else f.renderbufferStorage(f.RENDERBUFFER,f.RGBA4,b.width,b.height)}function K(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;
|
|
|
+b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function n(a,b){for(var c=a.length-1;c>=0;c--)a[c]===b&&a.splice(c,1)}function r(a,b,c,d,e){if(d.needsUpdate){d.program&&E.deallocateMaterial(d);E.initMaterial(d,b,c,e);d.needsUpdate=false}if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(E.maxMorphTargets);for(var g=0,i=E.maxMorphTargets;g<i;g++)e.__webglMorphTargetInfluences[g]=0}var h=false,g=d.program,i=g.uniforms,j=d.uniforms;if(g!==
|
|
|
+za){f.useProgram(g);za=g;h=true}if(d.id!==na){na=d.id;h=true}if(h||a!==ga){f.uniformMatrix4fv(i.projectionMatrix,false,a._projectionMatrixArray);a!==ga&&(ga=a)}if(h){if(c&&d.fog){j.fogColor.value=c.color;if(c instanceof THREE.Fog){j.fogNear.value=c.near;j.fogFar.value=c.far}else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density}if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){if(ob){for(var l,k=0,m=0,n=0,p,o,r,q=bc,v=q.directional.colors,s=q.directional.positions,
|
|
|
+w=q.point.colors,z=q.point.positions,H=q.point.distances,D=q.spot.colors,F=q.spot.positions,L=q.spot.distances,K=q.spot.directions,M=q.spot.angles,Q=q.spot.exponents,R=0,T=0,S=0,I=r=0,c=I=0,h=b.length;c<h;c++){l=b[c];if(!l.onlyShadow){p=l.color;o=l.intensity;r=l.distance;if(l instanceof THREE.AmbientLight)if(E.gammaInput){k=k+p.r*p.r;m=m+p.g*p.g;n=n+p.b*p.b}else{k=k+p.r;m=m+p.g;n=n+p.b}else if(l instanceof THREE.DirectionalLight){r=R*3;if(E.gammaInput){v[r]=p.r*p.r*o*o;v[r+1]=p.g*p.g*o*o;v[r+2]=p.b*
|
|
|
+p.b*o*o}else{v[r]=p.r*o;v[r+1]=p.g*o;v[r+2]=p.b*o}Ca.copy(l.matrixWorld.getPosition());Ca.subSelf(l.target.matrixWorld.getPosition());Ca.normalize();s[r]=Ca.x;s[r+1]=Ca.y;s[r+2]=Ca.z;R=R+1}else if(l instanceof THREE.PointLight){I=T*3;if(E.gammaInput){w[I]=p.r*p.r*o*o;w[I+1]=p.g*p.g*o*o;w[I+2]=p.b*p.b*o*o}else{w[I]=p.r*o;w[I+1]=p.g*o;w[I+2]=p.b*o}p=l.matrixWorld.getPosition();z[I]=p.x;z[I+1]=p.y;z[I+2]=p.z;H[T]=r;T=T+1}else if(l instanceof THREE.SpotLight){I=S*3;if(E.gammaInput){D[I]=p.r*p.r*o*o;D[I+
|
|
|
+1]=p.g*p.g*o*o;D[I+2]=p.b*p.b*o*o}else{D[I]=p.r*o;D[I+1]=p.g*o;D[I+2]=p.b*o}p=l.matrixWorld.getPosition();F[I]=p.x;F[I+1]=p.y;F[I+2]=p.z;L[S]=r;Ca.copy(p);Ca.subSelf(l.target.matrixWorld.getPosition());Ca.normalize();K[I]=Ca.x;K[I+1]=Ca.y;K[I+2]=Ca.z;M[S]=Math.cos(l.angle);Q[S]=l.exponent;S=S+1}}}c=R*3;for(h=v.length;c<h;c++)v[c]=0;c=T*3;for(h=w.length;c<h;c++)w[c]=0;c=S*3;for(h=D.length;c<h;c++)D[c]=0;q.directional.length=R;q.point.length=T;q.spot.length=S;q.ambient[0]=k;q.ambient[1]=m;q.ambient[2]=
|
|
|
+n;ob=false}c=bc;j.ambientLightColor.value=c.ambient;j.directionalLightColor.value=c.directional.colors;j.directionalLightDirection.value=c.directional.positions;j.pointLightColor.value=c.point.colors;j.pointLightPosition.value=c.point.positions;j.pointLightDistance.value=c.point.distances;j.spotLightColor.value=c.spot.colors;j.spotLightPosition.value=c.spot.positions;j.spotLightDistance.value=c.spot.distances;j.spotLightDirection.value=c.spot.directions;j.spotLightAngle.value=c.spot.angles;j.spotLightExponent.value=
|
|
|
+c.spot.exponents}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial){j.opacity.value=d.opacity;E.gammaInput?j.diffuse.value.copyGammaToLinear(d.color):j.diffuse.value=d.color;(j.map.texture=d.map)&&j.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y);j.lightMap.texture=d.lightMap;j.envMap.texture=d.envMap;j.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1;j.reflectivity.value=d.reflectivity;
|
|
|
+j.refractionRatio.value=d.refractionRatio;j.combine.value=d.combine;j.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping}if(d instanceof THREE.LineBasicMaterial){j.diffuse.value=d.color;j.opacity.value=d.opacity}else if(d instanceof THREE.ParticleBasicMaterial){j.psColor.value=d.color;j.opacity.value=d.opacity;j.size.value=d.size;j.scale.value=G.height/2;j.map.texture=d.map}else if(d instanceof THREE.MeshPhongMaterial){j.shininess.value=d.shininess;if(E.gammaInput){j.ambient.value.copyGammaToLinear(d.ambient);
|
|
|
+j.emissive.value.copyGammaToLinear(d.emissive);j.specular.value.copyGammaToLinear(d.specular)}else{j.ambient.value=d.ambient;j.emissive.value=d.emissive;j.specular.value=d.specular}d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB)}else if(d instanceof THREE.MeshLambertMaterial){if(E.gammaInput){j.ambient.value.copyGammaToLinear(d.ambient);j.emissive.value.copyGammaToLinear(d.emissive)}else{j.ambient.value=d.ambient;j.emissive.value=d.emissive}d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB)}else if(d instanceof
|
|
|
+THREE.MeshDepthMaterial){j.mNear.value=a.near;j.mFar.value=a.far;j.opacity.value=d.opacity}else if(d instanceof THREE.MeshNormalMaterial)j.opacity.value=d.opacity;if(e.receiveShadow&&!d._shadowPass&&j.shadowMatrix){h=c=0;for(l=b.length;h<l;h++){k=b[h];if(k.castShadow&&(k instanceof THREE.SpotLight||k instanceof THREE.DirectionalLight&&!k.shadowCascade)){j.shadowMap.texture[c]=k.shadowMap;j.shadowMapSize.value[c]=k.shadowMapSize;j.shadowMatrix.value[c]=k.shadowMatrix;j.shadowDarkness.value[c]=k.shadowDarkness;
|
|
|
+j.shadowBias.value[c]=k.shadowBias;c++}}}b=d.uniformsList;j=0;for(c=b.length;j<c;j++)if(k=g.uniforms[b[j][1]]){h=b[j][0];m=h.type;l=h.value;switch(m){case "i":f.uniform1i(k,l);break;case "f":f.uniform1f(k,l);break;case "v2":f.uniform2f(k,l.x,l.y);break;case "v3":f.uniform3f(k,l.x,l.y,l.z);break;case "v4":f.uniform4f(k,l.x,l.y,l.z,l.w);break;case "c":f.uniform3f(k,l.r,l.g,l.b);break;case "fv1":f.uniform1fv(k,l);break;case "fv":f.uniform3fv(k,l);break;case "v2v":if(!h._array)h._array=new Float32Array(2*
|
|
|
+l.length);m=0;for(n=l.length;m<n;m++){q=m*2;h._array[q]=l[m].x;h._array[q+1]=l[m].y}f.uniform2fv(k,h._array);break;case "v3v":if(!h._array)h._array=new Float32Array(3*l.length);m=0;for(n=l.length;m<n;m++){q=m*3;h._array[q]=l[m].x;h._array[q+1]=l[m].y;h._array[q+2]=l[m].z}f.uniform3fv(k,h._array);break;case "v4v":if(!h._array)h._array=new Float32Array(4*l.length);m=0;for(n=l.length;m<n;m++){q=m*4;h._array[q]=l[m].x;h._array[q+1]=l[m].y;h._array[q+2]=l[m].z;h._array[q+3]=l[m].w}f.uniform4fv(k,h._array);
|
|
|
+break;case "m4":if(!h._array)h._array=new Float32Array(16);l.flattenToArray(h._array);f.uniformMatrix4fv(k,false,h._array);break;case "m4v":if(!h._array)h._array=new Float32Array(16*l.length);m=0;for(n=l.length;m<n;m++)l[m].flattenToArrayOffset(h._array,m*16);f.uniformMatrix4fv(k,false,h._array);break;case "t":f.uniform1i(k,l);k=h.texture;if(!k)continue;if(k.image instanceof Array&&k.image.length===6){h=k;if(h.image.length===6)if(h.needsUpdate){if(!h.image.__webglTextureCube)h.image.__webglTextureCube=
|
|
|
+f.createTexture();f.activeTexture(f.TEXTURE0+l);f.bindTexture(f.TEXTURE_CUBE_MAP,h.image.__webglTextureCube);l=[];for(k=0;k<6;k++){m=l;n=k;if(E.autoScaleCubemaps){q=h.image[k];s=Kc;if(!(q.width<=s&&q.height<=s)){w=Math.max(q.width,q.height);v=Math.floor(q.width*s/w);s=Math.floor(q.height*s/w);w=document.createElement("canvas");w.width=v;w.height=s;w.getContext("2d").drawImage(q,0,0,q.width,q.height,0,0,v,s);q=w}}else q=h.image[k];m[n]=q}k=l[0];m=(k.width&k.width-1)===0&&(k.height&k.height-1)===0;
|
|
|
+n=A(h.format);q=A(h.type);C(f.TEXTURE_CUBE_MAP,h,m);for(k=0;k<6;k++)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,n,n,q,l[k]);h.generateMipmaps&&m&&f.generateMipmap(f.TEXTURE_CUBE_MAP);h.needsUpdate=false;if(h.onUpdate)h.onUpdate()}else{f.activeTexture(f.TEXTURE0+l);f.bindTexture(f.TEXTURE_CUBE_MAP,h.image.__webglTextureCube)}}else if(k instanceof THREE.WebGLRenderTargetCube){h=k;f.activeTexture(f.TEXTURE0+l);f.bindTexture(f.TEXTURE_CUBE_MAP,h.__webglTexture)}else E.setTexture(k,l);break;case "tv":if(!h._array){h._array=
|
|
|
+[];m=0;for(n=h.texture.length;m<n;m++)h._array[m]=l+m}f.uniform1iv(k,h._array);m=0;for(n=h.texture.length;m<n;m++)(k=h.texture[m])&&E.setTexture(k,h._array[m])}}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&i.cameraPosition!==null){b=a.matrixWorld.getPosition();f.uniform3f(i.cameraPosition,b.x,b.y,b.z)}(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&i.viewMatrix!==null&&f.uniformMatrix4fv(i.viewMatrix,
|
|
|
+false,a._viewMatrixArray);d.skinning&&f.uniformMatrix4fv(i.boneGlobalMatrices,false,e.boneMatrices)}f.uniformMatrix4fv(i.modelViewMatrix,false,e._modelViewMatrix.elements);i.normalMatrix&&f.uniformMatrix3fv(i.normalMatrix,false,e._normalMatrix.elements);i.objectMatrix!==null&&f.uniformMatrix4fv(i.objectMatrix,false,e.matrixWorld.elements);return g}function w(a,b){a._modelViewMatrix.multiply(b.matrixWorldInverse,a.matrixWorld);a._normalMatrix.getInverse(a._modelViewMatrix);a._normalMatrix.transpose()}
|
|
|
+function q(a,b,c){if(sc!==a){a?f.enable(f.POLYGON_OFFSET_FILL):f.disable(f.POLYGON_OFFSET_FILL);sc=a}if(a&&(tc!==b||uc!==c)){f.polygonOffset(b,c);tc=b;uc=c}}function F(a,b){var c;a==="fragment"?c=f.createShader(f.FRAGMENT_SHADER):a==="vertex"&&(c=f.createShader(f.VERTEX_SHADER));f.shaderSource(c,b);f.compileShader(c);if(!f.getShaderParameter(c,f.COMPILE_STATUS)){console.error(f.getShaderInfoLog(c));console.error(b);return null}return c}function C(a,b,c){if(c){f.texParameteri(a,f.TEXTURE_WRAP_S,A(b.wrapS));
|
|
|
+f.texParameteri(a,f.TEXTURE_WRAP_T,A(b.wrapT));f.texParameteri(a,f.TEXTURE_MAG_FILTER,A(b.magFilter));f.texParameteri(a,f.TEXTURE_MIN_FILTER,A(b.minFilter))}else{f.texParameteri(a,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE);f.texParameteri(a,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE);f.texParameteri(a,f.TEXTURE_MAG_FILTER,K(b.magFilter));f.texParameteri(a,f.TEXTURE_MIN_FILTER,K(b.minFilter))}}function s(a,b){f.bindRenderbuffer(f.RENDERBUFFER,a);if(b.depthBuffer&&!b.stencilBuffer){f.renderbufferStorage(f.RENDERBUFFER,
|
|
|
+f.DEPTH_COMPONENT16,b.width,b.height);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,a)}else if(b.depthBuffer&&b.stencilBuffer){f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_STENCIL,b.width,b.height);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,a)}else f.renderbufferStorage(f.RENDERBUFFER,f.RGBA4,b.width,b.height)}function K(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;
|
|
|
default:return f.LINEAR}}function A(a){switch(a){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.UnsignedIntType: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;
|
|
|
case THREE.AddEquation:return f.FUNC_ADD;case THREE.SubtractEquation:return f.FUNC_SUBTRACT;case THREE.ReverseSubtractEquation:return f.FUNC_REVERSE_SUBTRACT;case THREE.ZeroFactor:return f.ZERO;case THREE.OneFactor:return f.ONE;case THREE.SrcColorFactor:return f.SRC_COLOR;case THREE.OneMinusSrcColorFactor:return f.ONE_MINUS_SRC_COLOR;case THREE.SrcAlphaFactor:return f.SRC_ALPHA;case THREE.OneMinusSrcAlphaFactor:return f.ONE_MINUS_SRC_ALPHA;case THREE.DstAlphaFactor:return f.DST_ALPHA;case THREE.OneMinusDstAlphaFactor:return f.ONE_MINUS_DST_ALPHA;
|