diff --git a/build/Three.js b/build/Three.js index c5021ef9..839c1fc6 100755 --- a/build/Three.js +++ b/build/Three.js @@ -5,59 +5,62 @@ THREE.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,d){this.x=a||0;this.y=b||0;this.z=d||0}; THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, -cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,d=this.y,g=this.z;this.x=d*a.z-g*a.y;this.y=g*a.x-b*a.z;this.z=b*a.y-d*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/= +cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-b*a.z;this.z=b*a.y-d*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/= a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a= Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}}; -THREE.Vector4=function(a,b,d,g){this.x=a||0;this.y=b||0;this.z=d||0;this.w=g||1}; -THREE.Vector4.prototype={set:function(a,b,d,g){this.x=a;this.y=b;this.z=d;this.w=g;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; +THREE.Vector4=function(a,b,d,f){this.x=a||0;this.y=b||0;this.z=d||0;this.w=f||1}; +THREE.Vector4.prototype={set:function(a,b,d,f){this.x=a;this.y=b;this.z=d;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,d,g=a.objects,j=[];a=0;for(b=g.length;a0&&L>0&&k+L<1}var d,g,j,n,m,l,o,c,F,D, -w,x=a.geometry,I=x.vertices,G=[];d=0;for(g=x.faces.length;d= -0&&Math.min(j,o.getBottom())-Math.max(d,o.getTop())>=0};this.empty=function(){l=true;j=g=d=b=0;a()};this.isEmpty=function(){return l};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+g+", top: "+d+", bottom: "+j+", width: "+n+", height: "+m+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Ray.prototype={intersectScene:function(a){var b,d,f=a.objects,j=[];a=0;for(b=f.length;a0&&J>0&&k+J<1}var d,f,j,m,n,l,o,c,E,C, +x,z=a.geometry,H=z.vertices,G=[];d=0;for(f=z.faces.length;d= +0&&Math.min(j,o.getBottom())-Math.max(d,o.getTop())>=0};this.empty=function(){l=true;j=f=d=b=0;a()};this.isEmpty=function(){return l};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+f+", top: "+d+", bottom: "+j+", width: "+m+", height: "+n+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; THREE.Matrix4=function(){}; THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=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},lookAt:function(a,b,d){var g=new THREE.Vector3,j=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();g.cross(d,n).normalize();j.cross(n,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=n.x;this.n32=n.y;this.n33=n.z;this.n34=-n.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,g=a.z,j=1/(this.n41*b+this.n42* -d+this.n43*g+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*g+this.n14)*j;a.y=(this.n21*b+this.n22*d+this.n23*g+this.n24)*j;a.z=(this.n31*b+this.n32*d+this.n33*g+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,d=a.y,g=a.z,j=a.w;a.x=this.n11*b+this.n12*d+this.n13*g+this.n14*j;a.y=this.n21*b+this.n22*d+this.n23*g+this.n24*j;a.z=this.n31*b+this.n32*d+this.n33*g+this.n34*j;a.w=this.n41*b+this.n42*d+this.n43*g+this.n44*j;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,g=a.n12,j=a.n13,n=a.n14,m=a.n21,l=a.n22,o=a.n23,c=a.n24,F=a.n31,D=a.n32,w=a.n33,x=a.n34,I=a.n41,G=a.n42,L=a.n43,N=a.n44,O=b.n11,v=b.n12,f=b.n13,k=b.n14,e=b.n21,p=b.n22,h=b.n23,i=b.n24,s=b.n31,r=b.n32,M=b.n33,A=b.n34,H=b.n41,Q=b.n42,u=b.n43, -R=b.n44;this.n11=d*O+g*e+j*s+n*H;this.n12=d*v+g*p+j*r+n*Q;this.n13=d*f+g*h+j*M+n*u;this.n14=d*k+g*i+j*A+n*R;this.n21=m*O+l*e+o*s+c*H;this.n22=m*v+l*p+o*r+c*Q;this.n23=m*f+l*h+o*M+c*u;this.n24=m*k+l*i+o*A+c*R;this.n31=F*O+D*e+w*s+x*H;this.n32=F*v+D*p+w*r+x*Q;this.n33=F*f+D*h+w*M+x*u;this.n34=F*k+D*i+w*A+x*R;this.n41=I*O+G*e+L*s+N*H;this.n42=I*v+G*p+L*r+N*Q;this.n43=I*f+G*h+L*M+N*u;this.n44=I*k+G*i+L*A+N*R},multiplySelf:function(a){var b=this.n11,d=this.n12,g=this.n13,j=this.n14,n=this.n21,m=this.n22, -l=this.n23,o=this.n24,c=this.n31,F=this.n32,D=this.n33,w=this.n34,x=this.n41,I=this.n42,G=this.n43,L=this.n44;this.n11=b*a.n11+d*a.n21+g*a.n31+j*a.n41;this.n12=b*a.n12+d*a.n22+g*a.n32+j*a.n42;this.n13=b*a.n13+d*a.n23+g*a.n33+j*a.n43;this.n14=b*a.n14+d*a.n24+g*a.n34+j*a.n44;this.n21=n*a.n11+m*a.n21+l*a.n31+o*a.n41;this.n22=n*a.n12+m*a.n22+l*a.n32+o*a.n42;this.n23=n*a.n13+m*a.n23+l*a.n33+o*a.n43;this.n24=n*a.n14+m*a.n24+l*a.n34+o*a.n44;this.n31=c*a.n11+F*a.n21+D*a.n31+w*a.n41;this.n32=c*a.n12+F*a.n22+ -D*a.n32+w*a.n42;this.n33=c*a.n13+F*a.n23+D*a.n33+w*a.n43;this.n34=c*a.n14+F*a.n24+D*a.n34+w*a.n44;this.n41=x*a.n11+I*a.n21+G*a.n31+L*a.n41;this.n42=x*a.n12+I*a.n22+G*a.n32+L*a.n42;this.n43=x*a.n13+I*a.n23+G*a.n33+L*a.n43;this.n44=x*a.n14+I*a.n24+G*a.n34+L*a.n44},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},determinant:function(){return this.n14* +a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(a,b,d){var f=new THREE.Vector3,j=new THREE.Vector3,m=new THREE.Vector3;m.sub(a,b).normalize();f.cross(d,m).normalize();j.cross(m,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=m.x;this.n32=m.y;this.n33=m.z;this.n34=-m.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,f=a.z,j=1/(this.n41*b+this.n42* +d+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*f+this.n14)*j;a.y=(this.n21*b+this.n22*d+this.n23*f+this.n24)*j;a.z=(this.n31*b+this.n32*d+this.n33*f+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,d=a.y,f=a.z,j=a.w;a.x=this.n11*b+this.n12*d+this.n13*f+this.n14*j;a.y=this.n21*b+this.n22*d+this.n23*f+this.n24*j;a.z=this.n31*b+this.n32*d+this.n33*f+this.n34*j;a.w=this.n41*b+this.n42*d+this.n43*f+this.n44*j;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,f=a.n12,j=a.n13,m=a.n14,n=a.n21,l=a.n22,o=a.n23,c=a.n24,E=a.n31,C=a.n32,x=a.n33,z=a.n34,H=a.n41,G=a.n42,J=a.n43,L=a.n44,M=b.n11,u=b.n12,e=b.n13,k=b.n14,g=b.n21,q=b.n22,h=b.n23,i=b.n24,r=b.n31,p=b.n32,D=b.n33,w=b.n34,I=b.n41,S=b.n42,t=b.n43, +O=b.n44;this.n11=d*M+f*g+j*r+m*I;this.n12=d*u+f*q+j*p+m*S;this.n13=d*e+f*h+j*D+m*t;this.n14=d*k+f*i+j*w+m*O;this.n21=n*M+l*g+o*r+c*I;this.n22=n*u+l*q+o*p+c*S;this.n23=n*e+l*h+o*D+c*t;this.n24=n*k+l*i+o*w+c*O;this.n31=E*M+C*g+x*r+z*I;this.n32=E*u+C*q+x*p+z*S;this.n33=E*e+C*h+x*D+z*t;this.n34=E*k+C*i+x*w+z*O;this.n41=H*M+G*g+J*r+L*I;this.n42=H*u+G*q+J*p+L*S;this.n43=H*e+G*h+J*D+L*t;this.n44=H*k+G*i+J*w+L*O},multiplySelf:function(a){var b=this.n11,d=this.n12,f=this.n13,j=this.n14,m=this.n21,n=this.n22, +l=this.n23,o=this.n24,c=this.n31,E=this.n32,C=this.n33,x=this.n34,z=this.n41,H=this.n42,G=this.n43,J=this.n44;this.n11=b*a.n11+d*a.n21+f*a.n31+j*a.n41;this.n12=b*a.n12+d*a.n22+f*a.n32+j*a.n42;this.n13=b*a.n13+d*a.n23+f*a.n33+j*a.n43;this.n14=b*a.n14+d*a.n24+f*a.n34+j*a.n44;this.n21=m*a.n11+n*a.n21+l*a.n31+o*a.n41;this.n22=m*a.n12+n*a.n22+l*a.n32+o*a.n42;this.n23=m*a.n13+n*a.n23+l*a.n33+o*a.n43;this.n24=m*a.n14+n*a.n24+l*a.n34+o*a.n44;this.n31=c*a.n11+E*a.n21+C*a.n31+x*a.n41;this.n32=c*a.n12+E*a.n22+ +C*a.n32+x*a.n42;this.n33=c*a.n13+E*a.n23+C*a.n33+x*a.n43;this.n34=c*a.n14+E*a.n24+C*a.n34+x*a.n44;this.n41=z*a.n11+H*a.n21+G*a.n31+J*a.n41;this.n42=z*a.n12+H*a.n22+G*a.n32+J*a.n42;this.n43=z*a.n13+H*a.n23+G*a.n33+J*a.n43;this.n44=z*a.n14+H*a.n24+G*a.n34+J*a.n44},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},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,g){var j=b[d];b[d]=b[g];b[g]=j}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this, +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,f){var j=b[d];b[d]=b[f];b[f]=j}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,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]}, -toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,d){var g=new THREE.Matrix4;g.n14=a;g.n24=b;g.n34=d;return g};THREE.Matrix4.scaleMatrix=function(a,b,d){var g=new THREE.Matrix4;g.n11=a;g.n22=b;g.n33=d;return g}; +toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,d){var f=new THREE.Matrix4;f.n14=a;f.n24=b;f.n34=d;return f};THREE.Matrix4.scaleMatrix=function(a,b,d){var f=new THREE.Matrix4;f.n11=a;f.n22=b;f.n33=d;return f}; THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,g=Math.cos(b),j=Math.sin(b),n=1-g,m=a.x,l=a.y,o=a.z;d.n11=n*m*m+g;d.n12=n*m*l-j*o;d.n13=n*m*o+j*l;d.n21=n*m*l+j*o;d.n22=n*l*l+g;d.n23=n*l*o-j*m;d.n31=n*m*o-j*l;d.n32=n*l*o+j*m;d.n33=n*o*o+g;return d}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,f=Math.cos(b),j=Math.sin(b),m=1-f,n=a.x,l=a.y,o=a.z;d.n11=m*n*n+f;d.n12=m*n*l-j*o;d.n13=m*n*o+j*l;d.n21=m*n*l+j*o;d.n22=m*l*l+f;d.n23=m*l*o-j*n;d.n31=m*n*o-j*l;d.n32=m*l*o+j*n;d.n33=m*o*o+f;return d}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],g=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],n=-b[10]*b[4]+b[6]*b[8],m=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],F=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*n+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*g;a.m[2]=b*j;a.m[3]=b*n;a.m[4]=b*m;a.m[5]=b*l;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*F;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,g,j,n){var m,l,o;m=new THREE.Matrix4;l=2*j/(b-a);o=2*j/(g-d);a=(b+a)/(b-a);d=(g+d)/(g-d);g=-(n+j)/(n-j);j=-2*n*j/(n-j);m.n11=l;m.n12=0;m.n13=a;m.n14=0;m.n21=0;m.n22=o;m.n23=d;m.n24=0;m.n31=0;m.n32=0;m.n33=g;m.n34=j;m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,g){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,d,g)}; -THREE.Matrix4.makeOrtho=function(a,b,d,g,j,n){var m,l,o,c;m=new THREE.Matrix4;l=b-a;o=d-g;c=n-j;a=(b+a)/l;d=(d+g)/o;j=(n+j)/c;m.n11=2/l;m.n12=0;m.n13=0;m.n14=-a;m.n21=0;m.n22=2/o;m.n23=0;m.n24=-d;m.n31=0;m.n32=0;m.n33=-2/c;m.n34=-j;m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m}; -THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; -THREE.Face3=function(a,b,d,g,j){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.material=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,d,g,j,n){this.a=a;this.b=b;this.c=d;this.d=g;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=n instanceof Array?n:[n]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; -THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={}}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],f=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],m=-b[10]*b[4]+b[6]*b[8],n=b[10]*b[0]-b[2]*b[8],l=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],E=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*m+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*f;a.m[2]=b*j;a.m[3]=b*m;a.m[4]=b*n;a.m[5]=b*l;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*E;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,f,j,m){var n,l,o;n=new THREE.Matrix4;l=2*j/(b-a);o=2*j/(f-d);a=(b+a)/(b-a);d=(f+d)/(f-d);f=-(m+j)/(m-j);j=-2*m*j/(m-j);n.n11=l;n.n12=0;n.n13=a;n.n14=0;n.n21=0;n.n22=o;n.n23=d;n.n24=0;n.n31=0;n.n32=0;n.n33=f;n.n34=j;n.n41=0;n.n42=0;n.n43=-1;n.n44=0;return n};THREE.Matrix4.makePerspective=function(a,b,d,f){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,d,f)}; +THREE.Matrix4.makeOrtho=function(a,b,d,f,j,m){var n,l,o,c;n=new THREE.Matrix4;l=b-a;o=d-f;c=m-j;a=(b+a)/l;d=(d+f)/o;j=(m+j)/c;n.n11=2/l;n.n12=0;n.n13=0;n.n14=-a;n.n21=0;n.n22=2/o;n.n23=0;n.n24=-d;n.n31=0;n.n32=0;n.n33=-2/c;n.n34=-j;n.n41=0;n.n42=0;n.n43=0;n.n44=1;return n}; +THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; +THREE.Face3=function(a,b,d,f,j){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.material=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,b,d,f,j,m){this.a=a;this.b=b;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=m instanceof Array?m:[m]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a0){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;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y; -if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(F){var D=[];b=0;for(d=F.length;b65535){c[l].counter+=1;o=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:m,vertices:0}}this.geometryChunks[o].faces.push(g);this.geometryChunks[o].vertices+=n}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,d,g){this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,g);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)}; +d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeNormals:function(a){var b,d,f,j,m,n,l=new THREE.Vector3,o=new THREE.Vector3;f=0;for(j=this.vertices.length;f0){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;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(E){var C=[];b=0;for(d=E.length;b65535){c[l].counter+=1;o=c[l].hash+"_"+c[l].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:n,vertices:0}}this.geometryChunks[o].faces.push(f);this.geometryChunks[o].vertices+=m}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +THREE.Camera=function(a,b,d,f){this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,f);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)}; THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z); this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0}; THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; THREE.Mesh=function(a,b,d){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh; -THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,g,j;a=0;for(b=this.geometry.uvs.length;acolor: "+ this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map= @@ -82,91 +85,93 @@ undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shadi THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+ this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}}; -THREE.Texture=function(a,b,d,g,j,n){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=g!==undefined?g:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=n!==undefined?n:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+ +THREE.Texture=function(a,b,d,f,j,m){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=m!==undefined?m:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+ this.min_filter+"
)"}};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(O,v){var f=0,k=1,e=O.z+O.w,p=v.z+v.w,h=-O.z+O.w,i=-v.z+v.w;if(e>=0&&p>=0&&h>=0&&i>=0)return true;else if(e<0&&p<0||h<0&&i<0)return false;else{if(e<0)f=Math.max(f,e/(e-p));else if(p<0)k=Math.min(k,e/(e-p));if(h<0)f=Math.max(f,h/(h-i));else if(i<0)k=Math.min(k,h/(h-i));if(k0&&y.z<1}R=r.geometry.faces;e=0;for(p=R.length;e0&&w.z<1){c=D[F]=D[F]||new THREE.RenderableParticle;c.x=w.x/w.w;c.y=w.y/w.w;c.z=w.z;c.rotation=r.rotation.z;c.scale.x=r.scale.x*Math.abs(c.x-(w.x+v.projectionMatrix.n11)/(w.w+v.projectionMatrix.n14));c.scale.y=r.scale.y*Math.abs(c.y-(w.y+v.projectionMatrix.n22)/(w.w+v.projectionMatrix.n24));c.material=r.material;b.push(c);F++}}}b.sort(function(W,J){return J.z-W.z});return b};this.unprojectVector=function(O,v){var f=new THREE.Matrix4; -f.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));f.multiplyVector3(O);return O}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,g,j,n;this.domElement=document.createElement("div");this.setSize=function(m,l){d=m;g=l;j=d/2;n=g/2};this.render=function(m,l){var o,c,F,D,w,x,I,G;a=b.projectScene(m,l);o=0;for(c=a.length;o0){t.r+=aa.r*V;t.g+=aa.g*V;t.b+=aa.b*V}}else if(V instanceof THREE.PointLight){Y.sub(V.position,T);Y.normalize();V=K.dot(Y)*ca;if(V>0){t.r+=aa.r*V;t.g+=aa.g*V;t.b+=aa.b*V}}}}function Na(q,T,K){if(K.opacity!=0){Da(K.opacity);ya(K.blending);var t,C,V,aa,ca,da;if(K instanceof THREE.ParticleBasicMaterial){if(K.map){aa=K.map;ca=aa.width>>1;da=aa.height>>1;C=T.scale.x*n;V=T.scale.y*m;K=C*ca;t=V*da;X.set(q.x-K, -q.y-t,q.x+K,q.y+t);if(B.instersects(X)){l.save();l.translate(q.x,q.y);l.rotate(-T.rotation);l.scale(C,-V);l.translate(-ca,-da);l.drawImage(aa,0,0);l.restore()}}}else if(K instanceof THREE.ParticleCircleMaterial){if(S){P.r=Z.r+ia.r+ja.r;P.g=Z.g+ia.g+ja.g;P.b=Z.b+ia.b+ja.b;h.r=K.color.r*P.r;h.g=K.color.g*P.g;h.b=K.color.b*P.b;h.updateStyleString()}else h.__styleString=K.color.__styleString;K=T.scale.x*n;t=T.scale.y*m;X.set(q.x-K,q.y-t,q.x+K,q.y+t);if(B.instersects(X)){C=h.__styleString;if(D!=C)l.fillStyle= -D=C;l.save();l.translate(q.x,q.y);l.rotate(-T.rotation);l.scale(K,t);l.beginPath();l.arc(0,0,1,0,La,true);l.closePath();l.fill();l.restore()}}}}function Oa(q,T,K,t){if(t.opacity!=0){Da(t.opacity);ya(t.blending);l.beginPath();l.moveTo(q.positionScreen.x,q.positionScreen.y);l.lineTo(T.positionScreen.x,T.positionScreen.y);l.closePath();if(t instanceof THREE.LineBasicMaterial){h.__styleString=t.color.__styleString;q=t.linewidth;if(w!=q)l.lineWidth=w=q;q=h.__styleString;if(F!=q)l.strokeStyle=F=q;l.stroke(); -X.inflate(t.linewidth*2)}}}function Ha(q,T,K,t,C,V){if(C.opacity!=0){Da(C.opacity);ya(C.blending);O=q.positionScreen.x;v=q.positionScreen.y;f=T.positionScreen.x;k=T.positionScreen.y;e=K.positionScreen.x;p=K.positionScreen.y;l.beginPath();l.moveTo(O,v);l.lineTo(f,k);l.lineTo(e,p);l.lineTo(O,v);l.closePath();if(C instanceof THREE.MeshBasicMaterial)if(C.map)C.map.image.loaded&&C.map.mapping instanceof THREE.UVMapping&&qa(O,v,f,k,e,p,C.map.image,t.uvs[0].u,t.uvs[0].v,t.uvs[1].u,t.uvs[1].v,t.uvs[2].u, -t.uvs[2].v);else if(C.env_map){if(C.env_map.image.loaded)if(C.env_map.mapping instanceof THREE.SphericalReflectionMapping){q=wa.matrix;Y.copy(t.vertexNormalsWorld[0]);R=(Y.x*q.n11+Y.y*q.n12+Y.z*q.n13)*0.5+0.5;y=-(Y.x*q.n21+Y.y*q.n22+Y.z*q.n23)*0.5+0.5;Y.copy(t.vertexNormalsWorld[1]);z=(Y.x*q.n11+Y.y*q.n12+Y.z*q.n13)*0.5+0.5;E=-(Y.x*q.n21+Y.y*q.n22+Y.z*q.n23)*0.5+0.5;Y.copy(t.vertexNormalsWorld[2]);W=(Y.x*q.n11+Y.y*q.n12+Y.z*q.n13)*0.5+0.5;J=-(Y.x*q.n21+Y.y*q.n22+Y.z*q.n23)*0.5+0.5;qa(O,v,f,k,e,p, -C.env_map.image,R,y,z,E,W,J)}}else C.wireframe?za(C.color.__styleString,C.wireframe_linewidth):Aa(C.color.__styleString);else if(C instanceof THREE.MeshLambertMaterial){if(C.map&&!C.wireframe){C.map.mapping instanceof THREE.UVMapping&&qa(O,v,f,k,e,p,C.map.image,t.uvs[0].u,t.uvs[0].v,t.uvs[1].u,t.uvs[1].v,t.uvs[2].u,t.uvs[2].v);ya(THREE.SubtractiveBlending)}if(S)if(!C.wireframe&&C.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==3){i.r=s.r=r.r=Z.r;i.g=s.g=r.g=Z.g;i.b=s.b=r.b=Z.b;xa(V,t.v1.positionWorld, -t.vertexNormalsWorld[0],i);xa(V,t.v2.positionWorld,t.vertexNormalsWorld[1],s);xa(V,t.v3.positionWorld,t.vertexNormalsWorld[2],r);M.r=(s.r+r.r)*0.5;M.g=(s.g+r.g)*0.5;M.b=(s.b+r.b)*0.5;u=Ia(i,s,r,M);qa(O,v,f,k,e,p,u,0,0,1,0,0,1)}else{P.r=Z.r;P.g=Z.g;P.b=Z.b;xa(V,t.centroidWorld,t.normalWorld,P);h.r=C.color.r*P.r;h.g=C.color.g*P.g;h.b=C.color.b*P.b;h.updateStyleString();C.wireframe?za(h.__styleString,C.wireframe_linewidth):Aa(h.__styleString)}else C.wireframe?za(C.color.__styleString,C.wireframe_linewidth): -Aa(C.color.__styleString)}else if(C instanceof THREE.MeshDepthMaterial){A=C.__2near;H=C.__farPlusNear;Q=C.__farMinusNear;i.r=i.g=i.b=1-A/(H-q.positionScreen.z*Q);s.r=s.g=s.b=1-A/(H-T.positionScreen.z*Q);r.r=r.g=r.b=1-A/(H-K.positionScreen.z*Q);M.r=(s.r+r.r)*0.5;M.g=(s.g+r.g)*0.5;M.b=(s.b+r.b)*0.5;u=Ia(i,s,r,M);qa(O,v,f,k,e,p,u,0,0,1,0,0,1)}else if(C instanceof THREE.MeshNormalMaterial){h.r=Ea(t.normalWorld.x);h.g=Ea(t.normalWorld.y);h.b=Ea(t.normalWorld.z);h.updateStyleString();C.wireframe?za(h.__styleString, -C.wireframe_linewidth):Aa(h.__styleString)}}}function za(q,T){if(F!=q)l.strokeStyle=F=q;if(w!=T)l.lineWidth=w=T;l.stroke();X.inflate(T*2)}function Aa(q){if(D!=q)l.fillStyle=D=q;l.fill()}function qa(q,T,K,t,C,V,aa,ca,da,ra,ha,sa,ta){var ka,ga;ka=aa.width-1;ga=aa.height-1;ca*=ka;da*=ga;ra*=ka;ha*=ga;sa*=ka;ta*=ga;K-=q;t-=T;C-=q;V-=T;ra-=ca;ha-=da;sa-=ca;ta-=da;ga=1/(ra*ta-sa*ha);ka=(ta*K-ha*C)*ga;ha=(ta*t-ha*V)*ga;K=(ra*C-sa*K)*ga;t=(ra*V-sa*t)*ga;q=q-ka*ca-K*da;T=T-ha*ca-t*da;l.save();l.transform(ka, -ha,K,t,q,T);l.clip();l.drawImage(aa,0,0);l.restore()}function Da(q){if(o!=q)l.globalAlpha=o=q}function ya(q){if(c!=q){switch(q){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}c=q}}function Ia(q,T,K,t){ba[0]=I(0,x(255,~~(q.r*255)));ba[1]=I(0,x(255,~~(q.g*255)));ba[2]=I(0,x(255,~~(q.b*255)));ba[4]=I(0,x(255,~~(T.r*255)));ba[5]=I(0,x(255, -~~(T.g*255)));ba[6]=I(0,x(255,~~(T.b*255)));ba[8]=I(0,x(255,~~(K.r*255)));ba[9]=I(0,x(255,~~(K.g*255)));ba[10]=I(0,x(255,~~(K.b*255)));ba[12]=I(0,x(255,~~(t.r*255)));ba[13]=I(0,x(255,~~(t.g*255)));ba[14]=I(0,x(255,~~(t.b*255)));oa.putImageData(Ca,0,0);va.drawImage(na,0,0);return pa}function Ea(q){return q<0?x((1+q)*0.5,0.5):0.5+x(q*0.5,0.5)}function Fa(q,T){var K=T.x-q.x,t=T.y-q.y,C=1/Math.sqrt(K*K+t*t);K*=C;t*=C;T.x+=K;T.y+=t;q.x-=K;q.y-=t}var Ba,Ja,$,ea,ma,Ga,Ka,ua;l.setTransform(1,0,0,-1,n,m); -this.autoClear&&this.clear();a=b.projectScene(fa,wa);(S=fa.lights.length>0)&&Ma(fa);Ba=0;for(Ja=a.length;Ba0){E.r+=B.color.r*U;E.g+=B.color.g*U;E.b+=B.color.b*U}}else if(B instanceof THREE.PointLight){i.sub(B.position,z.centroidWorld);i.normalize();U=z.normalWorld.dot(i)*B.intensity;if(U>0){E.r+=B.color.r*U;E.g+=B.color.g*U;E.b+=B.color.b*U}}}}function b(y,z,E,W,J,B){A=g(H++);A.setAttribute("d","M "+y.positionScreen.x+ -" "+y.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)v.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(O){f.r=k.r;f.g=k.g;f.b=k.b;a(B,W,f);v.r=J.color.r*f.r;v.g=J.color.g*f.g;v.b=J.color.b*f.b;v.updateStyleString()}else v.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){h=1-J.__2near/(J.__farPlusNear-W.z*J.__farMinusNear); -v.setRGB(h,h,h)}else J instanceof THREE.MeshNormalMaterial&&v.setRGB(j(W.normalWorld.x),j(W.normalWorld.y),j(W.normalWorld.z));J.wireframe?A.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):A.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+J.opacity);l.appendChild(A)}function d(y,z,E,W,J,B,U){A=g(H++);A.setAttribute("d", -"M "+y.positionScreen.x+" "+y.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)v.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(O){f.r=k.r;f.g=k.g;f.b=k.b;a(U,J,f);v.r=B.color.r*f.r;v.g=B.color.g*f.g;v.b=B.color.b*f.b;v.updateStyleString()}else v.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){h= -1-B.__2near/(B.__farPlusNear-J.z*B.__farMinusNear);v.setRGB(h,h,h)}else B instanceof THREE.MeshNormalMaterial&&v.setRGB(j(J.normalWorld.x),j(J.normalWorld.y),j(J.normalWorld.z));B.wireframe?A.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+B.wireframe_linewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframe_linecap+"; stroke-linejoin: "+B.wireframe_linejoin):A.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+B.opacity);l.appendChild(A)} -function g(y){if(s[y]==null){s[y]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&s[y].setAttribute("shape-rendering","crispEdges");return s[y]}return s[y]}function j(y){return y<0?Math.min((1+y)*0.5,0.5):0.5+Math.min(y*0.5,0.5)}var n=null,m=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,F,D,w,x,I,G,L=new THREE.Rectangle,N=new THREE.Rectangle,O=false,v=new THREE.Color(16777215),f=new THREE.Color(16777215),k=new THREE.Color(0),e=new THREE.Color(0), -p=new THREE.Color(0),h,i=new THREE.Vector3,s=[],r=[],M=[],A,H,Q,u,R=1;this.domElement=l;this.autoClear=true;this.setQuality=function(y){switch(y){case "high":R=1;break;case "low":R=0}};this.setSize=function(y,z){o=y;c=z;F=o/2;D=c/2;l.setAttribute("viewBox",-F+" "+-D+" "+o+" "+c);l.setAttribute("width",o);l.setAttribute("height",c);L.set(-F,-D,F,D)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(y,z){var E,W,J,B,U,X,S,P;this.autoClear&&this.clear(); -n=m.projectScene(y,z);u=Q=H=0;if(O=y.lights.length>0){S=y.lights;k.setRGB(0,0,0);e.setRGB(0,0,0);p.setRGB(0,0,0);E=0;for(W=S.length;E=0&&c.enableVertexAttribArray(f.attributes[h])}}function m(f,k){var e;if(f=="fragment")e=c.createShader(c.FRAGMENT_SHADER);else if(f=="vertex")e=c.createShader(c.VERTEX_SHADER);c.shaderSource(e,k);c.compileShader(e);if(!c.getShaderParameter(e, -c.COMPILE_STATUS)){alert(c.getShaderInfoLog(e));return null}return e}function l(f){switch(f){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 o=document.createElement("canvas"),c,F,D,w=new THREE.Matrix4,x,I=new Float32Array(16),G=new Float32Array(16),L=new Float32Array(16),N=new Float32Array(9),O=new Float32Array(16);a=function(f,k){if(f){var e,p,h,i=pointLights=maxDirLights=maxPointLights=0;e=0;for(p=f.lights.length;e=0&&q>=0&&h>=0&&i>=0)return true;else if(g<0&&q<0||h<0&&i<0)return false;else{if(g<0)e=Math.max(e,g/(g-q));else if(q<0)k=Math.min(k,g/(g-q));if(h<0)e=Math.max(e,h/(h-i));else if(i<0)k=Math.min(k,h/(h-i));if(k0&&B.z<1}O=p.geometry.faces;g=0;for(q=O.length;g0&&x.z<1){c=C[E]=C[E]||new THREE.RenderableParticle;c.x=x.x/x.w;c.y=x.y/x.w;c.z=x.z;c.rotation=p.rotation.z;c.scale.x=p.scale.x*Math.abs(c.x-(x.x+u.projectionMatrix.n11)/(x.w+u.projectionMatrix.n14));c.scale.y=p.scale.y*Math.abs(c.y-(x.y+u.projectionMatrix.n22)/(x.w+u.projectionMatrix.n24));c.material=p.material;b.push(c);E++}}}b.sort(function(K,y){return y.z-K.z});return b};this.unprojectVector=function(M,u){var e=new THREE.Matrix4; +e.multiply(THREE.Matrix4.makeInvert(u.matrix),THREE.Matrix4.makeInvert(u.projectionMatrix));e.multiplyVector3(M);return M}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,f,j,m;this.domElement=document.createElement("div");this.setSize=function(n,l){d=n;f=l;j=d/2;m=f/2};this.render=function(n,l){var o,c,E,C,x,z,H,G;a=b.projectScene(n,l);o=0;for(c=a.length;o0){v.r+=aa.r*W;v.g+=aa.g*W;v.b+=aa.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,U);Y.normalize();W=N.dot(Y)*ca;if(W>0){v.r+=aa.r*W;v.g+=aa.g*W;v.b+=aa.b*W}}}}function Na(s,U,N){if(N.opacity!=0){Da(N.opacity);ya(N.blending);var v,F,W,aa,ca,da;if(N instanceof THREE.ParticleBasicMaterial){if(N.map){aa=N.map;ca=aa.width>>1;da=aa.height>>1;F=U.scale.x*m;W=U.scale.y*n;N=F*ca;v=W*da;X.set(s.x-N, +s.y-v,s.x+N,s.y+v);if(A.instersects(X)){l.save();l.translate(s.x,s.y);l.rotate(-U.rotation);l.scale(F,-W);l.translate(-ca,-da);l.drawImage(aa,0,0);l.restore()}}}else if(N instanceof THREE.ParticleCircleMaterial){if(T){R.r=Z.r+ia.r+ja.r;R.g=Z.g+ia.g+ja.g;R.b=Z.b+ia.b+ja.b;h.r=N.color.r*R.r;h.g=N.color.g*R.g;h.b=N.color.b*R.b;h.updateStyleString()}else h.__styleString=N.color.__styleString;N=U.scale.x*m;v=U.scale.y*n;X.set(s.x-N,s.y-v,s.x+N,s.y+v);if(A.instersects(X)){F=h.__styleString;if(C!=F)l.fillStyle= +C=F;l.save();l.translate(s.x,s.y);l.rotate(-U.rotation);l.scale(N,v);l.beginPath();l.arc(0,0,1,0,La,true);l.closePath();l.fill();l.restore()}}}}function Oa(s,U,N,v){if(v.opacity!=0){Da(v.opacity);ya(v.blending);l.beginPath();l.moveTo(s.positionScreen.x,s.positionScreen.y);l.lineTo(U.positionScreen.x,U.positionScreen.y);l.closePath();if(v instanceof THREE.LineBasicMaterial){h.__styleString=v.color.__styleString;s=v.linewidth;if(x!=s)l.lineWidth=x=s;s=h.__styleString;if(E!=s)l.strokeStyle=E=s;l.stroke(); +X.inflate(v.linewidth*2)}}}function Ha(s,U,N,v,F,W){if(F.opacity!=0){Da(F.opacity);ya(F.blending);M=s.positionScreen.x;u=s.positionScreen.y;e=U.positionScreen.x;k=U.positionScreen.y;g=N.positionScreen.x;q=N.positionScreen.y;l.beginPath();l.moveTo(M,u);l.lineTo(e,k);l.lineTo(g,q);l.lineTo(M,u);l.closePath();if(F instanceof THREE.MeshBasicMaterial)if(F.map)F.map.image.loaded&&F.map.mapping instanceof THREE.UVMapping&&qa(M,u,e,k,g,q,F.map.image,v.uvs[0].u,v.uvs[0].v,v.uvs[1].u,v.uvs[1].v,v.uvs[2].u, +v.uvs[2].v);else if(F.env_map){if(F.env_map.image.loaded)if(F.env_map.mapping instanceof THREE.SphericalReflectionMapping){s=wa.matrix;Y.copy(v.vertexNormalsWorld[0]);O=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;B=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;Y.copy(v.vertexNormalsWorld[1]);P=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;Q=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;Y.copy(v.vertexNormalsWorld[2]);K=(Y.x*s.n11+Y.y*s.n12+Y.z*s.n13)*0.5+0.5;y=-(Y.x*s.n21+Y.y*s.n22+Y.z*s.n23)*0.5+0.5;qa(M,u,e,k,g,q, +F.env_map.image,O,B,P,Q,K,y)}}else F.wireframe?za(F.color.__styleString,F.wireframe_linewidth):Aa(F.color.__styleString);else if(F instanceof THREE.MeshLambertMaterial){if(F.map&&!F.wireframe){F.map.mapping instanceof THREE.UVMapping&&qa(M,u,e,k,g,q,F.map.image,v.uvs[0].u,v.uvs[0].v,v.uvs[1].u,v.uvs[1].v,v.uvs[2].u,v.uvs[2].v);ya(THREE.SubtractiveBlending)}if(T)if(!F.wireframe&&F.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length==3){i.r=r.r=p.r=Z.r;i.g=r.g=p.g=Z.g;i.b=r.b=p.b=Z.b;xa(W,v.v1.positionWorld, +v.vertexNormalsWorld[0],i);xa(W,v.v2.positionWorld,v.vertexNormalsWorld[1],r);xa(W,v.v3.positionWorld,v.vertexNormalsWorld[2],p);D.r=(r.r+p.r)*0.5;D.g=(r.g+p.g)*0.5;D.b=(r.b+p.b)*0.5;t=Ia(i,r,p,D);qa(M,u,e,k,g,q,t,0,0,1,0,0,1)}else{R.r=Z.r;R.g=Z.g;R.b=Z.b;xa(W,v.centroidWorld,v.normalWorld,R);h.r=F.color.r*R.r;h.g=F.color.g*R.g;h.b=F.color.b*R.b;h.updateStyleString();F.wireframe?za(h.__styleString,F.wireframe_linewidth):Aa(h.__styleString)}else F.wireframe?za(F.color.__styleString,F.wireframe_linewidth): +Aa(F.color.__styleString)}else if(F instanceof THREE.MeshDepthMaterial){w=F.__2near;I=F.__farPlusNear;S=F.__farMinusNear;i.r=i.g=i.b=1-w/(I-s.positionScreen.z*S);r.r=r.g=r.b=1-w/(I-U.positionScreen.z*S);p.r=p.g=p.b=1-w/(I-N.positionScreen.z*S);D.r=(r.r+p.r)*0.5;D.g=(r.g+p.g)*0.5;D.b=(r.b+p.b)*0.5;t=Ia(i,r,p,D);qa(M,u,e,k,g,q,t,0,0,1,0,0,1)}else if(F instanceof THREE.MeshNormalMaterial){h.r=Ea(v.normalWorld.x);h.g=Ea(v.normalWorld.y);h.b=Ea(v.normalWorld.z);h.updateStyleString();F.wireframe?za(h.__styleString, +F.wireframe_linewidth):Aa(h.__styleString)}}}function za(s,U){if(E!=s)l.strokeStyle=E=s;if(x!=U)l.lineWidth=x=U;l.stroke();X.inflate(U*2)}function Aa(s){if(C!=s)l.fillStyle=C=s;l.fill()}function qa(s,U,N,v,F,W,aa,ca,da,ra,ha,sa,ta){var ka,ga;ka=aa.width-1;ga=aa.height-1;ca*=ka;da*=ga;ra*=ka;ha*=ga;sa*=ka;ta*=ga;N-=s;v-=U;F-=s;W-=U;ra-=ca;ha-=da;sa-=ca;ta-=da;ga=1/(ra*ta-sa*ha);ka=(ta*N-ha*F)*ga;ha=(ta*v-ha*W)*ga;N=(ra*F-sa*N)*ga;v=(ra*W-sa*v)*ga;s=s-ka*ca-N*da;U=U-ha*ca-v*da;l.save();l.transform(ka, +ha,N,v,s,U);l.clip();l.drawImage(aa,0,0);l.restore()}function Da(s){if(o!=s)l.globalAlpha=o=s}function ya(s){if(c!=s){switch(s){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}c=s}}function Ia(s,U,N,v){ba[0]=H(0,z(255,~~(s.r*255)));ba[1]=H(0,z(255,~~(s.g*255)));ba[2]=H(0,z(255,~~(s.b*255)));ba[4]=H(0,z(255,~~(U.r*255)));ba[5]=H(0,z(255, +~~(U.g*255)));ba[6]=H(0,z(255,~~(U.b*255)));ba[8]=H(0,z(255,~~(N.r*255)));ba[9]=H(0,z(255,~~(N.g*255)));ba[10]=H(0,z(255,~~(N.b*255)));ba[12]=H(0,z(255,~~(v.r*255)));ba[13]=H(0,z(255,~~(v.g*255)));ba[14]=H(0,z(255,~~(v.b*255)));oa.putImageData(Ca,0,0);va.drawImage(na,0,0);return pa}function Ea(s){return s<0?z((1+s)*0.5,0.5):0.5+z(s*0.5,0.5)}function Fa(s,U){var N=U.x-s.x,v=U.y-s.y,F=1/Math.sqrt(N*N+v*v);N*=F;v*=F;U.x+=N;U.y+=v;s.x-=N;s.y-=v}var Ba,Ja,$,ea,ma,Ga,Ka,ua;l.setTransform(1,0,0,-1,m,n); +this.autoClear&&this.clear();a=b.projectScene(fa,wa);(T=fa.lights.length>0)&&Ma(fa);Ba=0;for(Ja=a.length;Ba0){Q.r+=A.color.r*V;Q.g+=A.color.g*V;Q.b+=A.color.b*V}}else if(A instanceof THREE.PointLight){i.sub(A.position,P.centroidWorld);i.normalize();V=P.normalWorld.dot(i)*A.intensity;if(V>0){Q.r+=A.color.r*V;Q.g+=A.color.g*V;Q.b+=A.color.b*V}}}}function b(B,P,Q,K,y,A){w=f(I++);w.setAttribute("d","M "+B.positionScreen.x+ +" "+B.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)u.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(M){e.r=k.r;e.g=k.g;e.b=k.b;a(A,K,e);u.r=y.color.r*e.r;u.g=y.color.g*e.g;u.b=y.color.b*e.b;u.updateStyleString()}else u.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){h=1-y.__2near/(y.__farPlusNear-K.z*y.__farMinusNear); +u.setRGB(h,h,h)}else y instanceof THREE.MeshNormalMaterial&&u.setRGB(j(K.normalWorld.x),j(K.normalWorld.y),j(K.normalWorld.z));y.wireframe?w.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):w.setAttribute("style","fill: "+u.__styleString+"; fill-opacity: "+y.opacity);l.appendChild(w)}function d(B,P,Q,K,y,A,V){w=f(I++);w.setAttribute("d", +"M "+B.positionScreen.x+" "+B.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(A instanceof THREE.MeshBasicMaterial)u.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshLambertMaterial)if(M){e.r=k.r;e.g=k.g;e.b=k.b;a(V,y,e);u.r=A.color.r*e.r;u.g=A.color.g*e.g;u.b=A.color.b*e.b;u.updateStyleString()}else u.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshDepthMaterial){h= +1-A.__2near/(A.__farPlusNear-y.z*A.__farMinusNear);u.setRGB(h,h,h)}else A instanceof THREE.MeshNormalMaterial&&u.setRGB(j(y.normalWorld.x),j(y.normalWorld.y),j(y.normalWorld.z));A.wireframe?w.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+A.wireframe_linewidth+"; stroke-opacity: "+A.opacity+"; stroke-linecap: "+A.wireframe_linecap+"; stroke-linejoin: "+A.wireframe_linejoin):w.setAttribute("style","fill: "+u.__styleString+"; fill-opacity: "+A.opacity);l.appendChild(w)} +function f(B){if(r[B]==null){r[B]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&r[B].setAttribute("shape-rendering","crispEdges");return r[B]}return r[B]}function j(B){return B<0?Math.min((1+B)*0.5,0.5):0.5+Math.min(B*0.5,0.5)}var m=null,n=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,E,C,x,z,H,G,J=new THREE.Rectangle,L=new THREE.Rectangle,M=false,u=new THREE.Color(16777215),e=new THREE.Color(16777215),k=new THREE.Color(0),g=new THREE.Color(0), +q=new THREE.Color(0),h,i=new THREE.Vector3,r=[],p=[],D=[],w,I,S,t,O=1;this.domElement=l;this.autoClear=true;this.setQuality=function(B){switch(B){case "high":O=1;break;case "low":O=0}};this.setSize=function(B,P){o=B;c=P;E=o/2;C=c/2;l.setAttribute("viewBox",-E+" "+-C+" "+o+" "+c);l.setAttribute("width",o);l.setAttribute("height",c);J.set(-E,-C,E,C)};this.clear=function(){for(;l.childNodes.length>0;)l.removeChild(l.childNodes[0])};this.render=function(B,P){var Q,K,y,A,V,X,T,R;this.autoClear&&this.clear(); +m=n.projectScene(B,P);t=S=I=0;if(M=B.lights.length>0){T=B.lights;k.setRGB(0,0,0);g.setRGB(0,0,0);q.setRGB(0,0,0);Q=0;for(K=T.length;Q0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(g,n("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ +e));c.attachShader(g,n("vertex",q+k));c.linkProgram(g);c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(g,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");g.uniforms={};g.attributes={};return g}function d(e,k){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.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 g=0;g<6;++g)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[g]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+k);c.bindTexture(c.TEXTURE_CUBE_MAP, +e.image.__webGLTextureCube)}}function f(e,k){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,l(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,l(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,l(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,l(e.min_filter));c.generateMipmap(c.TEXTURE_2D); +c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+k);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function j(e,k){var g,q,h;g=0;for(q=k.length;g=0&&c.enableVertexAttribArray(e.attributes[h])}}function n(e,k){var g;if(e=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")g=c.createShader(c.VERTEX_SHADER); +c.shaderSource(g,k);c.compileShader(g);if(!c.getShaderParameter(g,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(g));return null}return g}function l(e){switch(e){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 o=document.createElement("canvas"),c,E,C,x=new THREE.Matrix4,z,H=new Float32Array(16),G=new Float32Array(16),J=new Float32Array(16),L=new Float32Array(9),M=new Float32Array(16);a=function(e,k){if(e){var g,q,h,i=pointLights=maxDirLights=maxPointLights=0;g=0;for(q=e.lights.length;g= 0.0 )": -"",k?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",k?"pointDiffuse += mColor * pointDiffuseWeight;":"",k?"pointSpecular += mSpecular * pointSpecularWeight;":"",k?"}":"",f?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",f?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",f?"vec3 dirVector = normalize( lDirection.xyz );":"",f?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": -"",f?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",f?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",f?"float dirSpecularWeight = 0.0;":"",f?"if ( dirDotNormalHalf >= 0.0 )":"",f?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",f?"dirDiffuse += mColor * dirDiffuseWeight;":"",f?"dirSpecular += mSpecular * dirSpecularWeight;":"",f?"}":"","vec4 totalLight = mAmbient;",f?"totalLight += dirDiffuse + dirSpecular;":"",k?"totalLight += pointDiffuse + pointSpecular;": +"",k?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",k?"pointDiffuse += mColor * pointDiffuseWeight;":"",k?"pointSpecular += mSpecular * pointSpecularWeight;":"",k?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": +"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",k?"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"); -e=b(p,e);c.useProgram(e);j(e,["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"]);f&&j(e,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);k&&j(e,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(e.uniforms.enableMap,0);c.uniform1i(e.uniforms.tMap,0);c.uniform1i(e.uniforms.enableCubeMap,0);c.uniform1i(e.uniforms.tCube,1);c.uniform1i(e.uniforms.mixEnvMap,0);c.uniform1i(e.uniforms.useRefract,0);n(e,["position","normal","uv"]);return e}(a.directional,a.point);this.setSize=function(f,k){o.width=f;o.height=k;c.viewport(0,0,o.width,o.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,k){var e,p,h,i,s,r=[], -M=[],A=[];i=[];s=[];c.uniform1i(f.uniforms.enableLighting,k.length);e=0;for(p=k.length;e0){E.__webGLUVBuffer=c.createBuffer(); -c.bindBuffer(c.ARRAY_BUFFER,E.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(y),c.STATIC_DRAW)}E.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(H),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);E.__webGLFaceCount=H.length;E.__webGLLineCount=Q.length}};this.renderBuffer= -function(f,k,e,p){var h,i,s,r,M,A,H,Q,u;if(e instanceof THREE.MeshShaderMaterial){if(!e.program){e.program=b(e.fragment_shader,e.vertex_shader);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(u in e.uniforms)H.push(u);j(e.program,H);n(e.program,["position","normal","uv"])}u=e.program}else u=D;if(u!=F){c.useProgram(u);F=u}u==D&&this.setupLights(u,k);this.loadCamera(u,f);this.loadMatrices(u);if(e instanceof THREE.MeshShaderMaterial){s=e.wireframe; -r=e.wireframe_linewidth;f=u;k=e.uniforms;var R;for(h in k){Q=k[h].type;H=k[h].value;R=f.uniforms[h];if(Q=="i")c.uniform1i(R,H);else if(Q=="f")c.uniform1f(R,H);else if(Q=="v3")c.uniform3f(R,H.x,H.y,H.z);else if(Q=="c")c.uniform3f(R,H.r,H.g,H.b);else if(Q=="t"){c.uniform1i(R,H);if(Q=k[h].texture)Q.image instanceof Array&&Q.image.length==6?d(Q,H):g(Q,H)}}}if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){h=e.color;i=e.opacity;s=e.wireframe; -r=e.wireframe_linewidth;M=e.map;A=e.env_map;k=e.combine==THREE.MixOperation;f=e.reflectivity;Q=e.env_map&&e.env_map.mapping instanceof THREE.CubeRefractionMapping;H=e.refraction_ratio;c.uniform4f(u.uniforms.mColor,h.r*i,h.g*i,h.b*i,i);c.uniform1i(u.uniforms.mixEnvMap,k);c.uniform1f(u.uniforms.mReflectivity,f);c.uniform1i(u.uniforms.useRefract,Q);c.uniform1f(u.uniforms.mRefractionRatio,H)}if(e instanceof THREE.MeshNormalMaterial){i=e.opacity;c.uniform1f(u.uniforms.mOpacity,i);c.uniform1i(u.uniforms.material, -4)}else if(e instanceof THREE.MeshDepthMaterial){i=e.opacity;s=e.wireframe;r=e.wireframe_linewidth;c.uniform1f(u.uniforms.mOpacity,i);c.uniform1f(u.uniforms.m2Near,e.__2near);c.uniform1f(u.uniforms.mFarPlusNear,e.__farPlusNear);c.uniform1f(u.uniforms.mFarMinusNear,e.__farMinusNear);c.uniform1i(u.uniforms.material,3)}else if(e instanceof THREE.MeshPhongMaterial){h=e.ambient;f=e.specular;e=e.shininess;c.uniform4f(u.uniforms.mAmbient,h.r,h.g,h.b,i);c.uniform4f(u.uniforms.mSpecular,f.r,f.g,f.b,i);c.uniform1f(u.uniforms.mShininess, -e);c.uniform1i(u.uniforms.material,2)}else if(e instanceof THREE.MeshLambertMaterial)c.uniform1i(u.uniforms.material,1);else if(e instanceof THREE.MeshBasicMaterial)c.uniform1i(u.uniforms.material,0);else if(e instanceof THREE.MeshCubeMaterial){c.uniform1i(u.uniforms.material,5);A=e.env_map}if(M){g(M,0);c.uniform1i(u.uniforms.tMap,0);c.uniform1i(u.uniforms.enableMap,1)}else c.uniform1i(u.uniforms.enableMap,0);if(A){d(A,1);c.uniform1i(u.uniforms.tCube,1);c.uniform1i(u.uniforms.enableCubeMap,1)}else c.uniform1i(u.uniforms.enableCubeMap, -0);i=u.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.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(s){c.lineWidth(r);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(f,k,e,p,h,i){var s,r,M,A,H;M=0;for(A=e.material.length;M=0;e--){p=f.__webGLObjects[e].object;k==p&&f.__webGLObjects.splice(e,1)}};this.setupMatrices=function(f,k){f.autoUpdateMatrix&&f.updateMatrix();w.multiply(k.matrix,f.matrix);I.set(k.matrix.flatten()); -G.set(w.flatten());L.set(k.projectionMatrix.flatten());x=THREE.Matrix4.makeInvert3x3(w).transpose();N.set(x.m);O.set(f.matrix.flatten())};this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,I);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,G);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,L);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,N);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,O)};this.loadCamera=function(f,k){c.uniform3f(f.uniforms.cameraPosition, -k.position.x,k.position.y,k.position.z)};this.setBlending=function(f){switch(f){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(f,k){if(f){!k||k=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK); -c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}};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};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null}; +g=b(q,g);c.useProgram(g);j(g,["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"]);e&&j(g,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);k&&j(g,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(g.uniforms.enableMap,0);c.uniform1i(g.uniforms.tMap,0);c.uniform1i(g.uniforms.enableCubeMap,0);c.uniform1i(g.uniforms.tCube,1);c.uniform1i(g.uniforms.mixEnvMap,0);c.uniform1i(g.uniforms.useRefract,0);m(g,["position","normal","uv"]);return g}(a.directional,a.point);this.setSize=function(e,k){o.width=e;o.height=k;c.viewport(0,0,o.width,o.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,k){var g,q,h,i,r,p=[], +D=[],w=[];i=[];r=[];c.uniform1i(e.uniforms.enableLighting,k.length);g=0;for(q=k.length;g0){y.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,y.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(Q),c.STATIC_DRAW)}y.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(S),c.STATIC_DRAW);y.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +y.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(t),c.STATIC_DRAW);y.__webGLFaceCount=S.length;y.__webGLLineCount=t.length}};this.renderBuffer=function(e,k,g,q){var h,i,r,p,D,w,I,S,t;if(g instanceof THREE.MeshShaderMaterial){if(!g.program){g.program=b(g.fragment_shader,g.vertex_shader);I=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in g.uniforms)I.push(t);j(g.program,I);m(g.program,["position","normal","uv","tangent"])}t= +g.program}else t=C;if(t!=E){c.useProgram(t);E=t}t==C&&this.setupLights(t,k);this.loadCamera(t,e);this.loadMatrices(t);if(g instanceof THREE.MeshShaderMaterial){r=g.wireframe;p=g.wireframe_linewidth;e=t;k=g.uniforms;var O;for(h in k){S=k[h].type;I=k[h].value;O=e.uniforms[h];if(S=="i")c.uniform1i(O,I);else if(S=="f")c.uniform1f(O,I);else if(S=="v3")c.uniform3f(O,I.x,I.y,I.z);else if(S=="c")c.uniform3f(O,I.r,I.g,I.b);else if(S=="t"){c.uniform1i(O,I);if(S=k[h].texture)S.image instanceof Array&&S.image.length== +6?d(S,I):f(S,I)}}}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshBasicMaterial){h=g.color;i=g.opacity;r=g.wireframe;p=g.wireframe_linewidth;D=g.map;w=g.env_map;k=g.combine==THREE.MixOperation;e=g.reflectivity;S=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;I=g.refraction_ratio;c.uniform4f(t.uniforms.mColor,h.r*i,h.g*i,h.b*i,i);c.uniform1i(t.uniforms.mixEnvMap,k);c.uniform1f(t.uniforms.mReflectivity,e);c.uniform1i(t.uniforms.useRefract, +S);c.uniform1f(t.uniforms.mRefractionRatio,I)}if(g instanceof THREE.MeshNormalMaterial){i=g.opacity;c.uniform1f(t.uniforms.mOpacity,i);c.uniform1i(t.uniforms.material,4)}else if(g instanceof THREE.MeshDepthMaterial){i=g.opacity;r=g.wireframe;p=g.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,i);c.uniform1f(t.uniforms.m2Near,g.__2near);c.uniform1f(t.uniforms.mFarPlusNear,g.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,g.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(g instanceof +THREE.MeshPhongMaterial){h=g.ambient;e=g.specular;g=g.shininess;c.uniform4f(t.uniforms.mAmbient,h.r,h.g,h.b,i);c.uniform4f(t.uniforms.mSpecular,e.r,e.g,e.b,i);c.uniform1f(t.uniforms.mShininess,g);c.uniform1i(t.uniforms.material,2)}else if(g instanceof THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else if(g instanceof THREE.MeshBasicMaterial)c.uniform1i(t.uniforms.material,0);else if(g instanceof THREE.MeshCubeMaterial){c.uniform1i(t.uniforms.material,5);w=g.env_map}if(D){f(D,0);c.uniform1i(t.uniforms.tMap, +0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(w){d(w,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);i=t.attributes;c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0);if(i.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLTangentBuffer); +c.vertexAttribPointer(i.tangent,4,c.FLOAT,false,0,0)}if(i.uv>=0)if(q.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(r){c.lineWidth(p);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.drawElements(c.LINES,q.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,q.__webGLFaceCount,c.UNSIGNED_SHORT, +0)}};this.renderPass=function(e,k,g,q,h,i){var r,p,D,w,I;D=0;for(w=g.material.length;D=0;g--){q=e.__webGLObjects[g].object;k==q&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,k){e.autoUpdateMatrix&&e.updateMatrix();x.multiply(k.matrix,e.matrix);H.set(k.matrix.flatten());G.set(x.flatten());J.set(k.projectionMatrix.flatten());z=THREE.Matrix4.makeInvert3x3(x).transpose();L.set(z.m);M.set(e.matrix.flatten())};this.loadMatrices= +function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,H);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,G);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,J);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,L);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,M)};this.loadCamera=function(e,k){c.uniform3f(e.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=function(e){switch(e){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(e,k){if(e){!k||k=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);else e=="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}; +THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null}; diff --git a/build/ThreeDebug.js b/build/ThreeDebug.js index ab26a16b..ee845525 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -5,59 +5,62 @@ THREE.Color.prototype={setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,d){this.x=a||0;this.y=b||0;this.z=d||0}; THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, -cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,d=this.y,g=this.z;this.x=d*a.z-g*a.y;this.y=g*a.x-b*a.z;this.z=b*a.y-d*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/= +cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-b*a.z;this.z=b*a.y-d*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/= a;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+d*d+a*a)},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},normalize:function(){var a= Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z);a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},toString:function(){return"THREE.Vector3 ( "+this.x+", "+this.y+", "+this.z+" )"}}; -THREE.Vector4=function(a,b,d,g){this.x=a||0;this.y=b||0;this.z=d||0;this.w=g||1}; -THREE.Vector4.prototype={set:function(a,b,d,g){this.x=a;this.y=b;this.z=d;this.w=g;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; +THREE.Vector4=function(a,b,d,f){this.x=a||0;this.y=b||0;this.z=d||0;this.w=f||1}; +THREE.Vector4.prototype={set:function(a,b,d,f){this.x=a;this.y=b;this.z=d;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,d,g=a.objects,j=[];a=0;for(b=g.length;a0&&L>0&&l+L<1}var d,g,j,n,m,k,o,c,F,D, -w,x=a.geometry,I=x.vertices,G=[];d=0;for(g=x.faces.length;d= -0&&Math.min(j,o.getBottom())-Math.max(d,o.getTop())>=0};this.empty=function(){k=true;j=g=d=b=0;a()};this.isEmpty=function(){return k};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+g+", top: "+d+", bottom: "+j+", width: "+n+", height: "+m+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Ray.prototype={intersectScene:function(a){var b,d,f=a.objects,j=[];a=0;for(b=f.length;a0&&J>0&&l+J<1}var d,f,j,m,n,k,o,c,E,C, +x,z=a.geometry,H=z.vertices,G=[];d=0;for(f=z.faces.length;d= +0&&Math.min(j,o.getBottom())-Math.max(d,o.getTop())>=0};this.empty=function(){k=true;j=f=d=b=0;a()};this.isEmpty=function(){return k};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+f+", top: "+d+", bottom: "+j+", width: "+m+", height: "+n+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; THREE.Matrix4=function(){}; THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=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},lookAt:function(a,b,d){var g=new THREE.Vector3,j=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();g.cross(d,n).normalize();j.cross(n,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=n.x;this.n32=n.y;this.n33=n.z;this.n34=-n.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,g=a.z,j=1/(this.n41*b+this.n42* -d+this.n43*g+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*g+this.n14)*j;a.y=(this.n21*b+this.n22*d+this.n23*g+this.n24)*j;a.z=(this.n31*b+this.n32*d+this.n33*g+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,d=a.y,g=a.z,j=a.w;a.x=this.n11*b+this.n12*d+this.n13*g+this.n14*j;a.y=this.n21*b+this.n22*d+this.n23*g+this.n24*j;a.z=this.n31*b+this.n32*d+this.n33*g+this.n34*j;a.w=this.n41*b+this.n42*d+this.n43*g+this.n44*j;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,g=a.n12,j=a.n13,n=a.n14,m=a.n21,k=a.n22,o=a.n23,c=a.n24,F=a.n31,D=a.n32,w=a.n33,x=a.n34,I=a.n41,G=a.n42,L=a.n43,N=a.n44,O=b.n11,v=b.n12,f=b.n13,l=b.n14,e=b.n21,q=b.n22,h=b.n23,i=b.n24,s=b.n31,r=b.n32,M=b.n33,B=b.n34,H=b.n41,Q=b.n42,u=b.n43, -R=b.n44;this.n11=d*O+g*e+j*s+n*H;this.n12=d*v+g*q+j*r+n*Q;this.n13=d*f+g*h+j*M+n*u;this.n14=d*l+g*i+j*B+n*R;this.n21=m*O+k*e+o*s+c*H;this.n22=m*v+k*q+o*r+c*Q;this.n23=m*f+k*h+o*M+c*u;this.n24=m*l+k*i+o*B+c*R;this.n31=F*O+D*e+w*s+x*H;this.n32=F*v+D*q+w*r+x*Q;this.n33=F*f+D*h+w*M+x*u;this.n34=F*l+D*i+w*B+x*R;this.n41=I*O+G*e+L*s+N*H;this.n42=I*v+G*q+L*r+N*Q;this.n43=I*f+G*h+L*M+N*u;this.n44=I*l+G*i+L*B+N*R},multiplySelf:function(a){var b=this.n11,d=this.n12,g=this.n13,j=this.n14,n=this.n21,m=this.n22, -k=this.n23,o=this.n24,c=this.n31,F=this.n32,D=this.n33,w=this.n34,x=this.n41,I=this.n42,G=this.n43,L=this.n44;this.n11=b*a.n11+d*a.n21+g*a.n31+j*a.n41;this.n12=b*a.n12+d*a.n22+g*a.n32+j*a.n42;this.n13=b*a.n13+d*a.n23+g*a.n33+j*a.n43;this.n14=b*a.n14+d*a.n24+g*a.n34+j*a.n44;this.n21=n*a.n11+m*a.n21+k*a.n31+o*a.n41;this.n22=n*a.n12+m*a.n22+k*a.n32+o*a.n42;this.n23=n*a.n13+m*a.n23+k*a.n33+o*a.n43;this.n24=n*a.n14+m*a.n24+k*a.n34+o*a.n44;this.n31=c*a.n11+F*a.n21+D*a.n31+w*a.n41;this.n32=c*a.n12+F*a.n22+ -D*a.n32+w*a.n42;this.n33=c*a.n13+F*a.n23+D*a.n33+w*a.n43;this.n34=c*a.n14+F*a.n24+D*a.n34+w*a.n44;this.n41=x*a.n11+I*a.n21+G*a.n31+L*a.n41;this.n42=x*a.n12+I*a.n22+G*a.n32+L*a.n42;this.n43=x*a.n13+I*a.n23+G*a.n33+L*a.n43;this.n44=x*a.n14+I*a.n24+G*a.n34+L*a.n44},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},determinant:function(){return this.n14* +a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44},lookAt:function(a,b,d){var f=new THREE.Vector3,j=new THREE.Vector3,m=new THREE.Vector3;m.sub(a,b).normalize();f.cross(d,m).normalize();j.cross(m,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=m.x;this.n32=m.y;this.n33=m.z;this.n34=-m.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,f=a.z,j=1/(this.n41*b+this.n42* +d+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*f+this.n14)*j;a.y=(this.n21*b+this.n22*d+this.n23*f+this.n24)*j;a.z=(this.n31*b+this.n32*d+this.n33*f+this.n34)*j;return a},multiplyVector4:function(a){var b=a.x,d=a.y,f=a.z,j=a.w;a.x=this.n11*b+this.n12*d+this.n13*f+this.n14*j;a.y=this.n21*b+this.n22*d+this.n23*f+this.n24*j;a.z=this.n31*b+this.n32*d+this.n33*f+this.n34*j;a.w=this.n41*b+this.n42*d+this.n43*f+this.n44*j;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,f=a.n12,j=a.n13,m=a.n14,n=a.n21,k=a.n22,o=a.n23,c=a.n24,E=a.n31,C=a.n32,x=a.n33,z=a.n34,H=a.n41,G=a.n42,J=a.n43,L=a.n44,M=b.n11,u=b.n12,e=b.n13,l=b.n14,g=b.n21,q=b.n22,h=b.n23,i=b.n24,s=b.n31,p=b.n32,D=b.n33,w=b.n34,I=b.n41,S=b.n42,t=b.n43, +O=b.n44;this.n11=d*M+f*g+j*s+m*I;this.n12=d*u+f*q+j*p+m*S;this.n13=d*e+f*h+j*D+m*t;this.n14=d*l+f*i+j*w+m*O;this.n21=n*M+k*g+o*s+c*I;this.n22=n*u+k*q+o*p+c*S;this.n23=n*e+k*h+o*D+c*t;this.n24=n*l+k*i+o*w+c*O;this.n31=E*M+C*g+x*s+z*I;this.n32=E*u+C*q+x*p+z*S;this.n33=E*e+C*h+x*D+z*t;this.n34=E*l+C*i+x*w+z*O;this.n41=H*M+G*g+J*s+L*I;this.n42=H*u+G*q+J*p+L*S;this.n43=H*e+G*h+J*D+L*t;this.n44=H*l+G*i+J*w+L*O},multiplySelf:function(a){var b=this.n11,d=this.n12,f=this.n13,j=this.n14,m=this.n21,n=this.n22, +k=this.n23,o=this.n24,c=this.n31,E=this.n32,C=this.n33,x=this.n34,z=this.n41,H=this.n42,G=this.n43,J=this.n44;this.n11=b*a.n11+d*a.n21+f*a.n31+j*a.n41;this.n12=b*a.n12+d*a.n22+f*a.n32+j*a.n42;this.n13=b*a.n13+d*a.n23+f*a.n33+j*a.n43;this.n14=b*a.n14+d*a.n24+f*a.n34+j*a.n44;this.n21=m*a.n11+n*a.n21+k*a.n31+o*a.n41;this.n22=m*a.n12+n*a.n22+k*a.n32+o*a.n42;this.n23=m*a.n13+n*a.n23+k*a.n33+o*a.n43;this.n24=m*a.n14+n*a.n24+k*a.n34+o*a.n44;this.n31=c*a.n11+E*a.n21+C*a.n31+x*a.n41;this.n32=c*a.n12+E*a.n22+ +C*a.n32+x*a.n42;this.n33=c*a.n13+E*a.n23+C*a.n33+x*a.n43;this.n34=c*a.n14+E*a.n24+C*a.n34+x*a.n44;this.n41=z*a.n11+H*a.n21+G*a.n31+J*a.n41;this.n42=z*a.n12+H*a.n22+G*a.n32+J*a.n42;this.n43=z*a.n13+H*a.n23+G*a.n33+J*a.n43;this.n44=z*a.n14+H*a.n24+G*a.n34+J*a.n44},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},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,g){var j=b[d];b[d]=b[g];b[g]=j}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this, +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,f){var j=b[d];b[d]=b[f];b[f]=j}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,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]}, -toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,d){var g=new THREE.Matrix4;g.n14=a;g.n24=b;g.n34=d;return g};THREE.Matrix4.scaleMatrix=function(a,b,d){var g=new THREE.Matrix4;g.n11=a;g.n22=b;g.n33=d;return g}; +toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,d){var f=new THREE.Matrix4;f.n14=a;f.n24=b;f.n34=d;return f};THREE.Matrix4.scaleMatrix=function(a,b,d){var f=new THREE.Matrix4;f.n11=a;f.n22=b;f.n33=d;return f}; THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,g=Math.cos(b),j=Math.sin(b),n=1-g,m=a.x,k=a.y,o=a.z;d.n11=n*m*m+g;d.n12=n*m*k-j*o;d.n13=n*m*o+j*k;d.n21=n*m*k+j*o;d.n22=n*k*k+g;d.n23=n*k*o-j*m;d.n31=n*m*o-j*k;d.n32=n*k*o+j*m;d.n33=n*o*o+g;return d}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,f=Math.cos(b),j=Math.sin(b),m=1-f,n=a.x,k=a.y,o=a.z;d.n11=m*n*n+f;d.n12=m*n*k-j*o;d.n13=m*n*o+j*k;d.n21=m*n*k+j*o;d.n22=m*k*k+f;d.n23=m*k*o-j*n;d.n31=m*n*o-j*k;d.n32=m*k*o+j*n;d.n33=m*o*o+f;return d}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],g=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],n=-b[10]*b[4]+b[6]*b[8],m=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],F=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*n+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*g;a.m[2]=b*j;a.m[3]=b*n;a.m[4]=b*m;a.m[5]=b*k;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*F;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,g,j,n){var m,k,o;m=new THREE.Matrix4;k=2*j/(b-a);o=2*j/(g-d);a=(b+a)/(b-a);d=(g+d)/(g-d);g=-(n+j)/(n-j);j=-2*n*j/(n-j);m.n11=k;m.n12=0;m.n13=a;m.n14=0;m.n21=0;m.n22=o;m.n23=d;m.n24=0;m.n31=0;m.n32=0;m.n33=g;m.n34=j;m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,g){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,d,g)}; -THREE.Matrix4.makeOrtho=function(a,b,d,g,j,n){var m,k,o,c;m=new THREE.Matrix4;k=b-a;o=d-g;c=n-j;a=(b+a)/k;d=(d+g)/o;j=(n+j)/c;m.n11=2/k;m.n12=0;m.n13=0;m.n14=-a;m.n21=0;m.n22=2/o;m.n23=0;m.n24=-d;m.n31=0;m.n32=0;m.n33=-2/c;m.n34=-j;m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m}; -THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; -THREE.Face3=function(a,b,d,g,j){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.material=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,d,g,j,n){this.a=a;this.b=b;this.c=d;this.d=g;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=n instanceof Array?n:[n]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; -THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={}}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],f=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],m=-b[10]*b[4]+b[6]*b[8],n=b[10]*b[0]-b[2]*b[8],k=-b[6]*b[0]+b[2]*b[4],o=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],E=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*m+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*f;a.m[2]=b*j;a.m[3]=b*m;a.m[4]=b*n;a.m[5]=b*k;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*E;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,f,j,m){var n,k,o;n=new THREE.Matrix4;k=2*j/(b-a);o=2*j/(f-d);a=(b+a)/(b-a);d=(f+d)/(f-d);f=-(m+j)/(m-j);j=-2*m*j/(m-j);n.n11=k;n.n12=0;n.n13=a;n.n14=0;n.n21=0;n.n22=o;n.n23=d;n.n24=0;n.n31=0;n.n32=0;n.n33=f;n.n34=j;n.n41=0;n.n42=0;n.n43=-1;n.n44=0;return n};THREE.Matrix4.makePerspective=function(a,b,d,f){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,d,f)}; +THREE.Matrix4.makeOrtho=function(a,b,d,f,j,m){var n,k,o,c;n=new THREE.Matrix4;k=b-a;o=d-f;c=m-j;a=(b+a)/k;d=(d+f)/o;j=(m+j)/c;n.n11=2/k;n.n12=0;n.n13=0;n.n14=-a;n.n21=0;n.n22=2/o;n.n23=0;n.n24=-d;n.n31=0;n.n32=0;n.n33=-2/c;n.n34=-j;n.n41=0;n.n42=0;n.n43=0;n.n44=1;return n}; +THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; +THREE.Face3=function(a,b,d,f,j){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.material=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,b,d,f,j,m){this.a=a;this.b=b;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=m instanceof Array?m:[m]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a0){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;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y; -if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(F){var D=[];b=0;for(d=F.length;b65535){c[k].counter+=1;o=c[k].hash+"_"+c[k].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:m,vertices:0}}this.geometryChunks[o].faces.push(g);this.geometryChunks[o].vertices+=n}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,d,g){this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,g);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)}; +d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeNormals:function(a){var b,d,f,j,m,n,k=new THREE.Vector3,o=new THREE.Vector3;f=0;for(j=this.vertices.length;f0){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;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(E){var C=[];b=0;for(d=E.length;b65535){c[k].counter+=1;o=c[k].hash+"_"+c[k].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:n,vertices:0}}this.geometryChunks[o].faces.push(f);this.geometryChunks[o].vertices+=m}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +THREE.Camera=function(a,b,d,f){this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,f);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)}; THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.autoUpdateMatrix=this.visible=true;this.updateMatrix=function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z); this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition);this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0}; THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.Line=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b]};THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; THREE.Mesh=function(a,b,d){THREE.Object3D.call(this);this.geometry=a;this.material=b instanceof Array?b:[b];this.overdraw=this.doubleSided=this.flipSided=false;d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh; -THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,g,j;a=0;for(b=this.geometry.uvs.length;acolor: "+ this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; THREE.MeshBasicMaterial=function(a){this.id=THREE.MeshBasicMaterialCounter.value++;this.color=new THREE.Color(15658734);this.env_map=this.map=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refraction_ratio=0.98;this.opacity=1;this.shading=THREE.SmoothShading;this.blending=THREE.NormalBlending;this.wireframe=false;this.wireframe_linewidth=1;this.wireframe_linejoin=this.wireframe_linecap="round";if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map= @@ -82,92 +85,94 @@ undefined)this.uniforms=a.uniforms;if(a.shading!==undefined)this.shading=a.shadi THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16711680);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+ this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16711680);this.opacity=1;this.blending=THREE.NormalBlending;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}this.toString=function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}}; -THREE.Texture=function(a,b,d,g,j,n){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=g!==undefined?g:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=n!==undefined?n:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+ +THREE.Texture=function(a,b,d,f,j,m){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=m!==undefined?m:THREE.LinearMipMapLinearFilter;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+ this.min_filter+"
)"}};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(O,v){var f=0,l=1,e=O.z+O.w,q=v.z+v.w,h=-O.z+O.w,i=-v.z+v.w;if(e>=0&&q>=0&&h>=0&&i>=0)return true;else if(e<0&&q<0||h<0&&i<0)return false;else{if(e<0)f=Math.max(f,e/(e-q));else if(q<0)l=Math.min(l,e/(e-q));if(h<0)f=Math.max(f,h/(h-i));else if(i<0)l=Math.min(l,h/(h-i));if(l0&&y.z<1}R=r.geometry.faces;e=0;for(q=R.length;e0&&w.z<1){c=D[F]=D[F]||new THREE.RenderableParticle;c.x=w.x/w.w;c.y=w.y/w.w;c.z=w.z;c.rotation=r.rotation.z;c.scale.x=r.scale.x*Math.abs(c.x-(w.x+v.projectionMatrix.n11)/(w.w+v.projectionMatrix.n14));c.scale.y=r.scale.y*Math.abs(c.y-(w.y+v.projectionMatrix.n22)/(w.w+v.projectionMatrix.n24));c.material=r.material;b.push(c);F++}}}b.sort(function(W,J){return J.z-W.z});return b};this.unprojectVector=function(O,v){var f=new THREE.Matrix4; -f.multiply(THREE.Matrix4.makeInvert(v.matrix),THREE.Matrix4.makeInvert(v.projectionMatrix));f.multiplyVector3(O);return O}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,g,j,n;this.domElement=document.createElement("div");this.setSize=function(m,k){d=m;g=k;j=d/2;n=g/2};this.render=function(m,k){var o,c,F,D,w,x,I,G;a=b.projectScene(m,k);o=0;for(c=a.length;o0){t.r+=aa.r*V;t.g+=aa.g*V;t.b+=aa.b*V}}else if(V instanceof THREE.PointLight){Y.sub(V.position,U);Y.normalize();V=K.dot(Y)*ca;if(V>0){t.r+=aa.r*V;t.g+=aa.g*V;t.b+=aa.b*V}}}}function Na(p,U,K){if(K.opacity!=0){Da(K.opacity);ya(K.blending);var t,C,V,aa,ca,da;if(K instanceof THREE.ParticleBasicMaterial){if(K.map){aa=K.map;ca=aa.width>>1;da=aa.height>>1;C=U.scale.x*n;V=U.scale.y*m;K=C*ca;t=V*da;X.set(p.x-K, -p.y-t,p.x+K,p.y+t);if(!z.instersects(X))return;k.save();k.translate(p.x,p.y);k.rotate(-U.rotation);k.scale(C,-V);k.translate(-ca,-da);k.drawImage(aa,0,0);k.restore()}k.beginPath();k.moveTo(p.x-10,p.y);k.lineTo(p.x+10,p.y);k.moveTo(p.x,p.y-10);k.lineTo(p.x,p.y+10);k.closePath();k.strokeStyle="rgb(255,255,0)";k.stroke()}else if(K instanceof THREE.ParticleCircleMaterial){if(T){P.r=Z.r+ia.r+ja.r;P.g=Z.g+ia.g+ja.g;P.b=Z.b+ia.b+ja.b;h.r=K.color.r*P.r;h.g=K.color.g*P.g;h.b=K.color.b*P.b;h.updateStyleString()}else h.__styleString= -K.color.__styleString;K=U.scale.x*n;t=U.scale.y*m;X.set(p.x-K,p.y-t,p.x+K,p.y+t);if(z.instersects(X)){C=h.__styleString;if(D!=C)k.fillStyle=D=C;k.save();k.translate(p.x,p.y);k.rotate(-U.rotation);k.scale(K,t);k.beginPath();k.arc(0,0,1,0,La,true);k.closePath();k.fill();k.restore()}}}}function Oa(p,U,K,t){if(t.opacity!=0){Da(t.opacity);ya(t.blending);k.beginPath();k.moveTo(p.positionScreen.x,p.positionScreen.y);k.lineTo(U.positionScreen.x,U.positionScreen.y);k.closePath();if(t instanceof THREE.LineBasicMaterial){h.__styleString= -t.color.__styleString;p=t.linewidth;if(w!=p)k.lineWidth=w=p;p=h.__styleString;if(F!=p)k.strokeStyle=F=p;k.stroke();X.inflate(t.linewidth*2)}}}function Ha(p,U,K,t,C,V){if(C.opacity!=0){Da(C.opacity);ya(C.blending);O=p.positionScreen.x;v=p.positionScreen.y;f=U.positionScreen.x;l=U.positionScreen.y;e=K.positionScreen.x;q=K.positionScreen.y;k.beginPath();k.moveTo(O,v);k.lineTo(f,l);k.lineTo(e,q);k.lineTo(O,v);k.closePath();if(C instanceof THREE.MeshBasicMaterial)if(C.map)C.map.image.loaded&&C.map.mapping instanceof -THREE.UVMapping&&qa(O,v,f,l,e,q,C.map.image,t.uvs[0].u,t.uvs[0].v,t.uvs[1].u,t.uvs[1].v,t.uvs[2].u,t.uvs[2].v);else if(C.env_map){if(C.env_map.image.loaded)if(C.env_map.mapping instanceof THREE.SphericalReflectionMapping){p=wa.matrix;Y.copy(t.vertexNormalsWorld[0]);R=(Y.x*p.n11+Y.y*p.n12+Y.z*p.n13)*0.5+0.5;y=-(Y.x*p.n21+Y.y*p.n22+Y.z*p.n23)*0.5+0.5;Y.copy(t.vertexNormalsWorld[1]);A=(Y.x*p.n11+Y.y*p.n12+Y.z*p.n13)*0.5+0.5;E=-(Y.x*p.n21+Y.y*p.n22+Y.z*p.n23)*0.5+0.5;Y.copy(t.vertexNormalsWorld[2]);W= -(Y.x*p.n11+Y.y*p.n12+Y.z*p.n13)*0.5+0.5;J=-(Y.x*p.n21+Y.y*p.n22+Y.z*p.n23)*0.5+0.5;qa(O,v,f,l,e,q,C.env_map.image,R,y,A,E,W,J)}}else C.wireframe?za(C.color.__styleString,C.wireframe_linewidth):Aa(C.color.__styleString);else if(C instanceof THREE.MeshLambertMaterial){if(C.map&&!C.wireframe){C.map.mapping instanceof THREE.UVMapping&&qa(O,v,f,l,e,q,C.map.image,t.uvs[0].u,t.uvs[0].v,t.uvs[1].u,t.uvs[1].v,t.uvs[2].u,t.uvs[2].v);ya(THREE.SubtractiveBlending)}if(T)if(!C.wireframe&&C.shading==THREE.SmoothShading&& -t.vertexNormalsWorld.length==3){i.r=s.r=r.r=Z.r;i.g=s.g=r.g=Z.g;i.b=s.b=r.b=Z.b;xa(V,t.v1.positionWorld,t.vertexNormalsWorld[0],i);xa(V,t.v2.positionWorld,t.vertexNormalsWorld[1],s);xa(V,t.v3.positionWorld,t.vertexNormalsWorld[2],r);M.r=(s.r+r.r)*0.5;M.g=(s.g+r.g)*0.5;M.b=(s.b+r.b)*0.5;u=Ia(i,s,r,M);qa(O,v,f,l,e,q,u,0,0,1,0,0,1)}else{P.r=Z.r;P.g=Z.g;P.b=Z.b;xa(V,t.centroidWorld,t.normalWorld,P);h.r=C.color.r*P.r;h.g=C.color.g*P.g;h.b=C.color.b*P.b;h.updateStyleString();C.wireframe?za(h.__styleString, -C.wireframe_linewidth):Aa(h.__styleString)}else C.wireframe?za(C.color.__styleString,C.wireframe_linewidth):Aa(C.color.__styleString)}else if(C instanceof THREE.MeshDepthMaterial){B=C.__2near;H=C.__farPlusNear;Q=C.__farMinusNear;i.r=i.g=i.b=1-B/(H-p.positionScreen.z*Q);s.r=s.g=s.b=1-B/(H-U.positionScreen.z*Q);r.r=r.g=r.b=1-B/(H-K.positionScreen.z*Q);M.r=(s.r+r.r)*0.5;M.g=(s.g+r.g)*0.5;M.b=(s.b+r.b)*0.5;u=Ia(i,s,r,M);qa(O,v,f,l,e,q,u,0,0,1,0,0,1)}else if(C instanceof THREE.MeshNormalMaterial){h.r= -Ea(t.normalWorld.x);h.g=Ea(t.normalWorld.y);h.b=Ea(t.normalWorld.z);h.updateStyleString();C.wireframe?za(h.__styleString,C.wireframe_linewidth):Aa(h.__styleString)}}}function za(p,U){if(F!=p)k.strokeStyle=F=p;if(w!=U)k.lineWidth=w=U;k.stroke();X.inflate(U*2)}function Aa(p){if(D!=p)k.fillStyle=D=p;k.fill()}function qa(p,U,K,t,C,V,aa,ca,da,ra,ha,sa,ta){var ka,ga;ka=aa.width-1;ga=aa.height-1;ca*=ka;da*=ga;ra*=ka;ha*=ga;sa*=ka;ta*=ga;K-=p;t-=U;C-=p;V-=U;ra-=ca;ha-=da;sa-=ca;ta-=da;ga=1/(ra*ta-sa*ha); -ka=(ta*K-ha*C)*ga;ha=(ta*t-ha*V)*ga;K=(ra*C-sa*K)*ga;t=(ra*V-sa*t)*ga;p=p-ka*ca-K*da;U=U-ha*ca-t*da;k.save();k.transform(ka,ha,K,t,p,U);k.clip();k.drawImage(aa,0,0);k.restore()}function Da(p){if(o!=p)k.globalAlpha=o=p}function ya(p){if(c!=p){switch(p){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}c=p}}function Ia(p,U,K,t){ba[0]=I(0,x(255, -~~(p.r*255)));ba[1]=I(0,x(255,~~(p.g*255)));ba[2]=I(0,x(255,~~(p.b*255)));ba[4]=I(0,x(255,~~(U.r*255)));ba[5]=I(0,x(255,~~(U.g*255)));ba[6]=I(0,x(255,~~(U.b*255)));ba[8]=I(0,x(255,~~(K.r*255)));ba[9]=I(0,x(255,~~(K.g*255)));ba[10]=I(0,x(255,~~(K.b*255)));ba[12]=I(0,x(255,~~(t.r*255)));ba[13]=I(0,x(255,~~(t.g*255)));ba[14]=I(0,x(255,~~(t.b*255)));oa.putImageData(Ca,0,0);va.drawImage(na,0,0);return pa}function Ea(p){return p<0?x((1+p)*0.5,0.5):0.5+x(p*0.5,0.5)}function Fa(p,U){var K=U.x-p.x,t=U.y-p.y, -C=1/Math.sqrt(K*K+t*t);K*=C;t*=C;U.x+=K;U.y+=t;p.x-=K;p.y-=t}var Ba,Ja,$,ea,ma,Ga,Ka,ua;k.setTransform(1,0,0,-1,n,m);this.autoClear&&this.clear();a=b.projectScene(fa,wa);k.fillStyle="rgba(0, 255, 255, 0.5)";k.fillRect(z.getX(),z.getY(),z.getWidth(),z.getHeight());(T=fa.lights.length>0)&&Ma(fa);Ba=0;for(Ja=a.length;Ba0){E.r+=z.color.r*S;E.g+=z.color.g*S;E.b+=z.color.b*S}}else if(z instanceof THREE.PointLight){i.sub(z.position,A.centroidWorld);i.normalize();S=A.normalWorld.dot(i)*z.intensity;if(S>0){E.r+=z.color.r*S;E.g+=z.color.g*S;E.b+=z.color.b*S}}}}function b(y,A,E,W,J,z){B=g(H++);B.setAttribute("d","M "+y.positionScreen.x+ -" "+y.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+"z");if(J instanceof THREE.MeshBasicMaterial)v.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshLambertMaterial)if(O){f.r=l.r;f.g=l.g;f.b=l.b;a(z,W,f);v.r=J.color.r*f.r;v.g=J.color.g*f.g;v.b=J.color.b*f.b;v.updateStyleString()}else v.__styleString=J.color.__styleString;else if(J instanceof THREE.MeshDepthMaterial){h=1-J.__2near/(J.__farPlusNear-W.z*J.__farMinusNear); -v.setRGB(h,h,h)}else J instanceof THREE.MeshNormalMaterial&&v.setRGB(j(W.normalWorld.x),j(W.normalWorld.y),j(W.normalWorld.z));J.wireframe?B.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+J.wireframe_linewidth+"; stroke-opacity: "+J.opacity+"; stroke-linecap: "+J.wireframe_linecap+"; stroke-linejoin: "+J.wireframe_linejoin):B.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+J.opacity);k.appendChild(B)}function d(y,A,E,W,J,z,S){B=g(H++);B.setAttribute("d", -"M "+y.positionScreen.x+" "+y.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+" L "+W.positionScreen.x+","+W.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)v.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(O){f.r=l.r;f.g=l.g;f.b=l.b;a(S,J,f);v.r=z.color.r*f.r;v.g=z.color.g*f.g;v.b=z.color.b*f.b;v.updateStyleString()}else v.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshDepthMaterial){h= -1-z.__2near/(z.__farPlusNear-J.z*z.__farMinusNear);v.setRGB(h,h,h)}else z instanceof THREE.MeshNormalMaterial&&v.setRGB(j(J.normalWorld.x),j(J.normalWorld.y),j(J.normalWorld.z));z.wireframe?B.setAttribute("style","fill: none; stroke: "+v.__styleString+"; stroke-width: "+z.wireframe_linewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframe_linecap+"; stroke-linejoin: "+z.wireframe_linejoin):B.setAttribute("style","fill: "+v.__styleString+"; fill-opacity: "+z.opacity);k.appendChild(B)} -function g(y){if(s[y]==null){s[y]=document.createElementNS("http://www.w3.org/2000/svg","path");R==0&&s[y].setAttribute("shape-rendering","crispEdges");return s[y]}return s[y]}function j(y){return y<0?Math.min((1+y)*0.5,0.5):0.5+Math.min(y*0.5,0.5)}var n=null,m=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,F,D,w,x,I,G,L=new THREE.Rectangle,N=new THREE.Rectangle,O=false,v=new THREE.Color(16777215),f=new THREE.Color(16777215),l=new THREE.Color(0),e=new THREE.Color(0), -q=new THREE.Color(0),h,i=new THREE.Vector3,s=[],r=[],M=[],B,H,Q,u,R=1;this.domElement=k;this.autoClear=true;this.setQuality=function(y){switch(y){case "high":R=1;break;case "low":R=0}};this.setSize=function(y,A){o=y;c=A;F=o/2;D=c/2;k.setAttribute("viewBox",-F+" "+-D+" "+o+" "+c);k.setAttribute("width",o);k.setAttribute("height",c);L.set(-F,-D,F,D)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(y,A){var E,W,J,z,S,X,T,P;this.autoClear&&this.clear(); -n=m.projectScene(y,A);u=Q=H=0;if(O=y.lights.length>0){T=y.lights;l.setRGB(0,0,0);e.setRGB(0,0,0);q.setRGB(0,0,0);E=0;for(W=T.length;E=0&&c.enableVertexAttribArray(f.attributes[h])}}function m(f,l){var e;if(f=="fragment")e=c.createShader(c.FRAGMENT_SHADER);else if(f=="vertex")e=c.createShader(c.VERTEX_SHADER);c.shaderSource(e,l);c.compileShader(e);if(!c.getShaderParameter(e, -c.COMPILE_STATUS)){alert(c.getShaderInfoLog(e));return null}return e}function k(f){switch(f){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 o=document.createElement("canvas"),c,F,D,w=new THREE.Matrix4,x,I=new Float32Array(16),G=new Float32Array(16),L=new Float32Array(16),N=new Float32Array(9),O=new Float32Array(16);a=function(f,l){if(f){var e,q,h,i=pointLights=maxDirLights=maxPointLights=0;e=0;for(q=f.lights.length;e=0&&q>=0&&h>=0&&i>=0)return true;else if(g<0&&q<0||h<0&&i<0)return false;else{if(g<0)e=Math.max(e,g/(g-q));else if(q<0)l=Math.min(l,g/(g-q));if(h<0)e=Math.max(e,h/(h-i));else if(i<0)l=Math.min(l,h/(h-i));if(l0&&B.z<1}O=p.geometry.faces;g=0;for(q=O.length;g0&&x.z<1){c=C[E]=C[E]||new THREE.RenderableParticle;c.x=x.x/x.w;c.y=x.y/x.w;c.z=x.z;c.rotation=p.rotation.z;c.scale.x=p.scale.x*Math.abs(c.x-(x.x+u.projectionMatrix.n11)/(x.w+u.projectionMatrix.n14));c.scale.y=p.scale.y*Math.abs(c.y-(x.y+u.projectionMatrix.n22)/(x.w+u.projectionMatrix.n24));c.material=p.material;b.push(c);E++}}}b.sort(function(K,y){return y.z-K.z});return b};this.unprojectVector=function(M,u){var e=new THREE.Matrix4; +e.multiply(THREE.Matrix4.makeInvert(u.matrix),THREE.Matrix4.makeInvert(u.projectionMatrix));e.multiplyVector3(M);return M}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,f,j,m;this.domElement=document.createElement("div");this.setSize=function(n,k){d=n;f=k;j=d/2;m=f/2};this.render=function(n,k){var o,c,E,C,x,z,H,G;a=b.projectScene(n,k);o=0;for(c=a.length;o0){v.r+=aa.r*W;v.g+=aa.g*W;v.b+=aa.b*W}}else if(W instanceof THREE.PointLight){Y.sub(W.position,V);Y.normalize();W=N.dot(Y)*ca;if(W>0){v.r+=aa.r*W;v.g+=aa.g*W;v.b+=aa.b*W}}}}function Na(r,V,N){if(N.opacity!=0){Da(N.opacity);ya(N.blending);var v,F,W,aa,ca,da;if(N instanceof THREE.ParticleBasicMaterial){if(N.map){aa=N.map;ca=aa.width>>1;da=aa.height>>1;F=V.scale.x*m;W=V.scale.y*n;N=F*ca;v=W*da;X.set(r.x-N, +r.y-v,r.x+N,r.y+v);if(!A.instersects(X))return;k.save();k.translate(r.x,r.y);k.rotate(-V.rotation);k.scale(F,-W);k.translate(-ca,-da);k.drawImage(aa,0,0);k.restore()}k.beginPath();k.moveTo(r.x-10,r.y);k.lineTo(r.x+10,r.y);k.moveTo(r.x,r.y-10);k.lineTo(r.x,r.y+10);k.closePath();k.strokeStyle="rgb(255,255,0)";k.stroke()}else if(N instanceof THREE.ParticleCircleMaterial){if(U){R.r=Z.r+ia.r+ja.r;R.g=Z.g+ia.g+ja.g;R.b=Z.b+ia.b+ja.b;h.r=N.color.r*R.r;h.g=N.color.g*R.g;h.b=N.color.b*R.b;h.updateStyleString()}else h.__styleString= +N.color.__styleString;N=V.scale.x*m;v=V.scale.y*n;X.set(r.x-N,r.y-v,r.x+N,r.y+v);if(A.instersects(X)){F=h.__styleString;if(C!=F)k.fillStyle=C=F;k.save();k.translate(r.x,r.y);k.rotate(-V.rotation);k.scale(N,v);k.beginPath();k.arc(0,0,1,0,La,true);k.closePath();k.fill();k.restore()}}}}function Oa(r,V,N,v){if(v.opacity!=0){Da(v.opacity);ya(v.blending);k.beginPath();k.moveTo(r.positionScreen.x,r.positionScreen.y);k.lineTo(V.positionScreen.x,V.positionScreen.y);k.closePath();if(v instanceof THREE.LineBasicMaterial){h.__styleString= +v.color.__styleString;r=v.linewidth;if(x!=r)k.lineWidth=x=r;r=h.__styleString;if(E!=r)k.strokeStyle=E=r;k.stroke();X.inflate(v.linewidth*2)}}}function Ha(r,V,N,v,F,W){if(F.opacity!=0){Da(F.opacity);ya(F.blending);M=r.positionScreen.x;u=r.positionScreen.y;e=V.positionScreen.x;l=V.positionScreen.y;g=N.positionScreen.x;q=N.positionScreen.y;k.beginPath();k.moveTo(M,u);k.lineTo(e,l);k.lineTo(g,q);k.lineTo(M,u);k.closePath();if(F instanceof THREE.MeshBasicMaterial)if(F.map)F.map.image.loaded&&F.map.mapping instanceof +THREE.UVMapping&&qa(M,u,e,l,g,q,F.map.image,v.uvs[0].u,v.uvs[0].v,v.uvs[1].u,v.uvs[1].v,v.uvs[2].u,v.uvs[2].v);else if(F.env_map){if(F.env_map.image.loaded)if(F.env_map.mapping instanceof THREE.SphericalReflectionMapping){r=wa.matrix;Y.copy(v.vertexNormalsWorld[0]);O=(Y.x*r.n11+Y.y*r.n12+Y.z*r.n13)*0.5+0.5;B=-(Y.x*r.n21+Y.y*r.n22+Y.z*r.n23)*0.5+0.5;Y.copy(v.vertexNormalsWorld[1]);P=(Y.x*r.n11+Y.y*r.n12+Y.z*r.n13)*0.5+0.5;Q=-(Y.x*r.n21+Y.y*r.n22+Y.z*r.n23)*0.5+0.5;Y.copy(v.vertexNormalsWorld[2]);K= +(Y.x*r.n11+Y.y*r.n12+Y.z*r.n13)*0.5+0.5;y=-(Y.x*r.n21+Y.y*r.n22+Y.z*r.n23)*0.5+0.5;qa(M,u,e,l,g,q,F.env_map.image,O,B,P,Q,K,y)}}else F.wireframe?za(F.color.__styleString,F.wireframe_linewidth):Aa(F.color.__styleString);else if(F instanceof THREE.MeshLambertMaterial){if(F.map&&!F.wireframe){F.map.mapping instanceof THREE.UVMapping&&qa(M,u,e,l,g,q,F.map.image,v.uvs[0].u,v.uvs[0].v,v.uvs[1].u,v.uvs[1].v,v.uvs[2].u,v.uvs[2].v);ya(THREE.SubtractiveBlending)}if(U)if(!F.wireframe&&F.shading==THREE.SmoothShading&& +v.vertexNormalsWorld.length==3){i.r=s.r=p.r=Z.r;i.g=s.g=p.g=Z.g;i.b=s.b=p.b=Z.b;xa(W,v.v1.positionWorld,v.vertexNormalsWorld[0],i);xa(W,v.v2.positionWorld,v.vertexNormalsWorld[1],s);xa(W,v.v3.positionWorld,v.vertexNormalsWorld[2],p);D.r=(s.r+p.r)*0.5;D.g=(s.g+p.g)*0.5;D.b=(s.b+p.b)*0.5;t=Ia(i,s,p,D);qa(M,u,e,l,g,q,t,0,0,1,0,0,1)}else{R.r=Z.r;R.g=Z.g;R.b=Z.b;xa(W,v.centroidWorld,v.normalWorld,R);h.r=F.color.r*R.r;h.g=F.color.g*R.g;h.b=F.color.b*R.b;h.updateStyleString();F.wireframe?za(h.__styleString, +F.wireframe_linewidth):Aa(h.__styleString)}else F.wireframe?za(F.color.__styleString,F.wireframe_linewidth):Aa(F.color.__styleString)}else if(F instanceof THREE.MeshDepthMaterial){w=F.__2near;I=F.__farPlusNear;S=F.__farMinusNear;i.r=i.g=i.b=1-w/(I-r.positionScreen.z*S);s.r=s.g=s.b=1-w/(I-V.positionScreen.z*S);p.r=p.g=p.b=1-w/(I-N.positionScreen.z*S);D.r=(s.r+p.r)*0.5;D.g=(s.g+p.g)*0.5;D.b=(s.b+p.b)*0.5;t=Ia(i,s,p,D);qa(M,u,e,l,g,q,t,0,0,1,0,0,1)}else if(F instanceof THREE.MeshNormalMaterial){h.r= +Ea(v.normalWorld.x);h.g=Ea(v.normalWorld.y);h.b=Ea(v.normalWorld.z);h.updateStyleString();F.wireframe?za(h.__styleString,F.wireframe_linewidth):Aa(h.__styleString)}}}function za(r,V){if(E!=r)k.strokeStyle=E=r;if(x!=V)k.lineWidth=x=V;k.stroke();X.inflate(V*2)}function Aa(r){if(C!=r)k.fillStyle=C=r;k.fill()}function qa(r,V,N,v,F,W,aa,ca,da,ra,ha,sa,ta){var ka,ga;ka=aa.width-1;ga=aa.height-1;ca*=ka;da*=ga;ra*=ka;ha*=ga;sa*=ka;ta*=ga;N-=r;v-=V;F-=r;W-=V;ra-=ca;ha-=da;sa-=ca;ta-=da;ga=1/(ra*ta-sa*ha); +ka=(ta*N-ha*F)*ga;ha=(ta*v-ha*W)*ga;N=(ra*F-sa*N)*ga;v=(ra*W-sa*v)*ga;r=r-ka*ca-N*da;V=V-ha*ca-v*da;k.save();k.transform(ka,ha,N,v,r,V);k.clip();k.drawImage(aa,0,0);k.restore()}function Da(r){if(o!=r)k.globalAlpha=o=r}function ya(r){if(c!=r){switch(r){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}c=r}}function Ia(r,V,N,v){ba[0]=H(0,z(255, +~~(r.r*255)));ba[1]=H(0,z(255,~~(r.g*255)));ba[2]=H(0,z(255,~~(r.b*255)));ba[4]=H(0,z(255,~~(V.r*255)));ba[5]=H(0,z(255,~~(V.g*255)));ba[6]=H(0,z(255,~~(V.b*255)));ba[8]=H(0,z(255,~~(N.r*255)));ba[9]=H(0,z(255,~~(N.g*255)));ba[10]=H(0,z(255,~~(N.b*255)));ba[12]=H(0,z(255,~~(v.r*255)));ba[13]=H(0,z(255,~~(v.g*255)));ba[14]=H(0,z(255,~~(v.b*255)));oa.putImageData(Ca,0,0);va.drawImage(na,0,0);return pa}function Ea(r){return r<0?z((1+r)*0.5,0.5):0.5+z(r*0.5,0.5)}function Fa(r,V){var N=V.x-r.x,v=V.y-r.y, +F=1/Math.sqrt(N*N+v*v);N*=F;v*=F;V.x+=N;V.y+=v;r.x-=N;r.y-=v}var Ba,Ja,$,ea,ma,Ga,Ka,ua;k.setTransform(1,0,0,-1,m,n);this.autoClear&&this.clear();a=b.projectScene(fa,wa);k.fillStyle="rgba(0, 255, 255, 0.5)";k.fillRect(A.getX(),A.getY(),A.getWidth(),A.getHeight());(U=fa.lights.length>0)&&Ma(fa);Ba=0;for(Ja=a.length;Ba0){Q.r+=A.color.r*T;Q.g+=A.color.g*T;Q.b+=A.color.b*T}}else if(A instanceof THREE.PointLight){i.sub(A.position,P.centroidWorld);i.normalize();T=P.normalWorld.dot(i)*A.intensity;if(T>0){Q.r+=A.color.r*T;Q.g+=A.color.g*T;Q.b+=A.color.b*T}}}}function b(B,P,Q,K,y,A){w=f(I++);w.setAttribute("d","M "+B.positionScreen.x+ +" "+B.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(y instanceof THREE.MeshBasicMaterial)u.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshLambertMaterial)if(M){e.r=l.r;e.g=l.g;e.b=l.b;a(A,K,e);u.r=y.color.r*e.r;u.g=y.color.g*e.g;u.b=y.color.b*e.b;u.updateStyleString()}else u.__styleString=y.color.__styleString;else if(y instanceof THREE.MeshDepthMaterial){h=1-y.__2near/(y.__farPlusNear-K.z*y.__farMinusNear); +u.setRGB(h,h,h)}else y instanceof THREE.MeshNormalMaterial&&u.setRGB(j(K.normalWorld.x),j(K.normalWorld.y),j(K.normalWorld.z));y.wireframe?w.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+y.wireframe_linewidth+"; stroke-opacity: "+y.opacity+"; stroke-linecap: "+y.wireframe_linecap+"; stroke-linejoin: "+y.wireframe_linejoin):w.setAttribute("style","fill: "+u.__styleString+"; fill-opacity: "+y.opacity);k.appendChild(w)}function d(B,P,Q,K,y,A,T){w=f(I++);w.setAttribute("d", +"M "+B.positionScreen.x+" "+B.positionScreen.y+" L "+P.positionScreen.x+" "+P.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(A instanceof THREE.MeshBasicMaterial)u.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshLambertMaterial)if(M){e.r=l.r;e.g=l.g;e.b=l.b;a(T,y,e);u.r=A.color.r*e.r;u.g=A.color.g*e.g;u.b=A.color.b*e.b;u.updateStyleString()}else u.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshDepthMaterial){h= +1-A.__2near/(A.__farPlusNear-y.z*A.__farMinusNear);u.setRGB(h,h,h)}else A instanceof THREE.MeshNormalMaterial&&u.setRGB(j(y.normalWorld.x),j(y.normalWorld.y),j(y.normalWorld.z));A.wireframe?w.setAttribute("style","fill: none; stroke: "+u.__styleString+"; stroke-width: "+A.wireframe_linewidth+"; stroke-opacity: "+A.opacity+"; stroke-linecap: "+A.wireframe_linecap+"; stroke-linejoin: "+A.wireframe_linejoin):w.setAttribute("style","fill: "+u.__styleString+"; fill-opacity: "+A.opacity);k.appendChild(w)} +function f(B){if(s[B]==null){s[B]=document.createElementNS("http://www.w3.org/2000/svg","path");O==0&&s[B].setAttribute("shape-rendering","crispEdges");return s[B]}return s[B]}function j(B){return B<0?Math.min((1+B)*0.5,0.5):0.5+Math.min(B*0.5,0.5)}var m=null,n=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,E,C,x,z,H,G,J=new THREE.Rectangle,L=new THREE.Rectangle,M=false,u=new THREE.Color(16777215),e=new THREE.Color(16777215),l=new THREE.Color(0),g=new THREE.Color(0), +q=new THREE.Color(0),h,i=new THREE.Vector3,s=[],p=[],D=[],w,I,S,t,O=1;this.domElement=k;this.autoClear=true;this.setQuality=function(B){switch(B){case "high":O=1;break;case "low":O=0}};this.setSize=function(B,P){o=B;c=P;E=o/2;C=c/2;k.setAttribute("viewBox",-E+" "+-C+" "+o+" "+c);k.setAttribute("width",o);k.setAttribute("height",c);J.set(-E,-C,E,C)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(B,P){var Q,K,y,A,T,X,U,R;this.autoClear&&this.clear(); +m=n.projectScene(B,P);t=S=I=0;if(M=B.lights.length>0){U=B.lights;l.setRGB(0,0,0);g.setRGB(0,0,0);q.setRGB(0,0,0);Q=0;for(K=U.length;Q0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(g,n("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ +e));c.attachShader(g,n("vertex",q+l));c.linkProgram(g);c.getProgramParameter(g,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(g,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");g.uniforms={};g.attributes={};return g}function d(e,l){if(e.image.length==6){if(!e.image.__webGLTextureCube&&!e.image.__cubeMapInitialized&&e.image.loadCount==6){e.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,e.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 g=0;g<6;++g)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+g,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image[g]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);e.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_CUBE_MAP, +e.image.__webGLTextureCube)}}function f(e,l){if(!e.__webGLTexture&&e.image.loaded){e.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,e.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,e.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,k(e.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,k(e.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,k(e.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,k(e.min_filter));c.generateMipmap(c.TEXTURE_2D); +c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+l);c.bindTexture(c.TEXTURE_2D,e.__webGLTexture)}function j(e,l){var g,q,h;g=0;for(q=l.length;g=0&&c.enableVertexAttribArray(e.attributes[h])}}function n(e,l){var g;if(e=="fragment")g=c.createShader(c.FRAGMENT_SHADER);else if(e=="vertex")g=c.createShader(c.VERTEX_SHADER); +c.shaderSource(g,l);c.compileShader(g);if(!c.getShaderParameter(g,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(g));return null}return g}function k(e){switch(e){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 o=document.createElement("canvas"),c,E,C,x=new THREE.Matrix4,z,H=new Float32Array(16),G=new Float32Array(16),J=new Float32Array(16),L=new Float32Array(9),M=new Float32Array(16);a=function(e,l){if(e){var g,q,h,i=pointLights=maxDirLights=maxPointLights=0;g=0;for(q=e.lights.length;g= 0.0 )": -"",l?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",l?"pointDiffuse += mColor * pointDiffuseWeight;":"",l?"pointSpecular += mSpecular * pointSpecularWeight;":"",l?"}":"",f?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",f?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",f?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",f?"vec3 dirVector = normalize( lDirection.xyz );":"",f?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": -"",f?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",f?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",f?"float dirSpecularWeight = 0.0;":"",f?"if ( dirDotNormalHalf >= 0.0 )":"",f?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",f?"dirDiffuse += mColor * dirDiffuseWeight;":"",f?"dirSpecular += mSpecular * dirSpecularWeight;":"",f?"}":"","vec4 totalLight = mAmbient;",f?"totalLight += dirDiffuse + dirSpecular;":"",l?"totalLight += pointDiffuse + pointSpecular;": +"",l?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",l?"pointDiffuse += mColor * pointDiffuseWeight;":"",l?"pointSpecular += mSpecular * pointSpecularWeight;":"",l?"}":"",e?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",e?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",e?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",e?"vec3 dirVector = normalize( lDirection.xyz );":"",e?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": +"",e?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",e?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",e?"float dirSpecularWeight = 0.0;":"",e?"if ( dirDotNormalHalf >= 0.0 )":"",e?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",e?"dirDiffuse += mColor * dirDiffuseWeight;":"",e?"dirSpecular += mSpecular * dirSpecularWeight;":"",e?"}":"","vec4 totalLight = mAmbient;",e?"totalLight += dirDiffuse + dirSpecular;":"",l?"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"); -e=b(q,e);c.useProgram(e);j(e,["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"]);f&&j(e,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);l&&j(e,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(e.uniforms.enableMap,0);c.uniform1i(e.uniforms.tMap,0);c.uniform1i(e.uniforms.enableCubeMap,0);c.uniform1i(e.uniforms.tCube,1);c.uniform1i(e.uniforms.mixEnvMap,0);c.uniform1i(e.uniforms.useRefract,0);n(e,["position","normal","uv"]);return e}(a.directional,a.point);this.setSize=function(f,l){o.width=f;o.height=l;c.viewport(0,0,o.width,o.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(f,l){var e,q,h,i,s,r=[], -M=[],B=[];i=[];s=[];c.uniform1i(f.uniforms.enableLighting,l.length);e=0;for(q=l.length;e0){E.__webGLUVBuffer=c.createBuffer(); -c.bindBuffer(c.ARRAY_BUFFER,E.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(y),c.STATIC_DRAW)}E.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(H),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);E.__webGLFaceCount=H.length;E.__webGLLineCount=Q.length}};this.renderBuffer= -function(f,l,e,q){var h,i,s,r,M,B,H,Q,u;if(e instanceof THREE.MeshShaderMaterial){if(!e.program){e.program=b(e.fragment_shader,e.vertex_shader);H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(u in e.uniforms)H.push(u);j(e.program,H);n(e.program,["position","normal","uv"])}u=e.program}else u=D;if(u!=F){c.useProgram(u);F=u}u==D&&this.setupLights(u,l);this.loadCamera(u,f);this.loadMatrices(u);if(e instanceof THREE.MeshShaderMaterial){s=e.wireframe; -r=e.wireframe_linewidth;f=u;l=e.uniforms;var R;for(h in l){Q=l[h].type;H=l[h].value;R=f.uniforms[h];if(Q=="i")c.uniform1i(R,H);else if(Q=="f")c.uniform1f(R,H);else if(Q=="v3")c.uniform3f(R,H.x,H.y,H.z);else if(Q=="c")c.uniform3f(R,H.r,H.g,H.b);else if(Q=="t"){c.uniform1i(R,H);if(Q=l[h].texture)Q.image instanceof Array&&Q.image.length==6?d(Q,H):g(Q,H)}}}if(e instanceof THREE.MeshPhongMaterial||e instanceof THREE.MeshLambertMaterial||e instanceof THREE.MeshBasicMaterial){h=e.color;i=e.opacity;s=e.wireframe; -r=e.wireframe_linewidth;M=e.map;B=e.env_map;l=e.combine==THREE.MixOperation;f=e.reflectivity;Q=e.env_map&&e.env_map.mapping instanceof THREE.CubeRefractionMapping;H=e.refraction_ratio;c.uniform4f(u.uniforms.mColor,h.r*i,h.g*i,h.b*i,i);c.uniform1i(u.uniforms.mixEnvMap,l);c.uniform1f(u.uniforms.mReflectivity,f);c.uniform1i(u.uniforms.useRefract,Q);c.uniform1f(u.uniforms.mRefractionRatio,H)}if(e instanceof THREE.MeshNormalMaterial){i=e.opacity;c.uniform1f(u.uniforms.mOpacity,i);c.uniform1i(u.uniforms.material, -4)}else if(e instanceof THREE.MeshDepthMaterial){i=e.opacity;s=e.wireframe;r=e.wireframe_linewidth;c.uniform1f(u.uniforms.mOpacity,i);c.uniform1f(u.uniforms.m2Near,e.__2near);c.uniform1f(u.uniforms.mFarPlusNear,e.__farPlusNear);c.uniform1f(u.uniforms.mFarMinusNear,e.__farMinusNear);c.uniform1i(u.uniforms.material,3)}else if(e instanceof THREE.MeshPhongMaterial){h=e.ambient;f=e.specular;e=e.shininess;c.uniform4f(u.uniforms.mAmbient,h.r,h.g,h.b,i);c.uniform4f(u.uniforms.mSpecular,f.r,f.g,f.b,i);c.uniform1f(u.uniforms.mShininess, -e);c.uniform1i(u.uniforms.material,2)}else if(e instanceof THREE.MeshLambertMaterial)c.uniform1i(u.uniforms.material,1);else if(e instanceof THREE.MeshBasicMaterial)c.uniform1i(u.uniforms.material,0);else if(e instanceof THREE.MeshCubeMaterial){c.uniform1i(u.uniforms.material,5);B=e.env_map}if(M){g(M,0);c.uniform1i(u.uniforms.tMap,0);c.uniform1i(u.uniforms.enableMap,1)}else c.uniform1i(u.uniforms.enableMap,0);if(B){d(B,1);c.uniform1i(u.uniforms.tCube,1);c.uniform1i(u.uniforms.enableCubeMap,1)}else c.uniform1i(u.uniforms.enableCubeMap, -0);i=u.attributes;c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0);if(i.uv>=0)if(q.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(s){c.lineWidth(r);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer); -c.drawElements(c.LINES,q.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,q.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(f,l,e,q,h,i){var s,r,M,B,H;M=0;for(B=e.material.length;M=0;e--){q=f.__webGLObjects[e].object;l==q&&f.__webGLObjects.splice(e,1)}};this.setupMatrices=function(f,l){f.autoUpdateMatrix&&f.updateMatrix();w.multiply(l.matrix,f.matrix);I.set(l.matrix.flatten()); -G.set(w.flatten());L.set(l.projectionMatrix.flatten());x=THREE.Matrix4.makeInvert3x3(w).transpose();N.set(x.m);O.set(f.matrix.flatten())};this.loadMatrices=function(f){c.uniformMatrix4fv(f.uniforms.viewMatrix,false,I);c.uniformMatrix4fv(f.uniforms.modelViewMatrix,false,G);c.uniformMatrix4fv(f.uniforms.projectionMatrix,false,L);c.uniformMatrix3fv(f.uniforms.normalMatrix,false,N);c.uniformMatrix4fv(f.uniforms.objectMatrix,false,O)};this.loadCamera=function(f,l){c.uniform3f(f.uniforms.cameraPosition, -l.position.x,l.position.y,l.position.z)};this.setBlending=function(f){switch(f){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(f,l){if(f){!l||l=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK); -c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}};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};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null}; +g=b(q,g);c.useProgram(g);j(g,["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"]);e&&j(g,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);l&&j(g,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(g.uniforms.enableMap,0);c.uniform1i(g.uniforms.tMap,0);c.uniform1i(g.uniforms.enableCubeMap,0);c.uniform1i(g.uniforms.tCube,1);c.uniform1i(g.uniforms.mixEnvMap,0);c.uniform1i(g.uniforms.useRefract,0);m(g,["position","normal","uv"]);return g}(a.directional,a.point);this.setSize=function(e,l){o.width=e;o.height=l;c.viewport(0,0,o.width,o.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,l){var g,q,h,i,s,p=[], +D=[],w=[];i=[];s=[];c.uniform1i(e.uniforms.enableLighting,l.length);g=0;for(q=l.length;g0){y.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,y.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(Q),c.STATIC_DRAW)}y.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(S),c.STATIC_DRAW);y.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +y.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(t),c.STATIC_DRAW);y.__webGLFaceCount=S.length;y.__webGLLineCount=t.length}};this.renderBuffer=function(e,l,g,q){var h,i,s,p,D,w,I,S,t;if(g instanceof THREE.MeshShaderMaterial){if(!g.program){g.program=b(g.fragment_shader,g.vertex_shader);I=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in g.uniforms)I.push(t);j(g.program,I);m(g.program,["position","normal","uv","tangent"])}t= +g.program}else t=C;if(t!=E){c.useProgram(t);E=t}t==C&&this.setupLights(t,l);this.loadCamera(t,e);this.loadMatrices(t);if(g instanceof THREE.MeshShaderMaterial){s=g.wireframe;p=g.wireframe_linewidth;e=t;l=g.uniforms;var O;for(h in l){S=l[h].type;I=l[h].value;O=e.uniforms[h];if(S=="i")c.uniform1i(O,I);else if(S=="f")c.uniform1f(O,I);else if(S=="v3")c.uniform3f(O,I.x,I.y,I.z);else if(S=="c")c.uniform3f(O,I.r,I.g,I.b);else if(S=="t"){c.uniform1i(O,I);if(S=l[h].texture)S.image instanceof Array&&S.image.length== +6?d(S,I):f(S,I)}}}if(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshBasicMaterial){h=g.color;i=g.opacity;s=g.wireframe;p=g.wireframe_linewidth;D=g.map;w=g.env_map;l=g.combine==THREE.MixOperation;e=g.reflectivity;S=g.env_map&&g.env_map.mapping instanceof THREE.CubeRefractionMapping;I=g.refraction_ratio;c.uniform4f(t.uniforms.mColor,h.r*i,h.g*i,h.b*i,i);c.uniform1i(t.uniforms.mixEnvMap,l);c.uniform1f(t.uniforms.mReflectivity,e);c.uniform1i(t.uniforms.useRefract, +S);c.uniform1f(t.uniforms.mRefractionRatio,I)}if(g instanceof THREE.MeshNormalMaterial){i=g.opacity;c.uniform1f(t.uniforms.mOpacity,i);c.uniform1i(t.uniforms.material,4)}else if(g instanceof THREE.MeshDepthMaterial){i=g.opacity;s=g.wireframe;p=g.wireframe_linewidth;c.uniform1f(t.uniforms.mOpacity,i);c.uniform1f(t.uniforms.m2Near,g.__2near);c.uniform1f(t.uniforms.mFarPlusNear,g.__farPlusNear);c.uniform1f(t.uniforms.mFarMinusNear,g.__farMinusNear);c.uniform1i(t.uniforms.material,3)}else if(g instanceof +THREE.MeshPhongMaterial){h=g.ambient;e=g.specular;g=g.shininess;c.uniform4f(t.uniforms.mAmbient,h.r,h.g,h.b,i);c.uniform4f(t.uniforms.mSpecular,e.r,e.g,e.b,i);c.uniform1f(t.uniforms.mShininess,g);c.uniform1i(t.uniforms.material,2)}else if(g instanceof THREE.MeshLambertMaterial)c.uniform1i(t.uniforms.material,1);else if(g instanceof THREE.MeshBasicMaterial)c.uniform1i(t.uniforms.material,0);else if(g instanceof THREE.MeshCubeMaterial){c.uniform1i(t.uniforms.material,5);w=g.env_map}if(D){f(D,0);c.uniform1i(t.uniforms.tMap, +0);c.uniform1i(t.uniforms.enableMap,1)}else c.uniform1i(t.uniforms.enableMap,0);if(w){d(w,1);c.uniform1i(t.uniforms.tCube,1);c.uniform1i(t.uniforms.enableCubeMap,1)}else c.uniform1i(t.uniforms.enableCubeMap,0);i=t.attributes;c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.vertexAttribPointer(i.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.vertexAttribPointer(i.normal,3,c.FLOAT,false,0,0);if(i.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLTangentBuffer); +c.vertexAttribPointer(i.tangent,4,c.FLOAT,false,0,0)}if(i.uv>=0)if(q.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.enableVertexAttribArray(i.uv);c.vertexAttribPointer(i.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(i.uv);if(s){c.lineWidth(p);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);c.drawElements(c.LINES,q.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,q.__webGLFaceCount,c.UNSIGNED_SHORT, +0)}};this.renderPass=function(e,l,g,q,h,i){var s,p,D,w,I;D=0;for(w=g.material.length;D=0;g--){q=e.__webGLObjects[g].object;l==q&&e.__webGLObjects.splice(g,1)}};this.setupMatrices=function(e,l){e.autoUpdateMatrix&&e.updateMatrix();x.multiply(l.matrix,e.matrix);H.set(l.matrix.flatten());G.set(x.flatten());J.set(l.projectionMatrix.flatten());z=THREE.Matrix4.makeInvert3x3(x).transpose();L.set(z.m);M.set(e.matrix.flatten())};this.loadMatrices= +function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,H);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,G);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,J);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,L);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,M)};this.loadCamera=function(e,l){c.uniform3f(e.uniforms.cameraPosition,l.position.x,l.position.y,l.position.z)};this.setBlending=function(e){switch(e){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(e,l){if(e){!l||l=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(e=="back")c.cullFace(c.BACK);else e=="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}; +THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null}; diff --git a/build/ThreeExtras.js b/build/ThreeExtras.js index 7b6c8d57..2bd1f685 100644 --- a/build/ThreeExtras.js +++ b/build/ThreeExtras.js @@ -12,44 +12,47 @@ THREE.Vector4=function(a,b,d,e){this.x=a||0;this.y=b||0;this.z=d||0;this.w=e||1} THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a0&&H>0&&n+H<1}var d,e,g,j,l,f,q,c,t,D, -r,u=a.geometry,v=u.vertices,w=[];d=0;for(e=u.faces.length;d= -0&&Math.min(g,q.getBottom())-Math.max(d,q.getTop())>=0};this.empty=function(){f=true;g=e=d=b=0;a()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+g+", width: "+j+", height: "+l+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a0&&G>0&&o+G<1}var d,e,g,j,l,f,p,c,t,C, +r,u=a.geometry,v=u.vertices,w=[];d=0;for(e=u.faces.length;d= +0&&Math.min(g,p.getBottom())-Math.max(d,p.getTop())>=0};this.empty=function(){f=true;g=e=d=b=0;a()};this.isEmpty=function(){return f};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+g+", width: "+j+", height: "+l+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; THREE.Matrix4=function(){}; THREE.Matrix4.prototype={n11:1,n12:0,n13:0,n14:0,n21:0,n22:1,n23:0,n24:0,n31:0,n32:0,n33:1,n34:0,n41:0,n42:0,n43:0,n44:1,identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=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},lookAt:function(a,b,d){var e=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(d,j).normalize();g.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x;this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,g=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)*g;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*g;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*g;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,g=a.n13,j=a.n14,l=a.n21,f=a.n22,q=a.n23,c=a.n24,t=a.n31,D=a.n32,r=a.n33,u=a.n34,v=a.n41,w=a.n42,H=a.n43,I=a.n44,z=b.n11,m=b.n12,h=b.n13,n=b.n14,i=b.n21,y=b.n22,k=b.n23,o=b.n24,B=b.n31,A=b.n32,P=b.n33,J=b.n34,Q=b.n41,T=b.n42,E=b.n43, -U=b.n44;this.n11=d*z+e*i+g*B+j*Q;this.n12=d*m+e*y+g*A+j*T;this.n13=d*h+e*k+g*P+j*E;this.n14=d*n+e*o+g*J+j*U;this.n21=l*z+f*i+q*B+c*Q;this.n22=l*m+f*y+q*A+c*T;this.n23=l*h+f*k+q*P+c*E;this.n24=l*n+f*o+q*J+c*U;this.n31=t*z+D*i+r*B+u*Q;this.n32=t*m+D*y+r*A+u*T;this.n33=t*h+D*k+r*P+u*E;this.n34=t*n+D*o+r*J+u*U;this.n41=v*z+w*i+H*B+I*Q;this.n42=v*m+w*y+H*A+I*T;this.n43=v*h+w*k+H*P+I*E;this.n44=v*n+w*o+H*J+I*U},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,j=this.n21,l=this.n22, -f=this.n23,q=this.n24,c=this.n31,t=this.n32,D=this.n33,r=this.n34,u=this.n41,v=this.n42,w=this.n43,H=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+g*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+g*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+g*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+g*a.n44;this.n21=j*a.n11+l*a.n21+f*a.n31+q*a.n41;this.n22=j*a.n12+l*a.n22+f*a.n32+q*a.n42;this.n23=j*a.n13+l*a.n23+f*a.n33+q*a.n43;this.n24=j*a.n14+l*a.n24+f*a.n34+q*a.n44;this.n31=c*a.n11+t*a.n21+D*a.n31+r*a.n41;this.n32=c*a.n12+t*a.n22+ -D*a.n32+r*a.n42;this.n33=c*a.n13+t*a.n23+D*a.n33+r*a.n43;this.n34=c*a.n14+t*a.n24+D*a.n34+r*a.n44;this.n41=u*a.n11+v*a.n21+w*a.n31+H*a.n41;this.n42=u*a.n12+v*a.n22+w*a.n32+H*a.n42;this.n43=u*a.n13+v*a.n23+w*a.n33+H*a.n43;this.n44=u*a.n14+v*a.n24+w*a.n34+H*a.n44},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},determinant:function(){return this.n14* +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,g=a.n13,j=a.n14,l=a.n21,f=a.n22,p=a.n23,c=a.n24,t=a.n31,C=a.n32,r=a.n33,u=a.n34,v=a.n41,w=a.n42,G=a.n43,H=a.n44,A=b.n11,m=b.n12,h=b.n13,o=b.n14,i=b.n21,x=b.n22,k=b.n23,n=b.n24,B=b.n31,y=b.n32,L=b.n33,F=b.n34,O=b.n41,V=b.n42,E=b.n43, +S=b.n44;this.n11=d*A+e*i+g*B+j*O;this.n12=d*m+e*x+g*y+j*V;this.n13=d*h+e*k+g*L+j*E;this.n14=d*o+e*n+g*F+j*S;this.n21=l*A+f*i+p*B+c*O;this.n22=l*m+f*x+p*y+c*V;this.n23=l*h+f*k+p*L+c*E;this.n24=l*o+f*n+p*F+c*S;this.n31=t*A+C*i+r*B+u*O;this.n32=t*m+C*x+r*y+u*V;this.n33=t*h+C*k+r*L+u*E;this.n34=t*o+C*n+r*F+u*S;this.n41=v*A+w*i+G*B+H*O;this.n42=v*m+w*x+G*y+H*V;this.n43=v*h+w*k+G*L+H*E;this.n44=v*o+w*n+G*F+H*S},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,j=this.n21,l=this.n22, +f=this.n23,p=this.n24,c=this.n31,t=this.n32,C=this.n33,r=this.n34,u=this.n41,v=this.n42,w=this.n43,G=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+g*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+g*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+g*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+g*a.n44;this.n21=j*a.n11+l*a.n21+f*a.n31+p*a.n41;this.n22=j*a.n12+l*a.n22+f*a.n32+p*a.n42;this.n23=j*a.n13+l*a.n23+f*a.n33+p*a.n43;this.n24=j*a.n14+l*a.n24+f*a.n34+p*a.n44;this.n31=c*a.n11+t*a.n21+C*a.n31+r*a.n41;this.n32=c*a.n12+t*a.n22+ +C*a.n32+r*a.n42;this.n33=c*a.n13+t*a.n23+C*a.n33+r*a.n43;this.n34=c*a.n14+t*a.n24+C*a.n34+r*a.n44;this.n41=u*a.n11+v*a.n21+w*a.n31+G*a.n41;this.n42=u*a.n12+v*a.n22+w*a.n32+G*a.n42;this.n43=u*a.n13+v*a.n23+w*a.n33+G*a.n43;this.n44=u*a.n14+v*a.n24+w*a.n34+G*a.n44},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},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 g=b[d];b[d]=b[e];b[e]=g}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,this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]}, toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=d;return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=d;return e}; THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),g=Math.sin(b),j=1-e,l=a.x,f=a.y,q=a.z;d.n11=j*l*l+e;d.n12=j*l*f-g*q;d.n13=j*l*q+g*f;d.n21=j*l*f+g*q;d.n22=j*f*f+e;d.n23=j*f*q-g*l;d.n31=j*l*q-g*f;d.n32=j*f*q+g*l;d.n33=j*q*q+e;return d}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),g=Math.sin(b),j=1-e,l=a.x,f=a.y,p=a.z;d.n11=j*l*l+e;d.n12=j*l*f-g*p;d.n13=j*l*p+g*f;d.n21=j*l*f+g*p;d.n22=j*f*f+e;d.n23=j*f*p-g*l;d.n31=j*l*p-g*f;d.n32=j*f*p+g*l;d.n33=j*p*p+e;return d}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],l=b[10]*b[0]-b[2]*b[8],f=-b[6]*b[0]+b[2]*b[4],q=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],t=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*j+b[2]*q;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*l;a.m[5]=b*f;a.m[6]=b*q;a.m[7]=b*c;a.m[8]=b*t;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,e,g,j){var l,f,q;l=new THREE.Matrix4;f=2*g/(b-a);q=2*g/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(j+g)/(j-g);g=-2*j*g/(j-g);l.n11=f;l.n12=0;l.n13=a;l.n14=0;l.n21=0;l.n22=q;l.n23=d;l.n24=0;l.n31=0;l.n32=0;l.n33=e;l.n34=g;l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,b,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,d,e)}; -THREE.Matrix4.makeOrtho=function(a,b,d,e,g,j){var l,f,q,c;l=new THREE.Matrix4;f=b-a;q=d-e;c=j-g;a=(b+a)/f;d=(d+e)/q;g=(j+g)/c;l.n11=2/f;l.n12=0;l.n13=0;l.n14=-a;l.n21=0;l.n22=2/q;l.n23=0;l.n24=-d;l.n31=0;l.n32=0;l.n33=-2/c;l.n34=-g;l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l}; -THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],l=b[10]*b[0]-b[2]*b[8],f=-b[6]*b[0]+b[2]*b[4],p=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],t=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*j+b[2]*p;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*l;a.m[5]=b*f;a.m[6]=b*p;a.m[7]=b*c;a.m[8]=b*t;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,e,g,j){var l,f,p;l=new THREE.Matrix4;f=2*g/(b-a);p=2*g/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(j+g)/(j-g);g=-2*j*g/(j-g);l.n11=f;l.n12=0;l.n13=a;l.n14=0;l.n21=0;l.n22=p;l.n23=d;l.n24=0;l.n31=0;l.n32=0;l.n33=e;l.n34=g;l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,b,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,d,e)}; +THREE.Matrix4.makeOrtho=function(a,b,d,e,g,j){var l,f,p,c;l=new THREE.Matrix4;f=b-a;p=d-e;c=j-g;a=(b+a)/f;d=(d+e)/p;g=(j+g)/c;l.n11=2/f;l.n12=0;l.n13=0;l.n14=-a;l.n21=0;l.n22=2/p;l.n23=0;l.n24=-d;l.n31=0;l.n32=0;l.n33=-2/c;l.n34=-g;l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l}; +THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; THREE.Face3=function(a,b,d,e,g){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.material=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; THREE.Face4=function(a,b,d,e,g,j){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.material=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; -THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={}}; +THREE.UV.prototype={copy:function(a){this.u=a.u;this.v=a.v},toString:function(){return"THREE.UV ("+this.u+", "+this.v+")"}};THREE.Geometry=function(){this.vertices=[];this.faces=[];this.uvs=[];this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a0){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;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y; -if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(t){var D=[];b=0;for(d=t.length;b65535){c[f].counter+=1;q=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[q]==undefined)this.geometryChunks[q]={faces:[],material:l,vertices:0}}this.geometryChunks[q].faces.push(e);this.geometryChunks[q].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeNormals:function(a){var b,d,e,g,j,l,f=new THREE.Vector3,p=new THREE.Vector3;e=0;for(g=this.vertices.length;e0){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;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.ythis.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},sortFacesByMaterial:function(){function a(t){var C=[];b=0;for(d=t.length;b65535){c[f].counter+=1;p=c[f].hash+"_"+c[f].counter;if(this.geometryChunks[p]==undefined)this.geometryChunks[p]={faces:[],material:l,vertices:0}}this.geometryChunks[p].faces.push(e);this.geometryChunks[p].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; THREE.Camera=function(a,b,d,e){this.position=new THREE.Vector3(0,0,0);this.target={position:new THREE.Vector3(0,0,0)};this.up=new THREE.Vector3(0,1,0);this.matrix=new THREE.Matrix4;this.projectionMatrix=THREE.Matrix4.makePerspective(a,b,d,e);this.autoUpdateMatrix=true;this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.toString=function(){return"THREE.Camera ( "+this.position+", "+this.target.position+" )"}};THREE.Light=function(a){this.color=new THREE.Color(a)}; THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; @@ -86,127 +89,132 @@ THREE.Texture=function(a,b,d,e,g,j){this.image=a;this.mapping=b!==undefined?b:ne this.min_filter+"
)"}};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(z,m){var h=0,n=1,i=z.z+z.w,y=m.z+m.w,k=-z.z+z.w,o=-m.z+m.w;if(i>=0&&y>=0&&k>=0&&o>=0)return true;else if(i<0&&y<0||k<0&&o<0)return false;else{if(i<0)h=Math.max(h,i/(i-y));else if(y<0)n=Math.min(n,i/(i-y));if(k<0)h=Math.max(h,k/(k-o));else if(o<0)n=Math.min(n,k/(k-o));if(n0&&K.z<1}U=A.geometry.faces;i=0;for(y=U.length;i0&&r.z<1){c=D[t]=D[t]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=A.rotation.z;c.scale.x=A.scale.x*Math.abs(c.x-(r.x+m.projectionMatrix.n11)/(r.w+m.projectionMatrix.n14));c.scale.y=A.scale.y*Math.abs(c.y-(r.y+m.projectionMatrix.n22)/(r.w+m.projectionMatrix.n24));c.material=A.material;b.push(c);t++}}}b.sort(function(Y,R){return R.z-Y.z});return b};this.unprojectVector=function(z,m){var h=new THREE.Matrix4; -h.multiply(THREE.Matrix4.makeInvert(m.matrix),THREE.Matrix4.makeInvert(m.projectionMatrix));h.multiplyVector3(z);return z}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,j;this.domElement=document.createElement("div");this.setSize=function(l,f){d=l;e=f;g=d/2;j=e/2};this.render=function(l,f){var q,c,t,D,r,u,v,w;a=b.projectScene(l,f);q=0;for(c=a.length;q0){F.r+=ca.r*Z;F.g+=ca.g*Z;F.b+=ca.b*Z}}else if(Z instanceof THREE.PointLight){$.sub(Z.position,X);$.normalize();Z=S.dot($)*ea;if(Z>0){F.r+=ca.r*Z;F.g+=ca.g*Z;F.b+=ca.b*Z}}}}function Na(C,X,S){if(S.opacity!=0){Ea(S.opacity);za(S.blending);var F,O,Z,ca,ea,fa;if(S instanceof THREE.ParticleBasicMaterial){if(S.map){ca=S.map;ea=ca.width>>1;fa=ca.height>>1;O=X.scale.x*j;Z=X.scale.y*l;S=O*ea;F=Z*fa;p.set(C.x-S,C.y-F,C.x+S, -C.y+F);if(M.instersects(p)){f.save();f.translate(C.x,C.y);f.rotate(-X.rotation);f.scale(O,-Z);f.translate(-ea,-fa);f.drawImage(ca,0,0);f.restore()}}}else if(S instanceof THREE.ParticleCircleMaterial){if(s){x.r=G.r+V.r+ba.r;x.g=G.g+V.g+ba.g;x.b=G.b+V.b+ba.b;k.r=S.color.r*x.r;k.g=S.color.g*x.g;k.b=S.color.b*x.b;k.updateStyleString()}else k.__styleString=S.color.__styleString;S=X.scale.x*j;F=X.scale.y*l;p.set(C.x-S,C.y-F,C.x+S,C.y+F);if(M.instersects(p)){O=k.__styleString;if(D!=O)f.fillStyle=D=O;f.save(); -f.translate(C.x,C.y);f.rotate(-X.rotation);f.scale(S,F);f.beginPath();f.arc(0,0,1,0,ga,true);f.closePath();f.fill();f.restore()}}}}function Oa(C,X,S,F){if(F.opacity!=0){Ea(F.opacity);za(F.blending);f.beginPath();f.moveTo(C.positionScreen.x,C.positionScreen.y);f.lineTo(X.positionScreen.x,X.positionScreen.y);f.closePath();if(F instanceof THREE.LineBasicMaterial){k.__styleString=F.color.__styleString;C=F.linewidth;if(r!=C)f.lineWidth=r=C;C=k.__styleString;if(t!=C)f.strokeStyle=t=C;f.stroke();p.inflate(F.linewidth* -2)}}}function Ia(C,X,S,F,O,Z){if(O.opacity!=0){Ea(O.opacity);za(O.blending);z=C.positionScreen.x;m=C.positionScreen.y;h=X.positionScreen.x;n=X.positionScreen.y;i=S.positionScreen.x;y=S.positionScreen.y;f.beginPath();f.moveTo(z,m);f.lineTo(h,n);f.lineTo(i,y);f.lineTo(z,m);f.closePath();if(O instanceof THREE.MeshBasicMaterial)if(O.map)O.map.image.loaded&&O.map.mapping instanceof THREE.UVMapping&&ra(z,m,h,n,i,y,O.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);else if(O.env_map){if(O.env_map.image.loaded)if(O.env_map.mapping instanceof -THREE.SphericalReflectionMapping){C=xa.matrix;$.copy(F.vertexNormalsWorld[0]);U=($.x*C.n11+$.y*C.n12+$.z*C.n13)*0.5+0.5;K=-($.x*C.n21+$.y*C.n22+$.z*C.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[1]);L=($.x*C.n11+$.y*C.n12+$.z*C.n13)*0.5+0.5;N=-($.x*C.n21+$.y*C.n22+$.z*C.n23)*0.5+0.5;$.copy(F.vertexNormalsWorld[2]);Y=($.x*C.n11+$.y*C.n12+$.z*C.n13)*0.5+0.5;R=-($.x*C.n21+$.y*C.n22+$.z*C.n23)*0.5+0.5;ra(z,m,h,n,i,y,O.env_map.image,U,K,L,N,Y,R)}}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth): -Ba(O.color.__styleString);else if(O instanceof THREE.MeshLambertMaterial){if(O.map&&!O.wireframe){O.map.mapping instanceof THREE.UVMapping&&ra(z,m,h,n,i,y,O.map.image,F.uvs[0].u,F.uvs[0].v,F.uvs[1].u,F.uvs[1].v,F.uvs[2].u,F.uvs[2].v);za(THREE.SubtractiveBlending)}if(s)if(!O.wireframe&&O.shading==THREE.SmoothShading&&F.vertexNormalsWorld.length==3){o.r=B.r=A.r=G.r;o.g=B.g=A.g=G.g;o.b=B.b=A.b=G.b;ya(Z,F.v1.positionWorld,F.vertexNormalsWorld[0],o);ya(Z,F.v2.positionWorld,F.vertexNormalsWorld[1],B);ya(Z, -F.v3.positionWorld,F.vertexNormalsWorld[2],A);P.r=(B.r+A.r)*0.5;P.g=(B.g+A.g)*0.5;P.b=(B.b+A.b)*0.5;E=Ja(o,B,A,P);ra(z,m,h,n,i,y,E,0,0,1,0,0,1)}else{x.r=G.r;x.g=G.g;x.b=G.b;ya(Z,F.centroidWorld,F.normalWorld,x);k.r=O.color.r*x.r;k.g=O.color.g*x.g;k.b=O.color.b*x.b;k.updateStyleString();O.wireframe?Aa(k.__styleString,O.wireframe_linewidth):Ba(k.__styleString)}else O.wireframe?Aa(O.color.__styleString,O.wireframe_linewidth):Ba(O.color.__styleString)}else if(O instanceof THREE.MeshDepthMaterial){J=O.__2near; -Q=O.__farPlusNear;T=O.__farMinusNear;o.r=o.g=o.b=1-J/(Q-C.positionScreen.z*T);B.r=B.g=B.b=1-J/(Q-X.positionScreen.z*T);A.r=A.g=A.b=1-J/(Q-S.positionScreen.z*T);P.r=(B.r+A.r)*0.5;P.g=(B.g+A.g)*0.5;P.b=(B.b+A.b)*0.5;E=Ja(o,B,A,P);ra(z,m,h,n,i,y,E,0,0,1,0,0,1)}else if(O instanceof THREE.MeshNormalMaterial){k.r=Fa(F.normalWorld.x);k.g=Fa(F.normalWorld.y);k.b=Fa(F.normalWorld.z);k.updateStyleString();O.wireframe?Aa(k.__styleString,O.wireframe_linewidth):Ba(k.__styleString)}}}function Aa(C,X){if(t!=C)f.strokeStyle= -t=C;if(r!=X)f.lineWidth=r=X;f.stroke();p.inflate(X*2)}function Ba(C){if(D!=C)f.fillStyle=D=C;f.fill()}function ra(C,X,S,F,O,Z,ca,ea,fa,sa,la,ta,ua){var ma,ja;ma=ca.width-1;ja=ca.height-1;ea*=ma;fa*=ja;sa*=ma;la*=ja;ta*=ma;ua*=ja;S-=C;F-=X;O-=C;Z-=X;sa-=ea;la-=fa;ta-=ea;ua-=fa;ja=1/(sa*ua-ta*la);ma=(ua*S-la*O)*ja;la=(ua*F-la*Z)*ja;S=(sa*O-ta*S)*ja;F=(sa*Z-ta*F)*ja;C=C-ma*ea-S*fa;X=X-la*ea-F*fa;f.save();f.transform(ma,la,S,F,C,X);f.clip();f.drawImage(ca,0,0);f.restore()}function Ea(C){if(q!=C)f.globalAlpha= -q=C}function za(C){if(c!=C){switch(C){case THREE.NormalBlending:f.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:f.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:f.globalCompositeOperation="darker"}c=C}}function Ja(C,X,S,F){da[0]=v(0,u(255,~~(C.r*255)));da[1]=v(0,u(255,~~(C.g*255)));da[2]=v(0,u(255,~~(C.b*255)));da[4]=v(0,u(255,~~(X.r*255)));da[5]=v(0,u(255,~~(X.g*255)));da[6]=v(0,u(255,~~(X.b*255)));da[8]=v(0,u(255,~~(S.r*255)));da[9]=v(0,u(255, -~~(S.g*255)));da[10]=v(0,u(255,~~(S.b*255)));da[12]=v(0,u(255,~~(F.r*255)));da[13]=v(0,u(255,~~(F.g*255)));da[14]=v(0,u(255,~~(F.b*255)));pa.putImageData(Da,0,0);wa.drawImage(ka,0,0);return qa}function Fa(C){return C<0?u((1+C)*0.5,0.5):0.5+u(C*0.5,0.5)}function Ga(C,X){var S=X.x-C.x,F=X.y-C.y,O=1/Math.sqrt(S*S+F*F);S*=O;F*=O;X.x+=S;X.y+=F;C.x-=S;C.y-=F}var Ca,Ka,aa,ha,oa,Ha,La,va;f.setTransform(1,0,0,-1,j,l);this.autoClear&&this.clear();a=b.projectScene(ia,xa);(s=ia.lights.length>0)&&Ma(ia);Ca=0; -for(Ka=a.length;Ca0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}else if(M instanceof THREE.PointLight){o.sub(M.position,L.centroidWorld);o.normalize();W=L.normalWorld.dot(o)*M.intensity;if(W>0){N.r+=M.color.r*W;N.g+=M.color.g*W;N.b+=M.color.b*W}}}}function b(K,L,N,Y,R,M){J=e(Q++);J.setAttribute("d","M "+K.positionScreen.x+ -" "+K.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+"z");if(R instanceof THREE.MeshBasicMaterial)m.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshLambertMaterial)if(z){h.r=n.r;h.g=n.g;h.b=n.b;a(M,Y,h);m.r=R.color.r*h.r;m.g=R.color.g*h.g;m.b=R.color.b*h.b;m.updateStyleString()}else m.__styleString=R.color.__styleString;else if(R instanceof THREE.MeshDepthMaterial){k=1-R.__2near/(R.__farPlusNear-Y.z*R.__farMinusNear); -m.setRGB(k,k,k)}else R instanceof THREE.MeshNormalMaterial&&m.setRGB(g(Y.normalWorld.x),g(Y.normalWorld.y),g(Y.normalWorld.z));R.wireframe?J.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+R.wireframe_linewidth+"; stroke-opacity: "+R.opacity+"; stroke-linecap: "+R.wireframe_linecap+"; stroke-linejoin: "+R.wireframe_linejoin):J.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+R.opacity);f.appendChild(J)}function d(K,L,N,Y,R,M,W){J=e(Q++);J.setAttribute("d", -"M "+K.positionScreen.x+" "+K.positionScreen.y+" L "+L.positionScreen.x+" "+L.positionScreen.y+" L "+N.positionScreen.x+","+N.positionScreen.y+" L "+Y.positionScreen.x+","+Y.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)m.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(z){h.r=n.r;h.g=n.g;h.b=n.b;a(W,R,h);m.r=M.color.r*h.r;m.g=M.color.g*h.g;m.b=M.color.b*h.b;m.updateStyleString()}else m.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){k= -1-M.__2near/(M.__farPlusNear-R.z*M.__farMinusNear);m.setRGB(k,k,k)}else M instanceof THREE.MeshNormalMaterial&&m.setRGB(g(R.normalWorld.x),g(R.normalWorld.y),g(R.normalWorld.z));M.wireframe?J.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):J.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+M.opacity);f.appendChild(J)} -function e(K){if(B[K]==null){B[K]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&B[K].setAttribute("shape-rendering","crispEdges");return B[K]}return B[K]}function g(K){return K<0?Math.min((1+K)*0.5,0.5):0.5+Math.min(K*0.5,0.5)}var j=null,l=new THREE.Projector,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),q,c,t,D,r,u,v,w,H=new THREE.Rectangle,I=new THREE.Rectangle,z=false,m=new THREE.Color(16777215),h=new THREE.Color(16777215),n=new THREE.Color(0),i=new THREE.Color(0), -y=new THREE.Color(0),k,o=new THREE.Vector3,B=[],A=[],P=[],J,Q,T,E,U=1;this.domElement=f;this.autoClear=true;this.setQuality=function(K){switch(K){case "high":U=1;break;case "low":U=0}};this.setSize=function(K,L){q=K;c=L;t=q/2;D=c/2;f.setAttribute("viewBox",-t+" "+-D+" "+q+" "+c);f.setAttribute("width",q);f.setAttribute("height",c);H.set(-t,-D,t,D)};this.clear=function(){for(;f.childNodes.length>0;)f.removeChild(f.childNodes[0])};this.render=function(K,L){var N,Y,R,M,W,p,s,x;this.autoClear&&this.clear(); -j=l.projectScene(K,L);E=T=Q=0;if(z=K.lights.length>0){s=K.lights;n.setRGB(0,0,0);i.setRGB(0,0,0);y.setRGB(0,0,0);N=0;for(Y=s.length;N=0&&c.enableVertexAttribArray(h.attributes[k])}}function l(h,n){var i;if(h=="fragment")i=c.createShader(c.FRAGMENT_SHADER);else if(h=="vertex")i=c.createShader(c.VERTEX_SHADER);c.shaderSource(i,n);c.compileShader(i);if(!c.getShaderParameter(i, -c.COMPILE_STATUS)){alert(c.getShaderInfoLog(i));return null}return i}function f(h){switch(h){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 q=document.createElement("canvas"),c,t,D,r=new THREE.Matrix4,u,v=new Float32Array(16),w=new Float32Array(16),H=new Float32Array(16),I=new Float32Array(9),z=new Float32Array(16);a=function(h,n){if(h){var i,y,k,o=pointLights=maxDirLights=maxPointLights=0;i=0;for(y=h.lights.length;i= 0.0 )": -"",n?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",n?"pointDiffuse += mColor * pointDiffuseWeight;":"",n?"pointSpecular += mSpecular * pointSpecularWeight;":"",n?"}":"",h?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"vec3 dirVector = normalize( lDirection.xyz );":"",h?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": -"",h?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",h?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",h?"float dirSpecularWeight = 0.0;":"",h?"if ( dirDotNormalHalf >= 0.0 )":"",h?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",h?"dirDiffuse += mColor * dirDiffuseWeight;":"",h?"dirSpecular += mSpecular * dirSpecularWeight;":"",h?"}":"","vec4 totalLight = mAmbient;",h?"totalLight += dirDiffuse + dirSpecular;":"",n?"totalLight += pointDiffuse + pointSpecular;": +THREE.Projector=function(){function a(A,m){var h=0,o=1,i=A.z+A.w,x=m.z+m.w,k=-A.z+A.w,n=-m.z+m.w;if(i>=0&&x>=0&&k>=0&&n>=0)return true;else if(i<0&&x<0||k<0&&n<0)return false;else{if(i<0)h=Math.max(h,i/(i-x));else if(x<0)o=Math.min(o,i/(i-x));if(k<0)h=Math.max(h,k/(k-n));else if(n<0)o=Math.min(o,k/(k-n));if(o0&&N.z<1}S=y.geometry.faces;i=0;for(x=S.length;i0&&r.z<1){c=C[t]=C[t]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=y.rotation.z;c.scale.x=y.scale.x*Math.abs(c.x-(r.x+m.projectionMatrix.n11)/(r.w+m.projectionMatrix.n14));c.scale.y=y.scale.y*Math.abs(c.y-(r.y+m.projectionMatrix.n22)/(r.w+m.projectionMatrix.n24));c.material=y.material;b.push(c);t++}}}b.sort(function(Q,K){return K.z-Q.z});return b};this.unprojectVector=function(A,m){var h=new THREE.Matrix4; +h.multiply(THREE.Matrix4.makeInvert(m.matrix),THREE.Matrix4.makeInvert(m.projectionMatrix));h.multiplyVector3(A);return A}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,g,j;this.domElement=document.createElement("div");this.setSize=function(l,f){d=l;e=f;g=d/2;j=e/2};this.render=function(l,f){var p,c,t,C,r,u,v,w;a=b.projectScene(l,f);p=0;for(c=a.length;p0){I.r+=ca.r*Z;I.g+=ca.g*Z;I.b+=ca.b*Z}}else if(Z instanceof THREE.PointLight){$.sub(Z.position,Y);$.normalize();Z=R.dot($)*ea;if(Z>0){I.r+=ca.r*Z;I.g+=ca.g*Z;I.b+=ca.b*Z}}}}function Na(D,Y,R){if(R.opacity!=0){Ea(R.opacity);za(R.blending);var I,P,Z,ca,ea,fa;if(R instanceof THREE.ParticleBasicMaterial){if(R.map){ca=R.map;ea=ca.width>>1;fa=ca.height>>1;P=Y.scale.x*j;Z=Y.scale.y*l;R=P*ea;I=Z*fa;q.set(D.x-R,D.y-I,D.x+R, +D.y+I);if(M.instersects(q)){f.save();f.translate(D.x,D.y);f.rotate(-Y.rotation);f.scale(P,-Z);f.translate(-ea,-fa);f.drawImage(ca,0,0);f.restore()}}}else if(R instanceof THREE.ParticleCircleMaterial){if(s){z.r=J.r+W.r+ba.r;z.g=J.g+W.g+ba.g;z.b=J.b+W.b+ba.b;k.r=R.color.r*z.r;k.g=R.color.g*z.g;k.b=R.color.b*z.b;k.updateStyleString()}else k.__styleString=R.color.__styleString;R=Y.scale.x*j;I=Y.scale.y*l;q.set(D.x-R,D.y-I,D.x+R,D.y+I);if(M.instersects(q)){P=k.__styleString;if(C!=P)f.fillStyle=C=P;f.save(); +f.translate(D.x,D.y);f.rotate(-Y.rotation);f.scale(R,I);f.beginPath();f.arc(0,0,1,0,ga,true);f.closePath();f.fill();f.restore()}}}}function Oa(D,Y,R,I){if(I.opacity!=0){Ea(I.opacity);za(I.blending);f.beginPath();f.moveTo(D.positionScreen.x,D.positionScreen.y);f.lineTo(Y.positionScreen.x,Y.positionScreen.y);f.closePath();if(I instanceof THREE.LineBasicMaterial){k.__styleString=I.color.__styleString;D=I.linewidth;if(r!=D)f.lineWidth=r=D;D=k.__styleString;if(t!=D)f.strokeStyle=t=D;f.stroke();q.inflate(I.linewidth* +2)}}}function Ia(D,Y,R,I,P,Z){if(P.opacity!=0){Ea(P.opacity);za(P.blending);A=D.positionScreen.x;m=D.positionScreen.y;h=Y.positionScreen.x;o=Y.positionScreen.y;i=R.positionScreen.x;x=R.positionScreen.y;f.beginPath();f.moveTo(A,m);f.lineTo(h,o);f.lineTo(i,x);f.lineTo(A,m);f.closePath();if(P instanceof THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&ra(A,m,h,o,i,x,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){D=xa.matrix;$.copy(I.vertexNormalsWorld[0]);S=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;N=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;$.copy(I.vertexNormalsWorld[1]);T=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;U=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;$.copy(I.vertexNormalsWorld[2]);Q=($.x*D.n11+$.y*D.n12+$.z*D.n13)*0.5+0.5;K=-($.x*D.n21+$.y*D.n22+$.z*D.n23)*0.5+0.5;ra(A,m,h,o,i,x,P.env_map.image,S,N,T,U,Q,K)}}else P.wireframe?Aa(P.color.__styleString,P.wireframe_linewidth): +Ba(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&ra(A,m,h,o,i,x,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);za(THREE.SubtractiveBlending)}if(s)if(!P.wireframe&&P.shading==THREE.SmoothShading&&I.vertexNormalsWorld.length==3){n.r=B.r=y.r=J.r;n.g=B.g=y.g=J.g;n.b=B.b=y.b=J.b;ya(Z,I.v1.positionWorld,I.vertexNormalsWorld[0],n);ya(Z,I.v2.positionWorld,I.vertexNormalsWorld[1],B);ya(Z, +I.v3.positionWorld,I.vertexNormalsWorld[2],y);L.r=(B.r+y.r)*0.5;L.g=(B.g+y.g)*0.5;L.b=(B.b+y.b)*0.5;E=Ja(n,B,y,L);ra(A,m,h,o,i,x,E,0,0,1,0,0,1)}else{z.r=J.r;z.g=J.g;z.b=J.b;ya(Z,I.centroidWorld,I.normalWorld,z);k.r=P.color.r*z.r;k.g=P.color.g*z.g;k.b=P.color.b*z.b;k.updateStyleString();P.wireframe?Aa(k.__styleString,P.wireframe_linewidth):Ba(k.__styleString)}else P.wireframe?Aa(P.color.__styleString,P.wireframe_linewidth):Ba(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){F=P.__2near; +O=P.__farPlusNear;V=P.__farMinusNear;n.r=n.g=n.b=1-F/(O-D.positionScreen.z*V);B.r=B.g=B.b=1-F/(O-Y.positionScreen.z*V);y.r=y.g=y.b=1-F/(O-R.positionScreen.z*V);L.r=(B.r+y.r)*0.5;L.g=(B.g+y.g)*0.5;L.b=(B.b+y.b)*0.5;E=Ja(n,B,y,L);ra(A,m,h,o,i,x,E,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){k.r=Fa(I.normalWorld.x);k.g=Fa(I.normalWorld.y);k.b=Fa(I.normalWorld.z);k.updateStyleString();P.wireframe?Aa(k.__styleString,P.wireframe_linewidth):Ba(k.__styleString)}}}function Aa(D,Y){if(t!=D)f.strokeStyle= +t=D;if(r!=Y)f.lineWidth=r=Y;f.stroke();q.inflate(Y*2)}function Ba(D){if(C!=D)f.fillStyle=C=D;f.fill()}function ra(D,Y,R,I,P,Z,ca,ea,fa,sa,la,ta,ua){var ma,ja;ma=ca.width-1;ja=ca.height-1;ea*=ma;fa*=ja;sa*=ma;la*=ja;ta*=ma;ua*=ja;R-=D;I-=Y;P-=D;Z-=Y;sa-=ea;la-=fa;ta-=ea;ua-=fa;ja=1/(sa*ua-ta*la);ma=(ua*R-la*P)*ja;la=(ua*I-la*Z)*ja;R=(sa*P-ta*R)*ja;I=(sa*Z-ta*I)*ja;D=D-ma*ea-R*fa;Y=Y-la*ea-I*fa;f.save();f.transform(ma,la,R,I,D,Y);f.clip();f.drawImage(ca,0,0);f.restore()}function Ea(D){if(p!=D)f.globalAlpha= +p=D}function za(D){if(c!=D){switch(D){case THREE.NormalBlending:f.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:f.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:f.globalCompositeOperation="darker"}c=D}}function Ja(D,Y,R,I){da[0]=v(0,u(255,~~(D.r*255)));da[1]=v(0,u(255,~~(D.g*255)));da[2]=v(0,u(255,~~(D.b*255)));da[4]=v(0,u(255,~~(Y.r*255)));da[5]=v(0,u(255,~~(Y.g*255)));da[6]=v(0,u(255,~~(Y.b*255)));da[8]=v(0,u(255,~~(R.r*255)));da[9]=v(0,u(255, +~~(R.g*255)));da[10]=v(0,u(255,~~(R.b*255)));da[12]=v(0,u(255,~~(I.r*255)));da[13]=v(0,u(255,~~(I.g*255)));da[14]=v(0,u(255,~~(I.b*255)));pa.putImageData(Da,0,0);wa.drawImage(ka,0,0);return qa}function Fa(D){return D<0?u((1+D)*0.5,0.5):0.5+u(D*0.5,0.5)}function Ga(D,Y){var R=Y.x-D.x,I=Y.y-D.y,P=1/Math.sqrt(R*R+I*I);R*=P;I*=P;Y.x+=R;Y.y+=I;D.x-=R;D.y-=I}var Ca,Ka,aa,ha,oa,Ha,La,va;f.setTransform(1,0,0,-1,j,l);this.autoClear&&this.clear();a=b.projectScene(ia,xa);(s=ia.lights.length>0)&&Ma(ia);Ca=0; +for(Ka=a.length;Ca0){U.r+=M.color.r*X;U.g+=M.color.g*X;U.b+=M.color.b*X}}else if(M instanceof THREE.PointLight){n.sub(M.position,T.centroidWorld);n.normalize();X=T.normalWorld.dot(n)*M.intensity;if(X>0){U.r+=M.color.r*X;U.g+=M.color.g*X;U.b+=M.color.b*X}}}}function b(N,T,U,Q,K,M){F=e(O++);F.setAttribute("d","M "+N.positionScreen.x+ +" "+N.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+"z");if(K instanceof THREE.MeshBasicMaterial)m.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshLambertMaterial)if(A){h.r=o.r;h.g=o.g;h.b=o.b;a(M,Q,h);m.r=K.color.r*h.r;m.g=K.color.g*h.g;m.b=K.color.b*h.b;m.updateStyleString()}else m.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshDepthMaterial){k=1-K.__2near/(K.__farPlusNear-Q.z*K.__farMinusNear); +m.setRGB(k,k,k)}else K instanceof THREE.MeshNormalMaterial&&m.setRGB(g(Q.normalWorld.x),g(Q.normalWorld.y),g(Q.normalWorld.z));K.wireframe?F.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: "+K.wireframe_linecap+"; stroke-linejoin: "+K.wireframe_linejoin):F.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+K.opacity);f.appendChild(F)}function d(N,T,U,Q,K,M,X){F=e(O++);F.setAttribute("d", +"M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+","+U.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)m.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(A){h.r=o.r;h.g=o.g;h.b=o.b;a(X,K,h);m.r=M.color.r*h.r;m.g=M.color.g*h.g;m.b=M.color.b*h.b;m.updateStyleString()}else m.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){k= +1-M.__2near/(M.__farPlusNear-K.z*M.__farMinusNear);m.setRGB(k,k,k)}else M instanceof THREE.MeshNormalMaterial&&m.setRGB(g(K.normalWorld.x),g(K.normalWorld.y),g(K.normalWorld.z));M.wireframe?F.setAttribute("style","fill: none; stroke: "+m.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):F.setAttribute("style","fill: "+m.__styleString+"; fill-opacity: "+M.opacity);f.appendChild(F)} +function e(N){if(B[N]==null){B[N]=document.createElementNS("http://www.w3.org/2000/svg","path");S==0&&B[N].setAttribute("shape-rendering","crispEdges");return B[N]}return B[N]}function g(N){return N<0?Math.min((1+N)*0.5,0.5):0.5+Math.min(N*0.5,0.5)}var j=null,l=new THREE.Projector,f=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,c,t,C,r,u,v,w,G=new THREE.Rectangle,H=new THREE.Rectangle,A=false,m=new THREE.Color(16777215),h=new THREE.Color(16777215),o=new THREE.Color(0),i=new THREE.Color(0), +x=new THREE.Color(0),k,n=new THREE.Vector3,B=[],y=[],L=[],F,O,V,E,S=1;this.domElement=f;this.autoClear=true;this.setQuality=function(N){switch(N){case "high":S=1;break;case "low":S=0}};this.setSize=function(N,T){p=N;c=T;t=p/2;C=c/2;f.setAttribute("viewBox",-t+" "+-C+" "+p+" "+c);f.setAttribute("width",p);f.setAttribute("height",c);G.set(-t,-C,t,C)};this.clear=function(){for(;f.childNodes.length>0;)f.removeChild(f.childNodes[0])};this.render=function(N,T){var U,Q,K,M,X,q,s,z;this.autoClear&&this.clear(); +j=l.projectScene(N,T);E=V=O=0;if(A=N.lights.length>0){s=N.lights;o.setRGB(0,0,0);i.setRGB(0,0,0);x.setRGB(0,0,0);U=0;for(Q=s.length;U0?"#define VERTEX_TEXTURES":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(i,l("fragment","#ifdef GL_ES\nprecision highp float;\n#endif\nuniform mat4 viewMatrix;\n"+ +h));c.attachShader(i,l("vertex",x+o));c.linkProgram(i);c.getProgramParameter(i,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(i,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");i.uniforms={};i.attributes={};return i}function d(h,o){if(h.image.length==6){if(!h.image.__webGLTextureCube&&!h.image.__cubeMapInitialized&&h.image.loadCount==6){h.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,h.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 i=0;i<6;++i)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+i,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image[i]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);h.image.__cubeMapInitialized=true}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_CUBE_MAP, +h.image.__webGLTextureCube)}}function e(h,o){if(!h.__webGLTexture&&h.image.loaded){h.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,h.__webGLTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,h.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,f(h.wrap_s));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,f(h.wrap_t));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,f(h.mag_filter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,f(h.min_filter));c.generateMipmap(c.TEXTURE_2D); +c.bindTexture(c.TEXTURE_2D,null)}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_2D,h.__webGLTexture)}function g(h,o){var i,x,k;i=0;for(x=o.length;i=0&&c.enableVertexAttribArray(h.attributes[k])}}function l(h,o){var i;if(h=="fragment")i=c.createShader(c.FRAGMENT_SHADER);else if(h=="vertex")i=c.createShader(c.VERTEX_SHADER); +c.shaderSource(i,o);c.compileShader(i);if(!c.getShaderParameter(i,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(i));return null}return i}function f(h){switch(h){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 p=document.createElement("canvas"),c,t,C,r=new THREE.Matrix4,u,v=new Float32Array(16),w=new Float32Array(16),G=new Float32Array(16),H=new Float32Array(9),A=new Float32Array(16);a=function(h,o){if(h){var i,x,k,n=pointLights=maxDirLights=maxPointLights=0;i=0;for(x=h.lights.length;i= 0.0 )": +"",o?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",o?"pointDiffuse += mColor * pointDiffuseWeight;":"",o?"pointSpecular += mSpecular * pointSpecularWeight;":"",o?"}":"",h?"vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );":"",h?"for( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {":"",h?"vec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );":"",h?"vec3 dirVector = normalize( lDirection.xyz );":"",h?"vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );": +"",h?"float dirDotNormalHalf = dot( normal, dirHalfVector );":"",h?"float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );":"",h?"float dirSpecularWeight = 0.0;":"",h?"if ( dirDotNormalHalf >= 0.0 )":"",h?"dirSpecularWeight = pow( dirDotNormalHalf, mShininess );":"",h?"dirDiffuse += mColor * dirDiffuseWeight;":"",h?"dirSpecular += mSpecular * dirSpecularWeight;":"",h?"}":"","vec4 totalLight = mAmbient;",h?"totalLight += dirDiffuse + dirSpecular;":"",o?"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"); -i=b(y,i);c.useProgram(i);g(i,["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"]);h&&g(i,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);n&&g(i,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(i.uniforms.enableMap,0);c.uniform1i(i.uniforms.tMap,0);c.uniform1i(i.uniforms.enableCubeMap,0);c.uniform1i(i.uniforms.tCube,1);c.uniform1i(i.uniforms.mixEnvMap,0);c.uniform1i(i.uniforms.useRefract,0);j(i,["position","normal","uv"]);return i}(a.directional,a.point);this.setSize=function(h,n){q.width=h;q.height=n;c.viewport(0,0,q.width,q.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(h,n){var i,y,k,o,B,A=[], -P=[],J=[];o=[];B=[];c.uniform1i(h.uniforms.enableLighting,n.length);i=0;for(y=n.length;i0){N.__webGLUVBuffer=c.createBuffer(); -c.bindBuffer(c.ARRAY_BUFFER,N.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(K),c.STATIC_DRAW)}N.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(Q),c.STATIC_DRAW);N.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,N.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(T),c.STATIC_DRAW);N.__webGLFaceCount=Q.length;N.__webGLLineCount=T.length}};this.renderBuffer= -function(h,n,i,y){var k,o,B,A,P,J,Q,T,E;if(i instanceof THREE.MeshShaderMaterial){if(!i.program){i.program=b(i.fragment_shader,i.vertex_shader);Q=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in i.uniforms)Q.push(E);g(i.program,Q);j(i.program,["position","normal","uv"])}E=i.program}else E=D;if(E!=t){c.useProgram(E);t=E}E==D&&this.setupLights(E,n);this.loadCamera(E,h);this.loadMatrices(E);if(i instanceof THREE.MeshShaderMaterial){B=i.wireframe; -A=i.wireframe_linewidth;h=E;n=i.uniforms;var U;for(k in n){T=n[k].type;Q=n[k].value;U=h.uniforms[k];if(T=="i")c.uniform1i(U,Q);else if(T=="f")c.uniform1f(U,Q);else if(T=="v3")c.uniform3f(U,Q.x,Q.y,Q.z);else if(T=="c")c.uniform3f(U,Q.r,Q.g,Q.b);else if(T=="t"){c.uniform1i(U,Q);if(T=n[k].texture)T.image instanceof Array&&T.image.length==6?d(T,Q):e(T,Q)}}}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){k=i.color;o=i.opacity;B=i.wireframe; -A=i.wireframe_linewidth;P=i.map;J=i.env_map;n=i.combine==THREE.MixOperation;h=i.reflectivity;T=i.env_map&&i.env_map.mapping instanceof THREE.CubeRefractionMapping;Q=i.refraction_ratio;c.uniform4f(E.uniforms.mColor,k.r*o,k.g*o,k.b*o,o);c.uniform1i(E.uniforms.mixEnvMap,n);c.uniform1f(E.uniforms.mReflectivity,h);c.uniform1i(E.uniforms.useRefract,T);c.uniform1f(E.uniforms.mRefractionRatio,Q)}if(i instanceof THREE.MeshNormalMaterial){o=i.opacity;c.uniform1f(E.uniforms.mOpacity,o);c.uniform1i(E.uniforms.material, -4)}else if(i instanceof THREE.MeshDepthMaterial){o=i.opacity;B=i.wireframe;A=i.wireframe_linewidth;c.uniform1f(E.uniforms.mOpacity,o);c.uniform1f(E.uniforms.m2Near,i.__2near);c.uniform1f(E.uniforms.mFarPlusNear,i.__farPlusNear);c.uniform1f(E.uniforms.mFarMinusNear,i.__farMinusNear);c.uniform1i(E.uniforms.material,3)}else if(i instanceof THREE.MeshPhongMaterial){k=i.ambient;h=i.specular;i=i.shininess;c.uniform4f(E.uniforms.mAmbient,k.r,k.g,k.b,o);c.uniform4f(E.uniforms.mSpecular,h.r,h.g,h.b,o);c.uniform1f(E.uniforms.mShininess, -i);c.uniform1i(E.uniforms.material,2)}else if(i instanceof THREE.MeshLambertMaterial)c.uniform1i(E.uniforms.material,1);else if(i instanceof THREE.MeshBasicMaterial)c.uniform1i(E.uniforms.material,0);else if(i instanceof THREE.MeshCubeMaterial){c.uniform1i(E.uniforms.material,5);J=i.env_map}if(P){e(P,0);c.uniform1i(E.uniforms.tMap,0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(J){d(J,1);c.uniform1i(E.uniforms.tCube,1);c.uniform1i(E.uniforms.enableCubeMap,1)}else c.uniform1i(E.uniforms.enableCubeMap, -0);o=E.attributes;c.bindBuffer(c.ARRAY_BUFFER,y.__webGLVertexBuffer);c.vertexAttribPointer(o.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,y.__webGLNormalBuffer);c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);if(o.uv>=0)if(y.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,y.__webGLUVBuffer);c.enableVertexAttribArray(o.uv);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(o.uv);if(B){c.lineWidth(A);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLLineBuffer); -c.drawElements(c.LINES,y.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,y.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(h,n,i,y,k,o){var B,A,P,J,Q;P=0;for(J=i.material.length;P=0;i--){y=h.__webGLObjects[i].object;n==y&&h.__webGLObjects.splice(i,1)}};this.setupMatrices=function(h,n){h.autoUpdateMatrix&&h.updateMatrix();r.multiply(n.matrix,h.matrix);v.set(n.matrix.flatten()); -w.set(r.flatten());H.set(n.projectionMatrix.flatten());u=THREE.Matrix4.makeInvert3x3(r).transpose();I.set(u.m);z.set(h.matrix.flatten())};this.loadMatrices=function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,w);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,H);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,I);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,z)};this.loadCamera=function(h,n){c.uniform3f(h.uniforms.cameraPosition, -n.position.x,n.position.y,n.position.z)};this.setBlending=function(h){switch(h){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(h,n){if(h){!n||n=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(h=="back")c.cullFace(c.BACK);else h=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK); -c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}};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};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null}; -var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,g=d?b.geometry:b,j=a.vertices,l=g.vertices,f=a.faces,q=g.faces,c=a.uvs;g=g.uvs;d&&b.updateMatrix();for(var t=0,D=l.length;t0){K.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,K.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(U),c.STATIC_DRAW)}K.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,K.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(V),c.STATIC_DRAW);K.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +K.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(E),c.STATIC_DRAW);K.__webGLFaceCount=V.length;K.__webGLLineCount=E.length}};this.renderBuffer=function(h,o,i,x){var k,n,B,y,L,F,O,V,E;if(i instanceof THREE.MeshShaderMaterial){if(!i.program){i.program=b(i.fragment_shader,i.vertex_shader);O=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(E in i.uniforms)O.push(E);g(i.program,O);j(i.program,["position","normal","uv","tangent"])}E= +i.program}else E=C;if(E!=t){c.useProgram(E);t=E}E==C&&this.setupLights(E,o);this.loadCamera(E,h);this.loadMatrices(E);if(i instanceof THREE.MeshShaderMaterial){B=i.wireframe;y=i.wireframe_linewidth;h=E;o=i.uniforms;var S;for(k in o){V=o[k].type;O=o[k].value;S=h.uniforms[k];if(V=="i")c.uniform1i(S,O);else if(V=="f")c.uniform1f(S,O);else if(V=="v3")c.uniform3f(S,O.x,O.y,O.z);else if(V=="c")c.uniform3f(S,O.r,O.g,O.b);else if(V=="t"){c.uniform1i(S,O);if(V=o[k].texture)V.image instanceof Array&&V.image.length== +6?d(V,O):e(V,O)}}}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){k=i.color;n=i.opacity;B=i.wireframe;y=i.wireframe_linewidth;L=i.map;F=i.env_map;o=i.combine==THREE.MixOperation;h=i.reflectivity;V=i.env_map&&i.env_map.mapping instanceof THREE.CubeRefractionMapping;O=i.refraction_ratio;c.uniform4f(E.uniforms.mColor,k.r*n,k.g*n,k.b*n,n);c.uniform1i(E.uniforms.mixEnvMap,o);c.uniform1f(E.uniforms.mReflectivity,h);c.uniform1i(E.uniforms.useRefract, +V);c.uniform1f(E.uniforms.mRefractionRatio,O)}if(i instanceof THREE.MeshNormalMaterial){n=i.opacity;c.uniform1f(E.uniforms.mOpacity,n);c.uniform1i(E.uniforms.material,4)}else if(i instanceof THREE.MeshDepthMaterial){n=i.opacity;B=i.wireframe;y=i.wireframe_linewidth;c.uniform1f(E.uniforms.mOpacity,n);c.uniform1f(E.uniforms.m2Near,i.__2near);c.uniform1f(E.uniforms.mFarPlusNear,i.__farPlusNear);c.uniform1f(E.uniforms.mFarMinusNear,i.__farMinusNear);c.uniform1i(E.uniforms.material,3)}else if(i instanceof +THREE.MeshPhongMaterial){k=i.ambient;h=i.specular;i=i.shininess;c.uniform4f(E.uniforms.mAmbient,k.r,k.g,k.b,n);c.uniform4f(E.uniforms.mSpecular,h.r,h.g,h.b,n);c.uniform1f(E.uniforms.mShininess,i);c.uniform1i(E.uniforms.material,2)}else if(i instanceof THREE.MeshLambertMaterial)c.uniform1i(E.uniforms.material,1);else if(i instanceof THREE.MeshBasicMaterial)c.uniform1i(E.uniforms.material,0);else if(i instanceof THREE.MeshCubeMaterial){c.uniform1i(E.uniforms.material,5);F=i.env_map}if(L){e(L,0);c.uniform1i(E.uniforms.tMap, +0);c.uniform1i(E.uniforms.enableMap,1)}else c.uniform1i(E.uniforms.enableMap,0);if(F){d(F,1);c.uniform1i(E.uniforms.tCube,1);c.uniform1i(E.uniforms.enableCubeMap,1)}else c.uniform1i(E.uniforms.enableCubeMap,0);n=E.attributes;c.bindBuffer(c.ARRAY_BUFFER,x.__webGLVertexBuffer);c.vertexAttribPointer(n.position,3,c.FLOAT,false,0,0);c.bindBuffer(c.ARRAY_BUFFER,x.__webGLNormalBuffer);c.vertexAttribPointer(n.normal,3,c.FLOAT,false,0,0);if(n.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,x.__webGLTangentBuffer); +c.vertexAttribPointer(n.tangent,4,c.FLOAT,false,0,0)}if(n.uv>=0)if(x.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,x.__webGLUVBuffer);c.enableVertexAttribArray(n.uv);c.vertexAttribPointer(n.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(n.uv);if(B){c.lineWidth(y);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLLineBuffer);c.drawElements(c.LINES,x.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,x.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,x.__webGLFaceCount,c.UNSIGNED_SHORT, +0)}};this.renderPass=function(h,o,i,x,k,n){var B,y,L,F,O;L=0;for(F=i.material.length;L=0;i--){x=h.__webGLObjects[i].object;o==x&&h.__webGLObjects.splice(i,1)}};this.setupMatrices=function(h,o){h.autoUpdateMatrix&&h.updateMatrix();r.multiply(o.matrix,h.matrix);v.set(o.matrix.flatten());w.set(r.flatten());G.set(o.projectionMatrix.flatten());u=THREE.Matrix4.makeInvert3x3(r).transpose();H.set(u.m);A.set(h.matrix.flatten())};this.loadMatrices= +function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,w);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,G);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,H);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,A)};this.loadCamera=function(h,o){c.uniform3f(h.uniforms.cameraPosition,o.position.x,o.position.y,o.position.z)};this.setBlending=function(h){switch(h){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(h,o){if(h){!o||o=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(h=="back")c.cullFace(c.BACK);else h=="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}; +THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.material=null}; +var GeometryUtils={merge:function(a,b){var d=b instanceof THREE.Mesh,e=a.vertices.length,g=d?b.geometry:b,j=a.vertices,l=g.vertices,f=a.faces,p=g.faces,c=a.uvs;g=g.uvs;d&&b.updateMatrix();for(var t=0,C=l.length;t= 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,g,j,l,f){function p(w,G,H,A,m,h,o,i){var x=e||1,k=g||1,n=x+1,B=k+1;m=m/x;h=h/k;var y=c.vertices.length,L;if(w=="x"&&G=="y"||w=="y"&&G=="x")L="z";else if(w=="x"&&G=="z"||w=="z"&&G=="x")L="y";else if(w=="z"&&G=="y"||w=="y"&&G=="z")L="x";for(iy=0;iy0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,l,D)))-1);q.push(c)}b.push(q)}var r,u,v;a=b.length;for(d=0;d0)for(e=0;e1){r=this.vertices[j].position.clone(); -u=this.vertices[f].position.clone();v=this.vertices[q].position.clone();r.normalize();u.normalize();v.normalize();this.faces.push(new THREE.Face3(j,f,q,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,t,w])}}}this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,g=Math.max(3,b||8),j=Math.max(2,d||6);b=[];for(d=0;d0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,l,C)))-1);p.push(c)}b.push(p)}var r,u,v;a=b.length;for(d=0;d0)for(e=0;e1){r=this.vertices[j].position.clone(); +u=this.vertices[f].position.clone();v=this.vertices[p].position.clone();r.normalize();u.normalize();v.normalize();this.faces.push(new THREE.Face3(j,f,p,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,t,w])}}}this.computeCentroids();this.computeNormals();this.sortFacesByMaterial()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null}; THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML= 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(g){THREE.Loader.prototype.createModel(g.data,b,d)};a.postMessage(e)},loadBinary:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers, j.data.materials,b,d,g)};a.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};a.postMessage(e)},loadAjaxBuffers:function(a,b,d,e,g){var j=new XMLHttpRequest,l=e+"/"+a,f=0;j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,d,e,b):alert("Couldn't load ["+l+"] ["+j.status+"]");else if(j.readyState==3){if(g){if(f==0)f=j.getResponseHeader("Content-Length");g({total:f,loaded:j.responseText.length})}}else if(j.readyState== -2)f=j.getResponseHeader("Content-Length")};j.open("GET",l,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(a,b,d,e){var g=function(j){function l(p,s){var x=t(p,s),G=t(p,s+1),V=t(p,s+2),ba=t(p,s+3),ga=(ba<<1&255|V>>7)-127;x=(V&127)<<16|G<<8|x;if(x==0&&ga==-127)return 0;return(1-2*(ba>>7))*(1+x*Math.pow(2,-23))*Math.pow(2,ga)}function f(p,s){var x=t(p,s),G=t(p,s+1),V=t(p,s+2);return(t(p,s+3)<<24)+(V<< -16)+(G<<8)+x}function q(p,s){var x=t(p,s);return(t(p,s+1)<<8)+x}function c(p,s){var x=t(p,s);return x>127?x-256:x}function t(p,s){return p.charCodeAt(s)&255}function D(p){var s,x,G;s=f(a,p);x=f(a,p+i);G=f(a,p+y);p=q(a,p+k);THREE.Loader.prototype.f3(I,s,x,G,p)}function r(p){var s,x,G,V,ba,ga;s=f(a,p);x=f(a,p+i);G=f(a,p+y);V=q(a,p+k);ba=f(a,p+o);ga=f(a,p+B);p=f(a,p+A);THREE.Loader.prototype.f3n(I,h,s,x,G,V,ba,ga,p)}function u(p){var s,x,G,V;s=f(a,p);x=f(a,p+P);G=f(a,p+J);V=f(a,p+Q);p=q(a,p+T);THREE.Loader.prototype.f4(I, -s,x,G,V,p)}function v(p){var s,x,G,V,ba,ga,$,ka;s=f(a,p);x=f(a,p+P);G=f(a,p+J);V=f(a,p+Q);ba=q(a,p+T);ga=f(a,p+E);$=f(a,p+U);ka=f(a,p+K);p=f(a,p+L);THREE.Loader.prototype.f4n(I,h,s,x,G,V,ba,ga,$,ka,p)}function w(p){var s,x;s=f(a,p);x=f(a,p+N);p=f(a,p+Y);THREE.Loader.prototype.uv3(I,n[s*2],n[s*2+1],n[x*2],n[x*2+1],n[p*2],n[p*2+1])}function H(p){var s,x,G;s=f(a,p);x=f(a,p+R);G=f(a,p+M);p=f(a,p+W);THREE.Loader.prototype.uv4(I,n[s*2],n[s*2+1],n[x*2],n[x*2+1],n[G*2],n[G*2+1],n[p*2],n[p*2+1])}var I=this, -z=0,m,h=[],n=[],i,y,k,o,B,A,P,J,Q,T,E,U,K,L,N,Y,R,M,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(I,e,j);m={signature:a.substr(z,8),header_bytes:t(a,z+8),vertex_coordinate_bytes:t(a,z+9),normal_coordinate_bytes:t(a,z+10),uv_coordinate_bytes:t(a,z+11),vertex_index_bytes:t(a,z+12),normal_index_bytes:t(a,z+13),uv_index_bytes:t(a,z+14),material_index_bytes:t(a,z+15),nvertices:f(a,z+16),nnormals:f(a,z+16+4),nuvs:f(a,z+16+8),ntri_flat:f(a,z+16+12),ntri_smooth:f(a,z+16+16),ntri_flat_uv:f(a, -z+16+20),ntri_smooth_uv:f(a,z+16+24),nquad_flat:f(a,z+16+28),nquad_smooth:f(a,z+16+32),nquad_flat_uv:f(a,z+16+36),nquad_smooth_uv:f(a,z+16+40)};z+=m.header_bytes;i=m.vertex_index_bytes;y=m.vertex_index_bytes*2;k=m.vertex_index_bytes*3;o=m.vertex_index_bytes*3+m.material_index_bytes;B=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;A=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;P=m.vertex_index_bytes;J=m.vertex_index_bytes*2;Q=m.vertex_index_bytes*3;T=m.vertex_index_bytes* -4;E=m.vertex_index_bytes*4+m.material_index_bytes;U=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;K=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;L=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;N=m.uv_index_bytes;Y=m.uv_index_bytes*2;R=m.uv_index_bytes;M=m.uv_index_bytes*2;W=m.uv_index_bytes*3;z+=function(p){var s,x,G,V=m.vertex_coordinate_bytes*3,ba=p+m.nvertices*V;for(p=p;p>7)-127;z=(W&127)<<16|J<<8|z;if(z==0&&ga==-127)return 0;return(1-2*(ba>>7))*(1+z*Math.pow(2,-23))*Math.pow(2,ga)}function f(q,s){var z=t(q,s),J=t(q,s+1),W=t(q,s+2);return(t(q,s+3)<<24)+(W<< +16)+(J<<8)+z}function p(q,s){var z=t(q,s);return(t(q,s+1)<<8)+z}function c(q,s){var z=t(q,s);return z>127?z-256:z}function t(q,s){return q.charCodeAt(s)&255}function C(q){var s,z,J;s=f(a,q);z=f(a,q+i);J=f(a,q+x);q=p(a,q+k);THREE.Loader.prototype.f3(H,s,z,J,q)}function r(q){var s,z,J,W,ba,ga;s=f(a,q);z=f(a,q+i);J=f(a,q+x);W=p(a,q+k);ba=f(a,q+n);ga=f(a,q+B);q=f(a,q+y);THREE.Loader.prototype.f3n(H,h,s,z,J,W,ba,ga,q)}function u(q){var s,z,J,W;s=f(a,q);z=f(a,q+L);J=f(a,q+F);W=f(a,q+O);q=p(a,q+V);THREE.Loader.prototype.f4(H, +s,z,J,W,q)}function v(q){var s,z,J,W,ba,ga,$,ka;s=f(a,q);z=f(a,q+L);J=f(a,q+F);W=f(a,q+O);ba=p(a,q+V);ga=f(a,q+E);$=f(a,q+S);ka=f(a,q+N);q=f(a,q+T);THREE.Loader.prototype.f4n(H,h,s,z,J,W,ba,ga,$,ka,q)}function w(q){var s,z;s=f(a,q);z=f(a,q+U);q=f(a,q+Q);THREE.Loader.prototype.uv3(H,o[s*2],o[s*2+1],o[z*2],o[z*2+1],o[q*2],o[q*2+1])}function G(q){var s,z,J;s=f(a,q);z=f(a,q+K);J=f(a,q+M);q=f(a,q+X);THREE.Loader.prototype.uv4(H,o[s*2],o[s*2+1],o[z*2],o[z*2+1],o[J*2],o[J*2+1],o[q*2],o[q*2+1])}var H=this, +A=0,m,h=[],o=[],i,x,k,n,B,y,L,F,O,V,E,S,N,T,U,Q,K,M,X;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(H,e,j);m={signature:a.substr(A,8),header_bytes:t(a,A+8),vertex_coordinate_bytes:t(a,A+9),normal_coordinate_bytes:t(a,A+10),uv_coordinate_bytes:t(a,A+11),vertex_index_bytes:t(a,A+12),normal_index_bytes:t(a,A+13),uv_index_bytes:t(a,A+14),material_index_bytes:t(a,A+15),nvertices:f(a,A+16),nnormals:f(a,A+16+4),nuvs:f(a,A+16+8),ntri_flat:f(a,A+16+12),ntri_smooth:f(a,A+16+16),ntri_flat_uv:f(a, +A+16+20),ntri_smooth_uv:f(a,A+16+24),nquad_flat:f(a,A+16+28),nquad_smooth:f(a,A+16+32),nquad_flat_uv:f(a,A+16+36),nquad_smooth_uv:f(a,A+16+40)};A+=m.header_bytes;i=m.vertex_index_bytes;x=m.vertex_index_bytes*2;k=m.vertex_index_bytes*3;n=m.vertex_index_bytes*3+m.material_index_bytes;B=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;y=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;L=m.vertex_index_bytes;F=m.vertex_index_bytes*2;O=m.vertex_index_bytes*3;V=m.vertex_index_bytes* +4;E=m.vertex_index_bytes*4+m.material_index_bytes;S=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;N=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;T=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;U=m.uv_index_bytes;Q=m.uv_index_bytes*2;K=m.uv_index_bytes;M=m.uv_index_bytes*2;X=m.uv_index_bytes*3;A+=function(q){var s,z,J,W=m.vertex_coordinate_bytes*3,ba=q+m.nvertices*W;for(q=q;q + + + three.js - webgl normal map + + + + + +

+		
+		
+ three.js - webgl (normal + ao + displacement) map demo. + ninja head from AMD GPU MeshMapper + +
displacement mapping needs vertex textures (GPU with Shader Model 3.0)
+ on Windows use Chrome --use-gl=desktop or Firefox 4
+ please star this Chrome issue to get ANGLE support +
+
+ +
+
+ Sorry, your browser doesn't support WebGL + and Web Workers.
+
+ Please try in + Chrome 9+ / + Firefox 4+ / + Safari OSX 10.6+ +
+
+ + + + + + + + diff --git a/examples/obj/ninja/.htaccess b/examples/obj/ninja/.htaccess new file mode 100644 index 00000000..d9f67316 --- /dev/null +++ b/examples/obj/ninja/.htaccess @@ -0,0 +1,7 @@ + +SetOutputFilter DEFLATE + + + +SetOutputFilter DEFLATE + diff --git a/examples/obj/ninja/NinjaLo_bin.bin b/examples/obj/ninja/NinjaLo_bin.bin new file mode 100644 index 00000000..2d6ff9dc Binary files /dev/null and b/examples/obj/ninja/NinjaLo_bin.bin differ diff --git a/examples/obj/ninja/NinjaLo_bin.js b/examples/obj/ninja/NinjaLo_bin.js new file mode 100644 index 00000000..604c8e2b --- /dev/null +++ b/examples/obj/ninja/NinjaLo_bin.js @@ -0,0 +1,22 @@ +// Converted from: ../../examples/obj/ninja/ninjaHead_Low.obj +// vertices: 4485 +// faces: 4810 +// materials: 0 +// +// Generated with OBJ -> Three.js converter +// http://github.com/alteredq/three.js/blob/master/utils/exporters/convert_obj_threejs_slim.py + + +var model = { + 'materials': [ { + "a_dbg_color" : 0xeeeeee, + "a_dbg_index" : 0, + "a_dbg_name" : "default" + }], + + 'buffers': 'NinjaLo_bin.bin', + + 'end': (new Date).getTime() + } + +postMessage( model ); diff --git a/examples/textures/normal/ninja/ao.jpg b/examples/textures/normal/ninja/ao.jpg new file mode 100644 index 00000000..bc791d01 Binary files /dev/null and b/examples/textures/normal/ninja/ao.jpg differ diff --git a/examples/textures/normal/ninja/displacement.jpg b/examples/textures/normal/ninja/displacement.jpg new file mode 100644 index 00000000..ed8508ed Binary files /dev/null and b/examples/textures/normal/ninja/displacement.jpg differ diff --git a/examples/textures/normal/ninja/displacement.txt b/examples/textures/normal/ninja/displacement.txt new file mode 100644 index 00000000..96779902 --- /dev/null +++ b/examples/textures/normal/ninja/displacement.txt @@ -0,0 +1,2 @@ +DisplacementMap Scale: 2.436143 +DisplacementMap Bias : -0.428408 diff --git a/examples/textures/normal/ninja/normal.jpg b/examples/textures/normal/ninja/normal.jpg new file mode 100644 index 00000000..35c10158 Binary files /dev/null and b/examples/textures/normal/ninja/normal.jpg differ diff --git a/src/core/Geometry.js b/src/core/Geometry.js index c315fb9d..1de060d2 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -12,6 +12,8 @@ THREE.Geometry = function () { this.geometryChunks = {}; + this.hasTangents = false; + }; THREE.Geometry.prototype = { @@ -167,6 +169,121 @@ THREE.Geometry.prototype = { }, + computeTangents: function() { + + // based on http://www.terathon.com/code/tangent.html + // tangents go to vertices + + var f, fl, v, vl, face, uv, vA, vB, vC, uvA, uvB, uvC, + x1, x2, y1, y2, z1, z2, + s1, s2, t1, t2, r, t, n, + tan1 = [], tan2 = [], + sdir = new THREE.Vector3(), tdir = new THREE.Vector3(), + tmp = new THREE.Vector3(), tmp2 = new THREE.Vector3(), + n = new THREE.Vector3(), w; + + for ( v = 0, vl = this.vertices.length; v < vl; v ++ ) { + + tan1[ v ] = new THREE.Vector3(); + tan2[ v ] = new THREE.Vector3(); + + } + + function handleTriangle( context, a, b, c ) { + + vA = context.vertices[ a ].position; + vB = context.vertices[ b ].position; + vC = context.vertices[ c ].position; + + uvA = uv[ 0 ]; + uvB = uv[ 1 ]; + uvC = uv[ 2 ]; + + x1 = vB.x - vA.x; + x2 = vC.x - vA.x; + y1 = vB.y - vA.y; + y2 = vC.y - vA.y; + z1 = vB.z - vA.z; + z2 = vC.z - vA.z; + + s1 = uvB.u - uvA.u; + s2 = uvC.u - uvA.u; + t1 = uvB.v - uvA.v; + t2 = uvC.v - uvA.v; + + r = 1.0 / ( s1 * t2 - s2 * t1 ); + sdir.set( ( t2 * x1 - t1 * x2 ) * r, + ( t2 * y1 - t1 * y2 ) * r, + ( t2 * z1 - t1 * z2 ) * r ); + tdir.set( ( s1 * x2 - s2 * x1 ) * r, + ( s1 * y2 - s2 * y1 ) * r, + ( s1 * z2 - s2 * z1 ) * r ); + + tan1[ a ].addSelf( sdir ); + tan1[ b ].addSelf( sdir ); + tan1[ c ].addSelf( sdir ); + + tan2[ a ].addSelf( tdir ); + tan2[ b ].addSelf( tdir ); + tan2[ c ].addSelf( tdir ); + + } + + for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { + + face = this.faces[ f ]; + uv = this.uvs[ f ]; + + if ( face instanceof THREE.Face3 ) { + + handleTriangle( this, face.a, face.b, face.c ); + + this.vertices[ face.a ].normal.copy( face.vertexNormals[ 0 ] ); + this.vertices[ face.b ].normal.copy( face.vertexNormals[ 1 ] ); + this.vertices[ face.c ].normal.copy( face.vertexNormals[ 2 ] ); + + + } else if ( face instanceof THREE.Face4 ) { + + handleTriangle( this, face.a, face.b, face.c ); + + // this messes up everything + // quads need to be handled differently + //handleTriangle( this, face.a, face.c, face.d ); + + this.vertices[ face.a ].normal.copy( face.vertexNormals[ 0 ] ); + this.vertices[ face.b ].normal.copy( face.vertexNormals[ 1 ] ); + this.vertices[ face.c ].normal.copy( face.vertexNormals[ 2 ] ); + this.vertices[ face.d ].normal.copy( face.vertexNormals[ 3 ] ); + + } + + } + + for ( v = 0, vl = this.vertices.length; v < vl; v ++ ) { + + n.copy( this.vertices[ v ].normal ); + t = tan1[ v ]; + + // Gram-Schmidt orthogonalize + + tmp.copy( t ); + tmp.subSelf( n.multiplyScalar( n.dot( t ) ) ).normalize(); + + // Calculate handedness + + tmp2.cross( this.vertices[ v ].normal, t ); + test = tmp2.dot( tan2[ v ] ); + w = (test < 0.0) ? -1.0 : 1.0; + + this.vertices[ v ].tangent.set( tmp.x, tmp.y, tmp.z, w ); + + } + + this.hasTangents = true; + + }, + computeBoundingBox: function () { if ( this.vertices.length > 0 ) { diff --git a/src/core/Vertex.js b/src/core/Vertex.js index 0fab06ee..af45869c 100644 --- a/src/core/Vertex.js +++ b/src/core/Vertex.js @@ -12,6 +12,8 @@ THREE.Vertex = function ( position, normal ) { this.normalWorld = new THREE.Vector3(); this.normalScreen = new THREE.Vector3(); + this.tangent = new THREE.Vector4(); + this.__visible = true; } diff --git a/src/extras/ShaderUtils.js b/src/extras/ShaderUtils.js index a87af227..8f11339d 100644 --- a/src/extras/ShaderUtils.js +++ b/src/extras/ShaderUtils.js @@ -62,6 +62,201 @@ var ShaderUtils = { "}" ].join("\n") + }, + + '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( 0xeeeeee ) }, + + "uDirLightPos": { type: "v3", value: new THREE.Vector3() }, + "uDirLightColor": { type: "c", value: new THREE.Color( 0xeeeeee ) }, + + "uAmbientLightColor":{ type: "c", value: new THREE.Color( 0x050505 ) }, + + "uDiffuseColor": { type: "c", value: new THREE.Color( 0xeeeeee ) }, + "uSpecularColor": { type: "c", value: new THREE.Color( 0x111111 ) }, + "uAmbientColor": { type: "c", value: new THREE.Color( 0x050505 ) }, + "uShininess": { type: "f", value: 30 } + + }, + + fragment_shader: [ + + "uniform vec3 uDirLightPos;", + "uniform vec3 uDirLightColor;", + + "uniform vec3 uPointLightPos;", + "uniform vec3 uPointLightColor;", + + "uniform vec3 uAmbientColor;", + "uniform vec3 uDiffuseColor;", + "uniform vec3 uSpecularColor;", + "uniform float uShininess;", + + "uniform sampler2D tNormal;", + "uniform sampler2D tAO;", + + "varying vec3 vTangent;", + "varying vec3 vBinormal;", + "varying vec3 vNormal;", + "varying vec2 vUv;", + + "varying vec3 vLightWeighting;", + "varying vec3 vPointLightVector;", + "varying vec3 vViewPosition;", + + "void main() {", + + "vec3 normalTex = normalize( texture2D( tNormal, vUv ).xyz * 2.0 - 1.0 );", + "vec3 aoTex = texture2D( tAO, vUv ).xyz;", + + "mat3 tsb = mat3( vTangent, vBinormal, vNormal );", + "vec3 finalNormal = tsb * normalTex;", + + "vec3 normal = normalize( finalNormal );", + "vec3 viewPosition = normalize( vViewPosition );", + + // point light + + "vec4 pointDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );", + "vec4 pointSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );", + + "vec3 pointVector = normalize( vPointLightVector );", + "vec3 pointHalfVector = normalize( vPointLightVector + vViewPosition );", + + "float pointDotNormalHalf = dot( normal, pointHalfVector );", + "float pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );", + + "float pointSpecularWeight = 0.0;", + "if ( pointDotNormalHalf >= 0.0 )", + "pointSpecularWeight = pow( pointDotNormalHalf, uShininess );", + + "pointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;", + "pointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;", + + // directional light + + "vec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );", + "vec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );", + + "vec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );", + + "vec3 dirVector = normalize( lDirection.xyz );", + "vec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );", + + "float dirDotNormalHalf = dot( normal, dirHalfVector );", + "float dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );", + + "float dirSpecularWeight = 0.0;", + "if ( dirDotNormalHalf >= 0.0 )", + "dirSpecularWeight = pow( dirDotNormalHalf, uShininess );", + + "dirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;", + "dirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;", + + // all lights contribution summation + + "vec4 totalLight = vec4( uAmbientColor, 1.0 );", + "totalLight += dirDiffuse + dirSpecular;", + "totalLight += pointDiffuse + pointSpecular;", + + "gl_FragColor = vec4( totalLight.xyz * vLightWeighting * aoTex, 1.0 );", + + "}" + ].join("\n"), + + vertex_shader: [ + + "attribute vec4 tangent;", + + "uniform vec3 uDirLightPos;", + "uniform vec3 uDirLightColor;", + + "uniform vec3 uPointLightPos;", + "uniform vec3 uPointLightColor;", + + "uniform vec3 uAmbientLightColor;", + + "#ifdef VERTEX_TEXTURES", + + "uniform sampler2D tDisplacement;", + "uniform float uDisplacementScale;", + "uniform float uDisplacementBias;", + + "#endif", + + "varying vec3 vTangent;", + "varying vec3 vBinormal;", + "varying vec3 vNormal;", + "varying vec2 vUv;", + + "varying vec3 vLightWeighting;", + "varying vec3 vPointLightVector;", + "varying vec3 vViewPosition;", + + "void main() {", + + "vec4 mPosition = objectMatrix * vec4( position, 1.0 );", + "vViewPosition = cameraPosition - mPosition.xyz;", + + "vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", + "vNormal = normalize( normalMatrix * normal );", + + // tangent and binormal vectors + + "vTangent = normalize( normalMatrix * tangent.xyz );", + + "vBinormal = cross( vNormal, vTangent ) * tangent.w;", + "vBinormal = normalize( vBinormal );", + + "vUv = uv;", + + // ambient light + + "vLightWeighting = uAmbientLightColor;", + + // point light + + "vec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );", + "vPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );", + "float pointLightWeighting = max( dot( vNormal, vPointLightVector ), 0.0 );", + "vLightWeighting += uPointLightColor * pointLightWeighting;", + + // directional light + + "vec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );", + "float directionalLightWeighting = max( dot( vNormal, normalize( lDirection.xyz ) ), 0.0 );", + "vLightWeighting += uDirLightColor * directionalLightWeighting;", + + // displacement mapping + + "#ifdef VERTEX_TEXTURES", + + "vec3 dv = texture2D( tDisplacement, uv ).xyz;", + "float df = uDisplacementScale * dv.x + uDisplacementBias;", + "vec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;", + "gl_Position = projectionMatrix * displacedPosition;", + + "#else", + + "gl_Position = projectionMatrix * mvPosition;", + + "#endif", + + "}" + + ].join("\n") + } } diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 66e19d2f..452c5533 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -159,13 +159,14 @@ THREE.WebGLRenderer = function ( scene ) { this.createBuffers = function ( object, g ) { - var f, fl, fi, face, vertexNormals, normal, uv, v1, v2, v3, v4, m, ml, i, + var f, fl, fi, face, vertexNormals, normal, uv, v1, v2, v3, v4, t1, t2, t3, t4, m, ml, i, faceArray = [], lineArray = [], vertexArray = [], normalArray = [], + tangentArray = [], uvArray = [], vertexIndex = 0, @@ -193,8 +194,21 @@ THREE.WebGLRenderer = function ( scene ) { vertexArray.push( v2.x, v2.y, v2.z ); vertexArray.push( v3.x, v3.y, v3.z ); + if ( object.geometry.hasTangents ) { + + t1 = object.geometry.vertices[ face.a ].tangent; + t2 = object.geometry.vertices[ face.b ].tangent; + t3 = object.geometry.vertices[ face.c ].tangent; + + tangentArray.push( t1.x, t1.y, t1.z, t1.w ); + tangentArray.push( t2.x, t2.y, t2.z, t2.w ); + tangentArray.push( t3.x, t3.y, t3.z, t3.w ); + + } + if ( vertexNormals.length == 3 && needsSmoothNormals ) { + for ( i = 0; i < 3; i ++ ) { normalArray.push( vertexNormals[ i ].x, vertexNormals[ i ].y, vertexNormals[ i ].z ); @@ -242,15 +256,29 @@ THREE.WebGLRenderer = function ( scene ) { vertexArray.push( v2.x, v2.y, v2.z ); vertexArray.push( v3.x, v3.y, v3.z ); vertexArray.push( v4.x, v4.y, v4.z ); + + if ( object.geometry.hasTangents ) { + + t1 = object.geometry.vertices[ face.a ].tangent; + t2 = object.geometry.vertices[ face.b ].tangent; + t3 = object.geometry.vertices[ face.c ].tangent; + t4 = object.geometry.vertices[ face.d ].tangent; + + tangentArray.push( t1.x, t1.y, t1.z, t1.w ); + tangentArray.push( t2.x, t2.y, t2.z, t2.w ); + tangentArray.push( t3.x, t3.y, t3.z, t3.w ); + tangentArray.push( t4.x, t4.y, t4.z, t4.w ); + + } if ( vertexNormals.length == 4 && needsSmoothNormals ) { - + for ( i = 0; i < 4; i ++ ) { normalArray.push( vertexNormals[ i ].x, vertexNormals[ i ].y, vertexNormals[ i ].z ); } - + } else { for ( i = 0; i < 4; i ++ ) { @@ -302,6 +330,14 @@ THREE.WebGLRenderer = function ( scene ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( normalArray ), _gl.STATIC_DRAW ); + if ( object.geometry.hasTangents ) { + + geometryChunk.__webGLTangentBuffer = _gl.createBuffer(); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLTangentBuffer ); + _gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( tangentArray ), _gl.STATIC_DRAW ); + + } + if ( uvArray.length > 0 ) { geometryChunk.__webGLUVBuffer = _gl.createBuffer(); @@ -346,7 +382,7 @@ THREE.WebGLRenderer = function ( scene ) { } cacheUniformLocations( material.program, identifiers ); - cacheAttributeLocations( material.program, [ "position", "normal", "uv" ] ); + cacheAttributeLocations( material.program, [ "position", "normal", "uv", "tangent" ] ); } @@ -374,7 +410,6 @@ THREE.WebGLRenderer = function ( scene ) { this.loadCamera( program, camera ); this.loadMatrices( program ); - if ( material instanceof THREE.MeshShaderMaterial ) { mWireframe = material.wireframe; @@ -507,6 +542,15 @@ THREE.WebGLRenderer = function ( scene ) { _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer ); _gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 ); + // tangents + + if ( attributes.tangent >= 0 ) { + + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLTangentBuffer ); + _gl.vertexAttribPointer( attributes.tangent, 4, _gl.FLOAT, false, 0, 0 ); + + } + // uvs if ( attributes.uv >= 0 ) { @@ -828,6 +872,19 @@ THREE.WebGLRenderer = function ( scene ) { }; + this.supportsVertexTextures = function() { + + return maxVertexTextures() > 0; + + }; + + function maxVertexTextures() { + + return _gl.getParameter( _gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS ); + + }; + + function initGL() { try { @@ -940,7 +997,7 @@ THREE.WebGLRenderer = function ( scene ) { "} else if ( material == 4 ) { ", - "gl_FragColor = vec4( 0.5*normalize( vNormal ) + vec3(0.5, 0.5, 0.5), mOpacity );", + "gl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, mOpacity );", // Depth @@ -1184,6 +1241,8 @@ THREE.WebGLRenderer = function ( scene ) { ].join("\n"), prefix_vertex = [ + maxVertexTextures() > 0 ? "#define VERTEX_TEXTURES" : "", + "uniform mat4 objectMatrix;", "uniform mat4 modelViewMatrix;", "uniform mat4 projectionMatrix;",