// 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,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)}, equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,c,e){this.x=b||0;this.y=c||0;this.z=e||0}; THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(b,c,e){this.x=b;this.y=c;this.z=e;return this},setX:function(b){this.x=b;return this},setY:function(b){this.y=b;return this},setZ:function(b){this.z=b;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;return this},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;return this}, addScalar:function(b){this.x+=b;this.y+=b;this.z+=b;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z-c.z;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this.z-=b.z;return this},multiply:function(b,c){this.x=b.x*c.x;this.y=b.y*c.y;this.z=b.z*c.z;return this},multiplySelf:function(b){this.x*=b.x;this.y*=b.y;this.z*=b.z;return this},multiplyScalar:function(b){this.x*=b;this.y*=b;this.z*=b;return this},divideSelf:function(b){this.x/=b.x;this.y/=b.y;this.z/=b.z;return this}, divideScalar:function(b){b?(this.x/=b,this.y/=b,this.z/=b):this.set(0,0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(b){return this.x*b.x+this.y*b.y+this.z*b.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.lengthSq())},lengthManhattan:function(){return this.x+this.y+this.z},normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)}, cross:function(b,c){this.x=b.y*c.z-b.z*c.y;this.y=b.z*c.x-b.x*c.z;this.z=b.x*c.y-b.y*c.x;return this},crossSelf:function(b){return this.set(this.y*b.z-this.z*b.y,this.z*b.x-this.x*b.z,this.x*b.y-this.y*b.x)},distanceTo:function(b){return Math.sqrt(this.distanceToSquared(b))},distanceToSquared:function(b){return(new THREE.Vector3).sub(this,b).lengthSq()},setPositionFromMatrix:function(b){this.x=b.n14;this.y=b.n24;this.z=b.n34},setRotationFromMatrix:function(b){var c=Math.cos(this.y);this.y=Math.asin(b.n13); Math.abs(c)>1.0E-5?(this.x=Math.atan2(-b.n23/c,b.n33/c),this.z=Math.atan2(-b.n12/c,b.n11/c)):(this.x=0,this.z=Math.atan2(b.n21,b.n22))},isZero:function(){return this.lengthSq()<1.0E-4}};THREE.Vector4=function(b,c,e,f){this.x=b||0;this.y=c||0;this.z=e||0;this.w=f!==void 0?f:1}; THREE.Vector4.prototype={constructor:THREE.Vector4,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!==void 0?b.w:1},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},add:function(b,c){this.x=b.x+c.x;this.y=b.y+c.y;this.z=b.z+c.z;this.w=b.w+c.w;return this},addSelf:function(b){this.x+=b.x;this.y+=b.y;this.z+=b.z;this.w+=b.w;return this},sub:function(b,c){this.x=b.x-c.x;this.y=b.y-c.y;this.z=b.z- 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&&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,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,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),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,m;e=0;for(f=this.children.length;e=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,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, 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?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),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[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(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(k.positionScreen.z,la,N),ka.r=ka.g=ka.b=1-Ra(m.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,h,m){v.beginPath();v.moveTo(b,e);v.lineTo(c,f);v.lineTo(h,m);v.lineTo(b,e); v.closePath()}function F(b,e,c,f,h,m,k,o){v.beginPath();v.moveTo(b,e);v.lineTo(c,f);v.lineTo(h,m);v.lineTo(k,o);v.lineTo(b,e);v.closePath()}function Na(b,e,c,h){if(G!=e)v.lineWidth=G=e;if(M!=c)v.lineCap=M=c;if(P!=h)v.lineJoin=P=h;f(b.getContextStyle());v.stroke();S.inflate(e*2)}function Oa(b){m(b.getContextStyle());v.fill()}function ab(b,e,c,f,h,k,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}m(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;h-=b;k-=e;p-=o;t-=n;u-=o;Fa-=n;w=1/(p*Fa-u*t);x=(Fa*c-t*h)*w;t=(Fa*f-t*k)*w;c=(p*h-u*c)*w;f=(p*k-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,h,m,k,o,n,p,t,u,Fa){var x,w;x=Fa.width-1;w=Fa.height-1;k*=x;o*=w;n*=x;p*=w;t*=x;u*=w;c-=b;f-=e;h-=b;m-=e;n-=k;p-=o;t-=k;u-=o;w=1/(n*u-t*p);x=(u*c-p*h)*w;p=(u*f-p*m)*w;c=(n*h-t*c)*w;f=(n*m-t*f)*w;b=b-x*k-c*o;e=e-p*k-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 h=~~(b.r*255),k=~~(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]=h<0? 0:h>255?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+=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\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\n#endif", lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 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 );\nfloat pointLightWeighting = max( dot( transformedNormal, lVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting * lDistance;\n}\n#endif\n}", lights_phong_pars_vertex:"#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\nuniform float pointLightDistance[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif",lights_phong_vertex:"#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", lights_pars_fragment:"uniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += diffuse * pointLightColor[ i ] * pointDiffuseWeight * pointDistance;\npointSpecular += specular * pointLightColor[ i ] * pointSpecularWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += diffuse * directionalLightColor[ i ] * dirDiffuseWeight;\ndirSpecular += specular * directionalLightColor[ i ] * dirSpecularWeight;\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * totalDiffuse + totalSpecular + ambientLightColor * ambient;", color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#endif", morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\nuniform float morphTargetInfluences[ 8 ];\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\nvec3 morphed = vec3( 0.0, 0.0, 0.0 );\nmorphed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\nmorphed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\nmorphed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\nmorphed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\nmorphed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\nmorphed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\nmorphed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\nmorphed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\nmorphed += position;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( morphed, 1.0 );\n#endif", default_vertex:"#ifndef USE_MORPHTARGETS\n#ifndef USE_SKINNING\ngl_Position = projectionMatrix * mvPosition;\n#endif\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\nuniform sampler2D shadowMap[ MAX_SHADOWS ];\nuniform float shadowDarkness;\nuniform float shadowBias;\nvarying vec4 vShadowCoord[ MAX_SHADOWS ];\nfloat unpackDepth( const in vec4 rgba_depth ) {\nconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\nfloat depth = dot( rgba_depth, bit_shift );\nreturn depth;\n}\n#endif", shadowmap_fragment:"#ifdef USE_SHADOWMAP\n#ifdef SHADOWMAP_SOFT\nconst float xPixelOffset = 1.0 / SHADOWMAP_WIDTH;\nconst float yPixelOffset = 1.0 / SHADOWMAP_HEIGHT;\n#endif\nvec4 shadowColor = vec4( 1.0 );\nfor( int i = 0; i < MAX_SHADOWS; i ++ ) {\nvec3 shadowCoord = vShadowCoord[ i ].xyz / vShadowCoord[ i ].w;\nshadowCoord.z += shadowBias;\nif ( shadowCoord.x >= 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,m={};for(c=0;c=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&&(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= o.createRenderbuffer();b.__webglTexture=o.createTexture();if(e){o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture);A(o.TEXTURE_CUBE_MAP,b,b);b.__webglFramebuffer=[];for(var c=0;c<6;c++)b.__webglFramebuffer[c]=o.createFramebuffer(),o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,V(b.format),b.width,b.height,0,V(b.format),V(b.type),null)}else b.__webglFramebuffer=o.createFramebuffer(),o.bindTexture(o.TEXTURE_2D,b.__webglTexture),A(o.TEXTURE_2D,b,b),o.texImage2D(o.TEXTURE_2D,0,V(b.format),b.width,b.height, 0,V(b.format),V(b.type),null);o.bindRenderbuffer(o.RENDERBUFFER,b.__webglRenderbuffer);if(e)for(c=0;c<6;++c)o.bindFramebuffer(o.FRAMEBUFFER,b.__webglFramebuffer[c]),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+c,b.__webglTexture,0);else o.bindFramebuffer(o.FRAMEBUFFER,b.__webglFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_COMPONENT16, b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,b.__webglRenderbuffer)):o.renderbufferStorage(o.RENDERBUFFER,o.RGBA4,b.width,b.height);e?o.bindTexture(o.TEXTURE_CUBE_MAP,null):o.bindTexture(o.TEXTURE_2D,null);o.bindRenderbuffer(o.RENDERBUFFER,null); o.bindFramebuffer(o.FRAMEBUFFER,null)}var f,h;b?(e=e?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,c=b.width,b=b.height,h=f=0):(e=null,c=ma,b=ra,f=la,h=N);e!=na&&(o.bindFramebuffer(o.FRAMEBUFFER,e),o.viewport(f,h,c,b),na=e)}function I(b){b instanceof THREE.WebGLRenderTargetCube?(o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture),o.generateMipmap(o.TEXTURE_CUBE_MAP),o.bindTexture(o.TEXTURE_CUBE_MAP,null)):(o.bindTexture(o.TEXTURE_2D,b.__webglTexture),o.generateMipmap(o.TEXTURE_2D),o.bindTexture(o.TEXTURE_2D, null))}function O(b,e){var c;b=="fragment"?c=o.createShader(o.FRAGMENT_SHADER):b=="vertex"&&(c=o.createShader(o.VERTEX_SHADER));o.shaderSource(c,e);o.compileShader(c);if(!o.getShaderParameter(c,o.COMPILE_STATUS))return console.error(o.getShaderInfoLog(c)),console.error(e),null;return c}function X(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return o.NEAREST;default:return o.LINEAR}}function V(b){switch(b){case THREE.RepeatWrapping:return o.REPEAT; case THREE.ClampToEdgeWrapping:return o.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return o.MIRRORED_REPEAT;case THREE.NearestFilter:return o.NEAREST;case THREE.NearestMipMapNearestFilter:return o.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return o.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return o.LINEAR;case THREE.LinearMipMapNearestFilter:return o.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return o.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return o.BYTE; case THREE.UnsignedByteType:return o.UNSIGNED_BYTE;case THREE.ShortType:return o.SHORT;case THREE.UnsignedShortType:return o.UNSIGNED_SHORT;case THREE.IntType:return o.INT;case THREE.UnsignedShortType:return o.UNSIGNED_INT;case THREE.FloatType:return o.FLOAT;case THREE.AlphaFormat:return o.ALPHA;case THREE.RGBFormat:return o.RGB;case THREE.RGBAFormat:return o.RGBA;case THREE.LuminanceFormat:return o.LUMINANCE;case THREE.LuminanceAlphaFormat:return o.LUMINANCE_ALPHA}return 0}var W=this,o,ea=[],T=null, na=null,aa=-1,ha=null,ca=0,qa=null,fa=null,da=null,U=null,$=null,ga=null,ka=null,ua=null,la=0,N=0,ma=0,ra=0,wa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Da=new THREE.Matrix4,Ea=new Float32Array(16),Aa=new Float32Array(16),Ca=new THREE.Vector4,Ga={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},K=b.canvas!==void 0?b.canvas:document.createElement("canvas"), R=b.stencil!==void 0?b.stencil:!0,S=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,ja=b.antialias!==void 0?b.antialias:!1,oa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),ia=b.clearAlpha!==void 0?b.clearAlpha:0,sa=b.maxLights!==void 0?b.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=K;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness= 0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var va,pa=[],b=THREE.ShaderLib.depthRGBA,xa=THREE.UniformsUtils.clone(b.uniforms),ya=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:xa}),Ka=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:xa,morphTargets:!0});ya._shadowPass= !0;Ka._shadowPass=!0;try{if(!(o=K.getContext("experimental-webgl",{antialias:ja,stencil:R,preserveDrawingBuffer:S})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+o.getParameter(o.VERSION)+" | "+o.getParameter(o.VENDOR)+" | "+o.getParameter(o.RENDERER)+" | "+o.getParameter(o.SHADING_LANGUAGE_VERSION))}catch(Ba){console.error(Ba)}o.clearColor(0,0,0,1);o.clearDepth(1);o.clearStencil(0);o.enable(o.DEPTH_TEST);o.depthFunc(o.LEQUAL);o.frontFace(o.CCW);o.cullFace(o.BACK);o.enable(o.CULL_FACE); o.enable(o.BLEND);o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA);o.clearColor(oa.r,oa.g,oa.b,ia);this.context=o;var Ha=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,Y={};Y.vertices=new Float32Array(16);Y.faces=new Uint16Array(6);R=0;Y.vertices[R++]=-1;Y.vertices[R++]=-1;Y.vertices[R++]=0;Y.vertices[R++]=1;Y.vertices[R++]=1;Y.vertices[R++]=-1;Y.vertices[R++]=1;Y.vertices[R++]=1;Y.vertices[R++]=1;Y.vertices[R++]=1;Y.vertices[R++]=1;Y.vertices[R++]=0;Y.vertices[R++]= -1;Y.vertices[R++]=1;Y.vertices[R++]=0;R=Y.vertices[R++]=0;Y.faces[R++]=0;Y.faces[R++]=1;Y.faces[R++]=2;Y.faces[R++]=0;Y.faces[R++]=2;Y.faces[R++]=3;Y.vertexBuffer=o.createBuffer();Y.elementBuffer=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,Y.vertexBuffer);o.bufferData(o.ARRAY_BUFFER,Y.vertices,o.STATIC_DRAW);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,Y.elementBuffer);o.bufferData(o.ELEMENT_ARRAY_BUFFER,Y.faces,o.STATIC_DRAW);Y.program=o.createProgram();o.attachShader(Y.program,O("fragment",THREE.ShaderLib.sprite.fragmentShader)); o.attachShader(Y.program,O("vertex",THREE.ShaderLib.sprite.vertexShader));o.linkProgram(Y.program);Y.attributes={};Y.uniforms={};Y.attributes.position=o.getAttribLocation(Y.program,"position");Y.attributes.uv=o.getAttribLocation(Y.program,"uv");Y.uniforms.uvOffset=o.getUniformLocation(Y.program,"uvOffset");Y.uniforms.uvScale=o.getUniformLocation(Y.program,"uvScale");Y.uniforms.rotation=o.getUniformLocation(Y.program,"rotation");Y.uniforms.scale=o.getUniformLocation(Y.program,"scale");Y.uniforms.alignment= o.getUniformLocation(Y.program,"alignment");Y.uniforms.color=o.getUniformLocation(Y.program,"color");Y.uniforms.map=o.getUniformLocation(Y.program,"map");Y.uniforms.opacity=o.getUniformLocation(Y.program,"opacity");Y.uniforms.useScreenCoordinates=o.getUniformLocation(Y.program,"useScreenCoordinates");Y.uniforms.affectedByDistance=o.getUniformLocation(Y.program,"affectedByDistance");Y.uniforms.screenPosition=o.getUniformLocation(Y.program,"screenPosition");Y.uniforms.modelViewMatrix=o.getUniformLocation(Y.program, "modelViewMatrix");Y.uniforms.projectionMatrix=o.getUniformLocation(Y.program,"projectionMatrix");var Ja=!1;this.setSize=function(b,e){K.width=b;K.height=e;this.setViewport(0,0,K.width,K.height)};this.setViewport=function(b,e,c,f){la=b;N=e;ma=c;ra=f;o.viewport(la,N,ma,ra)};this.setScissor=function(b,e,c,f){o.scissor(b,e,c,f)};this.enableScissorTest=function(b){b?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)};this.setClearColorHex=function(b,e){oa.setHex(b);ia=e;o.clearColor(oa.r,oa.g,oa.b,ia)}; this.setClearColor=function(b,e){oa.copy(b);ia=e;o.clearColor(oa.r,oa.g,oa.b,ia)};this.getClearColor=function(){return oa};this.getClearAlpha=function(){return ia};this.clear=function(){o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT|o.STENCIL_BUFFER_BIT)};this.getContext=function(){return o};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var e= 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);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;h(A);for(K=0;K0||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;e0&&(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=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,m=b.vertices.length,h=c instanceof THREE.Mesh?c.geometry:c,k=b.vertices,n=h.vertices,p=b.faces,u=h.faces,w=b.faceVertexUvs[0],h=h.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,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 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;", THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( vec3( 1.0 ), uOpacity );\nvec3 specularTex = vec3( 1.0 );\nvec3 normalTex = texture2D( tNormal, vUv ).xyz * 2.0 - 1.0;\nnormalTex.xy *= uNormalScale;\nnormalTex = normalize( normalTex );\nif( enableDiffuse )\ngl_FragColor = gl_FragColor * texture2D( tDiffuse, vUv );\nif( enableAO )\ngl_FragColor.xyz = gl_FragColor.xyz * texture2D( tAO, vUv ).xyz;\nif( enableSpecular )\nspecularTex = texture2D( tSpecular, vUv ).xyz;\nmat3 tsb = mat3( vTangent, vBinormal, vNormal );\nvec3 finalNormal = tsb * normalTex;\nvec3 normal = normalize( finalNormal );\nvec3 viewPosition = normalize( vViewPosition );\n#if MAX_POINT_LIGHTS > 0\nvec3 pointDiffuse = vec3( 0.0 );\nvec3 pointSpecular = vec3( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointDiffuse += pointDistance * pointLightColor[ i ] * uDiffuseColor * pointDiffuseWeight;\npointSpecular += pointDistance * pointLightColor[ i ] * uSpecularColor * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec3 dirDiffuse = vec3( 0.0 );\nvec3 dirSpecular = vec3( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirDiffuse += directionalLightColor[ i ] * uDiffuseColor * dirDiffuseWeight;\ndirSpecular += directionalLightColor[ i ] * uSpecularColor * dirSpecularWeight;\n}\n#endif\nvec3 totalDiffuse = vec3( 0.0 );\nvec3 totalSpecular = vec3( 0.0 );\n#if MAX_DIR_LIGHTS > 0\ntotalDiffuse += dirDiffuse;\ntotalSpecular += dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalDiffuse += pointDiffuse;\ntotalSpecular += pointSpecular;\n#endif\ngl_FragColor.xyz = gl_FragColor.xyz * totalDiffuse + totalSpecular + ambientLightColor * uAmbientColor;", THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:"attribute vec4 tangent;\n#ifdef VERTEX_TEXTURES\nuniform sampler2D tDisplacement;\nuniform float uDisplacementScale;\nuniform float uDisplacementBias;\n#endif\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\n#if MAX_POINT_LIGHTS > 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),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 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,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,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,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=h.x;else if(h.xe)e=h.y;else if(h.y0?(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;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=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, new THREE.Vector3(0,1,0));this.cameraNY.target.position.add(this.position,new THREE.Vector3(0,-1,0));this.cameraPZ.target.position.add(this.position,new THREE.Vector3(0,0,1));this.cameraNZ.target.position.add(this.position,new THREE.Vector3(0,0,-1))};this.updateCubeMap=function(b,e){var c=this.renderTarget;b.setFaceCulling("back","cw");e.scale.y=-1;e.position.y=2*this.height;e.updateMatrix();c.activeCubeFace=0;b.render(e,this.cameraPX,c);c.activeCubeFace=1;b.render(e,this.cameraNX,c);e.scale.y=1; e.position.y=0;e.updateMatrix();e.scale.x=-1;e.updateMatrix();c.activeCubeFace=2;b.render(e,this.cameraPY,c);e.scale.x=1;e.updateMatrix();b.setFaceCulling("back","ccw");c.activeCubeFace=3;b.render(e,this.cameraNY,c);e.scale.x=-1;e.updateMatrix();b.setFaceCulling("back","cw");c.activeCubeFace=4;b.render(e,this.cameraPZ,c);c.activeCubeFace=5;b.render(e,this.cameraNZ,c);e.scale.x=1;e.updateMatrix();b.setFaceCulling("back","ccw")}}; THREE.FirstPersonCamera=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.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(b){if(b.movementSpeed!==void 0)this.movementSpeed= b.movementSpeed;if(b.lookSpeed!==void 0)this.lookSpeed=b.lookSpeed;if(b.noFly!==void 0)this.noFly=b.noFly;if(b.lookVertical!==void 0)this.lookVertical=b.lookVertical;if(b.autoForward!==void 0)this.autoForward=b.autoForward;if(b.activeLook!==void 0)this.activeLook=b.activeLook;if(b.heightSpeed!==void 0)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==void 0)this.heightCoef=b.heightCoef;if(b.heightMin!==void 0)this.heightMin=b.heightMin;if(b.heightMax!==void 0)this.heightMax=b.heightMax;if(b.constrainVertical!== void 0)this.constrainVertical=b.constrainVertical;if(b.verticalMin!==void 0)this.verticalMin=b.verticalMin;if(b.verticalMax!==void 0)this.verticalMax=b.verticalMax;if(b.domElement!==void 0)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;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));this.onMouseDown=function(b){this.domElement!==document&&this.domElement.focus();b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward= !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,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(),p=m.length,E=0;k=p-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+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}),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(), 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 m=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,n=new THREE.Matrix4,p=!1,u=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);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?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,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 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);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,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){h.push([b[k[p]],b[k[u]],b[k[w]]]);n.push([k[p],k[u],k[w]]);p=u;for(w=u+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 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,m,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?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;fc){u=p.output[o];break}m=u!==void 0?u instanceof THREE.Matrix4?m.multiply(m,u):m.multiply(m,n.matrix):m.multiply(m,n.matrix)}else m=m.multiply(m,n.matrix);c=m;e.push({time:b,pos:[c.n14, c.n24,c.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=e}this.updateMatrix();return this};w.prototype.updateMatrix=function(){this.matrix.identity();for(var b=0;b0&&(this[e.nodeName]=parseFloat(f[0].textContent))}}this.create();return this};J.prototype.create=function(){var b= {},c=this.transparency!==void 0&&this.transparency<1,e;for(e in this)switch(e){case "ambient":case "emission":case "diffuse":case "specular":var f=this[e];if(f instanceof A)if(f.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(f=ua[this.effect.surface.init_from]))b.map=THREE.ImageUtils.loadTexture(Ea+f.init_from),b.map.wrapS=THREE.RepeatWrapping,b.map.wrapT=THREE.RepeatWrapping,b.map.repeat.x=1,b.map.repeat.y=-1}else e=="diffuse"?b.color= f.color.getHex():c||(b[e]=f.color.getHex());break;case "shininess":case "reflectivity":b[e]=this[e];break;case "transparency":if(c)b.transparent=!0,b.opacity=this[e],c=!0}b.shading=Ga;return this.material=new THREE.MeshLambertMaterial(b)};Z.prototype.parse=function(b){for(var c=0;c=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 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:p(t)}):B.type=="ascii_mesh"?X.load({model:f(B.url,O.urlBaseType),callback:p(t)}):B.type=="embedded_mesh"&&(B=O.embeds[B.id])&&X.createModel(B,u(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,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&&(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;hh?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,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,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,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(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)}};