// Three.js r44dev - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.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,g,j;if(e==0)this.r=this.g=this.b=0;else switch(f=Math.floor(b*6),g=b*6-f,b=e*(1-c),j=e*(1-c*g),c=e*(1-c*(1-g)),f){case 1:this.r=j;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=j;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=j;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},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||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||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 g,j,h,k,m,o,p,u,v,t,x=b.geometry,w=x.vertices,A=[],f=0;for(g=x.faces.length;f0:u<0)))if(u=p.dot((new THREE.Vector3).sub(h,v))/u,v=v.addSelf(t.multiplyScalar(u)),j instanceof THREE.Face3)e(v,h,k,m)&&(j={distance:this.origin.distanceTo(v),point:v,face:j,object:b},A.push(j));else if(j instanceof THREE.Face4&&(e(v,h,k,o)||e(v,k,m,o)))j={distance:this.origin.distanceTo(v),point:v,face:j,object:b},A.push(j);A.sort(function(b,c){return b.distance-c.distance});return A}else return[]}}; THREE.Rectangle=function(){function b(){j=f-c;h=g-e}var c,e,f,g,j,h,k=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return j};this.getHeight=function(){return h};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(h,j,p,u){k=!1;c=h;e=j;f=p;g=u;b()};this.addPoint=function(h,j){k?(k=!1,c=h,e=j,f=h,g=j):(c=ch?f:h,g=g>j?g:j);b()};this.add3Points= function(h,j,p,u,v,t){k?(k=!1,c=hp?h>v?h:v:p>v?p:v,g=j>u?j>t?j:t:u>t?u:t):(c=hp?h>v?h>f?h:f:v>f?v:f:p>v?p>f?p:f:v>f?v:f,g=j>u?j>t?j>g?j:g:t>g?t:g:u>t?u>g?u:g:t>g?t:g);b()};this.addRectangle=function(h){k?(k=!1,c=h.getLeft(),e=h.getTop(),f=h.getRight(),g=h.getBottom()):(c=ch.getRight()?f:h.getRight(),g=g> h.getBottom()?g:h.getBottom());b()};this.inflate=function(h){c-=h;e-=h;f+=h;g+=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(g,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){k=!0;g=f=e=c=0;b()};this.isEmpty=function(){return k}};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,g,j,h,k,m,o,p,u,v,t,x,w){this.set(b||1,c||0,e||0,f||0,g||0,j||1,h||0,k||0,m||0,o||0,p||1,u||0,v||0,t||0,x||0,w||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,g,j,h,k,m,o,p,u,v,t,x,w){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=g;this.n22=j;this.n23=h;this.n24=k;this.n31=m;this.n32=o;this.n33=p;this.n34=u;this.n41=v;this.n42=t;this.n43=x;this.n44=w;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,g=THREE.Matrix4.__v2,j=THREE.Matrix4.__v3;j.sub(b,c).normalize();if(j.length()===0)j.z=1;f.cross(e,j).normalize();f.length()===0&&(j.x+=1.0E-4,f.cross(e,j).normalize());g.cross(j,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=j.x;this.n21=f.y;this.n22=g.y;this.n23=j.y;this.n31=f.z;this.n32=g.z;this.n33=j.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,g=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)*g; b.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*g;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,g=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*g;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*g;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*g;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*g;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,g=b.n13,j=b.n14,h=b.n21,k=b.n22,m=b.n23,o=b.n24,p=b.n31,u=b.n32,v=b.n33,t=b.n34,x=b.n41,w=b.n42,A=b.n43,y=b.n44,G=c.n11,D=c.n12, I=c.n13,J=c.n14,C=c.n21,B=c.n22,L=c.n23,E=c.n24,V=c.n31,H=c.n32,S=c.n33,K=c.n34,Q=c.n41,n=c.n42,T=c.n43,X=c.n44;this.n11=e*G+f*C+g*V+j*Q;this.n12=e*D+f*B+g*H+j*n;this.n13=e*I+f*L+g*S+j*T;this.n14=e*J+f*E+g*K+j*X;this.n21=h*G+k*C+m*V+o*Q;this.n22=h*D+k*B+m*H+o*n;this.n23=h*I+k*L+m*S+o*T;this.n24=h*J+k*E+m*K+o*X;this.n31=p*G+u*C+v*V+t*Q;this.n32=p*D+u*B+v*H+t*n;this.n33=p*I+u*L+v*S+t*T;this.n34=p*J+u*E+v*K+t*X;this.n41=x*G+w*C+A*V+y*Q;this.n42=x*D+w*B+A*H+y*n;this.n43=x*I+w*L+A*S+y*T;this.n44=x*J+w* E+A*K+y*X;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,g=this.n21,j=this.n22,h=this.n23,k=this.n24,m=this.n31,o=this.n32,p=this.n33,u=this.n34,v=this.n41,t=this.n42,x=this.n43,w=this.n44;return f*h*o*v-e*k*o*v-f*j*p*v+c*k*p*v+e*j*u*v-c*h*u*v-f*h*m*t+e*k*m*t+f*g*p*t-b*k*p*t-e*g*u*t+b*h*u*t+f*j*m*x-c*k*m*x-f*g*o*x+b*k*o*x+c*g*u*x-b*j*u*x-e*j*m*w+c*h*m*w+e*g*o*w-b*h*o*w-c*g*p*w+b*j*p*w}, 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),g=1-e,j=b.x,h=b.y,k=b.z,m=g*j,o=g*h;this.set(m*j+e,m*h-f*k,m*k+f*h,0,m*h+f*k,o*h+e,o*k-f*j,0,m*k-f*h,o*k+f*j,g*k*k+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,g=b.z,j=Math.cos(e),e=Math.sin(e),h=Math.cos(f),f=Math.sin(f),k=Math.cos(g),g=Math.sin(g);switch(c){case "YXZ":var m= h*k,o=h*g,p=f*k,u=f*g;this.n11=m+u*e;this.n12=p*e-o;this.n13=j*f;this.n21=j*g;this.n22=j*k;this.n23=-e;this.n31=o*e-p;this.n32=u+m*e;this.n33=j*h;break;case "ZXY":m=h*k;o=h*g;p=f*k;u=f*g;this.n11=m-u*e;this.n12=-j*g;this.n13=p+o*e;this.n21=o+p*e;this.n22=j*k;this.n23=u-m*e;this.n31=-j*f;this.n32=e;this.n33=j*h;break;case "ZYX":m=j*k;o=j*g;p=e*k;u=e*g;this.n11=h*k;this.n12=p*f-o;this.n13=m*f+u;this.n21=h*g;this.n22=u*f+m;this.n23=o*f-p;this.n31=-f;this.n32=e*h;this.n33=j*h;break;case "YZX":m=j*h;o= j*f;p=e*h;u=e*f;this.n11=h*k;this.n12=u-m*g;this.n13=p*g+o;this.n21=g;this.n22=j*k;this.n23=-e*k;this.n31=-f*k;this.n32=o*g+p;this.n33=m-u*g;break;case "XZY":m=j*h;o=j*f;p=e*h;u=e*f;this.n11=h*k;this.n12=-g;this.n13=f*k;this.n21=m*g+u;this.n22=j*k;this.n23=o*g-p;this.n31=p*g-o;this.n32=e*k;this.n33=u*g+m;break;default:m=j*k,o=j*g,p=e*k,u=e*g,this.n11=h*k,this.n12=-h*g,this.n13=f,this.n21=o+p*f,this.n22=m-u*f,this.n23=-e*h,this.n31=u-m*f,this.n32=p+o*f,this.n33=j*h}return this},setRotationFromQuaternion:function(b){var c= b.x,e=b.y,f=b.z,g=b.w,j=c+c,h=e+e,k=f+f,b=c*j,m=c*h;c*=k;var o=e*h;e*=k;f*=k;j*=g;h*=g;g*=k;this.n11=1-(o+f);this.n12=m-g;this.n13=c+h;this.n21=m+g;this.n22=1-(b+f);this.n23=e-j;this.n31=c-h;this.n32=e+j;this.n33=1-(b+o);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,g=THREE.Matrix4.__m2; f.identity();f.setRotationFromQuaternion(c);g.setScale(e.x,e.y,e.z);this.multiply(f,g);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,e){var f=THREE.Matrix4.__v1,g=THREE.Matrix4.__v2,j=THREE.Matrix4.__v3;f.set(this.n11,this.n21,this.n31);g.set(this.n12,this.n22,this.n32);j.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=g.length();e.z=j.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,g=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*g;this.n23= b.n23*g;this.n33=b.n33*g}}; THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,h=b.n21,k=b.n22,m=b.n23,o=b.n24,p=b.n31,u=b.n32,v=b.n33,t=b.n34,x=b.n41,w=b.n42,A=b.n43,y=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=m*t*w-o*v*w+o*u*A-k*t*A-m*u*y+k*v*y;c.n12=j*v*w-g*t*w-j*u*A+f*t*A+g*u*y-f*v*y;c.n13=g*o*w-j*m*w+j*k*A-f*o*A-g*k*y+f*m*y;c.n14=j*m*u-g*o*u-j*k*v+f*o*v+g*k*t-f*m*t;c.n21=o*v*x-m*t*x-o*p*A+h*t*A+m*p*y-h*v*y;c.n22=g*t*x-j*v*x+j*p*A-e*t*A-g*p*y+e*v*y;c.n23=j*m*x-g*o*x-j*h*A+e*o*A+g*h*y-e*m*y;c.n24= g*o*p-j*m*p+j*h*v-e*o*v-g*h*t+e*m*t;c.n31=k*t*x-o*u*x+o*p*w-h*t*w-k*p*y+h*u*y;c.n32=j*u*x-f*t*x-j*p*w+e*t*w+f*p*y-e*u*y;c.n33=g*o*x-j*k*x+j*h*w-e*o*w-f*h*y+e*k*y;c.n34=j*k*p-f*o*p-j*h*u+e*o*u+f*h*t-e*k*t;c.n41=m*u*x-k*v*x-m*p*w+h*v*w+k*p*A-h*u*A;c.n42=f*v*x-g*u*x+g*p*w-e*v*w-f*p*A+e*u*A;c.n43=g*k*x-f*m*x-g*h*w+e*m*w+f*h*A-e*k*A;c.n44=f*m*p-g*k*p+g*h*u-e*m*u-f*h*v+e*k*v;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,g=-b.n33*b.n21+b.n31*b.n23,j=b.n32*b.n21-b.n31*b.n22,h=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,m=-b.n32*b.n11+b.n31*b.n12,o=b.n23*b.n12-b.n22*b.n13,p=-b.n23*b.n11+b.n21*b.n13,u=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*h+b.n31*o;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*g;e[2]=b*j;e[3]=b*h;e[4]=b*k;e[5]=b*m;e[6]=b*o;e[7]=b*p;e[8]=b*u;return c}; THREE.Matrix4.makeFrustum=function(b,c,e,f,g,j){var h;h=new THREE.Matrix4;h.n11=2*g/(c-b);h.n12=0;h.n13=(c+b)/(c-b);h.n14=0;h.n21=0;h.n22=2*g/(f-e);h.n23=(f+e)/(f-e);h.n24=0;h.n31=0;h.n32=0;h.n33=-(j+g)/(j-g);h.n34=-2*j*g/(j-g);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(b,c,e,f){var g,b=e*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*c,b*c,g,b,e,f)}; THREE.Matrix4.makeOrtho=function(b,c,e,f,g,j){var h,k,m,o;h=new THREE.Matrix4;k=c-b;m=e-f;o=j-g;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((c+b)/k);h.n21=0;h.n22=2/m;h.n23=0;h.n24=-((e+f)/m);h.n31=0;h.n32=0;h.n33=-2/o;h.n34=-((j+g)/o);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};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.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._vector=new THREE.Vector3;this.name=""}; 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)},addChild: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)}},removeChild:function(b){var c=this.children.indexOf(b);if(c!==-1)b.parent=void 0,this.children.splice(c,1)},getChildByName:function(b,c){var e,f,g;e=0;for(f=this.children.length;e=1)return e.w=b.w,e.x=b.x,e.y=b.y,e.z=b.z,e;var j=Math.acos(g),h=Math.sqrt(1-g*g);if(Math.abs(h)<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;g=Math.sin((1-f)*j)/h;f=Math.sin(f*j)/h;e.w=b.w*g+c.w*f;e.x=b.x*g+c.x*f;e.y=b.y*g+c.y*f;e.z=b.z*g+c.z*f;return e}; THREE.Vertex=function(b){this.position=b||new THREE.Vector3};THREE.Face3=function(b,c,e,f,g,j){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=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,c,e,f,g,j,h){this.a=b;this.b=c;this.c=e;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3};THREE.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="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1}; THREE.Geometry.prototype={constructor:THREE.Geometry,computeCentroids:function(){var b,c,e;b=0;for(c=this.faces.length;b0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var 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?j:j+1;e[3]=j>this.points.length-3?j:j+2;o=this.points[e[0]];p=this.points[e[1]]; u=this.points[e[2]];v=this.points[e[3]];k=h*h;m=h*k;f.x=c(o.x,p.x,u.x,v.x,h,k,m);f.y=c(o.y,p.y,u.y,v.y,h,k,m);f.z=c(o.z,p.z,u.z,v.z,h,k,m);return f};this.getControlPointsArray=function(){var b,c,e=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(;f=0&&g>=0&&j>=0&&k>=0?!0:h<0&&g<0||j<0&&k<0?!1:(h<0?e=Math.max(e,h/(h-g)):g<0&&(f=Math.min(f,h/(h-g))),j<0?e=Math.max(e,j/(j-k)):k<0&&(f=Math.min(f,j/(j-k))),fn&&h.positionScreen.z0&&J.z<1))ea=D[G]=D[G]||new THREE.RenderableParticle,G++,y=ea,y.x=J.x/J.w,y.y=J.y/J.w,y.z=J.z,y.rotation=P.rotation.z,y.scale.x=P.scale.x*Math.abs(y.x- (J.x+g.projectionMatrix.n11)/(J.w+g.projectionMatrix.n14)),y.scale.y=P.scale.y*Math.abs(y.y-(J.y+g.projectionMatrix.n22)/(J.w+g.projectionMatrix.n24)),y.materials=P.materials,I.push(y);j&&I.sort(c);return I}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,g,j;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;g=e/2;j=f/2};this.render=function(e,f){var m,o,p,u,v,t,x,w;b=c.projectScene(e,f);m=0;for(o=b.length;m0&&(e(THREE.NormalBlending),c(1),g("rgba("+Math.floor(x.r*255)+","+Math.floor(x.g*255)+","+ Math.floor(x.b*255)+","+w+")"),t.fillRect(Math.floor(na.getX()),Math.floor(na.getY()),Math.floor(na.getWidth()),Math.floor(na.getHeight()))),na.empty())};this.render=function(b,m){function o(b){var c,e,f,h=b.lights;oa.setRGB(0,0,0);Da.setRGB(0,0,0);Ga.setRGB(0,0,0);b=0;for(c=h.length;b>1,ka=o.height>>1,j=h.scale.x*u,m=h.scale.y*v,k=j*p,n=m*ka,aa.set(b.x-k,b.y-n,b.x+k,b.y+n),ra.instersects(aa)&&(t.save(),t.translate(b.x,b.y),t.rotate(-h.rotation),t.scale(j,-m),t.translate(-p,-ka),t.drawImage(o,0,0),t.restore())}else j instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*u,n=h.scale.y*v,aa.set(b.x-k,b.y-n,b.x+k,b.y+n),ra.instersects(aa)&&(f(j.color.getContextStyle()),g(j.color.getContextStyle()),t.save(),t.translate(b.x,b.y),t.rotate(-h.rotation),t.scale(k, n),j.program(t),t.restore()))}function w(b,h,g,j){c(j.opacity);e(j.blending);t.beginPath();t.moveTo(b.positionScreen.x,b.positionScreen.y);t.lineTo(h.positionScreen.x,h.positionScreen.y);t.closePath();if(j instanceof THREE.LineBasicMaterial){b=j.linewidth;if(I!=b)t.lineWidth=I=b;b=j.linecap;if(J!=b)t.lineCap=J=b;b=j.linejoin;if(C!=b)t.lineJoin=C=b;f(j.color.getContextStyle());t.stroke();aa.inflate(j.linewidth*2)}}function A(b,f,h,g,k,u,o,t,ka){j.data.vertices+=3;j.data.faces++;c(t.opacity);e(t.blending); K=b.positionScreen.x;Q=b.positionScreen.y;n=f.positionScreen.x;T=f.positionScreen.y;X=h.positionScreen.x;M=h.positionScreen.y;D(K,Q,n,T,X,M);if(t instanceof THREE.MeshBasicMaterial)if(t.map)t.map.mapping instanceof THREE.UVMapping&&(la=o.uvs[0],Za(K,Q,n,T,X,M,la[g].u,la[g].v,la[k].u,la[k].v,la[u].u,la[u].v,t.map));else if(t.envMap){if(t.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=m.matrixWorldInverse,sa.copy(o.vertexNormalsWorld[0]),ma=(sa.x*b.n11+sa.y*b.n12+sa.z*b.n13)*0.5+0.5,Fa= -(sa.x*b.n21+sa.y*b.n22+sa.z*b.n23)*0.5+0.5,sa.copy(o.vertexNormalsWorld[1]),ya=(sa.x*b.n11+sa.y*b.n12+sa.z*b.n13)*0.5+0.5,Ia=-(sa.x*b.n21+sa.y*b.n22+sa.z*b.n23)*0.5+0.5,sa.copy(o.vertexNormalsWorld[2]),Ja=(sa.x*b.n11+sa.y*b.n12+sa.z*b.n13)*0.5+0.5,Ta=-(sa.x*b.n21+sa.y*b.n22+sa.z*b.n23)*0.5+0.5,Za(K,Q,n,T,X,M,ma,Fa,ya,Ia,Ja,Ta,t.envMap)}else t.wireframe?Ka(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(t.color);else if(t instanceof THREE.MeshLambertMaterial)t.map&&!t.wireframe&& (t.map.mapping instanceof THREE.UVMapping&&(la=o.uvs[0],Za(K,Q,n,T,X,M,la[g].u,la[g].v,la[k].u,la[k].v,la[u].u,la[u].v,t.map)),e(THREE.SubtractiveBlending)),xa?!t.wireframe&&t.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==3?(P.r=ea.r=Z.r=oa.r,P.g=ea.g=Z.g=oa.g,P.b=ea.b=Z.b=oa.b,p(ka,o.v1.positionWorld,o.vertexNormalsWorld[0],P),p(ka,o.v2.positionWorld,o.vertexNormalsWorld[1],ea),p(ka,o.v3.positionWorld,o.vertexNormalsWorld[2],Z),da.r=(ea.r+Z.r)*0.5,da.g=(ea.g+Z.g)*0.5,da.b=(ea.b+Z.b)* 0.5,pa=Xa(P,ea,Z,da),Ua(K,Q,n,T,X,M,0,0,1,0,0,1,pa)):(va.r=oa.r,va.g=oa.g,va.b=oa.b,p(ka,o.centroidWorld,o.normalWorld,va),Y.r=Math.max(0,Math.min(t.color.r*va.r,1)),Y.g=Math.max(0,Math.min(t.color.g*va.g,1)),Y.b=Math.max(0,Math.min(t.color.b*va.b,1)),t.wireframe?Ka(Y,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(Y)):t.wireframe?Ka(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(t.color);else if(t instanceof THREE.MeshDepthMaterial)U=m.near,ja=m.far,P.r=P.g= P.b=1-Oa(b.positionScreen.z,U,ja),ea.r=ea.g=ea.b=1-Oa(f.positionScreen.z,U,ja),Z.r=Z.g=Z.b=1-Oa(h.positionScreen.z,U,ja),da.r=(ea.r+Z.r)*0.5,da.g=(ea.g+Z.g)*0.5,da.b=(ea.b+Z.b)*0.5,pa=Xa(P,ea,Z,da),Ua(K,Q,n,T,X,M,0,0,1,0,0,1,pa);else if(t instanceof THREE.MeshNormalMaterial)Y.r=Va(o.normalWorld.x),Y.g=Va(o.normalWorld.y),Y.b=Va(o.normalWorld.z),t.wireframe?Ka(Y,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(Y)}function y(b,f,h,g,k,u,o,t,ka){j.data.vertices+=4;j.data.faces++;c(t.opacity); e(t.blending);if(t.map||t.envMap)A(b,f,g,0,1,3,o,t,ka),A(k,h,u,1,2,3,o,t,ka);else if(K=b.positionScreen.x,Q=b.positionScreen.y,n=f.positionScreen.x,T=f.positionScreen.y,X=h.positionScreen.x,M=h.positionScreen.y,W=g.positionScreen.x,ha=g.positionScreen.y,ca=k.positionScreen.x,fa=k.positionScreen.y,ga=u.positionScreen.x,$=u.positionScreen.y,t instanceof THREE.MeshBasicMaterial)G(K,Q,n,T,X,M,W,ha),t.wireframe?Ka(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(t.color);else if(t instanceof THREE.MeshLambertMaterial)xa?!t.wireframe&&t.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==4?(P.r=ea.r=Z.r=da.r=oa.r,P.g=ea.g=Z.g=da.g=oa.g,P.b=ea.b=Z.b=da.b=oa.b,p(ka,o.v1.positionWorld,o.vertexNormalsWorld[0],P),p(ka,o.v2.positionWorld,o.vertexNormalsWorld[1],ea),p(ka,o.v4.positionWorld,o.vertexNormalsWorld[3],Z),p(ka,o.v3.positionWorld,o.vertexNormalsWorld[2],da),pa=Xa(P,ea,Z,da),D(K,Q,n,T,W,ha),Ua(K,Q,n,T,W,ha,0,0,1,0,0,1,pa),D(ca,fa,X,M,ga,$),Ua(ca,fa,X,M,ga,$,1,0,1,1,0,1,pa)):(va.r= oa.r,va.g=oa.g,va.b=oa.b,p(ka,o.centroidWorld,o.normalWorld,va),Y.r=Math.max(0,Math.min(t.color.r*va.r,1)),Y.g=Math.max(0,Math.min(t.color.g*va.g,1)),Y.b=Math.max(0,Math.min(t.color.b*va.b,1)),G(K,Q,n,T,X,M,W,ha),t.wireframe?Ka(Y,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(Y)):(G(K,Q,n,T,X,M,W,ha),t.wireframe?Ka(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(t.color));else if(t instanceof THREE.MeshNormalMaterial)Y.r=Va(o.normalWorld.x),Y.g=Va(o.normalWorld.y), Y.b=Va(o.normalWorld.z),G(K,Q,n,T,X,M,W,ha),t.wireframe?Ka(Y,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(Y);else if(t instanceof THREE.MeshDepthMaterial)U=m.near,ja=m.far,P.r=P.g=P.b=1-Oa(b.positionScreen.z,U,ja),ea.r=ea.g=ea.b=1-Oa(f.positionScreen.z,U,ja),Z.r=Z.g=Z.b=1-Oa(g.positionScreen.z,U,ja),da.r=da.g=da.b=1-Oa(h.positionScreen.z,U,ja),pa=Xa(P,ea,Z,da),D(K,Q,n,T,W,ha),Ua(K,Q,n,T,W,ha,0,0,1,0,0,1,pa),D(ca,fa,X,M,ga,$),Ua(ca,fa,X,M,ga,$,1,0,1,1,0,1,pa)}function D(b,c,e,f, h,g){t.beginPath();t.moveTo(b,c);t.lineTo(e,f);t.lineTo(h,g);t.lineTo(b,c);t.closePath()}function G(b,c,e,f,h,g,j,k){t.beginPath();t.moveTo(b,c);t.lineTo(e,f);t.lineTo(h,g);t.lineTo(j,k);t.lineTo(b,c);t.closePath()}function Ka(b,c,e,h){if(I!=c)t.lineWidth=I=c;if(J!=e)t.lineCap=J=e;if(C!=h)t.lineJoin=C=h;f(b.getContextStyle());t.stroke();aa.inflate(c*2)}function La(b){g(b.getContextStyle());t.fill()}function Za(b,c,e,f,h,j,k,n,m,o,u,p,ka){if(ka.image.width!=0){if(ka.needsUpdate==!0||ia[ka.id]==void 0){var v= ka.wrapS==THREE.RepeatWrapping,Ba=ka.wrapT==THREE.RepeatWrapping;ia[ka.id]=t.createPattern(ka.image,v&&Ba?"repeat":v&&!Ba?"repeat-x":!v&&Ba?"repeat-y":"no-repeat");ka.needsUpdate=!1}g(ia[ka.id]);var v=ka.offset.x/ka.repeat.x,Ba=ka.offset.y/ka.repeat.y,x=(ka.image.width-1)*ka.repeat.x,ka=(ka.image.height-1)*ka.repeat.y,k=(k+v)*x,n=(n+Ba)*ka,m=(m+v)*x,o=(o+Ba)*ka,u=(u+v)*x,p=(p+Ba)*ka;e-=b;f-=c;h-=b;j-=c;m-=k;o-=n;u-=k;p-=n;v=1/(m*p-u*o);ka=(p*e-o*h)*v;o=(p*f-o*j)*v;e=(m*h-u*e)*v;f=(m*j-u*f)*v;b=b- ka*k-e*n;c=c-o*k-f*n;t.save();t.transform(ka,o,e,f,b,c);t.fill();t.restore()}}function Ua(b,c,e,f,h,g,j,k,n,m,o,u,ka){var p,v;p=ka.width-1;v=ka.height-1;j*=p;k*=v;n*=p;m*=v;o*=p;u*=v;e-=b;f-=c;h-=b;g-=c;n-=j;m-=k;o-=j;u-=k;v=1/(n*u-o*m);p=(u*e-m*h)*v;m=(u*f-m*g)*v;e=(n*h-o*e)*v;f=(n*g-o*f)*v;b=b-p*j-e*k;c=c-m*j-f*k;t.save();t.transform(p,m,e,f,b,c);t.clip();t.drawImage(ka,0,0);t.restore()}function Xa(b,c,e,f){var h=~~(b.r*255),g=~~(b.g*255),b=~~(b.b*255),j=~~(c.r*255),k=~~(c.g*255),c=~~(c.b*255), n=~~(e.r*255),m=~~(e.g*255),e=~~(e.b*255),t=~~(f.r*255),o=~~(f.g*255),f=~~(f.b*255);za[0]=h<0?0:h>255?255:h;za[1]=g<0?0:g>255?255:g;za[2]=b<0?0:b>255?255:b;za[4]=j<0?0:j>255?255:j;za[5]=k<0?0:k>255?255:k;za[6]=c<0?0:c>255?255:c;za[8]=n<0?0:n>255?255:n;za[9]=m<0?0:m>255?255:m;za[10]=e<0?0:e>255?255:e;za[12]=t<0?0:t>255?255:t;za[13]=o<0?0:o>255?255:o;za[14]=f<0?0:f>255?255:f;Aa.putImageData(ka,0,0);Ba.drawImage(R,0,0);return Wa}function Oa(b,c,e){b=(b-c)/(e-c);return b*b*(3-2*b)}function Va(b){b=(b+ 1)*0.5;return b<0?0:b>1?1:b}function Ma(b,c){var e=c.x-b.x,f=c.y-b.y,h=e*e+f*f;h!=0&&(h=1/Math.sqrt(h),e*=h,f*=h,c.x+=e,c.y+=f,b.x-=e,b.y-=f)}var Ya,$a,qa,Ca,Na,F,z,N;this.autoClear?this.clear():t.setTransform(1,0,0,-1,u,v);j.data.vertices=0;j.data.faces=0;h=k.projectScene(b,m,this.sortElements);(xa=b.lights.length>0)&&o(b);Ya=0;for($a=h.length;Ya<$a;Ya++){qa=h[Ya];aa.empty();if(qa instanceof THREE.RenderableParticle){B=qa;B.x*=u;B.y*=v;Ca=0;for(Na=qa.materials.length;Ca0&&(e.r+=g.color.r*j,e.g+=g.color.g*j,e.b+=g.color.b*j)):g instanceof THREE.PointLight&&(V.sub(g.position,c.centroidWorld),V.normalize(),j=c.normalWorld.dot(V)*g.intensity,j>0&&(e.r+=g.color.r*j,e.g+=g.color.g*j,e.b+=g.color.b*j))}function c(c,e,h,k,n,t){j.data.vertices+=3;j.data.faces++;K=f(Q++);K.setAttribute("d", "M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+e.positionScreen.x+" "+e.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?I.copy(n.color):n instanceof THREE.MeshLambertMaterial?D?(J.r=C.r,J.g=C.g,J.b=C.b,b(t,k,J),I.r=Math.max(0,Math.min(n.color.r*J.r,1)),I.g=Math.max(0,Math.min(n.color.g*J.g,1)),I.b=Math.max(0,Math.min(n.color.b*J.b,1))):I.copy(n.color):n instanceof THREE.MeshDepthMaterial?(E=1-n.__2near/(n.__farPlusNear-k.z*n.__farMinusNear), I.setRGB(E,E,E)):n instanceof THREE.MeshNormalMaterial&&I.setRGB(g(k.normalWorld.x),g(k.normalWorld.y),g(k.normalWorld.z));n.wireframe?K.setAttribute("style","fill: none; stroke: "+I.getContextStyle()+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):K.setAttribute("style","fill: "+I.getContextStyle()+"; fill-opacity: "+n.opacity);m.appendChild(K)}function e(c,e,h,k,n,t,o){j.data.vertices+=4;j.data.faces++; K=f(Q++);K.setAttribute("d","M "+c.positionScreen.x+" "+c.positionScreen.y+" L "+e.positionScreen.x+" "+e.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?I.copy(t.color):t instanceof THREE.MeshLambertMaterial?D?(J.r=C.r,J.g=C.g,J.b=C.b,b(o,n,J),I.r=Math.max(0,Math.min(t.color.r*J.r,1)),I.g=Math.max(0,Math.min(t.color.g*J.g,1)),I.b=Math.max(0,Math.min(t.color.b*J.b,1))):I.copy(t.color):t instanceof THREE.MeshDepthMaterial?(E=1-t.__2near/(t.__farPlusNear-n.z*t.__farMinusNear),I.setRGB(E,E,E)):t instanceof THREE.MeshNormalMaterial&&I.setRGB(g(n.normalWorld.x),g(n.normalWorld.y),g(n.normalWorld.z));t.wireframe?K.setAttribute("style","fill: none; stroke: "+I.getContextStyle()+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):K.setAttribute("style","fill: "+I.getContextStyle()+"; fill-opacity: "+ t.opacity);m.appendChild(K)}function f(b){H[b]==null&&(H[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),T==0&&H[b].setAttribute("shape-rendering","crispEdges"));return H[b]}function g(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var j=this,h=null,k=new THREE.Projector,m=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,p,u,v,t,x,w,A,y=new THREE.Rectangle,G=new THREE.Rectangle,D=!1,I=new THREE.Color(16777215),J=new THREE.Color(16777215),C=new THREE.Color(0),B=new THREE.Color(0), L=new THREE.Color(0),E,V=new THREE.Vector3,H=[],S=[],K,Q,n,T=1;this.domElement=m;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":T=1;break;case "low":T=0}};this.setSize=function(b,c){o=b;p=c;u=o/2;v=p/2;m.setAttribute("viewBox",-u+" "+-v+" "+o+" "+p);m.setAttribute("width",o);m.setAttribute("height",p);y.set(-u,-v,u,v)};this.clear=function(){for(;m.childNodes.length>0;)m.removeChild(m.childNodes[0])};this.render= function(b,f){var g,o,p,I,J,H,E,P;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;h=k.projectScene(b,f,this.sortElements);n=Q=0;if(D=b.lights.length>0){E=b.lights;C.setRGB(0,0,0);B.setRGB(0,0,0);L.setRGB(0,0,0);g=0;for(o=E.length;g 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#ifdef PHONG\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\n#endif", lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i ++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 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#ifdef PHONG\nvPointLight[ i ] = vec4( lVector, lDistance );\n#endif\n}\n#endif\n}", lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse = vec4( vec3( 0.0 ), 1.0 );\nvec4 pointSpecular = vec4( vec3( 0.0 ), 1.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 += mColor * pointDiffuseWeight * pointDistance;\npointSpecular += mSpecular * pointSpecularWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( vec3( 0.0 ), 1.0 );\nvec4 dirSpecular = vec4( vec3( 0.0 ), 1.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 += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", 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;\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 + shadowBias ) )\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 + shadowBias ) )\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,g={};for(c=0;c=0)n.bindBuffer(n.ARRAY_BUFFER,g.__webglVertexBuffer),n.vertexAttribPointer(b.position,3,n.FLOAT,!1,0,0);else if(j.morphTargetBase){c= h.program.attributes;j.morphTargetBase!==-1?(n.bindBuffer(n.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[j.morphTargetBase]),n.vertexAttribPointer(c.position,3,n.FLOAT,!1,0,0)):c.position>=0&&(n.bindBuffer(n.ARRAY_BUFFER,g.__webglVertexBuffer),n.vertexAttribPointer(c.position,3,n.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var f=0,m=j.morphTargetForcedOrder,t=j.morphTargetInfluences;fo&&(u=p,o=t[u]);n.bindBuffer(n.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[u]);n.vertexAttribPointer(c["morphTarget"+f],3,n.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[f]=o;m[u]=1;o=-1;f++}}h.program.uniforms.morphTargetInfluences!==null&&n.uniform1fv(h.program.uniforms.morphTargetInfluences, j.__webglMorphTargetInfluences)}if(g.__webglCustomAttributes)for(k in g.__webglCustomAttributes)b[k]>=0&&(c=g.__webglCustomAttributes[k],n.bindBuffer(n.ARRAY_BUFFER,c.buffer),n.vertexAttribPointer(b[k],c.size,n.FLOAT,!1,0,0));b.color>=0&&(n.bindBuffer(n.ARRAY_BUFFER,g.__webglColorBuffer),n.vertexAttribPointer(b.color,3,n.FLOAT,!1,0,0));b.normal>=0&&(n.bindBuffer(n.ARRAY_BUFFER,g.__webglNormalBuffer),n.vertexAttribPointer(b.normal,3,n.FLOAT,!1,0,0));b.tangent>=0&&(n.bindBuffer(n.ARRAY_BUFFER,g.__webglTangentBuffer), n.vertexAttribPointer(b.tangent,4,n.FLOAT,!1,0,0));b.uv>=0&&(g.__webglUVBuffer?(n.bindBuffer(n.ARRAY_BUFFER,g.__webglUVBuffer),n.vertexAttribPointer(b.uv,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(b.uv)):n.disableVertexAttribArray(b.uv));b.uv2>=0&&(g.__webglUV2Buffer?(n.bindBuffer(n.ARRAY_BUFFER,g.__webglUV2Buffer),n.vertexAttribPointer(b.uv2,2,n.FLOAT,!1,0,0),n.enableVertexAttribArray(b.uv2)):n.disableVertexAttribArray(b.uv2));h.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>= 0&&(n.bindBuffer(n.ARRAY_BUFFER,g.__webglSkinVertexABuffer),n.vertexAttribPointer(b.skinVertexA,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),n.vertexAttribPointer(b.skinVertexB,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),n.vertexAttribPointer(b.skinIndex,4,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),n.vertexAttribPointer(b.skinWeight,4,n.FLOAT,!1,0,0));j instanceof THREE.Mesh?(h.wireframe?(n.lineWidth(h.wireframeLinewidth), n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),n.drawElements(n.LINES,g.__webglLineCount,n.UNSIGNED_SHORT,0)):(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),n.drawElements(n.TRIANGLES,g.__webglFaceCount,n.UNSIGNED_SHORT,0)),Q.data.vertices+=g.__webglFaceCount,Q.data.faces+=g.__webglFaceCount/3,Q.data.drawCalls++):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?n.LINE_STRIP:n.LINES,n.lineWidth(h.linewidth),n.drawArrays(j,0,g.__webglLineCount),Q.data.drawCalls++):j instanceof THREE.ParticleSystem?(n.drawArrays(n.POINTS,0,g.__webglParticleCount),Q.data.drawCalls++):j instanceof THREE.Ribbon&&(n.drawArrays(n.TRIANGLE_STRIP,0,g.__webglVertexCount),Q.data.drawCalls++)}}function g(b,c,e){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=n.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=n.createBuffer();b.hasPos&&(n.bindBuffer(n.ARRAY_BUFFER,b.__webglVertexBuffer),n.bufferData(n.ARRAY_BUFFER,b.positionArray,n.DYNAMIC_DRAW),n.enableVertexAttribArray(c.attributes.position), n.vertexAttribPointer(c.attributes.position,3,n.FLOAT,!1,0,0));if(b.hasNormal){n.bindBuffer(n.ARRAY_BUFFER,b.__webglNormalBuffer);if(e==THREE.FlatShading){var f,g,h,j,k,m,t,o,u,p,v=b.count*3;for(p=0;p=0;e--)b[e].object==c&&b.splice(e,1)}function I(b){function c(b){var g=[];e=0;for(f=b.length;e65535&&(t[n].counter+=1,m=t[n].hash+"_"+t[n].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:k,vertices:0,numMorphTargets:u})),b.geometryGroups[m].faces.push(g),b.geometryGroups[m].vertices+=j}function J(b,c,e){b.push({buffer:c,object:e,opaque:{list:[],count:0},transparent:{list:[], count:0}})}function C(b){if(b!=fa){switch(b){case THREE.AdditiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.SRC_ALPHA,n.ONE);break;case THREE.SubtractiveBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO,n.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:n.blendEquation(n.FUNC_ADD);n.blendFunc(n.ZERO,n.SRC_COLOR);break;default:n.blendEquationSeparate(n.FUNC_ADD,n.FUNC_ADD),n.blendFuncSeparate(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA,n.ONE,n.ONE_MINUS_SRC_ALPHA)}fa=b}}function B(b,c,e){(e.width& e.width-1)==0&&(e.height&e.height-1)==0?(n.texParameteri(b,n.TEXTURE_WRAP_S,K(c.wrapS)),n.texParameteri(b,n.TEXTURE_WRAP_T,K(c.wrapT)),n.texParameteri(b,n.TEXTURE_MAG_FILTER,K(c.magFilter)),n.texParameteri(b,n.TEXTURE_MIN_FILTER,K(c.minFilter)),n.generateMipmap(b)):(n.texParameteri(b,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(b,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(b,n.TEXTURE_MAG_FILTER,S(c.magFilter)),n.texParameteri(b,n.TEXTURE_MIN_FILTER,S(c.minFilter)))}function L(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglTexture= n.createTexture(),b.__webglInit=!0;n.activeTexture(n.TEXTURE0+c);n.bindTexture(n.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?n.texImage2D(n.TEXTURE_2D,0,K(b.format),b.image.width,b.image.height,0,K(b.format),n.UNSIGNED_BYTE,b.image.data):n.texImage2D(n.TEXTURE_2D,0,n.RGBA,n.RGBA,n.UNSIGNED_BYTE,b.image);B(n.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else n.activeTexture(n.TEXTURE0+c),n.bindTexture(n.TEXTURE_2D,b.__webglTexture)}function E(b){var c=b instanceof THREE.WebGLRenderTargetCube; if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglRenderbuffer=n.createRenderbuffer();b.__webglTexture=n.createTexture();if(c){n.bindTexture(n.TEXTURE_CUBE_MAP,b.__webglTexture);B(n.TEXTURE_CUBE_MAP,b,b);b.__webglFramebuffer=[];for(var e=0;e<6;e++)b.__webglFramebuffer[e]=n.createFramebuffer(),n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,K(b.format),b.width,b.height,0,K(b.format),K(b.type),null)}else b.__webglFramebuffer= n.createFramebuffer(),n.bindTexture(n.TEXTURE_2D,b.__webglTexture),B(n.TEXTURE_2D,b,b),n.texImage2D(n.TEXTURE_2D,0,K(b.format),b.width,b.height,0,K(b.format),K(b.type),null);n.bindRenderbuffer(n.RENDERBUFFER,b.__webglRenderbuffer);if(c)for(e=0;e<6;++e)n.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer[e]),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+e,b.__webglTexture,0);else n.bindFramebuffer(n.FRAMEBUFFER,b.__webglFramebuffer),n.framebufferTexture2D(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0,n.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_STENCIL,b.width,b.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.RENDERBUFFER,b.__webglRenderbuffer)):n.renderbufferStorage(n.RENDERBUFFER, n.RGBA4,b.width,b.height);c?n.bindTexture(n.TEXTURE_CUBE_MAP,null):n.bindTexture(n.TEXTURE_2D,null);n.bindRenderbuffer(n.RENDERBUFFER,null);n.bindFramebuffer(n.FRAMEBUFFER,null)}var f,g;b?(c=c?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,e=b.width,b=b.height,g=f=0):(c=null,e=da,b=ia,f=ea,g=Z);c!=M&&(n.bindFramebuffer(n.FRAMEBUFFER,c),n.viewport(f,g,e,b),M=c)}function V(b){b instanceof THREE.WebGLRenderTargetCube?(n.bindTexture(n.TEXTURE_CUBE_MAP,b.__webglTexture),n.generateMipmap(n.TEXTURE_CUBE_MAP), n.bindTexture(n.TEXTURE_CUBE_MAP,null)):(n.bindTexture(n.TEXTURE_2D,b.__webglTexture),n.generateMipmap(n.TEXTURE_2D),n.bindTexture(n.TEXTURE_2D,null))}function H(b,c){var e;b=="fragment"?e=n.createShader(n.FRAGMENT_SHADER):b=="vertex"&&(e=n.createShader(n.VERTEX_SHADER));n.shaderSource(e,c);n.compileShader(e);if(!n.getShaderParameter(e,n.COMPILE_STATUS))return console.error(n.getShaderInfoLog(e)),console.error(c),null;return e}function S(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return n.NEAREST; default:return n.LINEAR}}function K(b){switch(b){case THREE.RepeatWrapping:return n.REPEAT;case THREE.ClampToEdgeWrapping:return n.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return n.MIRRORED_REPEAT;case THREE.NearestFilter:return n.NEAREST;case THREE.NearestMipMapNearestFilter:return n.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return n.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return n.LINEAR;case THREE.LinearMipMapNearestFilter:return n.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return n.LINEAR_MIPMAP_LINEAR; case THREE.ByteType:return n.BYTE;case THREE.UnsignedByteType:return n.UNSIGNED_BYTE;case THREE.ShortType:return n.SHORT;case THREE.UnsignedShortType:return n.UNSIGNED_SHORT;case THREE.IntType:return n.INT;case THREE.UnsignedShortType:return n.UNSIGNED_INT;case THREE.FloatType:return n.FLOAT;case THREE.AlphaFormat:return n.ALPHA;case THREE.RGBFormat:return n.RGB;case THREE.RGBAFormat:return n.RGBA;case THREE.LuminanceFormat:return n.LUMINANCE;case THREE.LuminanceAlphaFormat:return n.LUMINANCE_ALPHA}return 0} var Q=this,n,T=[],X=null,M=null,W=!0,ha=null,ca=null,fa=null,ga=null,$=null,Y=null,P=null,ea=0,Z=0,da=0,ia=0,U=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ja=new THREE.Matrix4,pa=new Float32Array(16),la=new Float32Array(16),ma=new THREE.Vector4,Fa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},ya=b.canvas!==void 0?b.canvas:document.createElement("canvas"), Ia=b.stencil!==void 0?b.stencil:!0,Ja=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,Ta=b.antialias!==void 0?b.antialias:!1,ra=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),na=b.clearAlpha!==void 0?b.clearAlpha:0;_maxLights=b.maxLights!==void 0?b.maxLights:4;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=ya;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 aa,xa=[],b=THREE.ShaderLib.depthRGBA,va=THREE.UniformsUtils.clone(b.uniforms),oa=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:va}),Da=new THREE.MeshShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:va,morphTargets:!0});oa._shadowPass=!0;Da._shadowPass=!0;try{if(!(n= ya.getContext("experimental-webgl",{antialias:Ta,stencil:Ia,preserveDrawingBuffer:Ja})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+n.getParameter(n.VERSION)+" | "+n.getParameter(n.VENDOR)+" | "+n.getParameter(n.RENDERER)+" | "+n.getParameter(n.SHADING_LANGUAGE_VERSION))}catch(Ga){console.error(Ga)}n.clearColor(0,0,0,1);n.clearDepth(1);n.enable(n.DEPTH_TEST);n.depthFunc(n.LEQUAL);n.frontFace(n.CCW);n.cullFace(n.BACK);n.enable(n.CULL_FACE);n.enable(n.BLEND);n.blendEquation(n.FUNC_ADD); n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA);n.clearColor(ra.r,ra.g,ra.b,na);this.context=n;var sa=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,R={};R.vertices=new Float32Array(16);R.faces=new Uint16Array(6);i=0;R.vertices[i++]=-1;R.vertices[i++]=-1;R.vertices[i++]=0;R.vertices[i++]=1;R.vertices[i++]=1;R.vertices[i++]=-1;R.vertices[i++]=1;R.vertices[i++]=1;R.vertices[i++]=1;R.vertices[i++]=1;R.vertices[i++]=1;R.vertices[i++]=0;R.vertices[i++]=-1;R.vertices[i++]=1;R.vertices[i++]=0;i=R.vertices[i++]= 0;R.faces[i++]=0;R.faces[i++]=1;R.faces[i++]=2;R.faces[i++]=0;R.faces[i++]=2;R.faces[i++]=3;R.vertexBuffer=n.createBuffer();R.elementBuffer=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,R.vertexBuffer);n.bufferData(n.ARRAY_BUFFER,R.vertices,n.STATIC_DRAW);n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,R.elementBuffer);n.bufferData(n.ELEMENT_ARRAY_BUFFER,R.faces,n.STATIC_DRAW);R.program=n.createProgram();n.attachShader(R.program,H("fragment",THREE.ShaderLib.sprite.fragmentShader));n.attachShader(R.program,H("vertex", THREE.ShaderLib.sprite.vertexShader));n.linkProgram(R.program);R.attributes={};R.uniforms={};R.attributes.position=n.getAttribLocation(R.program,"position");R.attributes.uv=n.getAttribLocation(R.program,"uv");R.uniforms.uvOffset=n.getUniformLocation(R.program,"uvOffset");R.uniforms.uvScale=n.getUniformLocation(R.program,"uvScale");R.uniforms.rotation=n.getUniformLocation(R.program,"rotation");R.uniforms.scale=n.getUniformLocation(R.program,"scale");R.uniforms.alignment=n.getUniformLocation(R.program, "alignment");R.uniforms.map=n.getUniformLocation(R.program,"map");R.uniforms.opacity=n.getUniformLocation(R.program,"opacity");R.uniforms.useScreenCoordinates=n.getUniformLocation(R.program,"useScreenCoordinates");R.uniforms.affectedByDistance=n.getUniformLocation(R.program,"affectedByDistance");R.uniforms.screenPosition=n.getUniformLocation(R.program,"screenPosition");R.uniforms.modelViewMatrix=n.getUniformLocation(R.program,"modelViewMatrix");R.uniforms.projectionMatrix=n.getUniformLocation(R.program, "projectionMatrix");var Aa=!1;this.setSize=function(b,c){ya.width=b;ya.height=c;this.setViewport(0,0,ya.width,ya.height)};this.setViewport=function(b,c,e,f){ea=b;Z=c;da=e;ia=f;n.viewport(ea,Z,da,ia)};this.setScissor=function(b,c,e,f){n.scissor(b,c,e,f)};this.enableScissorTest=function(b){b?n.enable(n.SCISSOR_TEST):n.disable(n.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){W=b;n.depthMask(b)};this.setClearColorHex=function(b,c){ra.setHex(b);na=c;n.clearColor(ra.r,ra.g,ra.b,na)};this.setClearColor= function(b,c){ra.copy(b);na=c;n.clearColor(ra.r,ra.g,ra.b,na)};this.clear=function(){n.clear(n.COLOR_BUFFER_BIT|n.DEPTH_BUFFER_BIT|n.STENCIL_BUFFER_BIT)};this.getContext=function(){return n};this.initMaterial=function(b,c,e,f){var g,h,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.MeshNormalMaterial?j="normal":b instanceof THREE.MeshBasicMaterial?j="basic":b instanceof THREE.MeshLambertMaterial?j="lambert":b instanceof THREE.MeshPhongMaterial?j="phong":b instanceof THREE.LineBasicMaterial? j="basic":b instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var k=THREE.ShaderLib[j];b.uniforms=THREE.UniformsUtils.clone(k.uniforms);b.vertexShader=k.vertexShader;b.fragmentShader=k.fragmentShader}var m,t,u;m=u=k=0;for(t=c.length;m=0&&n.enableVertexAttribArray(p.position);p.color>=0&&n.enableVertexAttribArray(p.color);p.normal>=0&&n.enableVertexAttribArray(p.normal);p.tangent>=0&&n.enableVertexAttribArray(p.tangent);b.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(n.enableVertexAttribArray(p.skinVertexA),n.enableVertexAttribArray(p.skinVertexB),n.enableVertexAttribArray(p.skinIndex), n.enableVertexAttribArray(p.skinWeight));if(b.attributes)for(g in b.attributes)p[g]!==void 0&&p[g]>=0&&n.enableVertexAttribArray(p[g]);if(b.morphTargets)for(g=b.numSupportedMorphTargets=0;g=0&&(n.enableVertexAttribArray(p[x]),b.numSupportedMorphTargets++)};this.render=function(b,c,n,p){var y,D,G,I,U,J,H,B,L=b.lights,P=b.fog;this.shadowMapEnabled&&x(b,c);Q.data.vertices=0;Q.data.faces=0;Q.data.drawCalls=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0, !1,c);c.matrixWorldInverse.flattenToArray(la);c.projectionMatrix.flattenToArray(pa);ja.multiply(c.projectionMatrix,c.matrixWorldInverse);m(ja);this.initWebGLObjects(b);E(n);(this.autoClear||p)&&this.clear();U=b.__webglObjects.length;for(p=0;p=0;p--)if(y=b.__webglObjects[p],y.render){H=y.object;B=y.buffer;G=y.opaque;j(H);for(y=0;y0||v.faceVertexUvs.length>0)k.__uvArray=new Float32Array(t*2);if(v.faceUvs.length>1||v.faceVertexUvs.length>1)k.__uv2Array=new Float32Array(t*2)}if(m.geometry.skinWeights.length&&m.geometry.skinIndices.length)k.__skinVertexAArray=new Float32Array(t*4),k.__skinVertexBArray=new Float32Array(t*4),k.__skinIndexArray=new Float32Array(t*4),k.__skinWeightArray= new Float32Array(t*4);k.__faceArray=new Uint16Array(w*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));k.__lineArray=new Uint16Array(A*2);if(k.numMorphTargets){k.__morphTargetsArrays=[];v=0;for(x=k.numMorphTargets;v=0;h--)e[h]==f&&e.splice(h,1)}else f instanceof THREE.MarchingCubes&&D(e.__webglObjectsImmediate,f);b.__objectsRemoved.splice(0,1)}e=0;for(f=b.__webglObjects.length;e0&&(n.bindBuffer(n.ARRAY_BUFFER,m.__webglColorBuffer),n.bufferData(n.ARRAY_BUFFER,$,t));Aa&& (n.bindBuffer(n.ARRAY_BUFFER,m.__webglNormalBuffer),n.bufferData(n.ARRAY_BUFFER,fa,t));Ia&&wa.hasTangents&&(n.bindBuffer(n.ARRAY_BUFFER,m.__webglTangentBuffer),n.bufferData(n.ARRAY_BUFFER,ma,t));xa&&ea>0&&(n.bindBuffer(n.ARRAY_BUFFER,m.__webglUVBuffer),n.bufferData(n.ARRAY_BUFFER,ga,t));xa&&ca>0&&(n.bindBuffer(n.ARRAY_BUFFER,m.__webglUV2Buffer),n.bufferData(n.ARRAY_BUFFER,ha,t));va&&(n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,m.__webglFaceBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,ra,t),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER, m.__webglLineBuffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,oa,t));O>0&&(n.bindBuffer(n.ARRAY_BUFFER,m.__webglSkinVertexABuffer),n.bufferData(n.ARRAY_BUFFER,ia,t),n.bindBuffer(n.ARRAY_BUFFER,m.__webglSkinVertexBBuffer),n.bufferData(n.ARRAY_BUFFER,aa,t),n.bindBuffer(n.ARRAY_BUFFER,m.__webglSkinIndicesBuffer),n.bufferData(n.ARRAY_BUFFER,ta,t),n.bindBuffer(n.ARRAY_BUFFER,m.__webglSkinWeightsBuffer),n.bufferData(n.ARRAY_BUFFER,ua,t));H&&(delete m.__inittedArrays,delete m.__colorArray,delete m.__normalArray, delete m.__tangentArray,delete m.__uvArray,delete m.__uv2Array,delete m.__faceArray,delete m.__vertexArray,delete m.__lineArray,delete m.__skinVertexAArray,delete m.__skinVertexBArray,delete m.__skinIndexArray,delete m.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;G(k)}else if(g instanceof THREE.Ribbon){h=g.geometry;if(h.__dirtyVertices||h.__dirtyColors){g=h;j=n.DYNAMIC_DRAW;k=A=w=w= void 0;v=g.vertices;m=g.colors;p=v.length;t=m.length;u=g.__vertexArray;H=g.__colorArray;x=g.__dirtyColors;if(g.__dirtyVertices){for(w=0;w1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=h;c.v=j;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=c instanceof THREE.Mesh,f=b.vertices.length,g=e?c.geometry:c,j=b.vertices,h=g.vertices,k=b.faces,m=g.faces,o=b.faceVertexUvs[0],g=g.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var p=0,u=h.length;p1&&(f=1-f,g=1-g);j=1-f-g;h.copy(b);h.multiplyScalar(f);k.copy(c);k.multiplyScalar(g);h.addSelf(k);k.copy(e);k.multiplyScalar(j);h.addSelf(k);return h},randomPointInFace:function(b, c,e){var f,g,j;if(b instanceof THREE.Face3)return f=c.vertices[b.a].position,g=c.vertices[b.b].position,j=c.vertices[b.c].position,THREE.GeometryUtils.randomPointInTriangle(f,g,j);else if(b instanceof THREE.Face4){f=c.vertices[b.a].position;g=c.vertices[b.b].position;j=c.vertices[b.c].position;var c=c.vertices[b.d].position,h;e?b._area1&&b._area2?(e=b._area1,h=b._area2):(e=THREE.GeometryUtils.triangleArea(f,g,c),h=THREE.GeometryUtils.triangleArea(g,j,c),b._area1=e,b._area2=h):(e=THREE.GeometryUtils.triangleArea(f, g,c),h=THREE.GeometryUtils.triangleArea(g,j,c));return THREE.GeometryUtils.random()*(e+h)b?c(e,g-1):o[g] 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( 1.0 );\nvec4 mColor = vec4( uDiffuseColor, uOpacity );\nvec4 mSpecular = vec4( uSpecularColor, 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 = gl_FragColor * texture2D( tAO, vUv );\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\nvec4 pointTotal = vec4( vec3( 0.0 ), 1.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 );\npointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirTotal = vec4( vec3( 0.0 ), 1.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 );\ndirTotal += vec4( directionalLightColor[ i ], 1.0 ) * ( mColor * dirDiffuseWeight + mSpecular * dirSpecularWeight * dirDiffuseWeight );\n}\n#endif\nvec4 totalLight = vec4( ambientLightColor * uAmbientColor, uOpacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirTotal;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointTotal;\n#endif\ngl_FragColor = gl_FragColor * totalLight;", 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 );\nvViewPosition = cameraPosition - mPosition.xyz;\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvNormal = normalize( normalMatrix * normal );\nvTangent = normalize( normalMatrix * tangent.xyz );\nvBinormal = cross( vNormal, vTangent ) * tangent.w;\nvBinormal = normalize( vBinormal );\nvUv = uv;\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.AnimationHandler=function(){var b=[],c={},e={update:function(c){for(var e=0;e1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+t),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",t,h.index-1).pos,this.points[1]=g,this.points[2]=j,this.points[3]=this.getNextKeyWith("pos",t,k.index+1).pos,f=f*0.33+0.33,g=this.interpolateCatmullRom(this.points,f),e.x=g[0],e.y=g[1],e.z=g[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(g,j,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f}}if(this.JITCompile&&p[0][o]===void 0){this.hierarchy[0].update(void 0,!0);for(t=0;tb.length-2?j:j+1;e[3]=j>b.length-3?j:j+2;j=b[e[0]];k=b[e[1]];m=b[e[2]];o=b[e[3]];e=g*g;h=g*e;f[0]=this.interpolate(j[0],k[0],m[0],o[0],g,e,h);f[1]=this.interpolate(j[1],k[1],m[1],o[1],g,e,h);f[2]=this.interpolate(j[2],k[2],m[2],o[2],g,e,h);return f}; THREE.Animation.prototype.interpolate=function(b,c,e,f,g,j,h){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*h+(-3*(c-e)-2*b-f)*j+b*g+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.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=3.14;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.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){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.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};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,g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta)}b= 1;this.constrainVertical&&(b=3.14/(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)/3.14+this.verticalMin;b=this.target.position;g=this.position;b.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=g.y+100*Math.cos(this.phi);b.z=g.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,c,e,f){var g={name:e,fps:0.6,length:f,hierarchy:[]},h,j=c.getControlPointsArray(),k=c.getLength(),m=j.length,G=0;h=m-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:j[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[h]={time:f,pos:j[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h=0?f:f+g;f=this.verticalAngleMap.srcRange;h=this.verticalAngleMap.dstRange;var k=h[1]-h[0];this.phi= TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(h[1]-h[0])/(f[1]-f[0])+h[0]-h[0])/k)*k+h[0];f=this.horizontalAngleMap.srcRange;h=this.horizontalAngleMap.dstRange;k=h[1]-h[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(h[1]-h[0])/(f[1]-f[0])+h[0]-h[0])/k)*k+h[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,c,e)};this.onMouseMove=function(b){this.mouseX= b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};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}),h=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.CubeGeometry(10,10,20),m=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(m,h);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,c){return function(){c.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.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){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(),g=c.size[0]/2,j=c.size[1]/2;this.moveState.yawLeft=-(b.clientX-c.offset[0]-g)/g;this.moveState.pitchDown=(b.clientY- c.offset[1]-j)/j;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);window.addEventListener("keydown",c(this,this.keydown),!1);window.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 g=new THREE.Vector3,j=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Matrix4,m=!1,o=1,p=0,u=0,v=0,t=0,x=0,w=window.innerWidth/2,A=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*t),this.rotateVertically(b*x));b=this.delta*this.movementSpeed;this.translateZ(b*(p>0||this.autoForward&&!(p<0)?1:p));this.translateX(b*u);this.translateY(b*v);m&&(this.roll+=this.rollSpeed*this.delta*o);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); else if(this.forward.y1?e.normalize():e.z=Math.sqrt(1-f*f);g=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(e.y);f.addSelf(this.up.clone().crossSelf(g).setLength(e.x));f.addSelf(g.setLength(e.z));return f}; this.rotateCamera=function(){var b=Math.acos(j.dot(h)/j.length()/h.length());if(b){var c=(new THREE.Vector3).cross(j,h).normalize(),e=new THREE.Quaternion;b*=this.rotateSpeed;e.setFromAxisAngle(c,-b);e.multiplyVector3(g);e.multiplyVector3(this.up);e.multiplyVector3(h);this.staticMoving?j=h:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(j))}};this.zoomCamera=function(){var b=1+(m.y-k.y)*this.zoomSpeed;b!==1&&b>0&&(g.multiplyScalar(b),this.staticMoving?k=m:k.y+=(m.y-k.y)*this.dynamicDampingFactor)}; this.panCamera=function(){var b=p.clone().subSelf(o);if(b.lengthSq()){b.multiplyScalar(g.length()*this.panSpeed);var c=g.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?o=p:o.addSelf(b.sub(p,o).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), g.lengthSq()0)k=f-1;else{k=f;break}f=k;if(e[f]==j)return f/(g-1);h=e[f];return e=(f+(j-h)/(e[f+1]-h))/(g-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 g=Array.prototype.slice.call(arguments),b=new THREE.Vector2(g[0],g[1]),c=new THREE.Vector2(g[2],g[3]),e=new THREE.Vector2(g[4],g[5]),f=new THREE.Vector2(g[6],g[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,g;g=(f.length-1)*b;b=Math.floor(g);g-=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,g);c.y=THREE.Curve.Utils.interpolate(f[e[0]].y,f[e[1]].y,f[e[2]].y,f[e[3]].y,g);return c};THREE.ArcCurve=function(b,c,e,f,g,j){this.aX=b;this.aY=c;this.aRadius=e;this.aStartAngle=f;this.aEndAngle=g;this.aClockwise=j}; 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,g){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*g},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,g){var b=(e-b)*0.5,f=(f-c)*0.5,j=g*g;return(2*c-2*e+b+f)*g*j+(-3*c+3*e-2*b-f)*j+b*g+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.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=j.x;else if(j.xe)e=j.y;else if(j.y0?(h=e[e.length-1],t=h.x,x=h.y):(h=this.actions[f-1].args,t=h[h.length-2],x=h[h.length-1]);for(h=1;h<=b;h++)w=h/b,j=THREE.Shape.Utils.b2(w,t,u,k),w=THREE.Shape.Utils.b2(w,x,v, m),e.push(new THREE.Vector2(j,w));break;case THREE.PathActions.BEZIER_CURVE_TO:k=j[4];m=j[5];u=j[0];v=j[1];o=j[2];p=j[3];e.length>0?(h=e[e.length-1],t=h.x,x=h.y):(h=this.actions[f-1].args,t=h[h.length-2],x=h[h.length-1]);for(h=1;h<=b;h++)w=h/b,j=THREE.Shape.Utils.b3(w,t,u,o,k),w=THREE.Shape.Utils.b3(w,x,v,p,m),e.push(new THREE.Vector2(j,w));break;case THREE.PathActions.CSPLINE_THRU:h=this.actions[f-1].args;h=[new THREE.Vector2(h[h.length-2],h[h.length-1])];w=b*j[0].length;h=h.concat(j[0]);j=new THREE.SplineCurve(h); for(h=1;h<=w;h++)e.push(j.getPointAt(h/w));break;case THREE.PathActions.ARC:h=this.actions[f-1].args;k=j[0];m=j[1];o=j[2];u=j[3];w=j[4];v=!!j[5];p=h[h.length-2];t=h[h.length-1];h.length==0&&(p=t=0);x=w-u;var A=b*2;for(h=1;h<=A;h++)w=h/A,v||(w=1-w),w=u+w*x,j=p+k+o*Math.cos(w),w=t+m+o*Math.sin(w),e.push(new THREE.Vector2(j,w))}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,g,j){var h=this.getPoints(),k,m,o,p,u;k=0;for(m=h.length;k=0?k-1:e.length-1;j=h-1>=0?h-1:o.length-1;var w=[o[h],e[k],e[g]];u=THREE.FontUtils.Triangulate.area(w);var A=[o[h],o[j],e[k]];v=THREE.FontUtils.Triangulate.area(A);t=k;p=h;k+=1;h+=-1;k<0&&(k+=e.length);k%= e.length;h<0&&(h+=o.length);h%=o.length;g=k-1>=0?k-1:e.length-1;j=h-1>=0?h-1:o.length-1;w=[o[h],e[k],e[g]];w=THREE.FontUtils.Triangulate.area(w);A=[o[h],o[j],e[k]];A=THREE.FontUtils.Triangulate.area(A);u+v>w+A&&(k=t,h=p,k<0&&(k+=e.length),k%=e.length,h<0&&(h+=o.length),h%=o.length,g=k-1>=0?k-1:e.length-1,j=h-1>=0?h-1:o.length-1);u=e.slice(0,k);v=e.slice(k);t=o.slice(h);p=o.slice(0,h);j=[o[h],o[j],e[k]];x.push([o[h],e[k],e[g]]);x.push(j);e=u.concat(t).concat(p).concat(v)}return{shape:e,isolatedPts:x, allpoints:f}},triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,g=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),j,h,k,m,o={};j=0;for(h=f.length;j0){e=new THREE.Vector3(0,0,-1);h(0,0,-p-(j||0));for(m=b;m0){c=new THREE.Vector3(0,0,1);h(0,0,p+(g||0));for(m=b+b/2;m<2*b;m++)k.faces.push(new THREE.Face4(2*b+1,(2*m-2*b+2)%b+b,(2*m-2*b+1)%b+b,(2*m-2*b)%b+b,[c,c,c,c]))}m= 0;for(b=this.faces.length;mb&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(j).addSelf(k).subSelf(b).clone()}function g(b){for(H=b.length;--H>=0;){ga=H;$=H-1;$<0&&($=b.length- 1);for(var c=0,e=t+p*2,c=0;c=0;K--){Q=K/p;n=m*(1-Q);Q=o*Math.sin(Q*Math.PI/2);H=0;for(S=G.length;H0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(u,k,v)))-1);o.push(p)}c.push(o)}for(var t,x,w,g=c.length,e=0;e0)for(f=0;f1&&(t= this.vertices[h].position.clone(),x=this.vertices[m].position.clone(),w=this.vertices[o].position.clone(),t.normalize(),x.normalize(),w.normalize(),this.faces.push(new THREE.Face3(h,m,o,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(w.x,w.y,w.z)])),this.faceVertexUvs[0].push([p,u,A]))}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,g=String(b).split(""),j=g.length,h=[],b=0;b0)for(o=0;o2;){if(u--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return k;return j}m=o;g<=m&&(m=0);o=m+1;g<=o&&(o=0);p=o+1;g<=p&&(p=0);var v;a:{v=b;var t=m,x=o,w=p,A=g,y=h,G=void 0,D=void 0,I=void 0, J=void 0,C=void 0,B=void 0,L=void 0,E=void 0,V=void 0,D=v[y[t]].x,I=v[y[t]].y,J=v[y[x]].x,C=v[y[x]].y,B=v[y[w]].x,L=v[y[w]].y;if(1.0E-10>(J-D)*(L-I)-(C-I)*(B-D))v=!1;else{for(G=0;G=0&&K>=0&&n>=0){v=!1;break a}}v= !0}}if(v){j.push([b[h[m]],b[h[o]],b[h[p]]]);k.push([h[m],h[o],h[p]]);m=o;for(p=o+1;p>7)-127;f|=(h&127)<<16|g<<8;if(f==0&&k==-127)return 0;return(1-2*(j>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,k)}function g(b,c){var e=p(b,c),f=p(b,c+1),h=p(b,c+2);return(p(b,c+3)<<24)+(h<<16)+(f<<8)+e}function m(b,c){var e=p(b,c);return(p(b,c+1)<<8)+e}function o(b,c){var e=p(b,c);return e>127?e-256:e}function p(b, c){return b.charCodeAt(c)&255}function u(c){var e,f,h;e=g(b,c);f=g(b,c+C);h=g(b,c+B);c=m(b,c+L);THREE.BinaryLoader.prototype.f3(y,e,f,h,c)}function v(c){var e,f,h,j,n,o;e=g(b,c);f=g(b,c+C);h=g(b,c+B);j=m(b,c+L);n=g(b,c+E);o=g(b,c+V);c=g(b,c+H);THREE.BinaryLoader.prototype.f3n(y,I,e,f,h,j,n,o,c)}function t(c){var e,f,h,j;e=g(b,c);f=g(b,c+S);h=g(b,c+K);j=g(b,c+Q);c=m(b,c+n);THREE.BinaryLoader.prototype.f4(y,e,f,h,j,c)}function x(c){var e,f,h,j,o,p,t,u;e=g(b,c);f=g(b,c+S);h=g(b,c+K);j=g(b,c+Q);o=m(b, c+n);p=g(b,c+T);t=g(b,c+X);u=g(b,c+M);c=g(b,c+W);THREE.BinaryLoader.prototype.f4n(y,I,e,f,h,j,o,p,t,u,c)}function w(c){var e,f;e=g(b,c);f=g(b,c+ha);c=g(b,c+ca);THREE.BinaryLoader.prototype.uv3(y.faceVertexUvs[0],J[e*2],J[e*2+1],J[f*2],J[f*2+1],J[c*2],J[c*2+1])}function A(c){var e,f,h;e=g(b,c);f=g(b,c+fa);h=g(b,c+ga);c=g(b,c+$);THREE.BinaryLoader.prototype.uv4(y.faceVertexUvs[0],J[e*2],J[e*2+1],J[f*2],J[f*2+1],J[h*2],J[h*2+1],J[c*2],J[c*2+1])}var y=this,G=0,D,I=[],J=[],C,B,L,E,V,H,S,K,Q,n,T,X,M,W, ha,ca,fa,ga,$,Y,P,ea,Z,da,ia;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,f,c);D={signature:b.substr(G,8),header_bytes:p(b,G+8),vertex_coordinate_bytes:p(b,G+9),normal_coordinate_bytes:p(b,G+10),uv_coordinate_bytes:p(b,G+11),vertex_index_bytes:p(b,G+12),normal_index_bytes:p(b,G+13),uv_index_bytes:p(b,G+14),material_index_bytes:p(b,G+15),nvertices:g(b,G+16),nnormals:g(b,G+16+4),nuvs:g(b,G+16+8),ntri_flat:g(b,G+16+12),ntri_smooth:g(b,G+16+16),ntri_flat_uv:g(b,G+16+20),ntri_smooth_uv:g(b, G+16+24),nquad_flat:g(b,G+16+28),nquad_smooth:g(b,G+16+32),nquad_flat_uv:g(b,G+16+36),nquad_smooth_uv:g(b,G+16+40)};G+=D.header_bytes;C=D.vertex_index_bytes;B=D.vertex_index_bytes*2;L=D.vertex_index_bytes*3;E=D.vertex_index_bytes*3+D.material_index_bytes;V=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes;H=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes*2;S=D.vertex_index_bytes;K=D.vertex_index_bytes*2;Q=D.vertex_index_bytes*3;n=D.vertex_index_bytes*4;T=D.vertex_index_bytes* 4+D.material_index_bytes;X=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes;M=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*2;W=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*3;ha=D.uv_index_bytes;ca=D.uv_index_bytes*2;fa=D.uv_index_bytes;ga=D.uv_index_bytes*2;$=D.uv_index_bytes*3;c=D.vertex_index_bytes*3+D.material_index_bytes;ia=D.vertex_index_bytes*4+D.material_index_bytes;Y=D.ntri_flat*c;P=D.ntri_smooth*(c+D.normal_index_bytes*3);ea=D.ntri_flat_uv* (c+D.uv_index_bytes*3);Z=D.ntri_smooth_uv*(c+D.normal_index_bytes*3+D.uv_index_bytes*3);da=D.nquad_flat*ia;c=D.nquad_smooth*(ia+D.normal_index_bytes*4);ia=D.nquad_flat_uv*(ia+D.uv_index_bytes*4);G+=function(c){for(var f,g,j,k=D.vertex_coordinate_bytes*3,m=c+D.nvertices*k;c1&&(V=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(C,V);object.name=t;object.position.set(D[0],D[1],D[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=G.visible;M.scene.addObject(object);M.objects[t]=object;G.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),M.scene.collisions.colliders.push(b)); if(G.castsShadow)b=new THREE.ShadowVolume(C),M.scene.addChild(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;G.trigger&&G.trigger.toLowerCase()!="none"&&(b={type:G.trigger,object:G},M.triggers[object.name]=b)}}else D=G.position,r=G.rotation,q=G.quaternion,s=G.scale,q=0,object=new THREE.Object3D,object.name=t,object.position.set(D[0],D[1],D[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=G.visible!==void 0?G.visible:!1,M.scene.addObject(object),M.objects[t]=object,M.empties[t]=object,G.trigger&&G.trigger.toLowerCase()!="none"&&(b={type:G.trigger,object:G},M.triggers[object.name]=b)}function m(b){return function(c){M.geometries[b]=c;k();Q-=1;e.onLoadComplete();p()}}function o(b){return function(c){M.geometries[b]=c}}function p(){e.callbackProgress({totalModels:T,totalTextures:X,loadedModels:T-Q,loadedTextures:X-n},M);e.onLoadProgress();Q==0&&n==0&&c(M)}var u, v,t,x,w,A,y,G,D,I,J,C,B,L,E,V,H,S,K,Q,n,T,X,M;S=b.data;E=new THREE.BinaryLoader;K=new THREE.JSONLoader;n=Q=0;M={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(t in S.objects)if(G=S.objects[t],G.meshCollider){b=!0;break}if(b)M.scene.collisions=new THREE.CollisionSystem;if(S.transform){b=S.transform.position;I=S.transform.rotation;var W=S.transform.scale;b&&M.scene.position.set(b[0],b[1],b[2]);I&&M.scene.rotation.set(I[0], I[1],I[2]);W&&M.scene.scale.set(W[0],W[1],W[2]);(b||I||W)&&M.scene.updateMatrix()}b=function(){n-=1;p();e.onLoadComplete()};for(w in S.cameras){I=S.cameras[w];if(I.type=="perspective")B=new THREE.Camera(I.fov,I.aspect,I.near,I.far);else if(I.type=="ortho")B=new THREE.Camera,B.projectionMatrix=THREE.Matrix4.makeOrtho(I.left,I.right,I.top,I.bottom,I.near,I.far);D=I.position;I=I.target;B.position.set(D[0],D[1],D[2]);B.target.position.set(I[0],I[1],I[2]);M.cameras[w]=B}for(x in S.lights)w=S.lights[x], B=w.color!==void 0?w.color:16777215,I=w.intensity!==void 0?w.intensity:1,w.type=="directional"?(D=w.direction,H=new THREE.DirectionalLight(B,I),H.position.set(D[0],D[1],D[2]),H.position.normalize()):w.type=="point"?(D=w.position,d=w.distance,H=new THREE.PointLight(B,I,d),H.position.set(D[0],D[1],D[2])):w.type=="ambient"&&(H=new THREE.AmbientLight(B)),M.scene.addLight(H),M.lights[x]=H;for(A in S.fogs)x=S.fogs[A],x.type=="linear"?L=new THREE.Fog(0,x.near,x.far):x.type=="exp2"&&(L=new THREE.FogExp2(0, x.density)),I=x.color,L.color.setRGB(I[0],I[1],I[2]),M.fogs[A]=L;if(M.cameras&&S.defaults.camera)M.currentCamera=M.cameras[S.defaults.camera];if(M.fogs&&S.defaults.fog)M.scene.fog=M.fogs[S.defaults.fog];I=S.defaults.bgcolor;M.bgColor=new THREE.Color;M.bgColor.setRGB(I[0],I[1],I[2]);M.bgColorAlpha=S.defaults.bgalpha;for(u in S.geometries)if(A=S.geometries[u],A.type=="bin_mesh"||A.type=="ascii_mesh")Q+=1,e.onLoadStart();T=Q;for(u in S.geometries)A=S.geometries[u],A.type=="cube"?(C=new THREE.CubeGeometry(A.width, A.height,A.depth,A.segmentsWidth,A.segmentsHeight,A.segmentsDepth,null,A.flipped,A.sides),M.geometries[u]=C):A.type=="plane"?(C=new THREE.PlaneGeometry(A.width,A.height,A.segmentsWidth,A.segmentsHeight),M.geometries[u]=C):A.type=="sphere"?(C=new THREE.SphereGeometry(A.radius,A.segmentsWidth,A.segmentsHeight),M.geometries[u]=C):A.type=="cylinder"?(C=new THREE.CylinderGeometry(A.numSegs,A.topRad,A.botRad,A.height,A.topOffset,A.botOffset),M.geometries[u]=C):A.type=="torus"?(C=new THREE.TorusGeometry(A.radius, A.tube,A.segmentsR,A.segmentsT),M.geometries[u]=C):A.type=="icosahedron"?(C=new THREE.IcosahedronGeometry(A.subdivisions),M.geometries[u]=C):A.type=="bin_mesh"?E.load({model:f(A.url,S.urlBaseType),callback:m(u)}):A.type=="ascii_mesh"?K.load({model:f(A.url,S.urlBaseType),callback:m(u)}):A.type=="embedded_mesh"&&(A=S.embeds[A.id])&&K.createModel(A,o(u),"");for(y in S.textures)if(u=S.textures[y],u.url instanceof Array){n+=u.url.length;for(E=0;E=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,g=0;g<8;g++){for(var j=0,h=0;h>1^-(k&1);e[8*h+g]=j}f+=c}c=b.length-f;j=new Uint16Array(c);for(g=h=0;g=this.maxCount-3&&k(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&&(m=this.size-1);var v=Math.floor(o-k);v<1&&(v=1);o=Math.floor(o+k);o>this.size-1&&(o=this.size-1);var t=Math.floor(p-k);t<1&&(t=1);k=Math.floor(p+k);k>this.size-1&&(k=this.size- 1);for(var x,w,A,y,G,D;u0&&(this.field[A+x]+=y)}}};this.addPlaneX=function(b,c){var g,j,h,k,m,o=this.size,p=this.yd,u=this.zd,v=this.field,t=o*Math.sqrt(b/c);t>o&&(t=o);for(g=0;g0)for(j=0;jp&&(x=p);for(j=0;j0){m=j*u;for(g=0;gsize&&(dist=size);for(h=0;h0){m=zd*h;for(j=0;jj?this.hits.push(g):this.hits.unshift(g),j=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,g,j=0;j=k*g))return Number.MAX_VALUE;h/=k;k=THREE.CollisionSystem.__v3;k.copy(b.direction);k.multiplyScalar(h);k.addSelf(b.origin);Math.abs(j.x)> Math.abs(j.y)?Math.abs(j.x)>Math.abs(j.z)?(b=k.y-c.y,j=e.y-c.y,g=f.y-c.y,k=k.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=k.x-c.x,j=e.x-c.x,g=f.x-c.x,k=k.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(j.y)>Math.abs(j.z)?(b=k.x-c.x,j=e.x-c.x,g=f.x-c.x,k=k.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=k.x-c.x,j=e.x-c.x,g=f.x-c.x,k=k.y-c.y,e=e.y-c.y,f=f.y-c.y);c=j*f-e*g;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-k*g)*c;if(!(f>=0))return Number.MAX_VALUE;c*=j*k-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return h}; 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,g=0,j=0,h=0,k=0,m=0,o=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,o=!1,h=1);e.origin.yc.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y, o=!1,k=1);e.origin.zc.max.z&&(j=c.max.z-e.origin.z,j/=e.direction.z,o=!1,m=1);if(o)return-1;o=0;g>f&&(o=1,f=g);j>f&&(o=2,f=j);switch(o){case 0:k=e.origin.y+e.direction.y*f;if(kc.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(h,0,0);break;case 1:h=e.origin.x+e.direction.x*f;if(hc.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,k,0);break;case 2:h=e.origin.x+e.direction.x*f;if(hc.max.x)return Number.MAX_VALUE;k=e.origin.y+e.direction.y*f;if(kc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,m)}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,g=new THREE.Camera,j=new THREE.Camera,h=new THREE.Matrix4,k=new THREE.Matrix4,m,o,p;g.useTarget=j.useTarget=!1;g.matrixAutoUpdate=j.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},u=new THREE.WebGLRenderTarget(512,512,b),v=new THREE.WebGLRenderTarget(512,512,b),t=new THREE.Camera(53,1,1,1E4);t.position.z= 2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:u},mapRight:{type:"t",value:1,texture:v}},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 x=new THREE.Scene;x.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);u.width=b;u.height=f;v.width=b;v.height=f};this.render=function(b,e){e.update(null,!0);if(m!==e.aspect||o!==e.near||p!==e.fov){m=e.aspect;o=e.near;p=e.fov;var y=e.projectionMatrix.clone(),G=125/30*0.5,D=G*o/125,I=o*Math.tan(p*Math.PI/360),J;h.n14=G;k.n14=-G;G=-I*m+D;J=I*m+D;y.n11=2*o/(J-G);y.n13=(J+G)/(J-G);g.projectionMatrix=y.clone();G=-I*m-D;J=I*m-D;y.n11=2*o/(J-G); y.n13=(J+G)/(J-G);j.projectionMatrix=y.clone()}g.matrix=e.matrixWorld.clone().multiplySelf(k);g.update(null,!0);g.position.copy(e.position);g.near=o;g.far=e.far;f.call(c,b,g,u,!0);j.matrix=e.matrixWorld.clone().multiplySelf(h);j.update(null,!0);j.position.copy(e.position);j.near=o;j.far=e.far;f.call(c,b,j,v,!0);f.call(c,x,t)}}; if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,g,j,h=new THREE.Camera,k=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);g=b/2;j=f};this.render=function(b,e){this.clear();h.fov=e.fov;h.aspect=0.5*e.aspect;h.near=e.near;h.far=e.far; h.updateProjectionMatrix();h.position.copy(e.position);h.target.position.copy(e.target.position);h.translateX(c.separation);k.projectionMatrix=h.projectionMatrix;k.position.copy(e.position);k.target.position.copy(e.target.position);k.translateX(-c.separation);this.setViewport(0,0,g,j);f.call(c,b,h);this.setViewport(g,0,g,j);f.call(c,b,k,!1)}};