// 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,d){this.r=b;this.g=c;this.b=d;this.updateHex()},setHSV:function(b,c,d){var e,g,f,j,k,m;if(d==0)e=g=f=0;else switch(j=Math.floor(b*6),k=b*6-j,b=d*(1-c),m=d*(1-c*k),c=d*(1-c*(1-k)),j){case 1:e=m;g=d;f=b;break;case 2:e=b;g=d;f=c;break;case 3:e=b;g=m;f=d;break;case 4:e=c;g=b;f=d;break;case 5:e=d;g=b;f=m;break;case 6:case 0:e=d,g=c,f=b}this.setRGB(e, g,f)},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,d){this.set(b||0,c||0,d||0)}; THREE.Vector3.prototype={set:function(b,c,d){this.x=b;this.y=c;this.z=d;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,d,e){this.set(b||0,c||0,d||0,e||1)}; THREE.Vector4.prototype={set:function(b,c,d,e){this.x=b;this.y=c;this.z=d;this.w=e;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,d,e=[];c=0;for(d=b.length;c0&&b>0&&f+b<1}if(b instanceof THREE.Particle){var e=c(this.origin,this.direction,b);if(!e||e>b.scale.x)return[];return[{distance:e,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){e=c(this.origin,this.direction,b);if(!e||e>b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)))return[];var g,f,j,k,m,n,o,p,t,u,v=b.geometry, z=v.vertices,B=[],e=0;for(g=v.faces.length;e0:p<0))if(o=o.dot((new THREE.Vector3).sub(j,t))/p,t=t.addSelf(u.multiplyScalar(o)), f instanceof THREE.Face3)d(t,j,k,m)&&(f={distance:this.origin.distanceTo(t),point:t,face:f,object:b},B.push(f));else if(f instanceof THREE.Face4&&(d(t,j,k,n)||d(t,k,m,n)))f={distance:this.origin.distanceTo(t),point:t,face:f,object:b},B.push(f);return B}else return[]}}; THREE.Rectangle=function(){function b(){f=e-c;j=g-d}var c,d,e,g,f,j,k=!0;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return f};this.getHeight=function(){return j};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(f,j,o,p){k=!1;c=f;d=j;e=o;g=p;b()};this.addPoint=function(f,j){k?(k=!1,c=f,d=j,e=f,g=j):(c=cf?e:f,g=g>j?g:j);b()};this.add3Points= function(f,j,o,p,t,u){k?(k=!1,c=fo?f>t?f:t:o>t?o:t,g=j>p?j>u?j:u:p>u?p:u):(c=fo?f>t?f>e?f:e:t>e?t:e:o>t?o>e?o:e:t>e?t:e,g=j>p?j>u?j>g?j:g:u>g?u:g:p>u?p>g?p:g:u>g?u:g);b()};this.addRectangle=function(f){k?(k=!1,c=f.getLeft(),d=f.getTop(),e=f.getRight(),g=f.getBottom()):(c=cf.getRight()?e:f.getRight(),g=g> f.getBottom()?g:f.getBottom());b()};this.inflate=function(f){c-=f;d-=f;e+=f;g+=f;b()};this.minSelf=function(f){c=c>f.getLeft()?c:f.getLeft();d=d>f.getTop()?d:f.getTop();e=e=0&&Math.min(g,b.getBottom())-Math.max(d,b.getTop())>=0};this.empty=function(){k=!0;g=e=d=c=0;b()};this.isEmpty=function(){return k}};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,d,e,g,f,j,k,m,n,o,p,t,u,v,z){this.set(b||1,c||0,d||0,e||0,g||0,f||1,j||0,k||0,m||0,n||0,o||1,p||0,t||0,u||0,v||0,z||1);this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={set:function(b,c,d,e,g,f,j,k,m,n,o,p,t,u,v,z){this.n11=b;this.n12=c;this.n13=d;this.n14=e;this.n21=g;this.n22=f;this.n23=j;this.n24=k;this.n31=m;this.n32=n;this.n33=o;this.n34=p;this.n41=t;this.n42=u;this.n43=v;this.n44=z;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,c,d){var e=THREE.Matrix4.__v1, g=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(b,c).normalize();if(f.length()===0)f.z=1;e.cross(d,f).normalize();e.length()===0&&(f.x+=1.0E-4,e.cross(d,f).normalize());g.cross(f,e).normalize();this.n11=e.x;this.n12=g.x;this.n13=f.x;this.n21=e.y;this.n22=g.y;this.n23=f.y;this.n31=e.z;this.n32=g.z;this.n33=f.z;return this},multiplyVector3:function(b){var c=b.x,d=b.y,e=b.z,g=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);b.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*g;b.y=(this.n21*c+this.n22*d+this.n23* e+this.n24)*g;b.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*g;return b},multiplyVector4:function(b){var c=b.x,d=b.y,e=b.z,g=b.w;b.x=this.n11*c+this.n12*d+this.n13*e+this.n14*g;b.y=this.n21*c+this.n22*d+this.n23*e+this.n24*g;b.z=this.n31*c+this.n32*d+this.n33*e+this.n34*g;b.w=this.n41*c+this.n42*d+this.n43*e+this.n44*g;return b},rotateAxis:function(b){var c=b.x,d=b.y,e=b.z;b.x=c*this.n11+d*this.n12+e*this.n13;b.y=c*this.n21+d*this.n22+e*this.n23;b.z=c*this.n31+d*this.n32+e*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 d=b.n11,e=b.n12,g=b.n13,f=b.n14,j=b.n21,k=b.n22,m=b.n23,n=b.n24,o=b.n31,p=b.n32,t=b.n33,u=b.n34,v=b.n41,z=b.n42,B=b.n43,y=b.n44,D=c.n11,x=c.n12,H=c.n13,F=c.n14,A=c.n21,O=c.n22, C=c.n23,L=c.n24,G=c.n31,S=c.n32,h=c.n33,U=c.n34;this.n11=d*D+e*A+g*G;this.n12=d*x+e*O+g*S;this.n13=d*H+e*C+g*h;this.n14=d*F+e*L+g*U+f;this.n21=j*D+k*A+m*G;this.n22=j*x+k*O+m*S;this.n23=j*H+k*C+m*h;this.n24=j*F+k*L+m*U+n;this.n31=o*D+p*A+t*G;this.n32=o*x+p*O+t*S;this.n33=o*H+p*C+t*h;this.n34=o*F+p*L+t*U+u;this.n41=v*D+z*A+B*G;this.n42=v*x+z*O+B*S;this.n43=v*H+z*C+B*h;this.n44=v*F+z*L+B*U+y;return this},multiplyToArray:function(b,c,d){this.multiply(b,c);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]= this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[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,d=this.n13,e=this.n14,g=this.n21,f=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,z=this.n44;return e*j*n*t-d*k*n*t-e*f*o*t+c*k*o*t+d*f*p*t-c*j*p*t-e*j*m*u+d*k*m*u+e*g*o*u-b*k*o*u-d*g*p*u+b*j*p*u+e*f*m*v-c*k*m*v-e*g*n*v+b*k*n*v+c*g*p*v-b*f*p*v-d*f*m*z+c*j*m*z+d*g*n*z-b*j*n*z-c*g*o*z+b*f*o*z},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32= this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21; this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;b[9]=this.n23;b[10]= this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]=this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,d){this.set(1,0,0,b,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(b, c,d){this.set(b,0,0,0,0,c,0,0,0,0,d,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 d=Math.cos(c),e=Math.sin(c),g=1-d,f=b.x,j=b.y,k=b.z,m=g*f,n=g*j;this.set(m* f+d,m*j-e*k,m*k+e*j,0,m*j+e*k,n*j+d,n*k-e*f,0,m*k-e*j,n*k+e*f,g*k*k+d,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,d=b.y,e=b.z,b=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),f=Math.cos(e),e=Math.sin(e),j=b*d,k=c*d;this.n11=g*f;this.n12=-g*e;this.n13=d;this.n21=k*f+b*e;this.n22=-k*e+b*f;this.n23=-c*g;this.n31=-j*f+c*e;this.n32=j*e+c*f;this.n33=b*g;return this}, setRotationFromQuaternion:function(b){var c=b.x,d=b.y,e=b.z,g=b.w,f=c+c,j=d+d,k=e+e,b=c*f,m=c*j;c*=k;var n=d*j;d*=k;e*=k;f*=g;j*=g;g*=k;this.n11=1-(n+e);this.n12=m-g;this.n13=c+j;this.n21=m+g;this.n22=1-(b+e);this.n23=d-f;this.n31=c-j;this.n32=d+f;this.n33=1-(b+n);return this},scale:function(b){var c=b.x,d=b.y,b=b.z;this.n11*=c;this.n12*=d;this.n13*=b;this.n21*=c;this.n22*=d;this.n23*=b;this.n31*=c;this.n32*=d;this.n33*=b;this.n41*=c;this.n42*=d;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 d=1/c.x,e=1/c.y,g=1/c.z;this.n11=b.n11*d;this.n21=b.n21*d;this.n31=b.n31*d;this.n12=b.n12*e;this.n22=b.n22*e;this.n32=b.n32*e;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}}; THREE.Matrix4.makeInvert=function(b,c){var d=b.n11,e=b.n12,g=b.n13,f=b.n14,j=b.n21,k=b.n22,m=b.n23,n=b.n24,o=b.n31,p=b.n32,t=b.n33,u=b.n34,v=b.n41,z=b.n42,B=b.n43,y=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=m*u*z-n*t*z+n*p*B-k*u*B-m*p*y+k*t*y;c.n12=f*t*z-g*u*z-f*p*B+e*u*B+g*p*y-e*t*y;c.n13=g*n*z-f*m*z+f*k*B-e*n*B-g*k*y+e*m*y;c.n14=f*m*p-g*n*p-f*k*t+e*n*t+g*k*u-e*m*u;c.n21=n*t*v-m*u*v-n*o*B+j*u*B+m*o*y-j*t*y;c.n22=g*u*v-f*t*v+f*o*B-d*u*B-g*o*y+d*t*y;c.n23=f*m*v-g*n*v-f*j*B+d*n*B+g*j*y-d*m*y;c.n24= g*n*o-f*m*o+f*j*t-d*n*t-g*j*u+d*m*u;c.n31=k*u*v-n*p*v+n*o*z-j*u*z-k*o*y+j*p*y;c.n32=f*p*v-e*u*v-f*o*z+d*u*z+e*o*y-d*p*y;c.n33=g*n*v-f*k*v+f*j*z-d*n*z-e*j*y+d*k*y;c.n34=f*k*o-e*n*o-f*j*p+d*n*p+e*j*u-d*k*u;c.n41=m*p*v-k*t*v-m*o*z+j*t*z+k*o*B-j*p*B;c.n42=e*t*v-g*p*v+g*o*z-d*t*z-e*o*B+d*p*B;c.n43=g*k*v-e*m*v-g*j*z+d*m*z+e*j*B-d*k*B;c.n44=e*m*o-g*k*o+g*j*p-d*m*p-e*j*t+d*k*t;c.multiplyScalar(1/b.determinant());return c}; THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,d=c.m,e=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,f=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,m=-b.n32*b.n11+b.n31*b.n12,n=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,p=b.n22*b.n11-b.n21*b.n12,b=b.n11*e+b.n21*j+b.n31*n;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;d[0]=b*e;d[1]=b*g;d[2]=b*f;d[3]=b*j;d[4]=b*k;d[5]=b*m;d[6]=b*n;d[7]=b*o;d[8]=b*p;return c}; THREE.Matrix4.makeFrustum=function(b,c,d,e,g,f){var j;j=new THREE.Matrix4;j.n11=2*g/(c-b);j.n12=0;j.n13=(c+b)/(c-b);j.n14=0;j.n21=0;j.n22=2*g/(e-d);j.n23=(e+d)/(e-d);j.n24=0;j.n31=0;j.n32=0;j.n33=-(f+g)/(f-g);j.n34=-2*f*g/(f-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,c,d,e){var g,b=d*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*c,b*c,g,b,d,e)}; THREE.Matrix4.makeOrtho=function(b,c,d,e,g,f){var j,k,m,n;j=new THREE.Matrix4;k=c-b;m=d-e;n=f-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((c+b)/k);j.n21=0;j.n22=2/m;j.n23=0;j.n24=-((d+e)/m);j.n31=0;j.n32=0;j.n33=-2/n;j.n34=-((f+g)/n);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3; THREE.Object3D=function(){this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.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 d,e,g;d=0;for(e=this.children.length;d=1)return d.w=b.w,d.x=b.x,d.y=b.y,d.z=b.z,d;var f=Math.acos(g),j=Math.sqrt(1-g*g);if(Math.abs(j)<0.0010)return d.w=0.5*(b.w+c.w),d.x=0.5*(b.x+c.x),d.y=0.5*(b.y+c.y),d.z=0.5*(b.z+c.z),d;g=Math.sin((1-e)*f)/j;e=Math.sin(e*f)/j;d.w=b.w*g+c.w*e;d.x=b.x*g+c.x*e;d.y=b.y*g+c.y*e;d.z=b.z*g+c.z*e;return d};THREE.Vertex=function(b){this.position=b||new THREE.Vector3}; THREE.Face3=function(b,c,d,e,g,f){this.a=b;this.b=c;this.c=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3}; THREE.Face4=function(b,c,d,e,g,f,j){this.a=b;this.b=c;this.c=d;this.d=e;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};THREE.UV=function(b,c){this.set(b||0,c||0)}; THREE.UV.prototype={set:function(b,c){this.u=b;this.v=c;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1}; THREE.Geometry.prototype={computeCentroids:function(){var b,c,d;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,d=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,d=this.vertices.length;cthis.points.length-2?f:f+1;d[3]=f>this.points.length-3?f:f+2;n=this.points[d[0]];o=this.points[d[1]]; p=this.points[d[2]];t=this.points[d[3]];k=j*j;m=j*k;e.x=c(n.x,o.x,p.x,t.x,j,k,m);e.y=c(n.y,o.y,p.y,t.y,j,k,m);e.z=c(n.z,o.z,p.z,t.z,j,k,m);return e};this.getControlPointsArray=function(){var b,d,c=this.points.length,e=[];for(b=0;b1){b=d.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 e=1;e=this.LODs[e].visibleAtDistance)this.LODs[e-1].object3D.visible=!1, this.LODs[e].object3D.visible=!0;else break;for(;ep&&(d=o,o=p,p=d):ou&&(d=t,t=u,u=d):t=0&&f>=0&&j>=0&&k>=0?!0:g<0&&f<0||j<0&&k<0?!1:(g<0?c=Math.max(c,g/(g-f)):f<0&&(e=Math.min(e,g/(g-f))),j<0?c=Math.max(c,j/(j-k)):k<0&&(e=Math.min(e,j/(j-k))),eH&&j.positionScreen.z0&&F.z<1))K=x[D]=x[D]||new THREE.RenderableParticle,D++,y=K,y.x=F.x/F.w,y.y=F.y/F.w,y.z=F.z,y.rotation=N.rotation.z,y.scale.x=N.scale.x*Math.abs(y.x-(F.x+h.projectionMatrix.n11)/(F.w+ h.projectionMatrix.n14)),y.scale.y=N.scale.y*Math.abs(y.y-(F.y+h.projectionMatrix.n22)/(F.w+h.projectionMatrix.n24)),y.materials=N.materials,f.push(y);g&&f.sort(c);return f}}; THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,d,e,g,f;this.domElement=document.createElement("div");this.setSize=function(b,c){d=b;e=c;g=d/2;f=e/2};this.render=function(d,e){var m,n,o,p,t,u,v,z;b=c.projectScene(d,e);m=0;for(n=b.length;m>1,p=n.height>>1,f=h.scale.x*t, m=h.scale.y*u,j=f*T,k=m*p,pa.set(b.x-j,b.y-k,b.x+j,b.y+k),qa.instersects(pa)&&(v.save(),v.translate(b.x,b.y),v.rotate(-h.rotation),v.scale(f,-m),v.translate(-T,-p),v.drawImage(n,0,0),v.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(j=h.scale.x*t,k=h.scale.y*u,pa.set(b.x-j,b.y-k,b.x+j,b.y+k),qa.instersects(pa)&&(e(f.color),g(f.color),v.save(),v.translate(b.x,b.y),v.rotate(-h.rotation),v.scale(j,k),f.program(v),v.restore()))}function y(b,h,f,g){c(g.opacity);d(g.blending);v.beginPath(); v.moveTo(b.positionScreen.x,b.positionScreen.y);v.lineTo(h.positionScreen.x,h.positionScreen.y);v.closePath();if(g instanceof THREE.LineBasicMaterial){b=g.linewidth;if(F!=b)v.lineWidth=F=b;b=g.linecap;if(A!=b)v.lineCap=A=b;b=g.linejoin;if(O!=b)v.lineJoin=O=b;e(g.color);v.stroke();pa.inflate(g.linewidth*2)}}function x(b,e,h,g,k,m,n,T,o){j.data.vertices+=3;j.data.faces++;c(T.opacity);d(T.blending);Q=b.positionScreen.x;W=b.positionScreen.y;J=e.positionScreen.x;$=e.positionScreen.y;R=h.positionScreen.x; P=h.positionScreen.y;B(Q,W,J,$,R,P);if(T instanceof THREE.MeshBasicMaterial)if(T.map)T.map.mapping instanceof THREE.UVMapping&&(ma=n.uvs[0],w(Q,W,J,$,R,P,T.map.image,ma[g].u,ma[g].v,ma[k].u,ma[k].v,ma[m].u,ma[m].v));else if(T.envMap){if(T.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=f.matrixWorldInverse,na.copy(n.vertexNormalsWorld[0]),ia=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,za=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(n.vertexNormalsWorld[1]),wa=(na.x*b.n11+na.y*b.n12+ na.z*b.n13)*0.5+0.5,aa=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(n.vertexNormalsWorld[2]),M=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,xa=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,w(Q,W,J,$,R,P,T.envMap.image,ia,za,wa,aa,M,xa)}else T.wireframe?E(T.color,T.wireframeLinewidth,T.wireframeLinecap,T.wireframeLinejoin):H(T.color);else if(T instanceof THREE.MeshLambertMaterial)T.map&&!T.wireframe&&(T.map.mapping instanceof THREE.UVMapping&&(ma=n.uvs[0],w(Q,W,J,$,R,P,T.map.image,ma[g].u,ma[g].v, ma[k].u,ma[k].v,ma[m].u,ma[m].v)),d(THREE.SubtractiveBlending)),Ta?!T.wireframe&&T.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length==3?(K.r=X.r=Y.r=ra.r,K.g=X.g=Y.g=ra.g,K.b=X.b=Y.b=ra.b,p(o,n.v1.positionWorld,n.vertexNormalsWorld[0],K),p(o,n.v2.positionWorld,n.vertexNormalsWorld[1],X),p(o,n.v3.positionWorld,n.vertexNormalsWorld[2],Y),ka.r=(X.r+Y.r)*0.5,ka.g=(X.g+Y.g)*0.5,ka.b=(X.b+Y.b)*0.5,fa=Qa(K,X,Y,ka),w(Q,W,J,$,R,P,fa,0,0,1,0,0,1)):(sa.r=ra.r,sa.g=ra.g,sa.b=ra.b,p(o,n.centroidWorld, n.normalWorld,sa),N.r=Math.max(0,Math.min(T.color.r*sa.r,1)),N.g=Math.max(0,Math.min(T.color.g*sa.g,1)),N.b=Math.max(0,Math.min(T.color.b*sa.b,1)),N.updateHex(),T.wireframe?E(N,T.wireframeLinewidth,T.wireframeLinecap,T.wireframeLinejoin):H(N)):T.wireframe?E(T.color,T.wireframeLinewidth,T.wireframeLinecap,T.wireframeLinejoin):H(T.color);else if(T instanceof THREE.MeshDepthMaterial)Z=f.near,ja=f.far,K.r=K.g=K.b=1-Da(b.positionScreen.z,Z,ja),X.r=X.g=X.b=1-Da(e.positionScreen.z,Z,ja),Y.r=Y.g=Y.b=1-Da(h.positionScreen.z, Z,ja),ka.r=(X.r+Y.r)*0.5,ka.g=(X.g+Y.g)*0.5,ka.b=(X.b+Y.b)*0.5,fa=Qa(K,X,Y,ka),w(Q,W,J,$,R,P,fa,0,0,1,0,0,1);else if(T instanceof THREE.MeshNormalMaterial)N.r=Ia(n.normalWorld.x),N.g=Ia(n.normalWorld.y),N.b=Ia(n.normalWorld.z),N.updateHex(),T.wireframe?E(N,T.wireframeLinewidth,T.wireframeLinecap,T.wireframeLinejoin):H(N)}function z(b,e,h,g,k,T,n,m,o){j.data.vertices+=4;j.data.faces++;c(m.opacity);d(m.blending);if(m.map||m.envMap)x(b,e,g,0,1,3,n,m,o),x(k,h,T,1,2,3,n,m,o);else if(Q=b.positionScreen.x, W=b.positionScreen.y,J=e.positionScreen.x,$=e.positionScreen.y,R=h.positionScreen.x,P=h.positionScreen.y,ga=g.positionScreen.x,V=g.positionScreen.y,da=k.positionScreen.x,ha=k.positionScreen.y,ea=T.positionScreen.x,ca=T.positionScreen.y,m instanceof THREE.MeshBasicMaterial)D(Q,W,J,$,R,P,ga,V),m.wireframe?E(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):H(m.color);else if(m instanceof THREE.MeshLambertMaterial)Ta?!m.wireframe&&m.shading==THREE.SmoothShading&&n.vertexNormalsWorld.length== 4?(K.r=X.r=Y.r=ka.r=ra.r,K.g=X.g=Y.g=ka.g=ra.g,K.b=X.b=Y.b=ka.b=ra.b,p(o,n.v1.positionWorld,n.vertexNormalsWorld[0],K),p(o,n.v2.positionWorld,n.vertexNormalsWorld[1],X),p(o,n.v4.positionWorld,n.vertexNormalsWorld[3],Y),p(o,n.v3.positionWorld,n.vertexNormalsWorld[2],ka),fa=Qa(K,X,Y,ka),B(Q,W,J,$,ga,V),w(Q,W,J,$,ga,V,fa,0,0,1,0,0,1),B(da,ha,R,P,ea,ca),w(da,ha,R,P,ea,ca,fa,1,0,1,1,0,1)):(sa.r=ra.r,sa.g=ra.g,sa.b=ra.b,p(o,n.centroidWorld,n.normalWorld,sa),N.r=Math.max(0,Math.min(m.color.r*sa.r,1)),N.g= Math.max(0,Math.min(m.color.g*sa.g,1)),N.b=Math.max(0,Math.min(m.color.b*sa.b,1)),N.updateHex(),D(Q,W,J,$,R,P,ga,V),m.wireframe?E(N,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):H(N)):(D(Q,W,J,$,R,P,ga,V),m.wireframe?E(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):H(m.color));else if(m instanceof THREE.MeshNormalMaterial)N.r=Ia(n.normalWorld.x),N.g=Ia(n.normalWorld.y),N.b=Ia(n.normalWorld.z),N.updateHex(),D(Q,W,J,$,R,P,ga,V),m.wireframe?E(N,m.wireframeLinewidth, m.wireframeLinecap,m.wireframeLinejoin):H(N);else if(m instanceof THREE.MeshDepthMaterial)Z=f.near,ja=f.far,K.r=K.g=K.b=1-Da(b.positionScreen.z,Z,ja),X.r=X.g=X.b=1-Da(e.positionScreen.z,Z,ja),Y.r=Y.g=Y.b=1-Da(g.positionScreen.z,Z,ja),ka.r=ka.g=ka.b=1-Da(h.positionScreen.z,Z,ja),fa=Qa(K,X,Y,ka),B(Q,W,J,$,ga,V),w(Q,W,J,$,ga,V,fa,0,0,1,0,0,1),B(da,ha,R,P,ea,ca),w(da,ha,R,P,ea,ca,fa,1,0,1,1,0,1)}function B(b,d,c,e,h,f){v.beginPath();v.moveTo(b,d);v.lineTo(c,e);v.lineTo(h,f);v.lineTo(b,d);v.closePath()} function D(b,d,c,e,h,f,g,j){v.beginPath();v.moveTo(b,d);v.lineTo(c,e);v.lineTo(h,f);v.lineTo(g,j);v.lineTo(b,d);v.closePath()}function E(b,d,c,h){if(F!=d)v.lineWidth=F=d;if(A!=c)v.lineCap=A=c;if(O!=h)v.lineJoin=O=h;e(b);v.stroke();pa.inflate(d*2)}function H(b){g(b);v.fill()}function w(b,d,c,e,h,f,g,j,k,m,T,n,p){var o,t;o=g.width-1;t=g.height-1;j*=o;k*=t;m*=o;T*=t;n*=o;p*=t;c-=b;e-=d;h-=b;f-=d;m-=j;T-=k;n-=j;p-=k;o=m*p-n*T;o!=0&&(t=1/o,o=(p*c-T*h)*t,T=(p*e-T*f)*t,c=(m*h-n*c)*t,e=(m*f-n*e)*t,b=b-o* j-c*k,d=d-T*j-e*k,v.save(),v.transform(o,T,c,e,b,d),v.clip(),v.drawImage(g,0,0),v.restore())}function Qa(b,d,c,e){var h=~~(b.r*255),f=~~(b.g*255),b=~~(b.b*255),g=~~(d.r*255),j=~~(d.g*255),d=~~(d.b*255),k=~~(c.r*255),T=~~(c.g*255),c=~~(c.b*255),m=~~(e.r*255),n=~~(e.g*255),e=~~(e.b*255);ta[0]=h<0?0:h>255?255:h;ta[1]=f<0?0:f>255?255:f;ta[2]=b<0?0:b>255?255:b;ta[4]=g<0?0:g>255?255:g;ta[5]=j<0?0:j>255?255:j;ta[6]=d<0?0:d>255?255:d;ta[8]=k<0?0:k>255?255:k;ta[9]=T<0?0:T>255?255:T;ta[10]=c<0?0:c>255?255: c;ta[12]=m<0?0:m>255?255:m;ta[13]=n<0?0:n>255?255:n;ta[14]=e<0?0:e>255?255:e;La.putImageData(Ua,0,0);Pa.drawImage(Ka,0,0);return Ma}function Da(b,d,c){b=(b-d)/(c-d);return b*b*(3-2*b)}function Ia(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Aa(b,d){var c=d.x-b.x,e=d.y-b.y,h=1/Math.sqrt(c*c+e*e);c*=h;e*=h;d.x+=c;d.y+=e;b.x-=c;b.y-=e}var Ra,Ya,la,ua,Ba,Ja,Sa,I;this.autoClear?this.clear():v.setTransform(1,0,0,-1,t,u);j.data.vertices=0;j.data.faces=0;k=m.projectScene(b,f,this.sortElements);(Ta=b.lights.length> 0)&&n(b);Ra=0;for(Ya=k.length;Ra0&&(c.r+=f.color.r*g,c.g+=f.color.g*g,c.b+=f.color.b*g)):f instanceof THREE.PointLight&&(S.sub(f.position,d.centroidWorld),S.normalize(),g=d.normalWorld.dot(S)*f.intensity,g>0&&(c.r+=f.color.r*g,c.g+=f.color.g*g,c.b+=f.color.b*g))}function c(d,c,h,k,m,p){j.data.vertices+=3;j.data.faces++;Q=e(W++);Q.setAttribute("d", "M "+d.positionScreen.x+" "+d.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");m instanceof THREE.MeshBasicMaterial?F.hex=m.color.hex:m instanceof THREE.MeshLambertMaterial?H?(A.r=O.r,A.g=O.g,A.b=O.b,b(p,k,A),F.r=Math.max(0,Math.min(m.color.r*A.r,1)),F.g=Math.max(0,Math.min(m.color.g*A.g,1)),F.b=Math.max(0,Math.min(m.color.b*A.b,1)),F.updateHex()):F.hex=m.color.hex:m instanceof THREE.MeshDepthMaterial?(G=1-m.__2near/(m.__farPlusNear- k.z*m.__farMinusNear),F.setRGB(G,G,G)):m instanceof THREE.MeshNormalMaterial&&F.setRGB(g(k.normalWorld.x),g(k.normalWorld.y),g(k.normalWorld.z));m.wireframe?Q.setAttribute("style","fill: none; stroke: #"+f(F.hex.toString(16))+"; stroke-width: "+m.wireframeLinewidth+"; stroke-opacity: "+m.opacity+"; stroke-linecap: "+m.wireframeLinecap+"; stroke-linejoin: "+m.wireframeLinejoin):Q.setAttribute("style","fill: #"+f(F.hex.toString(16))+"; fill-opacity: "+m.opacity);n.appendChild(Q)}function d(d,c,h,k, m,p,o){j.data.vertices+=4;j.data.faces++;Q=e(W++);Q.setAttribute("d","M "+d.positionScreen.x+" "+d.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?F.hex=p.color.hex:p instanceof THREE.MeshLambertMaterial?H?(A.r=O.r,A.g=O.g,A.b=O.b,b(o,m,A),F.r=Math.max(0,Math.min(p.color.r*A.r,1)),F.g=Math.max(0,Math.min(p.color.g*A.g,1)),F.b=Math.max(0,Math.min(p.color.b* A.b,1)),F.updateHex()):F.hex=p.color.hex:p instanceof THREE.MeshDepthMaterial?(G=1-p.__2near/(p.__farPlusNear-m.z*p.__farMinusNear),F.setRGB(G,G,G)):p instanceof THREE.MeshNormalMaterial&&F.setRGB(g(m.normalWorld.x),g(m.normalWorld.y),g(m.normalWorld.z));p.wireframe?Q.setAttribute("style","fill: none; stroke: #"+f(F.hex.toString(16))+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):Q.setAttribute("style", "fill: #"+f(F.hex.toString(16))+"; fill-opacity: "+p.opacity);n.appendChild(Q)}function e(b){h[b]==null&&(h[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),$==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 f(b){for(;b.length<6;)b="0"+b;return b}var j=this,k=null,m=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),o,p,t,u,v,z,B,y,D=new THREE.Rectangle,x=new THREE.Rectangle,H= !1,F=new THREE.Color(16777215),A=new THREE.Color(16777215),O=new THREE.Color(0),C=new THREE.Color(0),L=new THREE.Color(0),G,S=new THREE.Vector3,h=[],U=[],Q,W,J,$=1;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,faces:0};this.setQuality=function(b){switch(b){case "high":$=1;break;case "low":$=0}};this.setSize=function(b,d){o=b;p=d;t=o/2;u=p/2;n.setAttribute("viewBox",-t+" "+-u+" "+o+" "+p);n.setAttribute("width",o);n.setAttribute("height",p);D.set(-t,-u, t,u)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render=function(b,e){var h,g,p,o,A,F,G,K;this.autoClear&&this.clear();j.data.vertices=0;j.data.faces=0;k=m.projectScene(b,e,this.sortElements);J=W=0;if(H=b.lights.length>0){G=b.lights;O.setRGB(0,0,0);C.setRGB(0,0,0);L.setRGB(0,0,0);h=0;for(g=G.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,d,e,g={};for(c=0;c=0)h.bindBuffer(h.ARRAY_BUFFER,f.__webglVertexBuffer),h.vertexAttribPointer(b.position,3,h.FLOAT,!1,0,0);else{c=g.program.attributes;j.morphTargetBase!==-1?(h.bindBuffer(h.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[j.morphTargetBase]), h.vertexAttribPointer(c.position,3,h.FLOAT,!1,0,0)):c.position>=0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglVertexBuffer),h.vertexAttribPointer(c.position,3,h.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var e=0,m=j.morphTargetForcedOrder,n=j.morphTargetInfluences;ep&&(o=t,p=n[o]);h.bindBuffer(h.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[o]);h.vertexAttribPointer(c["morphTarget"+e],3,h.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[e]=p;m[o]=1;p=-1;e++}}g.program.uniforms.morphTargetInfluences!==null&&h.uniform1fv(g.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(f.__webglCustomAttributes)for(k in f.__webglCustomAttributes)b[k]>= 0&&(c=f.__webglCustomAttributes[k],h.bindBuffer(h.ARRAY_BUFFER,c.buffer),h.vertexAttribPointer(b[k],c.size,h.FLOAT,!1,0,0));b.color>=0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglColorBuffer),h.vertexAttribPointer(b.color,3,h.FLOAT,!1,0,0));b.normal>=0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglNormalBuffer),h.vertexAttribPointer(b.normal,3,h.FLOAT,!1,0,0));b.tangent>=0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglTangentBuffer),h.vertexAttribPointer(b.tangent,4,h.FLOAT,!1,0,0));b.uv>=0&&(f.__webglUVBuffer?(h.bindBuffer(h.ARRAY_BUFFER, f.__webglUVBuffer),h.vertexAttribPointer(b.uv,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(b.uv)):h.disableVertexAttribArray(b.uv));b.uv2>=0&&(f.__webglUV2Buffer?(h.bindBuffer(h.ARRAY_BUFFER,f.__webglUV2Buffer),h.vertexAttribPointer(b.uv2,2,h.FLOAT,!1,0,0),h.enableVertexAttribArray(b.uv2)):h.disableVertexAttribArray(b.uv2));g.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinVertexABuffer),h.vertexAttribPointer(b.skinVertexA,4, h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),h.vertexAttribPointer(b.skinVertexB,4,h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),h.vertexAttribPointer(b.skinIndex,4,h.FLOAT,!1,0,0),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),h.vertexAttribPointer(b.skinWeight,4,h.FLOAT,!1,0,0));j instanceof THREE.Mesh?(g.wireframe?(h.lineWidth(g.wireframeLinewidth),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),h.drawElements(h.LINES,f.__webglLineCount, h.UNSIGNED_SHORT,0)):(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),h.drawElements(h.TRIANGLES,f.__webglFaceCount,h.UNSIGNED_SHORT,0)),S.data.vertices+=f.__webglFaceCount,S.data.faces+=f.__webglFaceCount/3,S.data.drawCalls++):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?h.LINE_STRIP:h.LINES,h.lineWidth(g.linewidth),h.drawArrays(j,0,f.__webglLineCount),S.data.drawCalls++):j instanceof THREE.ParticleSystem?(h.drawArrays(h.POINTS,0,f.__webglParticleCount),S.data.drawCalls++):j instanceof THREE.Ribbon&&(h.drawArrays(h.TRIANGLE_STRIP,0,f.__webglVertexCount),S.data.drawCalls++)}}function g(b,d,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(d.attributes.position),h.vertexAttribPointer(d.attributes.position,3,h.FLOAT,!1,0,0));if(b.hasNormal){h.bindBuffer(h.ARRAY_BUFFER, b.__webglNormalBuffer);if(c==THREE.FlatShading){var e,f,g,j,k,m,n,p,o,t,u=b.count*3;for(t=0;t0&&y[0]0&&y[1]0.0010&&k.scale>0.0010)v[0]=k.x,v[1]=k.y,v[2]=k.z,t=k.size*k.scale/ea,u[0]=t*n,u[1]=t,h.uniform3fv(x.screenPosition,v),h.uniform2fv(x.scale,u),h.uniform1f(x.rotation,k.rotation),h.uniform1f(x.opacity,k.opacity),H(k.blending),A(k.texture,1),h.drawElements(h.TRIANGLES,6,h.UNSIGNED_SHORT,0)}h.enable(h.CULL_FACE);h.enable(h.DEPTH_TEST);h.depthMask(J)}function B(b,d){b._modelViewMatrix.multiplyToArray(d.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)} function y(b){var d,e,f,g,j;if(b instanceof THREE.Mesh){e=b.geometry;for(d in e.geometryGroups){f=e.geometryGroups[d];j=!1;for(g in f.__webglCustomAttributes)if(f.__webglCustomAttributes[g].needsUpdate){j=!0;break}if(e.__dirtyVertices||e.__dirtyMorphTargets||e.__dirtyElements||e.__dirtyUvs||e.__dirtyNormals||e.__dirtyColors||e.__dirtyTangents||j){j=b;var k=h.DYNAMIC_DRAW;if(f.__inittedArrays){var m=void 0,n=void 0,p=void 0,o=void 0,t=p=void 0,u=void 0,v=void 0,y=void 0,x=void 0,z=void 0,B=void 0, G=void 0,Z=void 0,A=void 0,D=void 0,F=void 0,H=void 0,E=o=y=o=v=u=void 0,C=void 0,w=C=E=u=void 0,ja=void 0,L=w=C=E=p=p=t=y=o=w=C=E=ja=w=C=E=ja=w=C=E=void 0,fa=0,J=0,M=0,ma=0,O=0,S=0,K=0,Q=0,N=0,I=0,P=0,C=E=0,V=f.__vertexArray,aa=f.__uvArray,$=f.__uv2Array,ga=f.__normalArray,R=f.__tangentArray,W=f.__colorArray,U=f.__skinVertexAArray,ia=f.__skinVertexBArray,X=f.__skinIndexArray,Y=f.__skinWeightArray,ha=f.__morphTargetsArrays,ea=f.__webglCustomAttributes,w=void 0,ca=f.__faceArray,da=f.__lineArray,ka= f.__needsSmoothNormals,z=f.__vertexColorType,x=f.__uvType,B=f.__normalType,oa=j.geometry,za=oa.__dirtyVertices,wa=oa.__dirtyElements,qa=oa.__dirtyUvs,xa=oa.__dirtyNormals,Va=oa.__dirtyTangents,Wa=oa.__dirtyColors,Xa=oa.__dirtyMorphTargets,Ea=oa.vertices,Za=f.faces,bb=oa.faces,$a=oa.faceVertexUvs[0],ab=oa.faceVertexUvs[1],Fa=oa.skinVerticesA,Ga=oa.skinVerticesB,Ha=oa.skinIndices,ya=oa.skinWeights,Ca=j instanceof THREE.ShadowVolume?oa.edgeFaces:void 0,va=oa.morphTargets;if(ea)for(L in ea)ea[L].offset= 0,ea[L].offsetSrc=0;m=0;for(n=Za.length;m0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglColorBuffer),h.bufferData(h.ARRAY_BUFFER,W,k));xa&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglNormalBuffer),h.bufferData(h.ARRAY_BUFFER,ga,k));Va&&oa.hasTangents&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglTangentBuffer),h.bufferData(h.ARRAY_BUFFER,R,k));qa&&M>0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglUVBuffer),h.bufferData(h.ARRAY_BUFFER,aa,k));qa&&ma>0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglUV2Buffer),h.bufferData(h.ARRAY_BUFFER,$,k));wa&&(h.bindBuffer(h.ELEMENT_ARRAY_BUFFER, f.__webglFaceBuffer),h.bufferData(h.ELEMENT_ARRAY_BUFFER,ca,k),h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),h.bufferData(h.ELEMENT_ARRAY_BUFFER,da,k));I>0&&(h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinVertexABuffer),h.bufferData(h.ARRAY_BUFFER,U,k),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),h.bufferData(h.ARRAY_BUFFER,ia,k),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),h.bufferData(h.ARRAY_BUFFER,X,k),h.bindBuffer(h.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),h.bufferData(h.ARRAY_BUFFER, Y,k));j.dynamic||(delete f.__inittedArrays,delete f.__colorArray,delete f.__normalArray,delete f.__tangentArray,delete f.__uvArray,delete f.__uv2Array,delete f.__faceArray,delete f.__vertexArray,delete f.__lineArray,delete f.__skinVertexAArray,delete f.__skinVertexBArray,delete f.__skinIndexArray,delete f.__skinWeightArray)}}}e.__dirtyVertices=!1;e.__dirtyMorphTargets=!1;e.__dirtyElements=!1;e.__dirtyUvs=!1;e.__dirtyNormals=!1;e.__dirtyTangents=!1;e.__dirtyColors=!1}else if(b instanceof THREE.Ribbon){e= b.geometry;if(e.__dirtyVertices||e.__dirtyColors){b=e;d=h.DYNAMIC_DRAW;x=b.vertices;f=b.colors;z=x.length;j=f.length;B=b.__vertexArray;k=b.__colorArray;G=b.__dirtyColors;if(b.__dirtyVertices){for(m=0;m65535&&(o[k].counter+=1,m=o[k].hash+"_"+o[k].counter,b.geometryGroups[m]==void 0&&(b.geometryGroups[m]={faces:[],materials:j,vertices:0,numMorphTargets:n})),b.geometryGroups[m].faces.push(f), b.geometryGroups[m].vertices+=h}function x(b,d,c){b.push({buffer:d,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function H(b){if(b!=P){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)}P=b}}function F(b,d,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(h.texParameteri(b,h.TEXTURE_WRAP_S,G(d.wrapS)),h.texParameteri(b,h.TEXTURE_WRAP_T,G(d.wrapT)),h.texParameteri(b,h.TEXTURE_MAG_FILTER,G(d.magFilter)),h.texParameteri(b,h.TEXTURE_MIN_FILTER,G(d.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,L(d.magFilter)),h.texParameteri(b,h.TEXTURE_MIN_FILTER,L(d.minFilter)))}function A(b,d){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);F(h.TEXTURE_2D,b,b.image);h.bindTexture(h.TEXTURE_2D,null);b.needsUpdate=!1}h.activeTexture(h.TEXTURE0+d);h.bindTexture(h.TEXTURE_2D,b.__webglTexture)}function O(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,G(b.wrapS));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,G(b.wrapT));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,G(b.magFilter));h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER, G(b.minFilter));h.texImage2D(h.TEXTURE_2D,0,G(b.format),b.width,b.height,0,G(b.format),G(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 d,c;b?(d=b.__webglFramebuffer,c=b.width,b=b.height):(d=null,c=ha,b=ea);d!=W&&(h.bindFramebuffer(h.FRAMEBUFFER,d),h.viewport(V, da,c,b),W=d)}function C(b,d){var c;b=="fragment"?c=h.createShader(h.FRAGMENT_SHADER):b=="vertex"&&(c=h.createShader(h.VERTEX_SHADER));h.shaderSource(c,d);h.compileShader(c);if(!h.getShaderParameter(c,h.COMPILE_STATUS))return console.error(h.getShaderInfoLog(c)),console.error(d),null;return c}function L(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return h.NEAREST;default:return h.LINEAR}}function G(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 S=this,h,U=[],Q=null, W=null,J=!0,$=null,R=null,P=null,ga=null,V=0,da=0,ha=0,ea=0,ca=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],N=new THREE.Matrix4,K=new Float32Array(16),X=new Float32Array(16),Y=new THREE.Vector4,ka={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Z=b.canvas!==void 0?b.canvas:document.createElement("canvas"),ja=b.stencil!==void 0?b.stencil:!0,fa=b.antialias!== void 0?b.antialias:!1,ma=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),ia=b.clearAlpha!==void 0?b.clearAlpha:0;this.data={vertices:0,faces:0,drawCalls:0};this.maxMorphTargets=8;this.domElement=Z;this.sortObjects=this.autoClear=!0;try{if(!(h=Z.getContext("experimental-webgl",{antialias:fa,stencil:ja})))throw"Error creating WebGL context.";}catch(za){console.error(za)}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(ma.r,ma.g,ma.b,ia);this.context=h;var wa=h.getParameter(h.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0;if(ja){var aa={};aa.vertices=new Float32Array(12);aa.faces=new Uint16Array(6);aa.darkness=0.5;aa.vertices[0]=-20; aa.vertices[1]=-20;aa.vertices[2]=-1;aa.vertices[3]=20;aa.vertices[4]=-20;aa.vertices[5]=-1;aa.vertices[6]=20;aa.vertices[7]=20;aa.vertices[8]=-1;aa.vertices[9]=-20;aa.vertices[10]=20;aa.vertices[11]=-1;aa.faces[0]=0;aa.faces[1]=1;aa.faces[2]=2;aa.faces[3]=0;aa.faces[4]=2;aa.faces[5]=3;aa.vertexBuffer=h.createBuffer();aa.elementBuffer=h.createBuffer();h.bindBuffer(h.ARRAY_BUFFER,aa.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,aa.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,aa.elementBuffer); h.bufferData(h.ELEMENT_ARRAY_BUFFER,aa.faces,h.STATIC_DRAW);aa.program=h.createProgram();h.attachShader(aa.program,C("fragment",THREE.ShaderLib.shadowPost.fragmentShader));h.attachShader(aa.program,C("vertex",THREE.ShaderLib.shadowPost.vertexShader));h.linkProgram(aa.program);aa.vertexLocation=h.getAttribLocation(aa.program,"position");aa.projectionLocation=h.getUniformLocation(aa.program,"projectionMatrix");aa.darknessLocation=h.getUniformLocation(aa.program,"darkness")}var M={};M.vertices=new Float32Array(16); M.faces=new Uint16Array(6);b=0;M.vertices[b++]=-1;M.vertices[b++]=-1;M.vertices[b++]=0;M.vertices[b++]=0;M.vertices[b++]=1;M.vertices[b++]=-1;M.vertices[b++]=1;M.vertices[b++]=0;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=-1;M.vertices[b++]=1;M.vertices[b++]=0;M.vertices[b++]=1;b=0;M.faces[b++]=0;M.faces[b++]=1;M.faces[b++]=2;M.faces[b++]=0;M.faces[b++]=2;M.faces[b++]=3;M.vertexBuffer=h.createBuffer();M.elementBuffer=h.createBuffer();M.tempTexture=h.createTexture(); M.occlusionTexture=h.createTexture();h.bindBuffer(h.ARRAY_BUFFER,M.vertexBuffer);h.bufferData(h.ARRAY_BUFFER,M.vertices,h.STATIC_DRAW);h.bindBuffer(h.ELEMENT_ARRAY_BUFFER,M.elementBuffer);h.bufferData(h.ELEMENT_ARRAY_BUFFER,M.faces,h.STATIC_DRAW);h.bindTexture(h.TEXTURE_2D,M.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,M.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?(M.hasVertexTexture=!1,M.program=h.createProgram(),h.attachShader(M.program,C("fragment",THREE.ShaderLib.lensFlare.fragmentShader)),h.attachShader(M.program,C("vertex",THREE.ShaderLib.lensFlare.vertexShader))):(M.hasVertexTexture=!0,M.program=h.createProgram(),h.attachShader(M.program,C("fragment",THREE.ShaderLib.lensFlareVertexTexture.fragmentShader)),h.attachShader(M.program,C("vertex",THREE.ShaderLib.lensFlareVertexTexture.vertexShader)));h.linkProgram(M.program);M.attributes={};M.uniforms={}; M.attributes.vertex=h.getAttribLocation(M.program,"position");M.attributes.uv=h.getAttribLocation(M.program,"UV");M.uniforms.renderType=h.getUniformLocation(M.program,"renderType");M.uniforms.map=h.getUniformLocation(M.program,"map");M.uniforms.occlusionMap=h.getUniformLocation(M.program,"occlusionMap");M.uniforms.opacity=h.getUniformLocation(M.program,"opacity");M.uniforms.scale=h.getUniformLocation(M.program,"scale");M.uniforms.rotation=h.getUniformLocation(M.program,"rotation");M.uniforms.screenPosition= h.getUniformLocation(M.program,"screenPosition");var xa=!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,C("fragment",THREE.ShaderLib.sprite.fragmentShader));h.attachShader(_sprite.program,C("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 qa=!1;this.setSize=function(b,d){Z.width=b;Z.height=d;this.setViewport(0,0,Z.width,Z.height)};this.setViewport=function(b,d,c,e){V=b;da=d;ha=c;ea=e;h.viewport(V,da,ha,ea)}; this.setScissor=function(b,d,c,e){h.scissor(b,d,c,e)};this.enableScissorTest=function(b){b?h.enable(h.SCISSOR_TEST):h.disable(h.SCISSOR_TEST)};this.enableDepthBufferWrite=function(b){J=b;h.depthMask(b)};this.setClearColorHex=function(b,d){ma.setHex(b);ia=d;h.clearColor(ma.r,ma.g,ma.b,ia)};this.setClearColor=function(b,d){ma.copy(b);ia=d;h.clearColor(ma.r,ma.g,ma.b,ia)};this.clear=function(){h.clear(h.COLOR_BUFFER_BIT|h.DEPTH_BUFFER_BIT|h.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(b){aa.darkness= b};this.getContext=function(){return h};this.initMaterial=function(b,d,c,e){var f,g,j;b instanceof THREE.MeshDepthMaterial?j="depth":b instanceof THREE.ShadowVolumeDynamicMaterial?j="shadowVolumeDynamic":b instanceof THREE.MeshNormalMaterial?j="normal":b instanceof THREE.MeshBasicMaterial?j="basic":b instanceof THREE.MeshLambertMaterial?j="lambert":b instanceof THREE.MeshPhongMaterial?j="phong":b instanceof THREE.LineBasicMaterial?j="basic":b instanceof THREE.ParticleBasicMaterial&&(j="particle_basic"); if(j){var k=THREE.ShaderLib[j];b.uniforms=THREE.UniformsUtils.clone(k.uniforms);b.vertexShader=k.vertexShader;b.fragmentShader=k.fragmentShader}var m,o,n;m=n=k=0;for(o=d.length;m=0&&h.enableVertexAttribArray(p.position);p.color>=0&&h.enableVertexAttribArray(p.color);p.normal>= 0&&h.enableVertexAttribArray(p.normal);p.tangent>=0&&h.enableVertexAttribArray(p.tangent);b.skinning&&p.skinVertexA>=0&&p.skinVertexB>=0&&p.skinIndex>=0&&p.skinWeight>=0&&(h.enableVertexAttribArray(p.skinVertexA),h.enableVertexAttribArray(p.skinVertexB),h.enableVertexAttribArray(p.skinIndex),h.enableVertexAttribArray(p.skinWeight));if(b.attributes)for(f in b.attributes)p[f]!==void 0&&p[f]>=0&&h.enableVertexAttribArray(p[f]);if(b.morphTargets){b.numSupportedMorphTargets=0;p.morphTarget0>=0&&(h.enableVertexAttribArray(p.morphTarget0), b.numSupportedMorphTargets++);p.morphTarget1>=0&&(h.enableVertexAttribArray(p.morphTarget1),b.numSupportedMorphTargets++);p.morphTarget2>=0&&(h.enableVertexAttribArray(p.morphTarget2),b.numSupportedMorphTargets++);p.morphTarget3>=0&&(h.enableVertexAttribArray(p.morphTarget3),b.numSupportedMorphTargets++);p.morphTarget4>=0&&(h.enableVertexAttribArray(p.morphTarget4),b.numSupportedMorphTargets++);p.morphTarget5>=0&&(h.enableVertexAttribArray(p.morphTarget5),b.numSupportedMorphTargets++);p.morphTarget6>= 0&&(h.enableVertexAttribArray(p.morphTarget6),b.numSupportedMorphTargets++);p.morphTarget7>=0&&(h.enableVertexAttribArray(p.morphTarget7),b.numSupportedMorphTargets++);e.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);b=0;for(f=this.maxMorphTargets;b0||t.faceVertexUvs.length>0)j.__uvArray=new Float32Array(m*2);if(t.faceUvs.length>1||t.faceVertexUvs.length>1)j.__uv2Array=new Float32Array(m*2)}if(k.geometry.skinWeights.length&&k.geometry.skinIndices.length)j.__skinVertexAArray=new Float32Array(m*4),j.__skinVertexBArray=new Float32Array(m*4),j.__skinIndexArray=new Float32Array(m*4),j.__skinWeightArray= new Float32Array(m*4);j.__faceArray=new Uint16Array(v*3+(k.geometry.edgeFaces?k.geometry.edgeFaces.length*6:0));j.__lineArray=new Uint16Array(z*2);if(j.numMorphTargets){j.__morphTargetsArrays=[];t=0;for(u=j.numMorphTargets;t=0;f--){if(e=d.__webglObjects[f].object,c==e){d.__webglObjects.splice(f,1);break}}else if(c instanceof THREE.Sprite)for(f=d.__webglSprites.length-1;f>=0;f--)if(e=d.__webglSprites[f],c==e){d.__webglSprites.splice(f,1);break}b.__objectsRemoved.splice(0,1)}c=0;for(d=b.__webglObjects.length;c1&&(d-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=d;c.s=j;c.v=f;return c}, clamp:function(b,c,d){return bd?d:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; var GeometryUtils={merge:function(b,c){var d=c instanceof THREE.Mesh,e=b.vertices.length,g=d?c.geometry:c,f=b.vertices,j=g.vertices,k=b.faces,m=g.faces,n=b.faceVertexUvs[0],g=g.faceVertexUvs[0];d&&c.matrixAutoUpdate&&c.updateMatrix();for(var o=0,p=j.length;o= 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&&(f=25);g=(f-1)*0.5;d=Array(f);for(c=e=0;c1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+e+" on bone "+u),e=e<0?0:1;if(d==="pos")if(d=b.position,this.interpolationType===THREE.AnimationHandler.LINEAR)d.x=g[0]+(f[0]-g[0])*e,d.y=g[1]+(f[1]-g[1])*e,d.z=g[2]+(f[2]-g[2])*e;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]= this.getPrevKeyWith("pos",u,j.index-1).pos,this.points[1]=g,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",u,k.index+1).pos,e=e*0.33+0.33,g=this.interpolateCatmullRom(this.points,e),d.x=g[0],d.y=g[1],d.z=g[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=this.interpolateCatmullRom(this.points,e*1.01),this.target.set(e[0],e[1],e[2]),this.target.subSelf(d),this.target.y=0,this.target.normalize(),e=Math.atan2(this.target.x,this.target.z),b.rotation.set(0,e,0)}else if(d=== "rot")THREE.Quaternion.slerp(g,f,b.quaternion,e);else if(d==="scl")d=b.scale,d.x=g[0]+(f[0]-g[0])*e,d.y=g[1]+(f[1]-g[1])*e,d.z=g[2]+(f[2]-g[2])*e}}if(this.JITCompile&&o[0][n]===void 0){this.hierarchy[0].update(void 0,!0);for(u=0;ub.length-2?f:f+1;d[3]=f>b.length-3?f:f+2;f=b[d[0]];k=b[d[1]];m=b[d[2]];n=b[d[3]];d=g*g;j=g*d;e[0]=this.interpolate(f[0],k[0],m[0],n[0],g,d,j);e[1]=this.interpolate(f[1],k[1],m[1],n[1],g,d,j);e[2]=this.interpolate(f[2],k[2],m[2],n[2],g,d,j);return e}; THREE.Animation.prototype.interpolate=function(b,c,d,e,g,f,j){b=(d-b)*0.5;e=(e-c)*0.5;return(2*(c-d)+b+e)*j+(-3*(c-d)-2*b-e)*f+b*g+c};THREE.Animation.prototype.getNextKeyWith=function(b,c,d){var e=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?d=d0?d:0:d>=0?d:d+e.length;d>=0;d--)if(e[d][b]!==void 0)return e[d];return this.data.hierarchy[c].keys[e.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,d,e){var f={name:d,fps:0.6,length:e,hierarchy:[]},g,j=c.getControlPointsArray(),k=c.getLength(),m=j.length,D=0;g=m-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:j[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[g]={time:e,pos:j[g],rot:[0,0,0,1],scl:[1,1,1]};for(g=1;g=0?e:e+g;e=this.verticalAngleMap.srcRange;j=this.verticalAngleMap.dstRange;var k=j[1]-j[0];this.phi= TWEEN.Easing.Quadratic.EaseInOut(((this.phi-e[0])*(j[1]-j[0])/(e[1]-e[0])+j[0]-j[0])/k)*k+j[0];e=this.horizontalAngleMap.srcRange;j=this.horizontalAngleMap.dstRange;k=j[1]-j[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-e[0])*(j[1]-j[0])/(e[1]-e[0])+j[0]-j[0])/k)*k+j[0];e=this.target.position;e.x=100*Math.sin(this.phi)*Math.cos(this.theta);e.y=100*Math.cos(this.phi);e.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,b,c,d)};this.onMouseMove=function(b){this.mouseX= b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var b=new THREE.MeshLambertMaterial({color:30719}),j=new THREE.MeshLambertMaterial({color:65280}),k=new THREE.Cube(10,10,20),m=new THREE.Cube(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(m,j);b.position.set(0,10,0);this.animation=c(this.animationParent, this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else this.animation=c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&e(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,f=c.size[1]/2;this.moveState.yawLeft=-(b.clientX-c.offset[0]-g)/g;this.moveState.pitchDown=(b.clientY- c.offset[1]-f)/f;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,d,e){THREE.Camera.call(this,b,c,d,e);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,f=new THREE.Vector3,j=new THREE.Vector3,k=new THREE.Matrix4,m=!1,n=1,o=0,p=0,t=0,u=0,v=0,z=window.innerWidth/2,B=window.innerHeight/2;this.update= function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.delta=(b-this.lastUpdate)/1E3;this.lastUpdate=b;this.mouseLook&&(b=this.delta*this.lookSpeed,this.rotateHorizontally(b*u),this.rotateVertically(b*v));b=this.delta*this.movementSpeed;this.translateZ(b*(o>0||this.autoForward&&!(o<0)?1:o));this.translateX(b*p);this.translateY(b*t);m&&(this.roll+=this.rollSpeed*this.delta*n);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize(); else if(this.forward.y1?d.normalize():d.z=Math.sqrt(1-e*e);g=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(d.y);e.addSelf(this.up.clone().crossSelf(g).setLength(d.x));e.addSelf(g.setLength(d.z));return e}; this.rotateCamera=function(){var b=Math.acos(f.dot(j)/f.length()/j.length());if(b){var c=(new THREE.Vector3).cross(f,j).normalize(),d=new THREE.Quaternion;b*=this.rotateSpeed;d.setFromAxisAngle(c,-b);d.multiplyVector3(g);d.multiplyVector3(this.up);d.multiplyVector3(j);this.staticMoving?f=j:(d.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),d.multiplyVector3(f))}};this.zoomCamera=function(){var b=1+(m.y-k.y)*this.zoomSpeed;b!==1&&b>0&&(g.multiplyScalar(b),this.staticMoving?k=m:k.y+=(m.y-k.y)*this.dynamicDampingFactor)}; this.panCamera=function(){var b=o.clone().subSelf(n);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?n=o:n.addSelf(b.sub(o,n).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){j(0,0,-o-(f||0));for(m=b;m0){j(0,0,o+(g||0)); for(m=b+b/2;m<2*b;m++)k.faces.push(new THREE.Face4(2*b+1,(2*m-2*b+2)%b+b,(2*m-2*b+1)%b+b,(2*m-2*b)%b+b))}m=0;for(b=this.faces.length;m0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(p,k,t)))-1);n.push(o)}c.push(n)}for(var u,v,z,g=c.length,d=0;d0)for(e=0;e1&&(u=this.vertices[j].position.clone(), v=this.vertices[m].position.clone(),z=this.vertices[n].position.clone(),u.normalize(),v.normalize(),z.normalize(),this.faces.push(new THREE.Face3(j,m,n,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(z.x,z.y,z.z)])),this.faceVertexUvs[0].push([o,p,B]))}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,d,e){THREE.Geometry.call(this);this.radius=b||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;b=[];for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){var e=d/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(e),(this.radius+this.tube*Math.cos(g))*Math.sin(e),this.tube*Math.sin(g))));b.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d= 1;d<=this.segmentsT;++d){var e=(this.segmentsT+1)*c+d,g=(this.segmentsT+1)*c+d-1,f=(this.segmentsT+1)*(c-1)+d-1,j=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,g,f,j));this.faceVertexUvs[0].push([new THREE.UV(b[e][0],b[e][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[j][0],b[j][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,d,e,g,f,j){function k(b,c,d,e,f,g){c=d/e*b;d=Math.cos(c);return new THREE.Vector3(f*(2+d)*0.5*Math.cos(b),f*(2+d)*Math.sin(b)*0.5,g*f*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=d||64;this.segmentsT=e||8;this.p=g||2;this.q=f||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);d=new THREE.Vector3;e=new THREE.Vector3;f=new THREE.Vector3;for(b=0;b0;){if(o){if(o.equals(g[f])){o=null;continue}}else o=g[f];for(d=0;d0&&j.push({shape:g,holes:e}),g=p,e=[]):e.push(p):this.Triangulate.area(p)<0?(j.push({shape:p,holes:e}),e=[]):e.push(p);n++}o&&j.push({shape:g,holes:e})}var t,u,v,z,B,y;f=[];for(k=0;k=0?u-1:g.length-1;var p=t-1>=0?t-1:n.length-1,D=[];D.push(n[t]);D.push(g[u]);D.push(g[d]);v=this.Triangulate.area(D);var x=[];x.push(n[t]);x.push(n[p]);x.push(g[u]);B=this.Triangulate.area(x);z=u;y=t;u+=1;t+=-1;u<0&&(u+=g.length);u%=g.length;t<0&&(t+=n.length);t%=g.length;d=u-1>=0?u-1:g.length-1;p=t-1>=0?t-1:n.length- 1;D=[];D.push(n[t]);D.push(g[u]);D.push(g[d]);D=this.Triangulate.area(D);x=[];x.push(n[t]);x.push(n[p]);x.push(g[u]);x=this.Triangulate.area(x);v+B>D+x&&(u=z,t=y,u<0&&(u+=g.length),u%=g.length,t<0&&(t+=n.length),t%=g.length,d=u-1>=0?u-1:g.length-1,p=t-1>=0?t-1:n.length-1);v=g.slice(0,u);B=g.slice(u);z=n.slice(t);y=n.slice(0,t);f.push(n[t]);f.push(g[u]);f.push(g[d]);f.push(n[t]);f.push(n[p]);f.push(g[u]);g=v.concat(z).concat(y).concat(B)}m.shape=g}b=[];t=[];for(k=o=0;k0)for(n=0;n2;){if(p--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return k;return f}m=n;g<=m&&(m=0);n=m+1;g<=n&&(n=0);o=n+1;g<=o&&(o=0);var t;a:{t=b;var u=m,v=n,z=o,B=g,y=j,D=void 0,x=void 0,H=void 0, F=void 0,A=void 0,O=void 0,C=void 0,L=void 0,G=void 0,x=t[y[u]].x,H=t[y[u]].y,F=t[y[v]].x,A=t[y[v]].y,O=t[y[z]].x,C=t[y[z]].y;if(1.0E-10>(F-x)*(C-H)-(A-H)*(O-x))t=!1;else{for(D=0;D=0&&U>=0&&W>=0){t=!1;break a}}t= !0}}if(t){p=j[m];t=j[n];u=j[o];f.push(b[p]);f.push(b[t]);f.push(b[u]);k.push([j[m],j[n],j[o]]);m=n;for(o=n+1;o>7)-127;e|=(g&127)<<16|f<<8;if(e==0&&j==-127)return 0;return(1-2*(h>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,j)}function g(b,c){var d=o(b,c),e=o(b,c+1),f=o(b,c+2);return(o(b,c+3)<<24)+(f<<16)+(e<<8)+d}function m(b,c){var d=o(b,c);return(o(b,c+1)<<8)+d}function n(b,c){var d=o(b,c);return d>127?d-256:d}function o(b, c){return b.charCodeAt(c)&255}function p(c){var d,e,f;d=g(b,c);e=g(b,c+A);f=g(b,c+O);c=m(b,c+C);THREE.BinaryLoader.prototype.f3(y,d,e,f,c)}function t(c){var d,e,f,h,j,n;d=g(b,c);e=g(b,c+A);f=g(b,c+O);h=m(b,c+C);j=g(b,c+L);n=g(b,c+G);c=g(b,c+S);THREE.BinaryLoader.prototype.f3n(y,H,d,e,f,h,j,n,c)}function u(c){var d,e,f,j;d=g(b,c);e=g(b,c+h);f=g(b,c+U);j=g(b,c+Q);c=m(b,c+W);THREE.BinaryLoader.prototype.f4(y,d,e,f,j,c)}function v(c){var d,e,f,j,n,o,p,t;d=g(b,c);e=g(b,c+h);f=g(b,c+U);j=g(b,c+Q);n=m(b, c+W);o=g(b,c+J);p=g(b,c+$);t=g(b,c+R);c=g(b,c+P);THREE.BinaryLoader.prototype.f4n(y,H,d,e,f,j,n,o,p,t,c)}function z(c){var d,e;d=g(b,c);e=g(b,c+ga);c=g(b,c+V);THREE.BinaryLoader.prototype.uv3(y.faceVertexUvs[0],F[d*2],F[d*2+1],F[e*2],F[e*2+1],F[c*2],F[c*2+1])}function B(c){var d,e,f;d=g(b,c);e=g(b,c+da);f=g(b,c+ha);c=g(b,c+ea);THREE.BinaryLoader.prototype.uv4(y.faceVertexUvs[0],F[d*2],F[d*2+1],F[e*2],F[e*2+1],F[f*2],F[f*2+1],F[c*2],F[c*2+1])}var y=this,D=0,x,H=[],F=[],A,O,C,L,G,S,h,U,Q,W,J,$,R,P, ga,V,da,ha,ea,ca,N,K,X,Y,ka;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(y,e,c);x={signature:b.substr(D,8),header_bytes:o(b,D+8),vertex_coordinate_bytes:o(b,D+9),normal_coordinate_bytes:o(b,D+10),uv_coordinate_bytes:o(b,D+11),vertex_index_bytes:o(b,D+12),normal_index_bytes:o(b,D+13),uv_index_bytes:o(b,D+14),material_index_bytes:o(b,D+15),nvertices:g(b,D+16),nnormals:g(b,D+16+4),nuvs:g(b,D+16+8),ntri_flat:g(b,D+16+12),ntri_smooth:g(b,D+16+16),ntri_flat_uv:g(b,D+16+20),ntri_smooth_uv:g(b, D+16+24),nquad_flat:g(b,D+16+28),nquad_smooth:g(b,D+16+32),nquad_flat_uv:g(b,D+16+36),nquad_smooth_uv:g(b,D+16+40)};D+=x.header_bytes;A=x.vertex_index_bytes;O=x.vertex_index_bytes*2;C=x.vertex_index_bytes*3;L=x.vertex_index_bytes*3+x.material_index_bytes;G=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes;S=x.vertex_index_bytes*3+x.material_index_bytes+x.normal_index_bytes*2;h=x.vertex_index_bytes;U=x.vertex_index_bytes*2;Q=x.vertex_index_bytes*3;W=x.vertex_index_bytes*4;J=x.vertex_index_bytes* 4+x.material_index_bytes;$=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes;R=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*2;P=x.vertex_index_bytes*4+x.material_index_bytes+x.normal_index_bytes*3;ga=x.uv_index_bytes;V=x.uv_index_bytes*2;da=x.uv_index_bytes;ha=x.uv_index_bytes*2;ea=x.uv_index_bytes*3;c=x.vertex_index_bytes*3+x.material_index_bytes;ka=x.vertex_index_bytes*4+x.material_index_bytes;ca=x.ntri_flat*c;N=x.ntri_smooth*(c+x.normal_index_bytes*3);K=x.ntri_flat_uv* (c+x.uv_index_bytes*3);X=x.ntri_smooth_uv*(c+x.normal_index_bytes*3+x.uv_index_bytes*3);Y=x.nquad_flat*ka;c=x.nquad_smooth*(ka+x.normal_index_bytes*4);ka=x.nquad_flat_uv*(ka+x.uv_index_bytes*4);D+=function(c){for(var e,f,g,h=x.vertex_coordinate_bytes*3,k=c+x.nvertices*h;c1&&(L=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(A,L);object.name=u;object.position.set(x[0],x[1],x[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=D.visible;J.scene.addObject(object);J.objects[u]=object;if(D.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(object);J.scene.collisions.colliders.push(b)}if(D.castsShadow)b=new THREE.ShadowVolume(A),J.scene.addChild(b), b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;D.trigger&&D.trigger.toLowerCase()!="none"&&(b={type:D.trigger,object:D},J.triggers[object.name]=b)}}else x=D.position,r=D.rotation,q=D.quaternion,s=D.scale,q=0,object=new THREE.Object3D,object.name=u,object.position.set(x[0],x[1],x[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=D.visible!==void 0?D.visible:!1,J.scene.addObject(object), J.objects[u]=object,J.empties[u]=object,D.trigger&&D.trigger.toLowerCase()!="none"&&(b={type:D.trigger,object:D},J.triggers[object.name]=b)}function m(b){return function(c){J.geometries[b]=c;k();h-=1;d.onLoadComplete();o()}}function n(b){return function(c){J.geometries[b]=c}}function o(){d.callbackProgress({totalModels:Q,totalTextures:W,loadedModels:Q-h,loadedTextures:W-U},J);d.onLoadProgress();h==0&&U==0&&c(J)}var p,t,u,v,z,B,y,D,x,H,F,A,O,C,L,G,S,h,U,Q,W,J;G=b.data;b=new THREE.BinaryLoader;S=new THREE.JSONLoader; U=h=0;J={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};var $=!1;for(u in G.objects)if(D=G.objects[u],D.meshCollider){$=!0;break}if($)J.scene.collisions=new THREE.CollisionSystem;if(G.transform){$=G.transform.position;H=G.transform.rotation;var R=G.transform.scale;$&&J.scene.position.set($[0],$[1],$[2]);H&&J.scene.rotation.set(H[0],H[1],H[2]);R&&J.scene.scale.set(R[0],R[1],R[2]);($||H||R)&&J.scene.updateMatrix()}$=function(){U-= 1;o();d.onLoadComplete()};for(z in G.cameras){H=G.cameras[z];if(H.type=="perspective")O=new THREE.Camera(H.fov,H.aspect,H.near,H.far);else if(H.type=="ortho")O=new THREE.Camera,O.projectionMatrix=THREE.Matrix4.makeOrtho(H.left,H.right,H.top,H.bottom,H.near,H.far);x=H.position;H=H.target;O.position.set(x[0],x[1],x[2]);O.target.position.set(H[0],H[1],H[2]);J.cameras[z]=O}for(v in G.lights){z=G.lights[v];O=z.color!==void 0?z.color:16777215;H=z.intensity!==void 0?z.intensity:1;if(z.type=="directional")x= z.direction,light=new THREE.DirectionalLight(O,H),light.position.set(x[0],x[1],x[2]),light.position.normalize();else if(z.type=="point")x=z.position,light=new THREE.PointLight(O,H),light.position.set(x[0],x[1],x[2]);J.scene.addLight(light);J.lights[v]=light}for(B in G.fogs)v=G.fogs[B],v.type=="linear"?C=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(C=new THREE.FogExp2(0,v.density)),H=v.color,C.color.setRGB(H[0],H[1],H[2]),J.fogs[B]=C;if(J.cameras&&G.defaults.camera)J.currentCamera=J.cameras[G.defaults.camera]; if(J.fogs&&G.defaults.fog)J.scene.fog=J.fogs[G.defaults.fog];H=G.defaults.bgcolor;J.bgColor=new THREE.Color;J.bgColor.setRGB(H[0],H[1],H[2]);J.bgColorAlpha=G.defaults.bgalpha;for(p in G.geometries)if(B=G.geometries[p],B.type=="bin_mesh"||B.type=="ascii_mesh")h+=1,d.onLoadStart();Q=h;for(p in G.geometries)B=G.geometries[p],B.type=="cube"?(A=new THREE.Cube(B.width,B.height,B.depth,B.segmentsWidth,B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),J.geometries[p]=A):B.type=="plane"?(A=new THREE.Plane(B.width, B.height,B.segmentsWidth,B.segmentsHeight),J.geometries[p]=A):B.type=="sphere"?(A=new THREE.Sphere(B.radius,B.segmentsWidth,B.segmentsHeight),J.geometries[p]=A):B.type=="cylinder"?(A=new THREE.Cylinder(B.numSegs,B.topRad,B.botRad,B.height,B.topOffset,B.botOffset),J.geometries[p]=A):B.type=="torus"?(A=new THREE.Torus(B.radius,B.tube,B.segmentsR,B.segmentsT),J.geometries[p]=A):B.type=="icosahedron"?(A=new THREE.Icosahedron(B.subdivisions),J.geometries[p]=A):B.type=="bin_mesh"?b.load({model:e(B.url, G.urlBaseType),callback:m(p)}):B.type=="ascii_mesh"?S.load({model:e(B.url,G.urlBaseType),callback:m(p)}):B.type=="embedded_mesh"&&(B=G.embeds[B.id])&&S.createModel(B,n(p),"");for(y in G.textures)if(p=G.textures[y],p.url instanceof Array){U+=p.url.length;for(b=0;b=this.maxCount-3&&k(this)};this.begin=function(){this.count=0; this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(m=this.size-1);var t=Math.floor(n-k);t<1&&(t=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var u=Math.floor(o-k);u<1&&(u=1);k=Math.floor(o+k);k>this.size-1&&(k=this.size- 1);for(var v,z,B,y,D,x;p0&&(this.field[B+v]+=y)}}};this.addPlaneX=function(b,c){var g,f,j,k,m,n=this.size,o=this.yd,p=this.zd,t=this.field,u=n*Math.sqrt(b/c);u>n&&(u=n);for(g=0;g0)for(f=0;fo&&(v=o);for(f=0;f0){m=f*p;for(g=0;gsize&&(dist=size);for(j=0;j0){m=zd*j;for(f=0;ff?this.hits.push(g):this.hits.unshift(g),f=e;return this.hits}; THREE.CollisionSystem.prototype.rayCastNearest=function(b){var c=this.rayCastAll(b);if(c.length==0)return null;for(var d=0;c[d]instanceof THREE.MeshCollider;){var e=this.rayMesh(b,c[d]);if(e.distc.length)return null;return c[d]}; 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 d=this.makeRayLocal(b,c.mesh),e=Number.MAX_VALUE,g,f=0;f=k*g))return Number.MAX_VALUE;j/=k;k=THREE.CollisionSystem.__v3;k.copy(b.direction);k.multiplyScalar(j);k.addSelf(b.origin);Math.abs(f.x)>Math.abs(f.y)?Math.abs(f.x)>Math.abs(f.z)?(b=k.y-c.y,f=d.y-c.y, g=e.y-c.y,k=k.z-c.z,d=d.z-c.z,e=e.z-c.z):(b=k.x-c.x,f=d.x-c.x,g=e.x-c.x,k=k.y-c.y,d=d.y-c.y,e=e.y-c.y):Math.abs(f.y)>Math.abs(f.z)?(b=k.x-c.x,f=d.x-c.x,g=e.x-c.x,k=k.z-c.z,d=d.z-c.z,e=e.z-c.z):(b=k.x-c.x,f=d.x-c.x,g=e.x-c.x,k=k.y-c.y,d=d.y-c.y,e=e.y-c.y);c=f*e-d*g;if(c==0)return Number.MAX_VALUE;c=1/c;e=(b*e-k*g)*c;if(!(e>=0))return Number.MAX_VALUE;c*=f*k-d*b;if(!(c>=0))return Number.MAX_VALUE;if(!(1-e-c>=0))return Number.MAX_VALUE;return j}; THREE.CollisionSystem.prototype.makeRayLocal=function(b,c){var d=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,d);var e=THREE.CollisionSystem.__r;e.origin.copy(b.origin);e.direction.copy(b.direction);d.multiplyVector3(e.origin);d.rotateAxis(e.direction);e.direction.normalize();return e}; THREE.CollisionSystem.prototype.rayBox=function(b,c){var d;c.dynamic&&c.mesh&&c.mesh.matrixWorld?d=this.makeRayLocal(b,c.mesh):(d=THREE.CollisionSystem.__r,d.origin.copy(b.origin),d.direction.copy(b.direction));var e=0,g=0,f=0,j=0,k=0,m=0,n=!0;d.origin.xc.max.x&&(e=c.max.x-d.origin.x,e/=d.direction.x,n=!1,j=1);d.origin.yc.max.y&&(g=c.max.y-d.origin.y,g/=d.direction.y, n=!1,k=1);d.origin.zc.max.z&&(f=c.max.z-d.origin.z,f/=d.direction.z,n=!1,m=1);if(n)return-1;n=0;g>e&&(n=1,e=g);f>e&&(n=2,e=f);switch(n){case 0:k=d.origin.y+d.direction.y*e;if(kc.max.y)return Number.MAX_VALUE;d=d.origin.z+d.direction.z*e;if(dc.max.z)return Number.MAX_VALUE;c.normal.set(j,0,0);break;case 1:j=d.origin.x+d.direction.x*e;if(jc.max.x)return Number.MAX_VALUE;d=d.origin.z+d.direction.z* e;if(dc.max.z)return Number.MAX_VALUE;c.normal.set(0,k,0);break;case 2:j=d.origin.x+d.direction.x*e;if(jc.max.x)return Number.MAX_VALUE;k=d.origin.y+d.direction.y*e;if(kc.max.y)return Number.MAX_VALUE;c.normal.set(0,0,m)}return e};THREE.CollisionSystem.prototype.rayPlane=function(b,c){var d=b.direction.dot(c.normal),e=c.point.dot(c.normal);if(d<0)d=(e-b.origin.dot(c.normal))/d;else return Number.MAX_VALUE;return d>0?d:Number.MAX_VALUE}; THREE.CollisionSystem.prototype.raySphere=function(b,c){var d=c.center.clone().subSelf(b.origin);if(d.lengthSq=0)return Math.abs(e)-Math.sqrt(d);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,d=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]),d=new THREE.BoxCollider(d,c);d.mesh=b;return d};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,d=this.setSize,e=this.render,g=new THREE.Camera,f=new THREE.Camera,b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},j=new THREE.WebGLRenderTarget(512,512,b),k=new THREE.WebGLRenderTarget(512,512,b),m=new THREE.Camera(53,1,1,1E4);m.position.z=2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:j},mapRight:{type:"t",value:1,texture:k}},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 n=new THREE.Scene;n.addObject(new THREE.Mesh(new THREE.Plane(2,2),_material));this.setSize=function(b,e){d.call(c,b,e);j.width=b;j.height=e;k.width=b;k.height=e};this.render= function(b,d){g.projectionMatrix=d.projectionMatrix;g.position.copy(d.position);g.target.position.copy(d.target.position);g.translateX(-10);f.projectionMatrix=d.projectionMatrix;f.position.copy(d.position);f.target.position.copy(d.target.position);f.translateX(10);e.call(c,b,g,j,!0);e.call(c,b,f,k,!0);e.call(c,n,m)}};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,d=this.setSize,e=this.render,g,f,j=new THREE.Camera,k=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,e){d.call(c,b,e);g=b/2;f=e};this.render=function(b,d){this.clear();j.fov=d.fov;j.aspect=0.5*d.aspect;j.near=d.near;j.far=d.far;j.updateProjectionMatrix(); j.position.copy(d.position);j.target.position.copy(d.target.position);j.translateX(c.separation);k.projectionMatrix=j.projectionMatrix;k.position.copy(d.position);k.target.position.copy(d.target.position);k.translateX(-c.separation);this.setViewport(0,0,g,f);e.call(c,b,j);this.setViewport(g,0,g,f);e.call(c,b,k,!1)}};THREE.CrosseyedWebGLRenderer.prototype=new THREE.WebGLRenderer;THREE.CrosseyedWebGLRenderer.prototype.constructor=THREE.CrosseyedWebGLRenderer;