// Three.js r42 - http://github.com/mrdoob/three.js var THREE=THREE||{};if(!window.Int32Array)window.Int32Array=Array,window.Float32Array=Array;THREE.Color=function(b){this.setHex(b)}; THREE.Color.prototype={copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex},setHex:function(b){this.hex=~~b&16777215;this.updateRGB()},setRGB:function(b,c,e){this.r=b;this.g=c;this.b=e;this.updateHex()},setHSV:function(b,c,e){var f,g,h,j,m,n;if(e==0)f=g=h=0;else switch(j=Math.floor(b*6),m=b*6-j,b=e*(1-c),n=e*(1-c*m),c=e*(1-c*(1-m)),j){case 1:f=n;g=e;h=b;break;case 2:f=b;g=e;h=c;break;case 3:f=b;g=n;h=e;break;case 4:f=c;g=b;h=e;break;case 5:f=e;g=b;h=n;break;case 6:case 0:f=e,g=c,h=b}this.setRGB(f, g,h)},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},clone:function(){return new THREE.Color(this.hex)}};THREE.Vector2=function(b,c){this.set(b||0,c||0)}; THREE.Vector2.prototype={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)}, unit:function(){return this.normalize()},equals:function(b){return b.x==this.x&&b.y==this.y}};THREE.Vector3=function(b,c,e){this.set(b||0,c||0,e||0)}; THREE.Vector3.prototype={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){return this.divide(this,b)},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.set(b||0,c||0,e||0,f||1)}; THREE.Vector4.prototype={set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){return this.set(b.x,b.y,b.z,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.set(0,0,0,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={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);if(!f||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);if(!f||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var g,h,j,m,n,p,o,t,u,v,w=b.geometry, z=w.vertices,x=[],f=0;for(g=w.faces.length;f0:t<0))if(o=o.dot((new THREE.Vector3).sub(j,u))/t,u=u.addSelf(v.multiplyScalar(o)), h instanceof THREE.Face3)e(u,j,m,n)&&(h={distance:this.origin.distanceTo(u),point:u,face:h,object:b},x.push(h));else if(h instanceof THREE.Face4&&(e(u,j,m,p)||e(u,m,n,p)))h={distance:this.origin.distanceTo(u),point:u,face:h,object:b},x.push(h);return x}else return[]}}; THREE.Rectangle=function(){function b(){h=f-c;j=g-e}var c,e,f,g,h,j,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return h};this.getHeight=function(){return j};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,o,t){m=!1;c=h;e=j;f=o;g=t;b()};this.addPoint=function(h,j){m?(m=!1,c=h,e=j,f=h,g=j):(c=ch?f:h,g=g>j?g:j);b()};this.add3Points= function(h,j,o,t,u,v){m?(m=!1,c=ho?h>u?h:u:o>u?o:u,g=j>t?j>v?j:v:t>v?t:v):(c=ho?h>u?h>f?h:f:u>f?u:f:o>u?o>f?o:f:u>f?u:f,g=j>t?j>v?j>g?j:g:v>g?v:g:t>v?t>g?t:g:v>g?v:g);b()};this.addRectangle=function(h){m?(m=!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(){m=!0;g=f=e=c=0;b()};this.isEmpty=function(){return m}};THREE.Matrix3=function(){this.m=[]}; THREE.Matrix3.prototype={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,h,j,m,n,p,o,t,u,v,w,z){this.set(b||1,c||0,e||0,f||0,g||0,h||1,j||0,m||0,n||0,p||0,o||1,t||0,u||0,v||0,w||0,z||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={set:function(b,c,e,f,g,h,j,m,n,p,o,t,u,v,w,z){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=m;this.n31=n;this.n32=p;this.n33=o;this.n34=t;this.n41=u;this.n42=v;this.n43=w;this.n44=z;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,c,e){var f=THREE.Matrix4.__v1, g=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,c).normalize();if(h.length()===0)h.z=1;f.cross(e,h).normalize();f.length()===0&&(h.x+=1.0E-4,f.cross(e,h).normalize());g.cross(h,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=h.x;this.n21=f.y;this.n22=g.y;this.n23=h.y;this.n31=f.z;this.n32=g.z;this.n33=h.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,h=b.n14,j=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,u=b.n33,v=b.n34,w=b.n41,z=b.n42,x=b.n43,y=b.n44,F=c.n11,C=c.n12,E=c.n13,G=c.n14,B=c.n21,P=c.n22, I=c.n23,H=c.n24,T=c.n31,U=c.n32,J=c.n33,Y=c.n34,K=c.n41,S=c.n42,k=c.n43,V=c.n44;this.n11=e*F+f*B+g*T+h*K;this.n12=e*C+f*P+g*U+h*S;this.n13=e*E+f*I+g*J+h*k;this.n14=e*G+f*H+g*Y+h*V;this.n21=j*F+m*B+n*T+p*K;this.n22=j*C+m*P+n*U+p*S;this.n23=j*E+m*I+n*J+p*k;this.n24=j*G+m*H+n*Y+p*V;this.n31=o*F+t*B+u*T+v*K;this.n32=o*C+t*P+u*U+v*S;this.n33=o*E+t*I+u*J+v*k;this.n34=o*G+t*H+u*Y+v*V;this.n41=w*F+z*B+x*T+y*K;this.n42=w*C+z*P+x*U+y*S;this.n43=w*E+z*I+x*J+y*k;this.n44=w*G+z*H+x*Y+y*V;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,h=this.n22,j=this.n23,m=this.n24,n=this.n31,p=this.n32,o=this.n33,t=this.n34,u=this.n41,v=this.n42,w=this.n43,z=this.n44;return f*j*p*u-e*m*p*u-f*h*o*u+c*m*o*u+e*h*t*u-c*j*t*u-f*j*n*v+e*m*n*v+f*g*o*v-b*m*o*v-e*g*t*v+b*j*t*v+f*h*n*w-c*m*n*w-f*g*p*w+b*m*p*w+c*g*t*w-b*h*t*w-e*h*n*z+c*j*n*z+e*g*p*z-b*j*p*z-c*g*o*z+b*h*o*z},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,h=b.x,j=b.y,m=b.z,n=g*h,p=g*j;this.set(n*h+e,n*j-f*m,n*m+f*j,0,n*j+f*m,p*j+e,p*m-f*h,0,n*m-f*j,p*m+f*h,g*m*m+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,h=Math.cos(e),e=Math.sin(e),j=Math.cos(f),f=Math.sin(f),m=Math.cos(g),g=Math.sin(g);switch(c){case "YXZ":var n=j*m,p=j*g,o=f*m,t=f*g;this.n11=n+t*e;this.n12= o*e-p;this.n13=h*f;this.n21=h*g;this.n22=h*m;this.n23=-e;this.n31=p*e-o;this.n32=t+n*e;this.n33=h*j;break;case "ZXY":n=j*m;p=j*g;o=f*m;t=f*g;this.n11=n-t*e;this.n12=-h*g;this.n13=o+p*e;this.n21=p+o*e;this.n22=h*m;this.n23=t-n*e;this.n31=-h*f;this.n32=e;this.n33=h*j;break;case "ZYX":n=h*m;p=h*g;o=e*m;t=e*g;this.n11=j*m;this.n12=o*f-p;this.n13=n*f+t;this.n21=j*g;this.n22=t*f+n;this.n23=p*f-o;this.n31=-f;this.n32=e*j;this.n33=h*j;break;case "YZX":n=h*j;p=h*f;o=e*j;t=e*f;this.n11=j*m;this.n12=t-n*g;this.n13= o*g+p;this.n21=g;this.n22=h*m;this.n23=-e*m;this.n31=-f*m;this.n32=p*g+o;this.n33=n-t*g;break;case "XZY":n=h*j;p=h*f;o=e*j;t=e*f;this.n11=j*m;this.n12=-g;this.n13=f*m;this.n21=n*g+t;this.n22=h*m;this.n23=p*g-o;this.n31=o*g-p;this.n32=e*m;this.n33=t*g+n;break;default:n=h*m,p=h*g,o=e*m,t=e*g,this.n11=j*m,this.n12=-j*g,this.n13=f,this.n21=p+o*f,this.n22=n-t*f,this.n23=-e*j,this.n31=t-n*f,this.n32=o+p*f,this.n33=h*j}return this},setRotationFromQuaternion:function(b){var c=b.x,e=b.y,f=b.z,g=b.w,h=c+c, j=e+e,m=f+f,b=c*h,n=c*j;c*=m;var p=e*j;e*=m;f*=m;h*=g;j*=g;g*=m;this.n11=1-(p+f);this.n12=n-g;this.n13=c+j;this.n21=n+g;this.n22=1-(b+f);this.n23=e-h;this.n31=c-j;this.n32=e+h;this.n33=1-(b+p);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},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,h=b.n14,j=b.n21,m=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,u=b.n33,v=b.n34,w=b.n41,z=b.n42,x=b.n43,y=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=n*v*z-p*u*z+p*t*x-m*v*x-n*t*y+m*u*y;c.n12=h*u*z-g*v*z-h*t*x+f*v*x+g*t*y-f*u*y;c.n13=g*p*z-h*n*z+h*m*x-f*p*x-g*m*y+f*n*y;c.n14=h*n*t-g*p*t-h*m*u+f*p*u+g*m*v-f*n*v;c.n21=p*u*w-n*v*w-p*o*x+j*v*x+n*o*y-j*u*y;c.n22=g*v*w-h*u*w+h*o*x-e*v*x-g*o*y+e*u*y;c.n23=h*n*w-g*p*w-h*j*x+e*p*x+g*j*y-e*n*y;c.n24= g*p*o-h*n*o+h*j*u-e*p*u-g*j*v+e*n*v;c.n31=m*v*w-p*t*w+p*o*z-j*v*z-m*o*y+j*t*y;c.n32=h*t*w-f*v*w-h*o*z+e*v*z+f*o*y-e*t*y;c.n33=g*p*w-h*m*w+h*j*z-e*p*z-f*j*y+e*m*y;c.n34=h*m*o-f*p*o-h*j*t+e*p*t+f*j*v-e*m*v;c.n41=n*t*w-m*u*w-n*o*z+j*u*z+m*o*x-j*t*x;c.n42=f*u*w-g*t*w+g*o*z-e*u*z-f*o*x+e*t*x;c.n43=g*m*w-f*n*w-g*j*z+e*n*z+f*j*x-e*m*x;c.n44=f*n*o-g*m*o+g*j*t-e*n*t-f*j*u+e*m*u;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,h=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,n=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*j+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*g;e[2]=b*h;e[3]=b*j;e[4]=b*m;e[5]=b*n;e[6]=b*p;e[7]=b*o;e[8]=b*t;return c}; THREE.Matrix4.makeFrustum=function(b,c,e,f,g,h){var j;j=new THREE.Matrix4;j.n11=2*g/(c-b);j.n12=0;j.n13=(c+b)/(c-b);j.n14=0;j.n21=0;j.n22=2*g/(f-e);j.n23=(f+e)/(f-e);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+g)/(h-g);j.n34=-2*h*g/(h-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};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,h){var j,m,n,p;j=new THREE.Matrix4;m=c-b;n=e-f;p=h-g;j.n11=2/m;j.n12=0;j.n13=0;j.n14=-((c+b)/m);j.n21=0;j.n22=2/n;j.n23=0;j.n24=-((e+f)/n);j.n31=0;j.n32=0;j.n33=-2/p;j.n34=-((h+g)/p);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; 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._vector=new THREE.Vector3;this.name=""}; THREE.Object3D.prototype={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 h=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<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)*h)/j;f=Math.sin(f*h)/j;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,h){this.a=b;this.b=c;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=h instanceof Array?h:[h];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,c,e,f,g,h,j){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=h instanceof THREE.Color?h:new THREE.Color;this.vertexColors=h instanceof Array?h:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)}; THREE.UV.prototype={set:function(b,c){this.u=b;this.v=c;return this},copy:function(b){this.set(b.u,b.v);return this}};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.hasTangents=!1}; THREE.Geometry.prototype={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?h:h+1;e[3]=h>this.points.length-3?h:h+2;p=this.points[e[0]];o=this.points[e[1]]; t=this.points[e[2]];u=this.points[e[3]];m=j*j;n=j*m;f.x=c(p.x,o.x,t.x,u.x,j,m,n);f.y=c(p.y,o.y,t.y,u.y,j,m,n);f.z=c(p.z,o.z,t.z,u.z,j,m,n);return f};this.getControlPointsArray=function(){var b,e,c=this.points.length,f=[];for(b=0;b1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var f=1;f=this.LODs[f].visibleAtDistance)this.LODs[f-1].object3D.visible=!1, this.LODs[f].object3D.visible=!0;else break;for(;ft&&(e=o,o=t,t=e):ov&&(e=u,u=v,v=e):u=0&&h>=0&&j>=0&&m>=0?!0:g<0&&h<0||j<0&&m<0?!1:(g<0?c=Math.max(c,g/(g-h)):h<0&&(f=Math.min(f,g/(g-h))),j<0?c=Math.max(c,j/(j-m)):m<0&&(f=Math.min(f,j/(j-m))),fS&&j.positionScreen.z0&&G.z<1))ha=C[F]=C[F]||new THREE.RenderableParticle,F++,y=ha,y.x=G.x/G.w,y.y=G.y/G.w,y.z=G.z,y.rotation=R.rotation.z,y.scale.x= R.scale.x*Math.abs(y.x-(G.x+g.projectionMatrix.n11)/(G.w+g.projectionMatrix.n14)),y.scale.y=R.scale.y*Math.abs(y.y-(G.y+g.projectionMatrix.n22)/(G.w+g.projectionMatrix.n24)),y.materials=R.materials,E.push(y);h&&E.sort(c);return E}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,g,h;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;g=e/2;h=f/2};this.render=function(e,f){var n,p,o,t,u,v,w,z;b=c.projectScene(e,f);n=0;for(p=b.length;n>1,Z=n.height>>1,k=h.scale.x*u,p=h.scale.y*v,j=k*o,m=p*Z,qa.set(b.x-j,b.y-m,b.x+j,b.y+m),sa.instersects(qa)&&(w.save(),w.translate(b.x,b.y),w.rotate(-h.rotation),w.scale(k,-p),w.translate(-o,-Z),w.drawImage(n,0,0),w.restore())}else k instanceof THREE.ParticleCanvasMaterial&&(j=h.scale.x*u,m=h.scale.y*v,qa.set(b.x-j,b.y-m,b.x+j,b.y+m),sa.instersects(qa)&&(f(k.color),g(k.color),w.save(),w.translate(b.x,b.y),w.rotate(-h.rotation),w.scale(j,m),k.program(w),w.restore()))}function y(b,g,h,k){c(k.opacity); e(k.blending);w.beginPath();w.moveTo(b.positionScreen.x,b.positionScreen.y);w.lineTo(g.positionScreen.x,g.positionScreen.y);w.closePath();if(k instanceof THREE.LineBasicMaterial){b=k.linewidth;if(G!=b)w.lineWidth=G=b;b=k.linecap;if(B!=b)w.lineCap=B=b;b=k.linejoin;if(P!=b)w.lineJoin=P=b;f(k.color);w.stroke();qa.inflate(k.linewidth*2)}}function z(b,f,g,m,p,n,Z,t,u){j.data.vertices+=3;j.data.faces++;c(t.opacity);e(t.blending);K=b.positionScreen.x;S=b.positionScreen.y;k=f.positionScreen.x;V=f.positionScreen.y; O=g.positionScreen.x;fa=g.positionScreen.y;C(K,S,k,V,O,fa);if(t instanceof THREE.MeshBasicMaterial)if(t.map)t.map.mapping instanceof THREE.UVMapping&&(la=Z.uvs[0],Ca(K,S,k,V,O,fa,t.map.image,la[m].u,la[m].v,la[p].u,la[p].v,la[n].u,la[n].v));else if(t.envMap){if(t.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=h.matrixWorldInverse,ja.copy(Z.vertexNormalsWorld[0]),oa=(ja.x*b.n11+ja.y*b.n12+ja.z*b.n13)*0.5+0.5,wa=-(ja.x*b.n21+ja.y*b.n22+ja.z*b.n23)*0.5+0.5,ja.copy(Z.vertexNormalsWorld[1]), Aa=(ja.x*b.n11+ja.y*b.n12+ja.z*b.n13)*0.5+0.5,va=-(ja.x*b.n21+ja.y*b.n22+ja.z*b.n23)*0.5+0.5,ja.copy(Z.vertexNormalsWorld[2]),ya=(ja.x*b.n11+ja.y*b.n12+ja.z*b.n13)*0.5+0.5,Ma=-(ja.x*b.n21+ja.y*b.n22+ja.z*b.n23)*0.5+0.5,Ca(K,S,k,V,O,fa,t.envMap.image,oa,wa,Aa,va,ya,Ma)}else t.wireframe?E(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ea(t.color);else if(t instanceof THREE.MeshLambertMaterial)t.map&&!t.wireframe&&(t.map.mapping instanceof THREE.UVMapping&&(la=Z.uvs[0],Ca(K,S,k, V,O,fa,t.map.image,la[m].u,la[m].v,la[p].u,la[p].v,la[n].u,la[n].v)),e(THREE.SubtractiveBlending)),Ba?!t.wireframe&&t.shading==THREE.SmoothShading&&Z.vertexNormalsWorld.length==3?(ha.r=$.r=ma.r=M.r,ha.g=$.g=ma.g=M.g,ha.b=$.b=ma.b=M.b,o(u,Z.v1.positionWorld,Z.vertexNormalsWorld[0],ha),o(u,Z.v2.positionWorld,Z.vertexNormalsWorld[1],$),o(u,Z.v3.positionWorld,Z.vertexNormalsWorld[2],ma),aa.r=($.r+ma.r)*0.5,aa.g=($.g+ma.g)*0.5,aa.b=($.b+ma.b)*0.5,na=Sa(ha,$,ma,aa),Ca(K,S,k,V,O,fa,na,0,0,1,0,0,1)):(ca.r= M.r,ca.g=M.g,ca.b=M.b,o(u,Z.centroidWorld,Z.normalWorld,ca),R.r=Math.max(0,Math.min(t.color.r*ca.r,1)),R.g=Math.max(0,Math.min(t.color.g*ca.g,1)),R.b=Math.max(0,Math.min(t.color.b*ca.b,1)),R.updateHex(),t.wireframe?E(R,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ea(R)):t.wireframe?E(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ea(t.color);else if(t instanceof THREE.MeshDepthMaterial)ia=h.near,X=h.far,ha.r=ha.g=ha.b=1-Ia(b.positionScreen.z,ia,X),$.r=$.g=$.b= 1-Ia(f.positionScreen.z,ia,X),ma.r=ma.g=ma.b=1-Ia(g.positionScreen.z,ia,X),aa.r=($.r+ma.r)*0.5,aa.g=($.g+ma.g)*0.5,aa.b=($.b+ma.b)*0.5,na=Sa(ha,$,ma,aa),Ca(K,S,k,V,O,fa,na,0,0,1,0,0,1);else if(t instanceof THREE.MeshNormalMaterial)R.r=Na(Z.normalWorld.x),R.g=Na(Z.normalWorld.y),R.b=Na(Z.normalWorld.z),R.updateHex(),t.wireframe?E(R,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):Ea(R)}function x(b,f,g,m,p,n,t,Z,u){j.data.vertices+=4;j.data.faces++;c(Z.opacity);e(Z.blending);if(Z.map|| Z.envMap)z(b,f,m,0,1,3,t,Z,u),z(p,g,n,1,2,3,t,Z,u);else if(K=b.positionScreen.x,S=b.positionScreen.y,k=f.positionScreen.x,V=f.positionScreen.y,O=g.positionScreen.x,fa=g.positionScreen.y,ea=m.positionScreen.x,W=m.positionScreen.y,da=p.positionScreen.x,ga=p.positionScreen.y,ka=n.positionScreen.x,pa=n.positionScreen.y,Z instanceof THREE.MeshBasicMaterial)F(K,S,k,V,O,fa,ea,W),Z.wireframe?E(Z.color,Z.wireframeLinewidth,Z.wireframeLinecap,Z.wireframeLinejoin):Ea(Z.color);else if(Z instanceof THREE.MeshLambertMaterial)Ba? !Z.wireframe&&Z.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==4?(ha.r=$.r=ma.r=aa.r=M.r,ha.g=$.g=ma.g=aa.g=M.g,ha.b=$.b=ma.b=aa.b=M.b,o(u,t.v1.positionWorld,t.vertexNormalsWorld[0],ha),o(u,t.v2.positionWorld,t.vertexNormalsWorld[1],$),o(u,t.v4.positionWorld,t.vertexNormalsWorld[3],ma),o(u,t.v3.positionWorld,t.vertexNormalsWorld[2],aa),na=Sa(ha,$,ma,aa),C(K,S,k,V,ea,W),Ca(K,S,k,V,ea,W,na,0,0,1,0,0,1),C(da,ga,O,fa,ka,pa),Ca(da,ga,O,fa,ka,pa,na,1,0,1,1,0,1)):(ca.r=M.r,ca.g=M.g,ca.b=M.b, o(u,t.centroidWorld,t.normalWorld,ca),R.r=Math.max(0,Math.min(Z.color.r*ca.r,1)),R.g=Math.max(0,Math.min(Z.color.g*ca.g,1)),R.b=Math.max(0,Math.min(Z.color.b*ca.b,1)),R.updateHex(),F(K,S,k,V,O,fa,ea,W),Z.wireframe?E(R,Z.wireframeLinewidth,Z.wireframeLinecap,Z.wireframeLinejoin):Ea(R)):(F(K,S,k,V,O,fa,ea,W),Z.wireframe?E(Z.color,Z.wireframeLinewidth,Z.wireframeLinecap,Z.wireframeLinejoin):Ea(Z.color));else if(Z instanceof THREE.MeshNormalMaterial)R.r=Na(t.normalWorld.x),R.g=Na(t.normalWorld.y),R.b= Na(t.normalWorld.z),R.updateHex(),F(K,S,k,V,O,fa,ea,W),Z.wireframe?E(R,Z.wireframeLinewidth,Z.wireframeLinecap,Z.wireframeLinejoin):Ea(R);else if(Z instanceof THREE.MeshDepthMaterial)ia=h.near,X=h.far,ha.r=ha.g=ha.b=1-Ia(b.positionScreen.z,ia,X),$.r=$.g=$.b=1-Ia(f.positionScreen.z,ia,X),ma.r=ma.g=ma.b=1-Ia(m.positionScreen.z,ia,X),aa.r=aa.g=aa.b=1-Ia(g.positionScreen.z,ia,X),na=Sa(ha,$,ma,aa),C(K,S,k,V,ea,W),Ca(K,S,k,V,ea,W,na,0,0,1,0,0,1),C(da,ga,O,fa,ka,pa),Ca(da,ga,O,fa,ka,pa,na,1,0,1,1,0,1)}function C(b, e,c,f,g,h){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(g,h);w.lineTo(b,e);w.closePath()}function F(b,e,c,f,g,h,k,j){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(g,h);w.lineTo(k,j);w.lineTo(b,e);w.closePath()}function E(b,e,c,g){if(G!=e)w.lineWidth=G=e;if(B!=c)w.lineCap=B=c;if(P!=g)w.lineJoin=P=g;f(b);w.stroke();qa.inflate(e*2)}function Ea(b){g(b);w.fill()}function Ca(b,e,c,f,g,h,k,j,m,p,n,Z,t){var o,u;o=k.width-1;u=k.height-1;j*=o;m*=u;p*=o;n*=u;Z*=o;t*=u;c-=b;f-=e;g-=b;h-=e;p-=j;n-= m;Z-=j;t-=m;o=p*t-Z*n;if(!((o<0?-o:o)<1))u=1/o,o=(t*c-n*g)*u,n=(t*f-n*h)*u,c=(p*g-Z*c)*u,f=(p*h-Z*f)*u,b=b-o*j-c*m,e=e-n*j-f*m,w.save(),w.transform(o,n,c,f,b,e),w.clip(),w.drawImage(k,0,0),w.restore()}function Sa(b,e,c,f){var g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),k=~~(e.r*255),j=~~(e.g*255),e=~~(e.b*255),m=~~(c.r*255),p=~~(c.g*255),c=~~(c.b*255),n=~~(f.r*255),t=~~(f.g*255),f=~~(f.b*255);xa[0]=g<0?0:g>255?255:g;xa[1]=h<0?0:h>255?255:h;xa[2]=b<0?0:b>255?255:b;xa[4]=k<0?0:k>255?255:k;xa[5]=j<0?0: j>255?255:j;xa[6]=e<0?0:e>255?255:e;xa[8]=m<0?0:m>255?255:m;xa[9]=p<0?0:p>255?255:p;xa[10]=c<0?0:c>255?255:c;xa[12]=n<0?0:n>255?255:n;xa[13]=t<0?0:t>255?255:t;xa[14]=f<0?0:f>255?255:f;Pa.putImageData(Va,0,0);Ra.drawImage(Z,0,0);return Qa}function Ia(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Na(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Fa(b,e){var c=e.x-b.x,f=e.y-b.y,g=c*c+f*f;g!=0&&(g=1/Math.sqrt(g),c*=g,f*=g,e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Ta,D,L,A,Ga,Oa,Ua,ta;this.autoClear?this.clear(): w.setTransform(1,0,0,-1,u,v);j.data.vertices=0;j.data.faces=0;m=n.projectScene(b,h,this.sortElements);(Ba=b.lights.length>0)&&p(b);Ta=0;for(D=m.length;Ta0&&(c.r+=h.color.r*k,c.g+=h.color.g*k,c.b+=h.color.b*k)):h instanceof THREE.PointLight&&(U.sub(h.position,e.centroidWorld),U.normalize(),k=e.normalWorld.dot(U)*h.intensity,k>0&&(c.r+=h.color.r*k,c.g+=h.color.g*k,c.b+=h.color.b*k))}function c(e,c,k,m,n,t){j.data.vertices+=3;j.data.faces++;K=f(S++);K.setAttribute("d", "M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?G.hex=n.color.hex:n instanceof THREE.MeshLambertMaterial?E?(B.r=P.r,B.g=P.g,B.b=P.b,b(t,m,B),G.r=Math.max(0,Math.min(n.color.r*B.r,1)),G.g=Math.max(0,Math.min(n.color.g*B.g,1)),G.b=Math.max(0,Math.min(n.color.b*B.b,1)),G.updateHex()):G.hex=n.color.hex:n instanceof THREE.MeshDepthMaterial?(T=1-n.__2near/(n.__farPlusNear- m.z*n.__farMinusNear),G.setRGB(T,T,T)):n instanceof THREE.MeshNormalMaterial&&G.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));n.wireframe?K.setAttribute("style","fill: none; stroke: #"+h(G.hex.toString(16))+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):K.setAttribute("style","fill: #"+h(G.hex.toString(16))+"; fill-opacity: "+n.opacity);p.appendChild(K)}function e(e,c,k,m, n,t,o){j.data.vertices+=4;j.data.faces++;K=f(S++);K.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?G.hex=t.color.hex:t instanceof THREE.MeshLambertMaterial?E?(B.r=P.r,B.g=P.g,B.b=P.b,b(o,n,B),G.r=Math.max(0,Math.min(t.color.r*B.r,1)),G.g=Math.max(0,Math.min(t.color.g*B.g,1)),G.b=Math.max(0,Math.min(t.color.b* B.b,1)),G.updateHex()):G.hex=t.color.hex:t instanceof THREE.MeshDepthMaterial?(T=1-t.__2near/(t.__farPlusNear-n.z*t.__farMinusNear),G.setRGB(T,T,T)):t instanceof THREE.MeshNormalMaterial&&G.setRGB(g(n.normalWorld.x),g(n.normalWorld.y),g(n.normalWorld.z));t.wireframe?K.setAttribute("style","fill: none; stroke: #"+h(G.hex.toString(16))+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):K.setAttribute("style", "fill: #"+h(G.hex.toString(16))+"; fill-opacity: "+t.opacity);p.appendChild(K)}function f(b){J[b]==null&&(J[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),V==0&&J[b].setAttribute("shape-rendering","crispEdges"));return J[b]}function g(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function h(b){for(;b.length<6;)b="0"+b;return b}var j=this,m=null,n=new THREE.Projector,p=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,t,u,v,w,z,x,y,F=new THREE.Rectangle,C=new THREE.Rectangle,E= !1,G=new THREE.Color(16777215),B=new THREE.Color(16777215),P=new THREE.Color(0),I=new THREE.Color(0),H=new THREE.Color(0),T,U=new THREE.Vector3,J=[],Y=[],K,S,k,V=1;this.domElement=p;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":V=1;break;case "low":V=0}};this.setSize=function(b,e){o=b;t=e;u=o/2;v=t/2;p.setAttribute("viewBox",-u+" "+-v+" "+o+" "+t);p.setAttribute("width",o);p.setAttribute("height",t);F.set(-u,-v, u,v)};this.clear=function(){for(;p.childNodes.length>0;)p.removeChild(p.childNodes[0])};this.render=function(b,f){var g,t,o,B,G,T,R,J;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;m=n.projectScene(b,f,this.sortElements);k=S=0;if(E=b.lights.length>0){R=b.lights;P.setRGB(0,0,0);I.setRGB(0,0,0);H.setRGB(0,0,0);g=0;for(t=R.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( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse += mColor * pointDiffuseWeight * pointDistance;\npointSpecular += mSpecular * pointSpecularWeight * pointDistance;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse += 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"};THREE.UniformsUtils={merge:function(b){var c,e,f,g={};for(c=0;c=0)k.bindBuffer(k.ARRAY_BUFFER, h.__webglVertexBuffer),k.vertexAttribPointer(b.position,3,k.FLOAT,!1,0,0);else{c=g.program.attributes;j.morphTargetBase!==-1?(k.bindBuffer(k.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[j.morphTargetBase]),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0)):c.position>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglVertexBuffer),k.vertexAttribPointer(c.position,3,k.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var f=0,t=j.morphTargetForcedOrder,n=j.morphTargetInfluences;fp&&(o=u,p=n[o]);k.bindBuffer(k.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[o]);k.vertexAttribPointer(c["morphTarget"+f],3,k.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[f]= p;t[o]=1;p=-1;f++}}g.program.uniforms.morphTargetInfluences!==null&&k.uniform1fv(g.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(m in h.__webglCustomAttributes)b[m]>=0&&(c=h.__webglCustomAttributes[m],k.bindBuffer(k.ARRAY_BUFFER,c.buffer),k.vertexAttribPointer(b[m],c.size,k.FLOAT,!1,0,0));b.color>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglColorBuffer),k.vertexAttribPointer(b.color,3,k.FLOAT,!1,0,0));b.normal>=0&&(k.bindBuffer(k.ARRAY_BUFFER, h.__webglNormalBuffer),k.vertexAttribPointer(b.normal,3,k.FLOAT,!1,0,0));b.tangent>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglTangentBuffer),k.vertexAttribPointer(b.tangent,4,k.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(k.bindBuffer(k.ARRAY_BUFFER,h.__webglUVBuffer),k.vertexAttribPointer(b.uv,2,k.FLOAT,!1,0,0),k.enableVertexAttribArray(b.uv)):k.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(k.bindBuffer(k.ARRAY_BUFFER,h.__webglUV2Buffer),k.vertexAttribPointer(b.uv2,2,k.FLOAT,!1,0, 0),k.enableVertexAttribArray(b.uv2)):k.disableVertexAttribArray(b.uv2));g.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinVertexABuffer),k.vertexAttribPointer(b.skinVertexA,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),k.vertexAttribPointer(b.skinVertexB,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),k.vertexAttribPointer(b.skinIndex,4,k.FLOAT,!1,0,0),k.bindBuffer(k.ARRAY_BUFFER, h.__webglSkinWeightsBuffer),k.vertexAttribPointer(b.skinWeight,4,k.FLOAT,!1,0,0));j instanceof THREE.Mesh?(g.wireframe?(k.lineWidth(g.wireframeLinewidth),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),k.drawElements(k.LINES,h.__webglLineCount,k.UNSIGNED_SHORT,0)):(k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),k.drawElements(k.TRIANGLES,h.__webglFaceCount,k.UNSIGNED_SHORT,0)),S.data.vertices+=h.__webglFaceCount,S.data.faces+=h.__webglFaceCount/3,S.data.drawCalls++):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?k.LINE_STRIP:k.LINES,k.lineWidth(g.linewidth),k.drawArrays(j,0,h.__webglLineCount),S.data.drawCalls++):j instanceof THREE.ParticleSystem?(k.drawArrays(k.POINTS,0,h.__webglParticleCount),S.data.drawCalls++):j instanceof THREE.Ribbon&&(k.drawArrays(k.TRIANGLE_STRIP,0,h.__webglVertexCount),S.data.drawCalls++)}}function g(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=k.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=k.createBuffer();b.hasPos&& (k.bindBuffer(k.ARRAY_BUFFER,b.__webglVertexBuffer),k.bufferData(k.ARRAY_BUFFER,b.positionArray,k.DYNAMIC_DRAW),k.enableVertexAttribArray(e.attributes.position),k.vertexAttribPointer(e.attributes.position,3,k.FLOAT,!1,0,0));if(b.hasNormal){k.bindBuffer(k.ARRAY_BUFFER,b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,h,g,j,m,t,n,p,o,u,v=b.count*3;for(u=0;u0&&y[0]0&&y[1]0.0010&&m.scale>0.0010)w[0]=m.x,w[1]=m.y, w[2]=m.z,u=m.size*m.scale/ia,v[0]=u*n,v[1]=u,k.uniform3fv(x.screenPosition,w),k.uniform2fv(x.scale,v),k.uniform1f(x.rotation,m.rotation),k.uniform1f(x.opacity,m.opacity),I(m.blending),T(m.texture,1),k.drawElements(k.TRIANGLES,6,k.UNSIGNED_SHORT,0)}k.enable(k.CULL_FACE);k.enable(k.DEPTH_TEST);k.depthMask(ea)}function y(b,e){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)} function F(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglColorBuffer),k.bufferData(k.ARRAY_BUFFER,Y,m));sa&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglNormalBuffer),k.bufferData(k.ARRAY_BUFFER,ea, m));Aa&&ja.hasTangents&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglTangentBuffer),k.bufferData(k.ARRAY_BUFFER,V,m));qa&&T>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglUVBuffer),k.bufferData(k.ARRAY_BUFFER,fa,m));qa&&R>0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglUV2Buffer),k.bufferData(k.ARRAY_BUFFER,ca,m));ra&&(k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),k.bufferData(k.ELEMENT_ARRAY_BUFFER,ga,m),k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),k.bufferData(k.ELEMENT_ARRAY_BUFFER,ka,m));N> 0&&(k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinVertexABuffer),k.bufferData(k.ARRAY_BUFFER,da,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),k.bufferData(k.ARRAY_BUFFER,oa,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),k.bufferData(k.ARRAY_BUFFER,$,m),k.bindBuffer(k.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),k.bufferData(k.ARRAY_BUFFER,aa,m));j.dynamic||(delete g.__inittedArrays,delete g.__colorArray,delete g.__normalArray,delete g.__tangentArray,delete g.__uvArray,delete g.__uv2Array, delete g.__faceArray,delete g.__vertexArray,delete g.__lineArray,delete g.__skinVertexAArray,delete g.__skinVertexBArray,delete g.__skinIndexArray,delete g.__skinWeightArray)}}f.__dirtyVertices=!1;f.__dirtyMorphTargets=!1;f.__dirtyElements=!1;f.__dirtyUvs=!1;f.__dirtyNormals=!1;f.__dirtyTangents=!1;f.__dirtyColors=!1;C(h)}else if(b instanceof THREE.Ribbon){f=b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=k.DYNAMIC_DRAW;x=b.vertices;g=b.colors;z=x.length;j=g.length;B=b.__vertexArray;m=b.__colorArray; G=b.__dirtyColors;if(b.__dirtyVertices){for(t=0;t=0;c--)b[c].object==e&&b.splice(c,1)}function B(b){function e(b){var h=[];c=0;for(f=b.length;c65535&&(o[m].counter+=1,t=o[m].hash+"_"+o[m].counter,b.geometryGroups[t]==void 0&&(b.geometryGroups[t]={faces:[],materials:k,vertices:0,numMorphTargets:n})),b.geometryGroups[t].faces.push(h),b.geometryGroups[t].vertices+=j}function P(b,e,c){b.push({buffer:e,object:c, opaque:{list:[],count:0},transparent:{list:[],count:0}})}function I(b){if(b!=ga){switch(b){case THREE.AdditiveBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE);break;case THREE.SubtractiveBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:k.blendEquation(k.FUNC_ADD);k.blendFunc(k.ZERO,k.SRC_COLOR);break;default:k.blendEquationSeparate(k.FUNC_ADD,k.FUNC_ADD),k.blendFuncSeparate(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA,k.ONE,k.ONE_MINUS_SRC_ALPHA)}ga= b}}function H(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(k.texParameteri(b,k.TEXTURE_WRAP_S,K(e.wrapS)),k.texParameteri(b,k.TEXTURE_WRAP_T,K(e.wrapT)),k.texParameteri(b,k.TEXTURE_MAG_FILTER,K(e.magFilter)),k.texParameteri(b,k.TEXTURE_MIN_FILTER,K(e.minFilter)),k.generateMipmap(b)):(k.texParameteri(b,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE),k.texParameteri(b,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE),k.texParameteri(b,k.TEXTURE_MAG_FILTER,Y(e.magFilter)),k.texParameteri(b,k.TEXTURE_MIN_FILTER,Y(e.minFilter)))} function T(b,e){if(b.needsUpdate)b.__webglInit?(k.bindTexture(k.TEXTURE_2D,b.__webglTexture),k.texImage2D(k.TEXTURE_2D,0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,b.image)):(b.__webglTexture=k.createTexture(),k.bindTexture(k.TEXTURE_2D,b.__webglTexture),k.texImage2D(k.TEXTURE_2D,0,k.RGBA,k.RGBA,k.UNSIGNED_BYTE,b.image),b.__webglInit=!0),H(k.TEXTURE_2D,b,b.image),k.bindTexture(k.TEXTURE_2D,null),b.needsUpdate=!1;k.activeTexture(k.TEXTURE0+e);k.bindTexture(k.TEXTURE_2D,b.__webglTexture)}function U(b){if(b&&!b.__webglFramebuffer){if(b.depthBuffer=== void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=k.createFramebuffer();b.__webglRenderbuffer=k.createRenderbuffer();b.__webglTexture=k.createTexture();k.bindTexture(k.TEXTURE_2D,b.__webglTexture);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,K(b.wrapS));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,K(b.wrapT));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,K(b.magFilter));k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,K(b.minFilter));k.texImage2D(k.TEXTURE_2D, 0,K(b.format),b.width,b.height,0,K(b.format),K(b.type),null);k.bindRenderbuffer(k.RENDERBUFFER,b.__webglRenderbuffer);k.bindFramebuffer(k.FRAMEBUFFER,b.__webglFramebuffer);k.framebufferTexture2D(k.FRAMEBUFFER,k.COLOR_ATTACHMENT0,k.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER,k.DEPTH_COMPONENT16,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_ATTACHMENT,k.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(k.renderbufferStorage(k.RENDERBUFFER, k.DEPTH_STENCIL,b.width,b.height),k.framebufferRenderbuffer(k.FRAMEBUFFER,k.DEPTH_STENCIL_ATTACHMENT,k.RENDERBUFFER,b.__webglRenderbuffer)):k.renderbufferStorage(k.RENDERBUFFER,k.RGBA4,b.width,b.height);k.bindTexture(k.TEXTURE_2D,null);k.bindRenderbuffer(k.RENDERBUFFER,null);k.bindFramebuffer(k.FRAMEBUFFER,null)}var e,c;b?(e=b.__webglFramebuffer,c=b.width,b=b.height):(e=null,c=aa,b=ia);e!=fa&&(k.bindFramebuffer(k.FRAMEBUFFER,e),k.viewport($,ma,c,b),fa=e)}function J(b,e){var c;b=="fragment"?c=k.createShader(k.FRAGMENT_SHADER): b=="vertex"&&(c=k.createShader(k.VERTEX_SHADER));k.shaderSource(c,e);k.compileShader(c);if(!k.getShaderParameter(c,k.COMPILE_STATUS))return console.error(k.getShaderInfoLog(c)),console.error(e),null;return c}function Y(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return k.NEAREST;default:return k.LINEAR}}function K(b){switch(b){case THREE.RepeatWrapping:return k.REPEAT;case THREE.ClampToEdgeWrapping:return k.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return k.MIRRORED_REPEAT; case THREE.NearestFilter:return k.NEAREST;case THREE.NearestMipMapNearestFilter:return k.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return k.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return k.LINEAR;case THREE.LinearMipMapNearestFilter:return k.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return k.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return k.BYTE;case THREE.UnsignedByteType:return k.UNSIGNED_BYTE;case THREE.ShortType:return k.SHORT;case THREE.UnsignedShortType:return k.UNSIGNED_SHORT; case THREE.IntType:return k.INT;case THREE.UnsignedShortType:return k.UNSIGNED_INT;case THREE.FloatType:return k.FLOAT;case THREE.AlphaFormat:return k.ALPHA;case THREE.RGBFormat:return k.RGB;case THREE.RGBAFormat:return k.RGBA;case THREE.LuminanceFormat:return k.LUMINANCE;case THREE.LuminanceAlphaFormat:return k.LUMINANCE_ALPHA}return 0}var S=this,k,V=[],O=null,fa=null,ea=!0,W=null,da=null,ga=null,ka=null,pa=null,R=null,ha=null,$=0,ma=0,aa=0,ia=0,X=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4, new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],na=new THREE.Matrix4,la=new Float32Array(16),oa=new Float32Array(16),wa=new THREE.Vector4,Aa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},va=b.canvas!==void 0?b.canvas:document.createElement("canvas"),ya=b.stencil!==void 0?b.stencil:!0,Ma=b.antialias!==void 0?b.antialias:!1,sa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),ra=b.clearAlpha!== void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=va;this.sortObjects=this.autoClear=!0;try{if(!(k=va.getContext("experimental-webgl",{antialias:Ma,stencil:ya})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+k.getParameter(k.VERSION)+" | "+k.getParameter(k.VENDOR)+" | "+k.getParameter(k.RENDERER)+" | "+k.getParameter(k.SHADING_LANGUAGE_VERSION))}catch(qa){console.error(qa)}k.clearColor(0,0,0,1);k.clearDepth(1);k.enable(k.DEPTH_TEST); k.depthFunc(k.LEQUAL);k.frontFace(k.CCW);k.cullFace(k.BACK);k.enable(k.CULL_FACE);k.enable(k.BLEND);k.blendEquation(k.FUNC_ADD);k.blendFunc(k.SRC_ALPHA,k.ONE_MINUS_SRC_ALPHA);k.clearColor(sa.r,sa.g,sa.b,ra);this.context=k;var Ba=k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(ya){var ca={};ca.vertices=new Float32Array(12);ca.faces=new Uint16Array(6);ca.darkness=0.5;ca.vertices[0]=-20;ca.vertices[1]=-20;ca.vertices[2]=-1;ca.vertices[3]=20;ca.vertices[4]=-20;ca.vertices[5]=-1;ca.vertices[6]=20; ca.vertices[7]=20;ca.vertices[8]=-1;ca.vertices[9]=-20;ca.vertices[10]=20;ca.vertices[11]=-1;ca.faces[0]=0;ca.faces[1]=1;ca.faces[2]=2;ca.faces[3]=0;ca.faces[4]=2;ca.faces[5]=3;ca.vertexBuffer=k.createBuffer();ca.elementBuffer=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,ca.vertexBuffer);k.bufferData(k.ARRAY_BUFFER,ca.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,ca.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,ca.faces,k.STATIC_DRAW);ca.program=k.createProgram();k.attachShader(ca.program, J("fragment",THREE.ShaderLib.shadowPost.fragmentShader));k.attachShader(ca.program,J("vertex",THREE.ShaderLib.shadowPost.vertexShader));k.linkProgram(ca.program);ca.vertexLocation=k.getAttribLocation(ca.program,"position");ca.projectionLocation=k.getUniformLocation(ca.program,"projectionMatrix");ca.darknessLocation=k.getUniformLocation(ca.program,"darkness")}var M={};M.vertices=new Float32Array(16);M.faces=new Uint16Array(6);b=0;M.vertices[b++]=-1;M.vertices[b++]=-1;M.vertices[b++]=0;M.vertices[b++]= 0;M.vertices[b++]=1;M.vertices[b++]=-1;M.vertices[b++]=1;M.vertices[b++]=0;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=-1;M.vertices[b++]=1;M.vertices[b++]=0;M.vertices[b++]=1;b=0;M.faces[b++]=0;M.faces[b++]=1;M.faces[b++]=2;M.faces[b++]=0;M.faces[b++]=2;M.faces[b++]=3;M.vertexBuffer=k.createBuffer();M.elementBuffer=k.createBuffer();M.tempTexture=k.createTexture();M.occlusionTexture=k.createTexture();k.bindBuffer(k.ARRAY_BUFFER,M.vertexBuffer);k.bufferData(k.ARRAY_BUFFER, M.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,M.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,M.faces,k.STATIC_DRAW);k.bindTexture(k.TEXTURE_2D,M.tempTexture);k.texImage2D(k.TEXTURE_2D,0,k.RGB,16,16,0,k.RGB,k.UNSIGNED_BYTE,null);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,k.NEAREST);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,k.NEAREST);k.bindTexture(k.TEXTURE_2D, M.occlusionTexture);k.texImage2D(k.TEXTURE_2D,0,k.RGBA,16,16,0,k.RGBA,k.UNSIGNED_BYTE,null);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_S,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_WRAP_T,k.CLAMP_TO_EDGE);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MAG_FILTER,k.NEAREST);k.texParameteri(k.TEXTURE_2D,k.TEXTURE_MIN_FILTER,k.NEAREST);k.getParameter(k.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<=0?(M.hasVertexTexture=!1,M.program=k.createProgram(),k.attachShader(M.program,J("fragment",THREE.ShaderLib.lensFlare.fragmentShader)), k.attachShader(M.program,J("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(M.hasVertexTexture=!0,M.program=k.createProgram(),k.attachShader(M.program,J("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),k.attachShader(M.program,J("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));k.linkProgram(M.program);M.attributes={};M.uniforms={};M.attributes.vertex=k.getAttribLocation(M.program,"position");M.attributes.uv=k.getAttribLocation(M.program,"UV");M.uniforms.renderType= k.getUniformLocation(M.program,"renderType");M.uniforms.map=k.getUniformLocation(M.program,"map");M.uniforms.occlusionMap=k.getUniformLocation(M.program,"occlusionMap");M.uniforms.opacity=k.getUniformLocation(M.program,"opacity");M.uniforms.scale=k.getUniformLocation(M.program,"scale");M.uniforms.rotation=k.getUniformLocation(M.program,"rotation");M.uniforms.screenPosition=k.getUniformLocation(M.program,"screenPosition");var ua=!1,Q={};Q.vertices=new Float32Array(16);Q.faces=new Uint16Array(6);b= 0;Q.vertices[b++]=-1;Q.vertices[b++]=-1;Q.vertices[b++]=0;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=-1;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=1;Q.vertices[b++]=0;Q.vertices[b++]=-1;Q.vertices[b++]=1;Q.vertices[b++]=0;b=Q.vertices[b++]=0;Q.faces[b++]=0;Q.faces[b++]=1;Q.faces[b++]=2;Q.faces[b++]=0;Q.faces[b++]=2;Q.faces[b++]=3;Q.vertexBuffer=k.createBuffer();Q.elementBuffer=k.createBuffer();k.bindBuffer(k.ARRAY_BUFFER,Q.vertexBuffer);k.bufferData(k.ARRAY_BUFFER, Q.vertices,k.STATIC_DRAW);k.bindBuffer(k.ELEMENT_ARRAY_BUFFER,Q.elementBuffer);k.bufferData(k.ELEMENT_ARRAY_BUFFER,Q.faces,k.STATIC_DRAW);Q.program=k.createProgram();k.attachShader(Q.program,J("fragment",THREE.ShaderLib.sprite.fragmentShader));k.attachShader(Q.program,J("vertex",THREE.ShaderLib.sprite.vertexShader));k.linkProgram(Q.program);Q.attributes={};Q.uniforms={};Q.attributes.position=k.getAttribLocation(Q.program,"position");Q.attributes.uv=k.getAttribLocation(Q.program,"uv");Q.uniforms.uvOffset= k.getUniformLocation(Q.program,"uvOffset");Q.uniforms.uvScale=k.getUniformLocation(Q.program,"uvScale");Q.uniforms.rotation=k.getUniformLocation(Q.program,"rotation");Q.uniforms.scale=k.getUniformLocation(Q.program,"scale");Q.uniforms.alignment=k.getUniformLocation(Q.program,"alignment");Q.uniforms.map=k.getUniformLocation(Q.program,"map");Q.uniforms.opacity=k.getUniformLocation(Q.program,"opacity");Q.uniforms.useScreenCoordinates=k.getUniformLocation(Q.program,"useScreenCoordinates");Q.uniforms.affectedByDistance= k.getUniformLocation(Q.program,"affectedByDistance");Q.uniforms.screenPosition=k.getUniformLocation(Q.program,"screenPosition");Q.uniforms.modelViewMatrix=k.getUniformLocation(Q.program,"modelViewMatrix");Q.uniforms.projectionMatrix=k.getUniformLocation(Q.program,"projectionMatrix");var ja=!1;this.setSize=function(b,e){va.width=b;va.height=e;this.setViewport(0,0,va.width,va.height)};this.setViewport=function(b,e,c,f){$=b;ma=e;aa=c;ia=f;k.viewport($,ma,aa,ia)};this.setScissor=function(b,e,c,f){k.scissor(b, e,c,f)};this.enableScissorTest=function(b){b?k.enable(k.SCISSOR_TEST):k.disable(k.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){ea=b;k.depthMask(b)};this.setClearColorHex=function(b,e){sa.setHex(b);ra=e;k.clearColor(sa.r,sa.g,sa.b,ra)};this.setClearColor=function(b,e){sa.copy(b);ra=e;k.clearColor(sa.r,sa.g,sa.b,ra)};this.clear=function(){k.clear(k.COLOR_BUFFER_BIT|k.DEPTH_BUFFER_BIT|k.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){ca.darkness=b};this.getContext=function(){return k}; this.initMaterial=function(b,e,c,f){var h,g,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?j="shadowVolumeDynamic":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 m=THREE.ShaderLib[j];b.uniforms= THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var t,o,n;t=n=m=0;for(o=e.length;t=0&&k.enableVertexAttribArray(p.position);p.color>=0&&k.enableVertexAttribArray(p.color);p.normal>=0&&k.enableVertexAttribArray(p.normal);p.tangent>=0&&k.enableVertexAttribArray(p.tangent); b.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(k.enableVertexAttribArray(p.skinVertexA),k.enableVertexAttribArray(p.skinVertexB),k.enableVertexAttribArray(p.skinIndex),k.enableVertexAttribArray(p.skinWeight));if(b.attributes)for(h in b.attributes)p[h]!==void 0&&p[h]>=0&&k.enableVertexAttribArray(p[h]);if(b.morphTargets){b.numSupportedMorphTargets=0;p.morphTarget0>=0&&(k.enableVertexAttribArray(p.morphTarget0),b.numSupportedMorphTargets++);p.morphTarget1>=0&&(k.enableVertexAttribArray(p.morphTarget1), b.numSupportedMorphTargets++);p.morphTarget2>=0&&(k.enableVertexAttribArray(p.morphTarget2),b.numSupportedMorphTargets++);p.morphTarget3>=0&&(k.enableVertexAttribArray(p.morphTarget3),b.numSupportedMorphTargets++);p.morphTarget4>=0&&(k.enableVertexAttribArray(p.morphTarget4),b.numSupportedMorphTargets++);p.morphTarget5>=0&&(k.enableVertexAttribArray(p.morphTarget5),b.numSupportedMorphTargets++);p.morphTarget6>=0&&(k.enableVertexAttribArray(p.morphTarget6),b.numSupportedMorphTargets++);p.morphTarget7>= 0&&(k.enableVertexAttribArray(p.morphTarget7),b.numSupportedMorphTargets++);f.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(h=this.maxMorphTargets;b0||u.faceVertexUvs.length>0)j.__uvArray=new Float32Array(t*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(t*2)}if(m.geometry.skinWeights.length&&m.geometry.skinIndices.length)j.__skinVertexAArray=new Float32Array(t*4), j.__skinVertexBArray=new Float32Array(t*4),j.__skinIndexArray=new Float32Array(t*4),j.__skinWeightArray=new Float32Array(t*4);j.__faceArray=new Uint16Array(w*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));j.__lineArray=new Uint16Array(y*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];u=0;for(v=j.numMorphTargets;u=0;g--)e[g]==c&&e.splice(g,1)}else c instanceof THREE.LensFlare?G(e.__webglLensFlares,c):c instanceof THREE.MarchingCubes&&G(e.__webglObjectsImmediate,c);b.__objectsRemoved.splice(0,1)}e=0;for(c=b.__webglObjects.length;e1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=j;c.v=h;return c}, clamp:function(b,c,e){return be?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; THREE.GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,g=e?c.geometry:c,h=b.vertices,j=g.vertices,m=b.faces,n=g.faces,p=b.faceVertexUvs[0],g=g.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var o=0,t=j.length;o 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( 0.0 );\nfor ( int i = 0; i < MAX_POINT_LIGHTS; i ++ ) {\nvec3 pointVector = normalize( vPointLight[ i ].xyz );\nvec3 pointHalfVector = normalize( vPointLight[ i ].xyz + viewPosition );\nfloat pointDistance = vPointLight[ i ].w;\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointTotal += pointDistance * vec4( pointLightColor[ i ], 1.0 ) * ( mColor * pointDiffuseWeight + mSpecular * pointSpecularWeight * pointDiffuseWeight );\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirTotal = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + viewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\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}"},convolution:{uniforms:{tDiffuse:{type:"t", value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i25&&(h=25);g=(h-1)*0.5;e=Array(h);for(c=f=0;c1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+v),f=f<0?0:1;if(e==="pos")if(e=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)e.x=g[0]+(h[0]-g[0])*f,e.y=g[1]+(h[1]-g[1])*f,e.z=g[2]+(h[2]-g[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",v,j.index-1).pos,this.points[1]=g,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",v,m.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,h,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=g[0]+(h[0]-g[0])*f,e.y=g[1]+(h[1]-g[1])*f,e.z=g[2]+(h[2]-g[2])*f}}if(this.JITCompile&&o[0][p]===void 0){this.hierarchy[0].update(void 0,!0);for(v=0;vb.length-2?h:h+1;e[3]=h>b.length-3?h:h+2;h=b[e[0]];m=b[e[1]];n=b[e[2]];p=b[e[3]];e=g*g;j=g*e;f[0]=this.interpolate(h[0],m[0],n[0],p[0],g,e,j);f[1]=this.interpolate(h[1],m[1],n[1],p[1],g,e,j);f[2]=this.interpolate(h[2],m[2],n[2],p[2],g,e,j);return f}; THREE.Animation.prototype.interpolate=function(b,c,e,f,g,h,j){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*j+(-3*(c-e)-2*b-f)*h+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 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}};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);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)}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;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,e,c,f){var g={name:c,fps:0.6,length:f,hierarchy:[]},h,j=e.getControlPointsArray(),m=e.getLength(),n=j.length,F=0;h=n-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:j[0],rot:[0,0,0,1],scl:[1,1,1]};e.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;j=this.verticalAngleMap.dstRange;var m=j[1]-j[0];this.phi= TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(j[1]-j[0])/(f[1]-f[0])+j[0]-j[0])/m)*m+j[0];f=this.horizontalAngleMap.srcRange;j=this.horizontalAngleMap.dstRange;m=j[1]-j[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(j[1]-j[0])/(f[1]-f[0])+j[0]-j[0])/m)*m+j[0];f=this.target.position;f.x=100*Math.sin(this.phi)*Math.cos(this.theta);f.y=100*Math.cos(this.phi);f.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,e,c)};this.onMouseMove=function(b){this.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}),j=new THREE.MeshLambertMaterial({color:65280}),m=new THREE.CubeGeometry(10,10,20),n=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(n,j);b.position.set(0,10,0);this.animation= c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else this.animation=c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,e){return function(){e.apply(b,arguments)}}(this,this.onMouseMove), !1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; THREE.FlyCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.domElement=document;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==void 0)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==void 0)this.dragToLook=b.dragToLook;if(b.autoForward!==void 0)this.autoForward= b.autoForward;if(b.domElement!==void 0)this.domElement=b.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.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,h=c.size[1]/2;this.moveState.yawLeft=-(b.clientX-c.offset[0]-g)/g;this.moveState.pitchDown=(b.clientY- c.offset[1]-h)/h;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;var b=this.tdiff*this.movementSpeed,c=this.tdiff* this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVector.y*b);this.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*c,this.rotationVector.y*c,this.rotationVector.z*c,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var b=this.moveState.forward|| this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!= document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,this.mouseup),!1);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,h=new THREE.Vector3,j=new THREE.Vector3,m=new THREE.Matrix4,n=!1,p=1,o=0,t=0,u=0,v=0,w=0,z=window.innerWidth/2,x=window.innerHeight/2;this.update= function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.delta=(b-this.lastUpdate)/1E3;this.lastUpdate=b;this.mouseLook&&(b=this.delta*this.lookSpeed,this.rotateHorizontally(b*v),this.rotateVertically(b*w));b=this.delta*this.movementSpeed;this.translateZ(b*(o>0||this.autoForward&&!(o<0)?1:o));this.translateX(b*t);this.translateY(b*u);n&&(this.roll+=this.rollSpeed*this.delta*p);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); else if(this.forward.y1?c.normalize():c.z=Math.sqrt(1-f*f);g=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(c.y);f.addSelf(this.up.clone().crossSelf(g).setLength(c.x));f.addSelf(g.setLength(c.z));return f}; this.rotateCamera=function(){var b=Math.acos(h.dot(j)/h.length()/j.length());if(b){var e=(new THREE.Vector3).cross(h,j).normalize(),c=new THREE.Quaternion;b*=this.rotateSpeed;c.setFromAxisAngle(e,-b);c.multiplyVector3(g);c.multiplyVector3(this.up);c.multiplyVector3(j);this.staticMoving?h=j:(c.setFromAxisAngle(e,b*(this.dynamicDampingFactor-1)),c.multiplyVector3(h))}};this.zoomCamera=function(){var b=1+(n.y-m.y)*this.zoomSpeed;b!==1&&b>0&&(g.multiplyScalar(b),this.staticMoving?m=n:m.y+=(n.y-m.y)*this.dynamicDampingFactor)}; this.panCamera=function(){var b=o.clone().subSelf(p);if(b.lengthSq()){b.multiplyScalar(g.length()*this.panSpeed);var e=g.clone().crossSelf(this.up).setLength(b.x);e.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(e);this.target.position.addSelf(e);this.staticMoving?p=o:p.addSelf(b.sub(o,p).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()h)break;f++}return f/g};THREE.LineCurve=function(b,c,e,f){this.x1=b;this.y1=c;this.x2=e;this.y2=f};THREE.LineCurve.prototype=new THREE.Curve;THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(b){return new THREE.Vector2(this.x1+(this.x2-this.x1)*b,this.y1+(this.y2-this.y1)*b)}; THREE.QuadraticBezierCurve=function(b,c,e,f,g,h){this.x0=b;this.y0=c;this.x1=e;this.y1=f;this.x2=g;this.y2=h};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve;THREE.QuadraticBezierCurve.prototype.getPoint=function(b){var c;c=THREE.FontUtils.b2(b,this.x0,this.x1,this.x2);b=THREE.FontUtils.b2(b,this.y0,this.y1,this.y2);return new THREE.Vector2(c,b)}; THREE.QuadraticBezierCurve.prototype.getNormalVector=function(b){var c;c=THREE.Curve.Utils.tangentQuadraticBezier(b,this.x0,this.x1,this.x2);b=THREE.Curve.Utils.tangentQuadraticBezier(b,this.y0,this.y1,this.y2);return(new THREE.Vector2(-b,c)).unit()};THREE.CubicBezierCurve=function(b,c,e,f,g,h,j,m){this.x0=b;this.y0=c;this.x1=e;this.y1=f;this.x2=g;this.y2=h;this.x3=j;this.y3=m};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve; THREE.CubicBezierCurve.prototype.getPoint=function(b){var c;c=THREE.FontUtils.b3(b,this.x0,this.x1,this.x2,this.x3);b=THREE.FontUtils.b3(b,this.y0,this.y1,this.y2,this.y3);return new THREE.Vector2(c,b)};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,h){this.aX=b;this.aY=c;this.aRadius=e;this.aStartAngle=f;this.aEndAngle=g;this.aClockwise=h}; THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(b){var c=this.aEndAngle-this.aStartAngle;this.aClockwise||(b=1-b);b=this.aStartAngle+b*c;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(b),this.aY+this.aRadius*Math.sin(b))}; THREE.Curve.Utils={tangentQuadraticBezier:function(b,c,e,f){return 2*(1-b)*(e-c)+2*b*(f-e)},tangentSpline:function(){},interpolate:function(b,c,e,f,g){var b=(e-b)*0.5,f=(f-c)*0.5,h=g*g;return(2*c-2*e+b+f)*g*h+(-3*c+3*e-2*b-f)*h+b*g+c}};THREE.Path=function(b){this.actions=[];this.curves=[];b&&this.fromPoints(b)};THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc"}; THREE.Path.prototype.fromPoints=function(b){this.moveTo(b[0].x,b[0].y);var c,e=b.length;for(c=1;c0?(h=c[c.length-1],u=h.x,v=h.y):(h=this.actions[e-1].args,u=h[h.length-2],v=h[h.length-1]);for(h=1;h<=b;h++)w=h/b,g=THREE.FontUtils.b2(w,u,o,j),w=THREE.FontUtils.b2(w,v,t,m),c.push(new THREE.Vector2(g, w));break;case THREE.PathActions.BEZIER_CURVE_TO:j=g[4];m=g[5];o=g[0];t=g[1];n=g[2];p=g[3];c.length>0?(h=c[c.length-1],u=h.x,v=h.y):(h=this.actions[e-1].args,u=h[h.length-2],v=h[h.length-1]);for(h=1;h<=b;h++)w=h/b,g=THREE.FontUtils.b3(w,u,o,n,j),w=THREE.FontUtils.b3(w,v,t,p,m),c.push(new THREE.Vector2(g,w));break;case THREE.PathActions.CSPLINE_THRU:h=this.actions[e-1].args;h=[new THREE.Vector2(h[h.length-2],h[h.length-1])];w=b*g[0].length;h=h.concat(g[0]);g=new THREE.SplineCurve(h);for(h=1;h<=w;h++)c.push(g.getPointAt(h/ w));break;case THREE.PathActions.ARC:h=this.actions[e-1].args;j=g[0];m=g[1];n=g[2];o=g[3];w=g[4];t=!!g[5];p=h[h.length-2];u=h[h.length-1];h.length==0&&(p=u=0);v=w-o;var z=b*2;for(h=1;h<=z;h++)w=h/z,t||(w=1-w),w=o+w*v,g=p+j+n*Math.cos(w),w=u+m+n*Math.sin(w),c.push(new THREE.Vector2(g,w))}return c}; THREE.Path.prototype.getMinAndMax=function(){var b=this.getPoints(),c,e,f,g;c=e=Number.NEGATIVE_INFINITY;f=g=Number.POSITIVE_INFINITY;var h,j,m;j=0;for(m=b.length;jc)c=h.x;else if(h.xe)e=h.y;else if(h.y=c)return c=e[b]-c,b=this.curves[b],c=1-c/b.getLength(),b.getPointAt(c);b++}return null}; THREE.Path.prototype.getLength=function(){var b=[],c=0,e,f=this.curves.length;for(e=0;e=0?m-1:e.length-1;h=j-1>=0?j-1:p.length-1;var z=[p[j],e[m],e[g]];t=THREE.FontUtils.Triangulate.area(z);var x=[p[j],p[h],e[m]];u=THREE.FontUtils.Triangulate.area(x);v=m;o=j;m+=1;j+=-1;m<0&&(m+=e.length);m%=e.length; j<0&&(j+=p.length);j%=p.length;g=m-1>=0?m-1:e.length-1;h=j-1>=0?j-1:p.length-1;z=[p[j],e[m],e[g]];z=THREE.FontUtils.Triangulate.area(z);x=[p[j],p[h],e[m]];x=THREE.FontUtils.Triangulate.area(x);t+u>z+x&&(m=v,j=o,m<0&&(m+=e.length),m%=e.length,j<0&&(j+=p.length),j%=p.length,g=m-1>=0?m-1:e.length-1,h=j-1>=0?j-1:p.length-1);t=e.slice(0,m);u=e.slice(m);v=p.slice(j);o=p.slice(0,j);h=[p[j],p[h],e[m]];w.push([p[j],e[m],e[g]]);w.push(h);e=t.concat(v).concat(o).concat(u)}return{shape:e,isolatedPts:w,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),h,j,m,n;for(h=0;h0){j(0,0,-o-(h||0));for(n=b;n0){j(0,0,o+ (g||0));for(n=b+b/2;n<2*b;n++)m.faces.push(new THREE.Face4(2*b+1,(2*n-2*b+2)%b+b,(2*n-2*b+1)%b+b,(2*n-2*b)%b+b))}n=0;for(b=this.faces.length;n=0;){k=B;V=B-1;V<0&&(V=b.length-1);for(var e=0,e=0;e0;U--){z=U/o;Y=m*z;J=n*(1-Math.sin((1-z)*Math.PI/2));B=0;for(P=G.length;B0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,m,u)))-1);p.push(o)}c.push(p)}for(var v,w,z,g=c.length,e=0;e0)for(f=0;f1&&(v= this.vertices[j].position.clone(),w=this.vertices[n].position.clone(),z=this.vertices[p].position.clone(),v.normalize(),w.normalize(),z.normalize(),this.faces.push(new THREE.Face3(j,n,p,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(z.x,z.y,z.z)])),this.faceVertexUvs[0].push([o,t,x]))}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){THREE.Geometry.call(this);this.parameters=c||{};this.set(b)};THREE.TextGeometry.prototype=new THREE.Geometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry; THREE.TextGeometry.prototype.set=function(b,c){function e(b,e,c){w.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,c)))}function f(b,e,c,f){w.faces.push(new THREE.Face4(b,e,c,f))}this.text=b;var c=c||this.parameters,g=c.height!==void 0?c.height:50,h=c.curveSegments!==void 0?c.curveSegments:4,j=c.font!==void 0?c.font:"helvetiker",m=c.weight!==void 0?c.weight:"normal",n=c.style!==void 0?c.style:"normal",p=c.bezelThickness!==void 0?c.bezelThickness:10,o=c.bezelSize!==void 0?c.bezelSize:8,t=c.bezelEnabled!== void 0?c.bezelEnabled:!1;THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=h;THREE.FontUtils.face=j;THREE.FontUtils.weight=m;THREE.FontUtils.style=n;THREE.FontUtils.bezelSize=o;var m=THREE.FontUtils.drawText(b),h=m.points,u=m.faces,j=m.contour,v=m.bezel,w=this;w.vertices=[];w.faces=[];for(var z,n=h.length,x=u.length,o=v.length,m=0;m0;){if(y){if(y.equals(j[m])){y=null;continue}}else y=j[m];p=n*2+m;u=p-1;f(p,u,u+o,p+o);for(t=0;t0;){if(y){if(y.equals(j[m])){y=null;continue}}else y=j[m];for(t=0;t0&&m.push({shape:g,holes:f}),g=t,f=[]):f.push(t):this.Triangulate.area(t)<0?(m.push({shape:t,holes:f}),f=[]):f.push(t);e++}o&&m.push({shape:g,holes:f})}var u,v,w, z,x,y;h=[];for(j=0;j=0?v-1:g.length-1;var t=u-1>=0?u-1:o.length-1,F=[];F.push(o[u]);F.push(g[v]);F.push(g[e]);w=this.Triangulate.area(F);var C=[];C.push(o[u]);C.push(o[t]);C.push(g[v]);x=this.Triangulate.area(C);z=v;y=u;v+=1;u+=-1;v<0&&(v+=g.length);v%=g.length;u<0&&(u+=o.length);u%=g.length;e=v- 1>=0?v-1:g.length-1;t=u-1>=0?u-1:o.length-1;F=[];F.push(o[u]);F.push(g[v]);F.push(g[e]);F=this.Triangulate.area(F);C=[];C.push(o[u]);C.push(o[t]);C.push(g[v]);C=this.Triangulate.area(C);w+x>F+C&&(v=z,u=y,v<0&&(v+=g.length),v%=g.length,u<0&&(u+=o.length),u%=g.length,e=v-1>=0?v-1:g.length-1,t=u-1>=0?u-1:o.length-1);w=g.slice(0,v);x=g.slice(v);z=o.slice(u);y=o.slice(0,u);h.push(o[u]);h.push(g[v]);h.push(g[e]);h.push(o[u]);h.push(o[t]);h.push(g[v]);g=w.concat(z).concat(y).concat(x)}n.shape=g}u=[];v=[]; for(j=p=0;j=0;){if(o){if(o.equals(e[b])){o=null;n=this.Triangulate.area(f)>0;j.push(n);h.push(m.divideScalar(f.length));f=[];m=new THREE.Vector2;continue}}else o=e[b];m.addSelf(e[b]);f.push(e[b])}b=e.length;for(f= 0;--b>=0;)n=e[b],m=h[f],n=n.clone().subSelf(m),p=this.bezelSize/n.length(),j[f]?p+=1:p=1-p,p=n.multiplyScalar(p).addSelf(m),g.unshift(p),o?o.equals(e[b])&&(o=null,f++):o=e[b];c.bezel=g;return c},b2p0:function(b,c){var e=1-b;return e*e*c},b2p1:function(b,c){return 2*(1-b)*b*c},b2p2:function(b,c){return b*b*c},b2:function(b,c,e,f){return this.b2p0(b,c)+this.b2p1(b,e)+this.b2p2(b,f)},b3p0:function(b,c){var e=1-b;return e*e*e*c},b3p1:function(b,c){var e=1-b;return 3*e*e*b*c},b3p2:function(b,c){return 3* (1-b)*b*b*c},b3p3:function(b,c){return b*b*b*c},b3:function(b,c,e,f,g){return this.b3p0(b,c)+this.b3p1(b,e)+this.b3p2(b,f)+this.b3p3(b,g)},extractGlyphPoints:function(b,c,e,f,g){var h=[],j,m,n,p,o,t,u,v,w,z,x=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(x){if(x.o){c=x._cachedOutline||(x._cachedOutline=x.o.split(" "));n=c.length;for(b=0;b0)for(p=0;p2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return m;return h}n=p;g<=n&&(n=0);p=n+1;g<=p&&(p=0);o=p+1;g<=o&&(o=0);var u;a:{u=b;var v=n,w=p,z=o,x=g,y=j,F=void 0,C=void 0,E=void 0, G=void 0,B=void 0,P=void 0,I=void 0,H=void 0,T=void 0,C=u[y[v]].x,E=u[y[v]].y,G=u[y[w]].x,B=u[y[w]].y,P=u[y[z]].x,I=u[y[z]].y;if(1.0E-10>(G-C)*(I-E)-(B-E)*(P-C))u=!1;else{for(F=0;F=0&&Y>=0&&S>=0){u=!1;break a}}u= !0}}if(u){h.push([b[j[n]],b[j[p]],b[j[o]]]);m.push([j[n],j[p],j[o]]);n=p;for(o=p+1;o>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=o(b,c),f=o(b,c+1),h=o(b,c+2);return(o(b,c+3)<<24)+(h<<16)+(f<<8)+e}function n(b,c){var e=o(b,c);return(o(b,c+1)<<8)+e}function p(b,c){var e=o(b,c);return e>127?e-256:e}function o(b, c){return b.charCodeAt(c)&255}function t(c){var e,f,h;e=g(b,c);f=g(b,c+B);h=g(b,c+P);c=n(b,c+I);THREE.BinaryLoader.prototype.f3(y,e,f,h,c)}function u(c){var e,f,h,j,k,o;e=g(b,c);f=g(b,c+B);h=g(b,c+P);j=n(b,c+I);k=g(b,c+H);o=g(b,c+T);c=g(b,c+U);THREE.BinaryLoader.prototype.f3n(y,E,e,f,h,j,k,o,c)}function v(c){var e,f,h,j;e=g(b,c);f=g(b,c+J);h=g(b,c+Y);j=g(b,c+K);c=n(b,c+S);THREE.BinaryLoader.prototype.f4(y,e,f,h,j,c)}function w(c){var e,f,h,j,o,p,t,u;e=g(b,c);f=g(b,c+J);h=g(b,c+Y);j=g(b,c+K);o=n(b, c+S);p=g(b,c+k);t=g(b,c+V);u=g(b,c+O);c=g(b,c+fa);THREE.BinaryLoader.prototype.f4n(y,E,e,f,h,j,o,p,t,u,c)}function z(c){var e,f;e=g(b,c);f=g(b,c+ea);c=g(b,c+W);THREE.BinaryLoader.prototype.uv3(y.faceVertexUvs[0],G[e*2],G[e*2+1],G[f*2],G[f*2+1],G[c*2],G[c*2+1])}function x(c){var e,f,h;e=g(b,c);f=g(b,c+da);h=g(b,c+ga);c=g(b,c+ka);THREE.BinaryLoader.prototype.uv4(y.faceVertexUvs[0],G[e*2],G[e*2+1],G[f*2],G[f*2+1],G[h*2],G[h*2+1],G[c*2],G[c*2+1])}var y=this,F=0,C,E=[],G=[],B,P,I,H,T,U,J,Y,K,S,k,V,O,fa, ea,W,da,ga,ka,pa,R,ha,$,ma,aa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,f,c);C={signature:b.substr(F,8),header_bytes:o(b,F+8),vertex_coordinate_bytes:o(b,F+9),normal_coordinate_bytes:o(b,F+10),uv_coordinate_bytes:o(b,F+11),vertex_index_bytes:o(b,F+12),normal_index_bytes:o(b,F+13),uv_index_bytes:o(b,F+14),material_index_bytes:o(b,F+15),nvertices:g(b,F+16),nnormals:g(b,F+16+4),nuvs:g(b,F+16+8),ntri_flat:g(b,F+16+12),ntri_smooth:g(b,F+16+16),ntri_flat_uv:g(b,F+16+20),ntri_smooth_uv:g(b, F+16+24),nquad_flat:g(b,F+16+28),nquad_smooth:g(b,F+16+32),nquad_flat_uv:g(b,F+16+36),nquad_smooth_uv:g(b,F+16+40)};F+=C.header_bytes;B=C.vertex_index_bytes;P=C.vertex_index_bytes*2;I=C.vertex_index_bytes*3;H=C.vertex_index_bytes*3+C.material_index_bytes;T=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;U=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;J=C.vertex_index_bytes;Y=C.vertex_index_bytes*2;K=C.vertex_index_bytes*3;S=C.vertex_index_bytes*4;k=C.vertex_index_bytes* 4+C.material_index_bytes;V=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;O=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;fa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;ea=C.uv_index_bytes;W=C.uv_index_bytes*2;da=C.uv_index_bytes;ga=C.uv_index_bytes*2;ka=C.uv_index_bytes*3;c=C.vertex_index_bytes*3+C.material_index_bytes;aa=C.vertex_index_bytes*4+C.material_index_bytes;pa=C.ntri_flat*c;R=C.ntri_smooth*(c+C.normal_index_bytes*3);ha= C.ntri_flat_uv*(c+C.uv_index_bytes*3);$=C.ntri_smooth_uv*(c+C.normal_index_bytes*3+C.uv_index_bytes*3);ma=C.nquad_flat*aa;c=C.nquad_smooth*(aa+C.normal_index_bytes*4);aa=C.nquad_flat_uv*(aa+C.uv_index_bytes*4);F+=function(c){for(var f,g,h,k=C.vertex_coordinate_bytes*3,m=c+C.nvertices*k;c1&&(T=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(B,T);object.name=v;object.position.set(C[0],C[1],C[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=F.visible;O.scene.addObject(object);O.objects[v]=object;F.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),O.scene.collisions.colliders.push(b)); if(F.castsShadow)b=new THREE.ShadowVolume(B),O.scene.addChild(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;F.trigger&&F.trigger.toLowerCase()!="none"&&(b={type:F.trigger,object:F},O.triggers[object.name]=b)}}else C=F.position,r=F.rotation,q=F.quaternion,s=F.scale,q=0,object=new THREE.Object3D,object.name=v,object.position.set(C[0],C[1],C[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=F.visible!==void 0?F.visible:!1,O.scene.addObject(object),O.objects[v]=object,O.empties[v]=object,F.trigger&&F.trigger.toLowerCase()!="none"&&(b={type:F.trigger,object:F},O.triggers[object.name]=b)}function n(b){return function(c){O.geometries[b]=c;m();K-=1;e.onLoadComplete();o()}}function p(b){return function(c){O.geometries[b]=c}}function o(){e.callbackProgress({totalModels:k,totalTextures:V,loadedModels:k-K,loadedTextures:V-S},O);e.onLoadProgress();K==0&&S==0&&c(O)}var t, u,v,w,z,x,y,F,C,E,G,B,P,I,H,T,U,J,Y,K,S,k,V,O;J=b.data;H=new THREE.BinaryLoader;Y=new THREE.JSONLoader;S=K=0;O={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(v in J.objects)if(F=J.objects[v],F.meshCollider){b=!0;break}if(b)O.scene.collisions=new THREE.CollisionSystem;if(J.transform){b=J.transform.position;E=J.transform.rotation;var fa=J.transform.scale;b&&O.scene.position.set(b[0],b[1],b[2]);E&&O.scene.rotation.set(E[0], E[1],E[2]);fa&&O.scene.scale.set(fa[0],fa[1],fa[2]);(b||E||fa)&&O.scene.updateMatrix()}b=function(){S-=1;o();e.onLoadComplete()};for(z in J.cameras){E=J.cameras[z];if(E.type=="perspective")P=new THREE.Camera(E.fov,E.aspect,E.near,E.far);else if(E.type=="ortho")P=new THREE.Camera,P.projectionMatrix=THREE.Matrix4.makeOrtho(E.left,E.right,E.top,E.bottom,E.near,E.far);C=E.position;E=E.target;P.position.set(C[0],C[1],C[2]);P.target.position.set(E[0],E[1],E[2]);O.cameras[z]=P}for(w in J.lights)z=J.lights[w], P=z.color!==void 0?z.color:16777215,E=z.intensity!==void 0?z.intensity:1,z.type=="directional"?(C=z.direction,U=new THREE.DirectionalLight(P,E),U.position.set(C[0],C[1],C[2]),U.position.normalize()):z.type=="point"?(C=z.position,d=z.distance,U=new THREE.PointLight(P,E,d),U.position.set(C[0],C[1],C[2])):z.type=="ambient"&&(U=new THREE.AmbientLight(P)),O.scene.addLight(U),O.lights[w]=U;for(x in J.fogs)w=J.fogs[x],w.type=="linear"?I=new THREE.Fog(0,w.near,w.far):w.type=="exp2"&&(I=new THREE.FogExp2(0, w.density)),E=w.color,I.color.setRGB(E[0],E[1],E[2]),O.fogs[x]=I;if(O.cameras&&J.defaults.camera)O.currentCamera=O.cameras[J.defaults.camera];if(O.fogs&&J.defaults.fog)O.scene.fog=O.fogs[J.defaults.fog];E=J.defaults.bgcolor;O.bgColor=new THREE.Color;O.bgColor.setRGB(E[0],E[1],E[2]);O.bgColorAlpha=J.defaults.bgalpha;for(t in J.geometries)if(x=J.geometries[t],x.type=="bin_mesh"||x.type=="ascii_mesh")K+=1,e.onLoadStart();k=K;for(t in J.geometries)x=J.geometries[t],x.type=="cube"?(B=new THREE.CubeGeometry(x.width, x.height,x.depth,x.segmentsWidth,x.segmentsHeight,x.segmentsDepth,null,x.flipped,x.sides),O.geometries[t]=B):x.type=="plane"?(B=new THREE.PlaneGeometry(x.width,x.height,x.segmentsWidth,x.segmentsHeight),O.geometries[t]=B):x.type=="sphere"?(B=new THREE.SphereGeometry(x.radius,x.segmentsWidth,x.segmentsHeight),O.geometries[t]=B):x.type=="cylinder"?(B=new THREE.CylinderGeometry(x.numSegs,x.topRad,x.botRad,x.height,x.topOffset,x.botOffset),O.geometries[t]=B):x.type=="torus"?(B=new THREE.TorusGeometry(x.radius, x.tube,x.segmentsR,x.segmentsT),O.geometries[t]=B):x.type=="icosahedron"?(B=new THREE.IcosahedronGeometry(x.subdivisions),O.geometries[t]=B):x.type=="bin_mesh"?H.load({model:f(x.url,J.urlBaseType),callback:n(t)}):x.type=="ascii_mesh"?Y.load({model:f(x.url,J.urlBaseType),callback:n(t)}):x.type=="embedded_mesh"&&(x=J.embeds[x.id])&&Y.createModel(x,p(t),"");for(y in J.textures)if(t=J.textures[y],t.url instanceof Array){S+=t.url.length;for(H=0;H=this.maxCount-3&&m(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&&(n=this.size-1);var u=Math.floor(p-m);u<1&&(u=1);p=Math.floor(p+m);p>this.size-1&&(p=this.size-1);var v=Math.floor(o-m);v<1&&(v=1);m=Math.floor(o+m);m>this.size-1&&(m=this.size- 1);for(var w,z,x,y,F,C;t0&&(this.field[x+w]+=y)}}};this.addPlaneX=function(b,c){var g,h,j,m,n,p=this.size,o=this.yd,t=this.zd,u=this.field,v=p*Math.sqrt(b/c);v>p&&(v=p);for(g=0;g0)for(h=0;ho&&(w=o);for(h=0;h0){n=h*t;for(g=0;gsize&&(dist=size);for(j=0;j0){n=zd*j;for(h=0;hh?this.hits.push(g):this.hits.unshift(g),h=f;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var e=0;c[e]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,c[e]);if(f.distc.length)return null;return c[e]}; THREE.CollisionSystem.prototype.rayCast=function(b,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(b,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(b,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(b,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(b,c.box)}; THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,g,h=0;h=m*g))return Number.MAX_VALUE;j/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(j);m.addSelf(b.origin);Math.abs(h.x)> Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(b=m.y-c.y,h=e.y-c.y,g=f.y-c.y,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,h=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y):Math.abs(h.y)>Math.abs(h.z)?(b=m.x-c.x,h=e.x-c.x,g=f.x-c.x,m=m.z-c.z,e=e.z-c.z,f=f.z-c.z):(b=m.x-c.x,h=e.x-c.x,g=f.x-c.x,m=m.y-c.y,e=e.y-c.y,f=f.y-c.y);c=h*f-e*g;if(c==0)return Number.MAX_VALUE;c=1/c;f=(b*f-m*g)*c;if(!(f>=0))return Number.MAX_VALUE;c*=h*m-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return j}; 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,h=0,j=0,m=0,n=0,p=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,p=!1,j=1);e.origin.yc.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y, p=!1,m=1);e.origin.zc.max.z&&(h=c.max.z-e.origin.z,h/=e.direction.z,p=!1,n=1);if(p)return-1;p=0;g>f&&(p=1,f=g);h>f&&(p=2,f=h);switch(p){case 0:m=e.origin.y+e.direction.y*f;if(mc.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(j,0,0);break;case 1:j=e.origin.x+e.direction.x*f;if(jc.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,m,0);break;case 2:j=e.origin.x+e.direction.x*f;if(jc.max.x)return Number.MAX_VALUE;m=e.origin.y+e.direction.y*f;if(mc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,n)}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,h=new THREE.Camera,j=new THREE.Matrix4,m=new THREE.Matrix4,n,p,o;g.useTarget=h.useTarget=!1;g.matrixAutoUpdate=h.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},t=new THREE.WebGLRenderTarget(512,512,b),u=new THREE.WebGLRenderTarget(512,512,b),v=new THREE.Camera(53,1,1,1E4);v.position.z= 2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:t},mapRight:{type:"t",value:1,texture:u}},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 w=new THREE.Scene;w.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);t.width=b;t.height=f;u.width=b;u.height=f};this.render=function(b,e){e.update(null,!0);if(n!==e.aspect||p!==e.near||o!==e.fov){n=e.aspect;p=e.near;o=e.fov;var y=e.projectionMatrix.clone(),F=125/30*0.5,C=F*p/125,E=p*Math.tan(o*Math.PI/360),G;j.n14=F;m.n14=-F;F=-E*n+C;G=E*n+C;y.n11=2*p/(G-F);y.n13=(G+F)/(G-F);g.projectionMatrix=y.clone();F=-E*n-C;G=E*n-C;y.n11=2*p/(G-F); y.n13=(G+F)/(G-F);h.projectionMatrix=y.clone()}g.matrix=e.matrixWorld.clone().multiplySelf(m);g.update(null,!0);g.position.copy(e.position);g.near=p;g.far=e.far;f.call(c,b,g,t,!0);h.matrix=e.matrixWorld.clone().multiplySelf(j);h.update(null,!0);h.position.copy(e.position);h.near=p;h.far=e.far;f.call(c,b,h,u,!0);f.call(c,w,v)}}; if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,g,h,j=new THREE.Camera,m=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;h=f};this.render=function(b,e){this.clear();j.fov=e.fov;j.aspect=0.5*e.aspect;j.near=e.near;j.far=e.far; j.updateProjectionMatrix();j.position.copy(e.position);j.target.position.copy(e.target.position);j.translateX(c.separation);m.projectionMatrix=j.projectionMatrix;m.position.copy(e.position);m.target.position.copy(e.target.position);m.translateX(-c.separation);this.setViewport(0,0,g,h);f.call(c,b,j);this.setViewport(g,0,g,h);f.call(c,b,m,!1)}};