From 517f0f55ca8cc68e9b80bb86d2b30a83cc09fd69 Mon Sep 17 00:00:00 2001 From: alteredq Date: Sun, 11 Sep 2011 02:49:42 +0200 Subject: [PATCH] Fixed bug preventing setting 0 values in constructor at several places. This buggy pattern ("something = parameter || nonzero value") exists at more places though elsewhere setting to zero doesn't make that much sense (e.g. in geometries). Not sure if we should change it everywhere to proper pattern ("something = ( parameter !== undefined ) ? parameter : value"). Maybe it would be good for establishing habit. I remember fixing this buggy pattern long ago but it just keeps popping up. --- build/Three.js | 11 +- build/custom/ThreeCanvas.js | 85 +++++------ build/custom/ThreeDOM.js | 45 +++--- build/custom/ThreeSVG.js | 7 +- build/custom/ThreeWebGL.js | 249 +++++++++++++++++---------------- src/cameras/Camera.js | 5 +- src/core/Matrix4.js | 8 +- src/lights/DirectionalLight.js | 9 +- src/lights/PointLight.js | 8 +- src/lights/SpotLight.js | 6 +- src/scenes/Fog.js | 5 +- 11 files changed, 222 insertions(+), 216 deletions(-) diff --git a/build/Three.js b/build/Three.js index 2e809099af..fd115420ad 100644 --- a/build/Three.js +++ b/build/Three.js @@ -21,7 +21,8 @@ t=p.dot(w),b.doubleSided||(b.flipSided?t>0:t<0)))if(t=w.dot((new THREE.Vector3). THREE.Rectangle=function(){function b(){m=f-c;k=h-e}var c,e,f,h,m,k,n=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return m};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(k,m,w,t){n=!1;c=k;e=m;f=w;h=t;b()};this.addPoint=function(k,m){n?(n=!1,c=k,e=m,f=k,h=m):(c=ck?f:k,h=h>m?h:m);b()};this.add3Points= function(k,m,w,t,x,p){n?(n=!1,c=kw?k>x?k:x:w>x?w:x,h=m>t?m>p?m:p:t>p?t:p):(c=kw?k>x?k>f?k:f:x>f?x:f:w>x?w>f?w:f:x>f?x:f,h=m>t?m>p?m>h?m:h:p>h?p:h:t>p?t>h?t:h:p>h?p:h);b()};this.addRectangle=function(k){n?(n=!1,c=k.getLeft(),e=k.getTop(),f=k.getRight(),h=k.getBottom()):(c=ck.getRight()?f:k.getRight(),h=h> k.getBottom()?h:k.getBottom());b()};this.inflate=function(k){c-=k;e-=k;f+=k;h+=k;b()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();e=e>k.getTop()?e:k.getTop();f=f=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){n=!0;h=f=e=c=0;b()};this.isEmpty=function(){return n}};THREE.Matrix3=function(){this.m=[]}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,e,f,h,m,k,n,u,v,w,t,x,p,y,z){this.set(b||1,c||0,e||0,f||0,h||0,m||1,k||0,n||0,u||0,v||0,w||1,t||0,x||0,p||0,y||0,z||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}}; +THREE.Matrix4=function(b,c,e,f,h,m,k,n,u,v,w,t,x,p,y,z){this.set(b!==void 0?b:1,c||0,e||0,f||0,h||0,m!==void 0?m:1,k||0,n||0,u||0,v||0,w!==void 0?w:1,t||0,x||0,p||0,y||0,z!==void 0?z:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,h,m,k,n,u,v,w,t,x,p,y,z){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=h;this.n22=m;this.n23=k;this.n24=n;this.n31=u;this.n32=v;this.n33=w;this.n34=t;this.n41=x;this.n42=p;this.n43=y;this.n44=z;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(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b, c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,m=THREE.Matrix4.__v3;m.sub(b,c).normalize();if(m.length()===0)m.z=1;f.cross(e,m).normalize();f.length()===0&&(m.x+=1.0E-4,f.cross(e,m).normalize());h.cross(m,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=m.x;this.n21=f.y;this.n22=h.y;this.n23=m.y;this.n31=f.z;this.n32=h.z;this.n33=m.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,h=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*h; b.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*h;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*h;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,h=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*h;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*h;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*h;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*h;return b},rotateAxis:function(b){var c=b.x,e=b.y,f=b.z;b.x=c*this.n11+e*this.n12+f*this.n13;b.y=c*this.n21+e*this.n22+f*this.n23;b.z=c*this.n31+ @@ -87,15 +88,15 @@ THREE.GeometryCount=0; THREE.Spline=function(b){function c(b,e,c,f,k,h,m){b=(c-b)*0.5;f=(f-e)*0.5;return(2*(e-c)+b+f)*m+(-3*(e-c)-2*b-f)*h+b*k+e}this.points=b;var e=[],f={x:0,y:0,z:0},h,m,k,n,u,v,w,t,x;this.initFromArray=function(b){this.points=[];for(var e=0;ethis.points.length-2?m:m+1;e[3]=m>this.points.length-3?m:m+2;v=this.points[e[0]];w=this.points[e[1]]; t=this.points[e[2]];x=this.points[e[3]];n=k*k;u=k*n;f.x=c(v.x,w.x,t.x,x.x,k,n,u);f.y=c(v.y,w.y,t.y,x.y,k,n,u);f.z=c(v.z,w.z,t.z,x.z,k,n,u);return f};this.getControlPointsArray=function(){var b,e,c=this.points.length,f=[];for(b=0;b0&&a>0&&f+a<1}if(a instanceof THREE.Particle){var d=b(this.origin,this.direction,a.matrixWorld.getPosition());if(d==null||d>a.scale.x)return[];return[{distance:d,point:a.position,face:null,object:a}]}else if(a instanceof THREE.Mesh){d=b(this.origin,this.direction,a.matrixWorld.getPosition());if(d==null||d>a.geometry.boundingSphere.radius*Math.max(a.scale.x, -Math.max(a.scale.y,a.scale.z)))return[];var e,g,f,h,j,l,o,i,m,k,p=a.geometry,r=p.vertices,u=[],d=0;for(e=p.faces.length;d0:i<0)))if(i=o.dot((new THREE.Vector3).sub(f,m))/i,m=m.addSelf(k.multiplyScalar(i)),g instanceof THREE.Face3)c(m,f,h,j)&&(g={distance:this.origin.distanceTo(m),point:m,face:g,object:a},u.push(g));else if(g instanceof THREE.Face4&&(c(m,f,h,l)||c(m,h,j,l)))g={distance:this.origin.distanceTo(m),point:m,face:g,object:a},u.push(g);u.sort(function(a,b){return a.distance-b.distance});return u}else return[]}}; +Math.max(a.scale.y,a.scale.z)))return[];var e,g,f,h,j,l,o,i,n,k,p=a.geometry,q=p.vertices,u=[],d=0;for(e=p.faces.length;d0:i<0)))if(i=o.dot((new THREE.Vector3).sub(f,n))/i,n=n.addSelf(k.multiplyScalar(i)),g instanceof THREE.Face3)c(n,f,h,j)&&(g={distance:this.origin.distanceTo(n),point:n,face:g,object:a},u.push(g));else if(g instanceof THREE.Face4&&(c(n,f,h,l)||c(n,h,j,l)))g={distance:this.origin.distanceTo(n),point:n,face:g,object:a},u.push(g);u.sort(function(a,b){return a.distance-b.distance});return u}else return[]}}; THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,o,i){h=!1;b=f;c=g;d=o;e=i;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= -function(f,g,o,i,m,k){h?(h=!1,b=fo?f>m?f:m:o>m?o:m,e=g>i?g>k?g:k:i>k?i:k):(b=fo?f>m?f>d?f:d:m>d?m:d:o>m?o>d?o:d:m>d?m:d,e=g>i?g>k?g>e?g:e:k>e?k:e:i>k?i>e?i:e:k>e?k:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> +function(f,g,o,i,n,k){h?(h=!1,b=fo?f>n?f:n:o>n?o:n,e=g>i?g>k?g:k:i>k?i:k):(b=fo?f>n?f>d?f:d:n>d?n:d:o>n?o>d?o:d:n>d?n:d,e=g>i?g>k?g>e?g:e:k>e?k:e:i>k?i>e?i:e:k>e?k:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};THREE.Matrix3=function(){this.m=[]}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,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,f,h,j,l,o,i,m,k,p,r){this.set(a||1,b||0,c||0,d||0,e||0,g||1,f||0,h||0,j||0,l||0,o||1,i||0,m||0,k||0,p||0,r||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,f,h,j,l,o,i,m,k,p,r){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=h;this.n31=j;this.n32=l;this.n33=o;this.n34=i;this.n41=m;this.n42=k;this.n43=p;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, +THREE.Matrix3.prototype={constructor:THREE.Matrix3,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,f,h,j,l,o,i,n,k,p,q){this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,g!==void 0?g:1,f||0,h||0,j||0,l||0,o!==void 0?o:1,i||0,n||0,k||0,p||0,q!==void 0?q:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,f,h,j,l,o,i,n,k,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=h;this.n31=j;this.n32=l;this.n33=o;this.n34=i;this.n41=n;this.n42=k;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.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.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},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},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+ -c*this.n32+d*this.n33;a.normalize();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,f=a.n21,h=a.n22,j=a.n23,l=a.n24,o=a.n31,i=a.n32,m=a.n33,k=a.n34,p=a.n41,r=a.n42,u=a.n43,s=a.n44,K=b.n11,P=b.n12, -y=b.n13,L=b.n14,M=b.n21,q=b.n22,n=b.n23,z=b.n24,A=b.n31,R=b.n32,S=b.n33,E=b.n34,I=b.n41,G=b.n42,H=b.n43,N=b.n44;this.n11=c*K+d*M+e*A+g*I;this.n12=c*P+d*q+e*R+g*G;this.n13=c*y+d*n+e*S+g*H;this.n14=c*L+d*z+e*E+g*N;this.n21=f*K+h*M+j*A+l*I;this.n22=f*P+h*q+j*R+l*G;this.n23=f*y+h*n+j*S+l*H;this.n24=f*L+h*z+j*E+l*N;this.n31=o*K+i*M+m*A+k*I;this.n32=o*P+i*q+m*R+k*G;this.n33=o*y+i*n+m*S+k*H;this.n34=o*L+i*z+m*E+k*N;this.n41=p*K+r*M+u*A+s*I;this.n42=p*P+r*q+u*R+s*G;this.n43=p*y+r*n+u*S+s*H;this.n44=p*L+r* +c*this.n32+d*this.n33;a.normalize();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,f=a.n21,h=a.n22,j=a.n23,l=a.n24,o=a.n31,i=a.n32,n=a.n33,k=a.n34,p=a.n41,q=a.n42,u=a.n43,s=a.n44,K=b.n11,P=b.n12, +y=b.n13,L=b.n14,M=b.n21,r=b.n22,m=b.n23,z=b.n24,A=b.n31,R=b.n32,S=b.n33,E=b.n34,I=b.n41,G=b.n42,H=b.n43,N=b.n44;this.n11=c*K+d*M+e*A+g*I;this.n12=c*P+d*r+e*R+g*G;this.n13=c*y+d*m+e*S+g*H;this.n14=c*L+d*z+e*E+g*N;this.n21=f*K+h*M+j*A+l*I;this.n22=f*P+h*r+j*R+l*G;this.n23=f*y+h*m+j*S+l*H;this.n24=f*L+h*z+j*E+l*N;this.n31=o*K+i*M+n*A+k*I;this.n32=o*P+i*r+n*R+k*G;this.n33=o*y+i*m+n*S+k*H;this.n34=o*L+i*z+n*E+k*N;this.n41=p*K+q*M+u*A+s*I;this.n42=p*P+q*r+u*R+s*G;this.n43=p*y+q*m+u*S+s*H;this.n44=p*L+q* z+u*E+s*N;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,g=this.n22,f=this.n23,h=this.n24,j=this.n31,l=this.n32,o=this.n33,i=this.n34,m=this.n41,k=this.n42,p=this.n43,r=this.n44;return d*f*l*m-c*h*l*m-d*g*o*m+b*h*o*m+c*g*i*m-b*f*i*m-d*f*j*k+c*h*j*k+d*e*o*k-a*h*o*k-c*e*i*k+a*f*i*k+d*g*j*p-b*h*j*p-d*e*l*p+a*h*l*p+b*e*i*p-a*g*i*p-c*g*j*r+b*f*j*r+c*e*l*r-a*f*l*r-b*e*o*r+a*g*o*r}, +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,f=this.n23,h=this.n24,j=this.n31,l=this.n32,o=this.n33,i=this.n34,n=this.n41,k=this.n42,p=this.n43,q=this.n44;return d*f*l*n-c*h*l*n-d*g*o*n+b*h*o*n+c*g*i*n-b*f*i*n-d*f*j*k+c*h*j*k+d*e*o*k-a*h*o*k-c*e*i*k+a*f*i*k+d*g*j*p-b*h*j*p-d*e*l*p+a*h*l*p+b*e*i*p-a*g*i*p-c*g*j*q+b*f*j*q+c*e*l*q-a*f*l*q-b*e*o*q+a*g*o*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.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; @@ -41,8 +42,8 @@ a.x,c=a.y,d=a.z,e=a.w,g=b+b,f=c+c,h=d+d,a=b*g,j=b*f;b*=h;var l=c*f;c*=h;d*=h;g*= d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);g.set(this.n13,this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length(); c.y=e.length();c.z=g.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},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,g=a.n14,f=a.n21,h=a.n22,j=a.n23,l=a.n24,o=a.n31,i=a.n32,m=a.n33,k=a.n34,p=a.n41,r=a.n42,u=a.n43,s=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=j*k*r-l*m*r+l*i*u-h*k*u-j*i*s+h*m*s;b.n12=g*m*r-e*k*r-g*i*u+d*k*u+e*i*s-d*m*s;b.n13=e*l*r-g*j*r+g*h*u-d*l*u-e*h*s+d*j*s;b.n14=g*j*i-e*l*i-g*h*m+d*l*m+e*h*k-d*j*k;b.n21=l*m*p-j*k*p-l*o*u+f*k*u+j*o*s-f*m*s;b.n22=e*k*p-g*m*p+g*o*u-c*k*u-e*o*s+c*m*s;b.n23=g*j*p-e*l*p-g*f*u+c*l*u+e*f*s-c*j*s;b.n24= -e*l*o-g*j*o+g*f*m-c*l*m-e*f*k+c*j*k;b.n31=h*k*p-l*i*p+l*o*r-f*k*r-h*o*s+f*i*s;b.n32=g*i*p-d*k*p-g*o*r+c*k*r+d*o*s-c*i*s;b.n33=e*l*p-g*h*p+g*f*r-c*l*r-d*f*s+c*h*s;b.n34=g*h*o-d*l*o-g*f*i+c*l*i+d*f*k-c*h*k;b.n41=j*i*p-h*m*p-j*o*r+f*m*r+h*o*u-f*i*u;b.n42=d*m*p-e*i*p+e*o*r-c*m*r-d*o*u+c*i*u;b.n43=e*h*p-d*j*p-e*f*r+c*j*r+d*f*u-c*h*u;b.n44=d*j*o-e*h*o+e*f*i-c*j*i-d*f*m+c*h*m;b.multiplyScalar(1/a.determinant());return b}; +THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,j=a.n23,l=a.n24,o=a.n31,i=a.n32,n=a.n33,k=a.n34,p=a.n41,q=a.n42,u=a.n43,s=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=j*k*q-l*n*q+l*i*u-h*k*u-j*i*s+h*n*s;b.n12=g*n*q-e*k*q-g*i*u+d*k*u+e*i*s-d*n*s;b.n13=e*l*q-g*j*q+g*h*u-d*l*u-e*h*s+d*j*s;b.n14=g*j*i-e*l*i-g*h*n+d*l*n+e*h*k-d*j*k;b.n21=l*n*p-j*k*p-l*o*u+f*k*u+j*o*s-f*n*s;b.n22=e*k*p-g*n*p+g*o*u-c*k*u-e*o*s+c*n*s;b.n23=g*j*p-e*l*p-g*f*u+c*l*u+e*f*s-c*j*s;b.n24= +e*l*o-g*j*o+g*f*n-c*l*n-e*f*k+c*j*k;b.n31=h*k*p-l*i*p+l*o*q-f*k*q-h*o*s+f*i*s;b.n32=g*i*p-d*k*p-g*o*q+c*k*q+d*o*s-c*i*s;b.n33=e*l*p-g*h*p+g*f*q-c*l*q-d*f*s+c*h*s;b.n34=g*h*o-d*l*o-g*f*i+c*l*i+d*f*k-c*h*k;b.n41=j*i*p-h*n*p-j*o*q+f*n*q+h*o*u-f*i*u;b.n42=d*n*p-e*i*p+e*o*q-c*n*q-d*o*u+c*i*u;b.n43=e*h*p-d*j*p-e*f*q+c*j*q+d*f*u-c*h*u;b.n44=d*j*o-e*h*o+e*f*i-c*j*i-d*f*n+c*h*n;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,f=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,o=-a.n23*a.n11+a.n21*a.n13,i=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*f+a.n31*l;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*h;c[5]=a*j;c[6]=a*l;c[7]=a*o;c[8]=a*i;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+e)/(g-e);f.n34=-2*g*e/(g-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};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 f,h,j,l;f=new THREE.Matrix4;h=b-a;j=c-d;l=g-e;f.n11=2/h;f.n12=0;f.n13=0;f.n14=-((b+a)/h);f.n21=0;f.n22=2/j;f.n23=0;f.n24=-((c+d)/j);f.n31=0;f.n32=0;f.n33=-2/l;f.n34=-((g+e)/l);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; @@ -52,17 +53,17 @@ THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){thi -1){a.parent!==void 0&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},remove:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),dH&&f.positionScreen.z0&&q.z<1))B=P[K]=P[K]||new THREE.RenderableParticle,K++,s=B,s.x=q.x/q.w,s.y=q.y/q.w,s.z=q.z,s.rotation=t.rotation.z,s.scale.x=t.scale.x*Math.abs(s.x-(q.x+e.projectionMatrix.n11)/(q.w+e.projectionMatrix.n14)),s.scale.y=t.scale.y*Math.abs(s.y-(q.y+ -e.projectionMatrix.n22)/(q.w+e.projectionMatrix.n24)),s.materials=t.materials,L.push(s);g&&L.sort(b);return L}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; +0)))V=k[n]=k[n]||new THREE.RenderableFace4,n++,l=V,l.v1.copy(v),l.v2.copy(J),l.v3.copy(F),l.v4.copy(w);else continue;l.normalWorld.copy(D.normal);T.multiplyVector3(l.normalWorld);l.centroidWorld.copy(D.centroid);B.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);m.multiplyVector3(l.centroidScreen);F=D.vertexNormals;v=0;for(J=F.length;v0&&r.z<1))B=P[K]=P[K]||new THREE.RenderableParticle,K++,s=B,s.x=r.x/r.w,s.y=r.y/r.w,s.z=r.z,s.rotation=t.rotation.z,s.scale.x=t.scale.x*Math.abs(s.x-(r.x+e.projectionMatrix.n11)/(r.w+e.projectionMatrix.n14)),s.scale.y=t.scale.y*Math.abs(s.y-(r.y+ +e.projectionMatrix.n22)/(r.w+e.projectionMatrix.n24)),s.materials=t.materials,L.push(s);g&&L.sort(b);return L}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==void 0?d:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),g=Math.cos(c),c=Math.sin(c),f=a*b,h=d*e;this.w=f*g-h*c;this.x=f*c+h*g;this.y=d*b*g+a*e*c;this.z=a*e*g-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c); this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= @@ -77,20 +78,20 @@ b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid c,d,e,g,f,h=new THREE.Vector3,j=new THREE.Vector3;d=0;for(e=this.faces.length;d0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, +c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,e,g,m){h=a.vertices[b].position;j=a.vertices[c].position;l=a.vertices[d].position;o=f[e];i=f[g];n=f[m];k=j.x-h.x;p=l.x-h.x;q=j.y-h.y;u=l.y-h.y;s=j.z-h.z;K=l.z-h.z;P=i.u-o.u;y=n.u-o.u;L=i.v-o.v;M=n.v-o.v;r=1/(P*M-y*L);R.set((M*k-L*p)*r,(M*q-L*u)*r,(M*s-L*K)*r);S.set((P*p-y*k)*r,(P*u-y*q)*r,(P*K-y*s)*r);z[b].addSelf(R);z[c].addSelf(R);z[d].addSelf(R);A[b].addSelf(S); +A[c].addSelf(S);A[d].addSelf(S)}var b,c,d,e,g,f,h,j,l,o,i,n,k,p,q,u,s,K,P,y,L,M,r,m,z=[],A=[],R=new THREE.Vector3,S=new THREE.Vector3,E=new THREE.Vector3,I=new THREE.Vector3,G=new THREE.Vector3;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.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b0&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b* -255)+","+r+")"),k.fillRect(Math.floor(Z.getX()),Math.floor(Z.getY()),Math.floor(Z.getWidth()),Math.floor(Z.getHeight()))),Z.empty())};this.render=function(a,l){function j(a){var b,c,d,e=a.lights;$.setRGB(0,0,0);sa.setRGB(0,0,0);ta.setRGB(0,0,0);a=0;for(b=e.length;a>1,n=o.height>>1,g=f.scale.x*i,j=f.scale.y*m,h=g*Ba,l=j*n,X.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.intersects(X)&&(k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(g,-j),k.translate(-Ba,-n),k.drawImage(o,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=f.scale.x*i,l=f.scale.y*m,X.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.intersects(X)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(h,l),g.program(k),k.restore()))} -function r(a,e,f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(y!=a)k.lineWidth=y=a;a=g.linecap;if(L!=a)k.lineCap=L=a;a=g.linejoin;if(M!=a)k.lineJoin=M=a;d(g.color.getContextStyle());k.stroke();X.inflate(g.linewidth*2)}}function s(a,d,e,f,h,k,i,j,m){g.data.vertices+=3;g.data.faces++;b(j.opacity);c(j.blending);E=a.positionScreen.x;I=a.positionScreen.y; +l,o,i,n,k=j.getContext("2d"),p=new THREE.Color(0),q=0,u=1,s=0,K=null,P=null,y=null,L=null,M=null,r,m,z,A,R=new THREE.RenderableVertex,S=new THREE.RenderableVertex,E,I,G,H,N,O,U,D,oa,v,J,F,w=new THREE.Color(0),C=new THREE.Color(0),t=new THREE.Color(0),B=new THREE.Color(0),T=new THREE.Color(0),ya=[],da,Y,aa,V,Da,Ea,Fa,Ga,Ha,Ia,ja=new THREE.Rectangle,Z=new THREE.Rectangle,X=new THREE.Rectangle,za=!1,ba=new THREE.Color,$=new THREE.Color,sa=new THREE.Color,ta=new THREE.Color,Q=new THREE.Vector3,pa,qa, +Aa,ca,ra,ua,a=16;pa=document.createElement("canvas");pa.width=pa.height=2;qa=pa.getContext("2d");qa.fillStyle="rgba(0,0,0,1)";qa.fillRect(0,0,2,2);Aa=qa.getImageData(0,0,2,2);ca=Aa.data;ra=document.createElement("canvas");ra.width=ra.height=a;ua=ra.getContext("2d");ua.translate(-a/2,-a/2);ua.scale(a,a);a--;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setSize=function(a,b){l=a;o=b;i=Math.floor(l/2);n=Math.floor(o/2);j.width=l;j.height=o; +ja.set(-i,-n,i,n);Z.set(-i,-n,i,n);u=1;s=0;M=L=y=P=K=null};this.setClearColor=function(a,b){p.copy(a);q=b;Z.set(-i,-n,i,n)};this.setClearColorHex=function(a,b){p.setHex(a);q=b;Z.set(-i,-n,i,n)};this.clear=function(){k.setTransform(1,0,0,-1,i,n);Z.isEmpty()||(Z.minSelf(ja),Z.inflate(2),q<1&&k.clearRect(Math.floor(Z.getX()),Math.floor(Z.getY()),Math.floor(Z.getWidth()),Math.floor(Z.getHeight())),q>0&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(p.r*255)+","+Math.floor(p.g*255)+","+Math.floor(p.b* +255)+","+q+")"),k.fillRect(Math.floor(Z.getX()),Math.floor(Z.getY()),Math.floor(Z.getWidth()),Math.floor(Z.getHeight()))),Z.empty())};this.render=function(a,l){function j(a){var b,c,d,e=a.lights;$.setRGB(0,0,0);sa.setRGB(0,0,0);ta.setRGB(0,0,0);a=0;for(b=e.length;a>1,m=j.height>>1,g=f.scale.x*i,o=f.scale.y*n,h=g*Ba,l=o*m,X.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.intersects(X)&&(k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(g,-o),k.translate(-Ba,-m),k.drawImage(j,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=f.scale.x*i,l=f.scale.y*n,X.set(a.x-h,a.y-l,a.x+h,a.y+l),ja.intersects(X)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(h,l),g.program(k),k.restore()))} +function q(a,e,f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(y!=a)k.lineWidth=y=a;a=g.linecap;if(L!=a)k.lineCap=L=a;a=g.linejoin;if(M!=a)k.lineJoin=M=a;d(g.color.getContextStyle());k.stroke();X.inflate(g.linewidth*2)}}function s(a,d,e,f,h,k,i,j,n){g.data.vertices+=3;g.data.faces++;b(j.opacity);c(j.blending);E=a.positionScreen.x;I=a.positionScreen.y; G=d.positionScreen.x;H=d.positionScreen.y;N=e.positionScreen.x;O=e.positionScreen.y;K(E,I,G,H,N,O);if(j instanceof THREE.MeshBasicMaterial)if(j.map)j.map.mapping instanceof THREE.UVMapping&&(V=i.uvs[0],Ca(E,I,G,H,N,O,V[f].u,V[f].v,V[h].u,V[h].v,V[k].u,V[k].v,j.map));else if(j.envMap){if(j.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,Q.copy(i.vertexNormalsWorld[0]),Da=(Q.x*a.n11+Q.y*a.n12+Q.z*a.n13)*0.5+0.5,Ea=-(Q.x*a.n21+Q.y*a.n22+Q.z*a.n23)*0.5+0.5,Q.copy(i.vertexNormalsWorld[1]), Fa=(Q.x*a.n11+Q.y*a.n12+Q.z*a.n13)*0.5+0.5,Ga=-(Q.x*a.n21+Q.y*a.n22+Q.z*a.n23)*0.5+0.5,Q.copy(i.vertexNormalsWorld[2]),Ha=(Q.x*a.n11+Q.y*a.n12+Q.z*a.n13)*0.5+0.5,Ia=-(Q.x*a.n21+Q.y*a.n22+Q.z*a.n23)*0.5+0.5,Ca(E,I,G,H,N,O,Da,Ea,Fa,Ga,Ha,Ia,j.envMap)}else j.wireframe?fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color);else if(j instanceof THREE.MeshLambertMaterial)j.map&&!j.wireframe&&(j.map.mapping instanceof THREE.UVMapping&&(V=i.uvs[0],Ca(E,I,G,H,N,O,V[f].u,V[f].v, -V[h].u,V[h].v,V[k].u,V[k].v,j.map)),c(THREE.SubtractiveBlending)),za?!j.wireframe&&j.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==3?(C.r=t.r=B.r=$.r,C.g=t.g=B.g=$.g,C.b=t.b=B.b=$.b,o(m,i.v1.positionWorld,i.vertexNormalsWorld[0],C),o(m,i.v2.positionWorld,i.vertexNormalsWorld[1],t),o(m,i.v3.positionWorld,i.vertexNormalsWorld[2],B),T.r=(t.r+B.r)*0.5,T.g=(t.g+B.g)*0.5,T.b=(t.b+B.b)*0.5,aa=va(C,t,B,T),la(E,I,G,H,N,O,0,0,1,0,0,1,aa)):(ba.r=$.r,ba.g=$.g,ba.b=$.b,o(m,i.centroidWorld,i.normalWorld, +V[h].u,V[h].v,V[k].u,V[k].v,j.map)),c(THREE.SubtractiveBlending)),za?!j.wireframe&&j.shading==THREE.SmoothShading&&i.vertexNormalsWorld.length==3?(C.r=t.r=B.r=$.r,C.g=t.g=B.g=$.g,C.b=t.b=B.b=$.b,o(n,i.v1.positionWorld,i.vertexNormalsWorld[0],C),o(n,i.v2.positionWorld,i.vertexNormalsWorld[1],t),o(n,i.v3.positionWorld,i.vertexNormalsWorld[2],B),T.r=(t.r+B.r)*0.5,T.g=(t.g+B.g)*0.5,T.b=(t.b+B.b)*0.5,aa=va(C,t,B,T),la(E,I,G,H,N,O,0,0,1,0,0,1,aa)):(ba.r=$.r,ba.g=$.g,ba.b=$.b,o(n,i.centroidWorld,i.normalWorld, ba),w.r=Math.max(0,Math.min(j.color.r*ba.r,1)),w.g=Math.max(0,Math.min(j.color.g*ba.g,1)),w.b=Math.max(0,Math.min(j.color.b*ba.b,1)),j.wireframe?fa(w,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(w)):j.wireframe?fa(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(j.color);else if(j instanceof THREE.MeshDepthMaterial)da=l.near,Y=l.far,C.r=C.g=C.b=1-ka(a.positionScreen.z,da,Y),t.r=t.g=t.b=1-ka(d.positionScreen.z,da,Y),B.r=B.g=B.b=1-ka(e.positionScreen.z,da,Y), -T.r=(t.r+B.r)*0.5,T.g=(t.g+B.g)*0.5,T.b=(t.b+B.b)*0.5,aa=va(C,t,B,T),la(E,I,G,H,N,O,0,0,1,0,0,1,aa);else if(j instanceof THREE.MeshNormalMaterial)w.r=ma(i.normalWorld.x),w.g=ma(i.normalWorld.y),w.b=ma(i.normalWorld.z),j.wireframe?fa(w,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(w)}function u(a,d,e,f,h,j,k,i,m){g.data.vertices+=4;g.data.faces++;b(i.opacity);c(i.blending);if(i.map||i.envMap)s(a,d,f,0,1,3,k,i,m),s(h,e,j,1,2,3,k,i,m);else if(E=a.positionScreen.x,I=a.positionScreen.y, +T.r=(t.r+B.r)*0.5,T.g=(t.g+B.g)*0.5,T.b=(t.b+B.b)*0.5,aa=va(C,t,B,T),la(E,I,G,H,N,O,0,0,1,0,0,1,aa);else if(j instanceof THREE.MeshNormalMaterial)w.r=ma(i.normalWorld.x),w.g=ma(i.normalWorld.y),w.b=ma(i.normalWorld.z),j.wireframe?fa(w,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ga(w)}function u(a,d,e,f,h,j,k,i,n){g.data.vertices+=4;g.data.faces++;b(i.opacity);c(i.blending);if(i.map||i.envMap)s(a,d,f,0,1,3,k,i,n),s(h,e,j,1,2,3,k,i,n);else if(E=a.positionScreen.x,I=a.positionScreen.y, G=d.positionScreen.x,H=d.positionScreen.y,N=e.positionScreen.x,O=e.positionScreen.y,U=f.positionScreen.x,D=f.positionScreen.y,oa=h.positionScreen.x,v=h.positionScreen.y,J=j.positionScreen.x,F=j.positionScreen.y,i instanceof THREE.MeshBasicMaterial)P(E,I,G,H,N,O,U,D),i.wireframe?fa(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(i.color);else if(i instanceof THREE.MeshLambertMaterial)za?!i.wireframe&&i.shading==THREE.SmoothShading&&k.vertexNormalsWorld.length==4?(C.r=t.r=B.r= -T.r=$.r,C.g=t.g=B.g=T.g=$.g,C.b=t.b=B.b=T.b=$.b,o(m,k.v1.positionWorld,k.vertexNormalsWorld[0],C),o(m,k.v2.positionWorld,k.vertexNormalsWorld[1],t),o(m,k.v4.positionWorld,k.vertexNormalsWorld[3],B),o(m,k.v3.positionWorld,k.vertexNormalsWorld[2],T),aa=va(C,t,B,T),K(E,I,G,H,U,D),la(E,I,G,H,U,D,0,0,1,0,0,1,aa),K(oa,v,N,O,J,F),la(oa,v,N,O,J,F,1,0,1,1,0,1,aa)):(ba.r=$.r,ba.g=$.g,ba.b=$.b,o(m,k.centroidWorld,k.normalWorld,ba),w.r=Math.max(0,Math.min(i.color.r*ba.r,1)),w.g=Math.max(0,Math.min(i.color.g* +T.r=$.r,C.g=t.g=B.g=T.g=$.g,C.b=t.b=B.b=T.b=$.b,o(n,k.v1.positionWorld,k.vertexNormalsWorld[0],C),o(n,k.v2.positionWorld,k.vertexNormalsWorld[1],t),o(n,k.v4.positionWorld,k.vertexNormalsWorld[3],B),o(n,k.v3.positionWorld,k.vertexNormalsWorld[2],T),aa=va(C,t,B,T),K(E,I,G,H,U,D),la(E,I,G,H,U,D,0,0,1,0,0,1,aa),K(oa,v,N,O,J,F),la(oa,v,N,O,J,F,1,0,1,1,0,1,aa)):(ba.r=$.r,ba.g=$.g,ba.b=$.b,o(n,k.centroidWorld,k.normalWorld,ba),w.r=Math.max(0,Math.min(i.color.r*ba.r,1)),w.g=Math.max(0,Math.min(i.color.g* ba.g,1)),w.b=Math.max(0,Math.min(i.color.b*ba.b,1)),P(E,I,G,H,N,O,U,D),i.wireframe?fa(w,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(w)):(P(E,I,G,H,N,O,U,D),i.wireframe?fa(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(i.color));else if(i instanceof THREE.MeshNormalMaterial)w.r=ma(k.normalWorld.x),w.g=ma(k.normalWorld.y),w.b=ma(k.normalWorld.z),P(E,I,G,H,N,O,U,D),i.wireframe?fa(w,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ga(w);else if(i instanceof THREE.MeshDepthMaterial)da=l.near,Y=l.far,C.r=C.g=C.b=1-ka(a.positionScreen.z,da,Y),t.r=t.g=t.b=1-ka(d.positionScreen.z,da,Y),B.r=B.g=B.b=1-ka(f.positionScreen.z,da,Y),T.r=T.g=T.b=1-ka(e.positionScreen.z,da,Y),aa=va(C,t,B,T),K(E,I,G,H,U,D),la(E,I,G,H,U,D,0,0,1,0,0,1,aa),K(oa,v,N,O,J,F),la(oa,v,N,O,J,F,1,0,1,1,0,1,aa)}function K(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function P(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e, -f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function fa(a,b,c,e){if(y!=b)k.lineWidth=y=b;if(L!=c)k.lineCap=L=c;if(M!=e)k.lineJoin=M=e;d(a.getContextStyle());k.stroke();X.inflate(b*2)}function ga(a){e(a.getContextStyle());k.fill()}function Ca(a,b,c,d,f,g,h,i,j,l,m,o,n){if(n.image.width!=0){if(n.needsUpdate==!0||ya[n.id]==void 0){var p=n.wrapS==THREE.RepeatWrapping,q=n.wrapT==THREE.RepeatWrapping;ya[n.id]=k.createPattern(n.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");n.needsUpdate= -!1}e(ya[n.id]);var p=n.offset.x/n.repeat.x,q=n.offset.y/n.repeat.y,r=(n.image.width-1)*n.repeat.x,n=(n.image.height-1)*n.repeat.y,h=(h+p)*r,i=(i+q)*n,j=(j+p)*r,l=(l+q)*n,m=(m+p)*r,o=(o+q)*n;c-=a;d-=b;f-=a;g-=b;j-=h;l-=i;m-=h;o-=i;p=1/(j*o-m*l);n=(o*c-l*f)*p;l=(o*d-l*g)*p;c=(j*f-m*c)*p;d=(j*g-m*d)*p;a=a-n*h-c*i;b=b-l*h-d*i;k.save();k.transform(n,l,c,d,a,b);k.fill();k.restore()}}function la(a,b,c,d,e,f,g,h,i,j,l,m,n){var o,p;o=n.width-1;p=n.height-1;g*=o;h*=p;i*=o;j*=p;l*=o;m*=p;c-=a;d-=b;e-=a;f-=b; -i-=g;j-=h;l-=g;m-=h;p=1/(i*m-l*j);o=(m*c-j*e)*p;j=(m*d-j*f)*p;c=(i*e-l*c)*p;d=(i*f-l*d)*p;a=a-o*g-c*h;b=b-j*g-d*h;k.save();k.transform(o,j,c,d,a,b);k.clip();k.drawImage(n,0,0);k.restore()}function va(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);ca[0]=e<0?0:e>255?255:e;ca[1]=f<0?0:f>255?255:f;ca[2]=a<0?0:a>255?255:a;ca[4]=g<0?0:g>255?255:g;ca[5]=h<0?0:h>255?255:h; +f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function fa(a,b,c,e){if(y!=b)k.lineWidth=y=b;if(L!=c)k.lineCap=L=c;if(M!=e)k.lineJoin=M=e;d(a.getContextStyle());k.stroke();X.inflate(b*2)}function ga(a){e(a.getContextStyle());k.fill()}function Ca(a,b,c,d,f,g,h,i,j,l,o,n,m){if(m.image.width!=0){if(m.needsUpdate==!0||ya[m.id]==void 0){var p=m.wrapS==THREE.RepeatWrapping,q=m.wrapT==THREE.RepeatWrapping;ya[m.id]=k.createPattern(m.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");m.needsUpdate= +!1}e(ya[m.id]);var p=m.offset.x/m.repeat.x,q=m.offset.y/m.repeat.y,r=(m.image.width-1)*m.repeat.x,m=(m.image.height-1)*m.repeat.y,h=(h+p)*r,i=(i+q)*m,j=(j+p)*r,l=(l+q)*m,o=(o+p)*r,n=(n+q)*m;c-=a;d-=b;f-=a;g-=b;j-=h;l-=i;o-=h;n-=i;p=1/(j*n-o*l);m=(n*c-l*f)*p;l=(n*d-l*g)*p;c=(j*f-o*c)*p;d=(j*g-o*d)*p;a=a-m*h-c*i;b=b-l*h-d*i;k.save();k.transform(m,l,c,d,a,b);k.fill();k.restore()}}function la(a,b,c,d,e,f,g,h,i,j,l,m,o){var n,p;n=o.width-1;p=o.height-1;g*=n;h*=p;i*=n;j*=p;l*=n;m*=p;c-=a;d-=b;e-=a;f-=b; +i-=g;j-=h;l-=g;m-=h;p=1/(i*m-l*j);n=(m*c-j*e)*p;j=(m*d-j*f)*p;c=(i*e-l*c)*p;d=(i*f-l*d)*p;a=a-n*g-c*h;b=b-j*g-d*h;k.save();k.transform(n,j,c,d,a,b);k.clip();k.drawImage(o,0,0);k.restore()}function va(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);ca[0]=e<0?0:e>255?255:e;ca[1]=f<0?0:f>255?255:f;ca[2]=a<0?0:a>255?255:a;ca[4]=g<0?0:g>255?255:g;ca[5]=h<0?0:h>255?255:h; ca[6]=b<0?0:b>255?255:b;ca[8]=i<0?0:i>255?255:i;ca[9]=j<0?0:j>255?255:j;ca[10]=c<0?0:c>255?255:c;ca[12]=k<0?0:k>255?255:k;ca[13]=l<0?0:l>255?255:l;ca[14]=d<0?0:d>255?255:d;qa.putImageData(Aa,0,0);ua.drawImage(pa,0,0);return ra}function ka(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function ma(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ha(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var wa,Ja,x,ea,ia,na,xa,W;this.autoClear?this.clear():k.setTransform(1, -0,0,-1,i,m);g.data.vertices=0;g.data.faces=0;f=h.projectScene(a,l,this.sortElements);(za=a.lights.length>0)&&j(a);wa=0;for(Ja=f.length;wa0)&&j(a);wa=0;for(Ja=f.length;wa0&&a>0&&f+a<1}if(a instanceof THREE.Particle){var d=b(this.origin,this.direction,a.matrixWorld.getPosition());if(d==null||d>a.scale.x)return[];return[{distance:d,point:a.position,face:null,object:a}]}else if(a instanceof THREE.Mesh){d=b(this.origin,this.direction,a.matrixWorld.getPosition());if(d==null||d>a.geometry.boundingSphere.radius*Math.max(a.scale.x, -Math.max(a.scale.y,a.scale.z)))return[];var e,g,f,h,j,i,l,k,m,n,p=a.geometry,q=p.vertices,s=[],d=0;for(e=p.faces.length;d0:k<0)))if(k=l.dot((new THREE.Vector3).sub(f,m))/k,m=m.addSelf(n.multiplyScalar(k)),g instanceof THREE.Face3)c(m,f,h,j)&&(g={distance:this.origin.distanceTo(m),point:m,face:g,object:a},s.push(g));else if(g instanceof THREE.Face4&&(c(m,f,h,i)||c(m,h,j,i)))g={distance:this.origin.distanceTo(m),point:m,face:g,object:a},s.push(g);s.sort(function(a,b){return a.distance-b.distance});return s}else return[]}}; -THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,l,k){h=!1;b=f;c=g;d=l;e=k;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= -function(f,g,l,k,m,n){h?(h=!1,b=fl?f>m?f:m:l>m?l:m,e=g>k?g>n?g:n:k>n?k:n):(b=fl?f>m?f>d?f:d:m>d?m:d:l>m?l>d?l:d:m>d?m:d,e=g>k?g>n?g>e?g:e:n>e?n:e:k>n?k>e?k:e:n>e?n:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> +Math.max(a.scale.y,a.scale.z)))return[];var e,g,f,h,j,i,k,l,m,n,p=a.geometry,q=p.vertices,s=[],d=0;for(e=p.faces.length;d0:l<0)))if(l=k.dot((new THREE.Vector3).sub(f,m))/l,m=m.addSelf(n.multiplyScalar(l)),g instanceof THREE.Face3)c(m,f,h,j)&&(g={distance:this.origin.distanceTo(m),point:m,face:g,object:a},s.push(g));else if(g instanceof THREE.Face4&&(c(m,f,h,i)||c(m,h,j,i)))g={distance:this.origin.distanceTo(m),point:m,face:g,object:a},s.push(g);s.sort(function(a,b){return a.distance-b.distance});return s}else return[]}}; +THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,k,l){h=!1;b=f;c=g;d=k;e=l;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= +function(f,g,k,l,m,n){h?(h=!1,b=fk?f>m?f:m:k>m?k:m,e=g>l?g>n?g:n:l>n?l:n):(b=fk?f>m?f>d?f:d:m>d?m:d:k>m?k>d?k:d:m>d?m:d,e=g>l?g>n?g>e?g:e:n>e?n:e:l>n?l>e?l:e:n>e?n:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};THREE.Matrix3=function(){this.m=[]}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,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,f,h,j,i,l,k,m,n,p,q){this.set(a||1,b||0,c||0,d||0,e||0,g||1,f||0,h||0,j||0,i||0,l||1,k||0,m||0,n||0,p||0,q||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,f,h,j,i,l,k,m,n,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=h;this.n31=j;this.n32=i;this.n33=l;this.n34=k;this.n41=m;this.n42=n;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, +THREE.Matrix3.prototype={constructor:THREE.Matrix3,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,f,h,j,i,k,l,m,n,p,q){this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,g!==void 0?g:1,f||0,h||0,j||0,i||0,k!==void 0?k:1,l||0,m||0,n||0,p||0,q!==void 0?q:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,f,h,j,i,k,l,m,n,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=h;this.n31=j;this.n32=i;this.n33=k;this.n34=l;this.n41=m;this.n42=n;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.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.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},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},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+ -c*this.n32+d*this.n33;a.normalize();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,f=a.n21,h=a.n22,j=a.n23,i=a.n24,l=a.n31,k=a.n32,m=a.n33,n=a.n34,p=a.n41,q=a.n42,s=a.n43,r=a.n44,J=b.n11,M=b.n12, -C=b.n13,D=b.n14,H=b.n21,v=b.n22,o=b.n23,K=b.n24,z=b.n31,E=b.n32,F=b.n33,Q=b.n34,R=b.n41,S=b.n42,T=b.n43,U=b.n44;this.n11=c*J+d*H+e*z+g*R;this.n12=c*M+d*v+e*E+g*S;this.n13=c*C+d*o+e*F+g*T;this.n14=c*D+d*K+e*Q+g*U;this.n21=f*J+h*H+j*z+i*R;this.n22=f*M+h*v+j*E+i*S;this.n23=f*C+h*o+j*F+i*T;this.n24=f*D+h*K+j*Q+i*U;this.n31=l*J+k*H+m*z+n*R;this.n32=l*M+k*v+m*E+n*S;this.n33=l*C+k*o+m*F+n*T;this.n34=l*D+k*K+m*Q+n*U;this.n41=p*J+q*H+s*z+r*R;this.n42=p*M+q*v+s*E+r*S;this.n43=p*C+q*o+s*F+r*T;this.n44=p*D+q* +c*this.n32+d*this.n33;a.normalize();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,f=a.n21,h=a.n22,j=a.n23,i=a.n24,k=a.n31,l=a.n32,m=a.n33,n=a.n34,p=a.n41,q=a.n42,s=a.n43,r=a.n44,J=b.n11,M=b.n12, +C=b.n13,D=b.n14,H=b.n21,v=b.n22,o=b.n23,K=b.n24,z=b.n31,E=b.n32,F=b.n33,Q=b.n34,R=b.n41,S=b.n42,T=b.n43,U=b.n44;this.n11=c*J+d*H+e*z+g*R;this.n12=c*M+d*v+e*E+g*S;this.n13=c*C+d*o+e*F+g*T;this.n14=c*D+d*K+e*Q+g*U;this.n21=f*J+h*H+j*z+i*R;this.n22=f*M+h*v+j*E+i*S;this.n23=f*C+h*o+j*F+i*T;this.n24=f*D+h*K+j*Q+i*U;this.n31=k*J+l*H+m*z+n*R;this.n32=k*M+l*v+m*E+n*S;this.n33=k*C+l*o+m*F+n*T;this.n34=k*D+l*K+m*Q+n*U;this.n41=p*J+q*H+s*z+r*R;this.n42=p*M+q*v+s*E+r*S;this.n43=p*C+q*o+s*F+r*T;this.n44=p*D+q* K+s*Q+r*U;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,g=this.n22,f=this.n23,h=this.n24,j=this.n31,i=this.n32,l=this.n33,k=this.n34,m=this.n41,n=this.n42,p=this.n43,q=this.n44;return d*f*i*m-c*h*i*m-d*g*l*m+b*h*l*m+c*g*k*m-b*f*k*m-d*f*j*n+c*h*j*n+d*e*l*n-a*h*l*n-c*e*k*n+a*f*k*n+d*g*j*p-b*h*j*p-d*e*i*p+a*h*i*p+b*e*k*p-a*g*k*p-c*g*j*q+b*f*j*q+c*e*i*q-a*f*i*q-b*e*l*q+a*g*l*q}, +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,f=this.n23,h=this.n24,j=this.n31,i=this.n32,k=this.n33,l=this.n34,m=this.n41,n=this.n42,p=this.n43,q=this.n44;return d*f*i*m-c*h*i*m-d*g*k*m+b*h*k*m+c*g*l*m-b*f*l*m-d*f*j*n+c*h*j*n+d*e*k*n-a*h*k*n-c*e*l*n+a*f*l*n+d*g*j*p-b*h*j*p-d*e*i*p+a*h*i*p+b*e*l*p-a*g*l*p-c*g*j*q+b*f*j*q+c*e*i*q-a*f*i*q-b*e*k*q+a*g*k*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.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,g=a.x,f=a.y,h=a.z,j=e*g,i=e*f;this.set(j*g+c,j*f-d*h,j*h+d*f,0,j*f+d*h,i*f+c,i*h-d*g,0,j*h-d*f,i*h+d*g,e*h*h+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},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX= new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,e=a.z,g=Math.cos(c),c=Math.sin(c),f=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var j= -f*h,i=f*e,l=d*h,k=d*e;this.n11=j+k*c;this.n12=l*c-i;this.n13=g*d;this.n21=g*e;this.n22=g*h;this.n23=-c;this.n31=i*c-l;this.n32=k+j*c;this.n33=g*f;break;case "ZXY":j=f*h;i=f*e;l=d*h;k=d*e;this.n11=j-k*c;this.n12=-g*e;this.n13=l+i*c;this.n21=i+l*c;this.n22=g*h;this.n23=k-j*c;this.n31=-g*d;this.n32=c;this.n33=g*f;break;case "ZYX":j=g*h;i=g*e;l=c*h;k=c*e;this.n11=f*h;this.n12=l*d-i;this.n13=j*d+k;this.n21=f*e;this.n22=k*d+j;this.n23=i*d-l;this.n31=-d;this.n32=c*f;this.n33=g*f;break;case "YZX":j=g*f;i= -g*d;l=c*f;k=c*d;this.n11=f*h;this.n12=k-j*e;this.n13=l*e+i;this.n21=e;this.n22=g*h;this.n23=-c*h;this.n31=-d*h;this.n32=i*e+l;this.n33=j-k*e;break;case "XZY":j=g*f;i=g*d;l=c*f;k=c*d;this.n11=f*h;this.n12=-e;this.n13=d*h;this.n21=j*e+k;this.n22=g*h;this.n23=i*e-l;this.n31=l*e-i;this.n32=c*h;this.n33=k*e+j;break;default:j=g*h,i=g*e,l=c*h,k=c*e,this.n11=f*h,this.n12=-f*e,this.n13=d,this.n21=i+l*d,this.n22=j-k*d,this.n23=-c*f,this.n31=k-j*d,this.n32=l+i*d,this.n33=g*f}return this},setRotationFromQuaternion:function(a){var b= +f*h,i=f*e,k=d*h,l=d*e;this.n11=j+l*c;this.n12=k*c-i;this.n13=g*d;this.n21=g*e;this.n22=g*h;this.n23=-c;this.n31=i*c-k;this.n32=l+j*c;this.n33=g*f;break;case "ZXY":j=f*h;i=f*e;k=d*h;l=d*e;this.n11=j-l*c;this.n12=-g*e;this.n13=k+i*c;this.n21=i+k*c;this.n22=g*h;this.n23=l-j*c;this.n31=-g*d;this.n32=c;this.n33=g*f;break;case "ZYX":j=g*h;i=g*e;k=c*h;l=c*e;this.n11=f*h;this.n12=k*d-i;this.n13=j*d+l;this.n21=f*e;this.n22=l*d+j;this.n23=i*d-k;this.n31=-d;this.n32=c*f;this.n33=g*f;break;case "YZX":j=g*f;i= +g*d;k=c*f;l=c*d;this.n11=f*h;this.n12=l-j*e;this.n13=k*e+i;this.n21=e;this.n22=g*h;this.n23=-c*h;this.n31=-d*h;this.n32=i*e+k;this.n33=j-l*e;break;case "XZY":j=g*f;i=g*d;k=c*f;l=c*d;this.n11=f*h;this.n12=-e;this.n13=d*h;this.n21=j*e+l;this.n22=g*h;this.n23=i*e-k;this.n31=k*e-i;this.n32=c*h;this.n33=l*e+j;break;default:j=g*h,i=g*e,k=c*h,l=c*e,this.n11=f*h,this.n12=-f*e,this.n13=d,this.n21=i+k*d,this.n22=j-l*d,this.n23=-c*f,this.n31=l-j*d,this.n32=k+i*d,this.n33=g*f}return this},setRotationFromQuaternion:function(a){var b= a.x,c=a.y,d=a.z,e=a.w,g=b+b,f=c+c,h=d+d,a=b*g,j=b*f;b*=h;var i=c*f;c*=h;d*=h;g*=e;f*=e;e*=h;this.n11=1-(i+d);this.n12=j-e;this.n13=b+f;this.n21=j+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-f;this.n32=c+g;this.n33=1-(a+i);return this},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},compose:function(a,b,c){var d=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2; d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);g.set(this.n13,this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length(); c.y=e.length();c.z=g.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},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,g=a.n14,f=a.n21,h=a.n22,j=a.n23,i=a.n24,l=a.n31,k=a.n32,m=a.n33,n=a.n34,p=a.n41,q=a.n42,s=a.n43,r=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=j*n*q-i*m*q+i*k*s-h*n*s-j*k*r+h*m*r;b.n12=g*m*q-e*n*q-g*k*s+d*n*s+e*k*r-d*m*r;b.n13=e*i*q-g*j*q+g*h*s-d*i*s-e*h*r+d*j*r;b.n14=g*j*k-e*i*k-g*h*m+d*i*m+e*h*n-d*j*n;b.n21=i*m*p-j*n*p-i*l*s+f*n*s+j*l*r-f*m*r;b.n22=e*n*p-g*m*p+g*l*s-c*n*s-e*l*r+c*m*r;b.n23=g*j*p-e*i*p-g*f*s+c*i*s+e*f*r-c*j*r;b.n24= -e*i*l-g*j*l+g*f*m-c*i*m-e*f*n+c*j*n;b.n31=h*n*p-i*k*p+i*l*q-f*n*q-h*l*r+f*k*r;b.n32=g*k*p-d*n*p-g*l*q+c*n*q+d*l*r-c*k*r;b.n33=e*i*p-g*h*p+g*f*q-c*i*q-d*f*r+c*h*r;b.n34=g*h*l-d*i*l-g*f*k+c*i*k+d*f*n-c*h*n;b.n41=j*k*p-h*m*p-j*l*q+f*m*q+h*l*s-f*k*s;b.n42=d*m*p-e*k*p+e*l*q-c*m*q-d*l*s+c*k*s;b.n43=e*h*p-d*j*p-e*f*q+c*j*q+d*f*s-c*h*s;b.n44=d*j*l-e*h*l+e*f*k-c*j*k-d*f*m+c*h*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,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,l=-a.n23*a.n11+a.n21*a.n13,k=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*f+a.n31*i;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*h;c[5]=a*j;c[6]=a*i;c[7]=a*l;c[8]=a*k;return b}; +THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,f=a.n21,h=a.n22,j=a.n23,i=a.n24,k=a.n31,l=a.n32,m=a.n33,n=a.n34,p=a.n41,q=a.n42,s=a.n43,r=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=j*n*q-i*m*q+i*l*s-h*n*s-j*l*r+h*m*r;b.n12=g*m*q-e*n*q-g*l*s+d*n*s+e*l*r-d*m*r;b.n13=e*i*q-g*j*q+g*h*s-d*i*s-e*h*r+d*j*r;b.n14=g*j*l-e*i*l-g*h*m+d*i*m+e*h*n-d*j*n;b.n21=i*m*p-j*n*p-i*k*s+f*n*s+j*k*r-f*m*r;b.n22=e*n*p-g*m*p+g*k*s-c*n*s-e*k*r+c*m*r;b.n23=g*j*p-e*i*p-g*f*s+c*i*s+e*f*r-c*j*r;b.n24= +e*i*k-g*j*k+g*f*m-c*i*m-e*f*n+c*j*n;b.n31=h*n*p-i*l*p+i*k*q-f*n*q-h*k*r+f*l*r;b.n32=g*l*p-d*n*p-g*k*q+c*n*q+d*k*r-c*l*r;b.n33=e*i*p-g*h*p+g*f*q-c*i*q-d*f*r+c*h*r;b.n34=g*h*k-d*i*k-g*f*l+c*i*l+d*f*n-c*h*n;b.n41=j*l*p-h*m*p-j*k*q+f*m*q+h*k*s-f*l*s;b.n42=d*m*p-e*l*p+e*k*q-c*m*q-d*k*s+c*l*s;b.n43=e*h*p-d*j*p-e*f*q+c*j*q+d*f*s-c*h*s;b.n44=d*j*k-e*h*k+e*f*l-c*j*l-d*f*m+c*h*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,g=a.n32*a.n21-a.n31*a.n22,f=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,k=-a.n23*a.n11+a.n21*a.n13,l=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*f+a.n31*i;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*h;c[5]=a*j;c[6]=a*i;c[7]=a*k;c[8]=a*l;return b}; THREE.Matrix4.makeFrustum=function(a,b,c,d,e,g){var f;f=new THREE.Matrix4;f.n11=2*e/(b-a);f.n12=0;f.n13=(b+a)/(b-a);f.n14=0;f.n21=0;f.n22=2*e/(d-c);f.n23=(d+c)/(d-c);f.n24=0;f.n31=0;f.n32=0;f.n33=-(g+e)/(g-e);f.n34=-2*g*e/(g-e);f.n41=0;f.n42=0;f.n43=-1;f.n44=0;return f};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 f,h,j,i;f=new THREE.Matrix4;h=b-a;j=c-d;i=g-e;f.n11=2/h;f.n12=0;f.n13=0;f.n14=-((b+a)/h);f.n21=0;f.n22=2/j;f.n23=0;f.n24=-((c+d)/j);f.n31=0;f.n32=0;f.n33=-2/i;f.n34=-((g+e)/i);f.n41=0;f.n42=0;f.n43=0;f.n44=1;return f};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; THREE.Object3D=function(){this.id=THREE.Object3DCount++;this.name="";this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate= @@ -52,12 +53,12 @@ THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){thi -1){a.parent!==void 0&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b.parent!==void 0;)b=b.parent;b!==void 0&&b instanceof THREE.Scene&&b.addChildRecurse(a)}},remove:function(a){var b=this.children.indexOf(a);if(b!==-1)a.parent=void 0,this.children.splice(b,1)},getChildByName:function(a,b){var c,d,e;c=0;for(d=this.children.length;c=0&&e>=0&&g>=0&&h>=0?!0:f<0&&e<0||g<0&&h<0?!1:(f<0?c=Math.max(c,f/(f-e)):e<0&&(d=Math.min(d,f/(f-e))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d=0&&e>=0&&g>=0&&h>=0?!0:f<0&&e<0||g<0&&h<0?!1:(f<0?c=Math.max(c,f/(f-e)):e<0&&(d=Math.min(d,f/(f-e))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),dC&&f.positionScreen.zC&&f.positionScreen.z=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010)return 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),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;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}; +this.x,c=this.y,d=this.z,e=this.w,g=a.x,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,g=this.x,f=this.y,h=this.z,j=this.w,i=j*c+f*e-h*d,k=j*d+h*c-g*e,l=j*e+g*d-f*c,c=-g* +c-f*d-h*e;b.x=i*j+c*-g+k*-h-l*-f;b.y=k*j+c*-f+l*-g-i*-h;b.z=l*j+c*-h+i*-f-k*-g;return b}};THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),f=Math.sqrt(1-e*e);if(Math.abs(f)<0.0010)return 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),c;e=Math.sin((1-d)*g)/f;d=Math.sin(d*g)/f;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){this.position=a||new THREE.Vector3};THREE.Face3=function(a,b,c,d,e,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3}; THREE.Face4=function(a,b,c,d,e,g,f){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0}; -THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};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.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D; -THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);b.multiplyScalar(a);this.position.addSelf(b);this.target.position.addSelf(b)}; +THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c!==void 0?c:0.1;this.far=d!==void 0?d:2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()}; +THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;THREE.Camera.prototype.translate=function(a,b){this.matrix.rotateAxis(b);b.multiplyScalar(a);this.position.addSelf(b);this.target.position.addSelf(b)}; THREE.Camera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)}; THREE.Camera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()}; THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget)this.matrix.lookAt(this.position,this.target.position,this.up),this.matrix.setPosition(this.position),a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse),b=!0;else if(this.matrixAutoUpdate&&this.updateMatrix(),b||this.matrixWorldNeedsUpdate)a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate= @@ -84,5 +85,5 @@ THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.add=fu THREE.Scene.prototype.remove=function(a){this.supr.remove.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),b!==-1&&(this.objects.splice(b,1),this.__objectsRemoved.push(a)));for(b=0;b0:j<0)))if(j=l.dot((new THREE.Vector3). THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,l,j){h=!1;b=f;c=g;d=l;e=j;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=bf?d:f,e=e>g?e:g);a()};this.add3Points= function(f,g,l,j,m,n){h?(h=!1,b=fl?f>m?f:m:l>m?l:m,e=g>j?g>n?g:n:j>n?j:n):(b=fl?f>m?f>d?f:d:m>d?m:d:l>m?l>d?l:d:m>d?m:d,e=g>j?g>n?g>e?g:e:n>e?n:e:j>n?j>e?j:e:n>e?n:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=bf.getRight()?d:f.getRight(),e=e> f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d=0&&Math.min(e,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};THREE.Matrix3=function(){this.m=[]}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,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,f,h,k,i,l,j,m,n,p,q){this.set(a||1,b||0,c||0,d||0,e||0,g||1,f||0,h||0,k||0,i||0,l||1,j||0,m||0,n||0,p||0,q||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix3.prototype={constructor:THREE.Matrix3,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,f,h,k,i,l,j,m,n,p,q){this.set(a!==void 0?a:1,b||0,c||0,d||0,e||0,g!==void 0?g:1,f||0,h||0,k||0,i||0,l!==void 0?l:1,j||0,m||0,n||0,p||0,q!==void 0?q:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,g,f,h,k,i,l,j,m,n,p,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=f;this.n24=h;this.n31=k;this.n32=i;this.n33=l;this.n34=j;this.n41=m;this.n42=n;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.__v1,e=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.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},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},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+ @@ -83,14 +84,14 @@ D[c].addSelf(G);D[d].addSelf(G)}var b,c,d,e,g,f,h,k,i,l,j,m,n,p,q,v,u,C,K,t,w,z, 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.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b0&&b>0&&h+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b.matrixWorld.getPosition());if(f==null||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=c(this.origin,this.direction,b.matrixWorld.getPosition());if(f==null||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x, -Math.max(b.scale.y,b.scale.z)))return[];var j,h,k,m,r,p,u,n,s,v,B=b.geometry,y=B.vertices,E=[],f=0;for(j=B.faces.length;f0:n<0)))if(n=u.dot((new THREE.Vector3).sub(k,s))/n,s=s.addSelf(v.multiplyScalar(n)),h instanceof THREE.Face3)d(s,k,m,r)&&(h={distance:this.origin.distanceTo(s),point:s,face:h,object:b},E.push(h));else if(h instanceof THREE.Face4&&(d(s,k,m,p)||d(s,m,r,p)))h={distance:this.origin.distanceTo(s),point:s,face:h,object:b},E.push(h);E.sort(function(b,c){return b.distance-c.distance});return E}else return[]}}; -THREE.Rectangle=function(){function b(){h=f-c;k=j-d}var c,d,f,j,h,k,m=!0;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return j};this.set=function(h,k,u,n){m=!1;c=h;d=k;f=u;j=n;b()};this.addPoint=function(h,k){m?(m=!1,c=h,d=k,f=h,j=k):(c=ch?f:h,j=j>k?j:k);b()};this.add3Points= -function(h,k,u,n,s,v){m?(m=!1,c=hu?h>s?h:s:u>s?u:s,j=k>n?k>v?k:v:n>v?n:v):(c=hu?h>s?h>f?h:f:s>f?s:f:u>s?u>f?u:f:s>f?s:f,j=k>n?k>v?k>j?k:j:v>j?v:j:n>v?n>j?n:j:v>j?v:j);b()};this.addRectangle=function(h){m?(m=!1,c=h.getLeft(),d=h.getTop(),f=h.getRight(),j=h.getBottom()):(c=ch.getRight()?f:h.getRight(),j=j> +Math.max(b.scale.y,b.scale.z)))return[];var j,h,k,m,q,p,s,r,u,v,B=b.geometry,y=B.vertices,E=[],f=0;for(j=B.faces.length;f0:r<0)))if(r=s.dot((new THREE.Vector3).sub(k,u))/r,u=u.addSelf(v.multiplyScalar(r)),h instanceof THREE.Face3)d(u,k,m,q)&&(h={distance:this.origin.distanceTo(u),point:u,face:h,object:b},E.push(h));else if(h instanceof THREE.Face4&&(d(u,k,m,p)||d(u,m,q,p)))h={distance:this.origin.distanceTo(u),point:u,face:h,object:b},E.push(h);E.sort(function(b,c){return b.distance-c.distance});return E}else return[]}}; +THREE.Rectangle=function(){function b(){h=f-c;k=j-d}var c,d,f,j,h,k,m=!0;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return h};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return f};this.getBottom=function(){return j};this.set=function(h,k,s,r){m=!1;c=h;d=k;f=s;j=r;b()};this.addPoint=function(h,k){m?(m=!1,c=h,d=k,f=h,j=k):(c=ch?f:h,j=j>k?j:k);b()};this.add3Points= +function(h,k,s,r,u,v){m?(m=!1,c=hs?h>u?h:u:s>u?s:u,j=k>r?k>v?k:v:r>v?r:v):(c=hs?h>u?h>f?h:f:u>f?u:f:s>u?s>f?s:f:u>f?u:f,j=k>r?k>v?k>j?k:j:v>j?v:j:r>v?r>j?r:j:v>j?v:j);b()};this.addRectangle=function(h){m?(m=!1,c=h.getLeft(),d=h.getTop(),f=h.getRight(),j=h.getBottom()):(c=ch.getRight()?f:h.getRight(),j=j> h.getBottom()?j:h.getBottom());b()};this.inflate=function(h){c-=h;d-=h;f+=h;j+=h;b()};this.minSelf=function(h){c=c>h.getLeft()?c:h.getLeft();d=d>h.getTop()?d:h.getTop();f=f=0&&Math.min(j,b.getBottom())-Math.max(d,b.getTop())>=0};this.empty=function(){m=!0;j=f=d=c=0;b()};this.isEmpty=function(){return m}};THREE.Matrix3=function(){this.m=[]}; -THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}};THREE.Matrix4=function(b,c,d,f,j,h,k,m,r,p,u,n,s,v,B,y){this.set(b||1,c||0,d||0,f||0,j||0,h||1,k||0,m||0,r||0,p||0,u||1,n||0,s||0,v||0,B||0,y||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; -THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,d,f,j,h,k,m,r,p,u,n,s,v,B,y){this.n11=b;this.n12=c;this.n13=d;this.n14=f;this.n21=j;this.n22=h;this.n23=k;this.n24=m;this.n31=r;this.n32=p;this.n33=u;this.n34=n;this.n41=s;this.n42=v;this.n43=B;this.n44=y;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(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b, +THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var b,c=this.m;b=c[1];c[1]=c[3];c[3]=b;b=c[2];c[2]=c[6];c[6]=b;b=c[5];c[5]=c[7];c[7]=b;return this},transposeIntoArray:function(b){var c=this.m;b[0]=c[0];b[1]=c[3];b[2]=c[6];b[3]=c[1];b[4]=c[4];b[5]=c[7];b[6]=c[2];b[7]=c[5];b[8]=c[8];return this}}; +THREE.Matrix4=function(b,c,d,f,j,h,k,m,q,p,s,r,u,v,B,y){this.set(b!==void 0?b:1,c||0,d||0,f||0,j||0,h!==void 0?h:1,k||0,m||0,q||0,p||0,s!==void 0?s:1,r||0,u||0,v||0,B||0,y!==void 0?y:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; +THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,d,f,j,h,k,m,q,p,s,r,u,v,B,y){this.n11=b;this.n12=c;this.n13=d;this.n14=f;this.n21=j;this.n22=h;this.n23=k;this.n24=m;this.n31=q;this.n32=p;this.n33=s;this.n34=r;this.n41=u;this.n42=v;this.n43=B;this.n44=y;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(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b, c,d){var f=THREE.Matrix4.__v1,j=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,c).normalize();if(h.length()===0)h.z=1;f.cross(d,h).normalize();f.length()===0&&(h.x+=1.0E-4,f.cross(d,h).normalize());j.cross(h,f).normalize();this.n11=f.x;this.n12=j.x;this.n13=h.x;this.n21=f.y;this.n22=j.y;this.n23=h.y;this.n31=f.z;this.n32=j.z;this.n33=h.z;return this},multiplyVector3:function(b){var c=b.x,d=b.y,f=b.z,j=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*j; b.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*j;b.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*j;return b},multiplyVector4:function(b){var c=b.x,d=b.y,f=b.z,j=b.w;b.x=this.n11*c+this.n12*d+this.n13*f+this.n14*j;b.y=this.n21*c+this.n22*d+this.n23*f+this.n24*j;b.z=this.n31*c+this.n32*d+this.n33*f+this.n34*j;b.w=this.n41*c+this.n42*d+this.n43*f+this.n44*j;return b},rotateAxis:function(b){var c=b.x,d=b.y,f=b.z;b.x=c*this.n11+d*this.n12+f*this.n13;b.y=c*this.n21+d*this.n22+f*this.n23;b.z=c*this.n31+ -d*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var d=b.n11,f=b.n12,j=b.n13,h=b.n14,k=b.n21,m=b.n22,r=b.n23,p=b.n24,u=b.n31,n=b.n32,s=b.n33,v=b.n34,B=b.n41,y=b.n42,E=b.n43,C=b.n44,xa=c.n11,ya= -c.n12,pa=c.n13,ra=c.n14,fa=c.n21,F=c.n22,w=c.n23,ia=c.n24,L=c.n31,ja=c.n32,Y=c.n33,ua=c.n34,Q=c.n41,M=c.n42,e=c.n43,Da=c.n44;this.n11=d*xa+f*fa+j*L+h*Q;this.n12=d*ya+f*F+j*ja+h*M;this.n13=d*pa+f*w+j*Y+h*e;this.n14=d*ra+f*ia+j*ua+h*Da;this.n21=k*xa+m*fa+r*L+p*Q;this.n22=k*ya+m*F+r*ja+p*M;this.n23=k*pa+m*w+r*Y+p*e;this.n24=k*ra+m*ia+r*ua+p*Da;this.n31=u*xa+n*fa+s*L+v*Q;this.n32=u*ya+n*F+s*ja+v*M;this.n33=u*pa+n*w+s*Y+v*e;this.n34=u*ra+n*ia+s*ua+v*Da;this.n41=B*xa+y*fa+E*L+C*Q;this.n42=B*ya+y*F+E*ja+ -C*M;this.n43=B*pa+y*w+E*Y+C*e;this.n44=B*ra+y*ia+E*ua+C*Da;return this},multiplyToArray:function(b,c,d){this.multiply(b,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(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b; -this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,c=this.n12,d=this.n13,f=this.n14,j=this.n21,h=this.n22,k=this.n23,m=this.n24,r=this.n31,p=this.n32,u=this.n33,n=this.n34,s=this.n41,v=this.n42,B=this.n43,y=this.n44;return f*k*p*s-d*m*p*s-f*h*u*s+c*m*u*s+d*h*n*s-c*k*n*s-f*k*r*v+d*m*r*v+f*j*u*v-b*m*u*v-d*j*n*v+b*k*n*v+f*h*r*B-c*m*r*B-f*j*p*B+b*m*p*B+c*j*n* -B-b*h*n*B-d*h*r*y+c*k*r*y+d*j*p*y-b*k*p*y-c*j*u*y+b*h*u*y},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31= +d*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var d=b.n11,f=b.n12,j=b.n13,h=b.n14,k=b.n21,m=b.n22,q=b.n23,p=b.n24,s=b.n31,r=b.n32,u=b.n33,v=b.n34,B=b.n41,y=b.n42,E=b.n43,C=b.n44,ya=c.n11,za= +c.n12,qa=c.n13,sa=c.n14,ga=c.n21,F=c.n22,w=c.n23,ja=c.n24,L=c.n31,ka=c.n32,Y=c.n33,va=c.n34,Q=c.n41,M=c.n42,e=c.n43,Ea=c.n44;this.n11=d*ya+f*ga+j*L+h*Q;this.n12=d*za+f*F+j*ka+h*M;this.n13=d*qa+f*w+j*Y+h*e;this.n14=d*sa+f*ja+j*va+h*Ea;this.n21=k*ya+m*ga+q*L+p*Q;this.n22=k*za+m*F+q*ka+p*M;this.n23=k*qa+m*w+q*Y+p*e;this.n24=k*sa+m*ja+q*va+p*Ea;this.n31=s*ya+r*ga+u*L+v*Q;this.n32=s*za+r*F+u*ka+v*M;this.n33=s*qa+r*w+u*Y+v*e;this.n34=s*sa+r*ja+u*va+v*Ea;this.n41=B*ya+y*ga+E*L+C*Q;this.n42=B*za+y*F+E*ka+ +C*M;this.n43=B*qa+y*w+E*Y+C*e;this.n44=B*sa+y*ja+E*va+C*Ea;return this},multiplyToArray:function(b,c,d){this.multiply(b,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(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b; +this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,c=this.n12,d=this.n13,f=this.n14,j=this.n21,h=this.n22,k=this.n23,m=this.n24,q=this.n31,p=this.n32,s=this.n33,r=this.n34,u=this.n41,v=this.n42,B=this.n43,y=this.n44;return f*k*p*u-d*m*p*u-f*h*s*u+c*m*s*u+d*h*r*u-c*k*r*u-f*k*q*v+d*m*q*v+f*j*s*v-b*m*s*v-d*j*r*v+b*k*r*v+f*h*q*B-c*m*q*B-f*j*p*B+b*m*p*B+c*j*r* +B-b*h*r*B-d*h*q*y+c*k*q*y+d*j*p*y-b*k*p*y-c*j*s*y+b*h*s*y},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31= this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},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(b){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 b},flattenToArrayOffset:function(b,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]= this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]=this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,d){this.set(1,0,0,b,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(b,c,d){this.set(b,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c= -Math.cos(b),b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var d=Math.cos(c),f=Math.sin(c),j=1-d,h=b.x,k=b.y,m=b.z,r=j*h,p=j*k;this.set(r*h+d,r*k-f*m,r*m+f*k,0,r*k+f*m,p*k+d,p*m-f*h,0,r*m-f*k,p*m+f*h,j*m*m+d,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position}, +Math.cos(b),b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var d=Math.cos(c),f=Math.sin(c),j=1-d,h=b.x,k=b.y,m=b.z,q=j*h,p=j*k;this.set(q*h+d,q*k-f*m,q*m+f*k,0,q*k+f*m,p*k+d,p*m-f*h,0,q*m-f*k,p*m+f*h,j*m*m+d,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position}, getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,c){var d=b.x,f=b.y,j=b.z,h=Math.cos(d),d=Math.sin(d),k=Math.cos(f), -f=Math.sin(f),m=Math.cos(j),j=Math.sin(j);switch(c){case "YXZ":var r=k*m,p=k*j,u=f*m,n=f*j;this.n11=r+n*d;this.n12=u*d-p;this.n13=h*f;this.n21=h*j;this.n22=h*m;this.n23=-d;this.n31=p*d-u;this.n32=n+r*d;this.n33=h*k;break;case "ZXY":r=k*m;p=k*j;u=f*m;n=f*j;this.n11=r-n*d;this.n12=-h*j;this.n13=u+p*d;this.n21=p+u*d;this.n22=h*m;this.n23=n-r*d;this.n31=-h*f;this.n32=d;this.n33=h*k;break;case "ZYX":r=h*m;p=h*j;u=d*m;n=d*j;this.n11=k*m;this.n12=u*f-p;this.n13=r*f+n;this.n21=k*j;this.n22=n*f+r;this.n23= -p*f-u;this.n31=-f;this.n32=d*k;this.n33=h*k;break;case "YZX":r=h*k;p=h*f;u=d*k;n=d*f;this.n11=k*m;this.n12=n-r*j;this.n13=u*j+p;this.n21=j;this.n22=h*m;this.n23=-d*m;this.n31=-f*m;this.n32=p*j+u;this.n33=r-n*j;break;case "XZY":r=h*k;p=h*f;u=d*k;n=d*f;this.n11=k*m;this.n12=-j;this.n13=f*m;this.n21=r*j+n;this.n22=h*m;this.n23=p*j-u;this.n31=u*j-p;this.n32=d*m;this.n33=n*j+r;break;default:r=h*m,p=h*j,u=d*m,n=d*j,this.n11=k*m,this.n12=-k*j,this.n13=f,this.n21=p+u*f,this.n22=r-n*f,this.n23=-d*k,this.n31= -n-r*f,this.n32=u+p*f,this.n33=h*k}return this},setRotationFromQuaternion:function(b){var c=b.x,d=b.y,f=b.z,j=b.w,h=c+c,k=d+d,m=f+f,b=c*h,r=c*k;c*=m;var p=d*k;d*=m;f*=m;h*=j;k*=j;j*=m;this.n11=1-(p+f);this.n12=r-j;this.n13=c+k;this.n21=r+j;this.n22=1-(b+f);this.n23=d-h;this.n31=c-k;this.n32=d+h;this.n33=1-(b+p);return this},scale:function(b){var c=b.x,d=b.y,b=b.z;this.n11*=c;this.n12*=d;this.n13*=b;this.n21*=c;this.n22*=d;this.n23*=b;this.n31*=c;this.n32*=d;this.n33*=b;this.n41*=c;this.n42*=d;this.n43*= +f=Math.sin(f),m=Math.cos(j),j=Math.sin(j);switch(c){case "YXZ":var q=k*m,p=k*j,s=f*m,r=f*j;this.n11=q+r*d;this.n12=s*d-p;this.n13=h*f;this.n21=h*j;this.n22=h*m;this.n23=-d;this.n31=p*d-s;this.n32=r+q*d;this.n33=h*k;break;case "ZXY":q=k*m;p=k*j;s=f*m;r=f*j;this.n11=q-r*d;this.n12=-h*j;this.n13=s+p*d;this.n21=p+s*d;this.n22=h*m;this.n23=r-q*d;this.n31=-h*f;this.n32=d;this.n33=h*k;break;case "ZYX":q=h*m;p=h*j;s=d*m;r=d*j;this.n11=k*m;this.n12=s*f-p;this.n13=q*f+r;this.n21=k*j;this.n22=r*f+q;this.n23= +p*f-s;this.n31=-f;this.n32=d*k;this.n33=h*k;break;case "YZX":q=h*k;p=h*f;s=d*k;r=d*f;this.n11=k*m;this.n12=r-q*j;this.n13=s*j+p;this.n21=j;this.n22=h*m;this.n23=-d*m;this.n31=-f*m;this.n32=p*j+s;this.n33=q-r*j;break;case "XZY":q=h*k;p=h*f;s=d*k;r=d*f;this.n11=k*m;this.n12=-j;this.n13=f*m;this.n21=q*j+r;this.n22=h*m;this.n23=p*j-s;this.n31=s*j-p;this.n32=d*m;this.n33=r*j+q;break;default:q=h*m,p=h*j,s=d*m,r=d*j,this.n11=k*m,this.n12=-k*j,this.n13=f,this.n21=p+s*f,this.n22=q-r*f,this.n23=-d*k,this.n31= +r-q*f,this.n32=s+p*f,this.n33=h*k}return this},setRotationFromQuaternion:function(b){var c=b.x,d=b.y,f=b.z,j=b.w,h=c+c,k=d+d,m=f+f,b=c*h,q=c*k;c*=m;var p=d*k;d*=m;f*=m;h*=j;k*=j;j*=m;this.n11=1-(p+f);this.n12=q-j;this.n13=c+k;this.n21=q+j;this.n22=1-(b+f);this.n23=d-h;this.n31=c-k;this.n32=d+h;this.n33=1-(b+p);return this},scale:function(b){var c=b.x,d=b.y,b=b.z;this.n11*=c;this.n12*=d;this.n13*=b;this.n21*=c;this.n22*=d;this.n23*=b;this.n31*=c;this.n32*=d;this.n33*=b;this.n41*=c;this.n42*=d;this.n43*= b;return this},compose:function(b,c,d){var f=THREE.Matrix4.__m1,j=THREE.Matrix4.__m2;f.identity();f.setRotationFromQuaternion(c);j.setScale(d.x,d.y,d.z);this.multiply(f,j);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,d){var f=THREE.Matrix4.__v1,j=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;f.set(this.n11,this.n21,this.n31);j.set(this.n12,this.n22,this.n32);h.set(this.n13,this.n23,this.n33);b=b instanceof THREE.Vector3?b:new THREE.Vector3;c=c instanceof THREE.Quaternion?c: new THREE.Quaternion;d=d instanceof THREE.Vector3?d:new THREE.Vector3;d.x=f.length();d.y=j.length();d.z=h.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;f=THREE.Matrix4.__m1;f.copy(this);f.n11/=d.x;f.n21/=d.x;f.n31/=d.x;f.n12/=d.y;f.n22/=d.y;f.n32/=d.y;f.n13/=d.z;f.n23/=d.z;f.n33/=d.z;c.setFromRotationMatrix(f);return[b,c,d]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var d=1/c.x,f=1/c.y,j=1/c.z;this.n11=b.n11*d;this.n21=b.n21*d;this.n31= b.n31*d;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*j;this.n23=b.n23*j;this.n33=b.n33*j}}; -THREE.Matrix4.makeInvert=function(b,c){var d=b.n11,f=b.n12,j=b.n13,h=b.n14,k=b.n21,m=b.n22,r=b.n23,p=b.n24,u=b.n31,n=b.n32,s=b.n33,v=b.n34,B=b.n41,y=b.n42,E=b.n43,C=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=r*v*y-p*s*y+p*n*E-m*v*E-r*n*C+m*s*C;c.n12=h*s*y-j*v*y-h*n*E+f*v*E+j*n*C-f*s*C;c.n13=j*p*y-h*r*y+h*m*E-f*p*E-j*m*C+f*r*C;c.n14=h*r*n-j*p*n-h*m*s+f*p*s+j*m*v-f*r*v;c.n21=p*s*B-r*v*B-p*u*E+k*v*E+r*u*C-k*s*C;c.n22=j*v*B-h*s*B+h*u*E-d*v*E-j*u*C+d*s*C;c.n23=h*r*B-j*p*B-h*k*E+d*p*E+j*k*C-d*r*C;c.n24= -j*p*u-h*r*u+h*k*s-d*p*s-j*k*v+d*r*v;c.n31=m*v*B-p*n*B+p*u*y-k*v*y-m*u*C+k*n*C;c.n32=h*n*B-f*v*B-h*u*y+d*v*y+f*u*C-d*n*C;c.n33=j*p*B-h*m*B+h*k*y-d*p*y-f*k*C+d*m*C;c.n34=h*m*u-f*p*u-h*k*n+d*p*n+f*k*v-d*m*v;c.n41=r*n*B-m*s*B-r*u*y+k*s*y+m*u*E-k*n*E;c.n42=f*s*B-j*n*B+j*u*y-d*s*y-f*u*E+d*n*E;c.n43=j*m*B-f*r*B-j*k*y+d*r*y+f*k*E-d*m*E;c.n44=f*r*u-j*m*u+j*k*n-d*r*n-f*k*s+d*m*s;c.multiplyScalar(1/b.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,d=c.m,f=b.n33*b.n22-b.n32*b.n23,j=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,k=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,r=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,u=-b.n23*b.n11+b.n21*b.n13,n=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*k+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;d[0]=b*f;d[1]=b*j;d[2]=b*h;d[3]=b*k;d[4]=b*m;d[5]=b*r;d[6]=b*p;d[7]=b*u;d[8]=b*n;return c}; +THREE.Matrix4.makeInvert=function(b,c){var d=b.n11,f=b.n12,j=b.n13,h=b.n14,k=b.n21,m=b.n22,q=b.n23,p=b.n24,s=b.n31,r=b.n32,u=b.n33,v=b.n34,B=b.n41,y=b.n42,E=b.n43,C=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=q*v*y-p*u*y+p*r*E-m*v*E-q*r*C+m*u*C;c.n12=h*u*y-j*v*y-h*r*E+f*v*E+j*r*C-f*u*C;c.n13=j*p*y-h*q*y+h*m*E-f*p*E-j*m*C+f*q*C;c.n14=h*q*r-j*p*r-h*m*u+f*p*u+j*m*v-f*q*v;c.n21=p*u*B-q*v*B-p*s*E+k*v*E+q*s*C-k*u*C;c.n22=j*v*B-h*u*B+h*s*E-d*v*E-j*s*C+d*u*C;c.n23=h*q*B-j*p*B-h*k*E+d*p*E+j*k*C-d*q*C;c.n24= +j*p*s-h*q*s+h*k*u-d*p*u-j*k*v+d*q*v;c.n31=m*v*B-p*r*B+p*s*y-k*v*y-m*s*C+k*r*C;c.n32=h*r*B-f*v*B-h*s*y+d*v*y+f*s*C-d*r*C;c.n33=j*p*B-h*m*B+h*k*y-d*p*y-f*k*C+d*m*C;c.n34=h*m*s-f*p*s-h*k*r+d*p*r+f*k*v-d*m*v;c.n41=q*r*B-m*u*B-q*s*y+k*u*y+m*s*E-k*r*E;c.n42=f*u*B-j*r*B+j*s*y-d*u*y-f*s*E+d*r*E;c.n43=j*m*B-f*q*B-j*k*y+d*q*y+f*k*E-d*m*E;c.n44=f*q*s-j*m*s+j*k*r-d*q*r-f*k*u+d*m*u;c.multiplyScalar(1/b.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,d=c.m,f=b.n33*b.n22-b.n32*b.n23,j=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,k=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,q=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,s=-b.n23*b.n11+b.n21*b.n13,r=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*k+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;d[0]=b*f;d[1]=b*j;d[2]=b*h;d[3]=b*k;d[4]=b*m;d[5]=b*q;d[6]=b*p;d[7]=b*s;d[8]=b*r;return c}; THREE.Matrix4.makeFrustum=function(b,c,d,f,j,h){var k;k=new THREE.Matrix4;k.n11=2*j/(c-b);k.n12=0;k.n13=(c+b)/(c-b);k.n14=0;k.n21=0;k.n22=2*j/(f-d);k.n23=(f+d)/(f-d);k.n24=0;k.n31=0;k.n32=0;k.n33=-(h+j)/(h-j);k.n34=-2*h*j/(h-j);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(b,c,d,f){var j,b=d*Math.tan(b*Math.PI/360);j=-b;return THREE.Matrix4.makeFrustum(j*c,b*c,j,b,d,f)}; -THREE.Matrix4.makeOrtho=function(b,c,d,f,j,h){var k,m,r,p;k=new THREE.Matrix4;m=c-b;r=d-f;p=h-j;k.n11=2/m;k.n12=0;k.n13=0;k.n14=-((c+b)/m);k.n21=0;k.n22=2/r;k.n23=0;k.n24=-((d+f)/r);k.n31=0;k.n32=0;k.n33=-2/p;k.n34=-((h+j)/p);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; +THREE.Matrix4.makeOrtho=function(b,c,d,f,j,h){var k,m,q,p;k=new THREE.Matrix4;m=c-b;q=d-f;p=h-j;k.n11=2/m;k.n12=0;k.n13=0;k.n14=-((c+b)/m);k.n21=0;k.n22=2/q;k.n23=0;k.n24=-((d+f)/q);k.n31=0;k.n32=0;k.n33=-2/p;k.n34=-((h+j)/p);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; THREE.Object3D=function(){this.id=THREE.Object3DCount++;this.name="";this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate= !0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3}; THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(b,c){this.matrix.rotateAxis(c);this.position.addSelf(c.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(b,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},add:function(b){if(this.children.indexOf(b)=== -1){b.parent!==void 0&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var c=this;c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.addChildRecurse(b)}},remove:function(b){var c=this.children.indexOf(b);if(c!==-1)b.parent=void 0,this.children.splice(c,1)},getChildByName:function(b,c){var d,f,j;d=0;for(f=this.children.length;d=0&&j>=0&&h>=0&&k>=0?!0:f<0&&j<0||h<0&&k<0?!1:(f<0?d=Math.max(d,f/(f-j)):j<0&&(e=Math.min(e,f/(f-j))),h<0?d=Math.max(d,h/(h-k)):k<0&&(e=Math.min(e,h/(h-k))),ee&&k.positionScreen.z0&&F.z<1))sa=ya[xa]=ya[xa]||new THREE.RenderableParticle,xa++,C=sa,C.x=F.x/F.w,C.y=F.y/F.w,C.z=F.z,C.rotation=P.rotation.z,C.scale.x=P.scale.x*Math.abs(C.x- -(F.x+j.projectionMatrix.n11)/(F.w+j.projectionMatrix.n14)),C.scale.y=P.scale.y*Math.abs(C.y-(F.y+j.projectionMatrix.n22)/(F.w+j.projectionMatrix.n24)),C.materials=P.materials,ra.push(C);h&&ra.sort(c);return ra}};THREE.Quaternion=function(b,c,d,f){this.set(b||0,c||0,d||0,f!==void 0?f:1)}; +THREE.Projector=function(){function b(){var b=q[m]=q[m]||new THREE.RenderableVertex;m++;return b}function c(b,c){return c.z-b.z}function d(b,c){var d=0,e=1,f=b.z+b.w,j=c.z+c.w,h=-b.z+b.w,k=-c.z+c.w;return f>=0&&j>=0&&h>=0&&k>=0?!0:f<0&&j<0||h<0&&k<0?!1:(f<0?d=Math.max(d,f/(f-j)):j<0&&(e=Math.min(e,f/(f-j))),h<0?d=Math.max(d,h/(h-k)):k<0&&(e=Math.min(e,h/(h-k))),ee&&k.positionScreen.z0&&F.z<1))ta=za[ya]=za[ya]||new THREE.RenderableParticle,ya++,C=ta,C.x=F.x/F.w,C.y=F.y/F.w,C.z=F.z,C.rotation=P.rotation.z,C.scale.x=P.scale.x*Math.abs(C.x- +(F.x+j.projectionMatrix.n11)/(F.w+j.projectionMatrix.n14)),C.scale.y=P.scale.y*Math.abs(C.y-(F.y+j.projectionMatrix.n22)/(F.w+j.projectionMatrix.n24)),C.materials=P.materials,sa.push(C);h&&sa.sort(c);return sa}};THREE.Quaternion=function(b,c,d,f){this.set(b||0,c||0,d||0,f!==void 0?f:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,d,f){this.x=b;this.y=c;this.z=d;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=0.5*Math.PI/360,d=b.x*c,f=b.y*c,j=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-j),j=Math.sin(-j),h=Math.cos(d),d=Math.sin(d),k=b*c,m=f*j;this.w=k*h-m*d;this.x=k*d+m*h;this.y=f*c*h+b*j*d;this.z=b*j*h-f*c*d;return this},setFromAxisAngle:function(b,c){var d=c/2,f=Math.sin(d); this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(d);return this},setFromRotationMatrix:function(b){var c=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,c+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,c-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,c-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},multiplySelf:function(b){var c= -this.x,d=this.y,f=this.z,j=this.w,h=b.x,k=b.y,m=b.z,b=b.w;this.x=c*b+j*h+d*m-f*k;this.y=d*b+j*k+f*h-c*m;this.z=f*b+j*m+c*k-d*h;this.w=j*b-c*h-d*k-f*m;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var d=b.x,f=b.y,j=b.z,h=this.x,k=this.y,m=this.z,r=this.w,p=r*d+k*j-m*f,u=r*f+m*d-h*j,n=r*j+h*f-k*d,d=-h* -d-k*f-m*j;c.x=p*r+d*-h+u*-m-n*-k;c.y=u*r+d*-k+n*-h-p*-m;c.z=n*r+d*-m+p*-k-u*-h;return c}};THREE.Quaternion.slerp=function(b,c,d,f){var j=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(j)>=1)return d.w=b.w,d.x=b.x,d.y=b.y,d.z=b.z,d;var h=Math.acos(j),k=Math.sqrt(1-j*j);if(Math.abs(k)<0.0010)return d.w=0.5*(b.w+c.w),d.x=0.5*(b.x+c.x),d.y=0.5*(b.y+c.y),d.z=0.5*(b.z+c.z),d;j=Math.sin((1-f)*h)/k;f=Math.sin(f*h)/k;d.w=b.w*j+c.w*f;d.x=b.x*j+c.x*f;d.y=b.y*j+c.y*f;d.z=b.z*j+c.z*f;return d}; +this.x,d=this.y,f=this.z,j=this.w,h=b.x,k=b.y,m=b.z,b=b.w;this.x=c*b+j*h+d*m-f*k;this.y=d*b+j*k+f*h-c*m;this.z=f*b+j*m+c*k-d*h;this.w=j*b-c*h-d*k-f*m;return this},multiply:function(b,c){this.x=b.x*c.w+b.y*c.z-b.z*c.y+b.w*c.x;this.y=-b.x*c.z+b.y*c.w+b.z*c.x+b.w*c.y;this.z=b.x*c.y-b.y*c.x+b.z*c.w+b.w*c.z;this.w=-b.x*c.x-b.y*c.y-b.z*c.z+b.w*c.w;return this},multiplyVector3:function(b,c){c||(c=b);var d=b.x,f=b.y,j=b.z,h=this.x,k=this.y,m=this.z,q=this.w,p=q*d+k*j-m*f,s=q*f+m*d-h*j,r=q*j+h*f-k*d,d=-h* +d-k*f-m*j;c.x=p*q+d*-h+s*-m-r*-k;c.y=s*q+d*-k+r*-h-p*-m;c.z=r*q+d*-m+p*-k-s*-h;return c}};THREE.Quaternion.slerp=function(b,c,d,f){var j=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(j)>=1)return d.w=b.w,d.x=b.x,d.y=b.y,d.z=b.z,d;var h=Math.acos(j),k=Math.sqrt(1-j*j);if(Math.abs(k)<0.0010)return d.w=0.5*(b.w+c.w),d.x=0.5*(b.x+c.x),d.y=0.5*(b.y+c.y),d.z=0.5*(b.z+c.z),d;j=Math.sin((1-f)*h)/k;f=Math.sin(f*h)/k;d.w=b.w*j+c.w*f;d.x=b.x*j+c.x*f;d.y=b.y*j+c.y*f;d.z=b.z*j+c.z*f;return d}; THREE.Vertex=function(b){this.position=b||new THREE.Vector3};THREE.Face3=function(b,c,d,f,j,h){this.a=b;this.b=c;this.c=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,c,d,f,j,h,k){this.a=b;this.b=c;this.c=d;this.d=f;this.normal=j instanceof THREE.Vector3?j:new THREE.Vector3;this.vertexNormals=j instanceof Array?j:[];this.color=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.u=b||0;this.v=c||0}; THREE.UV.prototype={constructor:THREE.UV,set:function(b,c){this.u=b;this.v=c;return this},copy:function(b){this.u=b.u;this.v=b.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}}; THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1}; THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(b){var c=new THREE.Matrix4;c.extractRotation(b,new THREE.Vector3(1,1,1));for(var d=0,f=this.vertices.length;d0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +d.vertexNormals[1].copy(f[d.b]),d.vertexNormals[2].copy(f[d.c]),d.vertexNormals[3].copy(f[d.d]))},computeTangents:function(){function b(b,e,c,d,f,j,h){m=b.vertices[e].position;q=b.vertices[c].position;p=b.vertices[d].position;s=k[f];r=k[j];u=k[h];v=q.x-m.x;B=p.x-m.x;y=q.y-m.y;E=p.y-m.y;C=q.z-m.z;ya=p.z-m.z;za=r.u-s.u;qa=u.u-s.u;sa=r.v-s.v;ga=u.v-s.v;F=1/(za*ga-qa*sa);ka.set((ga*v-sa*B)*F,(ga*y-sa*E)*F,(ga*C-sa*ya)*F);Y.set((za*B-qa*v)*F,(za*E-qa*y)*F,(za*ya-qa*C)*F);ja[e].addSelf(ka);ja[c].addSelf(ka); +ja[d].addSelf(ka);L[e].addSelf(Y);L[c].addSelf(Y);L[d].addSelf(Y)}var c,d,f,j,h,k,m,q,p,s,r,u,v,B,y,E,C,ya,za,qa,sa,ga,F,w,ja=[],L=[],ka=new THREE.Vector3,Y=new THREE.Vector3,va=new THREE.Vector3,Q=new THREE.Vector3,M=new THREE.Vector3;c=0;for(d=this.vertices.length;c0){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]=b.position.x;if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z< this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,d=this.vertices.length;cthis.points.length-2?h:h+1;d[3]=h>this.points.length-3?h:h+2;p=this.points[d[0]];u=this.points[d[1]]; -n=this.points[d[2]];s=this.points[d[3]];m=k*k;r=k*m;f.x=c(p.x,u.x,n.x,s.x,k,m,r);f.y=c(p.y,u.y,n.y,s.y,k,m,r);f.z=c(p.z,u.z,n.z,s.z,k,m,r);return f};this.getControlPointsArray=function(){var b,c,d=this.points.length,f=[];for(b=0;bthis.points.length-2?h:h+1;d[3]=h>this.points.length-3?h:h+2;p=this.points[d[0]];s=this.points[d[1]]; +r=this.points[d[2]];u=this.points[d[3]];m=k*k;q=k*m;f.x=c(p.x,s.x,r.x,u.x,k,m,q);f.y=c(p.y,s.y,r.y,u.y,k,m,q);f.z=c(p.z,s.z,r.z,u.z,k,m,q);return f};this.getControlPointsArray=function(){var b,c,d=this.points.length,f=[];for(b=0;b=0)e.bindBuffer(e.ARRAY_BUFFER,h.__webglVertexBuffer),e.vertexAttribPointer(b.position, 3,e.FLOAT,!1,0,0);else if(k.morphTargetBase){c=j.program.attributes;k.morphTargetBase!==-1?(e.bindBuffer(e.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[k.morphTargetBase]),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0)):c.position>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglVertexBuffer),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0));if(k.morphTargetForcedOrder.length)for(var f=0,p=k.morphTargetForcedOrder,H=k.morphTargetInfluences;fr&&(D=n,r=H[D]);e.bindBuffer(e.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[D]);e.vertexAttribPointer(c["morphTarget"+f],3,e.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[f]=r;p[D]=1;r= +h.__webglMorphTargetsBuffers[p[f]]),e.vertexAttribPointer(c["morphTarget"+f],3,e.FLOAT,!1,0,0),k.__webglMorphTargetInfluences[f]=H[p[f]],f++;else{var p=[],q=-1,D=0,H=k.morphTargetInfluences,r,s=H.length,f=0;for(k.morphTargetBase!==-1&&(p[k.morphTargetBase]=!0);fq&&(D=r,q=H[D]);e.bindBuffer(e.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[D]);e.vertexAttribPointer(c["morphTarget"+f],3,e.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[f]=q;p[D]=1;q= -1;f++}}j.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(j.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(m in h.__webglCustomAttributes)b[m]>=0&&(c=h.__webglCustomAttributes[m],e.bindBuffer(e.ARRAY_BUFFER,c.buffer),e.vertexAttribPointer(b[m],c.size,e.FLOAT,!1,0,0));b.color>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglColorBuffer),e.vertexAttribPointer(b.color,3,e.FLOAT,!1,0,0));b.normal>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglNormalBuffer), e.vertexAttribPointer(b.normal,3,e.FLOAT,!1,0,0));b.tangent>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglTangentBuffer),e.vertexAttribPointer(b.tangent,4,e.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(e.bindBuffer(e.ARRAY_BUFFER,h.__webglUVBuffer),e.vertexAttribPointer(b.uv,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv)):e.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(e.bindBuffer(e.ARRAY_BUFFER,h.__webglUV2Buffer),e.vertexAttribPointer(b.uv2,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv2)): e.disableVertexAttribArray(b.uv2));j.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglSkinVertexABuffer),e.vertexAttribPointer(b.skinVertexA,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),e.vertexAttribPointer(b.skinVertexB,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),e.vertexAttribPointer(b.skinIndex,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,h.__webglSkinWeightsBuffer), e.vertexAttribPointer(b.skinWeight,4,e.FLOAT,!1,0,0));k instanceof THREE.Mesh?(j.wireframe?(e.lineWidth(j.wireframeLinewidth),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),e.drawElements(e.LINES,h.__webglLineCount,e.UNSIGNED_SHORT,0)):(e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),e.drawElements(e.TRIANGLES,h.__webglFaceCount,e.UNSIGNED_SHORT,0)),M.data.vertices+=h.__webglFaceCount,M.data.faces+=h.__webglFaceCount/3,M.data.drawCalls++):k instanceof THREE.Line?(k=k.type==THREE.LineStrip? e.LINE_STRIP:e.LINES,e.lineWidth(j.linewidth),e.drawArrays(k,0,h.__webglLineCount),M.data.drawCalls++):k instanceof THREE.ParticleSystem?(e.drawArrays(e.POINTS,0,h.__webglParticleCount),M.data.drawCalls++):k instanceof THREE.Ribbon&&(e.drawArrays(e.TRIANGLE_STRIP,0,h.__webglVertexCount),M.data.drawCalls++)}}function j(b,c,d){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=e.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=e.createBuffer();b.hasPos&&(e.bindBuffer(e.ARRAY_BUFFER,b.__webglVertexBuffer), -e.bufferData(e.ARRAY_BUFFER,b.positionArray,e.DYNAMIC_DRAW),e.enableVertexAttribArray(c.attributes.position),e.vertexAttribPointer(c.attributes.position,3,e.FLOAT,!1,0,0));if(b.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,b.__webglNormalBuffer);if(d==THREE.FlatShading){var f,h,j,k,m,H,p,r,n,q,u=b.count*3;for(q=0;q=0;d--)b[d].object==c&&b.splice(d,1)}function ra(b){function c(b){var f=[];d=0;for(e=b.length;d65535&&(r[m].counter+=1,p=r[m].hash+"_"+r[m].counter,b.geometryGroups[p]==void 0&&(b.geometryGroups[p]= -{faces:[],materials:k,vertices:0,numMorphTargets:n})),b.geometryGroups[p].faces.push(f),b.geometryGroups[p].vertices+=j;b.geometryGroupsList=[];for(var q in b.geometryGroups)b.geometryGroupsList.push(b.geometryGroups[q])}function fa(b,c,d){b.push({buffer:c,object:d,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function F(b){if(b!=J){switch(b){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD); +e.bufferData(e.ARRAY_BUFFER,b.positionArray,e.DYNAMIC_DRAW),e.enableVertexAttribArray(c.attributes.position),e.vertexAttribPointer(c.attributes.position,3,e.FLOAT,!1,0,0));if(b.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,b.__webglNormalBuffer);if(d==THREE.FlatShading){var f,h,j,k,m,H,p,q,r,s,n=b.count*3;for(s=0;s=0;d--)b[d].object==c&&b.splice(d,1)}function sa(b){function c(b){var f=[];d=0;for(e=b.length;d65535&&(q[m].counter+=1,p=q[m].hash+"_"+q[m].counter,b.geometryGroups[p]==void 0&&(b.geometryGroups[p]= +{faces:[],materials:k,vertices:0,numMorphTargets:r})),b.geometryGroups[p].faces.push(f),b.geometryGroups[p].vertices+=j;b.geometryGroupsList=[];for(var s in b.geometryGroups)b.geometryGroupsList.push(b.geometryGroups[s])}function ga(b,c,d){b.push({buffer:c,object:d,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function F(b){if(b!=J){switch(b){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD); e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}J=b}}function w(b,c,d){(d.width&d.width-1)==0&&(d.height&d.height-1)==0?(e.texParameteri(b,e.TEXTURE_WRAP_S,Q(c.wrapS)),e.texParameteri(b,e.TEXTURE_WRAP_T,Q(c.wrapT)),e.texParameteri(b,e.TEXTURE_MAG_FILTER,Q(c.magFilter)), -e.texParameteri(b,e.TEXTURE_MIN_FILTER,Q(c.minFilter)),e.generateMipmap(b)):(e.texParameteri(b,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(b,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(b,e.TEXTURE_MAG_FILTER,ua(c.magFilter)),e.texParameteri(b,e.TEXTURE_MIN_FILTER,ua(c.minFilter)))}function ia(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=e.createTexture();e.activeTexture(e.TEXTURE0+c);e.bindTexture(e.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture? +e.texParameteri(b,e.TEXTURE_MIN_FILTER,Q(c.minFilter)),e.generateMipmap(b)):(e.texParameteri(b,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(b,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(b,e.TEXTURE_MAG_FILTER,va(c.magFilter)),e.texParameteri(b,e.TEXTURE_MIN_FILTER,va(c.minFilter)))}function ja(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=e.createTexture();e.activeTexture(e.TEXTURE0+c);e.bindTexture(e.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture? e.texImage2D(e.TEXTURE_2D,0,Q(b.format),b.image.width,b.image.height,0,Q(b.format),e.UNSIGNED_BYTE,b.image.data):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,b.image);w(e.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else e.activeTexture(e.TEXTURE0+c),e.bindTexture(e.TEXTURE_2D,b.__webglTexture)}function L(b){var c=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglRenderbuffer= e.createRenderbuffer();b.__webglTexture=e.createTexture();if(c){e.bindTexture(e.TEXTURE_CUBE_MAP,b.__webglTexture);w(e.TEXTURE_CUBE_MAP,b,b);b.__webglFramebuffer=[];for(var d=0;d<6;d++)b.__webglFramebuffer[d]=e.createFramebuffer(),e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+d,0,Q(b.format),b.width,b.height,0,Q(b.format),Q(b.type),null)}else b.__webglFramebuffer=e.createFramebuffer(),e.bindTexture(e.TEXTURE_2D,b.__webglTexture),w(e.TEXTURE_2D,b,b),e.texImage2D(e.TEXTURE_2D,0,Q(b.format),b.width,b.height, 0,Q(b.format),Q(b.type),null);e.bindRenderbuffer(e.RENDERBUFFER,b.__webglRenderbuffer);if(c)for(d=0;d<6;++d)e.bindFramebuffer(e.FRAMEBUFFER,b.__webglFramebuffer[d]),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+d,b.__webglTexture,0);else e.bindFramebuffer(e.FRAMEBUFFER,b.__webglFramebuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16, b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,b.__webglRenderbuffer)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,b.width,b.height);c?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null); -e.bindFramebuffer(e.FRAMEBUFFER,null)}var f,h;b?(c=c?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,d=b.width,b=b.height,h=f=0):(c=null,d=za,b=Ea,f=sa,h=Ga);c!=va&&(e.bindFramebuffer(e.FRAMEBUFFER,c),e.viewport(f,h,d,b),va=c)}function ja(b){b instanceof THREE.WebGLRenderTargetCube?(e.bindTexture(e.TEXTURE_CUBE_MAP,b.__webglTexture),e.generateMipmap(e.TEXTURE_CUBE_MAP),e.bindTexture(e.TEXTURE_CUBE_MAP,null)):(e.bindTexture(e.TEXTURE_2D,b.__webglTexture),e.generateMipmap(e.TEXTURE_2D), -e.bindTexture(e.TEXTURE_2D,null))}function Y(b,c){var d;b=="fragment"?d=e.createShader(e.FRAGMENT_SHADER):b=="vertex"&&(d=e.createShader(e.VERTEX_SHADER));e.shaderSource(d,c);e.compileShader(d);if(!e.getShaderParameter(d,e.COMPILE_STATUS))return console.error(e.getShaderInfoLog(d)),console.error(c),null;return d}function ua(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function Q(b){switch(b){case THREE.RepeatWrapping:return e.REPEAT; +e.bindFramebuffer(e.FRAMEBUFFER,null)}var f,h;b?(c=c?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,d=b.width,b=b.height,h=f=0):(c=null,d=Aa,b=Fa,f=ta,h=Ga);c!=wa&&(e.bindFramebuffer(e.FRAMEBUFFER,c),e.viewport(f,h,d,b),wa=c)}function ka(b){b instanceof THREE.WebGLRenderTargetCube?(e.bindTexture(e.TEXTURE_CUBE_MAP,b.__webglTexture),e.generateMipmap(e.TEXTURE_CUBE_MAP),e.bindTexture(e.TEXTURE_CUBE_MAP,null)):(e.bindTexture(e.TEXTURE_2D,b.__webglTexture),e.generateMipmap(e.TEXTURE_2D), +e.bindTexture(e.TEXTURE_2D,null))}function Y(b,c){var d;b=="fragment"?d=e.createShader(e.FRAGMENT_SHADER):b=="vertex"&&(d=e.createShader(e.VERTEX_SHADER));e.shaderSource(d,c);e.compileShader(d);if(!e.getShaderParameter(d,e.COMPILE_STATUS))return console.error(e.getShaderInfoLog(d)),console.error(c),null;return d}function va(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function Q(b){switch(b){case THREE.RepeatWrapping:return e.REPEAT; case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE; -case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var M=this,e,Da=[],Va= -null,va=null,T=null,Z=null,J=null,W=null,S=null,V=null,wa=null,P=null,sa=0,Ga=0,za=0,Ea=0,R=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Aa=new THREE.Matrix4,Ca=new Float32Array(16),Ta=new Float32Array(16),Ja=new THREE.Vector4,Wa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ka=b.canvas!==void 0?b.canvas:document.createElement("canvas"),ab=b.stencil!==void 0? -b.stencil:!0,bb=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,cb=b.antialias!==void 0?b.antialias:!1,ga=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ha=b.clearAlpha!==void 0?b.clearAlpha:0;_maxLights=b.maxLights!==void 0?b.maxLights:4;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=Ka;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear= -1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var qa,Sa=[],b=THREE.ShaderLib.depthRGBA,Za=THREE.UniformsUtils.clone(b.uniforms),Ua=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Za}),Xa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Za,morphTargets:!0});Ua._shadowPass=!0;Xa._shadowPass=!0;try{if(!(e=Ka.getContext("experimental-webgl", +case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var M=this,e,Ea=[],Va= +null,wa=null,T=null,Z=null,J=null,W=null,S=null,V=null,xa=null,P=null,ta=0,Ga=0,Aa=0,Fa=0,R=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ba=new THREE.Matrix4,Da=new Float32Array(16),Ta=new Float32Array(16),Ja=new THREE.Vector4,Wa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ka=b.canvas!==void 0?b.canvas:document.createElement("canvas"),ab=b.stencil!==void 0? +b.stencil:!0,bb=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,cb=b.antialias!==void 0?b.antialias:!1,ha=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ha=b.clearAlpha!==void 0?b.clearAlpha:0;_maxLights=b.maxLights!==void 0?b.maxLights:4;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=Ka;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear= +1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var ra,Sa=[],b=THREE.ShaderLib.depthRGBA,Za=THREE.UniformsUtils.clone(b.uniforms),Ua=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Za}),Xa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Za,morphTargets:!0});Ua._shadowPass=!0;Xa._shadowPass=!0;try{if(!(e=Ka.getContext("experimental-webgl", {antialias:cb,stencil:ab,preserveDrawingBuffer:bb})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION))}catch(db){console.error(db)}e.clearColor(0,0,0,1);e.clearDepth(1);e.clearStencil(0);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD); -e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(ga.r,ga.g,ga.b,Ha);this.context=e;var $a=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,q={};q.vertices=new Float32Array(16);q.faces=new Uint16Array(6);i=0;q.vertices[i++]=-1;q.vertices[i++]=-1;q.vertices[i++]=0;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=-1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=1;q.vertices[i++]=0;q.vertices[i++]=-1;q.vertices[i++]=1;q.vertices[i++]=0;i=q.vertices[i++]= -0;q.faces[i++]=0;q.faces[i++]=1;q.faces[i++]=2;q.faces[i++]=0;q.faces[i++]=2;q.faces[i++]=3;q.vertexBuffer=e.createBuffer();q.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,q.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,q.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,q.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,q.faces,e.STATIC_DRAW);q.program=e.createProgram();e.attachShader(q.program,Y("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(q.program,Y("vertex", -THREE.ShaderLib.sprite.vertexShader));e.linkProgram(q.program);q.attributes={};q.uniforms={};q.attributes.position=e.getAttribLocation(q.program,"position");q.attributes.uv=e.getAttribLocation(q.program,"uv");q.uniforms.uvOffset=e.getUniformLocation(q.program,"uvOffset");q.uniforms.uvScale=e.getUniformLocation(q.program,"uvScale");q.uniforms.rotation=e.getUniformLocation(q.program,"rotation");q.uniforms.scale=e.getUniformLocation(q.program,"scale");q.uniforms.alignment=e.getUniformLocation(q.program, -"alignment");q.uniforms.map=e.getUniformLocation(q.program,"map");q.uniforms.opacity=e.getUniformLocation(q.program,"opacity");q.uniforms.useScreenCoordinates=e.getUniformLocation(q.program,"useScreenCoordinates");q.uniforms.affectedByDistance=e.getUniformLocation(q.program,"affectedByDistance");q.uniforms.screenPosition=e.getUniformLocation(q.program,"screenPosition");q.uniforms.modelViewMatrix=e.getUniformLocation(q.program,"modelViewMatrix");q.uniforms.projectionMatrix=e.getUniformLocation(q.program, -"projectionMatrix");var Ya=!1;this.setSize=function(b,c){Ka.width=b;Ka.height=c;this.setViewport(0,0,Ka.width,Ka.height)};this.setViewport=function(b,c,d,f){sa=b;Ga=c;za=d;Ea=f;e.viewport(sa,Ga,za,Ea)};this.setScissor=function(b,c,d,f){e.scissor(b,c,d,f)};this.enableScissorTest=function(b){b?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(b,c){ga.setHex(b);Ha=c;e.clearColor(ga.r,ga.g,ga.b,Ha)};this.setClearColor=function(b,c){ga.copy(b);Ha=c;e.clearColor(ga.r,ga.g, -ga.b,Ha)};this.getClearColor=function(){return ga};this.getClearAlpha=function(){return Ha};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.getContext=function(){return e};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c=b.geometry.geometryGroups[g];e.deleteBuffer(c.__webglVertexBuffer); +e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(ha.r,ha.g,ha.b,Ha);this.context=e;var $a=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,n={};n.vertices=new Float32Array(16);n.faces=new Uint16Array(6);i=0;n.vertices[i++]=-1;n.vertices[i++]=-1;n.vertices[i++]=0;n.vertices[i++]=1;n.vertices[i++]=1;n.vertices[i++]=-1;n.vertices[i++]=1;n.vertices[i++]=1;n.vertices[i++]=1;n.vertices[i++]=1;n.vertices[i++]=1;n.vertices[i++]=0;n.vertices[i++]=-1;n.vertices[i++]=1;n.vertices[i++]=0;i=n.vertices[i++]= +0;n.faces[i++]=0;n.faces[i++]=1;n.faces[i++]=2;n.faces[i++]=0;n.faces[i++]=2;n.faces[i++]=3;n.vertexBuffer=e.createBuffer();n.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,n.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,n.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,n.faces,e.STATIC_DRAW);n.program=e.createProgram();e.attachShader(n.program,Y("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(n.program,Y("vertex", +THREE.ShaderLib.sprite.vertexShader));e.linkProgram(n.program);n.attributes={};n.uniforms={};n.attributes.position=e.getAttribLocation(n.program,"position");n.attributes.uv=e.getAttribLocation(n.program,"uv");n.uniforms.uvOffset=e.getUniformLocation(n.program,"uvOffset");n.uniforms.uvScale=e.getUniformLocation(n.program,"uvScale");n.uniforms.rotation=e.getUniformLocation(n.program,"rotation");n.uniforms.scale=e.getUniformLocation(n.program,"scale");n.uniforms.alignment=e.getUniformLocation(n.program, +"alignment");n.uniforms.map=e.getUniformLocation(n.program,"map");n.uniforms.opacity=e.getUniformLocation(n.program,"opacity");n.uniforms.useScreenCoordinates=e.getUniformLocation(n.program,"useScreenCoordinates");n.uniforms.affectedByDistance=e.getUniformLocation(n.program,"affectedByDistance");n.uniforms.screenPosition=e.getUniformLocation(n.program,"screenPosition");n.uniforms.modelViewMatrix=e.getUniformLocation(n.program,"modelViewMatrix");n.uniforms.projectionMatrix=e.getUniformLocation(n.program, +"projectionMatrix");var Ya=!1;this.setSize=function(b,c){Ka.width=b;Ka.height=c;this.setViewport(0,0,Ka.width,Ka.height)};this.setViewport=function(b,c,d,f){ta=b;Ga=c;Aa=d;Fa=f;e.viewport(ta,Ga,Aa,Fa)};this.setScissor=function(b,c,d,f){e.scissor(b,c,d,f)};this.enableScissorTest=function(b){b?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(b,c){ha.setHex(b);Ha=c;e.clearColor(ha.r,ha.g,ha.b,Ha)};this.setClearColor=function(b,c){ha.copy(b);Ha=c;e.clearColor(ha.r,ha.g, +ha.b,Ha)};this.getClearColor=function(){return ha};this.getClearAlpha=function(){return Ha};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.getContext=function(){return e};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c=b.geometry.geometryGroups[g];e.deleteBuffer(c.__webglVertexBuffer); e.deleteBuffer(c.__webglNormalBuffer);e.deleteBuffer(c.__webglTangentBuffer);e.deleteBuffer(c.__webglColorBuffer);e.deleteBuffer(c.__webglUVBuffer);e.deleteBuffer(c.__webglUV2Buffer);e.deleteBuffer(c.__webglSkinVertexABuffer);e.deleteBuffer(c.__webglSkinVertexBBuffer);e.deleteBuffer(c.__webglSkinIndicesBuffer);e.deleteBuffer(c.__webglSkinWeightsBuffer);e.deleteBuffer(c.__webglFaceBuffer);e.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,f=c.numMorphTargets;d=0&&e.enableVertexAttribArray(s.position);s.color>=0&&e.enableVertexAttribArray(s.color);s.normal>=0&&e.enableVertexAttribArray(s.normal);s.tangent>=0&&e.enableVertexAttribArray(s.tangent);b.skinning&&s.skinVertexA>=0&&s.skinVertexB>=0&&s.skinIndex>=0&&s.skinWeight>=0&&(e.enableVertexAttribArray(s.skinVertexA),e.enableVertexAttribArray(s.skinVertexB),e.enableVertexAttribArray(s.skinIndex), -e.enableVertexAttribArray(s.skinWeight));if(b.attributes)for(h in b.attributes)s[h]!==void 0&&s[h]>=0&&e.enableVertexAttribArray(s[h]);if(b.morphTargets)for(h=b.numSupportedMorphTargets=0;h=0&&(e.enableVertexAttribArray(s[v]),b.numSupportedMorphTargets++)};this.clearTarget=function(b,c,d,f){L(b);b=0;c&&(b|=e.COLOR_BUFFER_BIT);d&&(b|=e.DEPTH_BUFFER_BIT);f&&(b|=e.STENCIL_BUFFER_BIT);e.clear(b)};this.render=function(b,c,e,n){var q,w,Fa,U,H,I,D,Qa,J=b.lights, -Ra=b.fog;this.shadowMapEnabled&&y(b,c);M.data.vertices=0;M.data.faces=0;M.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Ta);c.projectionMatrix.flattenToArray(Ca);Aa.multiply(c.projectionMatrix,c.matrixWorldInverse);p(Aa);this.initWebGLObjects(b);L(e);(this.autoClear||n)&&this.clear();H=b.__webglObjects.length;for(n=0;n=0;n--)if(q=b.__webglObjects[n],q.render){D=q.object;Qa=q.buffer;Fa=q.opaque;h(D);for(q=0;q=0&&e.enableVertexAttribArray(n.position);n.color>=0&&e.enableVertexAttribArray(n.color);n.normal>=0&&e.enableVertexAttribArray(n.normal);n.tangent>=0&&e.enableVertexAttribArray(n.tangent);b.skinning&&n.skinVertexA>=0&&n.skinVertexB>=0&&n.skinIndex>=0&&n.skinWeight>=0&&(e.enableVertexAttribArray(n.skinVertexA),e.enableVertexAttribArray(n.skinVertexB),e.enableVertexAttribArray(n.skinIndex), +e.enableVertexAttribArray(n.skinWeight));if(b.attributes)for(h in b.attributes)n[h]!==void 0&&n[h]>=0&&e.enableVertexAttribArray(n[h]);if(b.morphTargets)for(h=b.numSupportedMorphTargets=0;h=0&&(e.enableVertexAttribArray(n[v]),b.numSupportedMorphTargets++)};this.clearTarget=function(b,c,d,f){L(b);b=0;c&&(b|=e.COLOR_BUFFER_BIT);d&&(b|=e.DEPTH_BUFFER_BIT);f&&(b|=e.STENCIL_BUFFER_BIT);e.clear(b)};this.render=function(b,c,e,r){var n,w,fa,U,H,I,D,Qa,J=b.lights, +Ra=b.fog;this.shadowMapEnabled&&y(b,c);M.data.vertices=0;M.data.faces=0;M.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Ta);c.projectionMatrix.flattenToArray(Da);Ba.multiply(c.projectionMatrix,c.matrixWorldInverse);p(Ba);this.initWebGLObjects(b);L(e);(this.autoClear||r)&&this.clear();H=b.__webglObjects.length;for(r=0;r=0;r--)if(n=b.__webglObjects[r],n.render){D=n.object;Qa=n.buffer;fa=n.opaque;h(D);for(n=0;n0||u.faceVertexUvs.length>0)m.__uvArray=new Float32Array(n*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(n*2)}if(p.geometry.skinWeights.length&& +if(m.numMorphTargets){var p=void 0,n=void 0;m.__webglMorphTargetsBuffers=[];p=0;for(n=m.numMorphTargets;p0||u.faceVertexUvs.length>0)m.__uvArray=new Float32Array(n*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(n*2)}if(p.geometry.skinWeights.length&& p.geometry.skinIndices.length)m.__skinVertexAArray=new Float32Array(n*4),m.__skinVertexBArray=new Float32Array(n*4),m.__skinIndexArray=new Float32Array(n*4),m.__skinWeightArray=new Float32Array(n*4);m.__faceArray=new Uint16Array(w*3+(p.geometry.edgeFaces?p.geometry.edgeFaces.length*6:0));m.__lineArray=new Uint16Array(B*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];u=0;for(v=m.numMorphTargets;u=0;j--)d[j]==f&&d.splice(j,1)}else f instanceof THREE.MarchingCubes&&pa(d.__webglObjectsImmediate,f);b.__objectsRemoved.splice(0,1)}d=0;for(f=b.__webglObjects.length;d=0;j--)d[j]==f&&d.splice(j,1)}else f instanceof THREE.MarchingCubes&&qa(d.__webglObjectsImmediate,f);b.__objectsRemoved.splice(0,1)}d=0;for(f=b.__webglObjects.length;d0&&(e.bindBuffer(e.ARRAY_BUFFER,n.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,oa,C));Aa&&(e.bindBuffer(e.ARRAY_BUFFER,n.__webglNormalBuffer),e.bufferData(e.ARRAY_BUFFER,V,C));Ca&&ta.hasTangents&&(e.bindBuffer(e.ARRAY_BUFFER,n.__webglTangentBuffer),e.bufferData(e.ARRAY_BUFFER,$,C));sa&&W>0&&(e.bindBuffer(e.ARRAY_BUFFER,n.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,ia,C));sa&&Y>0&&(e.bindBuffer(e.ARRAY_BUFFER, -n.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,ja,C));va&&(e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.__webglFaceBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,ga,C),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.__webglLineBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ba,C));x>0&&(e.bindBuffer(e.ARRAY_BUFFER,n.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,aa,C),e.bindBuffer(e.ARRAY_BUFFER,n.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,ca,C),e.bindBuffer(e.ARRAY_BUFFER,n.__webglSkinIndicesBuffer), +z.z,aa[x+11]=1,aa[x+12]=P.x,aa[x+13]=P.y,aa[x+14]=P.z,aa[x+15]=1,t=Oa[A.a],o=Oa[A.b],z=Oa[A.c],A=Oa[A.d],ca[x]=t.x,ca[x+1]=t.y,ca[x+2]=t.z,ca[x+3]=1,ca[x+4]=o.x,ca[x+5]=o.y,ca[x+6]=o.z,ca[x+7]=1,ca[x+8]=z.x,ca[x+9]=z.y,ca[x+10]=z.z,ca[x+11]=1,ca[x+12]=A.x,ca[x+13]=A.y,ca[x+14]=A.z,ca[x+15]=1,x+=16;if(Ea&&q)F.length==4&&q==THREE.VertexColors?(A=F[0],t=F[1],o=F[2],F=F[3]):F=o=t=A=M,pa[la]=A.r,pa[la+1]=A.g,pa[la+2]=A.b,pa[la+3]=t.r,pa[la+4]=t.g,pa[la+5]=t.b,pa[la+6]=o.r,pa[la+7]=o.g,pa[la+8]=o.b,pa[la+ +9]=F.r,pa[la+10]=F.g,pa[la+11]=F.b,la+=12;if(Da&&ua.hasTangents)F=N[0],M=N[1],A=N[2],N=N[3],$[X]=F.x,$[X+1]=F.y,$[X+2]=F.z,$[X+3]=F.w,$[X+4]=M.x,$[X+5]=M.y,$[X+6]=M.z,$[X+7]=M.w,$[X+8]=A.x,$[X+9]=A.y,$[X+10]=A.z,$[X+11]=A.w,$[X+12]=N.x,$[X+13]=N.y,$[X+14]=N.z,$[X+15]=N.w,X+=16;if(Ba&&v)if(E.length==4&&xa)for(N=0;N<4;N++)J=E[N],V[Q]=J.x,V[Q+1]=J.y,V[Q+2]=J.z,Q+=3;else for(N=0;N<4;N++)V[Q]=J.x,V[Q+1]=J.y,V[Q+2]=J.z,Q+=3;if(ta&&y!==void 0&&r)for(N=0;N<4;N++)E=y[N],ja[W]=E.u,ja[W+1]=E.v,W+=2;if(ta&&s!== +void 0&&r)for(N=0;N<4;N++)E=s[N],ka[Y]=E.u,ka[Y+1]=E.v,Y+=2;wa&&(ha[T]=ia,ha[T+1]=ia+1,ha[T+2]=ia+3,ha[T+3]=ia+1,ha[T+4]=ia+2,ha[T+5]=ia+3,T+=6,Ca[R]=ia,Ca[R+1]=ia+1,Ca[R+2]=ia,Ca[R+3]=ia+3,Ca[R+4]=ia+1,Ca[R+5]=ia+2,Ca[R+6]=ia+2,Ca[R+7]=ia+3,R+=8,ia+=4)}va&&(e.bindBuffer(e.ARRAY_BUFFER,n.__webglVertexBuffer),e.bufferData(e.ARRAY_BUFFER,oa,C));if(Z)for(S in Z)o=Z[S],o.__original.needsUpdate&&(e.bindBuffer(e.ARRAY_BUFFER,o.buffer),e.bufferData(e.ARRAY_BUFFER,o.array,C));if(Fa){t=0;for(o=Ia.length;t< +o;t++)e.bindBuffer(e.ARRAY_BUFFER,n.__webglMorphTargetsBuffers[t]),e.bufferData(e.ARRAY_BUFFER,ra[t],C)}Ea&&la>0&&(e.bindBuffer(e.ARRAY_BUFFER,n.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,pa,C));Ba&&(e.bindBuffer(e.ARRAY_BUFFER,n.__webglNormalBuffer),e.bufferData(e.ARRAY_BUFFER,V,C));Da&&ua.hasTangents&&(e.bindBuffer(e.ARRAY_BUFFER,n.__webglTangentBuffer),e.bufferData(e.ARRAY_BUFFER,$,C));ta&&W>0&&(e.bindBuffer(e.ARRAY_BUFFER,n.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,ja,C));ta&&Y>0&&(e.bindBuffer(e.ARRAY_BUFFER, +n.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,ka,C));wa&&(e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.__webglFaceBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,ha,C),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,n.__webglLineBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ca,C));x>0&&(e.bindBuffer(e.ARRAY_BUFFER,n.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,aa,C),e.bindBuffer(e.ARRAY_BUFFER,n.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,ca,C),e.bindBuffer(e.ARRAY_BUFFER,n.__webglSkinIndicesBuffer), e.bufferData(e.ARRAY_BUFFER,da,C),e.bindBuffer(e.ARRAY_BUFFER,n.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,ea,C));w&&(delete n.__inittedArrays,delete n.__colorArray,delete n.__normalArray,delete n.__tangentArray,delete n.__uvArray,delete n.__uv2Array,delete n.__faceArray,delete n.__vertexArray,delete n.__lineArray,delete n.__skinVertexAArray,delete n.__skinVertexBArray,delete n.__skinIndexArray,delete n.__skinWeightArray)}j.__dirtyVertices=!1;j.__dirtyMorphTargets=!1;j.__dirtyElements= -!1;j.__dirtyUvs=!1;j.__dirtyNormals=!1;j.__dirtyTangents=!1;j.__dirtyColors=!1;ya(k)}else if(h instanceof THREE.Ribbon){j=h.geometry;if(j.__dirtyVertices||j.__dirtyColors){h=j;k=e.DYNAMIC_DRAW;m=B=w=w=void 0;u=h.vertices;p=h.colors;q=u.length;n=p.length;r=h.__vertexArray;C=h.__colorArray;v=h.__dirtyColors;if(h.__dirtyVertices){for(w=0;w