diff --git a/build/Three.js b/build/Three.js index df3ddc79..41cb03f7 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,70 +1,70 @@ // Three.js r32 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)}; -THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var f,j,k,q,o,l;if(d==0)f=j=k=0;else{q=Math.floor(a*6);o=a*6-q;a=d*(1-c);l=d*(1-c*o);c=d*(1-c*(1-o));switch(q){case 1:f=l;j=d;k=a;break;case 2:f=a;j=d;k=c;break;case 3:f=a;j=l;k=d;break;case 4:f=c;j=a;k=d;break;case 5:f=d;j=a;k=l;break;case 6:case 0:f=d;j=c;k=a}}this.r=f;this.g=j;this.b=k;if(this.autoUpdate){this.updateHex();this.updateStyleString()}}, +THREE.Color.prototype={setRGB:function(a,c,e){this.r=a;this.g=c;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,e){var g,i,k,q,p,l;if(e==0)g=i=k=0;else{q=Math.floor(a*6);p=a*6-q;a=e*(1-c);l=e*(1-c*p);c=e*(1-c*(1-p));switch(q){case 1:g=l;i=e;k=a;break;case 2:g=a;i=e;k=c;break;case 3:g=a;i=l;k=e;break;case 4:g=c;i=a;k=e;break;case 5:g=e;i=a;k=l;break;case 6:case 0:g=e;i=c;k=a}}this.r=g;this.g=i;this.b=k;if(this.autoUpdate){this.updateHex();this.updateStyleString()}}, setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+ this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0}; THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.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,c,d){this.x=a||0;this.y=c||0;this.z=d||0}; -THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, -cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/= -a.z;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 c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+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)},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,c,e){this.x=a||0;this.y=c||0;this.z=e||0}; +THREE.Vector3.prototype={set:function(a,c,e){this.x=a;this.y=c;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, +cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,e=this.y,g=this.z;this.x=e*a.z-g*a.y;this.y=g*a.x-c*a.z;this.z=c*a.y-e*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/= +a.z;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 c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+e*e+a*a)},distanceToSquared:function(a){var c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return c*c+e*e+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,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1}; -THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c,e,g){this.x=a||0;this.y=c||0;this.z=e||0;this.w=g||1}; +THREE.Vector4.prototype={set:function(a,c,e,g){this.x=a;this.y=c;this.z=e;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},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,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,j=[];a=0;for(c=f.length;a0&&I>0&&R+I<1}var d,f,j,k,q,o,l,n,z,y, -v,x=a.geometry,F=x.vertices,H=[];d=0;for(f=x.faces.length;dl?f:l;j=j>n? -j:n}a()};this.add3Points=function(l,n,z,y,v,x){if(o){o=false;c=lz?l>v?l:v:z>v?z:v;j=n>y?n>x?n:x:y>x?y:x}else{c=lz?l>v?l>f?l:f:v>f?v:f:z>v?z>f?z:f:v>f?v:f;j=n>y?n>x?n>j?n:j:x>j?x:j:y>x?y>j?y:j:x>j?x:j}a()};this.addRectangle=function(l){if(o){o=false;c=l.getLeft();d=l.getTop();f=l.getRight();j=l.getBottom()}else{c=cl.getRight()?f:l.getRight();j=j>l.getBottom()?j:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;f+=l;j+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();f=f=0&&Math.min(j,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){o=true;j=f=d=c=0;a()};this.isEmpty=function(){return o};this.toString= -function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+j+", width: "+k+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; -THREE.Matrix4=function(a,c,d,f,j,k,q,o,l,n,z,y,v,x,F,H){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=j||0;this.n22=k||1;this.n23=q||0;this.n24=o||0;this.n31=l||0;this.n32=n||0;this.n33=z||1;this.n34=y||0;this.n41=v||0;this.n42=x||0;this.n43=F||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={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;return this},set:function(a,c,d,f,j,k,q,o,l,n,z,y,v,x,F,H){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=j;this.n22=k;this.n23=q;this.n24=o;this.n31=l;this.n32=n;this.n33=z;this.n34=y;this.n41=v;this.n42=x;this.n43=F;this.n44=H;return this},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;return this},lookAt:function(a,c,d){var f=THREE.Matrix4.__tmpVec1,j=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,c).normalize();f.cross(d,k).normalize();j.cross(k,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a); -this.n31=k.x;this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,j=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*j;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*j;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*j;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,j=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*j;a.y=this.n21*c+this.n22*d+this.n23* -f+this.n24*j;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*j;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*j;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,f=a.n12,j=a.n13,k=a.n14,q=a.n21,o=a.n22,l=a.n23,n=a.n24,z=a.n31, -y=a.n32,v=a.n33,x=a.n34,F=a.n41,H=a.n42,I=a.n43,s=a.n44,O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43,aa=c.n44;this.n11=d*O+f*$+j*G+k*K;this.n12=d*C+f*Q+j*U+k*ca;this.n13=d*b+f*J+j*M+k*N;this.n14=d*R+f*X+j*D+k*aa;this.n21=q*O+o*$+l*G+n*K;this.n22=q*C+o*Q+l*U+n*ca;this.n23=q*b+o*J+l*M+n*N;this.n24=q*R+o*X+l*D+n*aa;this.n31=z*O+y*$+v*G+x*K;this.n32=z*C+y*Q+v*U+x*ca;this.n33=z*b+y*J+v*M+x*N;this.n34=z*R+y*X+v*D+x*aa;this.n41= -F*O+H*$+I*G+s*K;this.n42=F*C+H*Q+I*U+s*ca;this.n43=F*b+H*J+I*M+s*N;this.n44=F*R+H*X+I*D+s*aa;return this},multiplyToArray:function(a,c,d){var f=a.n11,j=a.n12,k=a.n13,q=a.n14,o=a.n21,l=a.n22,n=a.n23,z=a.n24,y=a.n31,v=a.n32,x=a.n33,F=a.n34,H=a.n41,I=a.n42,s=a.n43;a=a.n44;var O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43;c=c.n44;this.n11=f*O+j*$+k*G+q*K;this.n12=f*C+j*Q+k*U+q*ca;this.n13=f*b+j*J+k*M+q*N;this.n14=f*R+j*X+k*D+q* -c;this.n21=o*O+l*$+n*G+z*K;this.n22=o*C+l*Q+n*U+z*ca;this.n23=o*b+l*J+n*M+z*N;this.n24=o*R+l*X+n*D+z*c;this.n31=y*O+v*$+x*G+F*K;this.n32=y*C+v*Q+x*U+F*ca;this.n33=y*b+v*J+x*M+F*N;this.n34=y*R+v*X+x*D+F*c;this.n41=H*O+I*$+s*G+a*K;this.n42=H*C+I*Q+s*U+a*ca;this.n43=H*b+I*J+s*M+a*N;this.n44=H*R+I*X+s*D+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24; -d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,j=this.n14,k=this.n21,q=this.n22,o=this.n23,l=this.n24,n=this.n31,z=this.n32,y=this.n33,v=this.n34,x=this.n41,F=this.n42,H=this.n43,I=this.n44,s=a.n11,O=a.n21,C=a.n31,b=a.n41,R=a.n12,$=a.n22,Q=a.n32,J=a.n42,X=a.n13,G=a.n23,U=a.n33,M=a.n43,D=a.n14,K=a.n24,ca=a.n34;a=a.n44;this.n11=c*s+d*O+f*C+j*b;this.n12=c*R+d*$+f*Q+j*J;this.n13=c*X+d*G+f*U+j*M;this.n14=c*D+d*K+f*ca+j*a;this.n21=k*s+q*O+o*C+l* -b;this.n22=k*R+q*$+o*Q+l*J;this.n23=k*X+q*G+o*U+l*M;this.n24=k*D+q*K+o*ca+l*a;this.n31=n*s+z*O+y*C+v*b;this.n32=n*R+z*$+y*Q+v*J;this.n33=n*X+z*G+y*U+v*M;this.n34=n*D+z*K+y*ca+v*a;this.n41=x*s+F*O+H*C+I*b;this.n42=x*R+F*$+H*Q+I*J;this.n43=x*X+F*G+H*U+I*M;this.n44=x*D+F*K+H*ca+I*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*= -a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,f=this.n14,j=this.n21,k=this.n22,q=this.n23,o=this.n24,l=this.n31,n=this.n32,z=this.n33,y=this.n34,v=this.n41,x=this.n42,F=this.n43,H=this.n44;return f*q*n*v-d*o*n*v-f*k*z*v+c*o*z*v+d*k*y*v-c*q*y*v-f*q*l*x+d*o*l*x+f*j*z*x-a*o*z*x-d*j*y*x+a*q*y*x+f*k*l*F-c*o*l*F-f*j*n*F+a*o*n*F+c*j*y*F-a*k*y*F-d*k*l*H+c*q*l*H+d*j*n*H-a*q*n*H-c*j*z*H+a*k*z*H},transpose:function(){function a(c,d,f){var j=c[d];c[d]=c[f];c[f]=j}a(this,"n21","n12"); -a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12; -a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d, -0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),j=1-d,k=a.x,q=a.y, -o=a.z,l=j*k,n=j*q;this.set(l*k+d,l*q-f*o,l*o+f*q,0,l*q+f*o,n*q+d,n*o-f*k,0,l*o-f*q,n*o+f*k,j*o*o+d,0,0,0,0,1);return this},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,c,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f}; -THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d}; -THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,j=a.n14,k=a.n21,q=a.n22,o=a.n23,l=a.n24,n=a.n31,z=a.n32,y=a.n33,v=a.n34,x=a.n41,F=a.n42,H=a.n43,I=a.n44,s=new THREE.Matrix4;s.n11=o*v*F-l*y*F+l*z*H-q*v*H-o*z*I+q*y*I;s.n12=j*y*F-f*v*F-j*z*H+d*v*H+f*z*I-d*y*I;s.n13=f*l*F-j*o*F+j*q*H-d*l*H-f*q*I+d*o*I;s.n14=j*o*z-f*l*z-j*q*y+d*l*y+f*q*v-d*o*v;s.n21=l*y*x-o*v*x-l*n*H+k*v*H+o*n*I-k*y*I;s.n22=f*v*x-j*y*x+j*n*H-c*v*H-f*n*I+c*y*I;s.n23=j*o*x-f*l*x-j*k*H+c*l*H+f*k*I-c*o*I;s.n24=f*l*n-j*o*n+ -j*k*y-c*l*y-f*k*v+c*o*v;s.n31=q*v*x-l*z*x+l*n*F-k*v*F-q*n*I+k*z*I;s.n32=j*z*x-d*v*x-j*n*F+c*v*F+d*n*I-c*z*I;s.n33=f*l*x-j*q*x+j*k*F-c*l*F-d*k*I+c*q*I;s.n34=j*q*n-d*l*n-j*k*z+c*l*z+d*k*v-c*q*v;s.n41=o*z*x-q*y*x-o*n*F+k*y*F+q*n*H-k*z*H;s.n42=d*y*x-f*z*x+f*n*F-c*y*F-d*n*H+c*z*H;s.n43=f*q*x-d*o*x-f*k*F+c*o*F+d*k*H-c*q*H;s.n44=d*o*n-f*q*n+f*k*z-c*o*z-d*k*y+c*q*y;s.multiplyScalar(1/a.determinant());return s}; -THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,f=a.n33*a.n22-a.n32*a.n23,j=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,q=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,z=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*q+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*j;d[2]=a*k;d[3]=a*q;d[4]=a*o;d[5]=a*l;d[6]=a*n;d[7]=a*z;d[8]=a*y;return c}; -THREE.Matrix4.makeFrustum=function(a,c,d,f,j,k){var q,o,l;q=new THREE.Matrix4;o=2*j/(c-a);l=2*j/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(k+j)/(k-j);j=-2*k*j/(k-j);q.n11=o;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=j;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*c,a*c,j,a,d,f)}; -THREE.Matrix4.makeOrtho=function(a,c,d,f,j,k){var q,o,l,n;q=new THREE.Matrix4;o=c-a;l=d-f;n=k-j;a=(c+a)/o;d=(d+f)/l;j=(k+j)/n;q.n11=2/o;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/n;q.n34=-j;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; +THREE.Ray.prototype={intersectScene:function(a){var c,e,g=a.objects,i=[];a=0;for(c=g.length;a0&&G>0&&b+G<1}var e,g,i,k,q,p,l,n,y,z, +t,x=a.geometry,D=x.vertices,H=[];e=0;for(g=x.faces.length;el?g:l;i=i>n? +i:n}a()};this.add3Points=function(l,n,y,z,t,x){if(p){p=false;c=ly?l>t?l:t:y>t?y:t;i=n>z?n>x?n:x:z>x?z:x}else{c=ly?l>t?l>g?l:g:t>g?t:g:y>t?y>g?y:g:t>g?t:g;i=n>z?n>x?n>i?n:i:x>i?x:i:z>x?z>i?z:i:x>i?x:i}a()};this.addRectangle=function(l){if(p){p=false;c=l.getLeft();e=l.getTop();g=l.getRight();i=l.getBottom()}else{c=cl.getRight()?g:l.getRight();i=i>l.getBottom()?i:l.getBottom()}a()};this.inflate=function(l){c-=l;e-=l;g+=l;i+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();e=e>l.getTop()?e:l.getTop();g=g=0&&Math.min(i,l.getBottom())-Math.max(e,l.getTop())>=0};this.empty=function(){p=true;i=g=e=c=0;a()};this.isEmpty=function(){return p};this.toString= +function(){return"THREE.Rectangle ( left: "+c+", right: "+g+", top: "+e+", bottom: "+i+", width: "+k+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; +THREE.Matrix4=function(a,c,e,g,i,k,q,p,l,n,y,z,t,x,D,H){this.n11=a||1;this.n12=c||0;this.n13=e||0;this.n14=g||0;this.n21=i||0;this.n22=k||1;this.n23=q||0;this.n24=p||0;this.n31=l||0;this.n32=n||0;this.n33=y||1;this.n34=z||0;this.n41=t||0;this.n42=x||0;this.n43=D||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={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;return this},set:function(a,c,e,g,i,k,q,p,l,n,y,z,t,x,D,H){this.n11=a;this.n12=c;this.n13=e;this.n14=g;this.n21=i;this.n22=k;this.n23=q;this.n24=p;this.n31=l;this.n32=n;this.n33=y;this.n34=z;this.n41=t;this.n42=x;this.n43=D;this.n44=H;return this},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;return this},lookAt:function(a,c,e){var g=THREE.Matrix4.__tmpVec1,i=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,c).normalize();g.cross(e,k).normalize();i.cross(k,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a); +this.n31=k.x;this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,e=a.y,g=a.z,i=1/(this.n41*c+this.n42*e+this.n43*g+this.n44);a.x=(this.n11*c+this.n12*e+this.n13*g+this.n14)*i;a.y=(this.n21*c+this.n22*e+this.n23*g+this.n24)*i;a.z=(this.n31*c+this.n32*e+this.n33*g+this.n34)*i;return a},multiplyVector4:function(a){var c=a.x,e=a.y,g=a.z,i=a.w;a.x=this.n11*c+this.n12*e+this.n13*g+this.n14*i;a.y=this.n21*c+this.n22*e+this.n23* +g+this.n24*i;a.z=this.n31*c+this.n32*e+this.n33*g+this.n34*i;a.w=this.n41*c+this.n42*e+this.n43*g+this.n44*i;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var e=a.n11,g=a.n12,i=a.n13,k=a.n14,q=a.n21,p=a.n22,l=a.n23,n=a.n24,y=a.n31, +z=a.n32,t=a.n33,x=a.n34,D=a.n41,H=a.n42,G=a.n43,r=a.n44,S=c.n11,B=c.n12,I=c.n13,b=c.n14,aa=c.n21,P=c.n22,J=c.n23,W=c.n24,M=c.n31,R=c.n32,K=c.n33,C=c.n34,L=c.n41,ba=c.n42,N=c.n43,da=c.n44;this.n11=e*S+g*aa+i*M+k*L;this.n12=e*B+g*P+i*R+k*ba;this.n13=e*I+g*J+i*K+k*N;this.n14=e*b+g*W+i*C+k*da;this.n21=q*S+p*aa+l*M+n*L;this.n22=q*B+p*P+l*R+n*ba;this.n23=q*I+p*J+l*K+n*N;this.n24=q*b+p*W+l*C+n*da;this.n31=y*S+z*aa+t*M+x*L;this.n32=y*B+z*P+t*R+x*ba;this.n33=y*I+z*J+t*K+x*N;this.n34=y*b+z*W+t*C+x*da;this.n41= +D*S+H*aa+G*M+r*L;this.n42=D*B+H*P+G*R+r*ba;this.n43=D*I+H*J+G*K+r*N;this.n44=D*b+H*W+G*C+r*da;return this},multiplyToArray:function(a,c,e){var g=a.n11,i=a.n12,k=a.n13,q=a.n14,p=a.n21,l=a.n22,n=a.n23,y=a.n24,z=a.n31,t=a.n32,x=a.n33,D=a.n34,H=a.n41,G=a.n42,r=a.n43;a=a.n44;var S=c.n11,B=c.n12,I=c.n13,b=c.n14,aa=c.n21,P=c.n22,J=c.n23,W=c.n24,M=c.n31,R=c.n32,K=c.n33,C=c.n34,L=c.n41,ba=c.n42,N=c.n43;c=c.n44;this.n11=g*S+i*aa+k*M+q*L;this.n12=g*B+i*P+k*R+q*ba;this.n13=g*I+i*J+k*K+q*N;this.n14=g*b+i*W+k* +C+q*c;this.n21=p*S+l*aa+n*M+y*L;this.n22=p*B+l*P+n*R+y*ba;this.n23=p*I+l*J+n*K+y*N;this.n24=p*b+l*W+n*C+y*c;this.n31=z*S+t*aa+x*M+D*L;this.n32=z*B+t*P+x*R+D*ba;this.n33=z*I+t*J+x*K+D*N;this.n34=z*b+t*W+x*C+D*c;this.n41=H*S+G*aa+r*M+a*L;this.n42=H*B+G*P+r*R+a*ba;this.n43=H*I+G*J+r*K+a*N;this.n44=H*b+G*W+r*C+a*c;e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]= +this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,e=this.n12,g=this.n13,i=this.n14,k=this.n21,q=this.n22,p=this.n23,l=this.n24,n=this.n31,y=this.n32,z=this.n33,t=this.n34,x=this.n41,D=this.n42,H=this.n43,G=this.n44,r=a.n11,S=a.n21,B=a.n31,I=a.n41,b=a.n12,aa=a.n22,P=a.n32,J=a.n42,W=a.n13,M=a.n23,R=a.n33,K=a.n43,C=a.n14,L=a.n24,ba=a.n34;a=a.n44;this.n11=c*r+e*S+g*B+i*I;this.n12=c*b+e*aa+g*P+i*J;this.n13=c*W+e*M+g*R+i*K;this.n14=c*C+e*L+g*ba+i*a;this.n21=k*r+ +q*S+p*B+l*I;this.n22=k*b+q*aa+p*P+l*J;this.n23=k*W+q*M+p*R+l*K;this.n24=k*C+q*L+p*ba+l*a;this.n31=n*r+y*S+z*B+t*I;this.n32=n*b+y*aa+z*P+t*J;this.n33=n*W+y*M+z*R+t*K;this.n34=n*C+y*L+z*ba+t*a;this.n41=x*r+D*S+H*B+G*I;this.n42=x*b+D*aa+H*P+G*J;this.n43=x*W+D*M+H*R+G*K;this.n44=x*C+D*L+H*ba+G*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a; +this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,e=this.n13,g=this.n14,i=this.n21,k=this.n22,q=this.n23,p=this.n24,l=this.n31,n=this.n32,y=this.n33,z=this.n34,t=this.n41,x=this.n42,D=this.n43,H=this.n44;return g*q*n*t-e*p*n*t-g*k*y*t+c*p*y*t+e*k*z*t-c*q*z*t-g*q*l*x+e*p*l*x+g*i*y*x-a*p*y*x-e*i*z*x+a*q*z*x+g*k*l*D-c*p*l*D-g*i*n*D+a*p*n*D+c*i*z*D-a*k*z*D-e*k*l*H+c*q*l*H+e*i*n*H-a*q*n*H-c*i*y*H+a*k*y*H},transpose:function(){function a(c,e,g){var i=c[e];c[e]=c[g];c[g]= +i}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(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31; +a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,e){this.set(1, +0,0,a,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(a,c,e){this.set(a,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var e=Math.cos(c),g=Math.sin(c), +i=1-e,k=a.x,q=a.y,p=a.z,l=i*k,n=i*q;this.set(l*k+e,l*q-g*p,l*p+g*q,0,l*q+g*p,n*q+e,n*p-g*k,0,l*p-g*q,n*p+g*k,i*p*p+e,0,0,0,0,1);return this},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,c,e){var g=new THREE.Matrix4;g.setTranslation(a,c,e);return g}; +THREE.Matrix4.scaleMatrix=function(a,c,e){var g=new THREE.Matrix4;g.setScale(a,c,e);return g};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var e=new THREE.Matrix4;e.setRotAxis(a,c);return e}; +THREE.Matrix4.makeInvert=function(a){var c=a.n11,e=a.n12,g=a.n13,i=a.n14,k=a.n21,q=a.n22,p=a.n23,l=a.n24,n=a.n31,y=a.n32,z=a.n33,t=a.n34,x=a.n41,D=a.n42,H=a.n43,G=a.n44,r=new THREE.Matrix4;r.n11=p*t*D-l*z*D+l*y*H-q*t*H-p*y*G+q*z*G;r.n12=i*z*D-g*t*D-i*y*H+e*t*H+g*y*G-e*z*G;r.n13=g*l*D-i*p*D+i*q*H-e*l*H-g*q*G+e*p*G;r.n14=i*p*y-g*l*y-i*q*z+e*l*z+g*q*t-e*p*t;r.n21=l*z*x-p*t*x-l*n*H+k*t*H+p*n*G-k*z*G;r.n22=g*t*x-i*z*x+i*n*H-c*t*H-g*n*G+c*z*G;r.n23=i*p*x-g*l*x-i*k*H+c*l*H+g*k*G-c*p*G;r.n24=g*l*n-i*p*n+ +i*k*z-c*l*z-g*k*t+c*p*t;r.n31=q*t*x-l*y*x+l*n*D-k*t*D-q*n*G+k*y*G;r.n32=i*y*x-e*t*x-i*n*D+c*t*D+e*n*G-c*y*G;r.n33=g*l*x-i*q*x+i*k*D-c*l*D-e*k*G+c*q*G;r.n34=i*q*n-e*l*n-i*k*y+c*l*y+e*k*t-c*q*t;r.n41=p*y*x-q*z*x-p*n*D+k*z*D+q*n*H-k*y*H;r.n42=e*z*x-g*y*x+g*n*D-c*z*D-e*n*H+c*y*H;r.n43=g*q*x-e*p*x-g*k*D+c*p*D+e*k*H-c*q*H;r.n44=e*p*n-g*q*n+g*k*y-c*p*y-e*k*z+c*q*z;r.multiplyScalar(1/a.determinant());return r}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,e=c.m,g=a.n33*a.n22-a.n32*a.n23,i=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,q=-a.n33*a.n12+a.n32*a.n13,p=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,n=a.n23*a.n12-a.n22*a.n13,y=-a.n23*a.n11+a.n21*a.n13,z=a.n22*a.n11-a.n21*a.n12;a=a.n11*g+a.n21*q+a.n31*n;if(a==0)throw"matrix not invertible";a=1/a;e[0]=a*g;e[1]=a*i;e[2]=a*k;e[3]=a*q;e[4]=a*p;e[5]=a*l;e[6]=a*n;e[7]=a*y;e[8]=a*z;return c}; +THREE.Matrix4.makeFrustum=function(a,c,e,g,i,k){var q,p,l;q=new THREE.Matrix4;p=2*i/(c-a);l=2*i/(g-e);a=(c+a)/(c-a);e=(g+e)/(g-e);g=-(k+i)/(k-i);i=-2*k*i/(k-i);q.n11=p;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=e;q.n24=0;q.n31=0;q.n32=0;q.n33=g;q.n34=i;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,e,g){var i;a=e*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*c,a*c,i,a,e,g)}; +THREE.Matrix4.makeOrtho=function(a,c,e,g,i,k){var q,p,l,n;q=new THREE.Matrix4;p=c-a;l=e-g;n=k-i;a=(c+a)/p;e=(e+g)/l;i=(k+i)/n;q.n11=2/p;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-e;q.n31=0;q.n32=0;q.n33=-2/n;q.n34=-i;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; -THREE.Face3=function(a,c,d,f,j){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,c,d,f,j,k){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.materials=k instanceof Array?k:[k]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; -THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a0){this.boundingBox={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 c=1,d=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z -this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c65535){n[o].counter+=1;l=n[o].hash+"_"+n[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+ -this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; -this.translateZ=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()}; +THREE.Face3=function(a,c,e,g,i){this.a=a;this.b=c;this.c=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,c,e,g,i,k){this.a=a;this.b=c;this.c=e;this.d=g;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.materials=k instanceof Array?k:[k]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; +THREE.Geometry.prototype={computeCentroids:function(){var a,c,e;a=0;for(c=this.faces.length;a0){this.boundingBox={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 c=1,e=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z +this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,e=this.vertices.length;c65535){n[p].counter+=1;l=n[p].hash+"_"+n[p].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(g);this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+ +this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0; +THREE.Camera=function(a,c,e,g){this.fov=a;this.aspect=c;this.near=e;this.far=g;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(i);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; +this.translateZ=function(i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(i);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()}; THREE.Camera.prototype={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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light; THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true;this.children=[]}; -THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.matrix,j=this.rotationMatrix,k=this.tmpMatrix;f.setTranslation(a.x,a.y,a.z);j.setRotX(c.x);c.y!=0&&j.multiplySelf(k.setRotY(c.y));c.z!=0&&j.multiplySelf(k.setRotZ(c.z));f.multiplySelf(j);if(d.x!=0||d.y!=0||d.z!=0)f.multiplySelf(k.setScale(d.x, -d.y,d.z))}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem; -THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()}; +THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,c=this.rotation,e=this.scale,g=this.matrix,i=this.rotationMatrix,k=this.tmpMatrix;g.setTranslation(a.x,a.y,a.z);i.setRotX(c.x);c.y!=0&&i.multiplySelf(k.setRotY(c.y));c.z!=0&&i.multiplySelf(k.setRotZ(c.z));g.multiplySelf(i);if(e.x!=0||e.y!=0||e.z!=0)g.multiplySelf(k.setScale(e.x, +e.y,e.z))}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem; +THREE.Line=function(a,c,e){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=e!=undefined?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()}; THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3; THREE.LineBasicMaterial=function(a){this.id=THREE.LineBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;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;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth= a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}}; @@ -96,121 +96,121 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM THREE.ParticleBasicMaterial=function(a){this.id=THREE.ParticleBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.offset=new THREE.Vector2;this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending; if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (
id: "+this.id+"
color: "+this.color+"
opacity: "+this.opacity+"
map: "+this.map+"
size: "+this.size+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
vertex_colors: "+this.vertex_colors+"
)"}};THREE.ParticleBasicMaterialCounter={value:0}; THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);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}};THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; -THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,f,j,k){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter}; +THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,e,g,i,k){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=g!==undefined?g:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter}; THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+this.min_filter+"
)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2; THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20; -THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType}; -var Uniforms={clone:function(a){var c,d,f,j={};for(c in a){j[c]={};for(d in a[c]){f=a[c][d];j[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return j},merge:function(a){var c,d,f,j={};for(c=0;c=0&&M>=0&&D>=0&&K>=0)return true;else if(U<0&&M<0||D<0&&K<0)return false;else{if(U<0)X=Math.max(X,U/(U-M));else if(M<0)G=Math.min(G,U/(U-M));if(D<0)X=Math.max(X,D/(D-K));else if(K<0)G=Math.min(G,D/(D-K));if(GU&&N.z0&&I.z<1){v=F[x]=F[x]||new THREE.RenderableParticle;v.x=I.x/I.w;v.y=I.y/I.w;v.z=I.z;v.rotation=i.rotation.z;v.scale.x=i.scale.x*Math.abs(v.x-(I.x+J.projectionMatrix.n11)/ -(I.w+J.projectionMatrix.n14));v.scale.y=i.scale.y*Math.abs(v.y-(I.y+J.projectionMatrix.n22)/(I.w+J.projectionMatrix.n24));v.materials=i.materials;G.push(v);x++}}}}X&&G.sort(a);return G};this.unprojectVector=function(Q,J){var X=THREE.Matrix4.makeInvert(J.matrix);X.multiplySelf(THREE.Matrix4.makeInvert(J.projectionMatrix));X.multiplyVector3(Q);return Q}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,j,k;this.domElement=document.createElement("div");this.setSize=function(q,o){d=q;f=o;j=d/2;k=f/2};this.render=function(q,o){var l,n,z,y,v,x,F,H;a=c.projectScene(q,o);l=0;for(n=a.length;l0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}else if(ha instanceof THREE.PointLight){S.sub(ha.position,Z);S.normalize();ha=T.dot(S)* -xa;if(ha>0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}}}function la(A,Z,T){if(T.opacity!=0){a(T.opacity);c(T.blending);var E,L,ha,ra,xa,za;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){ra=T.map.image;xa=ra.width>>1;za=ra.height>>1;L=Z.scale.x*o;ha=Z.scale.y*l;T=L*xa;E=ha*za;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(r)){n.save();n.translate(A.x,A.y);n.rotate(-Z.rotation);n.scale(L,-ha);n.translate(-xa,-za);n.drawImage(ra,0,0);n.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(p){B.r= -V.r+da.r+ea.r;B.g=V.g+da.g+ea.g;B.b=V.b+da.b+ea.b;G.r=T.color.r*B.r;G.g=T.color.g*B.g;G.b=T.color.b*B.b;G.updateStyleString()}else G.__styleString=T.color.__styleString;T=Z.scale.x*o;E=Z.scale.y*l;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(r)){L=G.__styleString;if(H!=L)n.fillStyle=H=L;n.save();n.translate(A.x,A.y);n.rotate(-Z.rotation);n.scale(T,E);n.beginPath();n.arc(0,0,1,0,ia,true);n.closePath();n.fill();n.restore()}}}}function na(A,Z,T,E){if(E.opacity!=0){a(E.opacity);c(E.blending);n.beginPath(); -n.moveTo(A.positionScreen.x,A.positionScreen.y);n.lineTo(Z.positionScreen.x,Z.positionScreen.y);n.closePath();if(E instanceof THREE.LineBasicMaterial){G.__styleString=E.color.__styleString;A=E.linewidth;if(I!=A)n.lineWidth=I=A;A=G.__styleString;if(F!=A)n.strokeStyle=F=A;n.stroke();r.inflate(E.linewidth*2)}}}function Ja(A,Z,T,E,L,ha){if(L.opacity!=0){a(L.opacity);c(L.blending);b=A.positionScreen.x;R=A.positionScreen.y;$=Z.positionScreen.x;Q=Z.positionScreen.y;J=T.positionScreen.x;X=T.positionScreen.y; -n.beginPath();n.moveTo(b,R);n.lineTo($,Q);n.lineTo(J,X);n.lineTo(b,R);n.closePath();if(L instanceof THREE.MeshBasicMaterial)if(L.map)L.map.image.loaded&&L.map.mapping instanceof THREE.UVMapping&&ga(b,R,$,Q,J,X,L.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(L.env_map){if(L.env_map.image.loaded)if(L.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=ba.matrix;S.copy(E.vertexNormalsWorld[0]);e=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;i=-(S.x*A.n21+S.y* -A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[1]);m=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;h=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[2]);g=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;t=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;ga(b,R,$,Q,J,X,L.env_map.image,e,i,m,h,g,t)}}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):va(L.color.__styleString);else if(L instanceof THREE.MeshLambertMaterial){if(L.map&&!L.wireframe){L.map.mapping instanceof THREE.UVMapping&& -ga(b,R,$,Q,J,X,L.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);c(THREE.SubtractiveBlending)}if(p)if(!L.wireframe&&L.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){U.r=M.r=D.r=V.r;U.g=M.g=D.g=V.g;U.b=M.b=D.b=V.b;qa(ha,E.v1.positionWorld,E.vertexNormalsWorld[0],U);qa(ha,E.v2.positionWorld,E.vertexNormalsWorld[1],M);qa(ha,E.v3.positionWorld,E.vertexNormalsWorld[2],D);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0, -0,1,0,0,1)}else{B.r=V.r;B.g=V.g;B.b=V.b;qa(ha,E.centroidWorld,E.normalWorld,B);G.r=L.color.r*B.r;G.g=L.color.g*B.g;G.b=L.color.b*B.b;G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):va(L.color.__styleString)}else if(L instanceof THREE.MeshDepthMaterial){ca=ba.near;N=ba.far;U.r=U.g=U.b=1-Aa(A.positionScreen.z,ca,N);M.r=M.g=M.b=1-Aa(Z.positionScreen.z,ca,N);D.r=D.g=D.b=1-Aa(T.positionScreen.z, -ca,N);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,0,1,0,0,1)}else if(L instanceof THREE.MeshNormalMaterial){G.r=ta(E.normalWorld.x);G.g=ta(E.normalWorld.y);G.b=ta(E.normalWorld.z);G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}}}function Da(A,Z){if(F!=A)n.strokeStyle=F=A;if(I!=Z)n.lineWidth=I=Z;n.stroke();r.inflate(Z*2)}function va(A){if(H!=A)n.fillStyle=H=A;n.fill()}function ga(A,Z,T,E,L,ha,ra,xa,za,Ga, -Ba,Ha,Oa){var Ea,Ia;Ea=ra.width-1;Ia=ra.height-1;xa*=Ea;za*=Ia;Ga*=Ea;Ba*=Ia;Ha*=Ea;Oa*=Ia;T-=A;E-=Z;L-=A;ha-=Z;Ga-=xa;Ba-=za;Ha-=xa;Oa-=za;Ea=Ga*Oa-Ha*Ba;if(Ea!=0){Ia=1/Ea;Ea=(Oa*T-Ba*L)*Ia;Ba=(Oa*E-Ba*ha)*Ia;T=(Ga*L-Ha*T)*Ia;E=(Ga*ha-Ha*E)*Ia;A=A-Ea*xa-T*za;Z=Z-Ba*xa-E*za;n.save();n.transform(Ea,Ba,T,E,A,Z);n.clip();n.drawImage(ra,0,0);n.restore()}}function ma(A,Z,T,E){var L=~~(A.r*255),ha=~~(A.g*255);A=~~(A.b*255);var ra=~~(Z.r*255),xa=~~(Z.g*255);Z=~~(Z.b*255);var za=~~(T.r*255),Ga=~~(T.g*255); -T=~~(T.b*255);var Ba=~~(E.r*255),Ha=~~(E.g*255);E=~~(E.b*255);ka[0]=L<0?0:L>255?255:L;ka[1]=ha<0?0:ha>255?255:ha;ka[2]=A<0?0:A>255?255:A;ka[4]=ra<0?0:ra>255?255:ra;ka[5]=xa<0?0:xa>255?255:xa;ka[6]=Z<0?0:Z>255?255:Z;ka[8]=za<0?0:za>255?255:za;ka[9]=Ga<0?0:Ga>255?255:Ga;ka[10]=T<0?0:T>255?255:T;ka[12]=Ba<0?0:Ba>255?255:Ba;ka[13]=Ha<0?0:Ha>255?255:Ha;ka[14]=E<0?0:E>255?255:E;pa.putImageData(P,0,0);wa.drawImage(Y,0,0);return oa}function Aa(A,Z,T){A=(A-Z)/(T-Z);return A*A*(3-2*A)}function ta(A){A=(A+1)* -0.5;return A<0?0:A>1?1:A}function La(A,Z){var T=Z.x-A.x,E=Z.y-A.y,L=1/Math.sqrt(T*T+E*E);T*=L;E*=L;Z.x+=T;Z.y+=E;A.x-=T;A.y-=E}var ua,Ma,ja,ya,Fa,Ka,Na,sa;this.autoClear?this.clear():n.setTransform(1,0,0,-1,o,l);d=f.projectScene(W,ba,this.sortElements);(p=W.lights.length>0)&&Ca(W);ua=0;for(Ma=d.length;ua=0&&K>=0&&C>=0&&L>=0)return true;else if(R<0&&K<0||C<0&&L<0)return false;else{if(R<0)W=Math.max(W,R/(R-K));else if(K<0)M=Math.min(M,R/(R-K));if(C<0)W=Math.max(W,C/(C-L));else if(L<0)M=Math.min(M,C/(C-L));if(MR&&N.z0&&G.z<1){t=D[x]=D[x]||new THREE.RenderableParticle;t.x=G.x/G.w;t.y=G.y/G.w;t.z=G.z;t.rotation=d.rotation.z;t.scale.x=d.scale.x*Math.abs(t.x-(G.x+J.projectionMatrix.n11)/ +(G.w+J.projectionMatrix.n14));t.scale.y=d.scale.y*Math.abs(t.y-(G.y+J.projectionMatrix.n22)/(G.w+J.projectionMatrix.n24));t.materials=d.materials;M.push(t);x++}}}}W&&M.sort(a);return M};this.unprojectVector=function(P,J){var W=THREE.Matrix4.makeInvert(J.matrix);W.multiplySelf(THREE.Matrix4.makeInvert(J.projectionMatrix));W.multiplyVector3(P);return P}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,e,g,i,k;this.domElement=document.createElement("div");this.setSize=function(q,p){e=q;g=p;i=e/2;k=g/2};this.render=function(q,p){var l,n,y,z,t,x,D,H;a=c.projectScene(q,p);l=0;for(n=a.length;l0){E.r+=pa.r*$;E.g+=pa.g*$;E.b+=pa.b*$}}else if($ instanceof THREE.PointLight){U.sub($.position,X);U.normalize();$=T.dot(U)*wa;if($>0){E.r+= +pa.r*$;E.g+=pa.g*$;E.b+=pa.b*$}}}}function va(A,X,T){if(T.opacity!=0){a(T.opacity);c(T.blending);var E,Q,$,pa,wa,ya;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){pa=T.map.image;wa=pa.width>>1;ya=pa.height>>1;Q=X.scale.x*p;$=X.scale.y*l;T=Q*wa;E=$*ya;m.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(m)){n.save();n.translate(A.x,A.y);n.rotate(-X.rotation);n.scale(Q,-$);n.translate(-wa,-ya);n.drawImage(pa,0,0);n.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(v){s.r= +O.r+Y.r+ga.r;s.g=O.g+Y.g+ga.g;s.b=O.b+Y.b+ga.b;M.r=T.color.r*s.r;M.g=T.color.g*s.g;M.b=T.color.b*s.b;M.updateStyleString()}else M.__styleString=T.color.__styleString;T=X.scale.x*p;E=X.scale.y*l;m.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(m)){Q=M.__styleString;if(H!=Q)n.fillStyle=H=Q;n.save();n.translate(A.x,A.y);n.rotate(-X.rotation);n.scale(T,E);n.beginPath();n.arc(0,0,1,0,ia,true);n.closePath();n.fill();n.restore()}}}}function ma(A,X,T,E){if(E.opacity!=0){a(E.opacity);c(E.blending);n.beginPath(); +n.moveTo(A.positionScreen.x,A.positionScreen.y);n.lineTo(X.positionScreen.x,X.positionScreen.y);n.closePath();if(E instanceof THREE.LineBasicMaterial){M.__styleString=E.color.__styleString;A=E.linewidth;if(G!=A)n.lineWidth=G=A;A=M.__styleString;if(D!=A)n.strokeStyle=D=A;n.stroke();m.inflate(E.linewidth*2)}}}function na(A,X,T,E,Q,$){if(Q.opacity!=0){a(Q.opacity);c(Q.blending);I=A.positionScreen.x;b=A.positionScreen.y;aa=X.positionScreen.x;P=X.positionScreen.y;J=T.positionScreen.x;W=T.positionScreen.y; +n.beginPath();n.moveTo(I,b);n.lineTo(aa,P);n.lineTo(J,W);n.lineTo(I,b);n.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&sa(I,b,aa,P,J,W,Q.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(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof THREE.SphericalReflectionMapping){A=fa.matrix;U.copy(E.vertexNormalsWorld[0]);ca=(U.x*A.n11+U.y*A.n12+U.z*A.n13)*0.5+0.5;d=-(U.x*A.n21+ +U.y*A.n22+U.z*A.n23)*0.5+0.5;U.copy(E.vertexNormalsWorld[1]);j=(U.x*A.n11+U.y*A.n12+U.z*A.n13)*0.5+0.5;o=-(U.x*A.n21+U.y*A.n22+U.z*A.n23)*0.5+0.5;U.copy(E.vertexNormalsWorld[2]);h=(U.x*A.n11+U.y*A.n12+U.z*A.n13)*0.5+0.5;f=-(U.x*A.n21+U.y*A.n22+U.z*A.n23)*0.5+0.5;sa(I,b,aa,P,J,W,Q.env_map.image,ca,d,j,o,h,f)}}else Q.wireframe?Ea(Q.color.__styleString,Q.wireframe_linewidth):Fa(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&& +sa(I,b,aa,P,J,W,Q.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);c(THREE.SubtractiveBlending)}if(v)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){R.r=K.r=C.r=O.r;R.g=K.g=C.g=O.g;R.b=K.b=C.b=O.b;za($,E.v1.positionWorld,E.vertexNormalsWorld[0],R);za($,E.v2.positionWorld,E.vertexNormalsWorld[1],K);za($,E.v3.positionWorld,E.vertexNormalsWorld[2],C);L.r=(K.r+C.r)*0.5;L.g=(K.g+C.g)*0.5;L.b=(K.b+C.b)*0.5;da=ha(R,K,C,L);sa(I,b,aa,P,J,W,da,0, +0,1,0,0,1)}else{s.r=O.r;s.g=O.g;s.b=O.b;za($,E.centroidWorld,E.normalWorld,s);M.r=Q.color.r*s.r;M.g=Q.color.g*s.g;M.b=Q.color.b*s.b;M.updateStyleString();Q.wireframe?Ea(M.__styleString,Q.wireframe_linewidth):Fa(M.__styleString)}else Q.wireframe?Ea(Q.color.__styleString,Q.wireframe_linewidth):Fa(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){ba=fa.near;N=fa.far;R.r=R.g=R.b=1-la(A.positionScreen.z,ba,N);K.r=K.g=K.b=1-la(X.positionScreen.z,ba,N);C.r=C.g=C.b=1-la(T.positionScreen.z, +ba,N);L.r=(K.r+C.r)*0.5;L.g=(K.g+C.g)*0.5;L.b=(K.b+C.b)*0.5;da=ha(R,K,C,L);sa(I,b,aa,P,J,W,da,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){M.r=Aa(E.normalWorld.x);M.g=Aa(E.normalWorld.y);M.b=Aa(E.normalWorld.z);M.updateStyleString();Q.wireframe?Ea(M.__styleString,Q.wireframe_linewidth):Fa(M.__styleString)}}}function Ea(A,X){if(D!=A)n.strokeStyle=D=A;if(G!=X)n.lineWidth=G=X;n.stroke();m.inflate(X*2)}function Fa(A){if(H!=A)n.fillStyle=H=A;n.fill()}function sa(A,X,T,E,Q,$,pa,wa,ya,Ha, +Da,Ia,Oa){var Ga,Ja;Ga=pa.width-1;Ja=pa.height-1;wa*=Ga;ya*=Ja;Ha*=Ga;Da*=Ja;Ia*=Ga;Oa*=Ja;T-=A;E-=X;Q-=A;$-=X;Ha-=wa;Da-=ya;Ia-=wa;Oa-=ya;Ga=Ha*Oa-Ia*Da;if(Ga!=0){Ja=1/Ga;Ga=(Oa*T-Da*Q)*Ja;Da=(Oa*E-Da*$)*Ja;T=(Ha*Q-Ia*T)*Ja;E=(Ha*$-Ia*E)*Ja;A=A-Ga*wa-T*ya;X=X-Da*wa-E*ya;n.save();n.transform(Ga,Da,T,E,A,X);n.clip();n.drawImage(pa,0,0);n.restore()}}function ha(A,X,T,E){var Q=~~(A.r*255),$=~~(A.g*255);A=~~(A.b*255);var pa=~~(X.r*255),wa=~~(X.g*255);X=~~(X.b*255);var ya=~~(T.r*255),Ha=~~(T.g*255);T= +~~(T.b*255);var Da=~~(E.r*255),Ia=~~(E.g*255);E=~~(E.b*255);F[0]=Q<0?0:Q>255?255:Q;F[1]=$<0?0:$>255?255:$;F[2]=A<0?0:A>255?255:A;F[4]=pa<0?0:pa>255?255:pa;F[5]=wa<0?0:wa>255?255:wa;F[6]=X<0?0:X>255?255:X;F[8]=ya<0?0:ya>255?255:ya;F[9]=Ha<0?0:Ha>255?255:Ha;F[10]=T<0?0:T>255?255:T;F[12]=Da<0?0:Da>255?255:Da;F[13]=Ia<0?0:Ia>255?255:Ia;F[14]=E<0?0:E>255?255:E;Z.putImageData(qa,0,0);oa.drawImage(ea,0,0);return ua}function la(A,X,T){A=(A-X)/(T-X);return A*A*(3-2*A)}function Aa(A){A=(A+1)*0.5;return A<0? +0:A>1?1:A}function ta(A,X){var T=X.x-A.x,E=X.y-A.y,Q=1/Math.sqrt(T*T+E*E);T*=Q;E*=Q;X.x+=T;X.y+=E;A.x-=T;A.y-=E}var La,xa,ka,Ba,Ca,Ma,Na,Ka;this.autoClear?this.clear():n.setTransform(1,0,0,-1,p,l);e=g.projectScene(V,fa,this.sortElements);(v=V.lights.length>0)&&ja(V);La=0;for(xa=e.length;La0){m.r+=t.color.r*w;m.g+=t.color.g*w;m.b+=t.color.b*w}}else if(t instanceof THREE.PointLight){X.sub(t.position,i.centroidWorld);X.normalize();w=i.normalWorld.dot(X)*t.intensity;if(w>0){m.r+=t.color.r*w;m.g+=t.color.g*w;m.b+=t.color.b*w}}}}function c(e,i,m,h,g,t){D=f(K++);D.setAttribute("d","M "+e.positionScreen.x+ -" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");if(g instanceof THREE.MeshBasicMaterial)C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(t,h,b);C.r=g.color.r*b.r;C.g=g.color.g*b.g;C.b=g.color.b*b.b;C.updateStyleString()}else C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshDepthMaterial){J=1-g.__2near/(g.__farPlusNear-h.z*g.__farMinusNear); -C.setRGB(J,J,J)}else g instanceof THREE.MeshNormalMaterial&&C.setRGB(j(h.normalWorld.x),j(h.normalWorld.y),j(h.normalWorld.z));g.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+g.wireframe_linewidth+"; stroke-opacity: "+g.opacity+"; stroke-linecap: "+g.wireframe_linecap+"; stroke-linejoin: "+g.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+g.opacity);o.appendChild(D)}function d(e,i,m,h,g,t,w){D=f(K++);D.setAttribute("d", -"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");if(t instanceof THREE.MeshBasicMaterial)C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(w,g,b);C.r=t.color.r*b.r;C.g=t.color.g*b.g;C.b=t.color.b*b.b;C.updateStyleString()}else C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshDepthMaterial){J= -1-t.__2near/(t.__farPlusNear-g.z*t.__farMinusNear);C.setRGB(J,J,J)}else t instanceof THREE.MeshNormalMaterial&&C.setRGB(j(g.normalWorld.x),j(g.normalWorld.y),j(g.normalWorld.z));t.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+t.wireframe_linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframe_linecap+"; stroke-linejoin: "+t.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+t.opacity);o.appendChild(D)} -function f(e){if(G[e]==null){G[e]=document.createElementNS("http://www.w3.org/2000/svg","path");aa==0&&G[e].setAttribute("shape-rendering","crispEdges");return G[e]}return G[e]}function j(e){return e<0?Math.min((1+e)*0.5,0.5):0.5+Math.min(e*0.5,0.5)}var k=null,q=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,n,z,y,v,x,F,H,I=new THREE.Rectangle,s=new THREE.Rectangle,O=false,C=new THREE.Color(16777215),b=new THREE.Color(16777215),R=new THREE.Color(0),$=new THREE.Color(0), -Q=new THREE.Color(0),J,X=new THREE.Vector3,G=[],U=[],M=[],D,K,ca,N,aa=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(e){switch(e){case "high":aa=1;break;case "low":aa=0}};this.setSize=function(e,i){l=e;n=i;z=l/2;y=n/2;o.setAttribute("viewBox",-z+" "+-y+" "+l+" "+n);o.setAttribute("width",l);o.setAttribute("height",n);I.set(-z,-y,z,y)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(e,i){var m, -h,g,t,w,u,r,p;this.autoClear&&this.clear();k=q.projectScene(e,i,this.sortElements);N=ca=K=0;if(O=e.lights.length>0){r=e.lights;R.setRGB(0,0,0);$.setRGB(0,0,0);Q.setRGB(0,0,0);m=0;for(h=r.length;m0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,Ja,V)}if(ya&&ea>0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUV2Buffer); -b.bufferData(b.ARRAY_BUFFER,Da,V)}if(ja){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Aa,V);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ta,V)}}x(objlist,t,h,e,i,m)}g.__dirtyVertices=false;g.__dirtyElements=false;g.__dirtyUvs=false;g.__dirtyNormals=false;g.__dirtyTangents=false;g.__dirtyColors=false}else if(i instanceof THREE.Line){if(!g.__webGLVertexBuffer){g.__webGLVertexBuffer=b.createBuffer();g.__webGLColorBuffer= -b.createBuffer();h=g.vertices.length;g.__vertexArray=new Float32Array(h*3);g.__colorArray=new Float32Array(h*3);g.__webGLLineCount=h;g.__dirtyVertices=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyColors){h=b.DYNAMIC_DRAW;u=g.vertices;w=g.colors;B=u.length;V=w.length;ea=g.__vertexArray;da=g.__colorArray;ia=g.__dirtyColors;if(g.__dirtyVertices){for(r=0;r0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+ -t.maxPointLights,t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(m,s("fragment",g+r));b.attachShader(m, -s("vertex",t+i));b.linkProgram(m);b.getProgramParameter(m,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(m,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");m.uniforms={};m.attributes={};e.program=m;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in e.uniforms)m.push(h);h=e.program;r=0;for(i=m.length;r=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.vertexAttribPointer(e.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.color)}if(e.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(e.normal,3,b.FLOAT, -false,0,0);b.enableVertexAttribArray(e.normal)}if(e.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.vertexAttribPointer(e.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.tangent)}if(e.uv>=0)if(g.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.vertexAttribPointer(e.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv)}else b.disableVertexAttribArray(e.uv);if(e.uv2>=0)if(g.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.vertexAttribPointer(e.uv2, -2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv2)}else b.disableVertexAttribArray(e.uv2);if(t instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(t instanceof THREE.Line){t=t.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth); -b.drawArrays(t,0,g.__webGLLineCount)}else t instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,g.__webGLParticleCount)};this.render=function(e,i,m,h){var g,t,w,u,r,p,B,V=e.lights,da=e.fog;i.autoUpdateMatrix&&i.updateMatrix();i.matrix.flattenToArray(D);i.projectionMatrix.flattenToArray(M);U.multiply(i.projectionMatrix,i.matrix);k(U);this.initWebGLObjects(e,i);I(m,h!==undefined?h:true);this.autoClear&&this.clear();u=e.__webGLObjects.length;for(h=0;h=0;m--){h=e.__webGLObjects[m].object;i==h&&e.__webGLObjects.splice(m,1)}};this.setDepthTest=function(e){e?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)}; -this.setFaceCulling=function(e,i){if(e){!i||i=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; -THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif", -envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif", -envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif", -map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif", -lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", +THREE.SVGRenderer=function(){function a(ca,d,j){var o,h,f,w;o=0;for(h=ca.lights.length;o0){j.r+=f.color.r*w;j.g+=f.color.g*w;j.b+=f.color.b*w}}else if(f instanceof THREE.PointLight){W.sub(f.position,d.centroidWorld);W.normalize();w=d.normalWorld.dot(W)*f.intensity;if(w>0){j.r+=f.color.r*w;j.g+=f.color.g*w;j.b+=f.color.b*w}}}}function c(ca,d,j,o,h,f){C=g(L++);C.setAttribute("d","M "+ca.positionScreen.x+ +" "+ca.positionScreen.y+" L "+d.positionScreen.x+" "+d.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");if(h instanceof THREE.MeshBasicMaterial)B.__styleString=h.color.__styleString;else if(h instanceof THREE.MeshLambertMaterial)if(S){I.r=b.r;I.g=b.g;I.b=b.b;a(f,o,I);B.r=h.color.r*I.r;B.g=h.color.g*I.g;B.b=h.color.b*I.b;B.updateStyleString()}else B.__styleString=h.color.__styleString;else if(h instanceof THREE.MeshDepthMaterial){J=1-h.__2near/(h.__farPlusNear-o.z*h.__farMinusNear); +B.setRGB(J,J,J)}else h instanceof THREE.MeshNormalMaterial&&B.setRGB(i(o.normalWorld.x),i(o.normalWorld.y),i(o.normalWorld.z));h.wireframe?C.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+h.wireframe_linewidth+"; stroke-opacity: "+h.opacity+"; stroke-linecap: "+h.wireframe_linecap+"; stroke-linejoin: "+h.wireframe_linejoin):C.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+h.opacity);p.appendChild(C)}function e(ca,d,j,o,h,f,w){C=g(L++);C.setAttribute("d", +"M "+ca.positionScreen.x+" "+ca.positionScreen.y+" L "+d.positionScreen.x+" "+d.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+o.positionScreen.x+","+o.positionScreen.y+"z");if(f instanceof THREE.MeshBasicMaterial)B.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshLambertMaterial)if(S){I.r=b.r;I.g=b.g;I.b=b.b;a(w,h,I);B.r=f.color.r*I.r;B.g=f.color.g*I.g;B.b=f.color.b*I.b;B.updateStyleString()}else B.__styleString=f.color.__styleString;else if(f instanceof +THREE.MeshDepthMaterial){J=1-f.__2near/(f.__farPlusNear-h.z*f.__farMinusNear);B.setRGB(J,J,J)}else f instanceof THREE.MeshNormalMaterial&&B.setRGB(i(h.normalWorld.x),i(h.normalWorld.y),i(h.normalWorld.z));f.wireframe?C.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+f.wireframe_linewidth+"; stroke-opacity: "+f.opacity+"; stroke-linecap: "+f.wireframe_linecap+"; stroke-linejoin: "+f.wireframe_linejoin):C.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+ +f.opacity);p.appendChild(C)}function g(ca){if(M[ca]==null){M[ca]=document.createElementNS("http://www.w3.org/2000/svg","path");da==0&&M[ca].setAttribute("shape-rendering","crispEdges");return M[ca]}return M[ca]}function i(ca){return ca<0?Math.min((1+ca)*0.5,0.5):0.5+Math.min(ca*0.5,0.5)}var k=null,q=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,n,y,z,t,x,D,H,G=new THREE.Rectangle,r=new THREE.Rectangle,S=false,B=new THREE.Color(16777215),I=new THREE.Color(16777215), +b=new THREE.Color(0),aa=new THREE.Color(0),P=new THREE.Color(0),J,W=new THREE.Vector3,M=[],R=[],K=[],C,L,ba,N,da=1;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(ca){switch(ca){case "high":da=1;break;case "low":da=0}};this.setSize=function(ca,d){l=ca;n=d;y=l/2;z=n/2;p.setAttribute("viewBox",-y+" "+-z+" "+l+" "+n);p.setAttribute("width",l);p.setAttribute("height",n);G.set(-y,-z,y,z)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])}; +this.render=function(ca,d){var j,o,h,f,w,u,m,v;this.autoClear&&this.clear();k=q.projectScene(ca,d,this.sortElements);N=ba=L=0;if(S=ca.lights.length>0){m=ca.lights;b.setRGB(0,0,0);aa.setRGB(0,0,0);P.setRGB(0,0,0);j=0;for(o=m.length;j0){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLUVBuffer); +b.bufferData(b.ARRAY_BUFFER,Ea,Y)}if(Ca&&ia>0){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,Fa,Y)}if(Ba){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,u.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Aa,Y);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,u.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ta,Y)}}D(objlist,w,h,d,j,o)}f.__dirtyVertices=false;f.__dirtyElements=false;f.__dirtyUvs=false;f.__dirtyNormals=false;f.__dirtyTangents=false;f.__dirtyColors=false}else if(j instanceof +THREE.Line){if(!f.__webGLVertexBuffer){f.__webGLVertexBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer();h=f.vertices.length;f.__vertexArray=new Float32Array(h*3);f.__colorArray=new Float32Array(h*3);f.__webGLLineCount=h;f.__dirtyVertices=true;f.__dirtyColors=true}if(f.__dirtyVertices||f.__dirtyColors){h=b.DYNAMIC_DRAW;m=f.vertices;u=f.colors;O=m.length;Y=u.length;ia=f.__vertexArray;ga=f.__colorArray;U=f.__dirtyColors;if(f.__dirtyVertices){for(v=0;v0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,w.map?"#define USE_MAP":"",w.env_map?"#define USE_ENVMAP":"",w.light_map?"#define USE_LIGHTMAP":"",w.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n"); +b.attachShader(o,S("fragment",f+v));b.attachShader(o,S("vertex",w+j));b.linkProgram(o);b.getProgramParameter(o,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(o,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");o.uniforms={};o.attributes={};d.program=o;o=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in d.uniforms)o.push(h);h=d.program;v=0;for(j=o.length;v=0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.vertexAttribPointer(d.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.color)}if(d.normal>= +0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.normal)}if(d.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.vertexAttribPointer(d.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.tangent)}if(d.uv>=0)if(f.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv)}else b.disableVertexAttribArray(d.uv);if(d.uv2>= +0)if(f.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.vertexAttribPointer(d.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv2)}else b.disableVertexAttribArray(d.uv2);if(w instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.drawElements(b.LINES,f.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,f.__webGLFaceCount,b.UNSIGNED_SHORT, +0)}else if(w instanceof THREE.Line){w=w.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth);b.drawArrays(w,0,f.__webGLLineCount)}else w instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,f.__webGLParticleCount)};this.render=function(d,j,o,h){var f,w,u,m,v,s,O,Y=d.lights,ga=d.fog;j.autoUpdateMatrix&&j.updateMatrix();j.matrix.flattenToArray(L);j.projectionMatrix.flattenToArray(C);K.multiply(j.projectionMatrix,j.matrix);k(K);this.initWebGLObjects(d,j);r(o,h!==undefined?h:true); +this.autoClear&&this.clear();m=d.__webGLObjects.length;for(h=0;h=0;o--){h=d.__webGLObjects[o].object;j==h&&d.__webGLObjects.splice(o,1)}};this.setDepthTest=function(d){d?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setFaceCulling=function(d,j){if(d){!j||j=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(d=="back")b.cullFace(b.BACK);else d=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)> +0}}; +THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif", +envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", +map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif", +lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}", lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"}; diff --git a/build/ThreeDebug.js b/build/ThreeDebug.js index 4d7f1d14..b872e6de 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -1,70 +1,70 @@ // ThreeDebug.js r32 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.autoUpdate=true;this.setHex(a)}; -THREE.Color.prototype={setRGB:function(a,c,d){this.r=a;this.g=c;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,d){var f,j,k,q,o,l;if(d==0)f=j=k=0;else{q=Math.floor(a*6);o=a*6-q;a=d*(1-c);l=d*(1-c*o);c=d*(1-c*(1-o));switch(q){case 1:f=l;j=d;k=a;break;case 2:f=a;j=d;k=c;break;case 3:f=a;j=l;k=d;break;case 4:f=c;j=a;k=d;break;case 5:f=d;j=a;k=l;break;case 6:case 0:f=d;j=c;k=a}}this.r=f;this.g=j;this.b=k;if(this.autoUpdate){this.updateHex();this.updateStyleString()}}, +THREE.Color.prototype={setRGB:function(a,c,e){this.r=a;this.g=c;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,e){var g,i,k,q,p,l;if(e==0)g=i=k=0;else{q=Math.floor(a*6);p=a*6-q;a=e*(1-c);l=e*(1-c*p);c=e*(1-c*(1-p));switch(q){case 1:g=l;i=e;k=a;break;case 2:g=a;i=e;k=c;break;case 3:g=a;i=l;k=e;break;case 4:g=c;i=a;k=e;break;case 5:g=e;i=a;k=l;break;case 6:case 0:g=e;i=c;k=a}}this.r=g;this.g=i;this.b=k;if(this.autoUpdate){this.updateHex();this.updateStyleString()}}, setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGBA();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGBA:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)},toString:function(){return"THREE.Color ( r: "+ this.r+", g: "+this.g+", b: "+this.b+", hex: "+this.hex+" )"}};THREE.Vector2=function(a,c){this.x=a||0;this.y=c||0}; THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.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,c,d){this.x=a||0;this.y=c||0;this.z=d||0}; -THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, -cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,d=this.y,f=this.z;this.x=d*a.z-f*a.y;this.y=f*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/= -a.z;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 c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+d*d+a*a)},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+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)},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,c,e){this.x=a||0;this.y=c||0;this.z=e||0}; +THREE.Vector3.prototype={set:function(a,c,e){this.x=a;this.y=c;this.z=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, +cross:function(a,c){this.x=a.y*c.z-a.z*c.y;this.y=a.z*c.x-a.x*c.z;this.z=a.x*c.y-a.y*c.x;return this},crossSelf:function(a){var c=this.x,e=this.y,g=this.z;this.x=e*a.z-g*a.y;this.y=g*a.x-c*a.z;this.z=c*a.y-e*a.x;return this},multiply:function(a,c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.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},divideSelf:function(a){this.x/=a.x;this.y/=a.y;this.z/= +a.z;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 c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(c*c+e*e+a*a)},distanceToSquared:function(a){var c=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return c*c+e*e+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,c,d,f){this.x=a||0;this.y=c||0;this.z=d||0;this.w=f||1}; -THREE.Vector4.prototype={set:function(a,c,d,f){this.x=a;this.y=c;this.z=d;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c,e,g){this.x=a||0;this.y=c||0;this.z=e||0;this.w=g||1}; +THREE.Vector4.prototype={set:function(a,c,e,g){this.x=a;this.y=c;this.z=e;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,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.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,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.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,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},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,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var c,d,f=a.objects,j=[];a=0;for(c=f.length;a0&&I>0&&R+I<1}var d,f,j,k,q,o,l,m,z,y, -v,x=a.geometry,F=x.vertices,H=[];d=0;for(f=x.faces.length;dl?f:l;j=j>m? -j:m}a()};this.add3Points=function(l,m,z,y,v,x){if(o){o=false;c=lz?l>v?l:v:z>v?z:v;j=m>y?m>x?m:x:y>x?y:x}else{c=lz?l>v?l>f?l:f:v>f?v:f:z>v?z>f?z:f:v>f?v:f;j=m>y?m>x?m>j?m:j:x>j?x:j:y>x?y>j?y:j:x>j?x:j}a()};this.addRectangle=function(l){if(o){o=false;c=l.getLeft();d=l.getTop();f=l.getRight();j=l.getBottom()}else{c=cl.getRight()?f:l.getRight();j=j>l.getBottom()?j:l.getBottom()}a()};this.inflate=function(l){c-=l;d-=l;f+=l;j+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();d=d>l.getTop()?d:l.getTop();f=f=0&&Math.min(j,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){o=true;j=f=d=c=0;a()};this.isEmpty=function(){return o};this.toString= -function(){return"THREE.Rectangle ( left: "+c+", right: "+f+", top: "+d+", bottom: "+j+", width: "+k+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; -THREE.Matrix4=function(a,c,d,f,j,k,q,o,l,m,z,y,v,x,F,H){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=f||0;this.n21=j||0;this.n22=k||1;this.n23=q||0;this.n24=o||0;this.n31=l||0;this.n32=m||0;this.n33=z||1;this.n34=y||0;this.n41=v||0;this.n42=x||0;this.n43=F||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={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;return this},set:function(a,c,d,f,j,k,q,o,l,m,z,y,v,x,F,H){this.n11=a;this.n12=c;this.n13=d;this.n14=f;this.n21=j;this.n22=k;this.n23=q;this.n24=o;this.n31=l;this.n32=m;this.n33=z;this.n34=y;this.n41=v;this.n42=x;this.n43=F;this.n44=H;return this},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;return this},lookAt:function(a,c,d){var f=THREE.Matrix4.__tmpVec1,j=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,c).normalize();f.cross(d,k).normalize();j.cross(k,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=j.x;this.n22=j.y;this.n23=j.z;this.n24=-j.dot(a); -this.n31=k.x;this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,f=a.z,j=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*j;a.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*j;a.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*j;return a},multiplyVector4:function(a){var c=a.x,d=a.y,f=a.z,j=a.w;a.x=this.n11*c+this.n12*d+this.n13*f+this.n14*j;a.y=this.n21*c+this.n22*d+this.n23* -f+this.n24*j;a.z=this.n31*c+this.n32*d+this.n33*f+this.n34*j;a.w=this.n41*c+this.n42*d+this.n43*f+this.n44*j;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,f=a.n12,j=a.n13,k=a.n14,q=a.n21,o=a.n22,l=a.n23,m=a.n24,z=a.n31, -y=a.n32,v=a.n33,x=a.n34,F=a.n41,H=a.n42,I=a.n43,s=a.n44,O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43,aa=c.n44;this.n11=d*O+f*$+j*G+k*K;this.n12=d*C+f*Q+j*U+k*ca;this.n13=d*b+f*J+j*M+k*N;this.n14=d*R+f*X+j*D+k*aa;this.n21=q*O+o*$+l*G+m*K;this.n22=q*C+o*Q+l*U+m*ca;this.n23=q*b+o*J+l*M+m*N;this.n24=q*R+o*X+l*D+m*aa;this.n31=z*O+y*$+v*G+x*K;this.n32=z*C+y*Q+v*U+x*ca;this.n33=z*b+y*J+v*M+x*N;this.n34=z*R+y*X+v*D+x*aa;this.n41= -F*O+H*$+I*G+s*K;this.n42=F*C+H*Q+I*U+s*ca;this.n43=F*b+H*J+I*M+s*N;this.n44=F*R+H*X+I*D+s*aa;return this},multiplyToArray:function(a,c,d){var f=a.n11,j=a.n12,k=a.n13,q=a.n14,o=a.n21,l=a.n22,m=a.n23,z=a.n24,y=a.n31,v=a.n32,x=a.n33,F=a.n34,H=a.n41,I=a.n42,s=a.n43;a=a.n44;var O=c.n11,C=c.n12,b=c.n13,R=c.n14,$=c.n21,Q=c.n22,J=c.n23,X=c.n24,G=c.n31,U=c.n32,M=c.n33,D=c.n34,K=c.n41,ca=c.n42,N=c.n43;c=c.n44;this.n11=f*O+j*$+k*G+q*K;this.n12=f*C+j*Q+k*U+q*ca;this.n13=f*b+j*J+k*M+q*N;this.n14=f*R+j*X+k*D+q* -c;this.n21=o*O+l*$+m*G+z*K;this.n22=o*C+l*Q+m*U+z*ca;this.n23=o*b+l*J+m*M+z*N;this.n24=o*R+l*X+m*D+z*c;this.n31=y*O+v*$+x*G+F*K;this.n32=y*C+v*Q+x*U+F*ca;this.n33=y*b+v*J+x*M+F*N;this.n34=y*R+v*X+x*D+F*c;this.n41=H*O+I*$+s*G+a*K;this.n42=H*C+I*Q+s*U+a*ca;this.n43=H*b+I*J+s*M+a*N;this.n44=H*R+I*X+s*D+a*c;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24; -d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,f=this.n13,j=this.n14,k=this.n21,q=this.n22,o=this.n23,l=this.n24,m=this.n31,z=this.n32,y=this.n33,v=this.n34,x=this.n41,F=this.n42,H=this.n43,I=this.n44,s=a.n11,O=a.n21,C=a.n31,b=a.n41,R=a.n12,$=a.n22,Q=a.n32,J=a.n42,X=a.n13,G=a.n23,U=a.n33,M=a.n43,D=a.n14,K=a.n24,ca=a.n34;a=a.n44;this.n11=c*s+d*O+f*C+j*b;this.n12=c*R+d*$+f*Q+j*J;this.n13=c*X+d*G+f*U+j*M;this.n14=c*D+d*K+f*ca+j*a;this.n21=k*s+q*O+o*C+l* -b;this.n22=k*R+q*$+o*Q+l*J;this.n23=k*X+q*G+o*U+l*M;this.n24=k*D+q*K+o*ca+l*a;this.n31=m*s+z*O+y*C+v*b;this.n32=m*R+z*$+y*Q+v*J;this.n33=m*X+z*G+y*U+v*M;this.n34=m*D+z*K+y*ca+v*a;this.n41=x*s+F*O+H*C+I*b;this.n42=x*R+F*$+H*Q+I*J;this.n43=x*X+F*G+H*U+I*M;this.n44=x*D+F*K+H*ca+I*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*= -a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,f=this.n14,j=this.n21,k=this.n22,q=this.n23,o=this.n24,l=this.n31,m=this.n32,z=this.n33,y=this.n34,v=this.n41,x=this.n42,F=this.n43,H=this.n44;return f*q*m*v-d*o*m*v-f*k*z*v+c*o*z*v+d*k*y*v-c*q*y*v-f*q*l*x+d*o*l*x+f*j*z*x-a*o*z*x-d*j*y*x+a*q*y*x+f*k*l*F-c*o*l*F-f*j*m*F+a*o*m*F+c*j*y*F-a*k*y*F-d*k*l*H+c*q*l*H+d*j*m*H-a*q*m*H-c*j*z*H+a*k*z*H},transpose:function(){function a(c,d,f){var j=c[d];c[d]=c[f];c[f]=j}a(this,"n21","n12"); -a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12; -a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d, -0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),f=Math.sin(c),j=1-d,k=a.x,q=a.y, -o=a.z,l=j*k,m=j*q;this.set(l*k+d,l*q-f*o,l*o+f*q,0,l*q+f*o,m*q+d,m*o-f*k,0,l*o-f*q,m*o+f*k,j*o*o+d,0,0,0,0,1);return this},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,c,d){var f=new THREE.Matrix4;f.setTranslation(a,c,d);return f}; -THREE.Matrix4.scaleMatrix=function(a,c,d){var f=new THREE.Matrix4;f.setScale(a,c,d);return f};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d}; -THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,f=a.n13,j=a.n14,k=a.n21,q=a.n22,o=a.n23,l=a.n24,m=a.n31,z=a.n32,y=a.n33,v=a.n34,x=a.n41,F=a.n42,H=a.n43,I=a.n44,s=new THREE.Matrix4;s.n11=o*v*F-l*y*F+l*z*H-q*v*H-o*z*I+q*y*I;s.n12=j*y*F-f*v*F-j*z*H+d*v*H+f*z*I-d*y*I;s.n13=f*l*F-j*o*F+j*q*H-d*l*H-f*q*I+d*o*I;s.n14=j*o*z-f*l*z-j*q*y+d*l*y+f*q*v-d*o*v;s.n21=l*y*x-o*v*x-l*m*H+k*v*H+o*m*I-k*y*I;s.n22=f*v*x-j*y*x+j*m*H-c*v*H-f*m*I+c*y*I;s.n23=j*o*x-f*l*x-j*k*H+c*l*H+f*k*I-c*o*I;s.n24=f*l*m-j*o*m+ -j*k*y-c*l*y-f*k*v+c*o*v;s.n31=q*v*x-l*z*x+l*m*F-k*v*F-q*m*I+k*z*I;s.n32=j*z*x-d*v*x-j*m*F+c*v*F+d*m*I-c*z*I;s.n33=f*l*x-j*q*x+j*k*F-c*l*F-d*k*I+c*q*I;s.n34=j*q*m-d*l*m-j*k*z+c*l*z+d*k*v-c*q*v;s.n41=o*z*x-q*y*x-o*m*F+k*y*F+q*m*H-k*z*H;s.n42=d*y*x-f*z*x+f*m*F-c*y*F-d*m*H+c*z*H;s.n43=f*q*x-d*o*x-f*k*F+c*o*F+d*k*H-c*q*H;s.n44=d*o*m-f*q*m+f*k*z-c*o*z-d*k*y+c*q*y;s.multiplyScalar(1/a.determinant());return s}; -THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,f=a.n33*a.n22-a.n32*a.n23,j=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,q=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,z=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*f+a.n21*q+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*f;d[1]=a*j;d[2]=a*k;d[3]=a*q;d[4]=a*o;d[5]=a*l;d[6]=a*m;d[7]=a*z;d[8]=a*y;return c}; -THREE.Matrix4.makeFrustum=function(a,c,d,f,j,k){var q,o,l;q=new THREE.Matrix4;o=2*j/(c-a);l=2*j/(f-d);a=(c+a)/(c-a);d=(f+d)/(f-d);f=-(k+j)/(k-j);j=-2*k*j/(k-j);q.n11=o;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=d;q.n24=0;q.n31=0;q.n32=0;q.n33=f;q.n34=j;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,d,f){var j;a=d*Math.tan(a*Math.PI/360);j=-a;return THREE.Matrix4.makeFrustum(j*c,a*c,j,a,d,f)}; -THREE.Matrix4.makeOrtho=function(a,c,d,f,j,k){var q,o,l,m;q=new THREE.Matrix4;o=c-a;l=d-f;m=k-j;a=(c+a)/o;d=(d+f)/l;j=(k+j)/m;q.n11=2/o;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-d;q.n31=0;q.n32=0;q.n33=-2/m;q.n34=-j;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; +THREE.Ray.prototype={intersectScene:function(a){var c,e,g=a.objects,i=[];a=0;for(c=g.length;a0&&G>0&&b+G<1}var e,g,i,k,q,p,l,m,z,A, +t,y=a.geometry,D=y.vertices,H=[];e=0;for(g=y.faces.length;el?g:l;i=i>m? +i:m}a()};this.add3Points=function(l,m,z,A,t,y){if(p){p=false;c=lz?l>t?l:t:z>t?z:t;i=m>A?m>y?m:y:A>y?A:y}else{c=lz?l>t?l>g?l:g:t>g?t:g:z>t?z>g?z:g:t>g?t:g;i=m>A?m>y?m>i?m:i:y>i?y:i:A>y?A>i?A:i:y>i?y:i}a()};this.addRectangle=function(l){if(p){p=false;c=l.getLeft();e=l.getTop();g=l.getRight();i=l.getBottom()}else{c=cl.getRight()?g:l.getRight();i=i>l.getBottom()?i:l.getBottom()}a()};this.inflate=function(l){c-=l;e-=l;g+=l;i+=l;a()};this.minSelf=function(l){c=c>l.getLeft()?c:l.getLeft();e=e>l.getTop()?e:l.getTop();g=g=0&&Math.min(i,l.getBottom())-Math.max(e,l.getTop())>=0};this.empty=function(){p=true;i=g=e=c=0;a()};this.isEmpty=function(){return p};this.toString= +function(){return"THREE.Rectangle ( left: "+c+", right: "+g+", top: "+e+", bottom: "+i+", width: "+k+", height: "+q+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; +THREE.Matrix4=function(a,c,e,g,i,k,q,p,l,m,z,A,t,y,D,H){this.n11=a||1;this.n12=c||0;this.n13=e||0;this.n14=g||0;this.n21=i||0;this.n22=k||1;this.n23=q||0;this.n24=p||0;this.n31=l||0;this.n32=m||0;this.n33=z||1;this.n34=A||0;this.n41=t||0;this.n42=y||0;this.n43=D||0;this.n44=H||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={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;return this},set:function(a,c,e,g,i,k,q,p,l,m,z,A,t,y,D,H){this.n11=a;this.n12=c;this.n13=e;this.n14=g;this.n21=i;this.n22=k;this.n23=q;this.n24=p;this.n31=l;this.n32=m;this.n33=z;this.n34=A;this.n41=t;this.n42=y;this.n43=D;this.n44=H;return this},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;return this},lookAt:function(a,c,e){var g=THREE.Matrix4.__tmpVec1,i=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,c).normalize();g.cross(e,k).normalize();i.cross(k,g).normalize();this.n11=g.x;this.n12=g.y;this.n13=g.z;this.n14=-g.dot(a);this.n21=i.x;this.n22=i.y;this.n23=i.z;this.n24=-i.dot(a); +this.n31=k.x;this.n32=k.y;this.n33=k.z;this.n34=-k.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,e=a.y,g=a.z,i=1/(this.n41*c+this.n42*e+this.n43*g+this.n44);a.x=(this.n11*c+this.n12*e+this.n13*g+this.n14)*i;a.y=(this.n21*c+this.n22*e+this.n23*g+this.n24)*i;a.z=(this.n31*c+this.n32*e+this.n33*g+this.n34)*i;return a},multiplyVector4:function(a){var c=a.x,e=a.y,g=a.z,i=a.w;a.x=this.n11*c+this.n12*e+this.n13*g+this.n14*i;a.y=this.n21*c+this.n22*e+this.n23* +g+this.n24*i;a.z=this.n31*c+this.n32*e+this.n33*g+this.n34*i;a.w=this.n41*c+this.n42*e+this.n43*g+this.n44*i;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var e=a.n11,g=a.n12,i=a.n13,k=a.n14,q=a.n21,p=a.n22,l=a.n23,m=a.n24,z=a.n31, +A=a.n32,t=a.n33,y=a.n34,D=a.n41,H=a.n42,G=a.n43,r=a.n44,S=c.n11,B=c.n12,I=c.n13,b=c.n14,aa=c.n21,P=c.n22,J=c.n23,W=c.n24,M=c.n31,R=c.n32,K=c.n33,C=c.n34,L=c.n41,ba=c.n42,N=c.n43,da=c.n44;this.n11=e*S+g*aa+i*M+k*L;this.n12=e*B+g*P+i*R+k*ba;this.n13=e*I+g*J+i*K+k*N;this.n14=e*b+g*W+i*C+k*da;this.n21=q*S+p*aa+l*M+m*L;this.n22=q*B+p*P+l*R+m*ba;this.n23=q*I+p*J+l*K+m*N;this.n24=q*b+p*W+l*C+m*da;this.n31=z*S+A*aa+t*M+y*L;this.n32=z*B+A*P+t*R+y*ba;this.n33=z*I+A*J+t*K+y*N;this.n34=z*b+A*W+t*C+y*da;this.n41= +D*S+H*aa+G*M+r*L;this.n42=D*B+H*P+G*R+r*ba;this.n43=D*I+H*J+G*K+r*N;this.n44=D*b+H*W+G*C+r*da;return this},multiplyToArray:function(a,c,e){var g=a.n11,i=a.n12,k=a.n13,q=a.n14,p=a.n21,l=a.n22,m=a.n23,z=a.n24,A=a.n31,t=a.n32,y=a.n33,D=a.n34,H=a.n41,G=a.n42,r=a.n43;a=a.n44;var S=c.n11,B=c.n12,I=c.n13,b=c.n14,aa=c.n21,P=c.n22,J=c.n23,W=c.n24,M=c.n31,R=c.n32,K=c.n33,C=c.n34,L=c.n41,ba=c.n42,N=c.n43;c=c.n44;this.n11=g*S+i*aa+k*M+q*L;this.n12=g*B+i*P+k*R+q*ba;this.n13=g*I+i*J+k*K+q*N;this.n14=g*b+i*W+k* +C+q*c;this.n21=p*S+l*aa+m*M+z*L;this.n22=p*B+l*P+m*R+z*ba;this.n23=p*I+l*J+m*K+z*N;this.n24=p*b+l*W+m*C+z*c;this.n31=A*S+t*aa+y*M+D*L;this.n32=A*B+t*P+y*R+D*ba;this.n33=A*I+t*J+y*K+D*N;this.n34=A*b+t*W+y*C+D*c;this.n41=H*S+G*aa+r*M+a*L;this.n42=H*B+G*P+r*R+a*ba;this.n43=H*I+G*J+r*K+a*N;this.n44=H*b+G*W+r*C+a*c;e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]= +this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(a){var c=this.n11,e=this.n12,g=this.n13,i=this.n14,k=this.n21,q=this.n22,p=this.n23,l=this.n24,m=this.n31,z=this.n32,A=this.n33,t=this.n34,y=this.n41,D=this.n42,H=this.n43,G=this.n44,r=a.n11,S=a.n21,B=a.n31,I=a.n41,b=a.n12,aa=a.n22,P=a.n32,J=a.n42,W=a.n13,M=a.n23,R=a.n33,K=a.n43,C=a.n14,L=a.n24,ba=a.n34;a=a.n44;this.n11=c*r+e*S+g*B+i*I;this.n12=c*b+e*aa+g*P+i*J;this.n13=c*W+e*M+g*R+i*K;this.n14=c*C+e*L+g*ba+i*a;this.n21=k*r+ +q*S+p*B+l*I;this.n22=k*b+q*aa+p*P+l*J;this.n23=k*W+q*M+p*R+l*K;this.n24=k*C+q*L+p*ba+l*a;this.n31=m*r+z*S+A*B+t*I;this.n32=m*b+z*aa+A*P+t*J;this.n33=m*W+z*M+A*R+t*K;this.n34=m*C+z*L+A*ba+t*a;this.n41=y*r+D*S+H*B+G*I;this.n42=y*b+D*aa+H*P+G*J;this.n43=y*W+D*M+H*R+G*K;this.n44=y*C+D*L+H*ba+G*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a; +this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,e=this.n13,g=this.n14,i=this.n21,k=this.n22,q=this.n23,p=this.n24,l=this.n31,m=this.n32,z=this.n33,A=this.n34,t=this.n41,y=this.n42,D=this.n43,H=this.n44;return g*q*m*t-e*p*m*t-g*k*z*t+c*p*z*t+e*k*A*t-c*q*A*t-g*q*l*y+e*p*l*y+g*i*z*y-a*p*z*y-e*i*A*y+a*q*A*y+g*k*l*D-c*p*l*D-g*i*m*D+a*p*m*D+c*i*A*D-a*k*A*D-e*k*l*H+c*q*l*H+e*i*m*H-a*q*m*H-c*i*z*H+a*k*z*H},transpose:function(){function a(c,e,g){var i=c[e];c[e]=c[g];c[g]= +i}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(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31; +a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,e){this.set(1, +0,0,a,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(a,c,e){this.set(a,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var e=Math.cos(c),g=Math.sin(c), +i=1-e,k=a.x,q=a.y,p=a.z,l=i*k,m=i*q;this.set(l*k+e,l*q-g*p,l*p+g*q,0,l*q+g*p,m*q+e,m*p-g*k,0,l*p-g*q,m*p+g*k,i*p*p+e,0,0,0,0,1);return this},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,c,e){var g=new THREE.Matrix4;g.setTranslation(a,c,e);return g}; +THREE.Matrix4.scaleMatrix=function(a,c,e){var g=new THREE.Matrix4;g.setScale(a,c,e);return g};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var e=new THREE.Matrix4;e.setRotAxis(a,c);return e}; +THREE.Matrix4.makeInvert=function(a){var c=a.n11,e=a.n12,g=a.n13,i=a.n14,k=a.n21,q=a.n22,p=a.n23,l=a.n24,m=a.n31,z=a.n32,A=a.n33,t=a.n34,y=a.n41,D=a.n42,H=a.n43,G=a.n44,r=new THREE.Matrix4;r.n11=p*t*D-l*A*D+l*z*H-q*t*H-p*z*G+q*A*G;r.n12=i*A*D-g*t*D-i*z*H+e*t*H+g*z*G-e*A*G;r.n13=g*l*D-i*p*D+i*q*H-e*l*H-g*q*G+e*p*G;r.n14=i*p*z-g*l*z-i*q*A+e*l*A+g*q*t-e*p*t;r.n21=l*A*y-p*t*y-l*m*H+k*t*H+p*m*G-k*A*G;r.n22=g*t*y-i*A*y+i*m*H-c*t*H-g*m*G+c*A*G;r.n23=i*p*y-g*l*y-i*k*H+c*l*H+g*k*G-c*p*G;r.n24=g*l*m-i*p*m+ +i*k*A-c*l*A-g*k*t+c*p*t;r.n31=q*t*y-l*z*y+l*m*D-k*t*D-q*m*G+k*z*G;r.n32=i*z*y-e*t*y-i*m*D+c*t*D+e*m*G-c*z*G;r.n33=g*l*y-i*q*y+i*k*D-c*l*D-e*k*G+c*q*G;r.n34=i*q*m-e*l*m-i*k*z+c*l*z+e*k*t-c*q*t;r.n41=p*z*y-q*A*y-p*m*D+k*A*D+q*m*H-k*z*H;r.n42=e*A*y-g*z*y+g*m*D-c*A*D-e*m*H+c*z*H;r.n43=g*q*y-e*p*y-g*k*D+c*p*D+e*k*H-c*q*H;r.n44=e*p*m-g*q*m+g*k*z-c*p*z-e*k*A+c*q*A;r.multiplyScalar(1/a.determinant());return r}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,e=c.m,g=a.n33*a.n22-a.n32*a.n23,i=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,q=-a.n33*a.n12+a.n32*a.n13,p=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,z=-a.n23*a.n11+a.n21*a.n13,A=a.n22*a.n11-a.n21*a.n12;a=a.n11*g+a.n21*q+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;e[0]=a*g;e[1]=a*i;e[2]=a*k;e[3]=a*q;e[4]=a*p;e[5]=a*l;e[6]=a*m;e[7]=a*z;e[8]=a*A;return c}; +THREE.Matrix4.makeFrustum=function(a,c,e,g,i,k){var q,p,l;q=new THREE.Matrix4;p=2*i/(c-a);l=2*i/(g-e);a=(c+a)/(c-a);e=(g+e)/(g-e);g=-(k+i)/(k-i);i=-2*k*i/(k-i);q.n11=p;q.n12=0;q.n13=a;q.n14=0;q.n21=0;q.n22=l;q.n23=e;q.n24=0;q.n31=0;q.n32=0;q.n33=g;q.n34=i;q.n41=0;q.n42=0;q.n43=-1;q.n44=0;return q};THREE.Matrix4.makePerspective=function(a,c,e,g){var i;a=e*Math.tan(a*Math.PI/360);i=-a;return THREE.Matrix4.makeFrustum(i*c,a*c,i,a,e,g)}; +THREE.Matrix4.makeOrtho=function(a,c,e,g,i,k){var q,p,l,m;q=new THREE.Matrix4;p=c-a;l=e-g;m=k-i;a=(c+a)/p;e=(e+g)/l;i=(k+i)/m;q.n11=2/p;q.n12=0;q.n13=0;q.n14=-a;q.n21=0;q.n22=2/l;q.n23=0;q.n24=-e;q.n31=0;q.n32=0;q.n33=-2/m;q.n34=-i;q.n41=0;q.n42=0;q.n43=0;q.n44=1;return q};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; -THREE.Face3=function(a,c,d,f,j){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=j instanceof Array?j:[j]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; -THREE.Face4=function(a,c,d,f,j,k){this.a=a;this.b=c;this.c=d;this.d=f;this.centroid=new THREE.Vector3;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.materials=k instanceof Array?k:[k]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; -THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a0){this.boundingBox={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 c=1,d=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z -this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c65535){m[o].counter+=1;l=m[o].hash+"_"+m[o].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(f);this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+ -this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,c,d,f){this.fov=a;this.aspect=c;this.near=d;this.far=f;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; -this.translateZ=function(j){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(j);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()}; +THREE.Face3=function(a,c,e,g,i){this.a=a;this.b=c;this.c=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=i instanceof Array?i:[i]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; +THREE.Face4=function(a,c,e,g,i,k){this.a=a;this.b=c;this.c=e;this.d=g;this.centroid=new THREE.Vector3;this.normal=i instanceof THREE.Vector3?i:new THREE.Vector3;this.vertexNormals=i instanceof Array?i:[];this.materials=k instanceof Array?k:[k]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,c){this.u=a||0;this.v=c||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.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; +THREE.Geometry.prototype={computeCentroids:function(){var a,c,e;a=0;for(c=this.faces.length;a0){this.boundingBox={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 c=1,e=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z +this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,e=this.vertices.length;c65535){m[p].counter+=1;l=m[p].hash+"_"+m[p].counter;if(this.geometryChunks[l]==undefined)this.geometryChunks[l]={faces:[],materials:q,vertices:0}}this.geometryChunks[l].faces.push(g);this.geometryChunks[l].vertices+=k}},toString:function(){return"THREE.Geometry ( vertices: "+ +this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0; +THREE.Camera=function(a,c,e,g){this.fov=a;this.aspect=c;this.near=e;this.far=g;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(i);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; +this.translateZ=function(i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(i);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()}; THREE.Camera.prototype={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,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light; THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.tmpMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true;this.children=[]}; -THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,c=this.rotation,d=this.scale,f=this.matrix,j=this.rotationMatrix,k=this.tmpMatrix;f.setTranslation(a.x,a.y,a.z);j.setRotX(c.x);c.y!=0&&j.multiplySelf(k.setRotY(c.y));c.z!=0&&j.multiplySelf(k.setRotZ(c.z));f.multiplySelf(j);if(d.x!=0||d.y!=0||d.z!=0)f.multiplySelf(k.setScale(d.x, -d.y,d.z))}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem; -THREE.Line=function(a,c,d){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=d!=undefined?d:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()}; +THREE.Object3D.prototype={addChild:function(a){this.children.indexOf(a)===-1&&this.children.push(a)},removeChild:function(a){a=this.children.indexOf(a);a!==-1&&this.children.splice(a,1)},updateMatrix:function(){var a=this.position,c=this.rotation,e=this.scale,g=this.matrix,i=this.rotationMatrix,k=this.tmpMatrix;g.setTranslation(a.x,a.y,a.z);i.setRotX(c.x);c.y!=0&&i.multiplySelf(k.setRotY(c.y));c.z!=0&&i.multiplySelf(k.setRotZ(c.z));g.multiplySelf(i);if(e.x!=0||e.y!=0||e.z!=0)g.multiplySelf(k.setScale(e.x, +e.y,e.z))}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.materials=a instanceof Array?a:[a];this.autoUpdateMatrix=false};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;THREE.ParticleSystem=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.sortParticles=false};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem; +THREE.Line=function(a,c,e){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.type=e!=undefined?e:THREE.LineStrip};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;THREE.Mesh=function(a,c){THREE.Object3D.call(this);this.geometry=a;this.materials=c instanceof Array?c:[c];this.overdraw=this.doubleSided=this.flipSided=false;this.geometry.boundingSphere||this.geometry.computeBoundingSphere()}; THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3; THREE.LineBasicMaterial=function(a){this.id=THREE.LineBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.linewidth=1;this.linejoin=this.linecap="round";this.vertex_colors=false;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;if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.linewidth!==undefined)this.linewidth= a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}}; @@ -96,121 +96,121 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM THREE.ParticleBasicMaterial=function(a){this.id=THREE.ParticleBasicMaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depth_test=true;this.offset=new THREE.Vector2;this.vertex_colors=false;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending; if(a.depth_test!==undefined)this.depth_test=a.depth_test;if(a.vertex_colors!==undefined)this.vertex_colors=a.vertex_colors}};THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (
id: "+this.id+"
color: "+this.color+"
opacity: "+this.opacity+"
map: "+this.map+"
size: "+this.size+"
blending: "+this.blending+"
depth_test: "+this.depth_test+"
vertex_colors: "+this.vertex_colors+"
)"}};THREE.ParticleBasicMaterialCounter={value:0}; THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(16777215);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}};THREE.ParticleCircleMaterial.prototype={toString:function(){return"THREE.ParticleCircleMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}}; -THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,d,f,j,k){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=d!==undefined?d:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=j!==undefined?j:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter}; +THREE.ParticleDOMMaterial=function(a){this.domElement=a};THREE.ParticleDOMMaterial.prototype={toString:function(){return"THREE.ParticleDOMMaterial ( domElement: "+this.domElement+" )"}};THREE.Texture=function(a,c,e,g,i,k){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=g!==undefined?g:THREE.ClampToEdgeWrapping;this.mag_filter=i!==undefined?i:THREE.LinearFilter;this.min_filter=k!==undefined?k:THREE.LinearMipMapLinearFilter}; THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrap_s,this.wrap_t,this.mag_filter,this.min_filter)},toString:function(){return"THREE.Texture (
image: "+this.image+"
wrap_s: "+this.wrap_s+"
wrap_t: "+this.wrap_t+"
mag_filter: "+this.mag_filter+"
min_filter: "+this.min_filter+"
)"}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2; THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20; -THREE.RenderTarget=function(a,c,d){this.width=a;this.height=c;d=d||{};this.wrap_s=d.wrap_s!==undefined?d.wrap_s:THREE.ClampToEdgeWrapping;this.wrap_t=d.wrap_t!==undefined?d.wrap_t:THREE.ClampToEdgeWrapping;this.mag_filter=d.mag_filter!==undefined?d.mag_filter:THREE.LinearFilter;this.min_filter=d.min_filter!==undefined?d.min_filter:THREE.LinearMipMapLinearFilter;this.format=d.format!==undefined?d.format:THREE.RGBFormat;this.type=d.type!==undefined?d.type:THREE.UnsignedByteType}; -var Uniforms={clone:function(a){var c,d,f,j={};for(c in a){j[c]={};for(d in a[c]){f=a[c][d];j[c][d]=f instanceof THREE.Color||f instanceof THREE.Vector3||f instanceof THREE.Texture?f.clone():f}}return j},merge:function(a){var c,d,f,j={};for(c=0;c=0&&M>=0&&D>=0&&K>=0)return true;else if(U<0&&M<0||D<0&&K<0)return false;else{if(U<0)X=Math.max(X,U/(U-M));else if(M<0)G=Math.min(G,U/(U-M));if(D<0)X=Math.max(X,D/(D-K));else if(K<0)G=Math.min(G,D/(D-K));if(GU&&N.z0&&I.z<1){v=F[x]=F[x]||new THREE.RenderableParticle;v.x=I.x/I.w;v.y=I.y/I.w;v.z=I.z;v.rotation=i.rotation.z;v.scale.x=i.scale.x*Math.abs(v.x-(I.x+J.projectionMatrix.n11)/ -(I.w+J.projectionMatrix.n14));v.scale.y=i.scale.y*Math.abs(v.y-(I.y+J.projectionMatrix.n22)/(I.w+J.projectionMatrix.n24));v.materials=i.materials;G.push(v);x++}}}}X&&G.sort(a);return G};this.unprojectVector=function(Q,J){var X=THREE.Matrix4.makeInvert(J.matrix);X.multiplySelf(THREE.Matrix4.makeInvert(J.projectionMatrix));X.multiplyVector3(Q);return Q}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,f,j,k;this.domElement=document.createElement("div");this.setSize=function(q,o){d=q;f=o;j=d/2;k=f/2};this.render=function(q,o){var l,m,z,y,v,x,F,H;a=c.projectScene(q,o);l=0;for(m=a.length;l0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}else if(ha instanceof THREE.PointLight){S.sub(ha.position,Z);S.normalize();ha=T.dot(S)* -xa;if(ha>0){E.r+=ra.r*ha;E.g+=ra.g*ha;E.b+=ra.b*ha}}}}function la(A,Z,T){if(T.opacity!=0){a(T.opacity);c(T.blending);var E,L,ha,ra,xa,za;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){ra=T.map.image;xa=ra.width>>1;za=ra.height>>1;L=Z.scale.x*o;ha=Z.scale.y*l;T=L*xa;E=ha*za;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(!w.instersects(r))return;m.save();m.translate(A.x,A.y);m.rotate(-Z.rotation);m.scale(L,-ha);m.translate(-xa,-za);m.drawImage(ra,0,0);m.restore()}m.beginPath();m.moveTo(A.x- -10,A.y);m.lineTo(A.x+10,A.y);m.moveTo(A.x,A.y-10);m.lineTo(A.x,A.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(T instanceof THREE.ParticleCircleMaterial){if(p){B.r=V.r+da.r+ea.r;B.g=V.g+da.g+ea.g;B.b=V.b+da.b+ea.b;G.r=T.color.r*B.r;G.g=T.color.g*B.g;G.b=T.color.b*B.b;G.updateStyleString()}else G.__styleString=T.color.__styleString;T=Z.scale.x*o;E=Z.scale.y*l;r.set(A.x-T,A.y-E,A.x+T,A.y+E);if(w.instersects(r)){L=G.__styleString;if(H!=L)m.fillStyle=H=L;m.save();m.translate(A.x, -A.y);m.rotate(-Z.rotation);m.scale(T,E);m.beginPath();m.arc(0,0,1,0,ia,true);m.closePath();m.fill();m.restore()}}}}function na(A,Z,T,E){if(E.opacity!=0){a(E.opacity);c(E.blending);m.beginPath();m.moveTo(A.positionScreen.x,A.positionScreen.y);m.lineTo(Z.positionScreen.x,Z.positionScreen.y);m.closePath();if(E instanceof THREE.LineBasicMaterial){G.__styleString=E.color.__styleString;A=E.linewidth;if(I!=A)m.lineWidth=I=A;A=G.__styleString;if(F!=A)m.strokeStyle=F=A;m.stroke();r.inflate(E.linewidth*2)}}} -function Ja(A,Z,T,E,L,ha){if(L.opacity!=0){a(L.opacity);c(L.blending);b=A.positionScreen.x;R=A.positionScreen.y;$=Z.positionScreen.x;Q=Z.positionScreen.y;J=T.positionScreen.x;X=T.positionScreen.y;m.beginPath();m.moveTo(b,R);m.lineTo($,Q);m.lineTo(J,X);m.lineTo(b,R);m.closePath();if(L instanceof THREE.MeshBasicMaterial)if(L.map)L.map.image.loaded&&L.map.mapping instanceof THREE.UVMapping&&ga(b,R,$,Q,J,X,L.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(L.env_map){if(L.env_map.image.loaded)if(L.env_map.mapping instanceof -THREE.SphericalReflectionMapping){A=ba.matrix;S.copy(E.vertexNormalsWorld[0]);e=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;i=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[1]);n=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;h=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;S.copy(E.vertexNormalsWorld[2]);g=(S.x*A.n11+S.y*A.n12+S.z*A.n13)*0.5+0.5;t=-(S.x*A.n21+S.y*A.n22+S.z*A.n23)*0.5+0.5;ga(b,R,$,Q,J,X,L.env_map.image,e,i,n,h,g,t)}}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth): -va(L.color.__styleString);else if(L instanceof THREE.MeshLambertMaterial){if(L.map&&!L.wireframe){L.map.mapping instanceof THREE.UVMapping&&ga(b,R,$,Q,J,X,L.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);c(THREE.SubtractiveBlending)}if(p)if(!L.wireframe&&L.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){U.r=M.r=D.r=V.r;U.g=M.g=D.g=V.g;U.b=M.b=D.b=V.b;qa(ha,E.v1.positionWorld,E.vertexNormalsWorld[0],U);qa(ha,E.v2.positionWorld,E.vertexNormalsWorld[1],M); -qa(ha,E.v3.positionWorld,E.vertexNormalsWorld[2],D);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,0,1,0,0,1)}else{B.r=V.r;B.g=V.g;B.b=V.b;qa(ha,E.centroidWorld,E.normalWorld,B);G.r=L.color.r*B.r;G.g=L.color.g*B.g;G.b=L.color.b*B.b;G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}else L.wireframe?Da(L.color.__styleString,L.wireframe_linewidth):va(L.color.__styleString)}else if(L instanceof THREE.MeshDepthMaterial){ca= -ba.near;N=ba.far;U.r=U.g=U.b=1-Aa(A.positionScreen.z,ca,N);M.r=M.g=M.b=1-Aa(Z.positionScreen.z,ca,N);D.r=D.g=D.b=1-Aa(T.positionScreen.z,ca,N);K.r=(M.r+D.r)*0.5;K.g=(M.g+D.g)*0.5;K.b=(M.b+D.b)*0.5;aa=ma(U,M,D,K);ga(b,R,$,Q,J,X,aa,0,0,1,0,0,1)}else if(L instanceof THREE.MeshNormalMaterial){G.r=ta(E.normalWorld.x);G.g=ta(E.normalWorld.y);G.b=ta(E.normalWorld.z);G.updateStyleString();L.wireframe?Da(G.__styleString,L.wireframe_linewidth):va(G.__styleString)}}}function Da(A,Z){if(F!=A)m.strokeStyle=F= -A;if(I!=Z)m.lineWidth=I=Z;m.stroke();r.inflate(Z*2)}function va(A){if(H!=A)m.fillStyle=H=A;m.fill()}function ga(A,Z,T,E,L,ha,ra,xa,za,Ga,Ba,Ha,Oa){var Ea,Ia;Ea=ra.width-1;Ia=ra.height-1;xa*=Ea;za*=Ia;Ga*=Ea;Ba*=Ia;Ha*=Ea;Oa*=Ia;T-=A;E-=Z;L-=A;ha-=Z;Ga-=xa;Ba-=za;Ha-=xa;Oa-=za;Ea=Ga*Oa-Ha*Ba;if(Ea!=0){Ia=1/Ea;Ea=(Oa*T-Ba*L)*Ia;Ba=(Oa*E-Ba*ha)*Ia;T=(Ga*L-Ha*T)*Ia;E=(Ga*ha-Ha*E)*Ia;A=A-Ea*xa-T*za;Z=Z-Ba*xa-E*za;m.save();m.transform(Ea,Ba,T,E,A,Z);m.clip();m.drawImage(ra,0,0);m.restore()}}function ma(A, -Z,T,E){var L=~~(A.r*255),ha=~~(A.g*255);A=~~(A.b*255);var ra=~~(Z.r*255),xa=~~(Z.g*255);Z=~~(Z.b*255);var za=~~(T.r*255),Ga=~~(T.g*255);T=~~(T.b*255);var Ba=~~(E.r*255),Ha=~~(E.g*255);E=~~(E.b*255);ka[0]=L<0?0:L>255?255:L;ka[1]=ha<0?0:ha>255?255:ha;ka[2]=A<0?0:A>255?255:A;ka[4]=ra<0?0:ra>255?255:ra;ka[5]=xa<0?0:xa>255?255:xa;ka[6]=Z<0?0:Z>255?255:Z;ka[8]=za<0?0:za>255?255:za;ka[9]=Ga<0?0:Ga>255?255:Ga;ka[10]=T<0?0:T>255?255:T;ka[12]=Ba<0?0:Ba>255?255:Ba;ka[13]=Ha<0?0:Ha>255?255:Ha;ka[14]=E<0?0:E> -255?255:E;pa.putImageData(P,0,0);wa.drawImage(Y,0,0);return oa}function Aa(A,Z,T){A=(A-Z)/(T-Z);return A*A*(3-2*A)}function ta(A){A=(A+1)*0.5;return A<0?0:A>1?1:A}function La(A,Z){var T=Z.x-A.x,E=Z.y-A.y,L=1/Math.sqrt(T*T+E*E);T*=L;E*=L;Z.x+=T;Z.y+=E;A.x-=T;A.y-=E}var ua,Ma,ja,ya,Fa,Ka,Na,sa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,o,l);d=f.projectScene(W,ba,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(w.getX(),w.getY(),w.getWidth(),w.getHeight());(p=W.lights.length> -0)&&Ca(W);ua=0;for(Ma=d.length;ua0){n.r+=t.color.r*w;n.g+=t.color.g*w;n.b+=t.color.b*w}}else if(t instanceof THREE.PointLight){X.sub(t.position,i.centroidWorld);X.normalize();w=i.normalWorld.dot(X)*t.intensity;if(w>0){n.r+=t.color.r*w;n.g+=t.color.g*w;n.b+=t.color.b*w}}}}function c(e,i,n,h,g,t){D=f(K++);D.setAttribute("d","M "+e.positionScreen.x+ -" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+"z");if(g instanceof THREE.MeshBasicMaterial)C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(t,h,b);C.r=g.color.r*b.r;C.g=g.color.g*b.g;C.b=g.color.b*b.b;C.updateStyleString()}else C.__styleString=g.color.__styleString;else if(g instanceof THREE.MeshDepthMaterial){J=1-g.__2near/(g.__farPlusNear-h.z*g.__farMinusNear); -C.setRGB(J,J,J)}else g instanceof THREE.MeshNormalMaterial&&C.setRGB(j(h.normalWorld.x),j(h.normalWorld.y),j(h.normalWorld.z));g.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+g.wireframe_linewidth+"; stroke-opacity: "+g.opacity+"; stroke-linecap: "+g.wireframe_linecap+"; stroke-linejoin: "+g.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+g.opacity);o.appendChild(D)}function d(e,i,n,h,g,t,w){D=f(K++);D.setAttribute("d", -"M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+i.positionScreen.x+" "+i.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");if(t instanceof THREE.MeshBasicMaterial)C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshLambertMaterial)if(O){b.r=R.r;b.g=R.g;b.b=R.b;a(w,g,b);C.r=t.color.r*b.r;C.g=t.color.g*b.g;C.b=t.color.b*b.b;C.updateStyleString()}else C.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshDepthMaterial){J= -1-t.__2near/(t.__farPlusNear-g.z*t.__farMinusNear);C.setRGB(J,J,J)}else t instanceof THREE.MeshNormalMaterial&&C.setRGB(j(g.normalWorld.x),j(g.normalWorld.y),j(g.normalWorld.z));t.wireframe?D.setAttribute("style","fill: none; stroke: "+C.__styleString+"; stroke-width: "+t.wireframe_linewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframe_linecap+"; stroke-linejoin: "+t.wireframe_linejoin):D.setAttribute("style","fill: "+C.__styleString+"; fill-opacity: "+t.opacity);o.appendChild(D)} -function f(e){if(G[e]==null){G[e]=document.createElementNS("http://www.w3.org/2000/svg","path");aa==0&&G[e].setAttribute("shape-rendering","crispEdges");return G[e]}return G[e]}function j(e){return e<0?Math.min((1+e)*0.5,0.5):0.5+Math.min(e*0.5,0.5)}var k=null,q=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,z,y,v,x,F,H,I=new THREE.Rectangle,s=new THREE.Rectangle,O=false,C=new THREE.Color(16777215),b=new THREE.Color(16777215),R=new THREE.Color(0),$=new THREE.Color(0), -Q=new THREE.Color(0),J,X=new THREE.Vector3,G=[],U=[],M=[],D,K,ca,N,aa=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(e){switch(e){case "high":aa=1;break;case "low":aa=0}};this.setSize=function(e,i){l=e;m=i;z=l/2;y=m/2;o.setAttribute("viewBox",-z+" "+-y+" "+l+" "+m);o.setAttribute("width",l);o.setAttribute("height",m);I.set(-z,-y,z,y)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(e,i){var n, -h,g,t,w,u,r,p;this.autoClear&&this.clear();k=q.projectScene(e,i,this.sortElements);N=ca=K=0;if(O=e.lights.length>0){r=e.lights;R.setRGB(0,0,0);$.setRGB(0,0,0);Q.setRGB(0,0,0);n=0;for(h=r.length;n0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,Ja,V)}if(ya&&ea>0){b.bindBuffer(b.ARRAY_BUFFER,w.__webGLUV2Buffer); -b.bufferData(b.ARRAY_BUFFER,Da,V)}if(ja){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Aa,V);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,w.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ta,V)}}x(objlist,t,h,e,i,n)}g.__dirtyVertices=false;g.__dirtyElements=false;g.__dirtyUvs=false;g.__dirtyNormals=false;g.__dirtyTangents=false;g.__dirtyColors=false}else if(i instanceof THREE.Line){if(!g.__webGLVertexBuffer){g.__webGLVertexBuffer=b.createBuffer();g.__webGLColorBuffer= -b.createBuffer();h=g.vertices.length;g.__vertexArray=new Float32Array(h*3);g.__colorArray=new Float32Array(h*3);g.__webGLLineCount=h;g.__dirtyVertices=true;g.__dirtyColors=true}if(g.__dirtyVertices||g.__dirtyColors){h=b.DYNAMIC_DRAW;u=g.vertices;w=g.colors;B=u.length;V=w.length;ea=g.__vertexArray;da=g.__colorArray;ia=g.__dirtyColors;if(g.__dirtyVertices){for(r=0;r0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+ -t.maxPointLights,t.map?"#define USE_MAP":"",t.env_map?"#define USE_ENVMAP":"",t.light_map?"#define USE_LIGHTMAP":"",t.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(n,s("fragment",g+r));b.attachShader(n, -s("vertex",t+i));b.linkProgram(n);b.getProgramParameter(n,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(n,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");n.uniforms={};n.attributes={};e.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in e.uniforms)n.push(h);h=e.program;r=0;for(i=n.length;r=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLColorBuffer);b.vertexAttribPointer(e.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.color)}if(e.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLNormalBuffer);b.vertexAttribPointer(e.normal,3,b.FLOAT, -false,0,0);b.enableVertexAttribArray(e.normal)}if(e.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLTangentBuffer);b.vertexAttribPointer(e.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.tangent)}if(e.uv>=0)if(g.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUVBuffer);b.vertexAttribPointer(e.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv)}else b.disableVertexAttribArray(e.uv);if(e.uv2>=0)if(g.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,g.__webGLUV2Buffer);b.vertexAttribPointer(e.uv2, -2,b.FLOAT,false,0,0);b.enableVertexAttribArray(e.uv2)}else b.disableVertexAttribArray(e.uv2);if(t instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLLineBuffer);b.drawElements(b.LINES,g.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,g.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(t instanceof THREE.Line){t=t.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth); -b.drawArrays(t,0,g.__webGLLineCount)}else t instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,g.__webGLParticleCount)};this.render=function(e,i,n,h){var g,t,w,u,r,p,B,V=e.lights,da=e.fog;i.autoUpdateMatrix&&i.updateMatrix();i.matrix.flattenToArray(D);i.projectionMatrix.flattenToArray(M);U.multiply(i.projectionMatrix,i.matrix);k(U);this.initWebGLObjects(e,i);I(n,h!==undefined?h:true);this.autoClear&&this.clear();u=e.__webGLObjects.length;for(h=0;h=0;n--){h=e.__webGLObjects[n].object;i==h&&e.__webGLObjects.splice(n,1)}};this.setDepthTest=function(e){e?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)}; -this.setFaceCulling=function(e,i){if(e){!i||i=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(e=="back")b.cullFace(b.BACK);else e=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; -THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif", -envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif", -envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif", -map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif", -lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", +THREE.Fog=function(a,c,e){this.color=new THREE.Color(a);this.near=c||1;this.far=e||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4}; +THREE.Projector=function(){function a(P,J){return J.z-P.z}function c(P,J){var W=0,M=1,R=P.z+P.w,K=J.z+J.w,C=-P.z+P.w,L=-J.z+J.w;if(R>=0&&K>=0&&C>=0&&L>=0)return true;else if(R<0&&K<0||C<0&&L<0)return false;else{if(R<0)W=Math.max(W,R/(R-K));else if(K<0)M=Math.min(M,R/(R-K));if(C<0)W=Math.max(W,C/(C-L));else if(L<0)M=Math.min(M,C/(C-L));if(MR&&N.z0&&G.z<1){t=D[y]=D[y]||new THREE.RenderableParticle;t.x=G.x/G.w;t.y=G.y/G.w;t.z=G.z;t.rotation=d.rotation.z;t.scale.x=d.scale.x*Math.abs(t.x-(G.x+J.projectionMatrix.n11)/ +(G.w+J.projectionMatrix.n14));t.scale.y=d.scale.y*Math.abs(t.y-(G.y+J.projectionMatrix.n22)/(G.w+J.projectionMatrix.n24));t.materials=d.materials;M.push(t);y++}}}}W&&M.sort(a);return M};this.unprojectVector=function(P,J){var W=THREE.Matrix4.makeInvert(J.matrix);W.multiplySelf(THREE.Matrix4.makeInvert(J.projectionMatrix));W.multiplyVector3(P);return P}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,e,g,i,k;this.domElement=document.createElement("div");this.setSize=function(q,p){e=q;g=p;i=e/2;k=g/2};this.render=function(q,p){var l,m,z,A,t,y,D,H;a=c.projectScene(q,p);l=0;for(m=a.length;l0){E.r+=pa.r*$;E.g+=pa.g*$;E.b+=pa.b*$}}else if($ instanceof THREE.PointLight){U.sub($.position,X);U.normalize();$=T.dot(U)*wa;if($>0){E.r+= +pa.r*$;E.g+=pa.g*$;E.b+=pa.b*$}}}}function va(x,X,T){if(T.opacity!=0){a(T.opacity);c(T.blending);var E,Q,$,pa,wa,ya;if(T instanceof THREE.ParticleBasicMaterial){if(T.map&&T.map.image.loaded){pa=T.map.image;wa=pa.width>>1;ya=pa.height>>1;Q=X.scale.x*p;$=X.scale.y*l;T=Q*wa;E=$*ya;n.set(x.x-T,x.y-E,x.x+T,x.y+E);if(!v.instersects(n))return;m.save();m.translate(x.x,x.y);m.rotate(-X.rotation);m.scale(Q,-$);m.translate(-wa,-ya);m.drawImage(pa,0,0);m.restore()}m.beginPath();m.moveTo(x.x-10,x.y);m.lineTo(x.x+ +10,x.y);m.moveTo(x.x,x.y-10);m.lineTo(x.x,x.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(T instanceof THREE.ParticleCircleMaterial){if(w){s.r=O.r+Y.r+ga.r;s.g=O.g+Y.g+ga.g;s.b=O.b+Y.b+ga.b;M.r=T.color.r*s.r;M.g=T.color.g*s.g;M.b=T.color.b*s.b;M.updateStyleString()}else M.__styleString=T.color.__styleString;T=X.scale.x*p;E=X.scale.y*l;n.set(x.x-T,x.y-E,x.x+T,x.y+E);if(v.instersects(n)){Q=M.__styleString;if(H!=Q)m.fillStyle=H=Q;m.save();m.translate(x.x,x.y);m.rotate(-X.rotation); +m.scale(T,E);m.beginPath();m.arc(0,0,1,0,ia,true);m.closePath();m.fill();m.restore()}}}}function ma(x,X,T,E){if(E.opacity!=0){a(E.opacity);c(E.blending);m.beginPath();m.moveTo(x.positionScreen.x,x.positionScreen.y);m.lineTo(X.positionScreen.x,X.positionScreen.y);m.closePath();if(E instanceof THREE.LineBasicMaterial){M.__styleString=E.color.__styleString;x=E.linewidth;if(G!=x)m.lineWidth=G=x;x=M.__styleString;if(D!=x)m.strokeStyle=D=x;m.stroke();n.inflate(E.linewidth*2)}}}function na(x,X,T,E,Q,$){if(Q.opacity!= +0){a(Q.opacity);c(Q.blending);I=x.positionScreen.x;b=x.positionScreen.y;aa=X.positionScreen.x;P=X.positionScreen.y;J=T.positionScreen.x;W=T.positionScreen.y;m.beginPath();m.moveTo(I,b);m.lineTo(aa,P);m.lineTo(J,W);m.lineTo(I,b);m.closePath();if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.image.loaded&&Q.map.mapping instanceof THREE.UVMapping&&sa(I,b,aa,P,J,W,Q.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(Q.env_map){if(Q.env_map.image.loaded)if(Q.env_map.mapping instanceof +THREE.SphericalReflectionMapping){x=fa.matrix;U.copy(E.vertexNormalsWorld[0]);ca=(U.x*x.n11+U.y*x.n12+U.z*x.n13)*0.5+0.5;d=-(U.x*x.n21+U.y*x.n22+U.z*x.n23)*0.5+0.5;U.copy(E.vertexNormalsWorld[1]);j=(U.x*x.n11+U.y*x.n12+U.z*x.n13)*0.5+0.5;o=-(U.x*x.n21+U.y*x.n22+U.z*x.n23)*0.5+0.5;U.copy(E.vertexNormalsWorld[2]);h=(U.x*x.n11+U.y*x.n12+U.z*x.n13)*0.5+0.5;f=-(U.x*x.n21+U.y*x.n22+U.z*x.n23)*0.5+0.5;sa(I,b,aa,P,J,W,Q.env_map.image,ca,d,j,o,h,f)}}else Q.wireframe?Ea(Q.color.__styleString,Q.wireframe_linewidth): +Fa(Q.color.__styleString);else if(Q instanceof THREE.MeshLambertMaterial){if(Q.map&&!Q.wireframe){Q.map.mapping instanceof THREE.UVMapping&&sa(I,b,aa,P,J,W,Q.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);c(THREE.SubtractiveBlending)}if(w)if(!Q.wireframe&&Q.shading==THREE.SmoothShading&&E.vertexNormalsWorld.length==3){R.r=K.r=C.r=O.r;R.g=K.g=C.g=O.g;R.b=K.b=C.b=O.b;za($,E.v1.positionWorld,E.vertexNormalsWorld[0],R);za($,E.v2.positionWorld,E.vertexNormalsWorld[1],K);za($, +E.v3.positionWorld,E.vertexNormalsWorld[2],C);L.r=(K.r+C.r)*0.5;L.g=(K.g+C.g)*0.5;L.b=(K.b+C.b)*0.5;da=ha(R,K,C,L);sa(I,b,aa,P,J,W,da,0,0,1,0,0,1)}else{s.r=O.r;s.g=O.g;s.b=O.b;za($,E.centroidWorld,E.normalWorld,s);M.r=Q.color.r*s.r;M.g=Q.color.g*s.g;M.b=Q.color.b*s.b;M.updateStyleString();Q.wireframe?Ea(M.__styleString,Q.wireframe_linewidth):Fa(M.__styleString)}else Q.wireframe?Ea(Q.color.__styleString,Q.wireframe_linewidth):Fa(Q.color.__styleString)}else if(Q instanceof THREE.MeshDepthMaterial){ba= +fa.near;N=fa.far;R.r=R.g=R.b=1-la(x.positionScreen.z,ba,N);K.r=K.g=K.b=1-la(X.positionScreen.z,ba,N);C.r=C.g=C.b=1-la(T.positionScreen.z,ba,N);L.r=(K.r+C.r)*0.5;L.g=(K.g+C.g)*0.5;L.b=(K.b+C.b)*0.5;da=ha(R,K,C,L);sa(I,b,aa,P,J,W,da,0,0,1,0,0,1)}else if(Q instanceof THREE.MeshNormalMaterial){M.r=Aa(E.normalWorld.x);M.g=Aa(E.normalWorld.y);M.b=Aa(E.normalWorld.z);M.updateStyleString();Q.wireframe?Ea(M.__styleString,Q.wireframe_linewidth):Fa(M.__styleString)}}}function Ea(x,X){if(D!=x)m.strokeStyle=D= +x;if(G!=X)m.lineWidth=G=X;m.stroke();n.inflate(X*2)}function Fa(x){if(H!=x)m.fillStyle=H=x;m.fill()}function sa(x,X,T,E,Q,$,pa,wa,ya,Ha,Da,Ia,Oa){var Ga,Ja;Ga=pa.width-1;Ja=pa.height-1;wa*=Ga;ya*=Ja;Ha*=Ga;Da*=Ja;Ia*=Ga;Oa*=Ja;T-=x;E-=X;Q-=x;$-=X;Ha-=wa;Da-=ya;Ia-=wa;Oa-=ya;Ga=Ha*Oa-Ia*Da;if(Ga!=0){Ja=1/Ga;Ga=(Oa*T-Da*Q)*Ja;Da=(Oa*E-Da*$)*Ja;T=(Ha*Q-Ia*T)*Ja;E=(Ha*$-Ia*E)*Ja;x=x-Ga*wa-T*ya;X=X-Da*wa-E*ya;m.save();m.transform(Ga,Da,T,E,x,X);m.clip();m.drawImage(pa,0,0);m.restore()}}function ha(x,X, +T,E){var Q=~~(x.r*255),$=~~(x.g*255);x=~~(x.b*255);var pa=~~(X.r*255),wa=~~(X.g*255);X=~~(X.b*255);var ya=~~(T.r*255),Ha=~~(T.g*255);T=~~(T.b*255);var Da=~~(E.r*255),Ia=~~(E.g*255);E=~~(E.b*255);F[0]=Q<0?0:Q>255?255:Q;F[1]=$<0?0:$>255?255:$;F[2]=x<0?0:x>255?255:x;F[4]=pa<0?0:pa>255?255:pa;F[5]=wa<0?0:wa>255?255:wa;F[6]=X<0?0:X>255?255:X;F[8]=ya<0?0:ya>255?255:ya;F[9]=Ha<0?0:Ha>255?255:Ha;F[10]=T<0?0:T>255?255:T;F[12]=Da<0?0:Da>255?255:Da;F[13]=Ia<0?0:Ia>255?255:Ia;F[14]=E<0?0:E>255?255:E;Z.putImageData(qa, +0,0);oa.drawImage(ea,0,0);return ua}function la(x,X,T){x=(x-X)/(T-X);return x*x*(3-2*x)}function Aa(x){x=(x+1)*0.5;return x<0?0:x>1?1:x}function ta(x,X){var T=X.x-x.x,E=X.y-x.y,Q=1/Math.sqrt(T*T+E*E);T*=Q;E*=Q;X.x+=T;X.y+=E;x.x-=T;x.y-=E}var La,xa,ka,Ba,Ca,Ma,Na,Ka;this.autoClear?this.clear():m.setTransform(1,0,0,-1,p,l);e=g.projectScene(V,fa,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(v.getX(),v.getY(),v.getWidth(),v.getHeight());(w=V.lights.length>0)&&ja(V);La=0;for(xa= +e.length;La0){j.r+=f.color.r*v;j.g+=f.color.g*v;j.b+=f.color.b*v}}else if(f instanceof THREE.PointLight){W.sub(f.position,d.centroidWorld);W.normalize();v=d.normalWorld.dot(W)*f.intensity;if(v>0){j.r+=f.color.r*v;j.g+=f.color.g*v;j.b+=f.color.b*v}}}}function c(ca,d,j,o,h,f){C=g(L++);C.setAttribute("d","M "+ca.positionScreen.x+ +" "+ca.positionScreen.y+" L "+d.positionScreen.x+" "+d.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+"z");if(h instanceof THREE.MeshBasicMaterial)B.__styleString=h.color.__styleString;else if(h instanceof THREE.MeshLambertMaterial)if(S){I.r=b.r;I.g=b.g;I.b=b.b;a(f,o,I);B.r=h.color.r*I.r;B.g=h.color.g*I.g;B.b=h.color.b*I.b;B.updateStyleString()}else B.__styleString=h.color.__styleString;else if(h instanceof THREE.MeshDepthMaterial){J=1-h.__2near/(h.__farPlusNear-o.z*h.__farMinusNear); +B.setRGB(J,J,J)}else h instanceof THREE.MeshNormalMaterial&&B.setRGB(i(o.normalWorld.x),i(o.normalWorld.y),i(o.normalWorld.z));h.wireframe?C.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+h.wireframe_linewidth+"; stroke-opacity: "+h.opacity+"; stroke-linecap: "+h.wireframe_linecap+"; stroke-linejoin: "+h.wireframe_linejoin):C.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+h.opacity);p.appendChild(C)}function e(ca,d,j,o,h,f,v){C=g(L++);C.setAttribute("d", +"M "+ca.positionScreen.x+" "+ca.positionScreen.y+" L "+d.positionScreen.x+" "+d.positionScreen.y+" L "+j.positionScreen.x+","+j.positionScreen.y+" L "+o.positionScreen.x+","+o.positionScreen.y+"z");if(f instanceof THREE.MeshBasicMaterial)B.__styleString=f.color.__styleString;else if(f instanceof THREE.MeshLambertMaterial)if(S){I.r=b.r;I.g=b.g;I.b=b.b;a(v,h,I);B.r=f.color.r*I.r;B.g=f.color.g*I.g;B.b=f.color.b*I.b;B.updateStyleString()}else B.__styleString=f.color.__styleString;else if(f instanceof +THREE.MeshDepthMaterial){J=1-f.__2near/(f.__farPlusNear-h.z*f.__farMinusNear);B.setRGB(J,J,J)}else f instanceof THREE.MeshNormalMaterial&&B.setRGB(i(h.normalWorld.x),i(h.normalWorld.y),i(h.normalWorld.z));f.wireframe?C.setAttribute("style","fill: none; stroke: "+B.__styleString+"; stroke-width: "+f.wireframe_linewidth+"; stroke-opacity: "+f.opacity+"; stroke-linecap: "+f.wireframe_linecap+"; stroke-linejoin: "+f.wireframe_linejoin):C.setAttribute("style","fill: "+B.__styleString+"; fill-opacity: "+ +f.opacity);p.appendChild(C)}function g(ca){if(M[ca]==null){M[ca]=document.createElementNS("http://www.w3.org/2000/svg","path");da==0&&M[ca].setAttribute("shape-rendering","crispEdges");return M[ca]}return M[ca]}function i(ca){return ca<0?Math.min((1+ca)*0.5,0.5):0.5+Math.min(ca*0.5,0.5)}var k=null,q=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,m,z,A,t,y,D,H,G=new THREE.Rectangle,r=new THREE.Rectangle,S=false,B=new THREE.Color(16777215),I=new THREE.Color(16777215), +b=new THREE.Color(0),aa=new THREE.Color(0),P=new THREE.Color(0),J,W=new THREE.Vector3,M=[],R=[],K=[],C,L,ba,N,da=1;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(ca){switch(ca){case "high":da=1;break;case "low":da=0}};this.setSize=function(ca,d){l=ca;m=d;z=l/2;A=m/2;p.setAttribute("viewBox",-z+" "+-A+" "+l+" "+m);p.setAttribute("width",l);p.setAttribute("height",m);G.set(-z,-A,z,A)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])}; +this.render=function(ca,d){var j,o,h,f,v,u,n,w;this.autoClear&&this.clear();k=q.projectScene(ca,d,this.sortElements);N=ba=L=0;if(S=ca.lights.length>0){n=ca.lights;b.setRGB(0,0,0);aa.setRGB(0,0,0);P.setRGB(0,0,0);j=0;for(o=n.length;j0){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLUVBuffer); +b.bufferData(b.ARRAY_BUFFER,Ea,Y)}if(Ca&&ia>0){b.bindBuffer(b.ARRAY_BUFFER,u.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,Fa,Y)}if(Ba){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,u.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,Aa,Y);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,u.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ta,Y)}}D(objlist,v,h,d,j,o)}f.__dirtyVertices=false;f.__dirtyElements=false;f.__dirtyUvs=false;f.__dirtyNormals=false;f.__dirtyTangents=false;f.__dirtyColors=false}else if(j instanceof +THREE.Line){if(!f.__webGLVertexBuffer){f.__webGLVertexBuffer=b.createBuffer();f.__webGLColorBuffer=b.createBuffer();h=f.vertices.length;f.__vertexArray=new Float32Array(h*3);f.__colorArray=new Float32Array(h*3);f.__webGLLineCount=h;f.__dirtyVertices=true;f.__dirtyColors=true}if(f.__dirtyVertices||f.__dirtyColors){h=b.DYNAMIC_DRAW;n=f.vertices;u=f.colors;O=n.length;Y=u.length;ia=f.__vertexArray;ga=f.__colorArray;U=f.__dirtyColors;if(f.__dirtyVertices){for(w=0;w0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.map?"#define USE_MAP":"",v.env_map?"#define USE_ENVMAP":"",v.light_map?"#define USE_LIGHTMAP":"",v.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n"); +b.attachShader(o,S("fragment",f+w));b.attachShader(o,S("vertex",v+j));b.linkProgram(o);b.getProgramParameter(o,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(o,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");o.uniforms={};o.attributes={};d.program=o;o=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(h in d.uniforms)o.push(h);h=d.program;w=0;for(j=o.length;w=0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLColorBuffer);b.vertexAttribPointer(d.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.color)}if(d.normal>= +0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.vertexAttribPointer(d.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.normal)}if(d.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLTangentBuffer);b.vertexAttribPointer(d.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.tangent)}if(d.uv>=0)if(f.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUVBuffer);b.vertexAttribPointer(d.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv)}else b.disableVertexAttribArray(d.uv);if(d.uv2>= +0)if(f.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLUV2Buffer);b.vertexAttribPointer(d.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(d.uv2)}else b.disableVertexAttribArray(d.uv2);if(v instanceof THREE.Mesh)if(h.wireframe){b.lineWidth(h.wireframe_linewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLLineBuffer);b.drawElements(b.LINES,f.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,f.__webGLFaceCount,b.UNSIGNED_SHORT, +0)}else if(v instanceof THREE.Line){v=v.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(h.linewidth);b.drawArrays(v,0,f.__webGLLineCount)}else v instanceof THREE.ParticleSystem&&b.drawArrays(b.POINTS,0,f.__webGLParticleCount)};this.render=function(d,j,o,h){var f,v,u,n,w,s,O,Y=d.lights,ga=d.fog;j.autoUpdateMatrix&&j.updateMatrix();j.matrix.flattenToArray(L);j.projectionMatrix.flattenToArray(C);K.multiply(j.projectionMatrix,j.matrix);k(K);this.initWebGLObjects(d,j);r(o,h!==undefined?h:true); +this.autoClear&&this.clear();n=d.__webGLObjects.length;for(h=0;h=0;o--){h=d.__webGLObjects[o].object;j==h&&d.__webGLObjects.splice(o,1)}};this.setDepthTest=function(d){d?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST)};this.setFaceCulling=function(d,j){if(d){!j||j=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(d=="back")b.cullFace(b.BACK);else d=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)> +0}}; +THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif", +envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", +map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D light_map;\n#endif", +lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( light_map, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif", lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}", lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif"}; diff --git a/build/ThreeExtras.js b/build/ThreeExtras.js index 708d0856..3ad35edc 100644 --- a/build/ThreeExtras.js +++ b/build/ThreeExtras.js @@ -13,50 +13,50 @@ THREE.Vector4=function(a,b,c,e){this.x=a||0;this.y=b||0;this.z=c||0;this.w=e||1} THREE.Vector4.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;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,c,e=a.objects,g=[];a=0;for(b=e.length;a0&&H>0&&P+H<1}var c,e,g,f,h,k,j,m,p,x, -t,q=a.geometry,y=q.vertices,z=[];c=0;for(e=q.faces.length;cj?e:j;g=g>m? -g:m}a()};this.add3Points=function(j,m,p,x,t,q){if(k){k=false;b=jp?j>t?j:t:p>t?p:t;g=m>x?m>q?m:q:x>q?x:q}else{b=jp?j>t?j>e?j:e:t>e?t:e:p>t?p>e?p:e:t>e?t:e;g=m>x?m>q?m>g?m:g:q>g?q:g:x>q?x>g?x:g:q>g?q:g}a()};this.addRectangle=function(j){if(k){k=false;b=j.getLeft();c=j.getTop();e=j.getRight();g=j.getBottom()}else{b=b0&&E>0&&d+E<1}var c,e,g,f,h,k,j,m,q,w, +u,t=a.geometry,x=t.vertices,A=[];c=0;for(e=t.faces.length;cj?e:j;g=g>m? +g:m}a()};this.add3Points=function(j,m,q,w,u,t){if(k){k=false;b=jq?j>u?j:u:q>u?q:u;g=m>w?m>t?m:t:w>t?w:t}else{b=jq?j>u?j>e?j:e:u>e?u:e:q>u?q>e?q:e:u>e?u:e;g=m>w?m>t?m>g?m:g:t>g?t:g:w>t?w>g?w:g:t>g?t:g}a()};this.addRectangle=function(j){if(k){k=false;b=j.getLeft();c=j.getTop();e=j.getRight();g=j.getBottom()}else{b=bj.getRight()?e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;e+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();e=e=0&&Math.min(g,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=true;g=e=c=b=0;a()};this.isEmpty=function(){return k};this.toString= function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+c+", bottom: "+g+", width: "+f+", height: "+h+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}}; -THREE.Matrix4=function(a,b,c,e,g,f,h,k,j,m,p,x,t,q,y,z){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=h||0;this.n24=k||0;this.n31=j||0;this.n32=m||0;this.n33=p||1;this.n34=x||0;this.n41=t||0;this.n42=q||0;this.n43=y||0;this.n44=z||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={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;return this},set:function(a,b,c,e,g,f,h,k,j,m,p,x,t,q,y,z){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=p;this.n34=x;this.n41=t;this.n42=q;this.n43=y;this.n44=z;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13= +THREE.Matrix4=function(a,b,c,e,g,f,h,k,j,m,q,w,u,t,x,A){this.n11=a||1;this.n12=b||0;this.n13=c||0;this.n14=e||0;this.n21=g||0;this.n22=f||1;this.n23=h||0;this.n24=k||0;this.n31=j||0;this.n32=m||0;this.n33=q||1;this.n34=w||0;this.n41=u||0;this.n42=t||0;this.n43=x||0;this.n44=A||1;this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={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;return this},set:function(a,b,c,e,g,f,h,k,j,m,q,w,u,t,x,A){this.n11=a;this.n12=b;this.n13=c;this.n14=e;this.n21=g;this.n22=f;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=q;this.n34=w;this.n41=u;this.n42=t;this.n43=x;this.n44=A;return this},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;return this},lookAt:function(a,b,c){var e=THREE.Matrix4.__tmpVec1,g=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();e.cross(c,f).normalize();g.cross(f,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a); this.n31=f.x;this.n32=f.y;this.n33=f.z;this.n34=-f.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,c=a.y,e=a.z,g=1/(this.n41*b+this.n42*c+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*c+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*c+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,c=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*c+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*c+this.n23* -e+this.n24*g;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,e=a.n12,g=a.n13,f=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,p=a.n31, -x=a.n32,t=a.n33,q=a.n34,y=a.n41,z=a.n42,H=a.n43,w=a.n44,E=b.n11,o=b.n12,d=b.n13,P=b.n14,aa=b.n21,N=b.n22,M=b.n23,U=b.n24,O=b.n31,Y=b.n32,W=b.n33,J=b.n34,X=b.n41,ha=b.n42,Z=b.n43,ea=b.n44;this.n11=c*E+e*aa+g*O+f*X;this.n12=c*o+e*N+g*Y+f*ha;this.n13=c*d+e*M+g*W+f*Z;this.n14=c*P+e*U+g*J+f*ea;this.n21=h*E+k*aa+j*O+m*X;this.n22=h*o+k*N+j*Y+m*ha;this.n23=h*d+k*M+j*W+m*Z;this.n24=h*P+k*U+j*J+m*ea;this.n31=p*E+x*aa+t*O+q*X;this.n32=p*o+x*N+t*Y+q*ha;this.n33=p*d+x*M+t*W+q*Z;this.n34=p*P+x*U+t*J+q*ea;this.n41= -y*E+z*aa+H*O+w*X;this.n42=y*o+z*N+H*Y+w*ha;this.n43=y*d+z*M+H*W+w*Z;this.n44=y*P+z*U+H*J+w*ea;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,f=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,p=a.n24,x=a.n31,t=a.n32,q=a.n33,y=a.n34,z=a.n41,H=a.n42,w=a.n43;a=a.n44;var E=b.n11,o=b.n12,d=b.n13,P=b.n14,aa=b.n21,N=b.n22,M=b.n23,U=b.n24,O=b.n31,Y=b.n32,W=b.n33,J=b.n34,X=b.n41,ha=b.n42,Z=b.n43;b=b.n44;this.n11=e*E+g*aa+f*O+h*X;this.n12=e*o+g*N+f*Y+h*ha;this.n13=e*d+g*M+f*W+h*Z;this.n14=e*P+g*U+f* -J+h*b;this.n21=k*E+j*aa+m*O+p*X;this.n22=k*o+j*N+m*Y+p*ha;this.n23=k*d+j*M+m*W+p*Z;this.n24=k*P+j*U+m*J+p*b;this.n31=x*E+t*aa+q*O+y*X;this.n32=x*o+t*N+q*Y+y*ha;this.n33=x*d+t*M+q*W+y*Z;this.n34=x*P+t*U+q*J+y*b;this.n41=z*E+H*aa+w*O+a*X;this.n42=z*o+H*N+w*Y+a*ha;this.n43=z*d+H*M+w*W+a*Z;this.n44=z*P+H*U+w*J+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]= -this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,p=this.n32,x=this.n33,t=this.n34,q=this.n41,y=this.n42,z=this.n43,H=this.n44,w=a.n11,E=a.n21,o=a.n31,d=a.n41,P=a.n12,aa=a.n22,N=a.n32,M=a.n42,U=a.n13,O=a.n23,Y=a.n33,W=a.n43,J=a.n14,X=a.n24,ha=a.n34;a=a.n44;this.n11=b*w+c*E+e*o+g*d;this.n12=b*P+c*aa+e*N+g*M;this.n13=b*U+c*O+e*Y+g*W;this.n14=b*J+c*X+e*ha+g*a;this.n21=f*w+ -h*E+k*o+j*d;this.n22=f*P+h*aa+k*N+j*M;this.n23=f*U+h*O+k*Y+j*W;this.n24=f*J+h*X+k*ha+j*a;this.n31=m*w+p*E+x*o+t*d;this.n32=m*P+p*aa+x*N+t*M;this.n33=m*U+p*O+x*Y+t*W;this.n34=m*J+p*X+x*ha+t*a;this.n41=q*w+y*E+z*o+H*d;this.n42=q*P+y*aa+z*N+H*M;this.n43=q*U+y*O+z*Y+H*W;this.n44=q*J+y*X+z*ha+H*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a; -this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,e=this.n14,g=this.n21,f=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,p=this.n33,x=this.n34,t=this.n41,q=this.n42,y=this.n43,z=this.n44;return e*h*m*t-c*k*m*t-e*f*p*t+b*k*p*t+c*f*x*t-b*h*x*t-e*h*j*q+c*k*j*q+e*g*p*q-a*k*p*q-c*g*x*q+a*h*x*q+e*f*j*y-b*k*j*y-e*g*m*y+a*k*m*y+b*g*x*y-a*f*x*y-c*f*j*z+b*h*j*z+c*g*m*z-a*h*m*z-b*g*p*z+a*f*p*z},transpose:function(){function a(b,c,e){var g=b[c];b[c]=b[e];b[e]= +e+this.n24*g;a.z=this.n31*b+this.n32*c+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*c+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,e=a.n12,g=a.n13,f=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,q=a.n31, +w=a.n32,u=a.n33,t=a.n34,x=a.n41,A=a.n42,E=a.n43,v=a.n44,F=b.n11,p=b.n12,M=b.n13,d=b.n14,aa=b.n21,O=b.n22,K=b.n23,X=b.n24,Q=b.n31,U=b.n32,V=b.n33,H=b.n34,Y=b.n41,ea=b.n42,Z=b.n43,fa=b.n44;this.n11=c*F+e*aa+g*Q+f*Y;this.n12=c*p+e*O+g*U+f*ea;this.n13=c*M+e*K+g*V+f*Z;this.n14=c*d+e*X+g*H+f*fa;this.n21=h*F+k*aa+j*Q+m*Y;this.n22=h*p+k*O+j*U+m*ea;this.n23=h*M+k*K+j*V+m*Z;this.n24=h*d+k*X+j*H+m*fa;this.n31=q*F+w*aa+u*Q+t*Y;this.n32=q*p+w*O+u*U+t*ea;this.n33=q*M+w*K+u*V+t*Z;this.n34=q*d+w*X+u*H+t*fa;this.n41= +x*F+A*aa+E*Q+v*Y;this.n42=x*p+A*O+E*U+v*ea;this.n43=x*M+A*K+E*V+v*Z;this.n44=x*d+A*X+E*H+v*fa;return this},multiplyToArray:function(a,b,c){var e=a.n11,g=a.n12,f=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,q=a.n24,w=a.n31,u=a.n32,t=a.n33,x=a.n34,A=a.n41,E=a.n42,v=a.n43;a=a.n44;var F=b.n11,p=b.n12,M=b.n13,d=b.n14,aa=b.n21,O=b.n22,K=b.n23,X=b.n24,Q=b.n31,U=b.n32,V=b.n33,H=b.n34,Y=b.n41,ea=b.n42,Z=b.n43;b=b.n44;this.n11=e*F+g*aa+f*Q+h*Y;this.n12=e*p+g*O+f*U+h*ea;this.n13=e*M+g*K+f*V+h*Z;this.n14=e*d+g*X+f* +H+h*b;this.n21=k*F+j*aa+m*Q+q*Y;this.n22=k*p+j*O+m*U+q*ea;this.n23=k*M+j*K+m*V+q*Z;this.n24=k*d+j*X+m*H+q*b;this.n31=w*F+u*aa+t*Q+x*Y;this.n32=w*p+u*O+t*U+x*ea;this.n33=w*M+u*K+t*V+x*Z;this.n34=w*d+u*X+t*H+x*b;this.n41=A*F+E*aa+v*Q+a*Y;this.n42=A*p+E*O+v*U+a*ea;this.n43=A*M+E*K+v*V+a*Z;this.n44=A*d+E*X+v*H+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]= +this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,e=this.n13,g=this.n14,f=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,q=this.n32,w=this.n33,u=this.n34,t=this.n41,x=this.n42,A=this.n43,E=this.n44,v=a.n11,F=a.n21,p=a.n31,M=a.n41,d=a.n12,aa=a.n22,O=a.n32,K=a.n42,X=a.n13,Q=a.n23,U=a.n33,V=a.n43,H=a.n14,Y=a.n24,ea=a.n34;a=a.n44;this.n11=b*v+c*F+e*p+g*M;this.n12=b*d+c*aa+e*O+g*K;this.n13=b*X+c*Q+e*U+g*V;this.n14=b*H+c*Y+e*ea+g*a;this.n21=f*v+ +h*F+k*p+j*M;this.n22=f*d+h*aa+k*O+j*K;this.n23=f*X+h*Q+k*U+j*V;this.n24=f*H+h*Y+k*ea+j*a;this.n31=m*v+q*F+w*p+u*M;this.n32=m*d+q*aa+w*O+u*K;this.n33=m*X+q*Q+w*U+u*V;this.n34=m*H+q*Y+w*ea+u*a;this.n41=t*v+x*F+A*p+E*M;this.n42=t*d+x*aa+A*O+E*K;this.n43=t*X+x*Q+A*U+E*V;this.n44=t*H+x*Y+A*ea+E*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a; +this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,e=this.n14,g=this.n21,f=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,q=this.n33,w=this.n34,u=this.n41,t=this.n42,x=this.n43,A=this.n44;return e*h*m*u-c*k*m*u-e*f*q*u+b*k*q*u+c*f*w*u-b*h*w*u-e*h*j*t+c*k*j*t+e*g*q*t-a*k*q*t-c*g*w*t+a*h*w*t+e*f*j*x-b*k*j*x-e*g*m*x+a*k*m*x+b*g*w*x-a*f*w*x-c*f*j*A+b*h*j*A+c*g*m*A-a*h*m*A-b*g*q*A+a*f*q*A},transpose:function(){function a(b,c,e){var g=b[c];b[c]=b[e];b[e]= g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;a[1]=this.n21;a[2]=this.n31; a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1, 0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),e=Math.sin(b), g=1-c,f=a.x,h=a.y,k=a.z,j=g*f,m=g*h;this.set(j*f+c,j*h-e*k,j*k+e*h,0,j*h+e*k,m*h+c,m*k-e*f,0,j*k-e*h,m*k+e*f,g*k*k+c,0,0,0,0,1);return this},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,c){var e=new THREE.Matrix4;e.setTranslation(a,b,c);return e}; THREE.Matrix4.scaleMatrix=function(a,b,c){var e=new THREE.Matrix4;e.setScale(a,b,c);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c}; -THREE.Matrix4.makeInvert=function(a){var b=a.n11,c=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,j=a.n24,m=a.n31,p=a.n32,x=a.n33,t=a.n34,q=a.n41,y=a.n42,z=a.n43,H=a.n44,w=new THREE.Matrix4;w.n11=k*t*y-j*x*y+j*p*z-h*t*z-k*p*H+h*x*H;w.n12=g*x*y-e*t*y-g*p*z+c*t*z+e*p*H-c*x*H;w.n13=e*j*y-g*k*y+g*h*z-c*j*z-e*h*H+c*k*H;w.n14=g*k*p-e*j*p-g*h*x+c*j*x+e*h*t-c*k*t;w.n21=j*x*q-k*t*q-j*m*z+f*t*z+k*m*H-f*x*H;w.n22=e*t*q-g*x*q+g*m*z-b*t*z-e*m*H+b*x*H;w.n23=g*k*q-e*j*q-g*f*z+b*j*z+e*f*H-b*k*H;w.n24=e*j*m-g*k*m+ -g*f*x-b*j*x-e*f*t+b*k*t;w.n31=h*t*q-j*p*q+j*m*y-f*t*y-h*m*H+f*p*H;w.n32=g*p*q-c*t*q-g*m*y+b*t*y+c*m*H-b*p*H;w.n33=e*j*q-g*h*q+g*f*y-b*j*y-c*f*H+b*h*H;w.n34=g*h*m-c*j*m-g*f*p+b*j*p+c*f*t-b*h*t;w.n41=k*p*q-h*x*q-k*m*y+f*x*y+h*m*z-f*p*z;w.n42=c*x*q-e*p*q+e*m*y-b*x*y-c*m*z+b*p*z;w.n43=e*h*q-c*k*q-e*f*y+b*k*y+c*f*z-b*h*z;w.n44=c*k*m-e*h*m+e*f*p-b*k*p-c*f*x+b*h*x;w.multiplyScalar(1/a.determinant());return w}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*f;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*p;c[8]=a*x;return b}; +THREE.Matrix4.makeInvert=function(a){var b=a.n11,c=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,k=a.n23,j=a.n24,m=a.n31,q=a.n32,w=a.n33,u=a.n34,t=a.n41,x=a.n42,A=a.n43,E=a.n44,v=new THREE.Matrix4;v.n11=k*u*x-j*w*x+j*q*A-h*u*A-k*q*E+h*w*E;v.n12=g*w*x-e*u*x-g*q*A+c*u*A+e*q*E-c*w*E;v.n13=e*j*x-g*k*x+g*h*A-c*j*A-e*h*E+c*k*E;v.n14=g*k*q-e*j*q-g*h*w+c*j*w+e*h*u-c*k*u;v.n21=j*w*t-k*u*t-j*m*A+f*u*A+k*m*E-f*w*E;v.n22=e*u*t-g*w*t+g*m*A-b*u*A-e*m*E+b*w*E;v.n23=g*k*t-e*j*t-g*f*A+b*j*A+e*f*E-b*k*E;v.n24=e*j*m-g*k*m+ +g*f*w-b*j*w-e*f*u+b*k*u;v.n31=h*u*t-j*q*t+j*m*x-f*u*x-h*m*E+f*q*E;v.n32=g*q*t-c*u*t-g*m*x+b*u*x+c*m*E-b*q*E;v.n33=e*j*t-g*h*t+g*f*x-b*j*x-c*f*E+b*h*E;v.n34=g*h*m-c*j*m-g*f*q+b*j*q+c*f*u-b*h*u;v.n41=k*q*t-h*w*t-k*m*x+f*w*x+h*m*A-f*q*A;v.n42=c*w*t-e*q*t+e*m*x-b*w*x-c*m*A+b*q*A;v.n43=e*h*t-c*k*t-e*f*x+b*k*x+c*f*A-b*h*A;v.n44=c*k*m-e*h*m+e*f*q-b*k*q-c*f*w+b*h*w;v.multiplyScalar(1/a.determinant());return v}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,q=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*e;c[1]=a*g;c[2]=a*f;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*q;c[8]=a*w;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,e,g,f){var h,k,j;h=new THREE.Matrix4;k=2*g/(b-a);j=2*g/(e-c);a=(b+a)/(b-a);c=(e+c)/(e-c);e=-(f+g)/(f-g);g=-2*f*g/(f-g);h.n11=k;h.n12=0;h.n13=a;h.n14=0;h.n21=0;h.n22=j;h.n23=c;h.n24=0;h.n31=0;h.n32=0;h.n33=e;h.n34=g;h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,e){var g;a=c*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,c,e)}; THREE.Matrix4.makeOrtho=function(a,b,c,e,g,f){var h,k,j,m;h=new THREE.Matrix4;k=b-a;j=c-e;m=f-g;a=(b+a)/k;c=(c+e)/j;g=(f+g)/m;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-a;h.n21=0;h.n22=2/j;h.n23=0;h.n24=-c;h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-g;h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}}; THREE.Face3=function(a,b,c,e,g){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face3.prototype={toString:function(){return"THREE.Face3 ( "+this.a+", "+this.b+", "+this.c+" )"}}; THREE.Face4=function(a,b,c,e,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=f instanceof Array?f:[f]};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.uvs2=[];this.colors=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; +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.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], +this.vertices[e.d].normal.copy(e.vertexNormals[3])}}b=0;for(c=this.vertices.length;b0){this.boundingBox={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 b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z -this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b65535){m[k].counter+=1;j=m[k].hash+"_"+m[k].counter;if(this.geometryChunks[j]==undefined)this.geometryChunks[j]={faces:[],materials:h,vertices:0}}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=f}},toString:function(){return"THREE.Geometry ( vertices: "+ -this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};THREE.GeometryIdCounter=0; THREE.Camera=function(a,b,c,e){this.fov=a;this.aspect=b;this.near=c;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)}; this.translateZ=function(g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateMatrix=function(){this.matrix.lookAt(this.position,this.target.position,this.up)};this.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};this.updateProjectionMatrix()}; THREE.Camera.prototype={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; @@ -104,108 +104,108 @@ var Uniforms={clone:function(a){var b,c,e,g={};for(b in a){g[b]={};for(c in a[b] THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&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.indexOf(a)===-1&&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.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4}; -THREE.Projector=function(){function a(N,M){return M.z-N.z}function b(N,M){var U=0,O=1,Y=N.z+N.w,W=M.z+M.w,J=-N.z+N.w,X=-M.z+M.w;if(Y>=0&&W>=0&&J>=0&&X>=0)return true;else if(Y<0&&W<0||J<0&&X<0)return false;else{if(Y<0)U=Math.max(U,Y/(Y-W));else if(W<0)O=Math.min(O,Y/(Y-W));if(J<0)U=Math.max(U,J/(J-X));else if(X<0)O=Math.min(O,J/(J-X));if(OY&&Z.z0&&H.z<1){t=y[q]=y[q]||new THREE.RenderableParticle;t.x=H.x/H.w;t.y=H.y/H.w;t.z=H.z;t.rotation=v.rotation.z;t.scale.x=v.scale.x*Math.abs(t.x-(H.x+M.projectionMatrix.n11)/ -(H.w+M.projectionMatrix.n14));t.scale.y=v.scale.y*Math.abs(t.y-(H.y+M.projectionMatrix.n22)/(H.w+M.projectionMatrix.n24));t.materials=v.materials;O.push(t);q++}}}}U&&O.sort(a);return O};this.unprojectVector=function(N,M){var U=THREE.Matrix4.makeInvert(M.matrix);U.multiplySelf(THREE.Matrix4.makeInvert(M.projectionMatrix));U.multiplyVector3(N);return N}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,f;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;e=k;g=c/2;f=e/2};this.render=function(h,k){var j,m,p,x,t,q,y,z;a=b.projectScene(h,k);j=0;for(m=a.length;j0){T.r+=va.r*na;T.g+=va.g*na;T.b+=va.b*na}}else if(na instanceof THREE.PointLight){I.sub(na.position,ia);I.normalize(); -na=ca.dot(I)*Aa;if(na>0){T.r+=va.r*na;T.g+=va.g*na;T.b+=va.b*na}}}}function qa(S,ia,ca){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);var T,$,na,va,Aa,Ca;if(ca instanceof THREE.ParticleBasicMaterial){if(ca.map&&ca.map.image.loaded){va=ca.map.image;Aa=va.width>>1;Ca=va.height>>1;$=ia.scale.x*k;na=ia.scale.y*j;ca=$*Aa;T=na*Ca;D.set(S.x-ca,S.y-T,S.x+ca,S.y+T);if(L.instersects(D)){m.save();m.translate(S.x,S.y);m.rotate(-ia.rotation);m.scale($,-na);m.translate(-Aa,-Ca);m.drawImage(va,0,0);m.restore()}}}else if(ca instanceof -THREE.ParticleCircleMaterial){if(C){R.r=ba.r+ga.r+B.r;R.g=ba.g+ga.g+B.g;R.b=ba.b+ga.b+B.b;O.r=ca.color.r*R.r;O.g=ca.color.g*R.g;O.b=ca.color.b*R.b;O.updateStyleString()}else O.__styleString=ca.color.__styleString;ca=ia.scale.x*k;T=ia.scale.y*j;D.set(S.x-ca,S.y-T,S.x+ca,S.y+T);if(L.instersects(D)){$=O.__styleString;if(z!=$)m.fillStyle=z=$;m.save();m.translate(S.x,S.y);m.rotate(-ia.rotation);m.scale(ca,T);m.beginPath();m.arc(0,0,1,0,K,true);m.closePath();m.fill();m.restore()}}}}function sa(S,ia,ca, -T){if(T.opacity!=0){a(T.opacity);b(T.blending);m.beginPath();m.moveTo(S.positionScreen.x,S.positionScreen.y);m.lineTo(ia.positionScreen.x,ia.positionScreen.y);m.closePath();if(T instanceof THREE.LineBasicMaterial){O.__styleString=T.color.__styleString;S=T.linewidth;if(H!=S)m.lineWidth=H=S;S=O.__styleString;if(y!=S)m.strokeStyle=y=S;m.stroke();D.inflate(T.linewidth*2)}}}function Ma(S,ia,ca,T,$,na){if($.opacity!=0){a($.opacity);b($.blending);d=S.positionScreen.x;P=S.positionScreen.y;aa=ia.positionScreen.x; -N=ia.positionScreen.y;M=ca.positionScreen.x;U=ca.positionScreen.y;m.beginPath();m.moveTo(d,P);m.lineTo(aa,N);m.lineTo(M,U);m.lineTo(d,P);m.closePath();if($ instanceof THREE.MeshBasicMaterial)if($.map)$.map.image.loaded&&$.map.mapping instanceof THREE.UVMapping&&ma(d,P,aa,N,M,U,$.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);else if($.env_map){if($.env_map.image.loaded)if($.env_map.mapping instanceof THREE.SphericalReflectionMapping){S=ja.matrix;I.copy(T.vertexNormalsWorld[0]); -l=(I.x*S.n11+I.y*S.n12+I.z*S.n13)*0.5+0.5;v=-(I.x*S.n21+I.y*S.n22+I.z*S.n23)*0.5+0.5;I.copy(T.vertexNormalsWorld[1]);A=(I.x*S.n11+I.y*S.n12+I.z*S.n13)*0.5+0.5;u=-(I.x*S.n21+I.y*S.n22+I.z*S.n23)*0.5+0.5;I.copy(T.vertexNormalsWorld[2]);n=(I.x*S.n11+I.y*S.n12+I.z*S.n13)*0.5+0.5;F=-(I.x*S.n21+I.y*S.n22+I.z*S.n23)*0.5+0.5;ma(d,P,aa,N,M,U,$.env_map.image,l,v,A,u,n,F)}}else $.wireframe?Ga($.color.__styleString,$.wireframe_linewidth):za($.color.__styleString);else if($ instanceof THREE.MeshLambertMaterial){if($.map&& -!$.wireframe){$.map.mapping instanceof THREE.UVMapping&&ma(d,P,aa,N,M,U,$.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);b(THREE.SubtractiveBlending)}if(C)if(!$.wireframe&&$.shading==THREE.SmoothShading&&T.vertexNormalsWorld.length==3){Y.r=W.r=J.r=ba.r;Y.g=W.g=J.g=ba.g;Y.b=W.b=J.b=ba.b;ta(na,T.v1.positionWorld,T.vertexNormalsWorld[0],Y);ta(na,T.v2.positionWorld,T.vertexNormalsWorld[1],W);ta(na,T.v3.positionWorld,T.vertexNormalsWorld[2],J);X.r=(W.r+J.r)*0.5;X.g=(W.g+J.g)* -0.5;X.b=(W.b+J.b)*0.5;ea=ra(Y,W,J,X);ma(d,P,aa,N,M,U,ea,0,0,1,0,0,1)}else{R.r=ba.r;R.g=ba.g;R.b=ba.b;ta(na,T.centroidWorld,T.normalWorld,R);O.r=$.color.r*R.r;O.g=$.color.g*R.g;O.b=$.color.b*R.b;O.updateStyleString();$.wireframe?Ga(O.__styleString,$.wireframe_linewidth):za(O.__styleString)}else $.wireframe?Ga($.color.__styleString,$.wireframe_linewidth):za($.color.__styleString)}else if($ instanceof THREE.MeshDepthMaterial){ha=ja.near;Z=ja.far;Y.r=Y.g=Y.b=1-Da(S.positionScreen.z,ha,Z);W.r=W.g=W.b= -1-Da(ia.positionScreen.z,ha,Z);J.r=J.g=J.b=1-Da(ca.positionScreen.z,ha,Z);X.r=(W.r+J.r)*0.5;X.g=(W.g+J.g)*0.5;X.b=(W.b+J.b)*0.5;ea=ra(Y,W,J,X);ma(d,P,aa,N,M,U,ea,0,0,1,0,0,1)}else if($ instanceof THREE.MeshNormalMaterial){O.r=xa(T.normalWorld.x);O.g=xa(T.normalWorld.y);O.b=xa(T.normalWorld.z);O.updateStyleString();$.wireframe?Ga(O.__styleString,$.wireframe_linewidth):za(O.__styleString)}}}function Ga(S,ia){if(y!=S)m.strokeStyle=y=S;if(H!=ia)m.lineWidth=H=ia;m.stroke();D.inflate(ia*2)}function za(S){if(z!= -S)m.fillStyle=z=S;m.fill()}function ma(S,ia,ca,T,$,na,va,Aa,Ca,Ja,Ea,Ka,Ra){var Ha,La;Ha=va.width-1;La=va.height-1;Aa*=Ha;Ca*=La;Ja*=Ha;Ea*=La;Ka*=Ha;Ra*=La;ca-=S;T-=ia;$-=S;na-=ia;Ja-=Aa;Ea-=Ca;Ka-=Aa;Ra-=Ca;Ha=Ja*Ra-Ka*Ea;if(Ha!=0){La=1/Ha;Ha=(Ra*ca-Ea*$)*La;Ea=(Ra*T-Ea*na)*La;ca=(Ja*$-Ka*ca)*La;T=(Ja*na-Ka*T)*La;S=S-Ha*Aa-ca*Ca;ia=ia-Ea*Aa-T*Ca;m.save();m.transform(Ha,Ea,ca,T,S,ia);m.clip();m.drawImage(va,0,0);m.restore()}}function ra(S,ia,ca,T){var $=~~(S.r*255),na=~~(S.g*255);S=~~(S.b*255);var va= -~~(ia.r*255),Aa=~~(ia.g*255);ia=~~(ia.b*255);var Ca=~~(ca.r*255),Ja=~~(ca.g*255);ca=~~(ca.b*255);var Ea=~~(T.r*255),Ka=~~(T.g*255);T=~~(T.b*255);ka[0]=$<0?0:$>255?255:$;ka[1]=na<0?0:na>255?255:na;ka[2]=S<0?0:S>255?255:S;ka[4]=va<0?0:va>255?255:va;ka[5]=Aa<0?0:Aa>255?255:Aa;ka[6]=ia<0?0:ia>255?255:ia;ka[8]=Ca<0?0:Ca>255?255:Ca;ka[9]=Ja<0?0:Ja>255?255:Ja;ka[10]=ca<0?0:ca>255?255:ca;ka[12]=Ea<0?0:Ea>255?255:Ea;ka[13]=Ka<0?0:Ka>255?255:Ka;ka[14]=T<0?0:T>255?255:T;da.putImageData(V,0,0);ua.drawImage(Q, -0,0);return pa}function Da(S,ia,ca){S=(S-ia)/(ca-ia);return S*S*(3-2*S)}function xa(S){S=(S+1)*0.5;return S<0?0:S>1?1:S}function Oa(S,ia){var ca=ia.x-S.x,T=ia.y-S.y,$=1/Math.sqrt(ca*ca+T*T);ca*=$;T*=$;ia.x+=ca;ia.y+=T;S.x-=ca;S.y-=T}var ya,Pa,oa,Ba,Ia,Na,Qa,wa;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=e.projectScene(fa,ja,this.sortElements);(C=fa.lights.length>0)&&Fa(fa);ya=0;for(Pa=c.length;ya0){A.r+=F.color.r*L;A.g+=F.color.g*L;A.b+=F.color.b*L}}else if(F instanceof THREE.PointLight){U.sub(F.position,v.centroidWorld);U.normalize();L=v.normalWorld.dot(U)*F.intensity;if(L>0){A.r+=F.color.r*L;A.g+=F.color.g*L;A.b+=F.color.b*L}}}}function b(l,v,A,u,n,F){J=e(X++);J.setAttribute("d","M "+l.positionScreen.x+ -" "+l.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+A.positionScreen.x+","+A.positionScreen.y+"z");if(n instanceof THREE.MeshBasicMaterial)o.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshLambertMaterial)if(E){d.r=P.r;d.g=P.g;d.b=P.b;a(F,u,d);o.r=n.color.r*d.r;o.g=n.color.g*d.g;o.b=n.color.b*d.b;o.updateStyleString()}else o.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshDepthMaterial){M=1-n.__2near/(n.__farPlusNear-u.z*n.__farMinusNear); -o.setRGB(M,M,M)}else n instanceof THREE.MeshNormalMaterial&&o.setRGB(g(u.normalWorld.x),g(u.normalWorld.y),g(u.normalWorld.z));n.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+n.wireframe_linewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframe_linecap+"; stroke-linejoin: "+n.wireframe_linejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+n.opacity);k.appendChild(J)}function c(l,v,A,u,n,F,L){J=e(X++);J.setAttribute("d", -"M "+l.positionScreen.x+" "+l.positionScreen.y+" L "+v.positionScreen.x+" "+v.positionScreen.y+" L "+A.positionScreen.x+","+A.positionScreen.y+" L "+u.positionScreen.x+","+u.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)o.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(E){d.r=P.r;d.g=P.g;d.b=P.b;a(L,n,d);o.r=F.color.r*d.r;o.g=F.color.g*d.g;o.b=F.color.b*d.b;o.updateStyleString()}else o.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){M= -1-F.__2near/(F.__farPlusNear-n.z*F.__farMinusNear);o.setRGB(M,M,M)}else F instanceof THREE.MeshNormalMaterial&&o.setRGB(g(n.normalWorld.x),g(n.normalWorld.y),g(n.normalWorld.z));F.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+F.opacity);k.appendChild(J)} -function e(l){if(O[l]==null){O[l]=document.createElementNS("http://www.w3.org/2000/svg","path");ea==0&&O[l].setAttribute("shape-rendering","crispEdges");return O[l]}return O[l]}function g(l){return l<0?Math.min((1+l)*0.5,0.5):0.5+Math.min(l*0.5,0.5)}var f=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,p,x,t,q,y,z,H=new THREE.Rectangle,w=new THREE.Rectangle,E=false,o=new THREE.Color(16777215),d=new THREE.Color(16777215),P=new THREE.Color(0),aa=new THREE.Color(0), -N=new THREE.Color(0),M,U=new THREE.Vector3,O=[],Y=[],W=[],J,X,ha,Z,ea=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(l){switch(l){case "high":ea=1;break;case "low":ea=0}};this.setSize=function(l,v){j=l;m=v;p=j/2;x=m/2;k.setAttribute("viewBox",-p+" "+-x+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);H.set(-p,-x,p,x)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(l,v){var A, -u,n,F,L,G,D,C;this.autoClear&&this.clear();f=h.projectScene(l,v,this.sortElements);Z=ha=X=0;if(E=l.lights.length>0){D=l.lights;P.setRGB(0,0,0);aa.setRGB(0,0,0);N.setRGB(0,0,0);A=0;for(u=D.length;A0){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLUVBuffer);d.bufferData(d.ARRAY_BUFFER,Ma,ba)}if(Ba&& -B>0){d.bindBuffer(d.ARRAY_BUFFER,L.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ga,ba)}if(oa){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,L.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,Da,ba);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,L.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,xa,ba)}}q(objlist,F,u,l,v,A)}n.__dirtyVertices=false;n.__dirtyElements=false;n.__dirtyUvs=false;n.__dirtyNormals=false;n.__dirtyTangents=false;n.__dirtyColors=false}else if(v instanceof THREE.Line){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer= -d.createBuffer();n.__webGLColorBuffer=d.createBuffer();u=n.vertices.length;n.__vertexArray=new Float32Array(u*3);n.__colorArray=new Float32Array(u*3);n.__webGLLineCount=u;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors){u=d.DYNAMIC_DRAW;G=n.vertices;L=n.colors;R=G.length;ba=L.length;B=n.__vertexArray;ga=n.__colorArray;K=n.__dirtyColors;if(n.__dirtyVertices){for(D=0;D -0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+F.maxDirLights,"#define MAX_POINT_LIGHTS "+F.maxPointLights,F.map?"#define USE_MAP":"",F.env_map?"#define USE_ENVMAP":"",F.light_map?"#define USE_LIGHTMAP":"",F.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n"); -d.attachShader(A,w("fragment",n+D));d.attachShader(A,w("vertex",F+v));d.linkProgram(A);d.getProgramParameter(A,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(A,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");A.uniforms={};A.attributes={};l.program=A;A=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(u in l.uniforms)A.push(u);u=l.program;D=0;for(v=A.length;D=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.vertexAttribPointer(l.color,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.color)}if(l.normal>= +THREE.Projector=function(){function a(O,K){return K.z-O.z}function b(O,K){var X=0,Q=1,U=O.z+O.w,V=K.z+K.w,H=-O.z+O.w,Y=-K.z+K.w;if(U>=0&&V>=0&&H>=0&&Y>=0)return true;else if(U<0&&V<0||H<0&&Y<0)return false;else{if(U<0)X=Math.max(X,U/(U-V));else if(V<0)Q=Math.min(Q,U/(U-V));if(H<0)X=Math.max(X,H/(H-Y));else if(Y<0)Q=Math.min(Q,H/(H-Y));if(QU&&Z.z0&&E.z<1){u=x[t]=x[t]||new THREE.RenderableParticle;u.x=E.x/E.w;u.y=E.y/E.w;u.z=E.z;u.rotation=l.rotation.z;u.scale.x=l.scale.x*Math.abs(u.x-(E.x+K.projectionMatrix.n11)/ +(E.w+K.projectionMatrix.n14));u.scale.y=l.scale.y*Math.abs(u.y-(E.y+K.projectionMatrix.n22)/(E.w+K.projectionMatrix.n24));u.materials=l.materials;Q.push(u);t++}}}}X&&Q.sort(a);return Q};this.unprojectVector=function(O,K){var X=THREE.Matrix4.makeInvert(K.matrix);X.multiplySelf(THREE.Matrix4.makeInvert(K.projectionMatrix));X.multiplyVector3(O);return O}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,e,g,f;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;e=k;g=c/2;f=e/2};this.render=function(h,k){var j,m,q,w,u,t,x,A;a=b.projectScene(h,k);j=0;for(m=a.length;j0){T.r+=ua.r*ja;T.g+=ua.g*ja;T.b+=ua.b*ja}}else if(ja instanceof THREE.PointLight){J.sub(ja.position,ha);J.normalize(); +ja=ca.dot(J)*za;if(ja>0){T.r+=ua.r*ja;T.g+=ua.g*ja;T.b+=ua.b*ja}}}}function ya(P,ha,ca){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);var T,ba,ja,ua,za,Ba;if(ca instanceof THREE.ParticleBasicMaterial){if(ca.map&&ca.map.image.loaded){ua=ca.map.image;za=ua.width>>1;Ba=ua.height>>1;ba=ha.scale.x*k;ja=ha.scale.y*j;ca=ba*za;T=ja*Ba;z.set(P.x-ca,P.y-T,P.x+ca,P.y+T);if(N.instersects(z)){m.save();m.translate(P.x,P.y);m.rotate(-ha.rotation);m.scale(ba,-ja);m.translate(-za,-Ba);m.drawImage(ua,0,0);m.restore()}}}else if(ca instanceof +THREE.ParticleCircleMaterial){if(I){D.r=$.r+da.r+C.r;D.g=$.g+da.g+C.g;D.b=$.b+da.b+C.b;Q.r=ca.color.r*D.r;Q.g=ca.color.g*D.g;Q.b=ca.color.b*D.b;Q.updateStyleString()}else Q.__styleString=ca.color.__styleString;ca=ha.scale.x*k;T=ha.scale.y*j;z.set(P.x-ca,P.y-T,P.x+ca,P.y+T);if(N.instersects(z)){ba=Q.__styleString;if(A!=ba)m.fillStyle=A=ba;m.save();m.translate(P.x,P.y);m.rotate(-ha.rotation);m.scale(ca,T);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function qa(P,ha,ca, +T){if(T.opacity!=0){a(T.opacity);b(T.blending);m.beginPath();m.moveTo(P.positionScreen.x,P.positionScreen.y);m.lineTo(ha.positionScreen.x,ha.positionScreen.y);m.closePath();if(T instanceof THREE.LineBasicMaterial){Q.__styleString=T.color.__styleString;P=T.linewidth;if(E!=P)m.lineWidth=E=P;P=Q.__styleString;if(x!=P)m.strokeStyle=x=P;m.stroke();z.inflate(T.linewidth*2)}}}function ra(P,ha,ca,T,ba,ja){if(ba.opacity!=0){a(ba.opacity);b(ba.blending);M=P.positionScreen.x;d=P.positionScreen.y;aa=ha.positionScreen.x; +O=ha.positionScreen.y;K=ca.positionScreen.x;X=ca.positionScreen.y;m.beginPath();m.moveTo(M,d);m.lineTo(aa,O);m.lineTo(K,X);m.lineTo(M,d);m.closePath();if(ba instanceof THREE.MeshBasicMaterial)if(ba.map)ba.map.image.loaded&&ba.map.mapping instanceof THREE.UVMapping&&wa(M,d,aa,O,K,X,ba.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);else if(ba.env_map){if(ba.env_map.image.loaded)if(ba.env_map.mapping instanceof THREE.SphericalReflectionMapping){P=ka.matrix;J.copy(T.vertexNormalsWorld[0]); +ia=(J.x*P.n11+J.y*P.n12+J.z*P.n13)*0.5+0.5;l=-(J.x*P.n21+J.y*P.n22+J.z*P.n23)*0.5+0.5;J.copy(T.vertexNormalsWorld[1]);y=(J.x*P.n11+J.y*P.n12+J.z*P.n13)*0.5+0.5;B=-(J.x*P.n21+J.y*P.n22+J.z*P.n23)*0.5+0.5;J.copy(T.vertexNormalsWorld[2]);o=(J.x*P.n11+J.y*P.n12+J.z*P.n13)*0.5+0.5;n=-(J.x*P.n21+J.y*P.n22+J.z*P.n23)*0.5+0.5;wa(M,d,aa,O,K,X,ba.env_map.image,ia,l,y,B,o,n)}}else ba.wireframe?Ha(ba.color.__styleString,ba.wireframe_linewidth):Ia(ba.color.__styleString);else if(ba instanceof THREE.MeshLambertMaterial){if(ba.map&& +!ba.wireframe){ba.map.mapping instanceof THREE.UVMapping&&wa(M,d,aa,O,K,X,ba.map.image,T.uvs[0].u,T.uvs[0].v,T.uvs[1].u,T.uvs[1].v,T.uvs[2].u,T.uvs[2].v);b(THREE.SubtractiveBlending)}if(I)if(!ba.wireframe&&ba.shading==THREE.SmoothShading&&T.vertexNormalsWorld.length==3){U.r=V.r=H.r=$.r;U.g=V.g=H.g=$.g;U.b=V.b=H.b=$.b;Ca(ja,T.v1.positionWorld,T.vertexNormalsWorld[0],U);Ca(ja,T.v2.positionWorld,T.vertexNormalsWorld[1],V);Ca(ja,T.v3.positionWorld,T.vertexNormalsWorld[2],H);Y.r=(V.r+H.r)*0.5;Y.g=(V.g+ +H.g)*0.5;Y.b=(V.b+H.b)*0.5;fa=ma(U,V,H,Y);wa(M,d,aa,O,K,X,fa,0,0,1,0,0,1)}else{D.r=$.r;D.g=$.g;D.b=$.b;Ca(ja,T.centroidWorld,T.normalWorld,D);Q.r=ba.color.r*D.r;Q.g=ba.color.g*D.g;Q.b=ba.color.b*D.b;Q.updateStyleString();ba.wireframe?Ha(Q.__styleString,ba.wireframe_linewidth):Ia(Q.__styleString)}else ba.wireframe?Ha(ba.color.__styleString,ba.wireframe_linewidth):Ia(ba.color.__styleString)}else if(ba instanceof THREE.MeshDepthMaterial){ea=ka.near;Z=ka.far;U.r=U.g=U.b=1-pa(P.positionScreen.z,ea,Z); +V.r=V.g=V.b=1-pa(ha.positionScreen.z,ea,Z);H.r=H.g=H.b=1-pa(ca.positionScreen.z,ea,Z);Y.r=(V.r+H.r)*0.5;Y.g=(V.g+H.g)*0.5;Y.b=(V.b+H.b)*0.5;fa=ma(U,V,H,Y);wa(M,d,aa,O,K,X,fa,0,0,1,0,0,1)}else if(ba instanceof THREE.MeshNormalMaterial){Q.r=Da(T.normalWorld.x);Q.g=Da(T.normalWorld.y);Q.b=Da(T.normalWorld.z);Q.updateStyleString();ba.wireframe?Ha(Q.__styleString,ba.wireframe_linewidth):Ia(Q.__styleString)}}}function Ha(P,ha){if(x!=P)m.strokeStyle=x=P;if(E!=ha)m.lineWidth=E=ha;m.stroke();z.inflate(ha* +2)}function Ia(P){if(A!=P)m.fillStyle=A=P;m.fill()}function wa(P,ha,ca,T,ba,ja,ua,za,Ba,Ka,Ga,La,Ra){var Ja,Ma;Ja=ua.width-1;Ma=ua.height-1;za*=Ja;Ba*=Ma;Ka*=Ja;Ga*=Ma;La*=Ja;Ra*=Ma;ca-=P;T-=ha;ba-=P;ja-=ha;Ka-=za;Ga-=Ba;La-=za;Ra-=Ba;Ja=Ka*Ra-La*Ga;if(Ja!=0){Ma=1/Ja;Ja=(Ra*ca-Ga*ba)*Ma;Ga=(Ra*T-Ga*ja)*Ma;ca=(Ka*ba-La*ca)*Ma;T=(Ka*ja-La*T)*Ma;P=P-Ja*za-ca*Ba;ha=ha-Ga*za-T*Ba;m.save();m.transform(Ja,Ga,ca,T,P,ha);m.clip();m.drawImage(ua,0,0);m.restore()}}function ma(P,ha,ca,T){var ba=~~(P.r*255),ja= +~~(P.g*255);P=~~(P.b*255);var ua=~~(ha.r*255),za=~~(ha.g*255);ha=~~(ha.b*255);var Ba=~~(ca.r*255),Ka=~~(ca.g*255);ca=~~(ca.b*255);var Ga=~~(T.r*255),La=~~(T.g*255);T=~~(T.b*255);S[0]=ba<0?0:ba>255?255:ba;S[1]=ja<0?0:ja>255?255:ja;S[2]=P<0?0:P>255?255:P;S[4]=ua<0?0:ua>255?255:ua;S[5]=za<0?0:za>255?255:za;S[6]=ha<0?0:ha>255?255:ha;S[8]=Ba<0?0:Ba>255?255:Ba;S[9]=Ka<0?0:Ka>255?255:Ka;S[10]=ca<0?0:ca>255?255:ca;S[12]=Ga<0?0:Ga>255?255:Ga;S[13]=La<0?0:La>255?255:La;S[14]=T<0?0:T>255?255:T;W.putImageData(la, +0,0);sa.drawImage(R,0,0);return ta}function pa(P,ha,ca){P=(P-ha)/(ca-ha);return P*P*(3-2*P)}function Da(P){P=(P+1)*0.5;return P<0?0:P>1?1:P}function xa(P,ha){var ca=ha.x-P.x,T=ha.y-P.y,ba=1/Math.sqrt(ca*ca+T*T);ca*=ba;T*=ba;ha.x+=ca;ha.y+=T;P.x-=ca;P.y-=T}var Oa,Aa,oa,Ea,Fa,Pa,Qa,Na;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=e.projectScene(ga,ka,this.sortElements);(I=ga.lights.length>0)&&na(ga);Oa=0;for(Aa=c.length;Oa0){y.r+=n.color.r*N;y.g+=n.color.g*N;y.b+=n.color.b*N}}else if(n instanceof THREE.PointLight){X.sub(n.position,l.centroidWorld);X.normalize();N=l.normalWorld.dot(X)*n.intensity;if(N>0){y.r+=n.color.r*N;y.g+=n.color.g*N;y.b+=n.color.b*N}}}}function b(ia,l,y,B,o,n){H=e(Y++);H.setAttribute("d","M "+ia.positionScreen.x+ +" "+ia.positionScreen.y+" L "+l.positionScreen.x+" "+l.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+"z");if(o instanceof THREE.MeshBasicMaterial)p.__styleString=o.color.__styleString;else if(o instanceof THREE.MeshLambertMaterial)if(F){M.r=d.r;M.g=d.g;M.b=d.b;a(n,B,M);p.r=o.color.r*M.r;p.g=o.color.g*M.g;p.b=o.color.b*M.b;p.updateStyleString()}else p.__styleString=o.color.__styleString;else if(o instanceof THREE.MeshDepthMaterial){K=1-o.__2near/(o.__farPlusNear-B.z*o.__farMinusNear); +p.setRGB(K,K,K)}else o instanceof THREE.MeshNormalMaterial&&p.setRGB(g(B.normalWorld.x),g(B.normalWorld.y),g(B.normalWorld.z));o.wireframe?H.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+o.wireframe_linewidth+"; stroke-opacity: "+o.opacity+"; stroke-linecap: "+o.wireframe_linecap+"; stroke-linejoin: "+o.wireframe_linejoin):H.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+o.opacity);k.appendChild(H)}function c(ia,l,y,B,o,n,N){H=e(Y++);H.setAttribute("d", +"M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+l.positionScreen.x+" "+l.positionScreen.y+" L "+y.positionScreen.x+","+y.positionScreen.y+" L "+B.positionScreen.x+","+B.positionScreen.y+"z");if(n instanceof THREE.MeshBasicMaterial)p.__styleString=n.color.__styleString;else if(n instanceof THREE.MeshLambertMaterial)if(F){M.r=d.r;M.g=d.g;M.b=d.b;a(N,o,M);p.r=n.color.r*M.r;p.g=n.color.g*M.g;p.b=n.color.b*M.b;p.updateStyleString()}else p.__styleString=n.color.__styleString;else if(n instanceof +THREE.MeshDepthMaterial){K=1-n.__2near/(n.__farPlusNear-o.z*n.__farMinusNear);p.setRGB(K,K,K)}else n instanceof THREE.MeshNormalMaterial&&p.setRGB(g(o.normalWorld.x),g(o.normalWorld.y),g(o.normalWorld.z));n.wireframe?H.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+n.wireframe_linewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframe_linecap+"; stroke-linejoin: "+n.wireframe_linejoin):H.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+ +n.opacity);k.appendChild(H)}function e(ia){if(Q[ia]==null){Q[ia]=document.createElementNS("http://www.w3.org/2000/svg","path");fa==0&&Q[ia].setAttribute("shape-rendering","crispEdges");return Q[ia]}return Q[ia]}function g(ia){return ia<0?Math.min((1+ia)*0.5,0.5):0.5+Math.min(ia*0.5,0.5)}var f=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,q,w,u,t,x,A,E=new THREE.Rectangle,v=new THREE.Rectangle,F=false,p=new THREE.Color(16777215),M=new THREE.Color(16777215), +d=new THREE.Color(0),aa=new THREE.Color(0),O=new THREE.Color(0),K,X=new THREE.Vector3,Q=[],U=[],V=[],H,Y,ea,Z,fa=1;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(ia){switch(ia){case "high":fa=1;break;case "low":fa=0}};this.setSize=function(ia,l){j=ia;m=l;q=j/2;w=m/2;k.setAttribute("viewBox",-q+" "+-w+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);E.set(-q,-w,q,w)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])}; +this.render=function(ia,l){var y,B,o,n,N,G,z,I;this.autoClear&&this.clear();f=h.projectScene(ia,l,this.sortElements);Z=ea=Y=0;if(F=ia.lights.length>0){z=ia.lights;d.setRGB(0,0,0);aa.setRGB(0,0,0);O.setRGB(0,0,0);y=0;for(B=z.length;y0){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLUVBuffer); +d.bufferData(d.ARRAY_BUFFER,Ha,da)}if(Fa&&L>0){d.bindBuffer(d.ARRAY_BUFFER,G.__webGLUV2Buffer);d.bufferData(d.ARRAY_BUFFER,Ia,da)}if(Ea){d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,G.__webGLFaceBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,Da,da);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,G.__webGLLineBuffer);d.bufferData(d.ELEMENT_ARRAY_BUFFER,xa,da)}}x(objlist,N,o,l,y,B)}n.__dirtyVertices=false;n.__dirtyElements=false;n.__dirtyUvs=false;n.__dirtyNormals=false;n.__dirtyTangents=false;n.__dirtyColors=false}else if(y instanceof +THREE.Line){if(!n.__webGLVertexBuffer){n.__webGLVertexBuffer=d.createBuffer();n.__webGLColorBuffer=d.createBuffer();o=n.vertices.length;n.__vertexArray=new Float32Array(o*3);n.__colorArray=new Float32Array(o*3);n.__webGLLineCount=o;n.__dirtyVertices=true;n.__dirtyColors=true}if(n.__dirtyVertices||n.__dirtyColors){o=d.DYNAMIC_DRAW;z=n.vertices;G=n.colors;$=z.length;da=G.length;L=n.__vertexArray;C=n.__colorArray;J=n.__dirtyColors;if(n.__dirtyVertices){for(I=0;I<$;I++){D=z[I].position;l=I*3;L[l]=D.x; +L[l+1]=D.y;L[l+2]=D.z}d.bindBuffer(d.ARRAY_BUFFER,n.__webGLVertexBuffer);d.bufferData(d.ARRAY_BUFFER,L,o)}if(J){for(I=0;I0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+N.maxDirLights,"#define MAX_POINT_LIGHTS "+N.maxPointLights,N.map?"#define USE_MAP":"",N.env_map?"#define USE_ENVMAP":"",N.light_map?"#define USE_LIGHTMAP":"",N.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n"); +d.attachShader(B,F("fragment",n+I));d.attachShader(B,F("vertex",N+y));d.linkProgram(B);d.getProgramParameter(B,d.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+d.getProgramParameter(B,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");B.uniforms={};B.attributes={};l.program=B;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(o in l.uniforms)B.push(o);o=l.program;I=0;for(y=B.length;I=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLColorBuffer);d.vertexAttribPointer(l.color,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.color)}if(l.normal>= 0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLNormalBuffer);d.vertexAttribPointer(l.normal,3,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.normal)}if(l.tangent>=0){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLTangentBuffer);d.vertexAttribPointer(l.tangent,4,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.tangent)}if(l.uv>=0)if(n.__webGLUVBuffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUVBuffer);d.vertexAttribPointer(l.uv,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv)}else d.disableVertexAttribArray(l.uv);if(l.uv2>= -0)if(n.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUV2Buffer);d.vertexAttribPointer(l.uv2,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv2)}else d.disableVertexAttribArray(l.uv2);if(F instanceof THREE.Mesh)if(u.wireframe){d.lineWidth(u.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);d.drawElements(d.LINES,n.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,n.__webGLFaceCount,d.UNSIGNED_SHORT, -0)}else if(F instanceof THREE.Line){F=F.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(u.linewidth);d.drawArrays(F,0,n.__webGLLineCount)}else F instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,0,n.__webGLParticleCount)};this.render=function(l,v,A,u){var n,F,L,G,D,C,R,ba=l.lights,ga=l.fog;v.autoUpdateMatrix&&v.updateMatrix();v.matrix.flattenToArray(J);v.projectionMatrix.flattenToArray(W);Y.multiply(v.projectionMatrix,v.matrix);f(Y);this.initWebGLObjects(l,v);H(A,u!==undefined?u:true); -this.autoClear&&this.clear();G=l.__webGLObjects.length;for(u=0;u=0;A--){u=l.__webGLObjects[A].object;v==u&&l.__webGLObjects.splice(A,1)}};this.setDepthTest=function(l){l?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST)};this.setFaceCulling=function(l,v){if(l){!v||v=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(l=="back")d.cullFace(d.BACK);else l=="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK);d.enable(d.CULL_FACE)}else d.disable(d.CULL_FACE)};this.supportsVertexTextures=function(){return d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)> +0)if(n.__webGLUV2Buffer){d.bindBuffer(d.ARRAY_BUFFER,n.__webGLUV2Buffer);d.vertexAttribPointer(l.uv2,2,d.FLOAT,false,0,0);d.enableVertexAttribArray(l.uv2)}else d.disableVertexAttribArray(l.uv2);if(N instanceof THREE.Mesh)if(o.wireframe){d.lineWidth(o.wireframe_linewidth);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);d.drawElements(d.LINES,n.__webGLLineCount,d.UNSIGNED_SHORT,0)}else{d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);d.drawElements(d.TRIANGLES,n.__webGLFaceCount,d.UNSIGNED_SHORT, +0)}else if(N instanceof THREE.Line){N=N.type==THREE.LineStrip?d.LINE_STRIP:d.LINES;d.lineWidth(o.linewidth);d.drawArrays(N,0,n.__webGLLineCount)}else N instanceof THREE.ParticleSystem&&d.drawArrays(d.POINTS,0,n.__webGLParticleCount)};this.render=function(l,y,B,o){var n,N,G,z,I,D,$,da=l.lights,C=l.fog;y.autoUpdateMatrix&&y.updateMatrix();y.matrix.flattenToArray(Y);y.projectionMatrix.flattenToArray(H);V.multiply(y.projectionMatrix,y.matrix);f(V);this.initWebGLObjects(l,y);v(B,o!==undefined?o:true); +this.autoClear&&this.clear();z=l.__webGLObjects.length;for(o=0;o=0;B--){o=l.__webGLObjects[B].object;y==o&&l.__webGLObjects.splice(B,1)}};this.setDepthTest=function(l){l?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST)};this.setFaceCulling=function(l,y){if(l){!y||y=="ccw"?d.frontFace(d.CCW):d.frontFace(d.CW);if(l=="back")d.cullFace(d.BACK);else l=="front"?d.cullFace(d.FRONT):d.cullFace(d.FRONT_AND_BACK);d.enable(d.CULL_FACE)}else d.disable(d.CULL_FACE)};this.supportsVertexTextures=function(){return d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)> 0}}; THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube env_map;\nuniform int combine;\n#endif", envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refraction_ratio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", @@ -231,17 +231,17 @@ THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=ne THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null}; THREE.Detector={canvas:!!document.createElement("canvas").getContext,webgl:window.Uint8Array!=undefined,workers:!!window.Worker,addGetWebGLMessage:function(a){var b=document.body,c="oldie";if(a){if(a.parent!==undefined)b=a.parent;if(a.id!==undefined)c=a.id}a=document.createElement("center");var e=document.createElement("div");e.innerHTML='Sorry, your browser doesn\'t support WebGL
\n
\nPlease try in\nChrome 9+ /\nFirefox 4+ /\nSafari OSX 10.6+';e.id= c;c=e.style;c.fontFamily="monospace";c.fontSize="13px";c.textAlign="center";c.background="#eee";c.color="#000";c.padding="1em";c.width="475px";c.margin="5em auto 0";a.appendChild(e);b.appendChild(a);return e}}; -var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,e=a.vertices.length,g=c?b.geometry:b,f=a.vertices,h=g.vertices,k=a.faces,j=g.faces,m=a.uvs;g=g.uvs;c&&b.autoUpdateMatrix&&b.updateMatrix();for(var p=0,x=h.length;p25)f=25;g=(f-1)*0.5;c=Array(f);for(b=e=0;b25)f=25;g=(f-1)*0.5;c=Array(f);for(b=e=0;b0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(x,k,t)))-1);m.push(p)}b.push(m)}var q,y,z;g=b.length;for(c=0;c0)for(e=0;e1){q=this.vertices[h].position.clone(); -y=this.vertices[j].position.clone();z=this.vertices[m].position.clone();q.normalize();y.normalize();z.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)]));this.uvs.push([p,x,H])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; +var Sphere=function(a,b,c){THREE.Geometry.call(this);var e,g=Math.PI,f=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c0||(q=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,k,u)))-1);m.push(q)}b.push(m)}var t,x,A;g=b.length;for(c=0;c0)for(e=0;e1){t=this.vertices[h].position.clone(); +x=this.vertices[j].position.clone();A=this.vertices[m].position.clone();t.normalize();x.normalize();A.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([q,w,E])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; var Torus=function(a,b,c,e){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){e=c/this.segmentsT*2*Math.PI;var g=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c= 1;c<=this.segmentsT;++c){e=(this.segmentsT+1)*b+c;g=(this.segmentsT+1)*b+c-1;var f=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(e,g,f,h));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; -var Icosahedron=function(a){function b(x,t,q){var y=Math.sqrt(x*x+t*t+q*q);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(x/y,t/y,q/y)))-1}function c(x,t,q,y){y.faces.push(new THREE.Face3(x,t,q))}function e(x,t){var q=g.vertices[x].position,y=g.vertices[t].position;return b((q.x+y.x)/2,(q.y+y.y)/2,(q.z+y.z)/2)}var g=this,f=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0, -1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,f);c(0,5,1,f);c(0,1,7,f);c(0,7,10,f);c(0,10,11,f);c(1,5,9,f);c(5,11,4,f);c(11,10,2,f);c(10,7,6,f);c(7,1,8,f);c(3,9,4,f);c(3,4,2,f);c(3,2,6,f);c(3,6,8,f);c(3,8,9,f);c(4,9,5,f);c(2,4,11,f);c(6,2,10,f);c(8,6,7,f);c(9,8,1,f);for(a=0;a=this.maxCount-3&&k(this)};this.begin= -function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(c){if(this.count!=0){for(var e=this.count*3;ethis.size-1)j=this.size-1;var t=Math.floor(m-k);if(t<1)t=1;m=Math.floor(m+k);if(m>this.size-1)m=this.size-1;var q=Math.floor(p-k);if(q<1)q=1;k=Math.floor(p+k); -if(k>this.size-1)k=this.size-1;var y,z,H,w,E,o;for(x=x;x0)this.field[H+y]+=w}}}};this.addPlaneX=function(c,e){var g,f,h,k,j,m=this.size,p=this.yd,x=this.zd,t=this.field,q=m*Math.sqrt(c/e);if(q>m)q=m;for(g=0;g0)for(f=0;fp)y=p;for(f=0;f0){j=f*x;for(g=0;gsize)dist=size;for(h=0;h0){j=zd*h;for(f=0;fthis.size-1)j=this.size-1;var u=Math.floor(m-k);if(u<1)u=1;m=Math.floor(m+k);if(m>this.size-1)m=this.size-1;var t=Math.floor(q-k);if(t<1)t=1;k=Math.floor(q+k); +if(k>this.size-1)k=this.size-1;var x,A,E,v,F,p;for(w=w;w0)this.field[E+x]+=v}}}};this.addPlaneX=function(c,e){var g,f,h,k,j,m=this.size,q=this.yd,w=this.zd,u=this.field,t=m*Math.sqrt(c/e);if(t>m)t=m;for(g=0;g0)for(f=0;fq)x=q;for(f=0;f0){j=f*w;for(g=0;gsize)dist=size;for(h=0;h0){j=zd*h;for(f=0;f>7)-127;I=(da&127)<<16|Q<<8|I;if(I==0&&ka==-127)return 0;return(1-2*(V>>7))*(1+I*Math.pow(2,-23))*Math.pow(2,ka)}function k(B,K){var I=p(B,K),Q=p(B,K+1),da=p(B,K+2);return(p(B,K+3)<<24)+(da<<16)+(Q<<8)+I}function j(B,K){var I=p(B,K);return(p(B,K+1)<<8)+I}function m(B,K){var I=p(B,K);return I>127?I-256:I}function p(B,K){return B.charCodeAt(K)&255}function x(B){var K,I,Q; -K=k(a,B);I=k(a,B+aa);Q=k(a,B+N);B=j(a,B+M);THREE.Loader.prototype.f3(w,K,I,Q,B)}function t(B){var K,I,Q,da,V,ka;K=k(a,B);I=k(a,B+aa);Q=k(a,B+N);da=j(a,B+M);V=k(a,B+U);ka=k(a,B+O);B=k(a,B+Y);THREE.Loader.prototype.f3n(w,d,K,I,Q,da,V,ka,B)}function q(B){var K,I,Q,da;K=k(a,B);I=k(a,B+W);Q=k(a,B+J);da=k(a,B+X);B=j(a,B+ha);THREE.Loader.prototype.f4(w,K,I,Q,da,B)}function y(B){var K,I,Q,da,V,ka,pa,ua;K=k(a,B);I=k(a,B+W);Q=k(a,B+J);da=k(a,B+X);V=j(a,B+ha);ka=k(a,B+Z);pa=k(a,B+ea);ua=k(a,B+l);B=k(a,B+v); -THREE.Loader.prototype.f4n(w,d,K,I,Q,da,V,ka,pa,ua,B)}function z(B){var K,I;K=k(a,B);I=k(a,B+A);B=k(a,B+u);THREE.Loader.prototype.uv3(w.uvs,P[K*2],P[K*2+1],P[I*2],P[I*2+1],P[B*2],P[B*2+1])}function H(B){var K,I,Q;K=k(a,B);I=k(a,B+n);Q=k(a,B+F);B=k(a,B+L);THREE.Loader.prototype.uv4(w.uvs,P[K*2],P[K*2+1],P[I*2],P[I*2+1],P[Q*2],P[Q*2+1],P[B*2],P[B*2+1])}var w=this,E=0,o,d=[],P=[],aa,N,M,U,O,Y,W,J,X,ha,Z,ea,l,v,A,u,n,F,L,G,D,C,R,ba,ga;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w, -e,f);o={signature:a.substr(E,8),header_bytes:p(a,E+8),vertex_coordinate_bytes:p(a,E+9),normal_coordinate_bytes:p(a,E+10),uv_coordinate_bytes:p(a,E+11),vertex_index_bytes:p(a,E+12),normal_index_bytes:p(a,E+13),uv_index_bytes:p(a,E+14),material_index_bytes:p(a,E+15),nvertices:k(a,E+16),nnormals:k(a,E+16+4),nuvs:k(a,E+16+8),ntri_flat:k(a,E+16+12),ntri_smooth:k(a,E+16+16),ntri_flat_uv:k(a,E+16+20),ntri_smooth_uv:k(a,E+16+24),nquad_flat:k(a,E+16+28),nquad_smooth:k(a,E+16+32),nquad_flat_uv:k(a,E+16+36), -nquad_smooth_uv:k(a,E+16+40)};E+=o.header_bytes;aa=o.vertex_index_bytes;N=o.vertex_index_bytes*2;M=o.vertex_index_bytes*3;U=o.vertex_index_bytes*3+o.material_index_bytes;O=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;Y=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;W=o.vertex_index_bytes;J=o.vertex_index_bytes*2;X=o.vertex_index_bytes*3;ha=o.vertex_index_bytes*4;Z=o.vertex_index_bytes*4+o.material_index_bytes;ea=o.vertex_index_bytes*4+o.material_index_bytes+ -o.normal_index_bytes;l=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;v=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;A=o.uv_index_bytes;u=o.uv_index_bytes*2;n=o.uv_index_bytes;F=o.uv_index_bytes*2;L=o.uv_index_bytes*3;f=o.vertex_index_bytes*3+o.material_index_bytes;ga=o.vertex_index_bytes*4+o.material_index_bytes;G=o.ntri_flat*f;D=o.ntri_smooth*(f+o.normal_index_bytes*3);C=o.ntri_flat_uv*(f+o.uv_index_bytes*3);R=o.ntri_smooth_uv*(f+o.normal_index_bytes* -3+o.uv_index_bytes*3);ba=o.nquad_flat*ga;f=o.nquad_smooth*(ga+o.normal_index_bytes*4);ga=o.nquad_flat_uv*(ga+o.uv_index_bytes*4);E+=function(B){var K,I,Q,da=o.vertex_coordinate_bytes*3,V=B+o.nvertices*da;for(B=B;B>7)-127;J=(W&127)<<16|R<<8|J;if(J==0&&S==-127)return 0;return(1-2*(la>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,S)}function k(C,L){var J=q(C,L),R=q(C,L+1),W=q(C,L+2);return(q(C,L+3)<<24)+(W<<16)+(R<<8)+J}function j(C,L){var J=q(C,L);return(q(C,L+1)<<8)+J}function m(C,L){var J=q(C,L);return J>127?J-256:J}function q(C,L){return C.charCodeAt(L)&255}function w(C){var L,J,R;L=k(a, +C);J=k(a,C+aa);R=k(a,C+O);C=j(a,C+K);THREE.Loader.prototype.f3(v,L,J,R,C)}function u(C){var L,J,R,W,la,S;L=k(a,C);J=k(a,C+aa);R=k(a,C+O);W=j(a,C+K);la=k(a,C+X);S=k(a,C+Q);C=k(a,C+U);THREE.Loader.prototype.f3n(v,M,L,J,R,W,la,S,C)}function t(C){var L,J,R,W;L=k(a,C);J=k(a,C+V);R=k(a,C+H);W=k(a,C+Y);C=j(a,C+ea);THREE.Loader.prototype.f4(v,L,J,R,W,C)}function x(C){var L,J,R,W,la,S,ta,sa;L=k(a,C);J=k(a,C+V);R=k(a,C+H);W=k(a,C+Y);la=j(a,C+ea);S=k(a,C+Z);ta=k(a,C+fa);sa=k(a,C+ia);C=k(a,C+l);THREE.Loader.prototype.f4n(v, +M,L,J,R,W,la,S,ta,sa,C)}function A(C){var L,J;L=k(a,C);J=k(a,C+y);C=k(a,C+B);THREE.Loader.prototype.uv3(v.uvs,d[L*2],d[L*2+1],d[J*2],d[J*2+1],d[C*2],d[C*2+1])}function E(C){var L,J,R;L=k(a,C);J=k(a,C+o);R=k(a,C+n);C=k(a,C+N);THREE.Loader.prototype.uv4(v.uvs,d[L*2],d[L*2+1],d[J*2],d[J*2+1],d[R*2],d[R*2+1],d[C*2],d[C*2+1])}var v=this,F=0,p,M=[],d=[],aa,O,K,X,Q,U,V,H,Y,ea,Z,fa,ia,l,y,B,o,n,N,G,z,I,D,$,da;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,e,f);p={signature:a.substr(F,8), +header_bytes:q(a,F+8),vertex_coordinate_bytes:q(a,F+9),normal_coordinate_bytes:q(a,F+10),uv_coordinate_bytes:q(a,F+11),vertex_index_bytes:q(a,F+12),normal_index_bytes:q(a,F+13),uv_index_bytes:q(a,F+14),material_index_bytes:q(a,F+15),nvertices:k(a,F+16),nnormals:k(a,F+16+4),nuvs:k(a,F+16+8),ntri_flat:k(a,F+16+12),ntri_smooth:k(a,F+16+16),ntri_flat_uv:k(a,F+16+20),ntri_smooth_uv:k(a,F+16+24),nquad_flat:k(a,F+16+28),nquad_smooth:k(a,F+16+32),nquad_flat_uv:k(a,F+16+36),nquad_smooth_uv:k(a,F+16+40)};F+= +p.header_bytes;aa=p.vertex_index_bytes;O=p.vertex_index_bytes*2;K=p.vertex_index_bytes*3;X=p.vertex_index_bytes*3+p.material_index_bytes;Q=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes;U=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*2;V=p.vertex_index_bytes;H=p.vertex_index_bytes*2;Y=p.vertex_index_bytes*3;ea=p.vertex_index_bytes*4;Z=p.vertex_index_bytes*4+p.material_index_bytes;fa=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes;ia=p.vertex_index_bytes* +4+p.material_index_bytes+p.normal_index_bytes*2;l=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*3;y=p.uv_index_bytes;B=p.uv_index_bytes*2;o=p.uv_index_bytes;n=p.uv_index_bytes*2;N=p.uv_index_bytes*3;f=p.vertex_index_bytes*3+p.material_index_bytes;da=p.vertex_index_bytes*4+p.material_index_bytes;G=p.ntri_flat*f;z=p.ntri_smooth*(f+p.normal_index_bytes*3);I=p.ntri_flat_uv*(f+p.uv_index_bytes*3);D=p.ntri_smooth_uv*(f+p.normal_index_bytes*3+p.uv_index_bytes*3);$=p.nquad_flat*da;f= +p.nquad_smooth*(da+p.normal_index_bytes*4);da=p.nquad_flat_uv*(da+p.uv_index_bytes*4);F+=function(C){var L,J,R,W=p.vertex_coordinate_bytes*3,la=C+p.nvertices*W;for(C=C;C this.data.length ) { + + while( currentTime > this.data.length ) + currentTime -= this.data.length; + + this.startTime = new Date().getTime() * 0.001 - currentTime; + currentTime = new Date().getTime() * 0.001 - this.startTime; + } + + frame = Math.min( parseInt( currentTime * this.data.fps ), parseInt( this.data.length * this.data.fps )); + + + // update + + for( var h = 0, hl = this.hierarchy.length; h < hl; h++ ) + { + object = this.hierarchy[ h ]; + + if( JIThierarchy[ h ][ frame ] !== undefined ) { + + object.skinMatrix = JIThierarchy[ h ][ frame ]; + object.autoUpdateMatrix = false; + object.matrixNeedsToUpdate = false; + this.root.boneMatrices[ h ] = object.skinMatrix.flatten32; + } + else { + + for( var t = 0; t < 3; t++ ) { + + // get keys + + var type = types[ t ]; + var prevKey = object.prevKey[ type ]; + var nextKey = object.nextKey[ type ]; + + // switch keys? + + if( nextKey.time < unloopedCurrentTime ) { + + // did we loop? + + if( currentTime < unloopedCurrentTime ) { + + if( this.loop ) { + + prevKey = this.data.hierarchy[ h ].keys[ 0 ]; + nextKey = this.getNextKeyWith( type, h, 1 ); + } + else { + + this.stop(); + return; + } + } + else { + + do { + + prevKey = nextKey; + nextKey = this.getNextKeyWith( type, h, nextKey.index + 1 ); + } + while( nextKey.time < currentTime ) + } + + object.prevKey[ type ] = prevKey; + object.nextKey[ type ] = nextKey; + } + + + // interpolate rot (quaternion slerp) + + object.autoUpdateMatrix = true; + object.matrixNeedsToUpdate = true; + + scale = ( currentTime - prevKey.time ) / ( nextKey.time - prevKey.time ); + prevXYZ = prevKey[ type ]; + nextXYZ = nextKey[ type ]; + + if( type === "rot" ) { + + if( scale < 0 || scale > 1 ) + console.log( "Scale out of bounds:" + scale ); + + THREE.Quaternion.slerp( prevXYZ, nextXYZ, object.quaternion, scale ); + } + + // lerp pos/scl + + else { + + vector = type === "pos" ? object.position : object.scale; + vector.x = prevXYZ[ 0 ] + ( nextXYZ[ 0 ] - prevXYZ[ 0 ] ) * scale; + vector.y = prevXYZ[ 1 ] + ( nextXYZ[ 1 ] - prevXYZ[ 1 ] ) * scale; + vector.z = prevXYZ[ 2 ] + ( nextXYZ[ 2 ] - prevXYZ[ 2 ] ) * scale; + } + } + } + } + + + // update JIT? + + if( JIThierarchy[ 0 ][ frame ] === undefined ) { + + console.log(this.hierarchy); + + this.hierarchy[ 0 ].update( undefined, true ); + + for( var h = 0; h < this.hierarchy.length; h++ ) + JIThierarchy[ h ][ frame ] = this.hierarchy[ h ].skinMatrix.clone(); + } + +}; + + + +/* + * Update Object + */ + +THREE.Animation.prototype.updateObject = function( h, currentTime, unloopedCurrentTime ) { + + +} + + + + +THREE.Animation.prototype.getNextKeyWith = function( type, h, key ) { + + var keys = this.data.hierarchy[ h ].keys; + + for( ; key < keys.length; key++ ) { + + if( keys[ key ][ type ] !== undefined ) + return keys[ key ]; + } + + return this.data.hierarchy[ h ].keys[ 0 ]; +} + + + + + + + + + + + + + + diff --git a/src/animation/AnimationHandler.js b/src/animation/AnimationHandler.js new file mode 100644 index 00000000..b7cbca8c --- /dev/null +++ b/src/animation/AnimationHandler.js @@ -0,0 +1,97 @@ +/** + * @author mikael emtinger / http://gomo.se/ + */ + +THREE.AnimationHandler = (function() { + + var playing = []; + var that = {}; + + + //--- update --- + + that.update = function( time ) { + + for( var i = 0; i < playing.length; i++ ) + playing[ i ].update( time ); + + }; + + + //--- add --- + + that.add = function( animation ) { + + if( playing.indexOf( animation ) === -1 ) + playing.push( animation ); + + }; + + + //--- remove --- + + that.remove = function( animation ) { + + var index = playing.indexOf( animation ); + + if( index !== -1 ) + playing.splice( childIndex, 1 ); + + }; + + + //--- init data --- + + that.initData = function( data ) { + + if( data.initialized === true ) + return; + + // loop through all keys + + for( var h = 0; h < data.hierarchy.length; h++ ) { + + for( var k = 0; k < data.hierarchy[ h ].keys.length; k++ ) { + + // remove minus times + + if( data.hierarchy[ h ].keys[ k ].time < 0 ) + data.hierarchy[ h ].keys[ k ].time = 0; + + + // set index + + data.hierarchy[ h ].keys[ k ].index = k; + + + // create quaternions + + if( data.hierarchy[ h ].keys[ k ].rot !== undefined && + !(data.hierarchy[ h ].keys[ k ].rot instanceof THREE.Quaternion )) { + + var quat = data.hierarchy[ h ].keys[ k ].rot; + data.hierarchy[ h ].keys[ k ].rot = new THREE.Quaternion( quat[0], quat[1], quat[2], quat[3] ); + } + } + } + + + // JIT + + var lengthInFrames = parseInt( data.length * data.fps, 10 ); + + data.JIT = {}; + data.JIT.hierarchy = []; + + for( var h = 0; h < data.hierarchy.length; h++ ) + data.JIT.hierarchy.push( new Array( lengthInFrames )); + + + // done + + data.initialized = true; + + }; + + return that; +}()); diff --git a/src/cameras/Camera.js b/src/cameras/Camera.js index 698e1d8f..76c59d72 100644 --- a/src/cameras/Camera.js +++ b/src/cameras/Camera.js @@ -1,73 +1,168 @@ /** * @author mr.doob / http://mrdoob.com/ + * @author mikael emtinger / http://gomo.se/ */ -THREE.Camera = function ( fov, aspect, near, far ) { +THREE.Camera = function( FOV, aspect, zNear, zFar, renderer, target ) { + + // call super + + THREE.Object3D.call( this ); + - this.fov = fov; - this.aspect = aspect; - this.near = near; - this.far = far; + // set arguments + + this.FOV = FOV || 50; + this.aspect = aspect || 1.0; + this.zNear = zNear || 0.1; + this.zFar = zFar || 2000; + this.screenCenterX = 0; + this.screenCenterY = 0; + this.target = target || new THREE.Object3D(); + this.useTarget = true; + this.up = new THREE.Vector3( 0, 1, 0 ); - this.position = new THREE.Vector3(); - this.target = { position: new THREE.Vector3() }; - - this.autoUpdateMatrix = true; + // init + + this.inverseMatrix = new THREE.Matrix4(); this.projectionMatrix = null; - this.matrix = new THREE.Matrix4(); - - this.up = new THREE.Vector3( 0, 1, 0 ); - - this.tmpVec = new THREE.Vector3(); - - this.translateX = function ( amount ) { - - this.tmpVec.sub( this.target.position, this.position ).normalize().multiplyScalar( amount ); - this.tmpVec.crossSelf( this.up ); - - this.position.addSelf( this.tmpVec ); - this.target.position.addSelf( this.tmpVec ); - - }; - - /* TODO - this.translateY = function ( amount ) { - - }; - */ - - this.translateZ = function ( amount ) { - - this.tmpVec.sub( this.target.position, this.position ).normalize().multiplyScalar( amount ); - - this.position.subSelf( this.tmpVec ); - this.target.position.subSelf( this.tmpVec ); - - }; - - this.updateMatrix = function () { - - this.matrix.lookAt( this.position, this.target.position, this.up ); - - }; - - this.updateProjectionMatrix = function () { - - this.projectionMatrix = THREE.Matrix4.makePerspective( this.fov, this.aspect, this.near, this.far ); - - }; this.updateProjectionMatrix(); + +} -}; +THREE.Camera.prototype = new THREE.Object3D(); +THREE.Camera.prototype.constructor = THREE.Camera; +THREE.Camera.prototype.supr = THREE.Object3D.prototype; -THREE.Camera.prototype = { +/* + * Update projection matrix + * + * TODO: make it work also for ortho camera +*/ - toString: function () { +THREE.Camera.prototype.updateProjectionMatrix = function() { + + this.projectionMatrix = THREE.Matrix4.makePerspective( this.FOV, this.aspect, this.zNear, this.zFar ); - return 'THREE.Camera ( ' + this.position + ', ' + this.target.position + ' )'; +} + + +/* + * Update + */ + +THREE.Camera.prototype.update = function( parentGlobalMatrix, forceUpdate, scene, camera ) { + + if( this.useTarget ) { + + // local + + this.localMatrix.lookAt( this.position, this.target.position, this.up ); + + + // global + + if( parentGlobalMatrix ) + this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); + else + this.globalMatrix.copy( this.localMatrix ); + + THREE.Matrix4.makeInvert( this.globalMatrix, this.inverseMatrix ); + + forceUpdate = true; + + } else { + + if( this.autoUpdateMatrix ) + forceUpdate |= this.updateMatrix(); + + if( forceUpdate || this.matrixNeedsToUpdate ) { + + if( parentGlobalMatrix ) + this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); + else + this.globalMatrix.copy( this.localMatrix ); + + this.matrixNeedsToUpdate = false; + forceUpdate = true; + + THREE.Matrix4.makeInvert( this.globalMatrix, this.inverseMatrix ); + + } } + + // update children -}; + for( var i = 0; i < this.children.length; i++ ) + this.children[ i ].update( this.globalMatrix, forceUpdate, camera, renderer ); + +} + + +/* + * FrustumContains + * Checks object against projected image (as opposed to ordinary frustum check) + * + * TODO: make it work also for ortho camera + */ + +THREE.Camera.prototype.frustumContains = function( object3D ) { + + // object pos + + var vx0 = object3D.globalMatrix.n14, + vy0 = object3D.globalMatrix.n24, + vz0 = object3D.globalMatrix.n34; + + + // check z + + var inverse = this.inverseMatrix; + var radius = object3D.boundRadius * object3D.boundRadiusScale; + var vz1 = ( inverse.n31 * vx0 + inverse.n32 * vy0 + inverse.n33 * vz0 + inverse.n34 ); + + if( vz1 - radius > -this.zNear ) + return false; + + if( vz1 + radius < -this.zFar ) + return false; + + + // check x + + vz1 -= radius; + + var perspective = this.projectionMatrix; + var ooZ = 1 / ( perspective.n43 * vz1 ); + var ooZscreenCenterX = ooZ * this.screenCenterX; + var vx1 = ( inverse.n11 * vx0 + inverse.n12 * vy0 + inverse.n13 * vz0 + inverse.n14 ) * perspective.n11 * ooZscreenCenterX; + radius = perspective.n11 * radius * ooZscreenCenterX; + + if( vx1 + radius < -this.screenCenterX ) + return false; + + if( vx1 - radius > this.screenCenterX ) + return false; + + + // check y + + var vy1 = ( inverse.n21 * vx0 + inverse.n22 * vy0 + inverse.n23 * vz0 + inverse.n24 ) * perspective.n22 * ooZ * this.screenCenterY; + + if( vy1 + radius < -this.screenCenterY ) + return false; + + if( vy1 - radius > this.screenCenterY ) + return false; + + + // inside + + object3D.screenPosition.set( vx1, vy1, vz1, radius ); + + return true; + +} diff --git a/src/core/Geometry.js b/src/core/Geometry.js index 39a8b96a..eafbb341 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -2,15 +2,21 @@ * @author mr.doob / http://mrdoob.com/ * @author kile / http://kile.stravaganza.org/ * @author alteredq / http://alteredqualia.com/ + * @author mikael emtinger / http://gomo.se/ */ THREE.Geometry = function () { + this.id = "Geometry" + THREE.GeometryIdCounter++; + this.vertices = []; this.faces = []; this.uvs = []; this.uvs2 = []; this.colors = []; + + this.skinWeights = []; + this.skinIndices = []; this.boundingBox = null; this.boundingSphere = null; @@ -467,3 +473,5 @@ THREE.Geometry.prototype = { } }; + +THREE.GeometryIdCounter = 0; diff --git a/src/core/Matrix4.js b/src/core/Matrix4.js index 137a15f4..dff62376 100644 --- a/src/core/Matrix4.js +++ b/src/core/Matrix4.js @@ -4,6 +4,8 @@ * @author philogb / http://blog.thejit.org/ * @author jordi_ros / http://plattsoft.com * @author D1plo1d / http://github.com/D1plo1d + * @author alteredq / http://alteredqualia.com/ + * @author mikael emtinger / http://gomo.se/ */ THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) { @@ -83,6 +85,15 @@ THREE.Matrix4.prototype = { }, + multiplyVector3OnlyZ: function( v ) { + + var vx = v.x, vy = v.y, vz = v.z, + d = 1 / ( this.n41 * vx + this.n42 * vy + this.n43 * vz + this.n44 ); + + return ( this.n31 * vx + this.n32 * vy + this.n33 * vz + this.n34 ) * d; + + }, + multiplyVector4: function ( v ) { var vx = v.x, vy = v.y, vz = v.z, vw = v.w; @@ -458,6 +469,92 @@ THREE.Matrix4.prototype = { }, + setPosition: function( vec3 ) { + + this.n14 = vec3.x; + this.n24 = vec3.y; + this.n34 = vec3.z; + + return this; + + }, + + setRotationFromEuler: function( vec3 ) { + + //var c = Math.PI / 180; + var x = vec3.x,// * c; + y = vec3.y,// * c; + z = vec3.z,// * c; + + ch = Math.cos( y ), + sh = Math.sin( y ), + ca = Math.cos( -z ), + sa = Math.sin( -z ), + cb = Math.cos( x ), + sb = Math.sin( x ), + + chsa = ch * sa, + shsa = sh * sa; + + this.n11 = ch * ca; + this.n12 = sh * sb - chsa * cb; + this.n13 = chsa * sb + sh * cb; + this.n21 = sa; + this.n22 = ca * cb; + this.n23 = - ca * sb; + this.n31 = - sh * ca; + this.n32 = shsa * cb + ch * sb; + this.n33 = - shsa * sb + ch * cb; + + }, + + setRotationFromQuaternion: function( quat ) { + + var x = quat.x, y = quat.y, z = quat.z, w = quat.w, + + x2 = x + x, + y2 = y + y, + z2 = z + z, + + xx = x * x2, + xy = x * y2, + xz = x * z2, + + yy = y * y2, + yz = y * z2, + zz = z * z2, + + wx = w * x2, + wy = w * y2, + wz = w * z2; + + this.n11 = 1 - ( yy + zz ); + this.n12 = xy - wz; + this.n13 = xz + wy; + + this.n21 = xy + wz; + this.n22 = 1 - ( xx + zz ); + this.n23 = yz - wx; + + this.n31 = xz - wy; + this.n32 = yz + wx; + this.n33 = 1 - ( xx + yy ); + + }, + + scale: function( vec3 ) { + + var x = vec3.x; + var y = vec3.y; + var z = vec3.z; + + this.n11 *= x; this.n12 *= x; this.n13 *= x; + this.n21 *= y; this.n22 *= y; this.n23 *= y; + this.n31 *= z; this.n32 *= z; this.n33 *= z; + + return this; + }, + toString: function() { return "| " + this.n11 + " " + this.n12 + " " + this.n13 + " " + this.n14 + " |\n" + diff --git a/src/core/Quaternion.js b/src/core/Quaternion.js new file mode 100644 index 00000000..06de3a36 --- /dev/null +++ b/src/core/Quaternion.js @@ -0,0 +1,315 @@ +/* + * @author mikael emtinger / http://gomo.se/ + */ + +THREE.Quaternion = function( _x, _y, _z, _w ) { + + this.x = _x || 0; + this.y = _y || 0; + this.z = _z || 0; + this.w = _w !== undefined ? _w : 1; + + this.api = { + + isDirty: false, + that: this, + + get x() { return this.that.x; }, + get y() { return this.that.y; }, + get z() { return this.that.z; }, + get w() { return this.that.w; }, + + set x( value ) { this.that.x = value; this.isDirty = true; }, + set y( value ) { this.that.y = value; this.isDirty = true; }, + set z( value ) { this.that.z = value; this.isDirty = true; }, + set w( value ) { this.that.w = value; this.isDirty = true; }, + }; + + this.api.__proto__ = THREE.Quaternion.prototype; + + return this.api; + +}; + + +THREE.Quaternion.prototype.set = function( x, y, z, w ) { + + var quat = this.that; + quat.x = x; + quat.y = y; + quat.z = z; + quat.w = w; + + this.isDirty = true; + return this; + +}; + + +THREE.Quaternion.prototype.setFromEuler = function( vec3 ) { + + var c = 0.5 * Math.PI / 360, // 0.5 is an optimization + x = vec3.x * c, + y = vec3.y * c, + z = vec3.z * c, + + c1 = Math.cos( y ), + s1 = Math.sin( y ), + c2 = Math.cos( -z ), + s2 = Math.sin( -z ), + c3 = Math.cos( x ), + s3 = Math.sin( x ), + c1c2 = c1 * c2, + s1s2 = s1 * s2, + + quat = this.that; + + quat.w = c1c2 * c3 - s1s2 * s3; + quat.x = c1c2 * s3 + s1s2 * c3; + quat.y = s1 * c2 * c3 + c1 * s2 * s3; + quat.z = c1 * s2 * c3 - s1 * c2 * s3; + + this.isDirty = true; + return this; + +}; + + +THREE.Quaternion.prototype.calculateW = function() { + + var quat = this.that, + x = quat.x, + y = quat.y, + z = quat.z; + + quat.w = -Math.sqrt( Math.abs( 1.0 - x*x - y*y - z*z )); + + this.isDirty = true; + return this; + +}; + + +THREE.Quaternion.prototype.inverse = function() { + + var quat = this.that; + quat.x *= -1; + quat.y *= -1; + quat.z *= -1; + + this.isDirty = true; + return this; + +}; + + +THREE.Quaternion.prototype.length = function() { + + var quat = this.that; + + return Math.sqrt( quat.x * quat.x + quat.y * quat.y + quat.z * quat.z + quat.w * quat.w ); + +}; + + +THREE.Quaternion.prototype.normalize = function() { + + var quat = this.that, + x = quat.x, + y = quat.y, + z = quat.z, + w = quat.w; + + var len = Math.sqrt( x*x + y*y + z*z + w*w ); + + if ( len == 0 ) { + + quat.x = 0; + quat.y = 0; + quat.z = 0; + quat.w = 0; + + this.isDirty = true; + return this; + + } + + len = 1 / len; + + quat.x = x * len; + quat.y = y * len; + quat.z = z * len; + quat.w = w * len; + + this.isDirty = true; + return this; + +}; + + +THREE.Quaternion.prototype.multiplySelf = function( quat2 ) { + + var quat = this.that; + + qax = quat.x, qay = quat.y, qaz = quat.z, qaw = quat.w, + qbx = quat2.x, qby = quat2.y, qbz = quat2.z, qbw = quat2.w; + + quat.x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby; + quat.y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz; + quat.z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx; + quat.w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz; + + this.isDirty = true; + return this; + +}; + + +THREE.Quaternion.prototype.multiplyVector3 = function( vec, dest ) { + + if( !dest ) { dest = vec; } + + var quat = this.that, + x = vec.x, y = vec.y, z = vec.z, + qx = quat.x, qy = quat.y, qz = quat.z, qw = quat.w; + + // calculate quat * vec + + var ix = qw * x + qy * z - qz * y, + iy = qw * y + qz * x - qx * z, + iz = qw * z + qx * y - qy * x, + iw = -qx * x - qy * y - qz * z; + + // calculate result * inverse quat + + dest.x = ix * qw + iw * -qx + iy * -qz - iz * -qy; + dest.y = iy * qw + iw * -qy + iz * -qx - ix * -qz; + dest.z = iz * qw + iw * -qz + ix * -qy - iy * -qx; + + return dest; + +}; + + +THREE.Quaternion.prototype.toMatrix3 = function( matrix3 ) { + +/* todo: create a proper Matrix3 first + + var x = quat[0], y = quat[1], z = quat[2], w = quat[3]; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x*x2; + var xy = x*y2; + var xz = x*z2; + + var yy = y*y2; + var yz = y*z2; + var zz = z*z2; + + var wx = w*x2; + var wy = w*y2; + var wz = w*z2; + + dest[0] = 1 - (yy + zz); + dest[1] = xy - wz; + dest[2] = xz + wy; + + dest[3] = xy + wz; + dest[4] = 1 - (xx + zz); + dest[5] = yz - wx; + + dest[6] = xz - wy; + dest[7] = yz + wx; + dest[8] = 1 - (xx + yy); + + return dest;*/ +}; + +THREE.Quaternion.prototype.toMatrix4 = function( matrix4 ) { + +/* todo: this is implemented in Matrix4.setFromQuaternion + + var x = quat[0], y = quat[1], z = quat[2], w = quat[3]; + + var x2 = x + x; + var y2 = y + y; + var z2 = z + z; + + var xx = x*x2; + var xy = x*y2; + var xz = x*z2; + + var yy = y*y2; + var yz = y*z2; + var zz = z*z2; + + var wx = w*x2; + var wy = w*y2; + var wz = w*z2; + + dest[0] = 1 - (yy + zz); + dest[1] = xy - wz; + dest[2] = xz + wy; + dest[3] = 0; + + dest[4] = xy + wz; + dest[5] = 1 - (xx + zz); + dest[6] = yz - wx; + dest[7] = 0; + + dest[8] = xz - wy; + dest[9] = yz + wx; + dest[10] = 1 - (xx + yy); + dest[11] = 0; + + dest[12] = 0; + dest[13] = 0; + dest[14] = 0; + dest[15] = 1; + + */ +}; + +THREE.Quaternion.slerp = function( qa, qb, qm, t ) { + + + var cosHalfTheta = qa.w * qb.w + qa.x * qb.x + qa.y * qb.y + qa.z * qb.z; + + if( Math.abs( cosHalfTheta ) >= 1.0) { + + qm.w = qa.w; qm.x = qa.x; qm.y = qa.y; qm.z = qa.z; + return qm; + + } + + var halfTheta = Math.acos( cosHalfTheta ), + sinHalfTheta = Math.sqrt( 1.0 - cosHalfTheta * cosHalfTheta ); + + if( Math.abs( sinHalfTheta ) < 0.001 ) { + + qm.w = 0.5 * ( qa.w + qb.w ); + qm.x = 0.5 * ( qa.x + qb.x ); + qm.y = 0.5 * ( qa.y + qb.y ); + qm.z = 0.5 * ( qa.z + qb.z ); + + return qm; + + } + + var ratioA = Math.sin( (1 - t) * halfTheta ) / sinHalfTheta, + ratioB = Math.sin( t * halfTheta ) / sinHalfTheta; + + qm.w = ( qa.w * ratioA + qb.w * ratioB ); + qm.x = ( qa.x * ratioA + qb.x * ratioB ); + qm.y = ( qa.y * ratioA + qb.y * ratioB ); + qm.z = ( qa.z * ratioA + qb.z * ratioB ); + + return qm; + +}; + + + diff --git a/src/core/Vector3.js b/src/core/Vector3.js index 68461aab..65eecad5 100644 --- a/src/core/Vector3.js +++ b/src/core/Vector3.js @@ -2,208 +2,278 @@ * @author mr.doob / http://mrdoob.com/ * @author kile / http://kile.stravaganza.org/ * @author philogb / http://blog.thejit.org/ + * @author mikael emtinger / http://gomo.se/ */ -THREE.Vector3 = function ( x, y, z ) { +THREE.Vector3 = function ( _x, _y, _z ) { - this.x = x || 0; - this.y = y || 0; - this.z = z || 0; + this.x = _x || 0; + this.y = _y || 0; + this.z = _z || 0; + + this.api = { + + isDirty: false, + that: this, + + get x() { return this.that.x; }, + get y() { return this.that.y; }, + get z() { return this.that.z; }, + + set x( value ) { this.that.x = value; this.isDirty = true; }, + set y( value ) { this.that.y = value; this.isDirty = true; }, + set z( value ) { this.that.z = value; this.isDirty = true; }, + }; + + this.api.__proto__ = THREE.Vector3.prototype; + + return this.api; }; + THREE.Vector3.prototype = { set: function ( x, y, z ) { - this.x = x; - this.y = y; - this.z = z; + var vec = this.that; + vec.x = x; + vec.y = y; + vec.z = z; + this.isDirty = true; return this; }, copy: function ( v ) { - this.x = v.x; - this.y = v.y; - this.z = v.z; + var vec = this.that; + vec.x = v.x; + vec.y = v.y; + vec.z = v.z; + this.isDirty = true; return this; }, + add: function ( a, b ) { - this.x = a.x + b.x; - this.y = a.y + b.y; - this.z = a.z + b.z; + var vec = this.that; + vec.x = a.x + b.x; + vec.y = a.y + b.y; + vec.z = a.z + b.z; + this.isDirty = true; return this; }, + addSelf: function ( v ) { - this.x += v.x; - this.y += v.y; - this.z += v.z; + var vec = this.that; + vec.x += v.x; + vec.y += v.y; + vec.z += v.z; + this.isDirty = true; return this; }, + addScalar: function ( s ) { - this.x += s; - this.y += s; - this.z += s; + var vec = this.that; + vec.x += s; + vec.y += s; + vec.z += s; + this.isDirty = true; return this; }, + sub: function( a, b ) { - this.x = a.x - b.x; - this.y = a.y - b.y; - this.z = a.z - b.z; + var vec = this.that; + vec.x = a.x - b.x; + vec.y = a.y - b.y; + vec.z = a.z - b.z; + this.isDirty = true; return this; }, + subSelf: function ( v ) { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; + var vec = this.that; + vec.x -= v.x; + vec.y -= v.y; + vec.z -= v.z; + this.isDirty = true; 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; + var vec = this.that; + vec.x = a.y * b.z - a.z * b.y; + vec.y = a.z * b.x - a.x * b.z; + vec.z = a.x * b.y - a.y * b.x; + this.isDirty = true; return this; }, crossSelf: function ( v ) { - var tx = this.x, ty = this.y, tz = this.z; + var vec = this.that; + var tx = vec.x, ty = vec.y, tz = vec.z; - this.x = ty * v.z - tz * v.y; - this.y = tz * v.x - tx * v.z; - this.z = tx * v.y - ty * v.x; + vec.x = ty * v.z - tz * v.y; + vec.y = tz * v.x - tx * v.z; + vec.z = tx * v.y - ty * v.x; + this.isDirty = true; return this; }, multiply: function ( a, b ) { - this.x = a.x * b.x; - this.y = a.y * b.y; - this.z = a.z * b.z; + var vec = this.that; + vec.x = a.x * b.x; + vec.y = a.y * b.y; + vec.z = a.z * b.z; + this.isDirty = true; return this; }, multiplySelf: function ( v ) { - this.x *= v.x; - this.y *= v.y; - this.z *= v.z; + var vec = this.that; + vec.x *= v.x; + vec.y *= v.y; + vec.z *= v.z; + this.isDirty = true; return this; }, multiplyScalar: function ( s ) { - this.x *= s; - this.y *= s; - this.z *= s; + var vec = this.that; + vec.x *= s; + vec.y *= s; + vec.z *= s; + this.isDirty = true; return this; }, divideSelf: function ( v ) { - this.x /= v.x; - this.y /= v.y; - this.z /= v.z; + var vec = this.that; + vec.x /= v.x; + vec.y /= v.y; + vec.z /= v.z; + this.isDirty = true; return this; }, divideScalar: function ( s ) { - this.x /= s; - this.y /= s; - this.z /= s; + var vec = this.that; + vec.x /= s; + vec.y /= s; + vec.z /= s; + this.isDirty = true; return this; - }, dot: function ( v ) { - return this.x * v.x + this.y * v.y + this.z * v.z; + var vec = this.that; + return vec.x * v.x + vec.y * v.y + vec.z * v.z; }, distanceTo: function ( v ) { - var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z; + var vec = this.that; + var dx = vec.x - v.x, dy = vec.y - v.y, dz = vec.z - v.z; return Math.sqrt( dx * dx + dy * dy + dz * dz ); }, distanceToSquared: function ( v ) { - var dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z; + var vec = this.that; + var dx = vec.x - v.x, dy = vec.y - v.y, dz = vec.z - v.z; return dx * dx + dy * dy + dz * dz; }, length: function () { - return Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z ); + var vec = this.that; + return Math.sqrt( vec.x * vec.x + vec.y * vec.y + vec.z * vec.z ); }, lengthSq: function () { - return this.x * this.x + this.y * this.y + this.z * this.z; + var vec = this.that; + return vec.x * vec.x + vec.y * vec.y + vec.z * vec.z; }, + lengthManhattan: function () { + + var vec = this.that; + return vec.x + vec.y + vec.z; + + }, + + negate: function () { - this.x = - this.x; - this.y = - this.y; - this.z = - this.z; + var vec = this.that; + vec.x = - this.x; + vec.y = - this.y; + vec.z = - this.z; + this.isDirty = true; return this; }, normalize: function () { - var length = Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z ); + var vec = this.that; + var length = Math.sqrt( vec.x * vec.x + vec.y * vec.y + vec.z * vec.z ); length > 0 ? this.multiplyScalar( 1 / length ) : this.set( 0, 0, 0 ); + this.isDirty = true; return this; }, @@ -217,13 +287,16 @@ THREE.Vector3.prototype = { isZero: function () { var almostZero = 0.0001; - return ( Math.abs( this.x ) < almostZero ) && ( Math.abs( this.y ) < almostZero ) && ( Math.abs( this.z ) < almostZero ); + var vec = this.that; + + return ( Math.abs( vec.x ) < almostZero ) && ( Math.abs( vec.y ) < almostZero ) && ( Math.abs( vec.z ) < almostZero ); }, clone: function () { - return new THREE.Vector3( this.x, this.y, this.z ); + var vec = this.that; + return new THREE.Vector3( vec.x, vec.y, vec.z ); }, diff --git a/src/core/Vector4.js b/src/core/Vector4.js index 863f220f..7eaf0e3d 100644 --- a/src/core/Vector4.js +++ b/src/core/Vector4.js @@ -1,6 +1,7 @@ /** * @author supereggbert / http://www.paulbrunt.co.uk/ * @author philogb / http://blog.thejit.org/ + * @author mikael emtinger / http://gomo.se/ */ THREE.Vector4 = function ( x, y, z, w ) { @@ -8,7 +9,7 @@ THREE.Vector4 = function ( x, y, z, w ) { this.x = x || 0; this.y = y || 0; this.z = z || 0; - this.w = w || 1; + this.w = w !== undefined ? w : 1; }; @@ -108,6 +109,7 @@ THREE.Vector4.prototype = { this.y = this.y + (v.y - this.y) * alpha; this.z = this.z + (v.z - this.z) * alpha; this.w = this.w + (v.w - this.w) * alpha; + }, clone: function () { diff --git a/src/extras/io/Loader.js b/src/extras/io/Loader.js index c9c51441..1d934fa6 100644 --- a/src/extras/io/Loader.js +++ b/src/extras/io/Loader.js @@ -759,11 +759,51 @@ THREE.Loader.prototype = { init_vertices(); init_faces(); + init_skin(); this.computeCentroids(); this.computeFaceNormals(); this.sortFacesByMaterial(); + function init_skin() { + + var i, l, x, y, z, w, a, b, c, d; + + if ( data.skinWeights ) { + + for( i = 0, l = data.skinWeights.length; i < l; i += 2 ) { + + x = data.skinWeights[ i ]; + y = data.skinWeights[ i + 1 ]; + z = 0; + w = 0; + + THREE.Loader.prototype.sw( scope, x, y, z, w ); + + } + + } + + if ( data.skinIndices ) { + + for( i = 0, l = data.skinIndices.length; i < l; i += 2 ) { + + a = data.skinIndices[ i ]; + b = data.skinIndices[ i + 1 ]; + c = 0; + d = 0; + + THREE.Loader.prototype.si( scope, a, b, c, d ); + + } + + } + + THREE.Loader.prototype.bones( scope, data.bones ); + THREE.Loader.prototype.animation( scope, data.animation ); + + } + function init_vertices() { var i, l, x, y, z, r, g, b; @@ -882,7 +922,7 @@ THREE.Loader.prototype = { THREE.Loader.prototype.uv3( scope.uvs, u1, v1, u2, v2, u3, v3 ); - if( data.uvs2 ) { + if( data.uvs2 && data.uvs2.length ) { u1 = data.uvs2[ uva * 2 ]; v1 = data.uvs2[ uva * 2 + 1 ]; @@ -1012,6 +1052,30 @@ THREE.Loader.prototype = { }, + bones: function( scope, bones ) { + + scope.bones = bones; + + }, + + animation: function( scope, animation ) { + + scope.animation = animation; + + }, + + si: function( scope, a, b, c, d ) { + + scope.skinIndices.push( new THREE.Vector4( a, b, c, d ) ); + + }, + + sw: function( scope, x, y, z, w ) { + + scope.skinWeights.push( new THREE.Vector4( x, y, z, w ) ); + + }, + v: function( scope, x, y, z ) { scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) ); diff --git a/src/lights/Light.js b/src/lights/Light.js index 968d654d..d465ec24 100644 --- a/src/lights/Light.js +++ b/src/lights/Light.js @@ -1,5 +1,17 @@ +/** + * @author mr.doob / http://mrdoob.com/ + * @author alteredq / http://alteredqualia.com/ + */ + THREE.Light = function ( hex ) { + THREE.Object3D.call( this ); + this.color = new THREE.Color( hex ); }; + +THREE.Light.prototype = new THREE.Object3D(); +THREE.Light.prototype.constructor = THREE.Light; +THREE.Light.prototype.supr = THREE.Object3D.prototype; + diff --git a/src/objects/Bone.js b/src/objects/Bone.js new file mode 100644 index 00000000..1c4b9dfb --- /dev/null +++ b/src/objects/Bone.js @@ -0,0 +1,91 @@ +/** + * @author mikael emtinger / http://gomo.se/ + */ + +THREE.Bone = function( belongsToSkin ) { + + THREE.Object3D.call( this ); + + this.skin = belongsToSkin; + this.skinMatrix = new THREE.Matrix4(); + this.hasNoneBoneChildren = false; + +}; + +THREE.Bone.prototype = new THREE.Object3D(); +THREE.Bone.prototype.constructor = THREE.Bone; +THREE.Bone.prototype.supr = THREE.Object3D.prototype; + + +/* + * Update + */ + +THREE.Bone.prototype.update = function( parentSkinMatrix, forceUpdate, camera, renderer ) { + + // update local + + if( this.autoUpdateMatrix ) + forceUpdate |= this.updateMatrix(); + + + // update skin matrix + + if( forceUpdate || this.matrixNeedsToUpdate ) { + + if( parentSkinMatrix ) + this.skinMatrix.multiply( parentSkinMatrix, this.localMatrix ); + else + this.skinMatrix.copy( this.localMatrix ); + + this.matrixNeedsToUpdate = false; + forceUpdate = true; + + } + + + // update children + + if( this.hasNoneBoneChildren ) { + + this.globalMatrix.multiply( this.skin.globalMatrix, this.skinMatrix ); + + for( var i = 0; i < this.children.length; i++ ) + if( !( this.children[ i ] instanceof THREE.Bone )) + this.children[ i ].update( this.globalMatrix, true, camera, renderer ); + else + this.children[ i ].update( this.skinMatrix, forceUpdate, camera, renderer ); + + } else { + + for( var i = 0; i < this.children.length; i++ ) + this.children[ i ].update( this.skinMatrix, forceUpdate, camera, renderer ); + + } + +}; + + +/* + * Add child + */ + +THREE.Bone.prototype.addChild = function( child ) { + + if( this.children.indexOf( child ) === -1 ) { + + if( child.parent !== undefined ) + child.parent.removeChild( child ); + + child.parent = this; + this.children.push( child ); + + if( !( child instanceof THREE.Bone )) + this.hasNoneBoneChildren = true; + } + +}; + +/* + * Todo: Remove Children: see if any remaining are none-Bone + */ \ No newline at end of file diff --git a/src/objects/LOD.js b/src/objects/LOD.js new file mode 100644 index 00000000..040828f6 --- /dev/null +++ b/src/objects/LOD.js @@ -0,0 +1,97 @@ +/** + * @author mikael emtinger / http://gomo.se/ + */ + +THREE.LOD = function() { + + THREE.Object3D.call( this ); + + this.LODs = []; + +}; + +THREE.LOD.prototype = new THREE.Object3D(); +THREE.LOD.prototype.constructor = THREE.LOD; +THREE.LOD.prototype.supr = THREE.Object3D.prototype; + +/* + * Add + */ + +THREE.LOD.prototype.add = function( object3D, visibleAtDistance ) { + + if( visibleAtDistance === undefined ) visibleAtDistance = 0; + visibleAtDistance = Math.abs( visibleAtDistance ); + + for( var l = 0; l < this.LODs.length; l++ ) { + + if( visibleAtDistance < this.LODs[ l ].visibleAtDistance ) + break; + } + + this.LODs.splice( l, 0, { visibleAtDistance: visibleAtDistance, object3D: object3D } ); + this.addChild( object3D ); + +}; + + +/* + * Update + */ + +THREE.LOD.prototype.update = function( parentGlobalMatrix, forceUpdate, camera, renderer ) { + + // update local + + if( this.autoUpdateMatrix ) + forceUpdate |= this.updateMatrix(); + + + // update global + + if( forceUpdate || this.matrixNeedsToUpdate ) { + + if( parentGlobalMatrix ) + this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); + else + this.globalMatrix.copy( this.localMatrix ); + + this.matrixNeedsToUpdate = false; + forceUpdate = true; + + } + + + // update lods + + if( this.LODs.length > 1 ) { + + var distance = -camera.inverseMatrix.mulitplyVector3OnlyZ( this.position ); + + this.LODs[ 0 ].object3D.visible = true; + + for( var l = 1; l < this.LODs.length; l++ ) { + + if( distance >= this.LODs[ l ].visibleAtDistance ) { + + this.LODs[ l - 1 ].object3D.visible = false; + this.LODs[ l ].object3D.visible = true; + } + else + break; + + } + + for( ; l < this.LODs.length; l++ ) + this.LODs[ l ].object3D.visible = false; + + } + + + // update children + + for( var c = 0; c < this.children.length; c++ ) + this.children[ c ].update( this.globalMatrix, forceUpdate, camera, renderer ); + +}; + diff --git a/src/objects/Mesh.js b/src/objects/Mesh.js index c8555a6c..7c4f9491 100644 --- a/src/objects/Mesh.js +++ b/src/objects/Mesh.js @@ -1,23 +1,98 @@ /** * @author mr.doob / http://mrdoob.com/ * @author alteredq / http://alteredqualia.com/ + * @author mikael emtinger / http://gomo.se/ */ -THREE.Mesh = function ( geometry, materials ) { +THREE.Mesh = function( geometry, materials ) { THREE.Object3D.call( this ); - - this.geometry = geometry; - this.materials = materials instanceof Array ? materials : [ materials ]; - + + this.geometry = geometry; + this.materials = materials && materials.length ? materials : [ materials ]; + this.normalMatrix = THREE.Matrix4.makeInvert3x3( this.globalMatrix ).transpose(); + this.flipSided = false; this.doubleSided = false; this.overdraw = false; // TODO: Move to material? + + // calc bound radius + + if( this.geometry ) { + + if( !this.geometry.boundingSphere ) + this.geometry.computeBoundingSphere(); + + this.boundRadius = geometry.boundingSphere.radius; - this.geometry.boundingSphere || this.geometry.computeBoundingSphere(); + } -}; +} -THREE.Mesh.prototype = new THREE.Object3D(); +THREE.Mesh.prototype = new THREE.Object3D(); THREE.Mesh.prototype.constructor = THREE.Mesh; +THREE.Mesh.prototype.supr = THREE.Object3D.prototype; + +/* + * Update + */ + +THREE.Mesh.prototype.update = function( parentGlobalMatrix, forceUpdate, camera, renderer ) { + + // visible? + + if( this.visible ) { + + // update local + + if( this.autoUpdateMatrix ) + forceUpdate |= this.updateMatrix(); + + + // update global + + if( forceUpdate || this.matrixNeedsToUpdate ) { + + if( parentGlobalMatrix ) + this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); + else + this.globalMatrix.copy( this.localMatrix ); + + this.matrixNeedsToUpdate = false; + forceUpdate = true; + + + // update normal + + this.normalMatrix = THREE.Matrix4.makeInvert3x3( this.globalMatrix ).transpose(); + + } + + + // update children + + for( var i = 0; i < this.children.length; i++ ) + this.children[ i ].update( this.globalMatrix, forceUpdate, camera, renderer ); + + + // check camera frustum and add to render list + + if( renderer && camera ) { + + if( camera.frustumContains( this )) + renderer.addToRenderList( this ); + else + renderer.removeFromRenderList( this ); + + } + + } else { + + renderer.removeFromRenderList( this ); + + } + +} + + diff --git a/src/objects/Object3D.js b/src/objects/Object3D.js index 130fa58c..03cc15d7 100644 --- a/src/objects/Object3D.js +++ b/src/objects/Object3D.js @@ -1,74 +1,204 @@ /** * @author mr.doob / http://mrdoob.com/ + * @author mikael emtinger / http://gomo.se/ + * @author alteredq / http://alteredqualia.com/ */ -THREE.Object3D = function () { +THREE.Object3D = function() { - this.id = THREE.Object3DCounter.value ++; // TODO: Probably not needed? + this.id = THREE.Object3DCounter.value ++; + + this.visible = true; + this.autoUpdateMatrix = true; + this.matrixNeedsToUpdate = true; + + this.parent = undefined; + this.children = []; - this.position = new THREE.Vector3(); - this.rotation = new THREE.Vector3(); - this.scale = new THREE.Vector3( 1, 1, 1 ); - - this.matrix = new THREE.Matrix4(); - this.matrixWorld = new THREE.Matrix4(); - this.rotationMatrix = new THREE.Matrix4(); - this.tmpMatrix = new THREE.Matrix4(); - - this.screen = new THREE.Vector3(); - - this.autoUpdateMatrix = true; - this.visible = true; - - this.children = []; + this.position = new THREE.Vector3(); + this.rotation = new THREE.Vector3(); + this.scale = new THREE.Vector3( 1.0, 1.0, 1.0 ); + this.localMatrix = new THREE.Matrix4(); + this.globalMatrix = new THREE.Matrix4(); + this.quaternion = new THREE.Quaternion(); + this.useQuaternion = false; + this.screenPosition = new THREE.Vector4(); // xyzr + + this.boundRadius = 0.0; + this.boundRadiusScale = 1.0; }; -THREE.Object3D.prototype = { - addChild: function ( object ) { +/* + * Update + */ - var i = this.children.indexOf( object ); +THREE.Object3D.prototype.update = function( parentGlobalMatrix, forceUpdate, camera, renderer ) { - if ( i === -1 ) { + // visible and auto update? + + if( this.visible ) { - this.children.push( object ); + // update local + + if( this.autoUpdateMatrix ) + forceUpdate |= this.updateMatrix(); + + + // update global + + if( forceUpdate || this.matrixNeedsToUpdate ) { + + if( parentGlobalMatrix ) + this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); + else + this.globalMatrix.copy( this.localMatrix ); + + this.matrixNeedsToUpdate = false; + forceUpdate = true; } - }, - removeChild: function ( object ) { + // update children + + for( var i = 0; i < this.children.length; i++ ) { + + this.children[ i ].update( this.globalMatrix, forceUpdate, camera, renderer ); + + } - var i = this.children.indexOf( object ); + } - if ( i !== -1 ) { +}; - this.children.splice( i, 1 ); + +/* + * Update Matrix + */ + +THREE.Object3D.prototype.updateMatrix = function() { + + // update position + + var isDirty = false; + + if( this.position.isDirty ) { + + this.localMatrix.setPosition( this.position ); + this.position.isDirty = false; + isDirty = true; + + } + + + // update quaternion + + if( this.useQuaternion ) { + + if( this.quaternion.isDirty ) { + + this.localMatrix.setRotationFromQuaternion( this.quaternion ); + this.quaternion.isDirty = false; + this.rotation .isDirty = false; + + if( this.scale.isDirty || this.scale.x !== 1 || this.scale.y !== 1 || this.scale.z !== 1 ) { + + this.localMatrix.scale( this.scale ); + this.scale.isDirty = false; + + this.boundRadiusScale = Math.max( this.scale.x, Math.max( this.scale.y, this.scale.z ) ); + + } + + isDirty = true; } - }, + } - updateMatrix: function () { + // update rotation - var p = this.position, r = this.rotation, s = this.scale, - matrix = this.matrix, rotationMatrix = this.rotationMatrix, - tmpMatrix = this.tmpMatrix; + else if( this.rotation.isDirty ) { + + this.localMatrix.setRotationFromEuler( this.rotation ); + this.rotation.isDirty = false; - matrix.setTranslation( p.x, p.y, p.z ); + if( this.scale.isDirty || this.scale.x !== 1 || this.scale.y !== 1 || this.scale.z !== 1 ) { + + this.localMatrix.scale( this.scale ); + this.scale.isDirty = false; + + this.boundRadiusScale = Math.max( this.scale.x, Math.max( this.scale.y, this.scale.z ) ); - rotationMatrix.setRotX( r.x ); + } - if ( r.y != 0 ) rotationMatrix.multiplySelf( tmpMatrix.setRotY( r.y ) ); - if ( r.z != 0 ) rotationMatrix.multiplySelf( tmpMatrix.setRotZ( r.z ) ); + isDirty = true; - matrix.multiplySelf( rotationMatrix ); + } - if ( s.x != 0 || s.y != 0 || s.z != 0 ) matrix.multiplySelf( tmpMatrix.setScale( s.x, s.y, s.z ) ); + + // update scale + + if( this.scale.isDirty ) { + + if( this.useQuaternion ) + this.localMatrix.setRotationFromQuaternion( this.quaternion ); + else + this.localMatrix.setRotationFromEuler( this.rotation ); + + this.localMatrix.scale( this.scale ); + this.scale.isDirty = false; + + this.boundRadiusScale = Math.max( this.scale.x, Math.max( this.scale.y, this.scale.z )); + + isDirty = true; + + } + + + return isDirty; + +}; + + +/* + * AddChild + */ + +THREE.Object3D.prototype.addChild = function( child ) { + + if( this.children.indexOf( child ) === -1 ) { + + if( child.parent !== undefined ) + child.parent.removeChild( child ); + + child.parent = this; + this.children.push( child ); + + } + +}; + + +/* + * RemoveChild + */ + +THREE.Object3D.prototype.removeChild = function() { + + var childIndex = this.children.indexOf( child ); + + if( childIndex !== -1 ) { + + this.children.splice( childIndex, 1 ); + child.parent = undefined; } }; THREE.Object3DCounter = { value: 0 }; + + diff --git a/src/objects/SkinnedMesh.js b/src/objects/SkinnedMesh.js new file mode 100644 index 00000000..833a8776 --- /dev/null +++ b/src/objects/SkinnedMesh.js @@ -0,0 +1,193 @@ +/** + * @author mikael emtinger / http://gomo.se/ + */ + +THREE.SkinnedMesh = function( geometry, materials ) { + + THREE.Mesh.call( this, geometry, materials ); + + + // init bones + + this.identityMatrix = new THREE.Matrix4(); + + this.bones = []; + this.boneMatrices = []; + + if( this.geometry.bones !== undefined ) { + + for( var b = 0; b < this.geometry.bones.length; b++ ) { + + var bone = this.addBone(); + + bone.name = this.geometry.bones[ b ].name; + bone.position.x = this.geometry.bones[ b ].pos [ 0 ]; + bone.position.y = this.geometry.bones[ b ].pos [ 1 ]; + bone.position.z = this.geometry.bones[ b ].pos [ 2 ]; + bone.quaternion.x = this.geometry.bones[ b ].rotq[ 0 ]; + bone.quaternion.y = this.geometry.bones[ b ].rotq[ 1 ]; + bone.quaternion.z = this.geometry.bones[ b ].rotq[ 2 ]; + bone.quaternion.w = this.geometry.bones[ b ].rotq[ 3 ]; + bone.scale.x = this.geometry.bones[ b ].scl !== undefined ? this.geometry.bones[ b ].scl[ 0 ] : 1; + bone.scale.y = this.geometry.bones[ b ].scl !== undefined ? this.geometry.bones[ b ].scl[ 1 ] : 1; + bone.scale.z = this.geometry.bones[ b ].scl !== undefined ? this.geometry.bones[ b ].scl[ 2 ] : 1; + + } + + for( var b = 0; b < this.bones.length; b++ ) { + + if( this.geometry.bones[ b ].parent === -1 ) + this.addChild( this.bones[ b ] ); + else + this.bones[ this.geometry.bones[ b ].parent ].addChild( this.bones[ b ] ); + } + + this.pose(); + + } + +}; + +THREE.SkinnedMesh.prototype = new THREE.Mesh(); +THREE.SkinnedMesh.prototype.constructor = THREE.SkinnedMesh; + + +/* + * Update + */ + +THREE.SkinnedMesh.prototype.update = function( parentGlobalMatrix, forceUpdate, camera, renderer ) { + + // visible? + + if( this.visible ) { + + // update local + + if( this.autoUpdateMatrix ) + forceUpdate |= this.updateMatrix(); + + + // update global + + if( forceUpdate || this.matrixNeedsToUpdate ) { + + if( parentGlobalMatrix ) + this.globalMatrix.multiply( parentGlobalMatrix, this.localMatrix ); + else + this.globalMatrix.copy( this.localMatrix ); + + this.matrixNeedsToUpdate = false; + forceUpdate = true; + + + // update normal + + this.normalMatrix = THREE.Matrix4.makeInvert3x3( this.globalMatrix ).transpose(); + + } + + + // update children + + for( var i = 0; i < this.children.length; i++ ) + if( this.children[ i ] instanceof THREE.Bone ) + this.children[ i ].update( this.identityMatrix, false, camera, renderer ); + else + this.children[ i ].update( this.globalMatrix, forceUpdate, camera, renderer ); + + + + // check camera frustum and add to render list + + if( renderer && camera ) { + + if( camera.frustumContains( this ) ) + renderer.addToRenderList( this ); + else + renderer.removeFromRenderList( this ); + + } + + } else { + + renderer.removeFromRenderList( this ); + + } + +}; + + +/* + * Add + */ + +THREE.SkinnedMesh.prototype.addBone = function( bone ) { + + if( bone === undefined ) + bone = new THREE.Bone( this ); + + this.bones.push( bone ); + + return bone; + +}; + +/* + * Pose + */ + +THREE.SkinnedMesh.prototype.pose = function() { + + this.update( undefined, true ); + + var boneInverses = []; + + for( var b = 0; b < this.bones.length; b++ ) { + + boneInverses.push( THREE.Matrix4.makeInvert( this.bones[ b ].skinMatrix, new THREE.Matrix4())); + this.boneMatrices.push( this.bones[ b ].skinMatrix.flatten32 ); + + } + + + // project vertices to local + + if( this.geometry.skinVerticesA === undefined ) { + + this.geometry.skinVerticesA = []; + this.geometry.skinVerticesB = []; + var orgVertex; + var vertex; + + for( var i = 0; i < this.geometry.skinIndices.length; i++ ) { + + orgVertex = this.geometry.vertices[ i ].position; + + var indexA = this.geometry.skinIndices[ i ].x; + var indexB = this.geometry.skinIndices[ i ].y; + + vertex = new THREE.Vector3( orgVertex.x, orgVertex.y, orgVertex.z ); + this.geometry.skinVerticesA.push( boneInverses[ indexA ].multiplyVector3( vertex )); + + vertex = new THREE.Vector3( orgVertex.x, orgVertex.y, orgVertex.z ); + this.geometry.skinVerticesB.push( boneInverses[ indexB ].multiplyVector3( vertex )); + + // todo: add more influences + + // normalize weights + + if( this.geometry.skinWeights[ i ].x + this.geometry.skinWeights[ i ].y !== 1 ) { + + var len = ( 1.0 - ( this.geometry.skinWeights[ i ].x + this.geometry.skinWeights[ i ].y )) * 0.5; + this.geometry.skinWeights[ i ].x += len; + this.geometry.skinWeights[ i ].y += len; + + } + + } + + } + +}; + diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index b36b4833..5f1d3f81 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -64,6 +64,7 @@ THREE.WebGLRenderer = function ( parameters ) { this.domElement = _canvas; this.autoClear = true; + this.sortObjects = false; initGL( antialias, clearColor, clearAlpha ); @@ -809,7 +810,7 @@ THREE.WebGLRenderer = function ( parameters ) { if ( object.sortParticles ) { - _projScreenMatrix.multiplySelf( object.matrixWorld ); + _projScreenMatrix.multiplySelf( object.globalMatrix ); for ( v = 0; v < vl; v++ ) { @@ -1355,7 +1356,7 @@ THREE.WebGLRenderer = function ( parameters ) { function isInFrustum( object ) { - var distance, matrix = object.matrix, + var distance, matrix = object.globalMatrix, radius = - object.geometry.boundingSphere.radius * Math.max( object.scale.x, Math.max( object.scale.y, object.scale.z ) ); for ( var i = 0; i < 6; i ++ ) { @@ -1446,39 +1447,31 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function updateChildren( object ) { - - var i, l, child, children = object.children; - - for ( i = 0, l = children.length; i < l; i ++ ) { - - child = children[ i ]; - - child.autoUpdateMatrix && child.updateMatrix(); - child.matrixWorld.multiply( object.matrixWorld, child.matrix ); - - updateChildren( child ); - - } + function painterSort( a, b ) { + + return b.z - a.z; + }; this.render = function( scene, camera, renderTarget, clear ) { - + var i, program, opaque, transparent, o, ol, oil, webGLObject, object, buffer, lights = scene.lights, fog = scene.fog, ol; - camera.autoUpdateMatrix && camera.updateMatrix(); + camera.autoUpdateMatrix && camera.update(); - camera.matrix.flattenToArray( _viewMatrixArray ); + camera.globalMatrix.flattenToArray( _viewMatrixArray ); camera.projectionMatrix.flattenToArray( _projectionMatrixArray ); - _projScreenMatrix.multiply( camera.projectionMatrix, camera.matrix ); + _projScreenMatrix.multiply( camera.projectionMatrix, camera.globalMatrix ); computeFrustum( _projScreenMatrix ); + scene.update( undefined, false, camera, this ); + this.initWebGLObjects( scene, camera ); setRenderTarget( renderTarget, clear !== undefined ? clear : true ); @@ -1498,20 +1491,11 @@ THREE.WebGLRenderer = function ( parameters ) { webGLObject = scene.__webGLObjects[ o ]; object = webGLObject.object; - if ( object.visible ) { - - if ( webGLObject.root ) { - - object.autoUpdateMatrix && object.updateMatrix(); - object.matrixWorld.copy( object.matrix ); - - updateChildren( object ); - - } + if ( object.visible ) { if ( ! ( object instanceof THREE.Mesh ) || isInFrustum( object ) ) { - object.matrixWorld.flattenToArray( object._objectMatrixArray ); + object.globalMatrix.flattenToArray( object._objectMatrixArray ); setupMatrices( object, camera ); @@ -1519,6 +1503,14 @@ THREE.WebGLRenderer = function ( parameters ) { webGLObject.render = true; + if ( this.sortObjects ) { + + _vector3.copy( object.position ); + _projScreenMatrix.multiplyVector3( _vector3 ); + + webGLObject.z = _vector3.z; + + } } else { @@ -1534,6 +1526,12 @@ THREE.WebGLRenderer = function ( parameters ) { } + if ( this.sortObjects ) { + + scene.__webGLObjects.sort( painterSort ); + + } + oil = scene.__webGLObjectsImmediate.length; for ( o = 0; o < oil; o++ ) { @@ -1545,9 +1543,7 @@ THREE.WebGLRenderer = function ( parameters ) { if( object.autoUpdateMatrix ) { - object.updateMatrix(); - object.matrixWorld.copy( object.matrix ); - object.matrixWorld.flattenToArray( object._objectMatrixArray ); + object.globalMatrix.flattenToArray( object._objectMatrixArray ); } @@ -1681,22 +1677,7 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function addChildren( scene, object ) { - - var i, l, children = object.children; - - for ( i = 0, l = children.length; i < l; i ++ ) { - - child = children[ i ]; - - addObject( scene, child, false ); - addChildren( scene, child ); - - } - - }; - - function addObject( scene, object, root ) { + function addObject( scene, object ) { var g, geometry, geometryChunk, objmap; @@ -1712,7 +1693,7 @@ THREE.WebGLRenderer = function ( parameters ) { object._modelViewMatrixArray = new Float32Array( 16 ); object._objectMatrixArray = new Float32Array( 16 ); - object.matrix.flattenToArray( object._objectMatrixArray ); + object.globalMatrix.flattenToArray( object._objectMatrixArray ); } @@ -1753,7 +1734,7 @@ THREE.WebGLRenderer = function ( parameters ) { // create separate wrapper per each use of VBO - add_buffer( objlist, objmap, g, geometryChunk, object, root ); + add_buffer( objlist, objmap, g, geometryChunk, object ); } @@ -1782,7 +1763,7 @@ THREE.WebGLRenderer = function ( parameters ) { } - add_buffer( objlist, objmap, 0, geometry, object, root ); + add_buffer( objlist, objmap, 0, geometry, object ); geometry.__dirtyVertices = false; geometry.__dirtyColors = false; @@ -1805,14 +1786,14 @@ THREE.WebGLRenderer = function ( parameters ) { } - add_buffer( objlist, objmap, 0, geometry, object, root ); + add_buffer( objlist, objmap, 0, geometry, object ); geometry.__dirtyVertices = false; geometry.__dirtyColors = false; } else if ( object instanceof THREE.MarchingCubes ) { - add_buffer_immediate( scene.__webGLObjectsImmediate, objmap, 0, object, root ); + add_buffer_immediate( scene.__webGLObjectsImmediate, objmap, 0, object ); }/*else if ( object instanceof THREE.Particle ) { @@ -1820,14 +1801,13 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function add_buffer( objlist, objmap, id, buffer, object, root ) { + function add_buffer( objlist, objmap, id, buffer, object ) { if ( objmap[ id ] == undefined ) { objlist.push( { buffer: buffer, object: object, opaque: { list: [], count: 0 }, - transparent: { list: [], count: 0 }, - root: root + transparent: { list: [], count: 0 } } ); objmap[ id ] = 1; @@ -1836,14 +1816,13 @@ THREE.WebGLRenderer = function ( parameters ) { }; - function add_buffer_immediate( objlist, objmap, id, object, root ) { + function add_buffer_immediate( objlist, objmap, id, object ) { if ( objmap[ id ] == undefined ) { objlist.push( { object: object, opaque: { list: [], count: 0 }, - transparent: { list: [], count: 0 }, - root: root + transparent: { list: [], count: 0 } } ); objmap[ id ] = 1; @@ -1869,8 +1848,7 @@ THREE.WebGLRenderer = function ( parameters ) { object = scene.objects[ o ]; - addObject( scene, object, true ); - addChildren( scene, object ); + addObject( scene, object ); } @@ -1894,9 +1872,21 @@ THREE.WebGLRenderer = function ( parameters ) { }; + this.addToRenderList = function( object ) { + + // TODO: implement this + + }; + + this.removeFromRenderList = function( object ) { + + // TODO: implement this + + }; + function setupMatrices ( object, camera ) { - object._modelViewMatrix.multiplyToArray( camera.matrix, object.matrixWorld, object._modelViewMatrixArray ); + object._modelViewMatrix.multiplyToArray( camera.globalMatrix, object.globalMatrix, object._modelViewMatrixArray ); object._normalMatrix = THREE.Matrix4.makeInvert3x3( object._modelViewMatrix ).transposeIntoArray( object._normalMatrixArray ); }; diff --git a/src/scenes/Scene.js b/src/scenes/Scene.js index aebeb211..29e4bfad 100644 --- a/src/scenes/Scene.js +++ b/src/scenes/Scene.js @@ -1,65 +1,100 @@ /** * @author mr.doob / http://mrdoob.com/ + * @author mikael emtinger / http://gomo.se/ */ -THREE.Scene = function () { +THREE.Scene = function() { + + // call super + + THREE.Object3D.call( this ); + + // vars this.objects = []; - this.lights = []; - this.fog = null; - - this.addObject = function ( object ) { - - var i = this.objects.indexOf( object ); - - if ( i === -1 ) { - - this.objects.push( object ); - - } - - }; - - this.removeObject = function ( object ) { - - var i = this.objects.indexOf( object ); - - if ( i !== -1 ) { - - this.objects.splice( i, 1 ); - - } - - }; - - this.addLight = function ( light ) { - - var i = this.lights.indexOf( light ); - - if ( i === -1 ) { - - this.lights.push( light ); - - } - - }; - - this.removeLight = function ( light ) { - - var i = this.lights.indexOf( light ); - - if ( i !== -1 ) { - - this.lights.splice( i, 1 ); - - } - - }; - - this.toString = function () { - - return 'THREE.Scene ( ' + this.objects + ' )'; - - }; + this.lights = []; + this.fog = null; }; + +THREE.Scene.prototype = new THREE.Object3D(); +THREE.Scene.prototype.constructor = THREE.Scene; +THREE.Scene.prototype.supr = THREE.Object3D.prototype; + +/* + * Add Child + */ + +THREE.Scene.prototype.addChild = function( child ) { + + this.supr.addChild.call( this, child ); + this.addChildRecurse( child ); + +} + +THREE.Scene.prototype.addChildRecurse = function( object ) { + + + if( object instanceof THREE.Light ) { + + if( this.lights.indexOf( object ) === -1 ) + this.lights.push( object ); + + } else if( !( object instanceof THREE.Camera ) ) { + + if( this.objects.indexOf( object ) === -1 ) + this.objects.push( object ); + + } + + for( var c = 0; c < object.children.length; c++ ) + this.addChildRecurse( object.children[ c ] ); + +} + + +/* + * Remove Child + */ + +THREE.Scene.prototype.removeChild = function( child ) { + + this.supr.removeChild.call( this, child ); + this.removeChildRecurse( child ); + +} + +THREE.Scene.prototype.removeChildRecurse = function( child ) { + + if( object instanceof THREE.Light ) { + + var i = this.lights.indexOf( object ); + + if( i === -1 ) + this.lights.splice( i, 1 ); + + } else if( !( object instanceof THREE.Camera ) ) { + + var i = this.objects.indexOf( object ); + + if( i === -1 ) + this.objects.splice( i, 1 ); + + } + + for( var c = 0; c < object.children.length; c++ ) + this.removeChildRecurse( object.children[ c ] ); + +} + + + +/* + * Backward Compatibility + */ + +THREE.Scene.prototype.addObject = THREE.Scene.prototype.addChild; +THREE.Scene.prototype.removeObject = THREE.Scene.prototype.removeChild; +THREE.Scene.prototype.addLight = THREE.Scene.prototype.addChild; +THREE.Scene.prototype.removeLight = THREE.Scene.prototype.removeChild; + \ No newline at end of file