From 363ce622b08a964a5426664d9859d5203297a7fe Mon Sep 17 00:00:00 2001 From: alteredq Date: Wed, 26 Oct 2011 19:17:03 +0200 Subject: [PATCH] Refactored custom attributes setting for lines. Also here moved ifs out of the inner loop. Starts to get hard to measure performance impact - baseline JavaScript stuff just to produce some change gets very costly. Simply calling Math.random() hundreds thousands times causes massive garbage collection :S. --- build/Three.js | 433 +++++++++++++++++---------------- build/custom/ThreeWebGL.js | 168 ++++++------- src/renderers/WebGLRenderer.js | 81 +++--- 3 files changed, 353 insertions(+), 329 deletions(-) diff --git a/build/Three.js b/build/Three.js index 505ee08e..5ed94ed6 100644 --- a/build/Three.js +++ b/build/Three.js @@ -17,8 +17,8 @@ c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c;return this}};THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3}; THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(a){return this.intersectObjects(a.children)},intersectObjects:function(a){var c,b,e=[];c=0;for(b=a.length;c=0&&w>=0&&x+w<1}for(var e=new THREE.Vector3,l=new THREE.Vector3,h=new THREE.Vector3,f,k,n,t,v,p,x,w,z,u=[],B=0,y=a.children.length;Ba.scale.x)return[];z={distance:B,point:a.position, -face:null,object:a};u.push(z)}else if(a instanceof THREE.Mesh){B=c(this.origin,this.direction,a.matrixWorld.getPosition());if(B===null||B>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return u;var E,C,H,L,R,D,O,K,N=a.geometry,J=N.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);B=0;for(y=N.faces.length;B0:D<0)))if(D=R.dot((new THREE.Vector3).sub(E,O))/D,O=O.addSelf(K.multiplyScalar(D)),z instanceof THREE.Face3)b(O,E,C,H)&&(z={distance:this.origin.distanceTo(O),point:O,face:z,object:a}, +face:null,object:a};u.push(z)}else if(a instanceof THREE.Mesh){B=c(this.origin,this.direction,a.matrixWorld.getPosition());if(B===null||B>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return u;var E,C,H,L,R,D,O,J,N=a.geometry,K=N.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);B=0;for(y=N.faces.length;B0:D<0)))if(D=R.dot((new THREE.Vector3).sub(E,O))/D,O=O.addSelf(J.multiplyScalar(D)),z instanceof THREE.Face3)b(O,E,C,H)&&(z={distance:this.origin.distanceTo(O),point:O,face:z,object:a}, u.push(z));else if(z instanceof THREE.Face4&&(b(O,E,C,L)||b(O,C,H,L)))z={distance:this.origin.distanceTo(O),point:O,face:z,object:a},u.push(z)}return u}}; THREE.Rectangle=function(){function a(){h=e-c;f=l-b}var c,b,e,l,h,f,k=!0;this.getX=function(){return c};this.getY=function(){return b};this.getWidth=function(){return h};this.getHeight=function(){return f};this.getLeft=function(){return c};this.getTop=function(){return b};this.getRight=function(){return e};this.getBottom=function(){return l};this.set=function(h,f,v,p){k=!1;c=h;b=f;e=v;l=p;a()};this.addPoint=function(h,f){k?(k=!1,c=h,b=f,e=h,l=f):(c=ch?e:h,l=l>f?l:f);a()};this.add3Points= function(h,f,v,p,x,w){k?(k=!1,c=hv?h>x?h:x:v>x?v:x,l=f>p?f>w?f:w:p>w?p:w):(c=hv?h>x?h>e?h:e:x>e?x:e:v>x?v>e?v:e:x>e?x:e,l=f>p?f>w?f>l?f:l:w>l?w:l:p>w?p>l?p:l:w>l?w:l);a()};this.addRectangle=function(h){k?(k=!1,c=h.getLeft(),b=h.getTop(),e=h.getRight(),l=h.getBottom()):(c=ch.getRight()?e:h.getRight(),l=l> @@ -28,16 +28,16 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,c= THREE.Matrix4=function(a,c,b,e,l,h,f,k,n,t,v,p,x,w,z,u){this.set(a!==void 0?a:1,c||0,b||0,e||0,l||0,h!==void 0?h:1,f||0,k||0,n||0,t||0,v!==void 0?v:1,p||0,x||0,w||0,z||0,u!==void 0?u:1);this.flat=Array(16);this.m33=new THREE.Matrix3}; THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,c,b,e,l,h,f,k,n,t,v,p,x,w,z,u){this.n11=a;this.n12=c;this.n13=b;this.n14=e;this.n21=l;this.n22=h;this.n23=f;this.n24=k;this.n31=n;this.n32=t;this.n33=v;this.n34=p;this.n41=x;this.n42=w;this.n43=z;this.n44=u;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(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a, c,b){var e=THREE.Matrix4.__v1,l=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(a,c).normalize();if(h.length()===0)h.z=1;e.cross(b,h).normalize();e.length()===0&&(h.x+=1.0E-4,e.cross(b,h).normalize());l.cross(h,e).normalize();this.n11=e.x;this.n12=l.x;this.n13=h.x;this.n21=e.y;this.n22=l.y;this.n23=h.y;this.n31=e.z;this.n32=l.z;this.n33=h.z;return this},multiply:function(a,c){var b=a.n11,e=a.n12,l=a.n13,h=a.n14,f=a.n21,k=a.n22,n=a.n23,t=a.n24,v=a.n31,p=a.n32,x=a.n33,w=a.n34,z=a.n41,u=a.n42,B=a.n43, -y=a.n44,E=c.n11,C=c.n12,H=c.n13,L=c.n14,R=c.n21,D=c.n22,O=c.n23,K=c.n24,N=c.n31,J=c.n32,M=c.n33,ea=c.n34,ja=c.n41,Y=c.n42,U=c.n43,o=c.n44;this.n11=b*E+e*R+l*N+h*ja;this.n12=b*C+e*D+l*J+h*Y;this.n13=b*H+e*O+l*M+h*U;this.n14=b*L+e*K+l*ea+h*o;this.n21=f*E+k*R+n*N+t*ja;this.n22=f*C+k*D+n*J+t*Y;this.n23=f*H+k*O+n*M+t*U;this.n24=f*L+k*K+n*ea+t*o;this.n31=v*E+p*R+x*N+w*ja;this.n32=v*C+p*D+x*J+w*Y;this.n33=v*H+p*O+x*M+w*U;this.n34=v*L+p*K+x*ea+w*o;this.n41=z*E+u*R+B*N+y*ja;this.n42=z*C+u*D+B*J+y*Y;this.n43= -z*H+u*O+B*M+y*U;this.n44=z*L+u*K+B*ea+y*o;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,c,b){this.multiply(a,c);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 this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*= -a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},multiplyVector3:function(a){var c=a.x,b=a.y,e=a.z,l=1/(this.n41*c+this.n42*b+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*e+this.n14)*l;a.y=(this.n21*c+this.n22*b+this.n23*e+this.n24)*l;a.z=(this.n31*c+this.n32*b+this.n33*e+this.n34)*l;return a},multiplyVector4:function(a){var c=a.x,b=a.y,e=a.z,l=a.w;a.x=this.n11*c+this.n12*b+this.n13*e+this.n14*l;a.y= -this.n21*c+this.n22*b+this.n23*e+this.n24*l;a.z=this.n31*c+this.n32*b+this.n33*e+this.n34*l;a.w=this.n41*c+this.n42*b+this.n43*e+this.n44*l;return a},rotateAxis:function(a){var c=a.x,b=a.y,e=a.z;a.x=c*this.n11+b*this.n12+e*this.n13;a.y=c*this.n21+b*this.n22+e*this.n23;a.z=c*this.n31+b*this.n32+e*this.n33;a.normalize();return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31* -a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},determinant:function(){var a=this.n11,c=this.n12,b=this.n13,e=this.n14,l=this.n21,h=this.n22,f=this.n23,k=this.n24,n=this.n31,t=this.n32,v=this.n33,p=this.n34,x=this.n41,w=this.n42,z=this.n43,u=this.n44;return e*f*t*x-b*k*t*x-e*h*v*x+c*k*v*x+b*h*p*x-c*f*p*x-e*f*n*w+b*k*n*w+e*l*v*w-a*k*v*w-b*l*p*w+a*f*p*w+e*h*n*z-c*k*n*z-e*l*t*z+a*k*t*z+c*l*p*z-a*h*p*z-b*h*n*u+c*f*n*u+b*l*t*u-a*f*t*u- -c*l*v*u+a*h*v*u},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33; -a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},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(a){a[0]= -this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]= -this.n34;a[c+15]=this.n44;return a},setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a),a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a),a=Math.sin(a);this.set(c,-a,0, -0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,c){var b=Math.cos(c),e=Math.sin(c),l=1-b,h=a.x,f=a.y,k=a.z,n=l*h,t=l*f;this.set(n*h+b,n*f-e*k,n*k+e*f,0,n*f+e*k,t*f+b,t*k-e*h,0,n*k-e*f,t*k+e*h,l*k*k+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12, +y=a.n44,E=c.n11,C=c.n12,H=c.n13,L=c.n14,R=c.n21,D=c.n22,O=c.n23,J=c.n24,N=c.n31,K=c.n32,M=c.n33,Y=c.n34,oa=c.n41,Z=c.n42,U=c.n43,o=c.n44;this.n11=b*E+e*R+l*N+h*oa;this.n12=b*C+e*D+l*K+h*Z;this.n13=b*H+e*O+l*M+h*U;this.n14=b*L+e*J+l*Y+h*o;this.n21=f*E+k*R+n*N+t*oa;this.n22=f*C+k*D+n*K+t*Z;this.n23=f*H+k*O+n*M+t*U;this.n24=f*L+k*J+n*Y+t*o;this.n31=v*E+p*R+x*N+w*oa;this.n32=v*C+p*D+x*K+w*Z;this.n33=v*H+p*O+x*M+w*U;this.n34=v*L+p*J+x*Y+w*o;this.n41=z*E+u*R+B*N+y*oa;this.n42=z*C+u*D+B*K+y*Z;this.n43=z* +H+u*O+B*M+y*U;this.n44=z*L+u*J+B*Y+y*o;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,c,b){this.multiply(a,c);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 this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*= +a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},multiplyVector3:function(a){var c=a.x,b=a.y,e=a.z,l=1/(this.n41*c+this.n42*b+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*b+this.n13*e+this.n14)*l;a.y=(this.n21*c+this.n22*b+this.n23*e+this.n24)*l;a.z=(this.n31*c+this.n32*b+this.n33*e+this.n34)*l;return a},multiplyVector4:function(a){var c=a.x,b=a.y,e=a.z,l=a.w;a.x=this.n11*c+this.n12*b+this.n13*e+this.n14*l;a.y=this.n21*c+this.n22* +b+this.n23*e+this.n24*l;a.z=this.n31*c+this.n32*b+this.n33*e+this.n34*l;a.w=this.n41*c+this.n42*b+this.n43*e+this.n44*l;return a},rotateAxis:function(a){var c=a.x,b=a.y,e=a.z;a.x=c*this.n11+b*this.n12+e*this.n13;a.y=c*this.n21+b*this.n22+e*this.n23;a.z=c*this.n31+b*this.n32+e*this.n33;a.normalize();return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33* +a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},determinant:function(){var a=this.n11,c=this.n12,b=this.n13,e=this.n14,l=this.n21,h=this.n22,f=this.n23,k=this.n24,n=this.n31,t=this.n32,v=this.n33,p=this.n34,x=this.n41,w=this.n42,z=this.n43,u=this.n44;return e*f*t*x-b*k*t*x-e*h*v*x+c*k*v*x+b*h*p*x-c*f*p*x-e*f*n*w+b*k*n*w+e*l*v*w-a*k*v*w-b*l*p*w+a*f*p*w+e*h*n*z-c*k*n*z-e*l*t*z+a*k*t*z+c*l*p*z-a*h*p*z-b*h*n*u+c*f*n*u+b*l*t*u-a*f*t*u-c*l*v*u+a*h*v*u},transpose:function(){var a; +a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42; +a.n43=this.n43;a.n44=this.n44;return a},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(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31; +a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,c){a[c]=this.n11;a[c+1]=this.n21;a[c+2]=this.n31;a[c+3]=this.n41;a[c+4]=this.n12;a[c+5]=this.n22;a[c+6]=this.n32;a[c+7]=this.n42;a[c+8]=this.n13;a[c+9]=this.n23;a[c+10]=this.n33;a[c+11]=this.n43;a[c+12]=this.n14;a[c+13]=this.n24;a[c+14]=this.n34;a[c+15]=this.n44;return a}, +setTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},setScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},setRotationX:function(a){var c=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotationY:function(a){var c=Math.cos(a),a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotationZ:function(a){var c=Math.cos(a),a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this}, +setRotationAxis:function(a,c){var b=Math.cos(c),e=Math.sin(c),l=1-b,h=a.x,f=a.y,k=a.z,n=l*h,t=l*f;this.set(n*h+b,n*f-e*k,n*k+e*f,0,n*f+e*k,t*f+b,t*k-e*h,0,n*k-e*f,t*k+e*h,l*k*k+b,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12, this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var c=a.n11,b=a.n12,e=a.n13,l=a.n14,h=a.n21,f=a.n22,k=a.n23,n=a.n24,t=a.n31,v=a.n32,p=a.n33,x=a.n34,w=a.n41,z=a.n42,u=a.n43,B=a.n44;this.n11=k*x*z-n*p*z+n*v*u-f*x*u-k*v*B+f*p*B;this.n12=l*p*z-e*x*z-l*v*u+b*x*u+e*v*B-b*p*B;this.n13=e*n*z-l*k*z+l*f*u-b*n*u-e*f*B+b*k*B;this.n14=l*k*v-e*n*v-l*f*p+b*n*p+e*f*x-b*k*x;this.n21=n*p*w-k*x*w-n*t*u+h*x*u+k*t*B-h*p*B;this.n22=e*x*w-l*p*w+ l*t*u-c*x*u-e*t*B+c*p*B;this.n23=l*k*w-e*n*w-l*h*u+c*n*u+e*h*B-c*k*B;this.n24=e*n*t-l*k*t+l*h*p-c*n*p-e*h*x+c*k*x;this.n31=f*x*w-n*v*w+n*t*z-h*x*z-f*t*B+h*v*B;this.n32=l*v*w-b*x*w-l*t*z+c*x*z+b*t*B-c*v*B;this.n33=e*n*w-l*f*w+l*h*z-c*n*z-b*h*B+c*f*B;this.n34=l*f*t-b*n*t-l*h*v+c*n*v+b*h*x-c*f*x;this.n41=k*v*w-f*p*w-k*t*z+h*p*z+f*t*u-h*v*u;this.n42=b*p*w-e*v*w+e*t*z-c*p*z-b*t*u+c*v*u;this.n43=e*f*w-b*k*w-e*h*z+c*k*z+b*h*u-c*f*u;this.n44=b*k*t-e*f*t+e*h*v-c*k*v-b*h*p+c*f*p;this.multiplyScalar(1/a.determinant()); return this},setRotationFromEuler:function(a,c){var b=a.x,e=a.y,l=a.z,h=Math.cos(b),b=Math.sin(b),f=Math.cos(e),e=Math.sin(e),k=Math.cos(l),l=Math.sin(l);switch(c){case "YXZ":var n=f*k,t=f*l,v=e*k,p=e*l;this.n11=n+p*b;this.n12=v*b-t;this.n13=h*e;this.n21=h*l;this.n22=h*k;this.n23=-b;this.n31=t*b-v;this.n32=p+n*b;this.n33=h*f;break;case "ZXY":n=f*k;t=f*l;v=e*k;p=e*l;this.n11=n-p*b;this.n12=-h*l;this.n13=v+t*b;this.n21=t+v*b;this.n22=h*k;this.n23=p-n*b;this.n31=-h*e;this.n32=b;this.n33=h*f;break;case "ZYX":n= @@ -56,18 +56,18 @@ THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,c){thi if(c&&(l=l.getChildByName(a,c),l!==void 0))return l}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){this.matrixAutoUpdate&& this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var c=0,b=this.children.length;c=0&&l>=0&&f>=0&&k>=0?!0:h<0&&l<0||f<0&&k<0?!1:(h<0?c=Math.max(c,h/(h-l)):l<0&&(e=Math.min(e,h/(h-l))),f<0?c=Math.max(c,f/(f-k)):k<0&&(e=Math.min(e,f/(f-k))),ef&&k.positionScreen.z0&&D.z<1))f=H[C]=H[C]||new THREE.RenderableParticle,C++,E=f,E.x=D.x/D.w,E.y=D.y/D.w,E.z=D.z,E.rotation=ia.rotation.z,E.scale.x=ia.scale.x*Math.abs(E.x-(D.x+h.projectionMatrix.n11)/(D.w+h.projectionMatrix.n14)),E.scale.y=ia.scale.y*Math.abs(E.y-(D.y+h.projectionMatrix.n22)/ -(D.w+h.projectionMatrix.n24)),E.material=ia.material,L.elements.push(E);l&&L.elements.sort(b);return L}};THREE.Quaternion=function(a,c,b,e){this.set(a||0,c||0,b||0,e!==void 0?e:1)}; +L.objects.sort(b);return L};this.projectScene=function(a,h,l){var f=h.near,o=h.far,R,N,G,W,$,la,ja,sa,T,ea,ga,na,ia,I,Q,ha;C=B=w=p=0;L.elements.length=0;h.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(h));a.updateMatrixWorld();h.matrixWorldInverse.getInverse(h.matrixWorld);O.multiply(h.projectionMatrix,h.matrixWorldInverse);this.computeFrustum(O);L=this.projectGraph(a,!1);a=0;for(R=L.objects.length;af&&k.positionScreen.z0&&D.z<1))f=H[C]=H[C]||new THREE.RenderableParticle,C++,E=f,E.x=D.x/D.w,E.y=D.y/D.w,E.z=D.z,E.rotation=T.rotation.z,E.scale.x=T.scale.x*Math.abs(E.x-(D.x+h.projectionMatrix.n11)/(D.w+h.projectionMatrix.n14)),E.scale.y=T.scale.y*Math.abs(E.y-(D.y+h.projectionMatrix.n22)/(D.w+h.projectionMatrix.n24)), +E.material=T.material,L.elements.push(E);l&&L.elements.sort(b);return L}};THREE.Quaternion=function(a,c,b,e){this.set(a||0,c||0,b||0,e!==void 0?e:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,c,b,e){this.x=a;this.y=c;this.z=b;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var c=Math.PI/360,b=a.x*c,e=a.y*c,l=a.z*c,a=Math.cos(e),e=Math.sin(e),c=Math.cos(-l),l=Math.sin(-l),h=Math.cos(b),b=Math.sin(b),f=a*c,k=e*l;this.w=f*h-k*b;this.x=f*b+k*h;this.y=e*c*h+a*l*b;this.z=a*l*h-e*c*b;return this},setFromAxisAngle:function(a,c){var b=c/2,e=Math.sin(b); this.x=a.x*e;this.y=a.y*e;this.z=a.z*e;this.w=Math.cos(b);return this},setFromRotationMatrix:function(a){var c=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,c+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,c-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,c-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var c= @@ -83,9 +83,9 @@ c;a++)b=this.faces[a],b.centroid.set(0,0,0),b instanceof THREE.Face3?(b.centroid b,e,l,h,f,k=new THREE.Vector3,n=new THREE.Vector3;e=0;for(l=this.faces.length;e0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, +b.vertexNormals[1].copy(e[b.b]),b.vertexNormals[2].copy(e[b.c]),b.vertexNormals[3].copy(e[b.d]))},computeTangents:function(){function a(a,b,c,e,h,l,U){k=a.vertices[b].position;n=a.vertices[c].position;t=a.vertices[e].position;v=f[h];p=f[l];x=f[U];w=n.x-k.x;z=t.x-k.x;u=n.y-k.y;B=t.y-k.y;y=n.z-k.z;E=t.z-k.z;C=p.u-v.u;H=x.u-v.u;L=p.v-v.v;R=x.v-v.v;D=1/(C*R-H*L);K.set((R*w-L*z)*D,(R*u-L*B)*D,(R*y-L*E)*D);M.set((C*z-H*w)*D,(C*B-H*u)*D,(C*E-H*y)*D);J[b].addSelf(K);J[c].addSelf(K);J[e].addSelf(K);N[b].addSelf(M); +N[c].addSelf(M);N[e].addSelf(M)}var c,b,e,l,h,f,k,n,t,v,p,x,w,z,u,B,y,E,C,H,L,R,D,O,J=[],N=[],K=new THREE.Vector3,M=new THREE.Vector3,Y=new THREE.Vector3,oa=new THREE.Vector3,Z=new THREE.Vector3;c=0;for(b=this.vertices.length;c0){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,b=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,c=0,b=this.vertices.length;c0&&(b(THREE.NormalBlending),c(1),l("rgba("+Math.floor(B.r*255)+","+Math.floor(B.g*255)+","+Math.floor(B.b*255)+","+y+")"),u.fillRect(Math.floor(V.getX()), -Math.floor(V.getY()),Math.floor(V.getWidth()),Math.floor(V.getHeight()))),V.empty())};this.render=function(a,v){function p(a){var b,c,e,h;oa.setRGB(0,0,0);ta.setRGB(0,0,0);ua.setRGB(0,0,0);b=0;for(c=a.length;b>1,va=t.height>> -1,f=h.scale.x*w,n=h.scale.y*z,k=f*v,o=n*va,aa.set(a.x-k,a.y-o,a.x+k,a.y+o),ca.intersects(aa)&&(u.save(),u.translate(a.x,a.y),u.rotate(-h.rotation),u.scale(f,-n),u.translate(-v,-va),u.drawImage(t,0,0),u.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*w,o=h.scale.y*z,aa.set(a.x-k,a.y-o,a.x+k,a.y+o),ca.intersects(aa)&&(e(f.color.getContextStyle()),l(f.color.getContextStyle()),u.save(),u.translate(a.x,a.y),u.rotate(-h.rotation),u.scale(k,o),f.program(u),u.restore()))}function y(a, -h,l,f){c(f.opacity);b(f.blending);u.beginPath();u.moveTo(a.positionScreen.x,a.positionScreen.y);u.lineTo(h.positionScreen.x,h.positionScreen.y);u.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(R!=a)u.lineWidth=R=a;a=f.linecap;if(D!=a)u.lineCap=D=a;a=f.linejoin;if(O!=a)u.lineJoin=O=a;e(f.color.getContextStyle());u.stroke();aa.inflate(f.linewidth*2)}}function Qa(a,e,f,l,k,t,w,p){h.info.render.vertices+=3;h.info.render.faces++;c(p.opacity);b(p.blending);Y=a.positionScreen.x;U= -a.positionScreen.y;o=e.positionScreen.x;P=e.positionScreen.y;pa=f.positionScreen.x;G=f.positionScreen.y;Na(Y,U,o,P,pa,G);if(p instanceof THREE.MeshBasicMaterial)if(p.map)p.map.mapping instanceof THREE.UVMapping&&(sa=w.uvs[0],Ra(Y,U,o,P,pa,G,sa[l].u,sa[l].v,sa[k].u,sa[k].v,sa[t].u,sa[t].v,p.map));else if(p.envMap){if(p.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=v.matrixWorldInverse,X.copy(w.vertexNormalsWorld[l]),qa=(X.x*a.n11+X.y*a.n12+X.z*a.n13)*0.5+0.5,Ea=-(X.x*a.n21+X.y*a.n22+ -X.z*a.n23)*0.5+0.5,X.copy(w.vertexNormalsWorld[k]),ya=(X.x*a.n11+X.y*a.n12+X.z*a.n13)*0.5+0.5,Aa=-(X.x*a.n21+X.y*a.n22+X.z*a.n23)*0.5+0.5,X.copy(w.vertexNormalsWorld[t]),Ja=(X.x*a.n11+X.y*a.n12+X.z*a.n13)*0.5+0.5,Z=-(X.x*a.n21+X.y*a.n22+X.z*a.n23)*0.5+0.5,Ra(Y,U,o,P,pa,G,qa,Ea,ya,Aa,Ja,Z,p.envMap)}else p.wireframe?H(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(p.color);else if(p instanceof THREE.MeshLambertMaterial)p.map&&!p.wireframe&&(p.map.mapping instanceof THREE.UVMapping&& -(sa=w.uvs[0],Ra(Y,U,o,P,pa,G,sa[l].u,sa[l].v,sa[k].u,sa[k].v,sa[t].u,sa[t].v,p.map)),b(THREE.SubtractiveBlending)),ga?!p.wireframe&&p.shading==THREE.SmoothShading&&w.vertexNormalsWorld.length==3?(S.r=fa.r=ha.r=oa.r,S.g=fa.g=ha.g=oa.g,S.b=fa.b=ha.b=oa.b,x(n,w.v1.positionWorld,w.vertexNormalsWorld[0],S),x(n,w.v2.positionWorld,w.vertexNormalsWorld[1],fa),x(n,w.v3.positionWorld,w.vertexNormalsWorld[2],ha),S.r=Math.max(0,Math.min(p.color.r*S.r,1)),S.g=Math.max(0,Math.min(p.color.g*S.g,1)),S.b=Math.max(0, -Math.min(p.color.b*S.b,1)),fa.r=Math.max(0,Math.min(p.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(p.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(p.color.b*fa.b,1)),ha.r=Math.max(0,Math.min(p.color.r*ha.r,1)),ha.g=Math.max(0,Math.min(p.color.g*ha.g,1)),ha.b=Math.max(0,Math.min(p.color.b*ha.b,1)),I.r=(fa.r+ha.r)*0.5,I.g=(fa.g+ha.g)*0.5,I.b=(fa.b+ha.b)*0.5,wa=Oa(S,fa,ha,I),L(Y,U,o,P,pa,G,0,0,1,0,0,1,wa)):(da.r=oa.r,da.g=oa.g,da.b=oa.b,x(n,w.centroidWorld,w.normalWorld,da),da.r=Math.max(0,Math.min(p.color.r* -da.r,1)),da.g=Math.max(0,Math.min(p.color.g*da.g,1)),da.b=Math.max(0,Math.min(p.color.b*da.b,1)),p.wireframe?H(da,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(da)):p.wireframe?H(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(p.color);else if(p instanceof THREE.MeshDepthMaterial)ka=v.near,ma=v.far,S.r=S.g=S.b=1-La(a.positionScreen.z,ka,ma),fa.r=fa.g=fa.b=1-La(e.positionScreen.z,ka,ma),ha.r=ha.g=ha.b=1-La(f.positionScreen.z,ka,ma),I.r=(fa.r+ha.r)*0.5,I.g= -(fa.g+ha.g)*0.5,I.b=(fa.b+ha.b)*0.5,wa=Oa(S,fa,ha,I),L(Y,U,o,P,pa,G,0,0,1,0,0,1,wa);else if(p instanceof THREE.MeshNormalMaterial)da.r=Ma(w.normalWorld.x),da.g=Ma(w.normalWorld.y),da.b=Ma(w.normalWorld.z),p.wireframe?H(da,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(da)}function C(a,e,f,l,k,t,w,p,u){h.info.render.vertices+=4;h.info.render.faces++;c(p.opacity);b(p.blending);if(p.map||p.envMap)Qa(a,e,l,0,1,3,w,p,u),Qa(k,f,t,1,2,3,w,p,u);else if(Y=a.positionScreen.x,U=a.positionScreen.y, -o=e.positionScreen.x,P=e.positionScreen.y,pa=f.positionScreen.x,G=f.positionScreen.y,W=l.positionScreen.x,$=l.positionScreen.y,na=k.positionScreen.x,la=k.positionScreen.y,ra=t.positionScreen.x,ia=t.positionScreen.y,p instanceof THREE.MeshBasicMaterial)E(Y,U,o,P,pa,G,W,$),p.wireframe?H(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(p.color);else if(p instanceof THREE.MeshLambertMaterial)ga?!p.wireframe&&p.shading==THREE.SmoothShading&&w.vertexNormalsWorld.length==4?(S.r=fa.r= -ha.r=I.r=oa.r,S.g=fa.g=ha.g=I.g=oa.g,S.b=fa.b=ha.b=I.b=oa.b,x(n,w.v1.positionWorld,w.vertexNormalsWorld[0],S),x(n,w.v2.positionWorld,w.vertexNormalsWorld[1],fa),x(n,w.v4.positionWorld,w.vertexNormalsWorld[3],ha),x(n,w.v3.positionWorld,w.vertexNormalsWorld[2],I),S.r=Math.max(0,Math.min(p.color.r*S.r,1)),S.g=Math.max(0,Math.min(p.color.g*S.g,1)),S.b=Math.max(0,Math.min(p.color.b*S.b,1)),fa.r=Math.max(0,Math.min(p.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(p.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(p.color.b* -fa.b,1)),ha.r=Math.max(0,Math.min(p.color.r*ha.r,1)),ha.g=Math.max(0,Math.min(p.color.g*ha.g,1)),ha.b=Math.max(0,Math.min(p.color.b*ha.b,1)),I.r=Math.max(0,Math.min(p.color.r*I.r,1)),I.g=Math.max(0,Math.min(p.color.g*I.g,1)),I.b=Math.max(0,Math.min(p.color.b*I.b,1)),wa=Oa(S,fa,ha,I),Na(Y,U,o,P,W,$),L(Y,U,o,P,W,$,0,0,1,0,0,1,wa),Na(na,la,pa,G,ra,ia),L(na,la,pa,G,ra,ia,1,0,1,1,0,1,wa)):(da.r=oa.r,da.g=oa.g,da.b=oa.b,x(n,w.centroidWorld,w.normalWorld,da),da.r=Math.max(0,Math.min(p.color.r*da.r,1)),da.g= -Math.max(0,Math.min(p.color.g*da.g,1)),da.b=Math.max(0,Math.min(p.color.b*da.b,1)),E(Y,U,o,P,pa,G,W,$),p.wireframe?H(da,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(da)):(E(Y,U,o,P,pa,G,W,$),p.wireframe?H(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Da(p.color));else if(p instanceof THREE.MeshNormalMaterial)da.r=Ma(w.normalWorld.x),da.g=Ma(w.normalWorld.y),da.b=Ma(w.normalWorld.z),E(Y,U,o,P,pa,G,W,$),p.wireframe?H(da,p.wireframeLinewidth,p.wireframeLinecap, -p.wireframeLinejoin):Da(da);else if(p instanceof THREE.MeshDepthMaterial)ka=v.near,ma=v.far,S.r=S.g=S.b=1-La(a.positionScreen.z,ka,ma),fa.r=fa.g=fa.b=1-La(e.positionScreen.z,ka,ma),ha.r=ha.g=ha.b=1-La(l.positionScreen.z,ka,ma),I.r=I.g=I.b=1-La(f.positionScreen.z,ka,ma),wa=Oa(S,fa,ha,I),Na(Y,U,o,P,W,$),L(Y,U,o,P,W,$,0,0,1,0,0,1,wa),Na(na,la,pa,G,ra,ia),L(na,la,pa,G,ra,ia,1,0,1,1,0,1,wa)}function Na(a,b,c,e,h,f){u.beginPath();u.moveTo(a,b);u.lineTo(c,e);u.lineTo(h,f);u.lineTo(a,b);u.closePath()}function E(a, -b,c,e,h,f,l,k){u.beginPath();u.moveTo(a,b);u.lineTo(c,e);u.lineTo(h,f);u.lineTo(l,k);u.lineTo(a,b);u.closePath()}function H(a,b,c,h){if(R!=b)u.lineWidth=R=b;if(D!=c)u.lineCap=D=c;if(O!=h)u.lineJoin=O=h;e(a.getContextStyle());u.stroke();aa.inflate(b*2)}function Da(a){l(a.getContextStyle());u.fill()}function Ra(a,b,c,e,h,f,k,o,n,p,t,w,v){if(v.image.width!=0){if(v.needsUpdate==!0||Q[v.id]==void 0){var va=v.wrapS==THREE.RepeatWrapping,x=v.wrapT==THREE.RepeatWrapping;Q[v.id]=u.createPattern(v.image,va&& -x?"repeat":va&&!x?"repeat-x":!va&&x?"repeat-y":"no-repeat");v.needsUpdate=!1}l(Q[v.id]);var va=v.offset.x/v.repeat.x,x=v.offset.y/v.repeat.y,Z=(v.image.width-1)*v.repeat.x,v=(v.image.height-1)*v.repeat.y,k=(k+va)*Z,o=(o+x)*v,n=(n+va)*Z,p=(p+x)*v,t=(t+va)*Z,w=(w+x)*v;c-=a;e-=b;h-=a;f-=b;n-=k;p-=o;t-=k;w-=o;va=1/(n*w-t*p);v=(w*c-p*h)*va;p=(w*e-p*f)*va;c=(n*h-t*c)*va;e=(n*f-t*e)*va;a=a-v*k-c*o;b=b-p*k-e*o;u.save();u.transform(v,p,c,e,a,b);u.fill();u.restore()}}function L(a,b,c,e,h,f,l,k,o,n,p,t,w){var v, -va;v=w.width-1;va=w.height-1;l*=v;k*=va;o*=v;n*=va;p*=v;t*=va;c-=a;e-=b;h-=a;f-=b;o-=l;n-=k;p-=l;t-=k;va=1/(o*t-p*n);v=(t*c-n*h)*va;n=(t*e-n*f)*va;c=(o*h-p*c)*va;e=(o*f-p*e)*va;a=a-v*l-c*k;b=b-n*l-e*k;u.save();u.transform(v,n,c,e,a,b);u.clip();u.drawImage(w,0,0);u.restore()}function Oa(a,b,c,e){var h=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),l=~~(b.r*255),k=~~(b.g*255),b=~~(b.b*255),o=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),p=~~(e.r*255),t=~~(e.g*255),e=~~(e.b*255);xa[0]=h<0?0:h>255?255:h;xa[1]=f<0? -0:f>255?255:f;xa[2]=a<0?0:a>255?255:a;xa[4]=l<0?0:l>255?255:l;xa[5]=k<0?0:k>255?255:k;xa[6]=b<0?0:b>255?255:b;xa[8]=o<0?0:o>255?255:o;xa[9]=n<0?0:n>255?255:n;xa[10]=c<0?0:c>255?255:c;xa[12]=p<0?0:p>255?255:p;xa[13]=t<0?0:t>255?255:t;xa[14]=e<0?0:e>255?255:e;Ha.putImageData(Fa,0,0);T.drawImage(Ba,0,0);return Ca}function La(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ma(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Ka(a,b){var c=b.x-a.x,e=b.y-a.y,h=c*c+e*e;h!=0&&(h=1/Math.sqrt(h),c*=h,e*=h,b.x+= -c,b.y+=e,a.x-=c,a.y-=e)}var Pa,Sa,za,Ia;this.autoClear?this.clear():u.setTransform(1,0,0,-1,w,z);h.info.render.vertices=0;h.info.render.faces=0;f=t.projectScene(a,v,this.sortElements);k=f.elements;n=f.lights;(ga=n.length>0)&&p(n);Pa=0;for(Sa=k.length;Pa1?1:a}var e=this,l,h,f,k=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),t,v,p,x,w,z,u,B,y=new THREE.Rectangle,E=new THREE.Rectangle,C=!1,H=new THREE.Color,L=new THREE.Color,R=new THREE.Color,D=new THREE.Color,O,K=new THREE.Vector3,N=[],J=[],M,ea,ja,Y=1;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0, -faces:0}};this.setQuality=function(a){switch(a){case "high":Y=1;break;case "low":Y=0}};this.setSize=function(a,b){t=a;v=b;p=t/2;x=v/2;n.setAttribute("viewBox",-p+" "+-x+" "+t+" "+v);n.setAttribute("width",t);n.setAttribute("height",v);y.set(-p,-x,p,x)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render=function(t,o){var v,K,G,W;this.autoClear&&this.clear();e.info.render.vertices=0;e.info.render.faces=0;l=k.projectScene(t,o,this.sortElements);h=l.elements; -f=l.lights;ja=ea=0;if(C=f.length>0){L.setRGB(0,0,0);R.setRGB(0,0,0);D.setRGB(0,0,0);v=0;for(K=f.length;v>1,xa= +t.height>>1,f=h.scale.x*w,n=h.scale.y*z,k=f*v,o=n*xa,aa.set(a.x-k,a.y-o,a.x+k,a.y+o),ca.intersects(aa)&&(u.save(),u.translate(a.x,a.y),u.rotate(-h.rotation),u.scale(f,-n),u.translate(-v,-xa),u.drawImage(t,0,0),u.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(k=h.scale.x*w,o=h.scale.y*z,aa.set(a.x-k,a.y-o,a.x+k,a.y+o),ca.intersects(aa)&&(e(f.color.getContextStyle()),l(f.color.getContextStyle()),u.save(),u.translate(a.x,a.y),u.rotate(-h.rotation),u.scale(k,o),f.program(u),u.restore()))} +function y(a,h,l,f){c(f.opacity);b(f.blending);u.beginPath();u.moveTo(a.positionScreen.x,a.positionScreen.y);u.lineTo(h.positionScreen.x,h.positionScreen.y);u.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(R!=a)u.lineWidth=R=a;a=f.linecap;if(D!=a)u.lineCap=D=a;a=f.linejoin;if(O!=a)u.lineJoin=O=a;e(f.color.getContextStyle());u.stroke();aa.inflate(f.linewidth*2)}}function Qa(a,e,f,l,k,t,w,p){h.info.render.vertices+=3;h.info.render.faces++;c(p.opacity);b(p.blending);Z=a.positionScreen.x; +U=a.positionScreen.y;o=e.positionScreen.x;P=e.positionScreen.y;ra=f.positionScreen.x;G=f.positionScreen.y;Na(Z,U,o,P,ra,G);if(p instanceof THREE.MeshBasicMaterial)if(p.map)p.map.mapping instanceof THREE.UVMapping&&(va=w.uvs[0],Ra(Z,U,o,P,ra,G,va[l].u,va[l].v,va[k].u,va[k].v,va[t].u,va[t].v,p.map));else if(p.envMap){if(p.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=v.matrixWorldInverse,qa.copy(w.vertexNormalsWorld[l]),Ca=(qa.x*a.n11+qa.y*a.n12+qa.z*a.n13)*0.5+0.5,Ga=-(qa.x*a.n21+qa.y* +a.n22+qa.z*a.n23)*0.5+0.5,qa.copy(w.vertexNormalsWorld[k]),ya=(qa.x*a.n11+qa.y*a.n12+qa.z*a.n13)*0.5+0.5,Aa=-(qa.x*a.n21+qa.y*a.n22+qa.z*a.n23)*0.5+0.5,qa.copy(w.vertexNormalsWorld[t]),Ja=(qa.x*a.n11+qa.y*a.n12+qa.z*a.n13)*0.5+0.5,X=-(qa.x*a.n21+qa.y*a.n22+qa.z*a.n23)*0.5+0.5,Ra(Z,U,o,P,ra,G,Ca,Ga,ya,Aa,Ja,X,p.envMap)}else p.wireframe?H(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Fa(p.color);else if(p instanceof THREE.MeshLambertMaterial)p.map&&!p.wireframe&&(p.map.mapping instanceof +THREE.UVMapping&&(va=w.uvs[0],Ra(Z,U,o,P,ra,G,va[l].u,va[l].v,va[k].u,va[k].v,va[t].u,va[t].v,p.map)),b(THREE.SubtractiveBlending)),fa?!p.wireframe&&p.shading==THREE.SmoothShading&&w.vertexNormalsWorld.length==3?(ga.r=na.r=ia.r=ma.r,ga.g=na.g=ia.g=ma.g,ga.b=na.b=ia.b=ma.b,x(n,w.v1.positionWorld,w.vertexNormalsWorld[0],ga),x(n,w.v2.positionWorld,w.vertexNormalsWorld[1],na),x(n,w.v3.positionWorld,w.vertexNormalsWorld[2],ia),ga.r=Math.max(0,Math.min(p.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(p.color.g* +ga.g,1)),ga.b=Math.max(0,Math.min(p.color.b*ga.b,1)),na.r=Math.max(0,Math.min(p.color.r*na.r,1)),na.g=Math.max(0,Math.min(p.color.g*na.g,1)),na.b=Math.max(0,Math.min(p.color.b*na.b,1)),ia.r=Math.max(0,Math.min(p.color.r*ia.r,1)),ia.g=Math.max(0,Math.min(p.color.g*ia.g,1)),ia.b=Math.max(0,Math.min(p.color.b*ia.b,1)),I.r=(na.r+ia.r)*0.5,I.g=(na.g+ia.g)*0.5,I.b=(na.b+ia.b)*0.5,ua=Oa(ga,na,ia,I),L(Z,U,o,P,ra,G,0,0,1,0,0,1,ua)):(ea.r=ma.r,ea.g=ma.g,ea.b=ma.b,x(n,w.centroidWorld,w.normalWorld,ea),ea.r= +Math.max(0,Math.min(p.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(p.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(p.color.b*ea.b,1)),p.wireframe?H(ea,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Fa(ea)):p.wireframe?H(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Fa(p.color);else if(p instanceof THREE.MeshDepthMaterial)ha=v.near,ka=v.far,ga.r=ga.g=ga.b=1-La(a.positionScreen.z,ha,ka),na.r=na.g=na.b=1-La(e.positionScreen.z,ha,ka),ia.r=ia.g=ia.b=1-La(f.positionScreen.z, +ha,ka),I.r=(na.r+ia.r)*0.5,I.g=(na.g+ia.g)*0.5,I.b=(na.b+ia.b)*0.5,ua=Oa(ga,na,ia,I),L(Z,U,o,P,ra,G,0,0,1,0,0,1,ua);else if(p instanceof THREE.MeshNormalMaterial)ea.r=Ma(w.normalWorld.x),ea.g=Ma(w.normalWorld.y),ea.b=Ma(w.normalWorld.z),p.wireframe?H(ea,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Fa(ea)}function C(a,e,f,l,k,t,w,p,u){h.info.render.vertices+=4;h.info.render.faces++;c(p.opacity);b(p.blending);if(p.map||p.envMap)Qa(a,e,l,0,1,3,w,p,u),Qa(k,f,t,1,2,3,w,p,u);else if(Z=a.positionScreen.x, +U=a.positionScreen.y,o=e.positionScreen.x,P=e.positionScreen.y,ra=f.positionScreen.x,G=f.positionScreen.y,W=l.positionScreen.x,$=l.positionScreen.y,la=k.positionScreen.x,ja=k.positionScreen.y,sa=t.positionScreen.x,T=t.positionScreen.y,p instanceof THREE.MeshBasicMaterial)E(Z,U,o,P,ra,G,W,$),p.wireframe?H(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Fa(p.color);else if(p instanceof THREE.MeshLambertMaterial)fa?!p.wireframe&&p.shading==THREE.SmoothShading&&w.vertexNormalsWorld.length== +4?(ga.r=na.r=ia.r=I.r=ma.r,ga.g=na.g=ia.g=I.g=ma.g,ga.b=na.b=ia.b=I.b=ma.b,x(n,w.v1.positionWorld,w.vertexNormalsWorld[0],ga),x(n,w.v2.positionWorld,w.vertexNormalsWorld[1],na),x(n,w.v4.positionWorld,w.vertexNormalsWorld[3],ia),x(n,w.v3.positionWorld,w.vertexNormalsWorld[2],I),ga.r=Math.max(0,Math.min(p.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(p.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(p.color.b*ga.b,1)),na.r=Math.max(0,Math.min(p.color.r*na.r,1)),na.g=Math.max(0,Math.min(p.color.g*na.g,1)),na.b= +Math.max(0,Math.min(p.color.b*na.b,1)),ia.r=Math.max(0,Math.min(p.color.r*ia.r,1)),ia.g=Math.max(0,Math.min(p.color.g*ia.g,1)),ia.b=Math.max(0,Math.min(p.color.b*ia.b,1)),I.r=Math.max(0,Math.min(p.color.r*I.r,1)),I.g=Math.max(0,Math.min(p.color.g*I.g,1)),I.b=Math.max(0,Math.min(p.color.b*I.b,1)),ua=Oa(ga,na,ia,I),Na(Z,U,o,P,W,$),L(Z,U,o,P,W,$,0,0,1,0,0,1,ua),Na(la,ja,ra,G,sa,T),L(la,ja,ra,G,sa,T,1,0,1,1,0,1,ua)):(ea.r=ma.r,ea.g=ma.g,ea.b=ma.b,x(n,w.centroidWorld,w.normalWorld,ea),ea.r=Math.max(0, +Math.min(p.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(p.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(p.color.b*ea.b,1)),E(Z,U,o,P,ra,G,W,$),p.wireframe?H(ea,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Fa(ea)):(E(Z,U,o,P,ra,G,W,$),p.wireframe?H(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Fa(p.color));else if(p instanceof THREE.MeshNormalMaterial)ea.r=Ma(w.normalWorld.x),ea.g=Ma(w.normalWorld.y),ea.b=Ma(w.normalWorld.z),E(Z,U,o,P,ra,G,W,$),p.wireframe?H(ea,p.wireframeLinewidth, +p.wireframeLinecap,p.wireframeLinejoin):Fa(ea);else if(p instanceof THREE.MeshDepthMaterial)ha=v.near,ka=v.far,ga.r=ga.g=ga.b=1-La(a.positionScreen.z,ha,ka),na.r=na.g=na.b=1-La(e.positionScreen.z,ha,ka),ia.r=ia.g=ia.b=1-La(l.positionScreen.z,ha,ka),I.r=I.g=I.b=1-La(f.positionScreen.z,ha,ka),ua=Oa(ga,na,ia,I),Na(Z,U,o,P,W,$),L(Z,U,o,P,W,$,0,0,1,0,0,1,ua),Na(la,ja,ra,G,sa,T),L(la,ja,ra,G,sa,T,1,0,1,1,0,1,ua)}function Na(a,b,c,e,h,f){u.beginPath();u.moveTo(a,b);u.lineTo(c,e);u.lineTo(h,f);u.lineTo(a, +b);u.closePath()}function E(a,b,c,e,h,f,l,k){u.beginPath();u.moveTo(a,b);u.lineTo(c,e);u.lineTo(h,f);u.lineTo(l,k);u.lineTo(a,b);u.closePath()}function H(a,b,c,h){if(R!=b)u.lineWidth=R=b;if(D!=c)u.lineCap=D=c;if(O!=h)u.lineJoin=O=h;e(a.getContextStyle());u.stroke();aa.inflate(b*2)}function Fa(a){l(a.getContextStyle());u.fill()}function Ra(a,b,c,e,h,f,k,o,n,p,t,w,v){if(v.image.width!=0){if(v.needsUpdate==!0||Q[v.id]==void 0){var xa=v.wrapS==THREE.RepeatWrapping,x=v.wrapT==THREE.RepeatWrapping;Q[v.id]= +u.createPattern(v.image,xa&&x?"repeat":xa&&!x?"repeat-x":!xa&&x?"repeat-y":"no-repeat");v.needsUpdate=!1}l(Q[v.id]);var xa=v.offset.x/v.repeat.x,x=v.offset.y/v.repeat.y,X=(v.image.width-1)*v.repeat.x,v=(v.image.height-1)*v.repeat.y,k=(k+xa)*X,o=(o+x)*v,n=(n+xa)*X,p=(p+x)*v,t=(t+xa)*X,w=(w+x)*v;c-=a;e-=b;h-=a;f-=b;n-=k;p-=o;t-=k;w-=o;xa=1/(n*w-t*p);v=(w*c-p*h)*xa;p=(w*e-p*f)*xa;c=(n*h-t*c)*xa;e=(n*f-t*e)*xa;a=a-v*k-c*o;b=b-p*k-e*o;u.save();u.transform(v,p,c,e,a,b);u.fill();u.restore()}}function L(a, +b,c,e,h,f,l,k,o,n,p,t,w){var v,xa;v=w.width-1;xa=w.height-1;l*=v;k*=xa;o*=v;n*=xa;p*=v;t*=xa;c-=a;e-=b;h-=a;f-=b;o-=l;n-=k;p-=l;t-=k;xa=1/(o*t-p*n);v=(t*c-n*h)*xa;n=(t*e-n*f)*xa;c=(o*h-p*c)*xa;e=(o*f-p*e)*xa;a=a-v*l-c*k;b=b-n*l-e*k;u.save();u.transform(v,n,c,e,a,b);u.clip();u.drawImage(w,0,0);u.restore()}function Oa(a,b,c,e){var h=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),l=~~(b.r*255),k=~~(b.g*255),b=~~(b.b*255),o=~~(c.r*255),n=~~(c.g*255),c=~~(c.b*255),p=~~(e.r*255),t=~~(e.g*255),e=~~(e.b*255);za[0]= +h<0?0:h>255?255:h;za[1]=f<0?0:f>255?255:f;za[2]=a<0?0:a>255?255:a;za[4]=l<0?0:l>255?255:l;za[5]=k<0?0:k>255?255:k;za[6]=b<0?0:b>255?255:b;za[8]=o<0?0:o>255?255:o;za[9]=n<0?0:n>255?255:n;za[10]=c<0?0:c>255?255:c;za[12]=p<0?0:p>255?255:p;za[13]=t<0?0:t>255?255:t;za[14]=e<0?0:e>255?255:e;Da.putImageData(Ha,0,0);S.drawImage(ta,0,0);return Ea}function La(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Ma(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function Ka(a,b){var c=b.x-a.x,e=b.y-a.y,h=c*c+e*e;h!=0&&(h=1/ +Math.sqrt(h),c*=h,e*=h,b.x+=c,b.y+=e,a.x-=c,a.y-=e)}var Pa,Ta,Ba,Ia;this.autoClear?this.clear():u.setTransform(1,0,0,-1,w,z);h.info.render.vertices=0;h.info.render.faces=0;f=t.projectScene(a,v,this.sortElements);k=f.elements;n=f.lights;(fa=n.length>0)&&p(n);Pa=0;for(Ta=k.length;Pa1?1:a}var e=this,l,h,f,k=new THREE.Projector,n=document.createElementNS("http://www.w3.org/2000/svg","svg"),t,v,p,x,w,z,u,B,y=new THREE.Rectangle,E=new THREE.Rectangle,C=!1,H=new THREE.Color,L=new THREE.Color,R=new THREE.Color,D=new THREE.Color,O,J=new THREE.Vector3,N=[],K=[],M,Y,oa,Z=1;this.domElement=n;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0, +faces:0}};this.setQuality=function(a){switch(a){case "high":Z=1;break;case "low":Z=0}};this.setSize=function(a,b){t=a;v=b;p=t/2;x=v/2;n.setAttribute("viewBox",-p+" "+-x+" "+t+" "+v);n.setAttribute("width",t);n.setAttribute("height",v);y.set(-p,-x,p,x)};this.clear=function(){for(;n.childNodes.length>0;)n.removeChild(n.childNodes[0])};this.render=function(t,o){var v,J,G,W;this.autoClear&&this.clear();e.info.render.vertices=0;e.info.render.faces=0;l=k.projectScene(t,o,this.sortElements);h=l.elements; +f=l.lights;oa=Y=0;if(C=f.length>0){L.setRGB(0,0,0);R.setRGB(0,0,0);D.setRGB(0,0,0);v=0;for(J=f.length;v=0)return a.geometry.materials[b.materialIndex]}function e(a,b,c){var e,h,f,l=a.vertices,k=l.length,n=a.colors,p=n.length,t=a.__vertexArray,w=a.__colorArray,v=a.__sortArray,u=a.__dirtyVertices,x=a.__dirtyColors,Z=a.__webglCustomAttributesList;if(c.sortParticles){qa.multiplySelf(c.matrixWorld);for(e=0;e=0)return a.geometry.materials[b.materialIndex]}function e(a,b,c){var e,h,f,l=a.vertices,k=l.length,n=a.colors,p=n.length,t=a.__vertexArray,w=a.__colorArray,v=a.__sortArray,u=a.__dirtyVertices,x=a.__dirtyColors,X=a.__webglCustomAttributesList;if(c.sortParticles){Ca.multiplySelf(c.matrixWorld);for(e=0;e= 0)b&&(o.bindBuffer(o.ARRAY_BUFFER,f.__webglVertexBuffer),o.vertexAttribPointer(a.position,3,o.FLOAT,!1,0,0));else if(h.morphTargetBase){c=e.program.attributes;h.morphTargetBase!==-1?(o.bindBuffer(o.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[h.morphTargetBase]),o.vertexAttribPointer(c.position,3,o.FLOAT,!1,0,0)):c.position>=0&&(o.bindBuffer(o.ARRAY_BUFFER,f.__webglVertexBuffer),o.vertexAttribPointer(c.position,3,o.FLOAT,!1,0,0));if(h.morphTargetForcedOrder.length){k=0;var p=h.morphTargetForcedOrder; for(n=h.morphTargetInfluences;kt&&(w=v,t=n[w]);o.bindBuffer(o.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[w]); @@ -250,104 +250,105 @@ o.disableVertexAttribArray(a.uv));a.uv2>=0&&(f.__webglUV2Buffer?(o.bindBuffer(o. 4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),o.vertexAttribPointer(a.skinIndex,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),o.vertexAttribPointer(a.skinWeight,4,o.FLOAT,!1,0,0))}h instanceof THREE.Mesh?(e.wireframe?(o.lineWidth(e.wireframeLinewidth),b&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),o.drawElements(o.LINES,f.__webglLineCount,o.UNSIGNED_SHORT,0)):(b&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),o.drawElements(o.TRIANGLES, f.__webglFaceCount,o.UNSIGNED_SHORT,0)),U.info.render.calls++,U.info.render.vertices+=f.__webglFaceCount,U.info.render.faces+=f.__webglFaceCount/3):h instanceof THREE.Line?(h=h.type===THREE.LineStrip?o.LINE_STRIP:o.LINES,o.lineWidth(e.linewidth),o.drawArrays(h,0,f.__webglLineCount),U.info.render.calls++):h instanceof THREE.ParticleSystem?(o.drawArrays(o.POINTS,0,f.__webglParticleCount),U.info.render.calls++):h instanceof THREE.Ribbon&&(o.drawArrays(o.TRIANGLE_STRIP,0,f.__webglVertexCount),U.info.render.calls++)}} function f(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=o.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=o.createBuffer();a.hasPos&&(o.bindBuffer(o.ARRAY_BUFFER,a.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,a.positionArray,o.DYNAMIC_DRAW),o.enableVertexAttribArray(b.attributes.position),o.vertexAttribPointer(b.attributes.position,3,o.FLOAT,!1,0,0));if(a.hasNormal){o.bindBuffer(o.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var e,f,h,l,k,n,p,t,w,v,u= -a.count*3;for(v=0;v=0)b=b.geometry.materials[c],b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}else if(b=e)b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function u(a,b){return b.z- -a.z}function B(a){var b,c,e,t=0,w,v,u,Z,z=a.lights;ua||(ua=new THREE.PerspectiveCamera(U.shadowCameraFov,U.shadowMapWidth/U.shadowMapHeight,U.shadowCameraNear,U.shadowCameraFar));b=0;for(c=z.length;b=0)b=b.geometry.materials[c],b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}else if(b=e)b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function u(a,b){return b.z- +a.z}function B(a){var b,c,e,t=0,w,v,u,X,z=a.lights;pa||(pa=new THREE.PerspectiveCamera(U.shadowCameraFov,U.shadowMapWidth/U.shadowMapHeight,U.shadowCameraNear,U.shadowCameraFar));b=0;for(c=z.length;b=0;c--)a[c].object===b&&a.splice(c,1)}function R(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function D(a){if(a!==ia){switch(a){case THREE.AdditiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE);break;case THREE.SubtractiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO, -o.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.SRC_COLOR);break;default:o.blendEquationSeparate(o.FUNC_ADD,o.FUNC_ADD),o.blendFuncSeparate(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA)}ia=a}}function O(a,b,c){(c.width&c.width-1)===0&&(c.height&c.height-1)===0?(o.texParameteri(a,o.TEXTURE_WRAP_S,Y(b.wrapS)),o.texParameteri(a,o.TEXTURE_WRAP_T,Y(b.wrapT)),o.texParameteri(a,o.TEXTURE_MAG_FILTER,Y(b.magFilter)),o.texParameteri(a, -o.TEXTURE_MIN_FILTER,Y(b.minFilter)),o.generateMipmap(a)):(o.texParameteri(a,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(a,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(a,o.TEXTURE_MAG_FILTER,ja(b.magFilter)),o.texParameteri(a,o.TEXTURE_MIN_FILTER,ja(b.minFilter)))}function K(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=o.createTexture(),U.info.memory.textures++;o.activeTexture(o.TEXTURE0+b);o.bindTexture(o.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture? -o.texImage2D(o.TEXTURE_2D,0,Y(a.format),a.image.width,a.image.height,0,Y(a.format),o.UNSIGNED_BYTE,a.image.data):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,a.image);O(o.TEXTURE_2D,a,a.image);a.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+b),o.bindTexture(o.TEXTURE_2D,a.__webglTexture)}function N(a,b){o.bindRenderbuffer(o.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_COMPONENT16,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER, -o.DEPTH_ATTACHMENT,o.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,a)):o.renderbufferStorage(o.RENDERBUFFER,o.RGBA4,b.width,b.height)}function J(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=o.createTexture(); -if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];o.bindTexture(o.TEXTURE_CUBE_MAP,a.__webglTexture);O(o.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=o.createFramebuffer();a.__webglRenderbuffer[c]=o.createRenderbuffer();o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,Y(a.format),a.width,a.height,0,Y(a.format),Y(a.type),null);var e=a,f=o.TEXTURE_CUBE_MAP_POSITIVE_X+c;o.bindFramebuffer(o.FRAMEBUFFER,a.__webglFramebuffer[c]);o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0, -f,e.__webglTexture,0);N(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=o.createFramebuffer(),a.__webglRenderbuffer=o.createRenderbuffer(),o.bindTexture(o.TEXTURE_2D,a.__webglTexture),O(o.TEXTURE_2D,a,a),o.texImage2D(o.TEXTURE_2D,0,Y(a.format),a.width,a.height,0,Y(a.format),Y(a.type),null),c=o.TEXTURE_2D,o.bindFramebuffer(o.FRAMEBUFFER,a.__webglFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,c,a.__webglTexture,0),o.bindRenderbuffer(o.RENDERBUFFER,a.__webglRenderbuffer), -N(a.__webglRenderbuffer,a);b?o.bindTexture(o.TEXTURE_CUBE_MAP,null):o.bindTexture(o.TEXTURE_2D,null);o.bindRenderbuffer(o.RENDERBUFFER,null);o.bindFramebuffer(o.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,f=e=0):(b=null,c=ma,a=wa,e=Q,f=ka);b!==G&&(o.bindFramebuffer(o.FRAMEBUFFER,b),o.viewport(e,f,c,a),G=b)}function M(a){a instanceof THREE.WebGLRenderTargetCube?(o.bindTexture(o.TEXTURE_CUBE_MAP,a.__webglTexture),o.generateMipmap(o.TEXTURE_CUBE_MAP), -o.bindTexture(o.TEXTURE_CUBE_MAP,null)):(o.bindTexture(o.TEXTURE_2D,a.__webglTexture),o.generateMipmap(o.TEXTURE_2D),o.bindTexture(o.TEXTURE_2D,null))}function ea(a,b){var c;a==="fragment"?c=o.createShader(o.FRAGMENT_SHADER):a==="vertex"&&(c=o.createShader(o.VERTEX_SHADER));o.shaderSource(c,b);o.compileShader(c);if(!o.getShaderParameter(c,o.COMPILE_STATUS))return console.error(o.getShaderInfoLog(c)),console.error(b),null;return c}function ja(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return o.NEAREST; -default:return o.LINEAR}}function Y(a){switch(a){case THREE.RepeatWrapping:return o.REPEAT;case THREE.ClampToEdgeWrapping:return o.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return o.MIRRORED_REPEAT;case THREE.NearestFilter:return o.NEAREST;case THREE.NearestMipMapNearestFilter:return o.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return o.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return o.LINEAR;case THREE.LinearMipMapNearestFilter:return o.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return o.LINEAR_MIPMAP_LINEAR; +w,Math.max(0,Math.min(1,f.position.z)))):(o.uniform1i(h.useScreenCoordinates,0),o.uniform1i(h.affectedByDistance,f.affectedByDistance?1:0),o.uniformMatrix4fv(h.modelViewMatrix,!1,f._modelViewMatrixArray)),k=f.map.image.width/(f.scaleByViewport?ua:1),n[0]=k*l*f.scale.x,n[1]=k*f.scale.y,o.uniform2f(h.uvScale,f.uvScale.x,f.uvScale.y),o.uniform2f(h.uvOffset,f.uvOffset.x,f.uvOffset.y),o.uniform2f(h.alignment,f.alignment.x,f.alignment.y),o.uniform1f(h.opacity,f.opacity),o.uniform3f(h.color,f.color.r,f.color.g, +f.color.b),o.uniform1f(h.rotation,f.rotation),o.uniform2fv(h.scale,n),f.mergeWith3D&&!p?(o.enable(o.DEPTH_TEST),p=!0):!f.mergeWith3D&&p&&(o.disable(o.DEPTH_TEST),p=!1),D(f.blending),J(f.map,0),o.drawElements(o.TRIANGLES,6,o.UNSIGNED_SHORT,0));o.enable(o.CULL_FACE);o.enable(o.DEPTH_TEST);o.depthMask(ga)}function E(a,b,c){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(a._modelViewMatrix).transposeIntoArray(a._normalMatrixArray)} +function C(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function H(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function L(a,b){for(var c=a.length-1;c>=0;c--)a[c].object===b&&a.splice(c,1)}function R(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function D(a){if(a!==T){switch(a){case THREE.AdditiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE);break;case THREE.SubtractiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO, +o.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.SRC_COLOR);break;default:o.blendEquationSeparate(o.FUNC_ADD,o.FUNC_ADD),o.blendFuncSeparate(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA)}T=a}}function O(a,b,c){(c.width&c.width-1)===0&&(c.height&c.height-1)===0?(o.texParameteri(a,o.TEXTURE_WRAP_S,Z(b.wrapS)),o.texParameteri(a,o.TEXTURE_WRAP_T,Z(b.wrapT)),o.texParameteri(a,o.TEXTURE_MAG_FILTER,Z(b.magFilter)),o.texParameteri(a, +o.TEXTURE_MIN_FILTER,Z(b.minFilter)),o.generateMipmap(a)):(o.texParameteri(a,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(a,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(a,o.TEXTURE_MAG_FILTER,oa(b.magFilter)),o.texParameteri(a,o.TEXTURE_MIN_FILTER,oa(b.minFilter)))}function J(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=o.createTexture(),U.info.memory.textures++;o.activeTexture(o.TEXTURE0+b);o.bindTexture(o.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture? +o.texImage2D(o.TEXTURE_2D,0,Z(a.format),a.image.width,a.image.height,0,Z(a.format),o.UNSIGNED_BYTE,a.image.data):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,a.image);O(o.TEXTURE_2D,a,a.image);a.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+b),o.bindTexture(o.TEXTURE_2D,a.__webglTexture)}function N(a,b){o.bindRenderbuffer(o.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_COMPONENT16,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER, +o.DEPTH_ATTACHMENT,o.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,a)):o.renderbufferStorage(o.RENDERBUFFER,o.RGBA4,b.width,b.height)}function K(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=o.createTexture(); +if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];o.bindTexture(o.TEXTURE_CUBE_MAP,a.__webglTexture);O(o.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]=o.createFramebuffer();a.__webglRenderbuffer[c]=o.createRenderbuffer();o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,Z(a.format),a.width,a.height,0,Z(a.format),Z(a.type),null);var e=a,f=o.TEXTURE_CUBE_MAP_POSITIVE_X+c;o.bindFramebuffer(o.FRAMEBUFFER,a.__webglFramebuffer[c]);o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0, +f,e.__webglTexture,0);N(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=o.createFramebuffer(),a.__webglRenderbuffer=o.createRenderbuffer(),o.bindTexture(o.TEXTURE_2D,a.__webglTexture),O(o.TEXTURE_2D,a,a),o.texImage2D(o.TEXTURE_2D,0,Z(a.format),a.width,a.height,0,Z(a.format),Z(a.type),null),c=o.TEXTURE_2D,o.bindFramebuffer(o.FRAMEBUFFER,a.__webglFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,c,a.__webglTexture,0),o.bindRenderbuffer(o.RENDERBUFFER,a.__webglRenderbuffer), +N(a.__webglRenderbuffer,a);b?o.bindTexture(o.TEXTURE_CUBE_MAP,null):o.bindTexture(o.TEXTURE_2D,null);o.bindRenderbuffer(o.RENDERBUFFER,null);o.bindFramebuffer(o.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,f=e=0):(b=null,c=ka,a=ua,e=Q,f=ha);b!==G&&(o.bindFramebuffer(o.FRAMEBUFFER,b),o.viewport(e,f,c,a),G=b)}function M(a){a instanceof THREE.WebGLRenderTargetCube?(o.bindTexture(o.TEXTURE_CUBE_MAP,a.__webglTexture),o.generateMipmap(o.TEXTURE_CUBE_MAP), +o.bindTexture(o.TEXTURE_CUBE_MAP,null)):(o.bindTexture(o.TEXTURE_2D,a.__webglTexture),o.generateMipmap(o.TEXTURE_2D),o.bindTexture(o.TEXTURE_2D,null))}function Y(a,b){var c;a==="fragment"?c=o.createShader(o.FRAGMENT_SHADER):a==="vertex"&&(c=o.createShader(o.VERTEX_SHADER));o.shaderSource(c,b);o.compileShader(c);if(!o.getShaderParameter(c,o.COMPILE_STATUS))return console.error(o.getShaderInfoLog(c)),console.error(b),null;return c}function oa(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return o.NEAREST; +default:return o.LINEAR}}function Z(a){switch(a){case THREE.RepeatWrapping:return o.REPEAT;case THREE.ClampToEdgeWrapping:return o.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return o.MIRRORED_REPEAT;case THREE.NearestFilter:return o.NEAREST;case THREE.NearestMipMapNearestFilter:return o.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return o.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return o.LINEAR;case THREE.LinearMipMapNearestFilter:return o.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return o.LINEAR_MIPMAP_LINEAR; case THREE.ByteType:return o.BYTE;case THREE.UnsignedByteType:return o.UNSIGNED_BYTE;case THREE.ShortType:return o.SHORT;case THREE.UnsignedShortType:return o.UNSIGNED_SHORT;case THREE.IntType:return o.INT;case THREE.UnsignedShortType:return o.UNSIGNED_INT;case THREE.FloatType:return o.FLOAT;case THREE.AlphaFormat:return o.ALPHA;case THREE.RGBFormat:return o.RGB;case THREE.RGBAFormat:return o.RGBA;case THREE.LuminanceFormat:return o.LUMINANCE;case THREE.LuminanceAlphaFormat:return o.LUMINANCE_ALPHA}return 0} -var U=this,o,P=[],pa=null,G=null,W=-1,$=null,na=0,la=null,ra=null,ia=null,da=null,S=null,fa=null,ha=null,I=null,Q=0,ka=0,ma=0,wa=0,sa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],qa=new THREE.Matrix4,Ea=new Float32Array(16),ya=new Float32Array(16),Aa=new THREE.Vector4,Ja={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},Z=a.canvas!==void 0?a.canvas:document.createElement("canvas"), -ca=a.stencil!==void 0?a.stencil:!0,V=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,aa=a.antialias!==void 0?a.antialias:!1,ga=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),oa=a.clearAlpha!==void 0?a.clearAlpha:0,ta=a.maxLights!==void 0?a.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=Z;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil= -this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;var ua,X=[],a=THREE.ShaderLib.depthRGBA,Ba=THREE.UniformsUtils.clone(a.uniforms),Ha=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader, -vertexShader:a.vertexShader,uniforms:Ba}),Fa=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:Ba,morphTargets:!0});Ha._shadowPass=!0;Fa._shadowPass=!0;try{if(!(o=Z.getContext("experimental-webgl",{antialias:aa,stencil:ca,preserveDrawingBuffer:V})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+o.getParameter(o.VERSION)+" | "+o.getParameter(o.VENDOR)+" | "+o.getParameter(o.RENDERER)+" | "+o.getParameter(o.SHADING_LANGUAGE_VERSION))}catch(xa){console.error(xa)}o.clearColor(0, -0,0,1);o.clearDepth(1);o.clearStencil(0);o.enable(o.DEPTH_TEST);o.depthFunc(o.LEQUAL);o.frontFace(o.CCW);o.cullFace(o.BACK);o.enable(o.CULL_FACE);o.enable(o.BLEND);o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA);o.clearColor(ga.r,ga.g,ga.b,oa);this.context=o;var Ca=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,T={};T.vertices=new Float32Array(16);T.faces=new Uint16Array(6);ca=0;T.vertices[ca++]=-1;T.vertices[ca++]=-1;T.vertices[ca++]=0;T.vertices[ca++]=1;T.vertices[ca++]= -1;T.vertices[ca++]=-1;T.vertices[ca++]=1;T.vertices[ca++]=1;T.vertices[ca++]=1;T.vertices[ca++]=1;T.vertices[ca++]=1;T.vertices[ca++]=0;T.vertices[ca++]=-1;T.vertices[ca++]=1;T.vertices[ca++]=0;ca=T.vertices[ca++]=0;T.faces[ca++]=0;T.faces[ca++]=1;T.faces[ca++]=2;T.faces[ca++]=0;T.faces[ca++]=2;T.faces[ca++]=3;T.vertexBuffer=o.createBuffer();T.elementBuffer=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,T.vertexBuffer);o.bufferData(o.ARRAY_BUFFER,T.vertices,o.STATIC_DRAW);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, -T.elementBuffer);o.bufferData(o.ELEMENT_ARRAY_BUFFER,T.faces,o.STATIC_DRAW);T.program=o.createProgram();o.attachShader(T.program,ea("fragment",THREE.ShaderLib.sprite.fragmentShader));o.attachShader(T.program,ea("vertex",THREE.ShaderLib.sprite.vertexShader));o.linkProgram(T.program);T.attributes={};T.uniforms={};T.attributes.position=o.getAttribLocation(T.program,"position");T.attributes.uv=o.getAttribLocation(T.program,"uv");T.uniforms.uvOffset=o.getUniformLocation(T.program,"uvOffset");T.uniforms.uvScale= -o.getUniformLocation(T.program,"uvScale");T.uniforms.rotation=o.getUniformLocation(T.program,"rotation");T.uniforms.scale=o.getUniformLocation(T.program,"scale");T.uniforms.alignment=o.getUniformLocation(T.program,"alignment");T.uniforms.color=o.getUniformLocation(T.program,"color");T.uniforms.map=o.getUniformLocation(T.program,"map");T.uniforms.opacity=o.getUniformLocation(T.program,"opacity");T.uniforms.useScreenCoordinates=o.getUniformLocation(T.program,"useScreenCoordinates");T.uniforms.affectedByDistance= -o.getUniformLocation(T.program,"affectedByDistance");T.uniforms.screenPosition=o.getUniformLocation(T.program,"screenPosition");T.uniforms.modelViewMatrix=o.getUniformLocation(T.program,"modelViewMatrix");T.uniforms.projectionMatrix=o.getUniformLocation(T.program,"projectionMatrix");var Ga=!1;this.setSize=function(a,b){Z.width=a;Z.height=b;this.setViewport(0,0,Z.width,Z.height)};this.setViewport=function(a,b,c,e){Q=a;ka=b;ma=c;wa=e;o.viewport(Q,ka,ma,wa)};this.setScissor=function(a,b,c,e){o.scissor(a, -b,c,e)};this.enableScissorTest=function(a){a?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)};this.setClearColorHex=function(a,b){ga.setHex(a);oa=b;o.clearColor(ga.r,ga.g,ga.b,oa)};this.setClearColor=function(a,b){ga.copy(a);oa=b;o.clearColor(ga.r,ga.g,ga.b,oa)};this.getClearColor=function(){return ga};this.getClearAlpha=function(){return oa};this.clear=function(a,b,c){var e=0;if(a===void 0||a)e|=o.COLOR_BUFFER_BIT;if(b===void 0||b)e|=o.DEPTH_BUFFER_BIT;if(c===void 0||c)e|=o.STENCIL_BUFFER_BIT; +var U=this,o,P=[],ra=null,G=null,W=-1,$=null,la=0,ja=null,sa=null,T=null,ea=null,ga=null,na=null,ia=null,I=null,Q=0,ha=0,ka=0,ua=0,va=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ca=new THREE.Matrix4,Ga=new Float32Array(16),ya=new Float32Array(16),Aa=new THREE.Vector4,Ja={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},X=a.canvas!==void 0?a.canvas:document.createElement("canvas"), +ca=a.stencil!==void 0?a.stencil:!0,V=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,aa=a.antialias!==void 0?a.antialias:!1,fa=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),ma=a.clearAlpha!==void 0?a.clearAlpha:0,wa=a.maxLights!==void 0?a.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=X;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil= +this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;var pa,qa=[],a=THREE.ShaderLib.depthRGBA,ta=THREE.UniformsUtils.clone(a.uniforms),Da=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader, +vertexShader:a.vertexShader,uniforms:ta}),Ha=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:ta,morphTargets:!0});Da._shadowPass=!0;Ha._shadowPass=!0;try{if(!(o=X.getContext("experimental-webgl",{antialias:aa,stencil:ca,preserveDrawingBuffer:V})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+o.getParameter(o.VERSION)+" | "+o.getParameter(o.VENDOR)+" | "+o.getParameter(o.RENDERER)+" | "+o.getParameter(o.SHADING_LANGUAGE_VERSION))}catch(za){console.error(za)}o.clearColor(0, +0,0,1);o.clearDepth(1);o.clearStencil(0);o.enable(o.DEPTH_TEST);o.depthFunc(o.LEQUAL);o.frontFace(o.CCW);o.cullFace(o.BACK);o.enable(o.CULL_FACE);o.enable(o.BLEND);o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA);o.clearColor(fa.r,fa.g,fa.b,ma);this.context=o;var Ea=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,S={};S.vertices=new Float32Array(16);S.faces=new Uint16Array(6);ca=0;S.vertices[ca++]=-1;S.vertices[ca++]=-1;S.vertices[ca++]=0;S.vertices[ca++]=1;S.vertices[ca++]= +1;S.vertices[ca++]=-1;S.vertices[ca++]=1;S.vertices[ca++]=1;S.vertices[ca++]=1;S.vertices[ca++]=1;S.vertices[ca++]=1;S.vertices[ca++]=0;S.vertices[ca++]=-1;S.vertices[ca++]=1;S.vertices[ca++]=0;ca=S.vertices[ca++]=0;S.faces[ca++]=0;S.faces[ca++]=1;S.faces[ca++]=2;S.faces[ca++]=0;S.faces[ca++]=2;S.faces[ca++]=3;S.vertexBuffer=o.createBuffer();S.elementBuffer=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,S.vertexBuffer);o.bufferData(o.ARRAY_BUFFER,S.vertices,o.STATIC_DRAW);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER, +S.elementBuffer);o.bufferData(o.ELEMENT_ARRAY_BUFFER,S.faces,o.STATIC_DRAW);S.program=o.createProgram();o.attachShader(S.program,Y("fragment",THREE.ShaderLib.sprite.fragmentShader));o.attachShader(S.program,Y("vertex",THREE.ShaderLib.sprite.vertexShader));o.linkProgram(S.program);S.attributes={};S.uniforms={};S.attributes.position=o.getAttribLocation(S.program,"position");S.attributes.uv=o.getAttribLocation(S.program,"uv");S.uniforms.uvOffset=o.getUniformLocation(S.program,"uvOffset");S.uniforms.uvScale= +o.getUniformLocation(S.program,"uvScale");S.uniforms.rotation=o.getUniformLocation(S.program,"rotation");S.uniforms.scale=o.getUniformLocation(S.program,"scale");S.uniforms.alignment=o.getUniformLocation(S.program,"alignment");S.uniforms.color=o.getUniformLocation(S.program,"color");S.uniforms.map=o.getUniformLocation(S.program,"map");S.uniforms.opacity=o.getUniformLocation(S.program,"opacity");S.uniforms.useScreenCoordinates=o.getUniformLocation(S.program,"useScreenCoordinates");S.uniforms.affectedByDistance= +o.getUniformLocation(S.program,"affectedByDistance");S.uniforms.screenPosition=o.getUniformLocation(S.program,"screenPosition");S.uniforms.modelViewMatrix=o.getUniformLocation(S.program,"modelViewMatrix");S.uniforms.projectionMatrix=o.getUniformLocation(S.program,"projectionMatrix");var Sa=!1;this.setSize=function(a,b){X.width=a;X.height=b;this.setViewport(0,0,X.width,X.height)};this.setViewport=function(a,b,c,e){Q=a;ha=b;ka=c;ua=e;o.viewport(Q,ha,ka,ua)};this.setScissor=function(a,b,c,e){o.scissor(a, +b,c,e)};this.enableScissorTest=function(a){a?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)};this.setClearColorHex=function(a,b){fa.setHex(a);ma=b;o.clearColor(fa.r,fa.g,fa.b,ma)};this.setClearColor=function(a,b){fa.copy(a);ma=b;o.clearColor(fa.r,fa.g,fa.b,ma)};this.getClearColor=function(){return fa};this.getClearAlpha=function(){return ma};this.clear=function(a,b,c){var e=0;if(a===void 0||a)e|=o.COLOR_BUFFER_BIT;if(b===void 0||b)e|=o.DEPTH_BUFFER_BIT;if(c===void 0||c)e|=o.STENCIL_BUFFER_BIT; o.clear(e)};this.getContext=function(){return o};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(g in a.geometry.geometryGroups){var b=a.geometry.geometryGroups[g];o.deleteBuffer(b.__webglVertexBuffer);o.deleteBuffer(b.__webglNormalBuffer);o.deleteBuffer(b.__webglTangentBuffer);o.deleteBuffer(b.__webglColorBuffer);o.deleteBuffer(b.__webglUVBuffer); o.deleteBuffer(b.__webglUV2Buffer);o.deleteBuffer(b.__webglSkinVertexABuffer);o.deleteBuffer(b.__webglSkinVertexBBuffer);o.deleteBuffer(b.__webglSkinIndicesBuffer);o.deleteBuffer(b.__webglSkinWeightsBuffer);o.deleteBuffer(b.__webglFaceBuffer);o.deleteBuffer(b.__webglLineBuffer);if(b.numMorphTargets)for(var c=0,e=b.numMorphTargets;c=0&&o.enableVertexAttribArray(u.position);u.color>=0&&o.enableVertexAttribArray(u.color);u.normal>=0&&o.enableVertexAttribArray(u.normal); -u.tangent>=0&&o.enableVertexAttribArray(u.tangent);a.skinning&&u.skinVertexA>=0&&u.skinVertexB>=0&&u.skinIndex>=0&&u.skinWeight>=0&&(o.enableVertexAttribArray(u.skinVertexA),o.enableVertexAttribArray(u.skinVertexB),o.enableVertexAttribArray(u.skinIndex),o.enableVertexAttribArray(u.skinWeight));if(a.attributes)for(h in a.attributes)u[h]!==void 0&&u[h]>=0&&o.enableVertexAttribArray(u[h]);if(a.morphTargets)for(h=a.numSupportedMorphTargets=0;h=0&&(o.enableVertexAttribArray(u[Z]), -a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.clearTarget=function(a,b,c,e){J(a);this.clear(b,c,e)};this.updateShadowMap=function(a,b){B(a,b)};this.render=function(a,b,c,e){var Z,V,ca,C,H,aa,Da,I=a.lights,L=a.fog;W=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&B(a,b);U.info.render.calls=0;U.info.render.vertices=0;U.info.render.faces=0;b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."), -a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(ya);b.projectionMatrix.flattenToArray(Ea);qa.multiply(b.projectionMatrix,b.matrixWorldInverse);p(qa);J(c);(this.autoClear||e)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);ca=a.__webglObjects.length;for(e=0;e=0;e--)if(H=a.__webglObjects[e],H.render&&(aa=H.object,Da=H.buffer,V=H.opaque))k(aa),n(V.depthTest),t(V.depthWrite), -v(V.polygonOffset,V.polygonOffsetFactor,V.polygonOffsetUnits),h(b,I,L,V,Da,aa);for(e=0;e=0&&o.enableVertexAttribArray(u.position);u.color>=0&&o.enableVertexAttribArray(u.color);u.normal>=0&&o.enableVertexAttribArray(u.normal); +u.tangent>=0&&o.enableVertexAttribArray(u.tangent);a.skinning&&u.skinVertexA>=0&&u.skinVertexB>=0&&u.skinIndex>=0&&u.skinWeight>=0&&(o.enableVertexAttribArray(u.skinVertexA),o.enableVertexAttribArray(u.skinVertexB),o.enableVertexAttribArray(u.skinIndex),o.enableVertexAttribArray(u.skinWeight));if(a.attributes)for(h in a.attributes)u[h]!==void 0&&u[h]>=0&&o.enableVertexAttribArray(u[h]);if(a.morphTargets)for(h=a.numSupportedMorphTargets=0;h=0&&(o.enableVertexAttribArray(u[X]), +a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.clearTarget=function(a,b,c,e){K(a);this.clear(b,c,e)};this.updateShadowMap=function(a,b){B(a,b)};this.render=function(a,b,c,e){var X,V,ca,C,H,aa,Fa,I=a.lights,L=a.fog;W=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&B(a,b);U.info.render.calls=0;U.info.render.vertices=0;U.info.render.faces=0;b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."), +a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(ya);b.projectionMatrix.flattenToArray(Ga);Ca.multiply(b.projectionMatrix,b.matrixWorldInverse);p(Ca);K(c);(this.autoClear||e)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);ca=a.__webglObjects.length;for(e=0;e=0;e--)if(H=a.__webglObjects[e],H.render&&(aa=H.object,Fa=H.buffer,V=H.opaque))k(aa),n(V.depthTest),t(V.depthWrite), +v(V.polygonOffset,V.polygonOffsetFactor,V.polygonOffsetUnits),h(b,I,L,V,Fa,aa);for(e=0;e65535&&(z[x].counter+=1,Z=z[x].hash+"_"+z[x].counter,n.geometryGroups[Z]===void 0&&(n.geometryGroups[Z]={faces3:[],faces4:[],materialIndex:v,vertices:0,numMorphTargets:V})),w instanceof THREE.Face3?n.geometryGroups[Z].faces3.push(t):n.geometryGroups[Z].faces4.push(t),n.geometryGroups[Z].vertices+=u;n.geometryGroupsList=[];t=void 0;for(t in n.geometryGroups)n.geometryGroups[t].id=na++,n.geometryGroupsList.push(n.geometryGroups[t])}for(l in k.geometryGroups)if(n=k.geometryGroups[l],!n.__webglVertexBuffer){t= +f instanceof THREE.Mesh){k=f.geometry;if(k.geometryGroups===void 0){var n=k,t=void 0,p=void 0,w=void 0,v=void 0,u=void 0,x=void 0,X=void 0,z={},V=n.morphTargets.length;n.geometryGroups={};t=0;for(p=n.faces.length;t65535&&(z[x].counter+=1,X=z[x].hash+"_"+z[x].counter,n.geometryGroups[X]===void 0&&(n.geometryGroups[X]={faces3:[],faces4:[],materialIndex:v,vertices:0,numMorphTargets:V})),w instanceof THREE.Face3?n.geometryGroups[X].faces3.push(t):n.geometryGroups[X].faces4.push(t),n.geometryGroups[X].vertices+=u;n.geometryGroupsList=[];t=void 0;for(t in n.geometryGroups)n.geometryGroups[t].id=la++,n.geometryGroupsList.push(n.geometryGroups[t])}for(l in k.geometryGroups)if(n=k.geometryGroups[l],!n.__webglVertexBuffer){t= n;t.__webglVertexBuffer=o.createBuffer();t.__webglNormalBuffer=o.createBuffer();t.__webglTangentBuffer=o.createBuffer();t.__webglColorBuffer=o.createBuffer();t.__webglUVBuffer=o.createBuffer();t.__webglUV2Buffer=o.createBuffer();t.__webglSkinVertexABuffer=o.createBuffer();t.__webglSkinVertexBBuffer=o.createBuffer();t.__webglSkinIndicesBuffer=o.createBuffer();t.__webglSkinWeightsBuffer=o.createBuffer();t.__webglFaceBuffer=o.createBuffer();t.__webglLineBuffer=o.createBuffer();if(t.numMorphTargets){w= -p=void 0;t.__webglMorphTargetsBuffers=[];p=0;for(w=t.numMorphTargets;p0||u.faceVertexUvs.length>0)n.__uvArray=new Float32Array(t*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)n.__uv2Array=new Float32Array(t*2)}if(v.geometry.skinWeights.length&&v.geometry.skinIndices.length)n.__skinVertexAArray=new Float32Array(t* -4),n.__skinVertexBArray=new Float32Array(t*4),n.__skinIndexArray=new Float32Array(t*4),n.__skinWeightArray=new Float32Array(t*4);n.__faceArray=new Uint16Array(w*3);n.__lineArray=new Uint16Array(x*2);if(n.numMorphTargets){n.__morphTargetsArrays=[];v=0;for(u=n.numMorphTargets;v0||u.faceVertexUvs.length>0)n.__uvArray=new Float32Array(t*2);if(u.faceUvs.length>1||u.faceVertexUvs.length>1)n.__uv2Array=new Float32Array(t*2)}if(v.geometry.skinWeights.length&&v.geometry.skinIndices.length)n.__skinVertexAArray=new Float32Array(t* +4),n.__skinVertexBArray=new Float32Array(t*4),n.__skinIndexArray=new Float32Array(t*4),n.__skinWeightArray=new Float32Array(t*4);n.__faceArray=new Uint16Array(w*3);n.__lineArray=new Uint16Array(x*2);if(n.numMorphTargets){n.__morphTargetsArrays=[];v=0;for(u=n.numMorphTargets;v=0;k--)h[k]===l&&h.splice(k,1)}else(f instanceof THREE.MarchingCubes|| f.immediateRenderCallback)&&L(h.__webglObjectsImmediate,f);f.__webglActive=!1;a.__objectsRemoved.splice(0,1)}f=0;for(h=a.__webglObjects.length;f0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,O,w),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,ka,w),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,oa,w),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER,fa,w))}if(Ha&&J){u=0;for(x=z.length;u0&&(o.bindBuffer(o.ARRAY_BUFFER, -p.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,N,w))}if(ra&&ja.hasTangents){u=0;for(x=z.length;u0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER, -ua,w))}if(pa&&Aa&&W){u=0;for(x=z.length;u0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,F,w))}if(ha){u=0;for(x=z.length;u0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,O,w),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,ha,w),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,ma,w),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER,pa,w))}if(sa&&K){u=0;for(x=z.length;u0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglColorBuffer), +o.bufferData(o.ARRAY_BUFFER,N,w))}if(va&&ua.hasTangents){u=0;for(x=z.length;u0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,ia,w))}if(oa&& +Ga&&W){u=0;for(x=z.length;u0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,F,w))}if(ga){u=0;for(x=z.length;ua&&(a+=Math.PI*2),anglec=(b+a)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return e.multiplyScalar(k).addSelf(l).subSelf(a).clone()}function l(a){for(J=a.length;--J>=0;){na=J;la=J-1;la<0&&(la=a.length- -1);for(var b=0,c=w+v*2,b=0;b=0;ea--){ja=ea/v;Y=n*(1-ja);ja=t*Math.sin(ja*Math.PI/2);J=0;for(M=E.length;Ja&&(a+=Math.PI*2),anglec=(b+a)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return e.multiplyScalar(k).addSelf(l).subSelf(a).clone()}function l(a){for(K=a.length;--K>=0;){la=K;ja=K-1;ja<0&&(ja=a.length- +1);for(var b=0,c=w+v*2,b=0;b=0;Y--){oa=Y/v;Z=n*(1-oa);oa=t*Math.sin(oa*Math.PI/2);K=0;for(M=E.length;K0)for(t=0;t2;){if(p--<=0){console.log("Warning, unable to triangulate polygon!");if(e)return k;return h}n=t;l<=n&&(n=0);t=n+1;l<=t&&(t=0);v=t+1;l<=v&&(v=0);var x;a:{x=a;var w=n,z=t,u=v,B=l,y=f,E=void 0,C=void 0,H=void 0, -L=void 0,R=void 0,D=void 0,O=void 0,K=void 0,N=void 0,C=x[y[w]].x,H=x[y[w]].y,L=x[y[z]].x,R=x[y[z]].y,D=x[y[u]].x,O=x[y[u]].y;if(1.0E-10>(L-C)*(O-H)-(R-H)*(D-C))x=!1;else{for(E=0;E=0&&ea>=0&&Y>=0){x=!1;break a}}x= +L=void 0,R=void 0,D=void 0,O=void 0,J=void 0,N=void 0,C=x[y[w]].x,H=x[y[w]].y,L=x[y[z]].x,R=x[y[z]].y,D=x[y[u]].x,O=x[y[u]].y;if(1.0E-10>(L-C)*(O-H)-(R-H)*(D-C))x=!1;else{for(E=0;E=0&&Y>=0&&Z>=0){x=!1;break a}}x= !0}}if(x){h.push([a[f[n]],a[f[t]],a[f[v]]]);k.push([f[n],f[t],f[v]]);n=t;for(v=t+1;v0;)this.smooth(a)}; THREE.SubdivisionModifier.prototype.smooth=function(a){function c(a,b,c,e,k,n){var p=new THREE.Face4(a,b,c,e,null,k.color,k.material);if(f.useOldVertexColors){p.vertexColors=[];for(var t,u,w,v=0;v<4;v++){w=n[v];t=new THREE.Color;t.setRGB(0,0,0);for(var y=0;y>7)-127;e|=(h&127)<<16|f<<8;if(e==0&&l==-127)return 0;return(1-2*(k>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,l)}function k(a,b){var c=v(a,b),e=v(a,b+1),f=v(a,b+2);return(v(a,b+3)<<24)+(f<<16)+(e<<8)+c}function l(a,b){var c=v(a,b);return(v(a,b+1)<<8)+c}function t(a,b){var c=v(a,b);return c>127?c-256:c}function v(a,b){return a.charCodeAt(b)&255}function p(b){var c, -e,f;c=k(a,b);e=k(a,b+R);f=k(a,b+D);b=l(a,b+O);y.faces.push(new THREE.Face3(c,e,f,null,null,b))}function x(b){var c,e,f,h,o,p,t;c=k(a,b);e=k(a,b+R);f=k(a,b+D);h=l(a,b+O);o=k(a,b+K);p=k(a,b+N);t=k(a,b+J);var b=H[p*3],u=H[p*3+1];p=H[p*3+2];var v=H[t*3],w=H[t*3+1];t=H[t*3+2];y.faces.push(new THREE.Face3(c,e,f,[new THREE.Vector3(H[o*3],H[o*3+1],H[o*3+2]),new THREE.Vector3(b,u,p),new THREE.Vector3(v,w,t)],null,h))}function w(b){var c,e,f,h;c=k(a,b);e=k(a,b+M);f=k(a,b+ea);h=k(a,b+ja);b=l(a,b+Y);y.faces.push(new THREE.Face4(c, -e,f,h,null,null,b))}function z(b){var c,e,f,h,p,t,u,v,w;c=k(a,b);e=k(a,b+M);f=k(a,b+ea);h=k(a,b+ja);p=l(a,b+Y);t=k(a,b+U);u=k(a,b+o);v=k(a,b+P);w=k(a,b+pa);var b=H[u*3],x=H[u*3+1];u=H[u*3+2];var Z=H[v*3],z=H[v*3+1];v=H[v*3+2];var V=H[w*3],B=H[w*3+1];w=H[w*3+2];y.faces.push(new THREE.Face4(c,e,f,h,[new THREE.Vector3(H[t*3],H[t*3+1],H[t*3+2]),new THREE.Vector3(b,x,u),new THREE.Vector3(Z,z,v),new THREE.Vector3(V,B,w)],null,p))}function u(b){var c,e,f,h;c=k(a,b);e=k(a,b+G);f=k(a,b+W);b=L[c*2];h=L[c*2+ -1];c=L[e*2];var l=y.faceVertexUvs[0];e=L[e*2+1];var n=L[f*2];f=L[f*2+1];var o=[];o.push(new THREE.UV(b,h));o.push(new THREE.UV(c,e));o.push(new THREE.UV(n,f));l.push(o)}function B(b){var c,e,f,h,l,n;c=k(a,b);e=k(a,b+$);f=k(a,b+na);h=k(a,b+la);b=L[c*2];l=L[c*2+1];c=L[e*2];n=L[e*2+1];e=L[f*2];var o=y.faceVertexUvs[0];f=L[f*2+1];var p=L[h*2];h=L[h*2+1];var t=[];t.push(new THREE.UV(b,l));t.push(new THREE.UV(c,n));t.push(new THREE.UV(e,f));t.push(new THREE.UV(p,h));o.push(t)}var y=this,E=0,C,H=[],L=[], -R,D,O,K,N,J,M,ea,ja,Y,U,o,P,pa,G,W,$,na,la,ra,ia,da,S,fa,ha;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(y,e,b);C={signature:a.substr(E,8),header_bytes:v(a,E+8),vertex_coordinate_bytes:v(a,E+9),normal_coordinate_bytes:v(a,E+10),uv_coordinate_bytes:v(a,E+11),vertex_index_bytes:v(a,E+12),normal_index_bytes:v(a,E+13),uv_index_bytes:v(a,E+14),material_index_bytes:v(a,E+15),nvertices:k(a,E+16),nnormals:k(a,E+16+4),nuvs:k(a,E+16+8),ntri_flat:k(a,E+16+12),ntri_smooth:k(a,E+16+16),ntri_flat_uv:k(a, -E+16+20),ntri_smooth_uv:k(a,E+16+24),nquad_flat:k(a,E+16+28),nquad_smooth:k(a,E+16+32),nquad_flat_uv:k(a,E+16+36),nquad_smooth_uv:k(a,E+16+40)};E+=C.header_bytes;R=C.vertex_index_bytes;D=C.vertex_index_bytes*2;O=C.vertex_index_bytes*3;K=C.vertex_index_bytes*3+C.material_index_bytes;N=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;J=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;M=C.vertex_index_bytes;ea=C.vertex_index_bytes*2;ja=C.vertex_index_bytes*3;Y=C.vertex_index_bytes* -4;U=C.vertex_index_bytes*4+C.material_index_bytes;o=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;P=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;pa=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;G=C.uv_index_bytes;W=C.uv_index_bytes*2;$=C.uv_index_bytes;na=C.uv_index_bytes*2;la=C.uv_index_bytes*3;b=C.vertex_index_bytes*3+C.material_index_bytes;ha=C.vertex_index_bytes*4+C.material_index_bytes;ra=C.ntri_flat*b;ia=C.ntri_smooth*(b+C.normal_index_bytes* -3);da=C.ntri_flat_uv*(b+C.uv_index_bytes*3);S=C.ntri_smooth_uv*(b+C.normal_index_bytes*3+C.uv_index_bytes*3);fa=C.nquad_flat*ha;b=C.nquad_smooth*(ha+C.normal_index_bytes*4);ha=C.nquad_flat_uv*(ha+C.uv_index_bytes*4);E+=function(b){for(var e,h,k,l=C.vertex_coordinate_bytes*3,n=b+C.nvertices*l;b=0){x=n.invBindMatrices[u];o.invBindMatrix=x;o.skinningMatrix=new THREE.Matrix4;o.skinningMatrix.multiply(o.world,x);o.weights=[];for(x=0;x1){n=new THREE.MeshFaceMaterial;for(j=0;j1?b.add(n):b=n}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation, +new THREE.Object3D,c,e,f;for(f=0;f1){n=new THREE.MeshFaceMaterial;for(j=0;j1?b.add(n):b=n}}b.name=a.id||"";a.matrix.decompose(b.position,b.rotation, b.scale);for(f=0;f1?c[1].substr(0,b):"0";c[1].length1?c[1].substr(0,b):"0";c[1].length=0,k=f.indexOf("(")>=0,l;if(h)e=f.split("."),f=e.shift(),e.shift();else if(k){l=f.split("(");f=l.shift(); for(e=0;eb){t=o.output[n];break}k=t!==void 0?t instanceof THREE.Matrix4? k.multiply(k,t):k.multiply(k,l.matrix):k.multiply(k,l.matrix)}else k=k.multiply(k,l.matrix);b=k;c.push({time:a,pos:[b.n14,b.n24,b.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};p.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a0&&(this[c.nodeName]=parseFloat(e[0].textContent))}}this.create();return this};N.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var e=this[c];if(e instanceof K)if(e.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(e=I[this.effect.surface.init_from]))a.map=THREE.ImageUtils.loadTexture(Ea+e.init_from), -a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=e.color.getHex():b||(a[c]=e.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=Ja;return this.material=new THREE.MeshLambertMaterial(a)};J.prototype.parse=function(a){for(var b=0;b0&&(this[c.nodeName]=parseFloat(e[0].textContent))}}this.create();return this};N.prototype.create=function(){var a={},b=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var e=this[c];if(e instanceof J)if(e.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(e=I[this.effect.surface.init_from]))a.map=THREE.ImageUtils.loadTexture(Ga+e.init_from), +a.map.wrapS=THREE.RepeatWrapping,a.map.wrapT=THREE.RepeatWrapping,a.map.repeat.x=1,a.map.repeat.y=-1}else c=="diffuse"?a.color=e.color.getHex():b||(a[c]=e.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=Ja;return this.material=new THREE.MeshLambertMaterial(a)};K.prototype.parse=function(a){for(var b=0;b=0,e=a.indexOf("(")>=0,f,h;if(c)b=a.split("."),a=b.shift(),h=b.shift();else if(e){f=a.split("(");a=f.shift();for(b=0;b1&&(N=new THREE.MeshFaceMaterial);object=new THREE.Mesh(R,N);object.name=w;object.position.set(C[0],C[1],C[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=E.visible;P.scene.add(object);P.objects[w]=object;E.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),P.scene.collisions.colliders.push(a));if(E.castsShadow)a= new THREE.ShadowVolume(R),P.scene.add(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;E.trigger&&E.trigger.toLowerCase()!="none"&&(a={type:E.trigger,object:E},P.triggers[object.name]=a)}}else C=E.position,r=E.rotation,q=E.quaternion,s=E.scale,q=0,object=new THREE.Object3D,object.name=w,object.position.set(C[0],C[1],C[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],s[1],s[2]),object.visible= -E.visible!==void 0?E.visible:!1,P.scene.add(object),P.objects[w]=object,P.empties[w]=object,E.trigger&&E.trigger.toLowerCase()!="none"&&(a={type:E.trigger,object:E},P.triggers[object.name]=a)}function n(a){return function(c){P.geometries[a]=c;k();ja-=1;b.onLoadComplete();v()}}function t(a){return function(b){P.geometries[a]=b}}function v(){b.callbackProgress({totalModels:U,totalTextures:o,loadedModels:U-ja,loadedTextures:o-Y},P);b.onLoadProgress();ja==0&&Y==0&&c(P)}var p,x,w,z,u,B,y,E,C,H,L,R,D,O, -K,N,J,M,ea,ja,Y,U,o,P;M=a.data;K=new THREE.BinaryLoader;ea=new THREE.JSONLoader;Y=ja=0;P={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(w in M.objects)if(E=M.objects[w],E.meshCollider){a=!0;break}if(a)P.scene.collisions=new THREE.CollisionSystem;if(M.transform){a=M.transform.position;H=M.transform.rotation;var pa=M.transform.scale;a&&P.scene.position.set(a[0],a[1],a[2]);H&&P.scene.rotation.set(H[0],H[1],H[2]); -pa&&P.scene.scale.set(pa[0],pa[1],pa[2]);(a||H||pa)&&P.scene.updateMatrix()}a=function(){Y-=1;v();b.onLoadComplete()};for(u in M.cameras)H=M.cameras[u],H.type=="perspective"?D=new THREE.PerspectiveCamera(H.fov,H.aspect,H.near,H.far):H.type=="ortho"&&(D=new THREE.OrthographicCamera(H.left,H.right,H.top,H.bottom,H.near,H.far)),C=H.position,H=H.target,D.position.set(C[0],C[1],C[2]),D.target=new THREE.Vector3(H[0],H[1],H[2]),P.cameras[u]=D;for(z in M.lights)u=M.lights[z],D=u.color!==void 0?u.color:16777215, -H=u.intensity!==void 0?u.intensity:1,u.type=="directional"?(C=u.direction,J=new THREE.DirectionalLight(D,H),J.position.set(C[0],C[1],C[2]),J.position.normalize()):u.type=="point"?(C=u.position,d=u.distance,J=new THREE.PointLight(D,H,d),J.position.set(C[0],C[1],C[2])):u.type=="ambient"&&(J=new THREE.AmbientLight(D)),P.scene.add(J),P.lights[z]=J;for(B in M.fogs)z=M.fogs[B],z.type=="linear"?O=new THREE.Fog(0,z.near,z.far):z.type=="exp2"&&(O=new THREE.FogExp2(0,z.density)),H=z.color,O.color.setRGB(H[0], -H[1],H[2]),P.fogs[B]=O;if(P.cameras&&M.defaults.camera)P.currentCamera=P.cameras[M.defaults.camera];if(P.fogs&&M.defaults.fog)P.scene.fog=P.fogs[M.defaults.fog];H=M.defaults.bgcolor;P.bgColor=new THREE.Color;P.bgColor.setRGB(H[0],H[1],H[2]);P.bgColorAlpha=M.defaults.bgalpha;for(p in M.geometries)if(B=M.geometries[p],B.type=="bin_mesh"||B.type=="ascii_mesh")ja+=1,b.onLoadStart();U=ja;for(p in M.geometries)B=M.geometries[p],B.type=="cube"?(R=new THREE.CubeGeometry(B.width,B.height,B.depth,B.segmentsWidth, +E.visible!==void 0?E.visible:!1,P.scene.add(object),P.objects[w]=object,P.empties[w]=object,E.trigger&&E.trigger.toLowerCase()!="none"&&(a={type:E.trigger,object:E},P.triggers[object.name]=a)}function n(a){return function(c){P.geometries[a]=c;k();oa-=1;b.onLoadComplete();v()}}function t(a){return function(b){P.geometries[a]=b}}function v(){b.callbackProgress({totalModels:U,totalTextures:o,loadedModels:U-oa,loadedTextures:o-Z},P);b.onLoadProgress();oa==0&&Z==0&&c(P)}var p,x,w,z,u,B,y,E,C,H,L,R,D,O, +J,N,K,M,Y,oa,Z,U,o,P;M=a.data;J=new THREE.BinaryLoader;Y=new THREE.JSONLoader;Z=oa=0;P={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(w in M.objects)if(E=M.objects[w],E.meshCollider){a=!0;break}if(a)P.scene.collisions=new THREE.CollisionSystem;if(M.transform){a=M.transform.position;H=M.transform.rotation;var ra=M.transform.scale;a&&P.scene.position.set(a[0],a[1],a[2]);H&&P.scene.rotation.set(H[0],H[1],H[2]);ra&& +P.scene.scale.set(ra[0],ra[1],ra[2]);(a||H||ra)&&P.scene.updateMatrix()}a=function(){Z-=1;v();b.onLoadComplete()};for(u in M.cameras)H=M.cameras[u],H.type=="perspective"?D=new THREE.PerspectiveCamera(H.fov,H.aspect,H.near,H.far):H.type=="ortho"&&(D=new THREE.OrthographicCamera(H.left,H.right,H.top,H.bottom,H.near,H.far)),C=H.position,H=H.target,D.position.set(C[0],C[1],C[2]),D.target=new THREE.Vector3(H[0],H[1],H[2]),P.cameras[u]=D;for(z in M.lights)u=M.lights[z],D=u.color!==void 0?u.color:16777215, +H=u.intensity!==void 0?u.intensity:1,u.type=="directional"?(C=u.direction,K=new THREE.DirectionalLight(D,H),K.position.set(C[0],C[1],C[2]),K.position.normalize()):u.type=="point"?(C=u.position,d=u.distance,K=new THREE.PointLight(D,H,d),K.position.set(C[0],C[1],C[2])):u.type=="ambient"&&(K=new THREE.AmbientLight(D)),P.scene.add(K),P.lights[z]=K;for(B in M.fogs)z=M.fogs[B],z.type=="linear"?O=new THREE.Fog(0,z.near,z.far):z.type=="exp2"&&(O=new THREE.FogExp2(0,z.density)),H=z.color,O.color.setRGB(H[0], +H[1],H[2]),P.fogs[B]=O;if(P.cameras&&M.defaults.camera)P.currentCamera=P.cameras[M.defaults.camera];if(P.fogs&&M.defaults.fog)P.scene.fog=P.fogs[M.defaults.fog];H=M.defaults.bgcolor;P.bgColor=new THREE.Color;P.bgColor.setRGB(H[0],H[1],H[2]);P.bgColorAlpha=M.defaults.bgalpha;for(p in M.geometries)if(B=M.geometries[p],B.type=="bin_mesh"||B.type=="ascii_mesh")oa+=1,b.onLoadStart();U=oa;for(p in M.geometries)B=M.geometries[p],B.type=="cube"?(R=new THREE.CubeGeometry(B.width,B.height,B.depth,B.segmentsWidth, B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),P.geometries[p]=R):B.type=="plane"?(R=new THREE.PlaneGeometry(B.width,B.height,B.segmentsWidth,B.segmentsHeight),P.geometries[p]=R):B.type=="sphere"?(R=new THREE.SphereGeometry(B.radius,B.segmentsWidth,B.segmentsHeight),P.geometries[p]=R):B.type=="cylinder"?(R=new THREE.CylinderGeometry(B.topRad,B.botRad,B.height,B.radSegs,B.heightSegs),P.geometries[p]=R):B.type=="torus"?(R=new THREE.TorusGeometry(B.radius,B.tube,B.segmentsR,B.segmentsT),P.geometries[p]= -R):B.type=="icosahedron"?(R=new THREE.IcosahedronGeometry(B.subdivisions),P.geometries[p]=R):B.type=="bin_mesh"?K.load(e(B.url,M.urlBaseType),n(p)):B.type=="ascii_mesh"?ea.load(e(B.url,M.urlBaseType),n(p)):B.type=="embedded_mesh"&&(B=M.embeds[B.id])&&ea.createModel(B,t(p),"");for(y in M.textures)if(p=M.textures[y],p.url instanceof Array){Y+=p.url.length;for(K=0;K=57344&&(c-=2048);c++;for(var b=new Float32Array(8*c),e=1,l=0;l<8;l++){for(var h=0,f=0;f>1^-(k&1);b[8*f+l]=h}e+=c}c=a.length-e;h=new Uint16Array(c);for(l=f=0;l=this.maxCount-3&&k(this)};this.begin= function(){this.count=0;this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!==0){for(var c=this.count*3;cthis.size-1&&(n=this.size-1);var x=Math.floor(t-k);x<1&&(x=1);t=Math.floor(t+k);t>this.size-1&&(t=this.size-1);var w=Math.floor(v-k);w<1&&(w=1);k=Math.floor(v+k); k>this.size-1&&(k=this.size-1);for(var z,u,B,y,E,C;p0&&(this.field[B+z]+=y)}}};this.addPlaneX=function(a,c){var l,h,f,k,n,t=this.size,v=this.yd,p=this.zd,x=this.field,w=t*Math.sqrt(a/c);w>t&&(w=t);for(l=0;l0)for(h=0;h=0&&C>=0&&B+C<1}for(var e=new THREE.Vector3,h=new THREE.Vector3,f=new THREE.Vector3,i,k,r,n,l,t,B,C,D,F=[],E=0,ra=a.children.length;Ea.scale.x)return[];D={distance:E,point:a.position, -face:null,object:a};F.push(D)}else if(a instanceof THREE.Mesh){E=b(this.origin,this.direction,a.matrixWorld.getPosition());if(E===null||E>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return F;var O,la,na,R,da,K,U,X,J=a.geometry,Y=J.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);E=0;for(ra=J.faces.length;E0:K<0)))if(K=da.dot((new THREE.Vector3).sub(O,U))/K,U=U.addSelf(X.multiplyScalar(K)),D instanceof THREE.Face3)c(U,O,la,na)&&(D={distance:this.origin.distanceTo(U),point:U,face:D, -object:a},F.push(D));else if(D instanceof THREE.Face4&&(c(U,O,la,R)||c(U,la,na,R)))D={distance:this.origin.distanceTo(U),point:U,face:D,object:a},F.push(D)}return F}}; +h.copy(c).subSelf(b);f.copy(a).subSelf(b);i=e.dot(e);k=e.dot(h);r=e.dot(f);n=h.dot(h);l=h.dot(f);t=1/(i*n-k*k);B=(n*r-k*l)*t;C=(i*l-k*r)*t;return B>=0&&C>=0&&B+C<1}for(var e=new THREE.Vector3,h=new THREE.Vector3,f=new THREE.Vector3,i,k,r,n,l,t,B,C,D,G=[],F=0,ra=a.children.length;Fa.scale.x)return[];D={distance:F,point:a.position, +face:null,object:a};G.push(D)}else if(a instanceof THREE.Mesh){F=b(this.origin,this.direction,a.matrixWorld.getPosition());if(F===null||F>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return G;var O,la,na,S,da,K,V,Y,J=a.geometry,W=J.vertices;a.matrixRotationWorld.extractRotation(a.matrixWorld);F=0;for(ra=J.faces.length;F0:K<0)))if(K=da.dot((new THREE.Vector3).sub(O,V))/K,V=V.addSelf(Y.multiplyScalar(K)),D instanceof THREE.Face3)c(V,O,la,na)&&(D={distance:this.origin.distanceTo(V),point:V,face:D, +object:a},G.push(D));else if(D instanceof THREE.Face4&&(c(V,O,la,S)||c(V,la,na,S)))D={distance:this.origin.distanceTo(V),point:V,face:D,object:a},G.push(D)}return G}}; THREE.Rectangle=function(){function a(){f=e-b;i=h-c}var b,c,e,h,f,i,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return i};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return e};this.getBottom=function(){return h};this.set=function(f,i,l,t){k=!1;b=f;c=i;e=l;h=t;a()};this.addPoint=function(f,i){k?(k=!1,b=f,c=i,e=f,h=i):(b=bf?e:f,h=h>i?h:i);a()};this.add3Points= function(f,i,l,t,B,C){k?(k=!1,b=fl?f>B?f:B:l>B?l:B,h=i>t?i>C?i:C:t>C?t:C):(b=fl?f>B?f>e?f:e:B>e?B:e:l>B?l>e?l:e:B>e?B:e,h=i>t?i>C?i>h?i:h:C>h?C:h:t>C?t>h?t:h:C>h?C:h);a()};this.addRectangle=function(f){k?(k=!1,b=f.getLeft(),c=f.getTop(),e=f.getRight(),h=f.getBottom()):(b=bf.getRight()?e:f.getRight(),h=h> f.getBottom()?h:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;e+=f;h+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();e=e=0&&Math.min(h,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){k=!0;h=e=c=b=0;a()};this.isEmpty=function(){return k}}; THREE.Math={clamp:function(a,b,c){return ac?c:a},clampBottom:function(a,b){return a=0&&f>=0&&h>=0&&i>=0?!0:d<0&&f<0||h<0&&i<0?!1:(d<0?c=Math.max(c,d/(d-f)):f<0&&(e=Math.min(e,d/(d-f))),h<0?c=Math.max(c,h/(h-i)):i<0&&(e=Math.min(e,h/(h-i))),ei&&k.positionScreen.z< +l,t,B=[],C,D=[],G,F,ra=[],O,la,na=[],S={objects:[],sprites:[],lights:[],elements:[]},da=new THREE.Vector3,K=new THREE.Vector4,V=new THREE.Matrix4,Y=new THREE.Matrix4,J=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],W=new THREE.Vector4,aa=new THREE.Vector4;this.computeFrustum=function(a){J[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);J[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);J[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+ +a.n23,a.n44+a.n24);J[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);J[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);J[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;a<6;a++){var b=J[a];b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}};this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);V.multiply(b.projectionMatrix,b.matrixWorldInverse);V.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix); +V.multiply(b.matrixWorld,b.projectionMatrixInverse);V.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,e){f=0;S.objects.length=0;S.sprites.length=0;S.lights.length=0;var i=function(b){if(b.visible!==!1){var d;if(d=b instanceof THREE.Mesh||b instanceof THREE.Line)if(!(d=b.frustumCulled===!1))a:{for(var c=b.matrixWorld, +e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),f=0;f<6;f++)if(d=J[f].x*c.n14+J[f].y*c.n24+J[f].z*c.n34+J[f].w,d<=e){d=!1;break a}d=!0}d?(V.multiplyVector3(da.copy(b.position)),h=a(),h.object=b,h.z=da.z,S.objects.push(h)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(V.multiplyVector3(da.copy(b.position)),h=a(),h.object=b,h.z=da.z,S.sprites.push(h)):b instanceof THREE.Light&&S.lights.push(b);d=0;for(c=b.children.length;di&&k.positionScreen.z< d;sa=0;for(da=Ga.length;sa0&&K.z<1))i=na[la]=na[la]||new THREE.RenderableParticle,la++,O=i,O.x=K.x/K.w,O.y=K.y/K.w,O.z=K.z,O.rotation=P.rotation.z,O.scale.x=P.scale.x*Math.abs(O.x-(K.x+f.projectionMatrix.n11)/(K.w+f.projectionMatrix.n14)), -O.scale.y=P.scale.y*Math.abs(O.y-(K.y+f.projectionMatrix.n22)/(K.w+f.projectionMatrix.n24)),O.material=P.material,R.elements.push(O);h&&R.elements.sort(c);return R}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==void 0?e:1)}; +l.v3.copy(ga),l.v4.copy(ta);else continue;l.normalWorld.copy(ja.normal);ua.multiplyVector3(l.normalWorld);l.centroidWorld.copy(ja.centroid);oa.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);V.multiplyVector3(l.centroidScreen);ga=ja.vertexNormals;H=0;for(qa=ga.length;H0&&K.z<1))i=na[la]=na[la]||new THREE.RenderableParticle,la++,O=i,O.x=K.x/K.w,O.y=K.y/K.w,O.z=K.z,O.rotation=P.rotation.z,O.scale.x=P.scale.x*Math.abs(O.x-(K.x+f.projectionMatrix.n11)/(K.w+f.projectionMatrix.n14)), +O.scale.y=P.scale.y*Math.abs(O.y-(K.y+f.projectionMatrix.n22)/(K.w+f.projectionMatrix.n24)),O.material=P.material,S.elements.push(O);h&&S.elements.sort(c);return S}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==void 0?e:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,e=a.y*b,h=a.z*b,a=Math.cos(e),e=Math.sin(e),b=Math.cos(-h),h=Math.sin(-h),f=Math.cos(c),c=Math.sin(c),i=a*b,k=e*h;this.w=i*f-k*c;this.x=i*c+k*f;this.y=e*b*f+a*h*c;this.z=a*h*f-e*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,e=Math.sin(c); this.x=a.x*e;this.y=a.y*e;this.z=a.z*e;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=a.n32-a.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=a.n13-a.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=a.n21-a.n12<0?-Math.abs(this.z):Math.abs(this.z); this.normalize();return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a===0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b= @@ -82,9 +82,9 @@ b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid c,e,h,f,i,k=new THREE.Vector3,r=new THREE.Vector3;e=0;for(h=this.faces.length;e0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x], +c.vertexNormals[1].copy(e[c.b]),c.vertexNormals[2].copy(e[c.c]),c.vertexNormals[3].copy(e[c.d]))},computeTangents:function(){function a(a,b,c,e,f,h,N){k=a.vertices[b].position;r=a.vertices[c].position;n=a.vertices[e].position;l=i[f];t=i[h];B=i[N];C=r.x-k.x;D=n.x-k.x;G=r.y-k.y;F=n.y-k.y;ra=r.z-k.z;O=n.z-k.z;la=t.u-l.u;na=B.u-l.u;S=t.v-l.v;da=B.v-l.v;K=1/(la*da-na*S);W.set((da*C-S*D)*K,(da*G-S*F)*K,(da*ra-S*O)*K);aa.set((la*D-na*C)*K,(la*F-na*G)*K,(la*O-na*ra)*K);Y[b].addSelf(W);Y[c].addSelf(W);Y[e].addSelf(W); +J[b].addSelf(aa);J[c].addSelf(aa);J[e].addSelf(aa)}var b,c,e,h,f,i,k,r,n,l,t,B,C,D,G,F,ra,O,la,na,S,da,K,V,Y=[],J=[],W=new THREE.Vector3,aa=new THREE.Vector3,ma=new THREE.Vector3,xa=new THREE.Vector3,ka=new THREE.Vector3;b=0;for(c=this.vertices.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 b=1,c=this.vertices.length;bthis.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z< this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b=0)b&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglVertexBuffer), d.vertexAttribPointer(a.position,3,d.FLOAT,!1,0,0));else if(i.morphTargetBase){c=e.program.attributes;i.morphTargetBase!==-1?(d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[i.morphTargetBase]),d.vertexAttribPointer(c.position,3,d.FLOAT,!1,0,0)):c.position>=0&&(d.bindBuffer(d.ARRAY_BUFFER,f.__webglVertexBuffer),d.vertexAttribPointer(c.position,3,d.FLOAT,!1,0,0));if(i.morphTargetForcedOrder.length){k=0;var s=i.morphTargetForcedOrder;for(o=i.morphTargetInfluences;kl&&(m=q,l=o[m]);d.bindBuffer(d.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[m]);d.vertexAttribPointer(c["morphTarget"+k],3,d.FLOAT,!1,0,0);i.__webglMorphTargetInfluences[k]= @@ -206,32 +206,32 @@ d.createBuffer();a.hasPos&&(d.bindBuffer(d.ARRAY_BUFFER,a.__webglVertexBuffer),d 3,f=(f+k+l)/3,h=(h+m+q)/3,c[n]=e,c[n+1]=f,c[n+2]=h,c[n+3]=e,c[n+4]=f,c[n+5]=h,c[n+6]=e,c[n+7]=f,c[n+8]=h}d.bufferData(d.ARRAY_BUFFER,a.normalArray,d.DYNAMIC_DRAW);d.enableVertexAttribArray(b.attributes.normal);d.vertexAttribPointer(b.attributes.normal,3,d.FLOAT,!1,0,0)}d.drawArrays(d.TRIANGLES,0,a.count);a.count=0}function k(a){if(ga!==a.doubleSided)a.doubleSided?d.disable(d.CULL_FACE):d.enable(d.CULL_FACE),ga=a.doubleSided;if(ta!==a.flipSided)a.flipSided?d.frontFace(d.CW):d.frontFace(d.CCW),ta=a.flipSided} function r(a){oa!==a&&(a?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST),oa=a)}function n(a){ua!==a&&(d.depthMask(a),ua=a)}function l(a,b,c){Fa!==a&&(a?d.enable(d.POLYGON_OFFSET_FILL):d.disable(d.POLYGON_OFFSET_FILL),Fa=a);if(a&&(Ja!==b||Ga!==c))d.polygonOffset(b,c),Ja=b,Ga=c}function t(a){va[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);va[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);va[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);va[3].set(a.n41-a.n21,a.n42-a.n22, a.n43-a.n23,a.n44-a.n24);va[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);va[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(var b,a=0;a<6;a++)b=va[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))}function B(a){for(var b=a.matrixWorld,d=-a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)),c=0;c<6;c++)if(a=va[c].x*b.n14+va[c].y*b.n24+va[c].z*b.n34+va[c].w,a<=d)return!1;return!0}function C(a){var b=a.object.material;b.transparent?(a.transparent= -b,a.opaque=null):(a.opaque=b,a.transparent=null)}function D(a){var b=a.object,d=a.buffer,c;c=b.material;if(c instanceof THREE.MeshFaceMaterial){if(d=d.materialIndex,d>=0)b=b.geometry.materials[d],b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}else if(b=c)b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function F(a,b){return b.z-a.z}function E(a){var b,c,e,l=0,T,n,o,s,Q=a.lights;pa||(pa=new THREE.PerspectiveCamera(N.shadowCameraFov,N.shadowMapWidth/ -N.shadowMapHeight,N.shadowCameraNear,N.shadowCameraFar));b=0;for(c=Q.length;b=0)b=b.geometry.materials[d],b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}else if(b=c)b.transparent?(a.transparent=b,a.opaque=null):(a.opaque=b,a.transparent=null)}function G(a,b){return b.z-a.z}function F(a){var b,c,e,l=0,U,n,o,s,Q=a.lights;pa||(pa=new THREE.PerspectiveCamera(N.shadowCameraFov,N.shadowMapWidth/ +N.shadowMapHeight,N.shadowCameraNear,N.shadowCameraFar));b=0;for(c=Q.length;b=0;d--)a[d].object===b&&a.splice(d,1)}function da(a,b,d){a.push({buffer:b,object:d,opaque:null,transparent:null})}function K(a){if(a!==P){switch(a){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE);break;case THREE.SubtractiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ZERO,d.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ZERO,d.SRC_COLOR);break;default:d.blendEquationSeparate(d.FUNC_ADD, -d.FUNC_ADD),d.blendFuncSeparate(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA)}P=a}}function U(a,b,c){(c.width&c.width-1)===0&&(c.height&c.height-1)===0?(d.texParameteri(a,d.TEXTURE_WRAP_S,ka(b.wrapS)),d.texParameteri(a,d.TEXTURE_WRAP_T,ka(b.wrapT)),d.texParameteri(a,d.TEXTURE_MAG_FILTER,ka(b.magFilter)),d.texParameteri(a,d.TEXTURE_MIN_FILTER,ka(b.minFilter)),d.generateMipmap(a)):(d.texParameteri(a,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(a,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE), -d.texParameteri(a,d.TEXTURE_MAG_FILTER,xa(b.magFilter)),d.texParameteri(a,d.TEXTURE_MIN_FILTER,xa(b.minFilter)))}function X(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=d.createTexture(),N.info.memory.textures++;d.activeTexture(d.TEXTURE0+b);d.bindTexture(d.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture?d.texImage2D(d.TEXTURE_2D,0,ka(a.format),a.image.width,a.image.height,0,ka(a.format),d.UNSIGNED_BYTE,a.image.data):d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA, -d.UNSIGNED_BYTE,a.image);U(d.TEXTURE_2D,a,a.image);a.needsUpdate=!1}else d.activeTexture(d.TEXTURE0+b),d.bindTexture(d.TEXTURE_2D,a.__webglTexture)}function J(a,b){d.bindRenderbuffer(d.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,b.width,b.height),d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_STENCIL,b.width,b.height),d.framebufferRenderbuffer(d.FRAMEBUFFER, -d.DEPTH_STENCIL_ATTACHMENT,d.RENDERBUFFER,a)):d.renderbufferStorage(d.RENDERBUFFER,d.RGBA4,b.width,b.height)}function Y(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=d.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];d.bindTexture(d.TEXTURE_CUBE_MAP,a.__webglTexture);U(d.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]= +K(f.blending),Y(f.map,0),d.drawElements(d.TRIANGLES,6,d.UNSIGNED_SHORT,0));d.enable(d.CULL_FACE);d.enable(d.DEPTH_TEST);d.depthMask(ua)}function O(a,b,d){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);d&&THREE.Matrix4.makeInvert3x3(a._modelViewMatrix).transposeIntoArray(a._normalMatrixArray)}function la(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function na(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1} +function S(a,b){for(var d=a.length-1;d>=0;d--)a[d].object===b&&a.splice(d,1)}function da(a,b,d){a.push({buffer:b,object:d,opaque:null,transparent:null})}function K(a){if(a!==P){switch(a){case THREE.AdditiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE);break;case THREE.SubtractiveBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ZERO,d.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:d.blendEquation(d.FUNC_ADD);d.blendFunc(d.ZERO,d.SRC_COLOR);break;default:d.blendEquationSeparate(d.FUNC_ADD, +d.FUNC_ADD),d.blendFuncSeparate(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA,d.ONE,d.ONE_MINUS_SRC_ALPHA)}P=a}}function V(a,b,c){(c.width&c.width-1)===0&&(c.height&c.height-1)===0?(d.texParameteri(a,d.TEXTURE_WRAP_S,ka(b.wrapS)),d.texParameteri(a,d.TEXTURE_WRAP_T,ka(b.wrapT)),d.texParameteri(a,d.TEXTURE_MAG_FILTER,ka(b.magFilter)),d.texParameteri(a,d.TEXTURE_MIN_FILTER,ka(b.minFilter)),d.generateMipmap(a)):(d.texParameteri(a,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(a,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE), +d.texParameteri(a,d.TEXTURE_MAG_FILTER,xa(b.magFilter)),d.texParameteri(a,d.TEXTURE_MIN_FILTER,xa(b.minFilter)))}function Y(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=d.createTexture(),N.info.memory.textures++;d.activeTexture(d.TEXTURE0+b);d.bindTexture(d.TEXTURE_2D,a.__webglTexture);a instanceof THREE.DataTexture?d.texImage2D(d.TEXTURE_2D,0,ka(a.format),a.image.width,a.image.height,0,ka(a.format),d.UNSIGNED_BYTE,a.image.data):d.texImage2D(d.TEXTURE_2D,0,d.RGBA,d.RGBA, +d.UNSIGNED_BYTE,a.image);V(d.TEXTURE_2D,a,a.image);a.needsUpdate=!1}else d.activeTexture(d.TEXTURE0+b),d.bindTexture(d.TEXTURE_2D,a.__webglTexture)}function J(a,b){d.bindRenderbuffer(d.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_COMPONENT16,b.width,b.height),d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(d.renderbufferStorage(d.RENDERBUFFER,d.DEPTH_STENCIL,b.width,b.height),d.framebufferRenderbuffer(d.FRAMEBUFFER, +d.DEPTH_STENCIL_ATTACHMENT,d.RENDERBUFFER,a)):d.renderbufferStorage(d.RENDERBUFFER,d.RGBA4,b.width,b.height)}function W(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(a.depthBuffer===void 0)a.depthBuffer=!0;if(a.stencilBuffer===void 0)a.stencilBuffer=!0;a.__webglTexture=d.createTexture();if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];d.bindTexture(d.TEXTURE_CUBE_MAP,a.__webglTexture);V(d.TEXTURE_CUBE_MAP,a,a);for(var c=0;c<6;c++){a.__webglFramebuffer[c]= d.createFramebuffer();a.__webglRenderbuffer[c]=d.createRenderbuffer();d.texImage2D(d.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,ka(a.format),a.width,a.height,0,ka(a.format),ka(a.type),null);var e=a,f=d.TEXTURE_CUBE_MAP_POSITIVE_X+c;d.bindFramebuffer(d.FRAMEBUFFER,a.__webglFramebuffer[c]);d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,f,e.__webglTexture,0);J(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=d.createFramebuffer(),a.__webglRenderbuffer=d.createRenderbuffer(),d.bindTexture(d.TEXTURE_2D, -a.__webglTexture),U(d.TEXTURE_2D,a,a),d.texImage2D(d.TEXTURE_2D,0,ka(a.format),a.width,a.height,0,ka(a.format),ka(a.type),null),c=d.TEXTURE_2D,d.bindFramebuffer(d.FRAMEBUFFER,a.__webglFramebuffer),d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,c,a.__webglTexture,0),d.bindRenderbuffer(d.RENDERBUFFER,a.__webglRenderbuffer),J(a.__webglRenderbuffer,a);b?d.bindTexture(d.TEXTURE_CUBE_MAP,null):d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER, +a.__webglTexture),V(d.TEXTURE_2D,a,a),d.texImage2D(d.TEXTURE_2D,0,ka(a.format),a.width,a.height,0,ka(a.format),ka(a.type),null),c=d.TEXTURE_2D,d.bindFramebuffer(d.FRAMEBUFFER,a.__webglFramebuffer),d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,c,a.__webglTexture,0),d.bindRenderbuffer(d.RENDERBUFFER,a.__webglRenderbuffer),J(a.__webglRenderbuffer,a);b?d.bindTexture(d.TEXTURE_CUBE_MAP,null):d.bindTexture(d.TEXTURE_2D,null);d.bindRenderbuffer(d.RENDERBUFFER,null);d.bindFramebuffer(d.FRAMEBUFFER, null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,c=a.width,a=a.height,f=e=0):(b=null,c=Ma,a=Ia,e=Aa,f=ya);b!==ja&&(d.bindFramebuffer(d.FRAMEBUFFER,b),d.viewport(e,f,c,a),ja=b)}function aa(a){a instanceof THREE.WebGLRenderTargetCube?(d.bindTexture(d.TEXTURE_CUBE_MAP,a.__webglTexture),d.generateMipmap(d.TEXTURE_CUBE_MAP),d.bindTexture(d.TEXTURE_CUBE_MAP,null)):(d.bindTexture(d.TEXTURE_2D,a.__webglTexture),d.generateMipmap(d.TEXTURE_2D),d.bindTexture(d.TEXTURE_2D,null))}function ma(a, b){var c;a==="fragment"?c=d.createShader(d.FRAGMENT_SHADER):a==="vertex"&&(c=d.createShader(d.VERTEX_SHADER));d.shaderSource(c,b);d.compileShader(c);if(!d.getShaderParameter(c,d.COMPILE_STATUS))return console.error(d.getShaderInfoLog(c)),console.error(b),null;return c}function xa(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return d.NEAREST;default:return d.LINEAR}}function ka(a){switch(a){case THREE.RepeatWrapping:return d.REPEAT; case THREE.ClampToEdgeWrapping:return d.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return d.MIRRORED_REPEAT;case THREE.NearestFilter:return d.NEAREST;case THREE.NearestMipMapNearestFilter:return d.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return d.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return d.LINEAR;case THREE.LinearMipMapNearestFilter:return d.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return d.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return d.BYTE; case THREE.UnsignedByteType:return d.UNSIGNED_BYTE;case THREE.ShortType:return d.SHORT;case THREE.UnsignedShortType:return d.UNSIGNED_SHORT;case THREE.IntType:return d.INT;case THREE.UnsignedShortType:return d.UNSIGNED_INT;case THREE.FloatType:return d.FLOAT;case THREE.AlphaFormat:return d.ALPHA;case THREE.RGBFormat:return d.RGB;case THREE.RGBAFormat:return d.RGBA;case THREE.LuminanceFormat:return d.LUMINANCE;case THREE.LuminanceAlphaFormat:return d.LUMINANCE_ALPHA}return 0}var N=this,d,Ea=[],Qa= null,ja=null,sa=-1,H=null,qa=0,ga=null,ta=null,P=null,oa=null,ua=null,Fa=null,Ja=null,Ga=null,Aa=0,ya=0,Ma=0,Ia=0,va=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ba=new THREE.Matrix4,Na=new Float32Array(16),Oa=new Float32Array(16),Ha=new THREE.Vector4,Sa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},a=a||{},Ca=a.canvas!==void 0?a.canvas:document.createElement("canvas"), -S=a.stencil!==void 0?a.stencil:!0,Xa=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,Ya=a.antialias!==void 0?a.antialias:!1,wa=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),Da=a.clearAlpha!==void 0?a.clearAlpha:0,Ra=a.maxLights!==void 0?a.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=Ca;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil= +T=a.stencil!==void 0?a.stencil:!0,Xa=a.preserveDrawingBuffer!==void 0?a.preserveDrawingBuffer:!1,Ya=a.antialias!==void 0?a.antialias:!1,wa=a.clearColor!==void 0?new THREE.Color(a.clearColor):new THREE.Color(0),Da=a.clearAlpha!==void 0?a.clearAlpha:0,Ra=a.maxLights!==void 0?a.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=Ca;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil= this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=this.shadowMapAutoUpdate=!0;var pa,La=[],a=THREE.ShaderLib.depthRGBA,Va=THREE.UniformsUtils.clone(a.uniforms),Pa=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader, -vertexShader:a.vertexShader,uniforms:Va}),Ta=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:Va,morphTargets:!0});Pa._shadowPass=!0;Ta._shadowPass=!0;try{if(!(d=Ca.getContext("experimental-webgl",{antialias:Ya,stencil:S,preserveDrawingBuffer:Xa})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+d.getParameter(d.VERSION)+" | "+d.getParameter(d.VENDOR)+" | "+d.getParameter(d.RENDERER)+" | "+d.getParameter(d.SHADING_LANGUAGE_VERSION))}catch(Za){console.error(Za)}d.clearColor(0, -0,0,1);d.clearDepth(1);d.clearStencil(0);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA);d.clearColor(wa.r,wa.g,wa.b,Da);this.context=d;var Wa=d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,w={};w.vertices=new Float32Array(16);w.faces=new Uint16Array(6);S=0;w.vertices[S++]=-1;w.vertices[S++]=-1;w.vertices[S++]=0;w.vertices[S++]=1;w.vertices[S++]= -1;w.vertices[S++]=-1;w.vertices[S++]=1;w.vertices[S++]=1;w.vertices[S++]=1;w.vertices[S++]=1;w.vertices[S++]=1;w.vertices[S++]=0;w.vertices[S++]=-1;w.vertices[S++]=1;w.vertices[S++]=0;S=w.vertices[S++]=0;w.faces[S++]=0;w.faces[S++]=1;w.faces[S++]=2;w.faces[S++]=0;w.faces[S++]=2;w.faces[S++]=3;w.vertexBuffer=d.createBuffer();w.elementBuffer=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,w.vertexBuffer);d.bufferData(d.ARRAY_BUFFER,w.vertices,d.STATIC_DRAW);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,w.elementBuffer); +vertexShader:a.vertexShader,uniforms:Va}),Ta=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:Va,morphTargets:!0});Pa._shadowPass=!0;Ta._shadowPass=!0;try{if(!(d=Ca.getContext("experimental-webgl",{antialias:Ya,stencil:T,preserveDrawingBuffer:Xa})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+d.getParameter(d.VERSION)+" | "+d.getParameter(d.VENDOR)+" | "+d.getParameter(d.RENDERER)+" | "+d.getParameter(d.SHADING_LANGUAGE_VERSION))}catch(Za){console.error(Za)}d.clearColor(0, +0,0,1);d.clearDepth(1);d.clearStencil(0);d.enable(d.DEPTH_TEST);d.depthFunc(d.LEQUAL);d.frontFace(d.CCW);d.cullFace(d.BACK);d.enable(d.CULL_FACE);d.enable(d.BLEND);d.blendEquation(d.FUNC_ADD);d.blendFunc(d.SRC_ALPHA,d.ONE_MINUS_SRC_ALPHA);d.clearColor(wa.r,wa.g,wa.b,Da);this.context=d;var Wa=d.getParameter(d.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,w={};w.vertices=new Float32Array(16);w.faces=new Uint16Array(6);T=0;w.vertices[T++]=-1;w.vertices[T++]=-1;w.vertices[T++]=0;w.vertices[T++]=1;w.vertices[T++]= +1;w.vertices[T++]=-1;w.vertices[T++]=1;w.vertices[T++]=1;w.vertices[T++]=1;w.vertices[T++]=1;w.vertices[T++]=1;w.vertices[T++]=0;w.vertices[T++]=-1;w.vertices[T++]=1;w.vertices[T++]=0;T=w.vertices[T++]=0;w.faces[T++]=0;w.faces[T++]=1;w.faces[T++]=2;w.faces[T++]=0;w.faces[T++]=2;w.faces[T++]=3;w.vertexBuffer=d.createBuffer();w.elementBuffer=d.createBuffer();d.bindBuffer(d.ARRAY_BUFFER,w.vertexBuffer);d.bufferData(d.ARRAY_BUFFER,w.vertices,d.STATIC_DRAW);d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,w.elementBuffer); d.bufferData(d.ELEMENT_ARRAY_BUFFER,w.faces,d.STATIC_DRAW);w.program=d.createProgram();d.attachShader(w.program,ma("fragment",THREE.ShaderLib.sprite.fragmentShader));d.attachShader(w.program,ma("vertex",THREE.ShaderLib.sprite.vertexShader));d.linkProgram(w.program);w.attributes={};w.uniforms={};w.attributes.position=d.getAttribLocation(w.program,"position");w.attributes.uv=d.getAttribLocation(w.program,"uv");w.uniforms.uvOffset=d.getUniformLocation(w.program,"uvOffset");w.uniforms.uvScale=d.getUniformLocation(w.program, "uvScale");w.uniforms.rotation=d.getUniformLocation(w.program,"rotation");w.uniforms.scale=d.getUniformLocation(w.program,"scale");w.uniforms.alignment=d.getUniformLocation(w.program,"alignment");w.uniforms.color=d.getUniformLocation(w.program,"color");w.uniforms.map=d.getUniformLocation(w.program,"map");w.uniforms.opacity=d.getUniformLocation(w.program,"opacity");w.uniforms.useScreenCoordinates=d.getUniformLocation(w.program,"useScreenCoordinates");w.uniforms.affectedByDistance=d.getUniformLocation(w.program, "affectedByDistance");w.uniforms.screenPosition=d.getUniformLocation(w.program,"screenPosition");w.uniforms.modelViewMatrix=d.getUniformLocation(w.program,"modelViewMatrix");w.uniforms.projectionMatrix=d.getUniformLocation(w.program,"projectionMatrix");var Ua=!1;this.setSize=function(a,b){Ca.width=a;Ca.height=b;this.setViewport(0,0,Ca.width,Ca.height)};this.setViewport=function(a,b,c,e){Aa=a;ya=b;Ma=c;Ia=e;d.viewport(Aa,ya,Ma,Ia)};this.setScissor=function(a,b,c,e){d.scissor(a,b,c,e)};this.enableScissorTest= @@ -249,12 +249,12 @@ i=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+c.ma ma("vertex",e+m));d.linkProgram(r);d.getProgramParameter(r,d.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+d.getProgramParameter(r,d.VALIDATE_STATUS)+", gl error ["+d.getError()+"]");r.uniforms={};r.attributes={};var t,e=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(t in k)e.push(t);t=e;e=0;for(k=t.length;e=0&&d.enableVertexAttribArray(x.position);x.color>=0&&d.enableVertexAttribArray(x.color);x.normal>=0&&d.enableVertexAttribArray(x.normal); x.tangent>=0&&d.enableVertexAttribArray(x.tangent);a.skinning&&x.skinVertexA>=0&&x.skinVertexB>=0&&x.skinIndex>=0&&x.skinWeight>=0&&(d.enableVertexAttribArray(x.skinVertexA),d.enableVertexAttribArray(x.skinVertexB),d.enableVertexAttribArray(x.skinIndex),d.enableVertexAttribArray(x.skinWeight));if(a.attributes)for(h in a.attributes)x[h]!==void 0&&x[h]>=0&&d.enableVertexAttribArray(x[h]);if(a.morphTargets)for(h=a.numSupportedMorphTargets=0;h=0&&(d.enableVertexAttribArray(x[t]), -a.numSupportedMorphTargets++);a.uniformsList=[];for(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};this.clearTarget=function(a,b,c,d){Y(a);this.clear(b,c,d)};this.updateShadowMap=function(a,b){E(a,b)};this.render=function(a,b,c,e){var w,T,Ka,o,s,Q,m,q=a.lights,R=a.fog;sa=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);this.shadowMapEnabled&&this.shadowMapAutoUpdate&&E(a,b);N.info.render.calls=0;N.info.render.vertices=0;N.info.render.faces=0;b.parent===void 0&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."), -a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);b.matrixWorldInverse.flattenToArray(Oa);b.projectionMatrix.flattenToArray(Na);Ba.multiply(b.projectionMatrix,b.matrixWorldInverse);t(Ba);Y(c);(this.autoClear||e)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);Ka=a.__webglObjects.length;for(e=0;e=0;e--)if(s=a.__webglObjects[e],s.render&&(Q=s.object,m=s.buffer,T=s.opaque))k(Q),r(T.depthTest),n(T.depthWrite),l(T.polygonOffset,T.polygonOffsetFactor, -T.polygonOffsetUnits),f(b,q,R,T,m,Q);for(e=0;e=0;e--)if(s=a.__webglObjects[e],s.render&&(Q=s.object,m=s.buffer,U=s.opaque))k(Q),r(U.depthTest),n(U.depthWrite),l(U.polygonOffset,U.polygonOffsetFactor, +U.polygonOffsetUnits),f(b,q,S,U,m,Q);for(e=0;e65535&&(x[q].counter+=1,t=x[q].hash+"_"+x[q].counter,l.geometryGroups[t]===void 0&&(l.geometryGroups[t]= {faces3:[],faces4:[],materialIndex:r,vertices:0,numMorphTargets:w})),s instanceof THREE.Face3?l.geometryGroups[t].faces3.push(n):l.geometryGroups[t].faces4.push(n),l.geometryGroups[t].vertices+=m;l.geometryGroupsList=[];n=void 0;for(n in l.geometryGroups)l.geometryGroups[n].id=qa++,l.geometryGroupsList.push(l.geometryGroups[n])}for(i in k.geometryGroups)if(l=k.geometryGroups[i],!l.__webglVertexBuffer){n=l;n.__webglVertexBuffer=d.createBuffer();n.__webglNormalBuffer=d.createBuffer();n.__webglTangentBuffer= @@ -266,41 +266,41 @@ m.createUniqueBuffers)m.__webglInitialized=!0,q=1,m.type==="v2"?q=2:m.type==="v3 !k.__webglVertexBuffer)l=k,l.__webglVertexBuffer=d.createBuffer(),l.__webglColorBuffer=d.createBuffer(),N.info.memory.geometries++,l=k,n=l.vertices.length,l.__vertexArray=new Float32Array(n*3),l.__colorArray=new Float32Array(n*3),l.__webglVertexCount=n,k.__dirtyVertices=!0,k.__dirtyColors=!0}else if(f instanceof THREE.Line){if(k=f.geometry,!k.__webglVertexBuffer)l=k,l.__webglVertexBuffer=d.createBuffer(),l.__webglColorBuffer=d.createBuffer(),N.info.memory.geometries++,l=k,n=f,o=l.vertices.length, l.__vertexArray=new Float32Array(o*3),l.__colorArray=new Float32Array(o*3),l.__webglLineCount=o,b(l,n),k.__dirtyVertices=!0,k.__dirtyColors=!0}else if(f instanceof THREE.ParticleSystem&&(k=f.geometry,!k.__webglVertexBuffer))l=k,l.__webglVertexBuffer=d.createBuffer(),l.__webglColorBuffer=d.createBuffer(),N.info.geometries++,l=k,n=f,o=l.vertices.length,l.__vertexArray=new Float32Array(o*3),l.__colorArray=new Float32Array(o*3),l.__sortArray=[],l.__webglParticleCount=o,b(l,n),k.__dirtyVertices=!0,k.__dirtyColors= !0;if(!f.__webglActive){if(f instanceof THREE.Mesh)for(i in k=f.geometry,k.geometryGroups)l=k.geometryGroups[i],da(h.__webglObjects,l,f);else f instanceof THREE.Ribbon||f instanceof THREE.Line||f instanceof THREE.ParticleSystem?(k=f.geometry,da(h.__webglObjects,k,f)):THREE.MarchingCubes!==void 0&&f instanceof THREE.MarchingCubes||f.immediateRenderCallback?h.__webglObjectsImmediate.push({object:f,opaque:null,transparent:null}):f instanceof THREE.Sprite&&h.__webglSprites.push(f);f.__webglActive=!0}a.__objectsAdded.splice(0, -1)}for(;a.__objectsRemoved.length;){f=a.__objectsRemoved[0];h=a;if(f instanceof THREE.Mesh||f instanceof THREE.ParticleSystem||f instanceof THREE.Ribbon||f instanceof THREE.Line)R(h.__webglObjects,f);else if(f instanceof THREE.Sprite){h=h.__webglSprites;i=f;for(k=h.length-1;k>=0;k--)h[k]===i&&h.splice(k,1)}else(f instanceof THREE.MarchingCubes||f.immediateRenderCallback)&&R(h.__webglObjectsImmediate,f);f.__webglActive=!1;a.__objectsRemoved.splice(0,1)}f=0;for(h=a.__webglObjects.length;f=0;k--)h[k]===i&&h.splice(k,1)}else(f instanceof THREE.MarchingCubes||f.immediateRenderCallback)&&S(h.__webglObjectsImmediate,f);f.__webglActive=!1;a.__objectsRemoved.splice(0,1)}f=0;for(h=a.__webglObjects.length;f0&&(d.bindBuffer(d.ARRAY_BUFFER,o.__webglSkinVertexABuffer),d.bufferData(d.ARRAY_BUFFER,Z,s),d.bindBuffer(d.ARRAY_BUFFER,o.__webglSkinVertexBBuffer),d.bufferData(d.ARRAY_BUFFER,$,s),d.bindBuffer(d.ARRAY_BUFFER, -o.__webglSkinIndicesBuffer),d.bufferData(d.ARRAY_BUFFER,E,s),d.bindBuffer(d.ARRAY_BUFFER,o.__webglSkinWeightsBuffer),d.bufferData(d.ARRAY_BUFFER,ia,s))}if(ta&&K){m=0;for(q=x.length;m0&&(d.bindBuffer(d.ARRAY_BUFFER,o.__webglColorBuffer),d.bufferData(d.ARRAY_BUFFER,J,s))}if(sa&&aa.hasTangents){m=0;for(q=x.length;m0&&(d.bindBuffer(d.ARRAY_BUFFER,o.__webglUVBuffer),d.bufferData(d.ARRAY_BUFFER,ga,s))}if(pa&&wa&&U){m=0;for(q=x.length;m0&&(d.bindBuffer(d.ARRAY_BUFFER,o.__webglUV2Buffer),d.bufferData(d.ARRAY_BUFFER,p,s))}if(X){m=0;for(q=x.length;m0&&(d.bindBuffer(d.ARRAY_BUFFER,o.__webglColorBuffer),d.bufferData(d.ARRAY_BUFFER,J,s))}if(sa&&aa.hasTangents){m=0;for(q=x.length;m0&&(d.bindBuffer(d.ARRAY_BUFFER,o.__webglUVBuffer),d.bufferData(d.ARRAY_BUFFER,ga,s))}if(pa&&wa&&V){m=0;for(q=x.length;m0&&(d.bindBuffer(d.ARRAY_BUFFER,o.__webglUV2Buffer),d.bufferData(d.ARRAY_BUFFER,p,s))}if(Y){m=0;for(q=x.length;m