// Three.js r41/ROME - 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,j,k,m,n;if(e==0)f=g=j=0;else switch(k=Math.floor(b*6),m=b*6-k,b=e*(1-c),n=e*(1-c*m),c=e*(1-c*(1-m)),k){case 1:f=n;g=e;j=b;break;case 2:f=b;g=e;j=c;break;case 3:f=b;g=n;j=e;break;case 4:f=c;g=b;j=e;break;case 5:f=e;g=b;j=n;break;case 6:case 0:f=e,g=c,j=b}this.setRGB(f, g,j)},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.y;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&&j+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,j,k,m,n,o,p,t,u,v,w=b.geometry, E=w.vertices,I=[],f=0;for(g=w.faces.length;f0:t<0))if(p=p.dot((new THREE.Vector3).sub(k,u))/t,u=u.addSelf(v.multiplyScalar(p)), j instanceof THREE.Face3)e(u,k,m,n)&&(j={distance:this.origin.distanceTo(u),point:u,face:j,object:b},I.push(j));else if(j instanceof THREE.Face4&&(e(u,k,m,o)||e(u,m,n,o)))j={distance:this.origin.distanceTo(u),point:u,face:j,object:b},I.push(j);return I}else return[]}}; THREE.Rectangle=function(){function b(){j=f-c;k=g-e}var c,e,f,g,j,k,m=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(j,k,p,t){m=!1;c=j;e=k;f=p;g=t;b()};this.addPoint=function(j,k){m?(m=!1,c=j,e=k,f=j,g=k):(c=cj?f:j,g=g>k?g:k);b()};this.add3Points= function(j,k,p,t,u,v){m?(m=!1,c=jp?j>u?j:u:p>u?p:u,g=k>t?k>v?k:v:t>v?t:v):(c=jp?j>u?j>f?j:f:u>f?u:f:p>u?p>f?p:f:u>f?u:f,g=k>t?k>v?k>g?k:g:v>g?v:g:t>v?t>g?t:g:v>g?v:g);b()};this.addRectangle=function(j){m?(m=!1,c=j.getLeft(),e=j.getTop(),f=j.getRight(),g=j.getBottom()):(c=cj.getRight()?f:j.getRight(),g=g> j.getBottom()?g:j.getBottom());b()};this.inflate=function(j){c-=j;e-=j;f+=j;g+=j;b()};this.minSelf=function(j){c=c>j.getLeft()?c:j.getLeft();e=e>j.getTop()?e:j.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,j,k,m,n,o,p,t,u,v,w,E){this.set(b||1,c||0,e||0,f||0,g||0,j||1,k||0,m||0,n||0,o||0,p||1,t||0,u||0,v||0,w||0,E||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={set:function(b,c,e,f,g,j,k,m,n,o,p,t,u,v,w,E){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=g;this.n22=j;this.n23=k;this.n24=m;this.n31=n;this.n32=o;this.n33=p;this.n34=t;this.n41=u;this.n42=v;this.n43=w;this.n44=E;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,c,e){var f=THREE.Matrix4.__v1, g=THREE.Matrix4.__v2,j=THREE.Matrix4.__v3;j.sub(b,c).normalize();if(j.length()===0)j.z=1;f.cross(e,j).normalize();f.length()===0&&(j.x+=1.0E-4,f.cross(e,j).normalize());g.cross(j,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=j.x;this.n21=f.y;this.n22=g.y;this.n23=j.y;this.n31=f.z;this.n32=g.z;this.n33=j.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,g=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*g;b.y=(this.n21*c+this.n22*e+this.n23* f+this.n24)*g;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,g=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*g;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*g;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*g;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var c=b.x,e=b.y,f=b.z;b.x=c*this.n11+e*this.n12+f*this.n13;b.y=c*this.n21+e*this.n22+f*this.n23;b.z=c*this.n31+e*this.n32+f*this.n33;b.normalize(); return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,k=b.n21,m=b.n22,n=b.n23,o=b.n24,p=b.n31,t=b.n32,u=b.n33,v=b.n34,w=b.n41,E=b.n42,I=b.n43,B=b.n44,H=c.n11,A=c.n12,K=c.n13,G=c.n14,C=c.n21,R=c.n22, D=c.n23,N=c.n24,J=c.n31,V=c.n32,h=c.n33,X=c.n34;this.n11=e*H+f*C+g*J;this.n12=e*A+f*R+g*V;this.n13=e*K+f*D+g*h;this.n14=e*G+f*N+g*X+j;this.n21=k*H+m*C+n*J;this.n22=k*A+m*R+n*V;this.n23=k*K+m*D+n*h;this.n24=k*G+m*N+n*X+o;this.n31=p*H+t*C+u*J;this.n32=p*A+t*R+u*V;this.n33=p*K+t*D+u*h;this.n34=p*G+t*N+u*X+v;this.n41=w*H+E*C+I*J;this.n42=w*A+E*R+I*V;this.n43=w*K+E*D+I*h;this.n44=w*G+E*N+I*X+B;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]= this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b= this.n11,c=this.n12,e=this.n13,f=this.n14,g=this.n21,j=this.n22,k=this.n23,m=this.n24,n=this.n31,o=this.n32,p=this.n33,t=this.n34,u=this.n41,v=this.n42,w=this.n43,E=this.n44;return f*k*o*u-e*m*o*u-f*j*p*u+c*m*p*u+e*j*t*u-c*k*t*u-f*k*n*v+e*m*n*v+f*g*p*v-b*m*p*v-e*g*t*v+b*k*t*v+f*j*n*w-c*m*n*w-f*g*o*w+b*m*o*w+c*g*t*w-b*j*t*w-e*j*n*E+c*k*n*E+e*g*o*E-b*k*o*E-c*g*p*E+b*j*p*E},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32= this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21; this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]= this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]=this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,e){this.set(1,0,0,b,0,1,0,c,0,0,1,e,0,0,0,1);return this},setScale:function(b, c,e){this.set(b,0,0,0,0,c,0,0,0,0,e,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var e=Math.cos(c),f=Math.sin(c),g=1-e,j=b.x,k=b.y,m=b.z,n=g*j,o=g*k;this.set(n* j+e,n*k-f*m,n*m+f*k,0,n*k+f*m,o*k+e,o*m-f*j,0,n*m-f*k,o*m+f*j,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){var c=b.x,e=b.y,f=b.z,b=Math.cos(c),c=Math.sin(c),g=Math.cos(e),e=Math.sin(e),j=Math.cos(f),f=Math.sin(f),k=b*e,m=c*e;this.n11=g*j;this.n12=-g*f;this.n13=e;this.n21=m*j+b*f;this.n22=-m*f+b*j;this.n23=-c*g;this.n31=-k*j+c*f;this.n32=k*f+c*j;this.n33=b*g;return this}, setRotationFromQuaternion:function(b){var c=b.x,e=b.y,f=b.z,g=b.w,j=c+c,k=e+e,m=f+f,b=c*j,n=c*k;c*=m;var o=e*k;e*=m;f*=m;j*=g;k*=g;g*=m;this.n11=1-(o+f);this.n12=n-g;this.n13=c+k;this.n21=n+g;this.n22=1-(b+f);this.n23=e-j;this.n31=c-k;this.n32=e+j;this.n33=1-(b+o);return this},scale:function(b){var c=b.x,e=b.y,b=b.z;this.n11*=c;this.n12*=e;this.n13*=b;this.n21*=c;this.n22*=e;this.n23*=b;this.n31*=c;this.n32*=e;this.n33*=b;this.n41*=c;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14= b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var e=1/c.x,f=1/c.y,g=1/c.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}}; THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,g=b.n13,j=b.n14,k=b.n21,m=b.n22,n=b.n23,o=b.n24,p=b.n31,t=b.n32,u=b.n33,v=b.n34,w=b.n41,E=b.n42,I=b.n43,B=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=n*v*E-o*u*E+o*t*I-m*v*I-n*t*B+m*u*B;c.n12=j*u*E-g*v*E-j*t*I+f*v*I+g*t*B-f*u*B;c.n13=g*o*E-j*n*E+j*m*I-f*o*I-g*m*B+f*n*B;c.n14=j*n*t-g*o*t-j*m*u+f*o*u+g*m*v-f*n*v;c.n21=o*u*w-n*v*w-o*p*I+k*v*I+n*p*B-k*u*B;c.n22=g*v*w-j*u*w+j*p*I-e*v*I-g*p*B+e*u*B;c.n23=j*n*w-g*o*w-j*k*I+e*o*I+g*k*B-e*n*B;c.n24= g*o*p-j*n*p+j*k*u-e*o*u-g*k*v+e*n*v;c.n31=m*v*w-o*t*w+o*p*E-k*v*E-m*p*B+k*t*B;c.n32=j*t*w-f*v*w-j*p*E+e*v*E+f*p*B-e*t*B;c.n33=g*o*w-j*m*w+j*k*E-e*o*E-f*k*B+e*m*B;c.n34=j*m*p-f*o*p-j*k*t+e*o*t+f*k*v-e*m*v;c.n41=n*t*w-m*u*w-n*p*E+k*u*E+m*p*I-k*t*I;c.n42=f*u*w-g*t*w+g*p*E-e*u*E-f*p*I+e*t*I;c.n43=g*m*w-f*n*w-g*k*E+e*n*E+f*k*I-e*m*I;c.n44=f*n*p-g*m*p+g*k*t-e*n*t-f*k*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,j=b.n32*b.n21-b.n31*b.n22,k=-b.n33*b.n12+b.n32*b.n13,m=b.n33*b.n11-b.n31*b.n13,n=-b.n32*b.n11+b.n31*b.n12,o=b.n23*b.n12-b.n22*b.n13,p=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*k+b.n31*o;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*g;e[2]=b*j;e[3]=b*k;e[4]=b*m;e[5]=b*n;e[6]=b*o;e[7]=b*p;e[8]=b*t;return c}; THREE.Matrix4.makeFrustum=function(b,c,e,f,g,j){var k;k=new THREE.Matrix4;k.n11=2*g/(c-b);k.n12=0;k.n13=(c+b)/(c-b);k.n14=0;k.n21=0;k.n22=2*g/(f-e);k.n23=(f+e)/(f-e);k.n24=0;k.n31=0;k.n32=0;k.n33=-(j+g)/(j-g);k.n34=-2*j*g/(j-g);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(b,c,e,f){var g,b=e*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*c,b*c,g,b,e,f)}; THREE.Matrix4.makeOrtho=function(b,c,e,f,g,j){var k,m,n,o;k=new THREE.Matrix4;m=c-b;n=e-f;o=j-g;k.n11=2/m;k.n12=0;k.n13=0;k.n14=-((c+b)/m);k.n21=0;k.n22=2/n;k.n23=0;k.n24=-((e+f)/n);k.n31=0;k.n32=0;k.n33=-2/o;k.n34=-((j+g)/o);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.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.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;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 j=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<0.0010)return e.w=0.5*(b.w+c.w),e.x=0.5*(b.x+c.x),e.y=0.5*(b.y+c.y),e.z=0.5*(b.z+c.z),e;g=Math.sin((1-f)*j)/k;f=Math.sin(f*j)/k;e.w=b.w*g+c.w*f;e.x=b.x*g+c.x*f;e.y=b.y*g+c.y*f;e.z=b.z*g+c.z*f;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; THREE.Face3=function(b,c,e,f,g,j){this.a=b;this.b=c;this.c=e;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,c,e,f,g,j,k){this.a=b;this.b=c;this.c=e;this.d=f;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];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?j:j+1;e[3]=j>this.points.length-3?j:j+2;o=this.points[e[0]];p=this.points[e[1]]; t=this.points[e[2]];u=this.points[e[3]];m=k*k;n=k*m;f.x=c(o.x,p.x,t.x,u.x,k,m,n);f.y=c(o.y,p.y,t.y,u.y,k,m,n);f.z=c(o.z,p.z,t.z,u.z,k,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=p,p=t,t=e):pv&&(e=u,u=v,v=e):u=0&&g>=0&&k>=0&&m>=0?!0:j<0&&g<0||k<0&&m<0?!1:(j<0?c=Math.max(c,j/(j-g)):g<0&&(f=Math.min(f,j/(j-g))),k<0?c=Math.max(c,k/(k-m)):m<0&&(f=Math.min(f,k/(k-m))),fK&&k.positionScreen.z0&&G.z<1))T=A[H]=A[H]||new THREE.RenderableParticle,H++,B=T,B.x=G.x/G.w,B.y=G.y/G.w,B.z=G.z,B.rotation=Q.rotation.z,B.scale.x=Q.scale.x*Math.abs(B.x-(G.x+ h.projectionMatrix.n11)/(G.w+h.projectionMatrix.n14)),B.scale.y=Q.scale.y*Math.abs(B.y-(G.y+h.projectionMatrix.n22)/(G.w+h.projectionMatrix.n24)),B.materials=Q.materials,g.push(B);j&&g.sort(c);return g}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,g,j;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;g=e/2;j=f/2};this.render=function(e,f){var n,o,p,t,u,v,w,E;b=c.projectScene(e,f);n=0;for(o=b.length;n>1,t=ga.height>> 1,j=h.scale.x*u,n=h.scale.y*v,k=j*o,m=n*t,sa.set(b.x-k,b.y-m,b.x+k,b.y+m),ta.instersects(sa)&&(w.save(),w.translate(b.x,b.y),w.rotate(-h.rotation),w.scale(j,-n),w.translate(-o,-t),w.drawImage(ga,0,0),w.restore())}else j instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*u,m=h.scale.y*v,sa.set(b.x-k,b.y-m,b.x+k,b.y+m),ta.instersects(sa)&&(f(j.color),g(j.color),w.save(),w.translate(b.x,b.y),w.rotate(-h.rotation),w.scale(k,m),j.program(w),w.restore()))}function B(b,h,j,g){c(g.opacity);e(g.blending); w.beginPath();w.moveTo(b.positionScreen.x,b.positionScreen.y);w.lineTo(h.positionScreen.x,h.positionScreen.y);w.closePath();if(g instanceof THREE.LineBasicMaterial){b=g.linewidth;if(G!=b)w.lineWidth=G=b;b=g.linecap;if(C!=b)w.lineCap=C=b;b=g.linejoin;if(R!=b)w.lineJoin=R=b;f(g.color);w.stroke();sa.inflate(g.linewidth*2)}}function A(b,f,h,g,m,n,ga,o,p){k.data.vertices+=3;k.data.faces++;c(o.opacity);e(o.blending);O=b.positionScreen.x;$=b.positionScreen.y;M=f.positionScreen.x;ca=f.positionScreen.y;U= h.positionScreen.x;S=h.positionScreen.y;I(O,$,M,ca,U,S);if(o instanceof THREE.MeshBasicMaterial)if(o.map)o.map.mapping instanceof THREE.UVMapping&&(pa=ga.uvs[0],z(O,$,M,ca,U,S,o.map.image,pa[g].u,pa[g].v,pa[m].u,pa[m].v,pa[n].u,pa[n].v));else if(o.envMap){if(o.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=j.matrixWorldInverse,qa.copy(ga.vertexNormalsWorld[0]),la=(qa.x*b.n11+qa.y*b.n12+qa.z*b.n13)*0.5+0.5,Ca=-(qa.x*b.n21+qa.y*b.n22+qa.z*b.n23)*0.5+0.5,qa.copy(ga.vertexNormalsWorld[1]), za=(qa.x*b.n11+qa.y*b.n12+qa.z*b.n13)*0.5+0.5,da=-(qa.x*b.n21+qa.y*b.n22+qa.z*b.n23)*0.5+0.5,qa.copy(ga.vertexNormalsWorld[2]),P=(qa.x*b.n11+qa.y*b.n12+qa.z*b.n13)*0.5+0.5,Aa=-(qa.x*b.n21+qa.y*b.n22+qa.z*b.n23)*0.5+0.5,z(O,$,M,ca,U,S,o.envMap.image,la,Ca,za,da,P,Aa)}else o.wireframe?F(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):K(o.color);else if(o instanceof THREE.MeshLambertMaterial)o.map&&!o.wireframe&&(o.map.mapping instanceof THREE.UVMapping&&(pa=ga.uvs[0],z(O,$,M,ca, U,S,o.map.image,pa[g].u,pa[g].v,pa[m].u,pa[m].v,pa[n].u,pa[n].v)),e(THREE.SubtractiveBlending)),Wa?!o.wireframe&&o.shading==THREE.SmoothShading&&ga.vertexNormalsWorld.length==3?(T.r=Z.r=ka.r=ua.r,T.g=Z.g=ka.g=ua.g,T.b=Z.b=ka.b=ua.b,t(p,ga.v1.positionWorld,ga.vertexNormalsWorld[0],T),t(p,ga.v2.positionWorld,ga.vertexNormalsWorld[1],Z),t(p,ga.v3.positionWorld,ga.vertexNormalsWorld[2],ka),na.r=(Z.r+ka.r)*0.5,na.g=(Z.g+ka.g)*0.5,na.b=(Z.b+ka.b)*0.5,ia=Ta(T,Z,ka,na),z(O,$,M,ca,U,S,ia,0,0,1,0,0,1)):(va.r= ua.r,va.g=ua.g,va.b=ua.b,t(p,ga.centroidWorld,ga.normalWorld,va),Q.r=Math.max(0,Math.min(o.color.r*va.r,1)),Q.g=Math.max(0,Math.min(o.color.g*va.g,1)),Q.b=Math.max(0,Math.min(o.color.b*va.b,1)),Q.updateHex(),o.wireframe?F(Q,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):K(Q)):o.wireframe?F(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):K(o.color);else if(o instanceof THREE.MeshDepthMaterial)aa=j.near,ma=j.far,T.r=T.g=T.b=1-Ga(b.positionScreen.z,aa,ma),Z.r=Z.g=Z.b= 1-Ga(f.positionScreen.z,aa,ma),ka.r=ka.g=ka.b=1-Ga(h.positionScreen.z,aa,ma),na.r=(Z.r+ka.r)*0.5,na.g=(Z.g+ka.g)*0.5,na.b=(Z.b+ka.b)*0.5,ia=Ta(T,Z,ka,na),z(O,$,M,ca,U,S,ia,0,0,1,0,0,1);else if(o instanceof THREE.MeshNormalMaterial)Q.r=La(ga.normalWorld.x),Q.g=La(ga.normalWorld.y),Q.b=La(ga.normalWorld.z),Q.updateHex(),o.wireframe?F(Q,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):K(Q)}function E(b,f,h,g,m,ga,o,n,p){k.data.vertices+=4;k.data.faces++;c(n.opacity);e(n.blending);if(n.map|| n.envMap)A(b,f,g,0,1,3,o,n,p),A(m,h,ga,1,2,3,o,n,p);else if(O=b.positionScreen.x,$=b.positionScreen.y,M=f.positionScreen.x,ca=f.positionScreen.y,U=h.positionScreen.x,S=h.positionScreen.y,ja=g.positionScreen.x,W=g.positionScreen.y,fa=m.positionScreen.x,Y=m.positionScreen.y,ha=ga.positionScreen.x,ea=ga.positionScreen.y,n instanceof THREE.MeshBasicMaterial)H(O,$,M,ca,U,S,ja,W),n.wireframe?F(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):K(n.color);else if(n instanceof THREE.MeshLambertMaterial)Wa? !n.wireframe&&n.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==4?(T.r=Z.r=ka.r=na.r=ua.r,T.g=Z.g=ka.g=na.g=ua.g,T.b=Z.b=ka.b=na.b=ua.b,t(p,o.v1.positionWorld,o.vertexNormalsWorld[0],T),t(p,o.v2.positionWorld,o.vertexNormalsWorld[1],Z),t(p,o.v4.positionWorld,o.vertexNormalsWorld[3],ka),t(p,o.v3.positionWorld,o.vertexNormalsWorld[2],na),ia=Ta(T,Z,ka,na),I(O,$,M,ca,ja,W),z(O,$,M,ca,ja,W,ia,0,0,1,0,0,1),I(fa,Y,U,S,ha,ea),z(fa,Y,U,S,ha,ea,ia,1,0,1,1,0,1)):(va.r=ua.r,va.g=ua.g,va.b=ua.b,t(p, o.centroidWorld,o.normalWorld,va),Q.r=Math.max(0,Math.min(n.color.r*va.r,1)),Q.g=Math.max(0,Math.min(n.color.g*va.g,1)),Q.b=Math.max(0,Math.min(n.color.b*va.b,1)),Q.updateHex(),H(O,$,M,ca,U,S,ja,W),n.wireframe?F(Q,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):K(Q)):(H(O,$,M,ca,U,S,ja,W),n.wireframe?F(n.color,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):K(n.color));else if(n instanceof THREE.MeshNormalMaterial)Q.r=La(o.normalWorld.x),Q.g=La(o.normalWorld.y),Q.b=La(o.normalWorld.z), Q.updateHex(),H(O,$,M,ca,U,S,ja,W),n.wireframe?F(Q,n.wireframeLinewidth,n.wireframeLinecap,n.wireframeLinejoin):K(Q);else if(n instanceof THREE.MeshDepthMaterial)aa=j.near,ma=j.far,T.r=T.g=T.b=1-Ga(b.positionScreen.z,aa,ma),Z.r=Z.g=Z.b=1-Ga(f.positionScreen.z,aa,ma),ka.r=ka.g=ka.b=1-Ga(g.positionScreen.z,aa,ma),na.r=na.g=na.b=1-Ga(h.positionScreen.z,aa,ma),ia=Ta(T,Z,ka,na),I(O,$,M,ca,ja,W),z(O,$,M,ca,ja,W,ia,0,0,1,0,0,1),I(fa,Y,U,S,ha,ea),z(fa,Y,U,S,ha,ea,ia,1,0,1,1,0,1)}function I(b,e,c,f,h,j){w.beginPath(); w.moveTo(b,e);w.lineTo(c,f);w.lineTo(h,j);w.lineTo(b,e);w.closePath()}function H(b,e,c,f,h,j,g,k){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(h,j);w.lineTo(g,k);w.lineTo(b,e);w.closePath()}function F(b,e,c,h){if(G!=e)w.lineWidth=G=e;if(C!=c)w.lineCap=C=c;if(R!=h)w.lineJoin=R=h;f(b);w.stroke();sa.inflate(e*2)}function K(b){g(b);w.fill()}function z(b,e,c,f,h,j,g,k,m,n,o,ga,t){var p,u;p=g.width-1;u=g.height-1;k*=p;m*=u;n*=p;o*=u;ga*=p;t*=u;c-=b;f-=e;h-=b;j-=e;n-=k;o-=m;ga-=k;t-=m;p=n*t-ga*o;p!= 0&&(u=1/p,p=(t*c-o*h)*u,o=(t*f-o*j)*u,c=(n*h-ga*c)*u,f=(n*j-ga*f)*u,b=b-p*k-c*m,e=e-o*k-f*m,w.save(),w.transform(p,o,c,f,b,e),w.clip(),w.drawImage(g,0,0),w.restore())}function Ta(b,e,c,f){var h=~~(b.r*255),j=~~(b.g*255),b=~~(b.b*255),g=~~(e.r*255),k=~~(e.g*255),e=~~(e.b*255),m=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),o=~~(f.r*255),ga=~~(f.g*255),f=~~(f.b*255);wa[0]=h<0?0:h>255?255:h;wa[1]=j<0?0:j>255?255:j;wa[2]=b<0?0:b>255?255:b;wa[4]=g<0?0:g>255?255:g;wa[5]=k<0?0:k>255?255:k;wa[6]=e<0?0:e>255?255: e;wa[8]=m<0?0:m>255?255:m;wa[9]=n<0?0:n>255?255:n;wa[10]=c<0?0:c>255?255:c;wa[12]=o<0?0:o>255?255:o;wa[13]=ga<0?0:ga>255?255:ga;wa[14]=f<0?0:f>255?255:f;Oa.putImageData(Xa,0,0);Sa.drawImage(Na,0,0);return Pa}function Ga(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function La(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Da(b,e){var c=e.x-b.x,f=e.y-b.y,h=1/Math.sqrt(c*c+f*f);c*=h;f*=h;e.x+=c;e.y+=f;b.x-=c;b.y-=f}var Ua,ab,oa,xa,Ea,Ma,Va,L;this.autoClear?this.clear():w.setTransform(1,0,0,-1,u,v);k.data.vertices= 0;k.data.faces=0;m=n.projectScene(b,j,this.sortElements);(Wa=b.lights.length>0)&&o(b);Ua=0;for(ab=m.length;Ua0&&(c.r+=j.color.r*g,c.g+=j.color.g*g,c.b+=j.color.b*g)):j instanceof THREE.PointLight&&(V.sub(j.position,e.centroidWorld),V.normalize(),g=e.normalWorld.dot(V)*j.intensity,g>0&&(c.r+=j.color.r*g,c.g+=j.color.g*g,c.b+=j.color.b*g))}function c(e,c,h,m,n,t){k.data.vertices+=3;k.data.faces++;O=f($++);O.setAttribute("d", "M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?G.hex=n.color.hex:n instanceof THREE.MeshLambertMaterial?K?(C.r=R.r,C.g=R.g,C.b=R.b,b(t,m,C),G.r=Math.max(0,Math.min(n.color.r*C.r,1)),G.g=Math.max(0,Math.min(n.color.g*C.g,1)),G.b=Math.max(0,Math.min(n.color.b*C.b,1)),G.updateHex()):G.hex=n.color.hex:n instanceof THREE.MeshDepthMaterial?(J=1-n.__2near/(n.__farPlusNear- m.z*n.__farMinusNear),G.setRGB(J,J,J)):n instanceof THREE.MeshNormalMaterial&&G.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));n.wireframe?O.setAttribute("style","fill: none; stroke: #"+j(G.hex.toString(16))+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):O.setAttribute("style","fill: #"+j(G.hex.toString(16))+"; fill-opacity: "+n.opacity);o.appendChild(O)}function e(e,c,h,m, n,t,p){k.data.vertices+=4;k.data.faces++;O=f($++);O.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?G.hex=t.color.hex:t instanceof THREE.MeshLambertMaterial?K?(C.r=R.r,C.g=R.g,C.b=R.b,b(p,n,C),G.r=Math.max(0,Math.min(t.color.r*C.r,1)),G.g=Math.max(0,Math.min(t.color.g*C.g,1)),G.b=Math.max(0,Math.min(t.color.b* C.b,1)),G.updateHex()):G.hex=t.color.hex:t instanceof THREE.MeshDepthMaterial?(J=1-t.__2near/(t.__farPlusNear-n.z*t.__farMinusNear),G.setRGB(J,J,J)):t instanceof THREE.MeshNormalMaterial&&G.setRGB(g(n.normalWorld.x),g(n.normalWorld.y),g(n.normalWorld.z));t.wireframe?O.setAttribute("style","fill: none; stroke: #"+j(G.hex.toString(16))+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):O.setAttribute("style", "fill: #"+j(G.hex.toString(16))+"; fill-opacity: "+t.opacity);o.appendChild(O)}function f(b){h[b]==null&&(h[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),ca==0&&h[b].setAttribute("shape-rendering","crispEdges"));return h[b]}function g(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function j(b){for(;b.length<6;)b="0"+b;return b}var k=this,m=null,n=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,t,u,v,w,E,I,B,H=new THREE.Rectangle,A=new THREE.Rectangle, K=!1,G=new THREE.Color(16777215),C=new THREE.Color(16777215),R=new THREE.Color(0),D=new THREE.Color(0),N=new THREE.Color(0),J,V=new THREE.Vector3,h=[],X=[],O,$,M,ca=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":ca=1;break;case "low":ca=0}};this.setSize=function(b,e){p=b;t=e;u=p/2;v=t/2;o.setAttribute("viewBox",-u+" "+-v+" "+p+" "+t);o.setAttribute("width",p);o.setAttribute("height",t);H.set(-u, -v,u,v)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};this.render=function(b,f){var h,g,t,p,C,G,J,T;this.autoClear&&this.clear();k.data.vertices=0;k.data.faces=0;m=n.projectScene(b,f,this.sortElements);M=$=0;if(K=b.lights.length>0){J=b.lights;R.setRGB(0,0,0);D.setRGB(0,0,0);N.setRGB(0,0,0);h=0;for(g=J.length;h 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\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 + vViewPosition );\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 + vViewPosition );\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)h.bindBuffer(h.ARRAY_BUFFER,g.__webglVertexBuffer),h.vertexAttribPointer(b.position,3,h.FLOAT,!1,0,0);else{c=j.program.attributes;k.morphTargetBase!==-1?(h.bindBuffer(h.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[k.morphTargetBase]), h.vertexAttribPointer(c.position,3,h.FLOAT,!1,0,0)):c.position>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglVertexBuffer),h.vertexAttribPointer(c.position,3,h.FLOAT,!1,0,0));if(k.morphTargetForcedOrder.length)for(var f=0,n=k.morphTargetForcedOrder,o=k.morphTargetInfluences;ft&&(p=u,t=o[p]);h.bindBuffer(h.ARRAY_BUFFER,g.__webglMorphTargetsBuffers[p]);h.vertexAttribPointer(c["morphTarget"+f],3,h.FLOAT,!1,0,0);k.__webglMorphTargetInfluences[f]=t;n[p]=1;t=-1;f++}}j.program.uniforms.morphTargetInfluences!==null&&h.uniform1fv(j.program.uniforms.morphTargetInfluences,k.__webglMorphTargetInfluences)}if(g.__webglCustomAttributes)for(m in g.__webglCustomAttributes)b[m]>= 0&&(c=g.__webglCustomAttributes[m],h.bindBuffer(h.ARRAY_BUFFER,c.buffer),h.vertexAttribPointer(b[m],c.size,h.FLOAT,!1,0,0));b.color>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglColorBuffer),h.vertexAttribPointer(b.color,3,h.FLOAT,!1,0,0));b.normal>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglNormalBuffer),h.vertexAttribPointer(b.normal,3,h.FLOAT,!1,0,0));b.tangent>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglTangentBuffer),h.vertexAttribPointer(b.tangent,4,h.FLOAT,!1,0,0));b.uv>=0&&(g.__webglUVBuffer?(h.bindBuffer(h.ARRAY_BUFFER, g.__webglUVBuffer),h.vertexAttribPointer(b.uv,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(b.uv)):h.disableVertexAttribArray(b.uv));b.uv2>=0&&(g.__webglUV2Buffer?(h.bindBuffer(h.ARRAY_BUFFER,g.__webglUV2Buffer),h.vertexAttribPointer(b.uv2,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(b.uv2)):h.disableVertexAttribArray(b.uv2));j.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinVertexABuffer),h.vertexAttribPointer(b.skinVertexA,4, h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),h.vertexAttribPointer(b.skinVertexB,4,h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),h.vertexAttribPointer(b.skinIndex,4,h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),h.vertexAttribPointer(b.skinWeight,4,h.FLOAT,!1,0,0));k instanceof THREE.Mesh?(j.wireframe?(h.lineWidth(j.wireframeLinewidth),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),h.drawElements(h.LINES,g.__webglLineCount, h.UNSIGNED_SHORT,0)):(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,g.__webglFaceBuffer),h.drawElements(h.TRIANGLES,g.__webglFaceCount,h.UNSIGNED_SHORT,0)),V.data.vertices+=g.__webglFaceCount,V.data.faces+=g.__webglFaceCount/3,V.data.drawCalls++):k instanceof THREE.Line?(k=k.type==THREE.LineStrip?h.LINE_STRIP:h.LINES,h.lineWidth(j.linewidth),h.drawArrays(k,0,g.__webglLineCount),V.data.drawCalls++):k instanceof THREE.ParticleSystem?(h.drawArrays(h.POINTS,0,g.__webglParticleCount),V.data.drawCalls++):k instanceof THREE.Ribbon&&(h.drawArrays(h.TRIANGLE_STRIP,0,g.__webglVertexCount),V.data.drawCalls++)}}function g(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=h.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=h.createBuffer();b.hasPos&&(h.bindBuffer(h.ARRAY_BUFFER,b.__webglVertexBuffer),h.bufferData(h.ARRAY_BUFFER,b.positionArray,h.DYNAMIC_DRAW),h.enableVertexAttribArray(e.attributes.position),h.vertexAttribPointer(e.attributes.position,3,h.FLOAT,!1,0,0));if(b.hasNormal){h.bindBuffer(h.ARRAY_BUFFER, b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,g,j,k,m,n,o,t,p,u,v=b.count*3;for(u=0;u0&&B[0]0&&B[1]0.0010&&m.scale>0.0010)w[0]=m.x,w[1]=m.y,w[2]=m.z,u=m.size*m.scale/ha,v[0]=u*o,v[1]=u,h.uniform3fv(A.screenPosition,w),h.uniform2fv(A.scale,v),h.uniform1f(A.rotation,m.rotation),h.uniform1f(A.opacity,m.opacity),K(m.blending),C(m.texture,1),h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0)}h.enable(h.CULL_FACE);h.enable(h.DEPTH_TEST);h.depthMask(M)}function I(b,e){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)} function B(b){var e,f,g,j,k;if(b instanceof THREE.Mesh){f=b.geometry;for(e in f.geometryGroups){g=f.geometryGroups[e];k=!1;for(j in g.__webglCustomAttributes)if(g.__webglCustomAttributes[j].needsUpdate){k=!0;break}if(f.__dirtyVertices||f.__dirtyMorphTargets||f.__dirtyElements||f.__dirtyUvs||f.__dirtyNormals||f.__dirtyColors||f.__dirtyTangents||k){k=b;var m=h.DYNAMIC_DRAW;if(g.__inittedArrays){var n=void 0,o=void 0,t=void 0,p=void 0,u=t=void 0,v=void 0,w=void 0,B=void 0,A=void 0,E=void 0,I=void 0, J=void 0,aa=void 0,C=void 0,G=void 0,H=void 0,K=void 0,F=p=B=p=w=v=void 0,D=void 0,z=D=F=v=void 0,ma=void 0,N=z=D=F=t=t=u=B=p=z=D=F=ma=z=D=F=ma=z=D=F=void 0,M=0,ia=0,P=0,pa=0,R=0,V=0,O=0,T=0,Q=0,L=0,S=0,D=F=0,W=g.__vertexArray,da=g.__uvArray,ca=g.__uv2Array,ja=g.__normalArray,U=g.__tangentArray,$=g.__colorArray,la=g.__skinVertexAArray,X=g.__skinVertexBArray,Y=g.__skinIndexArray,Z=g.__skinWeightArray,ka=g.__morphTargetsArrays,ha=g.__webglCustomAttributes,z=void 0,ea=g.__faceArray,fa=g.__lineArray, na=g.__needsSmoothNormals,E=g.__vertexColorType,A=g.__uvType,I=g.__normalType,ra=k.geometry,Ca=ra.__dirtyVertices,za=ra.__dirtyElements,ta=ra.__dirtyUvs,Aa=ra.__dirtyNormals,Ya=ra.__dirtyTangents,Za=ra.__dirtyColors,$a=ra.__dirtyMorphTargets,Ha=ra.vertices,bb=g.faces,eb=ra.faces,cb=ra.faceVertexUvs[0],db=ra.faceVertexUvs[1],Ia=ra.skinVerticesA,Ja=ra.skinVerticesB,Ka=ra.skinIndices,Ba=ra.skinWeights,Fa=k instanceof THREE.ShadowVolume?ra.edgeFaces:void 0,ya=ra.morphTargets;if(ha)for(N in ha)ha[N].offset= 0,ha[N].offsetSrc=0;n=0;for(o=bb.length;n0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglColorBuffer),h.bufferData(h.ARRAY_BUFFER,$,m));Aa&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglNormalBuffer),h.bufferData(h.ARRAY_BUFFER,ja,m));Ya&&ra.hasTangents&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglTangentBuffer),h.bufferData(h.ARRAY_BUFFER,U,m));ta&&P>0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglUVBuffer),h.bufferData(h.ARRAY_BUFFER,da,m));ta&&pa>0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglUV2Buffer),h.bufferData(h.ARRAY_BUFFER,ca,m));za&&(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER, g.__webglFaceBuffer),h.bufferData(h.ELEMENT_ARRAY_BUFFER,ea,m),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,g.__webglLineBuffer),h.bufferData(h.ELEMENT_ARRAY_BUFFER,fa,m));L>0&&(h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinVertexABuffer),h.bufferData(h.ARRAY_BUFFER,la,m),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinVertexBBuffer),h.bufferData(h.ARRAY_BUFFER,X,m),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinIndicesBuffer),h.bufferData(h.ARRAY_BUFFER,Y,m),h.bindBuffer(h.ARRAY_BUFFER,g.__webglSkinWeightsBuffer),h.bufferData(h.ARRAY_BUFFER, Z,m));k.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}else if(b instanceof THREE.Ribbon){f= b.geometry;if(f.__dirtyVertices||f.__dirtyColors){b=f;e=h.DYNAMIC_DRAW;A=b.vertices;g=b.colors;E=A.length;k=g.length;I=b.__vertexArray;m=b.__colorArray;J=b.__dirtyColors;if(b.__dirtyVertices){for(n=0;n65535&&(p[m].counter+=1,n=p[m].hash+"_"+p[m].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:k,vertices:0,numMorphTargets:o})),b.geometryGroups[n].faces.push(g), b.geometryGroups[n].vertices+=h}function A(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function K(b){if(b!=S){switch(b){case THREE.AdditiveBlending:h.blendEquation(h.FUNC_ADD);h.blendFunc(h.SRC_ALPHA,h.ONE);break;case THREE.SubtractiveBlending:h.blendEquation(h.FUNC_ADD);h.blendFunc(h.ZERO,h.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:h.blendEquation(h.FUNC_ADD);h.blendFunc(h.ZERO,h.SRC_COLOR);break;default:h.blendEquationSeparate(h.FUNC_ADD, h.FUNC_ADD),h.blendFuncSeparate(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA,h.ONE,h.ONE_MINUS_SRC_ALPHA)}S=b}}function G(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(h.texParameteri(b,h.TEXTURE_WRAP_S,J(e.wrapS)),h.texParameteri(b,h.TEXTURE_WRAP_T,J(e.wrapT)),h.texParameteri(b,h.TEXTURE_MAG_FILTER,J(e.magFilter)),h.texParameteri(b,h.TEXTURE_MIN_FILTER,J(e.minFilter)),h.generateMipmap(b)):(h.texParameteri(b,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(b,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texParameteri(b, h.TEXTURE_MAG_FILTER,N(e.magFilter)),h.texParameteri(b,h.TEXTURE_MIN_FILTER,N(e.minFilter)))}function C(b,e){if(b.needsUpdate){if(b.__webglTexture)b.__webglTexture=h.deleteTexture(b.__webglTexture);b.__webglTexture=h.createTexture();h.bindTexture(h.TEXTURE_2D,b.__webglTexture);h.texImage2D(h.TEXTURE_2D,0,h.RGBA,h.RGBA,h.UNSIGNED_BYTE,b.image);G(h.TEXTURE_2D,b,b.image);h.bindTexture(h.TEXTURE_2D,null);b.needsUpdate=!1}h.activeTexture(h.TEXTURE0+e);h.bindTexture(h.TEXTURE_2D,b.__webglTexture)}function R(b){if(b&& !b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglFramebuffer=h.createFramebuffer();b.__webglRenderbuffer=h.createRenderbuffer();b.__webglTexture=h.createTexture();h.bindTexture(h.TEXTURE_2D,b.__webglTexture);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,J(b.wrapS));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,J(b.wrapT));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,J(b.magFilter));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER, J(b.minFilter));h.texImage2D(h.TEXTURE_2D,0,J(b.format),b.width,b.height,0,J(b.format),J(b.type),null);h.bindRenderbuffer(h.RENDERBUFFER,b.__webglRenderbuffer);h.bindFramebuffer(h.FRAMEBUFFER,b.__webglFramebuffer);h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(h.renderbufferStorage(h.RENDERBUFFER,h.DEPTH_COMPONENT16,b.width,b.height),h.framebufferRenderbuffer(h.FRAMEBUFFER,h.DEPTH_ATTACHMENT,h.RENDERBUFFER,b.__webglRenderbuffer)): b.depthBuffer&&b.stencilBuffer?(h.renderbufferStorage(h.RENDERBUFFER,h.DEPTH_STENCIL,b.width,b.height),h.framebufferRenderbuffer(h.FRAMEBUFFER,h.DEPTH_STENCIL_ATTACHMENT,h.RENDERBUFFER,b.__webglRenderbuffer)):h.renderbufferStorage(h.RENDERBUFFER,h.RGBA4,b.width,b.height);h.bindTexture(h.TEXTURE_2D,null);h.bindRenderbuffer(h.RENDERBUFFER,null);h.bindFramebuffer(h.FRAMEBUFFER,null)}var e,c;b?(e=b.__webglFramebuffer,c=b.width,b=b.height):(e=null,c=Y,b=ha);e!=$&&(h.bindFramebuffer(h.FRAMEBUFFER,e),h.viewport(W, fa,c,b),$=e)}function D(b,e){var c;b=="fragment"?c=h.createShader(h.FRAGMENT_SHADER):b=="vertex"&&(c=h.createShader(h.VERTEX_SHADER));h.shaderSource(c,e);h.compileShader(c);if(!h.getShaderParameter(c,h.COMPILE_STATUS))return console.error(h.getShaderInfoLog(c)),console.error(e),null;return c}function N(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return h.NEAREST;default:return h.LINEAR}}function J(b){switch(b){case THREE.RepeatWrapping:return h.REPEAT; case THREE.ClampToEdgeWrapping:return h.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return h.MIRRORED_REPEAT;case THREE.NearestFilter:return h.NEAREST;case THREE.NearestMipMapNearestFilter:return h.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return h.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return h.LINEAR;case THREE.LinearMipMapNearestFilter:return h.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return h.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return h.BYTE; case THREE.UnsignedByteType:return h.UNSIGNED_BYTE;case THREE.ShortType:return h.SHORT;case THREE.UnsignedShortType:return h.UNSIGNED_SHORT;case THREE.IntType:return h.INT;case THREE.UnsignedShortType:return h.UNSIGNED_INT;case THREE.FloatType:return h.FLOAT;case THREE.AlphaFormat:return h.ALPHA;case THREE.RGBFormat:return h.RGB;case THREE.RGBAFormat:return h.RGBA;case THREE.LuminanceFormat:return h.LUMINANCE;case THREE.LuminanceAlphaFormat:return h.LUMINANCE_ALPHA}return 0}var V=this,h,X=[],O=null, $=null,M=!0,ca=null,U=null,S=null,ja=null,W=0,fa=0,Y=0,ha=0,ea=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Q=new THREE.Matrix4,T=new Float32Array(16),Z=new Float32Array(16),ka=new THREE.Vector4,na={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},aa=b.canvas!==void 0?b.canvas:document.createElement("canvas"),ma=b.stencil!==void 0?b.stencil:!0,ia=b.antialias!== void 0?b.antialias:!1,pa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),la=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=aa;this.sortObjects=this.autoClear=!0;try{if(!(h=aa.getContext("experimental-webgl",{antialias:ia,stencil:ma})))throw"Error creating WebGL context.";}catch(Ca){console.error(Ca)}console.log(navigator.userAgent+" | "+h.getParameter(h.VERSION)+" | "+h.getParameter(h.VENDOR)+" | "+h.getParameter(h.RENDERER)+ " | "+h.getParameter(h.SHADING_LANGUAGE_VERSION));h.clearColor(0,0,0,1);h.clearDepth(1);h.enable(h.DEPTH_TEST);h.depthFunc(h.LEQUAL);h.frontFace(h.CCW);h.cullFace(h.BACK);h.enable(h.CULL_FACE);h.enable(h.BLEND);h.blendEquation(h.FUNC_ADD);h.blendFunc(h.SRC_ALPHA,h.ONE_MINUS_SRC_ALPHA);h.clearColor(pa.r,pa.g,pa.b,la);this.context=h;var za=h.getParameter(h.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(ma){var da={};da.vertices=new Float32Array(12);da.faces=new Uint16Array(6);da.darkness=0.5;da.vertices[0]=-20; da.vertices[1]=-20;da.vertices[2]=-1;da.vertices[3]=20;da.vertices[4]=-20;da.vertices[5]=-1;da.vertices[6]=20;da.vertices[7]=20;da.vertices[8]=-1;da.vertices[9]=-20;da.vertices[10]=20;da.vertices[11]=-1;da.faces[0]=0;da.faces[1]=1;da.faces[2]=2;da.faces[3]=0;da.faces[4]=2;da.faces[5]=3;da.vertexBuffer=h.createBuffer();da.elementBuffer=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,da.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,da.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,da.elementBuffer); h.bufferData(h.ELEMENT_ARRAY_BUFFER,da.faces,h.STATIC_DRAW);da.program=h.createProgram();h.attachShader(da.program,D("fragment",THREE.ShaderLib.shadowPost.fragmentShader));h.attachShader(da.program,D("vertex",THREE.ShaderLib.shadowPost.vertexShader));h.linkProgram(da.program);da.vertexLocation=h.getAttribLocation(da.program,"position");da.projectionLocation=h.getUniformLocation(da.program,"projectionMatrix");da.darknessLocation=h.getUniformLocation(da.program,"darkness")}var P={};P.vertices=new Float32Array(16); P.faces=new Uint16Array(6);b=0;P.vertices[b++]=-1;P.vertices[b++]=-1;P.vertices[b++]=0;P.vertices[b++]=0;P.vertices[b++]=1;P.vertices[b++]=-1;P.vertices[b++]=1;P.vertices[b++]=0;P.vertices[b++]=1;P.vertices[b++]=1;P.vertices[b++]=1;P.vertices[b++]=1;P.vertices[b++]=-1;P.vertices[b++]=1;P.vertices[b++]=0;P.vertices[b++]=1;b=0;P.faces[b++]=0;P.faces[b++]=1;P.faces[b++]=2;P.faces[b++]=0;P.faces[b++]=2;P.faces[b++]=3;P.vertexBuffer=h.createBuffer();P.elementBuffer=h.createBuffer();P.tempTexture=h.createTexture(); P.occlusionTexture=h.createTexture();h.bindBuffer(h.ARRAY_BUFFER,P.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,P.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,P.elementBuffer);h.bufferData(h.ELEMENT_ARRAY_BUFFER,P.faces,h.STATIC_DRAW);h.bindTexture(h.TEXTURE_2D,P.tempTexture);h.texImage2D(h.TEXTURE_2D,0,h.RGB,16,16,0,h.RGB,h.UNSIGNED_BYTE,null);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D, h.TEXTURE_MAG_FILTER,h.NEAREST);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST);h.bindTexture(h.TEXTURE_2D,P.occlusionTexture);h.texImage2D(h.TEXTURE_2D,0,h.RGBA,16,16,0,h.RGBA,h.UNSIGNED_BYTE,null);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST);h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST);h.getParameter(h.MAX_VERTEX_TEXTURE_IMAGE_UNITS)<= 0?(P.hasVertexTexture=!1,P.program=h.createProgram(),h.attachShader(P.program,D("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),h.attachShader(P.program,D("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(P.hasVertexTexture=!0,P.program=h.createProgram(),h.attachShader(P.program,D("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),h.attachShader(P.program,D("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));h.linkProgram(P.program);P.attributes={};P.uniforms={}; P.attributes.vertex=h.getAttribLocation(P.program,"position");P.attributes.uv=h.getAttribLocation(P.program,"UV");P.uniforms.renderType=h.getUniformLocation(P.program,"renderType");P.uniforms.map=h.getUniformLocation(P.program,"map");P.uniforms.occlusionMap=h.getUniformLocation(P.program,"occlusionMap");P.uniforms.opacity=h.getUniformLocation(P.program,"opacity");P.uniforms.scale=h.getUniformLocation(P.program,"scale");P.uniforms.rotation=h.getUniformLocation(P.program,"rotation");P.uniforms.screenPosition= h.getUniformLocation(P.program,"screenPosition");var Aa=!1;_sprite={};_sprite.vertices=new Float32Array(16);_sprite.faces=new Uint16Array(6);b=0;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=0;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=1;_sprite.vertices[b++]=-1;_sprite.vertices[b++]=1;_sprite.vertices[b++]= 0;_sprite.vertices[b++]=1;b=0;_sprite.faces[b++]=0;_sprite.faces[b++]=1;_sprite.faces[b++]=2;_sprite.faces[b++]=0;_sprite.faces[b++]=2;_sprite.faces[b++]=3;_sprite.vertexBuffer=h.createBuffer();_sprite.elementBuffer=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,_sprite.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,_sprite.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,_sprite.elementBuffer);h.bufferData(h.ELEMENT_ARRAY_BUFFER,_sprite.faces,h.STATIC_DRAW);_sprite.program=h.createProgram(); h.attachShader(_sprite.program,D("fragment",THREE.ShaderLib.sprite.fragmentShader));h.attachShader(_sprite.program,D("vertex",THREE.ShaderLib.sprite.vertexShader));h.linkProgram(_sprite.program);_sprite.attributes={};_sprite.uniforms={};_sprite.attributes.position=h.getAttribLocation(_sprite.program,"position");_sprite.attributes.uv=h.getAttribLocation(_sprite.program,"uv");_sprite.uniforms.uvOffset=h.getUniformLocation(_sprite.program,"uvOffset");_sprite.uniforms.uvScale=h.getUniformLocation(_sprite.program, "uvScale");_sprite.uniforms.rotation=h.getUniformLocation(_sprite.program,"rotation");_sprite.uniforms.scale=h.getUniformLocation(_sprite.program,"scale");_sprite.uniforms.alignment=h.getUniformLocation(_sprite.program,"alignment");_sprite.uniforms.map=h.getUniformLocation(_sprite.program,"map");_sprite.uniforms.opacity=h.getUniformLocation(_sprite.program,"opacity");_sprite.uniforms.useScreenCoordinates=h.getUniformLocation(_sprite.program,"useScreenCoordinates");_sprite.uniforms.affectedByDistance= h.getUniformLocation(_sprite.program,"affectedByDistance");_sprite.uniforms.screenPosition=h.getUniformLocation(_sprite.program,"screenPosition");_sprite.uniforms.modelViewMatrix=h.getUniformLocation(_sprite.program,"modelViewMatrix");_sprite.uniforms.projectionMatrix=h.getUniformLocation(_sprite.program,"projectionMatrix");var ta=!1;this.setSize=function(b,e){aa.width=b;aa.height=e;this.setViewport(0,0,aa.width,aa.height)};this.setViewport=function(b,e,c,f){W=b;fa=e;Y=c;ha=f;h.viewport(W,fa,Y,ha)}; this.setScissor=function(b,e,c,f){h.scissor(b,e,c,f)};this.enableScissorTest=function(b){b?h.enable(h.SCISSOR_TEST):h.disable(h.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){M=b;h.depthMask(b)};this.setClearColorHex=function(b,e){pa.setHex(b);la=e;h.clearColor(pa.r,pa.g,pa.b,la)};this.setClearColor=function(b,e){pa.copy(b);la=e;h.clearColor(pa.r,pa.g,pa.b,la)};this.clear=function(){h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT|h.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){da.darkness= b};this.getContext=function(){return h};this.initMaterial=function(b,e,c,f){var g,j,k;b instanceof THREE.MeshDepthMaterial?k="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?k="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?k="normal":b instanceof THREE.MeshBasicMaterial?k="basic":b instanceof THREE.MeshLambertMaterial?k="lambert":b instanceof THREE.MeshPhongMaterial?k="phong":b instanceof THREE.LineBasicMaterial?k="basic":b instanceof THREE.ParticleBasicMaterial&&(k="particle_basic"); if(k){var m=THREE.ShaderLib[k];b.uniforms=THREE.UniformsUtils.clone(m.uniforms);b.vertexShader=m.vertexShader;b.fragmentShader=m.fragmentShader}var n,p,o;n=o=m=0;for(p=e.length;n=0&&h.enableVertexAttribArray(t.position);t.color>=0&&h.enableVertexAttribArray(t.color);t.normal>= 0&&h.enableVertexAttribArray(t.normal);t.tangent>=0&&h.enableVertexAttribArray(t.tangent);b.skinning&&t.skinVertexA>=0&&t.skinVertexB>=0&&t.skinIndex>=0&&t.skinWeight>=0&&(h.enableVertexAttribArray(t.skinVertexA),h.enableVertexAttribArray(t.skinVertexB),h.enableVertexAttribArray(t.skinIndex),h.enableVertexAttribArray(t.skinWeight));if(b.attributes)for(g in b.attributes)t[g]!==void 0&&t[g]>=0&&h.enableVertexAttribArray(t[g]);if(b.morphTargets){b.numSupportedMorphTargets=0;t.morphTarget0>=0&&(h.enableVertexAttribArray(t.morphTarget0), b.numSupportedMorphTargets++);t.morphTarget1>=0&&(h.enableVertexAttribArray(t.morphTarget1),b.numSupportedMorphTargets++);t.morphTarget2>=0&&(h.enableVertexAttribArray(t.morphTarget2),b.numSupportedMorphTargets++);t.morphTarget3>=0&&(h.enableVertexAttribArray(t.morphTarget3),b.numSupportedMorphTargets++);t.morphTarget4>=0&&(h.enableVertexAttribArray(t.morphTarget4),b.numSupportedMorphTargets++);t.morphTarget5>=0&&(h.enableVertexAttribArray(t.morphTarget5),b.numSupportedMorphTargets++);t.morphTarget6>= 0&&(h.enableVertexAttribArray(t.morphTarget6),b.numSupportedMorphTargets++);t.morphTarget7>=0&&(h.enableVertexAttribArray(t.morphTarget7),b.numSupportedMorphTargets++);f.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(g=this.maxMorphTargets;b0||u.faceVertexUvs.length>0)k.__uvArray=new Float32Array(n*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)k.__uv2Array=new Float32Array(n*2)}if(m.geometry.skinWeights.length&&m.geometry.skinIndices.length)k.__skinVertexAArray=new Float32Array(n*4),k.__skinVertexBArray=new Float32Array(n*4), k.__skinIndexArray=new Float32Array(n*4),k.__skinWeightArray=new Float32Array(n*4);k.__faceArray=new Uint16Array(w*3+(m.geometry.edgeFaces?m.geometry.edgeFaces.length*6:0));k.__lineArray=new Uint16Array(G*2);if(k.numMorphTargets){k.__morphTargetsArrays=[];u=0;for(v=k.numMorphTargets;u=0;g--){if(f=e.__webglObjects[g].object,c==f){e.__webglObjects.splice(g,1);break}}else if(c instanceof THREE.Sprite)for(g=e.__webglSprites.length-1;g>=0;g--)if(f=e.__webglSprites[g],c==f){e.__webglSprites.splice(g,1);break}b.__objectsRemoved.splice(0,1)}c=0;for(e=b.__webglObjects.length;c1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=k;c.v=j;return c}, clamp:function(b,c,e){return be?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; var GeometryUtils={merge:function(b,c){var e=c instanceof THREE.Mesh,f=b.vertices.length,g=e?c.geometry:c,j=b.vertices,k=g.vertices,m=b.faces,n=g.faces,o=b.faceVertexUvs[0],g=g.faceVertexUvs[0];e&&c.matrixAutoUpdate&&c.updateMatrix();for(var p=0,t=k.length;p= 0.0 )\npointSpecularWeight = specularTex.r * pow( pointDotNormalHalf, uShininess );\npointDiffuse += vec4( uDiffuseColor, 1.0 ) * pointDiffuseWeight;\npointSpecular += vec4( uSpecularColor, 1.0 ) * pointSpecularWeight * pointDiffuseWeight;\nvec4 dirDiffuse = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 dirSpecular = vec4( 0.0, 0.0, 0.0, 0.0 );\nvec4 lDirection = viewMatrix * vec4( uDirLightPos, 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = specularTex.r * pow( dirDotNormalHalf, uShininess );\ndirDiffuse += vec4( uDiffuseColor, 1.0 ) * dirDiffuseWeight;\ndirSpecular += vec4( uSpecularColor, 1.0 ) * dirSpecularWeight * dirDiffuseWeight;\nvec4 totalLight = vec4( uAmbientLightColor * uAmbientColor, 1.0 );\ntotalLight += vec4( uDirLightColor, 1.0 ) * ( dirDiffuse + dirSpecular );\ntotalLight += vec4( uPointLightColor, 1.0 ) * ( pointDiffuse + pointSpecular );\ngl_FragColor = vec4( totalLight.xyz * aoTex * diffuseTex, 1.0 );\n}", vertexShader:"attribute vec4 tangent;\nuniform vec3 uPointLightPos;\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;\nvarying vec3 vPointLightVector;\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;\nvec4 lPosition = viewMatrix * vec4( uPointLightPos, 1.0 );\nvPointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\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&&(j=25);g=(j-1)*0.5;e=Array(j);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]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",v,k.index-1).pos,this.points[1]=g,this.points[2]=j,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,j,b.quaternion,f);else if(e==="scl")e=b.scale,e.x=g[0]+(j[0]-g[0])*f,e.y=g[1]+(j[1]-g[1])*f,e.z=g[2]+(j[2]-g[2])*f}}if(this.JITCompile&&p[0][o]===void 0){this.hierarchy[0].update(void 0,!0);for(v=0;vb.length-2?j:j+1;e[3]=j>b.length-3?j:j+2;j=b[e[0]];m=b[e[1]];n=b[e[2]];o=b[e[3]];e=g*g;k=g*e;f[0]=this.interpolate(j[0],m[0],n[0],o[0],g,e,k);f[1]=this.interpolate(j[1],m[1],n[1],o[1],g,e,k);f[2]=this.interpolate(j[2],m[2],n[2],o[2],g,e,k);return f}; THREE.Animation.prototype.interpolate=function(b,c,e,f,g,j,k){b=(e-b)*0.5;f=(f-c)*0.5;return(2*(c-e)+b+f)*k+(-3*(c-e)-2*b-f)*j+b*g+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,e){var f=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e=e0?e:0:e>=0?e:e+f.length;e>=0;e--)if(f[e][b]!==void 0)return f[e];return this.data.hierarchy[c].keys[f.length-1]}; THREE.QuakeCamera=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.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype; THREE.QuakeCamera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(b));this.target.position.addSelf(c.multiplyScalar(b))}; THREE.PathCamera=function(b){function c(b,c,e,f){var g={name:e,fps:0.6,length:f,hierarchy:[]},j,k=c.getControlPointsArray(),m=c.getLength(),n=k.length,H=0;j=n-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:k[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[j]={time:f,pos:k[j],rot:[0,0,0,1],scl:[1,1,1]};for(j=1;j=0?f:f+g;f=this.verticalAngleMap.srcRange;k=this.verticalAngleMap.dstRange;var m=k[1]-k[0];this.phi= TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(k[1]-k[0])/(f[1]-f[0])+k[0]-k[0])/m)*m+k[0];f=this.horizontalAngleMap.srcRange;k=this.horizontalAngleMap.dstRange;m=k[1]-k[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(k[1]-k[0])/(f[1]-f[0])+k[0]-k[0])/m)*m+k[0];f=this.target.position;f.x=100*Math.sin(this.phi)*Math.cos(this.theta);f.y=100*Math.cos(this.phi);f.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,c,e)};this.onMouseMove=function(b){this.mouseX= b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),k=new THREE.MeshLambertMaterial({color:65280}),m=new THREE.Cube(10,10,20),n=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(m,b);b=new THREE.Mesh(n,k);b.position.set(0,10,0);this.animation=c(this.animationParent, this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else this.animation=c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(b,c){return function(){c.apply(b,arguments)}}(this,this.onMouseMove),!1)}; THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0; THREE.FlyCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.domElement=document;if(b){if(b.movementSpeed!==void 0)this.movementSpeed=b.movementSpeed;if(b.rollSpeed!==void 0)this.rollSpeed=b.rollSpeed;if(b.dragToLook!==void 0)this.dragToLook=b.dragToLook;if(b.autoForward!==void 0)this.autoForward= b.autoForward;if(b.domElement!==void 0)this.domElement=b.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.keydown=function(b){if(!b.altKey){switch(b.keyCode){case 16:this.movementSpeedMultiplier= 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}}; this.keyup=function(b){switch(b.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break; case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(b){if(!this.dragToLook||this.mouseStatus>0){var c=this.getContainerDimensions(),g=c.size[0]/2,j=c.size[1]/2;this.moveState.yawLeft=-(b.clientX-c.offset[0]-g)/g;this.moveState.pitchDown=(b.clientY- c.offset[1]-j)/j;this.updateRotationVector()}};this.mouseup=function(b){b.preventDefault();b.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;var b=this.tdiff*this.movementSpeed,c=this.tdiff* this.rollSpeed;this.translateX(this.moveVector.x*b);this.translateY(this.moveVector.y*b);this.translateZ(this.moveVector.z*b);this.tmpQuaternion.set(this.rotationVector.x*c,this.rotationVector.y*c,this.rotationVector.z*c,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var b=this.moveState.forward|| this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!= document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,this.mouseup),!1);window.addEventListener("keydown",c(this,this.keydown),!1);window.addEventListener("keyup",c(this, this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype; THREE.RollCamera=function(b,c,e,f){THREE.Camera.call(this,b,c,e,f);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var g=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Vector3,m=new THREE.Matrix4,n=!1,o=1,p=0,t=0,u=0,v=0,w=0,E=window.innerWidth/2,I=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*(p>0||this.autoForward&&!(p<0)?1:p));this.translateX(b*t);this.translateY(b*u);n&&(this.roll+=this.rollSpeed*this.delta*o);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); else if(this.forward.y1?e.normalize():e.z=Math.sqrt(1-f*f);g=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(e.y);f.addSelf(this.up.clone().crossSelf(g).setLength(e.x));f.addSelf(g.setLength(e.z));return f}; this.rotateCamera=function(){var b=Math.acos(j.dot(k)/j.length()/k.length());if(b){var c=(new THREE.Vector3).cross(j,k).normalize(),e=new THREE.Quaternion;b*=this.rotateSpeed;e.setFromAxisAngle(c,-b);e.multiplyVector3(g);e.multiplyVector3(this.up);e.multiplyVector3(k);this.staticMoving?j=k:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(j))}};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=p.clone().subSelf(o);if(b.lengthSq()){b.multiplyScalar(g.length()*this.panSpeed);var c=g.clone().crossSelf(this.up).setLength(b.x);c.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?o=p:o.addSelf(b.sub(p,o).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance), g.lengthSq()0){k(0,0,-p-(j||0));for(n=b;n0){k(0,0,p+(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;n0||(p=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,m,u)))-1);o.push(p)}c.push(o)}for(var v,w,E,g=c.length,e=0;e0)for(f=0;f1&&(v=this.vertices[k].position.clone(), w=this.vertices[n].position.clone(),E=this.vertices[o].position.clone(),v.normalize(),w.normalize(),E.normalize(),this.faces.push(new THREE.Face3(k,n,o,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(E.x,E.y,E.z)])),this.faceVertexUvs[0].push([p,t,I]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.Sphere.prototype=new THREE.Geometry;THREE.Sphere.prototype.constructor=THREE.Sphere; THREE.Torus=function(b,c,e,f){THREE.Geometry.call(this);this.radius=b||100;this.tube=c||40;this.segmentsR=e||8;this.segmentsT=f||6;b=[];for(c=0;c<=this.segmentsR;++c)for(e=0;e<=this.segmentsT;++e){var f=e/this.segmentsT*2*Math.PI,g=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));b.push([e/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(e= 1;e<=this.segmentsT;++e){var f=(this.segmentsT+1)*c+e,g=(this.segmentsT+1)*c+e-1,j=(this.segmentsT+1)*(c-1)+e-1,k=(this.segmentsT+1)*(c-1)+e;this.faces.push(new THREE.Face4(f,g,j,k));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[j][0],b[j][1]),new THREE.UV(b[k][0],b[k][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.Torus.prototype=new THREE.Geometry;THREE.Torus.prototype.constructor=THREE.Torus; THREE.TorusKnot=function(b,c,e,f,g,j,k){function m(b,c,e,f,g,j){c=e/f*b;e=Math.cos(c);return new THREE.Vector3(g*(2+e)*0.5*Math.cos(b),g*(2+e)*Math.sin(b)*0.5,j*g*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=e||64;this.segmentsT=f||8;this.p=g||2;this.q=j||3;this.heightScale=k||1;this.grid=Array(this.segmentsR);e=new THREE.Vector3;f=new THREE.Vector3;j=new THREE.Vector3;for(b=0;b0;){if(k){if(k.equals(contour[j])){k=null;continue}}else k=contour[j];for(e=0;e0&&j.push({shape:g,holes:f}),g=p,f=[]):f.push(p):this.Triangulate.area(p)<0?(j.push({shape:p,holes:f}),f=[]):f.push(p);n++}o&&j.push({shape:g,holes:f})}e= [];for(var t in j){k=j[t];g=k.shape;f=k.holes;for(var u in f){o=f[u];n=Number.POSITIVE_INFINITY;var v,w,E;for(E in o)for(m in p=o[E],g)d=p.distanceTo(g[m]),d=0?w-1:g.length-1;nextShapeVert=w+1=0?v-1:o.length-1;nextHoleVert=v+12;){if(0>=o--)throw"Warning, unable to triangulate polygon!";var t=n;j<=t&&(t=0);n=t+1;j<=n&&(n=0);var u=n+1;j<=u&&(u=0);var v;a:{v=b;var w=t,E=n,I=u,B=j,H=k,A=void 0,K=void 0,G=void 0,C=void 0,R=void 0,D=void 0, N=void 0,J=void 0,V=void 0,K=v[H[w]].x,G=v[H[w]].y,C=v[H[E]].x,R=v[H[E]].y,D=v[H[I]].x,N=v[H[I]].y;if(1.0E-10>(C-K)*(N-G)-(R-G)*(D-K))v=!1;else{for(A=0;A=0&&O>=0&&M>=0){v=!1;break a}}v=!0}}if(v){o=k[t];v=k[n]; w=k[u];g.push(b[o]);g.push(b[v]);g.push(b[w]);m.push([k[t],k[n],k[u]]);p++;t=n;for(u=n+1;u>7)-127;f|=(h&127)<<16|g<<8;if(f==0&&k==-127)return 0;return(1-2*(j>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,k)}function g(b,c){var e=p(b,c),f=p(b,c+1),h=p(b,c+2);return(p(b,c+3)<<24)+(h<<16)+(f<<8)+e}function n(b,c){var e=p(b,c);return(p(b,c+1)<<8)+e}function o(b,c){var e=p(b,c);return e>127?e-256:e}function p(b, c){return b.charCodeAt(c)&255}function t(c){var e,f,h;e=g(b,c);f=g(b,c+C);h=g(b,c+R);c=n(b,c+D);THREE.BinaryLoader.prototype.f3(B,e,f,h,c)}function u(c){var e,f,h,j,k,o;e=g(b,c);f=g(b,c+C);h=g(b,c+R);j=n(b,c+D);k=g(b,c+N);o=g(b,c+J);c=g(b,c+V);THREE.BinaryLoader.prototype.f3n(B,K,e,f,h,j,k,o,c)}function v(c){var e,f,j,k;e=g(b,c);f=g(b,c+h);j=g(b,c+X);k=g(b,c+O);c=n(b,c+$);THREE.BinaryLoader.prototype.f4(B,e,f,j,k,c)}function w(c){var e,f,j,k,o,p,t,u;e=g(b,c);f=g(b,c+h);j=g(b,c+X);k=g(b,c+O);o=n(b, c+$);p=g(b,c+M);t=g(b,c+ca);u=g(b,c+U);c=g(b,c+S);THREE.BinaryLoader.prototype.f4n(B,K,e,f,j,k,o,p,t,u,c)}function E(c){var e,f;e=g(b,c);f=g(b,c+ja);c=g(b,c+W);THREE.BinaryLoader.prototype.uv3(B.faceVertexUvs[0],G[e*2],G[e*2+1],G[f*2],G[f*2+1],G[c*2],G[c*2+1])}function I(c){var e,f,h;e=g(b,c);f=g(b,c+fa);h=g(b,c+Y);c=g(b,c+ha);THREE.BinaryLoader.prototype.uv4(B.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 B=this,H=0,A,K=[],G=[],C,R,D,N,J,V,h,X,O,$,M,ca,U,S, ja,W,fa,Y,ha,ea,Q,T,Z,ka,na;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(B,f,c);A={signature:b.substr(H,8),header_bytes:p(b,H+8),vertex_coordinate_bytes:p(b,H+9),normal_coordinate_bytes:p(b,H+10),uv_coordinate_bytes:p(b,H+11),vertex_index_bytes:p(b,H+12),normal_index_bytes:p(b,H+13),uv_index_bytes:p(b,H+14),material_index_bytes:p(b,H+15),nvertices:g(b,H+16),nnormals:g(b,H+16+4),nuvs:g(b,H+16+8),ntri_flat:g(b,H+16+12),ntri_smooth:g(b,H+16+16),ntri_flat_uv:g(b,H+16+20),ntri_smooth_uv:g(b, H+16+24),nquad_flat:g(b,H+16+28),nquad_smooth:g(b,H+16+32),nquad_flat_uv:g(b,H+16+36),nquad_smooth_uv:g(b,H+16+40)};H+=A.header_bytes;C=A.vertex_index_bytes;R=A.vertex_index_bytes*2;D=A.vertex_index_bytes*3;N=A.vertex_index_bytes*3+A.material_index_bytes;J=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes;V=A.vertex_index_bytes*3+A.material_index_bytes+A.normal_index_bytes*2;h=A.vertex_index_bytes;X=A.vertex_index_bytes*2;O=A.vertex_index_bytes*3;$=A.vertex_index_bytes*4;M=A.vertex_index_bytes* 4+A.material_index_bytes;ca=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes;U=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*2;S=A.vertex_index_bytes*4+A.material_index_bytes+A.normal_index_bytes*3;ja=A.uv_index_bytes;W=A.uv_index_bytes*2;fa=A.uv_index_bytes;Y=A.uv_index_bytes*2;ha=A.uv_index_bytes*3;c=A.vertex_index_bytes*3+A.material_index_bytes;na=A.vertex_index_bytes*4+A.material_index_bytes;ea=A.ntri_flat*c;Q=A.ntri_smooth*(c+A.normal_index_bytes*3);T=A.ntri_flat_uv* (c+A.uv_index_bytes*3);Z=A.ntri_smooth_uv*(c+A.normal_index_bytes*3+A.uv_index_bytes*3);ka=A.nquad_flat*na;c=A.nquad_smooth*(na+A.normal_index_bytes*4);na=A.nquad_flat_uv*(na+A.uv_index_bytes*4);H+=function(c){for(var f,g,h,j=A.vertex_coordinate_bytes*3,m=c+A.nvertices*j;c1&&(N=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(C,N);object.name=v;object.position.set(A[0],A[1],A[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=H.visible;M.scene.addObject(object);M.objects[v]=object;if(H.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(object);M.scene.collisions.colliders.push(b)}if(H.castsShadow)b=new THREE.ShadowVolume(C),M.scene.addChild(b), b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;H.trigger&&H.trigger.toLowerCase()!="none"&&(b={type:H.trigger,object:H},M.triggers[object.name]=b)}}else A=H.position,r=H.rotation,q=H.quaternion,s=H.scale,q=0,object=new THREE.Object3D,object.name=v,object.position.set(A[0],A[1],A[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=H.visible!==void 0?H.visible:!1,M.scene.addObject(object), M.objects[v]=object,M.empties[v]=object,H.trigger&&H.trigger.toLowerCase()!="none"&&(b={type:H.trigger,object:H},M.triggers[object.name]=b)}function n(b){return function(c){M.geometries[b]=c;m();h-=1;e.onLoadComplete();p()}}function o(b){return function(c){M.geometries[b]=c}}function p(){e.callbackProgress({totalModels:O,totalTextures:$,loadedModels:O-h,loadedTextures:$-X},M);e.onLoadProgress();h==0&&X==0&&c(M)}var t,u,v,w,E,I,B,H,A,K,G,C,R,D,N,J,V,h,X,O,$,M;J=b.data;b=new THREE.BinaryLoader;V=new THREE.JSONLoader; X=h=0;M={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var ca=!1;for(v in J.objects)if(H=J.objects[v],H.meshCollider){ca=!0;break}if(ca)M.scene.collisions=new THREE.CollisionSystem;if(J.transform){ca=J.transform.position;K=J.transform.rotation;var U=J.transform.scale;ca&&M.scene.position.set(ca[0],ca[1],ca[2]);K&&M.scene.rotation.set(K[0],K[1],K[2]);U&&M.scene.scale.set(U[0],U[1],U[2]);(ca||K||U)&&M.scene.updateMatrix()}ca= function(){X-=1;p();e.onLoadComplete()};for(E in J.cameras){K=J.cameras[E];if(K.type=="perspective")R=new THREE.Camera(K.fov,K.aspect,K.near,K.far);else if(K.type=="ortho")R=new THREE.Camera,R.projectionMatrix=THREE.Matrix4.makeOrtho(K.left,K.right,K.top,K.bottom,K.near,K.far);A=K.position;K=K.target;R.position.set(A[0],A[1],A[2]);R.target.position.set(K[0],K[1],K[2]);M.cameras[E]=R}for(w in J.lights){E=J.lights[w];R=E.color!==void 0?E.color:16777215;K=E.intensity!==void 0?E.intensity:1;if(E.type== "directional")A=E.direction,light=new THREE.DirectionalLight(R,K),light.position.set(A[0],A[1],A[2]),light.position.normalize();else if(E.type=="point")A=E.position,light=new THREE.PointLight(R,K),light.position.set(A[0],A[1],A[2]);M.scene.addLight(light);M.lights[w]=light}for(I in J.fogs)w=J.fogs[I],w.type=="linear"?D=new THREE.Fog(0,w.near,w.far):w.type=="exp2"&&(D=new THREE.FogExp2(0,w.density)),K=w.color,D.color.setRGB(K[0],K[1],K[2]),M.fogs[I]=D;if(M.cameras&&J.defaults.camera)M.currentCamera= M.cameras[J.defaults.camera];if(M.fogs&&J.defaults.fog)M.scene.fog=M.fogs[J.defaults.fog];K=J.defaults.bgcolor;M.bgColor=new THREE.Color;M.bgColor.setRGB(K[0],K[1],K[2]);M.bgColorAlpha=J.defaults.bgalpha;for(t in J.geometries)if(I=J.geometries[t],I.type=="bin_mesh"||I.type=="ascii_mesh")h+=1,e.onLoadStart();O=h;for(t in J.geometries)I=J.geometries[t],I.type=="cube"?(C=new THREE.Cube(I.width,I.height,I.depth,I.segmentsWidth,I.segmentsHeight,I.segmentsDepth,null,I.flipped,I.sides),M.geometries[t]=C): I.type=="plane"?(C=new THREE.Plane(I.width,I.height,I.segmentsWidth,I.segmentsHeight),M.geometries[t]=C):I.type=="sphere"?(C=new THREE.Sphere(I.radius,I.segmentsWidth,I.segmentsHeight),M.geometries[t]=C):I.type=="cylinder"?(C=new THREE.Cylinder(I.numSegs,I.topRad,I.botRad,I.height,I.topOffset,I.botOffset),M.geometries[t]=C):I.type=="torus"?(C=new THREE.Torus(I.radius,I.tube,I.segmentsR,I.segmentsT),M.geometries[t]=C):I.type=="icosahedron"?(C=new THREE.Icosahedron(I.subdivisions),M.geometries[t]=C): I.type=="bin_mesh"?b.load({model:f(I.url,J.urlBaseType),callback:n(t)}):I.type=="ascii_mesh"?V.load({model:f(I.url,J.urlBaseType),callback:n(t)}):I.type=="embedded_mesh"&&(I=J.embeds[I.id])&&V.createModel(I,o(t),"");for(B in J.textures)if(t=J.textures[B],t.url instanceof Array){X+=t.url.length;for(b=0;b=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(o-m);u<1&&(u=1);o=Math.floor(o+m);o>this.size-1&&(o=this.size-1);var v=Math.floor(p-m);v<1&&(v=1);m=Math.floor(p+m);m>this.size-1&&(m=this.size- 1);for(var w,E,I,B,H,A;t0&&(this.field[I+w]+=B)}}};this.addPlaneX=function(b,c){var g,j,k,m,n,o=this.size,p=this.yd,t=this.zd,u=this.field,v=o*Math.sqrt(b/c);v>o&&(v=o);for(g=0;g0)for(j=0;jp&&(w=p);for(j=0;j0){n=j*t;for(g=0;gsize&&(dist=size);for(k=0;k0){n=zd*k;for(j=0;jj?this.hits.push(g):this.hits.unshift(g),j=f;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var e=0;c[e]instanceof THREE.MeshCollider;){var f=this.rayMesh(b,c[e]);if(f.distc.length)return null;return c[e]}; THREE.CollisionSystem.prototype.rayCast=function(b,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(b,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(b,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(b,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(b,c.box)}; THREE.CollisionSystem.prototype.rayMesh=function(b,c){for(var e=this.makeRayLocal(b,c.mesh),f=Number.MAX_VALUE,g,j=0;j=m*g))return Number.MAX_VALUE;k/=m;m=THREE.CollisionSystem.__v3;m.copy(b.direction);m.multiplyScalar(k);m.addSelf(b.origin);Math.abs(j.x)>Math.abs(j.y)?Math.abs(j.x)>Math.abs(j.z)?(b=m.y-c.y,j=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,j=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(j.y)>Math.abs(j.z)?(b=m.x-c.x,j=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,j=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=j*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*=j*m-e*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-f-c>=0))return Number.MAX_VALUE;return k}; THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var e=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,e);var f=THREE.CollisionSystem.__r;f.origin.copy(b.origin);f.direction.copy(b.direction);e.multiplyVector3(f.origin);e.rotateAxis(f.direction);f.direction.normalize();return f}; THREE.CollisionSystem.prototype.rayBox=function(b,c){var e;c.dynamic&&c.mesh&&c.mesh.matrixWorld?e=this.makeRayLocal(b,c.mesh):(e=THREE.CollisionSystem.__r,e.origin.copy(b.origin),e.direction.copy(b.direction));var f=0,g=0,j=0,k=0,m=0,n=0,o=!0;e.origin.xc.max.x&&(f=c.max.x-e.origin.x,f/=e.direction.x,o=!1,k=1);e.origin.yc.max.y&&(g=c.max.y-e.origin.y,g/=e.direction.y, o=!1,m=1);e.origin.zc.max.z&&(j=c.max.z-e.origin.z,j/=e.direction.z,o=!1,n=1);if(o)return-1;o=0;g>f&&(o=1,f=g);j>f&&(o=2,f=j);switch(o){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(k,0,0);break;case 1:k=e.origin.x+e.direction.x*f;if(kc.max.x)return Number.MAX_VALUE;e=e.origin.z+e.direction.z* f;if(ec.max.z)return Number.MAX_VALUE;c.normal.set(0,m,0);break;case 2:k=e.origin.x+e.direction.x*f;if(kc.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))}; THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,g=new THREE.Camera,j=new THREE.Camera,b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},k=new THREE.WebGLRenderTarget(512,512,b),m=new THREE.WebGLRenderTarget(512,512,b),n=new THREE.Camera(53,1,1,1E4);n.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:k},mapRight:{type:"t",value:1,texture:m}},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 o=new THREE.Scene;o.addObject(new THREE.Mesh(new THREE.Plane(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);k.width=b;k.height=f;m.width=b;m.height=f};this.render= function(b,e){g.projectionMatrix=e.projectionMatrix;g.position.copy(e.position);g.target.position.copy(e.target.position);g.translateX(-10);j.projectionMatrix=e.projectionMatrix;j.position.copy(e.position);j.target.position.copy(e.target.position);j.translateX(10);f.call(c,b,g,k,!0);f.call(c,b,j,m,!0);f.call(c,o,n)}};THREE.AnaglyphWebGLRenderer.prototype=new THREE.WebGLRenderer;THREE.AnaglyphWebGLRenderer.prototype.constructor=THREE.AnaglyphWebGLRenderer; THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,g,j,k=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;j=f};this.render=function(b,e){this.clear();k.fov=e.fov;k.aspect=0.5*e.aspect;k.near=e.near;k.far=e.far;k.updateProjectionMatrix(); k.position.copy(e.position);k.target.position.copy(e.target.position);k.translateX(c.separation);m.projectionMatrix=k.projectionMatrix;m.position.copy(e.position);m.target.position.copy(e.target.position);m.translateX(-c.separation);this.setViewport(0,0,g,j);f.call(c,b,k);this.setViewport(g,0,g,j);f.call(c,b,m,!1)}};THREE.CrosseyedWebGLRenderer.prototype=new THREE.WebGLRenderer;THREE.CrosseyedWebGLRenderer.prototype.constructor=THREE.CrosseyedWebGLRenderer;