diff --git a/build/Three.js b/build/Three.js index 6fdb7ab6..cba4def3 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,68 +1,69 @@ // 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,b,f){this.r=a;this.g=b;this.b=f;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)+ +THREE.Color.prototype={setRGB:function(a,b,e){this.r=a;this.g=b;this.b=e;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,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* -this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,f){this.x=a||0;this.y=b||0;this.z=f||0}; -THREE.Vector3.prototype={set:function(a,b,f){this.x=a;this.y=b;this.z=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, -cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,f=this.y,e=this.z;this.x=f*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-f*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},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 b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+f*f+a*a)},distanceToSquared:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return b*b+f*f+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,b,e){this.x=a||0;this.y=b||0;this.z=e||0}; +THREE.Vector3.prototype={set:function(a,b,e){this.x=a;this.y=b;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, +cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-b*a.z;this.z=b*a.y-e*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},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 b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+e*e+a*a)},distanceToSquared:function(a){var b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return b*b+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,b,f,e){this.x=a||0;this.y=b||0;this.z=f||0;this.w=e||1}; -THREE.Vector4.prototype={set:function(a,b,f,e){this.x=a;this.y=b;this.z=f;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; +THREE.Vector4=function(a,b,e,f){this.x=a||0;this.y=b||0;this.z=e||0;this.w=f||1}; +THREE.Vector4.prototype={set:function(a,b,e,f){this.x=a;this.y=b;this.z=e;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,f,e=a.objects,g=[];a=0;for(b=e.length;a0&&O>0&&q+O<1}var f,e,g,j,p,c,k,m,B,D, -x,A=a.geometry,M=A.vertices,Q=[];f=0;for(e=A.faces.length;fk?e:k;g=g>m? -g:m}a()};this.add3Points=function(k,m,B,D,x,A){if(c){c=false;b=kB?k>x?k:x:B>x?B:x;g=m>D?m>A?m:A:D>A?D:A}else{b=kB?k>x?k>e?k:e:x>e?x:e:B>x?B>e?B:e:x>e?x:e;g=m>D?m>A?m>g?m:g:A>g?A:g:D>A?D>g?D:g:A>g?A:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();f=k.getTop();e=k.getRight();g=k.getBottom()}else{b=bk.getRight()?e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;f-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();f=f>k.getTop()?f:k.getTop();e=e=0&&Math.min(g,k.getBottom())-Math.max(f,k.getTop())>=0};this.empty=function(){c=true;g=e=f=b=0;a()};this.isEmpty=function(){return c};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+f+", bottom: "+g+", width: "+j+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; -THREE.Matrix4=function(a,b,f,e,g,j,p,c,k,m,B,D,x,A,M,Q){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=e||0;this.n21=g||0;this.n22=j||1;this.n23=p||0;this.n24=c||0;this.n31=k||0;this.n32=m||0;this.n33=B||1;this.n34=D||0;this.n41=x||0;this.n42=A||0;this.n43=M||0;this.n44=Q||1}; -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,f,e,g,j,p,c,k,m,B,D,x,A,M,Q){this.n11=a;this.n12=b;this.n13=f;this.n14=e;this.n21=g;this.n22=j;this.n23=p;this.n24=c;this.n31=k;this.n32=m;this.n33=B;this.n34=D;this.n41=x;this.n42=A;this.n43=M;this.n44=Q;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,f){var e=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(f,j).normalize();g.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x; -this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,e=a.z,g=1/(this.n41*b+this.n42*f+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*f+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*f+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,f=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*f+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*f+this.n23*e+this.n24* -g;a.z=this.n31*b+this.n32*f+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*f+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 f=a.n11,e=a.n12,g=a.n13,j=a.n14,p=a.n21,c=a.n22,k=a.n23,m=a.n24,B=a.n31,D=a.n32, -x=a.n33,A=a.n34,M=a.n41,Q=a.n42,O=a.n43,s=a.n44,L=b.n11,d=b.n12,h=b.n13,q=b.n14,n=b.n21,l=b.n22,i=b.n23,u=b.n24,o=b.n31,y=b.n32,t=b.n33,r=b.n34,v=b.n41,W=b.n42,G=b.n43,S=b.n44;this.n11=f*L+e*n+g*o+j*v;this.n12=f*d+e*l+g*y+j*W;this.n13=f*h+e*i+g*t+j*G;this.n14=f*q+e*u+g*r+j*S;this.n21=p*L+c*n+k*o+m*v;this.n22=p*d+c*l+k*y+m*W;this.n23=p*h+c*i+k*t+m*G;this.n24=p*q+c*u+k*r+m*S;this.n31=B*L+D*n+x*o+A*v;this.n32=B*d+D*l+x*y+A*W;this.n33=B*h+D*i+x*t+A*G;this.n34=B*q+D*u+x*r+A*S;this.n41=M*L+Q*n+O*o+s*v; -this.n42=M*d+Q*l+O*y+s*W;this.n43=M*h+Q*i+O*t+s*G;this.n44=M*q+Q*u+O*r+s*S;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,e=this.n13,g=this.n14,j=this.n21,p=this.n22,c=this.n23,k=this.n24,m=this.n31,B=this.n32,D=this.n33,x=this.n34,A=this.n41,M=this.n42,Q=this.n43,O=this.n44,s=a.n11,L=a.n21,d=a.n31,h=a.n41,q=a.n12,n=a.n22,l=a.n32,i=a.n42,u=a.n13,o=a.n23,y=a.n33,t=a.n43,r=a.n14,v=a.n24,W=a.n34;a=a.n44;this.n11=b*s+f*L+e*d+g*h;this.n12=b*q+f*n+e*l+g*i;this.n13=b*u+f*o+e*y+g*t;this.n14= -b*r+f*v+e*W+g*a;this.n21=j*s+p*L+c*d+k*h;this.n22=j*q+p*n+c*l+k*i;this.n23=j*u+p*o+c*y+k*t;this.n24=j*r+p*v+c*W+k*a;this.n31=m*s+B*L+D*d+x*h;this.n32=m*q+B*n+D*l+x*i;this.n33=m*u+B*o+D*y+x*t;this.n34=m*r+B*v+D*W+x*a;this.n41=A*s+M*L+Q*d+O*h;this.n42=A*q+M*n+Q*l+O*i;this.n43=A*u+M*o+Q*y+O*t;this.n44=A*r+M*v+Q*W+O*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*= +THREE.Ray.prototype={intersectScene:function(a){var b,e,f=a.objects,g=[];a=0;for(b=f.length;a0&&U>0&&o+U<1}var e,f,g,i,p,c,k,m,D,F, +y,C=a.geometry,R=C.vertices,W=[];e=0;for(f=C.faces.length;ek?f:k;g=g>m? +g:m}a()};this.add3Points=function(k,m,D,F,y,C){if(c){c=false;b=kD?k>y?k:y:D>y?D:y;g=m>F?m>C?m:C:F>C?F:C}else{b=kD?k>y?k>f?k:f:y>f?y:f:D>y?D>f?D:f:y>f?y:f;g=m>F?m>C?m>g?m:g:C>g?C:g:F>C?F>g?F:g:C>g?C:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();e=k.getTop();f=k.getRight();g=k.getBottom()}else{b=bk.getRight()?f:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;e-=k;f+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();e=e>k.getTop()?e:k.getTop();f=f=0&&Math.min(g,k.getBottom())-Math.max(e,k.getTop())>=0};this.empty=function(){c=true;g=f=e=b=0;a()};this.isEmpty=function(){return c};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+f+", top: "+e+", bottom: "+g+", width: "+i+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Matrix4=function(a,b,e,f,g,i,p,c,k,m,D,F,y,C,R,W){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=f||0;this.n21=g||0;this.n22=i||1;this.n23=p||0;this.n24=c||0;this.n31=k||0;this.n32=m||0;this.n33=D||1;this.n34=F||0;this.n41=y||0;this.n42=C||0;this.n43=R||0;this.n44=W||1}; +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,e,f,g,i,p,c,k,m,D,F,y,C,R,W){this.n11=a;this.n12=b;this.n13=e;this.n14=f;this.n21=g;this.n22=i;this.n23=p;this.n24=c;this.n31=k;this.n32=m;this.n33=D;this.n34=F;this.n41=y;this.n42=C;this.n43=R;this.n44=W;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,e){var f=new THREE.Vector3,g=new THREE.Vector3,i=new THREE.Vector3;i.sub(a,b).normalize();f.cross(e,i).normalize();g.cross(i,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=i.x; +this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,f=a.z,g=1/(this.n41*b+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*f+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*f+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,f=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*f+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*f+this.n24* +g;a.z=this.n31*b+this.n32*e+this.n33*f+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*f+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 e=a.n11,f=a.n12,g=a.n13,i=a.n14,p=a.n21,c=a.n22,k=a.n23,m=a.n24,D=a.n31,F=a.n32, +y=a.n33,C=a.n34,R=a.n41,W=a.n42,U=a.n43,s=a.n44,Q=b.n11,d=b.n12,h=b.n13,o=b.n14,n=b.n21,l=b.n22,t=b.n23,r=b.n24,q=b.n31,z=b.n32,u=b.n33,j=b.n34,w=b.n41,S=b.n42,A=b.n43,J=b.n44;this.n11=e*Q+f*n+g*q+i*w;this.n12=e*d+f*l+g*z+i*S;this.n13=e*h+f*t+g*u+i*A;this.n14=e*o+f*r+g*j+i*J;this.n21=p*Q+c*n+k*q+m*w;this.n22=p*d+c*l+k*z+m*S;this.n23=p*h+c*t+k*u+m*A;this.n24=p*o+c*r+k*j+m*J;this.n31=D*Q+F*n+y*q+C*w;this.n32=D*d+F*l+y*z+C*S;this.n33=D*h+F*t+y*u+C*A;this.n34=D*o+F*r+y*j+C*J;this.n41=R*Q+W*n+U*q+s*w; +this.n42=R*d+W*l+U*z+s*S;this.n43=R*h+W*t+U*u+s*A;this.n44=R*o+W*r+U*j+s*J;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,f=this.n13,g=this.n14,i=this.n21,p=this.n22,c=this.n23,k=this.n24,m=this.n31,D=this.n32,F=this.n33,y=this.n34,C=this.n41,R=this.n42,W=this.n43,U=this.n44,s=a.n11,Q=a.n21,d=a.n31,h=a.n41,o=a.n12,n=a.n22,l=a.n32,t=a.n42,r=a.n13,q=a.n23,z=a.n33,u=a.n43,j=a.n14,w=a.n24,S=a.n34;a=a.n44;this.n11=b*s+e*Q+f*d+g*h;this.n12=b*o+e*n+f*l+g*t;this.n13=b*r+e*q+f*z+g*u;this.n14= +b*j+e*w+f*S+g*a;this.n21=i*s+p*Q+c*d+k*h;this.n22=i*o+p*n+c*l+k*t;this.n23=i*r+p*q+c*z+k*u;this.n24=i*j+p*w+c*S+k*a;this.n31=m*s+D*Q+F*d+y*h;this.n32=m*o+D*n+F*l+y*t;this.n33=m*r+D*q+F*z+y*u;this.n34=m*j+D*w+F*S+y*a;this.n41=C*s+R*Q+W*d+U*h;this.n42=C*o+R*n+W*l+U*t;this.n43=C*r+R*q+W*z+U*u;this.n44=C*j+R*w+W*S+U*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34* -this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,f,e){var g=b[f];b[f]=b[e]; -b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, -this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,f){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=f;return e}; -THREE.Matrix4.scaleMatrix=function(a,b,f){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=f;return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,e=Math.cos(b),g=Math.sin(b),j=1-e,p=a.x,c=a.y,k=a.z;f.n11=j*p*p+e;f.n12=j*p*c-g*k;f.n13=j*p*k+g*c;f.n21=j*p*c+g*k;f.n22=j*c*c+e;f.n23=j*c*k-g*p;f.n31=j*p*k-g*c;f.n32=j*c*k+g*p;f.n33=j*k*k+e;return f}; +this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,e,f){var g=b[e];b[e]=b[f]; +b[f]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, +this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,e){var f=new THREE.Matrix4;f.n14=a;f.n24=b;f.n34=e;return f}; +THREE.Matrix4.scaleMatrix=function(a,b,e){var f=new THREE.Matrix4;f.n11=a;f.n22=b;f.n33=e;return f};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var e=new THREE.Matrix4,f=Math.cos(b),g=Math.sin(b),i=1-f,p=a.x,c=a.y,k=a.z;e.n11=i*p*p+f;e.n12=i*p*c-g*k;e.n13=i*p*k+g*c;e.n21=i*p*c+g*k;e.n22=i*c*c+f;e.n23=i*c*k-g*p;e.n31=i*p*k-g*c;e.n32=i*c*k+g*p;e.n33=i*k*k+f;return e}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],m=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*p;a.m[5]=b*c;a.m[6]=b*k;a.m[7]=b*m;a.m[8]=b*B;return a}; -THREE.Matrix4.makeFrustum=function(a,b,f,e,g,j){var p,c,k;p=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(e-f);a=(b+a)/(b-a);f=(e+f)/(e-f);e=-(j+g)/(j-g);g=-2*j*g/(j-g);p.n11=c;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=k;p.n23=f;p.n24=0;p.n31=0;p.n32=0;p.n33=e;p.n34=g;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,f,e){var g;a=f*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,f,e)}; -THREE.Matrix4.makeOrtho=function(a,b,f,e,g,j){var p,c,k,m;p=new THREE.Matrix4;c=b-a;k=f-e;m=j-g;a=(b+a)/c;f=(f+e)/k;g=(j+g)/m;p.n11=2/c;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/k;p.n23=0;p.n24=-f;p.n31=0;p.n32=0;p.n33=-2/m;p.n34=-g;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var e=b[10]*b[5]-b[6]*b[9],f=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],i=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],m=-b[9]*b[0]+b[1]*b[8],D=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*i+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*e;a.m[1]=b*f;a.m[2]=b*g;a.m[3]=b*i;a.m[4]=b*p;a.m[5]=b*c;a.m[6]=b*k;a.m[7]=b*m;a.m[8]=b*D;return a}; +THREE.Matrix4.makeFrustum=function(a,b,e,f,g,i){var p,c,k;p=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(f-e);a=(b+a)/(b-a);e=(f+e)/(f-e);f=-(i+g)/(i-g);g=-2*i*g/(i-g);p.n11=c;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=k;p.n23=e;p.n24=0;p.n31=0;p.n32=0;p.n33=f;p.n34=g;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,e,f){var g;a=e*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,e,f)}; +THREE.Matrix4.makeOrtho=function(a,b,e,f,g,i){var p,c,k,m;p=new THREE.Matrix4;c=b-a;k=e-f;m=i-g;a=(b+a)/c;e=(e+f)/k;g=(i+g)/m;p.n11=2/c;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/k;p.n23=0;p.n24=-e;p.n31=0;p.n32=0;p.n33=-2/m;p.n34=-g;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p}; 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,f,e,g){this.a=a;this.b=b;this.c=f;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,f,e,g,j){this.a=a;this.b=b;this.c=f;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=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.Face3=function(a,b,e,f,g){this.a=a;this.b=b;this.c=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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,e,f,g,i){this.a=a;this.b=b;this.c=e;this.d=f;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.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.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; -THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;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],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,f=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[0])this.boundingBox.z[0]=a.position.z;else 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,f=this.vertices.length;b65535){m[c].counter+=1;k=m[c].hash+"_"+m[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:p,vertices:0}}this.geometryChunks[k].faces.push(e); -this.geometryChunks[k].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,f,e){this.fov=a;this.aspect=b;this.near=f;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.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); +THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;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], +z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,e=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,e=this.vertices.length;b65535){m[c].counter+=1;k=m[c].hash+"_"+m[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:p,vertices:0}}this.geometryChunks[k].faces.push(f);this.geometryChunks[k].vertices+=i}},toString:function(){return"THREE.Geometry ( vertices: "+ +this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +THREE.Camera=function(a,b,e,f){this.fov=a;this.aspect=b;this.near=e;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.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); this.position.subSelf(g);this.target.position.subSelf(g)};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;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true}; THREE.Object3D.prototype={updateMatrix:function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition); this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.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,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.autoUpdateMatrix=false}; -THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,f){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=f!==undefined?f:THREE.LineContinuous};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; +THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,e){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=e!==undefined?e:THREE.LineContinuous};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];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.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";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.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}}; THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; @@ -90,94 +91,97 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}}; THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(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,b,f,e,g,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter}; +THREE.Texture=function(a,b,e,f,g,i){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=i!==undefined?i: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;var Uniforms={clone:function(a){var b,f,e,g={};for(b in a){g[b]={};for(f in a[b]){e=a[b][f];g[b][f]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,f,e,g={};for(b=0;b=0&&t>=0&&r>=0&&v>=0)return true;else if(y<0&&t<0||r<0&&v<0)return false;else{if(y<0)u=Math.max(u,y/(y-t));else if(t<0)o=Math.min(o,y/(y-t));if(r<0)u=Math.max(u,r/(r-v));else if(v<0)o=Math.min(o,r/(r-v));if(oy&&G.z0&&O.z<1){x=M[A]=M[A]||new THREE.RenderableParticle;x.x=O.x/O.w;x.y=O.y/O.w;x.z=O.z;x.rotation=H.rotation.z;x.scale.x=H.scale.x*Math.abs(x.x-(O.x+i.projectionMatrix.n11)/(O.w+i.projectionMatrix.n14)); -x.scale.y=H.scale.y*Math.abs(x.y-(O.y+i.projectionMatrix.n22)/(O.w+i.projectionMatrix.n24));x.materials=H.materials;o.push(x);A++}}}}u&&o.sort(a);return o};this.unprojectVector=function(l,i){var u=new THREE.Matrix4;u.multiply(THREE.Matrix4.makeInvert(i.matrix),THREE.Matrix4.makeInvert(i.projectionMatrix));u.multiplyVector3(l);return l}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,e,g,j;this.domElement=document.createElement("div");this.setSize=function(p,c){f=p;e=c;g=f/2;j=e/2};this.render=function(p,c){var k,m,B,D,x,A,M,Q;a=b.projectScene(p,c);k=0;for(m=a.length;k0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}else if(Y instanceof THREE.PointLight){Z.sub(Y.position,R);Z.normalize();Y=J.dot(Z)*ca;if(Y>0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}}}function Na(w,R,J){if(J.opacity!=0){a(J.opacity);b(J.blending);var z, -I,Y,aa,ca,da;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){aa=J.map;ca=aa.width>>1;da=aa.height>>1;I=R.scale.x*c;Y=R.scale.y*k;J=I*ca;z=Y*da;C.set(w.x-J,w.y-z,w.x+J,w.y+z);if(U.instersects(C)){m.save();m.translate(w.x,w.y);m.rotate(-R.rotation);m.scale(I,-Y);m.translate(-ca,-da);m.drawImage(aa,0,0);m.restore()}}}else if(J instanceof THREE.ParticleCircleMaterial){if(N){V.r=ea.r+ma.r+na.r;V.g=ea.g+ma.g+na.g;V.b=ea.b+ma.b+na.b;o.r=J.color.r*V.r;o.g=J.color.g*V.g;o.b=J.color.b*V.b;o.updateStyleString()}else o.__styleString= -J.color.__styleString;J=R.scale.x*c;z=R.scale.y*k;C.set(w.x-J,w.y-z,w.x+J,w.y+z);if(U.instersects(C)){I=o.__styleString;if(Q!=I)m.fillStyle=Q=I;m.save();m.translate(w.x,w.y);m.rotate(-R.rotation);m.scale(J,z);m.beginPath();m.arc(0,0,1,0,La,true);m.closePath();m.fill();m.restore()}}}}function Oa(w,R,J,z){if(z.opacity!=0){a(z.opacity);b(z.blending);m.beginPath();m.moveTo(w.positionScreen.x,w.positionScreen.y);m.lineTo(R.positionScreen.x,R.positionScreen.y);m.closePath();if(z instanceof THREE.LineBasicMaterial){o.__styleString= -z.color.__styleString;w=z.linewidth;if(O!=w)m.lineWidth=O=w;w=o.__styleString;if(M!=w)m.strokeStyle=M=w;m.stroke();C.inflate(z.linewidth*2)}}}function Ha(w,R,J,z,I,Y){if(I.opacity!=0){a(I.opacity);b(I.blending);h=w.positionScreen.x;q=w.positionScreen.y;n=R.positionScreen.x;l=R.positionScreen.y;i=J.positionScreen.x;u=J.positionScreen.y;m.beginPath();m.moveTo(h,q);m.lineTo(n,l);m.lineTo(i,u);m.lineTo(h,q);m.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof -THREE.UVMapping&&ua(h,q,n,l,i,u,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){w=la.matrix;Z.copy(z.vertexNormalsWorld[0]);P=(Z.x*w.n11+Z.y*w.n12+Z.z*w.n13)*0.5+0.5;H=-(Z.x*w.n21+Z.y*w.n22+Z.z*w.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[1]);X=(Z.x*w.n11+Z.y*w.n12+Z.z*w.n13)*0.5+0.5;K=-(Z.x*w.n21+Z.y*w.n22+Z.z*w.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[2]);E= -(Z.x*w.n11+Z.y*w.n12+Z.z*w.n13)*0.5+0.5;F=-(Z.x*w.n21+Z.y*w.n22+Z.z*w.n23)*0.5+0.5;ua(h,q,n,l,i,u,I.env_map.image,P,H,X,K,E,F)}}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof THREE.UVMapping&&ua(h,q,n,l,i,u,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);b(THREE.SubtractiveBlending)}if(N)if(!I.wireframe&&I.shading==THREE.SmoothShading&& -z.vertexNormalsWorld.length==3){y.r=t.r=r.r=ea.r;y.g=t.g=r.g=ea.g;y.b=t.b=r.b=ea.b;ya(Y,z.v1.positionWorld,z.vertexNormalsWorld[0],y);ya(Y,z.v2.positionWorld,z.vertexNormalsWorld[1],t);ya(Y,z.v3.positionWorld,z.vertexNormalsWorld[2],r);v.r=(t.r+r.r)*0.5;v.g=(t.g+r.g)*0.5;v.b=(t.b+r.b)*0.5;S=Ia(y,t,r,v);ua(h,q,n,l,i,u,S,0,0,1,0,0,1)}else{V.r=ea.r;V.g=ea.g;V.b=ea.b;ya(Y,z.centroidWorld,z.normalWorld,V);o.r=I.color.r*V.r;o.g=I.color.g*V.g;o.b=I.color.b*V.b;o.updateStyleString();I.wireframe?za(o.__styleString, -I.wireframe_linewidth):Aa(o.__styleString)}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){W=la.near;G=la.far;y.r=y.g=y.b=1-Da(w.positionScreen.z,W,G);t.r=t.g=t.b=1-Da(R.positionScreen.z,W,G);r.r=r.g=r.b=1-Da(J.positionScreen.z,W,G);v.r=(t.r+r.r)*0.5;v.g=(t.g+r.g)*0.5;v.b=(t.b+r.b)*0.5;S=Ia(y,t,r,v);ua(h,q,n,l,i,u,S,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){o.r=Ea(z.normalWorld.x);o.g=Ea(z.normalWorld.y); -o.b=Ea(z.normalWorld.z);o.updateStyleString();I.wireframe?za(o.__styleString,I.wireframe_linewidth):Aa(o.__styleString)}}}function za(w,R){if(M!=w)m.strokeStyle=M=w;if(O!=R)m.lineWidth=O=R;m.stroke();C.inflate(R*2)}function Aa(w){if(Q!=w)m.fillStyle=Q=w;m.fill()}function ua(w,R,J,z,I,Y,aa,ca,da,ia,ga,ja,va){var oa,ka;oa=aa.width-1;ka=aa.height-1;ca*=oa;da*=ka;ia*=oa;ga*=ka;ja*=oa;va*=ka;J-=w;z-=R;I-=w;Y-=R;ia-=ca;ga-=da;ja-=ca;va-=da;ka=1/(ia*va-ja*ga);oa=(va*J-ga*I)*ka;ga=(va*z-ga*Y)*ka;J=(ia*I- -ja*J)*ka;z=(ia*Y-ja*z)*ka;w=w-oa*ca-J*da;R=R-ga*ca-z*da;m.save();m.transform(oa,ga,J,z,w,R);m.clip();m.drawImage(aa,0,0);m.restore()}function Ia(w,R,J,z){var I=~~(w.r*255),Y=~~(w.g*255);w=~~(w.b*255);var aa=~~(R.r*255),ca=~~(R.g*255);R=~~(R.b*255);var da=~~(J.r*255),ia=~~(J.g*255);J=~~(J.b*255);var ga=~~(z.r*255),ja=~~(z.g*255);z=~~(z.b*255);fa[0]=I<0?0:I>255?255:I;fa[1]=Y<0?0:Y>255?255:Y;fa[2]=w<0?0:w>255?255:w;fa[4]=aa<0?0:aa>255?255:aa;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=R<0?0:R>255?255:R;fa[8]=da< -0?0:da>255?255:da;fa[9]=ia<0?0:ia>255?255:ia;fa[10]=J<0?0:J>255?255:J;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ja<0?0:ja>255?255:ja;fa[14]=z<0?0:z>255?255:z;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(w,R,J){w=(w-R)/(J-R);return w*w*(3-2*w)}function Ea(w){w=(w+1)*0.5;return w<0?0:w>1?1:w}function Fa(w,R){var J=R.x-w.x,z=R.y-w.y,I=1/Math.sqrt(J*J+z*z);J*=I;z*=I;R.x+=J;R.y+=z;w.x-=J;w.y-=z}var Ba,Ja,$,ha,qa,Ga,Ka,wa;m.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();f=e.projectScene(ba, -la,this.sortElements);(N=ba.lights.length>0)&&Ma(ba);Ba=0;for(Ja=f.length;Ba0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}else if(F instanceof THREE.PointLight){u.sub(F.position,H.centroidWorld);u.normalize();U=H.normalWorld.dot(u)*F.intensity;if(U>0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}}}function b(P,H,X,K,E,F){r=e(v++);r.setAttribute("d","M "+P.positionScreen.x+ -" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(L){h.r=q.r;h.g=q.g;h.b=q.b;a(F,K,h);d.r=E.color.r*h.r;d.g=E.color.g*h.g;d.b=E.color.b*h.b;d.updateStyleString()}else d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){i=1-E.__2near/(E.__farPlusNear-K.z*E.__farMinusNear); -d.setRGB(i,i,i)}else E instanceof THREE.MeshNormalMaterial&&d.setRGB(g(K.normalWorld.x),g(K.normalWorld.y),g(K.normalWorld.z));E.wireframe?r.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):r.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+E.opacity);c.appendChild(r)}function f(P,H,X,K,E,F,U){r=e(v++);r.setAttribute("d", -"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(L){h.r=q.r;h.g=q.g;h.b=q.b;a(U,E,h);d.r=F.color.r*h.r;d.g=F.color.g*h.g;d.b=F.color.b*h.b;d.updateStyleString()}else d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){i= -1-F.__2near/(F.__farPlusNear-E.z*F.__farMinusNear);d.setRGB(i,i,i)}else F instanceof THREE.MeshNormalMaterial&&d.setRGB(g(E.normalWorld.x),g(E.normalWorld.y),g(E.normalWorld.z));F.wireframe?r.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):r.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+F.opacity);c.appendChild(r)} -function e(P){if(o[P]==null){o[P]=document.createElementNS("http://www.w3.org/2000/svg","path");S==0&&o[P].setAttribute("shape-rendering","crispEdges");return o[P]}return o[P]}function g(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var j=null,p=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,B,D,x,A,M,Q,O=new THREE.Rectangle,s=new THREE.Rectangle,L=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),q=new THREE.Color(0),n=new THREE.Color(0), -l=new THREE.Color(0),i,u=new THREE.Vector3,o=[],y=[],t=[],r,v,W,G,S=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(P){switch(P){case "high":S=1;break;case "low":S=0}};this.setSize=function(P,H){k=P;m=H;B=k/2;D=m/2;c.setAttribute("viewBox",-B+" "+-D+" "+k+" "+m);c.setAttribute("width",k);c.setAttribute("height",m);O.set(-B,-D,B,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(P,H){var X,K, -E,F,U,T,C,N;this.autoClear&&this.clear();j=p.projectScene(P,H,this.sortElements);G=W=v=0;if(L=P.lights.length>0){C=P.lights;q.setRGB(0,0,0);n.setRGB(0,0,0);l.setRGB(0,0,0);X=0;for(K=C.length;X0){E.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(X),c.STATIC_DRAW)}E.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(W),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),c.STATIC_DRAW);E.__webGLFaceCount=W.length;E.__webGLLineCount=G.length}};this.renderBuffer=function(d,h,q,n,l){var i,u,o,y;if(!n.program){if(n instanceof THREE.MeshDepthMaterial){b(n,THREE.ShaderLib.depth);n.uniforms.mNear.value=d.near;n.uniforms.mFar.value=d.far}else if(n instanceof -THREE.MeshNormalMaterial)b(n,THREE.ShaderLib.normal);else if(n instanceof THREE.MeshBasicMaterial){b(n,THREE.ShaderLib.basic);f(n,q)}else if(n instanceof THREE.MeshLambertMaterial){b(n,THREE.ShaderLib.lambert);f(n,q)}else if(n instanceof THREE.MeshPhongMaterial){b(n,THREE.ShaderLib.phong);f(n,q)}else if(n instanceof THREE.LineBasicMaterial){b(n,THREE.ShaderLib.basic);e(n,q)}var t,r,v;t=y=u=0;for(r=h.length;t0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.map?"#define USE_MAP":"",y.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(r, -g("fragment",v+u));c.attachShader(r,g("vertex",y+t));c.linkProgram(r);c.getProgramParameter(r,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(r,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");r.uniforms={};r.attributes={};n.program=r;u=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(i in n.uniforms)u.push(i);i=n.program;t=0;for(r=u.length;t=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLNormalBuffer); -c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.normal)}if(o.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLTangentBuffer);c.vertexAttribPointer(o.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.tangent)}if(o.uv>=0)if(l.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLUVBuffer);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.uv)}else c.disableVertexAttribArray(o.uv);if(n.wireframe||n instanceof THREE.LineBasicMaterial){o= -n.wireframe_linewidth!==undefined?n.wireframe_linewidth:n.linewidth!==undefined?n.linewidth:1;n=n instanceof THREE.LineBasicMaterial&&l.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(o);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);c.drawElements(n,l.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,l.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,h,q,n,l,i,u){var o,y,t,r,v;t=0;for(r= -n.materials.length;t=0;q--){n=d.__webGLObjects[q].object;h==n&&d.__webGLObjects.splice(q,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix(); -m.multiply(h.matrix,d.matrix);x.set(m.flatten());B=THREE.Matrix4.makeInvert3x3(m).transpose();M.set(B.m);Q.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,D);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,x);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,A);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,M);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,Q)};this.loadCamera=function(d,h){c.uniform3f(d.uniforms.cameraPosition,h.position.x, -h.position.y,h.position.z)};this.setBlending=function(d){switch(d){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(d,h){if(d){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}; -this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; -THREE.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, 1.0 ), 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\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\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_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\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\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,b,e){this.color=new THREE.Color(a);this.near=b||1;this.far=e||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4}; +THREE.Projector=function(){function a(l,t){return t.z-l.z}function b(l,t){var r=0,q=1,z=l.z+l.w,u=t.z+t.w,j=-l.z+l.w,w=-t.z+t.w;if(z>=0&&u>=0&&j>=0&&w>=0)return true;else if(z<0&&u<0||j<0&&w<0)return false;else{if(z<0)r=Math.max(r,z/(z-u));else if(u<0)q=Math.min(q,z/(z-u));if(j<0)r=Math.max(r,j/(j-w));else if(w<0)q=Math.min(q,j/(j-w));if(qz&&A.z0&&U.z<1){y=R[C]=R[C]||new THREE.RenderableParticle;y.x=U.x/U.w;y.y=U.y/U.w;y.z=U.z;y.rotation=I.rotation.z;y.scale.x=I.scale.x*Math.abs(y.x-(U.x+t.projectionMatrix.n11)/(U.w+t.projectionMatrix.n14)); +y.scale.y=I.scale.y*Math.abs(y.y-(U.y+t.projectionMatrix.n22)/(U.w+t.projectionMatrix.n24));y.materials=I.materials;q.push(y);C++}}}}r&&q.sort(a);return q};this.unprojectVector=function(l,t){var r=new THREE.Matrix4;r.multiply(THREE.Matrix4.makeInvert(t.matrix),THREE.Matrix4.makeInvert(t.projectionMatrix));r.multiplyVector3(l);return l}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,f,g,i;this.domElement=document.createElement("div");this.setSize=function(p,c){e=p;f=c;g=e/2;i=f/2};this.render=function(p,c){var k,m,D,F,y,C,R,W;a=b.projectScene(p,c);k=0;for(m=a.length;k0){B.r+=ca.r*$;B.g+=ca.g*$;B.b+=ca.b*$}}else if($ instanceof THREE.PointLight){Y.sub($.position,X);Y.normalize();$=O.dot(Y)*fa;if($>0){B.r+=ca.r*$;B.g+=ca.g*$;B.b+=ca.b*$}}}}function Na(x,X,O){if(O.opacity!=0){a(O.opacity);b(O.blending);var B, +L,$,ca,fa,ga;if(O instanceof THREE.ParticleBasicMaterial){if(O.map){ca=O.map;fa=ca.width>>1;ga=ca.height>>1;L=X.scale.x*c;$=X.scale.y*k;O=L*fa;B=$*ga;v.set(x.x-O,x.y-B,x.x+O,x.y+B);if(T.instersects(v)){m.save();m.translate(x.x,x.y);m.rotate(-X.rotation);m.scale(L,-$);m.translate(-fa,-ga);m.drawImage(ca,0,0);m.restore()}}}else if(O instanceof THREE.ParticleCircleMaterial){if(G){K.r=ea.r+ba.r+Z.r;K.g=ea.g+ba.g+Z.g;K.b=ea.b+ba.b+Z.b;q.r=O.color.r*K.r;q.g=O.color.g*K.g;q.b=O.color.b*K.b;q.updateStyleString()}else q.__styleString= +O.color.__styleString;O=X.scale.x*c;B=X.scale.y*k;v.set(x.x-O,x.y-B,x.x+O,x.y+B);if(T.instersects(v)){L=q.__styleString;if(W!=L)m.fillStyle=W=L;m.save();m.translate(x.x,x.y);m.rotate(-X.rotation);m.scale(O,B);m.beginPath();m.arc(0,0,1,0,ia,true);m.closePath();m.fill();m.restore()}}}}function Oa(x,X,O,B){if(B.opacity!=0){a(B.opacity);b(B.blending);m.beginPath();m.moveTo(x.positionScreen.x,x.positionScreen.y);m.lineTo(X.positionScreen.x,X.positionScreen.y);m.closePath();if(B instanceof THREE.LineBasicMaterial){q.__styleString= +B.color.__styleString;x=B.linewidth;if(U!=x)m.lineWidth=U=x;x=q.__styleString;if(R!=x)m.strokeStyle=R=x;m.stroke();v.inflate(B.linewidth*2)}}}function Ia(x,X,O,B,L,$){if(L.opacity!=0){a(L.opacity);b(L.blending);h=x.positionScreen.x;o=x.positionScreen.y;n=X.positionScreen.x;l=X.positionScreen.y;t=O.positionScreen.x;r=O.positionScreen.y;m.beginPath();m.moveTo(h,o);m.lineTo(n,l);m.lineTo(t,r);m.lineTo(h,o);m.closePath();if(L instanceof THREE.MeshBasicMaterial)if(L.map)L.map.image.loaded&&L.map.mapping instanceof +THREE.UVMapping&&va(h,o,n,l,t,r,L.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(L.env_map){if(L.env_map.image.loaded)if(L.env_map.mapping instanceof THREE.SphericalReflectionMapping){x=qa.matrix;Y.copy(B.vertexNormalsWorld[0]);M=(Y.x*x.n11+Y.y*x.n12+Y.z*x.n13)*0.5+0.5;I=-(Y.x*x.n21+Y.y*x.n22+Y.z*x.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[1]);V=(Y.x*x.n11+Y.y*x.n12+Y.z*x.n13)*0.5+0.5;P=-(Y.x*x.n21+Y.y*x.n22+Y.z*x.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[2]);E= +(Y.x*x.n11+Y.y*x.n12+Y.z*x.n13)*0.5+0.5;H=-(Y.x*x.n21+Y.y*x.n22+Y.z*x.n23)*0.5+0.5;va(h,o,n,l,t,r,L.env_map.image,M,I,V,P,E,H)}}else L.wireframe?Aa(L.color.__styleString,L.wireframe_linewidth):Ba(L.color.__styleString);else if(L instanceof THREE.MeshLambertMaterial){if(L.map&&!L.wireframe){L.map.mapping instanceof THREE.UVMapping&&va(h,o,n,l,t,r,L.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);b(THREE.SubtractiveBlending)}if(G)if(!L.wireframe&&L.shading==THREE.SmoothShading&& +B.vertexNormalsWorld.length==3){z.r=u.r=j.r=ea.r;z.g=u.g=j.g=ea.g;z.b=u.b=j.b=ea.b;za($,B.v1.positionWorld,B.vertexNormalsWorld[0],z);za($,B.v2.positionWorld,B.vertexNormalsWorld[1],u);za($,B.v3.positionWorld,B.vertexNormalsWorld[2],j);w.r=(u.r+j.r)*0.5;w.g=(u.g+j.g)*0.5;w.b=(u.b+j.b)*0.5;J=Ja(z,u,j,w);va(h,o,n,l,t,r,J,0,0,1,0,0,1)}else{K.r=ea.r;K.g=ea.g;K.b=ea.b;za($,B.centroidWorld,B.normalWorld,K);q.r=L.color.r*K.r;q.g=L.color.g*K.g;q.b=L.color.b*K.b;q.updateStyleString();L.wireframe?Aa(q.__styleString, +L.wireframe_linewidth):Ba(q.__styleString)}else L.wireframe?Aa(L.color.__styleString,L.wireframe_linewidth):Ba(L.color.__styleString)}else if(L instanceof THREE.MeshDepthMaterial){S=qa.near;A=qa.far;z.r=z.g=z.b=1-Ea(x.positionScreen.z,S,A);u.r=u.g=u.b=1-Ea(X.positionScreen.z,S,A);j.r=j.g=j.b=1-Ea(O.positionScreen.z,S,A);w.r=(u.r+j.r)*0.5;w.g=(u.g+j.g)*0.5;w.b=(u.b+j.b)*0.5;J=Ja(z,u,j,w);va(h,o,n,l,t,r,J,0,0,1,0,0,1)}else if(L instanceof THREE.MeshNormalMaterial){q.r=Fa(B.normalWorld.x);q.g=Fa(B.normalWorld.y); +q.b=Fa(B.normalWorld.z);q.updateStyleString();L.wireframe?Aa(q.__styleString,L.wireframe_linewidth):Ba(q.__styleString)}}}function Aa(x,X){if(R!=x)m.strokeStyle=R=x;if(U!=X)m.lineWidth=U=X;m.stroke();v.inflate(X*2)}function Ba(x){if(W!=x)m.fillStyle=W=x;m.fill()}function va(x,X,O,B,L,$,ca,fa,ga,ma,ka,na,wa){var ra,oa;ra=ca.width-1;oa=ca.height-1;fa*=ra;ga*=oa;ma*=ra;ka*=oa;na*=ra;wa*=oa;O-=x;B-=X;L-=x;$-=X;ma-=fa;ka-=ga;na-=fa;wa-=ga;oa=1/(ma*wa-na*ka);ra=(wa*O-ka*L)*oa;ka=(wa*B-ka*$)*oa;O=(ma*L- +na*O)*oa;B=(ma*$-na*B)*oa;x=x-ra*fa-O*ga;X=X-ka*fa-B*ga;m.save();m.transform(ra,ka,O,B,x,X);m.clip();m.drawImage(ca,0,0);m.restore()}function Ja(x,X,O,B){var L=~~(x.r*255),$=~~(x.g*255);x=~~(x.b*255);var ca=~~(X.r*255),fa=~~(X.g*255);X=~~(X.b*255);var ga=~~(O.r*255),ma=~~(O.g*255);O=~~(O.b*255);var ka=~~(B.r*255),na=~~(B.g*255);B=~~(B.b*255);ha[0]=L<0?0:L>255?255:L;ha[1]=$<0?0:$>255?255:$;ha[2]=x<0?0:x>255?255:x;ha[4]=ca<0?0:ca>255?255:ca;ha[5]=fa<0?0:fa>255?255:fa;ha[6]=X<0?0:X>255?255:X;ha[8]=ga< +0?0:ga>255?255:ga;ha[9]=ma<0?0:ma>255?255:ma;ha[10]=O<0?0:O>255?255:O;ha[12]=ka<0?0:ka>255?255:ka;ha[13]=na<0?0:na>255?255:na;ha[14]=B<0?0:B>255?255:B;ja.putImageData(Da,0,0);ya.drawImage(pa,0,0);return ua}function Ea(x,X,O){x=(x-X)/(O-X);return x*x*(3-2*x)}function Fa(x){x=(x+1)*0.5;return x<0?0:x>1?1:x}function Ga(x,X){var O=X.x-x.x,B=X.y-x.y,L=1/Math.sqrt(O*O+B*B);O*=L;B*=L;X.x+=O;X.y+=B;x.x-=O;x.y-=B}var Ca,Ka,aa,la,ta,Ha,La,xa;m.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();e=f.projectScene(da, +qa,this.sortElements);(G=da.lights.length>0)&&Ma(da);Ca=0;for(Ka=e.length;Ca0){V.r+=H.color.r*T;V.g+=H.color.g*T;V.b+=H.color.b*T}}else if(H instanceof THREE.PointLight){r.sub(H.position,I.centroidWorld);r.normalize();T=I.normalWorld.dot(r)*H.intensity;if(T>0){V.r+=H.color.r*T;V.g+=H.color.g*T;V.b+=H.color.b*T}}}}function b(M,I,V,P,E,H){j=f(w++);j.setAttribute("d","M "+M.positionScreen.x+ +" "+M.positionScreen.y+" L "+I.positionScreen.x+" "+I.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(Q){h.r=o.r;h.g=o.g;h.b=o.b;a(H,P,h);d.r=E.color.r*h.r;d.g=E.color.g*h.g;d.b=E.color.b*h.b;d.updateStyleString()}else d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){t=1-E.__2near/(E.__farPlusNear-P.z*E.__farMinusNear); +d.setRGB(t,t,t)}else E instanceof THREE.MeshNormalMaterial&&d.setRGB(g(P.normalWorld.x),g(P.normalWorld.y),g(P.normalWorld.z));E.wireframe?j.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):j.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+E.opacity);c.appendChild(j)}function e(M,I,V,P,E,H,T){j=f(w++);j.setAttribute("d", +"M "+M.positionScreen.x+" "+M.positionScreen.y+" L "+I.positionScreen.x+" "+I.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)d.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(Q){h.r=o.r;h.g=o.g;h.b=o.b;a(T,E,h);d.r=H.color.r*h.r;d.g=H.color.g*h.g;d.b=H.color.b*h.b;d.updateStyleString()}else d.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){t= +1-H.__2near/(H.__farPlusNear-E.z*H.__farMinusNear);d.setRGB(t,t,t)}else H instanceof THREE.MeshNormalMaterial&&d.setRGB(g(E.normalWorld.x),g(E.normalWorld.y),g(E.normalWorld.z));H.wireframe?j.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):j.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+H.opacity);c.appendChild(j)} +function f(M){if(q[M]==null){q[M]=document.createElementNS("http://www.w3.org/2000/svg","path");J==0&&q[M].setAttribute("shape-rendering","crispEdges");return q[M]}return q[M]}function g(M){return M<0?Math.min((1+M)*0.5,0.5):0.5+Math.min(M*0.5,0.5)}var i=null,p=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,D,F,y,C,R,W,U=new THREE.Rectangle,s=new THREE.Rectangle,Q=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),o=new THREE.Color(0),n=new THREE.Color(0), +l=new THREE.Color(0),t,r=new THREE.Vector3,q=[],z=[],u=[],j,w,S,A,J=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(M){switch(M){case "high":J=1;break;case "low":J=0}};this.setSize=function(M,I){k=M;m=I;D=k/2;F=m/2;c.setAttribute("viewBox",-D+" "+-F+" "+k+" "+m);c.setAttribute("width",k);c.setAttribute("height",m);U.set(-D,-F,D,F)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(M,I){var V,P, +E,H,T,N,v,G;this.autoClear&&this.clear();i=p.projectScene(M,I,this.sortElements);A=S=w=0;if(Q=M.lights.length>0){v=M.lights;o.setRGB(0,0,0);n.setRGB(0,0,0);l.setRGB(0,0,0);V=0;for(P=v.length;V0){c.bindBuffer(c.ARRAY_BUFFER,d.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,ea,o)}if(l){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,ia,o);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer); +c.bufferData(c.ELEMENT_ARRAY_BUFFER,Y,o)}};this.renderBuffer=function(d,h,o,n,l){var t,r,q,z;if(!n.program){if(n instanceof THREE.MeshDepthMaterial){b(n,THREE.ShaderLib.depth);n.uniforms.mNear.value=d.near;n.uniforms.mFar.value=d.far}else if(n instanceof THREE.MeshNormalMaterial)b(n,THREE.ShaderLib.normal);else if(n instanceof THREE.MeshBasicMaterial){b(n,THREE.ShaderLib.basic);e(n,o)}else if(n instanceof THREE.MeshLambertMaterial){b(n,THREE.ShaderLib.lambert);e(n,o)}else if(n instanceof THREE.MeshPhongMaterial){b(n, +THREE.ShaderLib.phong);e(n,o)}else if(n instanceof THREE.LineBasicMaterial){b(n,THREE.ShaderLib.basic);f(n,o)}var u,j,w;u=z=r=0;for(j=h.length;u0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+z.maxDirLights,"#define MAX_POINT_LIGHTS "+z.maxPointLights,z.map?"#define USE_MAP":"",z.env_map? +"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(j,g("fragment",w+r));c.attachShader(j,g("vertex",z+u));c.linkProgram(j);c.getProgramParameter(j,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(j,c.VALIDATE_STATUS)+ +", gl error ["+c.getError()+"]");j.uniforms={};j.attributes={};n.program=j;r=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in n.uniforms)r.push(t);t=n.program;u=0;for(j=r.length;u=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLNormalBuffer);c.vertexAttribPointer(q.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.normal)}if(q.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLTangentBuffer);c.vertexAttribPointer(q.tangent,4,c.FLOAT, +false,0,0);c.enableVertexAttribArray(q.tangent)}if(q.uv>=0)if(l.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLUVBuffer);c.vertexAttribPointer(q.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.uv)}else c.disableVertexAttribArray(q.uv);if(n.wireframe||n instanceof THREE.LineBasicMaterial){q=n.wireframe_linewidth!==undefined?n.wireframe_linewidth:n.linewidth!==undefined?n.linewidth:1;n=n instanceof THREE.LineBasicMaterial&&l.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(q);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +l.__webGLLineBuffer);c.drawElements(n,l.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,l.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,h,o,n,l,t,r){var q,z,u,j,w;u=0;for(j=n.materials.length;u=0;o--){n=d.__webGLObjects[o].object;h==n&&d.__webGLObjects.splice(o,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix();m.multiply(h.matrix,d.matrix);y.set(m.flatten());D=THREE.Matrix4.makeInvert3x3(m).transpose();R.set(D.m);W.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,F);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,y);c.uniformMatrix4fv(d.uniforms.projectionMatrix, +false,C);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,R);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,W)};this.loadCamera=function(d,h){c.uniform3f(d.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=function(d){switch(d){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling= +function(d,h){if(d){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; +THREE.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, 1.0 ), 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\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\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_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\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\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 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"}; THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv", diff --git a/build/ThreeDebug.js b/build/ThreeDebug.js index f20a6387..91f2f367 100644 --- a/build/ThreeDebug.js +++ b/build/ThreeDebug.js @@ -1,68 +1,69 @@ // 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,b,f){this.r=a;this.g=b;this.b=f;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)+ +THREE.Color.prototype={setRGB:function(a,b,e){this.r=a;this.g=b;this.b=e;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,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* -this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,f){this.x=a||0;this.y=b||0;this.z=f||0}; -THREE.Vector3.prototype={set:function(a,b,f){this.x=a;this.y=b;this.z=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, -cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,f=this.y,e=this.z;this.x=f*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-f*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},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 b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+f*f+a*a)},distanceToSquared:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return b*b+f*f+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,b,e){this.x=a||0;this.y=b||0;this.z=e||0}; +THREE.Vector3.prototype={set:function(a,b,e){this.x=a;this.y=b;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, +cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-b*a.z;this.z=b*a.y-e*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},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 b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+e*e+a*a)},distanceToSquared:function(a){var b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return b*b+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,b,f,e){this.x=a||0;this.y=b||0;this.z=f||0;this.w=e||1}; -THREE.Vector4.prototype={set:function(a,b,f,e){this.x=a;this.y=b;this.z=f;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; +THREE.Vector4=function(a,b,e,f){this.x=a||0;this.y=b||0;this.z=e||0;this.w=f||1}; +THREE.Vector4.prototype={set:function(a,b,e,f){this.x=a;this.y=b;this.z=e;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,f,e=a.objects,g=[];a=0;for(b=e.length;a0&&O>0&&q+O<1}var f,e,g,j,p,c,k,m,B,D, -x,A=a.geometry,M=A.vertices,Q=[];f=0;for(e=A.faces.length;fk?e:k;g=g>m? -g:m}a()};this.add3Points=function(k,m,B,D,x,A){if(c){c=false;b=kB?k>x?k:x:B>x?B:x;g=m>D?m>A?m:A:D>A?D:A}else{b=kB?k>x?k>e?k:e:x>e?x:e:B>x?B>e?B:e:x>e?x:e;g=m>D?m>A?m>g?m:g:A>g?A:g:D>A?D>g?D:g:A>g?A:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();f=k.getTop();e=k.getRight();g=k.getBottom()}else{b=bk.getRight()?e:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;f-=k;e+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();f=f>k.getTop()?f:k.getTop();e=e=0&&Math.min(g,k.getBottom())-Math.max(f,k.getTop())>=0};this.empty=function(){c=true;g=e=f=b=0;a()};this.isEmpty=function(){return c};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+f+", bottom: "+g+", width: "+j+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; -THREE.Matrix4=function(a,b,f,e,g,j,p,c,k,m,B,D,x,A,M,Q){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=e||0;this.n21=g||0;this.n22=j||1;this.n23=p||0;this.n24=c||0;this.n31=k||0;this.n32=m||0;this.n33=B||1;this.n34=D||0;this.n41=x||0;this.n42=A||0;this.n43=M||0;this.n44=Q||1}; -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,f,e,g,j,p,c,k,m,B,D,x,A,M,Q){this.n11=a;this.n12=b;this.n13=f;this.n14=e;this.n21=g;this.n22=j;this.n23=p;this.n24=c;this.n31=k;this.n32=m;this.n33=B;this.n34=D;this.n41=x;this.n42=A;this.n43=M;this.n44=Q;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,f){var e=new THREE.Vector3,g=new THREE.Vector3,j=new THREE.Vector3;j.sub(a,b).normalize();e.cross(f,j).normalize();g.cross(j,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=j.x; -this.n32=j.y;this.n33=j.z;this.n34=-j.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,e=a.z,g=1/(this.n41*b+this.n42*f+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*f+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*f+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,f=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*f+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*f+this.n23*e+this.n24* -g;a.z=this.n31*b+this.n32*f+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*f+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 f=a.n11,e=a.n12,g=a.n13,j=a.n14,p=a.n21,c=a.n22,k=a.n23,m=a.n24,B=a.n31,D=a.n32, -x=a.n33,A=a.n34,M=a.n41,Q=a.n42,O=a.n43,s=a.n44,L=b.n11,d=b.n12,h=b.n13,q=b.n14,n=b.n21,l=b.n22,i=b.n23,u=b.n24,o=b.n31,y=b.n32,t=b.n33,r=b.n34,w=b.n41,W=b.n42,G=b.n43,T=b.n44;this.n11=f*L+e*n+g*o+j*w;this.n12=f*d+e*l+g*y+j*W;this.n13=f*h+e*i+g*t+j*G;this.n14=f*q+e*u+g*r+j*T;this.n21=p*L+c*n+k*o+m*w;this.n22=p*d+c*l+k*y+m*W;this.n23=p*h+c*i+k*t+m*G;this.n24=p*q+c*u+k*r+m*T;this.n31=B*L+D*n+x*o+A*w;this.n32=B*d+D*l+x*y+A*W;this.n33=B*h+D*i+x*t+A*G;this.n34=B*q+D*u+x*r+A*T;this.n41=M*L+Q*n+O*o+s*w; -this.n42=M*d+Q*l+O*y+s*W;this.n43=M*h+Q*i+O*t+s*G;this.n44=M*q+Q*u+O*r+s*T;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,e=this.n13,g=this.n14,j=this.n21,p=this.n22,c=this.n23,k=this.n24,m=this.n31,B=this.n32,D=this.n33,x=this.n34,A=this.n41,M=this.n42,Q=this.n43,O=this.n44,s=a.n11,L=a.n21,d=a.n31,h=a.n41,q=a.n12,n=a.n22,l=a.n32,i=a.n42,u=a.n13,o=a.n23,y=a.n33,t=a.n43,r=a.n14,w=a.n24,W=a.n34;a=a.n44;this.n11=b*s+f*L+e*d+g*h;this.n12=b*q+f*n+e*l+g*i;this.n13=b*u+f*o+e*y+g*t;this.n14= -b*r+f*w+e*W+g*a;this.n21=j*s+p*L+c*d+k*h;this.n22=j*q+p*n+c*l+k*i;this.n23=j*u+p*o+c*y+k*t;this.n24=j*r+p*w+c*W+k*a;this.n31=m*s+B*L+D*d+x*h;this.n32=m*q+B*n+D*l+x*i;this.n33=m*u+B*o+D*y+x*t;this.n34=m*r+B*w+D*W+x*a;this.n41=A*s+M*L+Q*d+O*h;this.n42=A*q+M*n+Q*l+O*i;this.n43=A*u+M*o+Q*y+O*t;this.n44=A*r+M*w+Q*W+O*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*= +THREE.Ray.prototype={intersectScene:function(a){var b,e,f=a.objects,g=[];a=0;for(b=f.length;a0&&U>0&&o+U<1}var e,f,g,i,p,c,k,l,D,F, +y,C=a.geometry,S=C.vertices,W=[];e=0;for(f=C.faces.length;ek?f:k;g=g>l? +g:l}a()};this.add3Points=function(k,l,D,F,y,C){if(c){c=false;b=kD?k>y?k:y:D>y?D:y;g=l>F?l>C?l:C:F>C?F:C}else{b=kD?k>y?k>f?k:f:y>f?y:f:D>y?D>f?D:f:y>f?y:f;g=l>F?l>C?l>g?l:g:C>g?C:g:F>C?F>g?F:g:C>g?C:g}a()};this.addRectangle=function(k){if(c){c=false;b=k.getLeft();e=k.getTop();f=k.getRight();g=k.getBottom()}else{b=bk.getRight()?f:k.getRight();g=g>k.getBottom()?g:k.getBottom()}a()};this.inflate=function(k){b-=k;e-=k;f+=k;g+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();e=e>k.getTop()?e:k.getTop();f=f=0&&Math.min(g,k.getBottom())-Math.max(e,k.getTop())>=0};this.empty=function(){c=true;g=f=e=b=0;a()};this.isEmpty=function(){return c};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+f+", top: "+e+", bottom: "+g+", width: "+i+", height: "+p+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Matrix4=function(a,b,e,f,g,i,p,c,k,l,D,F,y,C,S,W){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=f||0;this.n21=g||0;this.n22=i||1;this.n23=p||0;this.n24=c||0;this.n31=k||0;this.n32=l||0;this.n33=D||1;this.n34=F||0;this.n41=y||0;this.n42=C||0;this.n43=S||0;this.n44=W||1}; +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,e,f,g,i,p,c,k,l,D,F,y,C,S,W){this.n11=a;this.n12=b;this.n13=e;this.n14=f;this.n21=g;this.n22=i;this.n23=p;this.n24=c;this.n31=k;this.n32=l;this.n33=D;this.n34=F;this.n41=y;this.n42=C;this.n43=S;this.n44=W;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,e){var f=new THREE.Vector3,g=new THREE.Vector3,i=new THREE.Vector3;i.sub(a,b).normalize();f.cross(e,i).normalize();g.cross(i,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=i.x; +this.n32=i.y;this.n33=i.z;this.n34=-i.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,f=a.z,g=1/(this.n41*b+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*f+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*f+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,f=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*f+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*f+this.n24* +g;a.z=this.n31*b+this.n32*e+this.n33*f+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*f+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 e=a.n11,f=a.n12,g=a.n13,i=a.n14,p=a.n21,c=a.n22,k=a.n23,l=a.n24,D=a.n31,F=a.n32, +y=a.n33,C=a.n34,S=a.n41,W=a.n42,U=a.n43,s=a.n44,R=b.n11,d=b.n12,h=b.n13,o=b.n14,n=b.n21,m=b.n22,t=b.n23,r=b.n24,q=b.n31,z=b.n32,u=b.n33,j=b.n34,w=b.n41,T=b.n42,A=b.n43,K=b.n44;this.n11=e*R+f*n+g*q+i*w;this.n12=e*d+f*m+g*z+i*T;this.n13=e*h+f*t+g*u+i*A;this.n14=e*o+f*r+g*j+i*K;this.n21=p*R+c*n+k*q+l*w;this.n22=p*d+c*m+k*z+l*T;this.n23=p*h+c*t+k*u+l*A;this.n24=p*o+c*r+k*j+l*K;this.n31=D*R+F*n+y*q+C*w;this.n32=D*d+F*m+y*z+C*T;this.n33=D*h+F*t+y*u+C*A;this.n34=D*o+F*r+y*j+C*K;this.n41=S*R+W*n+U*q+s*w; +this.n42=S*d+W*m+U*z+s*T;this.n43=S*h+W*t+U*u+s*A;this.n44=S*o+W*r+U*j+s*K;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,f=this.n13,g=this.n14,i=this.n21,p=this.n22,c=this.n23,k=this.n24,l=this.n31,D=this.n32,F=this.n33,y=this.n34,C=this.n41,S=this.n42,W=this.n43,U=this.n44,s=a.n11,R=a.n21,d=a.n31,h=a.n41,o=a.n12,n=a.n22,m=a.n32,t=a.n42,r=a.n13,q=a.n23,z=a.n33,u=a.n43,j=a.n14,w=a.n24,T=a.n34;a=a.n44;this.n11=b*s+e*R+f*d+g*h;this.n12=b*o+e*n+f*m+g*t;this.n13=b*r+e*q+f*z+g*u;this.n14= +b*j+e*w+f*T+g*a;this.n21=i*s+p*R+c*d+k*h;this.n22=i*o+p*n+c*m+k*t;this.n23=i*r+p*q+c*z+k*u;this.n24=i*j+p*w+c*T+k*a;this.n31=l*s+D*R+F*d+y*h;this.n32=l*o+D*n+F*m+y*t;this.n33=l*r+D*q+F*z+y*u;this.n34=l*j+D*w+F*T+y*a;this.n41=C*s+S*R+W*d+U*h;this.n42=C*o+S*n+W*m+U*t;this.n43=C*r+S*q+W*z+U*u;this.n44=C*j+S*w+W*T+U*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34* -this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,f,e){var g=b[f];b[f]=b[e]; -b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, -this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,f){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=f;return e}; -THREE.Matrix4.scaleMatrix=function(a,b,f){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=f;return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,e=Math.cos(b),g=Math.sin(b),j=1-e,p=a.x,c=a.y,k=a.z;f.n11=j*p*p+e;f.n12=j*p*c-g*k;f.n13=j*p*k+g*c;f.n21=j*p*c+g*k;f.n22=j*c*c+e;f.n23=j*c*k-g*p;f.n31=j*p*k-g*c;f.n32=j*c*k+g*p;f.n33=j*k*k+e;return f}; +this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,e,f){var g=b[e];b[e]=b[f]; +b[f]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, +this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,e){var f=new THREE.Matrix4;f.n14=a;f.n24=b;f.n34=e;return f}; +THREE.Matrix4.scaleMatrix=function(a,b,e){var f=new THREE.Matrix4;f.n11=a;f.n22=b;f.n33=e;return f};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var e=new THREE.Matrix4,f=Math.cos(b),g=Math.sin(b),i=1-f,p=a.x,c=a.y,k=a.z;e.n11=i*p*p+f;e.n12=i*p*c-g*k;e.n13=i*p*k+g*c;e.n21=i*p*c+g*k;e.n22=i*c*c+f;e.n23=i*c*k-g*p;e.n31=i*p*k-g*c;e.n32=i*c*k+g*p;e.n33=i*k*k+f;return e}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],j=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],m=-b[9]*b[0]+b[1]*b[8],B=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*j+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*j;a.m[4]=b*p;a.m[5]=b*c;a.m[6]=b*k;a.m[7]=b*m;a.m[8]=b*B;return a}; -THREE.Matrix4.makeFrustum=function(a,b,f,e,g,j){var p,c,k;p=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(e-f);a=(b+a)/(b-a);f=(e+f)/(e-f);e=-(j+g)/(j-g);g=-2*j*g/(j-g);p.n11=c;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=k;p.n23=f;p.n24=0;p.n31=0;p.n32=0;p.n33=e;p.n34=g;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,f,e){var g;a=f*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,f,e)}; -THREE.Matrix4.makeOrtho=function(a,b,f,e,g,j){var p,c,k,m;p=new THREE.Matrix4;c=b-a;k=f-e;m=j-g;a=(b+a)/c;f=(f+e)/k;g=(j+g)/m;p.n11=2/c;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/k;p.n23=0;p.n24=-f;p.n31=0;p.n32=0;p.n33=-2/m;p.n34=-g;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var e=b[10]*b[5]-b[6]*b[9],f=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],i=-b[10]*b[4]+b[6]*b[8],p=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],k=b[9]*b[4]-b[5]*b[8],l=-b[9]*b[0]+b[1]*b[8],D=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*i+b[2]*k;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*e;a.m[1]=b*f;a.m[2]=b*g;a.m[3]=b*i;a.m[4]=b*p;a.m[5]=b*c;a.m[6]=b*k;a.m[7]=b*l;a.m[8]=b*D;return a}; +THREE.Matrix4.makeFrustum=function(a,b,e,f,g,i){var p,c,k;p=new THREE.Matrix4;c=2*g/(b-a);k=2*g/(f-e);a=(b+a)/(b-a);e=(f+e)/(f-e);f=-(i+g)/(i-g);g=-2*i*g/(i-g);p.n11=c;p.n12=0;p.n13=a;p.n14=0;p.n21=0;p.n22=k;p.n23=e;p.n24=0;p.n31=0;p.n32=0;p.n33=f;p.n34=g;p.n41=0;p.n42=0;p.n43=-1;p.n44=0;return p};THREE.Matrix4.makePerspective=function(a,b,e,f){var g;a=e*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,e,f)}; +THREE.Matrix4.makeOrtho=function(a,b,e,f,g,i){var p,c,k,l;p=new THREE.Matrix4;c=b-a;k=e-f;l=i-g;a=(b+a)/c;e=(e+f)/k;g=(i+g)/l;p.n11=2/c;p.n12=0;p.n13=0;p.n14=-a;p.n21=0;p.n22=2/k;p.n23=0;p.n24=-e;p.n31=0;p.n32=0;p.n33=-2/l;p.n34=-g;p.n41=0;p.n42=0;p.n43=0;p.n44=1;return p}; 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,f,e,g){this.a=a;this.b=b;this.c=f;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,f,e,g,j){this.a=a;this.b=b;this.c=f;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=j instanceof Array?j:[j]};THREE.Face4.prototype={toString:function(){return"THREE.Face4 ( "+this.a+", "+this.b+", "+this.c+" "+this.d+" )"}};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; +THREE.Face3=function(a,b,e,f,g){this.a=a;this.b=b;this.c=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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,e,f,g,i){this.a=a;this.b=b;this.c=e;this.d=f;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.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.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; -THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;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],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,f=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[0])this.boundingBox.z[0]=a.position.z;else 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,f=this.vertices.length;b65535){m[c].counter+=1;k=m[c].hash+"_"+m[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:p,vertices:0}}this.geometryChunks[k].faces.push(e); -this.geometryChunks[k].vertices+=j}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,f,e){this.fov=a;this.aspect=b;this.near=f;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.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); +THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;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], +z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,e=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,e=this.vertices.length;b65535){l[c].counter+=1;k=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[k]==undefined)this.geometryChunks[k]={faces:[],materials:p,vertices:0}}this.geometryChunks[k].faces.push(f);this.geometryChunks[k].vertices+=i}},toString:function(){return"THREE.Geometry ( vertices: "+ +this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +THREE.Camera=function(a,b,e,f){this.fov=a;this.aspect=b;this.near=e;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.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); this.position.subSelf(g);this.target.position.subSelf(g)};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;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true}; THREE.Object3D.prototype={updateMatrix:function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition); this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.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,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.autoUpdateMatrix=false}; -THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,f){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=f!==undefined?f:THREE.LineContinuous};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; +THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,e){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=e!==undefined?e:THREE.LineContinuous};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];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.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";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.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}}; THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; @@ -90,95 +91,98 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}}; THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(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,b,f,e,g,j){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=j!==undefined?j:THREE.LinearMipMapLinearFilter}; +THREE.Texture=function(a,b,e,f,g,i){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=i!==undefined?i: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;var Uniforms={clone:function(a){var b,f,e,g={};for(b in a){g[b]={};for(f in a[b]){e=a[b][f];g[b][f]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,f,e,g={};for(b=0;b=0&&t>=0&&r>=0&&w>=0)return true;else if(y<0&&t<0||r<0&&w<0)return false;else{if(y<0)u=Math.max(u,y/(y-t));else if(t<0)o=Math.min(o,y/(y-t));if(r<0)u=Math.max(u,r/(r-w));else if(w<0)o=Math.min(o,r/(r-w));if(oy&&G.z0&&O.z<1){x=M[A]=M[A]||new THREE.RenderableParticle;x.x=O.x/O.w;x.y=O.y/O.w;x.z=O.z;x.rotation=H.rotation.z;x.scale.x=H.scale.x*Math.abs(x.x-(O.x+i.projectionMatrix.n11)/(O.w+i.projectionMatrix.n14)); -x.scale.y=H.scale.y*Math.abs(x.y-(O.y+i.projectionMatrix.n22)/(O.w+i.projectionMatrix.n24));x.materials=H.materials;o.push(x);A++}}}}u&&o.sort(a);return o};this.unprojectVector=function(l,i){var u=new THREE.Matrix4;u.multiply(THREE.Matrix4.makeInvert(i.matrix),THREE.Matrix4.makeInvert(i.projectionMatrix));u.multiplyVector3(l);return l}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,e,g,j;this.domElement=document.createElement("div");this.setSize=function(p,c){f=p;e=c;g=f/2;j=e/2};this.render=function(p,c){var k,m,B,D,x,A,M,Q;a=b.projectScene(p,c);k=0;for(m=a.length;k0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}else if(Y instanceof THREE.PointLight){Z.sub(Y.position,S);Z.normalize();Y=J.dot(Z)*ca;if(Y>0){z.r+=aa.r*Y;z.g+=aa.g*Y;z.b+=aa.b*Y}}}}function Na(v,S,J){if(J.opacity!=0){a(J.opacity);b(J.blending);var z, -I,Y,aa,ca,da;if(J instanceof THREE.ParticleBasicMaterial){if(J.map){aa=J.map;ca=aa.width>>1;da=aa.height>>1;I=S.scale.x*c;Y=S.scale.y*k;J=I*ca;z=Y*da;C.set(v.x-J,v.y-z,v.x+J,v.y+z);if(!U.instersects(C))return;m.save();m.translate(v.x,v.y);m.rotate(-S.rotation);m.scale(I,-Y);m.translate(-ca,-da);m.drawImage(aa,0,0);m.restore()}m.beginPath();m.moveTo(v.x-10,v.y);m.lineTo(v.x+10,v.y);m.moveTo(v.x,v.y-10);m.lineTo(v.x,v.y+10);m.closePath();m.strokeStyle="rgb(255,255,0)";m.stroke()}else if(J instanceof -THREE.ParticleCircleMaterial){if(N){V.r=ea.r+ma.r+na.r;V.g=ea.g+ma.g+na.g;V.b=ea.b+ma.b+na.b;o.r=J.color.r*V.r;o.g=J.color.g*V.g;o.b=J.color.b*V.b;o.updateStyleString()}else o.__styleString=J.color.__styleString;J=S.scale.x*c;z=S.scale.y*k;C.set(v.x-J,v.y-z,v.x+J,v.y+z);if(U.instersects(C)){I=o.__styleString;if(Q!=I)m.fillStyle=Q=I;m.save();m.translate(v.x,v.y);m.rotate(-S.rotation);m.scale(J,z);m.beginPath();m.arc(0,0,1,0,La,true);m.closePath();m.fill();m.restore()}}}}function Oa(v,S,J,z){if(z.opacity!= -0){a(z.opacity);b(z.blending);m.beginPath();m.moveTo(v.positionScreen.x,v.positionScreen.y);m.lineTo(S.positionScreen.x,S.positionScreen.y);m.closePath();if(z instanceof THREE.LineBasicMaterial){o.__styleString=z.color.__styleString;v=z.linewidth;if(O!=v)m.lineWidth=O=v;v=o.__styleString;if(M!=v)m.strokeStyle=M=v;m.stroke();C.inflate(z.linewidth*2)}}}function Ha(v,S,J,z,I,Y){if(I.opacity!=0){a(I.opacity);b(I.blending);h=v.positionScreen.x;q=v.positionScreen.y;n=S.positionScreen.x;l=S.positionScreen.y; -i=J.positionScreen.x;u=J.positionScreen.y;m.beginPath();m.moveTo(h,q);m.lineTo(n,l);m.lineTo(i,u);m.lineTo(h,q);m.closePath();if(I instanceof THREE.MeshBasicMaterial)if(I.map)I.map.image.loaded&&I.map.mapping instanceof THREE.UVMapping&&ua(h,q,n,l,i,u,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);else if(I.env_map){if(I.env_map.image.loaded)if(I.env_map.mapping instanceof THREE.SphericalReflectionMapping){v=la.matrix;Z.copy(z.vertexNormalsWorld[0]);P=(Z.x*v.n11+Z.y* -v.n12+Z.z*v.n13)*0.5+0.5;H=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[1]);X=(Z.x*v.n11+Z.y*v.n12+Z.z*v.n13)*0.5+0.5;K=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;Z.copy(z.vertexNormalsWorld[2]);E=(Z.x*v.n11+Z.y*v.n12+Z.z*v.n13)*0.5+0.5;F=-(Z.x*v.n21+Z.y*v.n22+Z.z*v.n23)*0.5+0.5;ua(h,q,n,l,i,u,I.env_map.image,P,H,X,K,E,F)}}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString);else if(I instanceof THREE.MeshLambertMaterial){if(I.map&&!I.wireframe){I.map.mapping instanceof -THREE.UVMapping&&ua(h,q,n,l,i,u,I.map.image,z.uvs[0].u,z.uvs[0].v,z.uvs[1].u,z.uvs[1].v,z.uvs[2].u,z.uvs[2].v);b(THREE.SubtractiveBlending)}if(N)if(!I.wireframe&&I.shading==THREE.SmoothShading&&z.vertexNormalsWorld.length==3){y.r=t.r=r.r=ea.r;y.g=t.g=r.g=ea.g;y.b=t.b=r.b=ea.b;ya(Y,z.v1.positionWorld,z.vertexNormalsWorld[0],y);ya(Y,z.v2.positionWorld,z.vertexNormalsWorld[1],t);ya(Y,z.v3.positionWorld,z.vertexNormalsWorld[2],r);w.r=(t.r+r.r)*0.5;w.g=(t.g+r.g)*0.5;w.b=(t.b+r.b)*0.5;T=Ia(y,t,r,w);ua(h, -q,n,l,i,u,T,0,0,1,0,0,1)}else{V.r=ea.r;V.g=ea.g;V.b=ea.b;ya(Y,z.centroidWorld,z.normalWorld,V);o.r=I.color.r*V.r;o.g=I.color.g*V.g;o.b=I.color.b*V.b;o.updateStyleString();I.wireframe?za(o.__styleString,I.wireframe_linewidth):Aa(o.__styleString)}else I.wireframe?za(I.color.__styleString,I.wireframe_linewidth):Aa(I.color.__styleString)}else if(I instanceof THREE.MeshDepthMaterial){W=la.near;G=la.far;y.r=y.g=y.b=1-Da(v.positionScreen.z,W,G);t.r=t.g=t.b=1-Da(S.positionScreen.z,W,G);r.r=r.g=r.b=1-Da(J.positionScreen.z, -W,G);w.r=(t.r+r.r)*0.5;w.g=(t.g+r.g)*0.5;w.b=(t.b+r.b)*0.5;T=Ia(y,t,r,w);ua(h,q,n,l,i,u,T,0,0,1,0,0,1)}else if(I instanceof THREE.MeshNormalMaterial){o.r=Ea(z.normalWorld.x);o.g=Ea(z.normalWorld.y);o.b=Ea(z.normalWorld.z);o.updateStyleString();I.wireframe?za(o.__styleString,I.wireframe_linewidth):Aa(o.__styleString)}}}function za(v,S){if(M!=v)m.strokeStyle=M=v;if(O!=S)m.lineWidth=O=S;m.stroke();C.inflate(S*2)}function Aa(v){if(Q!=v)m.fillStyle=Q=v;m.fill()}function ua(v,S,J,z,I,Y,aa,ca,da,ia,ga,ja, -va){var oa,ka;oa=aa.width-1;ka=aa.height-1;ca*=oa;da*=ka;ia*=oa;ga*=ka;ja*=oa;va*=ka;J-=v;z-=S;I-=v;Y-=S;ia-=ca;ga-=da;ja-=ca;va-=da;ka=1/(ia*va-ja*ga);oa=(va*J-ga*I)*ka;ga=(va*z-ga*Y)*ka;J=(ia*I-ja*J)*ka;z=(ia*Y-ja*z)*ka;v=v-oa*ca-J*da;S=S-ga*ca-z*da;m.save();m.transform(oa,ga,J,z,v,S);m.clip();m.drawImage(aa,0,0);m.restore()}function Ia(v,S,J,z){var I=~~(v.r*255),Y=~~(v.g*255);v=~~(v.b*255);var aa=~~(S.r*255),ca=~~(S.g*255);S=~~(S.b*255);var da=~~(J.r*255),ia=~~(J.g*255);J=~~(J.b*255);var ga=~~(z.r* -255),ja=~~(z.g*255);z=~~(z.b*255);fa[0]=I<0?0:I>255?255:I;fa[1]=Y<0?0:Y>255?255:Y;fa[2]=v<0?0:v>255?255:v;fa[4]=aa<0?0:aa>255?255:aa;fa[5]=ca<0?0:ca>255?255:ca;fa[6]=S<0?0:S>255?255:S;fa[8]=da<0?0:da>255?255:da;fa[9]=ia<0?0:ia>255?255:ia;fa[10]=J<0?0:J>255?255:J;fa[12]=ga<0?0:ga>255?255:ga;fa[13]=ja<0?0:ja>255?255:ja;fa[14]=z<0?0:z>255?255:z;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(v,S,J){v=(v-S)/(J-S);return v*v*(3-2*v)}function Ea(v){v=(v+1)*0.5;return v<0?0:v>1?1:v}function Fa(v, -S){var J=S.x-v.x,z=S.y-v.y,I=1/Math.sqrt(J*J+z*z);J*=I;z*=I;S.x+=J;S.y+=z;v.x-=J;v.y-=z}var Ba,Ja,$,ha,qa,Ga,Ka,wa;m.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();f=e.projectScene(ba,la,this.sortElements);m.fillStyle="rgba( 0, 255, 255, 0.5 )";m.fillRect(U.getX(),U.getY(),U.getWidth(),U.getHeight());(N=ba.lights.length>0)&&Ma(ba);Ba=0;for(Ja=f.length;Ba0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}else if(F instanceof THREE.PointLight){u.sub(F.position,H.centroidWorld);u.normalize();U=H.normalWorld.dot(u)*F.intensity;if(U>0){X.r+=F.color.r*U;X.g+=F.color.g*U;X.b+=F.color.b*U}}}}function b(P,H,X,K,E,F){r=e(w++);r.setAttribute("d","M "+P.positionScreen.x+ -" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(L){h.r=q.r;h.g=q.g;h.b=q.b;a(F,K,h);d.r=E.color.r*h.r;d.g=E.color.g*h.g;d.b=E.color.b*h.b;d.updateStyleString()}else d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){i=1-E.__2near/(E.__farPlusNear-K.z*E.__farMinusNear); -d.setRGB(i,i,i)}else E instanceof THREE.MeshNormalMaterial&&d.setRGB(g(K.normalWorld.x),g(K.normalWorld.y),g(K.normalWorld.z));E.wireframe?r.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):r.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+E.opacity);c.appendChild(r)}function f(P,H,X,K,E,F,U){r=e(w++);r.setAttribute("d", -"M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+H.positionScreen.x+" "+H.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+" L "+K.positionScreen.x+","+K.positionScreen.y+"z");if(F instanceof THREE.MeshBasicMaterial)d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshLambertMaterial)if(L){h.r=q.r;h.g=q.g;h.b=q.b;a(U,E,h);d.r=F.color.r*h.r;d.g=F.color.g*h.g;d.b=F.color.b*h.b;d.updateStyleString()}else d.__styleString=F.color.__styleString;else if(F instanceof THREE.MeshDepthMaterial){i= -1-F.__2near/(F.__farPlusNear-E.z*F.__farMinusNear);d.setRGB(i,i,i)}else F instanceof THREE.MeshNormalMaterial&&d.setRGB(g(E.normalWorld.x),g(E.normalWorld.y),g(E.normalWorld.z));F.wireframe?r.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+F.wireframe_linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframe_linecap+"; stroke-linejoin: "+F.wireframe_linejoin):r.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+F.opacity);c.appendChild(r)} -function e(P){if(o[P]==null){o[P]=document.createElementNS("http://www.w3.org/2000/svg","path");T==0&&o[P].setAttribute("shape-rendering","crispEdges");return o[P]}return o[P]}function g(P){return P<0?Math.min((1+P)*0.5,0.5):0.5+Math.min(P*0.5,0.5)}var j=null,p=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,B,D,x,A,M,Q,O=new THREE.Rectangle,s=new THREE.Rectangle,L=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),q=new THREE.Color(0),n=new THREE.Color(0), -l=new THREE.Color(0),i,u=new THREE.Vector3,o=[],y=[],t=[],r,w,W,G,T=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(P){switch(P){case "high":T=1;break;case "low":T=0}};this.setSize=function(P,H){k=P;m=H;B=k/2;D=m/2;c.setAttribute("viewBox",-B+" "+-D+" "+k+" "+m);c.setAttribute("width",k);c.setAttribute("height",m);O.set(-B,-D,B,D)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(P,H){var X,K, -E,F,U,R,C,N;this.autoClear&&this.clear();j=p.projectScene(P,H,this.sortElements);G=W=w=0;if(L=P.lights.length>0){C=P.lights;q.setRGB(0,0,0);n.setRGB(0,0,0);l.setRGB(0,0,0);X=0;for(K=C.length;X0){E.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,E.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(X),c.STATIC_DRAW)}E.__webGLFaceBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -E.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(W),c.STATIC_DRAW);E.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,E.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(G),c.STATIC_DRAW);E.__webGLFaceCount=W.length;E.__webGLLineCount=G.length}};this.renderBuffer=function(d,h,q,n,l){var i,u,o,y;if(!n.program){if(n instanceof THREE.MeshDepthMaterial){b(n,THREE.ShaderLib.depth);n.uniforms.mNear.value=d.near;n.uniforms.mFar.value=d.far}else if(n instanceof -THREE.MeshNormalMaterial)b(n,THREE.ShaderLib.normal);else if(n instanceof THREE.MeshBasicMaterial){b(n,THREE.ShaderLib.basic);f(n,q)}else if(n instanceof THREE.MeshLambertMaterial){b(n,THREE.ShaderLib.lambert);f(n,q)}else if(n instanceof THREE.MeshPhongMaterial){b(n,THREE.ShaderLib.phong);f(n,q)}else if(n instanceof THREE.LineBasicMaterial){b(n,THREE.ShaderLib.basic);e(n,q)}var t,r,w;t=y=u=0;for(r=h.length;t0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+y.maxDirLights,"#define MAX_POINT_LIGHTS "+y.maxPointLights,y.map?"#define USE_MAP":"",y.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(r, -g("fragment",w+u));c.attachShader(r,g("vertex",y+t));c.linkProgram(r);c.getProgramParameter(r,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(r,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");r.uniforms={};r.attributes={};n.program=r;u=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(i in n.uniforms)u.push(i);i=n.program;t=0;for(r=u.length;t=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLNormalBuffer); -c.vertexAttribPointer(o.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.normal)}if(o.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLTangentBuffer);c.vertexAttribPointer(o.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.tangent)}if(o.uv>=0)if(l.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLUVBuffer);c.vertexAttribPointer(o.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(o.uv)}else c.disableVertexAttribArray(o.uv);if(n.wireframe||n instanceof THREE.LineBasicMaterial){o= -n.wireframe_linewidth!==undefined?n.wireframe_linewidth:n.linewidth!==undefined?n.linewidth:1;n=n instanceof THREE.LineBasicMaterial&&l.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(o);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);c.drawElements(n,l.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,l.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,h,q,n,l,i,u){var o,y,t,r,w;t=0;for(r= -n.materials.length;t=0;q--){n=d.__webGLObjects[q].object;h==n&&d.__webGLObjects.splice(q,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix(); -m.multiply(h.matrix,d.matrix);x.set(m.flatten());B=THREE.Matrix4.makeInvert3x3(m).transpose();M.set(B.m);Q.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,D);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,x);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,A);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,M);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,Q)};this.loadCamera=function(d,h){c.uniform3f(d.uniforms.cameraPosition,h.position.x, -h.position.y,h.position.z)};this.setBlending=function(d){switch(d){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(d,h){if(d){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}; -this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; -THREE.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, 1.0 ), 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\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\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_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\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\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,b,e){this.color=new THREE.Color(a);this.near=b||1;this.far=e||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4}; +THREE.Projector=function(){function a(m,t){return t.z-m.z}function b(m,t){var r=0,q=1,z=m.z+m.w,u=t.z+t.w,j=-m.z+m.w,w=-t.z+t.w;if(z>=0&&u>=0&&j>=0&&w>=0)return true;else if(z<0&&u<0||j<0&&w<0)return false;else{if(z<0)r=Math.max(r,z/(z-u));else if(u<0)q=Math.min(q,z/(z-u));if(j<0)r=Math.max(r,j/(j-w));else if(w<0)q=Math.min(q,j/(j-w));if(qz&&A.z0&&U.z<1){y=S[C]=S[C]||new THREE.RenderableParticle;y.x=U.x/U.w;y.y=U.y/U.w;y.z=U.z;y.rotation=I.rotation.z;y.scale.x=I.scale.x*Math.abs(y.x-(U.x+t.projectionMatrix.n11)/(U.w+t.projectionMatrix.n14)); +y.scale.y=I.scale.y*Math.abs(y.y-(U.y+t.projectionMatrix.n22)/(U.w+t.projectionMatrix.n24));y.materials=I.materials;q.push(y);C++}}}}r&&q.sort(a);return q};this.unprojectVector=function(m,t){var r=new THREE.Matrix4;r.multiply(THREE.Matrix4.makeInvert(t.matrix),THREE.Matrix4.makeInvert(t.projectionMatrix));r.multiplyVector3(m);return m}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,f,g,i;this.domElement=document.createElement("div");this.setSize=function(p,c){e=p;f=c;g=e/2;i=f/2};this.render=function(p,c){var k,l,D,F,y,C,S,W;a=b.projectScene(p,c);k=0;for(l=a.length;k0){B.r+=ca.r*$;B.g+=ca.g*$;B.b+=ca.b*$}}else if($ instanceof THREE.PointLight){Y.sub($.position,X);Y.normalize();$=P.dot(Y)*fa;if($>0){B.r+=ca.r*$;B.g+=ca.g*$;B.b+=ca.b*$}}}}function Na(x,X,P){if(P.opacity!=0){a(P.opacity);b(P.blending);var B, +M,$,ca,fa,ga;if(P instanceof THREE.ParticleBasicMaterial){if(P.map){ca=P.map;fa=ca.width>>1;ga=ca.height>>1;M=X.scale.x*c;$=X.scale.y*k;P=M*fa;B=$*ga;v.set(x.x-P,x.y-B,x.x+P,x.y+B);if(!O.instersects(v))return;l.save();l.translate(x.x,x.y);l.rotate(-X.rotation);l.scale(M,-$);l.translate(-fa,-ga);l.drawImage(ca,0,0);l.restore()}l.beginPath();l.moveTo(x.x-10,x.y);l.lineTo(x.x+10,x.y);l.moveTo(x.x,x.y-10);l.lineTo(x.x,x.y+10);l.closePath();l.strokeStyle="rgb(255,255,0)";l.stroke()}else if(P instanceof +THREE.ParticleCircleMaterial){if(G){L.r=ea.r+ba.r+Z.r;L.g=ea.g+ba.g+Z.g;L.b=ea.b+ba.b+Z.b;q.r=P.color.r*L.r;q.g=P.color.g*L.g;q.b=P.color.b*L.b;q.updateStyleString()}else q.__styleString=P.color.__styleString;P=X.scale.x*c;B=X.scale.y*k;v.set(x.x-P,x.y-B,x.x+P,x.y+B);if(O.instersects(v)){M=q.__styleString;if(W!=M)l.fillStyle=W=M;l.save();l.translate(x.x,x.y);l.rotate(-X.rotation);l.scale(P,B);l.beginPath();l.arc(0,0,1,0,ia,true);l.closePath();l.fill();l.restore()}}}}function Oa(x,X,P,B){if(B.opacity!= +0){a(B.opacity);b(B.blending);l.beginPath();l.moveTo(x.positionScreen.x,x.positionScreen.y);l.lineTo(X.positionScreen.x,X.positionScreen.y);l.closePath();if(B instanceof THREE.LineBasicMaterial){q.__styleString=B.color.__styleString;x=B.linewidth;if(U!=x)l.lineWidth=U=x;x=q.__styleString;if(S!=x)l.strokeStyle=S=x;l.stroke();v.inflate(B.linewidth*2)}}}function Ia(x,X,P,B,M,$){if(M.opacity!=0){a(M.opacity);b(M.blending);h=x.positionScreen.x;o=x.positionScreen.y;n=X.positionScreen.x;m=X.positionScreen.y; +t=P.positionScreen.x;r=P.positionScreen.y;l.beginPath();l.moveTo(h,o);l.lineTo(n,m);l.lineTo(t,r);l.lineTo(h,o);l.closePath();if(M instanceof THREE.MeshBasicMaterial)if(M.map)M.map.image.loaded&&M.map.mapping instanceof THREE.UVMapping&&va(h,o,n,m,t,r,M.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);else if(M.env_map){if(M.env_map.image.loaded)if(M.env_map.mapping instanceof THREE.SphericalReflectionMapping){x=qa.matrix;Y.copy(B.vertexNormalsWorld[0]);N=(Y.x*x.n11+Y.y* +x.n12+Y.z*x.n13)*0.5+0.5;I=-(Y.x*x.n21+Y.y*x.n22+Y.z*x.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[1]);V=(Y.x*x.n11+Y.y*x.n12+Y.z*x.n13)*0.5+0.5;Q=-(Y.x*x.n21+Y.y*x.n22+Y.z*x.n23)*0.5+0.5;Y.copy(B.vertexNormalsWorld[2]);E=(Y.x*x.n11+Y.y*x.n12+Y.z*x.n13)*0.5+0.5;H=-(Y.x*x.n21+Y.y*x.n22+Y.z*x.n23)*0.5+0.5;va(h,o,n,m,t,r,M.env_map.image,N,I,V,Q,E,H)}}else M.wireframe?Aa(M.color.__styleString,M.wireframe_linewidth):Ba(M.color.__styleString);else if(M instanceof THREE.MeshLambertMaterial){if(M.map&&!M.wireframe){M.map.mapping instanceof +THREE.UVMapping&&va(h,o,n,m,t,r,M.map.image,B.uvs[0].u,B.uvs[0].v,B.uvs[1].u,B.uvs[1].v,B.uvs[2].u,B.uvs[2].v);b(THREE.SubtractiveBlending)}if(G)if(!M.wireframe&&M.shading==THREE.SmoothShading&&B.vertexNormalsWorld.length==3){z.r=u.r=j.r=ea.r;z.g=u.g=j.g=ea.g;z.b=u.b=j.b=ea.b;za($,B.v1.positionWorld,B.vertexNormalsWorld[0],z);za($,B.v2.positionWorld,B.vertexNormalsWorld[1],u);za($,B.v3.positionWorld,B.vertexNormalsWorld[2],j);w.r=(u.r+j.r)*0.5;w.g=(u.g+j.g)*0.5;w.b=(u.b+j.b)*0.5;K=Ja(z,u,j,w);va(h, +o,n,m,t,r,K,0,0,1,0,0,1)}else{L.r=ea.r;L.g=ea.g;L.b=ea.b;za($,B.centroidWorld,B.normalWorld,L);q.r=M.color.r*L.r;q.g=M.color.g*L.g;q.b=M.color.b*L.b;q.updateStyleString();M.wireframe?Aa(q.__styleString,M.wireframe_linewidth):Ba(q.__styleString)}else M.wireframe?Aa(M.color.__styleString,M.wireframe_linewidth):Ba(M.color.__styleString)}else if(M instanceof THREE.MeshDepthMaterial){T=qa.near;A=qa.far;z.r=z.g=z.b=1-Ea(x.positionScreen.z,T,A);u.r=u.g=u.b=1-Ea(X.positionScreen.z,T,A);j.r=j.g=j.b=1-Ea(P.positionScreen.z, +T,A);w.r=(u.r+j.r)*0.5;w.g=(u.g+j.g)*0.5;w.b=(u.b+j.b)*0.5;K=Ja(z,u,j,w);va(h,o,n,m,t,r,K,0,0,1,0,0,1)}else if(M instanceof THREE.MeshNormalMaterial){q.r=Fa(B.normalWorld.x);q.g=Fa(B.normalWorld.y);q.b=Fa(B.normalWorld.z);q.updateStyleString();M.wireframe?Aa(q.__styleString,M.wireframe_linewidth):Ba(q.__styleString)}}}function Aa(x,X){if(S!=x)l.strokeStyle=S=x;if(U!=X)l.lineWidth=U=X;l.stroke();v.inflate(X*2)}function Ba(x){if(W!=x)l.fillStyle=W=x;l.fill()}function va(x,X,P,B,M,$,ca,fa,ga,ma,ka,na, +wa){var ra,oa;ra=ca.width-1;oa=ca.height-1;fa*=ra;ga*=oa;ma*=ra;ka*=oa;na*=ra;wa*=oa;P-=x;B-=X;M-=x;$-=X;ma-=fa;ka-=ga;na-=fa;wa-=ga;oa=1/(ma*wa-na*ka);ra=(wa*P-ka*M)*oa;ka=(wa*B-ka*$)*oa;P=(ma*M-na*P)*oa;B=(ma*$-na*B)*oa;x=x-ra*fa-P*ga;X=X-ka*fa-B*ga;l.save();l.transform(ra,ka,P,B,x,X);l.clip();l.drawImage(ca,0,0);l.restore()}function Ja(x,X,P,B){var M=~~(x.r*255),$=~~(x.g*255);x=~~(x.b*255);var ca=~~(X.r*255),fa=~~(X.g*255);X=~~(X.b*255);var ga=~~(P.r*255),ma=~~(P.g*255);P=~~(P.b*255);var ka=~~(B.r* +255),na=~~(B.g*255);B=~~(B.b*255);ha[0]=M<0?0:M>255?255:M;ha[1]=$<0?0:$>255?255:$;ha[2]=x<0?0:x>255?255:x;ha[4]=ca<0?0:ca>255?255:ca;ha[5]=fa<0?0:fa>255?255:fa;ha[6]=X<0?0:X>255?255:X;ha[8]=ga<0?0:ga>255?255:ga;ha[9]=ma<0?0:ma>255?255:ma;ha[10]=P<0?0:P>255?255:P;ha[12]=ka<0?0:ka>255?255:ka;ha[13]=na<0?0:na>255?255:na;ha[14]=B<0?0:B>255?255:B;ja.putImageData(Da,0,0);ya.drawImage(pa,0,0);return ua}function Ea(x,X,P){x=(x-X)/(P-X);return x*x*(3-2*x)}function Fa(x){x=(x+1)*0.5;return x<0?0:x>1?1:x}function Ga(x, +X){var P=X.x-x.x,B=X.y-x.y,M=1/Math.sqrt(P*P+B*B);P*=M;B*=M;X.x+=P;X.y+=B;x.x-=P;x.y-=B}var Ca,Ka,aa,la,ta,Ha,La,xa;l.setTransform(1,0,0,-1,c,k);this.autoClear&&this.clear();e=f.projectScene(da,qa,this.sortElements);l.fillStyle="rgba( 0, 255, 255, 0.5 )";l.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight());(G=da.lights.length>0)&&Ma(da);Ca=0;for(Ka=e.length;Ca0){V.r+=H.color.r*O;V.g+=H.color.g*O;V.b+=H.color.b*O}}else if(H instanceof THREE.PointLight){r.sub(H.position,I.centroidWorld);r.normalize();O=I.normalWorld.dot(r)*H.intensity;if(O>0){V.r+=H.color.r*O;V.g+=H.color.g*O;V.b+=H.color.b*O}}}}function b(N,I,V,Q,E,H){j=f(w++);j.setAttribute("d","M "+N.positionScreen.x+ +" "+N.positionScreen.y+" L "+I.positionScreen.x+" "+I.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+"z");if(E instanceof THREE.MeshBasicMaterial)d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshLambertMaterial)if(R){h.r=o.r;h.g=o.g;h.b=o.b;a(H,Q,h);d.r=E.color.r*h.r;d.g=E.color.g*h.g;d.b=E.color.b*h.b;d.updateStyleString()}else d.__styleString=E.color.__styleString;else if(E instanceof THREE.MeshDepthMaterial){t=1-E.__2near/(E.__farPlusNear-Q.z*E.__farMinusNear); +d.setRGB(t,t,t)}else E instanceof THREE.MeshNormalMaterial&&d.setRGB(g(Q.normalWorld.x),g(Q.normalWorld.y),g(Q.normalWorld.z));E.wireframe?j.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+E.wireframe_linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframe_linecap+"; stroke-linejoin: "+E.wireframe_linejoin):j.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+E.opacity);c.appendChild(j)}function e(N,I,V,Q,E,H,O){j=f(w++);j.setAttribute("d", +"M "+N.positionScreen.x+" "+N.positionScreen.y+" L "+I.positionScreen.x+" "+I.positionScreen.y+" L "+V.positionScreen.x+","+V.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(H instanceof THREE.MeshBasicMaterial)d.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshLambertMaterial)if(R){h.r=o.r;h.g=o.g;h.b=o.b;a(O,E,h);d.r=H.color.r*h.r;d.g=H.color.g*h.g;d.b=H.color.b*h.b;d.updateStyleString()}else d.__styleString=H.color.__styleString;else if(H instanceof THREE.MeshDepthMaterial){t= +1-H.__2near/(H.__farPlusNear-E.z*H.__farMinusNear);d.setRGB(t,t,t)}else H instanceof THREE.MeshNormalMaterial&&d.setRGB(g(E.normalWorld.x),g(E.normalWorld.y),g(E.normalWorld.z));H.wireframe?j.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+H.wireframe_linewidth+"; stroke-opacity: "+H.opacity+"; stroke-linecap: "+H.wireframe_linecap+"; stroke-linejoin: "+H.wireframe_linejoin):j.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+H.opacity);c.appendChild(j)} +function f(N){if(q[N]==null){q[N]=document.createElementNS("http://www.w3.org/2000/svg","path");K==0&&q[N].setAttribute("shape-rendering","crispEdges");return q[N]}return q[N]}function g(N){return N<0?Math.min((1+N)*0.5,0.5):0.5+Math.min(N*0.5,0.5)}var i=null,p=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,l,D,F,y,C,S,W,U=new THREE.Rectangle,s=new THREE.Rectangle,R=false,d=new THREE.Color(16777215),h=new THREE.Color(16777215),o=new THREE.Color(0),n=new THREE.Color(0), +m=new THREE.Color(0),t,r=new THREE.Vector3,q=[],z=[],u=[],j,w,T,A,K=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(N){switch(N){case "high":K=1;break;case "low":K=0}};this.setSize=function(N,I){k=N;l=I;D=k/2;F=l/2;c.setAttribute("viewBox",-D+" "+-F+" "+k+" "+l);c.setAttribute("width",k);c.setAttribute("height",l);U.set(-D,-F,D,F)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(N,I){var V,Q, +E,H,O,J,v,G;this.autoClear&&this.clear();i=p.projectScene(N,I,this.sortElements);A=T=w=0;if(R=N.lights.length>0){v=N.lights;o.setRGB(0,0,0);n.setRGB(0,0,0);m.setRGB(0,0,0);V=0;for(Q=v.length;V0){c.bindBuffer(c.ARRAY_BUFFER,d.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,ea,o)}if(m){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,ia,o);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer); +c.bufferData(c.ELEMENT_ARRAY_BUFFER,Y,o)}};this.renderBuffer=function(d,h,o,n,m){var t,r,q,z;if(!n.program){if(n instanceof THREE.MeshDepthMaterial){b(n,THREE.ShaderLib.depth);n.uniforms.mNear.value=d.near;n.uniforms.mFar.value=d.far}else if(n instanceof THREE.MeshNormalMaterial)b(n,THREE.ShaderLib.normal);else if(n instanceof THREE.MeshBasicMaterial){b(n,THREE.ShaderLib.basic);e(n,o)}else if(n instanceof THREE.MeshLambertMaterial){b(n,THREE.ShaderLib.lambert);e(n,o)}else if(n instanceof THREE.MeshPhongMaterial){b(n, +THREE.ShaderLib.phong);e(n,o)}else if(n instanceof THREE.LineBasicMaterial){b(n,THREE.ShaderLib.basic);f(n,o)}var u,j,w;u=z=r=0;for(j=h.length;u0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+z.maxDirLights,"#define MAX_POINT_LIGHTS "+z.maxPointLights,z.map?"#define USE_MAP":"",z.env_map? +"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(j,g("fragment",w+r));c.attachShader(j,g("vertex",z+u));c.linkProgram(j);c.getProgramParameter(j,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(j,c.VALIDATE_STATUS)+ +", gl error ["+c.getError()+"]");j.uniforms={};j.attributes={};n.program=j;r=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in n.uniforms)r.push(t);t=n.program;u=0;for(j=r.length;u=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webGLNormalBuffer);c.vertexAttribPointer(q.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.normal)}if(q.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webGLTangentBuffer);c.vertexAttribPointer(q.tangent,4,c.FLOAT, +false,0,0);c.enableVertexAttribArray(q.tangent)}if(q.uv>=0)if(m.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,m.__webGLUVBuffer);c.vertexAttribPointer(q.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(q.uv)}else c.disableVertexAttribArray(q.uv);if(n.wireframe||n instanceof THREE.LineBasicMaterial){q=n.wireframe_linewidth!==undefined?n.wireframe_linewidth:n.linewidth!==undefined?n.linewidth:1;n=n instanceof THREE.LineBasicMaterial&&m.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(q);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +m.__webGLLineBuffer);c.drawElements(n,m.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,m.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,h,o,n,m,t,r){var q,z,u,j,w;u=0;for(j=n.materials.length;u=0;o--){n=d.__webGLObjects[o].object;h==n&&d.__webGLObjects.splice(o,1)}};this.setupMatrices=function(d,h){d.autoUpdateMatrix&&d.updateMatrix();l.multiply(h.matrix,d.matrix);y.set(l.flatten());D=THREE.Matrix4.makeInvert3x3(l).transpose();S.set(D.m);W.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,F);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,y);c.uniformMatrix4fv(d.uniforms.projectionMatrix, +false,C);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,S);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,W)};this.loadCamera=function(d,h){c.uniform3f(d.uniforms.cameraPosition,h.position.x,h.position.y,h.position.z)};this.setBlending=function(d){switch(d){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling= +function(d,h){if(d){!h||h=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; +THREE.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, 1.0 ), 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\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\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_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\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\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 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"}; THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv", diff --git a/build/ThreeExtras.js b/build/ThreeExtras.js index 09eb721b..e9d06a98 100644 --- a/build/ThreeExtras.js +++ b/build/ThreeExtras.js @@ -1,68 +1,69 @@ // ThreeExtras.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,b,f){this.r=a;this.g=b;this.b=f;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)+ +THREE.Color.prototype={setRGB:function(a,b,e){this.r=a;this.g=b;this.b=e;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,b){this.x=a||0;this.y=b||0}; THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},unit:function(){this.multiplyScalar(1/this.length());return this},length:function(){return Math.sqrt(this.x* -this.x+this.y*this.y)},lengthSq:function(){return this.x*this.x+this.y*this.y},negate:function(){this.x=-this.x;this.y=-this.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},toString:function(){return"THREE.Vector2 ("+this.x+", "+this.y+")"}};THREE.Vector3=function(a,b,f){this.x=a||0;this.y=b||0;this.z=f||0}; -THREE.Vector3.prototype={set:function(a,b,f){this.x=a;this.y=b;this.z=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, -cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,f=this.y,e=this.z;this.x=f*a.z-e*a.y;this.y=e*a.x-b*a.z;this.z=b*a.y-f*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},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 b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+f*f+a*a)},distanceToSquared:function(a){var b=this.x-a.x,f=this.y-a.y;a=this.z-a.z;return b*b+f*f+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,b,e){this.x=a||0;this.y=b||0;this.z=e||0}; +THREE.Vector3.prototype={set:function(a,b,e){this.x=a;this.y=b;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,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this}, +cross:function(a,b){this.x=a.y*b.z-a.z*b.y;this.y=a.z*b.x-a.x*b.z;this.z=a.x*b.y-a.y*b.x;return this},crossSelf:function(a){var b=this.x,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-b*a.z;this.z=b*a.y-e*a.x;return this},multiply:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},multiplySelf:function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;return this},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 b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return Math.sqrt(b*b+e*e+a*a)},distanceToSquared:function(a){var b=this.x-a.x,e=this.y-a.y;a=this.z-a.z;return b*b+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,b,f,e){this.x=a||0;this.y=b||0;this.z=f||0;this.w=e||1}; -THREE.Vector4.prototype={set:function(a,b,f,e){this.x=a;this.y=b;this.z=f;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; +THREE.Vector4=function(a,b,e,f){this.x=a||0;this.y=b||0;this.z=e||0;this.w=f||1}; +THREE.Vector4.prototype={set:function(a,b,e,f){this.x=a;this.y=b;this.z=e;this.w=f;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w; return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}}; THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,f,e=a.objects,g=[];a=0;for(b=e.length;a0&&K>0&&q+K<1}var f,e,g,h,j,c,i,l,r,B, -o,v=a.geometry,z=v.vertices,A=[];f=0;for(e=v.faces.length;fi?e:i;g=g>l? -g:l}a()};this.add3Points=function(i,l,r,B,o,v){if(c){c=false;b=ir?i>o?i:o:r>o?r:o;g=l>B?l>v?l:v:B>v?B:v}else{b=ir?i>o?i>e?i:e:o>e?o:e:r>o?r>e?r:e:o>e?o:e;g=l>B?l>v?l>g?l:g:v>g?v:g:B>v?B>g?B:g:v>g?v:g}a()};this.addRectangle=function(i){if(c){c=false;b=i.getLeft();f=i.getTop();e=i.getRight();g=i.getBottom()}else{b=bi.getRight()?e:i.getRight();g=g>i.getBottom()?g:i.getBottom()}a()};this.inflate=function(i){b-=i;f-=i;e+=i;g+=i;a()};this.minSelf=function(i){b=b>i.getLeft()?b:i.getLeft();f=f>i.getTop()?f:i.getTop();e=e=0&&Math.min(g,i.getBottom())-Math.max(f,i.getTop())>=0};this.empty=function(){c=true;g=e=f=b=0;a()};this.isEmpty=function(){return c};this.toString= -function(){return"THREE.Rectangle ( left: "+b+", right: "+e+", top: "+f+", bottom: "+g+", width: "+h+", height: "+j+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; -THREE.Matrix4=function(a,b,f,e,g,h,j,c,i,l,r,B,o,v,z,A){this.n11=a||1;this.n12=b||0;this.n13=f||0;this.n14=e||0;this.n21=g||0;this.n22=h||1;this.n23=j||0;this.n24=c||0;this.n31=i||0;this.n32=l||0;this.n33=r||1;this.n34=B||0;this.n41=o||0;this.n42=v||0;this.n43=z||0;this.n44=A||1}; -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,f,e,g,h,j,c,i,l,r,B,o,v,z,A){this.n11=a;this.n12=b;this.n13=f;this.n14=e;this.n21=g;this.n22=h;this.n23=j;this.n24=c;this.n31=i;this.n32=l;this.n33=r;this.n34=B;this.n41=o;this.n42=v;this.n43=z;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,f){var e=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3;h.sub(a,b).normalize();e.cross(f,h).normalize();g.cross(h,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=h.x; -this.n32=h.y;this.n33=h.z;this.n34=-h.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,f=a.y,e=a.z,g=1/(this.n41*b+this.n42*f+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*f+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*f+this.n23*e+this.n24)*g;a.z=(this.n31*b+this.n32*f+this.n33*e+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,f=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*f+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*f+this.n23*e+this.n24* -g;a.z=this.n31*b+this.n32*f+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*f+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 f=a.n11,e=a.n12,g=a.n13,h=a.n14,j=a.n21,c=a.n22,i=a.n23,l=a.n24,r=a.n31,B=a.n32, -o=a.n33,v=a.n34,z=a.n41,A=a.n42,K=a.n43,p=a.n44,E=b.n11,d=b.n12,k=b.n13,q=b.n14,s=b.n21,n=b.n22,m=b.n23,x=b.n24,t=b.n31,D=b.n32,y=b.n33,w=b.n34,C=b.n41,$=b.n42,M=b.n43,U=b.n44;this.n11=f*E+e*s+g*t+h*C;this.n12=f*d+e*n+g*D+h*$;this.n13=f*k+e*m+g*y+h*M;this.n14=f*q+e*x+g*w+h*U;this.n21=j*E+c*s+i*t+l*C;this.n22=j*d+c*n+i*D+l*$;this.n23=j*k+c*m+i*y+l*M;this.n24=j*q+c*x+i*w+l*U;this.n31=r*E+B*s+o*t+v*C;this.n32=r*d+B*n+o*D+v*$;this.n33=r*k+B*m+o*y+v*M;this.n34=r*q+B*x+o*w+v*U;this.n41=z*E+A*s+K*t+p*C; -this.n42=z*d+A*n+K*D+p*$;this.n43=z*k+A*m+K*y+p*M;this.n44=z*q+A*x+K*w+p*U;return this},multiplySelf:function(a){var b=this.n11,f=this.n12,e=this.n13,g=this.n14,h=this.n21,j=this.n22,c=this.n23,i=this.n24,l=this.n31,r=this.n32,B=this.n33,o=this.n34,v=this.n41,z=this.n42,A=this.n43,K=this.n44,p=a.n11,E=a.n21,d=a.n31,k=a.n41,q=a.n12,s=a.n22,n=a.n32,m=a.n42,x=a.n13,t=a.n23,D=a.n33,y=a.n43,w=a.n14,C=a.n24,$=a.n34;a=a.n44;this.n11=b*p+f*E+e*d+g*k;this.n12=b*q+f*s+e*n+g*m;this.n13=b*x+f*t+e*D+g*y;this.n14= -b*w+f*C+e*$+g*a;this.n21=h*p+j*E+c*d+i*k;this.n22=h*q+j*s+c*n+i*m;this.n23=h*x+j*t+c*D+i*y;this.n24=h*w+j*C+c*$+i*a;this.n31=l*p+r*E+B*d+o*k;this.n32=l*q+r*s+B*n+o*m;this.n33=l*x+r*t+B*D+o*y;this.n34=l*w+r*C+B*$+o*a;this.n41=v*p+z*E+A*d+K*k;this.n42=v*q+z*s+A*n+K*m;this.n43=v*x+z*t+A*D+K*y;this.n44=v*w+z*C+A*$+K*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= +THREE.Ray.prototype={intersectScene:function(a){var b,e,f=a.objects,g=[];a=0;for(b=f.length;a0&&M>0&&p+M<1}var e,f,g,h,j,c,i,l,u,C, +o,x=a.geometry,A=x.vertices,B=[];e=0;for(f=x.faces.length;ei?f:i;g=g>l? +g:l}a()};this.add3Points=function(i,l,u,C,o,x){if(c){c=false;b=iu?i>o?i:o:u>o?u:o;g=l>C?l>x?l:x:C>x?C:x}else{b=iu?i>o?i>f?i:f:o>f?o:f:u>o?u>f?u:f:o>f?o:f;g=l>C?l>x?l>g?l:g:x>g?x:g:C>x?C>g?C:g:x>g?x:g}a()};this.addRectangle=function(i){if(c){c=false;b=i.getLeft();e=i.getTop();f=i.getRight();g=i.getBottom()}else{b=bi.getRight()?f:i.getRight();g=g>i.getBottom()?g:i.getBottom()}a()};this.inflate=function(i){b-=i;e-=i;f+=i;g+=i;a()};this.minSelf=function(i){b=b>i.getLeft()?b:i.getLeft();e=e>i.getTop()?e:i.getTop();f=f=0&&Math.min(g,i.getBottom())-Math.max(e,i.getTop())>=0};this.empty=function(){c=true;g=f=e=b=0;a()};this.isEmpty=function(){return c};this.toString= +function(){return"THREE.Rectangle ( left: "+b+", right: "+f+", top: "+e+", bottom: "+g+", width: "+h+", height: "+j+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a;a=this.m[1];this.m[1]=this.m[3];this.m[3]=a;a=this.m[2];this.m[2]=this.m[6];this.m[6]=a;a=this.m[5];this.m[5]=this.m[7];this.m[7]=a;return this}}; +THREE.Matrix4=function(a,b,e,f,g,h,j,c,i,l,u,C,o,x,A,B){this.n11=a||1;this.n12=b||0;this.n13=e||0;this.n14=f||0;this.n21=g||0;this.n22=h||1;this.n23=j||0;this.n24=c||0;this.n31=i||0;this.n32=l||0;this.n33=u||1;this.n34=C||0;this.n41=o||0;this.n42=x||0;this.n43=A||0;this.n44=B||1}; +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,e,f,g,h,j,c,i,l,u,C,o,x,A,B){this.n11=a;this.n12=b;this.n13=e;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=c;this.n31=i;this.n32=l;this.n33=u;this.n34=C;this.n41=o;this.n42=x;this.n43=A;this.n44=B;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,e){var f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3;h.sub(a,b).normalize();f.cross(e,h).normalize();g.cross(h,f).normalize();this.n11=f.x;this.n12=f.y;this.n13=f.z;this.n14=-f.dot(a);this.n21=g.x;this.n22=g.y;this.n23=g.z;this.n24=-g.dot(a);this.n31=h.x; +this.n32=h.y;this.n33=h.z;this.n34=-h.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var b=a.x,e=a.y,f=a.z,g=1/(this.n41*b+this.n42*e+this.n43*f+this.n44);a.x=(this.n11*b+this.n12*e+this.n13*f+this.n14)*g;a.y=(this.n21*b+this.n22*e+this.n23*f+this.n24)*g;a.z=(this.n31*b+this.n32*e+this.n33*f+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,e=a.y,f=a.z,g=a.w;a.x=this.n11*b+this.n12*e+this.n13*f+this.n14*g;a.y=this.n21*b+this.n22*e+this.n23*f+this.n24* +g;a.z=this.n31*b+this.n32*e+this.n33*f+this.n34*g;a.w=this.n41*b+this.n42*e+this.n43*f+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 e=a.n11,f=a.n12,g=a.n13,h=a.n14,j=a.n21,c=a.n22,i=a.n23,l=a.n24,u=a.n31,C=a.n32, +o=a.n33,x=a.n34,A=a.n41,B=a.n42,M=a.n43,q=a.n44,G=b.n11,d=b.n12,k=b.n13,p=b.n14,s=b.n21,r=b.n22,t=b.n23,w=b.n24,v=b.n31,H=b.n32,y=b.n33,n=b.n34,D=b.n41,W=b.n42,J=b.n43,P=b.n44;this.n11=e*G+f*s+g*v+h*D;this.n12=e*d+f*r+g*H+h*W;this.n13=e*k+f*t+g*y+h*J;this.n14=e*p+f*w+g*n+h*P;this.n21=j*G+c*s+i*v+l*D;this.n22=j*d+c*r+i*H+l*W;this.n23=j*k+c*t+i*y+l*J;this.n24=j*p+c*w+i*n+l*P;this.n31=u*G+C*s+o*v+x*D;this.n32=u*d+C*r+o*H+x*W;this.n33=u*k+C*t+o*y+x*J;this.n34=u*p+C*w+o*n+x*P;this.n41=A*G+B*s+M*v+q*D; +this.n42=A*d+B*r+M*H+q*W;this.n43=A*k+B*t+M*y+q*J;this.n44=A*p+B*w+M*n+q*P;return this},multiplySelf:function(a){var b=this.n11,e=this.n12,f=this.n13,g=this.n14,h=this.n21,j=this.n22,c=this.n23,i=this.n24,l=this.n31,u=this.n32,C=this.n33,o=this.n34,x=this.n41,A=this.n42,B=this.n43,M=this.n44,q=a.n11,G=a.n21,d=a.n31,k=a.n41,p=a.n12,s=a.n22,r=a.n32,t=a.n42,w=a.n13,v=a.n23,H=a.n33,y=a.n43,n=a.n14,D=a.n24,W=a.n34;a=a.n44;this.n11=b*q+e*G+f*d+g*k;this.n12=b*p+e*s+f*r+g*t;this.n13=b*w+e*v+f*H+g*y;this.n14= +b*n+e*D+f*W+g*a;this.n21=h*q+j*G+c*d+i*k;this.n22=h*p+j*s+c*r+i*t;this.n23=h*w+j*v+c*H+i*y;this.n24=h*n+j*D+c*W+i*a;this.n31=l*q+u*G+C*d+o*k;this.n32=l*p+u*s+C*r+o*t;this.n33=l*w+u*v+C*H+o*y;this.n34=l*n+u*D+C*W+o*a;this.n41=x*q+A*G+B*d+M*k;this.n42=x*p+A*s+B*r+M*t;this.n43=x*w+A*v+B*H+M*y;this.n44=x*n+A*D+B*W+M*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*= a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){return this.n14*this.n23*this.n32*this.n41-this.n13*this.n24*this.n32*this.n41-this.n14*this.n22*this.n33*this.n41+this.n12*this.n24*this.n33*this.n41+this.n13*this.n22*this.n34*this.n41-this.n12*this.n23*this.n34*this.n41-this.n14*this.n23*this.n31*this.n42+this.n13*this.n24*this.n31*this.n42+this.n14*this.n21*this.n33*this.n42-this.n11*this.n24*this.n33*this.n42-this.n13*this.n21*this.n34*this.n42+this.n11*this.n23*this.n34* -this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,f,e){var g=b[f];b[f]=b[e]; -b[e]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, -this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,f){var e=new THREE.Matrix4;e.n14=a;e.n24=b;e.n34=f;return e}; -THREE.Matrix4.scaleMatrix=function(a,b,f){var e=new THREE.Matrix4;e.n11=a;e.n22=b;e.n33=f;return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; -THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var f=new THREE.Matrix4,e=Math.cos(b),g=Math.sin(b),h=1-e,j=a.x,c=a.y,i=a.z;f.n11=h*j*j+e;f.n12=h*j*c-g*i;f.n13=h*j*i+g*c;f.n21=h*j*c+g*i;f.n22=h*c*c+e;f.n23=h*c*i-g*j;f.n31=h*j*i-g*c;f.n32=h*c*i+g*j;f.n33=h*i*i+e;return f}; +this.n42+this.n14*this.n22*this.n31*this.n43-this.n12*this.n24*this.n31*this.n43-this.n14*this.n21*this.n32*this.n43+this.n11*this.n24*this.n32*this.n43+this.n12*this.n21*this.n34*this.n43-this.n11*this.n22*this.n34*this.n43-this.n13*this.n22*this.n31*this.n44+this.n12*this.n23*this.n31*this.n44+this.n13*this.n21*this.n32*this.n44-this.n11*this.n23*this.n32*this.n44-this.n12*this.n21*this.n33*this.n44+this.n11*this.n22*this.n33*this.n44},transpose:function(){function a(b,e,f){var g=b[e];b[e]=b[f]; +b[f]=g}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){return[this.n11,this.n21,this.n31,this.n41,this.n12, +this.n22,this.n32,this.n42,this.n13,this.n23,this.n33,this.n43,this.n14,this.n24,this.n34,this.n44]},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,b,e){var f=new THREE.Matrix4;f.n14=a;f.n24=b;f.n34=e;return f}; +THREE.Matrix4.scaleMatrix=function(a,b,e){var f=new THREE.Matrix4;f.n11=a;f.n22=b;f.n33=e;return f};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.n22=b.n33=Math.cos(a);b.n32=Math.sin(a);b.n23=-b.n32;return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n33=Math.cos(a);b.n13=Math.sin(a);b.n31=-b.n13;return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.n11=b.n22=Math.cos(a);b.n21=Math.sin(a);b.n12=-b.n21;return b}; +THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var e=new THREE.Matrix4,f=Math.cos(b),g=Math.sin(b),h=1-f,j=a.x,c=a.y,i=a.z;e.n11=h*j*j+f;e.n12=h*j*c-g*i;e.n13=h*j*i+g*c;e.n21=h*j*c+g*i;e.n22=h*c*c+f;e.n23=h*c*i-g*j;e.n31=h*j*i-g*c;e.n32=h*c*i+g*j;e.n33=h*i*i+f;return e}; THREE.Matrix4.makeInvert=function(a){var b=new THREE.Matrix4;b.n11=a.n23*a.n34*a.n42-a.n24*a.n33*a.n42+a.n24*a.n32*a.n43-a.n22*a.n34*a.n43-a.n23*a.n32*a.n44+a.n22*a.n33*a.n44;b.n12=a.n14*a.n33*a.n42-a.n13*a.n34*a.n42-a.n14*a.n32*a.n43+a.n12*a.n34*a.n43+a.n13*a.n32*a.n44-a.n12*a.n33*a.n44;b.n13=a.n13*a.n24*a.n42-a.n14*a.n23*a.n42+a.n14*a.n22*a.n43-a.n12*a.n24*a.n43-a.n13*a.n22*a.n44+a.n12*a.n23*a.n44;b.n14=a.n14*a.n23*a.n32-a.n13*a.n24*a.n32-a.n14*a.n22*a.n33+a.n12*a.n24*a.n33+a.n13*a.n22*a.n34-a.n12* a.n23*a.n34;b.n21=a.n24*a.n33*a.n41-a.n23*a.n34*a.n41-a.n24*a.n31*a.n43+a.n21*a.n34*a.n43+a.n23*a.n31*a.n44-a.n21*a.n33*a.n44;b.n22=a.n13*a.n34*a.n41-a.n14*a.n33*a.n41+a.n14*a.n31*a.n43-a.n11*a.n34*a.n43-a.n13*a.n31*a.n44+a.n11*a.n33*a.n44;b.n23=a.n14*a.n23*a.n41-a.n13*a.n24*a.n41-a.n14*a.n21*a.n43+a.n11*a.n24*a.n43+a.n13*a.n21*a.n44-a.n11*a.n23*a.n44;b.n24=a.n13*a.n24*a.n31-a.n14*a.n23*a.n31+a.n14*a.n21*a.n33-a.n11*a.n24*a.n33-a.n13*a.n21*a.n34+a.n11*a.n23*a.n34;b.n31=a.n22*a.n34*a.n41-a.n24*a.n32* a.n41+a.n24*a.n31*a.n42-a.n21*a.n34*a.n42-a.n22*a.n31*a.n44+a.n21*a.n32*a.n44;b.n32=a.n14*a.n32*a.n41-a.n12*a.n34*a.n41-a.n14*a.n31*a.n42+a.n11*a.n34*a.n42+a.n12*a.n31*a.n44-a.n11*a.n32*a.n44;b.n33=a.n13*a.n24*a.n41-a.n14*a.n22*a.n41+a.n14*a.n21*a.n42-a.n11*a.n24*a.n42-a.n12*a.n21*a.n44+a.n11*a.n22*a.n44;b.n34=a.n14*a.n22*a.n31-a.n12*a.n24*a.n31-a.n14*a.n21*a.n32+a.n11*a.n24*a.n32+a.n12*a.n21*a.n34-a.n11*a.n22*a.n34;b.n41=a.n23*a.n32*a.n41-a.n22*a.n33*a.n41-a.n23*a.n31*a.n42+a.n21*a.n33*a.n42+a.n22* a.n31*a.n43-a.n21*a.n32*a.n43;b.n42=a.n12*a.n33*a.n41-a.n13*a.n32*a.n41+a.n13*a.n31*a.n42-a.n11*a.n33*a.n42-a.n12*a.n31*a.n43+a.n11*a.n32*a.n43;b.n43=a.n13*a.n22*a.n41-a.n12*a.n23*a.n41-a.n13*a.n21*a.n42+a.n11*a.n23*a.n42+a.n12*a.n21*a.n43-a.n11*a.n22*a.n43;b.n44=a.n12*a.n23*a.n31-a.n13*a.n22*a.n31+a.n13*a.n21*a.n32-a.n11*a.n23*a.n32-a.n12*a.n21*a.n33+a.n11*a.n22*a.n33;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var f=b[10]*b[5]-b[6]*b[9],e=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],h=-b[10]*b[4]+b[6]*b[8],j=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],i=b[9]*b[4]-b[5]*b[8],l=-b[9]*b[0]+b[1]*b[8],r=b[5]*b[0]-b[1]*b[4];b=b[0]*f+b[1]*h+b[2]*i;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*f;a.m[1]=b*e;a.m[2]=b*g;a.m[3]=b*h;a.m[4]=b*j;a.m[5]=b*c;a.m[6]=b*i;a.m[7]=b*l;a.m[8]=b*r;return a}; -THREE.Matrix4.makeFrustum=function(a,b,f,e,g,h){var j,c,i;j=new THREE.Matrix4;c=2*g/(b-a);i=2*g/(e-f);a=(b+a)/(b-a);f=(e+f)/(e-f);e=-(h+g)/(h-g);g=-2*h*g/(h-g);j.n11=c;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=i;j.n23=f;j.n24=0;j.n31=0;j.n32=0;j.n33=e;j.n34=g;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,f,e){var g;a=f*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,f,e)}; -THREE.Matrix4.makeOrtho=function(a,b,f,e,g,h){var j,c,i,l;j=new THREE.Matrix4;c=b-a;i=f-e;l=h-g;a=(b+a)/c;f=(f+e)/i;g=(h+g)/l;j.n11=2/c;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/i;j.n23=0;j.n24=-f;j.n31=0;j.n32=0;j.n33=-2/l;j.n34=-g;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.flatten();a=new THREE.Matrix3;var e=b[10]*b[5]-b[6]*b[9],f=-b[10]*b[1]+b[2]*b[9],g=b[6]*b[1]-b[2]*b[5],h=-b[10]*b[4]+b[6]*b[8],j=b[10]*b[0]-b[2]*b[8],c=-b[6]*b[0]+b[2]*b[4],i=b[9]*b[4]-b[5]*b[8],l=-b[9]*b[0]+b[1]*b[8],u=b[5]*b[0]-b[1]*b[4];b=b[0]*e+b[1]*h+b[2]*i;if(b==0)throw"matrix not invertible";b=1/b;a.m[0]=b*e;a.m[1]=b*f;a.m[2]=b*g;a.m[3]=b*h;a.m[4]=b*j;a.m[5]=b*c;a.m[6]=b*i;a.m[7]=b*l;a.m[8]=b*u;return a}; +THREE.Matrix4.makeFrustum=function(a,b,e,f,g,h){var j,c,i;j=new THREE.Matrix4;c=2*g/(b-a);i=2*g/(f-e);a=(b+a)/(b-a);e=(f+e)/(f-e);f=-(h+g)/(h-g);g=-2*h*g/(h-g);j.n11=c;j.n12=0;j.n13=a;j.n14=0;j.n21=0;j.n22=i;j.n23=e;j.n24=0;j.n31=0;j.n32=0;j.n33=f;j.n34=g;j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(a,b,e,f){var g;a=e*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,e,f)}; +THREE.Matrix4.makeOrtho=function(a,b,e,f,g,h){var j,c,i,l;j=new THREE.Matrix4;c=b-a;i=e-f;l=h-g;a=(b+a)/c;e=(e+f)/i;g=(h+g)/l;j.n11=2/c;j.n12=0;j.n13=0;j.n14=-a;j.n21=0;j.n22=2/i;j.n23=0;j.n24=-e;j.n31=0;j.n32=0;j.n33=-2/l;j.n34=-g;j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j}; 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,f,e,g){this.a=a;this.b=b;this.c=f;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,f,e,g,h){this.a=a;this.b=b;this.c=f;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=h instanceof Array?h:[h]};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.Face3=function(a,b,e,f,g){this.a=a;this.b=b;this.c=e;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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,e,f,g,h){this.a=a;this.b=b;this.c=e;this.d=f;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=h instanceof Array?h:[h]};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.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=false}; -THREE.Geometry.prototype={computeCentroids:function(){var a,b,f;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],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,f=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[0])this.boundingBox.z[0]=a.position.z;else 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,f=this.vertices.length;b65535){l[c].counter+=1;i=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:j,vertices:0}}this.geometryChunks[i].faces.push(e); -this.geometryChunks[i].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; -THREE.Camera=function(a,b,f,e){this.fov=a;this.aspect=b;this.near=f;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.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); +THREE.Geometry.prototype={computeCentroids:function(){var a,b,e;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], +z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,e=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,e=this.vertices.length;b65535){l[c].counter+=1;i=l[c].hash+"_"+l[c].counter;if(this.geometryChunks[i]==undefined)this.geometryChunks[i]={faces:[],materials:j,vertices:0}}this.geometryChunks[i].faces.push(f);this.geometryChunks[i].vertices+=h}},toString:function(){return"THREE.Geometry ( vertices: "+ +this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}}; +THREE.Camera=function(a,b,e,f){this.fov=a;this.aspect=b;this.near=e;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.translateX=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g);g.cross(g.clone(),this.up);this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ=function(g){g=this.target.position.clone().subSelf(this.position).normalize().multiplyScalar(g); this.position.subSelf(g);this.target.position.subSelf(g)};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;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; THREE.PointLight=function(a,b){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=b||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.PointLight; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.translationMatrix=new THREE.Matrix4;this.rotationMatrix=new THREE.Matrix4;this.scaleMatrix=new THREE.Matrix4;this.screen=new THREE.Vector3;this.visible=this.autoUpdateMatrix=true}; THREE.Object3D.prototype={updateMatrix:function(){this.matrixPosition=THREE.Matrix4.translationMatrix(this.position.x,this.position.y,this.position.z);this.rotationMatrix=THREE.Matrix4.rotationXMatrix(this.rotation.x);this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationYMatrix(this.rotation.y));this.rotationMatrix.multiplySelf(THREE.Matrix4.rotationZMatrix(this.rotation.z));this.scaleMatrix=THREE.Matrix4.scaleMatrix(this.scale.x,this.scale.y,this.scale.z);this.matrix.copy(this.matrixPosition); this.matrix.multiplySelf(this.rotationMatrix);this.matrix.multiplySelf(this.scaleMatrix)}};THREE.Object3DCounter={value:0};THREE.Particle=function(a){THREE.Object3D.call(this);this.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,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.autoUpdateMatrix=false}; -THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,f){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=f!==undefined?f:THREE.LineContinuous};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; +THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;THREE.Line=function(a,b,e){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];this.type=e!==undefined?e:THREE.LineContinuous};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line; THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.materials=b instanceof Array?b:[b];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.LineBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.linewidth=1;this.linejoin=this.linecap="round";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.linewidth!==undefined)this.linewidth=a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin}}; THREE.LineBasicMaterial.prototype={toString:function(){return"THREE.LineBasicMaterial (
color: "+this.color+"
opacity: "+this.opacity+"
blending: "+this.blending+"
linewidth: "+this.linewidth+"
linecap: "+this.linecap+"
linejoin: "+this.linejoin+"
)"}}; @@ -90,94 +91,97 @@ THREE.MeshShaderMaterial.prototype={toString:function(){return"THREE.MeshShaderM THREE.ParticleBasicMaterial=function(a){this.color=new THREE.Color(16777215);this.map=null;this.opacity=1;this.blending=THREE.NormalBlending;this.offset=new THREE.Vector2;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.map!==undefined)this.map=a.map;if(a.opacity!==undefined)this.opacity=a.opacity;if(a.blending!==undefined)this.blending=a.blending}}; THREE.ParticleBasicMaterial.prototype={toString:function(){return"THREE.ParticleBasicMaterial (
color: "+this.color+"
map: "+this.map+"
opacity: "+this.opacity+"
blending: "+this.blending+"
)"}};THREE.ParticleCircleMaterial=function(a){this.color=new THREE.Color(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,b,f,e,g,h){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=f!==undefined?f:THREE.ClampToEdgeWrapping;this.wrap_t=e!==undefined?e:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=h!==undefined?h:THREE.LinearMipMapLinearFilter}; +THREE.Texture=function(a,b,e,f,g,h){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrap_s=e!==undefined?e:THREE.ClampToEdgeWrapping;this.wrap_t=f!==undefined?f:THREE.ClampToEdgeWrapping;this.mag_filter=g!==undefined?g:THREE.LinearFilter;this.min_filter=h!==undefined?h: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;var Uniforms={clone:function(a){var b,f,e,g={};for(b in a){g[b]={};for(f in a[b]){e=a[b][f];g[b][f]=e instanceof THREE.Color||e instanceof THREE.Vector3||e instanceof THREE.Texture?e.clone():e}}return g},merge:function(a){var b,f,e,g={};for(b=0;b=0&&y>=0&&w>=0&&C>=0)return true;else if(D<0&&y<0||w<0&&C<0)return false;else{if(D<0)x=Math.max(x,D/(D-y));else if(y<0)t=Math.min(t,D/(D-y));if(w<0)x=Math.max(x,w/(w-C));else if(C<0)t=Math.min(t,w/(w-C));if(tD&&M.z0&&K.z<1){o=z[v]=z[v]||new THREE.RenderableParticle;o.x=K.x/K.w;o.y=K.y/K.w;o.z=K.z;o.rotation=O.rotation.z;o.scale.x=O.scale.x*Math.abs(o.x-(K.x+m.projectionMatrix.n11)/(K.w+m.projectionMatrix.n14)); -o.scale.y=O.scale.y*Math.abs(o.y-(K.y+m.projectionMatrix.n22)/(K.w+m.projectionMatrix.n24));o.materials=O.materials;t.push(o);v++}}}}x&&t.sort(a);return t};this.unprojectVector=function(n,m){var x=new THREE.Matrix4;x.multiply(THREE.Matrix4.makeInvert(m.matrix),THREE.Matrix4.makeInvert(m.projectionMatrix));x.multiplyVector3(n);return n}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,f,e,g,h;this.domElement=document.createElement("div");this.setSize=function(j,c){f=j;e=c;g=f/2;h=e/2};this.render=function(j,c){var i,l,r,B,o,v,z,A;a=b.projectScene(j,c);i=0;for(l=a.length;i0){J.r+=fa.r*ca;J.g+=fa.g*ca;J.b+=fa.b*ca}}else if(ca instanceof THREE.PointLight){H.sub(ca.position,X);H.normalize();ca=T.dot(H)*ia;if(ca>0){J.r+=fa.r*ca;J.g+=fa.g*ca;J.b+=fa.b*ca}}}}function Na(F,X,T){if(T.opacity!=0){a(T.opacity); -b(T.blending);var J,P,ca,fa,ia,la;if(T instanceof THREE.ParticleBasicMaterial){if(T.map){fa=T.map;ia=fa.width>>1;la=fa.height>>1;P=X.scale.x*c;ca=X.scale.y*i;T=P*ia;J=ca*la;I.set(F.x-T,F.y-J,F.x+T,F.y+J);if(Z.instersects(I)){l.save();l.translate(F.x,F.y);l.rotate(-X.rotation);l.scale(P,-ca);l.translate(-ia,-la);l.drawImage(fa,0,0);l.restore()}}}else if(T instanceof THREE.ParticleCircleMaterial){if(S){Y.r=ha.r+ja.r+u.r;Y.g=ha.g+ja.g+u.g;Y.b=ha.b+ja.b+u.b;t.r=T.color.r*Y.r;t.g=T.color.g*Y.g;t.b=T.color.b* -Y.b;t.updateStyleString()}else t.__styleString=T.color.__styleString;T=X.scale.x*c;J=X.scale.y*i;I.set(F.x-T,F.y-J,F.x+T,F.y+J);if(Z.instersects(I)){P=t.__styleString;if(A!=P)l.fillStyle=A=P;l.save();l.translate(F.x,F.y);l.rotate(-X.rotation);l.scale(T,J);l.beginPath();l.arc(0,0,1,0,G,true);l.closePath();l.fill();l.restore()}}}}function Oa(F,X,T,J){if(J.opacity!=0){a(J.opacity);b(J.blending);l.beginPath();l.moveTo(F.positionScreen.x,F.positionScreen.y);l.lineTo(X.positionScreen.x,X.positionScreen.y); -l.closePath();if(J instanceof THREE.LineBasicMaterial){t.__styleString=J.color.__styleString;F=J.linewidth;if(K!=F)l.lineWidth=K=F;F=t.__styleString;if(z!=F)l.strokeStyle=z=F;l.stroke();I.inflate(J.linewidth*2)}}}function Ia(F,X,T,J,P,ca){if(P.opacity!=0){a(P.opacity);b(P.blending);k=F.positionScreen.x;q=F.positionScreen.y;s=X.positionScreen.x;n=X.positionScreen.y;m=T.positionScreen.x;x=T.positionScreen.y;l.beginPath();l.moveTo(k,q);l.lineTo(s,n);l.lineTo(m,x);l.lineTo(k,q);l.closePath();if(P instanceof -THREE.MeshBasicMaterial)if(P.map)P.map.image.loaded&&P.map.mapping instanceof THREE.UVMapping&&xa(k,q,s,n,m,x,P.map.image,J.uvs[0].u,J.uvs[0].v,J.uvs[1].u,J.uvs[1].v,J.uvs[2].u,J.uvs[2].v);else if(P.env_map){if(P.env_map.image.loaded)if(P.env_map.mapping instanceof THREE.SphericalReflectionMapping){F=sa.matrix;H.copy(J.vertexNormalsWorld[0]);V=(H.x*F.n11+H.y*F.n12+H.z*F.n13)*0.5+0.5;O=-(H.x*F.n21+H.y*F.n22+H.z*F.n23)*0.5+0.5;H.copy(J.vertexNormalsWorld[1]);ba=(H.x*F.n11+H.y*F.n12+H.z*F.n13)*0.5+0.5; -R=-(H.x*F.n21+H.y*F.n22+H.z*F.n23)*0.5+0.5;H.copy(J.vertexNormalsWorld[2]);L=(H.x*F.n11+H.y*F.n12+H.z*F.n13)*0.5+0.5;N=-(H.x*F.n21+H.y*F.n22+H.z*F.n23)*0.5+0.5;xa(k,q,s,n,m,x,P.env_map.image,V,O,ba,R,L,N)}}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){P.map.mapping instanceof THREE.UVMapping&&xa(k,q,s,n,m,x,P.map.image,J.uvs[0].u,J.uvs[0].v,J.uvs[1].u,J.uvs[1].v,J.uvs[2].u,J.uvs[2].v); -b(THREE.SubtractiveBlending)}if(S)if(!P.wireframe&&P.shading==THREE.SmoothShading&&J.vertexNormalsWorld.length==3){D.r=y.r=w.r=ha.r;D.g=y.g=w.g=ha.g;D.b=y.b=w.b=ha.b;Aa(ca,J.v1.positionWorld,J.vertexNormalsWorld[0],D);Aa(ca,J.v2.positionWorld,J.vertexNormalsWorld[1],y);Aa(ca,J.v3.positionWorld,J.vertexNormalsWorld[2],w);C.r=(y.r+w.r)*0.5;C.g=(y.g+w.g)*0.5;C.b=(y.b+w.b)*0.5;U=Ja(D,y,w,C);xa(k,q,s,n,m,x,U,0,0,1,0,0,1)}else{Y.r=ha.r;Y.g=ha.g;Y.b=ha.b;Aa(ca,J.centroidWorld,J.normalWorld,Y);t.r=P.color.r* -Y.r;t.g=P.color.g*Y.g;t.b=P.color.b*Y.b;t.updateStyleString();P.wireframe?Ba(t.__styleString,P.wireframe_linewidth):Ca(t.__styleString)}else P.wireframe?Ba(P.color.__styleString,P.wireframe_linewidth):Ca(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){$=sa.near;M=sa.far;D.r=D.g=D.b=1-Ea(F.positionScreen.z,$,M);y.r=y.g=y.b=1-Ea(X.positionScreen.z,$,M);w.r=w.g=w.b=1-Ea(T.positionScreen.z,$,M);C.r=(y.r+w.r)*0.5;C.g=(y.g+w.g)*0.5;C.b=(y.b+w.b)*0.5;U=Ja(D,y,w,C);xa(k,q,s,n,m,x,U,0, -0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){t.r=Fa(J.normalWorld.x);t.g=Fa(J.normalWorld.y);t.b=Fa(J.normalWorld.z);t.updateStyleString();P.wireframe?Ba(t.__styleString,P.wireframe_linewidth):Ca(t.__styleString)}}}function Ba(F,X){if(z!=F)l.strokeStyle=z=F;if(K!=X)l.lineWidth=K=X;l.stroke();I.inflate(X*2)}function Ca(F){if(A!=F)l.fillStyle=A=F;l.fill()}function xa(F,X,T,J,P,ca,fa,ia,la,oa,ma,pa,ya){var ua,qa;ua=fa.width-1;qa=fa.height-1;ia*=ua;la*=qa;oa*=ua;ma*=qa;pa*=ua;ya*=qa;T-=F; -J-=X;P-=F;ca-=X;oa-=ia;ma-=la;pa-=ia;ya-=la;qa=1/(oa*ya-pa*ma);ua=(ya*T-ma*P)*qa;ma=(ya*J-ma*ca)*qa;T=(oa*P-pa*T)*qa;J=(oa*ca-pa*J)*qa;F=F-ua*ia-T*la;X=X-ma*ia-J*la;l.save();l.transform(ua,ma,T,J,F,X);l.clip();l.drawImage(fa,0,0);l.restore()}function Ja(F,X,T,J){var P=~~(F.r*255),ca=~~(F.g*255);F=~~(F.b*255);var fa=~~(X.r*255),ia=~~(X.g*255);X=~~(X.b*255);var la=~~(T.r*255),oa=~~(T.g*255);T=~~(T.b*255);var ma=~~(J.r*255),pa=~~(J.g*255);J=~~(J.b*255);ea[0]=P<0?0:P>255?255:P;ea[1]=ca<0?0:ca>255?255: -ca;ea[2]=F<0?0:F>255?255:F;ea[4]=fa<0?0:fa>255?255:fa;ea[5]=ia<0?0:ia>255?255:ia;ea[6]=X<0?0:X>255?255:X;ea[8]=la<0?0:la>255?255:la;ea[9]=oa<0?0:oa>255?255:oa;ea[10]=T<0?0:T>255?255:T;ea[12]=ma<0?0:ma>255?255:ma;ea[13]=pa<0?0:pa>255?255:pa;ea[14]=J<0?0:J>255?255:J;aa.putImageData(ka,0,0);ta.drawImage(Q,0,0);return ra}function Ea(F,X,T){F=(F-X)/(T-X);return F*F*(3-2*F)}function Fa(F){F=(F+1)*0.5;return F<0?0:F>1?1:F}function Ga(F,X){var T=X.x-F.x,J=X.y-F.y,P=1/Math.sqrt(T*T+J*J);T*=P;J*=P;X.x+=T;X.y+= -J;F.x-=T;F.y-=J}var Da,Ka,da,na,wa,Ha,La,za;l.setTransform(1,0,0,-1,c,i);this.autoClear&&this.clear();f=e.projectScene(ga,sa,this.sortElements);(S=ga.lights.length>0)&&Ma(ga);Da=0;for(Ka=f.length;Da0){ba.r+=N.color.r*Z;ba.g+=N.color.g*Z;ba.b+=N.color.b*Z}}else if(N instanceof THREE.PointLight){x.sub(N.position,O.centroidWorld);x.normalize();Z=O.normalWorld.dot(x)*N.intensity;if(Z>0){ba.r+=N.color.r*Z;ba.g+=N.color.g*Z;ba.b+=N.color.b*Z}}}}function b(V,O,ba,R,L,N){w=e(C++);w.setAttribute("d","M "+ -V.positionScreen.x+" "+V.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(L instanceof THREE.MeshBasicMaterial)d.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshLambertMaterial)if(E){k.r=q.r;k.g=q.g;k.b=q.b;a(N,R,k);d.r=L.color.r*k.r;d.g=L.color.g*k.g;d.b=L.color.b*k.b;d.updateStyleString()}else d.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshDepthMaterial){m=1-L.__2near/(L.__farPlusNear- -R.z*L.__farMinusNear);d.setRGB(m,m,m)}else L instanceof THREE.MeshNormalMaterial&&d.setRGB(g(R.normalWorld.x),g(R.normalWorld.y),g(R.normalWorld.z));L.wireframe?w.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+L.wireframe_linewidth+"; stroke-opacity: "+L.opacity+"; stroke-linecap: "+L.wireframe_linecap+"; stroke-linejoin: "+L.wireframe_linejoin):w.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+L.opacity);c.appendChild(w)}function f(V,O,ba,R,L,N,Z){w= -e(C++);w.setAttribute("d","M "+V.positionScreen.x+" "+V.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+R.positionScreen.x+","+R.positionScreen.y+"z");if(N instanceof THREE.MeshBasicMaterial)d.__styleString=N.color.__styleString;else if(N instanceof THREE.MeshLambertMaterial)if(E){k.r=q.r;k.g=q.g;k.b=q.b;a(Z,L,k);d.r=N.color.r*k.r;d.g=N.color.g*k.g;d.b=N.color.b*k.b;d.updateStyleString()}else d.__styleString=N.color.__styleString; -else if(N instanceof THREE.MeshDepthMaterial){m=1-N.__2near/(N.__farPlusNear-L.z*N.__farMinusNear);d.setRGB(m,m,m)}else N instanceof THREE.MeshNormalMaterial&&d.setRGB(g(L.normalWorld.x),g(L.normalWorld.y),g(L.normalWorld.z));N.wireframe?w.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+N.wireframe_linewidth+"; stroke-opacity: "+N.opacity+"; stroke-linecap: "+N.wireframe_linecap+"; stroke-linejoin: "+N.wireframe_linejoin):w.setAttribute("style","fill: "+d.__styleString+ -"; fill-opacity: "+N.opacity);c.appendChild(w)}function e(V){if(t[V]==null){t[V]=document.createElementNS("http://www.w3.org/2000/svg","path");U==0&&t[V].setAttribute("shape-rendering","crispEdges");return t[V]}return t[V]}function g(V){return V<0?Math.min((1+V)*0.5,0.5):0.5+Math.min(V*0.5,0.5)}var h=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,l,r,B,o,v,z,A,K=new THREE.Rectangle,p=new THREE.Rectangle,E=false,d=new THREE.Color(16777215),k=new THREE.Color(16777215), -q=new THREE.Color(0),s=new THREE.Color(0),n=new THREE.Color(0),m,x=new THREE.Vector3,t=[],D=[],y=[],w,C,$,M,U=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(V){switch(V){case "high":U=1;break;case "low":U=0}};this.setSize=function(V,O){i=V;l=O;r=i/2;B=l/2;c.setAttribute("viewBox",-r+" "+-B+" "+i+" "+l);c.setAttribute("width",i);c.setAttribute("height",l);K.set(-r,-B,r,B)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])}; -this.render=function(V,O){var ba,R,L,N,Z,W,I,S;this.autoClear&&this.clear();h=j.projectScene(V,O,this.sortElements);M=$=C=0;if(E=V.lights.length>0){I=V.lights;q.setRGB(0,0,0);s.setRGB(0,0,0);n.setRGB(0,0,0);ba=0;for(R=I.length;ba0){L.__webGLUVBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,L.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,new Float32Array(ba),c.STATIC_DRAW)}L.__webGLFaceBuffer=c.createBuffer(); -c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,L.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array($),c.STATIC_DRAW);L.__webGLLineBuffer=c.createBuffer();c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,L.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,new Uint16Array(M),c.STATIC_DRAW);L.__webGLFaceCount=$.length;L.__webGLLineCount=M.length}};this.renderBuffer=function(d,k,q,s,n){var m,x,t,D;if(!s.program){if(s instanceof THREE.MeshDepthMaterial){b(s,THREE.ShaderLib.depth);s.uniforms.mNear.value= -d.near;s.uniforms.mFar.value=d.far}else if(s instanceof THREE.MeshNormalMaterial)b(s,THREE.ShaderLib.normal);else if(s instanceof THREE.MeshBasicMaterial){b(s,THREE.ShaderLib.basic);f(s,q)}else if(s instanceof THREE.MeshLambertMaterial){b(s,THREE.ShaderLib.lambert);f(s,q)}else if(s instanceof THREE.MeshPhongMaterial){b(s,THREE.ShaderLib.phong);f(s,q)}else if(s instanceof THREE.LineBasicMaterial){b(s,THREE.ShaderLib.basic);e(s,q)}var y,w,C;y=D=x=0;for(w=k.length;y0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+D.maxDirLights,"#define MAX_POINT_LIGHTS "+D.maxPointLights,D.map?"#define USE_MAP":"",D.env_map?"#define USE_ENVMAP":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n"); -c.attachShader(w,g("fragment",C+x));c.attachShader(w,g("vertex",D+y));c.linkProgram(w);c.getProgramParameter(w,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(w,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");w.uniforms={};w.attributes={};s.program=w;x=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(m in s.uniforms)x.push(m);m=s.program;y=0;for(w=x.length;y=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLNormalBuffer); -c.vertexAttribPointer(t.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(t.normal)}if(t.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLTangentBuffer);c.vertexAttribPointer(t.tangent,4,c.FLOAT,false,0,0);c.enableVertexAttribArray(t.tangent)}if(t.uv>=0)if(n.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,n.__webGLUVBuffer);c.vertexAttribPointer(t.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(t.uv)}else c.disableVertexAttribArray(t.uv);if(s.wireframe||s instanceof THREE.LineBasicMaterial){t= -s.wireframe_linewidth!==undefined?s.wireframe_linewidth:s.linewidth!==undefined?s.linewidth:1;s=s instanceof THREE.LineBasicMaterial&&n.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(t);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLLineBuffer);c.drawElements(s,n.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,n.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,n.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,k,q,s,n,m,x){var t,D,y,w,C;y=0;for(w= -s.materials.length;y=0;q--){s=d.__webGLObjects[q].object;k==s&&d.__webGLObjects.splice(q,1)}};this.setupMatrices=function(d,k){d.autoUpdateMatrix&&d.updateMatrix(); -l.multiply(k.matrix,d.matrix);o.set(l.flatten());r=THREE.Matrix4.makeInvert3x3(l).transpose();z.set(r.m);A.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,B);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,o);c.uniformMatrix4fv(d.uniforms.projectionMatrix,false,v);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,z);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,A)};this.loadCamera=function(d,k){c.uniform3f(d.uniforms.cameraPosition,k.position.x, -k.position.y,k.position.z)};this.setBlending=function(d){switch(d){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(d,k){if(d){!k||k=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)}; -this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; -THREE.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, 1.0 ), 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\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\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_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\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\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,b,e){this.color=new THREE.Color(a);this.near=b||1;this.far=e||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4}; +THREE.Projector=function(){function a(r,t){return t.z-r.z}function b(r,t){var w=0,v=1,H=r.z+r.w,y=t.z+t.w,n=-r.z+r.w,D=-t.z+t.w;if(H>=0&&y>=0&&n>=0&&D>=0)return true;else if(H<0&&y<0||n<0&&D<0)return false;else{if(H<0)w=Math.max(w,H/(H-y));else if(y<0)v=Math.min(v,H/(H-y));if(n<0)w=Math.max(w,n/(n-D));else if(D<0)v=Math.min(v,n/(n-D));if(vH&&J.z0&&M.z<1){o=A[x]=A[x]||new THREE.RenderableParticle;o.x=M.x/M.w;o.y=M.y/M.w;o.z=M.z;o.rotation=R.rotation.z;o.scale.x=R.scale.x*Math.abs(o.x-(M.x+t.projectionMatrix.n11)/(M.w+t.projectionMatrix.n14)); +o.scale.y=R.scale.y*Math.abs(o.y-(M.y+t.projectionMatrix.n22)/(M.w+t.projectionMatrix.n24));o.materials=R.materials;v.push(o);x++}}}}w&&v.sort(a);return v};this.unprojectVector=function(r,t){var w=new THREE.Matrix4;w.multiply(THREE.Matrix4.makeInvert(t.matrix),THREE.Matrix4.makeInvert(t.projectionMatrix));w.multiplyVector3(r);return r}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,e,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,c){e=j;f=c;g=e/2;h=f/2};this.render=function(j,c){var i,l,u,C,o,x,A,B;a=b.projectScene(j,c);i=0;for(l=a.length;i0){K.r+=ha.r*ca;K.g+=ha.g*ca;K.b+=ha.b*ca}}else if(ca instanceof THREE.PointLight){E.sub(ca.position,ba);E.normalize();ca=Y.dot(E)*ja;if(ca>0){K.r+=ha.r*ca;K.g+=ha.g*ca;K.b+=ha.b*ca}}}}function Na(I,ba,Y){if(Y.opacity!=0){a(Y.opacity); +b(Y.blending);var K,V,ca,ha,ja,la;if(Y instanceof THREE.ParticleBasicMaterial){if(Y.map){ha=Y.map;ja=ha.width>>1;la=ha.height>>1;V=ba.scale.x*c;ca=ba.scale.y*i;Y=V*ja;K=ca*la;z.set(I.x-Y,I.y-K,I.x+Y,I.y+K);if(Z.instersects(z)){l.save();l.translate(I.x,I.y);l.rotate(-ba.rotation);l.scale(V,-ca);l.translate(-ja,-la);l.drawImage(ha,0,0);l.restore()}}}else if(Y instanceof THREE.ParticleCircleMaterial){if(N){Q.r=ea.r+da.r+m.r;Q.g=ea.g+da.g+m.g;Q.b=ea.b+da.b+m.b;v.r=Y.color.r*Q.r;v.g=Y.color.g*Q.g;v.b= +Y.color.b*Q.b;v.updateStyleString()}else v.__styleString=Y.color.__styleString;Y=ba.scale.x*c;K=ba.scale.y*i;z.set(I.x-Y,I.y-K,I.x+Y,I.y+K);if(Z.instersects(z)){V=v.__styleString;if(B!=V)l.fillStyle=B=V;l.save();l.translate(I.x,I.y);l.rotate(-ba.rotation);l.scale(Y,K);l.beginPath();l.arc(0,0,1,0,F,true);l.closePath();l.fill();l.restore()}}}}function Oa(I,ba,Y,K){if(K.opacity!=0){a(K.opacity);b(K.blending);l.beginPath();l.moveTo(I.positionScreen.x,I.positionScreen.y);l.lineTo(ba.positionScreen.x,ba.positionScreen.y); +l.closePath();if(K instanceof THREE.LineBasicMaterial){v.__styleString=K.color.__styleString;I=K.linewidth;if(M!=I)l.lineWidth=M=I;I=v.__styleString;if(A!=I)l.strokeStyle=A=I;l.stroke();z.inflate(K.linewidth*2)}}}function Ia(I,ba,Y,K,V,ca){if(V.opacity!=0){a(V.opacity);b(V.blending);k=I.positionScreen.x;p=I.positionScreen.y;s=ba.positionScreen.x;r=ba.positionScreen.y;t=Y.positionScreen.x;w=Y.positionScreen.y;l.beginPath();l.moveTo(k,p);l.lineTo(s,r);l.lineTo(t,w);l.lineTo(k,p);l.closePath();if(V instanceof +THREE.MeshBasicMaterial)if(V.map)V.map.image.loaded&&V.map.mapping instanceof THREE.UVMapping&&xa(k,p,s,r,t,w,V.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v);else if(V.env_map){if(V.env_map.image.loaded)if(V.env_map.mapping instanceof THREE.SphericalReflectionMapping){I=sa.matrix;E.copy(K.vertexNormalsWorld[0]);U=(E.x*I.n11+E.y*I.n12+E.z*I.n13)*0.5+0.5;R=-(E.x*I.n21+E.y*I.n22+E.z*I.n23)*0.5+0.5;E.copy(K.vertexNormalsWorld[1]);$=(E.x*I.n11+E.y*I.n12+E.z*I.n13)*0.5+0.5; +X=-(E.x*I.n21+E.y*I.n22+E.z*I.n23)*0.5+0.5;E.copy(K.vertexNormalsWorld[2]);L=(E.x*I.n11+E.y*I.n12+E.z*I.n13)*0.5+0.5;O=-(E.x*I.n21+E.y*I.n22+E.z*I.n23)*0.5+0.5;xa(k,p,s,r,t,w,V.env_map.image,U,R,$,X,L,O)}}else V.wireframe?Ba(V.color.__styleString,V.wireframe_linewidth):Ca(V.color.__styleString);else if(V instanceof THREE.MeshLambertMaterial){if(V.map&&!V.wireframe){V.map.mapping instanceof THREE.UVMapping&&xa(k,p,s,r,t,w,V.map.image,K.uvs[0].u,K.uvs[0].v,K.uvs[1].u,K.uvs[1].v,K.uvs[2].u,K.uvs[2].v); +b(THREE.SubtractiveBlending)}if(N)if(!V.wireframe&&V.shading==THREE.SmoothShading&&K.vertexNormalsWorld.length==3){H.r=y.r=n.r=ea.r;H.g=y.g=n.g=ea.g;H.b=y.b=n.b=ea.b;Aa(ca,K.v1.positionWorld,K.vertexNormalsWorld[0],H);Aa(ca,K.v2.positionWorld,K.vertexNormalsWorld[1],y);Aa(ca,K.v3.positionWorld,K.vertexNormalsWorld[2],n);D.r=(y.r+n.r)*0.5;D.g=(y.g+n.g)*0.5;D.b=(y.b+n.b)*0.5;P=Ja(H,y,n,D);xa(k,p,s,r,t,w,P,0,0,1,0,0,1)}else{Q.r=ea.r;Q.g=ea.g;Q.b=ea.b;Aa(ca,K.centroidWorld,K.normalWorld,Q);v.r=V.color.r* +Q.r;v.g=V.color.g*Q.g;v.b=V.color.b*Q.b;v.updateStyleString();V.wireframe?Ba(v.__styleString,V.wireframe_linewidth):Ca(v.__styleString)}else V.wireframe?Ba(V.color.__styleString,V.wireframe_linewidth):Ca(V.color.__styleString)}else if(V instanceof THREE.MeshDepthMaterial){W=sa.near;J=sa.far;H.r=H.g=H.b=1-Ea(I.positionScreen.z,W,J);y.r=y.g=y.b=1-Ea(ba.positionScreen.z,W,J);n.r=n.g=n.b=1-Ea(Y.positionScreen.z,W,J);D.r=(y.r+n.r)*0.5;D.g=(y.g+n.g)*0.5;D.b=(y.b+n.b)*0.5;P=Ja(H,y,n,D);xa(k,p,s,r,t,w,P, +0,0,1,0,0,1)}else if(V instanceof THREE.MeshNormalMaterial){v.r=Fa(K.normalWorld.x);v.g=Fa(K.normalWorld.y);v.b=Fa(K.normalWorld.z);v.updateStyleString();V.wireframe?Ba(v.__styleString,V.wireframe_linewidth):Ca(v.__styleString)}}}function Ba(I,ba){if(A!=I)l.strokeStyle=A=I;if(M!=ba)l.lineWidth=M=ba;l.stroke();z.inflate(ba*2)}function Ca(I){if(B!=I)l.fillStyle=B=I;l.fill()}function xa(I,ba,Y,K,V,ca,ha,ja,la,oa,ma,pa,ya){var ua,qa;ua=ha.width-1;qa=ha.height-1;ja*=ua;la*=qa;oa*=ua;ma*=qa;pa*=ua;ya*= +qa;Y-=I;K-=ba;V-=I;ca-=ba;oa-=ja;ma-=la;pa-=ja;ya-=la;qa=1/(oa*ya-pa*ma);ua=(ya*Y-ma*V)*qa;ma=(ya*K-ma*ca)*qa;Y=(oa*V-pa*Y)*qa;K=(oa*ca-pa*K)*qa;I=I-ua*ja-Y*la;ba=ba-ma*ja-K*la;l.save();l.transform(ua,ma,Y,K,I,ba);l.clip();l.drawImage(ha,0,0);l.restore()}function Ja(I,ba,Y,K){var V=~~(I.r*255),ca=~~(I.g*255);I=~~(I.b*255);var ha=~~(ba.r*255),ja=~~(ba.g*255);ba=~~(ba.b*255);var la=~~(Y.r*255),oa=~~(Y.g*255);Y=~~(Y.b*255);var ma=~~(K.r*255),pa=~~(K.g*255);K=~~(K.b*255);ga[0]=V<0?0:V>255?255:V;ga[1]= +ca<0?0:ca>255?255:ca;ga[2]=I<0?0:I>255?255:I;ga[4]=ha<0?0:ha>255?255:ha;ga[5]=ja<0?0:ja>255?255:ja;ga[6]=ba<0?0:ba>255?255:ba;ga[8]=la<0?0:la>255?255:la;ga[9]=oa<0?0:oa>255?255:oa;ga[10]=Y<0?0:Y>255?255:Y;ga[12]=ma<0?0:ma>255?255:ma;ga[13]=pa<0?0:pa>255?255:pa;ga[14]=K<0?0:K>255?255:K;aa.putImageData(ka,0,0);ta.drawImage(T,0,0);return ra}function Ea(I,ba,Y){I=(I-ba)/(Y-ba);return I*I*(3-2*I)}function Fa(I){I=(I+1)*0.5;return I<0?0:I>1?1:I}function Ga(I,ba){var Y=ba.x-I.x,K=ba.y-I.y,V=1/Math.sqrt(Y* +Y+K*K);Y*=V;K*=V;ba.x+=Y;ba.y+=K;I.x-=Y;I.y-=K}var Da,Ka,fa,na,wa,Ha,La,za;l.setTransform(1,0,0,-1,c,i);this.autoClear&&this.clear();e=f.projectScene(ia,sa,this.sortElements);(N=ia.lights.length>0)&&Ma(ia);Da=0;for(Ka=e.length;Da0){$.r+=O.color.r*Z;$.g+=O.color.g*Z;$.b+=O.color.b*Z}}else if(O instanceof THREE.PointLight){w.sub(O.position,R.centroidWorld);w.normalize();Z=R.normalWorld.dot(w)*O.intensity;if(Z>0){$.r+=O.color.r*Z;$.g+=O.color.g*Z;$.b+=O.color.b*Z}}}}function b(U,R,$,X,L,O){n=f(D++);n.setAttribute("d","M "+U.positionScreen.x+ +" "+U.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+$.positionScreen.x+","+$.positionScreen.y+"z");if(L instanceof THREE.MeshBasicMaterial)d.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshLambertMaterial)if(G){k.r=p.r;k.g=p.g;k.b=p.b;a(O,X,k);d.r=L.color.r*k.r;d.g=L.color.g*k.g;d.b=L.color.b*k.b;d.updateStyleString()}else d.__styleString=L.color.__styleString;else if(L instanceof THREE.MeshDepthMaterial){t=1-L.__2near/(L.__farPlusNear-X.z*L.__farMinusNear); +d.setRGB(t,t,t)}else L instanceof THREE.MeshNormalMaterial&&d.setRGB(g(X.normalWorld.x),g(X.normalWorld.y),g(X.normalWorld.z));L.wireframe?n.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+L.wireframe_linewidth+"; stroke-opacity: "+L.opacity+"; stroke-linecap: "+L.wireframe_linecap+"; stroke-linejoin: "+L.wireframe_linejoin):n.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+L.opacity);c.appendChild(n)}function e(U,R,$,X,L,O,Z){n=f(D++);n.setAttribute("d", +"M "+U.positionScreen.x+" "+U.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+$.positionScreen.x+","+$.positionScreen.y+" L "+X.positionScreen.x+","+X.positionScreen.y+"z");if(O instanceof THREE.MeshBasicMaterial)d.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshLambertMaterial)if(G){k.r=p.r;k.g=p.g;k.b=p.b;a(Z,L,k);d.r=O.color.r*k.r;d.g=O.color.g*k.g;d.b=O.color.b*k.b;d.updateStyleString()}else d.__styleString=O.color.__styleString;else if(O instanceof THREE.MeshDepthMaterial){t= +1-O.__2near/(O.__farPlusNear-L.z*O.__farMinusNear);d.setRGB(t,t,t)}else O instanceof THREE.MeshNormalMaterial&&d.setRGB(g(L.normalWorld.x),g(L.normalWorld.y),g(L.normalWorld.z));O.wireframe?n.setAttribute("style","fill: none; stroke: "+d.__styleString+"; stroke-width: "+O.wireframe_linewidth+"; stroke-opacity: "+O.opacity+"; stroke-linecap: "+O.wireframe_linecap+"; stroke-linejoin: "+O.wireframe_linejoin):n.setAttribute("style","fill: "+d.__styleString+"; fill-opacity: "+O.opacity);c.appendChild(n)} +function f(U){if(v[U]==null){v[U]=document.createElementNS("http://www.w3.org/2000/svg","path");P==0&&v[U].setAttribute("shape-rendering","crispEdges");return v[U]}return v[U]}function g(U){return U<0?Math.min((1+U)*0.5,0.5):0.5+Math.min(U*0.5,0.5)}var h=null,j=new THREE.Projector,c=document.createElementNS("http://www.w3.org/2000/svg","svg"),i,l,u,C,o,x,A,B,M=new THREE.Rectangle,q=new THREE.Rectangle,G=false,d=new THREE.Color(16777215),k=new THREE.Color(16777215),p=new THREE.Color(0),s=new THREE.Color(0), +r=new THREE.Color(0),t,w=new THREE.Vector3,v=[],H=[],y=[],n,D,W,J,P=1;this.domElement=c;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(U){switch(U){case "high":P=1;break;case "low":P=0}};this.setSize=function(U,R){i=U;l=R;u=i/2;C=l/2;c.setAttribute("viewBox",-u+" "+-C+" "+i+" "+l);c.setAttribute("width",i);c.setAttribute("height",l);M.set(-u,-C,u,C)};this.clear=function(){for(;c.childNodes.length>0;)c.removeChild(c.childNodes[0])};this.render=function(U,R){var $,X, +L,O,Z,S,z,N;this.autoClear&&this.clear();h=j.projectScene(U,R,this.sortElements);J=W=D=0;if(G=U.lights.length>0){z=U.lights;p.setRGB(0,0,0);s.setRGB(0,0,0);r.setRGB(0,0,0);$=0;for(X=z.length;$0){c.bindBuffer(c.ARRAY_BUFFER,d.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,ea,p)}if(r){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,F,p);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,d.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER, +E,p)}};this.renderBuffer=function(d,k,p,s,r){var t,w,v,H;if(!s.program){if(s instanceof THREE.MeshDepthMaterial){b(s,THREE.ShaderLib.depth);s.uniforms.mNear.value=d.near;s.uniforms.mFar.value=d.far}else if(s instanceof THREE.MeshNormalMaterial)b(s,THREE.ShaderLib.normal);else if(s instanceof THREE.MeshBasicMaterial){b(s,THREE.ShaderLib.basic);e(s,p)}else if(s instanceof THREE.MeshLambertMaterial){b(s,THREE.ShaderLib.lambert);e(s,p)}else if(s instanceof THREE.MeshPhongMaterial){b(s,THREE.ShaderLib.phong); +e(s,p)}else if(s instanceof THREE.LineBasicMaterial){b(s,THREE.ShaderLib.basic);f(s,p)}var y,n,D;y=H=w=0;for(n=k.length;y0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+H.maxDirLights,"#define MAX_POINT_LIGHTS "+H.maxPointLights,H.map?"#define USE_MAP":"",H.env_map?"#define USE_ENVMAP":"", +"uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"].join("\n");c.attachShader(n,g("fragment",D+w));c.attachShader(n,g("vertex",H+y));c.linkProgram(n);c.getProgramParameter(n,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(n,c.VALIDATE_STATUS)+", gl error ["+ +c.getError()+"]");n.uniforms={};n.attributes={};s.program=n;w=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(t in s.uniforms)w.push(t);t=s.program;y=0;for(n=w.length;y=0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLNormalBuffer);c.vertexAttribPointer(v.normal,3,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.normal)}if(v.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLTangentBuffer);c.vertexAttribPointer(v.tangent,4,c.FLOAT, +false,0,0);c.enableVertexAttribArray(v.tangent)}if(v.uv>=0)if(r.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUVBuffer);c.vertexAttribPointer(v.uv,2,c.FLOAT,false,0,0);c.enableVertexAttribArray(v.uv)}else c.disableVertexAttribArray(v.uv);if(s.wireframe||s instanceof THREE.LineBasicMaterial){v=s.wireframe_linewidth!==undefined?s.wireframe_linewidth:s.linewidth!==undefined?s.linewidth:1;s=s instanceof THREE.LineBasicMaterial&&r.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(v);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, +r.__webGLLineBuffer);c.drawElements(s,r.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,r.__webGLFaceCount,c.UNSIGNED_SHORT,0)}};this.renderPass=function(d,k,p,s,r,t,w){var v,H,y,n,D;y=0;for(n=s.materials.length;y=0;p--){s=d.__webGLObjects[p].object;k==s&&d.__webGLObjects.splice(p,1)}};this.setupMatrices=function(d,k){d.autoUpdateMatrix&&d.updateMatrix();l.multiply(k.matrix,d.matrix);o.set(l.flatten());u=THREE.Matrix4.makeInvert3x3(l).transpose();A.set(u.m);B.set(d.matrix.flatten())};this.loadMatrices=function(d){c.uniformMatrix4fv(d.uniforms.viewMatrix,false,C);c.uniformMatrix4fv(d.uniforms.modelViewMatrix,false,o);c.uniformMatrix4fv(d.uniforms.projectionMatrix, +false,x);c.uniformMatrix3fv(d.uniforms.normalMatrix,false,A);c.uniformMatrix4fv(d.uniforms.objectMatrix,false,B)};this.loadCamera=function(d,k){c.uniform3f(d.uniforms.cameraPosition,k.position.x,k.position.y,k.position.z)};this.setBlending=function(d){switch(d){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling= +function(d,k){if(d){!k||k=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(d=="back")c.cullFace(c.BACK);else d=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}}; +THREE.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, 1.0 ), 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\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\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_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\nmapColor = texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\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 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"}; THREE.UniformsLib={common:{color:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:0,texture:null},env_map:{type:"t",value:1,texture:null},useRefract:{type:"i",value:0},reflectivity:{type:"f",value:1},refraction_ratio:{type:"f",value:0.98},combine:{type:"i",value:0},fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},lights:{enableLighting:{type:"i",value:1},ambientLightColor:{type:"fv", @@ -191,49 +195,49 @@ shininess:{type:"f",value:30}}]),fragment_shader:["uniform vec3 color;\nuniform "gl_FragColor = mapColor * totalLight * vec4( vLightWeighting, 1.0 );",THREE.Snippets.envmap_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.Snippets.map_pars_vertex,THREE.Snippets.envmap_pars_vertex,THREE.Snippets.lights_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.envmap_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;", THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=false;this.uvs=[null,null,null]}; THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.materials=null}; -var GeometryUtils={merge:function(a,b){var f=b instanceof THREE.Mesh,e=a.vertices.length,g=f?b.geometry:b,h=a.vertices,j=g.vertices,c=a.faces,i=g.faces,l=a.uvs;g=g.uvs;f&&b.updateMatrix();for(var r=0,B=j.length;r= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", vertex_shader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nvarying vec3 vPointLightVector;\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"}, basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"void main() {\ngl_FragColor = vec4(1.0, 0.0, 0.0, 0.5);\n}"},cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}", -fragment_shader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"}}},Cube=function(a,b,f,e,g,h,j,c){function i(A,K,p,E,d,k,q,s){var n,m,x=e||1,t=g||1,D=x+1,y=t+1,w=d/2,C=k/2;d=d/x;var $=k/t,M=l.vertices.length;if(A=="x"&&K=="y"||A=="y"&&K=="x")n="z";else if(A=="x"&&K=="z"||A=="z"&&K=="x")n="y";else if(A=="z"&&K=="y"||A=="y"&&K=="z")n="x";for(m=0;m0||(r=this.vertices.push(new THREE.Vertex(new THREE.Vector3(B,c,o)))-1);l.push(r)}b.push(l)}var v,z,A;g=b.length;for(f=0;f0)for(e=0;e1){v=this.vertices[j].position.clone(); -z=this.vertices[i].position.clone();A=this.vertices[l].position.clone();v.normalize();z.normalize();A.normalize();this.faces.push(new THREE.Face3(j,i,l,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([r,B,K])}}}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,e){THREE.Geometry.call(this);var f,g=Math.PI,h=Math.max(3,b||8),j=Math.max(2,e||6);b=[];for(e=0;e0||(u=this.vertices.push(new THREE.Vertex(new THREE.Vector3(C,c,o)))-1);l.push(u)}b.push(l)}var x,A,B;g=b.length;for(e=0;e0)for(f=0;f1){x=this.vertices[j].position.clone(); +A=this.vertices[i].position.clone();B=this.vertices[l].position.clone();x.normalize();A.normalize();B.normalize();this.faces.push(new THREE.Face3(j,i,l,[new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([u,C,M])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?this.addStatusElement():null}; THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="#b00";a.style.color="#fff";a.style.width="140px";a.style.padding="0.25em 0.25em 0.25em 0.5em";a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";this.statusDomElement.innerHTML= -b},loadAsciiOld:function(a,b){var f=document.createElement("script");f.type="text/javascript";f.onload=b;f.src=a;document.getElementsByTagName("head")[0].appendChild(f)},loadAscii:function(a){var b=a.model,f=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(g){THREE.Loader.prototype.createModel(g.data,f,e)};b.postMessage(a)},loadBinary:function(a){var b=a.model,f=a.callback,e=a.texture_path?a.texture_path: -THREE.Loader.prototype.extractUrlbase(b),g=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var h=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(j){THREE.Loader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,f,g,e,h)};b.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,f,e,g,h){var j=new XMLHttpRequest,c=e+"/"+a,i=0; -j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.Loader.prototype.createBinModel(j.responseText,f,g,b):alert("Couldn't load ["+c+"] ["+j.status+"]");else if(j.readyState==3){if(h){if(i==0)i=j.getResponseHeader("Content-Length");h({total:i,loaded:j.responseText.length})}}else if(j.readyState==2)i=j.getResponseHeader("Content-Length")};j.open("GET",c,true);j.overrideMimeType("text/plain; charset=x-user-defined");j.setRequestHeader("Content-Type","text/plain");j.send(null)}, -createBinModel:function(a,b,f,e){var g=function(h){function j(u,G){var H=r(u,G),Q=r(u,G+1),aa=r(u,G+2),ka=r(u,G+3),ea=(ka<<1&255|aa>>7)-127;H=(aa&127)<<16|Q<<8|H;if(H==0&&ea==-127)return 0;return(1-2*(ka>>7))*(1+H*Math.pow(2,-23))*Math.pow(2,ea)}function c(u,G){var H=r(u,G),Q=r(u,G+1),aa=r(u,G+2);return(r(u,G+3)<<24)+(aa<<16)+(Q<<8)+H}function i(u,G){var H=r(u,G);return(r(u,G+1)<<8)+H}function l(u,G){var H=r(u,G);return H>127?H-256:H}function r(u,G){return u.charCodeAt(G)&255}function B(u){var G, -H,Q;G=c(a,u);H=c(a,u+s);Q=c(a,u+n);u=i(a,u+m);THREE.Loader.prototype.f3(p,G,H,Q,u)}function o(u){var G,H,Q,aa,ka,ea;G=c(a,u);H=c(a,u+s);Q=c(a,u+n);aa=i(a,u+m);ka=c(a,u+x);ea=c(a,u+t);u=c(a,u+D);THREE.Loader.prototype.f3n(p,k,G,H,Q,aa,ka,ea,u)}function v(u){var G,H,Q,aa;G=c(a,u);H=c(a,u+y);Q=c(a,u+w);aa=c(a,u+C);u=i(a,u+$);THREE.Loader.prototype.f4(p,G,H,Q,aa,u)}function z(u){var G,H,Q,aa,ka,ea,ra,ta;G=c(a,u);H=c(a,u+y);Q=c(a,u+w);aa=c(a,u+C);ka=i(a,u+$);ea=c(a,u+M);ra=c(a,u+U);ta=c(a,u+V);u=c(a,u+ -O);THREE.Loader.prototype.f4n(p,k,G,H,Q,aa,ka,ea,ra,ta,u)}function A(u){var G,H;G=c(a,u);H=c(a,u+ba);u=c(a,u+R);THREE.Loader.prototype.uv3(p,q[G*2],q[G*2+1],q[H*2],q[H*2+1],q[u*2],q[u*2+1])}function K(u){var G,H,Q;G=c(a,u);H=c(a,u+L);Q=c(a,u+N);u=c(a,u+Z);THREE.Loader.prototype.uv4(p,q[G*2],q[G*2+1],q[H*2],q[H*2+1],q[Q*2],q[Q*2+1],q[u*2],q[u*2+1])}var p=this,E=0,d,k=[],q=[],s,n,m,x,t,D,y,w,C,$,M,U,V,O,ba,R,L,N,Z,W,I,S,Y,ha,ja;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(p,e,h); -d={signature:a.substr(E,8),header_bytes:r(a,E+8),vertex_coordinate_bytes:r(a,E+9),normal_coordinate_bytes:r(a,E+10),uv_coordinate_bytes:r(a,E+11),vertex_index_bytes:r(a,E+12),normal_index_bytes:r(a,E+13),uv_index_bytes:r(a,E+14),material_index_bytes:r(a,E+15),nvertices:c(a,E+16),nnormals:c(a,E+16+4),nuvs:c(a,E+16+8),ntri_flat:c(a,E+16+12),ntri_smooth:c(a,E+16+16),ntri_flat_uv:c(a,E+16+20),ntri_smooth_uv:c(a,E+16+24),nquad_flat:c(a,E+16+28),nquad_smooth:c(a,E+16+32),nquad_flat_uv:c(a,E+16+36),nquad_smooth_uv:c(a, -E+16+40)};E+=d.header_bytes;s=d.vertex_index_bytes;n=d.vertex_index_bytes*2;m=d.vertex_index_bytes*3;x=d.vertex_index_bytes*3+d.material_index_bytes;t=d.vertex_index_bytes*3+d.material_index_bytes+d.normal_index_bytes;D=d.vertex_index_bytes*3+d.material_index_bytes+d.normal_index_bytes*2;y=d.vertex_index_bytes;w=d.vertex_index_bytes*2;C=d.vertex_index_bytes*3;$=d.vertex_index_bytes*4;M=d.vertex_index_bytes*4+d.material_index_bytes;U=d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes; -V=d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes*2;O=d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes*3;ba=d.uv_index_bytes;R=d.uv_index_bytes*2;L=d.uv_index_bytes;N=d.uv_index_bytes*2;Z=d.uv_index_bytes*3;h=d.vertex_index_bytes*3+d.material_index_bytes;ja=d.vertex_index_bytes*4+d.material_index_bytes;W=d.ntri_flat*h;I=d.ntri_smooth*(h+d.normal_index_bytes*3);S=d.ntri_flat_uv*(h+d.uv_index_bytes*3);Y=d.ntri_smooth_uv*(h+d.normal_index_bytes*3+d.uv_index_bytes* -3);ha=d.nquad_flat*ja;h=d.nquad_smooth*(ja+d.normal_index_bytes*4);ja=d.nquad_flat_uv*(ja+d.uv_index_bytes*4);E+=function(u){var G,H,Q,aa=d.vertex_coordinate_bytes*3,ka=u+d.nvertices*aa;for(u=u;u>7)-127;E=(aa&127)<<16|T<<8|E;if(E==0&&ga==-127)return 0;return(1-2*(ka>>7))*(1+E*Math.pow(2,-23))*Math.pow(2,ga)}function c(m,F){var E=u(m,F),T=u(m,F+1),aa=u(m,F+2);return(u(m,F+3)<<24)+(aa<<16)+(T<<8)+E}function i(m,F){var E=u(m,F);return(u(m,F+1)<<8)+E}function l(m,F){var E=u(m,F);return E>127?E-256:E}function u(m,F){return m.charCodeAt(F)&255}function C(m){var F, +E,T;F=c(a,m);E=c(a,m+s);T=c(a,m+r);m=i(a,m+t);THREE.Loader.prototype.f3(q,F,E,T,m)}function o(m){var F,E,T,aa,ka,ga;F=c(a,m);E=c(a,m+s);T=c(a,m+r);aa=i(a,m+t);ka=c(a,m+w);ga=c(a,m+v);m=c(a,m+H);THREE.Loader.prototype.f3n(q,k,F,E,T,aa,ka,ga,m)}function x(m){var F,E,T,aa;F=c(a,m);E=c(a,m+y);T=c(a,m+n);aa=c(a,m+D);m=i(a,m+W);THREE.Loader.prototype.f4(q,F,E,T,aa,m)}function A(m){var F,E,T,aa,ka,ga,ra,ta;F=c(a,m);E=c(a,m+y);T=c(a,m+n);aa=c(a,m+D);ka=i(a,m+W);ga=c(a,m+J);ra=c(a,m+P);ta=c(a,m+U);m=c(a,m+ +R);THREE.Loader.prototype.f4n(q,k,F,E,T,aa,ka,ga,ra,ta,m)}function B(m){var F,E;F=c(a,m);E=c(a,m+$);m=c(a,m+X);THREE.Loader.prototype.uv3(q,p[F*2],p[F*2+1],p[E*2],p[E*2+1],p[m*2],p[m*2+1])}function M(m){var F,E,T;F=c(a,m);E=c(a,m+L);T=c(a,m+O);m=c(a,m+Z);THREE.Loader.prototype.uv4(q,p[F*2],p[F*2+1],p[E*2],p[E*2+1],p[T*2],p[T*2+1],p[m*2],p[m*2+1])}var q=this,G=0,d,k=[],p=[],s,r,t,w,v,H,y,n,D,W,J,P,U,R,$,X,L,O,Z,S,z,N,Q,ea,da;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(q,f,h);d= +{signature:a.substr(G,8),header_bytes:u(a,G+8),vertex_coordinate_bytes:u(a,G+9),normal_coordinate_bytes:u(a,G+10),uv_coordinate_bytes:u(a,G+11),vertex_index_bytes:u(a,G+12),normal_index_bytes:u(a,G+13),uv_index_bytes:u(a,G+14),material_index_bytes:u(a,G+15),nvertices:c(a,G+16),nnormals:c(a,G+16+4),nuvs:c(a,G+16+8),ntri_flat:c(a,G+16+12),ntri_smooth:c(a,G+16+16),ntri_flat_uv:c(a,G+16+20),ntri_smooth_uv:c(a,G+16+24),nquad_flat:c(a,G+16+28),nquad_smooth:c(a,G+16+32),nquad_flat_uv:c(a,G+16+36),nquad_smooth_uv:c(a, +G+16+40)};G+=d.header_bytes;s=d.vertex_index_bytes;r=d.vertex_index_bytes*2;t=d.vertex_index_bytes*3;w=d.vertex_index_bytes*3+d.material_index_bytes;v=d.vertex_index_bytes*3+d.material_index_bytes+d.normal_index_bytes;H=d.vertex_index_bytes*3+d.material_index_bytes+d.normal_index_bytes*2;y=d.vertex_index_bytes;n=d.vertex_index_bytes*2;D=d.vertex_index_bytes*3;W=d.vertex_index_bytes*4;J=d.vertex_index_bytes*4+d.material_index_bytes;P=d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes; +U=d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes*2;R=d.vertex_index_bytes*4+d.material_index_bytes+d.normal_index_bytes*3;$=d.uv_index_bytes;X=d.uv_index_bytes*2;L=d.uv_index_bytes;O=d.uv_index_bytes*2;Z=d.uv_index_bytes*3;h=d.vertex_index_bytes*3+d.material_index_bytes;da=d.vertex_index_bytes*4+d.material_index_bytes;S=d.ntri_flat*h;z=d.ntri_smooth*(h+d.normal_index_bytes*3);N=d.ntri_flat_uv*(h+d.uv_index_bytes*3);Q=d.ntri_smooth_uv*(h+d.normal_index_bytes*3+d.uv_index_bytes* +3);ea=d.nquad_flat*da;h=d.nquad_smooth*(da+d.normal_index_bytes*4);da=d.nquad_flat_uv*(da+d.uv_index_bytes*4);G+=function(m){var F,E,T,aa=d.vertex_coordinate_bytes*3,ka=m+d.nvertices*aa;for(m=m;m + + + three.js - geometry - dynamic - webgl + + + + + +





Generating world...
+
three.js - dynamic geometry demo - webgl
(left click: forward, right click: backward)
+ +
+
+ Sorry, your browser doesn't support WebGL.
+
+ Please try in + Chrome 9+ / + Firefox 4+ / + Safari OSX 10.6+ +
+
+ + + + + + + + diff --git a/examples/textures/water.jpg b/examples/textures/water.jpg new file mode 100644 index 00000000..1a38c936 Binary files /dev/null and b/examples/textures/water.jpg differ diff --git a/src/core/Geometry.js b/src/core/Geometry.js index a0d08e6f..95b1daa2 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -113,14 +113,50 @@ THREE.Geometry.prototype = { computeVertexNormals: function () { - var v, vl, vertices = [], - f, fl, face; + var v, vl, f, fl, face, vertices; - for ( v = 0, vl = this.vertices.length; v < vl; v ++ ) { + // create internal buffers for reuse when calling this method repeatedly + // (otherwise memory allocation / deallocation every frame is big resource hog) + + if ( this.__tmpVertices == undefined ) { + + this.__tmpVertices = new Array( this.vertices.length ); + vertices = this.__tmpVertices; + + for ( v = 0, vl = this.vertices.length; v < vl; v ++ ) { - vertices[ v ] = new THREE.Vector3(); + vertices[ v ] = new THREE.Vector3(); + } + + for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { + + face = this.faces[ f ]; + + if ( face instanceof THREE.Face3 ) { + + face.vertexNormals = [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ]; + + } else if ( face instanceof THREE.Face4 ) { + + face.vertexNormals = [ new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3(), new THREE.Vector3() ]; + + } + + } + + } else { + + vertices = this.__tmpVertices; + + for ( v = 0, vl = this.vertices.length; v < vl; v ++ ) { + + vertices[ v ].set( 0, 0, 0 ); + + } + } + for ( f = 0, fl = this.faces.length; f < fl; f ++ ) { @@ -155,16 +191,16 @@ THREE.Geometry.prototype = { if ( face instanceof THREE.Face3 ) { - face.vertexNormals[ 0 ] = vertices[ face.a ].clone(); - face.vertexNormals[ 1 ] = vertices[ face.b ].clone(); - face.vertexNormals[ 2 ] = vertices[ face.c ].clone(); + face.vertexNormals[ 0 ].copy( vertices[ face.a ] ); + face.vertexNormals[ 1 ].copy( vertices[ face.b ] ); + face.vertexNormals[ 2 ].copy( vertices[ face.c ] ); } else if ( face instanceof THREE.Face4 ) { - face.vertexNormals[ 0 ] = vertices[ face.a ].clone(); - face.vertexNormals[ 1 ] = vertices[ face.b ].clone(); - face.vertexNormals[ 2 ] = vertices[ face.c ].clone(); - face.vertexNormals[ 3 ] = vertices[ face.d ].clone(); + face.vertexNormals[ 0 ].copy( vertices[ face.a ] ); + face.vertexNormals[ 1 ].copy( vertices[ face.b ] ); + face.vertexNormals[ 2 ].copy( vertices[ face.c ] ); + face.vertexNormals[ 3 ].copy( vertices[ face.d ] ); } diff --git a/src/renderers/WebGLRenderer.js b/src/renderers/WebGLRenderer.js index 7d41cea3..4aa13ada 100644 --- a/src/renderers/WebGLRenderer.js +++ b/src/renderers/WebGLRenderer.js @@ -74,6 +74,7 @@ THREE.WebGLRenderer = function ( parameters ) { this.setupLights = function ( program, lights ) { var l, ll, light, r = 0, g = 0, b = 0, + color, position, intensity, dcolors = [], dpositions = [], pcolors = [], ppositions = []; @@ -81,32 +82,35 @@ THREE.WebGLRenderer = function ( parameters ) { for ( l = 0, ll = lights.length; l < ll; l++ ) { light = lights[ l ]; + color = light.color; + position = light.position; + intensity = light.intensity; if ( light instanceof THREE.AmbientLight ) { - r += light.color.r; - g += light.color.g; - b += light.color.b; + r += color.r; + g += color.g; + b += color.b; } else if ( light instanceof THREE.DirectionalLight ) { - dcolors.push( light.color.r * light.intensity, - light.color.g * light.intensity, - light.color.b * light.intensity ); + dcolors.push( color.r * intensity, + color.g * intensity, + color.b * intensity ); - dpositions.push( light.position.x, - light.position.y, - light.position.z ); + dpositions.push( position.x, + position.y, + position.z ); } else if( light instanceof THREE.PointLight ) { - pcolors.push( light.color.r * light.intensity, - light.color.g * light.intensity, - light.color.b * light.intensity ); + pcolors.push( color.r * intensity, + color.g * intensity, + color.b * intensity ); - ppositions.push( light.position.x, - light.position.y, - light.position.z ); + ppositions.push( position.x, + position.y, + position.z ); } @@ -152,205 +156,399 @@ THREE.WebGLRenderer = function ( parameters ) { }; - this.createBuffers = function ( object, g ) { + this.createBuffers = function ( geometryChunk ) { + + geometryChunk.__webGLVertexBuffer = _gl.createBuffer(); + geometryChunk.__webGLNormalBuffer = _gl.createBuffer(); + geometryChunk.__webGLTangentBuffer = _gl.createBuffer(); + geometryChunk.__webGLUVBuffer = _gl.createBuffer(); + geometryChunk.__webGLFaceBuffer = _gl.createBuffer(); + geometryChunk.__webGLLineBuffer = _gl.createBuffer(); + + }; + + this.initBuffers = function( geometryChunk, object ) { + + var f, fl, nvertices = 0, ntris = 0, nlines = 0, + obj_faces = object.geometry.faces, + chunk_faces = geometryChunk.faces; + + for ( f = 0, fl = chunk_faces.length; f < fl; f++ ) { + + fi = chunk_faces[ f ]; + face = obj_faces[ fi ]; + + if ( face instanceof THREE.Face3 ) { + + nvertices += 3; + ntris += 1; + nlines += 3; + + } else if ( face instanceof THREE.Face4 ) { + + nvertices += 4; + ntris += 2; + nlines += 5; + + } + + } + + // TODO: only create arrays for attributes existing in the object + + geometryChunk.__vertexArray = new Float32Array( nvertices * 3 ); + geometryChunk.__normalArray = new Float32Array( nvertices * 3 ); + geometryChunk.__tangentArray = new Float32Array( nvertices * 4 ); + geometryChunk.__uvArray = new Float32Array( nvertices * 2 ); + + geometryChunk.__faceArray = new Uint16Array( ntris * 3 ); + geometryChunk.__lineArray = new Uint16Array( nlines * 2 ); + + geometryChunk.__needsSmoothNormals = bufferNeedsSmoothNormals ( geometryChunk, object ); + + geometryChunk.__webGLFaceCount = ntris * 3; + geometryChunk.__webGLLineCount = nlines * 2; + + }; + + this.setBuffers = function ( geometryChunk, object, hint, dirtyVertices, dirtyElements, dirtyUvs, dirtyNormals, dirtyTangents ) { var f, fl, fi, face, vertexNormals, faceNormal, normal, uv, v1, v2, v3, v4, t1, t2, t3, t4, m, ml, i, - - faceArray = [], - lineArray = [], - - vertexArray = [], - normalArray = [], - tangentArray = [], - uvArray = [], - + vertices, vn, uvi, + vertexIndex = 0, - geometryChunk = object.geometry.geometryChunks[ g ], - - needsSmoothNormals = bufferNeedsSmoothNormals ( geometryChunk, object ); - + offset = 0, + offset_uv = 0, + offset_face = 0, + offset_normal = 0, + offset_tangent = 0, + offset_line = 0, + + vertexArray = geometryChunk.__vertexArray, + uvArray = geometryChunk.__uvArray, + normalArray = geometryChunk.__normalArray, + tangentArray = geometryChunk.__tangentArray, + + faceArray = geometryChunk.__faceArray, + lineArray = geometryChunk.__lineArray, + + needsSmoothNormals = geometryChunk.__needsSmoothNormals, + + geometry = object.geometry; + for ( f = 0, fl = geometryChunk.faces.length; f < fl; f++ ) { - + fi = geometryChunk.faces[ f ]; - face = object.geometry.faces[ fi ]; + face = geometry.faces[ fi ]; vertexNormals = face.vertexNormals; faceNormal = face.normal; - uv = object.geometry.uvs[ fi ]; + uv = geometry.uvs[ fi ]; + vertices = geometry.vertices; if ( face instanceof THREE.Face3 ) { - v1 = object.geometry.vertices[ face.a ].position; - v2 = object.geometry.vertices[ face.b ].position; - v3 = object.geometry.vertices[ face.c ].position; - - vertexArray.push( v1.x, v1.y, v1.z, - v2.x, v2.y, v2.z, - v3.x, v3.y, v3.z ); - - if ( object.geometry.hasTangents ) { - - t1 = object.geometry.vertices[ face.a ].tangent; - t2 = object.geometry.vertices[ face.b ].tangent; - t3 = object.geometry.vertices[ face.c ].tangent; - - tangentArray.push( t1.x, t1.y, t1.z, t1.w, - t2.x, t2.y, t2.z, t2.w, - t3.x, t3.y, t3.z, t3.w ); + if ( dirtyVertices ) { + + v1 = vertices[ face.a ].position; + v2 = vertices[ face.b ].position; + v3 = vertices[ face.c ].position; + + vertexArray[ offset ] = v1.x; + vertexArray[ offset + 1 ] = v1.y; + vertexArray[ offset + 2 ] = v1.z; + + vertexArray[ offset + 3 ] = v2.x; + vertexArray[ offset + 4 ] = v2.y; + vertexArray[ offset + 5 ] = v2.z; + vertexArray[ offset + 6 ] = v3.x; + vertexArray[ offset + 7 ] = v3.y; + vertexArray[ offset + 8 ] = v3.z; + + offset += 9; + } - if ( vertexNormals.length == 3 && needsSmoothNormals ) { + if ( dirtyTangents && geometry.hasTangents ) { + + t1 = vertices[ face.a ].tangent; + t2 = vertices[ face.b ].tangent; + t3 = vertices[ face.c ].tangent; + + tangentArray[ offset_tangent ] = t1.x; + tangentArray[ offset_tangent + 1 ] = t1.y; + tangentArray[ offset_tangent + 2 ] = t1.z; + tangentArray[ offset_tangent + 3 ] = t1.w; + + tangentArray[ offset_tangent + 4 ] = t2.x; + tangentArray[ offset_tangent + 5 ] = t2.y; + tangentArray[ offset_tangent + 6 ] = t2.z; + tangentArray[ offset_tangent + 7 ] = t2.w; + + tangentArray[ offset_tangent + 8 ] = t3.x; + tangentArray[ offset_tangent + 9 ] = t3.y; + tangentArray[ offset_tangent + 10 ] = t3.z; + tangentArray[ offset_tangent + 11 ] = t3.w; + + offset_tangent += 12; + + } + + if( dirtyNormals ) { + + if ( vertexNormals.length == 3 && needsSmoothNormals ) { - for ( i = 0; i < 3; i ++ ) { + for ( i = 0; i < 3; i ++ ) { - normalArray.push( vertexNormals[ i ].x, vertexNormals[ i ].y, vertexNormals[ i ].z ); + vn = vertexNormals[ i ]; + + normalArray[ offset_normal ] = vn.x; + normalArray[ offset_normal + 1 ] = vn.y; + normalArray[ offset_normal + 2 ] = vn.z; + + offset_normal += 3; + + } + + } else { + + for ( i = 0; i < 3; i ++ ) { + + normalArray[ offset_normal ] = faceNormal.x; + normalArray[ offset_normal + 1 ] = faceNormal.y; + normalArray[ offset_normal + 2 ] = faceNormal.z; + + offset_normal += 3; + + } } + + } - } else { + if ( dirtyUvs && uv ) { for ( i = 0; i < 3; i ++ ) { - normalArray.push( faceNormal.x, faceNormal.y, faceNormal.z ); + uvi = uv[ i ]; + + uvArray[ offset_uv ] = uvi.u; + uvArray[ offset_uv + 1 ] = uvi.v; + + offset_uv += 2; } } - if ( uv ) { - - for ( i = 0; i < 3; i ++ ) { - - uvArray.push( uv[ i ].u, uv[ i ].v ); - - } + if( dirtyElements ) { + + faceArray[ offset_face ] = vertexIndex; + faceArray[ offset_face + 1 ] = vertexIndex + 1; + faceArray[ offset_face + 2 ] = vertexIndex + 2; + + offset_face += 3; + + lineArray[ offset_line ] = vertexIndex; + lineArray[ offset_line + 1 ] = vertexIndex + 1; + + lineArray[ offset_line + 2 ] = vertexIndex; + lineArray[ offset_line + 3 ] = vertexIndex + 2; + + lineArray[ offset_line + 4 ] = vertexIndex + 1; + lineArray[ offset_line + 5 ] = vertexIndex + 2; + + offset_line += 6; + vertexIndex += 3; + } - - faceArray.push( vertexIndex, vertexIndex + 1, vertexIndex + 2 ); - - // TODO: don't add lines that already exist (faces sharing edge) - - lineArray.push( vertexIndex, vertexIndex + 1, - vertexIndex, vertexIndex + 2, - vertexIndex + 1, vertexIndex + 2 ); - - vertexIndex += 3; + } else if ( face instanceof THREE.Face4 ) { - v1 = object.geometry.vertices[ face.a ].position; - v2 = object.geometry.vertices[ face.b ].position; - v3 = object.geometry.vertices[ face.c ].position; - v4 = object.geometry.vertices[ face.d ].position; + if ( dirtyVertices ) { + + v1 = vertices[ face.a ].position; + v2 = vertices[ face.b ].position; + v3 = vertices[ face.c ].position; + v4 = vertices[ face.d ].position; + + vertexArray[ offset ] = v1.x; + vertexArray[ offset + 1 ] = v1.y; + vertexArray[ offset + 2 ] = v1.z; + + vertexArray[ offset + 3 ] = v2.x; + vertexArray[ offset + 4 ] = v2.y; + vertexArray[ offset + 5 ] = v2.z; - vertexArray.push( v1.x, v1.y, v1.z, - v2.x, v2.y, v2.z, - v3.x, v3.y, v3.z, - v4.x, v4.y, v4.z ); - - if ( object.geometry.hasTangents ) { - - t1 = object.geometry.vertices[ face.a ].tangent; - t2 = object.geometry.vertices[ face.b ].tangent; - t3 = object.geometry.vertices[ face.c ].tangent; - t4 = object.geometry.vertices[ face.d ].tangent; - - tangentArray.push( t1.x, t1.y, t1.z, t1.w, - t2.x, t2.y, t2.z, t2.w, - t3.x, t3.y, t3.z, t3.w, - t4.x, t4.y, t4.z, t4.w ); + vertexArray[ offset + 6 ] = v3.x; + vertexArray[ offset + 7 ] = v3.y; + vertexArray[ offset + 8 ] = v3.z; + vertexArray[ offset + 9 ] = v4.x; + vertexArray[ offset + 10 ] = v4.y; + vertexArray[ offset + 11 ] = v4.z; + + offset += 12; + } - if ( vertexNormals.length == 4 && needsSmoothNormals ) { + if ( dirtyTangents && geometry.hasTangents ) { - for ( i = 0; i < 4; i ++ ) { + t1 = vertices[ face.a ].tangent; + t2 = vertices[ face.b ].tangent; + t3 = vertices[ face.c ].tangent; + t4 = vertices[ face.d ].tangent; - normalArray.push( vertexNormals[ i ].x, vertexNormals[ i ].y, vertexNormals[ i ].z ); + tangentArray[ offset_tangent ] = t1.x; + tangentArray[ offset_tangent + 1 ] = t1.y; + tangentArray[ offset_tangent + 2 ] = t1.z; + tangentArray[ offset_tangent + 3 ] = t1.w; + + tangentArray[ offset_tangent + 4 ] = t2.x; + tangentArray[ offset_tangent + 5 ] = t2.y; + tangentArray[ offset_tangent + 6 ] = t2.z; + tangentArray[ offset_tangent + 7 ] = t2.w; + + tangentArray[ offset_tangent + 8 ] = t3.x; + tangentArray[ offset_tangent + 9 ] = t3.y; + tangentArray[ offset_tangent + 10 ] = t3.z; + tangentArray[ offset_tangent + 11 ] = t3.w; + + tangentArray[ offset_tangent + 12 ] = t4.x; + tangentArray[ offset_tangent + 13 ] = t4.y; + tangentArray[ offset_tangent + 14 ] = t4.z; + tangentArray[ offset_tangent + 15 ] = t4.w; + + offset_tangent += 16; + + } + + if( dirtyNormals ) { + + if ( vertexNormals.length == 4 && needsSmoothNormals ) { + + for ( i = 0; i < 4; i ++ ) { + + vn = vertexNormals[ i ]; + + normalArray[ offset_normal ] = vn.x; + normalArray[ offset_normal + 1 ] = vn.y; + normalArray[ offset_normal + 2 ] = vn.z; + + offset_normal += 3; + + } + + } else { + + for ( i = 0; i < 4; i ++ ) { + + normalArray[ offset_normal ] = faceNormal.x; + normalArray[ offset_normal + 1 ] = faceNormal.y; + normalArray[ offset_normal + 2 ] = faceNormal.z; + + offset_normal += 3; + + } } + + } - } else { + if ( dirtyUvs && uv ) { for ( i = 0; i < 4; i ++ ) { - normalArray.push( faceNormal.x, faceNormal.y, faceNormal.z ); + uvi = uv[ i ]; + + uvArray[ offset_uv ] = uvi.u; + uvArray[ offset_uv + 1 ] = uvi.v; + + offset_uv += 2; } } - - if ( uv ) { - - for ( i = 0; i < 4; i ++ ) { - - uvArray.push( uv[ i ].u, uv[ i ].v ); - - } - + + if( dirtyElements ) { + + faceArray[ offset_face ] = vertexIndex; + faceArray[ offset_face + 1 ] = vertexIndex + 1; + faceArray[ offset_face + 2 ] = vertexIndex + 2; + + faceArray[ offset_face + 3 ] = vertexIndex; + faceArray[ offset_face + 4 ] = vertexIndex + 2; + faceArray[ offset_face + 5 ] = vertexIndex + 3; + + offset_face += 6; + + lineArray[ offset_line ] = vertexIndex; + lineArray[ offset_line + 1 ] = vertexIndex + 1; + + lineArray[ offset_line + 2 ] = vertexIndex; + lineArray[ offset_line + 3 ] = vertexIndex + 2; + + lineArray[ offset_line + 4 ] = vertexIndex; + lineArray[ offset_line + 5 ] = vertexIndex + 3; + + lineArray[ offset_line + 6 ] = vertexIndex + 1; + lineArray[ offset_line + 7 ] = vertexIndex + 2; + + lineArray[ offset_line + 8 ] = vertexIndex + 2; + lineArray[ offset_line + 9 ] = vertexIndex + 3; + + offset_line += 10; + + vertexIndex += 4; + } - faceArray.push( vertexIndex, vertexIndex + 1, vertexIndex + 2, - vertexIndex, vertexIndex + 2, vertexIndex + 3 ); - - // TODO: don't add lines that already exist (faces sharing edge) - - lineArray.push( vertexIndex, vertexIndex + 1, - vertexIndex, vertexIndex + 2, - vertexIndex, vertexIndex + 3, - vertexIndex + 1, vertexIndex + 2, - vertexIndex + 2, vertexIndex + 3 ); - - vertexIndex += 4; - } } - if ( !vertexArray.length ) { - - return; - + if ( dirtyVertices ) { + + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLVertexBuffer ); + _gl.bufferData( _gl.ARRAY_BUFFER, vertexArray, hint ); + + } + + if ( dirtyNormals ) { + + _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer ); + _gl.bufferData( _gl.ARRAY_BUFFER, normalArray, hint ); + } - geometryChunk.__webGLVertexBuffer = _gl.createBuffer(); - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLVertexBuffer ); - _gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( vertexArray ), _gl.STATIC_DRAW ); + if ( dirtyTangents && geometry.hasTangents ) { - geometryChunk.__webGLNormalBuffer = _gl.createBuffer(); - _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer ); - _gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( normalArray ), _gl.STATIC_DRAW ); - - if ( object.geometry.hasTangents ) { - - geometryChunk.__webGLTangentBuffer = _gl.createBuffer(); _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLTangentBuffer ); - _gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( tangentArray ), _gl.STATIC_DRAW ); - + _gl.bufferData( _gl.ARRAY_BUFFER, tangentArray, hint ); + } - if ( uvArray.length > 0 ) { + if ( dirtyUvs && offset_uv > 0 ) { - geometryChunk.__webGLUVBuffer = _gl.createBuffer(); _gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLUVBuffer ); - _gl.bufferData( _gl.ARRAY_BUFFER, new Float32Array( uvArray ), _gl.STATIC_DRAW ); + _gl.bufferData( _gl.ARRAY_BUFFER, uvArray, hint ); } - geometryChunk.__webGLFaceBuffer = _gl.createBuffer(); - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLFaceBuffer ); - _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( faceArray ), _gl.STATIC_DRAW ); + if( dirtyElements ) { + + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLFaceBuffer ); + _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, faceArray, hint ); - geometryChunk.__webGLLineBuffer = _gl.createBuffer(); - _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLLineBuffer ); - _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, new Uint16Array( lineArray ), _gl.STATIC_DRAW ); - - geometryChunk.__webGLFaceCount = faceArray.length; - geometryChunk.__webGLLineCount = lineArray.length; + _gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLLineBuffer ); + _gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, lineArray, hint ); + + } }; @@ -741,7 +939,7 @@ THREE.WebGLRenderer = function ( parameters ) { }; - var o, ol, object, g, geometryChunk, objmap; + var o, ol, object, g, geometry, geometryChunk, objmap; if ( !scene.__webGLObjects ) { @@ -753,7 +951,8 @@ THREE.WebGLRenderer = function ( parameters ) { for ( o = 0, ol = scene.objects.length; o < ol; o++ ) { object = scene.objects[ o ]; - + geometry = object.geometry; + if ( scene.__webGLObjectsMap[ object.id ] == undefined ) { scene.__webGLObjectsMap[ object.id ] = {}; @@ -766,15 +965,31 @@ THREE.WebGLRenderer = function ( parameters ) { // create separate VBOs per geometry chunk - for ( g in object.geometry.geometryChunks ) { + for ( g in geometry.geometryChunks ) { - geometryChunk = object.geometry.geometryChunks[ g ]; + geometryChunk = geometry.geometryChunks[ g ]; // initialise VBO on the first access if( ! geometryChunk.__webGLVertexBuffer ) { - this.createBuffers( object, g ); + this.createBuffers( geometryChunk ); + this.initBuffers( geometryChunk, object ); + + geometry.__dirtyVertices = true; + geometry.__dirtyElements = true; + geometry.__dirtyUvs = true; + geometry.__dirtyNormals = true; + geometry.__dirtyTangents = true; + + } + + if( geometry.__dirtyVertices || geometry.__dirtyElements || geometry.__dirtyUvs ) { + + this.setBuffers( geometryChunk, object, _gl.DYNAMIC_DRAW, + geometry.__dirtyVertices, geometry.__dirtyElements, geometry.__dirtyUvs, + geometry.__dirtyNormals, geometry.__dirtyTangents ); + } @@ -784,6 +999,12 @@ THREE.WebGLRenderer = function ( parameters ) { } + geometry.__dirtyVertices = false; + geometry.__dirtyElements = false; + geometry.__dirtyUvs = false; + geometry.__dirtyNormals = false; + geometry.__dirtyTangents = false; + } else if ( object instanceof THREE.Line ) { @@ -1040,15 +1261,17 @@ THREE.WebGLRenderer = function ( parameters ) { function setUniforms( program, uniforms ) { - var u, value, type, location, texture; + var u, uniform, value, type, location, texture; for( u in uniforms ) { location = program.uniforms[u]; if ( !location ) continue; - type = uniforms[u].type; - value = uniforms[u].value; + uniform = uniforms[u]; + + type = uniform.type; + value = uniform.value; if( type == "i" ) { @@ -1078,7 +1301,7 @@ THREE.WebGLRenderer = function ( parameters ) { _gl.uniform1i( location, value ); - texture = uniforms[u].texture; + texture = uniform.texture; if ( !texture ) continue;