Merge remote branch 'alteredq/master'

This commit is contained in:
Mr.doob
2010-12-12 17:00:29 +00:00
4 changed files with 59 additions and 55 deletions
+1 -1
View File
@@ -166,7 +166,7 @@ f.program}else z=x;if(z!=A){c.useProgram(z);A=z}z==x&&this.setupLights(z,k);this
6?d(Q,H):e(Q,H)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){j=f.color;i=f.opacity;u=f.wireframe;s=f.wireframe_linewidth;G=f.map;y=f.env_map;k=f.combine==THREE.MixOperation;g=f.reflectivity;Q=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;H=f.refraction_ratio;c.uniform4f(z.uniforms.mColor,j.r*i,j.g*i,j.b*i,i);c.uniform1i(z.uniforms.mixEnvMap,k);c.uniform1f(z.uniforms.mReflectivity,g);c.uniform1i(z.uniforms.useRefract,
Q);c.uniform1f(z.uniforms.mRefractionRatio,H)}if(f instanceof THREE.MeshNormalMaterial){i=f.opacity;c.uniform1f(z.uniforms.mOpacity,i);c.uniform1i(z.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){i=f.opacity;u=f.wireframe;s=f.wireframe_linewidth;c.uniform1f(z.uniforms.mOpacity,i);c.uniform1f(z.uniforms.m2Near,f.__2near);c.uniform1f(z.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(z.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(z.uniforms.material,3)}else if(f instanceof
THREE.MeshPhongMaterial){j=f.ambient;g=f.specular;f=f.shininess;c.uniform4f(z.uniforms.mAmbient,j.r,j.g,j.b,i);c.uniform4f(z.uniforms.mSpecular,g.r,g.g,g.b,i);c.uniform1f(z.uniforms.mShininess,f);c.uniform1i(z.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(z.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(z.uniforms.material,0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(z.uniforms.material,5);y=f.env_map}if(G){e(G,0);c.uniform1i(z.uniforms.tMap,
0);c.uniform1i(z.uniforms.enableMap,1)}else c.uniform1i(z.uniforms.enableMap,0);if(y){d(y,1);c.uniform1i(z.uniforms.tCube,1);c.uniform1i(z.uniforms.enableCubeMap,1)}else c.uniform1i(z.uniforms.enableCubeMap,0);i=z.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0);if(i.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);
0);c.uniform1i(z.uniforms.enableMap,1)}else c.uniform1i(z.uniforms.enableMap,0);if(y){d(y,1);c.uniform1i(z.uniforms.tCube,1);c.uniform1i(z.uniforms.enableCubeMap,1)}else c.uniform1i(z.uniforms.enableCubeMap,0);i=z.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);if(i.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0)}if(i.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);
c.vertexAttribPointer(i.tangent,4,c.FLOAT,false,0,0)}if(i.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(u){c.lineWidth(s);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT,
0)}};this.renderPass=function(g,k,f,p,j,i){var u,s,G,y,H;G=0;for(y=f.material.length;G<y;G++){u=f.material[G];if(u instanceof THREE.MeshFaceMaterial){u=0;for(s=p.material.length;u<s;u++)if((H=p.material[u])&&H.blending==j&&H.opacity<1==i){this.setBlending(H.blending);this.renderBuffer(g,k,H,p)}}else if((H=u)&&H.blending==j&&H.opacity<1==i){this.setBlending(H.blending);this.renderBuffer(g,k,H,p)}}};this.render=function(g,k){var f,p,j,i,u=g.lights;this.initWebGLObjects(g);this.autoClear&&this.clear();
k.autoUpdateMatrix&&k.updateMatrix();f=0;for(p=g.__webGLObjects.length;f<p;f++){j=g.__webGLObjects[f];i=j.object;j=j.buffer;if(i.visible){this.setupMatrices(i,k);this.renderPass(k,u,i,j,THREE.NormalBlending,false)}}f=0;for(p=g.__webGLObjects.length;f<p;f++){j=g.__webGLObjects[f];i=j.object;j=j.buffer;if(i.visible){this.setupMatrices(i,k);this.renderPass(k,u,i,j,THREE.AdditiveBlending,false);this.renderPass(k,u,i,j,THREE.SubtractiveBlending,false);this.renderPass(k,u,i,j,THREE.AdditiveBlending,true);
+1 -1
View File
@@ -167,7 +167,7 @@ f.program}else A=y;if(A!=B){c.useProgram(A);B=A}A==y&&this.setupLights(A,l);this
6?d(Q,H):e(Q,H)}}}if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshBasicMaterial){j=f.color;i=f.opacity;u=f.wireframe;t=f.wireframe_linewidth;G=f.map;z=f.env_map;l=f.combine==THREE.MixOperation;g=f.reflectivity;Q=f.env_map&&f.env_map.mapping instanceof THREE.CubeRefractionMapping;H=f.refraction_ratio;c.uniform4f(A.uniforms.mColor,j.r*i,j.g*i,j.b*i,i);c.uniform1i(A.uniforms.mixEnvMap,l);c.uniform1f(A.uniforms.mReflectivity,g);c.uniform1i(A.uniforms.useRefract,
Q);c.uniform1f(A.uniforms.mRefractionRatio,H)}if(f instanceof THREE.MeshNormalMaterial){i=f.opacity;c.uniform1f(A.uniforms.mOpacity,i);c.uniform1i(A.uniforms.material,4)}else if(f instanceof THREE.MeshDepthMaterial){i=f.opacity;u=f.wireframe;t=f.wireframe_linewidth;c.uniform1f(A.uniforms.mOpacity,i);c.uniform1f(A.uniforms.m2Near,f.__2near);c.uniform1f(A.uniforms.mFarPlusNear,f.__farPlusNear);c.uniform1f(A.uniforms.mFarMinusNear,f.__farMinusNear);c.uniform1i(A.uniforms.material,3)}else if(f instanceof
THREE.MeshPhongMaterial){j=f.ambient;g=f.specular;f=f.shininess;c.uniform4f(A.uniforms.mAmbient,j.r,j.g,j.b,i);c.uniform4f(A.uniforms.mSpecular,g.r,g.g,g.b,i);c.uniform1f(A.uniforms.mShininess,f);c.uniform1i(A.uniforms.material,2)}else if(f instanceof THREE.MeshLambertMaterial)c.uniform1i(A.uniforms.material,1);else if(f instanceof THREE.MeshBasicMaterial)c.uniform1i(A.uniforms.material,0);else if(f instanceof THREE.MeshCubeMaterial){c.uniform1i(A.uniforms.material,5);z=f.env_map}if(G){e(G,0);c.uniform1i(A.uniforms.tMap,
0);c.uniform1i(A.uniforms.enableMap,1)}else c.uniform1i(A.uniforms.enableMap,0);if(z){d(z,1);c.uniform1i(A.uniforms.tCube,1);c.uniform1i(A.uniforms.enableCubeMap,1)}else c.uniform1i(A.uniforms.enableCubeMap,0);i=A.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0);if(i.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);
0);c.uniform1i(A.uniforms.enableMap,1)}else c.uniform1i(A.uniforms.enableMap,0);if(z){d(z,1);c.uniform1i(A.uniforms.tCube,1);c.uniform1i(A.uniforms.enableCubeMap,1)}else c.uniform1i(A.uniforms.enableCubeMap,0);i=A.attributes;c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);if(i.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0)}if(i.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLTangentBuffer);
c.vertexAttribPointer(i.tangent,4,c.FLOAT,false,0,0)}if(i.uv>=0)if(p.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(u){c.lineWidth(t);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLLineBuffer);c.drawElements(c.LINES,p.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,p.__webGLFaceCount,c.UNSIGNED_SHORT,
0)}};this.renderPass=function(g,l,f,p,j,i){var u,t,G,z,H;G=0;for(z=f.material.length;G<z;G++){u=f.material[G];if(u instanceof THREE.MeshFaceMaterial){u=0;for(t=p.material.length;u<t;u++)if((H=p.material[u])&&H.blending==j&&H.opacity<1==i){this.setBlending(H.blending);this.renderBuffer(g,l,H,p)}}else if((H=u)&&H.blending==j&&H.opacity<1==i){this.setBlending(H.blending);this.renderBuffer(g,l,H,p)}}};this.render=function(g,l){var f,p,j,i,u=g.lights;this.initWebGLObjects(g);this.autoClear&&this.clear();
l.autoUpdateMatrix&&l.updateMatrix();f=0;for(p=g.__webGLObjects.length;f<p;f++){j=g.__webGLObjects[f];i=j.object;j=j.buffer;if(i.visible){this.setupMatrices(i,l);this.renderPass(l,u,i,j,THREE.NormalBlending,false)}}f=0;for(p=g.__webGLObjects.length;f<p;f++){j=g.__webGLObjects[f];i=j.object;j=j.buffer;if(i.visible){this.setupMatrices(i,l);this.renderPass(l,u,i,j,THREE.AdditiveBlending,false);this.renderPass(l,u,i,j,THREE.SubtractiveBlending,false);this.renderPass(l,u,i,j,THREE.AdditiveBlending,true);
+51 -51
View File
@@ -24,9 +24,9 @@ THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n
a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,b,d){var e=new THREE.Vector3,f=new THREE.Vector3,k=new THREE.Vector3;k.sub(a,b).normalize();e.cross(d,k).normalize();f.cross(k,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);this.n31=k.x;
this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,f=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*
f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,f=a.n13,k=a.n14,l=a.n21,g=a.n22,j=a.n23,c=a.n24,t=a.n31,x=a.n32,
q=a.n33,s=a.n34,v=a.n41,z=a.n42,K=a.n43,F=a.n44,y=b.n11,o=b.n12,i=b.n13,p=b.n14,h=b.n21,w=b.n22,m=b.n23,n=b.n24,D=b.n31,A=b.n32,L=b.n33,E=b.n34,O=b.n41,S=b.n42,G=b.n43,T=b.n44;this.n11=d*y+e*h+f*D+k*O;this.n12=d*o+e*w+f*A+k*S;this.n13=d*i+e*m+f*L+k*G;this.n14=d*p+e*n+f*E+k*T;this.n21=l*y+g*h+j*D+c*O;this.n22=l*o+g*w+j*A+c*S;this.n23=l*i+g*m+j*L+c*G;this.n24=l*p+g*n+j*E+c*T;this.n31=t*y+x*h+q*D+s*O;this.n32=t*o+x*w+q*A+s*S;this.n33=t*i+x*m+q*L+s*G;this.n34=t*p+x*n+q*E+s*T;this.n41=v*y+z*h+K*D+F*O;
this.n42=v*o+z*w+K*A+F*S;this.n43=v*i+z*m+K*L+F*G;this.n44=v*p+z*n+K*E+F*T;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,k=this.n21,l=this.n22,g=this.n23,j=this.n24,c=this.n31,t=this.n32,x=this.n33,q=this.n34,s=this.n41,v=this.n42,z=this.n43,K=this.n44,F=a.n11,y=a.n21,o=a.n31,i=a.n41,p=a.n12,h=a.n22,w=a.n32,m=a.n42,n=a.n13,D=a.n23,A=a.n33,L=a.n43,E=a.n14,O=a.n24,S=a.n34;a=a.n44;this.n11=b*F+d*y+e*o+f*i;this.n12=b*p+d*h+e*w+f*m;this.n13=b*n+d*D+e*A+f*L;this.n14=
b*E+d*O+e*S+f*a;this.n21=k*F+l*y+g*o+j*i;this.n22=k*p+l*h+g*w+j*m;this.n23=k*n+l*D+g*A+j*L;this.n24=k*E+l*O+g*S+j*a;this.n31=c*F+t*y+x*o+q*i;this.n32=c*p+t*h+x*w+q*m;this.n33=c*n+t*D+x*A+q*L;this.n34=c*E+t*O+x*S+q*a;this.n41=s*F+v*y+z*o+K*i;this.n42=s*p+v*h+z*w+K*m;this.n43=s*n+v*D+z*A+K*L;this.n44=s*E+v*O+z*S+K*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
q=a.n33,s=a.n34,v=a.n41,z=a.n42,K=a.n43,F=a.n44,y=b.n11,o=b.n12,i=b.n13,p=b.n14,h=b.n21,w=b.n22,n=b.n23,m=b.n24,D=b.n31,A=b.n32,L=b.n33,E=b.n34,O=b.n41,S=b.n42,G=b.n43,T=b.n44;this.n11=d*y+e*h+f*D+k*O;this.n12=d*o+e*w+f*A+k*S;this.n13=d*i+e*n+f*L+k*G;this.n14=d*p+e*m+f*E+k*T;this.n21=l*y+g*h+j*D+c*O;this.n22=l*o+g*w+j*A+c*S;this.n23=l*i+g*n+j*L+c*G;this.n24=l*p+g*m+j*E+c*T;this.n31=t*y+x*h+q*D+s*O;this.n32=t*o+x*w+q*A+s*S;this.n33=t*i+x*n+q*L+s*G;this.n34=t*p+x*m+q*E+s*T;this.n41=v*y+z*h+K*D+F*O;
this.n42=v*o+z*w+K*A+F*S;this.n43=v*i+z*n+K*L+F*G;this.n44=v*p+z*m+K*E+F*T;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,k=this.n21,l=this.n22,g=this.n23,j=this.n24,c=this.n31,t=this.n32,x=this.n33,q=this.n34,s=this.n41,v=this.n42,z=this.n43,K=this.n44,F=a.n11,y=a.n21,o=a.n31,i=a.n41,p=a.n12,h=a.n22,w=a.n32,n=a.n42,m=a.n13,D=a.n23,A=a.n33,L=a.n43,E=a.n14,O=a.n24,S=a.n34;a=a.n44;this.n11=b*F+d*y+e*o+f*i;this.n12=b*p+d*h+e*w+f*n;this.n13=b*m+d*D+e*A+f*L;this.n14=
b*E+d*O+e*S+f*a;this.n21=k*F+l*y+g*o+j*i;this.n22=k*p+l*h+g*w+j*n;this.n23=k*m+l*D+g*A+j*L;this.n24=k*E+l*O+g*S+j*a;this.n31=c*F+t*y+x*o+q*i;this.n32=c*p+t*h+x*w+q*n;this.n33=c*m+t*D+x*A+q*L;this.n34=c*E+t*O+x*S+q*a;this.n41=s*F+v*y+z*o+K*i;this.n42=s*p+v*h+z*w+K*n;this.n43=s*m+v*D+z*A+K*L;this.n44=s*E+v*O+z*S+K*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*
this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,d,e){var f=b[d];b[d]=b[e];
b[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,
@@ -48,9 +48,9 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.f
d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,f,k,l,g=new THREE.Vector3,j=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){k=this.vertices[e];k.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){k=this.faces[e];if(a&&k.vertexNormals.length){g.set(0,0,0);b=0;for(d=k.normal.length;b<d;b++)g.addSelf(k.vertexNormals[b]);g.divideScalar(3)}else{b=this.vertices[k.a];d=this.vertices[k.b];l=this.vertices[k.c];g.sub(l.position,
d.position);j.sub(b.position,d.position);g.crossSelf(j)}g.isZero()||g.normalize();k.normal.copy(g)}},computeVertexNormals:function(){var a,b=[],d,e;a=0;for(vl=this.vertices.length;a<vl;a++)b[a]=new THREE.Vector3;a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){b[e.a].addSelf(e.normal);b[e.b].addSelf(e.normal);b[e.c].addSelf(e.normal);b[e.d].addSelf(e.normal)}}a=
0;for(vl=this.vertices.length;a<vl;a++)b[a].normalize();a=0;for(d=this.faces.length;a<d;a++){e=this.faces[a];if(e instanceof THREE.Face3){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone()}else if(e instanceof THREE.Face4){e.vertexNormals[0]=b[e.a].clone();e.vertexNormals[1]=b[e.b].clone();e.vertexNormals[2]=b[e.c].clone();e.vertexNormals[3]=b[e.d].clone()}}},computeTangents:function(){function a(E,O,S,G){k=E.vertices[O].position;l=E.vertices[S].position;
g=E.vertices[G].position;j=f[0];c=f[1];t=f[2];x=l.x-k.x;q=g.x-k.x;s=l.y-k.y;v=g.y-k.y;z=l.z-k.z;K=g.z-k.z;F=c.u-j.u;y=t.u-j.u;o=c.v-j.v;i=t.v-j.v;p=1/(F*i-y*o);n.set((i*x-o*q)*p,(i*s-o*v)*p,(i*z-o*K)*p);D.set((F*q-y*x)*p,(F*v-y*s)*p,(F*K-y*z)*p);w[O].addSelf(n);w[S].addSelf(n);w[G].addSelf(n);m[O].addSelf(D);m[S].addSelf(D);m[G].addSelf(D)}var b,d,e,f,k,l,g,j,c,t,x,q,s,v,z,K,F,y,o,i,p,h,w=[],m=[],n=new THREE.Vector3,D=new THREE.Vector3,A=new THREE.Vector3,L=new THREE.Vector3;h=new THREE.Vector3;b=
0;for(d=this.vertices.length;b<d;b++){w[b]=new THREE.Vector3;m[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];f=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);
this.vertices[e.c].normal.copy(e.vertexNormals[2]);this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){h.copy(this.vertices[b].normal);e=w[b];A.copy(e);A.subSelf(h.multiplyScalar(h.dot(e))).normalize();L.cross(this.vertices[b].normal,e);test=L.dot(m[b]);e=test<0?-1:1;this.vertices[b].tangent.set(A.x,A.y,A.z,e)}this.hasTangents=true},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],
g=E.vertices[G].position;j=f[0];c=f[1];t=f[2];x=l.x-k.x;q=g.x-k.x;s=l.y-k.y;v=g.y-k.y;z=l.z-k.z;K=g.z-k.z;F=c.u-j.u;y=t.u-j.u;o=c.v-j.v;i=t.v-j.v;p=1/(F*i-y*o);m.set((i*x-o*q)*p,(i*s-o*v)*p,(i*z-o*K)*p);D.set((F*q-y*x)*p,(F*v-y*s)*p,(F*K-y*z)*p);w[O].addSelf(m);w[S].addSelf(m);w[G].addSelf(m);n[O].addSelf(D);n[S].addSelf(D);n[G].addSelf(D)}var b,d,e,f,k,l,g,j,c,t,x,q,s,v,z,K,F,y,o,i,p,h,w=[],n=[],m=new THREE.Vector3,D=new THREE.Vector3,A=new THREE.Vector3,L=new THREE.Vector3;h=new THREE.Vector3;b=
0;for(d=this.vertices.length;b<d;b++){w[b]=new THREE.Vector3;n[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];f=this.uvs[b];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);
this.vertices[e.c].normal.copy(e.vertexNormals[2]);this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(d=this.vertices.length;b<d;b++){h.copy(this.vertices[b].normal);e=w[b];A.copy(e);A.subSelf(h.multiplyScalar(h.dot(e))).normalize();L.cross(this.vertices[b].normal,e);test=L.dot(n[b]);e=test<0?-1:1;this.vertices[b].tangent.set(A.x,A.y,A.z,e)}this.hasTangents=true},computeBoundingBox:function(){if(this.vertices.length>0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],
y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;a<b;a++){vertex=this.vertices[a];if(vertex.position.x<this.bbox.x[0])this.bbox.x[0]=vertex.position.x;else if(vertex.position.x>this.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y<this.bbox.y[0])this.bbox.y[0]=vertex.position.y;else if(vertex.position.y>this.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.z<this.bbox.z[0])this.bbox.z[0]=
vertex.position.z;else if(vertex.position.z>this.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(t){var x=[];b=0;for(d=t.length;b<d;b++)t[b]==undefined?x.push("undefined"):x.push(t[b].toString());return x.join("_")}var b,d,e,f,k,l,g,j,c={};e=0;for(f=this.faces.length;e<f;e++){k=this.faces[e];l=k.material;g=a(l);if(c[g]==undefined)c[g]={hash:g,counter:0};j=c[g].hash+"_"+c[g].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],material:l,
vertices:0};k=k instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+k>65535){c[g].counter+=1;j=c[g].hash+"_"+c[g].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],material:l,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
@@ -90,19 +90,19 @@ THREE.Texture=function(a,b,d,e,f,k){this.image=a;this.mapping=b!==undefined?b:ne
this.min_filter+"<br/>)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};
THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
THREE.Scene=function(){this.objects=[];this.lights=[];this.addObject=function(a){this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
THREE.Projector=function(){function a(y,o){var i=0,p=1,h=y.z+y.w,w=o.z+o.w,m=-y.z+y.w,n=-o.z+o.w;if(h>=0&&w>=0&&m>=0&&n>=0)return true;else if(h<0&&w<0||m<0&&n<0)return false;else{if(h<0)i=Math.max(i,h/(h-w));else if(w<0)p=Math.min(p,h/(h-w));if(m<0)i=Math.max(i,m/(m-n));else if(n<0)p=Math.min(p,m/(m-n));if(p<i)return false;else{y.lerpSelf(o,i);o.lerpSelf(y,1-p);return true}}}var b=null,d,e,f,k=[],l,g,j=[],c,t,x=[],q=new THREE.Vector4,s=new THREE.Matrix4,v=new THREE.Matrix4,z=new THREE.Vector4,K=
new THREE.Vector4,F;this.projectScene=function(y,o){var i,p,h,w,m,n,D,A,L,E,O,S,G,T,N,U,V;b=[];f=g=t=0;o.autoUpdateMatrix&&o.updateMatrix();s.multiply(o.projectionMatrix,o.matrix);D=y.objects;i=0;for(p=D.length;i<p;i++){A=D[i];A.autoUpdateMatrix&&A.updateMatrix();L=A.matrix;E=A.rotationMatrix;O=A.material;S=A.overdraw;if(A instanceof THREE.Mesh){G=A.geometry.vertices;h=0;for(w=G.length;h<w;h++){T=G[h];T.positionWorld.copy(T.position);L.multiplyVector3(T.positionWorld);N=T.positionScreen;N.copy(T.positionWorld);
s.multiplyVector4(N);N.multiplyScalar(1/N.w);T.__visible=N.z>0&&N.z<1}T=A.geometry.faces;h=0;for(w=T.length;h<w;h++){N=T[h];if(N instanceof THREE.Face3){m=G[N.a];n=G[N.b];U=G[N.c];if(m.__visible&&n.__visible&&U.__visible)if(A.doubleSided||A.flipSided!=(U.positionScreen.x-m.positionScreen.x)*(n.positionScreen.y-m.positionScreen.y)-(U.positionScreen.y-m.positionScreen.y)*(n.positionScreen.x-m.positionScreen.x)<0){d=k[f]=k[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(m.positionWorld);d.v2.positionWorld.copy(n.positionWorld);
d.v3.positionWorld.copy(U.positionWorld);d.v1.positionScreen.copy(m.positionScreen);d.v2.positionScreen.copy(n.positionScreen);d.v3.positionScreen.copy(U.positionScreen);d.normalWorld.copy(N.normal);E.multiplyVector3(d.normalWorld);d.centroidWorld.copy(N.centroid);L.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);s.multiplyVector3(d.centroidScreen);U=N.vertexNormals;F=d.vertexNormalsWorld;m=0;for(n=U.length;m<n;m++){V=F[m]=F[m]||new THREE.Vector3;V.copy(U[m]);E.multiplyVector3(V)}d.z=
d.centroidScreen.z;d.meshMaterial=O;d.faceMaterial=N.material;d.overdraw=S;if(A.geometry.uvs[h]){d.uvs[0]=A.geometry.uvs[h][0];d.uvs[1]=A.geometry.uvs[h][1];d.uvs[2]=A.geometry.uvs[h][2]}b.push(d);f++}}else if(N instanceof THREE.Face4){m=G[N.a];n=G[N.b];U=G[N.c];V=G[N.d];if(m.__visible&&n.__visible&&U.__visible&&V.__visible)if(A.doubleSided||A.flipSided!=((V.positionScreen.x-m.positionScreen.x)*(n.positionScreen.y-m.positionScreen.y)-(V.positionScreen.y-m.positionScreen.y)*(n.positionScreen.x-m.positionScreen.x)<
0||(n.positionScreen.x-U.positionScreen.x)*(V.positionScreen.y-U.positionScreen.y)-(n.positionScreen.y-U.positionScreen.y)*(V.positionScreen.x-U.positionScreen.x)<0)){d=k[f]=k[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(m.positionWorld);d.v2.positionWorld.copy(n.positionWorld);d.v3.positionWorld.copy(V.positionWorld);d.v1.positionScreen.copy(m.positionScreen);d.v2.positionScreen.copy(n.positionScreen);d.v3.positionScreen.copy(V.positionScreen);d.normalWorld.copy(N.normal);E.multiplyVector3(d.normalWorld);
d.centroidWorld.copy(N.centroid);L.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);s.multiplyVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=O;d.faceMaterial=N.material;d.overdraw=S;if(A.geometry.uvs[h]){d.uvs[0]=A.geometry.uvs[h][0];d.uvs[1]=A.geometry.uvs[h][1];d.uvs[2]=A.geometry.uvs[h][3]}b.push(d);f++;e=k[f]=k[f]||new THREE.RenderableFace3;e.v1.positionWorld.copy(n.positionWorld);e.v2.positionWorld.copy(U.positionWorld);e.v3.positionWorld.copy(V.positionWorld);
e.v1.positionScreen.copy(n.positionScreen);e.v2.positionScreen.copy(U.positionScreen);e.v3.positionScreen.copy(V.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=O;e.faceMaterial=N.material;e.overdraw=S;if(A.geometry.uvs[h]){e.uvs[0]=A.geometry.uvs[h][1];e.uvs[1]=A.geometry.uvs[h][2];e.uvs[2]=A.geometry.uvs[h][3]}b.push(e);f++}}}}else if(A instanceof THREE.Line){v.multiply(s,L);G=A.geometry.vertices;
T=G[0];T.positionScreen.copy(T.position);v.multiplyVector4(T.positionScreen);h=1;for(w=G.length;h<w;h++){m=G[h];m.positionScreen.copy(m.position);v.multiplyVector4(m.positionScreen);n=G[h-1];z.copy(m.positionScreen);K.copy(n.positionScreen);if(a(z,K)){z.multiplyScalar(1/z.w);K.multiplyScalar(1/K.w);l=j[g]=j[g]||new THREE.RenderableLine;l.v1.positionScreen.copy(z);l.v2.positionScreen.copy(K);l.z=Math.max(z.z,K.z);l.material=A.material;b.push(l);g++}}}else if(A instanceof THREE.Particle){q.set(A.position.x,
THREE.Projector=function(){function a(y,o){var i=0,p=1,h=y.z+y.w,w=o.z+o.w,n=-y.z+y.w,m=-o.z+o.w;if(h>=0&&w>=0&&n>=0&&m>=0)return true;else if(h<0&&w<0||n<0&&m<0)return false;else{if(h<0)i=Math.max(i,h/(h-w));else if(w<0)p=Math.min(p,h/(h-w));if(n<0)i=Math.max(i,n/(n-m));else if(m<0)p=Math.min(p,n/(n-m));if(p<i)return false;else{y.lerpSelf(o,i);o.lerpSelf(y,1-p);return true}}}var b=null,d,e,f,k=[],l,g,j=[],c,t,x=[],q=new THREE.Vector4,s=new THREE.Matrix4,v=new THREE.Matrix4,z=new THREE.Vector4,K=
new THREE.Vector4,F;this.projectScene=function(y,o){var i,p,h,w,n,m,D,A,L,E,O,S,G,T,N,U,V;b=[];f=g=t=0;o.autoUpdateMatrix&&o.updateMatrix();s.multiply(o.projectionMatrix,o.matrix);D=y.objects;i=0;for(p=D.length;i<p;i++){A=D[i];A.autoUpdateMatrix&&A.updateMatrix();L=A.matrix;E=A.rotationMatrix;O=A.material;S=A.overdraw;if(A instanceof THREE.Mesh){G=A.geometry.vertices;h=0;for(w=G.length;h<w;h++){T=G[h];T.positionWorld.copy(T.position);L.multiplyVector3(T.positionWorld);N=T.positionScreen;N.copy(T.positionWorld);
s.multiplyVector4(N);N.multiplyScalar(1/N.w);T.__visible=N.z>0&&N.z<1}T=A.geometry.faces;h=0;for(w=T.length;h<w;h++){N=T[h];if(N instanceof THREE.Face3){n=G[N.a];m=G[N.b];U=G[N.c];if(n.__visible&&m.__visible&&U.__visible)if(A.doubleSided||A.flipSided!=(U.positionScreen.x-n.positionScreen.x)*(m.positionScreen.y-n.positionScreen.y)-(U.positionScreen.y-n.positionScreen.y)*(m.positionScreen.x-n.positionScreen.x)<0){d=k[f]=k[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(n.positionWorld);d.v2.positionWorld.copy(m.positionWorld);
d.v3.positionWorld.copy(U.positionWorld);d.v1.positionScreen.copy(n.positionScreen);d.v2.positionScreen.copy(m.positionScreen);d.v3.positionScreen.copy(U.positionScreen);d.normalWorld.copy(N.normal);E.multiplyVector3(d.normalWorld);d.centroidWorld.copy(N.centroid);L.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);s.multiplyVector3(d.centroidScreen);U=N.vertexNormals;F=d.vertexNormalsWorld;n=0;for(m=U.length;n<m;n++){V=F[n]=F[n]||new THREE.Vector3;V.copy(U[n]);E.multiplyVector3(V)}d.z=
d.centroidScreen.z;d.meshMaterial=O;d.faceMaterial=N.material;d.overdraw=S;if(A.geometry.uvs[h]){d.uvs[0]=A.geometry.uvs[h][0];d.uvs[1]=A.geometry.uvs[h][1];d.uvs[2]=A.geometry.uvs[h][2]}b.push(d);f++}}else if(N instanceof THREE.Face4){n=G[N.a];m=G[N.b];U=G[N.c];V=G[N.d];if(n.__visible&&m.__visible&&U.__visible&&V.__visible)if(A.doubleSided||A.flipSided!=((V.positionScreen.x-n.positionScreen.x)*(m.positionScreen.y-n.positionScreen.y)-(V.positionScreen.y-n.positionScreen.y)*(m.positionScreen.x-n.positionScreen.x)<
0||(m.positionScreen.x-U.positionScreen.x)*(V.positionScreen.y-U.positionScreen.y)-(m.positionScreen.y-U.positionScreen.y)*(V.positionScreen.x-U.positionScreen.x)<0)){d=k[f]=k[f]||new THREE.RenderableFace3;d.v1.positionWorld.copy(n.positionWorld);d.v2.positionWorld.copy(m.positionWorld);d.v3.positionWorld.copy(V.positionWorld);d.v1.positionScreen.copy(n.positionScreen);d.v2.positionScreen.copy(m.positionScreen);d.v3.positionScreen.copy(V.positionScreen);d.normalWorld.copy(N.normal);E.multiplyVector3(d.normalWorld);
d.centroidWorld.copy(N.centroid);L.multiplyVector3(d.centroidWorld);d.centroidScreen.copy(d.centroidWorld);s.multiplyVector3(d.centroidScreen);d.z=d.centroidScreen.z;d.meshMaterial=O;d.faceMaterial=N.material;d.overdraw=S;if(A.geometry.uvs[h]){d.uvs[0]=A.geometry.uvs[h][0];d.uvs[1]=A.geometry.uvs[h][1];d.uvs[2]=A.geometry.uvs[h][3]}b.push(d);f++;e=k[f]=k[f]||new THREE.RenderableFace3;e.v1.positionWorld.copy(m.positionWorld);e.v2.positionWorld.copy(U.positionWorld);e.v3.positionWorld.copy(V.positionWorld);
e.v1.positionScreen.copy(m.positionScreen);e.v2.positionScreen.copy(U.positionScreen);e.v3.positionScreen.copy(V.positionScreen);e.normalWorld.copy(d.normalWorld);e.centroidWorld.copy(d.centroidWorld);e.centroidScreen.copy(d.centroidScreen);e.z=e.centroidScreen.z;e.meshMaterial=O;e.faceMaterial=N.material;e.overdraw=S;if(A.geometry.uvs[h]){e.uvs[0]=A.geometry.uvs[h][1];e.uvs[1]=A.geometry.uvs[h][2];e.uvs[2]=A.geometry.uvs[h][3]}b.push(e);f++}}}}else if(A instanceof THREE.Line){v.multiply(s,L);G=A.geometry.vertices;
T=G[0];T.positionScreen.copy(T.position);v.multiplyVector4(T.positionScreen);h=1;for(w=G.length;h<w;h++){n=G[h];n.positionScreen.copy(n.position);v.multiplyVector4(n.positionScreen);m=G[h-1];z.copy(n.positionScreen);K.copy(m.positionScreen);if(a(z,K)){z.multiplyScalar(1/z.w);K.multiplyScalar(1/K.w);l=j[g]=j[g]||new THREE.RenderableLine;l.v1.positionScreen.copy(z);l.v2.positionScreen.copy(K);l.z=Math.max(z.z,K.z);l.material=A.material;b.push(l);g++}}}else if(A instanceof THREE.Particle){q.set(A.position.x,
A.position.y,A.position.z,1);s.multiplyVector4(q);q.z/=q.w;if(q.z>0&&q.z<1){c=x[t]=x[t]||new THREE.RenderableParticle;c.x=q.x/q.w;c.y=q.y/q.w;c.z=q.z;c.rotation=A.rotation.z;c.scale.x=A.scale.x*Math.abs(c.x-(q.x+o.projectionMatrix.n11)/(q.w+o.projectionMatrix.n14));c.scale.y=A.scale.y*Math.abs(c.y-(q.y+o.projectionMatrix.n22)/(q.w+o.projectionMatrix.n24));c.material=A.material;b.push(c);t++}}}b.sort(function(Q,H){return H.z-Q.z});return b};this.unprojectVector=function(y,o){var i=new THREE.Matrix4;
i.multiply(THREE.Matrix4.makeInvert(o.matrix),THREE.Matrix4.makeInvert(o.projectionMatrix));i.multiplyVector3(y);return y}};
THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,k;this.domElement=document.createElement("div");this.setSize=function(l,g){d=l;e=g;f=d/2;k=e/2};this.render=function(l,g){var j,c,t,x,q,s,v,z;a=b.projectScene(l,g);j=0;for(c=a.length;j<c;j++){q=a[j];if(q instanceof THREE.RenderableParticle){v=q.x*f+f;z=q.y*k+k;t=0;for(x=q.material.length;t<x;t++){s=q.material[t];if(s instanceof THREE.ParticleDOMMaterial){s=s.domElement;s.style.left=v+"px";s.style.top=z+"px"}}}}}};
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,f,k,l,g=d.getContext("2d"),j=1,c=0,t=null,x=null,q=1,s,v,z,K,F,y,o,i,p,h=new THREE.Color,w=new THREE.Color,m=new THREE.Color,n=new THREE.Color,D=new THREE.Color,A,L,E,O,S,G,T,N,U,V,Q=new THREE.Rectangle,H=new THREE.Rectangle,J=new THREE.Rectangle,$=false,r=new THREE.Color,u=new THREE.Color,B=new THREE.Color,M=new THREE.Color,X=Math.PI*2,Y=new THREE.Vector3,ea,ma,oa,fa,ra,va,pa=16;ea=document.createElement("canvas");
THREE.CanvasRenderer=function(){var a=null,b=new THREE.Projector,d=document.createElement("canvas"),e,f,k,l,g=d.getContext("2d"),j=1,c=0,t=null,x=null,q=1,s,v,z,K,F,y,o,i,p,h=new THREE.Color,w=new THREE.Color,n=new THREE.Color,m=new THREE.Color,D=new THREE.Color,A,L,E,O,S,G,T,N,U,V,Q=new THREE.Rectangle,H=new THREE.Rectangle,J=new THREE.Rectangle,$=false,r=new THREE.Color,u=new THREE.Color,B=new THREE.Color,M=new THREE.Color,X=Math.PI*2,Y=new THREE.Vector3,ea,ma,oa,fa,ra,va,pa=16;ea=document.createElement("canvas");
ea.width=ea.height=2;ma=ea.getContext("2d");ma.fillStyle="rgba(0,0,0,1)";ma.fillRect(0,0,2,2);oa=ma.getImageData(0,0,2,2);fa=oa.data;ra=document.createElement("canvas");ra.width=ra.height=pa;va=ra.getContext("2d");va.translate(-pa/2,-pa/2);va.scale(pa,pa);pa--;this.domElement=d;this.autoClear=true;this.setSize=function(ia,wa){e=ia;f=wa;k=e/2;l=f/2;d.width=e;d.height=f;Q.set(-k,-l,k,l)};this.clear=function(){if(!H.isEmpty()){H.inflate(1);H.minSelf(Q);g.clearRect(H.getX(),H.getY(),H.getWidth(),H.getHeight());
H.empty()}};this.render=function(ia,wa){function Ka(C){var W,R,I,P=C.lights;u.setRGB(0,0,0);B.setRGB(0,0,0);M.setRGB(0,0,0);C=0;for(W=P.length;C<W;C++){R=P[C];I=R.color;if(R instanceof THREE.AmbientLight){u.r+=I.r;u.g+=I.g;u.b+=I.b}else if(R instanceof THREE.DirectionalLight){B.r+=I.r;B.g+=I.g;B.b+=I.b}else if(R instanceof THREE.PointLight){M.r+=I.r;M.g+=I.g;M.b+=I.b}}}function xa(C,W,R,I){var P,Z,ba,ca,da=C.lights;C=0;for(P=da.length;C<P;C++){Z=da[C];ba=Z.color;ca=Z.intensity;if(Z instanceof THREE.DirectionalLight){Z=
R.dot(Z.position)*ca;if(Z>0){I.r+=ba.r*Z;I.g+=ba.g*Z;I.b+=ba.b*Z}}else if(Z instanceof THREE.PointLight){Y.sub(Z.position,W);Y.normalize();Z=R.dot(Y)*ca;if(Z>0){I.r+=ba.r*Z;I.g+=ba.g*Z;I.b+=ba.b*Z}}}}function La(C,W,R){if(R.opacity!=0){Ca(R.opacity);ya(R.blending);var I,P,Z,ba,ca,da;if(R instanceof THREE.ParticleBasicMaterial){if(R.map){ba=R.map;ca=ba.width>>1;da=ba.height>>1;P=W.scale.x*k;Z=W.scale.y*l;R=P*ca;I=Z*da;J.set(C.x-R,C.y-I,C.x+R,C.y+I);if(Q.instersects(J)){g.save();g.translate(C.x,C.y);
@@ -110,22 +110,22 @@ g.rotate(-W.rotation);g.scale(P,-Z);g.translate(-ca,-da);g.drawImage(ba,0,0);g.r
g.beginPath();g.arc(0,0,1,0,X,true);g.closePath();g.fill();g.restore()}}}}function Ma(C,W,R,I){if(I.opacity!=0){Ca(I.opacity);ya(I.blending);g.beginPath();g.moveTo(C.positionScreen.x,C.positionScreen.y);g.lineTo(W.positionScreen.x,W.positionScreen.y);g.closePath();if(I instanceof THREE.LineBasicMaterial){h.__styleString=I.color.__styleString;C=I.linewidth;if(q!=C)g.lineWidth=q=C;C=h.__styleString;if(t!=C)g.strokeStyle=t=C;g.stroke();J.inflate(I.linewidth*2)}}}function Ga(C,W,R,I,P,Z){if(P.opacity!=
0){Ca(P.opacity);ya(P.blending);K=C.positionScreen.x;F=C.positionScreen.y;y=W.positionScreen.x;o=W.positionScreen.y;i=R.positionScreen.x;p=R.positionScreen.y;g.beginPath();g.moveTo(K,F);g.lineTo(y,o);g.lineTo(i,p);g.lineTo(K,F);g.closePath();if(P instanceof THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&sa(K,F,y,o,i,p,P.map.image,I.uvs[0].u,I.uvs[0].v,I.uvs[1].u,I.uvs[1].v,I.uvs[2].u,I.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof
THREE.SphericalReflectionMapping){C=wa.matrix;Y.copy(I.vertexNormalsWorld[0]);S=(Y.x*C.n11+Y.y*C.n12+Y.z*C.n13)*0.5+0.5;G=-(Y.x*C.n21+Y.y*C.n22+Y.z*C.n23)*0.5+0.5;Y.copy(I.vertexNormalsWorld[1]);T=(Y.x*C.n11+Y.y*C.n12+Y.z*C.n13)*0.5+0.5;N=-(Y.x*C.n21+Y.y*C.n22+Y.z*C.n23)*0.5+0.5;Y.copy(I.vertexNormalsWorld[2]);U=(Y.x*C.n11+Y.y*C.n12+Y.z*C.n13)*0.5+0.5;V=-(Y.x*C.n21+Y.y*C.n22+Y.z*C.n23)*0.5+0.5;sa(K,F,y,o,i,p,P.env_map.image,S,G,T,N,U,V)}}else P.wireframe?za(P.color.__styleString,P.wireframe_linewidth):
Aa(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&sa(K,F,y,o,i,p,P.map.image,I.uvs[0].u,I.uvs[0].v,I.uvs[1].u,I.uvs[1].v,I.uvs[2].u,I.uvs[2].v);ya(THREE.SubtractiveBlending)}if($)if(!P.wireframe&&P.shading==THREE.SmoothShading&&I.vertexNormalsWorld.length==3){w.r=m.r=n.r=u.r;w.g=m.g=n.g=u.g;w.b=m.b=n.b=u.b;xa(Z,I.v1.positionWorld,I.vertexNormalsWorld[0],w);xa(Z,I.v2.positionWorld,I.vertexNormalsWorld[1],m);xa(Z,
I.v3.positionWorld,I.vertexNormalsWorld[2],n);D.r=(m.r+n.r)*0.5;D.g=(m.g+n.g)*0.5;D.b=(m.b+n.b)*0.5;O=Ha(w,m,n,D);sa(K,F,y,o,i,p,O,0,0,1,0,0,1)}else{r.r=u.r;r.g=u.g;r.b=u.b;xa(Z,I.centroidWorld,I.normalWorld,r);h.r=P.color.r*r.r;h.g=P.color.g*r.g;h.b=P.color.b*r.b;h.updateStyleString();P.wireframe?za(h.__styleString,P.wireframe_linewidth):Aa(h.__styleString)}else P.wireframe?za(P.color.__styleString,P.wireframe_linewidth):Aa(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){A=P.__2near;
L=P.__farPlusNear;E=P.__farMinusNear;w.r=w.g=w.b=1-A/(L-C.positionScreen.z*E);m.r=m.g=m.b=1-A/(L-W.positionScreen.z*E);n.r=n.g=n.b=1-A/(L-R.positionScreen.z*E);D.r=(m.r+n.r)*0.5;D.g=(m.g+n.g)*0.5;D.b=(m.b+n.b)*0.5;O=Ha(w,m,n,D);sa(K,F,y,o,i,p,O,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){h.r=Da(I.normalWorld.x);h.g=Da(I.normalWorld.y);h.b=Da(I.normalWorld.z);h.updateStyleString();P.wireframe?za(h.__styleString,P.wireframe_linewidth):Aa(h.__styleString)}}}function za(C,W){if(t!=C)g.strokeStyle=
Aa(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&sa(K,F,y,o,i,p,P.map.image,I.uvs[0].u,I.uvs[0].v,I.uvs[1].u,I.uvs[1].v,I.uvs[2].u,I.uvs[2].v);ya(THREE.SubtractiveBlending)}if($)if(!P.wireframe&&P.shading==THREE.SmoothShading&&I.vertexNormalsWorld.length==3){w.r=n.r=m.r=u.r;w.g=n.g=m.g=u.g;w.b=n.b=m.b=u.b;xa(Z,I.v1.positionWorld,I.vertexNormalsWorld[0],w);xa(Z,I.v2.positionWorld,I.vertexNormalsWorld[1],n);xa(Z,
I.v3.positionWorld,I.vertexNormalsWorld[2],m);D.r=(n.r+m.r)*0.5;D.g=(n.g+m.g)*0.5;D.b=(n.b+m.b)*0.5;O=Ha(w,n,m,D);sa(K,F,y,o,i,p,O,0,0,1,0,0,1)}else{r.r=u.r;r.g=u.g;r.b=u.b;xa(Z,I.centroidWorld,I.normalWorld,r);h.r=P.color.r*r.r;h.g=P.color.g*r.g;h.b=P.color.b*r.b;h.updateStyleString();P.wireframe?za(h.__styleString,P.wireframe_linewidth):Aa(h.__styleString)}else P.wireframe?za(P.color.__styleString,P.wireframe_linewidth):Aa(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){A=P.__2near;
L=P.__farPlusNear;E=P.__farMinusNear;w.r=w.g=w.b=1-A/(L-C.positionScreen.z*E);n.r=n.g=n.b=1-A/(L-W.positionScreen.z*E);m.r=m.g=m.b=1-A/(L-R.positionScreen.z*E);D.r=(n.r+m.r)*0.5;D.g=(n.g+m.g)*0.5;D.b=(n.b+m.b)*0.5;O=Ha(w,n,m,D);sa(K,F,y,o,i,p,O,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){h.r=Da(I.normalWorld.x);h.g=Da(I.normalWorld.y);h.b=Da(I.normalWorld.z);h.updateStyleString();P.wireframe?za(h.__styleString,P.wireframe_linewidth):Aa(h.__styleString)}}}function za(C,W){if(t!=C)g.strokeStyle=
t=C;if(q!=W)g.lineWidth=q=W;g.stroke();J.inflate(W*2)}function Aa(C){if(x!=C)g.fillStyle=x=C;g.fill()}function sa(C,W,R,I,P,Z,ba,ca,da,ja,ga,ka,ta){var na,la;na=ba.width-1;la=ba.height-1;ca*=na;da*=la;ja*=na;ga*=la;ka*=na;ta*=la;R-=C;I-=W;P-=C;Z-=W;ja-=ca;ga-=da;ka-=ca;ta-=da;la=1/(ja*ta-ka*ga);na=(ta*R-ga*P)*la;ga=(ta*I-ga*Z)*la;R=(ja*P-ka*R)*la;I=(ja*Z-ka*I)*la;C=C-na*ca-R*da;W=W-ga*ca-I*da;g.save();g.transform(na,ga,R,I,C,W);g.clip();g.drawImage(ba,0,0);g.restore()}function Ca(C){if(j!=C)g.globalAlpha=
j=C}function ya(C){if(c!=C){switch(C){case THREE.NormalBlending:g.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:g.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:g.globalCompositeOperation="darker"}c=C}}function Ha(C,W,R,I){var P=~~(C.r*255),Z=~~(C.g*255);C=~~(C.b*255);var ba=~~(W.r*255),ca=~~(W.g*255);W=~~(W.b*255);var da=~~(R.r*255),ja=~~(R.g*255);R=~~(R.b*255);var ga=~~(I.r*255),ka=~~(I.g*255);I=~~(I.b*255);fa[0]=P<0?0:P>255?255:P;fa[1]=Z<0?0:
Z>255?255:Z;fa[2]=C<0?0:C>255?255:C;fa[4]=ba<0?0:ba>255?255:ba;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=W<0?0:W>255?255:W;fa[8]=da<0?0:da>255?255:da;fa[9]=ja<0?0:ja>255?255:ja;fa[10]=R<0?0:R>255?255:R;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ka<0?0:ka>255?255:ka;fa[14]=I<0?0:I>255?255:I;ma.putImageData(oa,0,0);va.drawImage(ea,0,0);return ra}function Da(C){C=(C+1)*0.5;return C<0?0:C>1?1:C}function Ea(C,W){var R=W.x-C.x,I=W.y-C.y,P=1/Math.sqrt(R*R+I*I);R*=P;I*=P;W.x+=R;W.y+=I;C.x-=R;C.y-=I}var Ba,Ia,aa,ha,qa,Fa,
Ja,ua;g.setTransform(1,0,0,-1,k,l);this.autoClear&&this.clear();a=b.projectScene(ia,wa);($=ia.lights.length>0)&&Ka(ia);Ba=0;for(Ia=a.length;Ba<Ia;Ba++){aa=a[Ba];J.empty();if(aa instanceof THREE.RenderableParticle){s=aa;s.x*=k;s.y*=l;ha=0;for(qa=aa.material.length;ha<qa;ha++)La(s,aa,aa.material[ha],ia)}else if(aa instanceof THREE.RenderableLine){s=aa.v1;v=aa.v2;s.positionScreen.x*=k;s.positionScreen.y*=l;v.positionScreen.x*=k;v.positionScreen.y*=l;J.addPoint(s.positionScreen.x,s.positionScreen.y);
J.addPoint(v.positionScreen.x,v.positionScreen.y);if(Q.instersects(J)){ha=0;for(qa=aa.material.length;ha<qa;)Ma(s,v,aa,aa.material[ha++],ia)}}else if(aa instanceof THREE.RenderableFace3){s=aa.v1;v=aa.v2;z=aa.v3;s.positionScreen.x*=k;s.positionScreen.y*=l;v.positionScreen.x*=k;v.positionScreen.y*=l;z.positionScreen.x*=k;z.positionScreen.y*=l;if(aa.overdraw){Ea(s.positionScreen,v.positionScreen);Ea(v.positionScreen,z.positionScreen);Ea(z.positionScreen,s.positionScreen)}J.add3Points(s.positionScreen.x,
s.positionScreen.y,v.positionScreen.x,v.positionScreen.y,z.positionScreen.x,z.positionScreen.y);if(Q.instersects(J)){ha=0;for(qa=aa.meshMaterial.length;ha<qa;){ua=aa.meshMaterial[ha++];if(ua instanceof THREE.MeshFaceMaterial){Fa=0;for(Ja=aa.faceMaterial.length;Fa<Ja;)(ua=aa.faceMaterial[Fa++])&&Ga(s,v,z,aa,ua,ia)}else Ga(s,v,z,aa,ua,ia)}}}H.addRectangle(J)}g.setTransform(1,0,0,1,0,0)}};
THREE.SVGRenderer=function(){function a(N,U,V){var Q,H,J,$;Q=0;for(H=N.lights.length;Q<H;Q++){J=N.lights[Q];if(J instanceof THREE.DirectionalLight){$=U.normalWorld.dot(J.position)*J.intensity;if($>0){V.r+=J.color.r*$;V.g+=J.color.g*$;V.b+=J.color.b*$}}else if(J instanceof THREE.PointLight){n.sub(J.position,U.centroidWorld);n.normalize();$=U.normalWorld.dot(n)*J.intensity;if($>0){V.r+=J.color.r*$;V.g+=J.color.g*$;V.b+=J.color.b*$}}}}function b(N,U,V,Q,H,J){E=e(O++);E.setAttribute("d","M "+N.positionScreen.x+
" "+N.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)o.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(y){i.r=p.r;i.g=p.g;i.b=p.b;a(J,Q,i);o.r=H.color.r*i.r;o.g=H.color.g*i.g;o.b=H.color.b*i.b;o.updateStyleString()}else o.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){m=1-H.__2near/(H.__farPlusNear-Q.z*H.__farMinusNear);
o.setRGB(m,m,m)}else H instanceof THREE.MeshNormalMaterial&&o.setRGB(f(Q.normalWorld.x),f(Q.normalWorld.y),f(Q.normalWorld.z));H.wireframe?E.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):E.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+H.opacity);g.appendChild(E)}function d(N,U,V,Q,H,J,$){E=e(O++);E.setAttribute("d",
"M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)o.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(y){i.r=p.r;i.g=p.g;i.b=p.b;a($,H,i);o.r=J.color.r*i.r;o.g=J.color.g*i.g;o.b=J.color.b*i.b;o.updateStyleString()}else o.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){m=
1-J.__2near/(J.__farPlusNear-H.z*J.__farMinusNear);o.setRGB(m,m,m)}else J instanceof THREE.MeshNormalMaterial&&o.setRGB(f(H.normalWorld.x),f(H.normalWorld.y),f(H.normalWorld.z));J.wireframe?E.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):E.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+J.opacity);g.appendChild(E)}
THREE.SVGRenderer=function(){function a(N,U,V){var Q,H,J,$;Q=0;for(H=N.lights.length;Q<H;Q++){J=N.lights[Q];if(J instanceof THREE.DirectionalLight){$=U.normalWorld.dot(J.position)*J.intensity;if($>0){V.r+=J.color.r*$;V.g+=J.color.g*$;V.b+=J.color.b*$}}else if(J instanceof THREE.PointLight){m.sub(J.position,U.centroidWorld);m.normalize();$=U.normalWorld.dot(m)*J.intensity;if($>0){V.r+=J.color.r*$;V.g+=J.color.g*$;V.b+=J.color.b*$}}}}function b(N,U,V,Q,H,J){E=e(O++);E.setAttribute("d","M "+N.positionScreen.x+
" "+N.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)o.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(y){i.r=p.r;i.g=p.g;i.b=p.b;a(J,Q,i);o.r=H.color.r*i.r;o.g=H.color.g*i.g;o.b=H.color.b*i.b;o.updateStyleString()}else o.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){n=1-H.__2near/(H.__farPlusNear-Q.z*H.__farMinusNear);
o.setRGB(n,n,n)}else H instanceof THREE.MeshNormalMaterial&&o.setRGB(f(Q.normalWorld.x),f(Q.normalWorld.y),f(Q.normalWorld.z));H.wireframe?E.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):E.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+H.opacity);g.appendChild(E)}function d(N,U,V,Q,H,J,$){E=e(O++);E.setAttribute("d",
"M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)o.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(y){i.r=p.r;i.g=p.g;i.b=p.b;a($,H,i);o.r=J.color.r*i.r;o.g=J.color.g*i.g;o.b=J.color.b*i.b;o.updateStyleString()}else o.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){n=
1-J.__2near/(J.__farPlusNear-H.z*J.__farMinusNear);o.setRGB(n,n,n)}else J instanceof THREE.MeshNormalMaterial&&o.setRGB(f(H.normalWorld.x),f(H.normalWorld.y),f(H.normalWorld.z));J.wireframe?E.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):E.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+J.opacity);g.appendChild(E)}
function e(N){if(D[N]==null){D[N]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&D[N].setAttribute("shape-rendering","crispEdges");return D[N]}return D[N]}function f(N){return N<0?Math.min((1+N)*0.5,0.5):0.5+Math.min(N*0.5,0.5)}var k=null,l=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,c,t,x,q,s,v,z,K=new THREE.Rectangle,F=new THREE.Rectangle,y=false,o=new THREE.Color(16777215),i=new THREE.Color(16777215),p=new THREE.Color(0),h=new THREE.Color(0),
w=new THREE.Color(0),m,n=new THREE.Vector3,D=[],A=[],L=[],E,O,S,G,T=1;this.domElement=g;this.autoClear=true;this.setQuality=function(N){switch(N){case "high":T=1;break;case "low":T=0}};this.setSize=function(N,U){j=N;c=U;t=j/2;x=c/2;g.setAttribute("viewBox",-t+" "+-x+" "+j+" "+c);g.setAttribute("width",j);g.setAttribute("height",c);K.set(-t,-x,t,x)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(N,U){var V,Q,H,J,$,r,u,B;this.autoClear&&this.clear();
w=new THREE.Color(0),n,m=new THREE.Vector3,D=[],A=[],L=[],E,O,S,G,T=1;this.domElement=g;this.autoClear=true;this.setQuality=function(N){switch(N){case "high":T=1;break;case "low":T=0}};this.setSize=function(N,U){j=N;c=U;t=j/2;x=c/2;g.setAttribute("viewBox",-t+" "+-x+" "+j+" "+c);g.setAttribute("width",j);g.setAttribute("height",c);K.set(-t,-x,t,x)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(N,U){var V,Q,H,J,$,r,u,B;this.autoClear&&this.clear();
k=l.projectScene(N,U);G=S=O=0;if(y=N.lights.length>0){u=N.lights;p.setRGB(0,0,0);h.setRGB(0,0,0);w.setRGB(0,0,0);V=0;for(Q=u.length;V<Q;V++){H=u[V];J=H.color;if(H instanceof THREE.AmbientLight){p.r+=J.r;p.g+=J.g;p.b+=J.b}else if(H instanceof THREE.DirectionalLight){h.r+=J.r;h.g+=J.g;h.b+=J.b}else if(H instanceof THREE.PointLight){w.r+=J.r;w.g+=J.g;w.b+=J.b}}}V=0;for(Q=k.length;V<Q;V++){u=k[V];F.empty();if(u instanceof THREE.RenderableParticle){q=u;q.x*=t;q.y*=-x;H=0;for(J=u.material.length;H<J;H++)if(B=
u.material[H]){$=q;r=u;B=B;var M=S++;if(A[M]==null){A[M]=document.createElementNS("http://www.w3.org/2000/svg","circle");T==0&&A[M].setAttribute("shape-rendering","crispEdges")}E=A[M];E.setAttribute("cx",$.x);E.setAttribute("cy",$.y);E.setAttribute("r",r.scale.x*t);if(B instanceof THREE.ParticleCircleMaterial){if(y){i.r=p.r+h.r+w.r;i.g=p.g+h.g+w.g;i.b=p.b+h.b+w.b;o.r=B.color.r*i.r;o.g=B.color.g*i.g;o.b=B.color.b*i.b;o.updateStyleString()}else o=B.color;E.setAttribute("style","fill: "+o.__styleString)}g.appendChild(E)}}else if(u instanceof
THREE.RenderableLine){q=u.v1;s=u.v2;q.positionScreen.x*=t;q.positionScreen.y*=-x;s.positionScreen.x*=t;s.positionScreen.y*=-x;F.addPoint(q.positionScreen.x,q.positionScreen.y);F.addPoint(s.positionScreen.x,s.positionScreen.y);if(K.instersects(F)){H=0;for(J=u.material.length;H<J;)if(B=u.material[H++]){$=q;r=s;B=B;M=G++;if(L[M]==null){L[M]=document.createElementNS("http://www.w3.org/2000/svg","line");T==0&&L[M].setAttribute("shape-rendering","crispEdges")}E=L[M];E.setAttribute("x1",$.positionScreen.x);
@@ -137,10 +137,10 @@ THREE.WebGLRenderer=function(a){function b(i,p){var h=c.createProgram(),w=[c.get
i));c.attachShader(h,l("vertex",w+p));c.linkProgram(h);c.getProgramParameter(h,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(h,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");h.uniforms={};h.attributes={};return h}function d(i,p){if(i.image.length==6){if(!i.image.__webGLTextureCube&&!i.image.__cubeMapInitialized&&i.image.loadCount==6){i.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,i.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,
c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(var h=0;h<6;++h)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image[h]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);i.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_CUBE_MAP,
i.image.__webGLTextureCube)}}function e(i,p){if(!i.__webGLTexture&&i.image.loaded){i.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,i.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,i.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,g(i.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,g(i.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,g(i.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,g(i.min_filter));c.generateMipmap(c.TEXTURE_2D);
c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function f(i,p){var h,w,m;h=0;for(w=p.length;h<w;h++){m=p[h];i.uniforms[m]=c.getUniformLocation(i,m)}}function k(i,p){var h,w,m;h=0;for(w=p.length;h<w;h++){m=p[h];i.attributes[m]=c.getAttribLocation(i,m);i.attributes[m]>=0&&c.enableVertexAttribArray(i.attributes[m])}}function l(i,p){var h;if(i=="fragment")h=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")h=c.createShader(c.VERTEX_SHADER);
c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_2D,i.__webGLTexture)}function f(i,p){var h,w,n;h=0;for(w=p.length;h<w;h++){n=p[h];i.uniforms[n]=c.getUniformLocation(i,n)}}function k(i,p){var h,w,n;h=0;for(w=p.length;h<w;h++){n=p[h];i.attributes[n]=c.getAttribLocation(i,n);i.attributes[n]>=0&&c.enableVertexAttribArray(i.attributes[n])}}function l(i,p){var h;if(i=="fragment")h=c.createShader(c.FRAGMENT_SHADER);else if(i=="vertex")h=c.createShader(c.VERTEX_SHADER);
c.shaderSource(h,p);c.compileShader(h);if(!c.getShaderParameter(h,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(h));return null}return h}function g(i){switch(i){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;
case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var j=document.createElement("canvas"),c,t,x,q=new THREE.Matrix4,s,v=new Float32Array(16),z=new Float32Array(16),K=new Float32Array(16),F=new Float32Array(9),y=new Float32Array(16);a=function(i,p){if(i){var h,w,m,n=pointLights=maxDirLights=maxPointLights=0;h=0;for(w=i.lights.length;h<w;h++){m=i.lights[h];m instanceof THREE.DirectionalLight&&n++;m instanceof
THREE.PointLight&&pointLights++}if(pointLights+n<=p){maxDirLights=n;maxPointLights=pointLights}else{maxDirLights=Math.ceil(p*n/(pointLights+n));maxPointLights=p-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:p-1}}(a,4);this.domElement=j;this.autoClear=true;try{c=j.getContext("experimental-webgl",{antialias:true})}catch(o){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);
case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR}return 0}var j=document.createElement("canvas"),c,t,x,q=new THREE.Matrix4,s,v=new Float32Array(16),z=new Float32Array(16),K=new Float32Array(16),F=new Float32Array(9),y=new Float32Array(16);a=function(i,p){if(i){var h,w,n,m=pointLights=maxDirLights=maxPointLights=0;h=0;for(w=i.lights.length;h<w;h++){n=i.lights[h];n instanceof THREE.DirectionalLight&&m++;n instanceof
THREE.PointLight&&pointLights++}if(pointLights+m<=p){maxDirLights=m;maxPointLights=pointLights}else{maxDirLights=Math.ceil(p*m/(pointLights+m));maxPointLights=p-maxDirLights}return{directional:maxDirLights,point:maxPointLights}}return{directional:1,point:p-1}}(a,4);this.domElement=j;this.autoClear=true;try{c=j.getContext("experimental-webgl",{antialias:true})}catch(o){}if(!c){alert("WebGL not supported");throw"cannot create webgl context";}c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);
c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(0,0,0,0);t=x=function(i,p){var h=[i?"#define MAX_DIR_LIGHTS "+i:"",p?"#define MAX_POINT_LIGHTS "+p:"","uniform bool enableLighting;\nuniform bool useRefract;\nuniform int pointLightNumber;\nuniform int directionalLightNumber;\nuniform vec3 ambientLightColor;",i?"uniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];":"",i?"uniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];":
"",p?"uniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];":"",p?"uniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];":"","varying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;",p?"varying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];":"","varying vec3 vViewPosition;\nvarying vec3 vReflect;\nuniform float mRefractionRatio;\nvoid main(void) {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec3 transformedNormal = normalize( normalMatrix * normal );\nif ( !enableLighting ) {\nvLightWeighting = vec3( 1.0, 1.0, 1.0 );\n} else {\nvLightWeighting = ambientLightColor;",
i?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",i?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",i?"float directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );":"",i?"vLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;":"",i?"}":"",p?"for( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {":"",p?"vec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );":"",p?"vPointLightVector[ i ] = normalize( lPosition.xyz - mvPosition.xyz );":
@@ -152,26 +152,26 @@ p?"vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",p?"vec4 pointSpecular =
"",i?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",i?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",i?"float dirSpecularWeight = 0.0;":"",i?"if ( dirDotNormalHalf >= 0.0 )":"",i?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",i?"dirDiffuse += mColor * dirDiffuseWeight;":"",i?"dirSpecular += mSpecular * dirSpecularWeight;":"",i?"}":"","vec4 totalLight = mAmbient;",i?"totalLight += dirDiffuse + dirSpecular;":"",p?"totalLight += pointDiffuse + pointSpecular;":
"","if ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mapColor.rgb * totalLight.xyz * vLightWeighting, cubeColor.rgb, mReflectivity ), mapColor.a );\n} else {\ngl_FragColor = vec4( mapColor.rgb * cubeColor.rgb * totalLight.xyz * vLightWeighting, mapColor.a );\n}\n} else if ( material == 1 ) {\nif ( mixEnvMap ) {\ngl_FragColor = vec4( mix( mColor.rgb * mapColor.rgb * vLightWeighting, cubeColor.rgb, mReflectivity ), mColor.a * mapColor.a );\n} else {\ngl_FragColor = vec4( mColor.rgb * mapColor.rgb * cubeColor.rgb * vLightWeighting, mColor.a * mapColor.a );\n}\n} else {\nif ( mixEnvMap ) {\ngl_FragColor = mix( mColor * mapColor, cubeColor, mReflectivity );\n} else {\ngl_FragColor = mColor * mapColor * cubeColor;\n}\n}\n}"].join("\n");
h=b(w,h);c.useProgram(h);f(h,["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","enableLighting","ambientLightColor","material","mColor","mAmbient","mSpecular","mShininess","mOpacity","enableMap","tMap","enableCubeMap","tCube","mixEnvMap","mReflectivity","mRefractionRatio","useRefract","m2Near","mFarPlusNear","mFarMinusNear"]);i&&f(h,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);p&&f(h,["pointLightNumber","pointLightColor",
"pointLightPosition"]);c.uniform1i(h.uniforms.enableMap,0);c.uniform1i(h.uniforms.tMap,0);c.uniform1i(h.uniforms.enableCubeMap,0);c.uniform1i(h.uniforms.tCube,1);c.uniform1i(h.uniforms.mixEnvMap,0);c.uniform1i(h.uniforms.useRefract,0);k(h,["position","normal","uv"]);return h}(a.directional,a.point);this.setSize=function(i,p){j.width=i;j.height=p;c.viewport(0,0,j.width,j.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,p){var h,w,m,n,D,A=[],
L=[],E=[];n=[];D=[];c.uniform1i(i.uniforms.enableLighting,p.length);h=0;for(w=p.length;h<w;h++){m=p[h];if(m instanceof THREE.AmbientLight)A.push(m);else if(m instanceof THREE.DirectionalLight)E.push(m);else m instanceof THREE.PointLight&&L.push(m)}h=m=n=D=0;for(w=A.length;h<w;h++){m+=A[h].color.r;n+=A[h].color.g;D+=A[h].color.b}c.uniform3f(i.uniforms.ambientLightColor,m,n,D);n=[];D=[];h=0;for(w=E.length;h<w;h++){m=E[h];n.push(m.color.r*m.intensity);n.push(m.color.g*m.intensity);n.push(m.color.b*m.intensity);
D.push(m.position.x);D.push(m.position.y);D.push(m.position.z)}if(E.length){c.uniform1i(i.uniforms.directionalLightNumber,E.length);c.uniform3fv(i.uniforms.directionalLightDirection,D);c.uniform3fv(i.uniforms.directionalLightColor,n)}n=[];D=[];h=0;for(w=L.length;h<w;h++){m=L[h];n.push(m.color.r*m.intensity);n.push(m.color.g*m.intensity);n.push(m.color.b*m.intensity);D.push(m.position.x);D.push(m.position.y);D.push(m.position.z)}if(L.length){c.uniform1i(i.uniforms.pointLightNumber,L.length);c.uniform3fv(i.uniforms.pointLightPosition,
D);c.uniform3fv(i.uniforms.pointLightColor,n)}};this.createBuffers=function(i,p){var h,w,m,n,D,A,L,E,O,S=[],G=[],T=[],N=[],U=[],V=[],Q=0,H=i.geometry.geometryChunks[p],J;m=false;h=0;for(w=i.material.length;h<w;h++){meshMaterial=i.material[h];if(meshMaterial instanceof THREE.MeshFaceMaterial){D=0;for(J=H.material.length;D<J;D++)if(H.material[D]&&H.material[D].shading!=undefined&&H.material[D].shading==THREE.SmoothShading){m=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
THREE.SmoothShading){m=true;break}if(m)break}J=m;h=0;for(w=H.faces.length;h<w;h++){m=H.faces[h];n=i.geometry.faces[m];D=n.vertexNormals;faceNormal=n.normal;m=i.geometry.uvs[m];if(n instanceof THREE.Face3){A=i.geometry.vertices[n.a].position;L=i.geometry.vertices[n.b].position;E=i.geometry.vertices[n.c].position;T.push(A.x,A.y,A.z);T.push(L.x,L.y,L.z);T.push(E.x,E.y,E.z);if(i.geometry.hasTangents){A=i.geometry.vertices[n.a].tangent;L=i.geometry.vertices[n.b].tangent;E=i.geometry.vertices[n.c].tangent;
U.push(A.x,A.y,A.z,A.w);U.push(L.x,L.y,L.z,L.w);U.push(E.x,E.y,E.z,E.w)}if(D.length==3&&J)for(n=0;n<3;n++)N.push(D[n].x,D[n].y,D[n].z);else for(n=0;n<3;n++)N.push(faceNormal.x,faceNormal.y,faceNormal.z);if(m)for(n=0;n<3;n++)V.push(m[n].u,m[n].v);S.push(Q,Q+1,Q+2);G.push(Q,Q+1);G.push(Q,Q+2);G.push(Q+1,Q+2);Q+=3}else if(n instanceof THREE.Face4){A=i.geometry.vertices[n.a].position;L=i.geometry.vertices[n.b].position;E=i.geometry.vertices[n.c].position;O=i.geometry.vertices[n.d].position;T.push(A.x,
A.y,A.z);T.push(L.x,L.y,L.z);T.push(E.x,E.y,E.z);T.push(O.x,O.y,O.z);if(i.geometry.hasTangents){A=i.geometry.vertices[n.a].tangent;L=i.geometry.vertices[n.b].tangent;E=i.geometry.vertices[n.c].tangent;n=i.geometry.vertices[n.d].tangent;U.push(A.x,A.y,A.z,A.w);U.push(L.x,L.y,L.z,L.w);U.push(E.x,E.y,E.z,E.w);U.push(n.x,n.y,n.z,n.w)}if(D.length==4&&J)for(n=0;n<4;n++)N.push(D[n].x,D[n].y,D[n].z);else for(n=0;n<4;n++)N.push(faceNormal.x,faceNormal.y,faceNormal.z);if(m)for(n=0;n<4;n++)V.push(m[n].u,m[n].v);
"pointLightPosition"]);c.uniform1i(h.uniforms.enableMap,0);c.uniform1i(h.uniforms.tMap,0);c.uniform1i(h.uniforms.enableCubeMap,0);c.uniform1i(h.uniforms.tCube,1);c.uniform1i(h.uniforms.mixEnvMap,0);c.uniform1i(h.uniforms.useRefract,0);k(h,["position","normal","uv"]);return h}(a.directional,a.point);this.setSize=function(i,p){j.width=i;j.height=p;c.viewport(0,0,j.width,j.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(i,p){var h,w,n,m,D,A=[],
L=[],E=[];m=[];D=[];c.uniform1i(i.uniforms.enableLighting,p.length);h=0;for(w=p.length;h<w;h++){n=p[h];if(n instanceof THREE.AmbientLight)A.push(n);else if(n instanceof THREE.DirectionalLight)E.push(n);else n instanceof THREE.PointLight&&L.push(n)}h=n=m=D=0;for(w=A.length;h<w;h++){n+=A[h].color.r;m+=A[h].color.g;D+=A[h].color.b}c.uniform3f(i.uniforms.ambientLightColor,n,m,D);m=[];D=[];h=0;for(w=E.length;h<w;h++){n=E[h];m.push(n.color.r*n.intensity);m.push(n.color.g*n.intensity);m.push(n.color.b*n.intensity);
D.push(n.position.x);D.push(n.position.y);D.push(n.position.z)}if(E.length){c.uniform1i(i.uniforms.directionalLightNumber,E.length);c.uniform3fv(i.uniforms.directionalLightDirection,D);c.uniform3fv(i.uniforms.directionalLightColor,m)}m=[];D=[];h=0;for(w=L.length;h<w;h++){n=L[h];m.push(n.color.r*n.intensity);m.push(n.color.g*n.intensity);m.push(n.color.b*n.intensity);D.push(n.position.x);D.push(n.position.y);D.push(n.position.z)}if(L.length){c.uniform1i(i.uniforms.pointLightNumber,L.length);c.uniform3fv(i.uniforms.pointLightPosition,
D);c.uniform3fv(i.uniforms.pointLightColor,m)}};this.createBuffers=function(i,p){var h,w,n,m,D,A,L,E,O,S=[],G=[],T=[],N=[],U=[],V=[],Q=0,H=i.geometry.geometryChunks[p],J;n=false;h=0;for(w=i.material.length;h<w;h++){meshMaterial=i.material[h];if(meshMaterial instanceof THREE.MeshFaceMaterial){D=0;for(J=H.material.length;D<J;D++)if(H.material[D]&&H.material[D].shading!=undefined&&H.material[D].shading==THREE.SmoothShading){n=true;break}}else if(meshMaterial&&meshMaterial.shading!=undefined&&meshMaterial.shading==
THREE.SmoothShading){n=true;break}if(n)break}J=n;h=0;for(w=H.faces.length;h<w;h++){n=H.faces[h];m=i.geometry.faces[n];D=m.vertexNormals;faceNormal=m.normal;n=i.geometry.uvs[n];if(m instanceof THREE.Face3){A=i.geometry.vertices[m.a].position;L=i.geometry.vertices[m.b].position;E=i.geometry.vertices[m.c].position;T.push(A.x,A.y,A.z);T.push(L.x,L.y,L.z);T.push(E.x,E.y,E.z);if(i.geometry.hasTangents){A=i.geometry.vertices[m.a].tangent;L=i.geometry.vertices[m.b].tangent;E=i.geometry.vertices[m.c].tangent;
U.push(A.x,A.y,A.z,A.w);U.push(L.x,L.y,L.z,L.w);U.push(E.x,E.y,E.z,E.w)}if(D.length==3&&J)for(m=0;m<3;m++)N.push(D[m].x,D[m].y,D[m].z);else for(m=0;m<3;m++)N.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(m=0;m<3;m++)V.push(n[m].u,n[m].v);S.push(Q,Q+1,Q+2);G.push(Q,Q+1);G.push(Q,Q+2);G.push(Q+1,Q+2);Q+=3}else if(m instanceof THREE.Face4){A=i.geometry.vertices[m.a].position;L=i.geometry.vertices[m.b].position;E=i.geometry.vertices[m.c].position;O=i.geometry.vertices[m.d].position;T.push(A.x,
A.y,A.z);T.push(L.x,L.y,L.z);T.push(E.x,E.y,E.z);T.push(O.x,O.y,O.z);if(i.geometry.hasTangents){A=i.geometry.vertices[m.a].tangent;L=i.geometry.vertices[m.b].tangent;E=i.geometry.vertices[m.c].tangent;m=i.geometry.vertices[m.d].tangent;U.push(A.x,A.y,A.z,A.w);U.push(L.x,L.y,L.z,L.w);U.push(E.x,E.y,E.z,E.w);U.push(m.x,m.y,m.z,m.w)}if(D.length==4&&J)for(m=0;m<4;m++)N.push(D[m].x,D[m].y,D[m].z);else for(m=0;m<4;m++)N.push(faceNormal.x,faceNormal.y,faceNormal.z);if(n)for(m=0;m<4;m++)V.push(n[m].u,n[m].v);
S.push(Q,Q+1,Q+2);S.push(Q,Q+2,Q+3);G.push(Q,Q+1);G.push(Q,Q+2);G.push(Q,Q+3);G.push(Q+1,Q+2);G.push(Q+2,Q+3);Q+=4}}if(T.length){H.__webGLVertexBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(T),c.STATIC_DRAW);H.__webGLNormalBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(N),c.STATIC_DRAW);if(i.geometry.hasTangents){H.__webGLTangentBuffer=c.createBuffer();
c.bindBuffer(c.ARRAY_BUFFER,H.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(U),c.STATIC_DRAW)}if(V.length>0){H.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,H.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(V),c.STATIC_DRAW)}H.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,H.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(S),c.STATIC_DRAW);H.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
H.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),c.STATIC_DRAW);H.__webGLFaceCount=S.length;H.__webGLLineCount=G.length}};this.renderBuffer=function(i,p,h,w){var m,n,D,A,L,E,O,S,G;if(h instanceof THREE.MeshShaderMaterial){if(!h.program){h.program=b(h.fragment_shader,h.vertex_shader);O=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(G in h.uniforms)O.push(G);f(h.program,O);k(h.program,["position","normal","uv","tangent"])}G=
h.program}else G=x;if(G!=t){c.useProgram(G);t=G}G==x&&this.setupLights(G,p);this.loadCamera(G,i);this.loadMatrices(G);if(h instanceof THREE.MeshShaderMaterial){D=h.wireframe;A=h.wireframe_linewidth;i=G;p=h.uniforms;var T;for(m in p){S=p[m].type;O=p[m].value;T=i.uniforms[m];if(S=="i")c.uniform1i(T,O);else if(S=="f")c.uniform1f(T,O);else if(S=="v3")c.uniform3f(T,O.x,O.y,O.z);else if(S=="c")c.uniform3f(T,O.r,O.g,O.b);else if(S=="t"){c.uniform1i(T,O);if(S=p[m].texture)S.image instanceof Array&&S.image.length==
6?d(S,O):e(S,O)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshBasicMaterial){m=h.color;n=h.opacity;D=h.wireframe;A=h.wireframe_linewidth;L=h.map;E=h.env_map;p=h.combine==THREE.MixOperation;i=h.reflectivity;S=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;O=h.refraction_ratio;c.uniform4f(G.uniforms.mColor,m.r*n,m.g*n,m.b*n,n);c.uniform1i(G.uniforms.mixEnvMap,p);c.uniform1f(G.uniforms.mReflectivity,i);c.uniform1i(G.uniforms.useRefract,
S);c.uniform1f(G.uniforms.mRefractionRatio,O)}if(h instanceof THREE.MeshNormalMaterial){n=h.opacity;c.uniform1f(G.uniforms.mOpacity,n);c.uniform1i(G.uniforms.material,4)}else if(h instanceof THREE.MeshDepthMaterial){n=h.opacity;D=h.wireframe;A=h.wireframe_linewidth;c.uniform1f(G.uniforms.mOpacity,n);c.uniform1f(G.uniforms.m2Near,h.__2near);c.uniform1f(G.uniforms.mFarPlusNear,h.__farPlusNear);c.uniform1f(G.uniforms.mFarMinusNear,h.__farMinusNear);c.uniform1i(G.uniforms.material,3)}else if(h instanceof
THREE.MeshPhongMaterial){m=h.ambient;i=h.specular;h=h.shininess;c.uniform4f(G.uniforms.mAmbient,m.r,m.g,m.b,n);c.uniform4f(G.uniforms.mSpecular,i.r,i.g,i.b,n);c.uniform1f(G.uniforms.mShininess,h);c.uniform1i(G.uniforms.material,2)}else if(h instanceof THREE.MeshLambertMaterial)c.uniform1i(G.uniforms.material,1);else if(h instanceof THREE.MeshBasicMaterial)c.uniform1i(G.uniforms.material,0);else if(h instanceof THREE.MeshCubeMaterial){c.uniform1i(G.uniforms.material,5);E=h.env_map}if(L){e(L,0);c.uniform1i(G.uniforms.tMap,
0);c.uniform1i(G.uniforms.enableMap,1)}else c.uniform1i(G.uniforms.enableMap,0);if(E){d(E,1);c.uniform1i(G.uniforms.tCube,1);c.uniform1i(G.uniforms.enableCubeMap,1)}else c.uniform1i(G.uniforms.enableCubeMap,0);n=G.attributes;c.bindBuffer(c.ARRAY_BUFFER,w.__webGLVertexBuffer);c.vertexAttribPointer(n.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,w.__webGLNormalBuffer);c.vertexAttribPointer(n.normal,3,c.FLOAT,false,0,0);if(n.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLTangentBuffer);
c.vertexAttribPointer(n.tangent,4,c.FLOAT,false,0,0)}if(n.uv>=0)if(w.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLUVBuffer);c.enableVertexAttribArray(n.uv);c.vertexAttribPointer(n.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(n.uv);if(D){c.lineWidth(A);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);c.drawElements(c.LINES,w.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,w.__webGLFaceCount,c.UNSIGNED_SHORT,
0)}};this.renderPass=function(i,p,h,w,m,n){var D,A,L,E,O;L=0;for(E=h.material.length;L<E;L++){D=h.material[L];if(D instanceof THREE.MeshFaceMaterial){D=0;for(A=w.material.length;D<A;D++)if((O=w.material[D])&&O.blending==m&&O.opacity<1==n){this.setBlending(O.blending);this.renderBuffer(i,p,O,w)}}else if((O=D)&&O.blending==m&&O.opacity<1==n){this.setBlending(O.blending);this.renderBuffer(i,p,O,w)}}};this.render=function(i,p){var h,w,m,n,D=i.lights;this.initWebGLObjects(i);this.autoClear&&this.clear();
p.autoUpdateMatrix&&p.updateMatrix();h=0;for(w=i.__webGLObjects.length;h<w;h++){m=i.__webGLObjects[h];n=m.object;m=m.buffer;if(n.visible){this.setupMatrices(n,p);this.renderPass(p,D,n,m,THREE.NormalBlending,false)}}h=0;for(w=i.__webGLObjects.length;h<w;h++){m=i.__webGLObjects[h];n=m.object;m=m.buffer;if(n.visible){this.setupMatrices(n,p);this.renderPass(p,D,n,m,THREE.AdditiveBlending,false);this.renderPass(p,D,n,m,THREE.SubtractiveBlending,false);this.renderPass(p,D,n,m,THREE.AdditiveBlending,true);
this.renderPass(p,D,n,m,THREE.SubtractiveBlending,true);this.renderPass(p,D,n,m,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(i){var p,h,w,m,n,D;if(!i.__webGLObjects){i.__webGLObjects=[];i.__webGLObjectsMap={}}p=0;for(h=i.objects.length;p<h;p++){w=i.objects[p];if(i.__webGLObjectsMap[w.id]==undefined)i.__webGLObjectsMap[w.id]={};D=i.__webGLObjectsMap[w.id];if(w instanceof THREE.Mesh)for(n in w.geometry.geometryChunks){m=w.geometry.geometryChunks[n];m.__webGLVertexBuffer||this.createBuffers(w,
n);if(D[n]==undefined){m={buffer:m,object:w};i.__webGLObjects.push(m);D[n]=1}}}};this.removeObject=function(i,p){var h,w;for(h=i.__webGLObjects.length-1;h>=0;h--){w=i.__webGLObjects[h].object;p==w&&i.__webGLObjects.splice(h,1)}};this.setupMatrices=function(i,p){i.autoUpdateMatrix&&i.updateMatrix();q.multiply(p.matrix,i.matrix);v.set(p.matrix.flatten());z.set(q.flatten());K.set(p.projectionMatrix.flatten());s=THREE.Matrix4.makeInvert3x3(q).transpose();F.set(s.m);y.set(i.matrix.flatten())};this.loadMatrices=
H.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),c.STATIC_DRAW);H.__webGLFaceCount=S.length;H.__webGLLineCount=G.length}};this.renderBuffer=function(i,p,h,w){var n,m,D,A,L,E,O,S,G;if(h instanceof THREE.MeshShaderMaterial){if(!h.program){h.program=b(h.fragment_shader,h.vertex_shader);O=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(G in h.uniforms)O.push(G);f(h.program,O);k(h.program,["position","normal","uv","tangent"])}G=
h.program}else G=x;if(G!=t){c.useProgram(G);t=G}G==x&&this.setupLights(G,p);this.loadCamera(G,i);this.loadMatrices(G);if(h instanceof THREE.MeshShaderMaterial){D=h.wireframe;A=h.wireframe_linewidth;i=G;p=h.uniforms;var T;for(n in p){S=p[n].type;O=p[n].value;T=i.uniforms[n];if(S=="i")c.uniform1i(T,O);else if(S=="f")c.uniform1f(T,O);else if(S=="v3")c.uniform3f(T,O.x,O.y,O.z);else if(S=="c")c.uniform3f(T,O.r,O.g,O.b);else if(S=="t"){c.uniform1i(T,O);if(S=p[n].texture)S.image instanceof Array&&S.image.length==
6?d(S,O):e(S,O)}}}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshBasicMaterial){n=h.color;m=h.opacity;D=h.wireframe;A=h.wireframe_linewidth;L=h.map;E=h.env_map;p=h.combine==THREE.MixOperation;i=h.reflectivity;S=h.env_map&&h.env_map.mapping instanceof THREE.CubeRefractionMapping;O=h.refraction_ratio;c.uniform4f(G.uniforms.mColor,n.r*m,n.g*m,n.b*m,m);c.uniform1i(G.uniforms.mixEnvMap,p);c.uniform1f(G.uniforms.mReflectivity,i);c.uniform1i(G.uniforms.useRefract,
S);c.uniform1f(G.uniforms.mRefractionRatio,O)}if(h instanceof THREE.MeshNormalMaterial){m=h.opacity;c.uniform1f(G.uniforms.mOpacity,m);c.uniform1i(G.uniforms.material,4)}else if(h instanceof THREE.MeshDepthMaterial){m=h.opacity;D=h.wireframe;A=h.wireframe_linewidth;c.uniform1f(G.uniforms.mOpacity,m);c.uniform1f(G.uniforms.m2Near,h.__2near);c.uniform1f(G.uniforms.mFarPlusNear,h.__farPlusNear);c.uniform1f(G.uniforms.mFarMinusNear,h.__farMinusNear);c.uniform1i(G.uniforms.material,3)}else if(h instanceof
THREE.MeshPhongMaterial){n=h.ambient;i=h.specular;h=h.shininess;c.uniform4f(G.uniforms.mAmbient,n.r,n.g,n.b,m);c.uniform4f(G.uniforms.mSpecular,i.r,i.g,i.b,m);c.uniform1f(G.uniforms.mShininess,h);c.uniform1i(G.uniforms.material,2)}else if(h instanceof THREE.MeshLambertMaterial)c.uniform1i(G.uniforms.material,1);else if(h instanceof THREE.MeshBasicMaterial)c.uniform1i(G.uniforms.material,0);else if(h instanceof THREE.MeshCubeMaterial){c.uniform1i(G.uniforms.material,5);E=h.env_map}if(L){e(L,0);c.uniform1i(G.uniforms.tMap,
0);c.uniform1i(G.uniforms.enableMap,1)}else c.uniform1i(G.uniforms.enableMap,0);if(E){d(E,1);c.uniform1i(G.uniforms.tCube,1);c.uniform1i(G.uniforms.enableCubeMap,1)}else c.uniform1i(G.uniforms.enableCubeMap,0);m=G.attributes;c.bindBuffer(c.ARRAY_BUFFER,w.__webGLVertexBuffer);c.vertexAttribPointer(m.position,3,c.FLOAT,false,0,0);if(m.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLNormalBuffer);c.vertexAttribPointer(m.normal,3,c.FLOAT,false,0,0)}if(m.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLTangentBuffer);
c.vertexAttribPointer(m.tangent,4,c.FLOAT,false,0,0)}if(m.uv>=0)if(w.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,w.__webGLUVBuffer);c.enableVertexAttribArray(m.uv);c.vertexAttribPointer(m.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(m.uv);if(D){c.lineWidth(A);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);c.drawElements(c.LINES,w.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,w.__webGLFaceCount,c.UNSIGNED_SHORT,
0)}};this.renderPass=function(i,p,h,w,n,m){var D,A,L,E,O;L=0;for(E=h.material.length;L<E;L++){D=h.material[L];if(D instanceof THREE.MeshFaceMaterial){D=0;for(A=w.material.length;D<A;D++)if((O=w.material[D])&&O.blending==n&&O.opacity<1==m){this.setBlending(O.blending);this.renderBuffer(i,p,O,w)}}else if((O=D)&&O.blending==n&&O.opacity<1==m){this.setBlending(O.blending);this.renderBuffer(i,p,O,w)}}};this.render=function(i,p){var h,w,n,m,D=i.lights;this.initWebGLObjects(i);this.autoClear&&this.clear();
p.autoUpdateMatrix&&p.updateMatrix();h=0;for(w=i.__webGLObjects.length;h<w;h++){n=i.__webGLObjects[h];m=n.object;n=n.buffer;if(m.visible){this.setupMatrices(m,p);this.renderPass(p,D,m,n,THREE.NormalBlending,false)}}h=0;for(w=i.__webGLObjects.length;h<w;h++){n=i.__webGLObjects[h];m=n.object;n=n.buffer;if(m.visible){this.setupMatrices(m,p);this.renderPass(p,D,m,n,THREE.AdditiveBlending,false);this.renderPass(p,D,m,n,THREE.SubtractiveBlending,false);this.renderPass(p,D,m,n,THREE.AdditiveBlending,true);
this.renderPass(p,D,m,n,THREE.SubtractiveBlending,true);this.renderPass(p,D,m,n,THREE.NormalBlending,true)}}};this.initWebGLObjects=function(i){var p,h,w,n,m,D;if(!i.__webGLObjects){i.__webGLObjects=[];i.__webGLObjectsMap={}}p=0;for(h=i.objects.length;p<h;p++){w=i.objects[p];if(i.__webGLObjectsMap[w.id]==undefined)i.__webGLObjectsMap[w.id]={};D=i.__webGLObjectsMap[w.id];if(w instanceof THREE.Mesh)for(m in w.geometry.geometryChunks){n=w.geometry.geometryChunks[m];n.__webGLVertexBuffer||this.createBuffers(w,
m);if(D[m]==undefined){n={buffer:n,object:w};i.__webGLObjects.push(n);D[m]=1}}}};this.removeObject=function(i,p){var h,w;for(h=i.__webGLObjects.length-1;h>=0;h--){w=i.__webGLObjects[h].object;p==w&&i.__webGLObjects.splice(h,1)}};this.setupMatrices=function(i,p){i.autoUpdateMatrix&&i.updateMatrix();q.multiply(p.matrix,i.matrix);v.set(p.matrix.flatten());z.set(q.flatten());K.set(p.projectionMatrix.flatten());s=THREE.Matrix4.makeInvert3x3(q).transpose();F.set(s.m);y.set(i.matrix.flatten())};this.loadMatrices=
function(i){c.uniformMatrix4fv(i.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(i.uniforms.modelViewMatrix,false,z);c.uniformMatrix4fv(i.uniforms.projectionMatrix,false,K);c.uniformMatrix3fv(i.uniforms.normalMatrix,false,F);c.uniformMatrix4fv(i.uniforms.objectMatrix,false,y)};this.loadCamera=function(i,p){c.uniform3f(i.uniforms.cameraPosition,p.position.x,p.position.y,p.position.z)};this.setBlending=function(i){switch(i){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);
break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(i,p){if(i){!p||p=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(i=="back")c.cullFace(c.BACK);else i=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterial=this.meshMaterial=null;this.overdraw=false;this.uvs=[null,null,null]};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};
@@ -186,8 +186,8 @@ vertex_shader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuni
normal:{uniforms:{tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},uDirLightColor:{type:"c",value:new THREE.Color(15658734)},uAmbientLightColor:{type:"c",value:new THREE.Color(328965)},uDiffuseColor:{type:"c",
value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30}},fragment_shader:"uniform vec3 uDirLightPos;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform sampler2D tNormal;\nuniform sampler2D tAO;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 normalTex = normalize( texture2D( tNormal, vUv ).xyz * 2.0 - 1.0 );\nvec3 aoTex = texture2D( tAO, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec3 pointVector = normalize( vPointLightVector );\nvec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientColor, 1.0 );\ntotalLight += dirDiffuse + dirSpecular;\ntotalLight += pointDiffuse + pointSpecular;\ngl_FragColor = vec4( totalLight.xyz * vLightWeighting * aoTex, 1.0 );\n}",
vertex_shader:"attribute vec4 tangent;\nuniform vec3 uDirLightPos;\nuniform vec3 uDirLightColor;\nuniform vec3 uPointLightPos;\nuniform vec3 uPointLightColor;\nuniform vec3 uAmbientLightColor;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vLightWeighting;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvLightWeighting = uAmbientLightColor;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( vNormal, vPointLightVector ), 0.0 );\nvLightWeighting += uPointLightColor * pointLightWeighting;\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nfloat directionalLightWeighting = max( dot( vNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += uDirLightColor * directionalLightWeighting;\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"}}},
Cube=function(a,b,d,e,f,k,l,g){function j(z,K,F,y,o,i,p,h){var w=e||1,m=f||1,n=w+1,D=m+1;o=o/w;i=i/m;var A=c.vertices.length,L;if(z=="x"&&K=="y"||z=="y"&&K=="x")L="z";else if(z=="x"&&K=="z"||z=="z"&&K=="x")L="y";else if(z=="z"&&K=="y"||z=="y"&&K=="z")L="x";for(iy=0;iy<D;iy++)for(ix=0;ix<n;ix++){var E=new THREE.Vector3;E[z]=(ix*o-t)*F;E[K]=(iy*i-x)*y;E[L]=p;c.vertices.push(new THREE.Vertex(E))}for(iy=0;iy<m;iy++)for(ix=0;ix<w;ix++){c.faces.push(new THREE.Face4(ix+n*iy+A,ix+n*(iy+1)+A,ix+1+n*(iy+1)+
A,ix+1+n*iy+A,null,h));c.uvs.push([new THREE.UV(ix/w,iy/m),new THREE.UV(ix/w,(iy+1)/m),new THREE.UV((ix+1)/w,(iy+1)/m),new THREE.UV((ix+1)/w,iy/m)])}}THREE.Geometry.call(this);var c=this,t=a/2,x=b/2,q=d/2;l=l?-1:1;if(k!==undefined)if(k instanceof Array)this.materials=k;else{this.materials=[];for(var s=0;s<6;s++)this.materials.push([k])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(g!=undefined)for(var v in g)if(this.sides[v]!=undefined)this.sides[v]=g[v];this.sides.px&&
Cube=function(a,b,d,e,f,k,l,g){function j(z,K,F,y,o,i,p,h){var w=e||1,n=f||1,m=w+1,D=n+1;o=o/w;i=i/n;var A=c.vertices.length,L;if(z=="x"&&K=="y"||z=="y"&&K=="x")L="z";else if(z=="x"&&K=="z"||z=="z"&&K=="x")L="y";else if(z=="z"&&K=="y"||z=="y"&&K=="z")L="x";for(iy=0;iy<D;iy++)for(ix=0;ix<m;ix++){var E=new THREE.Vector3;E[z]=(ix*o-t)*F;E[K]=(iy*i-x)*y;E[L]=p;c.vertices.push(new THREE.Vertex(E))}for(iy=0;iy<n;iy++)for(ix=0;ix<w;ix++){c.faces.push(new THREE.Face4(ix+m*iy+A,ix+m*(iy+1)+A,ix+1+m*(iy+1)+
A,ix+1+m*iy+A,null,h));c.uvs.push([new THREE.UV(ix/w,iy/n),new THREE.UV(ix/w,(iy+1)/n),new THREE.UV((ix+1)/w,(iy+1)/n),new THREE.UV((ix+1)/w,iy/n)])}}THREE.Geometry.call(this);var c=this,t=a/2,x=b/2,q=d/2;l=l?-1:1;if(k!==undefined)if(k instanceof Array)this.materials=k;else{this.materials=[];for(var s=0;s<6;s++)this.materials.push([k])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(g!=undefined)for(var v in g)if(this.sides[v]!=undefined)this.sides[v]=g[v];this.sides.px&&
j("z","y",1*l,-1,d,b,-t,this.materials[0]);this.sides.nx&&j("z","y",-1*l,-1,d,b,t,this.materials[1]);this.sides.py&&j("x","z",1*l,1,a,d,x,this.materials[2]);this.sides.ny&&j("x","z",1*l,-1,a,d,-x,this.materials[3]);this.sides.pz&&j("x","y",1*l,-1,a,b,q,this.materials[4]);this.sides.nz&&j("x","y",-1*l,-1,a,b,-q,this.materials[5]);(function(){for(var z=[],K=[],F=0,y=c.vertices.length;F<y;F++){for(var o=c.vertices[F],i=false,p=0,h=z.length;p<h;p++){var w=z[p];if(o.position.x==w.position.x&&o.position.y==
w.position.y&&o.position.z==w.position.z){K[F]=p;i=true;break}}if(!i){K[F]=z.length;z.push(new THREE.Vertex(o.position.clone()))}}F=0;for(y=c.faces.length;F<y;F++){o=c.faces[F];o.a=K[o.a];o.b=K[o.b];o.c=K[o.c];o.d=K[o.d]}c.vertices=z})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
var Cylinder=function(a,b,d,e,f){function k(c,t,x){l.vertices.push(new THREE.Vertex(new THREE.Vector3(c,t,x)))}THREE.Geometry.call(this);var l=this,g=Math.PI,j;for(j=0;j<a;j++)k(Math.sin(2*g*j/a)*b,Math.cos(2*g*j/a)*b,0);for(j=0;j<a;j++)k(Math.sin(2*g*j/a)*d,Math.cos(2*g*j/a)*d,e);for(j=0;j<a;j++)l.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(d!=0){k(0,0,-f);for(j=a;j<a+a/2;j++)l.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b!=0){k(0,0,e+f);for(j=a+a/2;j<
@@ -202,10 +202,10 @@ THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement
b},loadAsciiOld:function(a,b){var d=document.createElement("script");d.type="text/javascript";d.onload=b;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);a.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,b,d)};a.postMessage(e)},loadBinary:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(k){THREE.Loader.prototype.loadAjaxBuffers(k.data.buffers,
k.data.materials,b,d,f)};a.onerror=function(k){alert("worker.onerror: "+k.message+"\n"+k.data);k.preventDefault()};a.postMessage(e)},loadAjaxBuffers:function(a,b,d,e,f){var k=new XMLHttpRequest,l=e+"/"+a,g=0;k.onreadystatechange=function(){if(k.readyState==4)k.status==200||k.status==0?THREE.Loader.prototype.createBinModel(k.responseText,d,e,b):alert("Couldn't load ["+l+"] ["+k.status+"]");else if(k.readyState==3){if(f){if(g==0)g=k.getResponseHeader("Content-Length");f({total:g,loaded:k.responseText.length})}}else if(k.readyState==
2)g=k.getResponseHeader("Content-Length")};k.open("GET",l,true);k.overrideMimeType("text/plain; charset=x-user-defined");k.setRequestHeader("Content-Type","text/plain");k.send(null)},createBinModel:function(a,b,d,e){var f=function(k){function l(r,u){var B=t(r,u),M=t(r,u+1),X=t(r,u+2),Y=t(r,u+3),ea=(Y<<1&255|X>>7)-127;B=(X&127)<<16|M<<8|B;if(B==0&&ea==-127)return 0;return(1-2*(Y>>7))*(1+B*Math.pow(2,-23))*Math.pow(2,ea)}function g(r,u){var B=t(r,u),M=t(r,u+1),X=t(r,u+2);return(t(r,u+3)<<24)+(X<<16)+
(M<<8)+B}function j(r,u){var B=t(r,u);return(t(r,u+1)<<8)+B}function c(r,u){var B=t(r,u);return B>127?B-256:B}function t(r,u){return r.charCodeAt(u)&255}function x(r){var u,B,M;u=g(a,r);B=g(a,r+h);M=g(a,r+w);r=j(a,r+m);THREE.Loader.prototype.f3(F,u,B,M,r)}function q(r){var u,B,M,X,Y,ea;u=g(a,r);B=g(a,r+h);M=g(a,r+w);X=j(a,r+m);Y=g(a,r+n);ea=g(a,r+D);r=g(a,r+A);THREE.Loader.prototype.f3n(F,i,u,B,M,X,Y,ea,r)}function s(r){var u,B,M,X;u=g(a,r);B=g(a,r+L);M=g(a,r+E);X=g(a,r+O);r=j(a,r+S);THREE.Loader.prototype.f4(F,
(M<<8)+B}function j(r,u){var B=t(r,u);return(t(r,u+1)<<8)+B}function c(r,u){var B=t(r,u);return B>127?B-256:B}function t(r,u){return r.charCodeAt(u)&255}function x(r){var u,B,M;u=g(a,r);B=g(a,r+h);M=g(a,r+w);r=j(a,r+n);THREE.Loader.prototype.f3(F,u,B,M,r)}function q(r){var u,B,M,X,Y,ea;u=g(a,r);B=g(a,r+h);M=g(a,r+w);X=j(a,r+n);Y=g(a,r+m);ea=g(a,r+D);r=g(a,r+A);THREE.Loader.prototype.f3n(F,i,u,B,M,X,Y,ea,r)}function s(r){var u,B,M,X;u=g(a,r);B=g(a,r+L);M=g(a,r+E);X=g(a,r+O);r=j(a,r+S);THREE.Loader.prototype.f4(F,
u,B,M,X,r)}function v(r){var u,B,M,X,Y,ea,ma,oa;u=g(a,r);B=g(a,r+L);M=g(a,r+E);X=g(a,r+O);Y=j(a,r+S);ea=g(a,r+G);ma=g(a,r+T);oa=g(a,r+N);r=g(a,r+U);THREE.Loader.prototype.f4n(F,i,u,B,M,X,Y,ea,ma,oa,r)}function z(r){var u,B;u=g(a,r);B=g(a,r+V);r=g(a,r+Q);THREE.Loader.prototype.uv3(F,p[u*2],p[u*2+1],p[B*2],p[B*2+1],p[r*2],p[r*2+1])}function K(r){var u,B,M;u=g(a,r);B=g(a,r+H);M=g(a,r+J);r=g(a,r+$);THREE.Loader.prototype.uv4(F,p[u*2],p[u*2+1],p[B*2],p[B*2+1],p[M*2],p[M*2+1],p[r*2],p[r*2+1])}var F=this,
y=0,o,i=[],p=[],h,w,m,n,D,A,L,E,O,S,G,T,N,U,V,Q,H,J,$;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(F,e,k);o={signature:a.substr(y,8),header_bytes:t(a,y+8),vertex_coordinate_bytes:t(a,y+9),normal_coordinate_bytes:t(a,y+10),uv_coordinate_bytes:t(a,y+11),vertex_index_bytes:t(a,y+12),normal_index_bytes:t(a,y+13),uv_index_bytes:t(a,y+14),material_index_bytes:t(a,y+15),nvertices:g(a,y+16),nnormals:g(a,y+16+4),nuvs:g(a,y+16+8),ntri_flat:g(a,y+16+12),ntri_smooth:g(a,y+16+16),ntri_flat_uv:g(a,
y+16+20),ntri_smooth_uv:g(a,y+16+24),nquad_flat:g(a,y+16+28),nquad_smooth:g(a,y+16+32),nquad_flat_uv:g(a,y+16+36),nquad_smooth_uv:g(a,y+16+40)};y+=o.header_bytes;h=o.vertex_index_bytes;w=o.vertex_index_bytes*2;m=o.vertex_index_bytes*3;n=o.vertex_index_bytes*3+o.material_index_bytes;D=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;A=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;L=o.vertex_index_bytes;E=o.vertex_index_bytes*2;O=o.vertex_index_bytes*3;S=o.vertex_index_bytes*
y=0,o,i=[],p=[],h,w,n,m,D,A,L,E,O,S,G,T,N,U,V,Q,H,J,$;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(F,e,k);o={signature:a.substr(y,8),header_bytes:t(a,y+8),vertex_coordinate_bytes:t(a,y+9),normal_coordinate_bytes:t(a,y+10),uv_coordinate_bytes:t(a,y+11),vertex_index_bytes:t(a,y+12),normal_index_bytes:t(a,y+13),uv_index_bytes:t(a,y+14),material_index_bytes:t(a,y+15),nvertices:g(a,y+16),nnormals:g(a,y+16+4),nuvs:g(a,y+16+8),ntri_flat:g(a,y+16+12),ntri_smooth:g(a,y+16+16),ntri_flat_uv:g(a,
y+16+20),ntri_smooth_uv:g(a,y+16+24),nquad_flat:g(a,y+16+28),nquad_smooth:g(a,y+16+32),nquad_flat_uv:g(a,y+16+36),nquad_smooth_uv:g(a,y+16+40)};y+=o.header_bytes;h=o.vertex_index_bytes;w=o.vertex_index_bytes*2;n=o.vertex_index_bytes*3;m=o.vertex_index_bytes*3+o.material_index_bytes;D=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;A=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;L=o.vertex_index_bytes;E=o.vertex_index_bytes*2;O=o.vertex_index_bytes*3;S=o.vertex_index_bytes*
4;G=o.vertex_index_bytes*4+o.material_index_bytes;T=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes;N=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;U=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;V=o.uv_index_bytes;Q=o.uv_index_bytes*2;H=o.uv_index_bytes;J=o.uv_index_bytes*2;$=o.uv_index_bytes*3;y+=function(r){var u,B,M,X=o.vertex_coordinate_bytes*3,Y=r+o.nvertices*X;for(r=r;r<Y;r+=X){u=l(a,r);B=l(a,r+o.vertex_coordinate_bytes);M=l(a,
r+o.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(F,u,B,M)}return o.nvertices*X}(y);y+=function(r){var u,B,M,X=o.normal_coordinate_bytes*3,Y=r+o.nnormals*X;for(r=r;r<Y;r+=X){u=c(a,r);B=c(a,r+o.normal_coordinate_bytes);M=c(a,r+o.normal_coordinate_bytes*2);i.push(u/127,B/127,M/127)}return o.nnormals*X}(y);y+=function(r){var u,B,M=o.uv_coordinate_bytes*2,X=r+o.nuvs*M;for(r=r;r<X;r+=M){u=l(a,r);B=l(a,r+o.uv_coordinate_bytes);p.push(u,B)}return o.nuvs*M}(y);y+=function(r){var u,B=o.vertex_index_bytes*
3+o.material_index_bytes,M=r+o.ntri_flat*B;for(u=r;u<M;u+=B)x(u);return M-r}(y);y+=function(r){var u,B=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,M=r+o.ntri_smooth*B;for(u=r;u<M;u+=B)q(u);return M-r}(y);y+=function(r){var u,B=o.vertex_index_bytes*3+o.material_index_bytes,M=B+o.uv_index_bytes*3,X=r+o.ntri_flat_uv*M;for(u=r;u<X;u+=M){x(u);z(u+B)}return X-r}(y);y+=function(r){var u,B=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,M=B+o.uv_index_bytes*3,
+6 -2
View File
@@ -539,8 +539,12 @@ THREE.WebGLRenderer = function ( scene ) {
// normals
_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer );
_gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 );
if ( attributes.normal >= 0 ) {
_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer );
_gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 );
}
// tangents