From f2af3864cc8fcb7161ec94142ce33d36d15d4aad Mon Sep 17 00:00:00 2001 From: "Mr.doob" Date: Sat, 5 Mar 2011 13:56:22 +0000 Subject: [PATCH] Matrix4 public and static methods clean up. --- build/Three.js | 551 ++++++++++++++++++------------------ build/custom/ThreeCanvas.js | 123 ++++---- build/custom/ThreeDOM.js | 83 +++--- build/custom/ThreeSVG.js | 107 ++++--- build/custom/ThreeWebGL.js | 285 +++++++++---------- examples/webgl_ribbons.html | 4 +- src/core/Matrix4.js | 295 +++++-------------- src/core/Object3D.js | 40 ++- src/core/Vector3.js | 12 +- 9 files changed, 674 insertions(+), 826 deletions(-) diff --git a/build/Three.js b/build/Three.js index 11fe7018..f3901521 100755 --- a/build/Three.js +++ b/build/Three.js @@ -1,97 +1,94 @@ // Three.js r34 - http://github.com/mrdoob/three.js var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)}; -THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,g,h,j,k;if(c==0)d=e=g=0;else{h=Math.floor(a*6);j=a*6-h;a=c*(1-b);k=c*(1-b*j);b=c*(1-b*(1-j));switch(h){case 1:d=k;e=c;g=a;break;case 2:d=a;e=c;g=b;break;case 3:d=a;e=k;g=c;break;case 4:d=b;e=a;g=c;break;case 5:d=c;e=a;g=k;break;case 6:case 0:d=c;e=b;g=a}}this.r=d;this.g=e;this.b=g;if(this.autoUpdate){this.updateHex(); +THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,c,b){var d,e,g,h,j,k;if(b==0)d=e=g=0;else{h=Math.floor(a*6);j=a*6-h;a=b*(1-c);k=b*(1-c*j);c=b*(1-c*(1-j));switch(h){case 1:d=k;e=b;g=a;break;case 2:d=a;e=b;g=c;break;case 3:d=a;e=k;g=b;break;case 4:d=c;e=a;g=b;break;case 5:d=b;e=a;g=k;break;case 6:case 0:d=b;e=c;g=a}}this.r=d;this.g=e;this.b=g;if(this.autoUpdate){this.updateHex(); this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB: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)}}; -THREE.Vector2=function(a,b){this.set(a||0,b||0)}; -THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/ -this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,c){this.set(a||0,b||0,c||0)}; -THREE.Vector3.prototype={set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a, -b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,c=this.y,d=this.z;this.set(c*a.z-d*a.y,d*a.x-b*a.z,b*a.y-c*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/ -a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a= -this.length();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)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)}; -THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* -a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a0&&F>0&&J+F<1}var c,d,e,g,h,j,k,m,p,y, -t,q=a.geometry,z=q.vertices,C=[];c=0;for(d=q.faces.length;ck?d:k;e=e>m?e:m}a()}; -this.add3Points=function(k,m,p,y,t,q){if(j){j=!1;b=kp?k>t?k:t:p>t?p:t;e=m>y?m>q?m:q:y>q?y:q}else{b=kp?k>t?k>d?k:d:t>d?t:d:p>t?p>d?p:d:t>d?t:d;e=m>y?m>q?m>e?m:e:q>e?q:e:y>q?y>e?y:e:q>e?q:e}a()};this.addRectangle=function(k){if(j){j=!1;b=k.getLeft();c=k.getTop();d=k.getRight();e=k.getBottom()}else{b=bk.getRight()? -d:k.getRight();e=e>k.getBottom()?e:k.getBottom()}a()};this.inflate=function(k){b-=k;c-=k;d+=k;e+=k;a()};this.minSelf=function(k){b=b>k.getLeft()?b:k.getLeft();c=c>k.getTop()?c:k.getTop();d=d=0&&Math.min(e,k.getBottom())-Math.max(c,k.getTop())>=0};this.empty=function(){j=!0;e=d=c=b=0;a()};this.isEmpty=function(){return j}}; -THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}}; -THREE.Matrix4=function(a,b,c,d,e,g,h,j,k,m,p,y,t,q,z,C){this.set(a||1,b||0,c||0,d||0,e||0,g||1,h||0,j||0,k||0,m||0,p||1,y||0,t||0,q||0,z||0,C||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,b,c,d,e,g,h,j,k,m,p,y,t,q,z,C){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=j;this.n31=k;this.n32=m;this.n33=p;this.n34=y;this.n41=t;this.n42=q;this.n43=z;this.n44=C;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1, -e=THREE.Matrix4.__tmpVec2,g=THREE.Matrix4.__tmpVec3;g.sub(a,b).normalize();d.cross(c,g).normalize();e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n14=a.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n24=a.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31* -b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},crossVector:function(a){var b=new THREE.Vector4; -b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,m=a.n24,p=a.n31,y=a.n32,t=a.n33,q=a.n34,z=a.n41,C=a.n42,F=a.n43,v=a.n44,G=b.n11,w=b.n12,K=b.n13,J=b.n14,f=b.n21,N=b.n22,O=b.n23,U=b.n24,Q=b.n31,Z=b.n32,ca=b.n33,L=b.n34;this.n11= -c*G+d*f+e*Q;this.n12=c*w+d*N+e*Z;this.n13=c*K+d*O+e*ca;this.n14=c*J+d*U+e*L+g;this.n21=h*G+j*f+k*Q;this.n22=h*w+j*N+k*Z;this.n23=h*K+j*O+k*ca;this.n24=h*J+j*U+k*L+m;this.n31=p*G+y*f+t*Q;this.n32=p*w+y*N+t*Z;this.n33=p*K+y*O+t*ca;this.n34=p*J+y*U+t*L+q;this.n41=z*G+C*f+F*Q;this.n42=z*w+C*N+F*Z;this.n43=z*K+C*O+F*ca;this.n44=z*J+C*U+F*L+v;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,g=a.n13,h=a.n14,j=a.n21,k=a.n22,m=a.n23,p=a.n24,y=a.n31,t=a.n32,q=a.n33,z=a.n34,C=a.n41,F=a.n42,v= -a.n43;a=a.n44;var G=b.n11,w=b.n12,K=b.n13,J=b.n14,f=b.n21,N=b.n22,O=b.n23,U=b.n24,Q=b.n31,Z=b.n32,ca=b.n33,L=b.n34,W=b.n41,ma=b.n42,ba=b.n43;b=b.n44;this.n11=d*G+e*f+g*Q+h*W;this.n12=d*w+e*N+g*Z+h*ma;this.n13=d*K+e*O+g*ca+h*ba;this.n14=d*J+e*U+g*L+h*b;this.n21=j*G+k*f+m*Q+p*W;this.n22=j*w+k*N+m*Z+p*ma;this.n23=j*K+k*O+m*ca+p*ba;this.n24=j*J+k*U+m*L+p*b;this.n31=y*G+t*f+q*Q+z*W;this.n32=y*w+t*N+q*Z+z*ma;this.n33=y*K+t*O+q*ca+z*ba;this.n34=y*J+t*U+q*L+z*b;this.n41=C*G+F*f+v*Q+a*W;this.n42=C*w+F*N+v* -Z+a*ma;this.n43=C*K+F*O+v*ca+a*ba;this.n44=C*J+F*U+v*L+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,m=this.n31,p=this.n32,y=this.n33,t=this.n34,q=this.n41,z=this.n42,C=this.n43,F=this.n44, -v=a.n11,G=a.n21,w=a.n31,K=a.n12,J=a.n22,f=a.n32,N=a.n13,O=a.n23,U=a.n33,Q=a.n14,Z=a.n24;a=a.n34;this.n11=b*v+c*G+d*w;this.n12=b*K+c*J+d*f;this.n13=b*N+c*O+d*U;this.n14=b*Q+c*Z+d*a+e;this.n21=g*v+h*G+j*w;this.n22=g*K+h*J+j*f;this.n23=g*N+h*O+j*U;this.n24=g*Q+h*Z+j*a+k;this.n31=m*v+p*G+y*w;this.n32=m*K+p*J+y*f;this.n33=m*N+p*O+y*U;this.n34=m*Q+p*Z+y*a+t;this.n41=q*v+z*G+C*w;this.n42=q*K+z*J+C*f;this.n43=q*N+z*O+C*U;this.n44=q*Q+z*Z+C*a+F;return this},multiplyScalar:function(a){this.n11*=a;this.n12*= -a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,g=this.n22,h=this.n23,j=this.n24,k=this.n31,m=this.n32,p=this.n33,y=this.n34,t=this.n41,q=this.n42,z=this.n43,C=this.n44;return d*h*m*t-c*j*m*t-d*g*p*t+b*j*p*t+c*g*y*t-b*h*y*t-d*h*k*q+c*j*k*q+d*e*p*q-a*j*p*q-c*e*y*q+a*h*y*q+d*g*k*z-b*j* -k*z-d*e*m*z+a*j*m*z+b*e*y*z-a*g*y*z-c*g*k*C+b*h*k*C+c*e*m*C-a*h*m*C-b*e*p*C+a*g*p*C},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flattenToArray(this.flat);return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a, -b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1, -0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,g=a.x,h=a.y,j=a.z,k=e*g,m=e*h;this.set(k*g+c,k*h-d*j,k*j+d*h,0,k*h+d*j,m*h+c,m*j-d*g,0,k*j-d*h,m*j+d*g,e*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24= -a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=a*c,j=b*c;this.n11=e*g;this.n12=-e*d;this.n13=c;this.n21=j*g+a*d;this.n22=-j*d+a*g;this.n23=-b*e;this.n31=-h*g+b*d;this.n32=h*d+b*g;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,g=b+b,h=c+c,j=d+d;a=b*g;var k=b*h;b*=j;var m=c*h;c*=j;d*=j;g*=e;h*=e;e*=j;this.n11=1-(m+d);this.n12=k-e;this.n13= -b+h;this.n21=k+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-h;this.n32=c+g;this.n33=1-(a+m)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d}; -THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c}; -THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,m=a.n24,p=a.n31,y=a.n32,t=a.n33,q=a.n34,z=a.n41,C=a.n42,F=a.n43,v=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=k*q*C-m*t*C+m*y*F-j*q*F-k*y*v+j*t*v;b.n12=g*t*C-e*q*C-g*y*F+d*q*F+e*y*v-d*t*v;b.n13=e*m*C-g*k*C+g*j*F-d*m*F-e*j*v+d*k*v;b.n14=g*k*y-e*m*y-g*j*t+d*m*t+e*j*q-d*k*q;b.n21=m*t*z-k*q*z-m*p*F+h*q*F+k*p*v-h*t*v;b.n22=e*q*z-g*t*z+g*p*F-c*q*F-e*p*v+c*t*v;b.n23=g*k*z-e*m*z-g*h*F+c*m*F+e*h*v-c*k*v; -b.n24=e*m*p-g*k*p+g*h*t-c*m*t-e*h*q+c*k*q;b.n31=j*q*z-m*y*z+m*p*C-h*q*C-j*p*v+h*y*v;b.n32=g*y*z-d*q*z-g*p*C+c*q*C+d*p*v-c*y*v;b.n33=e*m*z-g*j*z+g*h*C-c*m*C-d*h*v+c*j*v;b.n34=g*j*p-d*m*p-g*h*y+c*m*y+d*h*q-c*j*q;b.n41=k*y*z-j*t*z-k*p*C+h*t*C+j*p*F-h*y*F;b.n42=d*t*z-e*y*z+e*p*C-c*t*C-d*p*F+c*y*F;b.n43=e*j*z-d*k*z-e*h*C+c*k*C+d*h*F-c*j*F;b.n44=d*k*p-e*j*p+e*h*y-c*k*y-d*h*t+c*j*t;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*h;c[4]=a*j;c[5]=a*k;c[6]=a*m;c[7]=a*p;c[8]=a*y;return b}; -THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*e/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)}; -THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var h,j,k,m;h=new THREE.Matrix4;j=b-a;k=c-d;m=g-e;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((b+a)/j);h.n21=0;h.n22=2/k;h.n23=0;h.n24=-((c+d)/k);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+e)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; +THREE.Vector2=function(a,c){this.set(a||0,c||0)}; +THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/ +this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,c,b){this.set(a||0,c||0,b||0)}; +THREE.Vector3.prototype={set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a, +c){this.set(a.y*c.z-a.z*c.y,a.z*c.x-a.x*c.z,a.x*c.y-a.y*c.x);return this},crossSelf:function(a){var c=this.x,b=this.y,d=this.z;this.set(b*a.z-d*a.y,d*a.x-c*a.z,c*a.y-b*a.x);return this},multiply:function(a,c){this.set(a.x*c.x,a.y*c.y,a.z*c.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/ +a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x,b=this.y-a.y;a=this.z-a.z;return c*c+b*b+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a= +this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},setRotationFromMatrix:function(){},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)}};THREE.Vector4=function(a,c,b,d){this.set(a||0,c||0,b||0,d||1)}; +THREE.Vector4.prototype={set:function(a,c,b,d){this.x=a;this.y=c;this.z=b;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* +a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,c){this.set(this.x+(a.x-this.x)*c,this.y+(a.y-this.y)*c,this.z+(a.z-this.z)*c,this.w+(a.w-this.w)*c)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; +THREE.Ray.prototype={intersectScene:function(a){var c,b,d=a.objects,e=[];a=0;for(c=d.length;a0&&F>0&&L+F<1}var b,d,e,g,h,j,k,m,p,y, +t,q=a.geometry,z=q.vertices,C=[];b=0;for(d=q.faces.length;bk?d:k;e=e>m?e:m}a()}; +this.add3Points=function(k,m,p,y,t,q){if(j){j=!1;c=kp?k>t?k:t:p>t?p:t;e=m>y?m>q?m:q:y>q?y:q}else{c=kp?k>t?k>d?k:d:t>d?t:d:p>t?p>d?p:d:t>d?t:d;e=m>y?m>q?m>e?m:e:q>e?q:e:y>q?y>e?y:e:q>e?q:e}a()};this.addRectangle=function(k){if(j){j=!1;c=k.getLeft();b=k.getTop();d=k.getRight();e=k.getBottom()}else{c=ck.getRight()? +d:k.getRight();e=e>k.getBottom()?e:k.getBottom()}a()};this.inflate=function(k){c-=k;b-=k;d+=k;e+=k;a()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();b=b>k.getTop()?b:k.getTop();d=d=0&&Math.min(e,k.getBottom())-Math.max(b,k.getTop())>=0};this.empty=function(){j=!0;e=d=b=c=0;a()};this.isEmpty=function(){return j}}; +THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; +THREE.Matrix4=function(a,c,b,d,e,g,h,j,k,m,p,y,t,q,z,C){this.set(a||1,c||0,b||0,d||0,e||0,g||1,h||0,j||0,k||0,m||0,p||1,y||0,t||0,q||0,z||0,C||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,c,b,d,e,g,h,j,k,m,p,y,t,q,z,C){this.n11=a;this.n12=c;this.n13=b;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=j;this.n31=k;this.n32=m;this.n33=p;this.n34=y;this.n41=t;this.n42=q;this.n43=z;this.n44=C;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,c,b){var d=THREE.Matrix4.__tmpVec1, +e=THREE.Matrix4.__tmpVec2,g=THREE.Matrix4.__tmpVec3;g.sub(a,c).normalize();d.cross(b,g).normalize();e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n14=a.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n24=a.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;this.n34=a.z;return this},multiplyVector3:function(a){var c=a.x,b=a.y,d=a.z,e=1/(this.n41*c+this.n42*b+this.n43*d+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*d+this.n14)*e;a.y=(this.n21*c+this.n22*b+this.n23*d+this.n24)*e;a.z=(this.n31* +c+this.n32*b+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var c=a.x,b=a.y;a=a.z;return(this.n31*c+this.n32*b+this.n33*a+this.n34)*(1/(this.n41*c+this.n42*b+this.n43*a+this.n44))},multiplyVector4:function(a){var c=a.x,b=a.y,d=a.z,e=a.w;a.x=this.n11*c+this.n12*b+this.n13*d+this.n14*e;a.y=this.n21*c+this.n22*b+this.n23*d+this.n24*e;a.z=this.n31*c+this.n32*b+this.n33*d+this.n34*e;a.w=this.n41*c+this.n42*b+this.n43*d+this.n44*e;return a},crossVector:function(a){var c=new THREE.Vector4; +c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,m=a.n24,p=a.n31,y=a.n32,t=a.n33,q=a.n34,z=a.n41,C=a.n42,F=a.n43,w=a.n44,H=c.n11,x=c.n12,M=c.n13,L=c.n14,f=c.n21,N=c.n22,P=c.n23,V=c.n24,T=c.n31,ba=c.n32,fa=c.n33,K=c.n34;this.n11= +b*H+d*f+e*T;this.n12=b*x+d*N+e*ba;this.n13=b*M+d*P+e*fa;this.n14=b*L+d*V+e*K+g;this.n21=h*H+j*f+k*T;this.n22=h*x+j*N+k*ba;this.n23=h*M+j*P+k*fa;this.n24=h*L+j*V+k*K+m;this.n31=p*H+y*f+t*T;this.n32=p*x+y*N+t*ba;this.n33=p*M+y*P+t*fa;this.n34=p*L+y*V+t*K+q;this.n41=z*H+C*f+F*T;this.n42=z*x+C*N+F*ba;this.n43=z*M+C*P+F*fa;this.n44=z*L+C*V+F*K+w;return this},multiplyToArray:function(a,c,b){this.multiply(a,c);b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32; +b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,b=this.n13,d=this.n14, +e=this.n21,g=this.n22,h=this.n23,j=this.n24,k=this.n31,m=this.n32,p=this.n33,y=this.n34,t=this.n41,q=this.n42,z=this.n43,C=this.n44;return d*h*m*t-b*j*m*t-d*g*p*t+c*j*p*t+b*g*y*t-c*h*y*t-d*h*k*q+b*j*k*q+d*e*p*q-a*j*p*q-b*e*y*q+a*h*y*q+d*g*k*z-c*j*k*z-d*e*m*z+a*j*m*z+c*e*y*z-a*g*y*z-b*g*k*C+c*h*k*C+b*e*m*C-a*h*m*C-c*e*p*C+a*g*p*C},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14; +this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41; +this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]= +this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0, +0,1);return this},setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),d=Math.sin(c),e=1-b,g=a.x,h=a.y,j=a.z,k=e*g,m=e*h;this.set(k*g+b,k*h-d*j,k*j+d*h,0,k*h+d*j,m*h+b, +m*j-d*g,0,k*j-d*h,m*j+d*g,e*j*j+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,b=a.y,d=a.z;a=Math.cos(c);c=Math.sin(c);var e=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var h=a*b,j=c*b;this.n11=e*g;this.n12=-e*d;this.n13=b;this.n21=j*g+a*d;this.n22=-j*d+a*g;this.n23=-c*e;this.n31=-h*g+c*d;this.n32=h*d+c*g;this.n33=a*e},setRotationFromQuaternion:function(a){var c=a.x,b=a.y,d=a.z,e=a.w,g= +c+c,h=b+b,j=d+d;a=c*g;var k=c*h;c*=j;var m=b*h;b*=j;d*=j;g*=e;h*=e;e*=j;this.n11=1-(m+d);this.n12=k-e;this.n13=c+h;this.n21=k+e;this.n22=1-(a+d);this.n23=b-g;this.n31=c-h;this.n32=b+g;this.n33=1-(a+m)},scale:function(a){var c=a.x,b=a.y;a=a.z;this.n11*=c;this.n12*=b;this.n13*=a;this.n21*=c;this.n22*=b;this.n23*=a;this.n31*=c;this.n32*=b;this.n33*=a;this.n41*=c;this.n42*=b;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,c){var b= +1/c.x,d=1/c.y,e=1/c.z;this.n11=a.n11*b;this.n21=a.n21*b;this.n31=a.n31*b;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}}; +THREE.Matrix4.makeInvert=function(a,c){var b=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,j=a.n22,k=a.n23,m=a.n24,p=a.n31,y=a.n32,t=a.n33,q=a.n34,z=a.n41,C=a.n42,F=a.n43,w=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=k*q*C-m*t*C+m*y*F-j*q*F-k*y*w+j*t*w;c.n12=g*t*C-e*q*C-g*y*F+d*q*F+e*y*w-d*t*w;c.n13=e*m*C-g*k*C+g*j*F-d*m*F-e*j*w+d*k*w;c.n14=g*k*y-e*m*y-g*j*t+d*m*t+e*j*q-d*k*q;c.n21=m*t*z-k*q*z-m*p*F+h*q*F+k*p*w-h*t*w;c.n22=e*q*z-g*t*z+g*p*F-b*q*F-e*p*w+b*t*w;c.n23=g*k*z-e*m*z-g*h*F+b*m*F+e*h*w-b*k*w; +c.n24=e*m*p-g*k*p+g*h*t-b*m*t-e*h*q+b*k*q;c.n31=j*q*z-m*y*z+m*p*C-h*q*C-j*p*w+h*y*w;c.n32=g*y*z-d*q*z-g*p*C+b*q*C+d*p*w-b*y*w;c.n33=e*m*z-g*j*z+g*h*C-b*m*C-d*h*w+b*j*w;c.n34=g*j*p-d*m*p-g*h*y+b*m*y+d*h*q-b*j*q;c.n41=k*y*z-j*t*z-k*p*C+h*t*C+j*p*F-h*y*F;c.n42=d*t*z-e*y*z+e*p*C-b*t*C-d*p*F+b*y*F;c.n43=e*j*z-d*k*z-e*h*C+b*k*C+d*h*F-b*j*F;c.n44=d*k*p-e*j*p+e*h*y-b*k*y-d*h*t+b*j*t;c.multiplyScalar(1/a.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,b=c.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;b[0]=a*d;b[1]=a*e;b[2]=a*g;b[3]=a*h;b[4]=a*j;b[5]=a*k;b[6]=a*m;b[7]=a*p;b[8]=a*y;return c}; +THREE.Matrix4.makeFrustum=function(a,c,b,d,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(c-a);h.n12=0;h.n13=(c+a)/(c-a);h.n14=0;h.n21=0;h.n22=2*e/(d-b);h.n23=(d+b)/(d-b);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,c,b,d){var e;a=b*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*c,a*c,e,a,b,d)}; +THREE.Matrix4.makeOrtho=function(a,c,b,d,e,g){var h,j,k,m;h=new THREE.Matrix4;j=c-a;k=b-d;m=g-e;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((c+a)/j);h.n21=0;h.n22=2/k;h.n23=0;h.n24=-((b+d)/k);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+e)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1; this.visible=!0}; -THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation); -if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var d=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21= -this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*d;this.matrixRotationWorld.n23=this.matrixWorld.n23*d;this.matrixRotationWorld.n33=this.matrixWorld.n33*d;this.matrixNeedsUpdate=!1;b=!0}a=0;for(d=this.children.length;a=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c}; -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=!0}; -THREE.Face3=function(a,b,c,d,e){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.d=d;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.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; -THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], -z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z -this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;bt.length-2?e:e+1;b[3]=e>t.length-3?e:e+2;k=t[b[0]];m=t[b[1]];p=t[b[2]];y=t[b[3]];h=g*g;j=g*h;c.x=a(k.x,m.x,p.x,y.x,g,h,j);c.y=a(k.y,m.y,p.y,y.y,g,h,j);c.z=a(k.z,m.z,p.z,y.z,g,h,j);return c}}; -THREE.AnimationHandler=function(){var a=[],b={},c={};c.update=function(e){for(var g=0;g=1){b.w=a.w;b.x=a.x;b.y=a.y;b.z=a.z;return b}var g=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.001){b.w=0.5*(a.w+c.w);b.x=0.5*(a.x+c.x);b.y=0.5*(a.y+c.y);b.z=0.5*(a.z+c.z);return b}e=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;b.w=a.w*e+c.w*d;b.x=a.x*e+c.x*d;b.y=a.y*e+c.y*d;b.z=a.z*e+c.z*d;return b}; +THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0}; +THREE.Face3=function(a,c,b,d,e){this.a=a;this.b=c;this.c=b;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,c,b,d,e,g){this.a=a;this.b=c;this.c=b;this.d=d;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.UV=function(a,c){this.set(a||0,c||0)};THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; +THREE.Geometry.prototype={computeCentroids:function(){var a,c,b;a=0;for(c=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], +z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,b=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z +this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,b=this.vertices.length;ct.length-2?e:e+1;c[3]=e>t.length-3?e:e+2;k=t[c[0]];m=t[c[1]];p=t[c[2]];y=t[c[3]];h=g*g;j=g*h;b.x=a(k.x,m.x,p.x,y.x,g,h,j);b.y=a(k.y,m.y,p.y,y.y,g,h,j);b.z=a(k.z,m.z,p.z,y.z,g,h,j);return b}}; +THREE.AnimationHandler=function(){var a=[],c={},b={};b.update=function(e){for(var g=0;g1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d);d=d<0?0:1}if(c==="pos")if(this.interpolationType===THREE.AnimationHandler.LINEAR){c=a.position;c.x=e[0]+(g[0]-e[0])*d;c.y=e[1]+(g[1]-e[1])*d;c.z=e[2]+(g[2]-e[2])*d}else{var F=[];F[0]=this.getPrevKeyWith(c,q,h.index-1)[c];F[1]=e;F[2]=g;F[3]=this.getNextKeyWith(c,q,j.index+1)[c];d=d*0.33+0.33;d=this.interpolateCatmullRom(F,d);a.position.x= -d[0];a.position.y=d[1];a.position.z=d[2]}else if(c==="rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(c==="scl"){c=a.scale;c.x=e[0]+(g[0]-e[0])*d;c.y=e[1]+(g[1]-e[1])*d;c.z=e[2]+(g[2]-e[2])*d}}}}if(this.JITCompile&&p[0][m]===undefined){this.hierarchy[0].update(undefined,!0);for(q=0;qa.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];j=a[c[1]];k=a[c[2]];m=a[c[3]];c=e*e;h=e*c;d[0]=this.interpolate(g[0],j[0],k[0],m[0],e,c,h);d[1]=this.interpolate(g[1],j[1],k[1],m[1],e,c,h);d[2]=this.interpolate(g[2],j[2],k[2],m[2],e,c,h);return d}; -THREE.Animation.prototype.interpolate=function(a,b,c,d,e,g,h){a=(c-a)*0.5;d=(d-b)*0.5;return(2*(b-c)+a+d)*h+(-3*(b-c)-2*a-d)*g+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var d=this.data.hierarchy[b].keys;for(c%=d.length;c=0?c:c+d.length;c>=0;c--)if(d[c][a]!==undefined)return d[c];return this.data.hierarchy[b].keys[d.length-1]}; -THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;var g=new THREE.Vector3;this.translateX=function(h,j){g.sub(this.target.position,this.position).normalize().multiplyScalar(h);g.crossSelf(this.up);if(j)g.y=0;this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ= +THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,d,e,g,h,j,k,m,p=this.data.JIT.hierarchy,y,t;this.currentTime+=a;t=this.currentTime;y=this.currentTime%=this.data.length;m=parseInt(Math.min(y*this.data.fps,this.data.length*this.data.fps),10);for(var q=0,z=this.hierarchy.length;q1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d);d=d<0?0:1}if(b==="pos")if(this.interpolationType===THREE.AnimationHandler.LINEAR){b=a.position;b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}else{var F=[];F[0]=this.getPrevKeyWith(b,q,h.index-1)[b];F[1]=e;F[2]=g;F[3]=this.getNextKeyWith(b,q,j.index+1)[b];d=d*0.33+0.33;d=this.interpolateCatmullRom(F,d);a.position.x= +d[0];a.position.y=d[1];a.position.z=d[2]}else if(b==="rot")THREE.Quaternion.slerp(e,g,a.quaternion,d);else if(b==="scl"){b=a.scale;b.x=e[0]+(g[0]-e[0])*d;b.y=e[1]+(g[1]-e[1])*d;b.z=e[2]+(g[2]-e[2])*d}}}}if(this.JITCompile&&p[0][m]===undefined){this.hierarchy[0].update(undefined,!0);for(q=0;qa.length-2?g:g+1;b[3]=g>a.length-3?g:g+2;g=a[b[0]];j=a[b[1]];k=a[b[2]];m=a[b[3]];b=e*e;h=e*b;d[0]=this.interpolate(g[0],j[0],k[0],m[0],e,b,h);d[1]=this.interpolate(g[1],j[1],k[1],m[1],e,b,h);d[2]=this.interpolate(g[2],j[2],k[2],m[2],e,b,h);return d}; +THREE.Animation.prototype.interpolate=function(a,c,b,d,e,g,h){a=(b-a)*0.5;d=(d-c)*0.5;return(2*(c-b)+a+d)*h+(-3*(c-b)-2*a-d)*g+a*e+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var d=this.data.hierarchy[c].keys;for(b%=d.length;b=0?b:b+d.length;b>=0;b--)if(d[b][a]!==undefined)return d[b];return this.data.hierarchy[c].keys[d.length-1]}; +THREE.Camera=function(a,c,b,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=c||1;this.near=b||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;var g=new THREE.Vector3;this.translateX=function(h,j){g.sub(this.target.position,this.position).normalize().multiplyScalar(h);g.crossSelf(this.up);if(j)g.y=0;this.position.addSelf(g);this.target.position.addSelf(g)};this.translateZ= function(h,j){g.sub(this.target.position,this.position).normalize().multiplyScalar(h);if(j)g.y=0;this.position.subSelf(g);this.target.position.subSelf(g)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)}; -THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld, -this.matrixWorldInverse)}}for(a=0;athis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor),this.noFly);this.moveBackward&&this.translateZ(this.movementSpeed,this.noFly);this.moveLeft&&this.translateX(-this.movementSpeed,this.noFly);this.moveRight&&this.translateX(this.movementSpeed,this.noFly);this.lon+=this.mouseX*this.lookSpeed;this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed); -this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var c=this.target.position,d=this.position;c.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);c.y=d.y+100*Math.cos(this.phi);c.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(c){c.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown", -b(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D; -THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;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.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){}; +this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target.position,d=this.position;b.x=d.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=d.y+100*Math.cos(this.phi);b.z=d.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown", +c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D; +THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=c||1};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight; +THREE.PointLight=function(a,c){THREE.Light.call(this,a);this.position=new THREE.Vector3;this.intensity=c||1};THREE.PointLight.prototype=new THREE.Light;THREE.PointLight.prototype.constructor=THREE.PointLight;THREE.FlatShading=0;THREE.SmoothShading=1;THREE.NormalBlending=0;THREE.AdditiveBlending=1;THREE.SubtractiveBlending=2;THREE.BillboardBlending=3;THREE.ReverseSubtractiveBlending=4;THREE.MaterialCounter={value:0};THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){}; THREE.LatitudeReflectionMapping=function(){};THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){}; THREE.LineBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=!1;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.depthTest!==undefined)this.depthTest=a.depthTest;if(a.linewidth!==undefined)this.linewidth= a.linewidth;if(a.linecap!==undefined)this.linecap=a.linecap;if(a.linejoin!==undefined)this.linejoin=a.linejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}}; @@ -114,148 +111,148 @@ a.vertexShader;if(a.uniforms!==undefined)this.uniforms=a.uniforms;if(a.opacity!= undefined)this.wireframeLinejoin=a.wireframeLinejoin;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors;if(a.skinning!==undefined)this.skinning=a.skinning}}; THREE.ParticleBasicMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.color=new THREE.Color(16777215);this.opacity=1;this.map=null;this.size=1;this.blending=THREE.NormalBlending;this.depthTest=!0;this.offset=new THREE.Vector2;this.vertexColors=!1;if(a){a.color!==undefined&&this.color.setHex(a.color);if(a.opacity!==undefined)this.opacity=a.opacity;if(a.map!==undefined)this.map=a.map;if(a.size!==undefined)this.size=a.size;if(a.blending!==undefined)this.blending=a.blending;if(a.depthTest!== undefined)this.depthTest=a.depthTest;if(a.vertexColors!==undefined)this.vertexColors=a.vertexColors}};THREE.ParticleCircleMaterial=function(a){this.id=THREE.MaterialCounter.value++;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.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.Texture=function(a,b,c,d,e,g){this.image=a;this.mapping=b!==undefined?b:new THREE.UVMapping;this.wrapS=c!==undefined?c:THREE.ClampToEdgeWrapping;this.wrapT=d!==undefined?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==undefined?e:THREE.LinearFilter;this.minFilter=g!==undefined?g:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1}; +THREE.ParticleDOMMaterial=function(a){this.id=THREE.MaterialCounter.value++;this.domElement=a};THREE.Texture=function(a,c,b,d,e,g){this.image=a;this.mapping=c!==undefined?c:new THREE.UVMapping;this.wrapS=b!==undefined?b:THREE.ClampToEdgeWrapping;this.wrapT=d!==undefined?d:THREE.ClampToEdgeWrapping;this.magFilter=e!==undefined?e:THREE.LinearFilter;this.minFilter=g!==undefined?g:THREE.LinearMipMapLinearFilter;this.needsUpdate=!1}; THREE.Texture.prototype={clone:function(){return new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter)}};THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10; THREE.ShortType=11;THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20; -THREE.RenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=c.wrapS!==undefined?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==undefined?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==undefined?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==undefined?c.minFilter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType}; -var Uniforms={clone:function(a){var b,c,d,e={};for(b in a){e[b]={};for(c in a[b]){d=a[b][c];e[b][c]=d instanceof THREE.Color||d instanceof THREE.Vector3||d instanceof THREE.Texture?d.clone():d}}return e},merge:function(a){var b,c,d,e={};for(b=0;b1){a=c.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var d=1;d=this.LODs[d].visibleAtDistance){this.LODs[d-1].object3D.visible=!1;this.LODs[d].object3D.visible= -!0}else break;for(;d=0&&ca>=0&&L>=0&&W>=0)return!0;else if(Z<0&&ca<0||L<0&&W<0)return!1;else{if(Z<0)U=Math.max(U,Z/(Z-ca));else ca<0&&(Q=Math.min(Q,Z/(Z-ca)));if(L<0)U=Math.max(U,L/(L-W));else W<0&&(Q=Math.min(Q,L/(L-W)));if(QZ&&ba.z0&&F.z<1){t=z[q]=z[q]||new THREE.RenderableParticle;t.x=F.x/F.w;t.y=F.y/F.w;t.z=F.z;t.rotation=ia.rotation.z;t.scale.x=ia.scale.x*Math.abs(t.x- -(F.x+O.projectionMatrix.n11)/(F.w+O.projectionMatrix.n14));t.scale.y=ia.scale.y*Math.abs(t.y-(F.y+O.projectionMatrix.n22)/(F.w+O.projectionMatrix.n24));t.materials=ia.materials;Q.push(t);q++}}}}U&&Q.sort(a);return Q};this.unprojectVector=function(N,O){var U=O.matrixWorld.clone();U.multiplySelf(THREE.Matrix4.makeInvert(O.projectionMatrix));U.multiplyVector3(N);return N}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,j){c=h;d=j;e=c/2;g=d/2};this.render=function(h,j){var k,m,p,y,t,q,z,C;a=b.projectScene(h,j);k=0;for(m=a.length;k0){V.r+=Da.r*qa;V.g+=Da.g*qa;V.b+=Da.b*qa}}else if(qa instanceof THREE.PointLight){H.sub(qa.position,fa);H.normalize();qa=ja.dot(H)*Ea;if(qa>0){V.r+=Da.r*qa;V.g+=Da.g*qa;V.b+=Da.b*qa}}}}function $(R,fa,ja){if(ja.opacity!=0){a(ja.opacity); -b(ja.blending);var V,ea,qa,Da,Ea,ya;if(ja instanceof THREE.ParticleBasicMaterial){if(ja.map){Da=ja.map.image;Ea=Da.width>>1;ya=Da.height>>1;ea=fa.scale.x*j;qa=fa.scale.y*k;ja=ea*Ea;V=qa*ya;o.set(R.x-ja,R.y-V,R.x+ja,R.y+V);if(B.instersects(o)){m.save();m.translate(R.x,R.y);m.rotate(-fa.rotation);m.scale(ea,-qa);m.translate(-Ea,-ya);m.drawImage(Da,0,0);m.restore()}}}else if(ja instanceof THREE.ParticleCircleMaterial){if(E){D.r=I.r+S.r+u.r;D.g=I.g+S.g+u.g;D.b=I.b+S.b+u.b;Q.r=ja.color.r*D.r;Q.g=ja.color.g* -D.g;Q.b=ja.color.b*D.b;Q.updateStyleString()}else Q.__styleString=ja.color.__styleString;ja=fa.scale.x*j;V=fa.scale.y*k;o.set(R.x-ja,R.y-V,R.x+ja,R.y+V);if(B.instersects(o)){ea=Q.__styleString;if(C!=ea)m.fillStyle=C=ea;m.save();m.translate(R.x,R.y);m.rotate(-fa.rotation);m.scale(ja,V);m.beginPath();m.arc(0,0,1,0,A,!0);m.closePath();m.fill();m.restore()}}}}function aa(R,fa,ja,V){if(V.opacity!=0){a(V.opacity);b(V.blending);m.beginPath();m.moveTo(R.positionScreen.x,R.positionScreen.y);m.lineTo(fa.positionScreen.x, -fa.positionScreen.y);m.closePath();if(V instanceof THREE.LineBasicMaterial){Q.__styleString=V.color.__styleString;R=V.linewidth;if(F!=R)m.lineWidth=F=R;R=Q.__styleString;if(z!=R)m.strokeStyle=z=R;m.stroke();o.inflate(V.linewidth*2)}}}function ta(R,fa,ja,V,ea,qa){if(ea.opacity!=0){a(ea.opacity);b(ea.blending);K=R.positionScreen.x;J=R.positionScreen.y;f=fa.positionScreen.x;N=fa.positionScreen.y;O=ja.positionScreen.x;U=ja.positionScreen.y;m.beginPath();m.moveTo(K,J);m.lineTo(f,N);m.lineTo(O,U);m.lineTo(K, -J);m.closePath();if(ea instanceof THREE.MeshBasicMaterial)if(ea.map)ea.map.mapping instanceof THREE.UVMapping&&M(K,J,f,N,O,U,ea.map.image,V.uvs[0].u,V.uvs[0].v,V.uvs[1].u,V.uvs[1].v,V.uvs[2].u,V.uvs[2].v);else if(ea.envMap){if(ea.envMap.mapping instanceof THREE.SphericalReflectionMapping){R=xa.matrixWorldInverse;H.copy(V.vertexNormalsWorld[0]);ga=(H.x*R.n11+H.y*R.n12+H.z*R.n13)*0.5+0.5;ia=-(H.x*R.n21+H.y*R.n22+H.z*R.n23)*0.5+0.5;H.copy(V.vertexNormalsWorld[1]);ra=(H.x*R.n11+H.y*R.n12+H.z*R.n13)*0.5+ -0.5;wa=-(H.x*R.n21+H.y*R.n22+H.z*R.n23)*0.5+0.5;H.copy(V.vertexNormalsWorld[2]);l=(H.x*R.n11+H.y*R.n12+H.z*R.n13)*0.5+0.5;x=-(H.x*R.n21+H.y*R.n22+H.z*R.n23)*0.5+0.5;M(K,J,f,N,O,U,ea.envMap.image,ga,ia,ra,wa,l,x)}}else ea.wireframe?Fa(ea.color.__styleString,ea.wireframeLinewidth):za(ea.color.__styleString);else if(ea instanceof THREE.MeshLambertMaterial){if(ea.map&&!ea.wireframe){ea.map.mapping instanceof THREE.UVMapping&&M(K,J,f,N,O,U,ea.map.image,V.uvs[0].u,V.uvs[0].v,V.uvs[1].u,V.uvs[1].v,V.uvs[2].u, -V.uvs[2].v);b(THREE.SubtractiveBlending)}if(E)if(!ea.wireframe&&ea.shading==THREE.SmoothShading&&V.vertexNormalsWorld.length==3){Z.r=ca.r=L.r=I.r;Z.g=ca.g=L.g=I.g;Z.b=ca.b=L.b=I.b;X(qa,V.v1.positionWorld,V.vertexNormalsWorld[0],Z);X(qa,V.v2.positionWorld,V.vertexNormalsWorld[1],ca);X(qa,V.v3.positionWorld,V.vertexNormalsWorld[2],L);W.r=(ca.r+L.r)*0.5;W.g=(ca.g+L.g)*0.5;W.b=(ca.b+L.b)*0.5;na=Aa(Z,ca,L,W);M(K,J,f,N,O,U,na,0,0,1,0,0,1)}else{D.r=I.r;D.g=I.g;D.b=I.b;X(qa,V.centroidWorld,V.normalWorld, -D);Q.r=ea.color.r*D.r;Q.g=ea.color.g*D.g;Q.b=ea.color.b*D.b;Q.updateStyleString();ea.wireframe?Fa(Q.__styleString,ea.wireframeLinewidth):za(Q.__styleString)}else ea.wireframe?Fa(ea.color.__styleString,ea.wireframeLinewidth):za(ea.color.__styleString)}else if(ea instanceof THREE.MeshDepthMaterial){ma=xa.near;ba=xa.far;Z.r=Z.g=Z.b=1-Pa(R.positionScreen.z,ma,ba);ca.r=ca.g=ca.b=1-Pa(fa.positionScreen.z,ma,ba);L.r=L.g=L.b=1-Pa(ja.positionScreen.z,ma,ba);W.r=(ca.r+L.r)*0.5;W.g=(ca.g+L.g)*0.5;W.b=(ca.b+ -L.b)*0.5;na=Aa(Z,ca,L,W);M(K,J,f,N,O,U,na,0,0,1,0,0,1)}else if(ea instanceof THREE.MeshNormalMaterial){Q.r=Qa(V.normalWorld.x);Q.g=Qa(V.normalWorld.y);Q.b=Qa(V.normalWorld.z);Q.updateStyleString();ea.wireframe?Fa(Q.__styleString,ea.wireframeLinewidth):za(Q.__styleString)}}}function Fa(R,fa){if(z!=R)m.strokeStyle=z=R;if(F!=fa)m.lineWidth=F=fa;m.stroke();o.inflate(fa*2)}function za(R){if(C!=R)m.fillStyle=C=R;m.fill()}function M(R,fa,ja,V,ea,qa,Da,Ea,ya,Na,La,Oa,Sa){var Ga,Ja;Ga=Da.width-1;Ja=Da.height- -1;Ea*=Ga;ya*=Ja;Na*=Ga;La*=Ja;Oa*=Ga;Sa*=Ja;ja-=R;V-=fa;ea-=R;qa-=fa;Na-=Ea;La-=ya;Oa-=Ea;Sa-=ya;Ga=Na*Sa-Oa*La;if(Ga!=0){Ja=1/Ga;Ga=(Sa*ja-La*ea)*Ja;La=(Sa*V-La*qa)*Ja;ja=(Na*ea-Oa*ja)*Ja;V=(Na*qa-Oa*V)*Ja;R=R-Ga*Ea-ja*ya;fa=fa-La*Ea-V*ya;m.save();m.transform(Ga,La,ja,V,R,fa);m.clip();m.drawImage(Da,0,0);m.restore()}}function Aa(R,fa,ja,V){var ea=~~(R.r*255),qa=~~(R.g*255);R=~~(R.b*255);var Da=~~(fa.r*255),Ea=~~(fa.g*255);fa=~~(fa.b*255);var ya=~~(ja.r*255),Na=~~(ja.g*255);ja=~~(ja.b*255);var La= -~~(V.r*255),Oa=~~(V.g*255);V=~~(V.b*255);da[0]=ea<0?0:ea>255?255:ea;da[1]=qa<0?0:qa>255?255:qa;da[2]=R<0?0:R>255?255:R;da[4]=Da<0?0:Da>255?255:Da;da[5]=Ea<0?0:Ea>255?255:Ea;da[6]=fa<0?0:fa>255?255:fa;da[8]=ya<0?0:ya>255?255:ya;da[9]=Na<0?0:Na>255?255:Na;da[10]=ja<0?0:ja>255?255:ja;da[12]=La<0?0:La>255?255:La;da[13]=Oa<0?0:Oa>255?255:Oa;da[14]=V<0?0:V>255?255:V;Y.putImageData(ha,0,0);Ca.drawImage(T,0,0);return ka}function Pa(R,fa,ja){R=(R-fa)/(ja-fa);return R*R*(3-2*R)}function Qa(R){R=(R+1)*0.5;return R< -0?0:R>1?1:R}function Ka(R,fa){var ja=fa.x-R.x,V=fa.y-R.y,ea=1/Math.sqrt(ja*ja+V*V);ja*=ea;V*=ea;fa.x+=ja;fa.y+=V;R.x-=ja;R.y-=V}var ua,Ba,la,oa,sa,va,Ma,Ha;this.autoClear?this.clear():m.setTransform(1,0,0,-1,j,k);c=d.projectScene(pa,xa,this.sortElements);(E=pa.lights.length>0)&&Ia(pa);ua=0;for(Ba=c.length;ua0){ra.r+=x.color.r*B;ra.g+=x.color.g*B;ra.b+=x.color.b*B}}else if(x instanceof THREE.PointLight){U.sub(x.position,ia.centroidWorld);U.normalize();B=ia.normalWorld.dot(U)*x.intensity;if(B>0){ra.r+=x.color.r*B;ra.g+=x.color.g*B;ra.b+=x.color.b*B}}}}function b(ga,ia,ra,wa,l,x){L=d(W++);L.setAttribute("d", -"M "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(l instanceof THREE.MeshBasicMaterial)w.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshLambertMaterial)if(G){K.r=J.r;K.g=J.g;K.b=J.b;a(x,wa,K);w.r=l.color.r*K.r;w.g=l.color.g*K.g;w.b=l.color.b*K.b;w.updateStyleString()}else w.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshDepthMaterial){O=1-l.__2near/(l.__farPlusNear- -wa.z*l.__farMinusNear);w.setRGB(O,O,O)}else l instanceof THREE.MeshNormalMaterial&&w.setRGB(e(wa.normalWorld.x),e(wa.normalWorld.y),e(wa.normalWorld.z));l.wireframe?L.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+l.wireframeLinewidth+"; stroke-opacity: "+l.opacity+"; stroke-linecap: "+l.wireframeLinecap+"; stroke-linejoin: "+l.wireframeLinejoin):L.setAttribute("style","fill: "+w.__styleString+"; fill-opacity: "+l.opacity);j.appendChild(L)}function c(ga,ia,ra,wa,l, -x,B){L=d(W++);L.setAttribute("d","M "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+" L "+wa.positionScreen.x+","+wa.positionScreen.y+"z");if(x instanceof THREE.MeshBasicMaterial)w.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshLambertMaterial)if(G){K.r=J.r;K.g=J.g;K.b=J.b;a(B,l,K);w.r=x.color.r*K.r;w.g=x.color.g*K.g;w.b=x.color.b*K.b;w.updateStyleString()}else w.__styleString=x.color.__styleString; -else if(x instanceof THREE.MeshDepthMaterial){O=1-x.__2near/(x.__farPlusNear-l.z*x.__farMinusNear);w.setRGB(O,O,O)}else x instanceof THREE.MeshNormalMaterial&&w.setRGB(e(l.normalWorld.x),e(l.normalWorld.y),e(l.normalWorld.z));x.wireframe?L.setAttribute("style","fill: none; stroke: "+w.__styleString+"; stroke-width: "+x.wireframeLinewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.wireframeLinecap+"; stroke-linejoin: "+x.wireframeLinejoin):L.setAttribute("style","fill: "+w.__styleString+ -"; fill-opacity: "+x.opacity);j.appendChild(L)}function d(ga){if(Q[ga]==null){Q[ga]=document.createElementNS("http://www.w3.org/2000/svg","path");na==0&&Q[ga].setAttribute("shape-rendering","crispEdges")}return Q[ga]}function e(ga){return ga<0?Math.min((1+ga)*0.5,0.5):0.5+Math.min(ga*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,p,y,t,q,z,C,F=new THREE.Rectangle,v=new THREE.Rectangle,G=!1,w=new THREE.Color(16777215),K=new THREE.Color(16777215), -J=new THREE.Color(0),f=new THREE.Color(0),N=new THREE.Color(0),O,U=new THREE.Vector3,Q=[],Z=[],ca=[],L,W,ma,ba,na=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ga){switch(ga){case "high":na=1;break;case "low":na=0}};this.setSize=function(ga,ia){k=ga;m=ia;p=k/2;y=m/2;j.setAttribute("viewBox",-p+" "+-y+" "+k+" "+m);j.setAttribute("width",k);j.setAttribute("height",m);F.set(-p,-y,p,y)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])}; -this.render=function(ga,ia){var ra,wa,l,x,B,n,o,E;this.autoClear&&this.clear();g=h.projectScene(ga,ia,this.sortElements);ba=ma=W=0;if(G=ga.lights.length>0){o=ga.lights;J.setRGB(0,0,0);f.setRGB(0,0,0);N.setRGB(0,0,0);ra=0;for(wa=o.length;ra1){a=b.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var d=1;d=this.LODs[d].visibleAtDistance){this.LODs[d-1].object3D.visible=!1;this.LODs[d].object3D.visible= +!0}else break;for(;d=0&&fa>=0&&K>=0&&Y>=0)return!0;else if(ba<0&&fa<0||K<0&&Y<0)return!1;else{if(ba<0)V=Math.max(V,ba/(ba-fa));else fa<0&&(T=Math.min(T,ba/(ba-fa)));if(K<0)V=Math.max(V,K/(K-Y));else Y<0&&(T=Math.min(T,K/(K-Y)));if(Tba&&da.z0&&F.z<1){t=z[q]=z[q]||new THREE.RenderableParticle;t.x=F.x/F.w;t.y=F.y/F.w;t.z=F.z;t.rotation=ia.rotation.z;t.scale.x=ia.scale.x*Math.abs(t.x- +(F.x+P.projectionMatrix.n11)/(F.w+P.projectionMatrix.n14));t.scale.y=ia.scale.y*Math.abs(t.y-(F.y+P.projectionMatrix.n22)/(F.w+P.projectionMatrix.n24));t.materials=ia.materials;T.push(t);q++}}}}V&&T.sort(a);return T};this.unprojectVector=function(N,P){var V=P.matrixWorld.clone();V.multiplySelf(THREE.Matrix4.makeInvert(P.projectionMatrix));V.multiplyVector3(N);return N}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,b,d,e,g;this.domElement=document.createElement("div");this.setSize=function(h,j){b=h;d=j;e=b/2;g=d/2};this.render=function(h,j){var k,m,p,y,t,q,z,C;a=c.projectScene(h,j);k=0;for(m=a.length;k0){U.r+=Da.r*qa;U.g+=Da.g*qa;U.b+=Da.b*qa}}else if(qa instanceof THREE.PointLight){G.sub(qa.position,ea);G.normalize();qa=ja.dot(G)*Ea;if(qa>0){U.r+=Da.r*qa;U.g+=Da.g*qa;U.b+=Da.b*qa}}}}function Z(Q,ea,ja){if(ja.opacity!= +0){a(ja.opacity);c(ja.blending);var U,ca,qa,Da,Ea,ya;if(ja instanceof THREE.ParticleBasicMaterial){if(ja.map){Da=ja.map.image;Ea=Da.width>>1;ya=Da.height>>1;ca=ea.scale.x*j;qa=ea.scale.y*k;ja=ca*Ea;U=qa*ya;o.set(Q.x-ja,Q.y-U,Q.x+ja,Q.y+U);if(B.instersects(o)){m.save();m.translate(Q.x,Q.y);m.rotate(-ea.rotation);m.scale(ca,-qa);m.translate(-Ea,-ya);m.drawImage(Da,0,0);m.restore()}}}else if(ja instanceof THREE.ParticleCircleMaterial){if(E){D.r=I.r+R.r+u.r;D.g=I.g+R.g+u.g;D.b=I.b+R.b+u.b;T.r=ja.color.r* +D.r;T.g=ja.color.g*D.g;T.b=ja.color.b*D.b;T.updateStyleString()}else T.__styleString=ja.color.__styleString;ja=ea.scale.x*j;U=ea.scale.y*k;o.set(Q.x-ja,Q.y-U,Q.x+ja,Q.y+U);if(B.instersects(o)){ca=T.__styleString;if(C!=ca)m.fillStyle=C=ca;m.save();m.translate(Q.x,Q.y);m.rotate(-ea.rotation);m.scale(ja,U);m.beginPath();m.arc(0,0,1,0,A,!0);m.closePath();m.fill();m.restore()}}}}function $(Q,ea,ja,U){if(U.opacity!=0){a(U.opacity);c(U.blending);m.beginPath();m.moveTo(Q.positionScreen.x,Q.positionScreen.y); +m.lineTo(ea.positionScreen.x,ea.positionScreen.y);m.closePath();if(U instanceof THREE.LineBasicMaterial){T.__styleString=U.color.__styleString;Q=U.linewidth;if(F!=Q)m.lineWidth=F=Q;Q=T.__styleString;if(z!=Q)m.strokeStyle=z=Q;m.stroke();o.inflate(U.linewidth*2)}}}function ta(Q,ea,ja,U,ca,qa){if(ca.opacity!=0){a(ca.opacity);c(ca.blending);M=Q.positionScreen.x;L=Q.positionScreen.y;f=ea.positionScreen.x;N=ea.positionScreen.y;P=ja.positionScreen.x;V=ja.positionScreen.y;m.beginPath();m.moveTo(M,L);m.lineTo(f, +N);m.lineTo(P,V);m.lineTo(M,L);m.closePath();if(ca instanceof THREE.MeshBasicMaterial)if(ca.map)ca.map.mapping instanceof THREE.UVMapping&&J(M,L,f,N,P,V,ca.map.image,U.uvs[0].u,U.uvs[0].v,U.uvs[1].u,U.uvs[1].v,U.uvs[2].u,U.uvs[2].v);else if(ca.envMap){if(ca.envMap.mapping instanceof THREE.SphericalReflectionMapping){Q=xa.matrixWorldInverse;G.copy(U.vertexNormalsWorld[0]);ga=(G.x*Q.n11+G.y*Q.n12+G.z*Q.n13)*0.5+0.5;ia=-(G.x*Q.n21+G.y*Q.n22+G.z*Q.n23)*0.5+0.5;G.copy(U.vertexNormalsWorld[1]);ra=(G.x* +Q.n11+G.y*Q.n12+G.z*Q.n13)*0.5+0.5;wa=-(G.x*Q.n21+G.y*Q.n22+G.z*Q.n23)*0.5+0.5;G.copy(U.vertexNormalsWorld[2]);l=(G.x*Q.n11+G.y*Q.n12+G.z*Q.n13)*0.5+0.5;v=-(G.x*Q.n21+G.y*Q.n22+G.z*Q.n23)*0.5+0.5;J(M,L,f,N,P,V,ca.envMap.image,ga,ia,ra,wa,l,v)}}else ca.wireframe?Fa(ca.color.__styleString,ca.wireframeLinewidth):za(ca.color.__styleString);else if(ca instanceof THREE.MeshLambertMaterial){if(ca.map&&!ca.wireframe){ca.map.mapping instanceof THREE.UVMapping&&J(M,L,f,N,P,V,ca.map.image,U.uvs[0].u,U.uvs[0].v, +U.uvs[1].u,U.uvs[1].v,U.uvs[2].u,U.uvs[2].v);c(THREE.SubtractiveBlending)}if(E)if(!ca.wireframe&&ca.shading==THREE.SmoothShading&&U.vertexNormalsWorld.length==3){ba.r=fa.r=K.r=I.r;ba.g=fa.g=K.g=I.g;ba.b=fa.b=K.b=I.b;W(qa,U.v1.positionWorld,U.vertexNormalsWorld[0],ba);W(qa,U.v2.positionWorld,U.vertexNormalsWorld[1],fa);W(qa,U.v3.positionWorld,U.vertexNormalsWorld[2],K);Y.r=(fa.r+K.r)*0.5;Y.g=(fa.g+K.g)*0.5;Y.b=(fa.b+K.b)*0.5;ma=Aa(ba,fa,K,Y);J(M,L,f,N,P,V,ma,0,0,1,0,0,1)}else{D.r=I.r;D.g=I.g;D.b=I.b; +W(qa,U.centroidWorld,U.normalWorld,D);T.r=ca.color.r*D.r;T.g=ca.color.g*D.g;T.b=ca.color.b*D.b;T.updateStyleString();ca.wireframe?Fa(T.__styleString,ca.wireframeLinewidth):za(T.__styleString)}else ca.wireframe?Fa(ca.color.__styleString,ca.wireframeLinewidth):za(ca.color.__styleString)}else if(ca instanceof THREE.MeshDepthMaterial){pa=xa.near;da=xa.far;ba.r=ba.g=ba.b=1-Pa(Q.positionScreen.z,pa,da);fa.r=fa.g=fa.b=1-Pa(ea.positionScreen.z,pa,da);K.r=K.g=K.b=1-Pa(ja.positionScreen.z,pa,da);Y.r=(fa.r+ +K.r)*0.5;Y.g=(fa.g+K.g)*0.5;Y.b=(fa.b+K.b)*0.5;ma=Aa(ba,fa,K,Y);J(M,L,f,N,P,V,ma,0,0,1,0,0,1)}else if(ca instanceof THREE.MeshNormalMaterial){T.r=Qa(U.normalWorld.x);T.g=Qa(U.normalWorld.y);T.b=Qa(U.normalWorld.z);T.updateStyleString();ca.wireframe?Fa(T.__styleString,ca.wireframeLinewidth):za(T.__styleString)}}}function Fa(Q,ea){if(z!=Q)m.strokeStyle=z=Q;if(F!=ea)m.lineWidth=F=ea;m.stroke();o.inflate(ea*2)}function za(Q){if(C!=Q)m.fillStyle=C=Q;m.fill()}function J(Q,ea,ja,U,ca,qa,Da,Ea,ya,Na,La,Oa, +Sa){var Ga,Ja;Ga=Da.width-1;Ja=Da.height-1;Ea*=Ga;ya*=Ja;Na*=Ga;La*=Ja;Oa*=Ga;Sa*=Ja;ja-=Q;U-=ea;ca-=Q;qa-=ea;Na-=Ea;La-=ya;Oa-=Ea;Sa-=ya;Ga=Na*Sa-Oa*La;if(Ga!=0){Ja=1/Ga;Ga=(Sa*ja-La*ca)*Ja;La=(Sa*U-La*qa)*Ja;ja=(Na*ca-Oa*ja)*Ja;U=(Na*qa-Oa*U)*Ja;Q=Q-Ga*Ea-ja*ya;ea=ea-La*Ea-U*ya;m.save();m.transform(Ga,La,ja,U,Q,ea);m.clip();m.drawImage(Da,0,0);m.restore()}}function Aa(Q,ea,ja,U){var ca=~~(Q.r*255),qa=~~(Q.g*255);Q=~~(Q.b*255);var Da=~~(ea.r*255),Ea=~~(ea.g*255);ea=~~(ea.b*255);var ya=~~(ja.r*255), +Na=~~(ja.g*255);ja=~~(ja.b*255);var La=~~(U.r*255),Oa=~~(U.g*255);U=~~(U.b*255);aa[0]=ca<0?0:ca>255?255:ca;aa[1]=qa<0?0:qa>255?255:qa;aa[2]=Q<0?0:Q>255?255:Q;aa[4]=Da<0?0:Da>255?255:Da;aa[5]=Ea<0?0:Ea>255?255:Ea;aa[6]=ea<0?0:ea>255?255:ea;aa[8]=ya<0?0:ya>255?255:ya;aa[9]=Na<0?0:Na>255?255:Na;aa[10]=ja<0?0:ja>255?255:ja;aa[12]=La<0?0:La>255?255:La;aa[13]=Oa<0?0:Oa>255?255:Oa;aa[14]=U<0?0:U>255?255:U;X.putImageData(ha,0,0);Ca.drawImage(S,0,0);return ka}function Pa(Q,ea,ja){Q=(Q-ea)/(ja-ea);return Q* +Q*(3-2*Q)}function Qa(Q){Q=(Q+1)*0.5;return Q<0?0:Q>1?1:Q}function Ka(Q,ea){var ja=ea.x-Q.x,U=ea.y-Q.y,ca=1/Math.sqrt(ja*ja+U*U);ja*=ca;U*=ca;ea.x+=ja;ea.y+=U;Q.x-=ja;Q.y-=U}var ua,Ba,la,na,sa,va,Ma,Ha;this.autoClear?this.clear():m.setTransform(1,0,0,-1,j,k);b=d.projectScene(oa,xa,this.sortElements);(E=oa.lights.length>0)&&Ia(oa);ua=0;for(Ba=b.length;ua0){ra.r+=v.color.r*B;ra.g+=v.color.g*B;ra.b+=v.color.b*B}}else if(v instanceof THREE.PointLight){V.sub(v.position,ia.centroidWorld);V.normalize();B=ia.normalWorld.dot(V)*v.intensity;if(B>0){ra.r+=v.color.r*B;ra.g+=v.color.g*B;ra.b+=v.color.b*B}}}}function c(ga,ia,ra,wa,l,v){K=d(Y++);K.setAttribute("d", +"M "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+"z");if(l instanceof THREE.MeshBasicMaterial)x.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshLambertMaterial)if(H){M.r=L.r;M.g=L.g;M.b=L.b;a(v,wa,M);x.r=l.color.r*M.r;x.g=l.color.g*M.g;x.b=l.color.b*M.b;x.updateStyleString()}else x.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshDepthMaterial){P=1-l.__2near/(l.__farPlusNear- +wa.z*l.__farMinusNear);x.setRGB(P,P,P)}else l instanceof THREE.MeshNormalMaterial&&x.setRGB(e(wa.normalWorld.x),e(wa.normalWorld.y),e(wa.normalWorld.z));l.wireframe?K.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+l.wireframeLinewidth+"; stroke-opacity: "+l.opacity+"; stroke-linecap: "+l.wireframeLinecap+"; stroke-linejoin: "+l.wireframeLinejoin):K.setAttribute("style","fill: "+x.__styleString+"; fill-opacity: "+l.opacity);j.appendChild(K)}function b(ga,ia,ra,wa,l, +v,B){K=d(Y++);K.setAttribute("d","M "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+ra.positionScreen.x+","+ra.positionScreen.y+" L "+wa.positionScreen.x+","+wa.positionScreen.y+"z");if(v instanceof THREE.MeshBasicMaterial)x.__styleString=v.color.__styleString;else if(v instanceof THREE.MeshLambertMaterial)if(H){M.r=L.r;M.g=L.g;M.b=L.b;a(B,l,M);x.r=v.color.r*M.r;x.g=v.color.g*M.g;x.b=v.color.b*M.b;x.updateStyleString()}else x.__styleString=v.color.__styleString; +else if(v instanceof THREE.MeshDepthMaterial){P=1-v.__2near/(v.__farPlusNear-l.z*v.__farMinusNear);x.setRGB(P,P,P)}else v instanceof THREE.MeshNormalMaterial&&x.setRGB(e(l.normalWorld.x),e(l.normalWorld.y),e(l.normalWorld.z));v.wireframe?K.setAttribute("style","fill: none; stroke: "+x.__styleString+"; stroke-width: "+v.wireframeLinewidth+"; stroke-opacity: "+v.opacity+"; stroke-linecap: "+v.wireframeLinecap+"; stroke-linejoin: "+v.wireframeLinejoin):K.setAttribute("style","fill: "+x.__styleString+ +"; fill-opacity: "+v.opacity);j.appendChild(K)}function d(ga){if(T[ga]==null){T[ga]=document.createElementNS("http://www.w3.org/2000/svg","path");ma==0&&T[ga].setAttribute("shape-rendering","crispEdges")}return T[ga]}function e(ga){return ga<0?Math.min((1+ga)*0.5,0.5):0.5+Math.min(ga*0.5,0.5)}var g=null,h=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),k,m,p,y,t,q,z,C,F=new THREE.Rectangle,w=new THREE.Rectangle,H=!1,x=new THREE.Color(16777215),M=new THREE.Color(16777215), +L=new THREE.Color(0),f=new THREE.Color(0),N=new THREE.Color(0),P,V=new THREE.Vector3,T=[],ba=[],fa=[],K,Y,pa,da,ma=1;this.domElement=j;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ga){switch(ga){case "high":ma=1;break;case "low":ma=0}};this.setSize=function(ga,ia){k=ga;m=ia;p=k/2;y=m/2;j.setAttribute("viewBox",-p+" "+-y+" "+k+" "+m);j.setAttribute("width",k);j.setAttribute("height",m);F.set(-p,-y,p,y)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])}; +this.render=function(ga,ia){var ra,wa,l,v,B,n,o,E;this.autoClear&&this.clear();g=h.projectScene(ga,ia,this.sortElements);da=pa=Y=0;if(H=ga.lights.length>0){o=ga.lights;L.setRGB(0,0,0);f.setRGB(0,0,0);N.setRGB(0,0,0);ra=0;for(wa=o.length;ra=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLColorBuffer);f.vertexAttribPointer(l.color,3,f.FLOAT,!1,0,0)}if(l.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLNormalBuffer);f.vertexAttribPointer(l.normal, +!1,ma);if(n.skinning){f.uniformMatrix4fv(D.cameraInverseMatrix,!1,ma);f.uniformMatrix4fv(D.boneGlobalMatrices,!1,o.boneMatrices)}return E}function e(l,v,B,n,o,E){l=d(l,v,B,n,E).attributes;f.bindBuffer(f.ARRAY_BUFFER,o.__webGLVertexBuffer);f.vertexAttribPointer(l.position,3,f.FLOAT,!1,0,0);if(l.color>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLColorBuffer);f.vertexAttribPointer(l.color,3,f.FLOAT,!1,0,0)}if(l.normal>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLNormalBuffer);f.vertexAttribPointer(l.normal, 3,f.FLOAT,!1,0,0)}if(l.tangent>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLTangentBuffer);f.vertexAttribPointer(l.tangent,4,f.FLOAT,!1,0,0)}if(l.uv>=0)if(o.__webGLUVBuffer){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLUVBuffer);f.vertexAttribPointer(l.uv,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(l.uv)}else f.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(o.__webGLUV2Buffer){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLUV2Buffer);f.vertexAttribPointer(l.uv2,2,f.FLOAT,!1,0,0);f.enableVertexAttribArray(l.uv2)}else f.disableVertexAttribArray(l.uv2); if(n.skinning&&l.skinVertexA>=0&&l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight>=0){f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);f.vertexAttribPointer(l.skinVertexA,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);f.vertexAttribPointer(l.skinVertexB,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);f.vertexAttribPointer(l.skinIndex,4,f.FLOAT,!1,0,0);f.bindBuffer(f.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);f.vertexAttribPointer(l.skinWeight, 4,f.FLOAT,!1,0,0)}if(E instanceof THREE.Mesh)if(n.wireframe){f.lineWidth(n.wireframeLinewidth);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);f.drawElements(f.LINES,o.__webGLLineCount,f.UNSIGNED_SHORT,0)}else{f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);f.drawElements(f.TRIANGLES,o.__webGLFaceCount,f.UNSIGNED_SHORT,0)}else if(E instanceof THREE.Line){E=E.type==THREE.LineStrip?f.LINE_STRIP:f.LINES;f.lineWidth(n.linewidth);f.drawArrays(E,0,o.__webGLLineCount)}else if(E instanceof -THREE.ParticleSystem)f.drawArrays(f.POINTS,0,o.__webGLParticleCount);else E instanceof THREE.Ribbon&&f.drawArrays(f.TRIANGLE_STRIP,0,o.__webGLVertexCount)}function g(l,x){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=f.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=f.createBuffer();if(l.hasPos){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,l.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(x.attributes.position);f.vertexAttribPointer(x.attributes.position, -3,f.FLOAT,!1,0,0)}if(l.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,l.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(x.attributes.normal);f.vertexAttribPointer(x.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,l.count);l.count=0}function h(l){if(Q!=l.doubleSided){l.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);Q=l.doubleSided}if(Z!=l.flipSided){l.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);Z=l.flipSided}}function j(l){if(L!= -l){l?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);L=l}}function k(l){W[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);W[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);W[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);W[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);W[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);W[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var x;for(l=0;l<6;l++){x=W[l];x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z))}} -function m(l){for(var x=l.matrixWorld,B=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),n=0;n<6;n++){l=W[n].x*x.n14+W[n].y*x.n24+W[n].z*x.n34+W[n].w;if(l<=B)return!1}return!0}function p(l,x){l.list[l.count]=x;l.count+=1}function y(l){var x,B,n=l.object,o=l.opaque,E=l.transparent;E.count=0;l=o.count=0;for(x=n.materials.length;l65535){A[S].counter+=1;u=A[S].hash+ -"_"+A[S].counter;l.geometryGroups[u]==undefined&&(l.geometryGroups[u]={faces:[],materials:I,vertices:0})}l.geometryGroups[u].faces.push(o);l.geometryGroups[u].vertices+=D}}function F(l,x,B){l.push({buffer:x,object:B,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function v(l){if(l!=ca){switch(l){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break;case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR,f.ZERO);break;case THREE.BillboardBlending:f.blendEquation(f.FUNC_ADD); -f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:f.blendEquation(f.FUNC_REVERSE_SUBTRACT);f.blendFunc(f.ONE,f.ONE);break;default:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA)}ca=l}}function G(l,x){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=f.createFramebuffer();l.__webGLRenderbuffer=f.createRenderbuffer();l.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,l.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER, -f.DEPTH_COMPONENT16,l.width,l.height);f.bindTexture(f.TEXTURE_2D,l.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,K(l.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,K(l.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,K(l.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,K(l.minFilter));f.texImage2D(f.TEXTURE_2D,0,K(l.format),l.width,l.height,0,K(l.format),K(l.type),null);f.bindFramebuffer(f.FRAMEBUFFER,l.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER, -f.COLOR_ATTACHMENT0,f.TEXTURE_2D,l.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,l.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var B,n,o;if(l){B=l.__webGLFramebuffer;n=l.width;o=l.height}else{B=null;n=J.width;o=J.height}if(B!=O){f.bindFramebuffer(f.FRAMEBUFFER,B);f.viewport(0,0,n,o);x&&f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT);O=B}}function w(l,x){var B;if(l== -"fragment")B=f.createShader(f.FRAGMENT_SHADER);else l=="vertex"&&(B=f.createShader(f.VERTEX_SHADER));f.shaderSource(B,x);f.compileShader(B);if(!f.getShaderParameter(B,f.COMPILE_STATUS)){alert(f.getShaderInfoLog(B));return null}return B}function K(l){switch(l){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST; +THREE.ParticleSystem)f.drawArrays(f.POINTS,0,o.__webGLParticleCount);else E instanceof THREE.Ribbon&&f.drawArrays(f.TRIANGLE_STRIP,0,o.__webGLVertexCount)}function g(l,v){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=f.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=f.createBuffer();if(l.hasPos){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLVertexBuffer);f.bufferData(f.ARRAY_BUFFER,l.positionArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(v.attributes.position);f.vertexAttribPointer(v.attributes.position, +3,f.FLOAT,!1,0,0)}if(l.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,l.__webGLNormalBuffer);f.bufferData(f.ARRAY_BUFFER,l.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(v.attributes.normal);f.vertexAttribPointer(v.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,l.count);l.count=0}function h(l){if(T!=l.doubleSided){l.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE);T=l.doubleSided}if(ba!=l.flipSided){l.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW);ba=l.flipSided}}function j(l){if(K!= +l){l?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST);K=l}}function k(l){Y[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);Y[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);Y[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);Y[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);Y[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);Y[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var v;for(l=0;l<6;l++){v=Y[l];v.divideScalar(Math.sqrt(v.x*v.x+v.y*v.y+v.z*v.z))}} +function m(l){for(var v=l.matrixWorld,B=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),n=0;n<6;n++){l=Y[n].x*v.n14+Y[n].y*v.n24+Y[n].z*v.n34+Y[n].w;if(l<=B)return!1}return!0}function p(l,v){l.list[l.count]=v;l.count+=1}function y(l){var v,B,n=l.object,o=l.opaque,E=l.transparent;E.count=0;l=o.count=0;for(v=n.materials.length;l65535){A[R].counter+=1;u=A[R].hash+ +"_"+A[R].counter;l.geometryGroups[u]==undefined&&(l.geometryGroups[u]={faces:[],materials:I,vertices:0})}l.geometryGroups[u].faces.push(o);l.geometryGroups[u].vertices+=D}}function F(l,v,B){l.push({buffer:v,object:B,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function w(l){if(l!=fa){switch(l){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE);break;case THREE.SubtractiveBlending:f.blendFunc(f.DST_COLOR,f.ZERO);break;case THREE.BillboardBlending:f.blendEquation(f.FUNC_ADD); +f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:f.blendEquation(f.FUNC_REVERSE_SUBTRACT);f.blendFunc(f.ONE,f.ONE);break;default:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA)}fa=l}}function H(l,v){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=f.createFramebuffer();l.__webGLRenderbuffer=f.createRenderbuffer();l.__webGLTexture=f.createTexture();f.bindRenderbuffer(f.RENDERBUFFER,l.__webGLRenderbuffer);f.renderbufferStorage(f.RENDERBUFFER, +f.DEPTH_COMPONENT16,l.width,l.height);f.bindTexture(f.TEXTURE_2D,l.__webGLTexture);f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,M(l.wrapS));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,M(l.wrapT));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,M(l.magFilter));f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,M(l.minFilter));f.texImage2D(f.TEXTURE_2D,0,M(l.format),l.width,l.height,0,M(l.format),M(l.type),null);f.bindFramebuffer(f.FRAMEBUFFER,l.__webGLFramebuffer);f.framebufferTexture2D(f.FRAMEBUFFER, +f.COLOR_ATTACHMENT0,f.TEXTURE_2D,l.__webGLTexture,0);f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,l.__webGLRenderbuffer);f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}var B,n,o;if(l){B=l.__webGLFramebuffer;n=l.width;o=l.height}else{B=null;n=L.width;o=L.height}if(B!=P){f.bindFramebuffer(f.FRAMEBUFFER,B);f.viewport(0,0,n,o);v&&f.clear(f.COLOR_BUFFER_BIT|f.DEPTH_BUFFER_BIT);P=B}}function x(l,v){var B;if(l== +"fragment")B=f.createShader(f.FRAGMENT_SHADER);else l=="vertex"&&(B=f.createShader(f.VERTEX_SHADER));f.shaderSource(B,v);f.compileShader(B);if(!f.getShaderParameter(B,f.COMPILE_STATUS)){alert(f.getShaderInfoLog(B));return null}return B}function M(l){switch(l){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST; case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT; -case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}var J=document.createElement("canvas"),f,N=null,O=null,U=this,Q=null,Z=null,ca=null,L=null,W=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ma=new THREE.Matrix4,ba=new Float32Array(16),na=new Float32Array(16),ga=new THREE.Vector4, -ia=!0,ra=new THREE.Color(0),wa=0;if(a){if(a.antialias!==undefined)ia=a.antialias;a.clearColor!==undefined&&ra.setHex(a.clearColor);if(a.clearAlpha!==undefined)wa=a.clearAlpha}this.domElement=J;this.autoClear=!0;this.sortObjects=!1;(function(l,x,B){try{f=J.getContext("experimental-webgl",{antialias:l})}catch(n){console.log(n)}if(!f)throw"cannot create webgl context";f.clearColor(0,0,0,1);f.clearDepth(1);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE); -f.enable(f.BLEND);f.blendFunc(f.ONE,f.ONE_MINUS_SRC_ALPHA);f.clearColor(x.r,x.g,x.b,B);_cullEnabled=!0})(ia,ra,wa);this.context=f;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,x){J.width=l;J.height=x;f.viewport(0,0,J.width,J.height)};this.setClearColorHex=function(l,x){var B=new THREE.Color(l);f.clearColor(B.r,B.g,B.b,x)};this.setClearColor=function(l,x){f.clearColor(l.r,l.g,l.b,x)};this.clear=function(){f.clear(f.COLOR_BUFFER_BIT| -f.DEPTH_BUFFER_BIT)};this.initMaterial=function(l,x,B){var n,o;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof -THREE.ParticleBasicMaterial&&c(l,THREE.ShaderLib.particle_basic);var E,D,I,S;o=I=S=0;for(E=x.length;o0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+ E.maxPointLights,E.map?"#define USE_MAP":"",E.envMap?"#define USE_ENVMAP":"",E.lightMap?"#define USE_LIGHTMAP":"",E.vertexColors?"#define USE_COLOR":"",E.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); -f.attachShader(B,w("fragment",o+S));f.attachShader(B,w("vertex",E+x));f.linkProgram(B);f.getProgramParameter(B,f.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+f.getProgramParameter(B,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");B.uniforms={};B.attributes={};l.program=B;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(n in l.uniforms)B.push(n);n=l.program;S=0;for(x=B.length;S< -x;S++){o=B[S];n.uniforms[o]=f.getUniformLocation(n,o)}n=l.program;B=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];S=0;for(x=B.length;S=0&&f.enableVertexAttribArray(n.color);n.normal>=0&&f.enableVertexAttribArray(n.normal);n.tangent>=0&&f.enableVertexAttribArray(n.tangent);if(l.skinning&&n.skinVertexA>=0&&n.skinVertexB>= -0&&n.skinIndex>=0&&n.skinWeight>=0){f.enableVertexAttribArray(n.skinVertexA);f.enableVertexAttribArray(n.skinVertexB);f.enableVertexAttribArray(n.skinIndex);f.enableVertexAttribArray(n.skinWeight)}};this.render=function(l,x,B,n){var o,E,D,I,S,u,A,H,T=l.lights,Y=l.fog;x.matrixAutoUpdate&&x.update();x.matrixWorldInverse.flattenToArray(na);x.projectionMatrix.flattenToArray(ba);ma.multiply(x.projectionMatrix,x.matrixWorldInverse);k(ma);l.update(undefined,!1,x);this.initWebGLObjects(l,x);G(B,n!==undefined? -n:!0);this.autoClear&&this.clear();S=l.__webglObjects.length;for(n=0;n=0&&f.enableVertexAttribArray(n.color);n.normal>=0&&f.enableVertexAttribArray(n.normal);n.tangent>=0&&f.enableVertexAttribArray(n.tangent);if(l.skinning&&n.skinVertexA>=0&&n.skinVertexB>= +0&&n.skinIndex>=0&&n.skinWeight>=0){f.enableVertexAttribArray(n.skinVertexA);f.enableVertexAttribArray(n.skinVertexB);f.enableVertexAttribArray(n.skinIndex);f.enableVertexAttribArray(n.skinWeight)}};this.render=function(l,v,B,n){var o,E,D,I,R,u,A,G,S=l.lights,X=l.fog;v.matrixAutoUpdate&&v.update();v.matrixWorldInverse.flattenToArray(ma);v.projectionMatrix.flattenToArray(da);pa.multiply(v.projectionMatrix,v.matrixWorldInverse);k(pa);l.update(undefined,!1,v);this.initWebGLObjects(l,v);H(B,n!==undefined? +n:!0);this.autoClear&&this.clear();R=l.__webglObjects.length;for(n=0;n=0;o--){n=B.__webglObjects[o].object;x==n&&B.__webglObjects.splice(o,1)}l.__objectsRemoved.splice(0,1)}x=0;for(B=l.__webglObjects.length;x0){f.bindBuffer(f.ARRAY_BUFFER,D.__webGLUVBuffer);f.bufferData(f.ARRAY_BUFFER,Pa,H)}if(ea&&Y>0){f.bindBuffer(f.ARRAY_BUFFER,D.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,Qa,H)}if(V){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,D.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ma,H);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,D.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ha,H)}if(M>0){f.bindBuffer(f.ARRAY_BUFFER,D.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER, -la,H);f.bindBuffer(f.ARRAY_BUFFER,D.__webGLSkinVertexBBuffer);f.bufferData(f.ARRAY_BUFFER,oa,H);f.bindBuffer(f.ARRAY_BUFFER,D.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,sa,H);f.bindBuffer(f.ARRAY_BUFFER,D.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,va,H)}}}o.__dirtyVertices=!1;o.__dirtyElements=!1;o.__dirtyUvs=!1;o.__dirtyNormals=!1;o.__dirtyTangents=!1;o.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){o=n.geometry;if(o.__dirtyVertices||o.__dirtyColors){n=o;E=f.DYNAMIC_DRAW; -u=void 0;u=void 0;I=void 0;D=void 0;A=n.vertices;H=n.colors;Y=A.length;T=H.length;ha=n.__vertexArray;S=n.__colorArray;da=n.__dirtyColors;if(n.__dirtyVertices){for(u=0;u0}}; +f.createBuffer();D=E;var I=v,R=void 0,u=void 0,A=0,G=0,S=0,X=I.geometry.faces,ha=D.faces;R=0;for(u=ha.length;R=0;o--){n=B.__webglObjects[o].object;v==n&&B.__webglObjects.splice(o,1)}l.__objectsRemoved.splice(0,1)}v=0;for(B=l.__webglObjects.length;v0){f.bindBuffer(f.ARRAY_BUFFER, +D.__webGLUVBuffer);f.bufferData(f.ARRAY_BUFFER,Pa,G)}if(ca&&X>0){f.bindBuffer(f.ARRAY_BUFFER,D.__webGLUV2Buffer);f.bufferData(f.ARRAY_BUFFER,Qa,G)}if(U){f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,D.__webGLFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ma,G);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,D.__webGLLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ha,G)}if(J>0){f.bindBuffer(f.ARRAY_BUFFER,D.__webGLSkinVertexABuffer);f.bufferData(f.ARRAY_BUFFER,la,G);f.bindBuffer(f.ARRAY_BUFFER,D.__webGLSkinVertexBBuffer); +f.bufferData(f.ARRAY_BUFFER,na,G);f.bindBuffer(f.ARRAY_BUFFER,D.__webGLSkinIndicesBuffer);f.bufferData(f.ARRAY_BUFFER,sa,G);f.bindBuffer(f.ARRAY_BUFFER,D.__webGLSkinWeightsBuffer);f.bufferData(f.ARRAY_BUFFER,va,G)}}}o.__dirtyVertices=!1;o.__dirtyElements=!1;o.__dirtyUvs=!1;o.__dirtyNormals=!1;o.__dirtyTangents=!1;o.__dirtyColors=!1}else if(n instanceof THREE.Ribbon){o=n.geometry;if(o.__dirtyVertices||o.__dirtyColors){n=o;E=f.DYNAMIC_DRAW;u=void 0;u=void 0;I=void 0;D=void 0;A=n.vertices;G=n.colors; +X=A.length;S=G.length;ha=n.__vertexArray;R=n.__colorArray;aa=n.__dirtyColors;if(n.__dirtyVertices){for(u=0;u0}}; THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif", envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\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 ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif", @@ -276,23 +273,23 @@ THREE.Snippets.lights_pars_fragment,"void main() {\ngl_FragColor = vec4( vLightW THREE.Snippets.lights_pars_vertex,THREE.Snippets.color_pars_vertex,THREE.Snippets.skinning_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.Snippets.map_vertex,THREE.Snippets.lightmap_vertex,THREE.Snippets.envmap_vertex,THREE.Snippets.color_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,THREE.Snippets.skinning_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.Snippets.color_pars_fragment,THREE.Snippets.map_particle_pars_fragment,THREE.Snippets.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.Snippets.map_particle_fragment,THREE.Snippets.color_fragment,THREE.Snippets.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;", THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}}; -THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,e=c.length;for(d=0;d= 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}", @@ -301,39 +298,39 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25&&(g=25);e=(g-1)*0.5;c=Array(g);for(b=d=0;b25&&(g=25);e=(g-1)*0.5;b=Array(g);for(c=d=0;c0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,j,t)))-1);m.push(p)}b.push(m)}var q,z,C;e=b.length;for(c=0;c0)for(d=0;d1){q=this.vertices[h].position.clone(); +var Sphere=function(a,c,b){THREE.Geometry.call(this);var d,e=Math.PI,g=Math.max(3,c||8),h=Math.max(2,b||6);c=[];for(b=0;b0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,j,t)))-1);m.push(p)}c.push(m)}var q,z,C;e=c.length;for(b=0;b0)for(d=0;d1){q=this.vertices[h].position.clone(); z=this.vertices[k].position.clone();C=this.vertices[m].position.clone();q.normalize();z.normalize();C.normalize();this.faces.push(new THREE.Face3(h,k,m,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([p,y,F])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere; -var Torus=function(a,b,c,d){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){d=c/this.segmentsT*2*Math.PI;var e=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(d),(this.radius+this.tube*Math.cos(e))*Math.sin(d),this.tube*Math.sin(e))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c= -1;c<=this.segmentsT;++c){d=(this.segmentsT+1)*b+c;e=(this.segmentsT+1)*b+c-1;var g=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(d,e,g,h));this.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus; -var Icosahedron=function(a){function b(y,t,q){var z=Math.sqrt(y*y+t*t+q*q);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(y/z,t/z,q/z)))-1}function c(y,t,q,z){z.faces.push(new THREE.Face3(y,t,q))}function d(y,t){var q=e.vertices[y].position,z=e.vertices[t].position;return b((q.x+z.x)/2,(q.y+z.y)/2,(q.z+z.z)/2)}var e=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0, -1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,g);c(0,5,1,g);c(0,1,7,g);c(0,7,10,g);c(0,10,11,g);c(1,5,9,g);c(5,11,4,g);c(11,10,2,g);c(10,7,6,g);c(7,1,8,g);c(3,9,4,g);c(3,4,2,g);c(3,2,6,g);c(3,6,8,g);c(3,8,9,g);c(4,9,5,g);c(2,4,11,g);c(6,2,10,g);c(8,6,7,g);c(9,8,1,g);for(a=0;a=this.maxCount-3&&j(this)};this.begin= -function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var d=this.count*3;dthis.size-1&&(k=this.size-1);var t=Math.floor(m-j);t<1&&(t=1);m=Math.floor(m+j);m>this.size-1&&(m=this.size-1);var q=Math.floor(p-j);q<1&&(q=1);j=Math.floor(p+j); -j>this.size-1&&(j=this.size-1);for(var z,C,F,v,G,w;y0&&(this.field[F+z]+=v)}}}};this.addPlaneX=function(c,d){var e,g,h,j,k,m=this.size,p=this.yd,y=this.zd,t=this.field,q=m*Math.sqrt(c/d);q>m&&(q=m);for(e=0;e0)for(g=0;gp&&(z=p);for(g=0;g0){k=g*y;for(e=0;esize&&(dist=size);for(h=0;h0){k=zd*h;for(g=0;g=this.maxCount-3&&j(this)};this.begin= +function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var d=this.count*3;dthis.size-1&&(k=this.size-1);var t=Math.floor(m-j);t<1&&(t=1);m=Math.floor(m+j);m>this.size-1&&(m=this.size-1);var q=Math.floor(p-j);q<1&&(q=1);j=Math.floor(p+j); +j>this.size-1&&(j=this.size-1);for(var z,C,F,w,H,x;y0&&(this.field[F+z]+=w)}}}};this.addPlaneX=function(b,d){var e,g,h,j,k,m=this.size,p=this.yd,y=this.zd,t=this.field,q=m*Math.sqrt(b/d);q>m&&(q=m);for(e=0;e0)for(g=0;gp&&(z=p);for(g=0;g0){k=g*y;for(e=0;esize&&(dist=size);for(h=0;h0){k=zd*h;for(g=0;g>7)-127;H|=(Y&127)<<16|T<<8;if(H==0&&da==-127)return 0;return(1-2*(ha>>7))*(1+H*Math.pow(2,-23))*Math.pow(2,da)}function j(u,A){var H=p(u,A),T=p(u,A+1),Y=p(u,A+2);return(p(u,A+3)<<24)+(Y<<16)+(T<<8)+H}function k(u,A){var H=p(u,A);return(p(u,A+1)<<8)+H}function m(u,A){var H=p(u,A);return H>127?H-256:H}function p(u,A){return u.charCodeAt(A)&255}function y(u){var A,H,T;A= -j(a,u);H=j(a,u+f);T=j(a,u+N);u=k(a,u+O);THREE.Loader.prototype.f3(v,A,H,T,u)}function t(u){var A,H,T,Y,ha,da;A=j(a,u);H=j(a,u+f);T=j(a,u+N);Y=k(a,u+O);ha=j(a,u+U);da=j(a,u+Q);u=j(a,u+Z);THREE.Loader.prototype.f3n(v,K,A,H,T,Y,ha,da,u)}function q(u){var A,H,T,Y;A=j(a,u);H=j(a,u+ca);T=j(a,u+L);Y=j(a,u+W);u=k(a,u+ma);THREE.Loader.prototype.f4(v,A,H,T,Y,u)}function z(u){var A,H,T,Y,ha,da,ka,Ca;A=j(a,u);H=j(a,u+ca);T=j(a,u+L);Y=j(a,u+W);ha=k(a,u+ma);da=j(a,u+ba);ka=j(a,u+na);Ca=j(a,u+ga);u=j(a,u+ia);THREE.Loader.prototype.f4n(v, -K,A,H,T,Y,ha,da,ka,Ca,u)}function C(u){var A,H;A=j(a,u);H=j(a,u+ra);u=j(a,u+wa);THREE.Loader.prototype.uv3(v.uvs,J[A*2],J[A*2+1],J[H*2],J[H*2+1],J[u*2],J[u*2+1])}function F(u){var A,H,T;A=j(a,u);H=j(a,u+l);T=j(a,u+x);u=j(a,u+B);THREE.Loader.prototype.uv4(v.uvs,J[A*2],J[A*2+1],J[H*2],J[H*2+1],J[T*2],J[T*2+1],J[u*2],J[u*2+1])}var v=this,G=0,w,K=[],J=[],f,N,O,U,Q,Z,ca,L,W,ma,ba,na,ga,ia,ra,wa,l,x,B,n,o,E,D,I,S;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,d,g);w={signature:a.substr(G, -8),header_bytes:p(a,G+8),vertex_coordinate_bytes:p(a,G+9),normal_coordinate_bytes:p(a,G+10),uv_coordinate_bytes:p(a,G+11),vertex_index_bytes:p(a,G+12),normal_index_bytes:p(a,G+13),uv_index_bytes:p(a,G+14),material_index_bytes:p(a,G+15),nvertices:j(a,G+16),nnormals:j(a,G+16+4),nuvs:j(a,G+16+8),ntri_flat:j(a,G+16+12),ntri_smooth:j(a,G+16+16),ntri_flat_uv:j(a,G+16+20),ntri_smooth_uv:j(a,G+16+24),nquad_flat:j(a,G+16+28),nquad_smooth:j(a,G+16+32),nquad_flat_uv:j(a,G+16+36),nquad_smooth_uv:j(a,G+16+40)}; -G+=w.header_bytes;f=w.vertex_index_bytes;N=w.vertex_index_bytes*2;O=w.vertex_index_bytes*3;U=w.vertex_index_bytes*3+w.material_index_bytes;Q=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes;Z=w.vertex_index_bytes*3+w.material_index_bytes+w.normal_index_bytes*2;ca=w.vertex_index_bytes;L=w.vertex_index_bytes*2;W=w.vertex_index_bytes*3;ma=w.vertex_index_bytes*4;ba=w.vertex_index_bytes*4+w.material_index_bytes;na=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes;ga= -w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*2;ia=w.vertex_index_bytes*4+w.material_index_bytes+w.normal_index_bytes*3;ra=w.uv_index_bytes;wa=w.uv_index_bytes*2;l=w.uv_index_bytes;x=w.uv_index_bytes*2;B=w.uv_index_bytes*3;g=w.vertex_index_bytes*3+w.material_index_bytes;S=w.vertex_index_bytes*4+w.material_index_bytes;n=w.ntri_flat*g;o=w.ntri_smooth*(g+w.normal_index_bytes*3);E=w.ntri_flat_uv*(g+w.uv_index_bytes*3);D=w.ntri_smooth_uv*(g+w.normal_index_bytes*3+w.uv_index_bytes* -3);I=w.nquad_flat*S;g=w.nquad_smooth*(S+w.normal_index_bytes*4);S=w.nquad_flat_uv*(S+w.uv_index_bytes*4);G+=function(u){for(var A,H,T,Y=w.vertex_coordinate_bytes*3,ha=u+w.nvertices*Y;u>7)-127;G|=(X&127)<<16|S<<8;if(G==0&&aa==-127)return 0;return(1-2*(ha>>7))*(1+G*Math.pow(2,-23))*Math.pow(2,aa)}function j(u,A){var G=p(u,A),S=p(u,A+1),X=p(u,A+2);return(p(u,A+3)<<24)+(X<<16)+(S<<8)+G}function k(u,A){var G=p(u,A);return(p(u,A+1)<<8)+G}function m(u,A){var G=p(u,A);return G>127?G-256:G}function p(u,A){return u.charCodeAt(A)&255}function y(u){var A,G,S;A= +j(a,u);G=j(a,u+f);S=j(a,u+N);u=k(a,u+P);THREE.Loader.prototype.f3(w,A,G,S,u)}function t(u){var A,G,S,X,ha,aa;A=j(a,u);G=j(a,u+f);S=j(a,u+N);X=k(a,u+P);ha=j(a,u+V);aa=j(a,u+T);u=j(a,u+ba);THREE.Loader.prototype.f3n(w,M,A,G,S,X,ha,aa,u)}function q(u){var A,G,S,X;A=j(a,u);G=j(a,u+fa);S=j(a,u+K);X=j(a,u+Y);u=k(a,u+pa);THREE.Loader.prototype.f4(w,A,G,S,X,u)}function z(u){var A,G,S,X,ha,aa,ka,Ca;A=j(a,u);G=j(a,u+fa);S=j(a,u+K);X=j(a,u+Y);ha=k(a,u+pa);aa=j(a,u+da);ka=j(a,u+ma);Ca=j(a,u+ga);u=j(a,u+ia);THREE.Loader.prototype.f4n(w, +M,A,G,S,X,ha,aa,ka,Ca,u)}function C(u){var A,G;A=j(a,u);G=j(a,u+ra);u=j(a,u+wa);THREE.Loader.prototype.uv3(w.uvs,L[A*2],L[A*2+1],L[G*2],L[G*2+1],L[u*2],L[u*2+1])}function F(u){var A,G,S;A=j(a,u);G=j(a,u+l);S=j(a,u+v);u=j(a,u+B);THREE.Loader.prototype.uv4(w.uvs,L[A*2],L[A*2+1],L[G*2],L[G*2+1],L[S*2],L[S*2+1],L[u*2],L[u*2+1])}var w=this,H=0,x,M=[],L=[],f,N,P,V,T,ba,fa,K,Y,pa,da,ma,ga,ia,ra,wa,l,v,B,n,o,E,D,I,R;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,d,g);x={signature:a.substr(H, +8),header_bytes:p(a,H+8),vertex_coordinate_bytes:p(a,H+9),normal_coordinate_bytes:p(a,H+10),uv_coordinate_bytes:p(a,H+11),vertex_index_bytes:p(a,H+12),normal_index_bytes:p(a,H+13),uv_index_bytes:p(a,H+14),material_index_bytes:p(a,H+15),nvertices:j(a,H+16),nnormals:j(a,H+16+4),nuvs:j(a,H+16+8),ntri_flat:j(a,H+16+12),ntri_smooth:j(a,H+16+16),ntri_flat_uv:j(a,H+16+20),ntri_smooth_uv:j(a,H+16+24),nquad_flat:j(a,H+16+28),nquad_smooth:j(a,H+16+32),nquad_flat_uv:j(a,H+16+36),nquad_smooth_uv:j(a,H+16+40)}; +H+=x.header_bytes;f=x.vertex_index_bytes;N=x.vertex_index_bytes*2;P=x.vertex_index_bytes*3;V=x.vertex_index_bytes*3+x.material_index_bytes;T=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes;ba=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2;fa=x.vertex_index_bytes;K=x.vertex_index_bytes*2;Y=x.vertex_index_bytes*3;pa=x.vertex_index_bytes*4;da=x.vertex_index_bytes*4+x.material_index_bytes;ma=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes;ga= +x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2;ia=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3;ra=x.uv_index_bytes;wa=x.uv_index_bytes*2;l=x.uv_index_bytes;v=x.uv_index_bytes*2;B=x.uv_index_bytes*3;g=x.vertex_index_bytes*3+x.material_index_bytes;R=x.vertex_index_bytes*4+x.material_index_bytes;n=x.ntri_flat*g;o=x.ntri_smooth*(g+x.normal_index_bytes*3);E=x.ntri_flat_uv*(g+x.uv_index_bytes*3);D=x.ntri_smooth_uv*(g+x.normal_index_bytes*3+x.uv_index_bytes* +3);I=x.nquad_flat*R;g=x.nquad_smooth*(R+x.normal_index_bytes*4);R=x.nquad_flat_uv*(R+x.uv_index_bytes*4);H+=function(u){for(var A,G,S,X=x.vertex_coordinate_bytes*3,ha=u+x.nvertices*X;u0?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)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)}; +this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},setRotationFromMatrix:function(){},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)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)}; THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a0&&r>0&&F+r<1}var c,d,e,f,g,j,h,i,n,m, -o,q=a.geometry,s=q.vertices,t=[];c=0;for(d=q.faces.length;ch?d:h;e=e>i?e:i}a()}; -this.add3Points=function(h,i,n,m,o,q){if(j){j=!1;b=hn?h>o?h:o:n>o?n:o;e=i>m?i>q?i:q:m>q?m:q}else{b=hn?h>o?h>d?h:d:o>d?o:d:n>o?n>d?n:d:o>d?o:d;e=i>m?i>q?i>e?i:e:q>e?q:e:m>q?m>e?m:e:q>e?q:e}a()};this.addRectangle=function(h){if(j){j=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=bh.getRight()? +THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a0&&s>0&&I+s<1}var c,d,e,f,g,j,h,i,p,n, +o,q=a.geometry,u=q.vertices,v=[];c=0;for(d=q.faces.length;ch?d:h;e=e>i?e:i}a()}; +this.add3Points=function(h,i,p,n,o,q){if(j){j=!1;b=hp?h>o?h:o:p>o?p:o;e=i>n?i>q?i:q:n>q?n:q}else{b=hp?h>o?h>d?h:d:o>d?o:d:p>o?p>d?p:d:o>d?o:d;e=i>n?i>q?i>e?i:e:q>e?q:e:n>q?n>e?n:e:q>e?q:e}a()};this.addRectangle=function(h){if(j){j=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=bh.getRight()? d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){j=!0;e=d=c=b=0;a()};this.isEmpty=function(){return j}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}}; -THREE.Matrix4=function(a,b,c,d,e,f,g,j,h,i,n,m,o,q,s,t){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,j||0,h||0,i||0,n||1,m||0,o||0,q||0,s||0,t||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,j,h,i,n,m,o,q,s,t){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=j;this.n31=h;this.n32=i;this.n33=n;this.n34=m;this.n41=o;this.n42=q;this.n43=s;this.n44=t;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1, +THREE.Matrix4=function(a,b,c,d,e,f,g,j,h,i,p,n,o,q,u,v){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,j||0,h||0,i||0,p||1,n||0,o||0,q||0,u||0,v||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,j,h,i,p,n,o,q,u,v){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=j;this.n31=h;this.n32=i;this.n33=p;this.n34=n;this.n41=o;this.n42=q;this.n43=u;this.n44=v;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1, e=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n14=a.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n24=a.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31* b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},crossVector:function(a){var b=new THREE.Vector4; -b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,n=a.n31,m=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,r=a.n43,k=a.n44,D=b.n11,C=b.n12,I=b.n13,F=b.n14,N=b.n21,A=b.n22,w=b.n23,J=b.n24,u=b.n31,K=b.n32,E=b.n33,y=b.n34;this.n11=c* -D+d*N+e*u;this.n12=c*C+d*A+e*K;this.n13=c*I+d*w+e*E;this.n14=c*F+d*J+e*y+f;this.n21=g*D+j*N+h*u;this.n22=g*C+j*A+h*K;this.n23=g*I+j*w+h*E;this.n24=g*F+j*J+h*y+i;this.n31=n*D+m*N+o*u;this.n32=n*C+m*A+o*K;this.n33=n*I+m*w+o*E;this.n34=n*F+m*J+o*y+q;this.n41=s*D+t*N+r*u;this.n42=s*C+t*A+r*K;this.n43=s*I+t*w+r*E;this.n44=s*F+t*J+r*y+k;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,g=a.n14,j=a.n21,h=a.n22,i=a.n23,n=a.n24,m=a.n31,o=a.n32,q=a.n33,s=a.n34,t=a.n41,r=a.n42,k=a.n43; -a=a.n44;var D=b.n11,C=b.n12,I=b.n13,F=b.n14,N=b.n21,A=b.n22,w=b.n23,J=b.n24,u=b.n31,K=b.n32,E=b.n33,y=b.n34,B=b.n41,T=b.n42,x=b.n43;b=b.n44;this.n11=d*D+e*N+f*u+g*B;this.n12=d*C+e*A+f*K+g*T;this.n13=d*I+e*w+f*E+g*x;this.n14=d*F+e*J+f*y+g*b;this.n21=j*D+h*N+i*u+n*B;this.n22=j*C+h*A+i*K+n*T;this.n23=j*I+h*w+i*E+n*x;this.n24=j*F+h*J+i*y+n*b;this.n31=m*D+o*N+q*u+s*B;this.n32=m*C+o*A+q*K+s*T;this.n33=m*I+o*w+q*E+s*x;this.n34=m*F+o*J+q*y+s*b;this.n41=t*D+r*N+k*u+a*B;this.n42=t*C+r*A+k*K+a*T;this.n43=t* -I+r*w+k*E+a*x;this.n44=t*F+r*J+k*y+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,g=this.n22,j=this.n23,h=this.n24,i=this.n31,n=this.n32,m=this.n33,o=this.n34,q=this.n41,s=this.n42,t=this.n43,r=this.n44,k=a.n11,D=a.n21, -C=a.n31,I=a.n12,F=a.n22,N=a.n32,A=a.n13,w=a.n23,J=a.n33,u=a.n14,K=a.n24;a=a.n34;this.n11=b*k+c*D+d*C;this.n12=b*I+c*F+d*N;this.n13=b*A+c*w+d*J;this.n14=b*u+c*K+d*a+e;this.n21=f*k+g*D+j*C;this.n22=f*I+g*F+j*N;this.n23=f*A+g*w+j*J;this.n24=f*u+g*K+j*a+h;this.n31=i*k+n*D+m*C;this.n32=i*I+n*F+m*N;this.n33=i*A+n*w+m*J;this.n34=i*u+n*K+m*a+o;this.n41=q*k+s*D+t*C;this.n42=q*I+s*F+t*N;this.n43=q*A+s*w+t*J;this.n44=q*u+s*K+t*a+r;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*= -a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,j=this.n24,h=this.n31,i=this.n32,n=this.n33,m=this.n34,o=this.n41,q=this.n42,s=this.n43,t=this.n44;return d*g*i*o-c*j*i*o-d*f*n*o+b*j*n*o+c*f*m*o-b*g*m*o-d*g*h*q+c*j*h*q+d*e*n*q-a*j*n*q-c*e*m*q+a*g*m*q+d*f*h*s-b*j*h*s-d*e*i*s+a*j*i*s+b*e* -m*s-a*f*m*s-c*f*h*t+b*g*h*t+c*e*i*t-a*g*i*t-b*e*n*t+a*f*n*t},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flattenToArray(this.flat);return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]= -this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0, -b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,j=a.z,h=e*f,i=e*g;this.set(h*f+c,h*g-d*j,h*j+d*g,0,h*g+d*j,i*g+c,i*j-d*f,0,h*j-d*g,i*j+d*f,e*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y; -this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,j=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=j*f+a*d;this.n22=-j*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,j=d+d;a=b*f;var h=b*g;b*=j;var i=c*g;c*=j;d*=j;f*=e;g*=e;e*=j;this.n11=1-(i+d);this.n12=h-e;this.n13= -b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+i)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d}; -THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c}; -THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,n=a.n31,m=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,r=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*q*t-i*o*t+i*m*r-j*q*r-h*m*k+j*o*k;b.n12=f*o*t-e*q*t-f*m*r+d*q*r+e*m*k-d*o*k;b.n13=e*i*t-f*h*t+f*j*r-d*i*r-e*j*k+d*h*k;b.n14=f*h*m-e*i*m-f*j*o+d*i*o+e*j*q-d*h*q;b.n21=i*o*s-h*q*s-i*n*r+g*q*r+h*n*k-g*o*k;b.n22=e*q*s-f*o*s+f*n*r-c*q*r-e*n*k+c*o*k;b.n23=f*h*s-e*i*s-f*g*r+c*i*r+e*g*k-c*h*k; -b.n24=e*i*n-f*h*n+f*g*o-c*i*o-e*g*q+c*h*q;b.n31=j*q*s-i*m*s+i*n*t-g*q*t-j*n*k+g*m*k;b.n32=f*m*s-d*q*s-f*n*t+c*q*t+d*n*k-c*m*k;b.n33=e*i*s-f*j*s+f*g*t-c*i*t-d*g*k+c*j*k;b.n34=f*j*n-d*i*n-f*g*m+c*i*m+d*g*q-c*j*q;b.n41=h*m*s-j*o*s-h*n*t+g*o*t+j*n*r-g*m*r;b.n42=d*o*s-e*m*s+e*n*t-c*o*t-d*n*r+c*m*r;b.n43=e*j*s-d*h*s-e*g*t+c*h*t+d*g*r-c*j*r;b.n44=d*h*n-e*j*n+e*g*m-c*h*m-d*g*o+c*j*o;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*j;c[5]=a*h;c[6]=a*i;c[7]=a*n;c[8]=a*m;return b}; +b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,p=a.n31,n=a.n32,o=a.n33,q=a.n34,u=a.n41,v=a.n42,s=a.n43,k=a.n44,G=b.n11,F=b.n12,K=b.n13,I=b.n14,S=b.n21,C=b.n22,A=b.n23,L=b.n24,y=b.n31,M=b.n32,D=b.n33,x=b.n34;this.n11=c* +G+d*S+e*y;this.n12=c*F+d*C+e*M;this.n13=c*K+d*A+e*D;this.n14=c*I+d*L+e*x+f;this.n21=g*G+j*S+h*y;this.n22=g*F+j*C+h*M;this.n23=g*K+j*A+h*D;this.n24=g*I+j*L+h*x+i;this.n31=p*G+n*S+o*y;this.n32=p*F+n*C+o*M;this.n33=p*K+n*A+o*D;this.n34=p*I+n*L+o*x+q;this.n41=u*G+v*S+s*y;this.n42=u*F+v*C+s*M;this.n43=u*K+v*A+s*D;this.n44=u*I+v*L+s*x+k;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42; +c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21, +f=this.n22,g=this.n23,j=this.n24,h=this.n31,i=this.n32,p=this.n33,n=this.n34,o=this.n41,q=this.n42,u=this.n43,v=this.n44;return d*g*i*o-c*j*i*o-d*f*p*o+b*j*p*o+c*f*n*o-b*g*n*o-d*g*h*q+c*j*h*q+d*e*p*q-a*j*p*q-c*e*n*q+a*g*n*q+d*f*h*u-b*j*h*u-d*e*i*u+a*j*i*u+b*e*n*u-a*f*n*u-c*f*h*v+b*g*h*v+c*e*i*v-a*g*i*v-b*e*p*v+a*f*p*v},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14= +a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]= +this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24; +a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this}, +setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,j=a.z,h=e*f,i=e*g;this.set(h*f+c,h*g-d*j,h*j+d*g,0,h*g+d*j,i*g+c,i*j-d*f,0,h*j-d*g, +i*j+d*f,e*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,j=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=j*f+a*d;this.n22=-j*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,j=d+d;a= +b*f;var h=b*g;b*=j;var i=c*g;c*=j;d*=j;f*=e;g*=e;e*=j;this.n11=1-(i+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+i)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/ +b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}}; +THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,p=a.n31,n=a.n32,o=a.n33,q=a.n34,u=a.n41,v=a.n42,s=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*q*v-i*o*v+i*n*s-j*q*s-h*n*k+j*o*k;b.n12=f*o*v-e*q*v-f*n*s+d*q*s+e*n*k-d*o*k;b.n13=e*i*v-f*h*v+f*j*s-d*i*s-e*j*k+d*h*k;b.n14=f*h*n-e*i*n-f*j*o+d*i*o+e*j*q-d*h*q;b.n21=i*o*u-h*q*u-i*p*s+g*q*s+h*p*k-g*o*k;b.n22=e*q*u-f*o*u+f*p*s-c*q*s-e*p*k+c*o*k;b.n23=f*h*u-e*i*u-f*g*s+c*i*s+e*g*k-c*h*k; +b.n24=e*i*p-f*h*p+f*g*o-c*i*o-e*g*q+c*h*q;b.n31=j*q*u-i*n*u+i*p*v-g*q*v-j*p*k+g*n*k;b.n32=f*n*u-d*q*u-f*p*v+c*q*v+d*p*k-c*n*k;b.n33=e*i*u-f*j*u+f*g*v-c*i*v-d*g*k+c*j*k;b.n34=f*j*p-d*i*p-f*g*n+c*i*n+d*g*q-c*j*q;b.n41=h*n*u-j*o*u-h*p*v+g*o*v+j*p*s-g*n*s;b.n42=d*o*u-e*n*u+e*p*v-c*o*v-d*p*s+c*n*s;b.n43=e*j*u-d*h*u-e*g*v+c*h*v+d*g*s-c*j*s;b.n44=d*h*p-e*j*p+e*g*n-c*h*n-d*g*o+c*j*o;b.multiplyScalar(1/a.determinant());return b}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,p=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*j;c[5]=a*h;c[6]=a*i;c[7]=a*p;c[8]=a*n;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)}; THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,j,h,i;g=new THREE.Matrix4;j=b-a;h=c-d;i=f-e;g.n11=2/j;g.n12=0;g.n13=0;g.n14=-((b+a)/j);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/i;g.n34=-((f+e)/i);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1; this.visible=!0}; -THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation); -if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var d=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21= -this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*d;this.matrixRotationWorld.n23=this.matrixWorld.n23*d;this.matrixRotationWorld.n33=this.matrixWorld.n33*d;this.matrixNeedsUpdate=!1;b=!0}a=0;for(d=this.children.length;a=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),g=Math.sqrt(1-e*e);if(Math.abs(g)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*f)/g;d=Math.sin(d*f)/g;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c}; 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=!0}; THREE.Face3=function(a,b,c,d,e){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]}; @@ -57,10 +54,10 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.f c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,f,g,j=new THREE.Vector3,h=new THREE.Vector3;d=0;for(e=this.vertices.length;d0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], +this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b=0&&E>=0&&y>=0&&B>=0)return!0;else if(K<0&&E<0||y<0&&B<0)return!1;else{if(K<0)J=Math.max(J,K/(K-E));else E<0&&(u=Math.min(u,K/(K-E)));if(y<0)J=Math.max(J,y/(y-B));else B<0&&(u=Math.min(u,y/(y-B)));if(uK&&x.z0&&r.z<1){o=s[q]=s[q]||new THREE.RenderableParticle;o.x=r.x/r.w;o.y=r.y/r.w;o.z=r.z;o.rotation=L.rotation.z;o.scale.x=L.scale.x*Math.abs(o.x-(r.x+w.projectionMatrix.n11)/(r.w+w.projectionMatrix.n14)); -o.scale.y=L.scale.y*Math.abs(o.y-(r.y+w.projectionMatrix.n22)/(r.w+w.projectionMatrix.n24));o.materials=L.materials;u.push(o);q++}}}}J&&u.sort(a);return u};this.unprojectVector=function(A,w){var J=w.matrixWorld.clone();J.multiplySelf(THREE.Matrix4.makeInvert(w.projectionMatrix));J.multiplyVector3(A);return A}}; -THREE.CanvasRenderer=function(){function a(V){if(o!=V)i.globalAlpha=o=V}function b(V){if(q!=V){switch(V){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}q=V}}var c=null,d=new THREE.Projector,e=document.createElement("canvas"),f,g,j,h,i=e.getContext("2d"),n=new THREE.Color(0),m=0,o=1,q=0,s=null,t=null,r=1,k,D,C,I,F,N,A,w,J,u=new THREE.Color, -K=new THREE.Color,E=new THREE.Color,y=new THREE.Color,B=new THREE.Color,T,x,P,Y,L,ja,ka,la,ma,$=new THREE.Rectangle,O=new THREE.Rectangle,H=new THREE.Rectangle,U=!1,Q=new THREE.Color,aa=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,La=Math.PI*2,R=new THREE.Vector3,ra,sa,Ca,ba,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);ba=Ca.data;ta=document.createElement("canvas"); -ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(V,da){f=V;g=da;j=f/2;h=g/2;e.width=f;e.height=g;$.set(-j,-h,j,h);o=1;q=0;t=s=null;r=1};this.setClearColor=function(V,da){n=V;m=da};this.setClearColorHex=function(V,da){n.setHex(V);m=da};this.clear=function(){i.setTransform(1,0,0,-1,j,h);if(!O.isEmpty()){O.inflate(1);O.minSelf($);if(n.hex==0&&m==0)i.clearRect(O.getX(), -O.getY(),O.getWidth(),O.getHeight());else{b(THREE.NormalBlending);a(1);i.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+m+")";i.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(V,da){function Ma(l){var G,z,p,v=l.lights;aa.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);l=0;for(G=v.length;l0){p.r+=W.r*M;p.g+=W.g*M;p.b+=W.b*M}}else if(M instanceof THREE.PointLight){R.sub(M.position,G);R.normalize();M=z.dot(R)*X;if(M>0){p.r+=W.r*M;p.g+=W.g*M;p.b+=W.b*M}}}}function Na(l,G,z){if(z.opacity!=0){a(z.opacity);b(z.blending);var p, -v,M,W,X,Z;if(z instanceof THREE.ParticleBasicMaterial){if(z.map){W=z.map.image;X=W.width>>1;Z=W.height>>1;v=G.scale.x*j;M=G.scale.y*h;z=v*X;p=M*Z;H.set(l.x-z,l.y-p,l.x+z,l.y+p);if($.instersects(H)){i.save();i.translate(l.x,l.y);i.rotate(-G.rotation);i.scale(v,-M);i.translate(-X,-Z);i.drawImage(W,0,0);i.restore()}}}else if(z instanceof THREE.ParticleCircleMaterial){if(U){Q.r=aa.r+na.r+oa.r;Q.g=aa.g+na.g+oa.g;Q.b=aa.b+na.b+oa.b;u.r=z.color.r*Q.r;u.g=z.color.g*Q.g;u.b=z.color.b*Q.b;u.updateStyleString()}else u.__styleString= -z.color.__styleString;z=G.scale.x*j;p=G.scale.y*h;H.set(l.x-z,l.y-p,l.x+z,l.y+p);if($.instersects(H)){v=u.__styleString;if(t!=v)i.fillStyle=t=v;i.save();i.translate(l.x,l.y);i.rotate(-G.rotation);i.scale(z,p);i.beginPath();i.arc(0,0,1,0,La,!0);i.closePath();i.fill();i.restore()}}}}function Oa(l,G,z,p){if(p.opacity!=0){a(p.opacity);b(p.blending);i.beginPath();i.moveTo(l.positionScreen.x,l.positionScreen.y);i.lineTo(G.positionScreen.x,G.positionScreen.y);i.closePath();if(p instanceof THREE.LineBasicMaterial){u.__styleString= -p.color.__styleString;l=p.linewidth;if(r!=l)i.lineWidth=r=l;l=u.__styleString;if(s!=l)i.strokeStyle=s=l;i.stroke();H.inflate(p.linewidth*2)}}}function Ha(l,G,z,p,v,M){if(v.opacity!=0){a(v.opacity);b(v.blending);I=l.positionScreen.x;F=l.positionScreen.y;N=G.positionScreen.x;A=G.positionScreen.y;w=z.positionScreen.x;J=z.positionScreen.y;i.beginPath();i.moveTo(I,F);i.lineTo(N,A);i.lineTo(w,J);i.lineTo(I,F);i.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map)v.map.mapping instanceof THREE.UVMapping&& -ua(I,F,N,A,w,J,v.map.image,p.uvs[0].u,p.uvs[0].v,p.uvs[1].u,p.uvs[1].v,p.uvs[2].u,p.uvs[2].v);else if(v.envMap){if(v.envMap.mapping instanceof THREE.SphericalReflectionMapping){l=da.matrixWorldInverse;R.copy(p.vertexNormalsWorld[0]);Y=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;L=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[1]);ja=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;ka=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[2]);la=(R.x*l.n11+R.y*l.n12+R.z*l.n13)* -0.5+0.5;ma=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;ua(I,F,N,A,w,J,v.envMap.image,Y,L,ja,ka,la,ma)}}else v.wireframe?za(v.color.__styleString,v.wireframeLinewidth):Aa(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){v.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,A,w,J,v.map.image,p.uvs[0].u,p.uvs[0].v,p.uvs[1].u,p.uvs[1].v,p.uvs[2].u,p.uvs[2].v);b(THREE.SubtractiveBlending)}if(U)if(!v.wireframe&&v.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length== -3){K.r=E.r=y.r=aa.r;K.g=E.g=y.g=aa.g;K.b=E.b=y.b=aa.b;ya(M,p.v1.positionWorld,p.vertexNormalsWorld[0],K);ya(M,p.v2.positionWorld,p.vertexNormalsWorld[1],E);ya(M,p.v3.positionWorld,p.vertexNormalsWorld[2],y);B.r=(E.r+y.r)*0.5;B.g=(E.g+y.g)*0.5;B.b=(E.b+y.b)*0.5;P=Ia(K,E,y,B);ua(I,F,N,A,w,J,P,0,0,1,0,0,1)}else{Q.r=aa.r;Q.g=aa.g;Q.b=aa.b;ya(M,p.centroidWorld,p.normalWorld,Q);u.r=v.color.r*Q.r;u.g=v.color.g*Q.g;u.b=v.color.b*Q.b;u.updateStyleString();v.wireframe?za(u.__styleString,v.wireframeLinewidth): -Aa(u.__styleString)}else v.wireframe?za(v.color.__styleString,v.wireframeLinewidth):Aa(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){T=da.near;x=da.far;K.r=K.g=K.b=1-Da(l.positionScreen.z,T,x);E.r=E.g=E.b=1-Da(G.positionScreen.z,T,x);y.r=y.g=y.b=1-Da(z.positionScreen.z,T,x);B.r=(E.r+y.r)*0.5;B.g=(E.g+y.g)*0.5;B.b=(E.b+y.b)*0.5;P=Ia(K,E,y,B);ua(I,F,N,A,w,J,P,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){u.r=Ea(p.normalWorld.x);u.g=Ea(p.normalWorld.y);u.b=Ea(p.normalWorld.z); -u.updateStyleString();v.wireframe?za(u.__styleString,v.wireframeLinewidth):Aa(u.__styleString)}}}function za(l,G){if(s!=l)i.strokeStyle=s=l;if(r!=G)i.lineWidth=r=G;i.stroke();H.inflate(G*2)}function Aa(l){if(t!=l)i.fillStyle=t=l;i.fill()}function ua(l,G,z,p,v,M,W,X,Z,ga,ca,ha,va){var ea,ia;ea=W.width-1;ia=W.height-1;X*=ea;Z*=ia;ga*=ea;ca*=ia;ha*=ea;va*=ia;z-=l;p-=G;v-=l;M-=G;ga-=X;ca-=Z;ha-=X;va-=Z;ea=ga*va-ha*ca;if(ea!=0){ia=1/ea;ea=(va*z-ca*v)*ia;ca=(va*p-ca*M)*ia;z=(ga*v-ha*z)*ia;p=(ga*M-ha*p)* -ia;l=l-ea*X-z*Z;G=G-ca*X-p*Z;i.save();i.transform(ea,ca,z,p,l,G);i.clip();i.drawImage(W,0,0);i.restore()}}function Ia(l,G,z,p){var v=~~(l.r*255),M=~~(l.g*255);l=~~(l.b*255);var W=~~(G.r*255),X=~~(G.g*255);G=~~(G.b*255);var Z=~~(z.r*255),ga=~~(z.g*255);z=~~(z.b*255);var ca=~~(p.r*255),ha=~~(p.g*255);p=~~(p.b*255);ba[0]=v<0?0:v>255?255:v;ba[1]=M<0?0:M>255?255:M;ba[2]=l<0?0:l>255?255:l;ba[4]=W<0?0:W>255?255:W;ba[5]=X<0?0:X>255?255:X;ba[6]=G<0?0:G>255?255:G;ba[8]=Z<0?0:Z>255?255:Z;ba[9]=ga<0?0:ga>255? -255:ga;ba[10]=z<0?0:z>255?255:z;ba[12]=ca<0?0:ca>255?255:ca;ba[13]=ha<0?0:ha>255?255:ha;ba[14]=p<0?0:p>255?255:p;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(l,G,z){l=(l-G)/(z-G);return l*l*(3-2*l)}function Ea(l){l=(l+1)*0.5;return l<0?0:l>1?1:l}function Fa(l,G){var z=G.x-l.x,p=G.y-l.y,v=1/Math.sqrt(z*z+p*p);z*=v;p*=v;G.x+=z;G.y+=p;l.x-=z;l.y-=p}var Ba,Ja,S,fa,qa,Ga,Ka,wa;this.autoClear?this.clear():i.setTransform(1,0,0,-1,j,h);c=d.projectScene(V,da,this.sortElements);(U=V.lights.length> -0)&&Ma(V);Ba=0;for(Ja=c.length;Ba=0&&D>=0&&x>=0&&z>=0)return!0;else if(M<0&&D<0||x<0&&z<0)return!1;else{if(M<0)L=Math.max(L,M/(M-D));else D<0&&(y=Math.min(y,M/(M-D)));if(x<0)L=Math.max(L,x/(x-z));else z<0&&(y=Math.min(y,x/(x-z)));if(yM&&w.z0&&s.z<1){o=u[q]=u[q]||new THREE.RenderableParticle;o.x=s.x/s.w;o.y=s.y/s.w;o.z=s.z;o.rotation=H.rotation.z;o.scale.x=H.scale.x*Math.abs(o.x-(s.x+A.projectionMatrix.n11)/(s.w+A.projectionMatrix.n14)); +o.scale.y=H.scale.y*Math.abs(o.y-(s.y+A.projectionMatrix.n22)/(s.w+A.projectionMatrix.n24));o.materials=H.materials;y.push(o);q++}}}}L&&y.sort(a);return y};this.unprojectVector=function(C,A){var L=A.matrixWorld.clone();L.multiplySelf(THREE.Matrix4.makeInvert(A.projectionMatrix));L.multiplyVector3(C);return C}}; +THREE.CanvasRenderer=function(){function a(U){if(o!=U)i.globalAlpha=o=U}function b(U){if(q!=U){switch(U){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}q=U}}var c=null,d=new THREE.Projector,e=document.createElement("canvas"),f,g,j,h,i=e.getContext("2d"),p=new THREE.Color(0),n=0,o=1,q=0,u=null,v=null,s=1,k,G,F,K,I,S,C,A,L,y=new THREE.Color, +M=new THREE.Color,D=new THREE.Color,x=new THREE.Color,z=new THREE.Color,W,w,O,Y,H,ja,ka,la,ma,$=new THREE.Rectangle,N=new THREE.Rectangle,E=new THREE.Rectangle,T=!1,P=new THREE.Color,aa=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,La=Math.PI*2,Q=new THREE.Vector3,ra,sa,Ca,ba,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);ba=Ca.data;ta=document.createElement("canvas"); +ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(U,da){f=U;g=da;j=f/2;h=g/2;e.width=f;e.height=g;$.set(-j,-h,j,h);o=1;q=0;v=u=null;s=1};this.setClearColor=function(U,da){p=U;n=da};this.setClearColorHex=function(U,da){p.setHex(U);n=da};this.clear=function(){i.setTransform(1,0,0,-1,j,h);if(!N.isEmpty()){N.inflate(1);N.minSelf($);if(p.hex==0&&n==0)i.clearRect(N.getX(), +N.getY(),N.getWidth(),N.getHeight());else{b(THREE.NormalBlending);a(1);i.fillStyle="rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b*255)+","+n+")";i.fillRect(N.getX(),N.getY(),N.getWidth(),N.getHeight())}N.empty()}};this.render=function(U,da){function Ma(l){var B,t,m,r=l.lights;aa.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);l=0;for(B=r.length;l0){m.r+=V.r*J;m.g+=V.g*J;m.b+=V.b*J}}else if(J instanceof THREE.PointLight){Q.sub(J.position,B);Q.normalize();J=t.dot(Q)*X;if(J>0){m.r+=V.r*J;m.g+=V.g*J;m.b+=V.b*J}}}}function Na(l,B,t){if(t.opacity!=0){a(t.opacity);b(t.blending);var m, +r,J,V,X,Z;if(t instanceof THREE.ParticleBasicMaterial){if(t.map){V=t.map.image;X=V.width>>1;Z=V.height>>1;r=B.scale.x*j;J=B.scale.y*h;t=r*X;m=J*Z;E.set(l.x-t,l.y-m,l.x+t,l.y+m);if($.instersects(E)){i.save();i.translate(l.x,l.y);i.rotate(-B.rotation);i.scale(r,-J);i.translate(-X,-Z);i.drawImage(V,0,0);i.restore()}}}else if(t instanceof THREE.ParticleCircleMaterial){if(T){P.r=aa.r+na.r+oa.r;P.g=aa.g+na.g+oa.g;P.b=aa.b+na.b+oa.b;y.r=t.color.r*P.r;y.g=t.color.g*P.g;y.b=t.color.b*P.b;y.updateStyleString()}else y.__styleString= +t.color.__styleString;t=B.scale.x*j;m=B.scale.y*h;E.set(l.x-t,l.y-m,l.x+t,l.y+m);if($.instersects(E)){r=y.__styleString;if(v!=r)i.fillStyle=v=r;i.save();i.translate(l.x,l.y);i.rotate(-B.rotation);i.scale(t,m);i.beginPath();i.arc(0,0,1,0,La,!0);i.closePath();i.fill();i.restore()}}}}function Oa(l,B,t,m){if(m.opacity!=0){a(m.opacity);b(m.blending);i.beginPath();i.moveTo(l.positionScreen.x,l.positionScreen.y);i.lineTo(B.positionScreen.x,B.positionScreen.y);i.closePath();if(m instanceof THREE.LineBasicMaterial){y.__styleString= +m.color.__styleString;l=m.linewidth;if(s!=l)i.lineWidth=s=l;l=y.__styleString;if(u!=l)i.strokeStyle=u=l;i.stroke();E.inflate(m.linewidth*2)}}}function Ha(l,B,t,m,r,J){if(r.opacity!=0){a(r.opacity);b(r.blending);K=l.positionScreen.x;I=l.positionScreen.y;S=B.positionScreen.x;C=B.positionScreen.y;A=t.positionScreen.x;L=t.positionScreen.y;i.beginPath();i.moveTo(K,I);i.lineTo(S,C);i.lineTo(A,L);i.lineTo(K,I);i.closePath();if(r instanceof THREE.MeshBasicMaterial)if(r.map)r.map.mapping instanceof THREE.UVMapping&& +ua(K,I,S,C,A,L,r.map.image,m.uvs[0].u,m.uvs[0].v,m.uvs[1].u,m.uvs[1].v,m.uvs[2].u,m.uvs[2].v);else if(r.envMap){if(r.envMap.mapping instanceof THREE.SphericalReflectionMapping){l=da.matrixWorldInverse;Q.copy(m.vertexNormalsWorld[0]);Y=(Q.x*l.n11+Q.y*l.n12+Q.z*l.n13)*0.5+0.5;H=-(Q.x*l.n21+Q.y*l.n22+Q.z*l.n23)*0.5+0.5;Q.copy(m.vertexNormalsWorld[1]);ja=(Q.x*l.n11+Q.y*l.n12+Q.z*l.n13)*0.5+0.5;ka=-(Q.x*l.n21+Q.y*l.n22+Q.z*l.n23)*0.5+0.5;Q.copy(m.vertexNormalsWorld[2]);la=(Q.x*l.n11+Q.y*l.n12+Q.z*l.n13)* +0.5+0.5;ma=-(Q.x*l.n21+Q.y*l.n22+Q.z*l.n23)*0.5+0.5;ua(K,I,S,C,A,L,r.envMap.image,Y,H,ja,ka,la,ma)}}else r.wireframe?za(r.color.__styleString,r.wireframeLinewidth):Aa(r.color.__styleString);else if(r instanceof THREE.MeshLambertMaterial){if(r.map&&!r.wireframe){r.map.mapping instanceof THREE.UVMapping&&ua(K,I,S,C,A,L,r.map.image,m.uvs[0].u,m.uvs[0].v,m.uvs[1].u,m.uvs[1].v,m.uvs[2].u,m.uvs[2].v);b(THREE.SubtractiveBlending)}if(T)if(!r.wireframe&&r.shading==THREE.SmoothShading&&m.vertexNormalsWorld.length== +3){M.r=D.r=x.r=aa.r;M.g=D.g=x.g=aa.g;M.b=D.b=x.b=aa.b;ya(J,m.v1.positionWorld,m.vertexNormalsWorld[0],M);ya(J,m.v2.positionWorld,m.vertexNormalsWorld[1],D);ya(J,m.v3.positionWorld,m.vertexNormalsWorld[2],x);z.r=(D.r+x.r)*0.5;z.g=(D.g+x.g)*0.5;z.b=(D.b+x.b)*0.5;O=Ia(M,D,x,z);ua(K,I,S,C,A,L,O,0,0,1,0,0,1)}else{P.r=aa.r;P.g=aa.g;P.b=aa.b;ya(J,m.centroidWorld,m.normalWorld,P);y.r=r.color.r*P.r;y.g=r.color.g*P.g;y.b=r.color.b*P.b;y.updateStyleString();r.wireframe?za(y.__styleString,r.wireframeLinewidth): +Aa(y.__styleString)}else r.wireframe?za(r.color.__styleString,r.wireframeLinewidth):Aa(r.color.__styleString)}else if(r instanceof THREE.MeshDepthMaterial){W=da.near;w=da.far;M.r=M.g=M.b=1-Da(l.positionScreen.z,W,w);D.r=D.g=D.b=1-Da(B.positionScreen.z,W,w);x.r=x.g=x.b=1-Da(t.positionScreen.z,W,w);z.r=(D.r+x.r)*0.5;z.g=(D.g+x.g)*0.5;z.b=(D.b+x.b)*0.5;O=Ia(M,D,x,z);ua(K,I,S,C,A,L,O,0,0,1,0,0,1)}else if(r instanceof THREE.MeshNormalMaterial){y.r=Ea(m.normalWorld.x);y.g=Ea(m.normalWorld.y);y.b=Ea(m.normalWorld.z); +y.updateStyleString();r.wireframe?za(y.__styleString,r.wireframeLinewidth):Aa(y.__styleString)}}}function za(l,B){if(u!=l)i.strokeStyle=u=l;if(s!=B)i.lineWidth=s=B;i.stroke();E.inflate(B*2)}function Aa(l){if(v!=l)i.fillStyle=v=l;i.fill()}function ua(l,B,t,m,r,J,V,X,Z,ga,ca,ha,va){var ea,ia;ea=V.width-1;ia=V.height-1;X*=ea;Z*=ia;ga*=ea;ca*=ia;ha*=ea;va*=ia;t-=l;m-=B;r-=l;J-=B;ga-=X;ca-=Z;ha-=X;va-=Z;ea=ga*va-ha*ca;if(ea!=0){ia=1/ea;ea=(va*t-ca*r)*ia;ca=(va*m-ca*J)*ia;t=(ga*r-ha*t)*ia;m=(ga*J-ha*m)* +ia;l=l-ea*X-t*Z;B=B-ca*X-m*Z;i.save();i.transform(ea,ca,t,m,l,B);i.clip();i.drawImage(V,0,0);i.restore()}}function Ia(l,B,t,m){var r=~~(l.r*255),J=~~(l.g*255);l=~~(l.b*255);var V=~~(B.r*255),X=~~(B.g*255);B=~~(B.b*255);var Z=~~(t.r*255),ga=~~(t.g*255);t=~~(t.b*255);var ca=~~(m.r*255),ha=~~(m.g*255);m=~~(m.b*255);ba[0]=r<0?0:r>255?255:r;ba[1]=J<0?0:J>255?255:J;ba[2]=l<0?0:l>255?255:l;ba[4]=V<0?0:V>255?255:V;ba[5]=X<0?0:X>255?255:X;ba[6]=B<0?0:B>255?255:B;ba[8]=Z<0?0:Z>255?255:Z;ba[9]=ga<0?0:ga>255? +255:ga;ba[10]=t<0?0:t>255?255:t;ba[12]=ca<0?0:ca>255?255:ca;ba[13]=ha<0?0:ha>255?255:ha;ba[14]=m<0?0:m>255?255:m;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(l,B,t){l=(l-B)/(t-B);return l*l*(3-2*l)}function Ea(l){l=(l+1)*0.5;return l<0?0:l>1?1:l}function Fa(l,B){var t=B.x-l.x,m=B.y-l.y,r=1/Math.sqrt(t*t+m*m);t*=r;m*=r;B.x+=t;B.y+=m;l.x-=t;l.y-=m}var Ba,Ja,R,fa,qa,Ga,Ka,wa;this.autoClear?this.clear():i.setTransform(1,0,0,-1,j,h);c=d.projectScene(U,da,this.sortElements);(T=U.lights.length> +0)&&Ma(U);Ba=0;for(Ja=c.length;Ba0?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)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)}; +this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},setRotationFromMatrix:function(){},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)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)}; THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a0&&r>0&&G+r<1}var c,d,e,f,g,i,h,j,n,l, -m,o=a.geometry,p=o.vertices,q=[];c=0;for(d=o.faces.length;ch?d:h;e=e>j?e:j}a()}; -this.add3Points=function(h,j,n,l,m,o){if(i){i=!1;b=hn?h>m?h:m:n>m?n:m;e=j>l?j>o?j:o:l>o?l:o}else{b=hn?h>m?h>d?h:d:m>d?m:d:n>m?n>d?n:d:m>d?m:d;e=j>l?j>o?j>e?j:e:o>e?o:e:l>o?l>e?l:e:o>e?o:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=bh.getRight()? +THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a0&&p>0&&H+p<1}var c,d,e,f,g,i,h,j,n,m, +l,o=a.geometry,q=o.vertices,r=[];c=0;for(d=o.faces.length;ch?d:h;e=e>j?e:j}a()}; +this.add3Points=function(h,j,n,m,l,o){if(i){i=!1;b=hn?h>l?h:l:n>l?n:l;e=j>m?j>o?j:o:m>o?m:o}else{b=hn?h>l?h>d?h:d:l>d?l:d:n>l?n>d?n:d:l>d?l:d;e=j>m?j>o?j>e?j:e:o>e?o:e:m>o?m>e?m:e:o>e?o:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=bh.getRight()? d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}}; -THREE.Matrix4=function(a,b,c,d,e,f,g,i,h,j,n,l,m,o,p,q){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,j||0,n||1,l||0,m||0,o||0,p||0,q||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,j,n,l,m,o,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=j;this.n33=n;this.n34=l;this.n41=m;this.n42=o;this.n43=p;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1, +THREE.Matrix4=function(a,b,c,d,e,f,g,i,h,j,n,m,l,o,q,r){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,j||0,n||1,m||0,l||0,o||0,q||0,r||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,j,n,m,l,o,q,r){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=j;this.n33=n;this.n34=m;this.n41=l;this.n42=o;this.n43=q;this.n44=r;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1, e=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n14=a.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n24=a.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31* b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},crossVector:function(a){var b=new THREE.Vector4; -b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,n=a.n31,l=a.n32,m=a.n33,o=a.n34,p=a.n41,q=a.n42,r=a.n43,k=a.n44,B=b.n11,w=b.n12,F=b.n13,G=b.n14,I=b.n21,v=b.n22,t=b.n23,C=b.n24,z=b.n31,D=b.n32,E=b.n33,x=b.n34;this.n11=c* -B+d*I+e*z;this.n12=c*w+d*v+e*D;this.n13=c*F+d*t+e*E;this.n14=c*G+d*C+e*x+f;this.n21=g*B+i*I+h*z;this.n22=g*w+i*v+h*D;this.n23=g*F+i*t+h*E;this.n24=g*G+i*C+h*x+j;this.n31=n*B+l*I+m*z;this.n32=n*w+l*v+m*D;this.n33=n*F+l*t+m*E;this.n34=n*G+l*C+m*x+o;this.n41=p*B+q*I+r*z;this.n42=p*w+q*v+r*D;this.n43=p*F+q*t+r*E;this.n44=p*G+q*C+r*x+k;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,g=a.n14,i=a.n21,h=a.n22,j=a.n23,n=a.n24,l=a.n31,m=a.n32,o=a.n33,p=a.n34,q=a.n41,r=a.n42,k=a.n43; -a=a.n44;var B=b.n11,w=b.n12,F=b.n13,G=b.n14,I=b.n21,v=b.n22,t=b.n23,C=b.n24,z=b.n31,D=b.n32,E=b.n33,x=b.n34,u=b.n41,L=b.n42,s=b.n43;b=b.n44;this.n11=d*B+e*I+f*z+g*u;this.n12=d*w+e*v+f*D+g*L;this.n13=d*F+e*t+f*E+g*s;this.n14=d*G+e*C+f*x+g*b;this.n21=i*B+h*I+j*z+n*u;this.n22=i*w+h*v+j*D+n*L;this.n23=i*F+h*t+j*E+n*s;this.n24=i*G+h*C+j*x+n*b;this.n31=l*B+m*I+o*z+p*u;this.n32=l*w+m*v+o*D+p*L;this.n33=l*F+m*t+o*E+p*s;this.n34=l*G+m*C+o*x+p*b;this.n41=q*B+r*I+k*z+a*u;this.n42=q*w+r*v+k*D+a*L;this.n43=q* -F+r*t+k*E+a*s;this.n44=q*G+r*C+k*x+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,g=this.n22,i=this.n23,h=this.n24,j=this.n31,n=this.n32,l=this.n33,m=this.n34,o=this.n41,p=this.n42,q=this.n43,r=this.n44,k=a.n11,B=a.n21, -w=a.n31,F=a.n12,G=a.n22,I=a.n32,v=a.n13,t=a.n23,C=a.n33,z=a.n14,D=a.n24;a=a.n34;this.n11=b*k+c*B+d*w;this.n12=b*F+c*G+d*I;this.n13=b*v+c*t+d*C;this.n14=b*z+c*D+d*a+e;this.n21=f*k+g*B+i*w;this.n22=f*F+g*G+i*I;this.n23=f*v+g*t+i*C;this.n24=f*z+g*D+i*a+h;this.n31=j*k+n*B+l*w;this.n32=j*F+n*G+l*I;this.n33=j*v+n*t+l*C;this.n34=j*z+n*D+l*a+m;this.n41=o*k+p*B+q*w;this.n42=o*F+p*G+q*I;this.n43=o*v+p*t+q*C;this.n44=o*z+p*D+q*a+r;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*= -a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,j=this.n32,n=this.n33,l=this.n34,m=this.n41,o=this.n42,p=this.n43,q=this.n44;return d*g*j*m-c*i*j*m-d*f*n*m+b*i*n*m+c*f*l*m-b*g*l*m-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*l*o+a*g*l*o+d*f*h*p-b*i*h*p-d*e*j*p+a*i*j*p+b*e* -l*p-a*f*l*p-c*f*h*q+b*g*h*q+c*e*j*q-a*g*j*q-b*e*n*q+a*f*n*q},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flattenToArray(this.flat);return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]= -this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0, -b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,j=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,j*g+c,j*i-d*f,0,h*i-d*g,j*i+d*f,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y; -this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var j=c*g;c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(j+d);this.n12=h-e;this.n13= -b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+j)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d}; -THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c}; -THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,n=a.n31,l=a.n32,m=a.n33,o=a.n34,p=a.n41,q=a.n42,r=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*q-j*m*q+j*l*r-i*o*r-h*l*k+i*m*k;b.n12=f*m*q-e*o*q-f*l*r+d*o*r+e*l*k-d*m*k;b.n13=e*j*q-f*h*q+f*i*r-d*j*r-e*i*k+d*h*k;b.n14=f*h*l-e*j*l-f*i*m+d*j*m+e*i*o-d*h*o;b.n21=j*m*p-h*o*p-j*n*r+g*o*r+h*n*k-g*m*k;b.n22=e*o*p-f*m*p+f*n*r-c*o*r-e*n*k+c*m*k;b.n23=f*h*p-e*j*p-f*g*r+c*j*r+e*g*k-c*h*k; -b.n24=e*j*n-f*h*n+f*g*m-c*j*m-e*g*o+c*h*o;b.n31=i*o*p-j*l*p+j*n*q-g*o*q-i*n*k+g*l*k;b.n32=f*l*p-d*o*p-f*n*q+c*o*q+d*n*k-c*l*k;b.n33=e*j*p-f*i*p+f*g*q-c*j*q-d*g*k+c*i*k;b.n34=f*i*n-d*j*n-f*g*l+c*j*l+d*g*o-c*i*o;b.n41=h*l*p-i*m*p-h*n*q+g*m*q+i*n*r-g*l*r;b.n42=d*m*p-e*l*p+e*n*q-c*m*q-d*n*r+c*l*r;b.n43=e*i*p-d*h*p-e*g*q+c*h*q+d*g*r-c*i*r;b.n44=d*h*n-e*i*n+e*g*l-c*h*l-d*g*m+c*i*m;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,l=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*n;c[8]=a*l;return b}; +b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,r=a.n42,p=a.n43,k=a.n44,D=b.n11,z=b.n12,G=b.n13,H=b.n14,M=b.n21,x=b.n22,v=b.n23,E=b.n24,B=b.n31,F=b.n32,A=b.n33,w=b.n34;this.n11=c* +D+d*M+e*B;this.n12=c*z+d*x+e*F;this.n13=c*G+d*v+e*A;this.n14=c*H+d*E+e*w+f;this.n21=g*D+i*M+h*B;this.n22=g*z+i*x+h*F;this.n23=g*G+i*v+h*A;this.n24=g*H+i*E+h*w+j;this.n31=n*D+m*M+l*B;this.n32=n*z+m*x+l*F;this.n33=n*G+m*v+l*A;this.n34=n*H+m*E+l*w+o;this.n41=q*D+r*M+p*B;this.n42=q*z+r*x+p*F;this.n43=q*G+r*v+p*A;this.n44=q*H+r*E+p*w+k;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42; +c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21, +f=this.n22,g=this.n23,i=this.n24,h=this.n31,j=this.n32,n=this.n33,m=this.n34,l=this.n41,o=this.n42,q=this.n43,r=this.n44;return d*g*j*l-c*i*j*l-d*f*n*l+b*i*n*l+c*f*m*l-b*g*m*l-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+d*f*h*q-b*i*h*q-d*e*j*q+a*i*j*q+b*e*m*q-a*f*m*q-c*f*h*r+b*g*h*r+c*e*j*r-a*g*j*r-b*e*n*r+a*f*n*r},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14= +a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]= +this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24; +a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this}, +setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,j=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,j*g+c,j*i-d*f,0,h*i-d*g, +j*i+d*f,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a= +b*f;var h=b*g;b*=i;var j=c*g;c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(j+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+j)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/ +b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}}; +THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,j=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,r=a.n42,p=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*r-j*l*r+j*m*p-i*o*p-h*m*k+i*l*k;b.n12=f*l*r-e*o*r-f*m*p+d*o*p+e*m*k-d*l*k;b.n13=e*j*r-f*h*r+f*i*p-d*j*p-e*i*k+d*h*k;b.n14=f*h*m-e*j*m-f*i*l+d*j*l+e*i*o-d*h*o;b.n21=j*l*q-h*o*q-j*n*p+g*o*p+h*n*k-g*l*k;b.n22=e*o*q-f*l*q+f*n*p-c*o*p-e*n*k+c*l*k;b.n23=f*h*q-e*j*q-f*g*p+c*j*p+e*g*k-c*h*k; +b.n24=e*j*n-f*h*n+f*g*l-c*j*l-e*g*o+c*h*o;b.n31=i*o*q-j*m*q+j*n*r-g*o*r-i*n*k+g*m*k;b.n32=f*m*q-d*o*q-f*n*r+c*o*r+d*n*k-c*m*k;b.n33=e*j*q-f*i*q+f*g*r-c*j*r-d*g*k+c*i*k;b.n34=f*i*n-d*j*n-f*g*m+c*j*m+d*g*o-c*i*o;b.n41=h*m*q-i*l*q-h*n*r+g*l*r+i*n*p-g*m*p;b.n42=d*l*q-e*m*q+e*n*r-c*l*r-d*n*p+c*m*p;b.n43=e*i*q-d*h*q-e*g*r+c*h*r+d*g*p-c*i*p;b.n44=d*h*n-e*i*n+e*g*m-c*h*m-d*g*l+c*i*l;b.multiplyScalar(1/a.determinant());return b}; +THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,j=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*j;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*j;c[7]=a*n;c[8]=a*m;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)}; THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,i,h,j;g=new THREE.Matrix4;i=b-a;h=c-d;j=f-e;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/j;g.n34=-((f+e)/j);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1; this.visible=!0}; -THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation); -if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var d=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21= -this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*d;this.matrixRotationWorld.n23=this.matrixWorld.n23*d;this.matrixRotationWorld.n33=this.matrixWorld.n33*d;this.matrixNeedsUpdate=!1;b=!0}a=0;for(d=this.children.length;a=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),g=Math.sqrt(1-e*e);if(Math.abs(g)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*f)/g;d=Math.sin(d*f)/g;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c}; 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=!0}; THREE.Face3=function(a,b,c,d,e){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]}; @@ -69,19 +66,19 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.f THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1){this.objects.push(a);this.__objectsAdded.push(a)}for(var b=0;b=0&&E>=0&&x>=0&&u>=0)return!0;else if(D<0&&E<0||x<0&&u<0)return!1;else{if(D<0)C=Math.max(C,D/(D-E));else E<0&&(z=Math.min(z,D/(D-E)));if(x<0)C=Math.max(C,x/(x-u));else u<0&&(z=Math.min(z,x/(x-u)));if(zD&&s.z0&&r.z<1){m=p[o]=p[o]||new THREE.RenderableParticle;m.x=r.x/r.w;m.y=r.y/r.w;m.z=r.z;m.rotation=y.rotation.z;m.scale.x=y.scale.x*Math.abs(m.x-(r.x+t.projectionMatrix.n11)/(r.w+t.projectionMatrix.n14));m.scale.y=y.scale.y*Math.abs(m.y-(r.y+t.projectionMatrix.n22)/ -(r.w+t.projectionMatrix.n24));m.materials=y.materials;z.push(m);o++}}}}C&&z.sort(a);return z};this.unprojectVector=function(v,t){var C=t.matrixWorld.clone();C.multiplySelf(THREE.Matrix4.makeInvert(t.projectionMatrix));C.multiplyVector3(v);return v}}; -THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,e,f;this.domElement=document.createElement("div");this.setSize=function(g,i){c=g;d=i;e=c/2;f=d/2};this.render=function(g,i){var h,j,n,l,m,o,p,q;a=b.projectScene(g,i);h=0;for(j=a.length;h=0&&A>=0&&w>=0&&t>=0)return!0;else if(F<0&&A<0||w<0&&t<0)return!1;else{if(F<0)E=Math.max(E,F/(F-A));else A<0&&(B=Math.min(B,F/(F-A)));if(w<0)E=Math.max(E,w/(w-t));else t<0&&(B=Math.min(B,w/(w-t)));if(BF&&s.z0&&p.z<1){l=q[o]=q[o]||new THREE.RenderableParticle;l.x=p.x/p.w;l.y=p.y/p.w;l.z=p.z;l.rotation=u.rotation.z;l.scale.x=u.scale.x*Math.abs(l.x-(p.x+v.projectionMatrix.n11)/(p.w+v.projectionMatrix.n14));l.scale.y=u.scale.y*Math.abs(l.y-(p.y+v.projectionMatrix.n22)/ +(p.w+v.projectionMatrix.n24));l.materials=u.materials;B.push(l);o++}}}}E&&B.sort(a);return B};this.unprojectVector=function(x,v){var E=v.matrixWorld.clone();E.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));E.multiplyVector3(x);return x}}; +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,e,f;this.domElement=document.createElement("div");this.setSize=function(g,i){c=g;d=i;e=c/2;f=d/2};this.render=function(g,i){var h,j,n,m,l,o,q,r;a=b.projectScene(g,i);h=0;for(j=a.length;h0?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)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)}; +this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},setRotationFromMatrix:function(){},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)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)}; THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a0&&t>0&&C+t<1}var c,d,e,f,g,i,h,l,n,m, -k,o=a.geometry,q=o.vertices,s=[];c=0;for(d=o.faces.length;c0&&u>0&&F+u<1}var c,d,e,f,g,i,h,l,n,m, +k,o=a.geometry,r=o.vertices,v=[];c=0;for(d=o.faces.length;ch?d:h;e=e>l?e:l}a()}; this.add3Points=function(h,l,n,m,k,o){if(i){i=!1;b=hn?h>k?h:k:n>k?n:k;e=l>m?l>o?l:o:m>o?m:o}else{b=hn?h>k?h>d?h:d:k>d?k:d:n>k?n>d?n:d:k>d?k:d;e=l>m?l>o?l>e?l:e:o>e?o:e:m>o?m>e?m:e:o>e?o:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=bh.getRight()? d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}}; THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}}; -THREE.Matrix4=function(a,b,c,d,e,f,g,i,h,l,n,m,k,o,q,s){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,l||0,n||1,m||0,k||0,o||0,q||0,s||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,l,n,m,k,o,q,s){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=l;this.n33=n;this.n34=m;this.n41=k;this.n42=o;this.n43=q;this.n44=s;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1, +THREE.Matrix4=function(a,b,c,d,e,f,g,i,h,l,n,m,k,o,r,v){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,l||0,n||1,m||0,k||0,o||0,r||0,v||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,l,n,m,k,o,r,v){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=l;this.n33=n;this.n34=m;this.n41=k;this.n42=o;this.n43=r;this.n44=v;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1, e=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n14=a.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n24=a.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31* b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},crossVector:function(a){var b=new THREE.Vector4; -b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,q=a.n41,s=a.n42,t=a.n43,j=a.n44,H=b.n11,p=b.n12,y=b.n13,C=b.n14,L=b.n21,z=b.n22,v=b.n23,I=b.n24,E=b.n31,K=b.n32,J=b.n33,u=b.n34;this.n11=c* -H+d*L+e*E;this.n12=c*p+d*z+e*K;this.n13=c*y+d*v+e*J;this.n14=c*C+d*I+e*u+f;this.n21=g*H+i*L+h*E;this.n22=g*p+i*z+h*K;this.n23=g*y+i*v+h*J;this.n24=g*C+i*I+h*u+l;this.n31=n*H+m*L+k*E;this.n32=n*p+m*z+k*K;this.n33=n*y+m*v+k*J;this.n34=n*C+m*I+k*u+o;this.n41=q*H+s*L+t*E;this.n42=q*p+s*z+t*K;this.n43=q*y+s*v+t*J;this.n44=q*C+s*I+t*u+j;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,g=a.n14,i=a.n21,h=a.n22,l=a.n23,n=a.n24,m=a.n31,k=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,j=a.n43; -a=a.n44;var H=b.n11,p=b.n12,y=b.n13,C=b.n14,L=b.n21,z=b.n22,v=b.n23,I=b.n24,E=b.n31,K=b.n32,J=b.n33,u=b.n34,D=b.n41,S=b.n42,x=b.n43;b=b.n44;this.n11=d*H+e*L+f*E+g*D;this.n12=d*p+e*z+f*K+g*S;this.n13=d*y+e*v+f*J+g*x;this.n14=d*C+e*I+f*u+g*b;this.n21=i*H+h*L+l*E+n*D;this.n22=i*p+h*z+l*K+n*S;this.n23=i*y+h*v+l*J+n*x;this.n24=i*C+h*I+l*u+n*b;this.n31=m*H+k*L+o*E+q*D;this.n32=m*p+k*z+o*K+q*S;this.n33=m*y+k*v+o*J+q*x;this.n34=m*C+k*I+o*u+q*b;this.n41=s*H+t*L+j*E+a*D;this.n42=s*p+t*z+j*K+a*S;this.n43=s* -y+t*v+j*J+a*x;this.n44=s*C+t*I+j*u+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,g=this.n22,i=this.n23,h=this.n24,l=this.n31,n=this.n32,m=this.n33,k=this.n34,o=this.n41,q=this.n42,s=this.n43,t=this.n44,j=a.n11,H=a.n21, -p=a.n31,y=a.n12,C=a.n22,L=a.n32,z=a.n13,v=a.n23,I=a.n33,E=a.n14,K=a.n24;a=a.n34;this.n11=b*j+c*H+d*p;this.n12=b*y+c*C+d*L;this.n13=b*z+c*v+d*I;this.n14=b*E+c*K+d*a+e;this.n21=f*j+g*H+i*p;this.n22=f*y+g*C+i*L;this.n23=f*z+g*v+i*I;this.n24=f*E+g*K+i*a+h;this.n31=l*j+n*H+m*p;this.n32=l*y+n*C+m*L;this.n33=l*z+n*v+m*I;this.n34=l*E+n*K+m*a+k;this.n41=o*j+q*H+s*p;this.n42=o*y+q*C+s*L;this.n43=o*z+q*v+s*I;this.n44=o*E+q*K+s*a+t;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*= -a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,l=this.n32,n=this.n33,m=this.n34,k=this.n41,o=this.n42,q=this.n43,s=this.n44;return d*g*l*k-c*i*l*k-d*f*n*k+b*i*n*k+c*f*m*k-b*g*m*k-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+d*f*h*q-b*i*h*q-d*e*l*q+a*i*l*q+b*e* -m*q-a*f*m*q-c*f*h*s+b*g*h*s+c*e*l*s-a*g*l*s-b*e*n*s+a*f*n*s},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flattenToArray(this.flat);return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]= -this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0, -b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,l=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,l*g+c,l*i-d*f,0,h*i-d*g,l*i+d*f,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y; -this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var l=c*g;c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(l+d);this.n12=h-e;this.n13= -b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+l)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d}; -THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c}; -THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,q=a.n41,s=a.n42,t=a.n43,j=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*s-l*k*s+l*m*t-i*o*t-h*m*j+i*k*j;b.n12=f*k*s-e*o*s-f*m*t+d*o*t+e*m*j-d*k*j;b.n13=e*l*s-f*h*s+f*i*t-d*l*t-e*i*j+d*h*j;b.n14=f*h*m-e*l*m-f*i*k+d*l*k+e*i*o-d*h*o;b.n21=l*k*q-h*o*q-l*n*t+g*o*t+h*n*j-g*k*j;b.n22=e*o*q-f*k*q+f*n*t-c*o*t-e*n*j+c*k*j;b.n23=f*h*q-e*l*q-f*g*t+c*l*t+e*g*j-c*h*j; -b.n24=e*l*n-f*h*n+f*g*k-c*l*k-e*g*o+c*h*o;b.n31=i*o*q-l*m*q+l*n*s-g*o*s-i*n*j+g*m*j;b.n32=f*m*q-d*o*q-f*n*s+c*o*s+d*n*j-c*m*j;b.n33=e*l*q-f*i*q+f*g*s-c*l*s-d*g*j+c*i*j;b.n34=f*i*n-d*l*n-f*g*m+c*l*m+d*g*o-c*i*o;b.n41=h*m*q-i*k*q-h*n*s+g*k*s+i*n*t-g*m*t;b.n42=d*k*q-e*m*q+e*n*s-c*k*s-d*n*t+c*m*t;b.n43=e*i*q-d*h*q-e*g*s+c*h*s+d*g*t-c*i*t;b.n44=d*h*n-e*i*n+e*g*m-c*h*m-d*g*k+c*i*k;b.multiplyScalar(1/a.determinant());return b}; +b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,r=a.n41,v=a.n42,u=a.n43,j=a.n44,J=b.n11,q=b.n12,A=b.n13,F=b.n14,R=b.n21,B=b.n22,z=b.n23,L=b.n24,G=b.n31,N=b.n32,H=b.n33,s=b.n34;this.n11=c* +J+d*R+e*G;this.n12=c*q+d*B+e*N;this.n13=c*A+d*z+e*H;this.n14=c*F+d*L+e*s+f;this.n21=g*J+i*R+h*G;this.n22=g*q+i*B+h*N;this.n23=g*A+i*z+h*H;this.n24=g*F+i*L+h*s+l;this.n31=n*J+m*R+k*G;this.n32=n*q+m*B+k*N;this.n33=n*A+m*z+k*H;this.n34=n*F+m*L+k*s+o;this.n41=r*J+v*R+u*G;this.n42=r*q+v*B+u*N;this.n43=r*A+v*z+u*H;this.n44=r*F+v*L+u*s+j;return this},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42; +c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21, +f=this.n22,g=this.n23,i=this.n24,h=this.n31,l=this.n32,n=this.n33,m=this.n34,k=this.n41,o=this.n42,r=this.n43,v=this.n44;return d*g*l*k-c*i*l*k-d*f*n*k+b*i*n*k+c*f*m*k-b*g*m*k-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+d*f*h*r-b*i*h*r-d*e*l*r+a*i*l*r+b*e*m*r-a*f*m*r-c*f*h*v+b*g*h*v+c*e*l*v-a*g*l*v-b*e*n*v+a*f*n*v},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14= +a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]= +this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24; +a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this}, +setRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,l=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,l*g+c,l*i-d*f,0,h*i-d*g, +l*i+d*f,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a= +b*f;var h=b*g;b*=i;var l=c*g;c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(l+d);this.n12=h-e;this.n13=b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+l)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,b){var c=1/b.x,d=1/ +b.y,e=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*e;this.n23=a.n23*e;this.n33=a.n33*e}}; +THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,r=a.n41,v=a.n42,u=a.n43,j=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*v-l*k*v+l*m*u-i*o*u-h*m*j+i*k*j;b.n12=f*k*v-e*o*v-f*m*u+d*o*u+e*m*j-d*k*j;b.n13=e*l*v-f*h*v+f*i*u-d*l*u-e*i*j+d*h*j;b.n14=f*h*m-e*l*m-f*i*k+d*l*k+e*i*o-d*h*o;b.n21=l*k*r-h*o*r-l*n*u+g*o*u+h*n*j-g*k*j;b.n22=e*o*r-f*k*r+f*n*u-c*o*u-e*n*j+c*k*j;b.n23=f*h*r-e*l*r-f*g*u+c*l*u+e*g*j-c*h*j; +b.n24=e*l*n-f*h*n+f*g*k-c*l*k-e*g*o+c*h*o;b.n31=i*o*r-l*m*r+l*n*v-g*o*v-i*n*j+g*m*j;b.n32=f*m*r-d*o*r-f*n*v+c*o*v+d*n*j-c*m*j;b.n33=e*l*r-f*i*r+f*g*v-c*l*v-d*g*j+c*i*j;b.n34=f*i*n-d*l*n-f*g*m+c*l*m+d*g*o-c*i*o;b.n41=h*m*r-i*k*r-h*n*v+g*k*v+i*n*u-g*m*u;b.n42=d*k*r-e*m*r+e*n*v-c*k*v-d*n*u+c*m*u;b.n43=e*i*r-d*h*r-e*g*v+c*h*v+d*g*u-c*i*u;b.n44=d*h*n-e*i*n+e*g*m-c*h*m-d*g*k+c*i*k;b.multiplyScalar(1/a.determinant());return b}; THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*l;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*l;c[7]=a*n;c[8]=a*m;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)}; THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,i,h,l;g=new THREE.Matrix4;i=b-a;h=c-d;l=f-e;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/l;g.n34=-((f+e)/l);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1; this.visible=!0}; -THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation); -if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var d=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21= -this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*d;this.matrixRotationWorld.n23=this.matrixWorld.n23*d;this.matrixRotationWorld.n33=this.matrixWorld.n33*d;this.matrixNeedsUpdate=!1;b=!0}a=0;for(d=this.children.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], +this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b=0&&J>=0&&u>=0&&D>=0)return!0;else if(K<0&&J<0||u<0&&D<0)return!1;else{if(K<0)I=Math.max(I,K/(K-J));else J<0&&(E=Math.min(E,K/(K-J)));if(u<0)I=Math.max(I,u/(u-D));else D<0&&(E=Math.min(E,u/(u-D)));if(EK&&x.z0&&t.z<1){k=q[o]=q[o]||new THREE.RenderableParticle;k.x=t.x/t.w;k.y=t.y/t.w;k.z=t.z;k.rotation=A.rotation.z;k.scale.x=A.scale.x*Math.abs(k.x-(t.x+v.projectionMatrix.n11)/(t.w+v.projectionMatrix.n14));k.scale.y=A.scale.y*Math.abs(k.y-(t.y+v.projectionMatrix.n22)/ -(t.w+v.projectionMatrix.n24));k.materials=A.materials;E.push(k);o++}}}}I&&E.sort(a);return E};this.unprojectVector=function(z,v){var I=v.matrixWorld.clone();I.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));I.multiplyVector3(z);return z}}; -THREE.SVGRenderer=function(){function a(F,A,O){var Q,B,w,M;Q=0;for(B=F.lights.length;Q0){O.r+=w.color.r*M;O.g+=w.color.g*M;O.b+=w.color.b*M}}else if(w instanceof THREE.PointLight){I.sub(w.position,A.centroidWorld);I.normalize();M=A.normalWorld.dot(I)*w.intensity;if(M>0){O.r+=w.color.r*M;O.g+=w.color.g*M;O.b+=w.color.b*M}}}}function b(F,A,O,Q,B,w){u=d(D++);u.setAttribute("d","M "+F.positionScreen.x+ -" "+F.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)p.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(H){y.r=C.r;y.g=C.g;y.b=C.b;a(w,Q,y);p.r=B.color.r*y.r;p.g=B.color.g*y.g;p.b=B.color.b*y.b;p.updateStyleString()}else p.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){v=1-B.__2near/(B.__farPlusNear-Q.z*B.__farMinusNear); -p.setRGB(v,v,v)}else B instanceof THREE.MeshNormalMaterial&&p.setRGB(e(Q.normalWorld.x),e(Q.normalWorld.y),e(Q.normalWorld.z));B.wireframe?u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+B.wireframeLinewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframeLinecap+"; stroke-linejoin: "+B.wireframeLinejoin):u.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+B.opacity);i.appendChild(u)}function c(F,A,O,Q,B,w,M){u=d(D++);u.setAttribute("d", -"M "+F.positionScreen.x+" "+F.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)p.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(H){y.r=C.r;y.g=C.g;y.b=C.b;a(M,B,y);p.r=w.color.r*y.r;p.g=w.color.g*y.g;p.b=w.color.b*y.b;p.updateStyleString()}else p.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){v= -1-w.__2near/(w.__farPlusNear-B.z*w.__farMinusNear);p.setRGB(v,v,v)}else w instanceof THREE.MeshNormalMaterial&&p.setRGB(e(B.normalWorld.x),e(B.normalWorld.y),e(B.normalWorld.z));w.wireframe?u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+w.wireframeLinewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframeLinecap+"; stroke-linejoin: "+w.wireframeLinejoin):u.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+w.opacity);i.appendChild(u)} -function d(F){if(E[F]==null){E[F]=document.createElementNS("http://www.w3.org/2000/svg","path");N==0&&E[F].setAttribute("shape-rendering","crispEdges")}return E[F]}function e(F){return F<0?Math.min((1+F)*0.5,0.5):0.5+Math.min(F*0.5,0.5)}var f=null,g=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,l,n,m,k,o,q,s,t=new THREE.Rectangle,j=new THREE.Rectangle,H=!1,p=new THREE.Color(16777215),y=new THREE.Color(16777215),C=new THREE.Color(0),L=new THREE.Color(0),z=new THREE.Color(0), -v,I=new THREE.Vector3,E=[],K=[],J=[],u,D,S,x,N=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(F){switch(F){case "high":N=1;break;case "low":N=0}};this.setSize=function(F,A){h=F;l=A;n=h/2;m=l/2;i.setAttribute("viewBox",-n+" "+-m+" "+h+" "+l);i.setAttribute("width",h);i.setAttribute("height",l);t.set(-n,-m,n,m)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(F,A){var O,Q,B,w,M,P,r,G;this.autoClear&& -this.clear();f=g.projectScene(F,A,this.sortElements);x=S=D=0;if(H=F.lights.length>0){r=F.lights;C.setRGB(0,0,0);L.setRGB(0,0,0);z.setRGB(0,0,0);O=0;for(Q=r.length;O=0&&H>=0&&s>=0&&C>=0)return!0;else if(N<0&&H<0||s<0&&C<0)return!1;else{if(N<0)L=Math.max(L,N/(N-H));else H<0&&(G=Math.min(G,N/(N-H)));if(s<0)L=Math.max(L,s/(s-C));else C<0&&(G=Math.min(G,s/(s-C)));if(GN&&y.z0&&u.z<1){k=r[o]=r[o]||new THREE.RenderableParticle;k.x=u.x/u.w;k.y=u.y/u.w;k.z=u.z;k.rotation=w.rotation.z;k.scale.x=w.scale.x*Math.abs(k.x-(u.x+z.projectionMatrix.n11)/(u.w+z.projectionMatrix.n14));k.scale.y=w.scale.y*Math.abs(k.y-(u.y+z.projectionMatrix.n22)/ +(u.w+z.projectionMatrix.n24));k.materials=w.materials;G.push(k);o++}}}}L&&G.sort(a);return G};this.unprojectVector=function(B,z){var L=z.matrixWorld.clone();L.multiplySelf(THREE.Matrix4.makeInvert(z.projectionMatrix));L.multiplyVector3(B);return B}}; +THREE.SVGRenderer=function(){function a(D,w,M){var P,x,t,I;P=0;for(x=D.lights.length;P0){M.r+=t.color.r*I;M.g+=t.color.g*I;M.b+=t.color.b*I}}else if(t instanceof THREE.PointLight){L.sub(t.position,w.centroidWorld);L.normalize();I=w.normalWorld.dot(L)*t.intensity;if(I>0){M.r+=t.color.r*I;M.g+=t.color.g*I;M.b+=t.color.b*I}}}}function b(D,w,M,P,x,t){s=d(C++);s.setAttribute("d","M "+D.positionScreen.x+ +" "+D.positionScreen.y+" L "+w.positionScreen.x+" "+w.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+"z");if(x instanceof THREE.MeshBasicMaterial)q.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshLambertMaterial)if(J){A.r=F.r;A.g=F.g;A.b=F.b;a(t,P,A);q.r=x.color.r*A.r;q.g=x.color.g*A.g;q.b=x.color.b*A.b;q.updateStyleString()}else q.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshDepthMaterial){z=1-x.__2near/(x.__farPlusNear-P.z*x.__farMinusNear); +q.setRGB(z,z,z)}else x instanceof THREE.MeshNormalMaterial&&q.setRGB(e(P.normalWorld.x),e(P.normalWorld.y),e(P.normalWorld.z));x.wireframe?s.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+x.wireframeLinewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.wireframeLinecap+"; stroke-linejoin: "+x.wireframeLinejoin):s.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+x.opacity);i.appendChild(s)}function c(D,w,M,P,x,t,I){s=d(C++);s.setAttribute("d", +"M "+D.positionScreen.x+" "+D.positionScreen.y+" L "+w.positionScreen.x+" "+w.positionScreen.y+" L "+M.positionScreen.x+","+M.positionScreen.y+" L "+P.positionScreen.x+","+P.positionScreen.y+"z");if(t instanceof THREE.MeshBasicMaterial)q.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshLambertMaterial)if(J){A.r=F.r;A.g=F.g;A.b=F.b;a(I,x,A);q.r=t.color.r*A.r;q.g=t.color.g*A.g;q.b=t.color.b*A.b;q.updateStyleString()}else q.__styleString=t.color.__styleString;else if(t instanceof THREE.MeshDepthMaterial){z= +1-t.__2near/(t.__farPlusNear-x.z*t.__farMinusNear);q.setRGB(z,z,z)}else t instanceof THREE.MeshNormalMaterial&&q.setRGB(e(x.normalWorld.x),e(x.normalWorld.y),e(x.normalWorld.z));t.wireframe?s.setAttribute("style","fill: none; stroke: "+q.__styleString+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):s.setAttribute("style","fill: "+q.__styleString+"; fill-opacity: "+t.opacity);i.appendChild(s)} +function d(D){if(G[D]==null){G[D]=document.createElementNS("http://www.w3.org/2000/svg","path");K==0&&G[D].setAttribute("shape-rendering","crispEdges")}return G[D]}function e(D){return D<0?Math.min((1+D)*0.5,0.5):0.5+Math.min(D*0.5,0.5)}var f=null,g=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,l,n,m,k,o,r,v,u=new THREE.Rectangle,j=new THREE.Rectangle,J=!1,q=new THREE.Color(16777215),A=new THREE.Color(16777215),F=new THREE.Color(0),R=new THREE.Color(0),B=new THREE.Color(0), +z,L=new THREE.Vector3,G=[],N=[],H=[],s,C,S,y,K=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(D){switch(D){case "high":K=1;break;case "low":K=0}};this.setSize=function(D,w){h=D;l=w;n=h/2;m=l/2;i.setAttribute("viewBox",-n+" "+-m+" "+h+" "+l);i.setAttribute("width",h);i.setAttribute("height",l);u.set(-n,-m,n,m)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(D,w){var M,P,x,t,I,O,p,E;this.autoClear&& +this.clear();f=g.projectScene(D,w,this.sortElements);y=S=C=0;if(J=D.lights.length>0){p=D.lights;F.setRGB(0,0,0);R.setRGB(0,0,0);B.setRGB(0,0,0);M=0;for(P=p.length;M>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)}}; -THREE.Vector2=function(a,b){this.set(a||0,b||0)}; -THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/ -this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,b,d){this.set(a||0,b||0,d||0)}; -THREE.Vector3.prototype={set:function(a,b,d){this.x=a;this.y=b;this.z=d;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a, -b){this.set(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);return this},crossSelf:function(a){var b=this.x,d=this.y,e=this.z;this.set(d*a.z-e*a.y,e*a.x-b*a.z,b*a.y-d*a.x);return this},multiply:function(a,b){this.set(a.x*b.x,a.y*b.y,a.z*b.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/ -a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return b*b+d*d+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a= -this.length();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)}};THREE.Vector4=function(a,b,d,e){this.set(a||0,b||0,d||0,e||1)}; -THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* -a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(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)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3}; -THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,h=[];a=0;for(b=e.length;a0&&I>0&&O+I<1}var d,e,h,j,k,o,m,t,y,x, -B,C=a.geometry,F=C.vertices,G=[];d=0;for(e=C.faces.length;dm?e:m;h=h>t?h:t}a()}; -this.add3Points=function(m,t,y,x,B,C){if(o){o=!1;b=my?m>B?m:B:y>B?y:B;h=t>x?t>C?t:C:x>C?x:C}else{b=my?m>B?m>e?m:e:B>e?B:e:y>B?y>e?y:e:B>e?B:e;h=t>x?t>C?t>h?t:h:C>h?C:h:x>C?x>h?x:h:C>h?C:h}a()};this.addRectangle=function(m){if(o){o=!1;b=m.getLeft();d=m.getTop();e=m.getRight();h=m.getBottom()}else{b=bm.getRight()? -e:m.getRight();h=h>m.getBottom()?h:m.getBottom()}a()};this.inflate=function(m){b-=m;d-=m;e+=m;h+=m;a()};this.minSelf=function(m){b=b>m.getLeft()?b:m.getLeft();d=d>m.getTop()?d:m.getTop();e=e=0&&Math.min(h,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){o=!0;h=e=d=b=0;a()};this.isEmpty=function(){return o}}; -THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}}; -THREE.Matrix4=function(a,b,d,e,h,j,k,o,m,t,y,x,B,C,F,G){this.set(a||1,b||0,d||0,e||0,h||0,j||1,k||0,o||0,m||0,t||0,y||1,x||0,B||0,C||0,F||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={set:function(a,b,d,e,h,j,k,o,m,t,y,x,B,C,F,G){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=h;this.n22=j;this.n23=k;this.n24=o;this.n31=m;this.n32=t;this.n33=y;this.n34=x;this.n41=B;this.n42=C;this.n43=F;this.n44=G;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,d){var e=THREE.Matrix4.__tmpVec1, -h=THREE.Matrix4.__tmpVec2,j=THREE.Matrix4.__tmpVec3;j.sub(a,b).normalize();e.cross(d,j).normalize();h.cross(j,e).normalize();this.n11=e.x;this.n12=h.x;this.n13=j.x;this.n14=a.x;this.n21=e.y;this.n22=h.y;this.n23=j.y;this.n24=a.y;this.n31=e.z;this.n32=h.z;this.n33=j.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,h=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31* -b+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector3OnlyZ:function(a){var b=a.x,d=a.y;a=a.z;return(this.n31*b+this.n32*d+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*d+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*h;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*h;return a},crossVector:function(a){var b=new THREE.Vector4; -b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,h=a.n13,j=a.n14,k=a.n21,o=a.n22,m=a.n23,t=a.n24,y=a.n31,x=a.n32,B=a.n33,C=a.n34,F=a.n41,G=a.n42,I=a.n43,H=a.n44,R=b.n11,Q=b.n12,N=b.n13,O=b.n14,c=b.n21,Z=b.n22,ca=b.n23,$=b.n24,aa=b.n31,fa=b.n32,la=b.n33,ma=b.n34;this.n11= -d*R+e*c+h*aa;this.n12=d*Q+e*Z+h*fa;this.n13=d*N+e*ca+h*la;this.n14=d*O+e*$+h*ma+j;this.n21=k*R+o*c+m*aa;this.n22=k*Q+o*Z+m*fa;this.n23=k*N+o*ca+m*la;this.n24=k*O+o*$+m*ma+t;this.n31=y*R+x*c+B*aa;this.n32=y*Q+x*Z+B*fa;this.n33=y*N+x*ca+B*la;this.n34=y*O+x*$+B*ma+C;this.n41=F*R+G*c+I*aa;this.n42=F*Q+G*Z+I*fa;this.n43=F*N+G*ca+I*la;this.n44=F*O+G*$+I*ma+H;return this},multiplyToArray:function(a,b,d){var e=a.n11,h=a.n12,j=a.n13,k=a.n14,o=a.n21,m=a.n22,t=a.n23,y=a.n24,x=a.n31,B=a.n32,C=a.n33,F=a.n34,G= -a.n41,I=a.n42,H=a.n43;a=a.n44;var R=b.n11,Q=b.n12,N=b.n13,O=b.n14,c=b.n21,Z=b.n22,ca=b.n23,$=b.n24,aa=b.n31,fa=b.n32,la=b.n33,ma=b.n34,ga=b.n41,qa=b.n42,ta=b.n43;b=b.n44;this.n11=e*R+h*c+j*aa+k*ga;this.n12=e*Q+h*Z+j*fa+k*qa;this.n13=e*N+h*ca+j*la+k*ta;this.n14=e*O+h*$+j*ma+k*b;this.n21=o*R+m*c+t*aa+y*ga;this.n22=o*Q+m*Z+t*fa+y*qa;this.n23=o*N+m*ca+t*la+y*ta;this.n24=o*O+m*$+t*ma+y*b;this.n31=x*R+B*c+C*aa+F*ga;this.n32=x*Q+B*Z+C*fa+F*qa;this.n33=x*N+B*ca+C*la+F*ta;this.n34=x*O+B*$+C*ma+F*b;this.n41= -G*R+I*c+H*aa+a*ga;this.n42=G*Q+I*Z+H*fa+a*qa;this.n43=G*N+I*ca+H*la+a*ta;this.n44=G*O+I*$+H*ma+a*b;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,j=this.n21,k=this.n22,o=this.n23,m=this.n24,t=this.n31,y=this.n32,x=this.n33,B=this.n34, -C=this.n41,F=this.n42,G=this.n43,I=this.n44,H=a.n11,R=a.n21,Q=a.n31,N=a.n12,O=a.n22,c=a.n32,Z=a.n13,ca=a.n23,$=a.n33,aa=a.n14,fa=a.n24;a=a.n34;this.n11=b*H+d*R+e*Q;this.n12=b*N+d*O+e*c;this.n13=b*Z+d*ca+e*$;this.n14=b*aa+d*fa+e*a+h;this.n21=j*H+k*R+o*Q;this.n22=j*N+k*O+o*c;this.n23=j*Z+k*ca+o*$;this.n24=j*aa+k*fa+o*a+m;this.n31=t*H+y*R+x*Q;this.n32=t*N+y*O+x*c;this.n33=t*Z+y*ca+x*$;this.n34=t*aa+y*fa+x*a+B;this.n41=C*H+F*R+G*Q;this.n42=C*N+F*O+G*c;this.n43=C*Z+F*ca+G*$;this.n44=C*aa+F*fa+G*a+I;return this}, -multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,h=this.n21,j=this.n22,k=this.n23,o=this.n24,m=this.n31,t=this.n32,y=this.n33,x=this.n34,B=this.n41,C=this.n42,F=this.n43,G=this.n44;return e*k*t*B-d*o*t*B-e*j*y*B+b*o*y*B+d*j*x*B-b*k*x*B-e*k*m*C+d*o* -m*C+e*h*y*C-a*o*y*C-d*h*x*C+a*k*x*C+e*j*m*F-b*o*m*F-e*h*t*F+a*o*t*F+b*h*x*F-a*j*x*F-d*j*m*G+b*k*m*G+d*h*t*G-a*k*t*G-b*h*y*G+a*j*y*G},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flattenToArray(this.flat);return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34; -a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,d){this.set(1,0,0,a,0,1,0,b,0,0,1,d,0,0,0,1);return this},setScale:function(a,b,d){this.set(a,0,0,0,0,b,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var b= -Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var d=Math.cos(b),e=Math.sin(b),h=1-d,j=a.x,k=a.y,o=a.z,m=h*j,t=h*k;this.set(m*j+d,m*k-e*o,m*o+e*k,0,m*k+e*o,t*k+d,t*o-e*j,0,m*o-e*k,t*o+e*j,h*o*o+d,0,0,0,0,1);return this},setPosition:function(a){this.n14= -a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,d=a.y,e=a.z;a=Math.cos(b);b=Math.sin(b);var h=Math.cos(d);d=Math.sin(d);var j=Math.cos(e);e=Math.sin(e);var k=a*d,o=b*d;this.n11=h*j;this.n12=-h*e;this.n13=d;this.n21=o*j+a*e;this.n22=-o*e+a*j;this.n23=-b*h;this.n31=-k*j+b*e;this.n32=k*e+b*j;this.n33=a*h},setRotationFromQuaternion:function(a){var b=a.x,d=a.y,e=a.z,h=a.w,j=b+b,k=d+d,o=e+e;a=b*j;var m=b*k;b*=o;var t=d*k;d*=o;e*=o;j*=h;k*=h;h*=o;this.n11=1-(t+e);this.n12= -m-h;this.n13=b+k;this.n21=m+h;this.n22=1-(a+e);this.n23=d-j;this.n31=b-k;this.n32=d+j;this.n33=1-(a+t)},scale:function(a){var b=a.x,d=a.y;a=a.z;this.n11*=b;this.n12*=d;this.n13*=a;this.n21*=b;this.n22*=d;this.n23*=a;this.n31*=b;this.n32*=d;this.n33*=a;this.n41*=b;this.n42*=d;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setTranslation(a,b,d);return e};THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setScale(a,b,d);return e}; -THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4;d.setRotAxis(a,b);return d}; -THREE.Matrix4.makeInvert=function(a,b){var d=a.n11,e=a.n12,h=a.n13,j=a.n14,k=a.n21,o=a.n22,m=a.n23,t=a.n24,y=a.n31,x=a.n32,B=a.n33,C=a.n34,F=a.n41,G=a.n42,I=a.n43,H=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=m*C*G-t*B*G+t*x*I-o*C*I-m*x*H+o*B*H;b.n12=j*B*G-h*C*G-j*x*I+e*C*I+h*x*H-e*B*H;b.n13=h*t*G-j*m*G+j*o*I-e*t*I-h*o*H+e*m*H;b.n14=j*m*x-h*t*x-j*o*B+e*t*B+h*o*C-e*m*C;b.n21=t*B*F-m*C*F-t*y*I+k*C*I+m*y*H-k*B*H;b.n22=h*C*F-j*B*F+j*y*I-d*C*I-h*y*H+d*B*H;b.n23=j*m*F-h*t*F-j*k*I+d*t*I+h*k*H-d*m*H; -b.n24=h*t*y-j*m*y+j*k*B-d*t*B-h*k*C+d*m*C;b.n31=o*C*F-t*x*F+t*y*G-k*C*G-o*y*H+k*x*H;b.n32=j*x*F-e*C*F-j*y*G+d*C*G+e*y*H-d*x*H;b.n33=h*t*F-j*o*F+j*k*G-d*t*G-e*k*H+d*o*H;b.n34=j*o*y-e*t*y-j*k*x+d*t*x+e*k*C-d*o*C;b.n41=m*x*F-o*B*F-m*y*G+k*B*G+o*y*I-k*x*I;b.n42=e*B*F-h*x*F+h*y*G-d*B*G-e*y*I+d*x*I;b.n43=h*o*F-e*m*F-h*k*G+d*m*G+e*k*I-d*o*I;b.n44=e*m*y-h*o*y+h*k*x-d*m*x-e*k*B+d*o*B;b.multiplyScalar(1/a.determinant());return b}; -THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,d=b.m,e=a.n33*a.n22-a.n32*a.n23,h=-a.n33*a.n21+a.n31*a.n23,j=a.n32*a.n21-a.n31*a.n22,k=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,t=a.n23*a.n12-a.n22*a.n13,y=-a.n23*a.n11+a.n21*a.n13,x=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*k+a.n31*t;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*e;d[1]=a*h;d[2]=a*j;d[3]=a*k;d[4]=a*o;d[5]=a*m;d[6]=a*t;d[7]=a*y;d[8]=a*x;return b}; -THREE.Matrix4.makeFrustum=function(a,b,d,e,h,j){var k;k=new THREE.Matrix4;k.n11=2*h/(b-a);k.n12=0;k.n13=(b+a)/(b-a);k.n14=0;k.n21=0;k.n22=2*h/(e-d);k.n23=(e+d)/(e-d);k.n24=0;k.n31=0;k.n32=0;k.n33=-(j+h)/(j-h);k.n34=-2*j*h/(j-h);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(a,b,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*b,a*b,h,a,d,e)}; -THREE.Matrix4.makeOrtho=function(a,b,d,e,h,j){var k,o,m,t;k=new THREE.Matrix4;o=b-a;m=d-e;t=j-h;k.n11=2/o;k.n12=0;k.n13=0;k.n14=-((b+a)/o);k.n21=0;k.n22=2/m;k.n23=0;k.n24=-((d+e)/m);k.n31=0;k.n32=0;k.n33=-2/t;k.n34=-((j+h)/t);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; +THREE.Vector2=function(a,c){this.set(a||0,c||0)}; +THREE.Vector2.prototype={set:function(a,c){this.x=a;this.y=c;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/ +this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(a,c,d){this.set(a||0,c||0,d||0)}; +THREE.Vector3.prototype={set:function(a,c,d){this.x=a;this.y=c;this.z=d;return this},copy:function(a){this.set(a.x,a.y,a.z);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z);return this},addScalar:function(a){this.set(this.x+a,this.y+a,this.z+a);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z);return this},cross:function(a, +c){this.set(a.y*c.z-a.z*c.y,a.z*c.x-a.x*c.z,a.x*c.y-a.y*c.x);return this},crossSelf:function(a){var c=this.x,d=this.y,e=this.z;this.set(d*a.z-e*a.y,e*a.x-c*a.z,c*a.y-d*a.x);return this},multiply:function(a,c){this.set(a.x*c.x,a.y*c.y,a.z*c.z);return this},multiplySelf:function(a){this.set(this.x*a.x,this.y*a.y,this.z*a.z);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a,this.z*a);return this},divideSelf:function(a){this.set(this.x/a.x,this.y/a.y,this.z/a.z);return this},divideScalar:function(a){this.set(this.x/ +a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-this.z);return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x,d=this.y-a.y;a=this.z-a.z;return c*c+d*d+a*a},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){var a= +this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},setRotationFromMatrix:function(){},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)}};THREE.Vector4=function(a,c,d,e){this.set(a||0,c||0,d||0,e||1)}; +THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,c){this.set(a.x+c.x,a.y+c.y,a.z+c.z,a.w+c.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,c){this.set(a.x-c.x,a.y-c.y,a.z-c.z,a.w-c.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x* +a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,c){this.set(this.x+(a.x-this.x)*c,this.y+(a.y-this.y)*c,this.z+(a.z-this.z)*c,this.w+(a.w-this.w)*c)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; +THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,h=[];a=0;for(c=e.length;a0&&L>0&&W+L<1}var d,e,h,k,l,q,m,w,A,y, +D,E=a.geometry,F=E.vertices,H=[];d=0;for(e=E.faces.length;dm?e:m;h=h>w?h:w}a()}; +this.add3Points=function(m,w,A,y,D,E){if(q){q=!1;c=mA?m>D?m:D:A>D?A:D;h=w>y?w>E?w:E:y>E?y:E}else{c=mA?m>D?m>e?m:e:D>e?D:e:A>D?A>e?A:e:D>e?D:e;h=w>y?w>E?w>h?w:h:E>h?E:h:y>E?y>h?y:h:E>h?E:h}a()};this.addRectangle=function(m){if(q){q=!1;c=m.getLeft();d=m.getTop();e=m.getRight();h=m.getBottom()}else{c=cm.getRight()? +e:m.getRight();h=h>m.getBottom()?h:m.getBottom()}a()};this.inflate=function(m){c-=m;d-=m;e+=m;h+=m;a()};this.minSelf=function(m){c=c>m.getLeft()?c:m.getLeft();d=d>m.getTop()?d:m.getTop();e=e=0&&Math.min(h,m.getBottom())-Math.max(d,m.getTop())>=0};this.empty=function(){q=!0;h=e=d=c=0;a()};this.isEmpty=function(){return q}}; +THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},transposeIntoArray:function(a){var c=this.m;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this}}; +THREE.Matrix4=function(a,c,d,e,h,k,l,q,m,w,A,y,D,E,F,H){this.set(a||1,c||0,d||0,e||0,h||0,k||1,l||0,q||0,m||0,w||0,A||1,y||0,D||0,E||0,F||0,H||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={set:function(a,c,d,e,h,k,l,q,m,w,A,y,D,E,F,H){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=h;this.n22=k;this.n23=l;this.n24=q;this.n31=m;this.n32=w;this.n33=A;this.n34=y;this.n41=D;this.n42=E;this.n43=F;this.n44=H;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1, +h=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,c).normalize();e.cross(d,k).normalize();h.cross(k,e).normalize();this.n11=e.x;this.n12=h.x;this.n13=k.x;this.n14=a.x;this.n21=e.y;this.n22=h.y;this.n23=k.y;this.n24=a.y;this.n31=e.z;this.n32=h.z;this.n33=k.z;this.n34=a.z;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,h=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*h;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*h;a.z=(this.n31* +c+this.n32*d+this.n33*e+this.n34)*h;return a},multiplyVector3OnlyZ:function(a){var c=a.x,d=a.y;a=a.z;return(this.n31*c+this.n32*d+this.n33*a+this.n34)*(1/(this.n41*c+this.n42*d+this.n43*a+this.n44))},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,h=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*h;a.y=this.n21*c+this.n22*d+this.n23*e+this.n24*h;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*h;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*h;return a},crossVector:function(a){var c=new THREE.Vector4; +c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,h=a.n13,k=a.n14,l=a.n21,q=a.n22,m=a.n23,w=a.n24,A=a.n31,y=a.n32,D=a.n33,E=a.n34,F=a.n41,H=a.n42,L=a.n43,M=a.n44,Z=c.n11,X=c.n12,O=c.n13,W=c.n14,b=c.n21,ka=c.n22,oa=c.n23,la=c.n24,ma=c.n31,ra=c.n32,pa=c.n33,qa=c.n34;this.n11= +d*Z+e*b+h*ma;this.n12=d*X+e*ka+h*ra;this.n13=d*O+e*oa+h*pa;this.n14=d*W+e*la+h*qa+k;this.n21=l*Z+q*b+m*ma;this.n22=l*X+q*ka+m*ra;this.n23=l*O+q*oa+m*pa;this.n24=l*W+q*la+m*qa+w;this.n31=A*Z+y*b+D*ma;this.n32=A*X+y*ka+D*ra;this.n33=A*O+y*oa+D*pa;this.n34=A*W+y*la+D*qa+E;this.n41=F*Z+H*b+L*ma;this.n42=F*X+H*ka+L*ra;this.n43=F*O+H*oa+L*pa;this.n44=F*W+H*la+L*qa+M;return this},multiplyToArray:function(a,c,d){this.multiply(a,c);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]= +this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12, +d=this.n13,e=this.n14,h=this.n21,k=this.n22,l=this.n23,q=this.n24,m=this.n31,w=this.n32,A=this.n33,y=this.n34,D=this.n41,E=this.n42,F=this.n43,H=this.n44;return e*l*w*D-d*q*w*D-e*k*A*D+c*q*A*D+d*k*y*D-c*l*y*D-e*l*m*E+d*q*m*E+e*h*A*E-a*q*A*E-d*h*y*E+a*l*y*E+e*k*m*F-c*q*m*F-e*h*w*F+a*q*w*F+c*h*y*F-a*k*y*F-d*k*m*H+c*l*m*H+d*h*w*H-a*l*w*H-c*h*A*H+a*k*A*H},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a; +a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;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(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31; +this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43; +a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0, +0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),h=1-d,k=a.x,l=a.y,q=a.z,m=h*k,w=h*l;this.set(m*k+d,m*l-e*q,m* +q+e*l,0,m*l+e*q,w*l+d,w*q-e*k,0,m*q-e*l,w*q+e*k,h*q*q+d,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var c=a.x,d=a.y,e=a.z;a=Math.cos(c);c=Math.sin(c);var h=Math.cos(d);d=Math.sin(d);var k=Math.cos(e);e=Math.sin(e);var l=a*d,q=c*d;this.n11=h*k;this.n12=-h*e;this.n13=d;this.n21=q*k+a*e;this.n22=-q*e+a*k;this.n23=-c*h;this.n31=-l*k+c*e;this.n32=l*e+c*k;this.n33=a*h},setRotationFromQuaternion:function(a){var c=a.x, +d=a.y,e=a.z,h=a.w,k=c+c,l=d+d,q=e+e;a=c*k;var m=c*l;c*=q;var w=d*l;d*=q;e*=q;k*=h;l*=h;h*=q;this.n11=1-(w+e);this.n12=m-h;this.n13=c+l;this.n21=m+h;this.n22=1-(a+e);this.n23=d-k;this.n31=c-l;this.n32=d+k;this.n33=1-(a+w)},scale:function(a){var c=a.x,d=a.y;a=a.z;this.n11*=c;this.n12*=d;this.n13*=a;this.n21*=c;this.n22*=d;this.n23*=a;this.n31*=c;this.n32*=d;this.n33*=a;this.n41*=c;this.n42*=d;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a, +c){var d=1/c.x,e=1/c.y,h=1/c.z;this.n11=a.n11*d;this.n21=a.n21*d;this.n31=a.n31*d;this.n12=a.n12*e;this.n22=a.n22*e;this.n32=a.n32*e;this.n13=a.n13*h;this.n23=a.n23*h;this.n33=a.n33*h}}; +THREE.Matrix4.makeInvert=function(a,c){var d=a.n11,e=a.n12,h=a.n13,k=a.n14,l=a.n21,q=a.n22,m=a.n23,w=a.n24,A=a.n31,y=a.n32,D=a.n33,E=a.n34,F=a.n41,H=a.n42,L=a.n43,M=a.n44;c===undefined&&(c=new THREE.Matrix4);c.n11=m*E*H-w*D*H+w*y*L-q*E*L-m*y*M+q*D*M;c.n12=k*D*H-h*E*H-k*y*L+e*E*L+h*y*M-e*D*M;c.n13=h*w*H-k*m*H+k*q*L-e*w*L-h*q*M+e*m*M;c.n14=k*m*y-h*w*y-k*q*D+e*w*D+h*q*E-e*m*E;c.n21=w*D*F-m*E*F-w*A*L+l*E*L+m*A*M-l*D*M;c.n22=h*E*F-k*D*F+k*A*L-d*E*L-h*A*M+d*D*M;c.n23=k*m*F-h*w*F-k*l*L+d*w*L+h*l*M-d*m*M; +c.n24=h*w*A-k*m*A+k*l*D-d*w*D-h*l*E+d*m*E;c.n31=q*E*F-w*y*F+w*A*H-l*E*H-q*A*M+l*y*M;c.n32=k*y*F-e*E*F-k*A*H+d*E*H+e*A*M-d*y*M;c.n33=h*w*F-k*q*F+k*l*H-d*w*H-e*l*M+d*q*M;c.n34=k*q*A-e*w*A-k*l*y+d*w*y+e*l*E-d*q*E;c.n41=m*y*F-q*D*F-m*A*H+l*D*H+q*A*L-l*y*L;c.n42=e*D*F-h*y*F+h*A*H-d*D*H-e*A*L+d*y*L;c.n43=h*q*F-e*m*F-h*l*H+d*m*H+e*l*L-d*q*L;c.n44=e*m*A-h*q*A+h*l*y-d*m*y-e*l*D+d*q*D;c.multiplyScalar(1/a.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(a){var c=a.m33,d=c.m,e=a.n33*a.n22-a.n32*a.n23,h=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,l=-a.n33*a.n12+a.n32*a.n13,q=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,w=a.n23*a.n12-a.n22*a.n13,A=-a.n23*a.n11+a.n21*a.n13,y=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*l+a.n31*w;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*e;d[1]=a*h;d[2]=a*k;d[3]=a*l;d[4]=a*q;d[5]=a*m;d[6]=a*w;d[7]=a*A;d[8]=a*y;return c}; +THREE.Matrix4.makeFrustum=function(a,c,d,e,h,k){var l;l=new THREE.Matrix4;l.n11=2*h/(c-a);l.n12=0;l.n13=(c+a)/(c-a);l.n14=0;l.n21=0;l.n22=2*h/(e-d);l.n23=(e+d)/(e-d);l.n24=0;l.n31=0;l.n32=0;l.n33=-(k+h)/(k-h);l.n34=-2*k*h/(k-h);l.n41=0;l.n42=0;l.n43=-1;l.n44=0;return l};THREE.Matrix4.makePerspective=function(a,c,d,e){var h;a=d*Math.tan(a*Math.PI/360);h=-a;return THREE.Matrix4.makeFrustum(h*c,a*c,h,a,d,e)}; +THREE.Matrix4.makeOrtho=function(a,c,d,e,h,k){var l,q,m,w;l=new THREE.Matrix4;q=c-a;m=d-e;w=k-h;l.n11=2/q;l.n12=0;l.n13=0;l.n14=-((c+a)/q);l.n21=0;l.n22=2/m;l.n23=0;l.n24=-((d+e)/m);l.n31=0;l.n32=0;l.n33=-2/w;l.n34=-((k+h)/w);l.n41=0;l.n42=0;l.n43=0;l.n44=1;return l};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3; THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1; this.visible=!0}; -THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation); -if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0},update:function(a,b,d){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var e=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21= -this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*e;this.matrixRotationWorld.n23=this.matrixWorld.n23*e;this.matrixRotationWorld.n33=this.matrixWorld.n33*e;this.matrixNeedsUpdate=!1;b=!0}a=0;for(e=this.children.length;a=1){d.w=a.w;d.x=a.x;d.y=a.y;d.z=a.z;return d}var j=Math.acos(h),k=Math.sqrt(1-h*h);if(Math.abs(k)<0.001){d.w=0.5*(a.w+b.w);d.x=0.5*(a.x+b.x);d.y=0.5*(a.y+b.y);d.z=0.5*(a.z+b.z);return d}h=Math.sin((1-e)*j)/k;e=Math.sin(e*j)/k;d.w=a.w*h+b.w*e;d.x=a.x*h+b.x*e;d.y=a.y*h+b.y*e;d.z=a.z*h+b.z*e;return d}; -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=!0}; -THREE.Face3=function(a,b,d,e,h){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=h instanceof Array?h:[h]};THREE.Face4=function(a,b,d,e,h,j){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=j instanceof Array?j:[j]}; -THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; -THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;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,d=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,d=this.vertices.length;b=1){d.w=a.w;d.x=a.x;d.y=a.y;d.z=a.z;return d}var k=Math.acos(h),l=Math.sqrt(1-h*h);if(Math.abs(l)<0.001){d.w=0.5*(a.w+c.w);d.x=0.5*(a.x+c.x);d.y=0.5*(a.y+c.y);d.z=0.5*(a.z+c.z);return d}h=Math.sin((1-e)*k)/l;e=Math.sin(e*k)/l;d.w=a.w*h+c.w*e;d.x=a.x*h+c.x*e;d.y=a.y*h+c.y*e;d.z=a.z*h+c.z*e;return d}; +THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0}; +THREE.Face3=function(a,c,d,e,h){this.a=a;this.b=c;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=h instanceof Array?h:[h]};THREE.Face4=function(a,c,d,e,h,k){this.a=a;this.b=c;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.materials=k instanceof Array?k:[k]}; +THREE.UV=function(a,c){this.set(a||0,c||0)};THREE.UV.prototype={set:function(a,c){this.u=a;this.v=c;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; +THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.faces.length;a0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y], +z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z +this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c=0){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLNormalBuffer);c.vertexAttribPointer(f.normal, -3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLTangentBuffer);c.vertexAttribPointer(f.tangent,4,c.FLOAT,!1,0,0)}if(f.uv>=0)if(i.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLUVBuffer);c.vertexAttribPointer(f.uv,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv)}else c.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(i.__webGLUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2); -if(g.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,i.__webGLSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,i.__webGLSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight, -4,c.FLOAT,!1,0,0)}if(v instanceof THREE.Mesh)if(g.wireframe){c.lineWidth(g.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webGLLineBuffer);c.drawElements(c.LINES,i.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,i.__webGLFaceCount,c.UNSIGNED_SHORT,0)}else if(v instanceof THREE.Line){v=v.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(g.linewidth);c.drawArrays(v,0,i.__webGLLineCount)}else if(v instanceof -THREE.ParticleSystem)c.drawArrays(c.POINTS,0,i.__webGLParticleCount);else v instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,i.__webGLVertexCount)}function j(f,l){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=c.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=c.createBuffer();if(f.hasPos){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,f.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(l.attributes.position);c.vertexAttribPointer(l.attributes.position, -3,c.FLOAT,!1,0,0)}if(f.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,f.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(l.attributes.normal);c.vertexAttribPointer(l.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,f.count);f.count=0}function k(f){if(aa!=f.doubleSided){f.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);aa=f.doubleSided}if(fa!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);fa=f.flipSided}}function o(f){if(ma!= -f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);ma=f}}function m(f){ga[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);ga[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);ga[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);ga[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);ga[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);ga[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var l;for(f=0;f<6;f++){l=ga[f];l.divideScalar(Math.sqrt(l.x*l.x+l.y*l.y+l.z* -l.z))}}function t(f){for(var l=f.matrixWorld,n=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),g=0;g<6;g++){f=ga[g].x*l.n14+ga[g].y*l.n24+ga[g].z*l.n34+ga[g].w;if(f<=n)return!1}return!0}function y(f,l){f.list[f.count]=l;f.count+=1}function x(f){var l,n,g=f.object,i=f.opaque,v=f.transparent;v.count=0;f=i.count=0;for(l=g.materials.length;f65535){w[z].counter+=1;s=w[z].hash+"_"+w[z].counter;f.geometryGroups[s]==undefined&&(f.geometryGroups[s]={faces:[],materials:r,vertices:0})}f.geometryGroups[s].faces.push(i);f.geometryGroups[s].vertices+=p}}function I(f,l,n){f.push({buffer:l,object:n,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function H(f){if(f!=la){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR, -c.ZERO);break;case THREE.BillboardBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:c.blendEquation(c.FUNC_REVERSE_SUBTRACT);c.blendFunc(c.ONE,c.ONE);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}la=f}}function R(f,l){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=c.createFramebuffer();f.__webGLRenderbuffer=c.createRenderbuffer();f.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER, -f.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,f.width,f.height);c.bindTexture(c.TEXTURE_2D,f.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,N(f.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,N(f.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,N(f.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,N(f.minFilter));c.texImage2D(c.TEXTURE_2D,0,N(f.format),f.width,f.height,0,N(f.format),N(f.type),null);c.bindFramebuffer(c.FRAMEBUFFER, -f.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,f.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,f.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var n,g,i;if(f){n=f.__webGLFramebuffer;g=f.width;i=f.height}else{n=null;g=O.width;i=O.height}if(n!=ca){c.bindFramebuffer(c.FRAMEBUFFER,n);c.viewport(0,0,g,i);l&&c.clear(c.COLOR_BUFFER_BIT| -c.DEPTH_BUFFER_BIT);ca=n}}function Q(f,l){var n;if(f=="fragment")n=c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(n=c.createShader(c.VERTEX_SHADER));c.shaderSource(n,l);c.compileShader(n);if(!c.getShaderParameter(n,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(n));return null}return n}function N(f){switch(f){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST; -case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;case THREE.IntType:return c.INT; -case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var O=document.createElement("canvas"),c,Z=null,ca=null,$=this,aa=null,fa=null,la=null,ma=null,ga=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4], -qa=new THREE.Matrix4,ta=new Float32Array(16),Ca=new Float32Array(16),xa=new THREE.Vector4,Fa=!0,La=new THREE.Color(0),Ma=0;if(a){if(a.antialias!==undefined)Fa=a.antialias;a.clearColor!==undefined&&La.setHex(a.clearColor);if(a.clearAlpha!==undefined)Ma=a.clearAlpha}this.domElement=O;this.autoClear=!0;this.sortObjects=!1;(function(f,l,n){try{c=O.getContext("experimental-webgl",{antialias:f})}catch(g){console.log(g)}if(!c)throw"cannot create webgl context";c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST); -c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(l.r,l.g,l.b,n);_cullEnabled=!0})(Fa,La,Ma);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,l){O.width=f;O.height=l;c.viewport(0,0,O.width,O.height)};this.setClearColorHex=function(f,l){var n=new THREE.Color(f);c.clearColor(n.r,n.g,n.b,l)};this.setClearColor= -function(f,l){c.clearColor(f.r,f.g,f.b,l)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.initMaterial=function(f,l,n){var g,i;if(f instanceof THREE.MeshDepthMaterial)d(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)d(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)d(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)d(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)d(f,THREE.ShaderLib.phong); -else if(f instanceof THREE.LineBasicMaterial)d(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&d(f,THREE.ShaderLib.particle_basic);var v,p,r,z;i=r=z=0;for(v=l.length;i -0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.map?"#define USE_MAP":"",v.envMap?"#define USE_ENVMAP":"",v.lightMap?"#define USE_LIGHTMAP":"",v.vertexColors?"#define USE_COLOR":"",v.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); -c.attachShader(n,Q("fragment",i+z));c.attachShader(n,Q("vertex",v+l));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={};f.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(g in f.uniforms)n.push(g);g=f.program;z=0;for(l=n.length;z< -l;z++){i=n[z];g.uniforms[i]=c.getUniformLocation(g,i)}g=f.program;n=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];z=0;for(l=n.length;z=0&&c.enableVertexAttribArray(g.color);g.normal>=0&&c.enableVertexAttribArray(g.normal);g.tangent>=0&&c.enableVertexAttribArray(g.tangent);if(f.skinning&&g.skinVertexA>=0&&g.skinVertexB>= -0&&g.skinIndex>=0&&g.skinWeight>=0){c.enableVertexAttribArray(g.skinVertexA);c.enableVertexAttribArray(g.skinVertexB);c.enableVertexAttribArray(g.skinIndex);c.enableVertexAttribArray(g.skinWeight)}};this.render=function(f,l,n,g){var i,v,p,r,z,s,w,L,T=f.lights,P=f.fog;l.matrixAutoUpdate&&l.update();l.matrixWorldInverse.flattenToArray(Ca);l.projectionMatrix.flattenToArray(ta);qa.multiply(l.projectionMatrix,l.matrixWorldInverse);m(qa);f.update(undefined,!1,l);this.initWebGLObjects(f,l);R(n,g!==undefined? -g:!0);this.autoClear&&this.clear();z=f.__webglObjects.length;for(g=0;g=0;i--){g=n.__webglObjects[i].object;l==g&&n.__webglObjects.splice(i,1)}f.__objectsRemoved.splice(0,1)}l=0;for(n=f.__webglObjects.length;l0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,Da,L)}if(Ba&&P>0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLUV2Buffer);c.bufferData(c.ARRAY_BUFFER,Ea,L)}if(Ha){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,p.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,ua,L);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER, -p.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,pa,L)}if(q>0){c.bindBuffer(c.ARRAY_BUFFER,p.__webGLSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,V,L);c.bindBuffer(c.ARRAY_BUFFER,p.__webGLSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,W,L);c.bindBuffer(c.ARRAY_BUFFER,p.__webGLSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,X,L);c.bindBuffer(c.ARRAY_BUFFER,p.__webGLSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,Y,L)}}}i.__dirtyVertices=!1;i.__dirtyElements=!1;i.__dirtyUvs=!1;i.__dirtyNormals= -!1;i.__dirtyTangents=!1;i.__dirtyColors=!1}else if(g instanceof THREE.Ribbon){i=g.geometry;if(i.__dirtyVertices||i.__dirtyColors){g=i;v=c.DYNAMIC_DRAW;s=void 0;s=void 0;r=void 0;p=void 0;w=g.vertices;L=g.colors;P=w.length;T=L.length;K=g.__vertexArray;z=g.__colorArray;M=g.__dirtyColors;if(g.__dirtyVertices){for(s=0;s0}}; +g.ambient.b);r.specular.value.setRGB(g.specular.r,g.specular.g,g.specular.b);r.shininess.value=g.shininess}else if(g instanceof THREE.MeshDepthMaterial){r.mNear.value=f.near;r.mFar.value=f.far;r.opacity.value=g.opacity}else if(g instanceof THREE.MeshNormalMaterial)r.opacity.value=g.opacity;for(var B in r)if(v=u.uniforms[B]){n=r[B];x=n.type;j=n.value;if(x=="i")b.uniform1i(v,j);else if(x=="f")b.uniform1f(v,j);else if(x=="fv1")b.uniform1fv(v,j);else if(x=="fv")b.uniform3fv(v,j);else if(x=="v2")b.uniform2f(v, +j.x,j.y);else if(x=="v3")b.uniform3f(v,j.x,j.y,j.z);else if(x=="c")b.uniform3f(v,j.r,j.g,j.b);else if(x=="t"){b.uniform1i(v,j);if(n=n.texture)if(n.image instanceof Array&&n.image.length==6){if(n.image.length==6){if(n.needsUpdate){if(!n.image.__webGLTextureCube)n.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE); +b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(x=0;x<6;++x)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+x,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,n.image[x]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);n.needsUpdate=!1}b.activeTexture(b.TEXTURE0+j);b.bindTexture(b.TEXTURE_CUBE_MAP,n.image.__webGLTextureCube)}}else{if(n.needsUpdate){if(n.__wasSetOnce){b.bindTexture(b.TEXTURE_2D, +n.__webGLTexture);b.texSubImage2D(b.TEXTURE_2D,0,0,0,b.RGBA,b.UNSIGNED_BYTE,n.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(n.wrapS));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,O(n.wrapT));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(n.magFilter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(n.minFilter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}else{n.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,n.__webGLTexture);b.texImage2D(b.TEXTURE_2D, +0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,n.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(n.wrapS));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,O(n.wrapT));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(n.magFilter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(n.minFilter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null);n.__wasSetOnce=!0}n.needsUpdate=!1}b.activeTexture(b.TEXTURE0+j);b.bindTexture(b.TEXTURE_2D,n.__webGLTexture)}}}b.uniformMatrix4fv(o.modelViewMatrix, +!1,i._modelViewMatrixArray);b.uniformMatrix3fv(o.normalMatrix,!1,i._normalMatrixArray);(g instanceof THREE.MeshShaderMaterial||g instanceof THREE.MeshPhongMaterial||g.envMap)&&b.uniform3f(o.cameraPosition,f.position.x,f.position.y,f.position.z);(g instanceof THREE.MeshShaderMaterial||g.envMap||g.skinning)&&b.uniformMatrix4fv(o.objectMatrix,!1,i._objectMatrixArray);(g instanceof THREE.MeshPhongMaterial||g instanceof THREE.MeshLambertMaterial||g instanceof THREE.MeshShaderMaterial||g.skinning)&&b.uniformMatrix4fv(o.viewMatrix, +!1,Ca);if(g.skinning){b.uniformMatrix4fv(o.cameraInverseMatrix,!1,Ca);b.uniformMatrix4fv(o.boneGlobalMatrices,!1,i.boneMatrices)}return u}function h(f,j,n,g,i,u){f=e(f,j,n,g,u).attributes;b.bindBuffer(b.ARRAY_BUFFER,i.__webGLVertexBuffer);b.vertexAttribPointer(f.position,3,b.FLOAT,!1,0,0);if(f.color>=0){b.bindBuffer(b.ARRAY_BUFFER,i.__webGLColorBuffer);b.vertexAttribPointer(f.color,3,b.FLOAT,!1,0,0)}if(f.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,i.__webGLNormalBuffer);b.vertexAttribPointer(f.normal, +3,b.FLOAT,!1,0,0)}if(f.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,i.__webGLTangentBuffer);b.vertexAttribPointer(f.tangent,4,b.FLOAT,!1,0,0)}if(f.uv>=0)if(i.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,i.__webGLUVBuffer);b.vertexAttribPointer(f.uv,2,b.FLOAT,!1,0,0);b.enableVertexAttribArray(f.uv)}else b.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(i.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,i.__webGLUV2Buffer);b.vertexAttribPointer(f.uv2,2,b.FLOAT,!1,0,0);b.enableVertexAttribArray(f.uv2)}else b.disableVertexAttribArray(f.uv2); +if(g.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){b.bindBuffer(b.ARRAY_BUFFER,i.__webGLSkinVertexABuffer);b.vertexAttribPointer(f.skinVertexA,4,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,i.__webGLSkinVertexBBuffer);b.vertexAttribPointer(f.skinVertexB,4,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,i.__webGLSkinIndicesBuffer);b.vertexAttribPointer(f.skinIndex,4,b.FLOAT,!1,0,0);b.bindBuffer(b.ARRAY_BUFFER,i.__webGLSkinWeightsBuffer);b.vertexAttribPointer(f.skinWeight, +4,b.FLOAT,!1,0,0)}if(u instanceof THREE.Mesh)if(g.wireframe){b.lineWidth(g.wireframeLinewidth);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,i.__webGLLineBuffer);b.drawElements(b.LINES,i.__webGLLineCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,i.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,i.__webGLFaceCount,b.UNSIGNED_SHORT,0)}else if(u instanceof THREE.Line){u=u.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(g.linewidth);b.drawArrays(u,0,i.__webGLLineCount)}else if(u instanceof +THREE.ParticleSystem)b.drawArrays(b.POINTS,0,i.__webGLParticleCount);else u instanceof THREE.Ribbon&&b.drawArrays(b.TRIANGLE_STRIP,0,i.__webGLVertexCount)}function k(f,j){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=b.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=b.createBuffer();if(f.hasPos){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,f.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(j.attributes.position);b.vertexAttribPointer(j.attributes.position, +3,b.FLOAT,!1,0,0)}if(f.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,f.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,f.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(j.attributes.normal);b.vertexAttribPointer(j.attributes.normal,3,b.FLOAT,!1,0,0)}b.drawArrays(b.TRIANGLES,0,f.count);f.count=0}function l(f){if(ma!=f.doubleSided){f.doubleSided?b.disable(b.CULL_FACE):b.enable(b.CULL_FACE);ma=f.doubleSided}if(ra!=f.flipSided){f.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW);ra=f.flipSided}}function q(f){if(qa!= +f){f?b.enable(b.DEPTH_TEST):b.disable(b.DEPTH_TEST);qa=f}}function m(f){ha[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);ha[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);ha[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);ha[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);ha[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);ha[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var j;for(f=0;f<6;f++){j=ha[f];j.divideScalar(Math.sqrt(j.x*j.x+j.y*j.y+j.z* +j.z))}}function w(f){for(var j=f.matrixWorld,n=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),g=0;g<6;g++){f=ha[g].x*j.n14+ha[g].y*j.n24+ha[g].z*j.n34+ha[g].w;if(f<=n)return!1}return!0}function A(f,j){f.list[f.count]=j;f.count+=1}function y(f){var j,n,g=f.object,i=f.opaque,u=f.transparent;u.count=0;f=i.count=0;for(j=g.materials.length;f65535){v[x].counter+=1;s=v[x].hash+"_"+v[x].counter;f.geometryGroups[s]==undefined&&(f.geometryGroups[s]={faces:[],materials:r,vertices:0})}f.geometryGroups[s].faces.push(i);f.geometryGroups[s].vertices+=o}}function L(f,j,n){f.push({buffer:j,object:n,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function M(f){if(f!=pa){switch(f){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR, +b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:b.blendEquation(b.FUNC_REVERSE_SUBTRACT);b.blendFunc(b.ONE,b.ONE);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}pa=f}}function Z(f,j){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=b.createFramebuffer();f.__webGLRenderbuffer=b.createRenderbuffer();f.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER, +f.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,f.width,f.height);b.bindTexture(b.TEXTURE_2D,f.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,O(f.wrapS));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,O(f.wrapT));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,O(f.magFilter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,O(f.minFilter));b.texImage2D(b.TEXTURE_2D,0,O(f.format),f.width,f.height,0,O(f.format),O(f.type),null);b.bindFramebuffer(b.FRAMEBUFFER, +f.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,f.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,f.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,null)}var n,g,i;if(f){n=f.__webGLFramebuffer;g=f.width;i=f.height}else{n=null;g=W.width;i=W.height}if(n!=oa){b.bindFramebuffer(b.FRAMEBUFFER,n);b.viewport(0,0,g,i);j&&b.clear(b.COLOR_BUFFER_BIT| +b.DEPTH_BUFFER_BIT);oa=n}}function X(f,j){var n;if(f=="fragment")n=b.createShader(b.FRAGMENT_SHADER);else f=="vertex"&&(n=b.createShader(b.VERTEX_SHADER));b.shaderSource(n,j);b.compileShader(n);if(!b.getShaderParameter(n,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(n));return null}return n}function O(f){switch(f){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST; +case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT; +case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var W=document.createElement("canvas"),b,ka=null,oa=null,la=this,ma=null,ra=null,pa=null,qa=null,ha=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4], +ua=new THREE.Matrix4,Aa=new Float32Array(16),Ca=new Float32Array(16),wa=new THREE.Vector4,Fa=!0,La=new THREE.Color(0),Ma=0;if(a){if(a.antialias!==undefined)Fa=a.antialias;a.clearColor!==undefined&&La.setHex(a.clearColor);if(a.clearAlpha!==undefined)Ma=a.clearAlpha}this.domElement=W;this.autoClear=!0;this.sortObjects=!1;(function(f,j,n){try{b=W.getContext("experimental-webgl",{antialias:f})}catch(g){console.log(g)}if(!b)throw"cannot create webgl context";b.clearColor(0,0,0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST); +b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(j.r,j.g,j.b,n);_cullEnabled=!0})(Fa,La,Ma);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,j){W.width=f;W.height=j;b.viewport(0,0,W.width,W.height)};this.setClearColorHex=function(f,j){var n=new THREE.Color(f);b.clearColor(n.r,n.g,n.b,j)};this.setClearColor= +function(f,j){b.clearColor(f.r,f.g,f.b,j)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.initMaterial=function(f,j,n){var g,i;if(f instanceof THREE.MeshDepthMaterial)d(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)d(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)d(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)d(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)d(f,THREE.ShaderLib.phong); +else if(f instanceof THREE.LineBasicMaterial)d(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&d(f,THREE.ShaderLib.particle_basic);var u,o,r,x;i=r=x=0;for(u=j.length;i +0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+u.maxDirLights,"#define MAX_POINT_LIGHTS "+u.maxPointLights,u.map?"#define USE_MAP":"",u.envMap?"#define USE_ENVMAP":"",u.lightMap?"#define USE_LIGHTMAP":"",u.vertexColors?"#define USE_COLOR":"",u.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n"); +b.attachShader(n,X("fragment",i+x));b.attachShader(n,X("vertex",u+j));b.linkProgram(n);b.getProgramParameter(n,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(n,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");n.uniforms={};n.attributes={};f.program=n;n=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(g in f.uniforms)n.push(g);g=f.program;x=0;for(j=n.length;x< +j;x++){i=n[x];g.uniforms[i]=b.getUniformLocation(g,i)}g=f.program;n=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];x=0;for(j=n.length;x=0&&b.enableVertexAttribArray(g.color);g.normal>=0&&b.enableVertexAttribArray(g.normal);g.tangent>=0&&b.enableVertexAttribArray(g.tangent);if(f.skinning&&g.skinVertexA>=0&&g.skinVertexB>= +0&&g.skinIndex>=0&&g.skinWeight>=0){b.enableVertexAttribArray(g.skinVertexA);b.enableVertexAttribArray(g.skinVertexB);b.enableVertexAttribArray(g.skinIndex);b.enableVertexAttribArray(g.skinWeight)}};this.render=function(f,j,n,g){var i,u,o,r,x,s,v,J,Q=f.lights,N=f.fog;j.matrixAutoUpdate&&j.update();j.matrixWorldInverse.flattenToArray(Ca);j.projectionMatrix.flattenToArray(Aa);ua.multiply(j.projectionMatrix,j.matrixWorldInverse);m(ua);f.update(undefined,!1,j);this.initWebGLObjects(f,j);Z(n,g!==undefined? +g:!0);this.autoClear&&this.clear();x=f.__webglObjects.length;for(g=0;g=0;i--){g=n.__webglObjects[i].object;j==g&&n.__webglObjects.splice(i,1)}f.__objectsRemoved.splice(0,1)}j=0;for(n=f.__webglObjects.length;j0){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,Da,J)}if(Ba&&N>0){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,Ea,J)}if(Ha){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,o.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,sa,J);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,o.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER, +ia,J)}if(p>0){b.bindBuffer(b.ARRAY_BUFFER,o.__webGLSkinVertexABuffer);b.bufferData(b.ARRAY_BUFFER,S,J);b.bindBuffer(b.ARRAY_BUFFER,o.__webGLSkinVertexBBuffer);b.bufferData(b.ARRAY_BUFFER,T,J);b.bindBuffer(b.ARRAY_BUFFER,o.__webGLSkinIndicesBuffer);b.bufferData(b.ARRAY_BUFFER,U,J);b.bindBuffer(b.ARRAY_BUFFER,o.__webGLSkinWeightsBuffer);b.bufferData(b.ARRAY_BUFFER,V,J)}}}i.__dirtyVertices=!1;i.__dirtyElements=!1;i.__dirtyUvs=!1;i.__dirtyNormals=!1;i.__dirtyTangents=!1;i.__dirtyColors=!1}else if(g instanceof +THREE.Ribbon){i=g.geometry;if(i.__dirtyVertices||i.__dirtyColors){g=i;u=b.DYNAMIC_DRAW;s=void 0;s=void 0;r=void 0;o=void 0;v=g.vertices;J=g.colors;N=v.length;Q=J.length;I=g.__vertexArray;x=g.__colorArray;K=g.__dirtyColors;if(g.__dirtyVertices){for(s=0;s0}}; THREE.Snippets={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif", envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\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 ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif", map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif", diff --git a/examples/webgl_ribbons.html b/examples/webgl_ribbons.html index 048a0874..381f391e 100644 --- a/examples/webgl_ribbons.html +++ b/examples/webgl_ribbons.html @@ -114,8 +114,8 @@ } var tmpRot = new THREE.Matrix4(); - tmpRot.setRotAxis( new THREE.Vector3( 1, 0, 0 ), 1.57 ); - + tmpRot.setRotationAxis( new THREE.Vector3( 1, 0, 0 ), 1.57 ); + var material_base = new THREE.MeshBasicMaterial( { color:0xffffff, vertexColors:true } ); renderer.initMaterial( material_base, scene.lights, scene.fog ); diff --git a/src/core/Matrix4.js b/src/core/Matrix4.js index 9939f0b6..0e487b04 100644 --- a/src/core/Matrix4.js +++ b/src/core/Matrix4.js @@ -26,7 +26,7 @@ THREE.Matrix4 = function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33 THREE.Matrix4.prototype = { - set: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) { + set : function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) { this.n11 = n11; this.n12 = n12; this.n13 = n13; this.n14 = n14; this.n21 = n21; this.n22 = n22; this.n23 = n23; this.n24 = n24; @@ -37,7 +37,7 @@ THREE.Matrix4.prototype = { }, - identity: function () { + identity : function () { this.set( @@ -52,7 +52,7 @@ THREE.Matrix4.prototype = { }, - copy: function ( m ) { + copy : function ( m ) { this.set( @@ -67,21 +67,16 @@ THREE.Matrix4.prototype = { }, - lookAt: function ( eye, center, up ) { + lookAt : function ( eye, center, up ) { - var x = THREE.Matrix4.__tmpVec1, y = THREE.Matrix4.__tmpVec2, z = THREE.Matrix4.__tmpVec3; + var x = THREE.Matrix4.__tmpVec1, + y = THREE.Matrix4.__tmpVec2, + z = THREE.Matrix4.__tmpVec3; z.sub( eye, center ).normalize(); x.cross( up, z ).normalize(); y.cross( z, x ).normalize(); -/* - this.n11 = x.x; this.n12 = x.y; this.n13 = x.z; this.n14 = - x.dot( eye ); - this.n21 = y.x; this.n22 = y.y; this.n23 = y.z; this.n24 = - y.dot( eye ); - this.n31 = z.x; this.n32 = z.y; this.n33 = z.z; this.n34 = - z.dot( eye ); - this.n41 = 0; this.n42 = 0; this.n43 = 0; this.n44 = 1; -*/ - this.n11 = x.x; this.n12 = y.x; this.n13 = z.x; this.n14 = eye.x; this.n21 = x.y; this.n22 = y.y; this.n23 = z.y; this.n24 = eye.y; this.n31 = x.z; this.n32 = y.z; this.n33 = z.z; this.n34 = eye.z; @@ -90,7 +85,7 @@ THREE.Matrix4.prototype = { }, - multiplyVector3: function ( v ) { + multiplyVector3 : function ( v ) { var vx = v.x, vy = v.y, vz = v.z, d = 1 / ( this.n41 * vx + this.n42 * vy + this.n43 * vz + this.n44 ); @@ -103,7 +98,7 @@ THREE.Matrix4.prototype = { }, - multiplyVector3OnlyZ: function( v ) { + multiplyVector3OnlyZ : function( v ) { var vx = v.x, vy = v.y, vz = v.z, d = 1 / ( this.n41 * vx + this.n42 * vy + this.n43 * vz + this.n44 ); @@ -112,7 +107,7 @@ THREE.Matrix4.prototype = { }, - multiplyVector4: function ( v ) { + multiplyVector4 : function ( v ) { var vx = v.x, vy = v.y, vz = v.z, vw = v.w; @@ -125,7 +120,7 @@ THREE.Matrix4.prototype = { }, - crossVector: function ( a ) { + crossVector : function ( a ) { var v = new THREE.Vector4(); @@ -139,7 +134,7 @@ THREE.Matrix4.prototype = { }, - multiply: function ( a, b ) { + multiply : function ( a, b ) { var a11 = a.n11, a12 = a.n12, a13 = a.n13, a14 = a.n14, a21 = a.n21, a22 = a.n22, a23 = a.n23, a24 = a.n24, @@ -151,28 +146,6 @@ THREE.Matrix4.prototype = { b31 = b.n31, b32 = b.n32, b33 = b.n33, b34 = b.n34, b41 = b.n41, b42 = b.n42, b43 = b.n43, b44 = b.n44; - /* - this.n11 = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41; - this.n12 = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42; - this.n13 = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43; - this.n14 = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44; - - this.n21 = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41; - this.n22 = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42; - this.n23 = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43; - this.n24 = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44; - - this.n31 = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41; - this.n32 = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42; - this.n33 = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43; - this.n34 = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44; - - this.n41 = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41; - this.n42 = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42; - this.n43 = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43; - this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44; - */ - this.n11 = a11 * b11 + a12 * b21 + a13 * b31; this.n12 = a11 * b12 + a12 * b22 + a13 * b32; this.n13 = a11 * b13 + a12 * b23 + a13 * b33; @@ -193,22 +166,7 @@ THREE.Matrix4.prototype = { this.n43 = a41 * b13 + a42 * b23 + a43 * b33; this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44; - return this; - - }, - - multiplyToArray: function ( a, b, r ) { - - var a11 = a.n11, a12 = a.n12, a13 = a.n13, a14 = a.n14, - a21 = a.n21, a22 = a.n22, a23 = a.n23, a24 = a.n24, - a31 = a.n31, a32 = a.n32, a33 = a.n33, a34 = a.n34, - a41 = a.n41, a42 = a.n42, a43 = a.n43, a44 = a.n44, - - b11 = b.n11, b12 = b.n12, b13 = b.n13, b14 = b.n14, - b21 = b.n21, b22 = b.n22, b23 = b.n23, b24 = b.n24, - b31 = b.n31, b32 = b.n32, b33 = b.n33, b34 = b.n34, - b41 = b.n41, b42 = b.n42, b43 = b.n43, b44 = b.n44; - + /* this.n11 = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41; this.n12 = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42; this.n13 = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43; @@ -228,6 +186,15 @@ THREE.Matrix4.prototype = { this.n42 = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42; this.n43 = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43; this.n44 = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44; + */ + + return this; + + }, + + multiplyToArray : function ( a, b, r ) { + + this.multiply( a, b ); r[ 0 ] = this.n11; r[ 1 ] = this.n21; r[ 2 ] = this.n31; r[ 3 ] = this.n41; r[ 4 ] = this.n12; r[ 5 ] = this.n22; r[ 6 ] = this.n32; r[ 7 ] = this.n42; @@ -238,64 +205,15 @@ THREE.Matrix4.prototype = { }, - multiplySelf: function ( m ) { + multiplySelf : function ( m ) { - var n11 = this.n11, n12 = this.n12, n13 = this.n13, n14 = this.n14, - n21 = this.n21, n22 = this.n22, n23 = this.n23, n24 = this.n24, - n31 = this.n31, n32 = this.n32, n33 = this.n33, n34 = this.n34, - n41 = this.n41, n42 = this.n42, n43 = this.n43, n44 = this.n44, - mn11 = m.n11, mn21 = m.n21, mn31 = m.n31, mn41 = m.n41, - mn12 = m.n12, mn22 = m.n22, mn32 = m.n32, mn42 = m.n42, - mn13 = m.n13, mn23 = m.n23, mn33 = m.n33, mn43 = m.n43, - mn14 = m.n14, mn24 = m.n24, mn34 = m.n34, mn44 = m.n44; - - /* - this.n11 = n11 * mn11 + n12 * mn21 + n13 * mn31 + n14 * mn41; - this.n12 = n11 * mn12 + n12 * mn22 + n13 * mn32 + n14 * mn42; - this.n13 = n11 * mn13 + n12 * mn23 + n13 * mn33 + n14 * mn43; - this.n14 = n11 * mn14 + n12 * mn24 + n13 * mn34 + n14 * mn44; - - this.n21 = n21 * mn11 + n22 * mn21 + n23 * mn31 + n24 * mn41; - this.n22 = n21 * mn12 + n22 * mn22 + n23 * mn32 + n24 * mn42; - this.n23 = n21 * mn13 + n22 * mn23 + n23 * mn33 + n24 * mn43; - this.n24 = n21 * mn14 + n22 * mn24 + n23 * mn34 + n24 * mn44; - - this.n31 = n31 * mn11 + n32 * mn21 + n33 * mn31 + n34 * mn41; - this.n32 = n31 * mn12 + n32 * mn22 + n33 * mn32 + n34 * mn42; - this.n33 = n31 * mn13 + n32 * mn23 + n33 * mn33 + n34 * mn43; - this.n34 = n31 * mn14 + n32 * mn24 + n33 * mn34 + n34 * mn44; - - this.n41 = n41 * mn11 + n42 * mn21 + n43 * mn31 + n44 * mn41; - this.n42 = n41 * mn12 + n42 * mn22 + n43 * mn32 + n44 * mn42; - this.n43 = n41 * mn13 + n42 * mn23 + n43 * mn33 + n44 * mn43; - this.n44 = n41 * mn14 + n42 * mn24 + n43 * mn34 + n44 * mn44; - */ - - this.n11 = n11 * mn11 + n12 * mn21 + n13 * mn31; - this.n12 = n11 * mn12 + n12 * mn22 + n13 * mn32; - this.n13 = n11 * mn13 + n12 * mn23 + n13 * mn33; - this.n14 = n11 * mn14 + n12 * mn24 + n13 * mn34 + n14; - - this.n21 = n21 * mn11 + n22 * mn21 + n23 * mn31; - this.n22 = n21 * mn12 + n22 * mn22 + n23 * mn32; - this.n23 = n21 * mn13 + n22 * mn23 + n23 * mn33; - this.n24 = n21 * mn14 + n22 * mn24 + n23 * mn34 + n24; - - this.n31 = n31 * mn11 + n32 * mn21 + n33 * mn31; - this.n32 = n31 * mn12 + n32 * mn22 + n33 * mn32; - this.n33 = n31 * mn13 + n32 * mn23 + n33 * mn33; - this.n34 = n31 * mn14 + n32 * mn24 + n33 * mn34 + n34; - - this.n41 = n41 * mn11 + n42 * mn21 + n43 * mn31; - this.n42 = n41 * mn12 + n42 * mn22 + n43 * mn32; - this.n43 = n41 * mn13 + n42 * mn23 + n43 * mn33; - this.n44 = n41 * mn14 + n42 * mn24 + n43 * mn34 + n44; + this.multiply( this, m ); return this; }, - multiplyScalar: function ( s ) { + multiplyScalar : function ( s ) { this.n11 *= s; this.n12 *= s; this.n13 *= s; this.n14 *= s; this.n21 *= s; this.n22 *= s; this.n23 *= s; this.n24 *= s; @@ -306,7 +224,7 @@ THREE.Matrix4.prototype = { }, - determinant: function () { + determinant : function () { var n11 = this.n11, n12 = this.n12, n13 = this.n13, n14 = this.n14, n21 = this.n21, n22 = this.n22, n23 = this.n23, n24 = this.n24, @@ -349,7 +267,7 @@ THREE.Matrix4.prototype = { }, - transpose: function () { + transpose : function () { var tmp; @@ -365,7 +283,7 @@ THREE.Matrix4.prototype = { }, - clone: function () { + clone : function () { var m = new THREE.Matrix4(); @@ -378,14 +296,18 @@ THREE.Matrix4.prototype = { }, - flatten: function () { + flatten : function () { + + this.flat[ 0 ] = this.n11; this.flat[ 1 ] = this.n21; this.flat[ 2 ] = this.n31; this.flat[ 3 ] = this.n41; + this.flat[ 4 ] = this.n12; this.flat[ 5 ] = this.n22; this.flat[ 6 ] = this.n32; this.flat[ 7 ] = this.n42; + this.flat[ 8 ] = this.n13; this.flat[ 9 ] = this.n23; this.flat[ 10 ] = this.n33; this.flat[ 11 ] = this.n43; + this.flat[ 12 ] = this.n14; this.flat[ 13 ] = this.n24; this.flat[ 14 ] = this.n34; this.flat[ 15 ] = this.n44; - this.flattenToArray( this.flat ); return this.flat; }, - flattenToArray: function ( flat ) { + flattenToArray : function ( flat ) { flat[ 0 ] = this.n11; flat[ 1 ] = this.n21; flat[ 2 ] = this.n31; flat[ 3 ] = this.n41; flat[ 4 ] = this.n12; flat[ 5 ] = this.n22; flat[ 6 ] = this.n32; flat[ 7 ] = this.n42; @@ -396,7 +318,7 @@ THREE.Matrix4.prototype = { }, - flattenToArrayOffset: function( flat, offset ) { + flattenToArrayOffset : function( flat, offset ) { flat[ offset ] = this.n11; flat[ offset + 1 ] = this.n21; @@ -422,7 +344,7 @@ THREE.Matrix4.prototype = { }, - setTranslation: function( x, y, z ) { + setTranslation : function( x, y, z ) { this.set( @@ -437,7 +359,7 @@ THREE.Matrix4.prototype = { }, - setScale: function ( x, y, z ) { + setScale : function ( x, y, z ) { this.set( @@ -452,7 +374,7 @@ THREE.Matrix4.prototype = { }, - setRotX: function ( theta ) { + setRotationX : function ( theta ) { var c = Math.cos( theta ), s = Math.sin( theta ); @@ -469,7 +391,7 @@ THREE.Matrix4.prototype = { }, - setRotY: function( theta ) { + setRotationY : function( theta ) { var c = Math.cos( theta ), s = Math.sin( theta ); @@ -486,7 +408,7 @@ THREE.Matrix4.prototype = { }, - setRotZ: function( theta ) { + setRotationZ : function( theta ) { var c = Math.cos( theta ), s = Math.sin( theta ); @@ -503,7 +425,7 @@ THREE.Matrix4.prototype = { }, - setRotAxis: function( axis, angle ) { + setRotationAxis : function( axis, angle ) { // Based on http://www.gamedev.net/reference/articles/article1199.asp @@ -526,7 +448,7 @@ THREE.Matrix4.prototype = { }, - setPosition: function( v ) { + setPosition : function( v ) { this.n14 = v.x; this.n24 = v.y; @@ -536,7 +458,7 @@ THREE.Matrix4.prototype = { }, - setRotationFromEuler: function( v ) { + setRotationFromEuler : function( v ) { var x = v.x, y = v.y, z = v.z, a = Math.cos( x ), b = Math.sin( x ), @@ -558,7 +480,7 @@ THREE.Matrix4.prototype = { }, - setRotationFromQuaternion: function( q ) { + setRotationFromQuaternion : function( q ) { var x = q.x, y = q.y, z = q.z, w = q.w, x2 = x + x, y2 = y + y, z2 = z + z, @@ -591,70 +513,36 @@ THREE.Matrix4.prototype = { return this; + }, + + extractPosition : function ( m ) { + + this.n14 = m.n14; + this.n24 = m.n24; + this.n34 = m.n34; + + }, + + extractRotation : function ( m, s ) { + + var invScaleX = 1 / s.x, invScaleY = 1 / s.y, invScaleZ = 1 / s.z; + + this.n11 = m.n11 * invScaleX; + this.n21 = m.n21 * invScaleX; + this.n31 = m.n31 * invScaleX; + + this.n12 = m.n12 * invScaleY; + this.n22 = m.n22 * invScaleY; + this.n32 = m.n32 * invScaleY; + + this.n13 = m.n13 * invScaleZ; + this.n23 = m.n23 * invScaleZ; + this.n33 = m.n33 * invScaleZ; + } }; -THREE.Matrix4.translationMatrix = function ( x, y, z ) { - - var m = new THREE.Matrix4(); - - m.setTranslation( x, y, z ); - - return m; - -}; - -THREE.Matrix4.scaleMatrix = function ( x, y, z ) { - - var m = new THREE.Matrix4(); - - m.setScale( x, y, z ); - - return m; - -}; - -THREE.Matrix4.rotationXMatrix = function ( theta ) { - - var m = new THREE.Matrix4(); - - m.setRotX( theta ); - - return m; - -}; - -THREE.Matrix4.rotationYMatrix = function ( theta ) { - - var m = new THREE.Matrix4(); - - m.setRotY( theta ); - - return m; - -}; - -THREE.Matrix4.rotationZMatrix = function ( theta ) { - - var m = new THREE.Matrix4(); - - m.setRotZ( theta ); - - return m; - -}; - -THREE.Matrix4.rotationAxisAngleMatrix = function ( axis, angle ) { - - var m = new THREE.Matrix4(); - - m.setRotAxis( axis, angle ); - - return m; - -}; - THREE.Matrix4.makeInvert = function ( m1, m2 ) { // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm @@ -688,47 +576,6 @@ THREE.Matrix4.makeInvert = function ( m1, m2 ) { }; -/* -THREE.Matrix4.makeInvert = function ( m1 ) { - - var m2 = new THREE.Matrix4(); - - return THREE.Matrix4.makeInvertTo( m1, m2 ); - -}; - -THREE.Matrix4.makeInvertTo = function ( m1, m2 ) { - - var n11 = m1.n11, n12 = m1.n12, n13 = m1.n13, n14 = m1.n14, - n21 = m1.n21, n22 = m1.n22, n23 = m1.n23, n24 = m1.n24, - n31 = m1.n31, n32 = m1.n32, n33 = m1.n33, n34 = m1.n34, - n41 = m1.n41, n42 = m1.n42, n43 = m1.n43, n44 = m1.n44; - - //TODO: make this more efficient - //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm ) - - m2.n11 = n23*n34*n42 - n24*n33*n42 + n24*n32*n43 - n22*n34*n43 - n23*n32*n44 + n22*n33*n44; - m2.n12 = n14*n33*n42 - n13*n34*n42 - n14*n32*n43 + n12*n34*n43 + n13*n32*n44 - n12*n33*n44; - m2.n13 = n13*n24*n42 - n14*n23*n42 + n14*n22*n43 - n12*n24*n43 - n13*n22*n44 + n12*n23*n44; - m2.n14 = n14*n23*n32 - n13*n24*n32 - n14*n22*n33 + n12*n24*n33 + n13*n22*n34 - n12*n23*n34; - m2.n21 = n24*n33*n41 - n23*n34*n41 - n24*n31*n43 + n21*n34*n43 + n23*n31*n44 - n21*n33*n44; - m2.n22 = n13*n34*n41 - n14*n33*n41 + n14*n31*n43 - n11*n34*n43 - n13*n31*n44 + n11*n33*n44; - m2.n23 = n14*n23*n41 - n13*n24*n41 - n14*n21*n43 + n11*n24*n43 + n13*n21*n44 - n11*n23*n44; - m2.n24 = n13*n24*n31 - n14*n23*n31 + n14*n21*n33 - n11*n24*n33 - n13*n21*n34 + n11*n23*n34; - m2.n31 = n22*n34*n41 - n24*n32*n41 + n24*n31*n42 - n21*n34*n42 - n22*n31*n44 + n21*n32*n44; - m2.n32 = n14*n32*n41 - n12*n34*n41 - n14*n31*n42 + n11*n34*n42 + n12*n31*n44 - n11*n32*n44; - m2.n33 = n13*n24*n41 - n14*n22*n41 + n14*n21*n42 - n11*n24*n42 - n12*n21*n44 + n11*n22*n44; - m2.n34 = n14*n22*n31 - n12*n24*n31 - n14*n21*n32 + n11*n24*n32 + n12*n21*n34 - n11*n22*n34; - m2.n41 = n23*n32*n41 - n22*n33*n41 - n23*n31*n42 + n21*n33*n42 + n22*n31*n43 - n21*n32*n43; - m2.n42 = n12*n33*n41 - n13*n32*n41 + n13*n31*n42 - n11*n33*n42 - n12*n31*n43 + n11*n32*n43; - m2.n43 = n13*n22*n41 - n12*n23*n41 - n13*n21*n42 + n11*n23*n42 + n12*n21*n43 - n11*n22*n43; - m2.n44 = n12*n23*n31 - n13*n22*n31 + n13*n21*n32 - n11*n23*n32 - n12*n21*n33 + n11*n22*n33; - m2.multiplyScalar( 1 / m1.determinant() ); - - return m2; - -}; -*/ THREE.Matrix4.makeInvert3x3 = function ( m1 ) { // input: THREE.Matrix4, output: THREE.Matrix3 diff --git a/src/core/Object3D.js b/src/core/Object3D.js index 78aabbfa..b8112d4f 100644 --- a/src/core/Object3D.js +++ b/src/core/Object3D.js @@ -35,6 +35,30 @@ THREE.Object3D = function() { THREE.Object3D.prototype = { + translateX : function () { + + + + }, + + translateY : function () { + + + + }, + + translateZ : function () { + + + + }, + + lookAt : function ( object ) { + + + + }, + addChild: function ( child ) { if ( this.children.indexOf( child ) === - 1 ) { @@ -124,21 +148,7 @@ THREE.Object3D.prototype = { } - // extract rotation matrix - - var invScaleX = 1 / this.scale.x, invScaleY = 1 / this.scale.y, invScaleZ = 1 / this.scale.z; - - this.matrixRotationWorld.n11 = this.matrixWorld.n11 * invScaleX; - this.matrixRotationWorld.n21 = this.matrixWorld.n21 * invScaleX; - this.matrixRotationWorld.n31 = this.matrixWorld.n31 * invScaleX; - - this.matrixRotationWorld.n12 = this.matrixWorld.n12 * invScaleY; - this.matrixRotationWorld.n22 = this.matrixWorld.n22 * invScaleY; - this.matrixRotationWorld.n32 = this.matrixWorld.n32 * invScaleY; - - this.matrixRotationWorld.n13 = this.matrixWorld.n13 * invScaleZ; - this.matrixRotationWorld.n23 = this.matrixWorld.n23 * invScaleZ; - this.matrixRotationWorld.n33 = this.matrixWorld.n33 * invScaleZ; + this.matrixRotationWorld.extractRotation( this.matrixWorld, this.scale ); this.matrixNeedsUpdate = false; forceUpdate = true; diff --git a/src/core/Vector3.js b/src/core/Vector3.js index 1258f7c1..6ad052f7 100644 --- a/src/core/Vector3.js +++ b/src/core/Vector3.js @@ -20,7 +20,7 @@ THREE.Vector3 = function ( x, y, z ) { THREE.Vector3.prototype = { - set: function ( x, y, z ) { + set : function ( x, y, z ) { this.x = x; this.y = y; @@ -280,9 +280,15 @@ THREE.Vector3.prototype = { }, - setLength : function( len ) { + setLength : function ( l ) { - return this.normalize().multiplyScalar( len ); + return this.normalize().multiplyScalar( l ); + + }, + + setRotationFromMatrix : function ( m ) { + + },