diff --git a/build/Three.js b/build/Three.js index 2ca1c2b703dcaa62f2cbc82586f73b7b9135fcd0..af5c0a3a8da025237f30f7f5ebb281cd8b5f2004 100755 --- a/build/Three.js +++ b/build/Three.js @@ -5,58 +5,57 @@ 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,i=this.z;this.x=d*a.z-i*a.y;this.y=i*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,i){this.x=a||0;this.y=b||0;this.z=d||0;this.w=i||1}; +THREE.Vector4.prototype={set:function(a,b,d,i){this.x=a;this.y=b;this.z=d;this.w=i;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,h=[];a=0;for(b=g.length;a0&&M>0&&f+M<1}var d,g,h,n,m,q,l,c,y,G, -w,F=a.geometry,N=F.vertices,J=[];d=0;for(g=F.faces.length;d= -0&&Math.min(h,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){q=true;h=g=d=b=0;a()};this.isEmpty=function(){return q};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+g+", top: "+d+", bottom: "+h+", 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,i=a.objects,j=[];a=0;for(b=i.length;a0&&M>0&&f+M<1}var d,i,j,o,m,q,l,c,z,G, +x,F=a.geometry,N=F.vertices,J=[];d=0;for(i=F.faces.length;d= +0&&Math.min(j,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){q=true;j=i=d=b=0;a()};this.isEmpty=function(){return q};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+i+", top: "+d+", bottom: "+j+", width: "+o+", 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.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,h=new THREE.Vector3,n=new THREE.Vector3;n.sub(a,b).normalize();g.cross(d,n).normalize();h.cross(n,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.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},transformVector3:function(a){var b=a.x,d=a.y,g=a.z,h=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)*h;a.y=(this.n21*b+this.n22*d+this.n23*g+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*g+this.n34)*h;return a},transformVector4:function(a){var b=a.x,d=a.y,g=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*g+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*g+this.n24*h;a.z=this.n31*b+this.n32*d+this.n33*g+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*g+this.n44*h;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,h=a.n13,n=a.n14,m=a.n21,q=a.n22,l=a.n23,c=a.n24,y=a.n31,G=a.n32,w=a.n33,F=a.n34,N=a.n41,J=a.n42,M=a.n43,r=a.n44,R=b.n11,B=b.n12,e=b.n13,f=b.n14,i=b.n21,o=b.n22,k=b.n23,j=b.n24,A=b.n31,s=b.n32,L=b.n33,u=b.n34,T=b.n41,P=b.n42,t=b.n43, -H=b.n44;this.n11=d*R+g*i+h*A+n*T;this.n12=d*B+g*o+h*s+n*P;this.n13=d*e+g*k+h*L+n*t;this.n14=d*f+g*j+h*u+n*H;this.n21=m*R+q*i+l*A+c*T;this.n22=m*B+q*o+l*s+c*P;this.n23=m*e+q*k+l*L+c*t;this.n24=m*f+q*j+l*u+c*H;this.n31=y*R+G*i+w*A+F*T;this.n32=y*B+G*o+w*s+F*P;this.n33=y*e+G*k+w*L+F*t;this.n34=y*f+G*j+w*u+F*H;this.n41=N*R+J*i+M*A+r*T;this.n42=N*B+J*o+M*s+r*P;this.n43=N*e+J*k+M*L+r*t;this.n44=N*f+J*j+M*u+r*H},multiplySelf:function(a){var b=this.n11,d=this.n12,g=this.n13,h=this.n14,n=this.n21,m=this.n22, -q=this.n23,l=this.n24,c=this.n31,y=this.n32,G=this.n33,w=this.n34,F=this.n41,N=this.n42,J=this.n43,M=this.n44;this.n11=b*a.n11+d*a.n21+g*a.n31+h*a.n41;this.n12=b*a.n12+d*a.n22+g*a.n32+h*a.n42;this.n13=b*a.n13+d*a.n23+g*a.n33+h*a.n43;this.n14=b*a.n14+d*a.n24+g*a.n34+h*a.n44;this.n21=n*a.n11+m*a.n21+q*a.n31+l*a.n41;this.n22=n*a.n12+m*a.n22+q*a.n32+l*a.n42;this.n23=n*a.n13+m*a.n23+q*a.n33+l*a.n43;this.n24=n*a.n14+m*a.n24+q*a.n34+l*a.n44;this.n31=c*a.n11+y*a.n21+G*a.n31+w*a.n41;this.n32=c*a.n12+y*a.n22+ -G*a.n32+w*a.n42;this.n33=c*a.n13+y*a.n23+G*a.n33+w*a.n43;this.n34=c*a.n14+y*a.n24+G*a.n34+w*a.n44;this.n41=F*a.n11+N*a.n21+J*a.n31+M*a.n41;this.n42=F*a.n12+N*a.n22+J*a.n32+M*a.n42;this.n43=F*a.n13+N*a.n23+J*a.n33+M*a.n43;this.n44=F*a.n14+N*a.n24+J*a.n34+M*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 i=new THREE.Vector3,j=new THREE.Vector3,o=new THREE.Vector3;o.sub(a,b).normalize();i.cross(d,o).normalize();j.cross(o,i).normalize();this.n11=i.x;this.n12=i.y;this.n13=i.z;this.n14=-i.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=o.x;this.n32=o.y;this.n33=o.z;this.n34=-o.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},transformVector3:function(a){var b=a.x,d=a.y,i=a.z,j=1/(this.n41*b+this.n42* +d+this.n43*i+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*i+this.n14)*j;a.y=(this.n21*b+this.n22*d+this.n23*i+this.n24)*j;a.z=(this.n31*b+this.n32*d+this.n33*i+this.n34)*j;return a},transformVector4:function(a){var b=a.x,d=a.y,i=a.z,j=a.w;a.x=this.n11*b+this.n12*d+this.n13*i+this.n14*j;a.y=this.n21*b+this.n22*d+this.n23*i+this.n24*j;a.z=this.n31*b+this.n32*d+this.n33*i+this.n34*j;a.w=this.n41*b+this.n42*d+this.n43*i+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,i=a.n12,j=a.n13,o=a.n14,m=a.n21,q=a.n22,l=a.n23,c=a.n24,z=a.n31,G=a.n32,x=a.n33,F=a.n34,N=a.n41,J=a.n42,M=a.n43,r=a.n44,R=b.n11,B=b.n12,e=b.n13,f=b.n14,k=b.n21,n=b.n22,g=b.n23,h=b.n24,w=b.n31,s=b.n32,L=b.n33,u=b.n34,T=b.n41,P=b.n42,t=b.n43, +H=b.n44;this.n11=d*R+i*k+j*w+o*T;this.n12=d*B+i*n+j*s+o*P;this.n13=d*e+i*g+j*L+o*t;this.n14=d*f+i*h+j*u+o*H;this.n21=m*R+q*k+l*w+c*T;this.n22=m*B+q*n+l*s+c*P;this.n23=m*e+q*g+l*L+c*t;this.n24=m*f+q*h+l*u+c*H;this.n31=z*R+G*k+x*w+F*T;this.n32=z*B+G*n+x*s+F*P;this.n33=z*e+G*g+x*L+F*t;this.n34=z*f+G*h+x*u+F*H;this.n41=N*R+J*k+M*w+r*T;this.n42=N*B+J*n+M*s+r*P;this.n43=N*e+J*g+M*L+r*t;this.n44=N*f+J*h+M*u+r*H},multiplySelf:function(a){var b=this.n11,d=this.n12,i=this.n13,j=this.n14,o=this.n21,m=this.n22, +q=this.n23,l=this.n24,c=this.n31,z=this.n32,G=this.n33,x=this.n34,F=this.n41,N=this.n42,J=this.n43,M=this.n44;this.n11=b*a.n11+d*a.n21+i*a.n31+j*a.n41;this.n12=b*a.n12+d*a.n22+i*a.n32+j*a.n42;this.n13=b*a.n13+d*a.n23+i*a.n33+j*a.n43;this.n14=b*a.n14+d*a.n24+i*a.n34+j*a.n44;this.n21=o*a.n11+m*a.n21+q*a.n31+l*a.n41;this.n22=o*a.n12+m*a.n22+q*a.n32+l*a.n42;this.n23=o*a.n13+m*a.n23+q*a.n33+l*a.n43;this.n24=o*a.n14+m*a.n24+q*a.n34+l*a.n44;this.n31=c*a.n11+z*a.n21+G*a.n31+x*a.n41;this.n32=c*a.n12+z*a.n22+ +G*a.n32+x*a.n42;this.n33=c*a.n13+z*a.n23+G*a.n33+x*a.n43;this.n34=c*a.n14+z*a.n24+G*a.n34+x*a.n44;this.n41=F*a.n11+N*a.n21+J*a.n31+M*a.n41;this.n42=F*a.n12+N*a.n22+J*a.n32+M*a.n42;this.n43=F*a.n13+N*a.n23+J*a.n33+M*a.n43;this.n44=F*a.n14+N*a.n24+J*a.n34+M*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 h=b[d];b[d]=b[g];b[g]=h}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,i){var j=b[d];b[d]=b[i];b[i]=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 i=new THREE.Matrix4;i.n14=a;i.n24=b;i.n34=d;return i};THREE.Matrix4.scaleMatrix=function(a,b,d){var i=new THREE.Matrix4;i.n11=a;i.n22=b;i.n33=d;return i}; 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),h=Math.sin(b),n=1-g,m=a.x,q=a.y,l=a.z;d.n11=n*m*m+g;d.n12=n*m*q-h*l;d.n13=n*m*l+h*q;d.n21=n*m*q+h*l;d.n22=n*q*q+g;d.n23=n*q*l-h*m;d.n31=n*m*l-h*q;d.n32=n*q*l+h*m;d.n33=n*l*l+g;return d}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,i=Math.cos(b),j=Math.sin(b),o=1-i,m=a.x,q=a.y,l=a.z;d.n11=o*m*m+i;d.n12=o*m*q-j*l;d.n13=o*m*l+j*q;d.n21=o*m*q+j*l;d.n22=o*q*q+i;d.n23=o*q*l-j*m;d.n31=o*m*l-j*q;d.n32=o*q*l+j*m;d.n33=o*l*l+i;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],h=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],q=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],y=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*n+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*g;a.m[2]=b*h;a.m[3]=b*n;a.m[4]=b*m;a.m[5]=b*q;a.m[6]=b*l;a.m[7]=b*c;a.m[8]=b*y;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,g,h,n){var m,q,l;m=new THREE.Matrix4;q=2*h/(b-a);l=2*h/(g-d);a=(b+a)/(b-a);d=(g+d)/(g-d);g=-(n+h)/(n-h);h=-2*n*h/(n-h);m.n11=q;m.n12=0;m.n13=a;m.n14=0;m.n21=0;m.n22=l;m.n23=d;m.n24=0;m.n31=0;m.n32=0;m.n33=g;m.n34=h;m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,g){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,g)}; -THREE.Matrix4.makeOrtho=function(a,b,d,g,h,n){var m,q,l,c;m=new THREE.Matrix4;q=b-a;l=d-g;c=n-h;a=(b+a)/q;d=(d+g)/l;h=(n+h)/c;m.n11=2/q;m.n12=0;m.n13=0;m.n14=-a;m.n21=0;m.n22=2/l;m.n23=0;m.n24=-d;m.n31=0;m.n32=0;m.n33=-2/c;m.n34=-h;m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],i=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],o=-b[10]*b[4]+b[6]*b[8],m=b[10]*b[0]-b[2]*b[8],q=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],z=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*o+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*i;a.m[2]=b*j;a.m[3]=b*o;a.m[4]=b*m;a.m[5]=b*q;a.m[6]=b*l;a.m[7]=b*c;a.m[8]=b*z;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,i,j,o){var m,q,l;m=new THREE.Matrix4;q=2*j/(b-a);l=2*j/(i-d);a=(b+a)/(b-a);d=(i+d)/(i-d);i=-(o+j)/(o-j);j=-2*o*j/(o-j);m.n11=q;m.n12=0;m.n13=a;m.n14=0;m.n21=0;m.n22=l;m.n23=d;m.n24=0;m.n31=0;m.n32=0;m.n33=i;m.n34=j;m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,i){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,d,i)}; +THREE.Matrix4.makeOrtho=function(a,b,d,i,j,o){var m,q,l,c;m=new THREE.Matrix4;q=b-a;l=d-i;c=o-j;a=(b+a)/q;d=(d+i)/l;j=(o+j)/c;m.n11=2/q;m.n12=0;m.n13=0;m.n14=-a;m.n21=0;m.n22=2/l;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,h){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=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,d,g,h,n){this.a=a;this.b=b;this.c=d;this.d=g;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];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=[]}; -THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a +THREE.Face3=function(a,b,d,i,j){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];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,i,j,o){this.a=a;this.b=b;this.c=d;this.d=i;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=o instanceof Array?o:[o]};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.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a 0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y -this.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}}; -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)}; +this.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(z){var G=[];b=0;for(d=z.length;b65535){c[q].counter+=1;l=c[q].hash+"_"+c[q].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],material:m,vertices:0}}this.geometryChunks[l].faces.push(i);this.geometryChunks[l].vertices+=o}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}}; +THREE.Camera=function(a,b,d,i){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,i);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.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.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;this.materialFaceGroup={};this.sortFacesByMaterial();d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh; -THREE.Mesh.prototype.sortFacesByMaterial=function(){function a(y){var G=[];b=0;for(d=y.length;b65535){c[q].counter+=1;l=c[q].hash+"_"+c[q].counter;if(this.materialFaceGroup[l]==undefined)this.materialFaceGroup[l]={faces:[],material:m,vertices:0}}this.materialFaceGroup[l].faces.push(g);this.materialFaceGroup[l].vertices+=n}};THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,g,h;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.Multiply;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=a.map;if(a.env_map!== @@ -80,89 +79,89 @@ a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undef this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshShaderMaterialCounter={value:0}; 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){this.image=a;this.loaded=false;this.mapping=b!==undefined?b:THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=g!==undefined?g:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
)"}}; +THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b,d,i){this.image=a;this.loaded=false;this.mapping=b!==undefined?b:THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=i!==undefined?i:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
)"}}; THREE.UVMapping=0;THREE.ReflectionMapping=1;THREE.RefractionMapping=2;THREE.Multiply=0;THREE.Mix=1;THREE.Repeat=0;THREE.ClampToEdge=1;THREE.MirroredRepeat=2;THREE.TextureCube=function(a,b){this.image=a;this.mapping=b?b:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (
image: "+this.image+"
mapping: "+this.mapping+"
)"}}; 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(R,B){var e=0,f=1,i=R.z+R.w,o=B.z+B.w,k=-R.z+R.w,j=-B.z+B.w;if(i>=0&&o>=0&&k>=0&&j>=0)return true;else if(i<0&&o<0||k<0&&j<0)return false;else{if(i<0)e=Math.max(e,i/(i-o));else if(o<0)f=Math.min(f,i/(i-o));if(k<0)e=Math.max(e,k/(k-j));else if(j<0)f=Math.min(f,k/(k-j));if(f0&&p.z<1}H=s.geometry.faces;i=0;for(o=H.length;i0&&w.z<1){c=G[y]=G[y]||new THREE.RenderableParticle;c.x=w.x/w.w;c.y=w.y/w.w;c.z=w.z;c.rotation=s.rotation.z;c.scale.x=s.scale.x*Math.abs(c.x-(w.x+B.projectionMatrix.n11)/(w.w+B.projectionMatrix.n14));c.scale.y=s.scale.y*Math.abs(c.y-(w.y+B.projectionMatrix.n22)/(w.w+B.projectionMatrix.n24));c.material=s.material;b.push(c);y++}}}b.sort(function(O,D){return D.z-O.z});return b};this.unprojectVector=function(R,B){var e=new THREE.Matrix4; +THREE.Projector=function(){function a(R,B){var e=0,f=1,k=R.z+R.w,n=B.z+B.w,g=-R.z+R.w,h=-B.z+B.w;if(k>=0&&n>=0&&g>=0&&h>=0)return true;else if(k<0&&n<0||g<0&&h<0)return false;else{if(k<0)e=Math.max(e,k/(k-n));else if(n<0)f=Math.min(f,k/(k-n));if(g<0)e=Math.max(e,g/(g-h));else if(h<0)f=Math.min(f,g/(g-h));if(f0&&p.z<1}H=s.geometry.faces;k=0;for(n=H.length;k0&&x.z<1){c=G[z]=G[z]||new THREE.RenderableParticle;c.x=x.x/x.w;c.y=x.y/x.w;c.z=x.z;c.rotation=s.rotation.z;c.scale.x=s.scale.x*Math.abs(c.x-(x.x+B.projectionMatrix.n11)/(x.w+B.projectionMatrix.n14));c.scale.y=s.scale.y*Math.abs(c.y-(x.y+B.projectionMatrix.n22)/(x.w+B.projectionMatrix.n24));c.material=s.material;b.push(c);z++}}}b.sort(function(O,D){return D.z-O.z});return b};this.unprojectVector=function(R,B){var e=new THREE.Matrix4; e.multiply(THREE.Matrix4.makeInvert(B.matrix),THREE.Matrix4.makeInvert(B.projectionMatrix));e.transformVector3(R);return R}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,g,h,n;this.domElement=document.createElement("div");this.setSize=function(m,q){d=m;g=q;h=d/2;n=g/2};this.render=function(m,q){var l,c,y,G,w,F,N,J;a=b.projectScene(m,q);l=0;for(c=a.length;l0){E.r+=$.r*K;E.g+=$.g*K;E.b+=$.b*K}}else if(K instanceof THREE.PointLight){aa.sub(K.position,Y);aa.normalize();K=U.dot(aa)*S;if(K>0){E.r+=$.r*K;E.g+=$.g*K;E.b+=$.b*K}}}}function b(I,Y,U,E,v,K){if(v.opacity!=0){n(v.opacity);m(v.blending);L=I.positionScreen.x;u=I.positionScreen.y;T=Y.positionScreen.x; -P=Y.positionScreen.y;t=U.positionScreen.x;H=U.positionScreen.y;var $=L,S=u,X=T,ba=P,Z=t,ca=H;r.beginPath();r.moveTo($,S);r.lineTo(X,ba);r.lineTo(Z,ca);r.lineTo($,S);r.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map&&v.map.loaded)h(L,u,T,P,t,H,v.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(v.env_map&&v.env_map.loaded){if(v.env_map.mapping==THREE.ReflectionMapping){aa.copy(E.vertexNormalsWorld[0]);V=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+ +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,i,j,o;this.domElement=document.createElement("div");this.setSize=function(m,q){d=m;i=q;j=d/2;o=i/2};this.render=function(m,q){var l,c,z,G,x,F,N,J;a=b.projectScene(m,q);l=0;for(c=a.length;l0){E.r+=$.r*K;E.g+=$.g*K;E.b+=$.b*K}}else if(K instanceof THREE.PointLight){aa.sub(K.position,Y);aa.normalize();K=U.dot(aa)*S;if(K>0){E.r+=$.r*K;E.g+=$.g*K;E.b+=$.b*K}}}}function b(I,Y,U,E,v,K){if(v.opacity!=0){o(v.opacity);m(v.blending);L=I.positionScreen.x;u=I.positionScreen.y;T=Y.positionScreen.x; +P=Y.positionScreen.y;t=U.positionScreen.x;H=U.positionScreen.y;var $=L,S=u,X=T,ba=P,Z=t,ca=H;r.beginPath();r.moveTo($,S);r.lineTo(X,ba);r.lineTo(Z,ca);r.lineTo($,S);r.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map&&v.map.loaded)j(L,u,T,P,t,H,v.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(v.env_map&&v.env_map.loaded){if(v.env_map.mapping==THREE.ReflectionMapping){aa.copy(E.vertexNormalsWorld[0]);V=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+ aa.z*camera.matrix.n13)*0.5+0.5;ja=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*0.5+0.5;aa.copy(E.vertexNormalsWorld[1]);za=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+aa.z*camera.matrix.n13)*0.5+0.5;Aa=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*0.5+0.5;aa.copy(E.vertexNormalsWorld[2]);Ba=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+aa.z*camera.matrix.n13)*0.5+0.5;Ca=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)* -0.5+0.5;h(L,u,T,P,t,H,v.env_map.image,V,ja,za,Aa,Ba,Ca)}}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):g(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){h(L,u,T,P,t,H,v.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);m(THREE.SubtractiveBlending)}if(va)if(!v.wireframe&&v.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){z.r=x.r=O.r=ga.r;z.g=x.g=O.g=ga.g;z.b=x.b=O.b=ga.b;a(K,E.v1.positionWorld, -E.vertexNormalsWorld[0],z);a(K,E.v2.positionWorld,E.vertexNormalsWorld[1],x);a(K,E.v3.positionWorld,E.vertexNormalsWorld[2],O);D.r=(x.r+O.r)*0.5;D.g=(x.g+O.g)*0.5;D.b=(x.b+O.b)*0.5;Q=q(z,x,O,D);h(L,u,T,P,t,H,Q,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;a(K,E.centroidWorld,E.normalWorld,ha);p.r=v.color.r*ha.r;p.g=v.color.g*ha.g;p.b=v.color.b*ha.b;p.updateStyleString();v.wireframe?d(p.__styleString,v.wireframe_linewidth):g(p.__styleString)}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth): -g(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){C=v.__2near;W=v.__farPlusNear;ea=v.__farMinusNear;z.r=z.g=z.b=1-C/(W-I.positionScreen.z*ea);x.r=x.g=x.b=1-C/(W-Y.positionScreen.z*ea);O.r=O.g=O.b=1-C/(W-U.positionScreen.z*ea);D.r=(x.r+O.r)*0.5;D.g=(x.g+O.g)*0.5;D.b=(x.b+O.b)*0.5;Q=q(z,x,O,D);h(L,u,T,P,t,H,Q,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){p.r=l(E.normalWorld.x);p.g=l(E.normalWorld.y);p.b=l(E.normalWorld.z);p.updateStyleString();v.wireframe?d(p.__styleString, -v.wireframe_linewidth):g(p.__styleString)}}}function d(I,Y){if(e!=I)r.strokeStyle=e=I;if(i!=Y)r.lineWidth=i=Y;r.stroke();da.inflate(Y*2)}function g(I){if(f!=I)r.fillStyle=f=I;r.fill()}function h(I,Y,U,E,v,K,$,S,X,ba,Z,ca,la){var ka,fa;ka=$.width-1;fa=$.height-1;S*=ka;X*=fa;ba*=ka;Z*=fa;ca*=ka;la*=fa;U-=I;E-=Y;v-=I;K-=Y;ba-=S;Z-=X;ca-=S;la-=X;fa=1/(ba*la-ca*Z);ka=(la*U-Z*v)*fa;Z=(la*E-Z*K)*fa;U=(ba*v-ca*U)*fa;E=(ba*K-ca*E)*fa;I=I-ka*S-U*X;Y=Y-Z*S-E*X;r.save();r.transform(ka,Z,U,E,I,Y);r.clip();r.drawImage($, -0,0);r.restore()}function n(I){if(R!=I)r.globalAlpha=R=I}function m(I){if(B!=I){switch(I){case THREE.NormalBlending:r.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:r.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:r.globalCompositeOperation="darker"}B=I}}function q(I,Y,U,E){ia[0]=k(0,o(255,~~(I.r*255)));ia[1]=k(0,o(255,~~(I.g*255)));ia[2]=k(0,o(255,~~(I.b*255)));ia[4]=k(0,o(255,~~(Y.r*255)));ia[5]=k(0,o(255,~~(Y.g*255)));ia[6]=k(0,o(255,~~(Y.b*255))); -ia[8]=k(0,o(255,~~(U.r*255)));ia[9]=k(0,o(255,~~(U.g*255)));ia[10]=k(0,o(255,~~(U.b*255)));ia[12]=k(0,o(255,~~(E.r*255)));ia[13]=k(0,o(255,~~(E.g*255)));ia[14]=k(0,o(255,~~(E.b*255)));ra.putImageData(wa,0,0);ua.drawImage(sa,0,0);return ta}function l(I){return I<0?o((1+I)*0.5,0.5):0.5+o(I*0.5,0.5)}function c(I,Y){var U=Y.x-I.x,E=Y.y-I.y,v=1/Math.sqrt(U*U+E*E);U*=v;E*=v;Y.x+=U;Y.y+=E;I.x-=U;I.y-=E}var y=null,G=new THREE.Projector,w=document.createElement("canvas"),F,N,J,M,r=w.getContext("2d"),R=1,B= -0,e=null,f=null,i=1,o=Math.min,k=Math.max,j,A,s,L,u,T,P,t,H,p=new THREE.Color,z=new THREE.Color,x=new THREE.Color,O=new THREE.Color,D=new THREE.Color,C,W,ea,Q,V,ja,za,Aa,Ba,Ca,pa=new THREE.Rectangle,ma=new THREE.Rectangle,da=new THREE.Rectangle,va=false,ha=new THREE.Color,ga=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,Da=Math.PI*2,aa=new THREE.Vector3,sa,ra,wa,ia,ta,ua,qa=16;sa=document.createElement("canvas");sa.width=sa.height=2;ra=sa.getContext("2d");ra.fillStyle="rgba(0,0,0,1)";ra.fillRect(0, -0,2,2);wa=ra.getImageData(0,0,2,2);ia=wa.data;ta=document.createElement("canvas");ta.width=ta.height=qa;ua=ta.getContext("2d");ua.translate(-qa/2,-qa/2);ua.scale(qa,qa);qa--;this.domElement=w;this.autoClear=true;this.setSize=function(I,Y){F=I;N=Y;J=F/2;M=N/2;w.width=F;w.height=N;pa.set(-J,-M,J,M)};this.clear=function(){if(!ma.isEmpty()){ma.inflate(1);ma.minSelf(pa);r.clearRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight());ma.empty()}};this.render=function(I,Y){var U,E,v,K,$,S,X,ba;r.setTransform(1, -0,0,-1,J,M);this.autoClear&&this.clear();y=G.projectScene(I,Y);if(va=I.lights.length>0){$=I.lights;ga.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);U=0;for(E=$.length;U>1;ya=fa.height>>1;la=X.scale.x*J;ka=X.scale.y*M;ba=la*xa;ca=ka*ya;da.set(S.x-ba,S.y-ca,S.x+ba,S.y+ca);if(pa.instersects(da)){r.save();r.translate(S.x,S.y);r.rotate(-X.rotation);r.scale(la,-ka);r.translate(-xa,-ya);r.drawImage(fa,0,0); +0.5+0.5;j(L,u,T,P,t,H,v.env_map.image,V,ja,za,Aa,Ba,Ca)}}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):i(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){j(L,u,T,P,t,H,v.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);m(THREE.SubtractiveBlending)}if(va)if(!v.wireframe&&v.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){A.r=y.r=O.r=ga.r;A.g=y.g=O.g=ga.g;A.b=y.b=O.b=ga.b;a(K,E.v1.positionWorld, +E.vertexNormalsWorld[0],A);a(K,E.v2.positionWorld,E.vertexNormalsWorld[1],y);a(K,E.v3.positionWorld,E.vertexNormalsWorld[2],O);D.r=(y.r+O.r)*0.5;D.g=(y.g+O.g)*0.5;D.b=(y.b+O.b)*0.5;Q=q(A,y,O,D);j(L,u,T,P,t,H,Q,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;a(K,E.centroidWorld,E.normalWorld,ha);p.r=v.color.r*ha.r;p.g=v.color.g*ha.g;p.b=v.color.b*ha.b;p.updateStyleString();v.wireframe?d(p.__styleString,v.wireframe_linewidth):i(p.__styleString)}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth): +i(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){C=v.__2near;W=v.__farPlusNear;ea=v.__farMinusNear;A.r=A.g=A.b=1-C/(W-I.positionScreen.z*ea);y.r=y.g=y.b=1-C/(W-Y.positionScreen.z*ea);O.r=O.g=O.b=1-C/(W-U.positionScreen.z*ea);D.r=(y.r+O.r)*0.5;D.g=(y.g+O.g)*0.5;D.b=(y.b+O.b)*0.5;Q=q(A,y,O,D);j(L,u,T,P,t,H,Q,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){p.r=l(E.normalWorld.x);p.g=l(E.normalWorld.y);p.b=l(E.normalWorld.z);p.updateStyleString();v.wireframe?d(p.__styleString, +v.wireframe_linewidth):i(p.__styleString)}}}function d(I,Y){if(e!=I)r.strokeStyle=e=I;if(k!=Y)r.lineWidth=k=Y;r.stroke();da.inflate(Y*2)}function i(I){if(f!=I)r.fillStyle=f=I;r.fill()}function j(I,Y,U,E,v,K,$,S,X,ba,Z,ca,la){var ka,fa;ka=$.width-1;fa=$.height-1;S*=ka;X*=fa;ba*=ka;Z*=fa;ca*=ka;la*=fa;U-=I;E-=Y;v-=I;K-=Y;ba-=S;Z-=X;ca-=S;la-=X;fa=1/(ba*la-ca*Z);ka=(la*U-Z*v)*fa;Z=(la*E-Z*K)*fa;U=(ba*v-ca*U)*fa;E=(ba*K-ca*E)*fa;I=I-ka*S-U*X;Y=Y-Z*S-E*X;r.save();r.transform(ka,Z,U,E,I,Y);r.clip();r.drawImage($, +0,0);r.restore()}function o(I){if(R!=I)r.globalAlpha=R=I}function m(I){if(B!=I){switch(I){case THREE.NormalBlending:r.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:r.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:r.globalCompositeOperation="darker"}B=I}}function q(I,Y,U,E){ia[0]=g(0,n(255,~~(I.r*255)));ia[1]=g(0,n(255,~~(I.g*255)));ia[2]=g(0,n(255,~~(I.b*255)));ia[4]=g(0,n(255,~~(Y.r*255)));ia[5]=g(0,n(255,~~(Y.g*255)));ia[6]=g(0,n(255,~~(Y.b*255))); +ia[8]=g(0,n(255,~~(U.r*255)));ia[9]=g(0,n(255,~~(U.g*255)));ia[10]=g(0,n(255,~~(U.b*255)));ia[12]=g(0,n(255,~~(E.r*255)));ia[13]=g(0,n(255,~~(E.g*255)));ia[14]=g(0,n(255,~~(E.b*255)));ra.putImageData(wa,0,0);ua.drawImage(sa,0,0);return ta}function l(I){return I<0?n((1+I)*0.5,0.5):0.5+n(I*0.5,0.5)}function c(I,Y){var U=Y.x-I.x,E=Y.y-I.y,v=1/Math.sqrt(U*U+E*E);U*=v;E*=v;Y.x+=U;Y.y+=E;I.x-=U;I.y-=E}var z=null,G=new THREE.Projector,x=document.createElement("canvas"),F,N,J,M,r=x.getContext("2d"),R=1,B= +0,e=null,f=null,k=1,n=Math.min,g=Math.max,h,w,s,L,u,T,P,t,H,p=new THREE.Color,A=new THREE.Color,y=new THREE.Color,O=new THREE.Color,D=new THREE.Color,C,W,ea,Q,V,ja,za,Aa,Ba,Ca,pa=new THREE.Rectangle,ma=new THREE.Rectangle,da=new THREE.Rectangle,va=false,ha=new THREE.Color,ga=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,Da=Math.PI*2,aa=new THREE.Vector3,sa,ra,wa,ia,ta,ua,qa=16;sa=document.createElement("canvas");sa.width=sa.height=2;ra=sa.getContext("2d");ra.fillStyle="rgba(0,0,0,1)";ra.fillRect(0, +0,2,2);wa=ra.getImageData(0,0,2,2);ia=wa.data;ta=document.createElement("canvas");ta.width=ta.height=qa;ua=ta.getContext("2d");ua.translate(-qa/2,-qa/2);ua.scale(qa,qa);qa--;this.domElement=x;this.autoClear=true;this.setSize=function(I,Y){F=I;N=Y;J=F/2;M=N/2;x.width=F;x.height=N;pa.set(-J,-M,J,M)};this.clear=function(){if(!ma.isEmpty()){ma.inflate(1);ma.minSelf(pa);r.clearRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight());ma.empty()}};this.render=function(I,Y){var U,E,v,K,$,S,X,ba;r.setTransform(1, +0,0,-1,J,M);this.autoClear&&this.clear();z=G.projectScene(I,Y);if(va=I.lights.length>0){$=I.lights;ga.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);U=0;for(E=$.length;U>1;ya=fa.height>>1;la=X.scale.x*J;ka=X.scale.y*M;ba=la*xa;ca=ka*ya;da.set(S.x-ba,S.y-ca,S.x+ba,S.y+ca);if(pa.instersects(da)){r.save();r.translate(S.x,S.y);r.rotate(-X.rotation);r.scale(la,-ka);r.translate(-xa,-ya);r.drawImage(fa,0,0); r.restore()}}}else if(Z instanceof THREE.ParticleCircleMaterial){if(va){ha.r=ga.r+na.r+oa.r;ha.g=ga.g+na.g+oa.g;ha.b=ga.b+na.b+oa.b;p.r=Z.color.r*ha.r;p.g=Z.color.g*ha.g;p.b=Z.color.b*ha.b;p.updateStyleString()}else p.__styleString=Z.color.__styleString;ba=X.scale.x*J;ca=X.scale.y*M;da.set(S.x-ba,S.y-ca,S.x+ba,S.y+ca);if(pa.instersects(da)){Z=p.__styleString;if(f!=Z)r.fillStyle=f=Z;r.save();r.translate(S.x,S.y);r.rotate(-X.rotation);r.scale(ba,ca);r.beginPath();r.arc(0,0,1,0,Da,true);r.closePath(); -r.fill();r.restore()}}}}}else if(v instanceof THREE.RenderableLine){j=v.v1;A=v.v2;j.positionScreen.x*=J;j.positionScreen.y*=M;A.positionScreen.x*=J;A.positionScreen.y*=M;da.addPoint(j.positionScreen.x,j.positionScreen.y);da.addPoint(A.positionScreen.x,A.positionScreen.y);if(pa.instersects(da)){K=0;for($=v.material.length;K<$;){X=j;ba=A;S=v.material[K++];if(S.opacity!=0){n(S.opacity);m(S.blending);r.beginPath();r.moveTo(X.positionScreen.x,X.positionScreen.y);r.lineTo(ba.positionScreen.x,ba.positionScreen.y); -r.closePath();if(S instanceof THREE.LineBasicMaterial){p.__styleString=S.color.__styleString;X=S.linewidth;if(i!=X)r.lineWidth=i=X;X=p.__styleString;if(e!=X)r.strokeStyle=e=X;r.stroke();da.inflate(S.linewidth*2)}}}}}else if(v instanceof THREE.RenderableFace3){j=v.v1;A=v.v2;s=v.v3;j.positionScreen.x*=J;j.positionScreen.y*=M;A.positionScreen.x*=J;A.positionScreen.y*=M;s.positionScreen.x*=J;s.positionScreen.y*=M;if(v.overdraw){c(j.positionScreen,A.positionScreen);c(A.positionScreen,s.positionScreen); -c(s.positionScreen,j.positionScreen)}da.addPoint(j.positionScreen.x,j.positionScreen.y);da.addPoint(A.positionScreen.x,A.positionScreen.y);da.addPoint(s.positionScreen.x,s.positionScreen.y);if(pa.instersects(da)){K=0;for($=v.meshMaterial.length;K<$;){ba=v.meshMaterial[K++];if(ba instanceof THREE.MeshFaceMaterial){S=0;for(X=v.faceMaterial.length;S0){x.r+=C.color.r*W;x.g+=C.color.g*W;x.b+=C.color.b*W}}else if(C instanceof THREE.PointLight){j.sub(C.position,z.centroidWorld);j.normalize();W=z.normalWorld.dot(j)*C.intensity;if(W>0){x.r+=C.color.r*W;x.g+=C.color.g*W;x.b+=C.color.b*W}}}}function b(p,z,x,O,D,C){u=g(T++);u.setAttribute("d","M "+p.positionScreen.x+ -" "+p.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+"z");if(D instanceof THREE.MeshBasicMaterial)B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshLambertMaterial)if(R){e.r=f.r;e.g=f.g;e.b=f.b;a(C,O,e);B.r=D.color.r*e.r;B.g=D.color.g*e.g;B.b=D.color.b*e.b;B.updateStyleString()}else B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshDepthMaterial){k=1-D.__2near/(D.__farPlusNear-O.z*D.__farMinusNear); -B.setRGB(k,k,k)}else D instanceof THREE.MeshNormalMaterial&&B.setRGB(h(O.normalWorld.x),h(O.normalWorld.y),h(O.normalWorld.z));D.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+D.wireframe_linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframe_linecap+"; stroke-linejoin: "+D.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+D.opacity);q.appendChild(u)}function d(p,z,x,O,D,C,W){u=g(T++);u.setAttribute("d", -"M "+p.positionScreen.x+" "+p.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)B.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(R){e.r=f.r;e.g=f.g;e.b=f.b;a(W,D,e);B.r=C.color.r*e.r;B.g=C.color.g*e.g;B.b=C.color.b*e.b;B.updateStyleString()}else B.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){k= -1-C.__2near/(C.__farPlusNear-D.z*C.__farMinusNear);B.setRGB(k,k,k)}else C instanceof THREE.MeshNormalMaterial&&B.setRGB(h(D.normalWorld.x),h(D.normalWorld.y),h(D.normalWorld.z));C.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+C.opacity);q.appendChild(u)} -function g(p){if(A[p]==null){A[p]=document.createElementNS("http://www.w3.org/2000/svg","path");H==0&&A[p].setAttribute("shape-rendering","crispEdges");return A[p]}return A[p]}function h(p){return p<0?Math.min((1+p)*0.5,0.5):0.5+Math.min(p*0.5,0.5)}var n=null,m=new THREE.Projector,q=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,c,y,G,w,F,N,J,M=new THREE.Rectangle,r=new THREE.Rectangle,R=false,B=new THREE.Color(16777215),e=new THREE.Color(16777215),f=new THREE.Color(0),i=new THREE.Color(0), -o=new THREE.Color(0),k,j=new THREE.Vector3,A=[],s=[],L=[],u,T,P,t,H=1;this.domElement=q;this.autoClear=true;this.setQuality=function(p){switch(p){case "high":H=1;break;case "low":H=0}};this.setSize=function(p,z){l=p;c=z;y=l/2;G=c/2;q.setAttribute("viewBox",-y+" "+-G+" "+l+" "+c);q.setAttribute("width",l);q.setAttribute("height",c);M.set(-y,-G,y,G)};this.clear=function(){for(;q.childNodes.length>0;)q.removeChild(q.childNodes[0])};this.render=function(p,z){var x,O,D,C,W,ea,Q,V;this.autoClear&&this.clear(); -n=m.projectScene(p,z);t=P=T=0;if(R=p.lights.length>0){Q=p.lights;f.setRGB(0,0,0);i.setRGB(0,0,0);o.setRGB(0,0,0);x=0;for(O=Q.length;x0){y.r+=C.color.r*W;y.g+=C.color.g*W;y.b+=C.color.b*W}}else if(C instanceof THREE.PointLight){h.sub(C.position,A.centroidWorld);h.normalize();W=A.normalWorld.dot(h)*C.intensity;if(W>0){y.r+=C.color.r*W;y.g+=C.color.g*W;y.b+=C.color.b*W}}}}function b(p,A,y,O,D,C){u=i(T++);u.setAttribute("d","M "+p.positionScreen.x+ +" "+p.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+"z");if(D instanceof THREE.MeshBasicMaterial)B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshLambertMaterial)if(R){e.r=f.r;e.g=f.g;e.b=f.b;a(C,O,e);B.r=D.color.r*e.r;B.g=D.color.g*e.g;B.b=D.color.b*e.b;B.updateStyleString()}else B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshDepthMaterial){g=1-D.__2near/(D.__farPlusNear-O.z*D.__farMinusNear); +B.setRGB(g,g,g)}else D instanceof THREE.MeshNormalMaterial&&B.setRGB(j(O.normalWorld.x),j(O.normalWorld.y),j(O.normalWorld.z));D.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+D.wireframe_linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframe_linecap+"; stroke-linejoin: "+D.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+D.opacity);q.appendChild(u)}function d(p,A,y,O,D,C,W){u=i(T++);u.setAttribute("d", +"M "+p.positionScreen.x+" "+p.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)B.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(R){e.r=f.r;e.g=f.g;e.b=f.b;a(W,D,e);B.r=C.color.r*e.r;B.g=C.color.g*e.g;B.b=C.color.b*e.b;B.updateStyleString()}else B.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){g= +1-C.__2near/(C.__farPlusNear-D.z*C.__farMinusNear);B.setRGB(g,g,g)}else C instanceof THREE.MeshNormalMaterial&&B.setRGB(j(D.normalWorld.x),j(D.normalWorld.y),j(D.normalWorld.z));C.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+C.opacity);q.appendChild(u)} +function i(p){if(w[p]==null){w[p]=document.createElementNS("http://www.w3.org/2000/svg","path");H==0&&w[p].setAttribute("shape-rendering","crispEdges");return w[p]}return w[p]}function j(p){return p<0?Math.min((1+p)*0.5,0.5):0.5+Math.min(p*0.5,0.5)}var o=null,m=new THREE.Projector,q=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,c,z,G,x,F,N,J,M=new THREE.Rectangle,r=new THREE.Rectangle,R=false,B=new THREE.Color(16777215),e=new THREE.Color(16777215),f=new THREE.Color(0),k=new THREE.Color(0), +n=new THREE.Color(0),g,h=new THREE.Vector3,w=[],s=[],L=[],u,T,P,t,H=1;this.domElement=q;this.autoClear=true;this.setQuality=function(p){switch(p){case "high":H=1;break;case "low":H=0}};this.setSize=function(p,A){l=p;c=A;z=l/2;G=c/2;q.setAttribute("viewBox",-z+" "+-G+" "+l+" "+c);q.setAttribute("width",l);q.setAttribute("height",c);M.set(-z,-G,z,G)};this.clear=function(){for(;q.childNodes.length>0;)q.removeChild(q.childNodes[0])};this.render=function(p,A){var y,O,D,C,W,ea,Q,V;this.autoClear&&this.clear(); +o=m.projectScene(p,A);t=P=T=0;if(R=p.lights.length>0){Q=p.lights;f.setRGB(0,0,0);k.setRGB(0,0,0);n.setRGB(0,0,0);y=0;for(O=Q.length;y= 0.0 )": "",f?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",f?"pointDiffuse += mColor * pointDiffuseWeight;":"",f?"pointSpecular += mSpecular * pointSpecularWeight;":"",f?"}":"",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;":"",f?"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"); -y=b(o,i);c.useProgram(y);h(y,["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&&h(y,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);f&&h(y,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(y.uniforms.enableMap,0);c.uniform1i(y.uniforms.tMap,0);c.uniform1i(y.uniforms.enableCubeMap,0);c.uniform1i(y.uniforms.tCube,1);c.uniform1i(y.uniforms.mixEnvMap,0);c.uniform1i(y.uniforms.useRefract,0);n(y)})(a.directional,a.point);this.setSize=function(e,f){l.width=e;l.height=f;c.viewport(0,0,l.width,l.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,f){var i,o,k,j,A,s=[],L=[],u=[];j=[];A=[];c.uniform1i(e.uniforms.enableLighting, -f.lights.length);i=0;for(o=f.lights.length;i=0;i--){o=e.__webGLObjects[i].__object;f==o&&e.__webGLObjects.splice(i,1)}};this.setupMatrices=function(e,f){e.autoUpdateMatrix&&e.updateMatrix();w.multiply(f.matrix,e.matrix);N.set(f.matrix.flatten());J.set(w.flatten());M.set(f.projectionMatrix.flatten());F=THREE.Matrix4.makeInvert3x3(w).transpose();r.set(F.m); -R.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,N);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,J);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,M);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,r);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,R)};this.loadCamera=function(e,f){c.uniform3f(e.uniforms.cameraPosition,f.position.x,f.position.y,f.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD); +z=b(n,k);c.useProgram(z);j(z,["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(z,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);f&&j(z,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(z.uniforms.enableMap,0);c.uniform1i(z.uniforms.tMap,0);c.uniform1i(z.uniforms.enableCubeMap,0);c.uniform1i(z.uniforms.tCube,1);c.uniform1i(z.uniforms.mixEnvMap,0);c.uniform1i(z.uniforms.useRefract,0);o(z)})(a.directional,a.point);this.setSize=function(e,f){l.width=e;l.height=f;c.viewport(0,0,l.width,l.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,f){var k,n,g,h,w,s=[],L=[],u=[];h=[];w=[];c.uniform1i(e.uniforms.enableLighting, +f.lights.length);k=0;for(n=f.lights.length;k=0;k--){n=e.__webGLObjects[k].object;f==n&&e.__webGLObjects.splice(k,1)}};this.setupMatrices=function(e,f){e.autoUpdateMatrix&&e.updateMatrix();x.multiply(f.matrix,e.matrix);N.set(f.matrix.flatten());J.set(x.flatten());M.set(f.projectionMatrix.flatten());F=THREE.Matrix4.makeInvert3x3(x).transpose(); +r.set(F.m);R.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,N);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,J);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,M);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,r);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,R)};this.loadCamera=function(e,f){c.uniform3f(e.uniforms.cameraPosition,f.position.x,f.position.y,f.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,f){if(e){!f||f=="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)}}; 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 b7fa1fc9f8b5f1fc328cfc5b63808e54f6be0235..7dcc982d985287877794ed70d843eb740d3c1022 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -5,58 +5,57 @@ 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,i=this.z;this.x=d*a.z-i*a.y;this.y=i*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,i){this.x=a||0;this.y=b||0;this.z=d||0;this.w=i||1}; +THREE.Vector4.prototype={set:function(a,b,d,i){this.x=a;this.y=b;this.z=d;this.w=i;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,h=[];a=0;for(b=g.length;a0&&M>0&&f+M<1}var d,g,h,o,m,r,l,c,y,G, -w,F=a.geometry,O=F.vertices,J=[];d=0;for(g=F.faces.length;d= -0&&Math.min(h,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){r=true;h=g=d=b=0;a()};this.isEmpty=function(){return r};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+g+", top: "+d+", bottom: "+h+", width: "+o+", 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,i=a.objects,j=[];a=0;for(b=i.length;a0&&M>0&&f+M<1}var d,i,j,p,m,r,l,c,z,G, +x,F=a.geometry,O=F.vertices,J=[];d=0;for(i=F.faces.length;d= +0&&Math.min(j,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){r=true;j=i=d=b=0;a()};this.isEmpty=function(){return r};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+i+", top: "+d+", bottom: "+j+", width: "+p+", 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.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,h=new THREE.Vector3,o=new THREE.Vector3;o.sub(a,b).normalize();g.cross(d,o).normalize();h.cross(o,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=h.x;this.n22=h.y;this.n23=h.z;this.n24=-h.dot(a);this.n31=o.x;this.n32=o.y;this.n33=o.z;this.n34=-o.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},transformVector3:function(a){var b=a.x,d=a.y,g=a.z,h=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)*h;a.y=(this.n21*b+this.n22*d+this.n23*g+this.n24)*h;a.z=(this.n31*b+this.n32*d+this.n33*g+this.n34)*h;return a},transformVector4:function(a){var b=a.x,d=a.y,g=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*g+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*g+this.n24*h;a.z=this.n31*b+this.n32*d+this.n33*g+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*g+this.n44*h;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,h=a.n13,o=a.n14,m=a.n21,r=a.n22,l=a.n23,c=a.n24,y=a.n31,G=a.n32,w=a.n33,F=a.n34,O=a.n41,J=a.n42,M=a.n43,n=a.n44,S=b.n11,B=b.n12,e=b.n13,f=b.n14,i=b.n21,p=b.n22,k=b.n23,j=b.n24,A=b.n31,s=b.n32,L=b.n33,u=b.n34,T=b.n41,Q=b.n42,t=b.n43, -H=b.n44;this.n11=d*S+g*i+h*A+o*T;this.n12=d*B+g*p+h*s+o*Q;this.n13=d*e+g*k+h*L+o*t;this.n14=d*f+g*j+h*u+o*H;this.n21=m*S+r*i+l*A+c*T;this.n22=m*B+r*p+l*s+c*Q;this.n23=m*e+r*k+l*L+c*t;this.n24=m*f+r*j+l*u+c*H;this.n31=y*S+G*i+w*A+F*T;this.n32=y*B+G*p+w*s+F*Q;this.n33=y*e+G*k+w*L+F*t;this.n34=y*f+G*j+w*u+F*H;this.n41=O*S+J*i+M*A+n*T;this.n42=O*B+J*p+M*s+n*Q;this.n43=O*e+J*k+M*L+n*t;this.n44=O*f+J*j+M*u+n*H},multiplySelf:function(a){var b=this.n11,d=this.n12,g=this.n13,h=this.n14,o=this.n21,m=this.n22, -r=this.n23,l=this.n24,c=this.n31,y=this.n32,G=this.n33,w=this.n34,F=this.n41,O=this.n42,J=this.n43,M=this.n44;this.n11=b*a.n11+d*a.n21+g*a.n31+h*a.n41;this.n12=b*a.n12+d*a.n22+g*a.n32+h*a.n42;this.n13=b*a.n13+d*a.n23+g*a.n33+h*a.n43;this.n14=b*a.n14+d*a.n24+g*a.n34+h*a.n44;this.n21=o*a.n11+m*a.n21+r*a.n31+l*a.n41;this.n22=o*a.n12+m*a.n22+r*a.n32+l*a.n42;this.n23=o*a.n13+m*a.n23+r*a.n33+l*a.n43;this.n24=o*a.n14+m*a.n24+r*a.n34+l*a.n44;this.n31=c*a.n11+y*a.n21+G*a.n31+w*a.n41;this.n32=c*a.n12+y*a.n22+ -G*a.n32+w*a.n42;this.n33=c*a.n13+y*a.n23+G*a.n33+w*a.n43;this.n34=c*a.n14+y*a.n24+G*a.n34+w*a.n44;this.n41=F*a.n11+O*a.n21+J*a.n31+M*a.n41;this.n42=F*a.n12+O*a.n22+J*a.n32+M*a.n42;this.n43=F*a.n13+O*a.n23+J*a.n33+M*a.n43;this.n44=F*a.n14+O*a.n24+J*a.n34+M*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 i=new THREE.Vector3,j=new THREE.Vector3,p=new THREE.Vector3;p.sub(a,b).normalize();i.cross(d,p).normalize();j.cross(p,i).normalize();this.n11=i.x;this.n12=i.y;this.n13=i.z;this.n14=-i.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a);this.n31=p.x;this.n32=p.y;this.n33=p.z;this.n34=-p.dot(a);this.n43=this.n42=this.n41=0;this.n44=1},transformVector3:function(a){var b=a.x,d=a.y,i=a.z,j=1/(this.n41*b+this.n42* +d+this.n43*i+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*i+this.n14)*j;a.y=(this.n21*b+this.n22*d+this.n23*i+this.n24)*j;a.z=(this.n31*b+this.n32*d+this.n33*i+this.n34)*j;return a},transformVector4:function(a){var b=a.x,d=a.y,i=a.z,j=a.w;a.x=this.n11*b+this.n12*d+this.n13*i+this.n14*j;a.y=this.n21*b+this.n22*d+this.n23*i+this.n24*j;a.z=this.n31*b+this.n32*d+this.n33*i+this.n34*j;a.w=this.n41*b+this.n42*d+this.n43*i+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,i=a.n12,j=a.n13,p=a.n14,m=a.n21,r=a.n22,l=a.n23,c=a.n24,z=a.n31,G=a.n32,x=a.n33,F=a.n34,O=a.n41,J=a.n42,M=a.n43,n=a.n44,S=b.n11,B=b.n12,e=b.n13,f=b.n14,k=b.n21,o=b.n22,g=b.n23,h=b.n24,w=b.n31,s=b.n32,L=b.n33,u=b.n34,T=b.n41,Q=b.n42,t=b.n43, +H=b.n44;this.n11=d*S+i*k+j*w+p*T;this.n12=d*B+i*o+j*s+p*Q;this.n13=d*e+i*g+j*L+p*t;this.n14=d*f+i*h+j*u+p*H;this.n21=m*S+r*k+l*w+c*T;this.n22=m*B+r*o+l*s+c*Q;this.n23=m*e+r*g+l*L+c*t;this.n24=m*f+r*h+l*u+c*H;this.n31=z*S+G*k+x*w+F*T;this.n32=z*B+G*o+x*s+F*Q;this.n33=z*e+G*g+x*L+F*t;this.n34=z*f+G*h+x*u+F*H;this.n41=O*S+J*k+M*w+n*T;this.n42=O*B+J*o+M*s+n*Q;this.n43=O*e+J*g+M*L+n*t;this.n44=O*f+J*h+M*u+n*H},multiplySelf:function(a){var b=this.n11,d=this.n12,i=this.n13,j=this.n14,p=this.n21,m=this.n22, +r=this.n23,l=this.n24,c=this.n31,z=this.n32,G=this.n33,x=this.n34,F=this.n41,O=this.n42,J=this.n43,M=this.n44;this.n11=b*a.n11+d*a.n21+i*a.n31+j*a.n41;this.n12=b*a.n12+d*a.n22+i*a.n32+j*a.n42;this.n13=b*a.n13+d*a.n23+i*a.n33+j*a.n43;this.n14=b*a.n14+d*a.n24+i*a.n34+j*a.n44;this.n21=p*a.n11+m*a.n21+r*a.n31+l*a.n41;this.n22=p*a.n12+m*a.n22+r*a.n32+l*a.n42;this.n23=p*a.n13+m*a.n23+r*a.n33+l*a.n43;this.n24=p*a.n14+m*a.n24+r*a.n34+l*a.n44;this.n31=c*a.n11+z*a.n21+G*a.n31+x*a.n41;this.n32=c*a.n12+z*a.n22+ +G*a.n32+x*a.n42;this.n33=c*a.n13+z*a.n23+G*a.n33+x*a.n43;this.n34=c*a.n14+z*a.n24+G*a.n34+x*a.n44;this.n41=F*a.n11+O*a.n21+J*a.n31+M*a.n41;this.n42=F*a.n12+O*a.n22+J*a.n32+M*a.n42;this.n43=F*a.n13+O*a.n23+J*a.n33+M*a.n43;this.n44=F*a.n14+O*a.n24+J*a.n34+M*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 h=b[d];b[d]=b[g];b[g]=h}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,i){var j=b[d];b[d]=b[i];b[i]=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 i=new THREE.Matrix4;i.n14=a;i.n24=b;i.n34=d;return i};THREE.Matrix4.scaleMatrix=function(a,b,d){var i=new THREE.Matrix4;i.n11=a;i.n22=b;i.n33=d;return i}; 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),h=Math.sin(b),o=1-g,m=a.x,r=a.y,l=a.z;d.n11=o*m*m+g;d.n12=o*m*r-h*l;d.n13=o*m*l+h*r;d.n21=o*m*r+h*l;d.n22=o*r*r+g;d.n23=o*r*l-h*m;d.n31=o*m*l-h*r;d.n32=o*r*l+h*m;d.n33=o*l*l+g;return d}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,i=Math.cos(b),j=Math.sin(b),p=1-i,m=a.x,r=a.y,l=a.z;d.n11=p*m*m+i;d.n12=p*m*r-j*l;d.n13=p*m*l+j*r;d.n21=p*m*r+j*l;d.n22=p*r*r+i;d.n23=p*r*l-j*m;d.n31=p*m*l-j*r;d.n32=p*r*l+j*m;d.n33=p*l*l+i;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],h=b[6]*b[1]-b[2]*b[5],o=-b[10]*b[4]+b[6]*b[8],m=b[10]*b[0]-b[2]*b[8],r=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],y=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*o+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*g;a.m[2]=b*h;a.m[3]=b*o;a.m[4]=b*m;a.m[5]=b*r;a.m[6]=b*l;a.m[7]=b*c;a.m[8]=b*y;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,g,h,o){var m,r,l;m=new THREE.Matrix4;r=2*h/(b-a);l=2*h/(g-d);a=(b+a)/(b-a);d=(g+d)/(g-d);g=-(o+h)/(o-h);h=-2*o*h/(o-h);m.n11=r;m.n12=0;m.n13=a;m.n14=0;m.n21=0;m.n22=l;m.n23=d;m.n24=0;m.n31=0;m.n32=0;m.n33=g;m.n34=h;m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,g){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,g)}; -THREE.Matrix4.makeOrtho=function(a,b,d,g,h,o){var m,r,l,c;m=new THREE.Matrix4;r=b-a;l=d-g;c=o-h;a=(b+a)/r;d=(d+g)/l;h=(o+h)/c;m.n11=2/r;m.n12=0;m.n13=0;m.n14=-a;m.n21=0;m.n22=2/l;m.n23=0;m.n24=-d;m.n31=0;m.n32=0;m.n33=-2/c;m.n34=-h;m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var d=b[10]*b[5]-b[6]*b[9],i=-b[10]*b[1]+b[2]*b[9],j=b[6]*b[1]-b[2]*b[5],p=-b[10]*b[4]+b[6]*b[8],m=b[10]*b[0]-b[2]*b[8],r=-b[6]*b[0]+b[2]*b[4],l=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],z=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*p+b[2]*l;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*i;a.m[2]=b*j;a.m[3]=b*p;a.m[4]=b*m;a.m[5]=b*r;a.m[6]=b*l;a.m[7]=b*c;a.m[8]=b*z;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,i,j,p){var m,r,l;m=new THREE.Matrix4;r=2*j/(b-a);l=2*j/(i-d);a=(b+a)/(b-a);d=(i+d)/(i-d);i=-(p+j)/(p-j);j=-2*p*j/(p-j);m.n11=r;m.n12=0;m.n13=a;m.n14=0;m.n21=0;m.n22=l;m.n23=d;m.n24=0;m.n31=0;m.n32=0;m.n33=i;m.n34=j;m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(a,b,d,i){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*b,a*b,j,a,d,i)}; +THREE.Matrix4.makeOrtho=function(a,b,d,i,j,p){var m,r,l,c;m=new THREE.Matrix4;r=b-a;l=d-i;c=p-j;a=(b+a)/r;d=(d+i)/l;j=(p+j)/c;m.n11=2/r;m.n12=0;m.n13=0;m.n14=-a;m.n21=0;m.n22=2/l;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,h){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=h instanceof Array?h:[h]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,b,d,g,h,o){this.a=a;this.b=b;this.c=d;this.d=g;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.material=o instanceof Array?o:[o]};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=[]}; -THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a +THREE.Face3=function(a,b,d,i,j){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];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,i,j,p){this.a=a;this.b=b;this.c=d;this.d=i;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.material=p instanceof Array?p:[p]};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.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a 0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y -this.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}}; -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)}; +this.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(z){var G=[];b=0;for(d=z.length;b65535){c[r].counter+=1;l=c[r].hash+"_"+c[r].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],material:m,vertices:0}}this.geometryChunks[l].faces.push(i);this.geometryChunks[l].vertices+=p}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}}; +THREE.Camera=function(a,b,d,i){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,i);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.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.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;this.materialFaceGroup={};this.sortFacesByMaterial();d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh; -THREE.Mesh.prototype.sortFacesByMaterial=function(){function a(y){var G=[];b=0;for(d=y.length;b65535){c[r].counter+=1;l=c[r].hash+"_"+c[r].counter;if(this.materialFaceGroup[l]==undefined)this.materialFaceGroup[l]={faces:[],material:m,vertices:0}}this.materialFaceGroup[l].faces.push(g);this.materialFaceGroup[l].vertices+=o}};THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,g,h;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.Multiply;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=a.map;if(a.env_map!== @@ -80,90 +79,90 @@ a.uniforms;if(a.shading!==undefined)this.shading=a.shading;if(a.blending!==undef this.blending+"
wireframe: "+this.wireframe+"
wireframe_linewidth: "+this.wireframe_linewidth+"
wireframe_linecap: "+this.wireframe_linecap+"
wireframe_linejoin: "+this.wireframe_linejoin+"
)"}};THREE.MeshShaderMaterialCounter={value:0}; 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){this.image=a;this.loaded=false;this.mapping=b!==undefined?b:THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=g!==undefined?g:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
)"}}; +THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b,d,i){this.image=a;this.loaded=false;this.mapping=b!==undefined?b:THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=i!==undefined?i:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
)"}}; THREE.UVMapping=0;THREE.ReflectionMapping=1;THREE.RefractionMapping=2;THREE.Multiply=0;THREE.Mix=1;THREE.Repeat=0;THREE.ClampToEdge=1;THREE.MirroredRepeat=2;THREE.TextureCube=function(a,b){this.image=a;this.mapping=b?b:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (
image: "+this.image+"
mapping: "+this.mapping+"
)"}}; 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(S,B){var e=0,f=1,i=S.z+S.w,p=B.z+B.w,k=-S.z+S.w,j=-B.z+B.w;if(i>=0&&p>=0&&k>=0&&j>=0)return true;else if(i<0&&p<0||k<0&&j<0)return false;else{if(i<0)e=Math.max(e,i/(i-p));else if(p<0)f=Math.min(f,i/(i-p));if(k<0)e=Math.max(e,k/(k-j));else if(j<0)f=Math.min(f,k/(k-j));if(f0&&q.z<1}H=s.geometry.faces;i=0;for(p=H.length;i0&&w.z<1){c=G[y]=G[y]||new THREE.RenderableParticle;c.x=w.x/w.w;c.y=w.y/w.w;c.z=w.z;c.rotation=s.rotation.z;c.scale.x=s.scale.x*Math.abs(c.x-(w.x+B.projectionMatrix.n11)/(w.w+B.projectionMatrix.n14));c.scale.y=s.scale.y*Math.abs(c.y-(w.y+B.projectionMatrix.n22)/(w.w+B.projectionMatrix.n24));c.material=s.material;b.push(c);y++}}}b.sort(function(P,D){return D.z-P.z});return b};this.unprojectVector=function(S,B){var e=new THREE.Matrix4; +THREE.Projector=function(){function a(S,B){var e=0,f=1,k=S.z+S.w,o=B.z+B.w,g=-S.z+S.w,h=-B.z+B.w;if(k>=0&&o>=0&&g>=0&&h>=0)return true;else if(k<0&&o<0||g<0&&h<0)return false;else{if(k<0)e=Math.max(e,k/(k-o));else if(o<0)f=Math.min(f,k/(k-o));if(g<0)e=Math.max(e,g/(g-h));else if(h<0)f=Math.min(f,g/(g-h));if(f0&&q.z<1}H=s.geometry.faces;k=0;for(o=H.length;k0&&x.z<1){c=G[z]=G[z]||new THREE.RenderableParticle;c.x=x.x/x.w;c.y=x.y/x.w;c.z=x.z;c.rotation=s.rotation.z;c.scale.x=s.scale.x*Math.abs(c.x-(x.x+B.projectionMatrix.n11)/(x.w+B.projectionMatrix.n14));c.scale.y=s.scale.y*Math.abs(c.y-(x.y+B.projectionMatrix.n22)/(x.w+B.projectionMatrix.n24));c.material=s.material;b.push(c);z++}}}b.sort(function(P,D){return D.z-P.z});return b};this.unprojectVector=function(S,B){var e=new THREE.Matrix4; e.multiply(THREE.Matrix4.makeInvert(B.matrix),THREE.Matrix4.makeInvert(B.projectionMatrix));e.transformVector3(S);return S}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,g,h,o;this.domElement=document.createElement("div");this.setSize=function(m,r){d=m;g=r;h=d/2;o=g/2};this.render=function(m,r){var l,c,y,G,w,F,O,J;a=b.projectScene(m,r);l=0;for(c=a.length;l0){E.r+=$.r*K;E.g+=$.g*K;E.b+=$.b*K}}else if(K instanceof THREE.PointLight){aa.sub(K.position,Y);aa.normalize();K=U.dot(aa)*N;if(K>0){E.r+=$.r*K;E.g+=$.g*K;E.b+=$.b*K}}}}function b(I,Y,U,E,v,K){if(v.opacity!=0){o(v.opacity);m(v.blending);L=I.positionScreen.x;u=I.positionScreen.y;T=Y.positionScreen.x; -Q=Y.positionScreen.y;t=U.positionScreen.x;H=U.positionScreen.y;var $=L,N=u,X=T,ba=Q,Z=t,ca=H;n.beginPath();n.moveTo($,N);n.lineTo(X,ba);n.lineTo(Z,ca);n.lineTo($,N);n.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map&&v.map.loaded)h(L,u,T,Q,t,H,v.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(v.env_map&&v.env_map.loaded){if(v.env_map.mapping==THREE.ReflectionMapping){aa.copy(E.vertexNormalsWorld[0]);V=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+ +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,i,j,p;this.domElement=document.createElement("div");this.setSize=function(m,r){d=m;i=r;j=d/2;p=i/2};this.render=function(m,r){var l,c,z,G,x,F,O,J;a=b.projectScene(m,r);l=0;for(c=a.length;l0){E.r+=$.r*K;E.g+=$.g*K;E.b+=$.b*K}}else if(K instanceof THREE.PointLight){aa.sub(K.position,Y);aa.normalize();K=U.dot(aa)*N;if(K>0){E.r+=$.r*K;E.g+=$.g*K;E.b+=$.b*K}}}}function b(I,Y,U,E,v,K){if(v.opacity!=0){p(v.opacity);m(v.blending);L=I.positionScreen.x;u=I.positionScreen.y;T=Y.positionScreen.x; +Q=Y.positionScreen.y;t=U.positionScreen.x;H=U.positionScreen.y;var $=L,N=u,X=T,ba=Q,Z=t,ca=H;n.beginPath();n.moveTo($,N);n.lineTo(X,ba);n.lineTo(Z,ca);n.lineTo($,N);n.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map&&v.map.loaded)j(L,u,T,Q,t,H,v.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);else if(v.env_map&&v.env_map.loaded){if(v.env_map.mapping==THREE.ReflectionMapping){aa.copy(E.vertexNormalsWorld[0]);V=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+ aa.z*camera.matrix.n13)*0.5+0.5;ka=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*0.5+0.5;aa.copy(E.vertexNormalsWorld[1]);za=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+aa.z*camera.matrix.n13)*0.5+0.5;Aa=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)*0.5+0.5;aa.copy(E.vertexNormalsWorld[2]);Ba=(aa.x*camera.matrix.n11+aa.y*camera.matrix.n12+aa.z*camera.matrix.n13)*0.5+0.5;Ca=-(aa.x*camera.matrix.n21+aa.y*camera.matrix.n22+aa.z*camera.matrix.n23)* -0.5+0.5;h(L,u,T,Q,t,H,v.env_map.image,V,ka,za,Aa,Ba,Ca)}}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):g(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){h(L,u,T,Q,t,H,v.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);m(THREE.SubtractiveBlending)}if(va)if(!v.wireframe&&v.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){z.r=x.r=P.r=ga.r;z.g=x.g=P.g=ga.g;z.b=x.b=P.b=ga.b;a(K,E.v1.positionWorld, -E.vertexNormalsWorld[0],z);a(K,E.v2.positionWorld,E.vertexNormalsWorld[1],x);a(K,E.v3.positionWorld,E.vertexNormalsWorld[2],P);D.r=(x.r+P.r)*0.5;D.g=(x.g+P.g)*0.5;D.b=(x.b+P.b)*0.5;R=r(z,x,P,D);h(L,u,T,Q,t,H,R,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;a(K,E.centroidWorld,E.normalWorld,ha);q.r=v.color.r*ha.r;q.g=v.color.g*ha.g;q.b=v.color.b*ha.b;q.updateStyleString();v.wireframe?d(q.__styleString,v.wireframe_linewidth):g(q.__styleString)}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth): -g(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){C=v.__2near;W=v.__farPlusNear;ea=v.__farMinusNear;z.r=z.g=z.b=1-C/(W-I.positionScreen.z*ea);x.r=x.g=x.b=1-C/(W-Y.positionScreen.z*ea);P.r=P.g=P.b=1-C/(W-U.positionScreen.z*ea);D.r=(x.r+P.r)*0.5;D.g=(x.g+P.g)*0.5;D.b=(x.b+P.b)*0.5;R=r(z,x,P,D);h(L,u,T,Q,t,H,R,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){q.r=l(E.normalWorld.x);q.g=l(E.normalWorld.y);q.b=l(E.normalWorld.z);q.updateStyleString();v.wireframe?d(q.__styleString, -v.wireframe_linewidth):g(q.__styleString)}}}function d(I,Y){if(e!=I)n.strokeStyle=e=I;if(i!=Y)n.lineWidth=i=Y;n.stroke();da.inflate(Y*2)}function g(I){if(f!=I)n.fillStyle=f=I;n.fill()}function h(I,Y,U,E,v,K,$,N,X,ba,Z,ca,na){var la,fa;la=$.width-1;fa=$.height-1;N*=la;X*=fa;ba*=la;Z*=fa;ca*=la;na*=fa;U-=I;E-=Y;v-=I;K-=Y;ba-=N;Z-=X;ca-=N;na-=X;fa=1/(ba*na-ca*Z);la=(na*U-Z*v)*fa;Z=(na*E-Z*K)*fa;U=(ba*v-ca*U)*fa;E=(ba*K-ca*E)*fa;I=I-la*N-U*X;Y=Y-Z*N-E*X;n.save();n.transform(la,Z,U,E,I,Y);n.clip();n.drawImage($, -0,0);n.restore()}function o(I){if(S!=I)n.globalAlpha=S=I}function m(I){if(B!=I){switch(I){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}B=I}}function r(I,Y,U,E){ia[0]=k(0,p(255,~~(I.r*255)));ia[1]=k(0,p(255,~~(I.g*255)));ia[2]=k(0,p(255,~~(I.b*255)));ia[4]=k(0,p(255,~~(Y.r*255)));ia[5]=k(0,p(255,~~(Y.g*255)));ia[6]=k(0,p(255,~~(Y.b*255))); -ia[8]=k(0,p(255,~~(U.r*255)));ia[9]=k(0,p(255,~~(U.g*255)));ia[10]=k(0,p(255,~~(U.b*255)));ia[12]=k(0,p(255,~~(E.r*255)));ia[13]=k(0,p(255,~~(E.g*255)));ia[14]=k(0,p(255,~~(E.b*255)));ra.putImageData(wa,0,0);ua.drawImage(sa,0,0);return ta}function l(I){return I<0?p((1+I)*0.5,0.5):0.5+p(I*0.5,0.5)}function c(I,Y){var U=Y.x-I.x,E=Y.y-I.y,v=1/Math.sqrt(U*U+E*E);U*=v;E*=v;Y.x+=U;Y.y+=E;I.x-=U;I.y-=E}var y=null,G=new THREE.Projector,w=document.createElement("canvas"),F,O,J,M,n=w.getContext("2d"),S=1,B= -0,e=null,f=null,i=1,p=Math.min,k=Math.max,j,A,s,L,u,T,Q,t,H,q=new THREE.Color,z=new THREE.Color,x=new THREE.Color,P=new THREE.Color,D=new THREE.Color,C,W,ea,R,V,ka,za,Aa,Ba,Ca,ma=new THREE.Rectangle,ja=new THREE.Rectangle,da=new THREE.Rectangle,va=false,ha=new THREE.Color,ga=new THREE.Color,oa=new THREE.Color,pa=new THREE.Color,Da=Math.PI*2,aa=new THREE.Vector3,sa,ra,wa,ia,ta,ua,qa=16;sa=document.createElement("canvas");sa.width=sa.height=2;ra=sa.getContext("2d");ra.fillStyle="rgba(0,0,0,1)";ra.fillRect(0, -0,2,2);wa=ra.getImageData(0,0,2,2);ia=wa.data;ta=document.createElement("canvas");ta.width=ta.height=qa;ua=ta.getContext("2d");ua.translate(-qa/2,-qa/2);ua.scale(qa,qa);qa--;this.domElement=w;this.autoClear=true;this.setSize=function(I,Y){F=I;O=Y;J=F/2;M=O/2;w.width=F;w.height=O;ma.set(-J,-M,J,M)};this.clear=function(){if(!ja.isEmpty()){ja.inflate(1);ja.minSelf(ma);n.clearRect(ja.getX(),ja.getY(),ja.getWidth(),ja.getHeight());ja.empty()}};this.render=function(I,Y){var U,E,v,K,$,N,X,ba;n.setTransform(1, -0,0,-1,J,M);this.autoClear&&this.clear();y=G.projectScene(I,Y);n.fillStyle="rgba(0, 255, 255, 0.5)";n.fillRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight());if(va=I.lights.length>0){$=I.lights;ga.setRGB(0,0,0);oa.setRGB(0,0,0);pa.setRGB(0,0,0);U=0;for(E=$.length;U>1;ya=fa.height>>1;na=X.scale.x*J;la=X.scale.y*M;ba=na*xa;ca=la*ya;da.set(N.x-ba,N.y-ca,N.x+ba,N.y+ca);if(!ma.instersects(da))break a;n.save(); +0.5+0.5;j(L,u,T,Q,t,H,v.env_map.image,V,ka,za,Aa,Ba,Ca)}}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth):i(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){j(L,u,T,Q,t,H,v.map.image,E.uvs[0].u,E.uvs[0].v,E.uvs[1].u,E.uvs[1].v,E.uvs[2].u,E.uvs[2].v);m(THREE.SubtractiveBlending)}if(va)if(!v.wireframe&&v.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){A.r=y.r=P.r=ga.r;A.g=y.g=P.g=ga.g;A.b=y.b=P.b=ga.b;a(K,E.v1.positionWorld, +E.vertexNormalsWorld[0],A);a(K,E.v2.positionWorld,E.vertexNormalsWorld[1],y);a(K,E.v3.positionWorld,E.vertexNormalsWorld[2],P);D.r=(y.r+P.r)*0.5;D.g=(y.g+P.g)*0.5;D.b=(y.b+P.b)*0.5;R=r(A,y,P,D);j(L,u,T,Q,t,H,R,0,0,1,0,0,1)}else{ha.r=ga.r;ha.g=ga.g;ha.b=ga.b;a(K,E.centroidWorld,E.normalWorld,ha);q.r=v.color.r*ha.r;q.g=v.color.g*ha.g;q.b=v.color.b*ha.b;q.updateStyleString();v.wireframe?d(q.__styleString,v.wireframe_linewidth):i(q.__styleString)}else v.wireframe?d(v.color.__styleString,v.wireframe_linewidth): +i(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){C=v.__2near;W=v.__farPlusNear;ea=v.__farMinusNear;A.r=A.g=A.b=1-C/(W-I.positionScreen.z*ea);y.r=y.g=y.b=1-C/(W-Y.positionScreen.z*ea);P.r=P.g=P.b=1-C/(W-U.positionScreen.z*ea);D.r=(y.r+P.r)*0.5;D.g=(y.g+P.g)*0.5;D.b=(y.b+P.b)*0.5;R=r(A,y,P,D);j(L,u,T,Q,t,H,R,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){q.r=l(E.normalWorld.x);q.g=l(E.normalWorld.y);q.b=l(E.normalWorld.z);q.updateStyleString();v.wireframe?d(q.__styleString, +v.wireframe_linewidth):i(q.__styleString)}}}function d(I,Y){if(e!=I)n.strokeStyle=e=I;if(k!=Y)n.lineWidth=k=Y;n.stroke();da.inflate(Y*2)}function i(I){if(f!=I)n.fillStyle=f=I;n.fill()}function j(I,Y,U,E,v,K,$,N,X,ba,Z,ca,na){var la,fa;la=$.width-1;fa=$.height-1;N*=la;X*=fa;ba*=la;Z*=fa;ca*=la;na*=fa;U-=I;E-=Y;v-=I;K-=Y;ba-=N;Z-=X;ca-=N;na-=X;fa=1/(ba*na-ca*Z);la=(na*U-Z*v)*fa;Z=(na*E-Z*K)*fa;U=(ba*v-ca*U)*fa;E=(ba*K-ca*E)*fa;I=I-la*N-U*X;Y=Y-Z*N-E*X;n.save();n.transform(la,Z,U,E,I,Y);n.clip();n.drawImage($, +0,0);n.restore()}function p(I){if(S!=I)n.globalAlpha=S=I}function m(I){if(B!=I){switch(I){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}B=I}}function r(I,Y,U,E){ia[0]=g(0,o(255,~~(I.r*255)));ia[1]=g(0,o(255,~~(I.g*255)));ia[2]=g(0,o(255,~~(I.b*255)));ia[4]=g(0,o(255,~~(Y.r*255)));ia[5]=g(0,o(255,~~(Y.g*255)));ia[6]=g(0,o(255,~~(Y.b*255))); +ia[8]=g(0,o(255,~~(U.r*255)));ia[9]=g(0,o(255,~~(U.g*255)));ia[10]=g(0,o(255,~~(U.b*255)));ia[12]=g(0,o(255,~~(E.r*255)));ia[13]=g(0,o(255,~~(E.g*255)));ia[14]=g(0,o(255,~~(E.b*255)));ra.putImageData(wa,0,0);ua.drawImage(sa,0,0);return ta}function l(I){return I<0?o((1+I)*0.5,0.5):0.5+o(I*0.5,0.5)}function c(I,Y){var U=Y.x-I.x,E=Y.y-I.y,v=1/Math.sqrt(U*U+E*E);U*=v;E*=v;Y.x+=U;Y.y+=E;I.x-=U;I.y-=E}var z=null,G=new THREE.Projector,x=document.createElement("canvas"),F,O,J,M,n=x.getContext("2d"),S=1,B= +0,e=null,f=null,k=1,o=Math.min,g=Math.max,h,w,s,L,u,T,Q,t,H,q=new THREE.Color,A=new THREE.Color,y=new THREE.Color,P=new THREE.Color,D=new THREE.Color,C,W,ea,R,V,ka,za,Aa,Ba,Ca,ma=new THREE.Rectangle,ja=new THREE.Rectangle,da=new THREE.Rectangle,va=false,ha=new THREE.Color,ga=new THREE.Color,oa=new THREE.Color,pa=new THREE.Color,Da=Math.PI*2,aa=new THREE.Vector3,sa,ra,wa,ia,ta,ua,qa=16;sa=document.createElement("canvas");sa.width=sa.height=2;ra=sa.getContext("2d");ra.fillStyle="rgba(0,0,0,1)";ra.fillRect(0, +0,2,2);wa=ra.getImageData(0,0,2,2);ia=wa.data;ta=document.createElement("canvas");ta.width=ta.height=qa;ua=ta.getContext("2d");ua.translate(-qa/2,-qa/2);ua.scale(qa,qa);qa--;this.domElement=x;this.autoClear=true;this.setSize=function(I,Y){F=I;O=Y;J=F/2;M=O/2;x.width=F;x.height=O;ma.set(-J,-M,J,M)};this.clear=function(){if(!ja.isEmpty()){ja.inflate(1);ja.minSelf(ma);n.clearRect(ja.getX(),ja.getY(),ja.getWidth(),ja.getHeight());ja.empty()}};this.render=function(I,Y){var U,E,v,K,$,N,X,ba;n.setTransform(1, +0,0,-1,J,M);this.autoClear&&this.clear();z=G.projectScene(I,Y);n.fillStyle="rgba(0, 255, 255, 0.5)";n.fillRect(ma.getX(),ma.getY(),ma.getWidth(),ma.getHeight());if(va=I.lights.length>0){$=I.lights;ga.setRGB(0,0,0);oa.setRGB(0,0,0);pa.setRGB(0,0,0);U=0;for(E=$.length;U>1;ya=fa.height>>1;na=X.scale.x*J;la=X.scale.y*M;ba=na*xa;ca=la*ya;da.set(N.x-ba,N.y-ca,N.x+ba,N.y+ca);if(!ma.instersects(da))break a;n.save(); n.translate(N.x,N.y);n.rotate(-X.rotation);n.scale(na,-la);n.translate(-xa,-ya);n.drawImage(fa,0,0);n.restore()}n.beginPath();n.moveTo(N.x-10,N.y);n.lineTo(N.x+10,N.y);n.moveTo(N.x,N.y-10);n.lineTo(N.x,N.y+10);n.closePath();n.strokeStyle="rgb(255,255,0)";n.stroke()}else if(Z instanceof THREE.ParticleCircleMaterial){if(va){ha.r=ga.r+oa.r+pa.r;ha.g=ga.g+oa.g+pa.g;ha.b=ga.b+oa.b+pa.b;q.r=Z.color.r*ha.r;q.g=Z.color.g*ha.g;q.b=Z.color.b*ha.b;q.updateStyleString()}else q.__styleString=Z.color.__styleString; -ba=X.scale.x*J;ca=X.scale.y*M;da.set(N.x-ba,N.y-ca,N.x+ba,N.y+ca);if(ma.instersects(da)){Z=q.__styleString;if(f!=Z)n.fillStyle=f=Z;n.save();n.translate(N.x,N.y);n.rotate(-X.rotation);n.scale(ba,ca);n.beginPath();n.arc(0,0,1,0,Da,true);n.closePath();n.fill();n.restore()}}}}}else if(v instanceof THREE.RenderableLine){j=v.v1;A=v.v2;j.positionScreen.x*=J;j.positionScreen.y*=M;A.positionScreen.x*=J;A.positionScreen.y*=M;da.addPoint(j.positionScreen.x,j.positionScreen.y);da.addPoint(A.positionScreen.x, -A.positionScreen.y);if(ma.instersects(da)){K=0;for($=v.material.length;K<$;){X=j;ba=A;N=v.material[K++];if(N.opacity!=0){o(N.opacity);m(N.blending);n.beginPath();n.moveTo(X.positionScreen.x,X.positionScreen.y);n.lineTo(ba.positionScreen.x,ba.positionScreen.y);n.closePath();if(N instanceof THREE.LineBasicMaterial){q.__styleString=N.color.__styleString;X=N.linewidth;if(i!=X)n.lineWidth=i=X;X=q.__styleString;if(e!=X)n.strokeStyle=e=X;n.stroke();da.inflate(N.linewidth*2)}}}}}else if(v instanceof THREE.RenderableFace3){j= -v.v1;A=v.v2;s=v.v3;j.positionScreen.x*=J;j.positionScreen.y*=M;A.positionScreen.x*=J;A.positionScreen.y*=M;s.positionScreen.x*=J;s.positionScreen.y*=M;if(v.overdraw){c(j.positionScreen,A.positionScreen);c(A.positionScreen,s.positionScreen);c(s.positionScreen,j.positionScreen)}da.addPoint(j.positionScreen.x,j.positionScreen.y);da.addPoint(A.positionScreen.x,A.positionScreen.y);da.addPoint(s.positionScreen.x,s.positionScreen.y);if(ma.instersects(da)){K=0;for($=v.meshMaterial.length;K<$;){ba=v.meshMaterial[K++]; -if(ba instanceof THREE.MeshFaceMaterial){N=0;for(X=v.faceMaterial.length;N0){x.r+=C.color.r*W;x.g+=C.color.g*W;x.b+=C.color.b*W}}else if(C instanceof THREE.PointLight){j.sub(C.position,z.centroidWorld);j.normalize();W=z.normalWorld.dot(j)*C.intensity;if(W>0){x.r+=C.color.r*W;x.g+=C.color.g*W;x.b+=C.color.b*W}}}}function b(q,z,x,P,D,C){u=g(T++);u.setAttribute("d","M "+q.positionScreen.x+ -" "+q.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+"z");if(D instanceof THREE.MeshBasicMaterial)B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshLambertMaterial)if(S){e.r=f.r;e.g=f.g;e.b=f.b;a(C,P,e);B.r=D.color.r*e.r;B.g=D.color.g*e.g;B.b=D.color.b*e.b;B.updateStyleString()}else B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshDepthMaterial){k=1-D.__2near/(D.__farPlusNear-P.z*D.__farMinusNear); -B.setRGB(k,k,k)}else D instanceof THREE.MeshNormalMaterial&&B.setRGB(h(P.normalWorld.x),h(P.normalWorld.y),h(P.normalWorld.z));D.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+D.wireframe_linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframe_linecap+"; stroke-linejoin: "+D.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+D.opacity);r.appendChild(u)}function d(q,z,x,P,D,C,W){u=g(T++);u.setAttribute("d", -"M "+q.positionScreen.x+" "+q.positionScreen.y+" L "+z.positionScreen.x+" "+z.positionScreen.y+" L "+x.positionScreen.x+","+x.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)B.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(S){e.r=f.r;e.g=f.g;e.b=f.b;a(W,D,e);B.r=C.color.r*e.r;B.g=C.color.g*e.g;B.b=C.color.b*e.b;B.updateStyleString()}else B.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){k= -1-C.__2near/(C.__farPlusNear-D.z*C.__farMinusNear);B.setRGB(k,k,k)}else C instanceof THREE.MeshNormalMaterial&&B.setRGB(h(D.normalWorld.x),h(D.normalWorld.y),h(D.normalWorld.z));C.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+C.opacity);r.appendChild(u)} -function g(q){if(A[q]==null){A[q]=document.createElementNS("http://www.w3.org/2000/svg","path");H==0&&A[q].setAttribute("shape-rendering","crispEdges");return A[q]}return A[q]}function h(q){return q<0?Math.min((1+q)*0.5,0.5):0.5+Math.min(q*0.5,0.5)}var o=null,m=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,c,y,G,w,F,O,J,M=new THREE.Rectangle,n=new THREE.Rectangle,S=false,B=new THREE.Color(16777215),e=new THREE.Color(16777215),f=new THREE.Color(0),i=new THREE.Color(0), -p=new THREE.Color(0),k,j=new THREE.Vector3,A=[],s=[],L=[],u,T,Q,t,H=1;this.domElement=r;this.autoClear=true;this.setQuality=function(q){switch(q){case "high":H=1;break;case "low":H=0}};this.setSize=function(q,z){l=q;c=z;y=l/2;G=c/2;r.setAttribute("viewBox",-y+" "+-G+" "+l+" "+c);r.setAttribute("width",l);r.setAttribute("height",c);M.set(-y,-G,y,G)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(q,z){var x,P,D,C,W,ea,R,V;this.autoClear&&this.clear(); -o=m.projectScene(q,z);t=Q=T=0;if(S=q.lights.length>0){R=q.lights;f.setRGB(0,0,0);i.setRGB(0,0,0);p.setRGB(0,0,0);x=0;for(P=R.length;x0){y.r+=C.color.r*W;y.g+=C.color.g*W;y.b+=C.color.b*W}}else if(C instanceof THREE.PointLight){h.sub(C.position,A.centroidWorld);h.normalize();W=A.normalWorld.dot(h)*C.intensity;if(W>0){y.r+=C.color.r*W;y.g+=C.color.g*W;y.b+=C.color.b*W}}}}function b(q,A,y,P,D,C){u=i(T++);u.setAttribute("d","M "+q.positionScreen.x+ +" "+q.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+"z");if(D instanceof THREE.MeshBasicMaterial)B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshLambertMaterial)if(S){e.r=f.r;e.g=f.g;e.b=f.b;a(C,P,e);B.r=D.color.r*e.r;B.g=D.color.g*e.g;B.b=D.color.b*e.b;B.updateStyleString()}else B.__styleString=D.color.__styleString;else if(D instanceof THREE.MeshDepthMaterial){g=1-D.__2near/(D.__farPlusNear-P.z*D.__farMinusNear); +B.setRGB(g,g,g)}else D instanceof THREE.MeshNormalMaterial&&B.setRGB(j(P.normalWorld.x),j(P.normalWorld.y),j(P.normalWorld.z));D.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+D.wireframe_linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+D.wireframe_linecap+"; stroke-linejoin: "+D.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+D.opacity);r.appendChild(u)}function d(q,A,y,P,D,C,W){u=i(T++);u.setAttribute("d", +"M "+q.positionScreen.x+" "+q.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(C instanceof THREE.MeshBasicMaterial)B.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshLambertMaterial)if(S){e.r=f.r;e.g=f.g;e.b=f.b;a(W,D,e);B.r=C.color.r*e.r;B.g=C.color.g*e.g;B.b=C.color.b*e.b;B.updateStyleString()}else B.__styleString=C.color.__styleString;else if(C instanceof THREE.MeshDepthMaterial){g= +1-C.__2near/(C.__farPlusNear-D.z*C.__farMinusNear);B.setRGB(g,g,g)}else C instanceof THREE.MeshNormalMaterial&&B.setRGB(j(D.normalWorld.x),j(D.normalWorld.y),j(D.normalWorld.z));C.wireframe?u.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+C.wireframe_linewidth+"; stroke-opacity: "+C.opacity+"; stroke-linecap: "+C.wireframe_linecap+"; stroke-linejoin: "+C.wireframe_linejoin):u.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+C.opacity);r.appendChild(u)} +function i(q){if(w[q]==null){w[q]=document.createElementNS("http://www.w3.org/2000/svg","path");H==0&&w[q].setAttribute("shape-rendering","crispEdges");return w[q]}return w[q]}function j(q){return q<0?Math.min((1+q)*0.5,0.5):0.5+Math.min(q*0.5,0.5)}var p=null,m=new THREE.Projector,r=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,c,z,G,x,F,O,J,M=new THREE.Rectangle,n=new THREE.Rectangle,S=false,B=new THREE.Color(16777215),e=new THREE.Color(16777215),f=new THREE.Color(0),k=new THREE.Color(0), +o=new THREE.Color(0),g,h=new THREE.Vector3,w=[],s=[],L=[],u,T,Q,t,H=1;this.domElement=r;this.autoClear=true;this.setQuality=function(q){switch(q){case "high":H=1;break;case "low":H=0}};this.setSize=function(q,A){l=q;c=A;z=l/2;G=c/2;r.setAttribute("viewBox",-z+" "+-G+" "+l+" "+c);r.setAttribute("width",l);r.setAttribute("height",c);M.set(-z,-G,z,G)};this.clear=function(){for(;r.childNodes.length>0;)r.removeChild(r.childNodes[0])};this.render=function(q,A){var y,P,D,C,W,ea,R,V;this.autoClear&&this.clear(); +p=m.projectScene(q,A);t=Q=T=0;if(S=q.lights.length>0){R=q.lights;f.setRGB(0,0,0);k.setRGB(0,0,0);o.setRGB(0,0,0);y=0;for(P=R.length;y= 0.0 )": "",f?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",f?"pointDiffuse += mColor * pointDiffuseWeight;":"",f?"pointSpecular += mSpecular * pointSpecularWeight;":"",f?"}":"",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;":"",f?"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"); -y=b(p,i);c.useProgram(y);h(y,["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&&h(y,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);f&&h(y,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(y.uniforms.enableMap,0);c.uniform1i(y.uniforms.tMap,0);c.uniform1i(y.uniforms.enableCubeMap,0);c.uniform1i(y.uniforms.tCube,1);c.uniform1i(y.uniforms.mixEnvMap,0);c.uniform1i(y.uniforms.useRefract,0);o(y)})(a.directional,a.point);this.setSize=function(e,f){l.width=e;l.height=f;c.viewport(0,0,l.width,l.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,f){var i,p,k,j,A,s=[],L=[],u=[];j=[];A=[];c.uniform1i(e.uniforms.enableLighting, -f.lights.length);i=0;for(p=f.lights.length;i=0;i--){p=e.__webGLObjects[i].__object;f==p&&e.__webGLObjects.splice(i,1)}};this.setupMatrices=function(e,f){e.autoUpdateMatrix&&e.updateMatrix();w.multiply(f.matrix,e.matrix);O.set(f.matrix.flatten());J.set(w.flatten());M.set(f.projectionMatrix.flatten());F=THREE.Matrix4.makeInvert3x3(w).transpose();n.set(F.m); -S.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,O);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,J);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,M);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,n);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,S)};this.loadCamera=function(e,f){c.uniform3f(e.uniforms.cameraPosition,f.position.x,f.position.y,f.position.z)};this.setBlending=function(e){switch(e){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD); +z=b(o,k);c.useProgram(z);j(z,["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(z,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);f&&j(z,["pointLightNumber","pointLightColor", +"pointLightPosition"]);c.uniform1i(z.uniforms.enableMap,0);c.uniform1i(z.uniforms.tMap,0);c.uniform1i(z.uniforms.enableCubeMap,0);c.uniform1i(z.uniforms.tCube,1);c.uniform1i(z.uniforms.mixEnvMap,0);c.uniform1i(z.uniforms.useRefract,0);p(z)})(a.directional,a.point);this.setSize=function(e,f){l.width=e;l.height=f;c.viewport(0,0,l.width,l.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(e,f){var k,o,g,h,w,s=[],L=[],u=[];h=[];w=[];c.uniform1i(e.uniforms.enableLighting, +f.lights.length);k=0;for(o=f.lights.length;k=0;k--){o=e.__webGLObjects[k].object;f==o&&e.__webGLObjects.splice(k,1)}};this.setupMatrices=function(e,f){e.autoUpdateMatrix&&e.updateMatrix();x.multiply(f.matrix,e.matrix);O.set(f.matrix.flatten());J.set(x.flatten());M.set(f.projectionMatrix.flatten());F=THREE.Matrix4.makeInvert3x3(x).transpose(); +n.set(F.m);S.set(e.matrix.flatten())};this.loadMatrices=function(e){c.uniformMatrix4fv(e.uniforms.viewMatrix,false,O);c.uniformMatrix4fv(e.uniforms.modelViewMatrix,false,J);c.uniformMatrix4fv(e.uniforms.projectionMatrix,false,M);c.uniformMatrix3fv(e.uniforms.normalMatrix,false,n);c.uniformMatrix4fv(e.uniforms.objectMatrix,false,S)};this.loadCamera=function(e,f){c.uniform3f(e.uniforms.cameraPosition,f.position.x,f.position.y,f.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,f){if(e){!f||f=="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)}}; 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 dcac11b18920b3c0f443f8d91228f2ab190ddd51..4ffa77b9521d2e3babb6f131f31ccd4221f39019 100644 --- a/build/ThreeExtras.js +++ b/build/ThreeExtras.js @@ -12,51 +12,50 @@ 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,f=[];a=0;for(b=e.length;a0&&L>0&&i+L<1}var d,e,f,j,k,g,m,c,s,E, -r,w=a.geometry,v=w.vertices,x=[];d=0;for(e=w.faces.length;d= -0&&Math.min(f,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){g=true;f=e=d=b=0;a()};this.isEmpty=function(){return g};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+f+", width: "+j+", height: "+k+" )"}};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,f=[];a=0;for(b=e.length;a0&&L>0&&i+L<1}var d,e,f,j,k,g,o,c,s,F, +r,w=a.geometry,v=w.vertices,y=[];d=0;for(e=w.faces.length;d= +0&&Math.min(f,o.getBottom())-Math.max(d,o.getTop())>=0};this.empty=function(){g=true;f=e=d=b=0;a()};this.isEmpty=function(){return g};this.toString=function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+d+", bottom: "+f+", width: "+j+", height: "+k+" )"}};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,f=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(d,j).normalize();f.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);this.n31=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},transformVector3:function(a){var b=a.x,d=a.y,e=a.z,f=1/(this.n41*b+this.n42* d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*b+this.n32*d+this.n33*e+this.n34)*f;return a},transformVector4:function(a){var b=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*f;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11* -a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,f=a.n13,j=a.n14,k=a.n21,g=a.n22,m=a.n23,c=a.n24,s=a.n31,E=a.n32,r=a.n33,w=a.n34,v=a.n41,x=a.n42,L=a.n43,u=a.n44,A=b.n11,l=b.n12,h=b.n13,i=b.n14,n=b.n21,y=b.n22,p=b.n23,o=b.n24,G=b.n31,B=b.n32,Q=b.n33,F=b.n34,V=b.n41,U=b.n42,D=b.n43, -P=b.n44;this.n11=d*A+e*n+f*G+j*V;this.n12=d*l+e*y+f*B+j*U;this.n13=d*h+e*p+f*Q+j*D;this.n14=d*i+e*o+f*F+j*P;this.n21=k*A+g*n+m*G+c*V;this.n22=k*l+g*y+m*B+c*U;this.n23=k*h+g*p+m*Q+c*D;this.n24=k*i+g*o+m*F+c*P;this.n31=s*A+E*n+r*G+w*V;this.n32=s*l+E*y+r*B+w*U;this.n33=s*h+E*p+r*Q+w*D;this.n34=s*i+E*o+r*F+w*P;this.n41=v*A+x*n+L*G+u*V;this.n42=v*l+x*y+L*B+u*U;this.n43=v*h+x*p+L*Q+u*D;this.n44=v*i+x*o+L*F+u*P},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,j=this.n21,k=this.n22, -g=this.n23,m=this.n24,c=this.n31,s=this.n32,E=this.n33,r=this.n34,w=this.n41,v=this.n42,x=this.n43,L=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+f*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+f*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+f*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+f*a.n44;this.n21=j*a.n11+k*a.n21+g*a.n31+m*a.n41;this.n22=j*a.n12+k*a.n22+g*a.n32+m*a.n42;this.n23=j*a.n13+k*a.n23+g*a.n33+m*a.n43;this.n24=j*a.n14+k*a.n24+g*a.n34+m*a.n44;this.n31=c*a.n11+s*a.n21+E*a.n31+r*a.n41;this.n32=c*a.n12+s*a.n22+ -E*a.n32+r*a.n42;this.n33=c*a.n13+s*a.n23+E*a.n33+r*a.n43;this.n34=c*a.n14+s*a.n24+E*a.n34+r*a.n44;this.n41=w*a.n11+v*a.n21+x*a.n31+L*a.n41;this.n42=w*a.n12+v*a.n22+x*a.n32+L*a.n42;this.n43=w*a.n13+v*a.n23+x*a.n33+L*a.n43;this.n44=w*a.n14+v*a.n24+x*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.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,f=a.n13,j=a.n14,k=a.n21,g=a.n22,o=a.n23,c=a.n24,s=a.n31,F=a.n32,r=a.n33,w=a.n34,v=a.n41,y=a.n42,L=a.n43,u=a.n44,A=b.n11,n=b.n12,h=b.n13,i=b.n14,p=b.n21,x=b.n22,m=b.n23,l=b.n24,E=b.n31,B=b.n32,Q=b.n33,G=b.n34,V=b.n41,U=b.n42,D=b.n43, +P=b.n44;this.n11=d*A+e*p+f*E+j*V;this.n12=d*n+e*x+f*B+j*U;this.n13=d*h+e*m+f*Q+j*D;this.n14=d*i+e*l+f*G+j*P;this.n21=k*A+g*p+o*E+c*V;this.n22=k*n+g*x+o*B+c*U;this.n23=k*h+g*m+o*Q+c*D;this.n24=k*i+g*l+o*G+c*P;this.n31=s*A+F*p+r*E+w*V;this.n32=s*n+F*x+r*B+w*U;this.n33=s*h+F*m+r*Q+w*D;this.n34=s*i+F*l+r*G+w*P;this.n41=v*A+y*p+L*E+u*V;this.n42=v*n+y*x+L*B+u*U;this.n43=v*h+y*m+L*Q+u*D;this.n44=v*i+y*l+L*G+u*P},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,f=this.n14,j=this.n21,k=this.n22, +g=this.n23,o=this.n24,c=this.n31,s=this.n32,F=this.n33,r=this.n34,w=this.n41,v=this.n42,y=this.n43,L=this.n44;this.n11=b*a.n11+d*a.n21+e*a.n31+f*a.n41;this.n12=b*a.n12+d*a.n22+e*a.n32+f*a.n42;this.n13=b*a.n13+d*a.n23+e*a.n33+f*a.n43;this.n14=b*a.n14+d*a.n24+e*a.n34+f*a.n44;this.n21=j*a.n11+k*a.n21+g*a.n31+o*a.n41;this.n22=j*a.n12+k*a.n22+g*a.n32+o*a.n42;this.n23=j*a.n13+k*a.n23+g*a.n33+o*a.n43;this.n24=j*a.n14+k*a.n24+g*a.n34+o*a.n44;this.n31=c*a.n11+s*a.n21+F*a.n31+r*a.n41;this.n32=c*a.n12+s*a.n22+ +F*a.n32+r*a.n42;this.n33=c*a.n13+s*a.n23+F*a.n33+r*a.n43;this.n34=c*a.n14+s*a.n24+F*a.n34+r*a.n44;this.n41=w*a.n11+v*a.n21+y*a.n31+L*a.n41;this.n42=w*a.n12+v*a.n22+y*a.n32+L*a.n42;this.n43=w*a.n13+v*a.n23+y*a.n33+L*a.n43;this.n44=w*a.n14+v*a.n24+y*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* this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34*this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14* this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,d,e){var f=b[d];b[d]=b[e];b[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this, "n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12,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),f=Math.sin(b),j=1-e,k=a.x,g=a.y,m=a.z;d.n11=j*k*k+e;d.n12=j*k*g-f*m;d.n13=j*k*m+f*g;d.n21=j*k*g+f*m;d.n22=j*g*g+e;d.n23=j*g*m-f*k;d.n31=j*k*m-f*g;d.n32=j*g*m+f*k;d.n33=j*m*m+e;return d}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4,e=Math.cos(b),f=Math.sin(b),j=1-e,k=a.x,g=a.y,o=a.z;d.n11=j*k*k+e;d.n12=j*k*g-f*o;d.n13=j*k*o+f*g;d.n21=j*k*g+f*o;d.n22=j*g*g+e;d.n23=j*g*o-f*k;d.n31=j*k*o-f*g;d.n32=j*g*o+f*k;d.n33=j*o*o+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],f=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],g=-b[6]*b[0]+b[2]*b[4],m=b[9]*b[4]-b[5]*b[8],c=-b[9]*b[0]+b[1]*b[8],s=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*j+b[2]*m;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*f;a.m[3]=b*j;a.m[4]=b*k;a.m[5]=b*g;a.m[6]=b*m;a.m[7]=b*c;a.m[8]=b*s;return a}; -THREE.Matrix4.makeFrustum=function(a,b,d,e,f,j){var k,g,m;k=new THREE.Matrix4;g=2*f/(b-a);m=2*f/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(j+f)/(j-f);f=-2*j*f/(j-f);k.n11=g;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=m;k.n23=d;k.n24=0;k.n31=0;k.n32=0;k.n33=e;k.n34=f;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,d,e)}; -THREE.Matrix4.makeOrtho=function(a,b,d,e,f,j){var k,g,m,c;k=new THREE.Matrix4;g=b-a;m=d-e;c=j-f;a=(b+a)/g;d=(d+e)/m;f=(j+f)/c;k.n11=2/g;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/m;k.n23=0;k.n24=-d;k.n31=0;k.n32=0;k.n33=-2/c;k.n34=-f;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k}; +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],f=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],k=b[10]*b[0]-b[2]*b[8],g=-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],s=b[5]*b[0]-b[1]*b[4];b=b[0]*d+b[1]*j+b[2]*o;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*d;a.m[1]=b*e;a.m[2]=b*f;a.m[3]=b*j;a.m[4]=b*k;a.m[5]=b*g;a.m[6]=b*o;a.m[7]=b*c;a.m[8]=b*s;return a}; +THREE.Matrix4.makeFrustum=function(a,b,d,e,f,j){var k,g,o;k=new THREE.Matrix4;g=2*f/(b-a);o=2*f/(e-d);a=(b+a)/(b-a);d=(e+d)/(e-d);e=-(j+f)/(j-f);f=-2*j*f/(j-f);k.n11=g;k.n12=0;k.n13=a;k.n14=0;k.n21=0;k.n22=o;k.n23=d;k.n24=0;k.n31=0;k.n32=0;k.n33=e;k.n34=f;k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,d,e)}; +THREE.Matrix4.makeOrtho=function(a,b,d,e,f,j){var k,g,o,c;k=new THREE.Matrix4;g=b-a;o=d-e;c=j-f;a=(b+a)/g;d=(d+e)/o;f=(j+f)/c;k.n11=2/g;k.n12=0;k.n13=0;k.n14=-a;k.n21=0;k.n22=2/o;k.n23=0;k.n24=-d;k.n31=0;k.n32=0;k.n33=-2/c;k.n34=-f;k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k}; 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,e,f){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=f instanceof Array?f:[f]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; THREE.Face4=function(a,b,d,e,f,j){this.a=a;this.b=b;this.c=d;this.d=e;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.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=[]}; +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.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a +o=new THREE.Vector3;e=0;for(f=this.vertices.length;e 0){this.bbox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var a=1,b=this.vertices.length;athis.bbox.x[1])this.bbox.x[1]=vertex.position.x;if(vertex.position.y -this.bbox.y[1])this.bbox.y[1]=vertex.position.y;if(vertex.position.zthis.bbox.z[1])this.bbox.z[1]=vertex.position.z}}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}}; +this.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(s){var F=[];b=0;for(d=s.length;b65535){c[g].counter+=1;o=c[g].hash+"_"+c[g].counter;if(this.geometryChunks[o]==undefined)this.geometryChunks[o]={faces:[],material:k,vertices:0}}this.geometryChunks[o].faces.push(e);this.geometryChunks[o].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+" )"}}; 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; -THREE.Object3D=function(){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.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;this.materialFaceGroup={};this.sortFacesByMaterial();d&&this.normalizeUVs();this.geometry.computeBoundingBox()};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh; -THREE.Mesh.prototype.sortFacesByMaterial=function(){function a(s){var E=[];b=0;for(d=s.length;b65535){c[g].counter+=1;m=c[g].hash+"_"+c[g].counter;if(this.materialFaceGroup[m]==undefined)this.materialFaceGroup[m]={faces:[],material:k,vertices:0}}this.materialFaceGroup[m].faces.push(e);this.materialFaceGroup[m].vertices+=j}};THREE.Mesh.prototype.normalizeUVs=function(){var a,b,d,e,f;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.Multiply;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=a.map;if(a.env_map!== @@ -83,124 +82,126 @@ this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.ParticleDOMMaterial=function(a){this.domElement=a;this.toString=function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,b,d,e){this.image=a;this.loaded=false;this.mapping=b!==undefined?b:THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdge;this.wrap_t=e!==undefined?e:THREE.ClampToEdge;this.toString=function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
)"}}; THREE.UVMapping=0;THREE.ReflectionMapping=1;THREE.RefractionMapping=2;THREE.Multiply=0;THREE.Mix=1;THREE.Repeat=0;THREE.ClampToEdge=1;THREE.MirroredRepeat=2;THREE.TextureCube=function(a,b){this.image=a;this.mapping=b?b:THREE.ReflectionMap;this.toString=function(){return"THREE.TextureCube (
image: "+this.image+"
mapping: "+this.mapping+"
)"}}; 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(A,l){var h=0,i=1,n=A.z+A.w,y=l.z+l.w,p=-A.z+A.w,o=-l.z+l.w;if(n>=0&&y>=0&&p>=0&&o>=0)return true;else if(n<0&&y<0||p<0&&o<0)return false;else{if(n<0)h=Math.max(h,n/(n-y));else if(y<0)i=Math.min(i,n/(n-y));if(p<0)h=Math.max(h,p/(p-o));else if(o<0)i=Math.min(i,p/(p-o));if(i0&&C.z<1}P=B.geometry.faces;n=0;for(y=P.length;n0&&r.z<1){c=E[s]=E[s]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=B.rotation.z;c.scale.x=B.scale.x*Math.abs(c.x-(r.x+l.projectionMatrix.n11)/(r.w+l.projectionMatrix.n14));c.scale.y=B.scale.y*Math.abs(c.y-(r.y+l.projectionMatrix.n22)/(r.w+l.projectionMatrix.n24));c.material=B.material;b.push(c);s++}}}b.sort(function(T,N){return N.z-T.z});return b};this.unprojectVector=function(A,l){var h=new THREE.Matrix4; -h.multiply(THREE.Matrix4.makeInvert(l.matrix),THREE.Matrix4.makeInvert(l.projectionMatrix));h.transformVector3(A);return A}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,j;this.domElement=document.createElement("div");this.setSize=function(k,g){d=k;e=g;f=d/2;j=e/2};this.render=function(k,g){var m,c,s,E,r,w,v,x;a=b.projectScene(k,g);m=0;for(c=a.length;m0){O.r+=ca.r*S;O.g+=ca.g*S;O.b+=ca.b*S}}else if(S instanceof THREE.PointLight){da.sub(S.position,aa);da.normalize();S=Z.dot(da)*X;if(S>0){O.r+=ca.r*S;O.g+=ca.g*S;O.b+=ca.b*S}}}}function b(R,aa,Z,O,H,S){if(H.opacity!=0){j(H.opacity);k(H.blending);Q=R.positionScreen.x;F=R.positionScreen.y;V=aa.positionScreen.x; -U=aa.positionScreen.y;D=Z.positionScreen.x;P=Z.positionScreen.y;var ca=Q,X=F,$=V,ea=U,ba=D,fa=P;u.beginPath();u.moveTo(ca,X);u.lineTo($,ea);u.lineTo(ba,fa);u.lineTo(ca,X);u.closePath();if(H instanceof THREE.MeshBasicMaterial)if(H.map&&H.map.loaded)f(Q,F,V,U,D,P,H.map.image,O.uvs[0].u,O.uvs[0].v,O.uvs[1].u,O.uvs[1].v,O.uvs[2].u,O.uvs[2].v);else if(H.env_map&&H.env_map.loaded){if(H.env_map.mapping==THREE.ReflectionMapping){da.copy(O.vertexNormalsWorld[0]);z=(da.x*camera.matrix.n11+da.y*camera.matrix.n12+ +THREE.Projector=function(){function a(A,n){var h=0,i=1,p=A.z+A.w,x=n.z+n.w,m=-A.z+A.w,l=-n.z+n.w;if(p>=0&&x>=0&&m>=0&&l>=0)return true;else if(p<0&&x<0||m<0&&l<0)return false;else{if(p<0)h=Math.max(h,p/(p-x));else if(x<0)i=Math.min(i,p/(p-x));if(m<0)h=Math.max(h,m/(m-l));else if(l<0)i=Math.min(i,m/(m-l));if(i0&&C.z<1}P=B.geometry.faces;p=0;for(x=P.length;p0&&r.z<1){c=F[s]=F[s]||new THREE.RenderableParticle;c.x=r.x/r.w;c.y=r.y/r.w;c.z=r.z;c.rotation=B.rotation.z;c.scale.x=B.scale.x*Math.abs(c.x-(r.x+n.projectionMatrix.n11)/(r.w+n.projectionMatrix.n14));c.scale.y=B.scale.y*Math.abs(c.y-(r.y+n.projectionMatrix.n22)/(r.w+n.projectionMatrix.n24));c.material=B.material;b.push(c);s++}}}b.sort(function(T,N){return N.z-T.z});return b};this.unprojectVector=function(A,n){var h=new THREE.Matrix4; +h.multiply(THREE.Matrix4.makeInvert(n.matrix),THREE.Matrix4.makeInvert(n.projectionMatrix));h.transformVector3(A);return A}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,d,e,f,j;this.domElement=document.createElement("div");this.setSize=function(k,g){d=k;e=g;f=d/2;j=e/2};this.render=function(k,g){var o,c,s,F,r,w,v,y;a=b.projectScene(k,g);o=0;for(c=a.length;o0){O.r+=ca.r*S;O.g+=ca.g*S;O.b+=ca.b*S}}else if(S instanceof THREE.PointLight){da.sub(S.position,aa);da.normalize();S=Z.dot(da)*X;if(S>0){O.r+=ca.r*S;O.g+=ca.g*S;O.b+=ca.b*S}}}}function b(R,aa,Z,O,H,S){if(H.opacity!=0){j(H.opacity);k(H.blending);Q=R.positionScreen.x;G=R.positionScreen.y;V=aa.positionScreen.x; +U=aa.positionScreen.y;D=Z.positionScreen.x;P=Z.positionScreen.y;var ca=Q,X=G,$=V,ea=U,ba=D,fa=P;u.beginPath();u.moveTo(ca,X);u.lineTo($,ea);u.lineTo(ba,fa);u.lineTo(ca,X);u.closePath();if(H instanceof THREE.MeshBasicMaterial)if(H.map&&H.map.loaded)f(Q,G,V,U,D,P,H.map.image,O.uvs[0].u,O.uvs[0].v,O.uvs[1].u,O.uvs[1].v,O.uvs[2].u,O.uvs[2].v);else if(H.env_map&&H.env_map.loaded){if(H.env_map.mapping==THREE.ReflectionMapping){da.copy(O.vertexNormalsWorld[0]);z=(da.x*camera.matrix.n11+da.y*camera.matrix.n12+ da.z*camera.matrix.n13)*0.5+0.5;K=-(da.x*camera.matrix.n21+da.y*camera.matrix.n22+da.z*camera.matrix.n23)*0.5+0.5;da.copy(O.vertexNormalsWorld[1]);W=(da.x*camera.matrix.n11+da.y*camera.matrix.n12+da.z*camera.matrix.n13)*0.5+0.5;ga=-(da.x*camera.matrix.n21+da.y*camera.matrix.n22+da.z*camera.matrix.n23)*0.5+0.5;da.copy(O.vertexNormalsWorld[2]);ma=(da.x*camera.matrix.n11+da.y*camera.matrix.n12+da.z*camera.matrix.n13)*0.5+0.5;ua=-(da.x*camera.matrix.n21+da.y*camera.matrix.n22+da.z*camera.matrix.n23)* -0.5+0.5;f(Q,F,V,U,D,P,H.env_map.image,z,K,W,ga,ma,ua)}}else H.wireframe?d(H.color.__styleString,H.wireframe_linewidth):e(H.color.__styleString);else if(H instanceof THREE.MeshLambertMaterial){if(H.map&&!H.wireframe){f(Q,F,V,U,D,P,H.map.image,O.uvs[0].u,O.uvs[0].v,O.uvs[1].u,O.uvs[1].v,O.uvs[2].u,O.uvs[2].v);k(THREE.SubtractiveBlending)}if(za)if(!H.wireframe&&H.shading==THREE.SmoothShading&&O.vertexNormalsWorld.length==3){J.r=I.r=T.r=ja.r;J.g=I.g=T.g=ja.g;J.b=I.b=T.b=ja.b;a(S,O.v1.positionWorld,O.vertexNormalsWorld[0], -J);a(S,O.v2.positionWorld,O.vertexNormalsWorld[1],I);a(S,O.v3.positionWorld,O.vertexNormalsWorld[2],T);N.r=(I.r+T.r)*0.5;N.g=(I.g+T.g)*0.5;N.b=(I.b+T.b)*0.5;t=g(J,I,T,N);f(Q,F,V,U,D,P,t,0,0,1,0,0,1)}else{ka.r=ja.r;ka.g=ja.g;ka.b=ja.b;a(S,O.centroidWorld,O.normalWorld,ka);C.r=H.color.r*ka.r;C.g=H.color.g*ka.g;C.b=H.color.b*ka.b;C.updateStyleString();H.wireframe?d(C.__styleString,H.wireframe_linewidth):e(C.__styleString)}else H.wireframe?d(H.color.__styleString,H.wireframe_linewidth):e(H.color.__styleString)}else if(H instanceof -THREE.MeshDepthMaterial){M=H.__2near;Y=H.__farPlusNear;q=H.__farMinusNear;J.r=J.g=J.b=1-M/(Y-R.positionScreen.z*q);I.r=I.g=I.b=1-M/(Y-aa.positionScreen.z*q);T.r=T.g=T.b=1-M/(Y-Z.positionScreen.z*q);N.r=(I.r+T.r)*0.5;N.g=(I.g+T.g)*0.5;N.b=(I.b+T.b)*0.5;t=g(J,I,T,N);f(Q,F,V,U,D,P,t,0,0,1,0,0,1)}else if(H instanceof THREE.MeshNormalMaterial){C.r=m(O.normalWorld.x);C.g=m(O.normalWorld.y);C.b=m(O.normalWorld.z);C.updateStyleString();H.wireframe?d(C.__styleString,H.wireframe_linewidth):e(C.__styleString)}}} -function d(R,aa){if(h!=R)u.strokeStyle=h=R;if(n!=aa)u.lineWidth=n=aa;u.stroke();ha.inflate(aa*2)}function e(R){if(i!=R)u.fillStyle=i=R;u.fill()}function f(R,aa,Z,O,H,S,ca,X,$,ea,ba,fa,oa){var na,ia;na=ca.width-1;ia=ca.height-1;X*=na;$*=ia;ea*=na;ba*=ia;fa*=na;oa*=ia;Z-=R;O-=aa;H-=R;S-=aa;ea-=X;ba-=$;fa-=X;oa-=$;ia=1/(ea*oa-fa*ba);na=(oa*Z-ba*H)*ia;ba=(oa*O-ba*S)*ia;Z=(ea*H-fa*Z)*ia;O=(ea*S-fa*O)*ia;R=R-na*X-Z*$;aa=aa-ba*X-O*$;u.save();u.transform(na,ba,Z,O,R,aa);u.clip();u.drawImage(ca,0,0);u.restore()} -function j(R){if(A!=R)u.globalAlpha=A=R}function k(R){if(l!=R){switch(R){case THREE.NormalBlending:u.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:u.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:u.globalCompositeOperation="darker"}l=R}}function g(R,aa,Z,O){la[0]=p(0,y(255,~~(R.r*255)));la[1]=p(0,y(255,~~(R.g*255)));la[2]=p(0,y(255,~~(R.b*255)));la[4]=p(0,y(255,~~(aa.r*255)));la[5]=p(0,y(255,~~(aa.g*255)));la[6]=p(0,y(255,~~(aa.b*255)));la[8]=p(0, -y(255,~~(Z.r*255)));la[9]=p(0,y(255,~~(Z.g*255)));la[10]=p(0,y(255,~~(Z.b*255)));la[12]=p(0,y(255,~~(O.r*255)));la[13]=p(0,y(255,~~(O.g*255)));la[14]=p(0,y(255,~~(O.b*255)));va.putImageData(Aa,0,0);ya.drawImage(wa,0,0);return xa}function m(R){return R<0?y((1+R)*0.5,0.5):0.5+y(R*0.5,0.5)}function c(R,aa){var Z=aa.x-R.x,O=aa.y-R.y,H=1/Math.sqrt(Z*Z+O*O);Z*=H;O*=H;aa.x+=Z;aa.y+=O;R.x-=Z;R.y-=O}var s=null,E=new THREE.Projector,r=document.createElement("canvas"),w,v,x,L,u=r.getContext("2d"),A=1,l=0,h= -null,i=null,n=1,y=Math.min,p=Math.max,o,G,B,Q,F,V,U,D,P,C=new THREE.Color,J=new THREE.Color,I=new THREE.Color,T=new THREE.Color,N=new THREE.Color,M,Y,q,t,z,K,W,ga,ma,ua,pa=new THREE.Rectangle,qa=new THREE.Rectangle,ha=new THREE.Rectangle,za=false,ka=new THREE.Color,ja=new THREE.Color,ra=new THREE.Color,sa=new THREE.Color,Da=Math.PI*2,da=new THREE.Vector3,wa,va,Aa,la,xa,ya,ta=16;wa=document.createElement("canvas");wa.width=wa.height=2;va=wa.getContext("2d");va.fillStyle="rgba(0,0,0,1)";va.fillRect(0, -0,2,2);Aa=va.getImageData(0,0,2,2);la=Aa.data;xa=document.createElement("canvas");xa.width=xa.height=ta;ya=xa.getContext("2d");ya.translate(-ta/2,-ta/2);ya.scale(ta,ta);ta--;this.domElement=r;this.autoClear=true;this.setSize=function(R,aa){w=R;v=aa;x=w/2;L=v/2;r.width=w;r.height=v;pa.set(-x,-L,x,L)};this.clear=function(){if(!qa.isEmpty()){qa.inflate(1);qa.minSelf(pa);u.clearRect(qa.getX(),qa.getY(),qa.getWidth(),qa.getHeight());qa.empty()}};this.render=function(R,aa){var Z,O,H,S,ca,X,$,ea;u.setTransform(1, -0,0,-1,x,L);this.autoClear&&this.clear();s=E.projectScene(R,aa);if(za=R.lights.length>0){ca=R.lights;ja.setRGB(0,0,0);ra.setRGB(0,0,0);sa.setRGB(0,0,0);Z=0;for(O=ca.length;Z>1;Ca=ia.height>>1;oa=$.scale.x*x;na=$.scale.y*L;ea=oa*Ba;fa=na*Ca;ha.set(X.x-ea,X.y-fa,X.x+ea,X.y+fa);if(pa.instersects(ha)){u.save();u.translate(X.x,X.y);u.rotate(-$.rotation);u.scale(oa,-na);u.translate(-Ba,-Ca);u.drawImage(ia, -0,0);u.restore()}}}else if(ba instanceof THREE.ParticleCircleMaterial){if(za){ka.r=ja.r+ra.r+sa.r;ka.g=ja.g+ra.g+sa.g;ka.b=ja.b+ra.b+sa.b;C.r=ba.color.r*ka.r;C.g=ba.color.g*ka.g;C.b=ba.color.b*ka.b;C.updateStyleString()}else C.__styleString=ba.color.__styleString;ea=$.scale.x*x;fa=$.scale.y*L;ha.set(X.x-ea,X.y-fa,X.x+ea,X.y+fa);if(pa.instersects(ha)){ba=C.__styleString;if(i!=ba)u.fillStyle=i=ba;u.save();u.translate(X.x,X.y);u.rotate(-$.rotation);u.scale(ea,fa);u.beginPath();u.arc(0,0,1,0,Da,true); -u.closePath();u.fill();u.restore()}}}}}else if(H instanceof THREE.RenderableLine){o=H.v1;G=H.v2;o.positionScreen.x*=x;o.positionScreen.y*=L;G.positionScreen.x*=x;G.positionScreen.y*=L;ha.addPoint(o.positionScreen.x,o.positionScreen.y);ha.addPoint(G.positionScreen.x,G.positionScreen.y);if(pa.instersects(ha)){S=0;for(ca=H.material.length;S0){I.r+=M.color.r*Y;I.g+=M.color.g*Y;I.b+=M.color.b*Y}}else if(M instanceof THREE.PointLight){o.sub(M.position,J.centroidWorld);o.normalize();Y=J.normalWorld.dot(o)*M.intensity;if(Y>0){I.r+=M.color.r*Y;I.g+=M.color.g*Y;I.b+=M.color.b*Y}}}}function b(C,J,I,T,N,M){F=e(V++);F.setAttribute("d","M "+C.positionScreen.x+ -" "+C.positionScreen.y+" L "+J.positionScreen.x+" "+J.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)l.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(A){h.r=i.r;h.g=i.g;h.b=i.b;a(M,T,h);l.r=N.color.r*h.r;l.g=N.color.g*h.g;l.b=N.color.b*h.b;l.updateStyleString()}else l.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshDepthMaterial){p=1-N.__2near/(N.__farPlusNear-T.z*N.__farMinusNear); -l.setRGB(p,p,p)}else N instanceof THREE.MeshNormalMaterial&&l.setRGB(f(T.normalWorld.x),f(T.normalWorld.y),f(T.normalWorld.z));N.wireframe?F.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):F.setAttribute("style","fill: "+l.__styleString+"; fill-opacity: "+N.opacity);g.appendChild(F)}function d(C,J,I,T,N,M,Y){F=e(V++);F.setAttribute("d", -"M "+C.positionScreen.x+" "+C.positionScreen.y+" L "+J.positionScreen.x+" "+J.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)l.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(A){h.r=i.r;h.g=i.g;h.b=i.b;a(Y,N,h);l.r=M.color.r*h.r;l.g=M.color.g*h.g;l.b=M.color.b*h.b;l.updateStyleString()}else l.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){p= -1-M.__2near/(M.__farPlusNear-N.z*M.__farMinusNear);l.setRGB(p,p,p)}else M instanceof THREE.MeshNormalMaterial&&l.setRGB(f(N.normalWorld.x),f(N.normalWorld.y),f(N.normalWorld.z));M.wireframe?F.setAttribute("style","fill: none; stroke: "+l.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):F.setAttribute("style","fill: "+l.__styleString+"; fill-opacity: "+M.opacity);g.appendChild(F)} -function e(C){if(G[C]==null){G[C]=document.createElementNS("http://www.w3.org/2000/svg","path");P==0&&G[C].setAttribute("shape-rendering","crispEdges");return G[C]}return G[C]}function f(C){return C<0?Math.min((1+C)*0.5,0.5):0.5+Math.min(C*0.5,0.5)}var j=null,k=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),m,c,s,E,r,w,v,x,L=new THREE.Rectangle,u=new THREE.Rectangle,A=false,l=new THREE.Color(16777215),h=new THREE.Color(16777215),i=new THREE.Color(0),n=new THREE.Color(0), -y=new THREE.Color(0),p,o=new THREE.Vector3,G=[],B=[],Q=[],F,V,U,D,P=1;this.domElement=g;this.autoClear=true;this.setQuality=function(C){switch(C){case "high":P=1;break;case "low":P=0}};this.setSize=function(C,J){m=C;c=J;s=m/2;E=c/2;g.setAttribute("viewBox",-s+" "+-E+" "+m+" "+c);g.setAttribute("width",m);g.setAttribute("height",c);L.set(-s,-E,s,E)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(C,J){var I,T,N,M,Y,q,t,z;this.autoClear&&this.clear(); -j=k.projectScene(C,J);D=U=V=0;if(A=C.lights.length>0){t=C.lights;i.setRGB(0,0,0);n.setRGB(0,0,0);y.setRGB(0,0,0);I=0;for(T=t.length;I0){ca=R.lights;ja.setRGB(0,0,0);ra.setRGB(0,0,0);sa.setRGB(0,0,0);Z=0;for(O=ca.length;Z>1;Ca=ia.height>>1;oa=$.scale.x*y;na=$.scale.y*L;ea=oa*Ba;fa=na*Ca;ha.set(X.x-ea,X.y-fa,X.x+ea,X.y+fa);if(pa.instersects(ha)){u.save();u.translate(X.x,X.y);u.rotate(-$.rotation);u.scale(oa,-na);u.translate(-Ba,-Ca);u.drawImage(ia, +0,0);u.restore()}}}else if(ba instanceof THREE.ParticleCircleMaterial){if(za){ka.r=ja.r+ra.r+sa.r;ka.g=ja.g+ra.g+sa.g;ka.b=ja.b+ra.b+sa.b;C.r=ba.color.r*ka.r;C.g=ba.color.g*ka.g;C.b=ba.color.b*ka.b;C.updateStyleString()}else C.__styleString=ba.color.__styleString;ea=$.scale.x*y;fa=$.scale.y*L;ha.set(X.x-ea,X.y-fa,X.x+ea,X.y+fa);if(pa.instersects(ha)){ba=C.__styleString;if(i!=ba)u.fillStyle=i=ba;u.save();u.translate(X.x,X.y);u.rotate(-$.rotation);u.scale(ea,fa);u.beginPath();u.arc(0,0,1,0,Da,true); +u.closePath();u.fill();u.restore()}}}}}else if(H instanceof THREE.RenderableLine){l=H.v1;E=H.v2;l.positionScreen.x*=y;l.positionScreen.y*=L;E.positionScreen.x*=y;E.positionScreen.y*=L;ha.addPoint(l.positionScreen.x,l.positionScreen.y);ha.addPoint(E.positionScreen.x,E.positionScreen.y);if(pa.instersects(ha)){S=0;for(ca=H.material.length;S0){I.r+=M.color.r*Y;I.g+=M.color.g*Y;I.b+=M.color.b*Y}}else if(M instanceof THREE.PointLight){l.sub(M.position,J.centroidWorld);l.normalize();Y=J.normalWorld.dot(l)*M.intensity;if(Y>0){I.r+=M.color.r*Y;I.g+=M.color.g*Y;I.b+=M.color.b*Y}}}}function b(C,J,I,T,N,M){G=e(V++);G.setAttribute("d","M "+C.positionScreen.x+ +" "+C.positionScreen.y+" L "+J.positionScreen.x+" "+J.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)n.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(A){h.r=i.r;h.g=i.g;h.b=i.b;a(M,T,h);n.r=N.color.r*h.r;n.g=N.color.g*h.g;n.b=N.color.b*h.b;n.updateStyleString()}else n.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshDepthMaterial){m=1-N.__2near/(N.__farPlusNear-T.z*N.__farMinusNear); +n.setRGB(m,m,m)}else N instanceof THREE.MeshNormalMaterial&&n.setRGB(f(T.normalWorld.x),f(T.normalWorld.y),f(T.normalWorld.z));N.wireframe?G.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):G.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+N.opacity);g.appendChild(G)}function d(C,J,I,T,N,M,Y){G=e(V++);G.setAttribute("d", +"M "+C.positionScreen.x+" "+C.positionScreen.y+" L "+J.positionScreen.x+" "+J.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+" L "+T.positionScreen.x+","+T.positionScreen.y+"z");if(M instanceof THREE.MeshBasicMaterial)n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshLambertMaterial)if(A){h.r=i.r;h.g=i.g;h.b=i.b;a(Y,N,h);n.r=M.color.r*h.r;n.g=M.color.g*h.g;n.b=M.color.b*h.b;n.updateStyleString()}else n.__styleString=M.color.__styleString;else if(M instanceof THREE.MeshDepthMaterial){m= +1-M.__2near/(M.__farPlusNear-N.z*M.__farMinusNear);n.setRGB(m,m,m)}else M instanceof THREE.MeshNormalMaterial&&n.setRGB(f(N.normalWorld.x),f(N.normalWorld.y),f(N.normalWorld.z));M.wireframe?G.setAttribute("style","fill: none; stroke: "+n.__styleString+"; stroke-width: "+M.wireframe_linewidth+"; stroke-opacity: "+M.opacity+"; stroke-linecap: "+M.wireframe_linecap+"; stroke-linejoin: "+M.wireframe_linejoin):G.setAttribute("style","fill: "+n.__styleString+"; fill-opacity: "+M.opacity);g.appendChild(G)} +function e(C){if(E[C]==null){E[C]=document.createElementNS("http://www.w3.org/2000/svg","path");P==0&&E[C].setAttribute("shape-rendering","crispEdges");return E[C]}return E[C]}function f(C){return C<0?Math.min((1+C)*0.5,0.5):0.5+Math.min(C*0.5,0.5)}var j=null,k=new THREE.Projector,g=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,c,s,F,r,w,v,y,L=new THREE.Rectangle,u=new THREE.Rectangle,A=false,n=new THREE.Color(16777215),h=new THREE.Color(16777215),i=new THREE.Color(0),p=new THREE.Color(0), +x=new THREE.Color(0),m,l=new THREE.Vector3,E=[],B=[],Q=[],G,V,U,D,P=1;this.domElement=g;this.autoClear=true;this.setQuality=function(C){switch(C){case "high":P=1;break;case "low":P=0}};this.setSize=function(C,J){o=C;c=J;s=o/2;F=c/2;g.setAttribute("viewBox",-s+" "+-F+" "+o+" "+c);g.setAttribute("width",o);g.setAttribute("height",c);L.set(-s,-F,s,F)};this.clear=function(){for(;g.childNodes.length>0;)g.removeChild(g.childNodes[0])};this.render=function(C,J){var I,T,N,M,Y,q,t,z;this.autoClear&&this.clear(); +j=k.projectScene(C,J);D=U=V=0;if(A=C.lights.length>0){t=C.lights;i.setRGB(0,0,0);p.setRGB(0,0,0);x.setRGB(0,0,0);I=0;for(T=t.length;I= 0.0 )": "",i?"pointSpecularWeight = pow( pointDotNormalHalf, mShininess );":"",i?"pointDiffuse += mColor * pointDiffuseWeight;":"",i?"pointSpecular += mSpecular * pointSpecularWeight;":"",i?"}":"",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;":"",i?"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"); -s=b(y,n);c.useProgram(s);f(s,["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&&f(s,["directionalLightNumber","directionalLightColor","directionalLightDirection"]);i&&f(s,["pointLightNumber","pointLightColor", -"pointLightPosition"]);c.uniform1i(s.uniforms.enableMap,0);c.uniform1i(s.uniforms.tMap,0);c.uniform1i(s.uniforms.enableCubeMap,0);c.uniform1i(s.uniforms.tCube,1);c.uniform1i(s.uniforms.mixEnvMap,0);c.uniform1i(s.uniforms.useRefract,0);j(s)})(a.directional,a.point);this.setSize=function(h,i){m.width=h;m.height=i;c.viewport(0,0,m.width,m.height)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.setupLights=function(h,i){var n,y,p,o,G,B=[],Q=[],F=[];o=[];G=[];c.uniform1i(h.uniforms.enableLighting, -i.lights.length);n=0;for(y=i.lights.length;n=0;n--){y=h.__webGLObjects[n].__object;i==y&&h.__webGLObjects.splice(n,1)}};this.setupMatrices=function(h,i){h.autoUpdateMatrix&&h.updateMatrix();r.multiply(i.matrix,h.matrix);v.set(i.matrix.flatten());x.set(r.flatten());L.set(i.projectionMatrix.flatten());w=THREE.Matrix4.makeInvert3x3(r).transpose();u.set(w.m); -A.set(h.matrix.flatten())};this.loadMatrices=function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,x);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,L);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,u);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,A)};this.loadCamera=function(h,i){c.uniform3f(h.uniforms.cameraPosition,i.position.x,i.position.y,i.position.z)};this.setBlending=function(h){switch(h){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD); +c.bufferData(c.ARRAY_BUFFER,new Float32Array(C),c.STATIC_DRAW);I.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,I.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(V),c.STATIC_DRAW);I.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,I.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(U),c.STATIC_DRAW);I.__webGLFaceCount=V.length;I.__webGLLineCount=U.length}};this.renderBuffer=function(h,i,p){var x,m,l,E,B,Q,G, +V,U,D;if(i instanceof THREE.MeshShaderMaterial){if(!i.program){i.program=b(i.fragment_shader,i.vertex_shader);G=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(D in i.uniforms)G.push(D);f(i.program,G);j(i.program)}D=i.program}else D=s;if(D!=F){c.useProgram(D);F=D}if(i instanceof THREE.MeshShaderMaterial){l=i.wireframe;E=i.wireframe_linewidth;G=D;V=i.uniforms;var P,C;for(m in V){P=V[m].type;U=V[m].value;C=G.uniforms[m];if(P=="i")c.uniform1i(C, +U);else if(P=="f")c.uniform1f(C,U);else if(P=="t"){c.uniform1i(C,U);P=V[m].texture;if(P instanceof THREE.TextureCube)d(P,U);else P instanceof THREE.Texture&&e(P,U)}}this.loadCamera(D,h);this.loadMatrices(D)}else if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshBasicMaterial){h=i.color;x=i.opacity;l=i.wireframe;E=i.wireframe_linewidth;B=i.map;Q=i.env_map;G=i.combine==THREE.Mix;m=i.reflectivity;U=i.env_map&&i.env_map.mapping==THREE.RefractionMapping; +V=i.refraction_ratio;c.uniform4f(D.uniforms.mColor,h.r*x,h.g*x,h.b*x,x);c.uniform1i(D.uniforms.mixEnvMap,G);c.uniform1f(D.uniforms.mReflectivity,m);c.uniform1i(D.uniforms.useRefract,U);c.uniform1f(D.uniforms.mRefractionRatio,V)}if(i instanceof THREE.MeshNormalMaterial){x=i.opacity;c.uniform1f(D.uniforms.mOpacity,x);c.uniform1i(D.uniforms.material,4)}else if(i instanceof THREE.MeshDepthMaterial){x=i.opacity;l=i.wireframe;E=i.wireframe_linewidth;c.uniform1f(D.uniforms.mOpacity,x);c.uniform1f(D.uniforms.m2Near, +i.__2near);c.uniform1f(D.uniforms.mFarPlusNear,i.__farPlusNear);c.uniform1f(D.uniforms.mFarMinusNear,i.__farMinusNear);c.uniform1i(D.uniforms.material,3)}else if(i instanceof THREE.MeshPhongMaterial){h=i.ambient;m=i.specular;i=i.shininess;c.uniform4f(D.uniforms.mAmbient,h.r,h.g,h.b,x);c.uniform4f(D.uniforms.mSpecular,m.r,m.g,m.b,x);c.uniform1f(D.uniforms.mShininess,i);c.uniform1i(D.uniforms.material,2)}else if(i instanceof THREE.MeshLambertMaterial)c.uniform1i(D.uniforms.material,1);else if(i instanceof +THREE.MeshBasicMaterial)c.uniform1i(D.uniforms.material,0);else if(i instanceof THREE.MeshCubeMaterial){c.uniform1i(D.uniforms.material,5);Q=i.env_map}if(B){e(B,0);c.uniform1i(D.uniforms.tMap,0);c.uniform1i(D.uniforms.enableMap,1)}else c.uniform1i(D.uniforms.enableMap,0);if(Q){d(Q,1);c.uniform1i(D.uniforms.tCube,1);c.uniform1i(D.uniforms.enableCubeMap,1)}else c.uniform1i(D.uniforms.enableCubeMap,0);c.bindBuffer(c.ARRAY_BUFFER,p.__webGLVertexBuffer);c.vertexAttribPointer(D.position,3,c.FLOAT,false, +0,0);c.bindBuffer(c.ARRAY_BUFFER,p.__webGLNormalBuffer);c.vertexAttribPointer(D.normal,3,c.FLOAT,false,0,0);if(B){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.enableVertexAttribArray(D.uv);c.vertexAttribPointer(D.uv,2,c.FLOAT,false,0,0)}else c.disableVertexAttribArray(D.uv);if(l){c.lineWidth(E);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(h,i,p,x,m){var l,E,B,Q,G;B=0;for(Q=i.material.length;B=0;p--){x=h.__webGLObjects[p].object;i==x&&h.__webGLObjects.splice(p,1)}};this.setupMatrices=function(h,i){h.autoUpdateMatrix&&h.updateMatrix();r.multiply(i.matrix,h.matrix);v.set(i.matrix.flatten());y.set(r.flatten());L.set(i.projectionMatrix.flatten());w=THREE.Matrix4.makeInvert3x3(r).transpose(); +u.set(w.m);A.set(h.matrix.flatten())};this.loadMatrices=function(h){c.uniformMatrix4fv(h.uniforms.viewMatrix,false,v);c.uniformMatrix4fv(h.uniforms.modelViewMatrix,false,y);c.uniformMatrix4fv(h.uniforms.projectionMatrix,false,L);c.uniformMatrix3fv(h.uniforms.normalMatrix,false,u);c.uniformMatrix4fv(h.uniforms.objectMatrix,false,A)};this.loadCamera=function(h,i){c.uniform3f(h.uniforms.cameraPosition,i.position.x,i.position.y,i.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,i){if(h){!i||i=="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,f=d?b.geometry:b,j=a.vertices,k=f.vertices,g=a.faces,m=f.faces,c=a.uvs;f=f.uvs;d&&b.updateMatrix();for(var s=0,E=k.length;s0||(c=this.vertices.push(new THREE.Vertex(new THREE.Vector3(s,k,E)))-1);m.push(c)}b.push(m)}var r,w,v;a=b.length;for(d=0;d0)for(e=0;e1){r=this.vertices[j].position.clone(); -w=this.vertices[g].position.clone();v=this.vertices[m].position.clone();r.normalize();w.normalize();v.normalize();this.faces.push(new THREE.Face3(j,g,m,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,s,x])}}}this.computeCentroids();this.computeNormals()};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null}; +var Sphere=function(a,b,d){THREE.Geometry.call(this);var e,f=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(s,k,F)))-1);o.push(c)}b.push(o)}var r,w,v;a=b.length;for(d=0;d0)for(e=0;e1){r=this.vertices[j].position.clone(); +w=this.vertices[g].position.clone();v=this.vertices[o].position.clone();r.normalize();w.normalize();v.normalize();this.faces.push(new THREE.Face3(j,g,o,[new THREE.Vector3(r.x,r.y,r.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(v.x,v.y,v.z)]));this.uvs.push([c,s,y])}}}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(f){THREE.Loader.prototype.createModel(f.data,b,d)};a.postMessage(e)},loadBinary:function(a,b,d){var e=(new Date).getTime();a=new Worker(a);var f=this.showProgress?THREE.Loader.prototype.updateProgress:null;a.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers, j.data.materials,b,d,f)};a.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};a.postMessage(e)},loadAjaxBuffers:function(a,b,d,e,f){var j=new XMLHttpRequest,k=e+"/"+a,g=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 ["+k+"] ["+j.status+"]");else if(j.readyState==3){if(f){if(g==0)g=j.getResponseHeader("Content-Length");f({total:g,loaded:j.responseText.length})}}else if(j.readyState== 2)g=j.getResponseHeader("Content-Length")};j.open("GET",k,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 f=function(j){function k(q,t){var z=s(q,t),K=s(q,t+1),W=s(q,t+2),ga=s(q,t+3),ma=(ga<<1&255|W>>7)-127;z=(W&127)<<16|K<<8|z;if(z==0&&ma==-127)return 0;return(1-2*(ga>>7))*(1+z*Math.pow(2,-23))*Math.pow(2,ma)}function g(q,t){var z=s(q,t),K=s(q,t+1),W=s(q,t+2);return(s(q,t+3)<<24)+(W<< -16)+(K<<8)+z}function m(q,t){var z=s(q,t);return(s(q,t+1)<<8)+z}function c(q,t){var z=s(q,t);return z>127?z-256:z}function s(q,t){return q.charCodeAt(t)&255}function E(q){var t,z,K;t=g(a,q);z=g(a,q+n);K=g(a,q+y);q=m(a,q+p);THREE.Loader.prototype.f3(u,t,z,K,q)}function r(q){var t,z,K,W,ga,ma;t=g(a,q);z=g(a,q+n);K=g(a,q+y);W=m(a,q+p);ga=g(a,q+o);ma=g(a,q+G);q=g(a,q+B);THREE.Loader.prototype.f3n(u,h,t,z,K,W,ga,ma,q)}function w(q){var t,z,K,W;t=g(a,q);z=g(a,q+Q);K=g(a,q+F);W=g(a,q+V);q=m(a,q+U);THREE.Loader.prototype.f4(u, -t,z,K,W,q)}function v(q){var t,z,K,W,ga,ma,ua,pa;t=g(a,q);z=g(a,q+Q);K=g(a,q+F);W=g(a,q+V);ga=m(a,q+U);ma=g(a,q+D);ua=g(a,q+P);pa=g(a,q+C);q=g(a,q+J);THREE.Loader.prototype.f4n(u,h,t,z,K,W,ga,ma,ua,pa,q)}function x(q){var t,z;t=g(a,q);z=g(a,q+I);q=g(a,q+T);THREE.Loader.prototype.uv3(u,i[t*2],i[t*2+1],i[z*2],i[z*2+1],i[q*2],i[q*2+1])}function L(q){var t,z,K;t=g(a,q);z=g(a,q+N);K=g(a,q+M);q=g(a,q+Y);THREE.Loader.prototype.uv4(u,i[t*2],i[t*2+1],i[z*2],i[z*2+1],i[K*2],i[K*2+1],i[q*2],i[q*2+1])}var u= -this,A=0,l,h=[],i=[],n,y,p,o,G,B,Q,F,V,U,D,P,C,J,I,T,N,M,Y;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,e,j);l={signature:a.substr(A,8),header_bytes:s(a,A+8),vertex_coordinate_bytes:s(a,A+9),normal_coordinate_bytes:s(a,A+10),uv_coordinate_bytes:s(a,A+11),vertex_index_bytes:s(a,A+12),normal_index_bytes:s(a,A+13),uv_index_bytes:s(a,A+14),material_index_bytes:s(a,A+15),nvertices:g(a,A+16),nnormals:g(a,A+16+4),nuvs:g(a,A+16+8),ntri_flat:g(a,A+16+12),ntri_smooth:g(a,A+16+16),ntri_flat_uv:g(a, -A+16+20),ntri_smooth_uv:g(a,A+16+24),nquad_flat:g(a,A+16+28),nquad_smooth:g(a,A+16+32),nquad_flat_uv:g(a,A+16+36),nquad_smooth_uv:g(a,A+16+40)};A+=l.header_bytes;n=l.vertex_index_bytes;y=l.vertex_index_bytes*2;p=l.vertex_index_bytes*3;o=l.vertex_index_bytes*3+l.material_index_bytes;G=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes;B=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*2;Q=l.vertex_index_bytes;F=l.vertex_index_bytes*2;V=l.vertex_index_bytes*3;U=l.vertex_index_bytes* -4;D=l.vertex_index_bytes*4+l.material_index_bytes;P=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes;C=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*2;J=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*3;I=l.uv_index_bytes;T=l.uv_index_bytes*2;N=l.uv_index_bytes;M=l.uv_index_bytes*2;Y=l.uv_index_bytes*3;A+=function(q){var t,z,K,W=l.vertex_coordinate_bytes*3,ga=q+l.nvertices*W;for(q=q;q127?z-256:z}function s(q,t){return q.charCodeAt(t)&255}function F(q){var t,z,K;t=g(a,q);z=g(a,q+p);K=g(a,q+x);q=o(a,q+m);THREE.Loader.prototype.f3(u,t,z,K,q)}function r(q){var t,z,K,W,ga,ma;t=g(a,q);z=g(a,q+p);K=g(a,q+x);W=o(a,q+m);ga=g(a,q+l);ma=g(a,q+E);q=g(a,q+B);THREE.Loader.prototype.f3n(u,h,t,z,K,W,ga,ma,q)}function w(q){var t,z,K,W;t=g(a,q);z=g(a,q+Q);K=g(a,q+G);W=g(a,q+V);q=o(a,q+U);THREE.Loader.prototype.f4(u, +t,z,K,W,q)}function v(q){var t,z,K,W,ga,ma,ua,pa;t=g(a,q);z=g(a,q+Q);K=g(a,q+G);W=g(a,q+V);ga=o(a,q+U);ma=g(a,q+D);ua=g(a,q+P);pa=g(a,q+C);q=g(a,q+J);THREE.Loader.prototype.f4n(u,h,t,z,K,W,ga,ma,ua,pa,q)}function y(q){var t,z;t=g(a,q);z=g(a,q+I);q=g(a,q+T);THREE.Loader.prototype.uv3(u,i[t*2],i[t*2+1],i[z*2],i[z*2+1],i[q*2],i[q*2+1])}function L(q){var t,z,K;t=g(a,q);z=g(a,q+N);K=g(a,q+M);q=g(a,q+Y);THREE.Loader.prototype.uv4(u,i[t*2],i[t*2+1],i[z*2],i[z*2+1],i[K*2],i[K*2+1],i[q*2],i[q*2+1])}var u= +this,A=0,n,h=[],i=[],p,x,m,l,E,B,Q,G,V,U,D,P,C,J,I,T,N,M,Y;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,e,j);n={signature:a.substr(A,8),header_bytes:s(a,A+8),vertex_coordinate_bytes:s(a,A+9),normal_coordinate_bytes:s(a,A+10),uv_coordinate_bytes:s(a,A+11),vertex_index_bytes:s(a,A+12),normal_index_bytes:s(a,A+13),uv_index_bytes:s(a,A+14),material_index_bytes:s(a,A+15),nvertices:g(a,A+16),nnormals:g(a,A+16+4),nuvs:g(a,A+16+8),ntri_flat:g(a,A+16+12),ntri_smooth:g(a,A+16+16),ntri_flat_uv:g(a, +A+16+20),ntri_smooth_uv:g(a,A+16+24),nquad_flat:g(a,A+16+28),nquad_smooth:g(a,A+16+32),nquad_flat_uv:g(a,A+16+36),nquad_smooth_uv:g(a,A+16+40)};A+=n.header_bytes;p=n.vertex_index_bytes;x=n.vertex_index_bytes*2;m=n.vertex_index_bytes*3;l=n.vertex_index_bytes*3+n.material_index_bytes;E=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes;B=n.vertex_index_bytes*3+n.material_index_bytes+n.normal_index_bytes*2;Q=n.vertex_index_bytes;G=n.vertex_index_bytes*2;V=n.vertex_index_bytes*3;U=n.vertex_index_bytes* +4;D=n.vertex_index_bytes*4+n.material_index_bytes;P=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes;C=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*2;J=n.vertex_index_bytes*4+n.material_index_bytes+n.normal_index_bytes*3;I=n.uv_index_bytes;T=n.uv_index_bytes*2;N=n.uv_index_bytes;M=n.uv_index_bytes*2;Y=n.uv_index_bytes*3;A+=function(q){var t,z,K,W=n.vertex_coordinate_bytes*3,ga=q+n.nvertices*W;for(q=q;q 0.7 ) face.material = [ materials[ Math.floor( Math.random() * materials.length ) ].material ]; } @@ -104,16 +102,19 @@ objects = []; - var sphere, geometry; + var sphere, geometry, material; for ( var i = 0, l = materials.length; i < l; i ++ ) { - geometry = materials[ i ].material instanceof THREE.MeshFaceMaterial ? geometry2 : geometry1; - - sphere = new THREE.Mesh( geometry, materials[ i ].material ); + material = materials[ i ].material; + + geometry = material instanceof THREE.MeshFaceMaterial ? geometry_pieces : + ( material.shading == THREE.FlatShading ? geometry_flat : geometry_smooth ); + + sphere = new THREE.Mesh( geometry, material ); - sphere.overdraw = materials[ i ].overdraw; - sphere.doubleSided = materials[ i ].doubleSided; + sphere.overdraw = material.overdraw; + sphere.doubleSided = material.doubleSided; sphere.position.x = ( i % 4 ) * 200 - 400; sphere.position.z = Math.floor( i / 4 ) * 200 - 200; diff --git a/examples/materials_shaders_fresnel.html b/examples/materials_shaders_fresnel.html index c8f10851cd20ea5e0a030a6bb43ad17094d3f9db..572fd4bafe57f42ccaf88207f956502e822f3cfa 100644 --- a/examples/materials_shaders_fresnel.html +++ b/examples/materials_shaders_fresnel.html @@ -92,7 +92,8 @@ GeometryUtils.merge( geometry, sphere ); } - + geometry.sortFacesByMaterial(); + var path = "textures/cube/Park2/"; var format = '.jpg'; var urls = [ diff --git a/examples/obj/Bird.js b/examples/obj/Bird.js index 120ebd1f24987e993bda7865ca58ccb12c64d39a..0406579e50f9a1266a2aff3d3ebbe66f8ba565e8 100644 --- a/examples/obj/Bird.js +++ b/examples/obj/Bird.js @@ -20,6 +20,10 @@ var Bird = function () { f3( 4, 7, 6 ); f3( 5, 6, 7 ); + this.computeCentroids(); + this.computeNormals(); + this.sortFacesByMaterial(); + function v( x, y, z ) { scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) ); diff --git a/examples/obj/Qrcode.js b/examples/obj/Qrcode.js index 0ab776692ec3a758399e895c9734357976f94294..9c9b26fa094aba6aa4f75e21dee5c5ba6e4d3a64 100644 --- a/examples/obj/Qrcode.js +++ b/examples/obj/Qrcode.js @@ -1435,6 +1435,7 @@ var Qrcode = function () { this.computeCentroids(); this.computeNormals(); + this.sortFacesByMaterial(); function v( x, y, z ) { diff --git a/examples/obj/WaltHead.js b/examples/obj/WaltHead.js index 35a1c0b499cacd6500040d89111e3ea3c8e37136..7b180b79e4ca84e0c7638a58e08f71d8c295515d 100644 --- a/examples/obj/WaltHead.js +++ b/examples/obj/WaltHead.js @@ -4885,6 +4885,7 @@ var WaltHead = function () { this.computeCentroids(); this.computeNormals(); + this.sortFacesByMaterial(); function v( x, y, z ) { diff --git a/examples/uqbiquity_test.html b/examples/uqbiquity_test.html index c5a8bf97716475db6840edfe7c453b0b71ec3ef5..20c2b080893cf94beca9849f75e3be34b3001b7c 100644 --- a/examples/uqbiquity_test.html +++ b/examples/uqbiquity_test.html @@ -175,6 +175,7 @@ geometry.computeNormals(); geometry.computeCentroids(); + geometry.sortFacesByMaterial(); mesh = new THREE.Mesh( geometry, [ new THREE.MeshFaceMaterial(), new THREE.MeshBasicMaterial( { color: 0xff0000, opacity: 0.5, wireframe: true, wireframe_linewidth: 10 } ) ] ); mesh.doubleSided = true; diff --git a/src/core/Geometry.js b/src/core/Geometry.js index 1e16e8270f67b44d138a28d110460994b091b48d..617b254d77211b2e04296e92dc1958e2c3b71aa9 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -1,6 +1,7 @@ /** * @author mr.doob / http://mrdoob.com/ * @author kile / http://kile.stravaganza.org/ + * @author alteredq / http://alteredqualia.com/ */ THREE.Geometry = function () { @@ -9,6 +10,8 @@ THREE.Geometry = function () { this.faces = []; this.uvs = []; + this.geometryChunks = {}; + }; THREE.Geometry.prototype = { @@ -89,7 +92,7 @@ THREE.Geometry.prototype = { if ( !cb.isZero() ) { - cb.normalize(); + cb.normalize(); } @@ -149,6 +152,80 @@ THREE.Geometry.prototype = { }, + sortFacesByMaterial: function () { + + // TODO + // Should optimize by grouping faces with ColorFill / ColorStroke materials + // which could then use vertex color attributes instead of each being + // in its separate VBO + + var i, l, f, fl, face, material, vertices, mhash, ghash, hash_map = {}; + + function materialHash( material ) { + + var hash_array = []; + + for ( i = 0, l = material.length; i < l; i++ ) { + + if ( material[ i ] == undefined ) { + + hash_array.push( "undefined" ); + + } else { + + hash_array.push( material[ i ].toString() ); + + } + + } + + return hash_array.join( '_' ); + + } + + for ( f = 0, fl = this.faces.length; f < fl; f++ ) { + + face = this.faces[ f ]; + material = face.material; + + mhash = materialHash( material ); + + if ( hash_map[ mhash ] == undefined ) { + + hash_map[ mhash ] = { 'hash': mhash, 'counter': 0 }; + + } + + ghash = hash_map[ mhash ].hash + '_' + hash_map[ mhash ].counter; + + if ( this.geometryChunks[ ghash ] == undefined ) { + + this.geometryChunks[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 }; + + } + + vertices = face instanceof THREE.Face3 ? 3 : 4; + + if ( this.geometryChunks[ ghash ].vertices + vertices > 65535 ) { + + hash_map[ mhash ].counter += 1; + ghash = hash_map[ mhash ].hash + '_' + hash_map[ mhash ].counter; + + if ( this.geometryChunks[ ghash ] == undefined ) { + + this.geometryChunks[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 }; + + } + + } + + this.geometryChunks[ ghash ].faces.push( f ); + this.geometryChunks[ ghash ].vertices += vertices; + + } + + }, + toString: function () { return 'THREE.Geometry ( vertices: ' + this.vertices + ', faces: ' + this.faces + ' )'; diff --git a/src/extras/io/Loader.js b/src/extras/io/Loader.js index 448c9231caefe21db4aabb9b523f26999cc1047b..cb93dd495190557db956abd3e684e62366f551a4 100644 --- a/src/extras/io/Loader.js +++ b/src/extras/io/Loader.js @@ -245,6 +245,7 @@ THREE.Loader.prototype = { this.computeCentroids(); this.computeNormals(); + this.sortFacesByMaterial(); //var e = (new Date).getTime(); @@ -706,6 +707,7 @@ THREE.Loader.prototype = { this.computeCentroids(); this.computeNormals(); + this.sortFacesByMaterial(); function init_vertices() { diff --git a/src/extras/primitives/Cube.js b/src/extras/primitives/Cube.js index a197ac263b309d473b634e0590f997f4b91b161d..2c1c06e933624c1bf9350bf43b9224db9d51f20c 100644 --- a/src/extras/primitives/Cube.js +++ b/src/extras/primitives/Cube.js @@ -158,6 +158,7 @@ var Cube = function ( width, height, depth, segments_width, segments_height, mat this.computeCentroids(); this.computeNormals(); + this.sortFacesByMaterial(); } diff --git a/src/extras/primitives/Cylinder.js b/src/extras/primitives/Cylinder.js index 392041a2ab761987e0337916386824732bc35142..3dc6378a66522621ca704131c643fada7982c148 100644 --- a/src/extras/primitives/Cylinder.js +++ b/src/extras/primitives/Cylinder.js @@ -67,6 +67,7 @@ var Cylinder = function (numSegs, topRad, botRad, height, topOffset, botOffset) this.computeCentroids(); this.computeNormals(); + this.sortFacesByMaterial(); function v(x, y, z) { diff --git a/src/extras/primitives/Plane.js b/src/extras/primitives/Plane.js index 8fd6595550270ec00c58d8519cb8568133ffb411..9d398c32e5ec7fc5fbf97418d3759ff43574dd18 100644 --- a/src/extras/primitives/Plane.js +++ b/src/extras/primitives/Plane.js @@ -54,6 +54,7 @@ var Plane = function ( width, height, segments_width, segments_height ) { this.computeCentroids(); this.computeNormals(); + this.sortFacesByMaterial(); } diff --git a/src/extras/primitives/Sphere.js b/src/extras/primitives/Sphere.js index c542839900b34fe5ee965c0b3fd7fdf260b20d84..5f981040ff47f84657a28a264352689b9a56dc08 100644 --- a/src/extras/primitives/Sphere.js +++ b/src/extras/primitives/Sphere.js @@ -105,6 +105,8 @@ var Sphere = function ( radius, segments_width, segments_height ) { this.computeCentroids(); this.computeNormals(); + this.sortFacesByMaterial(); + } Sphere.prototype = new THREE.Geometry(); diff --git a/src/objects/Mesh.js b/src/objects/Mesh.js index a6828f3386b1928b3be5943e82b6c817853604b4..2d148c4e8baed48eedfb6c6d3d56d4dd1ab0be56 100644 --- a/src/objects/Mesh.js +++ b/src/objects/Mesh.js @@ -1,5 +1,6 @@ /** * @author mr.doob / http://mrdoob.com/ + * @author alteredq / http://alteredqualia.com/ */ THREE.Mesh = function ( geometry, material, normUVs ) { @@ -14,8 +15,6 @@ THREE.Mesh = function ( geometry, material, normUVs ) { this.overdraw = false; - this.materialFaceGroup = {}; - this.sortFacesByMaterial(); if ( normUVs ) this.normalizeUVs(); this.geometry.computeBoundingBox(); @@ -25,81 +24,6 @@ THREE.Mesh = function ( geometry, material, normUVs ) { THREE.Mesh.prototype = new THREE.Object3D(); THREE.Mesh.prototype.constructor = THREE.Mesh; -THREE.Mesh.prototype.sortFacesByMaterial = function () { - - // TODO - // Should optimize by grouping faces with ColorFill / ColorStroke materials - // which could then use vertex color attributes instead of each being - // in its separate VBO - - var i, l, f, fl, face, material, vertices, mhash, ghash, hash_map = {}; - - function materialHash( material ) { - - var hash_array = []; - - for ( i = 0, l = material.length; i < l; i++ ) { - - if ( material[ i ] == undefined ) { - - hash_array.push( "undefined" ); - - } else { - - hash_array.push( material[ i ].toString() ); - - } - - } - - return hash_array.join( '_' ); - - } - - for ( f = 0, fl = this.geometry.faces.length; f < fl; f++ ) { - - face = this.geometry.faces[ f ]; - material = face.material; - - mhash = materialHash( material ); - - if ( hash_map[ mhash ] == undefined ) { - - hash_map[ mhash ] = { 'hash': mhash, 'counter': 0 }; - - } - - ghash = hash_map[ mhash ].hash + '_' + hash_map[ mhash ].counter; - - if ( this.materialFaceGroup[ ghash ] == undefined ) { - - this.materialFaceGroup[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 }; - - } - - vertices = face instanceof THREE.Face3 ? 3 : 4; - - if ( this.materialFaceGroup[ ghash ].vertices + vertices > 65535 ) { - - hash_map[ mhash ].counter += 1; - ghash = hash_map[ mhash ].hash + '_' + hash_map[ mhash ].counter; - - if ( this.materialFaceGroup[ ghash ] == undefined ) { - - this.materialFaceGroup[ ghash ] = { 'faces': [], 'material': material, 'vertices': 0 }; - - } - - } - - this.materialFaceGroup[ ghash ].faces.push( f ); - this.materialFaceGroup[ ghash ].vertices += vertices; - - - } - -}; - THREE.Mesh.prototype.normalizeUVs = function () { var i, il, j, jl, uvs; diff --git a/src/objects/Object3D.js b/src/objects/Object3D.js index 2e67329367729e147342238781355dc05838f11f..60ea4f1f3b7c3494d2cefe42bef09ac7ab57a903 100644 --- a/src/objects/Object3D.js +++ b/src/objects/Object3D.js @@ -4,6 +4,8 @@ THREE.Object3D = function ( material ) { + this.id = THREE.Object3DCounter.value ++; + this.position = new THREE.Vector3(); this.rotation = new THREE.Vector3(); this.scale = new THREE.Vector3( 1, 1, 1 ); @@ -35,3 +37,5 @@ THREE.Object3D = function ( material ) { }; }; + +THREE.Object3DCounter = { value: 0 }; diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 0895dc3b80f0505492fc7ead66353c17043d58bc..4aa04dfcac6344be95513b908573587d54fe56f6 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -155,7 +155,7 @@ THREE.WebGLRenderer = function ( scene ) { }; - this.createBuffers = function ( object, mf ) { + this.createBuffers = function ( object, g ) { var f, fl, fi, face, vertexNormals, normal, uv, v1, v2, v3, v4, m, ml, i, @@ -168,13 +168,13 @@ THREE.WebGLRenderer = function ( scene ) { vertexIndex = 0, - materialFaceGroup = object.materialFaceGroup[ mf ], + geometryChunk = object.geometry.geometryChunks[ g ], - needsSmoothNormals = bufferNeedsSmoothNormals ( materialFaceGroup, object ); + needsSmoothNormals = bufferNeedsSmoothNormals ( geometryChunk, object ); - for ( f = 0, fl = materialFaceGroup.faces.length; f < fl; f++ ) { + for ( f = 0, fl = geometryChunk.faces.length; f < fl; f++ ) { - fi = materialFaceGroup.faces[f]; + fi = geometryChunk.faces[ f ]; face = object.geometry.faces[ fi ]; vertexNormals = face.vertexNormals; @@ -283,6 +283,7 @@ THREE.WebGLRenderer = function ( scene ) { vertexIndex += 4; } + } if ( !vertexArray.length ) { @@ -291,32 +292,32 @@ THREE.WebGLRenderer = function ( scene ) { } - materialFaceGroup.__webGLVertexBuffer = _gl.createBuffer(); - _gl.bindBuffer( _gl.ARRAY_BUFFER, materialFaceGroup.__webGLVertexBuffer ); + geometryChunk.__webGLVertexBuffer = _gl.createBuffer(); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLVertexBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( vertexArray ), _gl.STATIC_DRAW ); - materialFaceGroup.__webGLNormalBuffer = _gl.createBuffer(); - _gl.bindBuffer( _gl.ARRAY_BUFFER, materialFaceGroup.__webGLNormalBuffer ); + geometryChunk.__webGLNormalBuffer = _gl.createBuffer(); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( normalArray ), _gl.STATIC_DRAW ); - materialFaceGroup.__webGLUVBuffer = _gl.createBuffer(); - _gl.bindBuffer( _gl.ARRAY_BUFFER, materialFaceGroup.__webGLUVBuffer ); + geometryChunk.__webGLUVBuffer = _gl.createBuffer(); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLUVBuffer ); _gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( uvArray ), _gl.STATIC_DRAW ); - materialFaceGroup.__webGLFaceBuffer = _gl.createBuffer(); - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, materialFaceGroup.__webGLFaceBuffer ); + geometryChunk.__webGLFaceBuffer = _gl.createBuffer(); + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLFaceBuffer ); _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( faceArray ), _gl.STATIC_DRAW ); - materialFaceGroup.__webGLLineBuffer = _gl.createBuffer(); - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, materialFaceGroup.__webGLLineBuffer ); + geometryChunk.__webGLLineBuffer = _gl.createBuffer(); + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLLineBuffer ); _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( lineArray ), _gl.STATIC_DRAW ); - materialFaceGroup.__webGLFaceCount = faceArray.length; - materialFaceGroup.__webGLLineCount = lineArray.length; + geometryChunk.__webGLFaceCount = faceArray.length; + geometryChunk.__webGLLineCount = lineArray.length; }; - this.renderBuffer = function ( camera, material, materialFaceGroup ) { + this.renderBuffer = function ( camera, material, geometryChunk ) { var mColor, mOpacity, mReflectivity, mWireframe, mLineWidth, mBlending, @@ -356,6 +357,9 @@ THREE.WebGLRenderer = function ( scene ) { if ( material instanceof THREE.MeshShaderMaterial ) { + mWireframe = material.wireframe; + mLineWidth = material.wireframe_linewidth; + setUniforms( program, material.uniforms ); this.loadCamera( program, camera ); this.loadMatrices( program ); @@ -471,19 +475,19 @@ THREE.WebGLRenderer = function ( scene ) { // vertices - _gl.bindBuffer( _gl.ARRAY_BUFFER, materialFaceGroup.__webGLVertexBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLVertexBuffer ); _gl.vertexAttribPointer( program.position, 3, _gl.FLOAT, false, 0, 0 ); // normals - _gl.bindBuffer( _gl.ARRAY_BUFFER, materialFaceGroup.__webGLNormalBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer ); _gl.vertexAttribPointer( program.normal, 3, _gl.FLOAT, false, 0, 0 ); // uvs if ( mMap ) { - _gl.bindBuffer( _gl.ARRAY_BUFFER, materialFaceGroup.__webGLUVBuffer ); + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLUVBuffer ); _gl.enableVertexAttribArray( program.uv ); _gl.vertexAttribPointer( program.uv, 2, _gl.FLOAT, false, 0, 0 ); @@ -498,22 +502,22 @@ THREE.WebGLRenderer = function ( scene ) { if ( ! mWireframe ) { - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, materialFaceGroup.__webGLFaceBuffer ); - _gl.drawElements( _gl.TRIANGLES, materialFaceGroup.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 ); + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLFaceBuffer ); + _gl.drawElements( _gl.TRIANGLES, geometryChunk.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 ); // render lines } else { _gl.lineWidth( mLineWidth ); - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, materialFaceGroup.__webGLLineBuffer ); - _gl.drawElements( _gl.LINES, materialFaceGroup.__webGLLineCount, _gl.UNSIGNED_SHORT, 0 ); + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLLineBuffer ); + _gl.drawElements( _gl.LINES, geometryChunk.__webGLLineCount, _gl.UNSIGNED_SHORT, 0 ); } }; - this.renderPass = function ( camera, object, materialFaceGroup, blending, transparent ) { + this.renderPass = function ( camera, object, geometryChunk, blending, transparent ) { var i, l, m, ml, material, meshMaterial; @@ -523,13 +527,13 @@ THREE.WebGLRenderer = function ( scene ) { if ( meshMaterial instanceof THREE.MeshFaceMaterial ) { - for ( i = 0, l = materialFaceGroup.material.length; i < l; i++ ) { + for ( i = 0, l = geometryChunk.material.length; i < l; i++ ) { - material = materialFaceGroup.material[ i ]; + material = geometryChunk.material[ i ]; if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) { this.setBlending( material.blending ); - this.renderBuffer( camera, material, materialFaceGroup ); + this.renderBuffer( camera, material, geometryChunk ); } @@ -541,7 +545,7 @@ THREE.WebGLRenderer = function ( scene ) { if ( material && material.blending == blending && ( material.opacity < 1.0 == transparent ) ) { this.setBlending( material.blending ); - this.renderBuffer( camera, material, materialFaceGroup ); + this.renderBuffer( camera, material, geometryChunk ); } @@ -553,7 +557,7 @@ THREE.WebGLRenderer = function ( scene ) { this.render = function( scene, camera ) { - var o, ol; + var o, ol, webGLObject, object, buffer; this.initWebGLObjects( scene ); @@ -574,11 +578,14 @@ THREE.WebGLRenderer = function ( scene ) { webGLObject = scene.__webGLObjects[ o ]; - if ( webGLObject.__object.visible ) { + object = webGLObject.object; + buffer = webGLObject.buffer; + + if ( object.visible ) { - this.setupMatrices( webGLObject.__object, camera ); + this.setupMatrices( object, camera ); this.loadMatrices( _program ); - this.renderPass( camera, webGLObject.__object, webGLObject, THREE.NormalBlending, false ); + this.renderPass( camera, object, buffer, THREE.NormalBlending, false ); } @@ -590,24 +597,27 @@ THREE.WebGLRenderer = function ( scene ) { webGLObject = scene.__webGLObjects[ o ]; - if ( webGLObject.__object.visible ) { + object = webGLObject.object; + buffer = webGLObject.buffer; + + if ( object.visible ) { - this.setupMatrices( webGLObject.__object, camera ); + this.setupMatrices( object, camera ); this.loadMatrices( _program ); // opaque blended materials - this.renderPass( camera, webGLObject.__object, webGLObject, THREE.AdditiveBlending, false ); - this.renderPass( camera, webGLObject.__object, webGLObject, THREE.SubtractiveBlending, false ); + this.renderPass( camera, object, buffer, THREE.AdditiveBlending, false ); + this.renderPass( camera, object, buffer, THREE.SubtractiveBlending, false ); // transparent blended materials - this.renderPass( camera, webGLObject.__object, webGLObject, THREE.AdditiveBlending, true ); - this.renderPass( camera, webGLObject.__object, webGLObject, THREE.SubtractiveBlending, true ); + this.renderPass( camera, object, buffer, THREE.AdditiveBlending, true ); + this.renderPass( camera, object, buffer, THREE.SubtractiveBlending, true ); // transparent normal materials - this.renderPass( camera, webGLObject.__object, webGLObject, THREE.NormalBlending, true ); + this.renderPass( camera, object, buffer, THREE.NormalBlending, true ); } @@ -617,11 +627,12 @@ THREE.WebGLRenderer = function ( scene ) { this.initWebGLObjects = function( scene ) { - var o, ol, object, mf, materialFaceGroup; + var o, ol, object, globject, g, geometryChunk, objmap; if ( !scene.__webGLObjects ) { scene.__webGLObjects = []; + scene.__webGLObjectsMap = {}; } @@ -629,23 +640,40 @@ THREE.WebGLRenderer = function ( scene ) { object = scene.objects[ o ]; + if ( scene.__webGLObjectsMap[ object.id ] == undefined ) { + + scene.__webGLObjectsMap[ object.id ] = {}; + + } + + objmap = scene.__webGLObjectsMap[ object.id ]; + if ( object instanceof THREE.Mesh ) { - // create separate VBOs per material + // create separate VBOs per geometry chunk - for ( mf in object.materialFaceGroup ) { + for ( g in object.geometry.geometryChunks ) { - materialFaceGroup = object.materialFaceGroup[ mf ]; + geometryChunk = object.geometry.geometryChunks[ g ]; - // initialise buffers on the first access + // initialise VBO on the first access - if( ! materialFaceGroup.__webGLVertexBuffer ) { + if( ! geometryChunk.__webGLVertexBuffer ) { - this.createBuffers( object, mf ); - materialFaceGroup.__object = object; - scene.__webGLObjects.push( materialFaceGroup ); + this.createBuffers( object, g ); } + + // create separate wrapper per each use of VBO + + if ( objmap[ g ] == undefined ) { + + globject = { buffer: geometryChunk, object: object }; + scene.__webGLObjects.push( globject ); + + objmap[ g ] = 1; + + } } @@ -665,7 +693,7 @@ THREE.WebGLRenderer = function ( scene ) { for ( o = scene.__webGLObjects.length - 1; o >= 0; o-- ) { - zobject = scene.__webGLObjects[ o ].__object; + zobject = scene.__webGLObjects[ o ].object; if ( object == zobject ) { @@ -1296,7 +1324,7 @@ THREE.WebGLRenderer = function ( scene ) { function initUbershader( maxDirLights, maxPointLights ) { var vertex_shader = generateVertexShader( maxDirLights, maxPointLights ), - fragment_shader = generateFragmentShader( maxDirLights, maxPointLights ); + fragment_shader = generateFragmentShader( maxDirLights, maxPointLights ); //log ( vertex_shader ); //log ( fragment_shader ); @@ -1401,7 +1429,7 @@ THREE.WebGLRenderer = function ( scene ) { }; - function bufferNeedsSmoothNormals( materialFaceGroup, object ) { + function bufferNeedsSmoothNormals( geometryChunk, object ) { var m, ml, i, l, needsSmoothNormals = false; @@ -1411,9 +1439,9 @@ THREE.WebGLRenderer = function ( scene ) { if ( meshMaterial instanceof THREE.MeshFaceMaterial ) { - for ( i = 0, l = materialFaceGroup.material.length; i < l; i++ ) { + for ( i = 0, l = geometryChunk.material.length; i < l; i++ ) { - if ( materialNeedsSmoothNormals( materialFaceGroup.material[ i ] ) ) { + if ( materialNeedsSmoothNormals( geometryChunk.material[ i ] ) ) { needsSmoothNormals = true; break;