From 195a0b31ae65825d033c61ac9dc77fcd01d64e10 Mon Sep 17 00:00:00 2001 From: zz85 Date: Wed, 5 Oct 2011 00:39:38 +0800 Subject: [PATCH 1/2] Quick fix for boundary cases in Subdivision. Updated example --- build/Three.js | 341 ++++++++++---------- examples/canvas_geometry_subdivison.html | 209 ++++++------ src/extras/modifiers/SubdivisionModifier.js | 46 +-- 3 files changed, 318 insertions(+), 278 deletions(-) diff --git a/build/Three.js b/build/Three.js index 66b0f526..7a0e792a 100644 --- a/build/Three.js +++ b/build/Three.js @@ -26,9 +26,9 @@ THREE.Matrix4=function(b,c,e,f,h,k,m,n,t,v,w,u,x,p,y,A){this.set(b!==void 0?b:1, THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,h,k,m,n,t,v,w,u,x,p,y,A){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=h;this.n22=k;this.n23=m;this.n24=n;this.n31=t;this.n32=v;this.n33=w;this.n34=u;this.n41=x;this.n42=p;this.n43=y;this.n44=A;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b, c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;k.sub(b,c).normalize();if(k.length()===0)k.z=1;f.cross(e,k).normalize();f.length()===0&&(k.x+=1.0E-4,f.cross(e,k).normalize());h.cross(k,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=k.x;this.n21=f.y;this.n22=h.y;this.n23=k.y;this.n31=f.z;this.n32=h.z;this.n33=k.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,h=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*h; b.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*h;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*h;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,h=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*h;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*h;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*h;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*h;return b},rotateAxis:function(b){var c=b.x,e=b.y,f=b.z;b.x=c*this.n11+e*this.n12+f*this.n13;b.y=c*this.n21+e*this.n22+f*this.n23;b.z=c*this.n31+ -e*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,f=b.n12,h=b.n13,k=b.n14,m=b.n21,n=b.n22,t=b.n23,v=b.n24,w=b.n31,u=b.n32,x=b.n33,p=b.n34,y=b.n41,A=b.n42,z=b.n43,E=b.n44,F=c.n11,D=c.n12, -H=c.n13,N=c.n14,O=c.n21,K=c.n22,G=c.n23,B=c.n24,da=c.n31,J=c.n32,R=c.n33,S=c.n34,Y=c.n41,W=c.n42,o=c.n43,ea=c.n44;this.n11=e*F+f*O+h*da+k*Y;this.n12=e*D+f*K+h*J+k*W;this.n13=e*H+f*G+h*R+k*o;this.n14=e*N+f*B+h*S+k*ea;this.n21=m*F+n*O+t*da+v*Y;this.n22=m*D+n*K+t*J+v*W;this.n23=m*H+n*G+t*R+v*o;this.n24=m*N+n*B+t*S+v*ea;this.n31=w*F+u*O+x*da+p*Y;this.n32=w*D+u*K+x*J+p*W;this.n33=w*H+u*G+x*R+p*o;this.n34=w*N+u*B+x*S+p*ea;this.n41=y*F+A*O+z*da+E*Y;this.n42=y*D+A*K+z*J+E*W;this.n43=y*H+A*G+z*R+E*o;this.n44= -y*N+A*B+z*S+E*ea;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*= +e*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,f=b.n12,h=b.n13,k=b.n14,m=b.n21,n=b.n22,t=b.n23,v=b.n24,w=b.n31,u=b.n32,x=b.n33,p=b.n34,y=b.n41,A=b.n42,z=b.n43,F=b.n44,E=c.n11,D=c.n12, +G=c.n13,N=c.n14,O=c.n21,K=c.n22,H=c.n23,B=c.n24,da=c.n31,J=c.n32,R=c.n33,S=c.n34,Y=c.n41,W=c.n42,o=c.n43,ea=c.n44;this.n11=e*E+f*O+h*da+k*Y;this.n12=e*D+f*K+h*J+k*W;this.n13=e*G+f*H+h*R+k*o;this.n14=e*N+f*B+h*S+k*ea;this.n21=m*E+n*O+t*da+v*Y;this.n22=m*D+n*K+t*J+v*W;this.n23=m*G+n*H+t*R+v*o;this.n24=m*N+n*B+t*S+v*ea;this.n31=w*E+u*O+x*da+p*Y;this.n32=w*D+u*K+x*J+p*W;this.n33=w*G+u*H+x*R+p*o;this.n34=w*N+u*B+x*S+p*ea;this.n41=y*E+A*O+z*da+F*Y;this.n42=y*D+A*K+z*J+F*W;this.n43=y*G+A*H+z*R+F*o;this.n44= +y*N+A*B+z*S+F*ea;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);e[0]=this.n11;e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*= b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},determinant:function(){var b=this.n11,c=this.n12,e=this.n13,f=this.n14,h=this.n21,k=this.n22,m=this.n23,n=this.n24,t=this.n31,v=this.n32,w=this.n33,u=this.n34,x=this.n41,p=this.n42,y=this.n43,A=this.n44;return f*m*v*x-e*n*v*x-f*k*w*x+c*n*w*x+e*k*u*x-c*m*u*x-f*m*t*p+e*n*t*p+f*h*w*p-b*n*w*p-e*h*u*p+b*m*u*p+f*k*t*y-c*n*t*y-f*h*v*y+b*n*v*y+c*h*u*y-b*k*u*y-e*k*t*A+c*m*t*A+e*h*v*A-b*m*v*A-c*h* w*A+b*k*w*A},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34= this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]= @@ -42,8 +42,8 @@ b.x,e=b.y,f=b.z,h=b.w,k=c+c,m=e+e,n=f+f,b=c*k,t=c*m;c*=n;var v=e*m;e*=n;f*=n;k*= f.identity();f.setRotationFromQuaternion(c);h.setScale(e.x,e.y,e.z);this.multiply(f,h);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,k=THREE.Matrix4.__v3;f.set(this.n11,this.n21,this.n31);h.set(this.n12,this.n22,this.n32);k.set(this.n13,this.n23,this.n33);b=b instanceof THREE.Vector3?b:new THREE.Vector3;c=c instanceof THREE.Quaternion?c:new THREE.Quaternion;e=e instanceof THREE.Vector3?e:new THREE.Vector3;e.x=f.length(); e.y=h.length();e.z=k.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;f=THREE.Matrix4.__m1;f.copy(this);f.n11/=e.x;f.n21/=e.x;f.n31/=e.x;f.n12/=e.y;f.n22/=e.y;f.n32/=e.y;f.n13/=e.z;f.n23/=e.z;f.n33/=e.z;c.setFromRotationMatrix(f);return[b,c,e]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var e=1/c.x,f=1/c.y,h=1/c.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*h;this.n23= b.n23*h;this.n33=b.n33*h}}; -THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,h=b.n13,k=b.n14,m=b.n21,n=b.n22,t=b.n23,v=b.n24,w=b.n31,u=b.n32,x=b.n33,p=b.n34,y=b.n41,A=b.n42,z=b.n43,E=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=t*p*A-v*x*A+v*u*z-n*p*z-t*u*E+n*x*E;c.n12=k*x*A-h*p*A-k*u*z+f*p*z+h*u*E-f*x*E;c.n13=h*v*A-k*t*A+k*n*z-f*v*z-h*n*E+f*t*E;c.n14=k*t*u-h*v*u-k*n*x+f*v*x+h*n*p-f*t*p;c.n21=v*x*y-t*p*y-v*w*z+m*p*z+t*w*E-m*x*E;c.n22=h*p*y-k*x*y+k*w*z-e*p*z-h*w*E+e*x*E;c.n23=k*t*y-h*v*y-k*m*z+e*v*z+h*m*E-e*t*E;c.n24= -h*v*w-k*t*w+k*m*x-e*v*x-h*m*p+e*t*p;c.n31=n*p*y-v*u*y+v*w*A-m*p*A-n*w*E+m*u*E;c.n32=k*u*y-f*p*y-k*w*A+e*p*A+f*w*E-e*u*E;c.n33=h*v*y-k*n*y+k*m*A-e*v*A-f*m*E+e*n*E;c.n34=k*n*w-f*v*w-k*m*u+e*v*u+f*m*p-e*n*p;c.n41=t*u*y-n*x*y-t*w*A+m*x*A+n*w*z-m*u*z;c.n42=f*x*y-h*u*y+h*w*A-e*x*A-f*w*z+e*u*z;c.n43=h*n*y-f*t*y-h*m*A+e*t*A+f*m*z-e*n*z;c.n44=f*t*w-h*n*w+h*m*u-e*t*u-f*m*x+e*n*x;c.multiplyScalar(1/b.determinant());return c}; +THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,h=b.n13,k=b.n14,m=b.n21,n=b.n22,t=b.n23,v=b.n24,w=b.n31,u=b.n32,x=b.n33,p=b.n34,y=b.n41,A=b.n42,z=b.n43,F=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=t*p*A-v*x*A+v*u*z-n*p*z-t*u*F+n*x*F;c.n12=k*x*A-h*p*A-k*u*z+f*p*z+h*u*F-f*x*F;c.n13=h*v*A-k*t*A+k*n*z-f*v*z-h*n*F+f*t*F;c.n14=k*t*u-h*v*u-k*n*x+f*v*x+h*n*p-f*t*p;c.n21=v*x*y-t*p*y-v*w*z+m*p*z+t*w*F-m*x*F;c.n22=h*p*y-k*x*y+k*w*z-e*p*z-h*w*F+e*x*F;c.n23=k*t*y-h*v*y-k*m*z+e*v*z+h*m*F-e*t*F;c.n24= +h*v*w-k*t*w+k*m*x-e*v*x-h*m*p+e*t*p;c.n31=n*p*y-v*u*y+v*w*A-m*p*A-n*w*F+m*u*F;c.n32=k*u*y-f*p*y-k*w*A+e*p*A+f*w*F-e*u*F;c.n33=h*v*y-k*n*y+k*m*A-e*v*A-f*m*F+e*n*F;c.n34=k*n*w-f*v*w-k*m*u+e*v*u+f*m*p-e*n*p;c.n41=t*u*y-n*x*y-t*w*A+m*x*A+n*w*z-m*u*z;c.n42=f*x*y-h*u*y+h*w*A-e*x*A-f*w*z+e*u*z;c.n43=h*n*y-f*t*y-h*m*A+e*t*A+f*m*z-e*n*z;c.n44=f*t*w-h*n*w+h*m*u-e*t*u-f*m*x+e*n*x;c.multiplyScalar(1/b.determinant());return c}; THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,k=b.n32*b.n21-b.n31*b.n22,m=-b.n33*b.n12+b.n32*b.n13,n=b.n33*b.n11-b.n31*b.n13,t=-b.n32*b.n11+b.n31*b.n12,v=b.n23*b.n12-b.n22*b.n13,w=-b.n23*b.n11+b.n21*b.n13,u=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*m+b.n31*v;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*k;e[3]=b*m;e[4]=b*n;e[5]=b*t;e[6]=b*v;e[7]=b*w;e[8]=b*u;return c}; THREE.Matrix4.makeFrustum=function(b,c,e,f,h,k){var m;m=new THREE.Matrix4;m.n11=2*h/(c-b);m.n12=0;m.n13=(c+b)/(c-b);m.n14=0;m.n21=0;m.n22=2*h/(f-e);m.n23=(f+e)/(f-e);m.n24=0;m.n31=0;m.n32=0;m.n33=-(k+h)/(k-h);m.n34=-2*k*h/(k-h);m.n41=0;m.n42=0;m.n43=-1;m.n44=0;return m};THREE.Matrix4.makePerspective=function(b,c,e,f){var h,b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*c,b*c,h,b,e,f)}; THREE.Matrix4.makeOrtho=function(b,c,e,f,h,k){var m,n,t,v;m=new THREE.Matrix4;n=c-b;t=e-f;v=k-h;m.n11=2/n;m.n12=0;m.n13=0;m.n14=-((c+b)/n);m.n21=0;m.n22=2/t;m.n23=0;m.n24=-((e+f)/t);m.n31=0;m.n32=0;m.n33=-2/v;m.n34=-((k+h)/v);m.n41=0;m.n42=0;m.n43=0;m.n44=1;return m};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;THREE.Matrix4.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4; @@ -54,17 +54,17 @@ THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(b,c){thi b)return h;if(c&&(h=h.getChildByName(b,c),h!==void 0))return h}},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},update:function(b,c,e){this.matrixAutoUpdate&& this.updateMatrix();if(this.matrixWorldNeedsUpdate||c)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,c=!0;for(var b=0,f=this.children.length;b=0&&h>=0&&m>=0&&n>=0?!0:k<0&&h<0||m<0&&n<0?!1:(k<0?c=Math.max(c,k/(k-h)):h<0&&(f=Math.min(f,k/(k-h))),m<0?c=Math.max(c,m/(m-n)):n<0&&(f=Math.min(f,m/(m-n))),fo&&m.positionScreen.z=0&&h>=0&&m>=0&&n>=0?!0:k<0&&h<0||m<0&&n<0?!1:(k<0?c=Math.max(c,k/(k-h)):h<0&&(f=Math.min(f,k/(k-h))),m<0?c=Math.max(c,m/(m-n)):n<0&&(f=Math.min(f,m/(m-n))),fo&&m.positionScreen.z0&&K.z<1))ga=D[F]=D[F]||new THREE.RenderableParticle,F++,E=ga,E.x=K.x/K.w,E.y=K.y/K.w,E.z=K.z,E.rotation= -X.rotation.z,E.scale.x=X.scale.x*Math.abs(E.x-(K.x+k.projectionMatrix.n11)/(K.w+k.projectionMatrix.n14)),E.scale.y=X.scale.y*Math.abs(E.y-(K.y+k.projectionMatrix.n22)/(K.w+k.projectionMatrix.n24)),E.materials=X.materials,N.push(E);h&&N.sort(c);return N}};THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)}; +(ka.positionScreen.y-fa.positionScreen.y)*(ca.positionScreen.x-fa.positionScreen.x)<0)))qa=p[x]=p[x]||new THREE.RenderableFace4,x++,v=qa,v.v1.copy(aa),v.v2.copy(ka),v.v3.copy(fa),v.v4.copy(ca);else continue;v.normalWorld.copy(Z.normal);la.multiplyVector3(v.normalWorld);v.centroidWorld.copy(Z.centroid);ga.multiplyVector3(v.centroidWorld);v.centroidScreen.copy(v.centroidWorld);H.multiplyVector3(v.centroidScreen);fa=Z.vertexNormals;aa=0;for(ka=fa.length;aa0&&K.z<1))ga=D[E]=D[E]||new THREE.RenderableParticle,E++,F=ga,F.x=K.x/K.w,F.y=K.y/K.w,F.z=K.z,F.rotation= +X.rotation.z,F.scale.x=X.scale.x*Math.abs(F.x-(K.x+k.projectionMatrix.n11)/(K.w+k.projectionMatrix.n14)),F.scale.y=X.scale.y*Math.abs(F.y-(K.y+k.projectionMatrix.n22)/(K.w+k.projectionMatrix.n24)),F.materials=X.materials,N.push(F);h&&N.sort(c);return N}};THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)}; THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=Math.PI/360,e=b.x*c,f=b.y*c,h=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-h),h=Math.sin(-h),k=Math.cos(e),e=Math.sin(e),m=b*c,n=f*h;this.w=m*k-n*e;this.x=m*e+n*k;this.y=f*c*k+b*h*e;this.z=b*h*k-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e); this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(e);return this},setFromRotationMatrix:function(b){var c=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,c+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,c-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,c-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.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 b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},multiplySelf:function(b){var c= @@ -78,9 +78,9 @@ c;b++)e=this.faces[b],e.centroid.set(0,0,0),e instanceof THREE.Face3?(e.centroid e,f,h,k,m,n=new THREE.Vector3,t=new THREE.Vector3;f=0;for(h=this.faces.length;f0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y, +e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c]),e.vertexNormals[3].copy(f[e.d]))},computeTangents:function(){function b(b,e,c,f,k,h,o){n=b.vertices[e].position;t=b.vertices[c].position;v=b.vertices[f].position;w=m[k];u=m[h];x=m[o];p=t.x-n.x;y=v.x-n.x;A=t.y-n.y;z=v.y-n.y;F=t.z-n.z;E=v.z-n.z;D=u.u-w.u;G=x.u-w.u;N=u.v-w.v;O=x.v-w.v;K=1/(D*O-G*N);J.set((O*p-N*y)*K,(O*A-N*z)*K,(O*F-N*E)*K);R.set((D*y-G*p)*K,(D*z-G*A)*K,(D*E-G*F)*K);B[e].addSelf(J);B[c].addSelf(J);B[f].addSelf(J);da[e].addSelf(R); +da[c].addSelf(R);da[f].addSelf(R)}var c,e,f,h,k,m,n,t,v,w,u,x,p,y,A,z,F,E,D,G,N,O,K,H,B=[],da=[],J=new THREE.Vector3,R=new THREE.Vector3,S=new THREE.Vector3,Y=new THREE.Vector3,W=new THREE.Vector3;c=0;for(e=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,e=this.vertices.length;cthis.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.ythis.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.zthis.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;c0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b* +t.height=w;L.set(-u,-x,u,x);U.set(-u,-x,u,x);z=1;F=0;O=N=G=D=E=null};this.setClearColor=function(b,e){y.copy(b);A=e;U.set(-u,-x,u,x)};this.setClearColorHex=function(b,e){y.setHex(b);A=e;U.set(-u,-x,u,x)};this.clear=function(){p.setTransform(1,0,0,-1,u,x);U.isEmpty()||(U.minSelf(L),U.inflate(2),A<1&&p.clearRect(Math.floor(U.getX()),Math.floor(U.getY()),Math.floor(U.getWidth()),Math.floor(U.getHeight())),A>0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+Math.floor(y.b* 255)+","+A+")"),p.fillRect(Math.floor(U.getX()),Math.floor(U.getY()),Math.floor(U.getWidth()),Math.floor(U.getHeight()))),U.empty())};this.render=function(b,v){function t(b){var e,c,f,k=b.lights;ja.setRGB(0,0,0);ya.setRGB(0,0,0);xa.setRGB(0,0,0);b=0;for(e=k.length;b>1,va=t.height>>1,m=k.scale.x*u,v=k.scale.y*x,o=m*w,n=v*va,M.set(b.x-o,b.y-n,b.x+o,b.y+n),L.intersects(M)&&(p.save(),p.translate(b.x,b.y),p.rotate(-k.rotation),p.scale(m,-v),p.translate(-w,-va),p.drawImage(t,0,0),p.restore())}else m instanceof THREE.ParticleCanvasMaterial&&(o=k.scale.x*u,n=k.scale.y*x,M.set(b.x-o,b.y-n,b.x+o,b.y+n),L.intersects(M)&&(f(m.color.getContextStyle()),h(m.color.getContextStyle()),p.save(),p.translate(b.x,b.y),p.rotate(-k.rotation),p.scale(o,n),m.program(p), -p.restore()))}function z(b,k,h,m){c(m.opacity);e(m.blending);p.beginPath();p.moveTo(b.positionScreen.x,b.positionScreen.y);p.lineTo(k.positionScreen.x,k.positionScreen.y);p.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(H!=b)p.lineWidth=H=b;b=m.linecap;if(N!=b)p.lineCap=N=b;b=m.linejoin;if(O!=b)p.lineJoin=O=b;f(m.color.getContextStyle());p.stroke();M.inflate(m.linewidth*2)}}function A(b,f,h,m,n,u,t,p,x){k.info.render.vertices+=3;k.info.render.faces++;c(p.opacity);e(p.blending); -S=b.positionScreen.x;Y=b.positionScreen.y;W=f.positionScreen.x;o=f.positionScreen.y;ea=h.positionScreen.x;Q=h.positionScreen.y;F(S,Y,W,o,ea,Q);if(p instanceof THREE.MeshBasicMaterial)if(p.map)p.map.mapping instanceof THREE.UVMapping&&(qa=t.uvs[0],ab(S,Y,W,o,ea,Q,qa[m].u,qa[m].v,qa[n].u,qa[n].v,qa[u].u,qa[u].v,p.map));else if(p.envMap){if(p.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=v.matrixWorldInverse,pa.copy(t.vertexNormalsWorld[0]),wa=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5, +p.restore()))}function z(b,k,h,m){c(m.opacity);e(m.blending);p.beginPath();p.moveTo(b.positionScreen.x,b.positionScreen.y);p.lineTo(k.positionScreen.x,k.positionScreen.y);p.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(G!=b)p.lineWidth=G=b;b=m.linecap;if(N!=b)p.lineCap=N=b;b=m.linejoin;if(O!=b)p.lineJoin=O=b;f(m.color.getContextStyle());p.stroke();M.inflate(m.linewidth*2)}}function A(b,f,h,m,n,u,t,p,x){k.info.render.vertices+=3;k.info.render.faces++;c(p.opacity);e(p.blending); +S=b.positionScreen.x;Y=b.positionScreen.y;W=f.positionScreen.x;o=f.positionScreen.y;ea=h.positionScreen.x;Q=h.positionScreen.y;E(S,Y,W,o,ea,Q);if(p instanceof THREE.MeshBasicMaterial)if(p.map)p.map.mapping instanceof THREE.UVMapping&&(qa=t.uvs[0],ab(S,Y,W,o,ea,Q,qa[m].u,qa[m].v,qa[n].u,qa[n].v,qa[u].u,qa[u].v,p.map));else if(p.envMap){if(p.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=v.matrixWorldInverse,pa.copy(t.vertexNormalsWorld[0]),wa=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5, ta=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(t.vertexNormalsWorld[1]),Ea=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,Aa=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,pa.copy(t.vertexNormalsWorld[2]),Ca=(pa.x*b.n11+pa.y*b.n12+pa.z*b.n13)*0.5+0.5,Fa=-(pa.x*b.n21+pa.y*b.n22+pa.z*b.n23)*0.5+0.5,ab(S,Y,W,o,ea,Q,wa,ta,Ea,Aa,Ca,Fa,p.envMap)}else p.wireframe?Na(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Oa(p.color);else if(p instanceof THREE.MeshLambertMaterial)p.map&&!p.wireframe&& (p.map.mapping instanceof THREE.UVMapping&&(qa=t.uvs[0],ab(S,Y,W,o,ea,Q,qa[m].u,qa[m].v,qa[n].u,qa[n].v,qa[u].u,qa[u].v,p.map)),e(THREE.SubtractiveBlending)),ua?!p.wireframe&&p.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==3?($.r=X.r=ga.r=ja.r,$.g=X.g=ga.g=ja.g,$.b=X.b=ga.b=ja.b,w(x,t.v1.positionWorld,t.vertexNormalsWorld[0],$),w(x,t.v2.positionWorld,t.vertexNormalsWorld[1],X),w(x,t.v3.positionWorld,t.vertexNormalsWorld[2],ga),$.r=Math.max(0,Math.min(p.color.r*$.r,1)),$.g=Math.max(0, Math.min(p.color.g*$.g,1)),$.b=Math.max(0,Math.min(p.color.b*$.b,1)),X.r=Math.max(0,Math.min(p.color.r*X.r,1)),X.g=Math.max(0,Math.min(p.color.g*X.g,1)),X.b=Math.max(0,Math.min(p.color.b*X.b,1)),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)),la.r=(X.r+ga.r)*0.5,la.g=(X.g+ga.g)*0.5,la.b=(X.b+ga.b)*0.5,oa=Ya($,X,ga,la),Va(S,Y,W,o,ea,Q,0,0,1,0,0,1,oa)):(ha.r=ja.r,ha.g=ja.g,ha.b=ja.b,w(x,t.centroidWorld,t.normalWorld, ha),ca.r=Math.max(0,Math.min(p.color.r*ha.r,1)),ca.g=Math.max(0,Math.min(p.color.g*ha.g,1)),ca.b=Math.max(0,Math.min(p.color.b*ha.b,1)),p.wireframe?Na(ca,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Oa(ca)):p.wireframe?Na(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Oa(p.color);else if(p instanceof THREE.MeshDepthMaterial)na=v.near,P=v.far,$.r=$.g=$.b=1-Ra(b.positionScreen.z,na,P),X.r=X.g=X.b=1-Ra(f.positionScreen.z,na,P),ga.r=ga.g=ga.b=1-Ra(h.positionScreen.z, -na,P),la.r=(X.r+ga.r)*0.5,la.g=(X.g+ga.g)*0.5,la.b=(X.b+ga.b)*0.5,oa=Ya($,X,ga,la),Va(S,Y,W,o,ea,Q,0,0,1,0,0,1,oa);else if(p instanceof THREE.MeshNormalMaterial)ca.r=Wa(t.normalWorld.x),ca.g=Wa(t.normalWorld.y),ca.b=Wa(t.normalWorld.z),p.wireframe?Na(ca,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Oa(ca)}function E(b,f,h,m,n,u,t,p,x){k.info.render.vertices+=4;k.info.render.faces++;c(p.opacity);e(p.blending);if(p.map||p.envMap)A(b,f,m,0,1,3,t,p,x),A(n,h,u,1,2,3,t,p,x);else if(S=b.positionScreen.x, +na,P),la.r=(X.r+ga.r)*0.5,la.g=(X.g+ga.g)*0.5,la.b=(X.b+ga.b)*0.5,oa=Ya($,X,ga,la),Va(S,Y,W,o,ea,Q,0,0,1,0,0,1,oa);else if(p instanceof THREE.MeshNormalMaterial)ca.r=Wa(t.normalWorld.x),ca.g=Wa(t.normalWorld.y),ca.b=Wa(t.normalWorld.z),p.wireframe?Na(ca,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Oa(ca)}function F(b,f,h,m,n,u,t,p,x){k.info.render.vertices+=4;k.info.render.faces++;c(p.opacity);e(p.blending);if(p.map||p.envMap)A(b,f,m,0,1,3,t,p,x),A(n,h,u,1,2,3,t,p,x);else if(S=b.positionScreen.x, Y=b.positionScreen.y,W=f.positionScreen.x,o=f.positionScreen.y,ea=h.positionScreen.x,Q=h.positionScreen.y,ma=m.positionScreen.x,Z=m.positionScreen.y,ia=n.positionScreen.x,aa=n.positionScreen.y,ka=u.positionScreen.x,fa=u.positionScreen.y,p instanceof THREE.MeshBasicMaterial)D(S,Y,W,o,ea,Q,ma,Z),p.wireframe?Na(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Oa(p.color);else if(p instanceof THREE.MeshLambertMaterial)ua?!p.wireframe&&p.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length== 4?($.r=X.r=ga.r=la.r=ja.r,$.g=X.g=ga.g=la.g=ja.g,$.b=X.b=ga.b=la.b=ja.b,w(x,t.v1.positionWorld,t.vertexNormalsWorld[0],$),w(x,t.v2.positionWorld,t.vertexNormalsWorld[1],X),w(x,t.v4.positionWorld,t.vertexNormalsWorld[3],ga),w(x,t.v3.positionWorld,t.vertexNormalsWorld[2],la),$.r=Math.max(0,Math.min(p.color.r*$.r,1)),$.g=Math.max(0,Math.min(p.color.g*$.g,1)),$.b=Math.max(0,Math.min(p.color.b*$.b,1)),X.r=Math.max(0,Math.min(p.color.r*X.r,1)),X.g=Math.max(0,Math.min(p.color.g*X.g,1)),X.b=Math.max(0,Math.min(p.color.b* -X.b,1)),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)),la.r=Math.max(0,Math.min(p.color.r*la.r,1)),la.g=Math.max(0,Math.min(p.color.g*la.g,1)),la.b=Math.max(0,Math.min(p.color.b*la.b,1)),oa=Ya($,X,ga,la),F(S,Y,W,o,ma,Z),Va(S,Y,W,o,ma,Z,0,0,1,0,0,1,oa),F(ia,aa,ea,Q,ka,fa),Va(ia,aa,ea,Q,ka,fa,1,0,1,1,0,1,oa)):(ha.r=ja.r,ha.g=ja.g,ha.b=ja.b,w(x,t.centroidWorld,t.normalWorld,ha),ca.r=Math.max(0,Math.min(p.color.r*ha.r, +X.b,1)),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)),la.r=Math.max(0,Math.min(p.color.r*la.r,1)),la.g=Math.max(0,Math.min(p.color.g*la.g,1)),la.b=Math.max(0,Math.min(p.color.b*la.b,1)),oa=Ya($,X,ga,la),E(S,Y,W,o,ma,Z),Va(S,Y,W,o,ma,Z,0,0,1,0,0,1,oa),E(ia,aa,ea,Q,ka,fa),Va(ia,aa,ea,Q,ka,fa,1,0,1,1,0,1,oa)):(ha.r=ja.r,ha.g=ja.g,ha.b=ja.b,w(x,t.centroidWorld,t.normalWorld,ha),ca.r=Math.max(0,Math.min(p.color.r*ha.r, 1)),ca.g=Math.max(0,Math.min(p.color.g*ha.g,1)),ca.b=Math.max(0,Math.min(p.color.b*ha.b,1)),D(S,Y,W,o,ea,Q,ma,Z),p.wireframe?Na(ca,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Oa(ca)):(D(S,Y,W,o,ea,Q,ma,Z),p.wireframe?Na(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Oa(p.color));else if(p instanceof THREE.MeshNormalMaterial)ca.r=Wa(t.normalWorld.x),ca.g=Wa(t.normalWorld.y),ca.b=Wa(t.normalWorld.z),D(S,Y,W,o,ea,Q,ma,Z),p.wireframe?Na(ca,p.wireframeLinewidth,p.wireframeLinecap, -p.wireframeLinejoin):Oa(ca);else if(p instanceof THREE.MeshDepthMaterial)na=v.near,P=v.far,$.r=$.g=$.b=1-Ra(b.positionScreen.z,na,P),X.r=X.g=X.b=1-Ra(f.positionScreen.z,na,P),ga.r=ga.g=ga.b=1-Ra(m.positionScreen.z,na,P),la.r=la.g=la.b=1-Ra(h.positionScreen.z,na,P),oa=Ya($,X,ga,la),F(S,Y,W,o,ma,Z),Va(S,Y,W,o,ma,Z,0,0,1,0,0,1,oa),F(ia,aa,ea,Q,ka,fa),Va(ia,aa,ea,Q,ka,fa,1,0,1,1,0,1,oa)}function F(b,e,c,f,k,h){p.beginPath();p.moveTo(b,e);p.lineTo(c,f);p.lineTo(k,h);p.lineTo(b,e);p.closePath()}function D(b, -e,c,f,k,h,m,o){p.beginPath();p.moveTo(b,e);p.lineTo(c,f);p.lineTo(k,h);p.lineTo(m,o);p.lineTo(b,e);p.closePath()}function Na(b,e,c,k){if(H!=e)p.lineWidth=H=e;if(N!=c)p.lineCap=N=c;if(O!=k)p.lineJoin=O=k;f(b.getContextStyle());p.stroke();M.inflate(e*2)}function Oa(b){h(b.getContextStyle());p.fill()}function ab(b,e,c,f,k,m,o,n,u,t,v,w,va){if(va.image.width!=0){if(va.needsUpdate==!0||ra[va.id]==void 0){var x=va.wrapS==THREE.RepeatWrapping,y=va.wrapT==THREE.RepeatWrapping;ra[va.id]=p.createPattern(va.image, +p.wireframeLinejoin):Oa(ca);else if(p instanceof THREE.MeshDepthMaterial)na=v.near,P=v.far,$.r=$.g=$.b=1-Ra(b.positionScreen.z,na,P),X.r=X.g=X.b=1-Ra(f.positionScreen.z,na,P),ga.r=ga.g=ga.b=1-Ra(m.positionScreen.z,na,P),la.r=la.g=la.b=1-Ra(h.positionScreen.z,na,P),oa=Ya($,X,ga,la),E(S,Y,W,o,ma,Z),Va(S,Y,W,o,ma,Z,0,0,1,0,0,1,oa),E(ia,aa,ea,Q,ka,fa),Va(ia,aa,ea,Q,ka,fa,1,0,1,1,0,1,oa)}function E(b,e,c,f,k,h){p.beginPath();p.moveTo(b,e);p.lineTo(c,f);p.lineTo(k,h);p.lineTo(b,e);p.closePath()}function D(b, +e,c,f,k,h,m,o){p.beginPath();p.moveTo(b,e);p.lineTo(c,f);p.lineTo(k,h);p.lineTo(m,o);p.lineTo(b,e);p.closePath()}function Na(b,e,c,k){if(G!=e)p.lineWidth=G=e;if(N!=c)p.lineCap=N=c;if(O!=k)p.lineJoin=O=k;f(b.getContextStyle());p.stroke();M.inflate(e*2)}function Oa(b){h(b.getContextStyle());p.fill()}function ab(b,e,c,f,k,m,o,n,u,t,v,w,va){if(va.image.width!=0){if(va.needsUpdate==!0||ra[va.id]==void 0){var x=va.wrapS==THREE.RepeatWrapping,y=va.wrapT==THREE.RepeatWrapping;ra[va.id]=p.createPattern(va.image, x&&y?"repeat":x&&!y?"repeat-x":!x&&y?"repeat-y":"no-repeat");va.needsUpdate=!1}h(ra[va.id]);var x=va.offset.x/va.repeat.x,y=va.offset.y/va.repeat.y,L=(va.image.width-1)*va.repeat.x,va=(va.image.height-1)*va.repeat.y,o=(o+x)*L,n=(n+y)*va,u=(u+x)*L,t=(t+y)*va,v=(v+x)*L,w=(w+y)*va;c-=b;f-=e;k-=b;m-=e;u-=o;t-=n;v-=o;w-=n;x=1/(u*w-v*t);va=(w*c-t*k)*x;t=(w*f-t*m)*x;c=(u*k-v*c)*x;f=(u*m-v*f)*x;b=b-va*o-c*n;e=e-t*o-f*n;p.save();p.transform(va,t,c,f,b,e);p.fill();p.restore()}}function Va(b,e,c,f,k,m,h,o,n, u,t,v,va){var w,x;w=va.width-1;x=va.height-1;h*=w;o*=x;n*=w;u*=x;t*=w;v*=x;c-=b;f-=e;k-=b;m-=e;n-=h;u-=o;t-=h;v-=o;x=1/(n*v-t*u);w=(v*c-u*k)*x;u=(v*f-u*m)*x;c=(n*k-t*c)*x;f=(n*m-t*f)*x;b=b-w*h-c*o;e=e-u*h-f*o;p.save();p.transform(w,u,c,f,b,e);p.clip();p.drawImage(va,0,0);p.restore()}function Ya(b,e,c,f){var k=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),m=~~(e.r*255),o=~~(e.g*255),e=~~(e.b*255),n=~~(c.r*255),p=~~(c.g*255),c=~~(c.b*255),u=~~(f.r*255),t=~~(f.g*255),f=~~(f.b*255);Ba[0]=k<0?0:k>255?255:k; Ba[1]=h<0?0:h>255?255:h;Ba[2]=b<0?0:b>255?255:b;Ba[4]=m<0?0:m>255?255:m;Ba[5]=o<0?0:o>255?255:o;Ba[6]=e<0?0:e>255?255:e;Ba[8]=n<0?0:n>255?255:n;Ba[9]=p<0?0:p>255?255:p;Ba[10]=c<0?0:c>255?255:c;Ba[12]=u<0?0:u>255?255:u;Ba[13]=t<0?0:t>255?255:t;Ba[14]=f<0?0:f>255?255:f;Da.putImageData(Ka,0,0);V.drawImage(Ia,0,0);return Ga}function Ra(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Wa(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Pa(b,e){var c=e.x-b.x,f=e.y-b.y,k=c*c+f*f;k!=0&&(k=1/Math.sqrt(k),c*=k, -f*=k,e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Za,bb,sa,Ha,Qa,Xa,$a,za;this.autoClear?this.clear():p.setTransform(1,0,0,-1,u,x);k.info.render.vertices=0;k.info.render.faces=0;m=n.projectScene(b,v,this.sortElements);(ua=b.lights.length>0)&&t(b);Za=0;for(bb=m.length;Za0)&&t(b);Za=0;for(bb=m.length;Za0&&(c.r+=h.color.r*m,c.g+=h.color.g*m,c.b+=h.color.b*m)):h instanceof THREE.PointLight&&(da.sub(h.position,e.centroidWorld),da.normalize(),m=e.normalWorld.dot(da)*h.intensity,m>0&&(c.r+=h.color.r*m,c.g+=h.color.g*m,c.b+=h.color.b*m))}function c(e,c,m,o,n,p){k.info.render.vertices+=3;k.info.render.faces++;S=f(Y++); -S.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?H.copy(n.color):n instanceof THREE.MeshLambertMaterial?D?(N.r=O.r,N.g=O.g,N.b=O.b,b(p,o,N),H.r=Math.max(0,Math.min(n.color.r*N.r,1)),H.g=Math.max(0,Math.min(n.color.g*N.g,1)),H.b=Math.max(0,Math.min(n.color.b*N.b,1))):H.copy(n.color):n instanceof THREE.MeshDepthMaterial?(B=1-n.__2near/(n.__farPlusNear- -o.z*n.__farMinusNear),H.setRGB(B,B,B)):n instanceof THREE.MeshNormalMaterial&&H.setRGB(h(o.normalWorld.x),h(o.normalWorld.y),h(o.normalWorld.z));n.wireframe?S.setAttribute("style","fill: none; stroke: "+H.getContextStyle()+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):S.setAttribute("style","fill: "+H.getContextStyle()+"; fill-opacity: "+n.opacity);t.appendChild(S)}function e(e,c,m,n,o,p,u){k.info.render.vertices+= -4;k.info.render.faces++;S=f(Y++);S.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+" L "+n.positionScreen.x+","+n.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?H.copy(p.color):p instanceof THREE.MeshLambertMaterial?D?(N.r=O.r,N.g=O.g,N.b=O.b,b(u,o,N),H.r=Math.max(0,Math.min(p.color.r*N.r,1)),H.g=Math.max(0,Math.min(p.color.g*N.g,1)),H.b=Math.max(0,Math.min(p.color.b*N.b,1))): -H.copy(p.color):p instanceof THREE.MeshDepthMaterial?(B=1-p.__2near/(p.__farPlusNear-o.z*p.__farMinusNear),H.setRGB(B,B,B)):p instanceof THREE.MeshNormalMaterial&&H.setRGB(h(o.normalWorld.x),h(o.normalWorld.y),h(o.normalWorld.z));p.wireframe?S.setAttribute("style","fill: none; stroke: "+H.getContextStyle()+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):S.setAttribute("style","fill: "+H.getContextStyle()+ -"; fill-opacity: "+p.opacity);t.appendChild(S)}function f(b){J[b]==null&&(J[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),o==0&&J[b].setAttribute("shape-rendering","crispEdges"));return J[b]}function h(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var k=this,m=null,n=new THREE.Projector,t=document.createElementNS("http://www.w3.org/2000/svg","svg"),v,w,u,x,p,y,A,z,E=new THREE.Rectangle,F=new THREE.Rectangle,D=!1,H=new THREE.Color(16777215),N=new THREE.Color(16777215),O=new THREE.Color(0), -K=new THREE.Color(0),G=new THREE.Color(0),B,da=new THREE.Vector3,J=[],R=[],S,Y,W,o=1;this.domElement=t;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(b){switch(b){case "high":o=1;break;case "low":o=0}};this.setSize=function(b,e){v=b;w=e;u=v/2;x=w/2;t.setAttribute("viewBox",-u+" "+-x+" "+v+" "+w);t.setAttribute("width",v);t.setAttribute("height",w);E.set(-u,-x,u,x)};this.clear=function(){for(;t.childNodes.length>0;)t.removeChild(t.childNodes[0])}; -this.render=function(b,f){var h,v,w,H,N,J,B,$;this.autoClear&&this.clear();k.info.render.vertices=0;k.info.render.faces=0;m=n.projectScene(b,f,this.sortElements);W=Y=0;if(D=b.lights.length>0){B=b.lights;O.setRGB(0,0,0);K.setRGB(0,0,0);G.setRGB(0,0,0);h=0;for(v=B.length;h1?1:b}var k=this,m=null,n=new THREE.Projector,t=document.createElementNS("http://www.w3.org/2000/svg","svg"),v,w,u,x,p,y,A,z,F=new THREE.Rectangle,E=new THREE.Rectangle,D=!1,G=new THREE.Color(16777215),N=new THREE.Color(16777215),O=new THREE.Color(0), +K=new THREE.Color(0),H=new THREE.Color(0),B,da=new THREE.Vector3,J=[],R=[],S,Y,W,o=1;this.domElement=t;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(b){switch(b){case "high":o=1;break;case "low":o=0}};this.setSize=function(b,e){v=b;w=e;u=v/2;x=w/2;t.setAttribute("viewBox",-u+" "+-x+" "+v+" "+w);t.setAttribute("width",v);t.setAttribute("height",w);F.set(-u,-x,u,x)};this.clear=function(){for(;t.childNodes.length>0;)t.removeChild(t.childNodes[0])}; +this.render=function(b,f){var h,v,w,G,N,J,B,$;this.autoClear&&this.clear();k.info.render.vertices=0;k.info.render.faces=0;m=n.projectScene(b,f,this.sortElements);W=Y=0;if(D=b.lights.length>0){B=b.lights;O.setRGB(0,0,0);K.setRGB(0,0,0);H.setRGB(0,0,0);h=0;for(v=B.length;h=0)c&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(b.position,3,o.FLOAT,!1,0,0));else if(m.morphTargetBase){f=k.program.attributes;m.morphTargetBase!==-1?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[m.morphTargetBase]), -o.vertexAttribPointer(f.position,3,o.FLOAT,!1,0,0)):f.position>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(f.position,3,o.FLOAT,!1,0,0));if(m.morphTargetForcedOrder.length)for(var u=0,p=m.morphTargetForcedOrder,v=m.morphTargetInfluences;ut&&(w=x,t=v[w]);o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[w]);o.vertexAttribPointer(f["morphTarget"+u],3,o.FLOAT,!1,0,0);m.__webglMorphTargetInfluences[u]=t;p[w]=1;t=-1;u++}}k.program.uniforms.morphTargetInfluences!==null&&o.uniform1fv(k.program.uniforms.morphTargetInfluences,m.__webglMorphTargetInfluences)}if(c){if(h.__webglCustomAttributes)for(n in h.__webglCustomAttributes)b[n]>= +o.vertexAttribPointer(f.position,3,o.FLOAT,!1,0,0)):f.position>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(f.position,3,o.FLOAT,!1,0,0));if(m.morphTargetForcedOrder.length)for(var p=0,u=m.morphTargetForcedOrder,v=m.morphTargetInfluences;pt&&(w=x,t=v[w]);o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[w]);o.vertexAttribPointer(f["morphTarget"+p],3,o.FLOAT,!1,0,0);m.__webglMorphTargetInfluences[p]=t;u[w]=1;t=-1;p++}}k.program.uniforms.morphTargetInfluences!==null&&o.uniform1fv(k.program.uniforms.morphTargetInfluences,m.__webglMorphTargetInfluences)}if(c){if(h.__webglCustomAttributes)for(n in h.__webglCustomAttributes)b[n]>= 0&&(f=h.__webglCustomAttributes[n],o.bindBuffer(o.ARRAY_BUFFER,f.buffer),o.vertexAttribPointer(b[n],f.size,o.FLOAT,!1,0,0));b.color>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglColorBuffer),o.vertexAttribPointer(b.color,3,o.FLOAT,!1,0,0));b.normal>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglNormalBuffer),o.vertexAttribPointer(b.normal,3,o.FLOAT,!1,0,0));b.tangent>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglTangentBuffer),o.vertexAttribPointer(b.tangent,4,o.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(o.bindBuffer(o.ARRAY_BUFFER, h.__webglUVBuffer),o.vertexAttribPointer(b.uv,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(b.uv)):o.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglUV2Buffer),o.vertexAttribPointer(b.uv2,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(b.uv2)):o.disableVertexAttribArray(b.uv2));k.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinVertexABuffer),o.vertexAttribPointer(b.skinVertexA,4, o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinVertexBBuffer),o.vertexAttribPointer(b.skinVertexB,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),o.vertexAttribPointer(b.skinIndex,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),o.vertexAttribPointer(b.skinWeight,4,o.FLOAT,!1,0,0))}m instanceof THREE.Mesh?(k.wireframe?(o.lineWidth(k.wireframeLinewidth),c&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),o.drawElements(o.LINES,h.__webglLineCount, o.UNSIGNED_SHORT,0)):(c&&o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,h.__webglFaceBuffer),o.drawElements(o.TRIANGLES,h.__webglFaceCount,o.UNSIGNED_SHORT,0)),W.info.render.calls++,W.info.render.vertices+=h.__webglFaceCount,W.info.render.faces+=h.__webglFaceCount/3):m instanceof THREE.Line?(m=m.type==THREE.LineStrip?o.LINE_STRIP:o.LINES,o.lineWidth(k.linewidth),o.drawArrays(m,0,h.__webglLineCount),W.info.render.calls++):m instanceof THREE.ParticleSystem?(o.drawArrays(o.POINTS,0,h.__webglParticleCount),W.info.render.calls++): m instanceof THREE.Ribbon&&(o.drawArrays(o.TRIANGLE_STRIP,0,h.__webglVertexCount),W.info.render.calls++)}}function h(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=o.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=o.createBuffer();b.hasPos&&(o.bindBuffer(o.ARRAY_BUFFER,b.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,b.positionArray,o.DYNAMIC_DRAW),o.enableVertexAttribArray(e.attributes.position),o.vertexAttribPointer(e.attributes.position,3,o.FLOAT,!1,0,0));if(b.hasNormal){o.bindBuffer(o.ARRAY_BUFFER, -b.__webglNormalBuffer);if(c==THREE.FlatShading){var f,h,k,m,n,u,p,v,t,w,x=b.count*3;for(w=0;w=0;c--)b[c].object==e&&b.splice(c,1)}function N(b){function e(b){var h=[];c=0;for(f=b.length;c65535&&(p[o].counter+=1,u=p[o].hash+"_"+p[o].counter,b.geometryGroups[u]==void 0&&(b.geometryGroups[u]={faces:[], -materials:n,vertices:0,numMorphTargets:t})),b.geometryGroups[u].faces.push(h),b.geometryGroups[u].vertices+=m;b.geometryGroupsList=[];for(var v in b.geometryGroups)b.geometryGroups[v].id=aa++,b.geometryGroupsList.push(b.geometryGroups[v])}function O(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function K(b){if(b!=ca){switch(b){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)}ca=b}}function G(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(o.texParameteri(b,o.TEXTURE_WRAP_S,Y(e.wrapS)),o.texParameteri(b,o.TEXTURE_WRAP_T,Y(e.wrapT)),o.texParameteri(b,o.TEXTURE_MAG_FILTER,Y(e.magFilter)), +(h.position.x-u)/u,(t-h.position.y)/t,Math.max(0,Math.min(1,h.position.z)))):(o.uniform1i(k.useScreenCoordinates,0),o.uniform1i(k.affectedByDistance,h.affectedByDistance?1:0),o.uniformMatrix4fv(k.modelViewMatrix,!1,h._modelViewMatrixArray)),n=h.map.image.width/(h.scaleByViewport?qa:1),p[0]=n*m*h.scale.x,p[1]=n*h.scale.y,o.uniform2f(k.uvScale,h.uvScale.x,h.uvScale.y),o.uniform2f(k.uvOffset,h.uvOffset.x,h.uvOffset.y),o.uniform2f(k.alignment,h.alignment.x,h.alignment.y),o.uniform1f(k.opacity,h.opacity), +o.uniform3f(k.color,h.color.r,h.color.g,h.color.b),o.uniform1f(k.rotation,h.rotation),o.uniform2fv(k.scale,p),h.mergeWith3D&&!v?(o.enable(o.DEPTH_TEST),v=!0):!h.mergeWith3D&&v&&(o.disable(o.DEPTH_TEST),v=!1),K(h.blending),B(h.map,0),o.drawElements(o.TRIANGLES,6,o.UNSIGNED_SHORT,0));o.enable(o.CULL_FACE);o.enable(o.DEPTH_TEST);o.depthMask(X)}function F(b,e,c){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)} +function E(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b=0;c--)b[c].object==e&&b.splice(c,1)}function N(b){function e(b){var h=[];c=0;for(f=b.length;c65535&&(u[o].counter+=1,p=u[o].hash+"_"+u[o].counter,b.geometryGroups[p]==void 0&&(b.geometryGroups[p]={faces:[], +materials:n,vertices:0,numMorphTargets:t})),b.geometryGroups[p].faces.push(h),b.geometryGroups[p].vertices+=m;b.geometryGroupsList=[];for(var v in b.geometryGroups)b.geometryGroups[v].id=aa++,b.geometryGroupsList.push(b.geometryGroups[v])}function O(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function K(b){if(b!=ca){switch(b){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)}ca=b}}function H(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(o.texParameteri(b,o.TEXTURE_WRAP_S,Y(e.wrapS)),o.texParameteri(b,o.TEXTURE_WRAP_T,Y(e.wrapT)),o.texParameteri(b,o.TEXTURE_MAG_FILTER,Y(e.magFilter)), o.texParameteri(b,o.TEXTURE_MIN_FILTER,Y(e.minFilter)),o.generateMipmap(b)):(o.texParameteri(b,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(b,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(b,o.TEXTURE_MAG_FILTER,S(e.magFilter)),o.texParameteri(b,o.TEXTURE_MIN_FILTER,S(e.minFilter)))}function B(b,e){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=o.createTexture(),W.info.memory.textures++;o.activeTexture(o.TEXTURE0+e);o.bindTexture(o.TEXTURE_2D,b.__webglTexture);b instanceof -THREE.DataTexture?o.texImage2D(o.TEXTURE_2D,0,Y(b.format),b.image.width,b.image.height,0,Y(b.format),o.UNSIGNED_BYTE,b.image.data):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,b.image);G(o.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+e),o.bindTexture(o.TEXTURE_2D,b.__webglTexture)}function da(b){var e=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0; -b.__webglRenderbuffer=o.createRenderbuffer();b.__webglTexture=o.createTexture();if(e){o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture);G(o.TEXTURE_CUBE_MAP,b,b);b.__webglFramebuffer=[];for(var c=0;c<6;c++)b.__webglFramebuffer[c]=o.createFramebuffer(),o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,Y(b.format),b.width,b.height,0,Y(b.format),Y(b.type),null)}else b.__webglFramebuffer=o.createFramebuffer(),o.bindTexture(o.TEXTURE_2D,b.__webglTexture),G(o.TEXTURE_2D,b,b),o.texImage2D(o.TEXTURE_2D,0,Y(b.format), +THREE.DataTexture?o.texImage2D(o.TEXTURE_2D,0,Y(b.format),b.image.width,b.image.height,0,Y(b.format),o.UNSIGNED_BYTE,b.image.data):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,b.image);H(o.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+e),o.bindTexture(o.TEXTURE_2D,b.__webglTexture)}function da(b){var e=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0; +b.__webglRenderbuffer=o.createRenderbuffer();b.__webglTexture=o.createTexture();if(e){o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture);H(o.TEXTURE_CUBE_MAP,b,b);b.__webglFramebuffer=[];for(var c=0;c<6;c++)b.__webglFramebuffer[c]=o.createFramebuffer(),o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,Y(b.format),b.width,b.height,0,Y(b.format),Y(b.type),null)}else b.__webglFramebuffer=o.createFramebuffer(),o.bindTexture(o.TEXTURE_2D,b.__webglTexture),H(o.TEXTURE_2D,b,b),o.texImage2D(o.TEXTURE_2D,0,Y(b.format), b.width,b.height,0,Y(b.format),Y(b.type),null);o.bindRenderbuffer(o.RENDERBUFFER,b.__webglRenderbuffer);if(e)for(c=0;c<6;++c)o.bindFramebuffer(o.FRAMEBUFFER,b.__webglFramebuffer[c]),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+c,b.__webglTexture,0);else o.bindFramebuffer(o.FRAMEBUFFER,b.__webglFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER, o.DEPTH_COMPONENT16,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,b.__webglRenderbuffer)):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,b.__webglRenderbuffer)):o.renderbufferStorage(o.RENDERBUFFER,o.RGBA4,b.width,b.height);e?o.bindTexture(o.TEXTURE_CUBE_MAP,null):o.bindTexture(o.TEXTURE_2D,null);o.bindRenderbuffer(o.RENDERBUFFER, null);o.bindFramebuffer(o.FRAMEBUFFER,null)}var f,h;b?(e=e?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,c=b.width,b=b.height,h=f=0):(e=null,c=oa,b=qa,f=na,h=P);e!=ma&&(o.bindFramebuffer(o.FRAMEBUFFER,e),o.viewport(f,h,c,b),ma=e)}function J(b){b instanceof THREE.WebGLRenderTargetCube?(o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture),o.generateMipmap(o.TEXTURE_CUBE_MAP),o.bindTexture(o.TEXTURE_CUBE_MAP,null)):(o.bindTexture(o.TEXTURE_2D,b.__webglTexture),o.generateMipmap(o.TEXTURE_2D), @@ -280,59 +280,59 @@ function(b,e){ha.setHex(b);ja=e;o.clearColor(ha.r,ha.g,ha.b,ja)};this.setClearCo delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var e=b.geometry.geometryGroups[g];o.deleteBuffer(e.__webglVertexBuffer);o.deleteBuffer(e.__webglNormalBuffer);o.deleteBuffer(e.__webglTangentBuffer);o.deleteBuffer(e.__webglColorBuffer);o.deleteBuffer(e.__webglUVBuffer);o.deleteBuffer(e.__webglUV2Buffer);o.deleteBuffer(e.__webglSkinVertexABuffer);o.deleteBuffer(e.__webglSkinVertexBBuffer);o.deleteBuffer(e.__webglSkinIndicesBuffer); o.deleteBuffer(e.__webglSkinWeightsBuffer);o.deleteBuffer(e.__webglFaceBuffer);o.deleteBuffer(e.__webglLineBuffer);if(e.numMorphTargets)for(var c=0,f=e.numMorphTargets;c=0&&o.enableVertexAttribArray(x.position);x.color>=0&&o.enableVertexAttribArray(x.color);x.normal>=0&&o.enableVertexAttribArray(x.normal);x.tangent>=0&&o.enableVertexAttribArray(x.tangent);b.skinning&&x.skinVertexA>=0&&x.skinVertexB>=0&&x.skinIndex>=0&&x.skinWeight>=0&&(o.enableVertexAttribArray(x.skinVertexA), o.enableVertexAttribArray(x.skinVertexB),o.enableVertexAttribArray(x.skinIndex),o.enableVertexAttribArray(x.skinWeight));if(b.attributes)for(k in b.attributes)x[k]!==void 0&&x[k]>=0&&o.enableVertexAttribArray(x[k]);if(b.morphTargets)for(k=b.numSupportedMorphTargets=0;k=0&&(o.enableVertexAttribArray(x[L]),b.numSupportedMorphTargets++);b.uniformsList=[];for(h in b.uniforms)b.uniformsList.push([b.uniforms[h],h])};this.clearTarget=function(b,e,c,f){da(b); -this.clear(e,c,f)};this.render=function(b,c,u,L){var M,U,F,D,H,na,B,G,ua=b.lights,N=b.fog;Z=-1;this.shadowMapEnabled&&A(b,c);W.info.render.calls=0;W.info.render.vertices=0;W.info.render.faces=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Aa);c.projectionMatrix.flattenToArray(Ea);ta.multiply(c.projectionMatrix,c.matrixWorldInverse);v(ta);this.initWebGLObjects(b);da(u);(this.autoClear||L)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil); -H=b.__webglObjects.length;for(L=0;L=0;L--)if(M=b.__webglObjects[L],M.render){B=M.object;G=M.buffer;F=M.opaque;k(B);for(M=0;M=0;L--)if(M=b.__webglObjects[L],M.render){B=M.object;H=M.buffer;E=M.opaque;k(B);for(M=0;M0||w.faceVertexUvs.length>0)m.__uvArray=new Float32Array(u*2);if(w.faceUvs.length>1||w.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(u*2)}if(n.geometry.skinWeights.length&&n.geometry.skinIndices.length)m.__skinVertexAArray=new Float32Array(u*4),m.__skinVertexBArray= -new Float32Array(u*4),m.__skinIndexArray=new Float32Array(u*4),m.__skinWeightArray=new Float32Array(u*4);m.__faceArray=new Uint16Array(y*3+(n.geometry.edgeFaces?n.geometry.edgeFaces.length*6:0));m.__lineArray=new Uint16Array(M*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];w=0;for(L=m.numMorphTargets;w0||w.faceVertexUvs.length>0)m.__uvArray=new Float32Array(p*2);if(w.faceUvs.length>1||w.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(p*2)}if(n.geometry.skinWeights.length&&n.geometry.skinIndices.length)m.__skinVertexAArray=new Float32Array(p*4),m.__skinVertexBArray= +new Float32Array(p*4),m.__skinIndexArray=new Float32Array(p*4),m.__skinWeightArray=new Float32Array(p*4);m.__faceArray=new Uint16Array(y*3+(n.geometry.edgeFaces?n.geometry.edgeFaces.length*6:0));m.__lineArray=new Uint16Array(M*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];w=0;for(L=m.numMorphTargets;w=0;k--)f[k]==h&&f.splice(k,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&H(f.__webglObjectsImmediate,e);e.__webglActive=!1;b.__objectsRemoved.splice(0, -1)}e=0;for(f=b.__webglObjects.length;e=0;k--)f[k]==h&&f.splice(k,1)}else(e instanceof THREE.MarchingCubes||e.immediateRenderCallback)&&G(f.__webglObjectsImmediate,e);e.__webglActive=!1;b.__objectsRemoved.splice(0, +1)}e=0;for(f=b.__webglObjects.length;e0&&(o.bindBuffer(o.ARRAY_BUFFER, -p.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,ca,y));Ga&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglNormalBuffer),o.bufferData(o.ARRAY_BUFFER,la,y));Ka&&ta.hasTangents&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglTangentBuffer),o.bufferData(o.ARRAY_BUFFER,ia,y));Aa&&$>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,xa,y));Aa&&da>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,wa,y));Ba&&(o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,p.__webglFaceBuffer), -o.bufferData(o.ELEMENT_ARRAY_BUFFER,ma,y),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,p.__webglLineBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,ra,y));T>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,aa,y),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,Z,y),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,ea,y),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER, -fa,y));M&&(delete p.__inittedArrays,delete p.__colorArray,delete p.__normalArray,delete p.__tangentArray,delete p.__uvArray,delete p.__uv2Array,delete p.__faceArray,delete p.__vertexArray,delete p.__lineArray,delete p.__skinVertexAArray,delete p.__skinVertexBArray,delete p.__skinIndexArray,delete p.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;D(m)}else if(k instanceof THREE.Ribbon){h= -k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=o.DYNAMIC_DRAW;n=w=M=M=void 0;t=k.vertices;u=k.colors;v=t.length;p=u.length;L=k.__vertexArray;y=k.__colorArray;z=k.__dirtyColors;if(k.__dirtyVertices){for(M=0;M0&&(o.bindBuffer(o.ARRAY_BUFFER, +u.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,ca,y));Ga&&(o.bindBuffer(o.ARRAY_BUFFER,u.__webglNormalBuffer),o.bufferData(o.ARRAY_BUFFER,la,y));Ka&&ta.hasTangents&&(o.bindBuffer(o.ARRAY_BUFFER,u.__webglTangentBuffer),o.bufferData(o.ARRAY_BUFFER,ia,y));Aa&&$>0&&(o.bindBuffer(o.ARRAY_BUFFER,u.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,xa,y));Aa&&da>0&&(o.bindBuffer(o.ARRAY_BUFFER,u.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,wa,y));Ba&&(o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,u.__webglFaceBuffer), +o.bufferData(o.ELEMENT_ARRAY_BUFFER,ma,y),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,u.__webglLineBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,ra,y));T>0&&(o.bindBuffer(o.ARRAY_BUFFER,u.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,aa,y),o.bindBuffer(o.ARRAY_BUFFER,u.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,Z,y),o.bindBuffer(o.ARRAY_BUFFER,u.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,ea,y),o.bindBuffer(o.ARRAY_BUFFER,u.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER, +fa,y));M&&(delete u.__inittedArrays,delete u.__colorArray,delete u.__normalArray,delete u.__tangentArray,delete u.__uvArray,delete u.__uv2Array,delete u.__faceArray,delete u.__vertexArray,delete u.__lineArray,delete u.__skinVertexAArray,delete u.__skinVertexBArray,delete u.__skinIndexArray,delete u.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;D(m)}else if(k instanceof THREE.Ribbon){h= +k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=o.DYNAMIC_DRAW;n=w=M=M=void 0;t=k.vertices;p=k.colors;v=t.length;u=p.length;L=k.__vertexArray;y=k.__colorArray;z=k.__dirtyColors;if(k.__dirtyVertices){for(M=0;M1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=m;c.v=k;return c}, clamp:function(b,c,e){return be?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0}; THREE.GeometryUtils={merge:function(b,c){var e,f,h=b.vertices.length,k=c instanceof THREE.Mesh?c.geometry:c,m=b.vertices,n=k.vertices,t=b.faces,v=k.faces,w=b.faceVertexUvs[0],k=k.faceVertexUvs[0];if(c instanceof THREE.Mesh)c.matrixAutoUpdate&&c.updateMatrix(),e=c.matrix,f=new THREE.Matrix4,f.extractRotation(e,c.scale);for(var u=0,x=n.length;u1&&(f=1-f,h=1-h);k=1-f-h;m.copy(b);m.multiplyScalar(f);n.copy(c);n.multiplyScalar(h);m.addSelf(n);n.copy(e);n.multiplyScalar(k);m.addSelf(n);return m},randomPointInFace:function(b,c,e){var f,h,k;if(b instanceof THREE.Face3)return f=c.vertices[b.a].position,h=c.vertices[b.b].position,k=c.vertices[b.c].position,THREE.GeometryUtils.randomPointInTriangle(f,h,k);else if(b instanceof THREE.Face4){f=c.vertices[b.a].position;h=c.vertices[b.b].position;k=c.vertices[b.c].position;var c=c.vertices[b.d].position, @@ -353,9 +353,9 @@ b?e(c,h-1):v[h]0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,m,0)));for(n=0;n0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-m,0)));for(n=0;n0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,m,0)));for(n=0;n0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-m,0)));for(n=0;nb&&(b+=Math.PI*2),anglec=(e+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(m).addSelf(n).subSelf(b).clone()}function h(b){for(J=b.length;--J>=0;){ka=J;fa=J-1;fa<0&&(fa=b.length- -1);for(var e=0,c=p+w*2,e=0;e=0;S--){Y=S/w;W=t*(1-Y);Y=v*Math.sin(Y*Math.PI/2);J=0;for(R=F.length;J=0;S--){Y=S/w;W=t*(1-Y);Y=v*Math.sin(Y*Math.PI/2);J=0;for(R=E.length;J0)for(v=0;v2;){if(u--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return n;return k}t=v;h<=t&&(t=0);v=t+1;h<=v&&(v=0);w=v+1;h<=w&&(w=0);var x;a:{x=b;var p=t,y=v,A=w,z=h,E=m,F=void 0,D=void 0,H=void 0, -N=void 0,O=void 0,K=void 0,G=void 0,B=void 0,da=void 0,D=x[E[p]].x,H=x[E[p]].y,N=x[E[y]].x,O=x[E[y]].y,K=x[E[A]].x,G=x[E[A]].y;if(1.0E-10>(N-D)*(G-H)-(O-H)*(K-D))x=!1;else{for(F=0;F=0&&S>=0&&W>=0){x= +v));h.moveTo(n,v);break;case "l":n=c[b++]*e+f;v=c[b++]*e;k.push(new THREE.Vector2(n,v));h.lineTo(n,v);break;case "q":n=c[b++]*e+f;v=c[b++]*e;x=c[b++]*e+f;p=c[b++]*e;h.quadraticCurveTo(x,p,n,v);if(m=k[k.length-1]){w=m.x;u=m.y;m=1;for(divisions=this.divisions;m<=divisions;m++){var F=m/divisions,E=THREE.Shape.Utils.b2(F,w,x,n),F=THREE.Shape.Utils.b2(F,u,p,v);k.push(new THREE.Vector2(E,F))}}break;case "b":if(n=c[b++]*e+f,v=c[b++]*e,x=c[b++]*e+f,p=c[b++]*-e,y=c[b++]*e+f,A=c[b++]*-e,h.bezierCurveTo(n,v, +x,p,y,A),m=k[k.length-1]){w=m.x;u=m.y;m=1;for(divisions=this.divisions;m<=divisions;m++)F=m/divisions,E=THREE.Shape.Utils.b3(F,w,x,y,n),F=THREE.Shape.Utils.b3(F,u,p,A,v),k.push(new THREE.Vector2(E,F))}}}return{offset:z.ha*e,points:k,path:h}}}}; +(function(b){var c=function(b){for(var c=b.length,h=0,k=c-1,m=0;m0)for(v=0;v2;){if(u--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return n;return k}t=v;h<=t&&(t=0);v=t+1;h<=v&&(v=0);w=v+1;h<=w&&(w=0);var x;a:{x=b;var p=t,y=v,A=w,z=h,F=m,E=void 0,D=void 0,G=void 0, +N=void 0,O=void 0,K=void 0,H=void 0,B=void 0,da=void 0,D=x[F[p]].x,G=x[F[p]].y,N=x[F[y]].x,O=x[F[y]].y,K=x[F[A]].x,H=x[F[A]].y;if(1.0E-10>(N-D)*(H-G)-(O-G)*(K-D))x=!1;else{for(E=0;E=0&&S>=0&&W>=0){x= !1;break a}}x=!0}}if(x){k.push([b[m[t]],b[m[v]],b[m[w]]]);n.push([m[t],m[v],m[w]]);t=v;for(w=v+1;w0;)this.smooth(b)}; +THREE.SubdivisionModifier.prototype.smooth=function(b){function c(b,e,c,f,n){var p=new THREE.Face4(b,e,c,f,null,n.color,n.material);if(m.useOldVertexColors)p.vertexColors=n.vertexColors;h.push(p);(!m.supportUVs||u.length!=0)&&k.push([u[b],u[e],u[c],u[f]])}function e(b,e){return Math.min(b,e)+"_"+Math.max(b,e)}var f=[],h=[],k=[],m=this,n=b.vertices,f=b.faces,t=n.concat(),v=[],w={},u=[],x,p,y,A,z,F=b.faceVertexUvs[0];x=0;for(p=F.length;x>7)-127;f|=(k&127)<<16|h<<8;if(f==0&&n==-127)return 0;return(1-2*(m>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,n)}function h(b,e){var c=w(b,e),f=w(b,e+1),k=w(b,e+2);return(w(b,e+3)<<24)+(k<<16)+(f<<8)+c}function t(b,e){var c=w(b,e);return(w(b,e+1)<<8)+c}function v(b,e){var c=w(b,e);return c>127?c-256:c}function w(b,e){return b.charCodeAt(e)&255}function u(e){var c, -f,k;c=h(b,e);f=h(b,e+O);k=h(b,e+K);e=t(b,e+G);E.faces.push(new THREE.Face3(c,f,k,null,null,E.materials[e]))}function x(e){var c,f,k,m,o,p;c=h(b,e);f=h(b,e+O);k=h(b,e+K);m=t(b,e+G);o=h(b,e+B);p=h(b,e+da);e=h(b,e+J);m=E.materials[m];var u=H[p*3],v=H[p*3+1];p=H[p*3+2];var w=H[e*3],x=H[e*3+1],e=H[e*3+2];E.faces.push(new THREE.Face3(c,f,k,[new THREE.Vector3(H[o*3],H[o*3+1],H[o*3+2]),new THREE.Vector3(u,v,p),new THREE.Vector3(w,x,e)],null,m))}function p(e){var c,f,k,m;c=h(b,e);f=h(b,e+R);k=h(b,e+S);m=h(b, -e+Y);e=t(b,e+W);E.faces.push(new THREE.Face4(c,f,k,m,null,null,E.materials[e]))}function y(e){var c,f,k,m,p,u,v,w;c=h(b,e);f=h(b,e+R);k=h(b,e+S);m=h(b,e+Y);p=t(b,e+W);u=h(b,e+o);v=h(b,e+ea);w=h(b,e+Q);e=h(b,e+ma);p=E.materials[p];var x=H[v*3],L=H[v*3+1];v=H[v*3+2];var y=H[w*3],M=H[w*3+1];w=H[w*3+2];var z=H[e*3],A=H[e*3+1],e=H[e*3+2];E.faces.push(new THREE.Face4(c,f,k,m,[new THREE.Vector3(H[u*3],H[u*3+1],H[u*3+2]),new THREE.Vector3(x,L,v),new THREE.Vector3(y,M,w),new THREE.Vector3(z,A,e)],null,p))} -function A(e){var c,f,k,m;c=h(b,e);f=h(b,e+Z);k=h(b,e+ia);e=N[c*2];m=N[c*2+1];c=N[f*2];var o=E.faceVertexUvs[0];f=N[f*2+1];var p=N[k*2];k=N[k*2+1];var t=[];t.push(new THREE.UV(e,m));t.push(new THREE.UV(c,f));t.push(new THREE.UV(p,k));o.push(t)}function z(e){var c,f,k,m,o,p;c=h(b,e);f=h(b,e+aa);k=h(b,e+ka);m=h(b,e+fa);e=N[c*2];o=N[c*2+1];c=N[f*2];p=N[f*2+1];f=N[k*2];var t=E.faceVertexUvs[0];k=N[k*2+1];var u=N[m*2];m=N[m*2+1];var v=[];v.push(new THREE.UV(e,o));v.push(new THREE.UV(c,p));v.push(new THREE.UV(f, -k));v.push(new THREE.UV(u,m));t.push(v)}var E=this,F=0,D,H=[],N=[],O,K,G,B,da,J,R,S,Y,W,o,ea,Q,ma,Z,ia,aa,ka,fa,ca,$,X,ga,la,ra;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(E,f,e);D={signature:b.substr(F,8),header_bytes:w(b,F+8),vertex_coordinate_bytes:w(b,F+9),normal_coordinate_bytes:w(b,F+10),uv_coordinate_bytes:w(b,F+11),vertex_index_bytes:w(b,F+12),normal_index_bytes:w(b,F+13),uv_index_bytes:w(b,F+14),material_index_bytes:w(b,F+15),nvertices:h(b,F+16),nnormals:h(b,F+16+4),nuvs:h(b, -F+16+8),ntri_flat:h(b,F+16+12),ntri_smooth:h(b,F+16+16),ntri_flat_uv:h(b,F+16+20),ntri_smooth_uv:h(b,F+16+24),nquad_flat:h(b,F+16+28),nquad_smooth:h(b,F+16+32),nquad_flat_uv:h(b,F+16+36),nquad_smooth_uv:h(b,F+16+40)};F+=D.header_bytes;O=D.vertex_index_bytes;K=D.vertex_index_bytes*2;G=D.vertex_index_bytes*3;B=D.vertex_index_bytes*3+D.material_index_bytes;da=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes;J=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes*2;R=D.vertex_index_bytes; +f,k;c=h(b,e);f=h(b,e+O);k=h(b,e+K);e=t(b,e+H);F.faces.push(new THREE.Face3(c,f,k,null,null,F.materials[e]))}function x(e){var c,f,k,m,o,p;c=h(b,e);f=h(b,e+O);k=h(b,e+K);m=t(b,e+H);o=h(b,e+B);p=h(b,e+da);e=h(b,e+J);m=F.materials[m];var u=G[p*3],v=G[p*3+1];p=G[p*3+2];var w=G[e*3],x=G[e*3+1],e=G[e*3+2];F.faces.push(new THREE.Face3(c,f,k,[new THREE.Vector3(G[o*3],G[o*3+1],G[o*3+2]),new THREE.Vector3(u,v,p),new THREE.Vector3(w,x,e)],null,m))}function p(e){var c,f,k,m;c=h(b,e);f=h(b,e+R);k=h(b,e+S);m=h(b, +e+Y);e=t(b,e+W);F.faces.push(new THREE.Face4(c,f,k,m,null,null,F.materials[e]))}function y(e){var c,f,k,m,p,u,v,w;c=h(b,e);f=h(b,e+R);k=h(b,e+S);m=h(b,e+Y);p=t(b,e+W);u=h(b,e+o);v=h(b,e+ea);w=h(b,e+Q);e=h(b,e+ma);p=F.materials[p];var x=G[v*3],L=G[v*3+1];v=G[v*3+2];var y=G[w*3],M=G[w*3+1];w=G[w*3+2];var z=G[e*3],A=G[e*3+1],e=G[e*3+2];F.faces.push(new THREE.Face4(c,f,k,m,[new THREE.Vector3(G[u*3],G[u*3+1],G[u*3+2]),new THREE.Vector3(x,L,v),new THREE.Vector3(y,M,w),new THREE.Vector3(z,A,e)],null,p))} +function A(e){var c,f,k,m;c=h(b,e);f=h(b,e+Z);k=h(b,e+ia);e=N[c*2];m=N[c*2+1];c=N[f*2];var o=F.faceVertexUvs[0];f=N[f*2+1];var p=N[k*2];k=N[k*2+1];var t=[];t.push(new THREE.UV(e,m));t.push(new THREE.UV(c,f));t.push(new THREE.UV(p,k));o.push(t)}function z(e){var c,f,k,m,o,p;c=h(b,e);f=h(b,e+aa);k=h(b,e+ka);m=h(b,e+fa);e=N[c*2];o=N[c*2+1];c=N[f*2];p=N[f*2+1];f=N[k*2];var t=F.faceVertexUvs[0];k=N[k*2+1];var u=N[m*2];m=N[m*2+1];var v=[];v.push(new THREE.UV(e,o));v.push(new THREE.UV(c,p));v.push(new THREE.UV(f, +k));v.push(new THREE.UV(u,m));t.push(v)}var F=this,E=0,D,G=[],N=[],O,K,H,B,da,J,R,S,Y,W,o,ea,Q,ma,Z,ia,aa,ka,fa,ca,$,X,ga,la,ra;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(F,f,e);D={signature:b.substr(E,8),header_bytes:w(b,E+8),vertex_coordinate_bytes:w(b,E+9),normal_coordinate_bytes:w(b,E+10),uv_coordinate_bytes:w(b,E+11),vertex_index_bytes:w(b,E+12),normal_index_bytes:w(b,E+13),uv_index_bytes:w(b,E+14),material_index_bytes:w(b,E+15),nvertices:h(b,E+16),nnormals:h(b,E+16+4),nuvs:h(b, +E+16+8),ntri_flat:h(b,E+16+12),ntri_smooth:h(b,E+16+16),ntri_flat_uv:h(b,E+16+20),ntri_smooth_uv:h(b,E+16+24),nquad_flat:h(b,E+16+28),nquad_smooth:h(b,E+16+32),nquad_flat_uv:h(b,E+16+36),nquad_smooth_uv:h(b,E+16+40)};E+=D.header_bytes;O=D.vertex_index_bytes;K=D.vertex_index_bytes*2;H=D.vertex_index_bytes*3;B=D.vertex_index_bytes*3+D.material_index_bytes;da=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes;J=D.vertex_index_bytes*3+D.material_index_bytes+D.normal_index_bytes*2;R=D.vertex_index_bytes; S=D.vertex_index_bytes*2;Y=D.vertex_index_bytes*3;W=D.vertex_index_bytes*4;o=D.vertex_index_bytes*4+D.material_index_bytes;ea=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes;Q=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*2;ma=D.vertex_index_bytes*4+D.material_index_bytes+D.normal_index_bytes*3;Z=D.uv_index_bytes;ia=D.uv_index_bytes*2;aa=D.uv_index_bytes;ka=D.uv_index_bytes*2;fa=D.uv_index_bytes*3;e=D.vertex_index_bytes*3+D.material_index_bytes;ra=D.vertex_index_bytes* -4+D.material_index_bytes;ca=D.ntri_flat*e;$=D.ntri_smooth*(e+D.normal_index_bytes*3);X=D.ntri_flat_uv*(e+D.uv_index_bytes*3);ga=D.ntri_smooth_uv*(e+D.normal_index_bytes*3+D.uv_index_bytes*3);la=D.nquad_flat*ra;e=D.nquad_smooth*(ra+D.normal_index_bytes*4);ra=D.nquad_flat_uv*(ra+D.uv_index_bytes*4);F+=function(e){for(var f,h,k,n=D.vertex_coordinate_bytes*3,o=e+D.nvertices*n;e1){o=new THREE.MeshFaceMaterial;for(j=0;j1?c[1].substr(0,e):"0";c[1].length0&&(this[c.nodeName]=parseFloat(f[0].textContent))}}this.create();return this};B.prototype.create=function(){var b= -{},e=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var f=this[c];if(f instanceof G)if(f.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(f=ra[this.effect.surface.init_from]))b.map=THREE.ImageUtils.loadTexture(Ea+f.init_from),b.map.wrapS=THREE.RepeatWrapping,b.map.wrapT=THREE.RepeatWrapping,b.map.repeat.x=1,b.map.repeat.y=-1}else c=="diffuse"?b.color= +this.data.slice(e,e+16),f=new THREE.Matrix4;f.set(c[0],c[1],c[2],c[3],c[4],c[5],c[6],c[7],c[8],c[9],c[10],c[11],c[12],c[13],c[14],c[15]);b.push(f)}break;default:console.log("Dae::Source:read dont know how to read "+e.type)}return b};K.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");for(var e=0;e0&&(this[c.nodeName]=parseFloat(f[0].textContent))}}this.create();return this};B.prototype.create=function(){var b= +{},e=this.transparency!==void 0&&this.transparency<1,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var f=this[c];if(f instanceof H)if(f.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(f=ra[this.effect.surface.init_from]))b.map=THREE.ImageUtils.loadTexture(Ea+f.init_from),b.map.wrapS=THREE.RepeatWrapping,b.map.wrapT=THREE.RepeatWrapping,b.map.repeat.x=1,b.map.repeat.y=-1}else c=="diffuse"?b.color= f.color.getHex():e||(b[c]=f.color.getHex());break;case "shininess":case "reflectivity":b[c]=this[c];break;case "transparency":if(e)b.transparent=!0,b.opacity=this[c],e=!0}b.shading=Fa;return this.material=new THREE.MeshLambertMaterial(b)};da.prototype.parse=function(b){for(var e=0;e1&&(da=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(O,da);object.name=p;object.position.set(D[0],D[1],D[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=F.visible;Q.scene.add(object);Q.objects[p]=object;F.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),Q.scene.collisions.colliders.push(b)); -if(F.castsShadow)b=new THREE.ShadowVolume(O),Q.scene.add(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;F.trigger&&F.trigger.toLowerCase()!="none"&&(b={type:F.trigger,object:F},Q.triggers[object.name]=b)}}else D=F.position,r=F.rotation,q=F.quaternion,s=F.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(D[0],D[1],D[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], -s[1],s[2]),object.visible=F.visible!==void 0?F.visible:!1,Q.scene.add(object),Q.objects[p]=object,Q.empties[p]=object,F.trigger&&F.trigger.toLowerCase()!="none"&&(b={type:F.trigger,object:F},Q.triggers[object.name]=b)}function t(b){return function(c){Q.geometries[b]=c;n();Y-=1;e.onLoadComplete();w()}}function v(b){return function(e){Q.geometries[b]=e}}function w(){e.callbackProgress({totalModels:o,totalTextures:ea,loadedModels:o-Y,loadedTextures:ea-W},Q);e.onLoadProgress();Y==0&&W==0&&c(Q)}var u, -x,p,y,A,z,E,F,D,H,N,O,K,G,B,da,J,R,S,Y,W,o,ea,Q;R=b.data;B=new THREE.BinaryLoader;S=new THREE.JSONLoader;W=Y=0;Q={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(p in R.objects)if(F=R.objects[p],F.meshCollider){b=!0;break}if(b)Q.scene.collisions=new THREE.CollisionSystem;if(R.transform){b=R.transform.position;H=R.transform.rotation;var ma=R.transform.scale;b&&Q.scene.position.set(b[0],b[1],b[2]);H&&Q.scene.rotation.set(H[0], -H[1],H[2]);ma&&Q.scene.scale.set(ma[0],ma[1],ma[2]);(b||H||ma)&&Q.scene.updateMatrix()}b=function(){W-=1;w();e.onLoadComplete()};for(A in R.cameras){H=R.cameras[A];if(H.type=="perspective")K=new THREE.Camera(H.fov,H.aspect,H.near,H.far),K.useTarget=!0;else if(H.type=="ortho")K=new THREE.Camera,K.useTarget=!0,K.projectionMatrix=THREE.Matrix4.makeOrtho(H.left,H.right,H.top,H.bottom,H.near,H.far);D=H.position;H=H.target;K.position.set(D[0],D[1],D[2]);K.target.position.set(H[0],H[1],H[2]);Q.cameras[A]= -K}for(y in R.lights)A=R.lights[y],K=A.color!==void 0?A.color:16777215,H=A.intensity!==void 0?A.intensity:1,A.type=="directional"?(D=A.direction,J=new THREE.DirectionalLight(K,H),J.position.set(D[0],D[1],D[2]),J.position.normalize()):A.type=="point"?(D=A.position,d=A.distance,J=new THREE.PointLight(K,H,d),J.position.set(D[0],D[1],D[2])):A.type=="ambient"&&(J=new THREE.AmbientLight(K)),Q.scene.add(J),Q.lights[y]=J;for(z in R.fogs)y=R.fogs[z],y.type=="linear"?G=new THREE.Fog(0,y.near,y.far):y.type== -"exp2"&&(G=new THREE.FogExp2(0,y.density)),H=y.color,G.color.setRGB(H[0],H[1],H[2]),Q.fogs[z]=G;if(Q.cameras&&R.defaults.camera)Q.currentCamera=Q.cameras[R.defaults.camera];if(Q.fogs&&R.defaults.fog)Q.scene.fog=Q.fogs[R.defaults.fog];H=R.defaults.bgcolor;Q.bgColor=new THREE.Color;Q.bgColor.setRGB(H[0],H[1],H[2]);Q.bgColorAlpha=R.defaults.bgalpha;for(u in R.geometries)if(z=R.geometries[u],z.type=="bin_mesh"||z.type=="ascii_mesh")Y+=1,e.onLoadStart();o=Y;for(u in R.geometries)z=R.geometries[u],z.type== +THREE.SceneLoader.prototype={load:function(b,c){var e=this,f=new Worker(b);f.postMessage(0);var h=THREE.Loader.prototype.extractUrlbase(b);f.onmessage=function(b){function f(b,e){return e=="relativeToHTML"?b:h+"/"+b}function n(){for(p in R.objects)if(!Q.objects[p])if(E=R.objects[p],E.geometry!==void 0){if(O=Q.geometries[E.geometry]){var b=!1;da=[];for(Z=0;Z1&&(da=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(O,da);object.name=p;object.position.set(D[0],D[1],D[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=E.visible;Q.scene.add(object);Q.objects[p]=object;E.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),Q.scene.collisions.colliders.push(b)); +if(E.castsShadow)b=new THREE.ShadowVolume(O),Q.scene.add(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;E.trigger&&E.trigger.toLowerCase()!="none"&&(b={type:E.trigger,object:E},Q.triggers[object.name]=b)}}else D=E.position,r=E.rotation,q=E.quaternion,s=E.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(D[0],D[1],D[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0], +s[1],s[2]),object.visible=E.visible!==void 0?E.visible:!1,Q.scene.add(object),Q.objects[p]=object,Q.empties[p]=object,E.trigger&&E.trigger.toLowerCase()!="none"&&(b={type:E.trigger,object:E},Q.triggers[object.name]=b)}function t(b){return function(c){Q.geometries[b]=c;n();Y-=1;e.onLoadComplete();w()}}function v(b){return function(e){Q.geometries[b]=e}}function w(){e.callbackProgress({totalModels:o,totalTextures:ea,loadedModels:o-Y,loadedTextures:ea-W},Q);e.onLoadProgress();Y==0&&W==0&&c(Q)}var u, +x,p,y,A,z,F,E,D,G,N,O,K,H,B,da,J,R,S,Y,W,o,ea,Q;R=b.data;B=new THREE.BinaryLoader;S=new THREE.JSONLoader;W=Y=0;Q={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(p in R.objects)if(E=R.objects[p],E.meshCollider){b=!0;break}if(b)Q.scene.collisions=new THREE.CollisionSystem;if(R.transform){b=R.transform.position;G=R.transform.rotation;var ma=R.transform.scale;b&&Q.scene.position.set(b[0],b[1],b[2]);G&&Q.scene.rotation.set(G[0], +G[1],G[2]);ma&&Q.scene.scale.set(ma[0],ma[1],ma[2]);(b||G||ma)&&Q.scene.updateMatrix()}b=function(){W-=1;w();e.onLoadComplete()};for(A in R.cameras){G=R.cameras[A];if(G.type=="perspective")K=new THREE.Camera(G.fov,G.aspect,G.near,G.far),K.useTarget=!0;else if(G.type=="ortho")K=new THREE.Camera,K.useTarget=!0,K.projectionMatrix=THREE.Matrix4.makeOrtho(G.left,G.right,G.top,G.bottom,G.near,G.far);D=G.position;G=G.target;K.position.set(D[0],D[1],D[2]);K.target.position.set(G[0],G[1],G[2]);Q.cameras[A]= +K}for(y in R.lights)A=R.lights[y],K=A.color!==void 0?A.color:16777215,G=A.intensity!==void 0?A.intensity:1,A.type=="directional"?(D=A.direction,J=new THREE.DirectionalLight(K,G),J.position.set(D[0],D[1],D[2]),J.position.normalize()):A.type=="point"?(D=A.position,d=A.distance,J=new THREE.PointLight(K,G,d),J.position.set(D[0],D[1],D[2])):A.type=="ambient"&&(J=new THREE.AmbientLight(K)),Q.scene.add(J),Q.lights[y]=J;for(z in R.fogs)y=R.fogs[z],y.type=="linear"?H=new THREE.Fog(0,y.near,y.far):y.type== +"exp2"&&(H=new THREE.FogExp2(0,y.density)),G=y.color,H.color.setRGB(G[0],G[1],G[2]),Q.fogs[z]=H;if(Q.cameras&&R.defaults.camera)Q.currentCamera=Q.cameras[R.defaults.camera];if(Q.fogs&&R.defaults.fog)Q.scene.fog=Q.fogs[R.defaults.fog];G=R.defaults.bgcolor;Q.bgColor=new THREE.Color;Q.bgColor.setRGB(G[0],G[1],G[2]);Q.bgColorAlpha=R.defaults.bgalpha;for(u in R.geometries)if(z=R.geometries[u],z.type=="bin_mesh"||z.type=="ascii_mesh")Y+=1,e.onLoadStart();o=Y;for(u in R.geometries)z=R.geometries[u],z.type== "cube"?(O=new THREE.CubeGeometry(z.width,z.height,z.depth,z.segmentsWidth,z.segmentsHeight,z.segmentsDepth,null,z.flipped,z.sides),Q.geometries[u]=O):z.type=="plane"?(O=new THREE.PlaneGeometry(z.width,z.height,z.segmentsWidth,z.segmentsHeight),Q.geometries[u]=O):z.type=="sphere"?(O=new THREE.SphereGeometry(z.radius,z.segmentsWidth,z.segmentsHeight),Q.geometries[u]=O):z.type=="cylinder"?(O=new THREE.CylinderGeometry(z.topRad,z.botRad,z.height,z.radSegs,z.heightSegs),Q.geometries[u]=O):z.type=="torus"? -(O=new THREE.TorusGeometry(z.radius,z.tube,z.segmentsR,z.segmentsT),Q.geometries[u]=O):z.type=="icosahedron"?(O=new THREE.IcosahedronGeometry(z.subdivisions),Q.geometries[u]=O):z.type=="bin_mesh"?B.load({model:f(z.url,R.urlBaseType),callback:t(u)}):z.type=="ascii_mesh"?S.load({model:f(z.url,R.urlBaseType),callback:t(u)}):z.type=="embedded_mesh"&&(z=R.embeds[z.id])&&S.createModel(z,v(u),"");for(E in R.textures)if(u=R.textures[E],u.url instanceof Array){W+=u.url.length;for(B=0;B=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,h=0;h<8;h++){for(var k=0,m=0;m>1^-(n&1);e[8*m+h]=k}f+=c}c=b.length-f;k=new Uint16Array(c);for(h=m=0;h=this.maxCount-3&&n(this)};this.begin=function(){this.count=0; this.hasNormal=this.hasPos=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;cthis.size-1&&(t=this.size-1);var x=Math.floor(v-n);x<1&&(x=1);v=Math.floor(v+n);v>this.size-1&&(v=this.size-1);var p=Math.floor(w-n);p<1&&(p=1);n=Math.floor(w+n);n>this.size-1&&(n=this.size- -1);for(var y,A,z,E,F,D;u0&&(this.field[z+y]+=E)}}};this.addPlaneX=function(b,c){var h,k,m,n,t,v=this.size,w=this.yd,u=this.zd,x=this.field,p=v*Math.sqrt(b/c);p>v&&(p=v);for(h=0;h0)for(k=0;k0&&(this.field[z+y]+=F)}}};this.addPlaneX=function(b,c){var h,k,m,n,t,v=this.size,w=this.yd,u=this.zd,x=this.field,p=v*Math.sqrt(b/c);p>v&&(p=v);for(h=0;h0)for(k=0;kw&&(y=w);for(k=0;k0){t=k*u;for(h=0;hsize&&(dist=size);for(m=0;m0){t=zd*m;for(k=0;k - +