From cdd5a20de24772f7b69e29afb475bd7b059fbbf5 Mon Sep 17 00:00:00 2001 From: zz85 Date: Sun, 2 Oct 2011 18:54:18 +0800 Subject: [PATCH] Switched to hashmap implementation for mergeVertices() --- build/Three.js | 685 +++++++++++------------ examples/canvas_geometry_subdivison.html | 14 +- src/core/Geometry.js | 109 +--- 3 files changed, 368 insertions(+), 440 deletions(-) diff --git a/build/Three.js b/build/Three.js index da8384bb..e7f53bf9 100644 --- a/build/Three.js +++ b/build/Three.js @@ -1,7 +1,7 @@ // Three.js r45dev - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;THREE.Color=function(b){b!==void 0&&this.setHex(b);return this}; -THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;return this},setRGB:function(b,c,e){this.r=b;this.g=c;this.b=e;return this},setHSV:function(b,c,e){var f,h,k;if(e==0)this.r=this.g=this.b=0;else switch(f=Math.floor(b*6),h=b*6-f,b=e*(1-c),k=e*(1-c*h),c=e*(1-c*(1-h)),f){case 1:this.r=k;this.g=e;this.b=b;break;case 2:this.r=b;this.g=e;this.b=c;break;case 3:this.r=b;this.g=k;this.b=e;break;case 4:this.r=c;this.g=b;this.b=e;break;case 5:this.r= -e;this.g=b;this.b=k;break;case 6:case 0:this.r=e,this.g=c,this.b=b}return this},setHex:function(b){b=Math.floor(b);this.r=(b>>16&255)/255;this.g=(b>>8&255)/255;this.b=(b&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; +THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;return this},setRGB:function(b,c,e){this.r=b;this.g=c;this.b=e;return this},setHSV:function(b,c,e){var f,m,h;if(e==0)this.r=this.g=this.b=0;else switch(f=Math.floor(b*6),m=b*6-f,b=e*(1-c),h=e*(1-c*m),c=e*(1-c*(1-m)),f){case 1:this.r=h;this.g=e;this.b=b;break;case 2:this.r=b;this.g=e;this.b=c;break;case 3:this.r=b;this.g=h;this.b=e;break;case 4:this.r=c;this.g=b;this.b=e;break;case 5:this.r= +e;this.g=b;this.b=h;break;case 6:case 0:this.r=e,this.g=c,this.b=b}return this},setHex:function(b){b=Math.floor(b);this.r=(b>>16&255)/255;this.g=(b>>8&255)/255;this.b=(b&255)/255;return this},getHex:function(){return~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},getContextStyle:function(){return"rgb("+Math.floor(this.r*255)+","+Math.floor(this.g*255)+","+Math.floor(this.b*255)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}}; THREE.Vector2=function(b,c){this.x=b||0;this.y=c||0}; THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(b,c){this.x=b;this.y=c;return this},copy:function(b){this.x=b.x;this.y=b.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;return this}, divideScalar:function(b){b?(this.x/=b,this.y/=b):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){var c=this.x-b.x,b=this.y-b.y;return c*c+b*b},setLength:function(b){return this.normalize().multiplyScalar(b)}, @@ -15,85 +15,84 @@ THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(b,c,e,f){this.x= c.z;this.w=b.w-c.w;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;this.w-=b.w;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;this.w*=b;return this},divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b,this.w/=b):(this.z=this.y=this.x=0,this.w=1);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z+this.w*b.w},lengthSq:function(){return this.dot(this)},length:function(){return Math.sqrt(this.lengthSq())}, normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,c){this.x+=(b.x-this.x)*c;this.y+=(b.y-this.y)*c;this.z+=(b.z-this.z)*c;this.w+=(b.w-this.w)*c;return this}};THREE.Ray=function(b,c){this.origin=b||new THREE.Vector3;this.direction=c||new THREE.Vector3}; THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,e,f=[];c=0;for(e=b.length;c0&&b>0&&k+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 h,k,m,n,u,p,w,t,x,v,z=b.geometry,y=z.vertices,B=[],f=0;for(h=z.faces.length;f0:t<0)))if(t=w.dot((new THREE.Vector3).sub(m,x))/t,x=x.addSelf(v.multiplyScalar(t)),k instanceof THREE.Face3)e(x,m,n,u)&&(k={distance:this.origin.distanceTo(x),point:x,face:k,object:b},B.push(k));else if(k instanceof THREE.Face4&&(e(x,m,n,p)||e(x,n,u,p)))k={distance:this.origin.distanceTo(x),point:x,face:k,object:b},B.push(k);B.sort(function(b,e){return b.distance-e.distance});return B}else return[]}}; -THREE.Rectangle=function(){function b(){k=f-c;m=h-e}var c,e,f,h,k,m,n=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return k};this.getHeight=function(){return m};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,v){n?(n=!1,c=kw?k>x?k:x:w>x?w:x,h=m>t?m>v?m:v:t>v?t:v):(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>v?m>h?m:h:v>h?v:h:t>v?t>h?t:h:v>h?v: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=[]}; +c=c.clone().subSelf(e),m=b.clone().subSelf(e),b=f.dot(f),e=f.dot(c),f=f.dot(m),h=c.dot(c),c=c.dot(m),m=1/(b*h-e*e),h=(h*f-e*c)*m,b=(b*c-e*f)*m;return h>0&&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 m,h,k,n,p,u,w,t,x,v,z=b.geometry,y=z.vertices,B=[],f=0;for(m=z.faces.length;f0:t<0)))if(t=w.dot((new THREE.Vector3).sub(k,x))/t,x=x.addSelf(v.multiplyScalar(t)),h instanceof THREE.Face3)e(x,k,n,p)&&(h={distance:this.origin.distanceTo(x),point:x,face:h,object:b},B.push(h));else if(h instanceof THREE.Face4&&(e(x,k,n,u)||e(x,n,p,u)))h={distance:this.origin.distanceTo(x),point:x,face:h,object:b},B.push(h);B.sort(function(b,e){return b.distance-e.distance});return B}else return[]}}; +THREE.Rectangle=function(){function b(){h=f-c;k=m-e}var c,e,f,m,h,k,n=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return h};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return m};this.set=function(h,k,w,t){n=!1;c=h;e=k;f=w;m=t;b()};this.addPoint=function(h,k){n?(n=!1,c=h,e=k,f=h,m=k):(c=ch?f:h,m=m>k?m:k);b()};this.add3Points= +function(h,k,w,t,x,v){n?(n=!1,c=hw?h>x?h:x:w>x?w:x,m=k>t?k>v?k:v:t>v?t:v):(c=hw?h>x?h>f?h:f:x>f?x:f:w>x?w>f?w:f:x>f?x:f,m=k>t?k>v?k>m?k:m:v>m?v:m:t>v?t>m?t:m:v>m?v:m);b()};this.addRectangle=function(h){n?(n=!1,c=h.getLeft(),e=h.getTop(),f=h.getRight(),m=h.getBottom()):(c=ch.getRight()?f:h.getRight(),m=m> +h.getBottom()?m:h.getBottom());b()};this.inflate=function(h){c-=h;e-=h;f+=h;m+=h;b()};this.minSelf=function(h){c=c>h.getLeft()?c:h.getLeft();e=e>h.getTop()?e:h.getTop();f=f=0&&Math.min(m,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){n=!0;m=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,k,m,n,u,p,w,t,x,v,z,y){this.set(b!==void 0?b:1,c||0,e||0,f||0,h||0,k!==void 0?k:1,m||0,n||0,u||0,p||0,w!==void 0?w:1,t||0,x||0,v||0,z||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,e,f,h,k,m,n,u,p,w,t,x,v,z,y){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=h;this.n22=k;this.n23=m;this.n24=n;this.n31=u;this.n32=p;this.n33=w;this.n34=t;this.n41=x;this.n42=v;this.n43=z;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,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;k.sub(b,c).normalize();if(k.length()===0)k.z=1;f.cross(e,k).normalize();f.length()===0&&(k.x+=1.0E-4,f.cross(e,k).normalize());h.cross(k,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=k.x;this.n21=f.y;this.n22=h.y;this.n23=k.y;this.n31=f.z;this.n32=h.z;this.n33=k.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+ -e*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 e=b.n11,f=b.n12,h=b.n13,k=b.n14,m=b.n21,n=b.n22,u=b.n23,p=b.n24,w=b.n31,t=b.n32,x=b.n33,v=b.n34,z=b.n41,y=b.n42,B=b.n43,C=b.n44,E=c.n11,F=c.n12, -G=c.n13,M=c.n14,P=c.n21,L=c.n22,A=c.n23,J=c.n24,Z=c.n31,I=c.n32,O=c.n33,X=c.n34,V=c.n41,W=c.n42,o=c.n43,ea=c.n44;this.n11=e*E+f*P+h*Z+k*V;this.n12=e*F+f*L+h*I+k*W;this.n13=e*G+f*A+h*O+k*o;this.n14=e*M+f*J+h*X+k*ea;this.n21=m*E+n*P+u*Z+p*V;this.n22=m*F+n*L+u*I+p*W;this.n23=m*G+n*A+u*O+p*o;this.n24=m*M+n*J+u*X+p*ea;this.n31=w*E+t*P+x*Z+v*V;this.n32=w*F+t*L+x*I+v*W;this.n33=w*G+t*A+x*O+v*o;this.n34=w*M+t*J+x*X+v*ea;this.n41=z*E+y*P+B*Z+C*V;this.n42=z*F+y*L+B*I+C*W;this.n43=z*G+y*A+B*O+C*o;this.n44=z* +THREE.Matrix4=function(b,c,e,f,m,h,k,n,p,u,w,t,x,v,z,y){this.set(b!==void 0?b:1,c||0,e||0,f||0,m||0,h!==void 0?h:1,k||0,n||0,p||0,u||0,w!==void 0?w:1,t||0,x||0,v||0,z||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,e,f,m,h,k,n,p,u,w,t,x,v,z,y){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=m;this.n22=h;this.n23=k;this.n24=n;this.n31=p;this.n32=u;this.n33=w;this.n34=t;this.n41=x;this.n42=v;this.n43=z;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,e){var f=THREE.Matrix4.__v1,m=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,c).normalize();if(h.length()===0)h.z=1;f.cross(e,h).normalize();f.length()===0&&(h.x+=1.0E-4,f.cross(e,h).normalize());m.cross(h,f).normalize();this.n11=f.x;this.n12=m.x;this.n13=h.x;this.n21=f.y;this.n22=m.y;this.n23=h.y;this.n31=f.z;this.n32=m.z;this.n33=h.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,m=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)*m; +b.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*m;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*m;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,m=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*m;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*m;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*m;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*m;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+ +e*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 e=b.n11,f=b.n12,m=b.n13,h=b.n14,k=b.n21,n=b.n22,p=b.n23,u=b.n24,w=b.n31,t=b.n32,x=b.n33,v=b.n34,z=b.n41,y=b.n42,B=b.n43,C=b.n44,E=c.n11,F=c.n12, +G=c.n13,M=c.n14,P=c.n21,L=c.n22,A=c.n23,J=c.n24,Z=c.n31,I=c.n32,O=c.n33,X=c.n34,V=c.n41,W=c.n42,o=c.n43,ea=c.n44;this.n11=e*E+f*P+m*Z+h*V;this.n12=e*F+f*L+m*I+h*W;this.n13=e*G+f*A+m*O+h*o;this.n14=e*M+f*J+m*X+h*ea;this.n21=k*E+n*P+p*Z+u*V;this.n22=k*F+n*L+p*I+u*W;this.n23=k*G+n*A+p*O+u*o;this.n24=k*M+n*J+p*X+u*ea;this.n31=w*E+t*P+x*Z+v*V;this.n32=w*F+t*L+x*I+v*W;this.n33=w*G+t*A+x*O+v*o;this.n34=w*M+t*J+x*X+v*ea;this.n41=z*E+y*P+B*Z+C*V;this.n42=z*F+y*L+B*I+C*W;this.n43=z*G+y*A+B*O+C*o;this.n44=z* M+y*J+B*X+C*ea;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(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,e=this.n13,f=this.n14,h=this.n21,k=this.n22,m=this.n23,n=this.n24,u=this.n31,p=this.n32,w=this.n33,t=this.n34,x=this.n41,v=this.n42,z=this.n43,y=this.n44;return f*m*p*x-e*n*p*x-f*k*w*x+c*n*w*x+e*k*t*x-c*m*t*x-f*m*u*v+e*n*u*v+f*h*w*v-b*n*w*v-e*h*t*v+b*m*t*v+f*k*u*z-c*n*u*z-f*h*p*z+b*n*p*z+c*h*t*z-b*k*t*z-e*k*u*y+c*m*u*y+e*h*p*y-b*m*p*y-c*h* -w*y+b*k*w*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= +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,e=this.n13,f=this.n14,m=this.n21,h=this.n22,k=this.n23,n=this.n24,p=this.n31,u=this.n32,w=this.n33,t=this.n34,x=this.n41,v=this.n42,z=this.n43,y=this.n44;return f*k*u*x-e*n*u*x-f*h*w*x+c*n*w*x+e*h*t*x-c*k*t*x-f*k*p*v+e*n*p*v+f*m*w*v-b*n*w*v-e*m*t*v+b*k*t*v+f*h*p*z-c*n*p*z-f*m*u*z+b*n*u*z+c*m*t*z-b*h*t*z-e*h*p*y+c*k*p*y+e*m*u*y-b*k*u*y-c*m* +w*y+b*h*w*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,e){this.set(1,0,0,b,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(b,c,e){this.set(b,0,0,0,0,c,0,0,0,0,e,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 e=Math.cos(c),f=Math.sin(c),h=1-e,k=b.x,m=b.y,n=b.z,u=h*k,p=h*m;this.set(u*k+e,u*m-f*n,u*n+f*m,0,u*m+f*n,p*m+e,p*n-f*k,0,u*n-f*m,p*n+f*k,h*n*n+e,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 e=b.x,f=b.y,h=b.z,k=Math.cos(e),e=Math.sin(e),m=Math.cos(f),f=Math.sin(f),n=Math.cos(h),h=Math.sin(h);switch(c){case "YXZ":var u= -m*n,p=m*h,w=f*n,t=f*h;this.n11=u+t*e;this.n12=w*e-p;this.n13=k*f;this.n21=k*h;this.n22=k*n;this.n23=-e;this.n31=p*e-w;this.n32=t+u*e;this.n33=k*m;break;case "ZXY":u=m*n;p=m*h;w=f*n;t=f*h;this.n11=u-t*e;this.n12=-k*h;this.n13=w+p*e;this.n21=p+w*e;this.n22=k*n;this.n23=t-u*e;this.n31=-k*f;this.n32=e;this.n33=k*m;break;case "ZYX":u=k*n;p=k*h;w=e*n;t=e*h;this.n11=m*n;this.n12=w*f-p;this.n13=u*f+t;this.n21=m*h;this.n22=t*f+u;this.n23=p*f-w;this.n31=-f;this.n32=e*m;this.n33=k*m;break;case "YZX":u=k*m;p= -k*f;w=e*m;t=e*f;this.n11=m*n;this.n12=t-u*h;this.n13=w*h+p;this.n21=h;this.n22=k*n;this.n23=-e*n;this.n31=-f*n;this.n32=p*h+w;this.n33=u-t*h;break;case "XZY":u=k*m;p=k*f;w=e*m;t=e*f;this.n11=m*n;this.n12=-h;this.n13=f*n;this.n21=u*h+t;this.n22=k*n;this.n23=p*h-w;this.n31=w*h-p;this.n32=e*n;this.n33=t*h+u;break;default:u=k*n,p=k*h,w=e*n,t=e*h,this.n11=m*n,this.n12=-m*h,this.n13=f,this.n21=p+w*f,this.n22=u-t*f,this.n23=-e*m,this.n31=t-u*f,this.n32=w+p*f,this.n33=k*m}return this},setRotationFromQuaternion:function(b){var c= -b.x,e=b.y,f=b.z,h=b.w,k=c+c,m=e+e,n=f+f,b=c*k,u=c*m;c*=n;var p=e*m;e*=n;f*=n;k*=h;m*=h;h*=n;this.n11=1-(p+f);this.n12=u-h;this.n13=c+m;this.n21=u+h;this.n22=1-(b+f);this.n23=e-k;this.n31=c-m;this.n32=e+k;this.n33=1-(b+p);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},compose:function(b,c,e){var f=THREE.Matrix4.__m1,h=THREE.Matrix4.__m2; -f.identity();f.setRotationFromQuaternion(c);h.setScale(e.x,e.y,e.z);this.multiply(f,h);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;f.set(this.n11,this.n21,this.n31);h.set(this.n12,this.n22,this.n32);k.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;e=e instanceof THREE.Vector3?e:new THREE.Vector3;e.x=f.length(); -e.y=h.length();e.z=k.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;f=THREE.Matrix4.__m1;f.copy(this);f.n11/=e.x;f.n21/=e.x;f.n31/=e.x;f.n12/=e.y;f.n22/=e.y;f.n32/=e.y;f.n13/=e.z;f.n23/=e.z;f.n33/=e.z;c.setFromRotationMatrix(f);return[b,c,e]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var e=1/c.x,f=1/c.y,h=1/c.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*h;this.n23= -b.n23*h;this.n33=b.n33*h}}; -THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,h=b.n13,k=b.n14,m=b.n21,n=b.n22,u=b.n23,p=b.n24,w=b.n31,t=b.n32,x=b.n33,v=b.n34,z=b.n41,y=b.n42,B=b.n43,C=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=u*v*y-p*x*y+p*t*B-n*v*B-u*t*C+n*x*C;c.n12=k*x*y-h*v*y-k*t*B+f*v*B+h*t*C-f*x*C;c.n13=h*p*y-k*u*y+k*n*B-f*p*B-h*n*C+f*u*C;c.n14=k*u*t-h*p*t-k*n*x+f*p*x+h*n*v-f*u*v;c.n21=p*x*z-u*v*z-p*w*B+m*v*B+u*w*C-m*x*C;c.n22=h*v*z-k*x*z+k*w*B-e*v*B-h*w*C+e*x*C;c.n23=k*u*z-h*p*z-k*m*B+e*p*B+h*m*C-e*u*C;c.n24= -h*p*w-k*u*w+k*m*x-e*p*x-h*m*v+e*u*v;c.n31=n*v*z-p*t*z+p*w*y-m*v*y-n*w*C+m*t*C;c.n32=k*t*z-f*v*z-k*w*y+e*v*y+f*w*C-e*t*C;c.n33=h*p*z-k*n*z+k*m*y-e*p*y-f*m*C+e*n*C;c.n34=k*n*w-f*p*w-k*m*t+e*p*t+f*m*v-e*n*v;c.n41=u*t*z-n*x*z-u*w*y+m*x*y+n*w*B-m*t*B;c.n42=f*x*z-h*t*z+h*w*y-e*x*y-f*w*B+e*t*B;c.n43=h*n*z-f*u*z-h*m*y+e*u*y+f*m*B-e*n*B;c.n44=f*u*w-h*n*w+h*m*t-e*u*t-f*m*x+e*n*x;c.multiplyScalar(1/b.determinant());return c}; -THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,k=b.n32*b.n21-b.n31*b.n22,m=-b.n33*b.n12+b.n32*b.n13,n=b.n33*b.n11-b.n31*b.n13,u=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,w=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*m+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*k;e[3]=b*m;e[4]=b*n;e[5]=b*u;e[6]=b*p;e[7]=b*w;e[8]=b*t;return c}; -THREE.Matrix4.makeFrustum=function(b,c,e,f,h,k){var m;m=new THREE.Matrix4;m.n11=2*h/(c-b);m.n12=0;m.n13=(c+b)/(c-b);m.n14=0;m.n21=0;m.n22=2*h/(f-e);m.n23=(f+e)/(f-e);m.n24=0;m.n31=0;m.n32=0;m.n33=-(k+h)/(k-h);m.n34=-2*k*h/(k-h);m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(b,c,e,f){var h,b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*c,b*c,h,b,e,f)}; -THREE.Matrix4.makeOrtho=function(b,c,e,f,h,k){var m,n,u,p;m=new THREE.Matrix4;n=c-b;u=e-f;p=k-h;m.n11=2/n;m.n12=0;m.n13=0;m.n14=-((c+b)/n);m.n21=0;m.n22=2/u;m.n23=0;m.n24=-((e+f)/u);m.n31=0;m.n32=0;m.n33=-2/p;m.n34=-((k+h)/p);m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m};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; +0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var e=Math.cos(c),f=Math.sin(c),m=1-e,h=b.x,k=b.y,n=b.z,p=m*h,u=m*k;this.set(p*h+e,p*k-f*n,p*n+f*k,0,p*k+f*n,u*k+e,u*n-f*h,0,p*n-f*k,u*n+f*h,m*n*n+e,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 e=b.x,f=b.y,m=b.z,h=Math.cos(e),e=Math.sin(e),k=Math.cos(f),f=Math.sin(f),n=Math.cos(m),m=Math.sin(m);switch(c){case "YXZ":var p= +k*n,u=k*m,w=f*n,t=f*m;this.n11=p+t*e;this.n12=w*e-u;this.n13=h*f;this.n21=h*m;this.n22=h*n;this.n23=-e;this.n31=u*e-w;this.n32=t+p*e;this.n33=h*k;break;case "ZXY":p=k*n;u=k*m;w=f*n;t=f*m;this.n11=p-t*e;this.n12=-h*m;this.n13=w+u*e;this.n21=u+w*e;this.n22=h*n;this.n23=t-p*e;this.n31=-h*f;this.n32=e;this.n33=h*k;break;case "ZYX":p=h*n;u=h*m;w=e*n;t=e*m;this.n11=k*n;this.n12=w*f-u;this.n13=p*f+t;this.n21=k*m;this.n22=t*f+p;this.n23=u*f-w;this.n31=-f;this.n32=e*k;this.n33=h*k;break;case "YZX":p=h*k;u= +h*f;w=e*k;t=e*f;this.n11=k*n;this.n12=t-p*m;this.n13=w*m+u;this.n21=m;this.n22=h*n;this.n23=-e*n;this.n31=-f*n;this.n32=u*m+w;this.n33=p-t*m;break;case "XZY":p=h*k;u=h*f;w=e*k;t=e*f;this.n11=k*n;this.n12=-m;this.n13=f*n;this.n21=p*m+t;this.n22=h*n;this.n23=u*m-w;this.n31=w*m-u;this.n32=e*n;this.n33=t*m+p;break;default:p=h*n,u=h*m,w=e*n,t=e*m,this.n11=k*n,this.n12=-k*m,this.n13=f,this.n21=u+w*f,this.n22=p-t*f,this.n23=-e*k,this.n31=t-p*f,this.n32=w+u*f,this.n33=h*k}return this},setRotationFromQuaternion:function(b){var c= +b.x,e=b.y,f=b.z,m=b.w,h=c+c,k=e+e,n=f+f,b=c*h,p=c*k;c*=n;var u=e*k;e*=n;f*=n;h*=m;k*=m;m*=n;this.n11=1-(u+f);this.n12=p-m;this.n13=c+k;this.n21=p+m;this.n22=1-(b+f);this.n23=e-h;this.n31=c-k;this.n32=e+h;this.n33=1-(b+u);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},compose:function(b,c,e){var f=THREE.Matrix4.__m1,m=THREE.Matrix4.__m2; +f.identity();f.setRotationFromQuaternion(c);m.setScale(e.x,e.y,e.z);this.multiply(f,m);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,e){var f=THREE.Matrix4.__v1,m=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;f.set(this.n11,this.n21,this.n31);m.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;e=e instanceof THREE.Vector3?e:new THREE.Vector3;e.x=f.length(); +e.y=m.length();e.z=h.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;f=THREE.Matrix4.__m1;f.copy(this);f.n11/=e.x;f.n21/=e.x;f.n31/=e.x;f.n12/=e.y;f.n22/=e.y;f.n32/=e.y;f.n13/=e.z;f.n23/=e.z;f.n33/=e.z;c.setFromRotationMatrix(f);return[b,c,e]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var e=1/c.x,f=1/c.y,m=1/c.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*m;this.n23= +b.n23*m;this.n33=b.n33*m}}; +THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,m=b.n13,h=b.n14,k=b.n21,n=b.n22,p=b.n23,u=b.n24,w=b.n31,t=b.n32,x=b.n33,v=b.n34,z=b.n41,y=b.n42,B=b.n43,C=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=p*v*y-u*x*y+u*t*B-n*v*B-p*t*C+n*x*C;c.n12=h*x*y-m*v*y-h*t*B+f*v*B+m*t*C-f*x*C;c.n13=m*u*y-h*p*y+h*n*B-f*u*B-m*n*C+f*p*C;c.n14=h*p*t-m*u*t-h*n*x+f*u*x+m*n*v-f*p*v;c.n21=u*x*z-p*v*z-u*w*B+k*v*B+p*w*C-k*x*C;c.n22=m*v*z-h*x*z+h*w*B-e*v*B-m*w*C+e*x*C;c.n23=h*p*z-m*u*z-h*k*B+e*u*B+m*k*C-e*p*C;c.n24= +m*u*w-h*p*w+h*k*x-e*u*x-m*k*v+e*p*v;c.n31=n*v*z-u*t*z+u*w*y-k*v*y-n*w*C+k*t*C;c.n32=h*t*z-f*v*z-h*w*y+e*v*y+f*w*C-e*t*C;c.n33=m*u*z-h*n*z+h*k*y-e*u*y-f*k*C+e*n*C;c.n34=h*n*w-f*u*w-h*k*t+e*u*t+f*k*v-e*n*v;c.n41=p*t*z-n*x*z-p*w*y+k*x*y+n*w*B-k*t*B;c.n42=f*x*z-m*t*z+m*w*y-e*x*y-f*w*B+e*t*B;c.n43=m*n*z-f*p*z-m*k*y+e*p*y+f*k*B-e*n*B;c.n44=f*p*w-m*n*w+m*k*t-e*p*t-f*k*x+e*n*x;c.multiplyScalar(1/b.determinant());return c}; +THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=b.n33*b.n22-b.n32*b.n23,m=-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,n=b.n33*b.n11-b.n31*b.n13,p=-b.n32*b.n11+b.n31*b.n12,u=b.n23*b.n12-b.n22*b.n13,w=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*k+b.n31*u;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*m;e[2]=b*h;e[3]=b*k;e[4]=b*n;e[5]=b*p;e[6]=b*u;e[7]=b*w;e[8]=b*t;return c}; +THREE.Matrix4.makeFrustum=function(b,c,e,f,m,h){var k;k=new THREE.Matrix4;k.n11=2*m/(c-b);k.n12=0;k.n13=(c+b)/(c-b);k.n14=0;k.n21=0;k.n22=2*m/(f-e);k.n23=(f+e)/(f-e);k.n24=0;k.n31=0;k.n32=0;k.n33=-(h+m)/(h-m);k.n34=-2*h*m/(h-m);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(b,c,e,f){var m,b=e*Math.tan(b*Math.PI/360);m=-b;return THREE.Matrix4.makeFrustum(m*c,b*c,m,b,e,f)}; +THREE.Matrix4.makeOrtho=function(b,c,e,f,m,h){var k,n,p,u;k=new THREE.Matrix4;n=c-b;p=e-f;u=h-m;k.n11=2/n;k.n12=0;k.n13=0;k.n14=-((c+b)/n);k.n21=0;k.n22=2/p;k.n23=0;k.n24=-((e+f)/p);k.n31=0;k.n32=0;k.n33=-2/u;k.n34=-((h+m)/u);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,e=this.children.indexOf(b);if(e!==-1){b.parent=void 0;for(this.children.splice(e,1);c.parent!==void 0;)c=c.parent;c!==void 0&&c instanceof THREE.Scene&&c.removeChildRecurse(b)}},getChildByName:function(b,c){var e,f,h;e=0;for(f=this.children.length;e=0&&h>=0&&m>=0&&n>=0?!0:k<0&&h<0||m<0&&n<0?!1:(k<0?c=Math.max(c,k/(k-h)):h<0&&(f=Math.min(f,k/(k-h))),m<0?c=Math.max(c,m/(m-n)):n<0&&(f=Math.min(f,m/(m-n))),fo&&m.positionScreen.z0&&L.z<1))ga=F[E]=F[E]||new THREE.RenderableParticle,E++,C=ga,C.x=L.x/L.w,C.y=L.y/L.w,C.z= -L.z,C.rotation=$.rotation.z,C.scale.x=$.scale.x*Math.abs(C.x-(L.x+k.projectionMatrix.n11)/(L.w+k.projectionMatrix.n14)),C.scale.y=$.scale.y*Math.abs(C.y-(L.y+k.projectionMatrix.n22)/(L.w+k.projectionMatrix.n24)),C.materials=$.materials,M.push(C);h&&M.sort(c);return M}};THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)}; -THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;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,e=b.x*c,f=b.y*c,h=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-h),h=Math.sin(-h),k=Math.cos(e),e=Math.sin(e),m=b*c,n=f*h;this.w=m*k-n*e;this.x=m*e+n*k;this.y=f*c*k+b*h*e;this.z=b*h*k-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e); +THREE.Projector=function(){function b(){var b=p[n]=p[n]||new THREE.RenderableVertex;n++;return b}function c(b,e){return e.z-b.z}function e(b,e){var c=0,f=1,h=b.z+b.w,m=e.z+e.w,k=-b.z+b.w,n=-e.z+e.w;return h>=0&&m>=0&&k>=0&&n>=0?!0:h<0&&m<0||k<0&&n<0?!1:(h<0?c=Math.max(c,h/(h-m)):m<0&&(f=Math.min(f,h/(h-m))),k<0?c=Math.max(c,k/(k-n)):n<0&&(f=Math.min(f,k/(k-n))),fo&&k.positionScreen.z0&&L.z<1))ga=F[E]=F[E]||new THREE.RenderableParticle,E++,C=ga,C.x=L.x/L.w,C.y=L.y/L.w,C.z= +L.z,C.rotation=$.rotation.z,C.scale.x=$.scale.x*Math.abs(C.x-(L.x+h.projectionMatrix.n11)/(L.w+h.projectionMatrix.n14)),C.scale.y=$.scale.y*Math.abs(C.y-(L.y+h.projectionMatrix.n22)/(L.w+h.projectionMatrix.n24)),C.materials=$.materials,M.push(C);m&&M.sort(c);return M}};THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)}; +THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;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,e=b.x*c,f=b.y*c,m=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-m),m=Math.sin(-m),h=Math.cos(e),e=Math.sin(e),k=b*c,n=f*m;this.w=k*h-n*e;this.x=k*e+n*h;this.y=f*c*h+b*m*e;this.z=b*m*h-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e); this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(e);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,e=this.y,f=this.z,h=this.w,k=b.x,m=b.y,n=b.z,b=b.w;this.x=c*b+h*k+e*n-f*m;this.y=e*b+h*m+f*k-c*n;this.z=f*b+h*n+c*m-e*k;this.w=h*b-c*k-e*m-f*n;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 e=b.x,f=b.y,h=b.z,k=this.x,m=this.y,n=this.z,u=this.w,p=u*e+m*h-n*f,w=u*f+n*e-k*h,t=u*h+k*f-m*e,e=-k* -e-m*f-n*h;c.x=p*u+e*-k+w*-n-t*-m;c.y=w*u+e*-m+t*-k-p*-n;c.z=t*u+e*-n+p*-m-w*-k;return c}};THREE.Quaternion.slerp=function(b,c,e,f){var h=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(h)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var k=Math.acos(h),m=Math.sqrt(1-h*h);if(Math.abs(m)<0.0010)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;h=Math.sin((1-f)*k)/m;f=Math.sin(f*k)/m;e.w=b.w*h+c.w*f;e.x=b.x*h+c.x*f;e.y=b.y*h+c.y*f;e.z=b.z*h+c.z*f;return e}; -THREE.Vertex=function(b){this.position=b||new THREE.Vector3};THREE.Face3=function(b,c,e,f,h,k){this.a=b;this.b=c;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];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.Face4=function(b,c,e,f,h,k,m){this.a=b;this.b=c;this.c=e;this.d=f;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=k instanceof THREE.Color?k:new THREE.Color;this.vertexColors=k instanceof Array?k:[];this.vertexTangents=[];this.materials=m instanceof Array?m:[m];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.u=b||0;this.v=c||0}; +this.x,e=this.y,f=this.z,m=this.w,h=b.x,k=b.y,n=b.z,b=b.w;this.x=c*b+m*h+e*n-f*k;this.y=e*b+m*k+f*h-c*n;this.z=f*b+m*n+c*k-e*h;this.w=m*b-c*h-e*k-f*n;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 e=b.x,f=b.y,m=b.z,h=this.x,k=this.y,n=this.z,p=this.w,u=p*e+k*m-n*f,w=p*f+n*e-h*m,t=p*m+h*f-k*e,e=-h* +e-k*f-n*m;c.x=u*p+e*-h+w*-n-t*-k;c.y=w*p+e*-k+t*-h-u*-n;c.z=t*p+e*-n+u*-k-w*-h;return c}};THREE.Quaternion.slerp=function(b,c,e,f){var m=b.w*c.w+b.x*c.x+b.y*c.y+b.z*c.z;if(Math.abs(m)>=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var h=Math.acos(m),k=Math.sqrt(1-m*m);if(Math.abs(k)<0.0010)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;m=Math.sin((1-f)*h)/k;f=Math.sin(f*h)/k;e.w=b.w*m+c.w*f;e.x=b.x*m+c.x*f;e.y=b.y*m+c.y*f;e.z=b.z*m+c.z*f;return e}; +THREE.Vertex=function(b){this.position=b||new THREE.Vector3};THREE.Face3=function(b,c,e,f,m,h){this.a=b;this.b=c;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=m instanceof THREE.Color?m:new THREE.Color;this.vertexColors=m instanceof Array?m:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; +THREE.Face4=function(b,c,e,f,m,h,k){this.a=b;this.b=c;this.c=e;this.d=f;this.normal=m instanceof THREE.Vector3?m:new THREE.Vector3;this.vertexNormals=m instanceof Array?m:[];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.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 e=0,f=this.vertices.length;e0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, +e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c]),e.vertexNormals[3].copy(f[e.d]))},computeTangents:function(){function b(b,e,c,f,h,m,o){n=b.vertices[e].position;p=b.vertices[c].position;u=b.vertices[f].position;w=k[h];t=k[m];x=k[o];v=p.x-n.x;z=u.x-n.x;y=p.y-n.y;B=u.y-n.y;C=p.z-n.z;E=u.z-n.z;F=t.u-w.u;G=x.u-w.u;M=t.v-w.v;P=x.v-w.v;L=1/(F*P-G*M);I.set((P*v-M*z)*L,(P*y-M*B)*L,(P*C-M*E)*L);O.set((F*z-G*v)*L,(F*B-G*y)*L,(F*E-G*C)*L);J[e].addSelf(I);J[c].addSelf(I);J[f].addSelf(I);Z[e].addSelf(O); +Z[c].addSelf(O);Z[f].addSelf(O)}var c,e,f,m,h,k,n,p,u,w,t,x,v,z,y,B,C,E,F,G,M,P,L,A,J=[],Z=[],I=new THREE.Vector3,O=new THREE.Vector3,X=new THREE.Vector3,V=new THREE.Vector3,W=new THREE.Vector3;c=0;for(e=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,e=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.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;cthis.points.length-2?k:k+1;e[3]=k>this.points.length-3?k:k+2;p=this.points[e[0]];w=this.points[e[1]]; -t=this.points[e[2]];x=this.points[e[3]];n=m*m;u=m*n;f.x=c(p.x,w.x,t.x,x.x,m,n,u);f.y=c(p.y,w.y,t.y,x.y,m,n,u);f.z=c(p.z,w.z,t.z,x.z,m,n,u);return f};this.getControlPointsArray=function(){var b,e,c=this.points.length,f=[];for(b=0;bthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;cthis.points.length-2?h:h+1;e[3]=h>this.points.length-3?h:h+2;u=this.points[e[0]];w=this.points[e[1]]; +t=this.points[e[2]];x=this.points[e[3]];n=k*k;p=k*n;f.x=c(u.x,w.x,t.x,x.x,k,n,p);f.y=c(u.y,w.y,t.y,x.y,k,n,p);f.z=c(u.z,w.z,t.z,x.z,k,n,p);return f};this.getControlPointsArray=function(){var b,e,c=this.points.length,f=[];for(b=0;b1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1, this.LODs[f].object3D.visible=!0;else break;for(;f0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b* -255)+","+y+")"),v.fillRect(Math.floor(R.getX()),Math.floor(R.getY()),Math.floor(R.getWidth()),Math.floor(R.getHeight()))),R.empty())};this.render=function(b,u){function p(b){var e,c,f,k=b.lights;ia.setRGB(0,0,0);sa.setRGB(0,0,0);va.setRGB(0,0,0);b=0;for(e=k.length;b>1,w=p.height>>1,m=k.scale.x*t,u=k.scale.y*x,o=m*Fa,n=u*w,S.set(b.x-o,b.y-n,b.x+o,b.y+n),K.intersects(S)&&(v.save(),v.translate(b.x,b.y),v.rotate(-k.rotation),v.scale(m,-u),v.translate(-Fa,-w),v.drawImage(p,0,0),v.restore())}else m instanceof THREE.ParticleCanvasMaterial&&(o=k.scale.x*t,n=k.scale.y*x,S.set(b.x-o,b.y-n,b.x+o,b.y+n),K.intersects(S)&&(f(m.color.getContextStyle()),h(m.color.getContextStyle()),v.save(),v.translate(b.x,b.y),v.rotate(-k.rotation),v.scale(o,n),m.program(v), -v.restore()))}function z(b,k,h,m){c(m.opacity);e(m.blending);v.beginPath();v.moveTo(b.positionScreen.x,b.positionScreen.y);v.lineTo(k.positionScreen.x,k.positionScreen.y);v.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(G!=b)v.lineWidth=G=b;b=m.linecap;if(M!=b)v.lineCap=M=b;b=m.linejoin;if(P!=b)v.lineJoin=P=b;f(m.color.getContextStyle());v.stroke();S.inflate(m.linewidth*2)}}function B(b,f,h,m,n,t,p,v,x){k.info.render.vertices+=3;k.info.render.faces++;c(v.opacity);e(v.blending); -X=b.positionScreen.x;V=b.positionScreen.y;W=f.positionScreen.x;o=f.positionScreen.y;ea=h.positionScreen.x;T=h.positionScreen.y;E(X,V,W,o,ea,T);if(v instanceof THREE.MeshBasicMaterial)if(v.map)v.map.mapping instanceof THREE.UVMapping&&(ra=p.uvs[0],ab(X,V,W,o,ea,T,ra[m].u,ra[m].v,ra[n].u,ra[n].v,ra[t].u,ra[t].v,v.map));else if(v.envMap){if(v.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=u.matrixWorldInverse,pa.copy(p.vertexNormalsWorld[0]),wa=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5, +THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,m,h;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;m=e/2;h=f/2};this.render=function(e,f){var p,u,w,t,x,v,z,y;b=c.projectScene(e,f);p=0;for(u=b.length;p0&&(e(THREE.NormalBlending),c(1),m("rgba("+Math.floor(z.r*255)+","+Math.floor(z.g*255)+","+Math.floor(z.b* +255)+","+y+")"),v.fillRect(Math.floor(R.getX()),Math.floor(R.getY()),Math.floor(R.getWidth()),Math.floor(R.getHeight()))),R.empty())};this.render=function(b,u){function p(b){var e,c,f,h=b.lights;ia.setRGB(0,0,0);sa.setRGB(0,0,0);va.setRGB(0,0,0);b=0;for(e=h.length;b>1,w=p.height>>1,k=h.scale.x*t,u=h.scale.y*x,o=k*Fa,n=u*w,S.set(b.x-o,b.y-n,b.x+o,b.y+n),K.intersects(S)&&(v.save(),v.translate(b.x,b.y),v.rotate(-h.rotation),v.scale(k,-u),v.translate(-Fa,-w),v.drawImage(p,0,0),v.restore())}else k instanceof THREE.ParticleCanvasMaterial&&(o=h.scale.x*t,n=h.scale.y*x,S.set(b.x-o,b.y-n,b.x+o,b.y+n),K.intersects(S)&&(f(k.color.getContextStyle()),m(k.color.getContextStyle()),v.save(),v.translate(b.x,b.y),v.rotate(-h.rotation),v.scale(o,n),k.program(v), +v.restore()))}function z(b,h,k,m){c(m.opacity);e(m.blending);v.beginPath();v.moveTo(b.positionScreen.x,b.positionScreen.y);v.lineTo(h.positionScreen.x,h.positionScreen.y);v.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(G!=b)v.lineWidth=G=b;b=m.linecap;if(M!=b)v.lineCap=M=b;b=m.linejoin;if(P!=b)v.lineJoin=P=b;f(m.color.getContextStyle());v.stroke();S.inflate(m.linewidth*2)}}function B(b,f,m,k,n,t,p,v,x){h.info.render.vertices+=3;h.info.render.faces++;c(v.opacity);e(v.blending); +X=b.positionScreen.x;V=b.positionScreen.y;W=f.positionScreen.x;o=f.positionScreen.y;ea=m.positionScreen.x;T=m.positionScreen.y;E(X,V,W,o,ea,T);if(v instanceof THREE.MeshBasicMaterial)if(v.map)v.map.mapping instanceof THREE.UVMapping&&(ra=p.uvs[0],ab(X,V,W,o,ea,T,ra[k].u,ra[k].v,ra[n].u,ra[n].v,ra[t].u,ra[t].v,v.map));else if(v.envMap){if(v.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=u.matrixWorldInverse,pa.copy(p.vertexNormalsWorld[0]),wa=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5, Da=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(p.vertexNormalsWorld[1]),Ea=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,Aa=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(p.vertexNormalsWorld[2]),Ca=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,Ga=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,ab(X,V,W,o,ea,T,wa,Da,Ea,Aa,Ca,Ga,v.envMap)}else v.wireframe?Na(v.color,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Oa(v.color);else if(v instanceof THREE.MeshLambertMaterial)v.map&&!v.wireframe&& -(v.map.mapping instanceof THREE.UVMapping&&(ra=p.uvs[0],ab(X,V,W,o,ea,T,ra[m].u,ra[m].v,ra[n].u,ra[n].v,ra[t].u,ra[t].v,v.map)),e(THREE.SubtractiveBlending)),ja?!v.wireframe&&v.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==3?(U.r=$.r=ga.r=ia.r,U.g=$.g=ga.g=ia.g,U.b=$.b=ga.b=ia.b,w(x,p.v1.positionWorld,p.vertexNormalsWorld[0],U),w(x,p.v2.positionWorld,p.vertexNormalsWorld[1],$),w(x,p.v3.positionWorld,p.vertexNormalsWorld[2],ga),U.r=Math.max(0,Math.min(v.color.r*U.r,1)),U.g=Math.max(0, +(v.map.mapping instanceof THREE.UVMapping&&(ra=p.uvs[0],ab(X,V,W,o,ea,T,ra[k].u,ra[k].v,ra[n].u,ra[n].v,ra[t].u,ra[t].v,v.map)),e(THREE.SubtractiveBlending)),ja?!v.wireframe&&v.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==3?(U.r=$.r=ga.r=ia.r,U.g=$.g=ga.g=ia.g,U.b=$.b=ga.b=ia.b,w(x,p.v1.positionWorld,p.vertexNormalsWorld[0],U),w(x,p.v2.positionWorld,p.vertexNormalsWorld[1],$),w(x,p.v3.positionWorld,p.vertexNormalsWorld[2],ga),U.r=Math.max(0,Math.min(v.color.r*U.r,1)),U.g=Math.max(0, Math.min(v.color.g*U.g,1)),U.b=Math.max(0,Math.min(v.color.b*U.b,1)),$.r=Math.max(0,Math.min(v.color.r*$.r,1)),$.g=Math.max(0,Math.min(v.color.g*$.g,1)),$.b=Math.max(0,Math.min(v.color.b*$.b,1)),ga.r=Math.max(0,Math.min(v.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(v.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(v.color.b*ga.b,1)),ka.r=($.r+ga.r)*0.5,ka.g=($.g+ga.g)*0.5,ka.b=($.b+ga.b)*0.5,ma=Ya(U,$,ga,ka),Va(X,V,W,o,ea,T,0,0,1,0,0,1,ma)):(oa.r=ia.r,oa.g=ia.g,oa.b=ia.b,w(x,p.centroidWorld,p.normalWorld, -oa),da.r=Math.max(0,Math.min(v.color.r*oa.r,1)),da.g=Math.max(0,Math.min(v.color.g*oa.g,1)),da.b=Math.max(0,Math.min(v.color.b*oa.b,1)),v.wireframe?Na(da,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Oa(da)):v.wireframe?Na(v.color,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Oa(v.color);else if(v instanceof THREE.MeshDepthMaterial)la=u.near,N=u.far,U.r=U.g=U.b=1-Ra(b.positionScreen.z,la,N),$.r=$.g=$.b=1-Ra(f.positionScreen.z,la,N),ga.r=ga.g=ga.b=1-Ra(h.positionScreen.z, -la,N),ka.r=($.r+ga.r)*0.5,ka.g=($.g+ga.g)*0.5,ka.b=($.b+ga.b)*0.5,ma=Ya(U,$,ga,ka),Va(X,V,W,o,ea,T,0,0,1,0,0,1,ma);else if(v instanceof THREE.MeshNormalMaterial)da.r=Wa(p.normalWorld.x),da.g=Wa(p.normalWorld.y),da.b=Wa(p.normalWorld.z),v.wireframe?Na(da,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Oa(da)}function C(b,f,h,m,n,t,v,p,x){k.info.render.vertices+=4;k.info.render.faces++;c(p.opacity);e(p.blending);if(p.map||p.envMap)B(b,f,m,0,1,3,v,p,x),B(n,h,t,1,2,3,v,p,x);else if(X=b.positionScreen.x, -V=b.positionScreen.y,W=f.positionScreen.x,o=f.positionScreen.y,ea=h.positionScreen.x,T=h.positionScreen.y,na=m.positionScreen.x,aa=m.positionScreen.y,ha=n.positionScreen.x,ca=n.positionScreen.y,qa=t.positionScreen.x,fa=t.positionScreen.y,p instanceof THREE.MeshBasicMaterial)F(X,V,W,o,ea,T,na,aa),p.wireframe?Na(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Oa(p.color);else if(p instanceof THREE.MeshLambertMaterial)ja?!p.wireframe&&p.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length== +oa),da.r=Math.max(0,Math.min(v.color.r*oa.r,1)),da.g=Math.max(0,Math.min(v.color.g*oa.g,1)),da.b=Math.max(0,Math.min(v.color.b*oa.b,1)),v.wireframe?Na(da,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Oa(da)):v.wireframe?Na(v.color,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Oa(v.color);else if(v instanceof THREE.MeshDepthMaterial)la=u.near,N=u.far,U.r=U.g=U.b=1-Ra(b.positionScreen.z,la,N),$.r=$.g=$.b=1-Ra(f.positionScreen.z,la,N),ga.r=ga.g=ga.b=1-Ra(m.positionScreen.z, +la,N),ka.r=($.r+ga.r)*0.5,ka.g=($.g+ga.g)*0.5,ka.b=($.b+ga.b)*0.5,ma=Ya(U,$,ga,ka),Va(X,V,W,o,ea,T,0,0,1,0,0,1,ma);else if(v instanceof THREE.MeshNormalMaterial)da.r=Wa(p.normalWorld.x),da.g=Wa(p.normalWorld.y),da.b=Wa(p.normalWorld.z),v.wireframe?Na(da,v.wireframeLinewidth,v.wireframeLinecap,v.wireframeLinejoin):Oa(da)}function C(b,f,m,k,n,t,v,p,x){h.info.render.vertices+=4;h.info.render.faces++;c(p.opacity);e(p.blending);if(p.map||p.envMap)B(b,f,k,0,1,3,v,p,x),B(n,m,t,1,2,3,v,p,x);else if(X=b.positionScreen.x, +V=b.positionScreen.y,W=f.positionScreen.x,o=f.positionScreen.y,ea=m.positionScreen.x,T=m.positionScreen.y,na=k.positionScreen.x,aa=k.positionScreen.y,ha=n.positionScreen.x,ca=n.positionScreen.y,qa=t.positionScreen.x,fa=t.positionScreen.y,p instanceof THREE.MeshBasicMaterial)F(X,V,W,o,ea,T,na,aa),p.wireframe?Na(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Oa(p.color);else if(p instanceof THREE.MeshLambertMaterial)ja?!p.wireframe&&p.shading==THREE.SmoothShading&&v.vertexNormalsWorld.length== 4?(U.r=$.r=ga.r=ka.r=ia.r,U.g=$.g=ga.g=ka.g=ia.g,U.b=$.b=ga.b=ka.b=ia.b,w(x,v.v1.positionWorld,v.vertexNormalsWorld[0],U),w(x,v.v2.positionWorld,v.vertexNormalsWorld[1],$),w(x,v.v4.positionWorld,v.vertexNormalsWorld[3],ga),w(x,v.v3.positionWorld,v.vertexNormalsWorld[2],ka),U.r=Math.max(0,Math.min(p.color.r*U.r,1)),U.g=Math.max(0,Math.min(p.color.g*U.g,1)),U.b=Math.max(0,Math.min(p.color.b*U.b,1)),$.r=Math.max(0,Math.min(p.color.r*$.r,1)),$.g=Math.max(0,Math.min(p.color.g*$.g,1)),$.b=Math.max(0,Math.min(p.color.b* $.b,1)),ga.r=Math.max(0,Math.min(p.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(p.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(p.color.b*ga.b,1)),ka.r=Math.max(0,Math.min(p.color.r*ka.r,1)),ka.g=Math.max(0,Math.min(p.color.g*ka.g,1)),ka.b=Math.max(0,Math.min(p.color.b*ka.b,1)),ma=Ya(U,$,ga,ka),E(X,V,W,o,na,aa),Va(X,V,W,o,na,aa,0,0,1,0,0,1,ma),E(ha,ca,ea,T,qa,fa),Va(ha,ca,ea,T,qa,fa,1,0,1,1,0,1,ma)):(oa.r=ia.r,oa.g=ia.g,oa.b=ia.b,w(x,v.centroidWorld,v.normalWorld,oa),da.r=Math.max(0,Math.min(p.color.r*oa.r, 1)),da.g=Math.max(0,Math.min(p.color.g*oa.g,1)),da.b=Math.max(0,Math.min(p.color.b*oa.b,1)),F(X,V,W,o,ea,T,na,aa),p.wireframe?Na(da,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Oa(da)):(F(X,V,W,o,ea,T,na,aa),p.wireframe?Na(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Oa(p.color));else if(p instanceof THREE.MeshNormalMaterial)da.r=Wa(v.normalWorld.x),da.g=Wa(v.normalWorld.y),da.b=Wa(v.normalWorld.z),F(X,V,W,o,ea,T,na,aa),p.wireframe?Na(da,p.wireframeLinewidth, -p.wireframeLinecap,p.wireframeLinejoin):Oa(da);else if(p instanceof THREE.MeshDepthMaterial)la=u.near,N=u.far,U.r=U.g=U.b=1-Ra(b.positionScreen.z,la,N),$.r=$.g=$.b=1-Ra(f.positionScreen.z,la,N),ga.r=ga.g=ga.b=1-Ra(m.positionScreen.z,la,N),ka.r=ka.g=ka.b=1-Ra(h.positionScreen.z,la,N),ma=Ya(U,$,ga,ka),E(X,V,W,o,na,aa),Va(X,V,W,o,na,aa,0,0,1,0,0,1,ma),E(ha,ca,ea,T,qa,fa),Va(ha,ca,ea,T,qa,fa,1,0,1,1,0,1,ma)}function E(b,e,c,f,k,h){v.beginPath();v.moveTo(b,e);v.lineTo(c,f);v.lineTo(k,h);v.lineTo(b,e); -v.closePath()}function F(b,e,c,f,k,h,m,o){v.beginPath();v.moveTo(b,e);v.lineTo(c,f);v.lineTo(k,h);v.lineTo(m,o);v.lineTo(b,e);v.closePath()}function Na(b,e,c,k){if(G!=e)v.lineWidth=G=e;if(M!=c)v.lineCap=M=c;if(P!=k)v.lineJoin=P=k;f(b.getContextStyle());v.stroke();S.inflate(e*2)}function Oa(b){h(b.getContextStyle());v.fill()}function ab(b,e,c,f,k,m,o,n,p,t,u,Fa,x){if(x.image.width!=0){if(x.needsUpdate==!0||ua[x.id]==void 0){var w=x.wrapS==THREE.RepeatWrapping,y=x.wrapT==THREE.RepeatWrapping;ua[x.id]= -v.createPattern(x.image,w&&y?"repeat":w&&!y?"repeat-x":!w&&y?"repeat-y":"no-repeat");x.needsUpdate=!1}h(ua[x.id]);var w=x.offset.x/x.repeat.x,y=x.offset.y/x.repeat.y,K=(x.image.width-1)*x.repeat.x,x=(x.image.height-1)*x.repeat.y,o=(o+w)*K,n=(n+y)*x,p=(p+w)*K,t=(t+y)*x,u=(u+w)*K,Fa=(Fa+y)*x;c-=b;f-=e;k-=b;m-=e;p-=o;t-=n;u-=o;Fa-=n;w=1/(p*Fa-u*t);x=(Fa*c-t*k)*w;t=(Fa*f-t*m)*w;c=(p*k-u*c)*w;f=(p*m-u*f)*w;b=b-x*o-c*n;e=e-t*o-f*n;v.save();v.transform(x,t,c,f,b,e);v.fill();v.restore()}}function Va(b,e, -c,f,k,m,h,o,n,p,t,u,Fa){var x,w;x=Fa.width-1;w=Fa.height-1;h*=x;o*=w;n*=x;p*=w;t*=x;u*=w;c-=b;f-=e;k-=b;m-=e;n-=h;p-=o;t-=h;u-=o;w=1/(n*u-t*p);x=(u*c-p*k)*w;p=(u*f-p*m)*w;c=(n*k-t*c)*w;f=(n*m-t*f)*w;b=b-x*h-c*o;e=e-p*h-f*o;v.save();v.transform(x,p,c,f,b,e);v.clip();v.drawImage(Fa,0,0);v.restore()}function Ya(b,e,c,f){var k=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),m=~~(e.r*255),o=~~(e.g*255),e=~~(e.b*255),n=~~(c.r*255),p=~~(c.g*255),c=~~(c.b*255),t=~~(f.r*255),v=~~(f.g*255),f=~~(f.b*255);Ba[0]=k<0? -0:k>255?255:k;Ba[1]=h<0?0:h>255?255:h;Ba[2]=b<0?0:b>255?255:b;Ba[4]=m<0?0:m>255?255:m;Ba[5]=o<0?0:o>255?255:o;Ba[6]=e<0?0:e>255?255:e;Ba[8]=n<0?0:n>255?255:n;Ba[9]=p<0?0:p>255?255:p;Ba[10]=c<0?0:c>255?255:c;Ba[12]=t<0?0:t>255?255:t;Ba[13]=v<0?0:v>255?255:v;Ba[14]=f<0?0:f>255?255:f;ya.putImageData(Ka,0,0);Y.drawImage(xa,0,0);return Ha}function Ra(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Wa(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Pa(b,e){var c=e.x-b.x,f=e.y-b.y,k=c*c+f*f;k!=0&&(k=1/Math.sqrt(k), -c*=k,f*=k,e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Za,bb,ta,Ia,Qa,Xa,$a,za;this.autoClear?this.clear():v.setTransform(1,0,0,-1,t,x);k.info.render.vertices=0;k.info.render.faces=0;m=n.projectScene(b,u,this.sortElements);(ja=b.lights.length>0)&&p(b);Za=0;for(bb=m.length;Za255?255:h;Ba[1]=k<0?0:k>255?255:k;Ba[2]=b<0?0:b>255?255:b;Ba[4]=m<0?0:m>255?255:m;Ba[5]=o<0?0:o>255?255:o;Ba[6]=e<0?0:e>255?255:e;Ba[8]=n<0?0:n>255?255:n;Ba[9]=p<0?0:p>255?255:p;Ba[10]=c<0?0:c>255?255:c;Ba[12]=t<0?0:t>255?255:t;Ba[13]=v<0?0:v>255?255:v;Ba[14]=f<0?0:f>255?255:f;ya.putImageData(Ka,0,0);Y.drawImage(xa,0,0);return Ha}function Ra(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Wa(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Pa(b,e){var c=e.x-b.x,f=e.y-b.y,h=c*c+f*f;h!=0&&(h=1/Math.sqrt(h), +c*=h,f*=h,e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Za,bb,ta,Ia,Qa,Xa,$a,za;this.autoClear?this.clear():v.setTransform(1,0,0,-1,t,x);h.info.render.vertices=0;h.info.render.faces=0;k=n.projectScene(b,u,this.sortElements);(ja=b.lights.length>0)&&p(b);Za=0;for(bb=k.length;Za0&&(c.r+=h.color.r*m,c.g+=h.color.g*m,c.b+=h.color.b*m)):h instanceof THREE.PointLight&&(Z.sub(h.position,e.centroidWorld),Z.normalize(),m=e.normalWorld.dot(Z)*h.intensity,m>0&&(c.r+=h.color.r*m,c.g+=h.color.g*m,c.b+=h.color.b*m))}function c(e,c,m,o,n,p){k.info.render.vertices+=3;k.info.render.faces++;X=f(V++); -X.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?G.copy(n.color):n instanceof THREE.MeshLambertMaterial?F?(M.r=P.r,M.g=P.g,M.b=P.b,b(p,o,M),G.r=Math.max(0,Math.min(n.color.r*M.r,1)),G.g=Math.max(0,Math.min(n.color.g*M.g,1)),G.b=Math.max(0,Math.min(n.color.b*M.b,1))):G.copy(n.color):n instanceof THREE.MeshDepthMaterial?(J=1-n.__2near/(n.__farPlusNear- -o.z*n.__farMinusNear),G.setRGB(J,J,J)):n instanceof THREE.MeshNormalMaterial&&G.setRGB(h(o.normalWorld.x),h(o.normalWorld.y),h(o.normalWorld.z));n.wireframe?X.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):X.setAttribute("style","fill: "+G.getContextStyle()+"; fill-opacity: "+n.opacity);u.appendChild(X)}function e(e,c,m,o,n,p,t){k.info.render.vertices+= -4;k.info.render.faces++;X=f(V++);X.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+" L "+o.positionScreen.x+","+o.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?G.copy(p.color):p instanceof THREE.MeshLambertMaterial?F?(M.r=P.r,M.g=P.g,M.b=P.b,b(t,n,M),G.r=Math.max(0,Math.min(p.color.r*M.r,1)),G.g=Math.max(0,Math.min(p.color.g*M.g,1)),G.b=Math.max(0,Math.min(p.color.b*M.b,1))): -G.copy(p.color):p instanceof THREE.MeshDepthMaterial?(J=1-p.__2near/(p.__farPlusNear-n.z*p.__farMinusNear),G.setRGB(J,J,J)):p instanceof THREE.MeshNormalMaterial&&G.setRGB(h(n.normalWorld.x),h(n.normalWorld.y),h(n.normalWorld.z));p.wireframe?X.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):X.setAttribute("style","fill: "+G.getContextStyle()+ -"; fill-opacity: "+p.opacity);u.appendChild(X)}function f(b){I[b]==null&&(I[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),o==0&&I[b].setAttribute("shape-rendering","crispEdges"));return I[b]}function h(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var k=this,m=null,n=new THREE.Projector,u=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,w,t,x,v,z,y,B,C=new THREE.Rectangle,E=new THREE.Rectangle,F=!1,G=new THREE.Color(16777215),M=new THREE.Color(16777215),P=new THREE.Color(0), -L=new THREE.Color(0),A=new THREE.Color(0),J,Z=new THREE.Vector3,I=[],O=[],X,V,W,o=1;this.domElement=u;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(b){switch(b){case "high":o=1;break;case "low":o=0}};this.setSize=function(b,e){p=b;w=e;t=p/2;x=w/2;u.setAttribute("viewBox",-t+" "+-x+" "+p+" "+w);u.setAttribute("width",p);u.setAttribute("height",w);C.set(-t,-x,t,x)};this.clear=function(){for(;u.childNodes.length>0;)u.removeChild(u.childNodes[0])}; -this.render=function(b,f){var h,p,w,G,I,M,J,U;this.autoClear&&this.clear();k.info.render.vertices=0;k.info.render.faces=0;m=n.projectScene(b,f,this.sortElements);W=V=0;if(F=b.lights.length>0){J=b.lights;P.setRGB(0,0,0);L.setRGB(0,0,0);A.setRGB(0,0,0);h=0;for(p=J.length;h0&&(c.r+=k.color.r*m,c.g+=k.color.g*m,c.b+=k.color.b*m)):k instanceof THREE.PointLight&&(Z.sub(k.position,e.centroidWorld),Z.normalize(),m=e.normalWorld.dot(Z)*k.intensity,m>0&&(c.r+=k.color.r*m,c.g+=k.color.g*m,c.b+=k.color.b*m))}function c(e,c,k,o,n,t){h.info.render.vertices+=3;h.info.render.faces++;X=f(V++); +X.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?G.copy(n.color):n instanceof THREE.MeshLambertMaterial?F?(M.r=P.r,M.g=P.g,M.b=P.b,b(t,o,M),G.r=Math.max(0,Math.min(n.color.r*M.r,1)),G.g=Math.max(0,Math.min(n.color.g*M.g,1)),G.b=Math.max(0,Math.min(n.color.b*M.b,1))):G.copy(n.color):n instanceof THREE.MeshDepthMaterial?(J=1-n.__2near/(n.__farPlusNear- +o.z*n.__farMinusNear),G.setRGB(J,J,J)):n instanceof THREE.MeshNormalMaterial&&G.setRGB(m(o.normalWorld.x),m(o.normalWorld.y),m(o.normalWorld.z));n.wireframe?X.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):X.setAttribute("style","fill: "+G.getContextStyle()+"; fill-opacity: "+n.opacity);p.appendChild(X)}function e(e,c,k,o,n,t,v){h.info.render.vertices+= +4;h.info.render.faces++;X=f(V++);X.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+" L "+o.positionScreen.x+","+o.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?G.copy(t.color):t instanceof THREE.MeshLambertMaterial?F?(M.r=P.r,M.g=P.g,M.b=P.b,b(v,n,M),G.r=Math.max(0,Math.min(t.color.r*M.r,1)),G.g=Math.max(0,Math.min(t.color.g*M.g,1)),G.b=Math.max(0,Math.min(t.color.b*M.b,1))): +G.copy(t.color):t instanceof THREE.MeshDepthMaterial?(J=1-t.__2near/(t.__farPlusNear-n.z*t.__farMinusNear),G.setRGB(J,J,J)):t instanceof THREE.MeshNormalMaterial&&G.setRGB(m(n.normalWorld.x),m(n.normalWorld.y),m(n.normalWorld.z));t.wireframe?X.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):X.setAttribute("style","fill: "+G.getContextStyle()+ +"; fill-opacity: "+t.opacity);p.appendChild(X)}function f(b){I[b]==null&&(I[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),o==0&&I[b].setAttribute("shape-rendering","crispEdges"));return I[b]}function m(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var h=this,k=null,n=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),u,w,t,x,v,z,y,B,C=new THREE.Rectangle,E=new THREE.Rectangle,F=!1,G=new THREE.Color(16777215),M=new THREE.Color(16777215),P=new THREE.Color(0), +L=new THREE.Color(0),A=new THREE.Color(0),J,Z=new THREE.Vector3,I=[],O=[],X,V,W,o=1;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(b){switch(b){case "high":o=1;break;case "low":o=0}};this.setSize=function(b,e){u=b;w=e;t=u/2;x=w/2;p.setAttribute("viewBox",-t+" "+-x+" "+u+" "+w);p.setAttribute("width",u);p.setAttribute("height",w);C.set(-t,-x,t,x)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])}; +this.render=function(b,f){var m,u,w,G,I,M,J,U;this.autoClear&&this.clear();h.info.render.vertices=0;h.info.render.faces=0;k=n.projectScene(b,f,this.sortElements);W=V=0;if(F=b.lights.length>0){J=b.lights;P.setRGB(0,0,0);L.setRGB(0,0,0);A.setRGB(0,0,0);m=0;for(u=J.length;m= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 ) {\n#ifdef SHADOWMAP_SOFT\nfloat shadow = 0.0;\nfor ( float y = -1.25; y <= 1.25; y += 1.25 )\nfor ( float x = -1.25; x <= 1.25; x += 1.25 ) {\nvec4 rgbaDepth = texture2D( shadowMap[ i ], vec2( x * xPixelOffset, y * yPixelOffset ) + shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadow += 1.0;\n}\nshadow /= 9.0;\nshadowColor = shadowColor * vec4( vec3( ( 1.0 - shadowDarkness * shadow ) ), 1.0 );\n#else\nvec4 rgbaDepth = texture2D( shadowMap[ i ], shadowCoord.xy );\nfloat fDepth = unpackDepth( rgbaDepth );\nif ( fDepth < shadowCoord.z )\nshadowColor = shadowColor * vec4( vec3( shadowDarkness ), 1.0 );\n#endif\n}\n}\ngl_FragColor = gl_FragColor * shadowColor;\n#endif", shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nuniform mat4 shadowMatrix[ MAX_SHADOWS ];\n#endif",shadowmap_vertex:"#ifdef USE_SHADOWMAP\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvShadowCoord[ i ] = shadowMatrix[ i ] * objectMatrix * vec4( position, 1.0 );\n}\n#endif",alphatest_fragment:"#ifdef ALPHATEST\nif ( gl_FragColor.a < ALPHATEST ) discard;\n#endif"}; -THREE.UniformsUtils={merge:function(b){var c,e,f,h={};for(c=0;c=0)c&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(b.position,3,o.FLOAT,!1,0,0));else if(m.morphTargetBase){f=k.program.attributes;m.morphTargetBase!==-1?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[m.morphTargetBase]), -o.vertexAttribPointer(f.position,3,o.FLOAT,!1,0,0)):f.position>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(f.position,3,o.FLOAT,!1,0,0));if(m.morphTargetForcedOrder.length)for(var p=0,t=m.morphTargetForcedOrder,u=m.morphTargetInfluences;pv&&(x=w,v=u[x]);o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[x]);o.vertexAttribPointer(f["morphTarget"+p],3,o.FLOAT,!1,0,0);m.__webglMorphTargetInfluences[p]=v;t[x]=1;v=-1;p++}}k.program.uniforms.morphTargetInfluences!==null&&o.uniform1fv(k.program.uniforms.morphTargetInfluences,m.__webglMorphTargetInfluences)}if(c){if(h.__webglCustomAttributes)for(n in h.__webglCustomAttributes)b[n]>= -0&&(f=h.__webglCustomAttributes[n],o.bindBuffer(o.ARRAY_BUFFER,f.buffer),o.vertexAttribPointer(b[n],f.size,o.FLOAT,!1,0,0));b.color>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglColorBuffer),o.vertexAttribPointer(b.color,3,o.FLOAT,!1,0,0));b.normal>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglNormalBuffer),o.vertexAttribPointer(b.normal,3,o.FLOAT,!1,0,0));b.tangent>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglTangentBuffer),o.vertexAttribPointer(b.tangent,4,o.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(o.bindBuffer(o.ARRAY_BUFFER, -h.__webglUVBuffer),o.vertexAttribPointer(b.uv,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(b.uv)):o.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglUV2Buffer),o.vertexAttribPointer(b.uv2,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(b.uv2)):o.disableVertexAttribArray(b.uv2));k.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinVertexABuffer),o.vertexAttribPointer(b.skinVertexA,4, -o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),o.vertexAttribPointer(b.skinVertexB,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),o.vertexAttribPointer(b.skinIndex,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),o.vertexAttribPointer(b.skinWeight,4,o.FLOAT,!1,0,0))}m instanceof THREE.Mesh?(k.wireframe?(o.lineWidth(k.wireframeLinewidth),c&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),o.drawElements(o.LINES,h.__webglLineCount, -o.UNSIGNED_SHORT,0)):(c&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),o.drawElements(o.TRIANGLES,h.__webglFaceCount,o.UNSIGNED_SHORT,0)),W.info.render.calls++,W.info.render.vertices+=h.__webglFaceCount,W.info.render.faces+=h.__webglFaceCount/3):m instanceof THREE.Line?(m=m.type==THREE.LineStrip?o.LINE_STRIP:o.LINES,o.lineWidth(k.linewidth),o.drawArrays(m,0,h.__webglLineCount),W.info.render.calls++):m instanceof THREE.ParticleSystem?(o.drawArrays(o.POINTS,0,h.__webglParticleCount),W.info.render.calls++): -m instanceof THREE.Ribbon&&(o.drawArrays(o.TRIANGLE_STRIP,0,h.__webglVertexCount),W.info.render.calls++)}}function h(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=o.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=o.createBuffer();b.hasPos&&(o.bindBuffer(o.ARRAY_BUFFER,b.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,b.positionArray,o.DYNAMIC_DRAW),o.enableVertexAttribArray(e.attributes.position),o.vertexAttribPointer(e.attributes.position,3,o.FLOAT,!1,0,0));if(b.hasNormal){o.bindBuffer(o.ARRAY_BUFFER, -b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,h,k,m,n,p,t,u,v,x,w=b.count*3;for(x=0;x=0)c&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer),o.vertexAttribPointer(b.position,3,o.FLOAT,!1,0,0));else if(m.morphTargetBase){f=h.program.attributes;m.morphTargetBase!==-1?(o.bindBuffer(o.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[m.morphTargetBase]), +o.vertexAttribPointer(f.position,3,o.FLOAT,!1,0,0)):f.position>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer),o.vertexAttribPointer(f.position,3,o.FLOAT,!1,0,0));if(m.morphTargetForcedOrder.length)for(var t=0,p=m.morphTargetForcedOrder,u=m.morphTargetInfluences;tv&&(x=w,v=u[x]);o.bindBuffer(o.ARRAY_BUFFER,k.__webglMorphTargetsBuffers[x]);o.vertexAttribPointer(f["morphTarget"+t],3,o.FLOAT,!1,0,0);m.__webglMorphTargetInfluences[t]=v;p[x]=1;v=-1;t++}}h.program.uniforms.morphTargetInfluences!==null&&o.uniform1fv(h.program.uniforms.morphTargetInfluences,m.__webglMorphTargetInfluences)}if(c){if(k.__webglCustomAttributes)for(n in k.__webglCustomAttributes)b[n]>= +0&&(f=k.__webglCustomAttributes[n],o.bindBuffer(o.ARRAY_BUFFER,f.buffer),o.vertexAttribPointer(b[n],f.size,o.FLOAT,!1,0,0));b.color>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglColorBuffer),o.vertexAttribPointer(b.color,3,o.FLOAT,!1,0,0));b.normal>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglNormalBuffer),o.vertexAttribPointer(b.normal,3,o.FLOAT,!1,0,0));b.tangent>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglTangentBuffer),o.vertexAttribPointer(b.tangent,4,o.FLOAT,!1,0,0));b.uv>=0&&(k.__webglUVBuffer?(o.bindBuffer(o.ARRAY_BUFFER, +k.__webglUVBuffer),o.vertexAttribPointer(b.uv,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(b.uv)):o.disableVertexAttribArray(b.uv));b.uv2>=0&&(k.__webglUV2Buffer?(o.bindBuffer(o.ARRAY_BUFFER,k.__webglUV2Buffer),o.vertexAttribPointer(b.uv2,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(b.uv2)):o.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinVertexABuffer),o.vertexAttribPointer(b.skinVertexA,4, +o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinVertexBBuffer),o.vertexAttribPointer(b.skinVertexB,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinIndicesBuffer),o.vertexAttribPointer(b.skinIndex,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,k.__webglSkinWeightsBuffer),o.vertexAttribPointer(b.skinWeight,4,o.FLOAT,!1,0,0))}m instanceof THREE.Mesh?(h.wireframe?(o.lineWidth(h.wireframeLinewidth),c&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,k.__webglLineBuffer),o.drawElements(o.LINES,k.__webglLineCount, +o.UNSIGNED_SHORT,0)):(c&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,k.__webglFaceBuffer),o.drawElements(o.TRIANGLES,k.__webglFaceCount,o.UNSIGNED_SHORT,0)),W.info.render.calls++,W.info.render.vertices+=k.__webglFaceCount,W.info.render.faces+=k.__webglFaceCount/3):m instanceof THREE.Line?(m=m.type==THREE.LineStrip?o.LINE_STRIP:o.LINES,o.lineWidth(h.linewidth),o.drawArrays(m,0,k.__webglLineCount),W.info.render.calls++):m instanceof THREE.ParticleSystem?(o.drawArrays(o.POINTS,0,k.__webglParticleCount),W.info.render.calls++): +m instanceof THREE.Ribbon&&(o.drawArrays(o.TRIANGLE_STRIP,0,k.__webglVertexCount),W.info.render.calls++)}}function m(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=o.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=o.createBuffer();b.hasPos&&(o.bindBuffer(o.ARRAY_BUFFER,b.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,b.positionArray,o.DYNAMIC_DRAW),o.enableVertexAttribArray(e.attributes.position),o.vertexAttribPointer(e.attributes.position,3,o.FLOAT,!1,0,0));if(b.hasNormal){o.bindBuffer(o.ARRAY_BUFFER, +b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,h,k,m,n,t,p,u,v,x,w=b.count*3;for(x=0;x=0;c--)b[c].object==e&&b.splice(c,1)}function M(b){function e(b){var h=[];c=0;for(f=b.length;c65535&&(t[o].counter+=1,p=t[o].hash+"_"+t[o].counter,b.geometryGroups[p]==void 0&&(b.geometryGroups[p]={faces:[],materials:n,vertices:0,numMorphTargets:v})), -b.geometryGroups[p].faces.push(h),b.geometryGroups[p].vertices+=m;b.geometryGroupsList=[];for(var u in b.geometryGroups)b.geometryGroups[u].id=ca++,b.geometryGroupsList.push(b.geometryGroups[u])}function P(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function L(b){if(b!=da){switch(b){case THREE.AdditiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE);break;case THREE.SubtractiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO, +c;b++)if(f=h[b],f.attributes)for(e in f.attributes)if(f.attributes[e].needsUpdate)return!0;return!1}function F(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b=0;c--)b[c].object==e&&b.splice(c,1)}function M(b){function e(b){var h=[];c=0;for(f=b.length;c65535&&(p[o].counter+=1,t=p[o].hash+"_"+p[o].counter,b.geometryGroups[t]==void 0&&(b.geometryGroups[t]={faces:[],materials:n,vertices:0,numMorphTargets:v})), +b.geometryGroups[t].faces.push(h),b.geometryGroups[t].vertices+=m;b.geometryGroupsList=[];for(var u in b.geometryGroups)b.geometryGroups[u].id=ca++,b.geometryGroupsList.push(b.geometryGroups[u])}function P(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function L(b){if(b!=da){switch(b){case THREE.AdditiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE);break;case THREE.SubtractiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO, o.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.SRC_COLOR);break;default:o.blendEquationSeparate(o.FUNC_ADD,o.FUNC_ADD),o.blendFuncSeparate(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA)}da=b}}function A(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(o.texParameteri(b,o.TEXTURE_WRAP_S,V(e.wrapS)),o.texParameteri(b,o.TEXTURE_WRAP_T,V(e.wrapT)),o.texParameteri(b,o.TEXTURE_MAG_FILTER,V(e.magFilter)),o.texParameteri(b, o.TEXTURE_MIN_FILTER,V(e.minFilter)),o.generateMipmap(b)):(o.texParameteri(b,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(b,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(b,o.TEXTURE_MAG_FILTER,X(e.magFilter)),o.texParameteri(b,o.TEXTURE_MIN_FILTER,X(e.minFilter)))}function J(b,e){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=o.createTexture(),W.info.memory.textures++;o.activeTexture(o.TEXTURE0+e);o.bindTexture(o.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture? o.texImage2D(o.TEXTURE_2D,0,V(b.format),b.image.width,b.image.height,0,V(b.format),o.UNSIGNED_BYTE,b.image.data):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,b.image);A(o.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+e),o.bindTexture(o.TEXTURE_2D,b.__webglTexture)}function Z(b){var e=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= @@ -281,43 +280,43 @@ this.setClearColor=function(b,e){oa.copy(b);ia=e;o.clearColor(oa.r,oa.g,oa.b,ia) b.geometry.geometryGroups[g];o.deleteBuffer(e.__webglVertexBuffer);o.deleteBuffer(e.__webglNormalBuffer);o.deleteBuffer(e.__webglTangentBuffer);o.deleteBuffer(e.__webglColorBuffer);o.deleteBuffer(e.__webglUVBuffer);o.deleteBuffer(e.__webglUV2Buffer);o.deleteBuffer(e.__webglSkinVertexABuffer);o.deleteBuffer(e.__webglSkinVertexBBuffer);o.deleteBuffer(e.__webglSkinIndicesBuffer);o.deleteBuffer(e.__webglSkinWeightsBuffer);o.deleteBuffer(e.__webglFaceBuffer);o.deleteBuffer(e.__webglLineBuffer);if(e.numMorphTargets)for(var c= 0,f=e.numMorphTargets;c=0&&o.enableVertexAttribArray(w.position);w.color>=0&&o.enableVertexAttribArray(w.color);w.normal>=0&&o.enableVertexAttribArray(w.normal);w.tangent>=0&&o.enableVertexAttribArray(w.tangent);b.skinning&&w.skinVertexA>=0&&w.skinVertexB>=0&&w.skinIndex>=0&&w.skinWeight>=0&&(o.enableVertexAttribArray(w.skinVertexA), o.enableVertexAttribArray(w.skinVertexB),o.enableVertexAttribArray(w.skinIndex),o.enableVertexAttribArray(w.skinWeight));if(b.attributes)for(k in b.attributes)w[k]!==void 0&&w[k]>=0&&o.enableVertexAttribArray(w[k]);if(b.morphTargets)for(k=b.numSupportedMorphTargets=0;k=0&&(o.enableVertexAttribArray(w[K]),b.numSupportedMorphTargets++);b.uniformsList=[];for(h in b.uniforms)b.uniformsList.push([b.uniforms[h],h])};this.clearTarget=function(b,e,c,f){Z(b); -b=0;e&&(b|=o.COLOR_BUFFER_BIT);c&&(b|=o.DEPTH_BUFFER_BIT);f&&(b|=o.STENCIL_BUFFER_BIT);o.clear(b)};this.render=function(b,c,o,t){var K,S,R,E,F,G,A,la,J=b.lights,ja=b.fog;aa=-1;this.shadowMapEnabled&&y(b,c);W.info.render.calls=0;W.info.render.vertices=0;W.info.render.faces=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Aa);c.projectionMatrix.flattenToArray(Ea);Da.multiply(c.projectionMatrix,c.matrixWorldInverse);p(Da);this.initWebGLObjects(b);Z(o); +b=0;e&&(b|=o.COLOR_BUFFER_BIT);c&&(b|=o.DEPTH_BUFFER_BIT);f&&(b|=o.STENCIL_BUFFER_BIT);o.clear(b)};this.render=function(b,c,o,t){var K,S,R,E,F,G,A,la,J=b.lights,ja=b.fog;aa=-1;this.shadowMapEnabled&&y(b,c);W.info.render.calls=0;W.info.render.vertices=0;W.info.render.faces=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Aa);c.projectionMatrix.flattenToArray(Ea);Da.multiply(c.projectionMatrix,c.matrixWorldInverse);u(Da);this.initWebGLObjects(b);Z(o); (this.autoClear||t)&&this.clear();F=b.__webglObjects.length;for(t=0;t=0;t--)if(K=b.__webglObjects[t],K.render){A=K.object;la=K.buffer;R=K.opaque;k(A);for(K=0;K=0;t--)if(K=b.__webglObjects[t],K.render){A=K.object;la=K.buffer;R=K.opaque;h(A);for(K=0;K0||w.faceVertexUvs.length>0)m.__uvArray=new Float32Array(p*2);if(w.faceUvs.length>1||w.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(p*2)}if(n.geometry.skinWeights.length&&n.geometry.skinIndices.length)m.__skinVertexAArray=new Float32Array(p*4),m.__skinVertexBArray=new Float32Array(p*4),m.__skinIndexArray=new Float32Array(p*4),m.__skinWeightArray=new Float32Array(p*4);m.__faceArray=new Uint16Array(y*3+(n.geometry.edgeFaces?n.geometry.edgeFaces.length*6:0));m.__lineArray= -new Uint16Array(z*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];w=0;for(K=m.numMorphTargets;w0||w.faceVertexUvs.length>0)m.__uvArray=new Float32Array(t*2);if(w.faceUvs.length>1||w.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(t*2)}if(n.geometry.skinWeights.length&&n.geometry.skinIndices.length)m.__skinVertexAArray=new Float32Array(t*4),m.__skinVertexBArray=new Float32Array(t*4),m.__skinIndexArray=new Float32Array(t*4),m.__skinWeightArray=new Float32Array(t*4);m.__faceArray=new Uint16Array(y*3+(n.geometry.edgeFaces?n.geometry.edgeFaces.length*6:0));m.__lineArray= +new Uint16Array(z*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];w=0;for(K=m.numMorphTargets;w=0;k--)f[k]==h&&f.splice(k,1)}else e instanceof THREE.MarchingCubes&&G(f.__webglObjectsImmediate,e);e.__webglActive=!1;b.__objectsRemoved.splice(0,1)}e=0;for(f=b.__webglObjects.length;e=0;k--)f[k]==h&&f.splice(k,1)}else e instanceof THREE.MarchingCubes&&G(f.__webglObjectsImmediate,e);e.__webglActive=!1;b.__objectsRemoved.splice(0,1)}e=0;for(f=b.__webglObjects.length;e0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,da,y));Ha&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglNormalBuffer),o.bufferData(o.ARRAY_BUFFER,ka,y));Ka&&na.hasTangents&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglTangentBuffer),o.bufferData(o.ARRAY_BUFFER,ha, -y));Aa&&X>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,va,y));Aa&&ra>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,wa,y));Ba&&(o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t.__webglFaceBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,ua,y),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t.__webglLineBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,xa,y));Q>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,ca,y),o.bindBuffer(o.ARRAY_BUFFER, -t.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,aa,y),o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,ea,y),o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER,fa,y));z&&(delete t.__inittedArrays,delete t.__colorArray,delete t.__normalArray,delete t.__tangentArray,delete t.__uvArray,delete t.__uv2Array,delete t.__faceArray,delete t.__vertexArray,delete t.__lineArray,delete t.__skinVertexAArray,delete t.__skinVertexBArray, -delete t.__skinIndexArray,delete t.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;F(m)}else if(k instanceof THREE.Ribbon){h=k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=o.DYNAMIC_DRAW;n=w=z=z=void 0;u=k.vertices;p=k.colors;v=u.length;t=p.length;K=k.__vertexArray;y=k.__colorArray;S=k.__dirtyColors;if(k.__dirtyVertices){for(z=0;z0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,da,y));Ha&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglNormalBuffer),o.bufferData(o.ARRAY_BUFFER,ka,y));Ka&&na.hasTangents&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglTangentBuffer),o.bufferData(o.ARRAY_BUFFER,ha, +y));Aa&&X>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,va,y));Aa&&ra>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,wa,y));Ba&&(o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,p.__webglFaceBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,ua,y),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,p.__webglLineBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,xa,y));Q>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,ca,y),o.bindBuffer(o.ARRAY_BUFFER, +p.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,aa,y),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,ea,y),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER,fa,y));z&&(delete p.__inittedArrays,delete p.__colorArray,delete p.__normalArray,delete p.__tangentArray,delete p.__uvArray,delete p.__uv2Array,delete p.__faceArray,delete p.__vertexArray,delete p.__lineArray,delete p.__skinVertexAArray,delete p.__skinVertexBArray, +delete p.__skinIndexArray,delete p.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;F(m)}else if(k instanceof THREE.Ribbon){h=k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=o.DYNAMIC_DRAW;n=w=z=z=void 0;v=k.vertices;t=k.colors;u=v.length;p=t.length;K=k.__vertexArray;y=k.__colorArray;S=k.__dirtyColors;if(k.__dirtyVertices){for(z=0;z1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=m;c.v=k;return c}, +THREE.ColorUtils={adjustHSV:function(b,c,e,f){var m=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(b,m);m.h=THREE.ColorUtils.clamp(m.h+c,0,1);m.s=THREE.ColorUtils.clamp(m.s+e,0,1);m.v=THREE.ColorUtils.clamp(m.v+f,0,1);b.setHSV(m.h,m.s,m.v)},rgbToHsv:function(b,c){var e=b.r,f=b.g,m=b.b,h=Math.max(Math.max(e,f),m),k=Math.min(Math.min(e,f),m);if(k==h)k=e=0;else{var n=h-k,k=n/h,e=e==h?(f-m)/n:f==h?2+(m-e)/n:4+(e-f)/n;e/=6;e<0&&(e+=1);e>1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=k;c.v=h;return c}, clamp:function(b,c,e){return be?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; -THREE.GeometryUtils={merge:function(b,c){var e,f,h=b.vertices.length,k=c instanceof THREE.Mesh?c.geometry:c,m=b.vertices,n=k.vertices,u=b.faces,p=k.faces,w=b.faceVertexUvs[0],k=k.faceVertexUvs[0];if(c instanceof THREE.Mesh)c.matrixAutoUpdate&&c.updateMatrix(),e=c.matrix,f=new THREE.Matrix4,f.extractRotation(e,c.scale);for(var t=0,x=n.length;t1&&(f=1-f,h=1-h);k=1-f-h;m.copy(b);m.multiplyScalar(f);n.copy(c);n.multiplyScalar(h);m.addSelf(n);n.copy(e);n.multiplyScalar(k);m.addSelf(n);return m},randomPointInFace:function(b,c,e){var f,h,k;if(b instanceof THREE.Face3)return f=c.vertices[b.a].position,h=c.vertices[b.b].position,k=c.vertices[b.c].position,THREE.GeometryUtils.randomPointInTriangle(f,h,k);else if(b instanceof THREE.Face4){f=c.vertices[b.a].position;h=c.vertices[b.b].position;k=c.vertices[b.c].position;var c=c.vertices[b.d].position, -m;e?b._area1&&b._area2?(e=b._area1,m=b._area2):(e=THREE.GeometryUtils.triangleArea(f,h,c),m=THREE.GeometryUtils.triangleArea(h,k,c),b._area1=e,b._area2=m):(e=THREE.GeometryUtils.triangleArea(f,h,c),m=THREE.GeometryUtils.triangleArea(h,k,c));return THREE.GeometryUtils.random()*(e+m) -b?e(c,h-1):p[h]1&&(f=1-f,m=1-m);h=1-f-m;k.copy(b);k.multiplyScalar(f);n.copy(c);n.multiplyScalar(m);k.addSelf(n);n.copy(e);n.multiplyScalar(h);k.addSelf(n);return k},randomPointInFace:function(b,c,e){var f,m,h;if(b instanceof THREE.Face3)return f=c.vertices[b.a].position,m=c.vertices[b.b].position,h=c.vertices[b.c].position,THREE.GeometryUtils.randomPointInTriangle(f,m,h);else if(b instanceof THREE.Face4){f=c.vertices[b.a].position;m=c.vertices[b.b].position;h=c.vertices[b.c].position;var c=c.vertices[b.d].position, +k;e?b._area1&&b._area2?(e=b._area1,k=b._area2):(e=THREE.GeometryUtils.triangleArea(f,m,c),k=THREE.GeometryUtils.triangleArea(m,h,c),b._area1=e,b._area2=k):(e=THREE.GeometryUtils.triangleArea(f,m,c),k=THREE.GeometryUtils.triangleArea(m,h,c));return THREE.GeometryUtils.random()*(e+k) +b?e(c,h-1):u[h] 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvViewPosition = -mvPosition.xyz;\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 lVector = lPosition.xyz - mvPosition.xyz;\nfloat lDistance = 1.0;\nif ( pointLightDistance[ i ] > 0.0 )\nlDistance = 1.0 - min( ( length( lVector ) / pointLightDistance[ i ] ), 1.0 );\nlVector = normalize( lVector );\nvPointLight[ i ] = vec4( lVector, lDistance );\n}\n#endif\n#ifdef VERTEX_TEXTURES\nvec3 dv = texture2D( tDisplacement, uv ).xyz;\nfloat df = uDisplacementScale * dv.x + uDisplacementBias;\nvec4 displacedPosition = vec4( vNormal.xyz * df, 0.0 ) + mvPosition;\ngl_Position = projectionMatrix * displacedPosition;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif\n}"}, cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec3 vViewPosition;\nvoid main() {\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvViewPosition = cameraPosition - mPosition.xyz;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vViewPosition;\nvoid main() {\nvec3 wPos = cameraPosition - vViewPosition;\ngl_FragColor = textureCube( tCube, vec3( - wPos.x, wPos.yz ) );\n}"}}}; THREE.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(b){return this.getPoint(this.getUtoTmapping(b))};THREE.Curve.prototype.getPoints=function(b){b||(b=5);var c,e=[];for(c=0;c<=b;c++)e.push(this.getPoint(c/b));return e};THREE.Curve.prototype.getSpacedPoints=function(b){b||(b=5);var c,e=[];for(c=0;c<=b;c++)e.push(this.getPointAt(c/b));return e}; -THREE.Curve.prototype.getLength=function(){var b=this.getLengths();return b[b.length-1]};THREE.Curve.prototype.getLengths=function(b){b||(b=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==b+1)return this.cacheArcLengths;var c=[],e,f=this.getPoint(0),h,k=0;c.push(0);for(h=1;h<=b;h++)e=this.getPoint(h/b),k+=e.distanceTo(f),c.push(k),f=e;return this.cacheArcLengths=c}; -THREE.Curve.prototype.getUtoTmapping=function(b,c){var e=this.getLengths(),f=0,h=e.length,k;k=c?c:b*e[h-1];time=Date.now();for(var m=0,n=h-1,u;m<=n;)if(f=Math.floor(m+(n-m)/2),u=e[f]-k,u<0)m=f+1;else if(u>0)n=f-1;else{n=f;break}f=n;if(e[f]==k)return f/(h-1);m=e[f];return e=(f+(k-m)/(e[f+1]-m))/(h-1)};THREE.Curve.prototype.getNormalVector=function(b){b=this.getTangent(b);return new THREE.Vector2(-b.y,b.x)}; +THREE.Curve.prototype.getLength=function(){var b=this.getLengths();return b[b.length-1]};THREE.Curve.prototype.getLengths=function(b){b||(b=200);if(this.cacheArcLengths&&this.cacheArcLengths.length==b+1)return this.cacheArcLengths;var c=[],e,f=this.getPoint(0),m,h=0;c.push(0);for(m=1;m<=b;m++)e=this.getPoint(m/b),h+=e.distanceTo(f),c.push(h),f=e;return this.cacheArcLengths=c}; +THREE.Curve.prototype.getUtoTmapping=function(b,c){var e=this.getLengths(),f=0,m=e.length,h;h=c?c:b*e[m-1];time=Date.now();for(var k=0,n=m-1,p;k<=n;)if(f=Math.floor(k+(n-k)/2),p=e[f]-h,p<0)k=f+1;else if(p>0)n=f-1;else{n=f;break}f=n;if(e[f]==h)return f/(m-1);k=e[f];return e=(f+(h-k)/(e[f+1]-k))/(m-1)};THREE.Curve.prototype.getNormalVector=function(b){b=this.getTangent(b);return new THREE.Vector2(-b.y,b.x)}; THREE.Curve.prototype.getTangent=function(b){var c=b-1.0E-4;b+=1.0E-4;c<0&&(c=0);b>1&&(b=1);var c=this.getPoint(c),b=this.getPoint(b),e=new THREE.Vector2;e.sub(b,c);return e.unit()};THREE.LineCurve=function(b,c){b instanceof THREE.Vector2?(this.v1=b,this.v2=c):THREE.LineCurve.oldConstructor.apply(this,arguments)};THREE.LineCurve.oldConstructor=function(b,c,e,f){this.constructor(new THREE.Vector2(b,c),new THREE.Vector2(e,f))};THREE.LineCurve.prototype=new THREE.Curve; THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(b){var c=new THREE.Vector2;c.sub(this.v2,this.v1);c.multiplyScalar(b).addSelf(this.v1);return c};THREE.LineCurve.prototype.getPointAt=function(b){return this.getPoint(b)};THREE.LineCurve.prototype.getTangent=function(){var b=new THREE.Vector2;b.sub(this.v2,this.v1);b.normalize();return b}; THREE.QuadraticBezierCurve=function(b,c,e){if(!(c instanceof THREE.Vector2))var f=Array.prototype.slice.call(arguments),b=new THREE.Vector2(f[0],f[1]),c=new THREE.Vector2(f[2],f[3]),e=new THREE.Vector2(f[4],f[5]);this.v0=b;this.v1=c;this.v2=e};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve; THREE.QuadraticBezierCurve.prototype.getPoint=function(b){var c;c=THREE.Shape.Utils.b2(b,this.v0.x,this.v1.x,this.v2.x);b=THREE.Shape.Utils.b2(b,this.v0.y,this.v1.y,this.v2.y);return new THREE.Vector2(c,b)};THREE.QuadraticBezierCurve.prototype.getTangent=function(b){var c;c=THREE.Curve.Utils.tangentQuadraticBezier(b,this.v0.x,this.v1.x,this.v2.x);b=THREE.Curve.Utils.tangentQuadraticBezier(b,this.v0.y,this.v1.y,this.v2.y);c=new THREE.Vector2(c,b);c.normalize();return c}; -THREE.CubicBezierCurve=function(b,c,e,f){if(!(c instanceof THREE.Vector2))var h=Array.prototype.slice.call(arguments),b=new THREE.Vector2(h[0],h[1]),c=new THREE.Vector2(h[2],h[3]),e=new THREE.Vector2(h[4],h[5]),f=new THREE.Vector2(h[6],h[7]);this.v0=b;this.v1=c;this.v2=e;this.v3=f};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve; +THREE.CubicBezierCurve=function(b,c,e,f){if(!(c instanceof THREE.Vector2))var m=Array.prototype.slice.call(arguments),b=new THREE.Vector2(m[0],m[1]),c=new THREE.Vector2(m[2],m[3]),e=new THREE.Vector2(m[4],m[5]),f=new THREE.Vector2(m[6],m[7]);this.v0=b;this.v1=c;this.v2=e;this.v3=f};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve; THREE.CubicBezierCurve.prototype.getPoint=function(b){var c;c=THREE.Shape.Utils.b3(b,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b=THREE.Shape.Utils.b3(b,this.v0.y,this.v1.y,this.v2.y,this.v3.y);return new THREE.Vector2(c,b)};THREE.CubicBezierCurve.prototype.getTangent=function(b){var c;c=THREE.Curve.Utils.tangentCubicBezier(b,this.v0.x,this.v1.x,this.v2.x,this.v3.x);b=THREE.Curve.Utils.tangentCubicBezier(b,this.v0.y,this.v1.y,this.v2.y,this.v3.y);c=new THREE.Vector2(c,b);c.normalize();return c}; THREE.SplineCurve=function(b){this.points=b};THREE.SplineCurve.prototype=new THREE.Curve;THREE.SplineCurve.prototype.constructor=THREE.SplineCurve; -THREE.SplineCurve.prototype.getPoint=function(b){var c=new THREE.Vector2,e=[],f=this.points,h;h=(f.length-1)*b;b=Math.floor(h);h-=b;e[0]=b==0?b:b-1;e[1]=b;e[2]=b>f.length-2?b:b+1;e[3]=b>f.length-3?b:b+2;c.x=THREE.Curve.Utils.interpolate(f[e[0]].x,f[e[1]].x,f[e[2]].x,f[e[3]].x,h);c.y=THREE.Curve.Utils.interpolate(f[e[0]].y,f[e[1]].y,f[e[2]].y,f[e[3]].y,h);return c};THREE.ArcCurve=function(b,c,e,f,h,k){this.aX=b;this.aY=c;this.aRadius=e;this.aStartAngle=f;this.aEndAngle=h;this.aClockwise=k}; +THREE.SplineCurve.prototype.getPoint=function(b){var c=new THREE.Vector2,e=[],f=this.points,m;m=(f.length-1)*b;b=Math.floor(m);m-=b;e[0]=b==0?b:b-1;e[1]=b;e[2]=b>f.length-2?b:b+1;e[3]=b>f.length-3?b:b+2;c.x=THREE.Curve.Utils.interpolate(f[e[0]].x,f[e[1]].x,f[e[2]].x,f[e[3]].x,m);c.y=THREE.Curve.Utils.interpolate(f[e[0]].y,f[e[1]].y,f[e[2]].y,f[e[3]].y,m);return c};THREE.ArcCurve=function(b,c,e,f,m,h){this.aX=b;this.aY=c;this.aRadius=e;this.aStartAngle=f;this.aEndAngle=m;this.aClockwise=h}; THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(b){var c=this.aEndAngle-this.aStartAngle;this.aClockwise||(b=1-b);b=this.aStartAngle+b*c;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(b),this.aY+this.aRadius*Math.sin(b))}; -THREE.Curve.Utils={tangentQuadraticBezier:function(b,c,e,f){return 2*(1-b)*(e-c)+2*b*(f-e)},tangentCubicBezier:function(b,c,e,f,h){return-3*c*(1-b)*(1-b)+3*e*(1-b)*(1-b)-6*b*e*(1-b)+6*b*f*(1-b)-3*b*b*f+3*b*b*h},tangentSpline:function(b){return 6*b*b-6*b+(3*b*b-4*b+1)+(-6*b*b+6*b)+(3*b*b-2*b)},interpolate:function(b,c,e,f,h){var b=(e-b)*0.5,f=(f-c)*0.5,k=h*h;return(2*c-2*e+b+f)*h*k+(-3*c+3*e-2*b-f)*k+b*h+c}}; +THREE.Curve.Utils={tangentQuadraticBezier:function(b,c,e,f){return 2*(1-b)*(e-c)+2*b*(f-e)},tangentCubicBezier:function(b,c,e,f,m){return-3*c*(1-b)*(1-b)+3*e*(1-b)*(1-b)-6*b*e*(1-b)+6*b*f*(1-b)-3*b*b*f+3*b*b*m},tangentSpline:function(b){return 6*b*b-6*b+(3*b*b-4*b+1)+(-6*b*b+6*b)+(3*b*b-2*b)},interpolate:function(b,c,e,f,m){var b=(e-b)*0.5,f=(f-c)*0.5,h=m*m;return(2*c-2*e+b+f)*m*h+(-3*c+3*e-2*b-f)*h+b*m+c}}; THREE.Curve.create=function(b,c){b.prototype=new THREE.Curve;b.prototype.constructor=b;b.prototype.getPoint=c;return b};THREE.LineCurve3=THREE.Curve.create(function(b,c){this.v1=b;this.v2=c},function(b){var c=new THREE.Vector3;c.sub(v2,v1);c.multiplyScalar(b);c.addSelf(this.v1);return c}); THREE.QuadraticBezierCurve3=THREE.Curve.create(function(b,c,e){this.v0=b;this.v1=c;this.v2=e},function(b){var c,e;c=THREE.Shape.Utils.b2(b,this.v0.x,this.v1.x,this.v2.x);e=THREE.Shape.Utils.b2(b,this.v0.y,this.v1.y,this.v2.y);b=THREE.Shape.Utils.b2(b,this.v0.z,this.v1.z,this.v2.z);return new THREE.Vector3(c,e,b)}); THREE.CubicBezierCurve3=THREE.Curve.create(function(b,c,e,f){this.v0=b;this.v1=c;this.v2=e;this.v3=f},function(b){var c,e;c=THREE.Shape.Utils.b3(b,this.v0.x,this.v1.x,this.v2.x,this.v3.x);e=THREE.Shape.Utils.b3(b,this.v0.y,this.v1.y,this.v2.y,this.v3.y);b=THREE.Shape.Utils.b3(b,this.v0.z,this.v1.z,this.v2.z,this.v3.z);return new THREE.Vector3(c,e,b)}); -THREE.SplineCurve3=THREE.Curve.create(function(b){this.points=b},function(b){var c=new THREE.Vector3,e=[],f=this.points,h;h=(f.length-1)*b;b=Math.floor(h);h-=b;e[0]=b==0?b:b-1;e[1]=b;e[2]=b>f.length-2?b:b+1;e[3]=b>f.length-3?b:b+2;c.x=THREE.Curve.Utils.interpolate(f[e[0]].x,f[e[1]].x,f[e[2]].x,f[e[3]].x,h);c.y=THREE.Curve.Utils.interpolate(f[e[0]].y,f[e[1]].y,f[e[2]].y,f[e[3]].y,h);c.z=THREE.Curve.Utils.interpolate(f[e[0]].z,f[e[1]].z,f[e[2]].z,f[e[3]].z,h);return c}); +THREE.SplineCurve3=THREE.Curve.create(function(b){this.points=b},function(b){var c=new THREE.Vector3,e=[],f=this.points,m;m=(f.length-1)*b;b=Math.floor(m);m-=b;e[0]=b==0?b:b-1;e[1]=b;e[2]=b>f.length-2?b:b+1;e[3]=b>f.length-3?b:b+2;c.x=THREE.Curve.Utils.interpolate(f[e[0]].x,f[e[1]].x,f[e[2]].x,f[e[3]].x,m);c.y=THREE.Curve.Utils.interpolate(f[e[0]].y,f[e[1]].y,f[e[2]].y,f[e[3]].y,m);c.z=THREE.Curve.Utils.interpolate(f[e[0]].z,f[e[1]].z,f[e[2]].z,f[e[3]].z,m);return c}); THREE.CurvePath=function(){this.curves=[];this.bends=[]};THREE.CurvePath.prototype=new THREE.Curve;THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(b){this.curves.push(b)};THREE.CurvePath.prototype.checkConnection=function(){};THREE.CurvePath.prototype.closePath=function(){}; THREE.CurvePath.prototype.getPoint=function(b){for(var c=b*this.getLength(),e=this.getCurveLengths(),b=0;b=c)return c=e[b]-c,b=this.curves[b],c=1-c/b.getLength(),b.getPointAt(c);b++}return null};THREE.CurvePath.prototype.getLength=function(){var b=this.getCurveLengths();return b[b.length-1]}; THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length==this.curves.length)return this.cacheLengths;var b=[],c=0,e,f=this.curves.length;for(e=0;ec)c=k.x;else if(k.xe)e=k.y;else if(k.yc)c=h.x;else if(h.xe)e=h.y;else if(h.y0?(m=e[e.length-1],v=m.x,z=m.y):(m=this.actions[f-1].args,v=m[m.length-2],z=m[m.length-1]);for(m=1;m<=b;m++)y=m/b,k=THREE.Shape.Utils.b2(y,v,t,n),y=THREE.Shape.Utils.b2(y,z,x, -u),e.push(new THREE.Vector2(k,y));break;case THREE.PathActions.BEZIER_CURVE_TO:n=k[4];u=k[5];t=k[0];x=k[1];p=k[2];w=k[3];e.length>0?(m=e[e.length-1],v=m.x,z=m.y):(m=this.actions[f-1].args,v=m[m.length-2],z=m[m.length-1]);for(m=1;m<=b;m++)y=m/b,k=THREE.Shape.Utils.b3(y,v,t,p,n),y=THREE.Shape.Utils.b3(y,z,x,w,u),e.push(new THREE.Vector2(k,y));break;case THREE.PathActions.CSPLINE_THRU:m=this.actions[f-1].args;m=[new THREE.Vector2(m[m.length-2],m[m.length-1])];y=b*k[0].length;m=m.concat(k[0]);k=new THREE.SplineCurve(m); -for(m=1;m<=y;m++)e.push(k.getPointAt(m/y));break;case THREE.PathActions.ARC:m=this.actions[f-1].args;n=k[0];u=k[1];p=k[2];t=k[3];y=k[4];x=!!k[5];w=m[m.length-2];v=m[m.length-1];m.length==0&&(w=v=0);z=y-t;var B=b*2;for(m=1;m<=B;m++)y=m/B,x||(y=1-y),y=t+y*z,k=w+n+p*Math.cos(y),y=v+u+p*Math.sin(y),e.push(new THREE.Vector2(k,y))}c&&e.push(e[0]);return e};THREE.Path.prototype.transform=function(b,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),b)}; -THREE.Path.prototype.nltransform=function(b,c,e,f,h,k){var m=this.getPoints(),n,u,p,w,t;n=0;for(u=m.length;n0?(k=e[e.length-1],v=k.x,z=k.y):(k=this.actions[f-1].args,v=k[k.length-2],z=k[k.length-1]);for(k=1;k<=b;k++)y=k/b,h=THREE.Shape.Utils.b2(y,v,t,n),y=THREE.Shape.Utils.b2(y,z,x, +p),e.push(new THREE.Vector2(h,y));break;case THREE.PathActions.BEZIER_CURVE_TO:n=h[4];p=h[5];t=h[0];x=h[1];u=h[2];w=h[3];e.length>0?(k=e[e.length-1],v=k.x,z=k.y):(k=this.actions[f-1].args,v=k[k.length-2],z=k[k.length-1]);for(k=1;k<=b;k++)y=k/b,h=THREE.Shape.Utils.b3(y,v,t,u,n),y=THREE.Shape.Utils.b3(y,z,x,w,p),e.push(new THREE.Vector2(h,y));break;case THREE.PathActions.CSPLINE_THRU:k=this.actions[f-1].args;k=[new THREE.Vector2(k[k.length-2],k[k.length-1])];y=b*h[0].length;k=k.concat(h[0]);h=new THREE.SplineCurve(k); +for(k=1;k<=y;k++)e.push(h.getPointAt(k/y));break;case THREE.PathActions.ARC:k=this.actions[f-1].args;n=h[0];p=h[1];u=h[2];t=h[3];y=h[4];x=!!h[5];w=k[k.length-2];v=k[k.length-1];k.length==0&&(w=v=0);z=y-t;var B=b*2;for(k=1;k<=B;k++)y=k/B,x||(y=1-y),y=t+y*z,h=w+n+u*Math.cos(y),y=v+p+u*Math.sin(y),e.push(new THREE.Vector2(h,y))}c&&e.push(e[0]);return e};THREE.Path.prototype.transform=function(b,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),b)}; +THREE.Path.prototype.nltransform=function(b,c,e,f,m,h){var k=this.getPoints(),n,p,u,w,t;n=0;for(p=k.length;n=0?n-1:e.length-1;k=m-1>=0?m-1:p.length-1;var y=[p[m],e[n],e[h]];t=THREE.FontUtils.Triangulate.area(y);var B=[p[m],p[k],e[n]];x=THREE.FontUtils.Triangulate.area(B);v=n;w=m;n+=1;m+=-1;n< -0&&(n+=e.length);n%=e.length;m<0&&(m+=p.length);m%=p.length;h=n-1>=0?n-1:e.length-1;k=m-1>=0?m-1:p.length-1;y=[p[m],e[n],e[h]];y=THREE.FontUtils.Triangulate.area(y);B=[p[m],p[k],e[n]];B=THREE.FontUtils.Triangulate.area(B);t+x>y+B&&(n=v,m=w,n<0&&(n+=e.length),n%=e.length,m<0&&(m+=p.length),m%=p.length,h=n-1>=0?n-1:e.length-1,k=m-1>=0?m-1:p.length-1);t=e.slice(0,n);x=e.slice(n);v=p.slice(m);w=p.slice(0,m);k=[p[m],p[k],e[n]];z.push([p[m],e[n],e[h]]);z.push(k);e=t.concat(v).concat(w).concat(x)}return{shape:e, -isolatedPts:z,allpoints:f}},triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,h=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),k,m,n,u,p={};k=0;for(m=f.length;k=0?n-1:e.length-1;h=k-1>=0?k-1:u.length-1;var y=[u[k],e[n],e[m]];t=THREE.FontUtils.Triangulate.area(y);var B=[u[k],u[h],e[n]];x=THREE.FontUtils.Triangulate.area(B);v=n;w=k;n+=1;k+=-1;n< +0&&(n+=e.length);n%=e.length;k<0&&(k+=u.length);k%=u.length;m=n-1>=0?n-1:e.length-1;h=k-1>=0?k-1:u.length-1;y=[u[k],e[n],e[m]];y=THREE.FontUtils.Triangulate.area(y);B=[u[k],u[h],e[n]];B=THREE.FontUtils.Triangulate.area(B);t+x>y+B&&(n=v,k=w,n<0&&(n+=e.length),n%=e.length,k<0&&(k+=u.length),k%=u.length,m=n-1>=0?n-1:e.length-1,h=k-1>=0?k-1:u.length-1);t=e.slice(0,n);x=e.slice(n);v=u.slice(k);w=u.slice(0,k);h=[u[k],u[h],e[n]];z.push([u[k],e[n],e[m]]);z.push(h);e=t.concat(v).concat(w).concat(x)}return{shape:e, +isolatedPts:z,allpoints:f}},triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,m=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),h,k,n,p,u={};h=0;for(k=f.length;h1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+v),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=h[0]+(k[0]-h[0])*f,e.y=h[1]+(k[1]-h[1])*f,e.z=h[2]+(k[2]-h[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= -this.getPrevKeyWith("pos",v,m.index-1).pos,this.points[1]=h,this.points[2]=k,this.points[3]=this.getNextKeyWith("pos",v,n.index+1).pos,f=f*0.33+0.33,h=this.interpolateCatmullRom(this.points,f),e.x=h[0],e.y=h[1],e.z=h[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)f=this.interpolateCatmullRom(this.points,f*1.01),this.target.set(f[0],f[1],f[2]),this.target.subSelf(e),this.target.y=0,this.target.normalize(),f=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,f,0)}else if(e=== -"rot")THREE.Quaternion.slerp(h,k,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=h[0]+(k[0]-h[0])*f,e.y=h[1]+(k[1]-h[1])*f,e.z=h[2]+(k[2]-h[2])*f}}if(this.JITCompile&&w[0][p]===void 0){this.hierarchy[0].update(void 0,!0);for(v=0;vb.length-2?k:k+1;e[3]=k>b.length-3?k:k+2;k=b[e[0]];n=b[e[1]];u=b[e[2]];p=b[e[3]];e=h*h;m=h*e;f[0]=this.interpolate(k[0],n[0],u[0],p[0],h,e,m);f[1]=this.interpolate(k[1],n[1],u[1],p[1],h,e,m);f[2]=this.interpolate(k[2],n[2],u[2],p[2],h,e,m);return f}; -THREE.Animation.prototype.interpolate=function(b,c,e,f,h,k,m){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*m+(-3*(c-e)-2*b-f)*k+b*h+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,e){var f=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e=e1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+v),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=m[0]+(h[0]-m[0])*f,e.y=m[1]+(h[1]-m[1])*f,e.z=m[2]+(h[2]-m[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= +this.getPrevKeyWith("pos",v,k.index-1).pos,this.points[1]=m,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",v,n.index+1).pos,f=f*0.33+0.33,m=this.interpolateCatmullRom(this.points,f),e.x=m[0],e.y=m[1],e.z=m[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)f=this.interpolateCatmullRom(this.points,f*1.01),this.target.set(f[0],f[1],f[2]),this.target.subSelf(e),this.target.y=0,this.target.normalize(),f=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,f,0)}else if(e=== +"rot")THREE.Quaternion.slerp(m,h,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=m[0]+(h[0]-m[0])*f,e.y=m[1]+(h[1]-m[1])*f,e.z=m[2]+(h[2]-m[2])*f}}if(this.JITCompile&&w[0][u]===void 0){this.hierarchy[0].update(void 0,!0);for(v=0;vb.length-2?h:h+1;e[3]=h>b.length-3?h:h+2;h=b[e[0]];n=b[e[1]];p=b[e[2]];u=b[e[3]];e=m*m;k=m*e;f[0]=this.interpolate(h[0],n[0],p[0],u[0],m,e,k);f[1]=this.interpolate(h[1],n[1],p[1],u[1],m,e,k);f[2]=this.interpolate(h[2],n[2],p[2],u[2],m,e,k);return f}; +THREE.Animation.prototype.interpolate=function(b,c,e,f,m,h,k){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*k+(-3*(c-e)-2*b-f)*h+b*m+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,e){var f=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e=e0?e:0:e>=0?e:e+f.length;e>=0;e--)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[f.length-1]}; THREE.CubeCamera=function(b,c,e,f){this.cameraPX=new THREE.Camera(90,1,b,c);this.cameraNX=new THREE.Camera(90,1,b,c);this.cameraPY=new THREE.Camera(90,1,b,c);this.cameraNY=new THREE.Camera(90,1,b,c);this.cameraPZ=new THREE.Camera(90,1,b,c);this.cameraNZ=new THREE.Camera(90,1,b,c);this.height=e;this.position=new THREE.Vector3(0,e,0);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position=this.position;this.cameraNY.position=this.position;this.cameraPZ.position= this.position;this.cameraNZ.position=this.position;this.cameraPY.up.set(0,0,1);this.cameraPZ.up.set(0,-1,0);this.cameraNZ.up.set(0,-1,0);this.renderTarget=new THREE.WebGLRenderTargetCube(f,f,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updatePosition=function(b){this.position.x=b.x;this.position.z=b.z;this.cameraPX.target.position.add(this.position,new THREE.Vector3(-1,0,0));this.cameraNX.target.position.add(this.position,new THREE.Vector3(1,0,0));this.cameraPY.target.position.add(this.position, @@ -437,144 +436,144 @@ this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this !1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.domElement===document?(this.mouseX=b.pageX-this.viewHalfX,this.mouseY=b.pageY-this.viewHalfY):(this.mouseX=b.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=b.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp= !0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=!1;break;case 70:this.moveDown=!1}};this.update=function(){var b=(new Date).getTime();this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?this.tdiff* ((this.position.ythis.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.translateZ(c);this.moveLeft&&this.translateX(-c);this.moveRight&&this.translateX(c);this.moveUp&&this.translateY(c);this.moveDown&&this.translateY(-c);c=this.tdiff*this.lookSpeed;this.activeLook|| -(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target.position,h=this.position;b.x=h.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=h.y+100*Math.cos(this.phi);b.z=h.z+100*Math.sin(this.phi)*Math.sin(this.theta)}b=1;this.constrainVertical&&(b=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY* -c*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/(Math.PI-0)+this.verticalMin;b=this.target.position;h=this.position;b.x=h.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=h.y+100*Math.cos(this.phi);b.z=h.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()}, +(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target.position,m=this.position;b.x=m.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=m.y+100*Math.cos(this.phi);b.z=m.z+100*Math.sin(this.phi)*Math.sin(this.theta)}b=1;this.constrainVertical&&(b=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY* +c*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/(Math.PI-0)+this.verticalMin;b=this.target.position;m=this.position;b.x=m.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=m.y+100*Math.cos(this.phi);b.z=m.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()}, !1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera; THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;THREE.FirstPersonCamera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(b));this.target.position.addSelf(c.multiplyScalar(b))}; -THREE.PathCamera=function(b){function c(b,e,c,f){var h={name:c,fps:0.6,length:f,hierarchy:[]},k,m=e.getControlPointsArray(),n=e.getLength(),u=m.length,E=0;k=u-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:m[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[k]={time:f,pos:m[k],rot:[0,0,0,1],scl:[1,1,1]};for(k=1;k=0?f:f+h;f=this.verticalAngleMap.srcRange;m=this.verticalAngleMap.dstRange;var n=m[1]-m[0];this.phi=TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(m[1]-m[0])/(f[1]-f[0])+m[0]-m[0])/n)*n+m[0];f=this.horizontalAngleMap.srcRange;m=this.horizontalAngleMap.dstRange;n=m[1]-m[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(m[1]-m[0])/(f[1]-f[0])+m[0]-m[0])/n)*n+m[0];f=this.target.position; +this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));var m=Math.PI*2,h=Math.PI/180;this.update=function(b,e,c){var f,k;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85, +Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;f=this.phi%m;this.phi=f>=0?f:f+m;f=this.verticalAngleMap.srcRange;k=this.verticalAngleMap.dstRange;var n=k[1]-k[0];this.phi=TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(k[1]-k[0])/(f[1]-f[0])+k[0]-k[0])/n)*n+k[0];f=this.horizontalAngleMap.srcRange;k=this.horizontalAngleMap.dstRange;n=k[1]-k[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(k[1]-k[0])/(f[1]-f[0])+k[0]-k[0])/n)*n+k[0];f=this.target.position; f.x=100*Math.sin(this.phi)*Math.cos(this.theta);f.y=100*Math.cos(this.phi);f.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,e,c)};this.onMouseMove=function(b){this.domElement===document?(this.mouseX=b.pageX-this.viewHalfX,this.mouseY=b.pageY-this.viewHalfY):(this.mouseX=b.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=b.pageY-this.domElement.offsetTop-this.viewHalfY)};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&& -this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),m=new THREE.MeshLambertMaterial({color:65280}),n=new THREE.CubeGeometry(10,10,20),u=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(n,b);b=new THREE.Mesh(u,m);b.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else this.animation= +this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),k=new THREE.MeshLambertMaterial({color:65280}),n=new THREE.CubeGeometry(10,10,20),p=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(n,b);b=new THREE.Mesh(p,k);b.position.set(0,10,0);this.animation=c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else this.animation= c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,e){return function(){e.apply(b,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; THREE.FlyCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.domElement=document;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==void 0)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==void 0)this.dragToLook=b.dragToLook;if(b.autoForward!==void 0)this.autoForward= b.autoForward;if(b.domElement!==void 0)this.domElement=b.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.domElement!==document&&this.domElement.setAttribute("tabindex",-1);this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)}; this.keydown=function(b){if(!b.altKey){switch(b.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft= 1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(b){switch(b.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft= 0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(b){this.domElement!==document&&this.domElement.focus();b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var c=this.getContainerDimensions(), -h=c.size[0]/2,k=c.size[1]/2;this.moveState.yawLeft=-(b.pageX-c.offset[0]-h)/h;this.moveState.pitchDown=(b.pageY-c.offset[1]-k)/k;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate= +m=c.size[0]/2,h=c.size[1]/2;this.moveState.yawLeft=-(b.pageX-c.offset[0]-m)/m;this.moveState.pitchDown=(b.pageY-c.offset[1]-h)/h;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate= b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;var b=this.tdiff*this.movementSpeed,c=this.tdiff*this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVector.y*b);this.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*c,this.rotationVector.y*c,this.rotationVector.z*c,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate= !0;this.supr.update.call(this)};this.updateMovementVector=function(){var b=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z= -this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this, this.mouseup),!1);this.domElement.addEventListener("keydown",c(this,this.keydown),!1);this.domElement.addEventListener("keyup",c(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype; -THREE.RollCamera=function(b,c,e,f){THREE.Camera.call(this,b,c,e,f);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var h=new THREE.Vector3,k=new THREE.Vector3,m=new THREE.Vector3,n=new THREE.Matrix4,u=!1,p=1,w=0,t=0,x=0,v=0,z=0,y=window.innerWidth/2,B=window.innerHeight/2;this.update= -function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.delta=(b-this.lastUpdate)/1E3;this.lastUpdate=b;this.mouseLook&&(b=this.delta*this.lookSpeed,this.rotateHorizontally(b*v),this.rotateVertically(b*z));b=this.delta*this.movementSpeed;this.translateZ(b*(w>0||this.autoForward&&!(w<0)?1:w));this.translateX(b*t);this.translateY(b*x);u&&(this.roll+=this.rollSpeed*this.delta*p);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); -else if(this.forward.y0||this.autoForward&&!(w<0)?1:w));this.translateX(b*t);this.translateY(b*x);p&&(this.roll+=this.rollSpeed*this.delta*u);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); +else if(this.forward.y1?e.normalize():e.z=Math.sqrt(1-f*f);h=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(e.y);f.addSelf(this.up.clone().crossSelf(h).setLength(e.x));f.addSelf(h.setLength(e.z));return f}; -this.rotateCamera=function(){var b=Math.acos(k.dot(m)/k.length()/m.length());if(b){var c=(new THREE.Vector3).cross(k,m).normalize(),e=new THREE.Quaternion;b*=this.rotateSpeed;e.setFromAxisAngle(c,-b);e.multiplyVector3(h);e.multiplyVector3(this.up);e.multiplyVector3(m);this.staticMoving?k=m:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(k))}};this.zoomCamera=function(){var b=1+(u.y-n.y)*this.zoomSpeed;b!==1&&b>0&&(h.multiplyScalar(b),this.staticMoving?n=u:n.y+=(u.y-n.y)*this.dynamicDampingFactor)}; -this.panCamera=function(){var b=w.clone().subSelf(p);if(b.lengthSq()){b.multiplyScalar(h.length()*this.panSpeed);var c=h.clone().crossSelf(this.up).setLength(b.x);c.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?p=w:p.addSelf(b.sub(w,p).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), -h.lengthSq()1?c.normalize():c.z=Math.sqrt(1-f*f);m=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(c.y);f.addSelf(this.up.clone().crossSelf(m).setLength(c.x));f.addSelf(m.setLength(c.z));return f}; +this.rotateCamera=function(){var b=Math.acos(h.dot(k)/h.length()/k.length());if(b){var e=(new THREE.Vector3).cross(h,k).normalize(),c=new THREE.Quaternion;b*=this.rotateSpeed;c.setFromAxisAngle(e,-b);c.multiplyVector3(m);c.multiplyVector3(this.up);c.multiplyVector3(k);this.staticMoving?h=k:(c.setFromAxisAngle(e,b*(this.dynamicDampingFactor-1)),c.multiplyVector3(h))}};this.zoomCamera=function(){var b=1+(p.y-n.y)*this.zoomSpeed;b!==1&&b>0&&(m.multiplyScalar(b),this.staticMoving?n=p:n.y+=(p.y-n.y)*this.dynamicDampingFactor)}; +this.panCamera=function(){var b=w.clone().subSelf(u);if(b.lengthSq()){b.multiplyScalar(m.length()*this.panSpeed);var c=m.clone().crossSelf(this.up).setLength(b.x);c.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?u=w:u.addSelf(b.sub(w,u).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), +m.lengthSq()0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,m,0)));for(n=0;n0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-m,0)));for(n=0;n0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,k,0)));for(n=0;n0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-k,0)));for(n=0;nb&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(m).addSelf(n).subSelf(b).clone()}function h(b){for(I=b.length;--I>=0;){qa=I;fa=I-1;fa<0&&(fa=b.length- -1);for(var c=0,e=v+w*2,c=0;c=0;X--){V=X/w;W=u*(1-V);V=p*Math.sin(V*Math.PI/2);I=0;for(O=E.length;Ib&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(m).addSelf(n).subSelf(b).clone()}function m(b){for(I=b.length;--I>=0;){qa=I;fa=I-1;fa<0&&(fa=b.length- +1);for(var c=0,e=v+w*2,c=0;c=0;X--){V=X/w;W=p*(1-V);V=u*Math.sin(V*Math.PI/2);I=0;for(O=E.length;I0||(w=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,n,x)))-1);p.push(w)}c.push(p)}for(var v,z,y,h=c.length,e=0;e0)for(f=0;f1&&(v= -this.vertices[m].position.clone(),z=this.vertices[u].position.clone(),y=this.vertices[p].position.clone(),v.normalize(),z.normalize(),y.normalize(),this.faces.push(new THREE.Face3(m,u,p,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(y.x,y.y,y.z)])),this.faceVertexUvs[0].push([w,t,B]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry; +THREE.SphereGeometry=function(b,c,e){THREE.Geometry.call(this);for(var b=b||50,f,m=Math.PI,h=Math.max(3,c||8),k=Math.max(2,e||6),c=[],e=0;e0||(w=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,n,x)))-1);u.push(w)}c.push(u)}for(var v,z,y,m=c.length,e=0;e0)for(f=0;f1&&(v= +this.vertices[k].position.clone(),z=this.vertices[p].position.clone(),y=this.vertices[u].position.clone(),v.normalize(),z.normalize(),y.normalize(),this.faces.push(new THREE.Face3(k,p,u,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(y.x,y.y,y.z)])),this.faceVertexUvs[0].push([w,t,B]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry; THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry; THREE.TextGeometry=function(b,c){var e=(new THREE.TextPath(b,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;if(c.bend){var f=e[e.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(f/2,120),new THREE.Vector2(f,0))}THREE.ExtrudeGeometry.call(this,e,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry; THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(b,c){return(new TextPath(b,c)).toShapes()},loadFace:function(b){var c=b.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][b.cssFontWeight]=this.faces[c][b.cssFontWeight]||{};this.faces[c][b.cssFontWeight][b.cssFontStyle]=b;return this.faces[c][b.cssFontWeight][b.cssFontStyle]=b},drawText:function(b){for(var c= -this.getFace(),e=this.size/c.resolution,f=0,h=String(b).split(""),k=h.length,m=[],b=0;b0)for(p=0;p2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return n;return k}u=p;h<=u&&(u=0);p=u+1;h<=p&&(p=0);w=p+1;h<=w&&(w=0);var x;a:{x=b;var v=u,z=p,y=w,B=h,C=m,E=void 0,F=void 0,G=void 0, +this.getFace(),e=this.size/c.resolution,f=0,m=String(b).split(""),h=m.length,k=[],b=0;b0)for(u=0;u2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return n;return h}p=u;m<=p&&(p=0);u=p+1;m<=u&&(u=0);w=u+1;m<=w&&(w=0);var x;a:{x=b;var v=p,z=u,y=w,B=m,C=k,E=void 0,F=void 0,G=void 0, M=void 0,P=void 0,L=void 0,A=void 0,J=void 0,Z=void 0,F=x[C[v]].x,G=x[C[v]].y,M=x[C[z]].x,P=x[C[z]].y,L=x[C[y]].x,A=x[C[y]].y;if(1.0E-10>(M-F)*(A-G)-(P-G)*(L-F))x=!1;else{for(E=0;E=0&&X>=0&&W>=0){x=!1; -break a}}x=!0}}if(x){k.push([b[m[u]],b[m[p]],b[m[w]]]);n.push([m[u],m[p],m[w]]);u=p;for(w=p+1;w>7)-127;f|=(k&127)<<16|h<<8;if(f==0&&n==-127)return 0;return(1-2*(m>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,n)}function h(b,c){var e=w(b,c),f=w(b,c+1),k=w(b,c+2);return(w(b,c+3)<<24)+(k<<16)+(f<<8)+e}function u(b,c){var e=w(b,c);return(w(b,c+1)<<8)+e}function p(b,c){var e=w(b,c);return e>127?e-256:e}function w(b,c){return b.charCodeAt(c)&255}function t(c){var e, -f,k;e=h(b,c);f=h(b,c+P);k=h(b,c+L);c=u(b,c+A);C.faces.push(new THREE.Face3(e,f,k,null,null,C.materials[c]))}function x(c){var e,f,k,m,o,p;e=h(b,c);f=h(b,c+P);k=h(b,c+L);m=u(b,c+A);o=h(b,c+J);p=h(b,c+Z);c=h(b,c+I);m=C.materials[m];var t=G[p*3],v=G[p*3+1];p=G[p*3+2];var w=G[c*3],x=G[c*3+1],c=G[c*3+2];C.faces.push(new THREE.Face3(e,f,k,[new THREE.Vector3(G[o*3],G[o*3+1],G[o*3+2]),new THREE.Vector3(t,v,p),new THREE.Vector3(w,x,c)],null,m))}function v(c){var e,f,k,m;e=h(b,c);f=h(b,c+O);k=h(b,c+X);m=h(b, -c+V);c=u(b,c+W);C.faces.push(new THREE.Face4(e,f,k,m,null,null,C.materials[c]))}function z(c){var e,f,k,m,p,t,v,w;e=h(b,c);f=h(b,c+O);k=h(b,c+X);m=h(b,c+V);p=u(b,c+W);t=h(b,c+o);v=h(b,c+ea);w=h(b,c+T);c=h(b,c+na);p=C.materials[p];var x=G[v*3],K=G[v*3+1];v=G[v*3+2];var y=G[w*3],S=G[w*3+1];w=G[w*3+2];var z=G[c*3],B=G[c*3+1],c=G[c*3+2];C.faces.push(new THREE.Face4(e,f,k,m,[new THREE.Vector3(G[t*3],G[t*3+1],G[t*3+2]),new THREE.Vector3(x,K,v),new THREE.Vector3(y,S,w),new THREE.Vector3(z,B,c)],null,p))} -function y(c){var e,f,k,m;e=h(b,c);f=h(b,c+aa);k=h(b,c+ha);c=M[e*2];m=M[e*2+1];e=M[f*2];var o=C.faceVertexUvs[0];f=M[f*2+1];var p=M[k*2];k=M[k*2+1];var t=[];t.push(new THREE.UV(c,m));t.push(new THREE.UV(e,f));t.push(new THREE.UV(p,k));o.push(t)}function B(c){var e,f,k,m,o,p;e=h(b,c);f=h(b,c+ca);k=h(b,c+qa);m=h(b,c+fa);c=M[e*2];o=M[e*2+1];e=M[f*2];p=M[f*2+1];f=M[k*2];var t=C.faceVertexUvs[0];k=M[k*2+1];var u=M[m*2];m=M[m*2+1];var v=[];v.push(new THREE.UV(c,o));v.push(new THREE.UV(e,p));v.push(new THREE.UV(f, -k));v.push(new THREE.UV(u,m));t.push(v)}var C=this,E=0,F,G=[],M=[],P,L,A,J,Z,I,O,X,V,W,o,ea,T,na,aa,ha,ca,qa,fa,da,U,$,ga,ka,ua;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(C,f,c);F={signature:b.substr(E,8),header_bytes:w(b,E+8),vertex_coordinate_bytes:w(b,E+9),normal_coordinate_bytes:w(b,E+10),uv_coordinate_bytes:w(b,E+11),vertex_index_bytes:w(b,E+12),normal_index_bytes:w(b,E+13),uv_index_bytes:w(b,E+14),material_index_bytes:w(b,E+15),nvertices:h(b,E+16),nnormals:h(b,E+16+4),nuvs:h(b, -E+16+8),ntri_flat:h(b,E+16+12),ntri_smooth:h(b,E+16+16),ntri_flat_uv:h(b,E+16+20),ntri_smooth_uv:h(b,E+16+24),nquad_flat:h(b,E+16+28),nquad_smooth:h(b,E+16+32),nquad_flat_uv:h(b,E+16+36),nquad_smooth_uv:h(b,E+16+40)};E+=F.header_bytes;P=F.vertex_index_bytes;L=F.vertex_index_bytes*2;A=F.vertex_index_bytes*3;J=F.vertex_index_bytes*3+F.material_index_bytes;Z=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes;I=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*2;O=F.vertex_index_bytes; +THREE.BinaryLoader.prototype.loadAjaxBuffers=function(b,c,e,f,m,h){var k=new XMLHttpRequest,n=f+"/"+b,p=0;k.onreadystatechange=function(){k.readyState==4?k.status==200||k.status==0?THREE.BinaryLoader.prototype.createBinModel(k.responseText,e,m,c):alert("Couldn't load ["+n+"] ["+k.status+"]"):k.readyState==3?h&&(p==0&&(p=k.getResponseHeader("Content-Length")),h({total:p,loaded:k.responseText.length})):k.readyState==2&&(p=k.getResponseHeader("Content-Length"))};k.open("GET",n,!0);k.overrideMimeType("text/plain; charset=x-user-defined"); +k.setRequestHeader("Content-Type","text/plain");k.send(null)}; +THREE.BinaryLoader.prototype.createBinModel=function(b,c,e,f){var m=function(c){function e(b,c){var f=w(b,c),h=w(b,c+1),k=w(b,c+2),m=w(b,c+3),n=(m<<1&255|k>>7)-127;f|=(k&127)<<16|h<<8;if(f==0&&n==-127)return 0;return(1-2*(m>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,n)}function m(b,c){var e=w(b,c),f=w(b,c+1),h=w(b,c+2);return(w(b,c+3)<<24)+(h<<16)+(f<<8)+e}function p(b,c){var e=w(b,c);return(w(b,c+1)<<8)+e}function u(b,c){var e=w(b,c);return e>127?e-256:e}function w(b,c){return b.charCodeAt(c)&255}function t(c){var e, +f,h;e=m(b,c);f=m(b,c+P);h=m(b,c+L);c=p(b,c+A);C.faces.push(new THREE.Face3(e,f,h,null,null,C.materials[c]))}function x(c){var e,f,h,k,o,t;e=m(b,c);f=m(b,c+P);h=m(b,c+L);k=p(b,c+A);o=m(b,c+J);t=m(b,c+Z);c=m(b,c+I);k=C.materials[k];var u=G[t*3],v=G[t*3+1];t=G[t*3+2];var w=G[c*3],x=G[c*3+1],c=G[c*3+2];C.faces.push(new THREE.Face3(e,f,h,[new THREE.Vector3(G[o*3],G[o*3+1],G[o*3+2]),new THREE.Vector3(u,v,t),new THREE.Vector3(w,x,c)],null,k))}function v(c){var e,f,h,k;e=m(b,c);f=m(b,c+O);h=m(b,c+X);k=m(b, +c+V);c=p(b,c+W);C.faces.push(new THREE.Face4(e,f,h,k,null,null,C.materials[c]))}function z(c){var e,f,h,k,t,u,v,w;e=m(b,c);f=m(b,c+O);h=m(b,c+X);k=m(b,c+V);t=p(b,c+W);u=m(b,c+o);v=m(b,c+ea);w=m(b,c+T);c=m(b,c+na);t=C.materials[t];var x=G[v*3],K=G[v*3+1];v=G[v*3+2];var y=G[w*3],S=G[w*3+1];w=G[w*3+2];var z=G[c*3],B=G[c*3+1],c=G[c*3+2];C.faces.push(new THREE.Face4(e,f,h,k,[new THREE.Vector3(G[u*3],G[u*3+1],G[u*3+2]),new THREE.Vector3(x,K,v),new THREE.Vector3(y,S,w),new THREE.Vector3(z,B,c)],null,t))} +function y(c){var e,f,h,k;e=m(b,c);f=m(b,c+aa);h=m(b,c+ha);c=M[e*2];k=M[e*2+1];e=M[f*2];var o=C.faceVertexUvs[0];f=M[f*2+1];var p=M[h*2];h=M[h*2+1];var t=[];t.push(new THREE.UV(c,k));t.push(new THREE.UV(e,f));t.push(new THREE.UV(p,h));o.push(t)}function B(c){var e,f,h,k,o,p;e=m(b,c);f=m(b,c+ca);h=m(b,c+qa);k=m(b,c+fa);c=M[e*2];o=M[e*2+1];e=M[f*2];p=M[f*2+1];f=M[h*2];var t=C.faceVertexUvs[0];h=M[h*2+1];var u=M[k*2];k=M[k*2+1];var v=[];v.push(new THREE.UV(c,o));v.push(new THREE.UV(e,p));v.push(new THREE.UV(f, +h));v.push(new THREE.UV(u,k));t.push(v)}var C=this,E=0,F,G=[],M=[],P,L,A,J,Z,I,O,X,V,W,o,ea,T,na,aa,ha,ca,qa,fa,da,U,$,ga,ka,ua;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(C,f,c);F={signature:b.substr(E,8),header_bytes:w(b,E+8),vertex_coordinate_bytes:w(b,E+9),normal_coordinate_bytes:w(b,E+10),uv_coordinate_bytes:w(b,E+11),vertex_index_bytes:w(b,E+12),normal_index_bytes:w(b,E+13),uv_index_bytes:w(b,E+14),material_index_bytes:w(b,E+15),nvertices:m(b,E+16),nnormals:m(b,E+16+4),nuvs:m(b, +E+16+8),ntri_flat:m(b,E+16+12),ntri_smooth:m(b,E+16+16),ntri_flat_uv:m(b,E+16+20),ntri_smooth_uv:m(b,E+16+24),nquad_flat:m(b,E+16+28),nquad_smooth:m(b,E+16+32),nquad_flat_uv:m(b,E+16+36),nquad_smooth_uv:m(b,E+16+40)};E+=F.header_bytes;P=F.vertex_index_bytes;L=F.vertex_index_bytes*2;A=F.vertex_index_bytes*3;J=F.vertex_index_bytes*3+F.material_index_bytes;Z=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes;I=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*2;O=F.vertex_index_bytes; X=F.vertex_index_bytes*2;V=F.vertex_index_bytes*3;W=F.vertex_index_bytes*4;o=F.vertex_index_bytes*4+F.material_index_bytes;ea=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes;T=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*2;na=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*3;aa=F.uv_index_bytes;ha=F.uv_index_bytes*2;ca=F.uv_index_bytes;qa=F.uv_index_bytes*2;fa=F.uv_index_bytes*3;c=F.vertex_index_bytes*3+F.material_index_bytes;ua=F.vertex_index_bytes* -4+F.material_index_bytes;da=F.ntri_flat*c;U=F.ntri_smooth*(c+F.normal_index_bytes*3);$=F.ntri_flat_uv*(c+F.uv_index_bytes*3);ga=F.ntri_smooth_uv*(c+F.normal_index_bytes*3+F.uv_index_bytes*3);ka=F.nquad_flat*ua;c=F.nquad_smooth*(ua+F.normal_index_bytes*4);ua=F.nquad_flat_uv*(ua+F.uv_index_bytes*4);E+=function(c){for(var f,h,k,n=F.vertex_coordinate_bytes*3,o=c+F.nvertices*n;c=0){y=o.invBindMatrices[v];p.invBindMatrix=y;p.skinningMatrix=new THREE.Matrix4;p.skinningMatrix.multiply(p.world,y);p.weights=[]; -for(y=0;y1){o=new THREE.MeshFaceMaterial;for(j=0;j1){o=new THREE.MeshFaceMaterial;for(j=0;j1?e[1].substr(0,c):"0";e[1].length1?e[1].substr(0,c):"0";e[1].length=0,m=h.indexOf("(")>=0,n;if(k)f=h.split("."),h=f.shift(),f.shift();else if(m){n=h.split("(");h=n.shift();for(f=0;f=0,f=b.indexOf("(")>=0,h,k;if(e)c=b.split("."),b=c.shift(),k=c.shift();else if(f){h=b.split("(");b=h.shift();for(c=0;c1&&(Z=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(P,Z);object.name=v;object.position.set(F[0],F[1],F[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=E.visible;T.scene.add(object);T.objects[v]=object;E.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),T.scene.collisions.colliders.push(b)); if(E.castsShadow)b=new THREE.ShadowVolume(P),T.scene.add(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;E.trigger&&E.trigger.toLowerCase()!="none"&&(b={type:E.trigger,object:E},T.triggers[object.name]=b)}}else F=E.position,r=E.rotation,q=E.quaternion,s=E.scale,q=0,object=new THREE.Object3D,object.name=v,object.position.set(F[0],F[1],F[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], -s[1],s[2]),object.visible=E.visible!==void 0?E.visible:!1,T.scene.add(object),T.objects[v]=object,T.empties[v]=object,E.trigger&&E.trigger.toLowerCase()!="none"&&(b={type:E.trigger,object:E},T.triggers[object.name]=b)}function u(b){return function(c){T.geometries[b]=c;n();V-=1;e.onLoadComplete();w()}}function p(b){return function(c){T.geometries[b]=c}}function w(){e.callbackProgress({totalModels:o,totalTextures:ea,loadedModels:o-V,loadedTextures:ea-W},T);e.onLoadProgress();V==0&&W==0&&c(T)}var t, +s[1],s[2]),object.visible=E.visible!==void 0?E.visible:!1,T.scene.add(object),T.objects[v]=object,T.empties[v]=object,E.trigger&&E.trigger.toLowerCase()!="none"&&(b={type:E.trigger,object:E},T.triggers[object.name]=b)}function p(b){return function(c){T.geometries[b]=c;n();V-=1;e.onLoadComplete();w()}}function u(b){return function(c){T.geometries[b]=c}}function w(){e.callbackProgress({totalModels:o,totalTextures:ea,loadedModels:o-V,loadedTextures:ea-W},T);e.onLoadProgress();V==0&&W==0&&c(T)}var t, x,v,z,y,B,C,E,F,G,M,P,L,A,J,Z,I,O,X,V,W,o,ea,T;O=b.data;J=new THREE.BinaryLoader;X=new THREE.JSONLoader;W=V=0;T={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(v in O.objects)if(E=O.objects[v],E.meshCollider){b=!0;break}if(b)T.scene.collisions=new THREE.CollisionSystem;if(O.transform){b=O.transform.position;G=O.transform.rotation;var na=O.transform.scale;b&&T.scene.position.set(b[0],b[1],b[2]);G&&T.scene.rotation.set(G[0], G[1],G[2]);na&&T.scene.scale.set(na[0],na[1],na[2]);(b||G||na)&&T.scene.updateMatrix()}b=function(){W-=1;w();e.onLoadComplete()};for(y in O.cameras){G=O.cameras[y];if(G.type=="perspective")L=new THREE.Camera(G.fov,G.aspect,G.near,G.far);else if(G.type=="ortho")L=new THREE.Camera,L.projectionMatrix=THREE.Matrix4.makeOrtho(G.left,G.right,G.top,G.bottom,G.near,G.far);F=G.position;G=G.target;L.position.set(F[0],F[1],F[2]);L.target.position.set(G[0],G[1],G[2]);T.cameras[y]=L}for(z in O.lights)y=O.lights[z], L=y.color!==void 0?y.color:16777215,G=y.intensity!==void 0?y.intensity:1,y.type=="directional"?(F=y.direction,I=new THREE.DirectionalLight(L,G),I.position.set(F[0],F[1],F[2]),I.position.normalize()):y.type=="point"?(F=y.position,d=y.distance,I=new THREE.PointLight(L,G,d),I.position.set(F[0],F[1],F[2])):y.type=="ambient"&&(I=new THREE.AmbientLight(L)),T.scene.add(I),T.lights[z]=I;for(B in O.fogs)z=O.fogs[B],z.type=="linear"?A=new THREE.Fog(0,z.near,z.far):z.type=="exp2"&&(A=new THREE.FogExp2(0,z.density)), G=z.color,A.color.setRGB(G[0],G[1],G[2]),T.fogs[B]=A;if(T.cameras&&O.defaults.camera)T.currentCamera=T.cameras[O.defaults.camera];if(T.fogs&&O.defaults.fog)T.scene.fog=T.fogs[O.defaults.fog];G=O.defaults.bgcolor;T.bgColor=new THREE.Color;T.bgColor.setRGB(G[0],G[1],G[2]);T.bgColorAlpha=O.defaults.bgalpha;for(t in O.geometries)if(B=O.geometries[t],B.type=="bin_mesh"||B.type=="ascii_mesh")V+=1,e.onLoadStart();o=V;for(t in O.geometries)B=O.geometries[t],B.type=="cube"?(P=new THREE.CubeGeometry(B.width, B.height,B.depth,B.segmentsWidth,B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),T.geometries[t]=P):B.type=="plane"?(P=new THREE.PlaneGeometry(B.width,B.height,B.segmentsWidth,B.segmentsHeight),T.geometries[t]=P):B.type=="sphere"?(P=new THREE.SphereGeometry(B.radius,B.segmentsWidth,B.segmentsHeight),T.geometries[t]=P):B.type=="cylinder"?(P=new THREE.CylinderGeometry(B.topRad,B.botRad,B.height,B.radSegs,B.heightSegs),T.geometries[t]=P):B.type=="torus"?(P=new THREE.TorusGeometry(B.radius,B.tube, -B.segmentsR,B.segmentsT),T.geometries[t]=P):B.type=="icosahedron"?(P=new THREE.IcosahedronGeometry(B.subdivisions),T.geometries[t]=P):B.type=="bin_mesh"?J.load({model:f(B.url,O.urlBaseType),callback:u(t)}):B.type=="ascii_mesh"?X.load({model:f(B.url,O.urlBaseType),callback:u(t)}):B.type=="embedded_mesh"&&(B=O.embeds[B.id])&&X.createModel(B,p(t),"");for(C in O.textures)if(t=O.textures[C],t.url instanceof Array){W+=t.url.length;for(J=0;J=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,h=0;h<8;h++){for(var k=0,m=0;m>1^-(n&1);e[8*m+h]=k}f+=c}c=b.length-f;k=new Uint16Array(c);for(h=m=0;h=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,m=0;m<8;m++){for(var h=0,k=0;k>1^-(n&1);e[8*k+m]=h}f+=c}c=b.length-f;h=new Uint16Array(c);for(m=k=0;m=this.maxCount-3&&n(this)};this.begin=function(){this.count=0; -this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(u=this.size-1);var x=Math.floor(p-n);x<1&&(x=1);p=Math.floor(p+n);p>this.size-1&&(p=this.size-1);var v=Math.floor(w-n);v<1&&(v=1);n=Math.floor(w+n);n>this.size-1&&(n=this.size- -1);for(var z,y,B,C,E,F;t0&&(this.field[B+z]+=C)}}};this.addPlaneX=function(b,c){var h,k,m,n,u,p=this.size,w=this.yd,t=this.zd,x=this.field,v=p*Math.sqrt(b/c);v>p&&(v=p);for(h=0;h0)for(k=0;kw&&(z=w);for(k=0;k0){u=k*t;for(h=0;hsize&&(dist=size);for(m=0;m0){u=zd*m;for(k=0;k=this.maxCount-3&&n(this)};this.begin=function(){this.count=0; +this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(p=this.size-1);var x=Math.floor(u-n);x<1&&(x=1);u=Math.floor(u+n);u>this.size-1&&(u=this.size-1);var v=Math.floor(w-n);v<1&&(v=1);n=Math.floor(w+n);n>this.size-1&&(n=this.size- +1);for(var z,y,B,C,E,F;t0&&(this.field[B+z]+=C)}}};this.addPlaneX=function(b,c){var m,h,k,n,p,u=this.size,w=this.yd,t=this.zd,x=this.field,v=u*Math.sqrt(b/c);v>u&&(v=u);for(m=0;m0)for(h=0;hw&&(z=w);for(h=0;h0){p=h*t;for(m=0;msize&&(dist=size);for(k=0;k0){p=zd*k;for(h=0;hk?this.hits.push(h):this.hits.unshift(h),k=f;return this.hits}; +THREE.CollisionSystem.prototype.merge=function(b){Array.prototype.push.apply(this.colliders,b.colliders);Array.prototype.push.apply(this.hits,b.hits)};THREE.CollisionSystem.prototype.rayCastAll=function(b){b.direction.normalize();this.hits.length=0;var c,e,f,m,h=0;c=0;for(e=this.colliders.length;ch?this.hits.push(m):this.hits.unshift(m),h=f;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var e=0;c[e]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,c[e]);if(f.distc.length)return null;return c[e]}; THREE.CollisionSystem.prototype.rayCast=function(b,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(b,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(b,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(b,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(b,c.box)}; -THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,h,k=0;k=n*h))return Number.MAX_VALUE;m/=n;n=THREE.CollisionSystem.__v3;n.copy(b.direction);n.multiplyScalar(m);n.addSelf(b.origin);Math.abs(k.x)> -Math.abs(k.y)?Math.abs(k.x)>Math.abs(k.z)?(b=n.y-c.y,k=e.y-c.y,h=f.y-c.y,n=n.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=n.x-c.x,k=e.x-c.x,h=f.x-c.x,n=n.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(k.y)>Math.abs(k.z)?(b=n.x-c.x,k=e.x-c.x,h=f.x-c.x,n=n.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=n.x-c.x,k=e.x-c.x,h=f.x-c.x,n=n.y-c.y,e=e.y-c.y,f=f.y-c.y);c=k*f-e*h;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-n*h)*c;if(!(f>=0))return Number.MAX_VALUE;c*=k*n-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return m}; +THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,m,h=0;h=n*m))return Number.MAX_VALUE;k/=n;n=THREE.CollisionSystem.__v3;n.copy(b.direction);n.multiplyScalar(k);n.addSelf(b.origin);Math.abs(h.x)> +Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(b=n.y-c.y,h=e.y-c.y,m=f.y-c.y,n=n.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=n.x-c.x,h=e.x-c.x,m=f.x-c.x,n=n.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(h.y)>Math.abs(h.z)?(b=n.x-c.x,h=e.x-c.x,m=f.x-c.x,n=n.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=n.x-c.x,h=e.x-c.x,m=f.x-c.x,n=n.y-c.y,e=e.y-c.y,f=f.y-c.y);c=h*f-e*m;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-n*m)*c;if(!(f>=0))return Number.MAX_VALUE;c*=h*n-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return k}; THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var e=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,e);var f=THREE.CollisionSystem.__r;f.origin.copy(b.origin);f.direction.copy(b.direction);e.multiplyVector3(f.origin);e.rotateAxis(f.direction);f.direction.normalize();return f}; -THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,h=0,k=0,m=0,n=0,u=0,p=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,p=!1,m=1);e.origin.yc.max.y&&(h=c.max.y-e.origin.y,h/=e.direction.y, -p=!1,n=1);e.origin.zc.max.z&&(k=c.max.z-e.origin.z,k/=e.direction.z,p=!1,u=1);if(p)return-1;p=0;h>f&&(p=1,f=h);k>f&&(p=2,f=k);switch(p){case 0:n=e.origin.y+e.direction.y*f;if(nc.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(m,0,0);break;case 1:m=e.origin.x+e.direction.x*f;if(mc.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z* -f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(0,n,0);break;case 2:m=e.origin.x+e.direction.x*f;if(mc.max.x)return Number.MAX_VALUE;n=e.origin.y+e.direction.y*f;if(nc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,u)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var e=b.direction.dot(c.normal),f=c.point.dot(c.normal);if(e<0)e=(f-b.origin.dot(c.normal))/e;else return Number.MAX_VALUE;return e>0?e:Number.MAX_VALUE}; +THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,m=0,h=0,k=0,n=0,p=0,u=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,u=!1,k=1);e.origin.yc.max.y&&(m=c.max.y-e.origin.y,m/=e.direction.y, +u=!1,n=1);e.origin.zc.max.z&&(h=c.max.z-e.origin.z,h/=e.direction.z,u=!1,p=1);if(u)return-1;u=0;m>f&&(u=1,f=m);h>f&&(u=2,f=h);switch(u){case 0:n=e.origin.y+e.direction.y*f;if(nc.max.y)return Number.MAX_VALUE;e=e.origin.z+e.direction.z*f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(k,0,0);break;case 1:k=e.origin.x+e.direction.x*f;if(kc.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z* +f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(0,n,0);break;case 2:k=e.origin.x+e.direction.x*f;if(kc.max.x)return Number.MAX_VALUE;n=e.origin.y+e.direction.y*f;if(nc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,p)}return f};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var e=b.direction.dot(c.normal),f=c.point.dot(c.normal);if(e<0)e=(f-b.origin.dot(c.normal))/e;else return Number.MAX_VALUE;return e>0?e:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(b,c){var e=c.center.clone().subSelf(b.origin);if(e.lengthSq=0)return Math.abs(f)-Math.sqrt(e);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4; THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(b){b.geometry.computeBoundingBox();var c=b.geometry.boundingBox,e=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),e=new THREE.BoxCollider(e,c);e.mesh=b;return e};THREE.CollisionUtils.MeshAABB=function(b){var c=THREE.CollisionUtils.MeshOBB(b);c.min.addSelf(b.position);c.max.addSelf(b.position);c.dynamic=!1;return c}; THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))}; -if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,h=new THREE.Camera,k=new THREE.Camera,m=new THREE.Matrix4,n=new THREE.Matrix4,u,p,w;h.useTarget=k.useTarget=!1;h.matrixAutoUpdate=k.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},t=new THREE.WebGLRenderTarget(512,512,b),x=new THREE.WebGLRenderTarget(512,512,b),v=new THREE.Camera(53,1,1,1E4);v.position.z= +if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,m=new THREE.Camera,h=new THREE.Camera,k=new THREE.Matrix4,n=new THREE.Matrix4,p,u,w;m.useTarget=h.useTarget=!1;m.matrixAutoUpdate=h.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},t=new THREE.WebGLRenderTarget(512,512,b),x=new THREE.WebGLRenderTarget(512,512,b),v=new THREE.Camera(53,1,1,1E4);v.position.z= 2;_material=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:t},mapRight:{type:"t",value:1,texture:x}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"}); -var z=new THREE.Scene;z.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);t.width=b;t.height=f;x.width=b;x.height=f};this.render=function(b,e){e.update(null,!0);if(u!==e.aspect||p!==e.near||w!==e.fov){u=e.aspect;p=e.near;w=e.fov;var C=e.projectionMatrix.clone(),E=125/30*0.5,F=E*p/125,G=p*Math.tan(w*Math.PI/360),M;m.n14=E;n.n14=-E;E=-G*u+F;M=G*u+F;C.n11=2*p/(M-E);C.n13=(M+E)/(M-E);h.projectionMatrix=C.clone();E=-G*u-F;M=G*u-F;C.n11=2*p/(M-E);C.n13= -(M+E)/(M-E);k.projectionMatrix=C.clone()}h.matrix=e.matrixWorld.clone().multiplySelf(n);h.update(null,!0);h.position.copy(e.position);h.near=p;h.far=e.far;f.call(c,b,h,t,!0);k.matrix=e.matrixWorld.clone().multiplySelf(m);k.update(null,!0);k.position.copy(e.position);k.near=p;k.far=e.far;f.call(c,b,k,x,!0);f.call(c,z,v)}}; -if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,h,k,m=new THREE.Camera,n=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,f){e.call(c,b,f);h=b/2;k=f};this.render=function(b,e){this.clear();m.fov=e.fov;m.aspect=0.5*e.aspect;m.near=e.near;m.far=e.far; -m.updateProjectionMatrix();m.position.copy(e.position);m.target.position.copy(e.target.position);m.translateX(c.separation);n.projectionMatrix=m.projectionMatrix;n.position.copy(e.position);n.target.position.copy(e.target.position);n.translateX(-c.separation);this.setViewport(0,0,h,k);f.call(c,b,m);this.setViewport(h,0,h,k);f.call(c,b,n,!1)}}; +var z=new THREE.Scene;z.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);t.width=b;t.height=f;x.width=b;x.height=f};this.render=function(b,e){e.update(null,!0);if(p!==e.aspect||u!==e.near||w!==e.fov){p=e.aspect;u=e.near;w=e.fov;var C=e.projectionMatrix.clone(),E=125/30*0.5,F=E*u/125,G=u*Math.tan(w*Math.PI/360),M;k.n14=E;n.n14=-E;E=-G*p+F;M=G*p+F;C.n11=2*u/(M-E);C.n13=(M+E)/(M-E);m.projectionMatrix=C.clone();E=-G*p-F;M=G*p-F;C.n11=2*u/(M-E);C.n13= +(M+E)/(M-E);h.projectionMatrix=C.clone()}m.matrix=e.matrixWorld.clone().multiplySelf(n);m.update(null,!0);m.position.copy(e.position);m.near=u;m.far=e.far;f.call(c,b,m,t,!0);h.matrix=e.matrixWorld.clone().multiplySelf(k);h.update(null,!0);h.position.copy(e.position);h.near=u;h.far=e.far;f.call(c,b,h,x,!0);f.call(c,z,v)}}; +if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,m,h,k=new THREE.Camera,n=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,f){e.call(c,b,f);m=b/2;h=f};this.render=function(b,e){this.clear();k.fov=e.fov;k.aspect=0.5*e.aspect;k.near=e.near;k.far=e.far; +k.updateProjectionMatrix();k.position.copy(e.position);k.target.position.copy(e.target.position);k.translateX(c.separation);n.projectionMatrix=k.projectionMatrix;n.position.copy(e.position);n.target.position.copy(e.target.position);n.translateX(-c.separation);this.setViewport(0,0,m,h);f.call(c,b,k);this.setViewport(m,0,m,h);f.call(c,b,n,!1)}}; diff --git a/examples/canvas_geometry_subdivison.html b/examples/canvas_geometry_subdivison.html index 8e0c8fcf..ae14f79e 100644 --- a/examples/canvas_geometry_subdivison.html +++ b/examples/canvas_geometry_subdivison.html @@ -96,6 +96,8 @@ //geometry = new THREE.CubeGeometry( 200, 200, 200, 2, 2, 2, materials ); geometry = new THREE.CubeGeometry( 200, 200, 200, 1, 1, 3, materials ); + //geometry = new THREE.IcosahedronGeometry( 1 ); + //geometry = new THREE.TorusGeometry( 100, 60, 4, 8, Math.PI*2 ); //geometry = new THREE.SphereGeometry( 200, 1, 1); //geometry = new THREE.CylinderGeometry( 50, 50, 200 ); @@ -107,14 +109,12 @@ // // }); - //PlaneGeometry not supported + //PlaneGeometry not supported - // quick fix for duplicated vertices - // either mergeVertices or checkDupVertices(true) works + // make sure mergeVertices(); is run to fix quick duplicated vertices geometry.mergeVertices(); - geometry.checkDupVertices( true ); - + //console.log(geometry); @@ -175,6 +175,10 @@ //cube = new THREE.Mesh( smooth, new THREE.MeshFaceMaterial() ); // material = new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.FlatShading } ); // new THREE.MeshPhongMaterial( { color: 0xffffff, shading: THREE.SmoothShading } ); + // cube.scale.x = 200; + // cube.scale.y = 200; + // cube.scale.z = 200; + // cube.doubleSided = true; diff --git a/src/core/Geometry.js b/src/core/Geometry.js index f67fe0fd..99611277 100644 --- a/src/core/Geometry.js +++ b/src/core/Geometry.js @@ -15,8 +15,6 @@ THREE.Geometry = function () { this.faces = []; - //this.edges = []; - this.faceUvs = [[]]; this.faceVertexUvs = [[]]; @@ -438,74 +436,19 @@ THREE.Geometry.prototype = { }, - /* - * Merge Vertices which distances close enough - * - */ - mergeVertices: function() { - - var unique = [], changes = [], scope = this; - - var isEqual = function(a, b) { - var epsilon = 0.0001; - return (Math.abs(a - b) < epsilon); - } - - for ( var i = 0, il = scope.vertices.length; i < il; i ++ ) { - - var v = scope.vertices[ i ], - duplicate = false; - - for ( var j = 0, jl = unique.length; j < jl; j ++ ) { - - var vu = unique[ j ]; - - if( isEqual(v.position.x, vu.position.x) && isEqual(v.position.y, vu.position.y) && isEqual(v.position.z, vu.position.z) ) { - - changes[ i ] = j; - duplicate = true; - break; - - } - - } - - if ( ! duplicate ) { - - changes[ i ] = unique.length; - unique.push( new THREE.Vertex( v.position.clone() ) ); - - } - - } - - for ( i = 0, il = scope.faces.length; i < il; i ++ ) { - - var face = scope.faces[ i ]; - - face.a = changes[ face.a ]; - face.b = changes[ face.b ]; - face.c = changes[ face.c ]; - face.d = changes[ face.d ]; - - } - - scope.vertices = unique; - - }, - /* * Checks for duplicate vertices with hashmap. - * If toPatch is true, duplicated vertices are removed + * Duplicated vertices are removed * and faces' vertices are updated. */ - checkDupVertices: function(toPatch) { + mergeVertices: function() { - var uniqueVertices = {}, patch = {}; + var verticesMap = {}; // Hashmap for looking up vertice by position coordinates (and making sure they are unique) var unique = [], changes = []; var v, key; - var precision = 1000; + var precisionPoints = 4; // number of decimal points, eg. 4 for epsilon of 0.0001 + var precision = Math.pow(10, precisionPoints) var i,il, face; for (i=0,il=this.vertices.length;i