Browse Source

Rename SubdivisonGeometry.js to SubdivisionGeometry.js. Fix geometries which use duplicate vertices. SubdivisionGeometry tested with Cube/Sphere/Cylinder/TextGeometry

zz85 14 years ago
parent
commit
8edfa99583
5 changed files with 267 additions and 421 deletions
  1. 146 145
      build/Three.js
  2. 58 10
      examples/canvas_geometry_subdivison.html
  3. 62 17
      src/core/Geometry.js
  4. 0 248
      src/extras/geometries/SubdivisonGeometry.js
  5. 1 1
      utils/build.py

+ 146 - 145
build/Three.js

@@ -26,8 +26,8 @@ THREE.Matrix4=function(b,c,e,f,m,k,h,n,o,u,v,t,x,w,y,A){this.set(b!==void 0?b:1,
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,m,k,h,n,o,u,v,t,x,w,y,A){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=m;this.n22=k;this.n23=h;this.n24=n;this.n31=o;this.n32=u;this.n33=v;this.n34=t;this.n41=x;this.n42=w;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,m=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());m.cross(k,f).normalize();this.n11=f.x;this.n12=m.x;this.n13=k.x;this.n21=f.y;this.n22=m.y;this.n23=k.y;this.n31=f.z;this.n32=m.z;this.n33=k.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,m=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)*m;
 b.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*m;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*m;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,m=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*m;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*m;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*m;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*m;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,m=b.n13,k=b.n14,h=b.n21,n=b.n22,o=b.n23,u=b.n24,v=b.n31,t=b.n32,x=b.n33,w=b.n34,y=b.n41,A=b.n42,z=b.n43,D=b.n44,F=c.n11,C=c.n12,
-G=c.n13,N=c.n14,R=c.n21,H=c.n22,J=c.n23,I=c.n24,X=c.n31,E=c.n32,O=c.n33,P=c.n34,U=c.n41,V=c.n42,p=c.n43,ea=c.n44;this.n11=e*F+f*R+m*X+k*U;this.n12=e*C+f*H+m*E+k*V;this.n13=e*G+f*J+m*O+k*p;this.n14=e*N+f*I+m*P+k*ea;this.n21=h*F+n*R+o*X+u*U;this.n22=h*C+n*H+o*E+u*V;this.n23=h*G+n*J+o*O+u*p;this.n24=h*N+n*I+o*P+u*ea;this.n31=v*F+t*R+x*X+w*U;this.n32=v*C+t*H+x*E+w*V;this.n33=v*G+t*J+x*O+w*p;this.n34=v*N+t*I+x*P+w*ea;this.n41=y*F+A*R+z*X+D*U;this.n42=y*C+A*H+z*E+D*V;this.n43=y*G+A*J+z*O+D*p;this.n44=y*
+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,m=b.n13,k=b.n14,h=b.n21,n=b.n22,o=b.n23,u=b.n24,v=b.n31,t=b.n32,x=b.n33,w=b.n34,y=b.n41,A=b.n42,z=b.n43,D=b.n44,C=c.n11,F=c.n12,
+G=c.n13,N=c.n14,R=c.n21,H=c.n22,J=c.n23,I=c.n24,X=c.n31,E=c.n32,O=c.n33,P=c.n34,U=c.n41,V=c.n42,p=c.n43,ea=c.n44;this.n11=e*C+f*R+m*X+k*U;this.n12=e*F+f*H+m*E+k*V;this.n13=e*G+f*J+m*O+k*p;this.n14=e*N+f*I+m*P+k*ea;this.n21=h*C+n*R+o*X+u*U;this.n22=h*F+n*H+o*E+u*V;this.n23=h*G+n*J+o*O+u*p;this.n24=h*N+n*I+o*P+u*ea;this.n31=v*C+t*R+x*X+w*U;this.n32=v*F+t*H+x*E+w*V;this.n33=v*G+t*J+x*O+w*p;this.n34=v*N+t*I+x*P+w*ea;this.n41=y*C+A*R+z*X+D*U;this.n42=y*F+A*H+z*E+D*V;this.n43=y*G+A*J+z*O+D*p;this.n44=y*
 N+A*I+z*P+D*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,m=this.n21,k=this.n22,h=this.n23,n=this.n24,o=this.n31,u=this.n32,v=this.n33,t=this.n34,x=this.n41,w=this.n42,y=this.n43,A=this.n44;return f*h*u*x-e*n*u*x-f*k*v*x+c*n*v*x+e*k*t*x-c*h*t*x-f*h*o*w+e*n*o*w+f*m*v*w-b*n*v*w-e*m*t*w+b*h*t*w+f*k*o*y-c*n*o*y-f*m*u*y+b*n*u*y+c*m*t*y-b*k*t*y-e*k*o*A+c*h*o*A+e*m*u*A-b*h*u*A-c*m*
 v*A+b*k*v*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=
@@ -54,16 +54,16 @@ THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(b,c){thi
 b)return m;if(c&&(m=m.getChildByName(b,c),m!==void 0))return m}},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<f;b++)this.children[b].update(this.matrixWorld,c,e)},addChild:function(b){console.warn("DEPRECATED: Object3D.addChild() is now Object3D.add().");this.add(b)},removeChild:function(b){console.warn("DEPRECATED: Object3D.removeChild() is now Object3D.remove().");
 this.remove(b)}};THREE.Object3DCount=0;
-THREE.Projector=function(){function b(){var b=o[n]=o[n]||new THREE.RenderableVertex;n++;return b}function c(b,e){return e.z-b.z}function e(b,e){var c=0,f=1,k=b.z+b.w,m=e.z+e.w,h=-b.z+b.w,n=-e.z+e.w;return k>=0&&m>=0&&h>=0&&n>=0?!0:k<0&&m<0||h<0&&n<0?!1:(k<0?c=Math.max(c,k/(k-m)):m<0&&(f=Math.min(f,k/(k-m))),h<0?c=Math.max(c,h/(h-n)):n<0&&(f=Math.min(f,h/(h-n))),f<c?!1:(b.lerpSelf(e,c),e.lerpSelf(b,1-f),!0))}var f,m,k=[],h,n,o=[],u,v,t=[],x,w=[],y,A,z=[],D,F,C=[],G=[],N=[],R=new THREE.Vector4,H=new THREE.Vector4,
+THREE.Projector=function(){function b(){var b=o[n]=o[n]||new THREE.RenderableVertex;n++;return b}function c(b,e){return e.z-b.z}function e(b,e){var c=0,f=1,k=b.z+b.w,m=e.z+e.w,h=-b.z+b.w,n=-e.z+e.w;return k>=0&&m>=0&&h>=0&&n>=0?!0:k<0&&m<0||h<0&&n<0?!1:(k<0?c=Math.max(c,k/(k-m)):m<0&&(f=Math.min(f,k/(k-m))),h<0?c=Math.max(c,h/(h-n)):n<0&&(f=Math.min(f,h/(h-n))),f<c?!1:(b.lerpSelf(e,c),e.lerpSelf(b,1-f),!0))}var f,m,k=[],h,n,o=[],u,v,t=[],x,w=[],y,A,z=[],D,C,F=[],G=[],N=[],R=new THREE.Vector4,H=new THREE.Vector4,
 J=new THREE.Matrix4,I=new THREE.Matrix4,X=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],E=new THREE.Vector4,O=new THREE.Vector4;this.projectVector=function(b,e){J.multiply(e.projectionMatrix,e.matrixWorldInverse);J.multiplyVector3(b);return b};this.unprojectVector=function(b,e){J.multiply(e.matrixWorld,THREE.Matrix4.makeInvert(e.projectionMatrix));J.multiplyVector3(b);return b};this.projectObjects=function(b,e,h){var p,n;m=G.length=0;
 p=b.objects;b=0;for(e=p.length;b<e;b++){n=p[b];var t;if(!(t=!n.visible))if(t=n instanceof THREE.Mesh)if(t=n.frustumCulled){a:{t=void 0;for(var w=n.matrixWorld,o=-n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)),u=0;u<6;u++)if(t=X[u].x*w.n14+X[u].y*w.n24+X[u].z*w.n34+X[u].w,t<=o){t=!1;break a}t=!0}t=!t}if(!t)t=k[m]=k[m]||new THREE.RenderableObject,m++,f=t,R.copy(n.position),J.multiplyVector3(R),f.object=n,f.z=R.z,G.push(f)}h&&G.sort(c);return G};this.projectScene=
-function(f,k,m){var p=k.near,G=k.far,R,ka,$,ia,ca,ma,fa,da,T,Y,ga,ja,sa,M,la,pa,qa;F=A=x=v=N.length=0;k.matrixAutoUpdate&&k.update(void 0,!0);f.update(void 0,!1,k);J.multiply(k.projectionMatrix,k.matrixWorldInverse);X[0].set(J.n41-J.n11,J.n42-J.n12,J.n43-J.n13,J.n44-J.n14);X[1].set(J.n41+J.n11,J.n42+J.n12,J.n43+J.n13,J.n44+J.n14);X[2].set(J.n41+J.n21,J.n42+J.n22,J.n43+J.n23,J.n44+J.n24);X[3].set(J.n41-J.n21,J.n42-J.n22,J.n43-J.n23,J.n44-J.n24);X[4].set(J.n41-J.n31,J.n42-J.n32,J.n43-J.n33,J.n44-J.n34);
+function(f,k,m){var p=k.near,G=k.far,R,ka,$,ia,ca,ma,fa,da,T,Y,ga,ja,sa,M,la,pa,qa;C=A=x=v=N.length=0;k.matrixAutoUpdate&&k.update(void 0,!0);f.update(void 0,!1,k);J.multiply(k.projectionMatrix,k.matrixWorldInverse);X[0].set(J.n41-J.n11,J.n42-J.n12,J.n43-J.n13,J.n44-J.n14);X[1].set(J.n41+J.n11,J.n42+J.n12,J.n43+J.n13,J.n44+J.n14);X[2].set(J.n41+J.n21,J.n42+J.n22,J.n43+J.n23,J.n44+J.n24);X[3].set(J.n41-J.n21,J.n42-J.n22,J.n43-J.n23,J.n44-J.n24);X[4].set(J.n41-J.n31,J.n42-J.n32,J.n43-J.n33,J.n44-J.n34);
 X[5].set(J.n41+J.n31,J.n42+J.n32,J.n43+J.n33,J.n44+J.n34);for(R=0;R<6;R++)T=X[R],T.divideScalar(Math.sqrt(T.x*T.x+T.y*T.y+T.z*T.z));T=this.projectObjects(f,k,!0);f=0;for(R=T.length;f<R;f++)if(Y=T[f].object,Y.visible)if(ga=Y.matrixWorld,ja=Y.matrixRotationWorld,sa=Y.materials,M=Y.overdraw,n=0,Y instanceof THREE.Mesh){la=Y.geometry;ia=la.vertices;pa=la.faces;la=la.faceVertexUvs;ka=0;for($=ia.length;ka<$;ka++)h=b(),h.positionWorld.copy(ia[ka].position),ga.multiplyVector3(h.positionWorld),h.positionScreen.copy(h.positionWorld),
 J.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>p&&h.positionScreen.z<G;ia=0;for(ka=pa.length;ia<ka;ia++){$=pa[ia];if($ instanceof THREE.Face3)if(ca=o[$.a],ma=o[$.b],fa=o[$.c],ca.visible&&ma.visible&&fa.visible&&(Y.doubleSided||Y.flipSided!=(fa.positionScreen.x-ca.positionScreen.x)*(ma.positionScreen.y-ca.positionScreen.y)-(fa.positionScreen.y-ca.positionScreen.y)*(ma.positionScreen.x-ca.positionScreen.x)<
 0))da=t[v]=t[v]||new THREE.RenderableFace3,v++,u=da,u.v1.copy(ca),u.v2.copy(ma),u.v3.copy(fa);else continue;else if($ instanceof THREE.Face4)if(ca=o[$.a],ma=o[$.b],fa=o[$.c],da=o[$.d],ca.visible&&ma.visible&&fa.visible&&da.visible&&(Y.doubleSided||Y.flipSided!=((da.positionScreen.x-ca.positionScreen.x)*(ma.positionScreen.y-ca.positionScreen.y)-(da.positionScreen.y-ca.positionScreen.y)*(ma.positionScreen.x-ca.positionScreen.x)<0||(ma.positionScreen.x-fa.positionScreen.x)*(da.positionScreen.y-fa.positionScreen.y)-
 (ma.positionScreen.y-fa.positionScreen.y)*(da.positionScreen.x-fa.positionScreen.x)<0)))qa=w[x]=w[x]||new THREE.RenderableFace4,x++,u=qa,u.v1.copy(ca),u.v2.copy(ma),u.v3.copy(fa),u.v4.copy(da);else continue;u.normalWorld.copy($.normal);ja.multiplyVector3(u.normalWorld);u.centroidWorld.copy($.centroid);ga.multiplyVector3(u.centroidWorld);u.centroidScreen.copy(u.centroidWorld);J.multiplyVector3(u.centroidScreen);fa=$.vertexNormals;ca=0;for(ma=fa.length;ca<ma;ca++)da=u.vertexNormalsWorld[ca],da.copy(fa[ca]),
 ja.multiplyVector3(da);ca=0;for(ma=la.length;ca<ma;ca++)if(qa=la[ca][ia]){fa=0;for(da=qa.length;fa<da;fa++)u.uvs[ca][fa]=qa[fa]}u.meshMaterials=sa;u.faceMaterials=$.materials;u.overdraw=M;u.z=u.centroidScreen.z;N.push(u)}}else if(Y instanceof THREE.Line){I.multiply(J,ga);ia=Y.geometry.vertices;ca=b();ca.positionScreen.copy(ia[0].position);I.multiplyVector4(ca.positionScreen);ka=1;for($=ia.length;ka<$;ka++)if(ca=b(),ca.positionScreen.copy(ia[ka].position),I.multiplyVector4(ca.positionScreen),ma=o[n-
-2],E.copy(ca.positionScreen),O.copy(ma.positionScreen),e(E,O))E.multiplyScalar(1/E.w),O.multiplyScalar(1/O.w),ga=z[A]=z[A]||new THREE.RenderableLine,A++,y=ga,y.v1.positionScreen.copy(E),y.v2.positionScreen.copy(O),y.z=Math.max(E.z,O.z),y.materials=Y.materials,N.push(y)}else if(Y instanceof THREE.Particle&&(H.set(Y.matrixWorld.n14,Y.matrixWorld.n24,Y.matrixWorld.n34,1),J.multiplyVector4(H),H.z/=H.w,H.z>0&&H.z<1))ga=C[F]=C[F]||new THREE.RenderableParticle,F++,D=ga,D.x=H.x/H.w,D.y=H.y/H.w,D.z=H.z,D.rotation=
+2],E.copy(ca.positionScreen),O.copy(ma.positionScreen),e(E,O))E.multiplyScalar(1/E.w),O.multiplyScalar(1/O.w),ga=z[A]=z[A]||new THREE.RenderableLine,A++,y=ga,y.v1.positionScreen.copy(E),y.v2.positionScreen.copy(O),y.z=Math.max(E.z,O.z),y.materials=Y.materials,N.push(y)}else if(Y instanceof THREE.Particle&&(H.set(Y.matrixWorld.n14,Y.matrixWorld.n24,Y.matrixWorld.n34,1),J.multiplyVector4(H),H.z/=H.w,H.z>0&&H.z<1))ga=F[C]=F[C]||new THREE.RenderableParticle,C++,D=ga,D.x=H.x/H.w,D.y=H.y/H.w,D.z=H.z,D.rotation=
 Y.rotation.z,D.scale.x=Y.scale.x*Math.abs(D.x-(H.x+k.projectionMatrix.n11)/(H.w+k.projectionMatrix.n14)),D.scale.y=Y.scale.y*Math.abs(D.y-(H.y+k.projectionMatrix.n22)/(H.w+k.projectionMatrix.n24)),D.materials=Y.materials,N.push(D);m&&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=0.5*Math.PI/360,e=b.x*c,f=b.y*c,m=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-m),m=Math.sin(-m),k=Math.cos(e),e=Math.sin(e),h=b*c,n=f*m;this.w=h*k-n*e;this.x=h*e+n*k;this.y=f*c*k+b*m*e;this.z=b*m*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);
@@ -79,12 +79,13 @@ c;b++)e=this.faces[b],e.centroid.set(0,0,0),e instanceof THREE.Face3?(e.centroid
 e,f,m,k,h,n=new THREE.Vector3,o=new THREE.Vector3;f=0;for(m=this.faces.length;f<m;f++){k=this.faces[f];if(b&&k.vertexNormals.length){n.set(0,0,0);c=0;for(e=k.vertexNormals.length;c<e;c++)n.addSelf(k.vertexNormals[c]);n.divideScalar(3)}else c=this.vertices[k.a],e=this.vertices[k.b],h=this.vertices[k.c],n.sub(h.position,e.position),o.sub(c.position,e.position),n.crossSelf(o);n.isZero()||n.normalize();k.normal.copy(n)}},computeVertexNormals:function(){var b,c,e,f;if(this.__tmpVertices==void 0){f=this.__tmpVertices=
 Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)f[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)if(e=this.faces[b],e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{f=this.__tmpVertices;b=0;for(c=this.vertices.length;b<c;b++)f[b].set(0,0,0)}b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e instanceof
 THREE.Face3?(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal)):e instanceof THREE.Face4&&(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal),f[e.d].addSelf(e.normal));b=0;for(c=this.vertices.length;b<c;b++)f[b].normalize();b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e instanceof THREE.Face3?(e.vertexNormals[0].copy(f[e.a]),e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c])):e instanceof THREE.Face4&&(e.vertexNormals[0].copy(f[e.a]),
-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,m,p){n=b.vertices[e].position;o=b.vertices[c].position;u=b.vertices[f].position;v=h[k];t=h[m];x=h[p];w=o.x-n.x;y=u.x-n.x;A=o.y-n.y;z=u.y-n.y;D=o.z-n.z;F=u.z-n.z;C=t.u-v.u;G=x.u-v.u;N=t.v-v.v;R=x.v-v.v;H=1/(C*R-G*N);E.set((R*w-N*y)*H,(R*A-N*z)*H,(R*D-N*F)*H);O.set((C*y-G*w)*H,(C*z-G*A)*H,(C*F-G*D)*H);I[e].addSelf(E);I[c].addSelf(E);I[f].addSelf(E);X[e].addSelf(O);
-X[c].addSelf(O);X[f].addSelf(O)}var c,e,f,m,k,h,n,o,u,v,t,x,w,y,A,z,D,F,C,G,N,R,H,J,I=[],X=[],E=new THREE.Vector3,O=new THREE.Vector3,P=new THREE.Vector3,U=new THREE.Vector3,V=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++)I[c]=new THREE.Vector3,X[c]=new THREE.Vector3;c=0;for(e=this.faces.length;c<e;c++)k=this.faces[c],h=this.faceVertexUvs[0][c],k instanceof THREE.Face3?b(this,k.a,k.b,k.c,0,1,2):k instanceof THREE.Face4&&(b(this,k.a,k.b,k.c,0,1,2),b(this,k.a,k.b,k.d,0,1,3));var p=["a","b",
+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,m,p){n=b.vertices[e].position;o=b.vertices[c].position;u=b.vertices[f].position;v=h[k];t=h[m];x=h[p];w=o.x-n.x;y=u.x-n.x;A=o.y-n.y;z=u.y-n.y;D=o.z-n.z;C=u.z-n.z;F=t.u-v.u;G=x.u-v.u;N=t.v-v.v;R=x.v-v.v;H=1/(F*R-G*N);E.set((R*w-N*y)*H,(R*A-N*z)*H,(R*D-N*C)*H);O.set((F*y-G*w)*H,(F*z-G*A)*H,(F*C-G*D)*H);I[e].addSelf(E);I[c].addSelf(E);I[f].addSelf(E);X[e].addSelf(O);
+X[c].addSelf(O);X[f].addSelf(O)}var c,e,f,m,k,h,n,o,u,v,t,x,w,y,A,z,D,C,F,G,N,R,H,J,I=[],X=[],E=new THREE.Vector3,O=new THREE.Vector3,P=new THREE.Vector3,U=new THREE.Vector3,V=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++)I[c]=new THREE.Vector3,X[c]=new THREE.Vector3;c=0;for(e=this.faces.length;c<e;c++)k=this.faces[c],h=this.faceVertexUvs[0][c],k instanceof THREE.Face3?b(this,k.a,k.b,k.c,0,1,2):k instanceof THREE.Face4&&(b(this,k.a,k.b,k.c,0,1,2),b(this,k.a,k.b,k.d,0,1,3));var p=["a","b",
 "c","d"];c=0;for(e=this.faces.length;c<e;c++){k=this.faces[c];for(f=0;f<k.vertexNormals.length;f++)V.copy(k.vertexNormals[f]),m=k[p[f]],J=I[m],P.copy(J),P.subSelf(V.multiplyScalar(V.dot(J))).normalize(),U.cross(k.vertexNormals[f],J),m=U.dot(X[m]),m=m<0?-1:1,k.vertexTangents[f]=new THREE.Vector4(P.x,P.y,P.z,m)}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){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;c<e;c++){b=this.vertices[c];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=
-b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;c<e;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,e){return Math.min(b,e)+"_"+Math.max(b,e)}function c(b,e,c){b[e]===void 0?(b[e]={set:{},array:[]},b[e].set[c]=1,b[e].array.push(c)):b[e].set[c]===void 0&&(b[e].set[c]=1,b[e].array.push(c))}var e,f,m,k,h={};
-e=0;for(f=this.faces.length;e<f;e++)m=this.faces[e],m instanceof THREE.Face3?(k=b(m.a,m.b),c(h,k,e),k=b(m.b,m.c),c(h,k,e),k=b(m.a,m.c),c(h,k,e)):m instanceof THREE.Face4&&(k=b(m.a,m.b),c(h,k,e),k=b(m.a,m.d),c(h,k,e),k=b(m.b,m.c),c(h,k,e),k=b(m.c,m.d),c(h,k,e));this.vfMap=h;m=0;for(e in h)m++,f=h[e],this.edges.push(f.array)}};THREE.GeometryCount=0;
+b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=0,c=0,e=this.vertices.length;c<e;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,e){return Math.min(b,e)+"_"+Math.max(b,e)}function c(b,e,c){b[e]===void 0&&(b[e]={set:{},array:[]});b[e].set[c]=1;b[e].array.push(c)}var e,f,m,k,h={};e=0;for(f=this.faces.length;e<f;e++)m=this.faces[e],m instanceof
+THREE.Face3?(k=b(m.a,m.b),c(h,k,e),k=b(m.b,m.c),c(h,k,e),k=b(m.c,m.a),c(h,k,e)):m instanceof THREE.Face4&&(k=b(m.a,m.b),c(h,k,e),k=b(m.b,m.c),c(h,k,e),k=b(m.c,m.d),c(h,k,e),k=b(m.d,m.a),c(h,k,e));this.vfMap=h;m=0;for(e in h)m++,f=h[e],this.edges.push(f.array)},checkDupVertices:function(){var b={},c={},e,f,m;f=0;for(m=this.vertices.length;f<m;f++)e=this.vertices[f].position,e=[Math.round(e.x*1E3),Math.round(e.y*1E3),Math.round(e.z*1E3)].join("_"),b[e]===void 0?b[e]=f:c[f]=b[e];e=function(b){if(c[b]!==
+void 0)return c[b];return b};f=0;for(m=this.faces.length;f<m;f++){b=this.faces[f];if(b instanceof THREE.Face3)b.a=e(b.a),b.b=e(b.b),b.c=e(b.c);if(b instanceof THREE.Face4)b.a=e(b.a),b.b=e(b.b),b.c=e(b.c),b.d=e(b.d)}}};THREE.GeometryCount=0;
 THREE.Spline=function(b){function c(b,e,c,f,k,m,h){b=(c-b)*0.5;f=(f-e)*0.5;return(2*(e-c)+b+f)*h+(-3*(e-c)-2*b-f)*m+b*k+e}this.points=b;var e=[],f={x:0,y:0,z:0},m,k,h,n,o,u,v,t,x;this.initFromArray=function(b){this.points=[];for(var e=0;e<b.length;e++)this.points[e]={x:b[e][0],y:b[e][1],z:b[e][2]}};this.getPoint=function(b){m=(this.points.length-1)*b;k=Math.floor(m);h=m-k;e[0]=k==0?k:k-1;e[1]=k;e[2]=k>this.points.length-2?k:k+1;e[3]=k>this.points.length-3?k:k+2;u=this.points[e[0]];v=this.points[e[1]];
 t=this.points[e[2]];x=this.points[e[3]];n=h*h;o=h*n;f.x=c(u.x,v.x,t.x,x.x,h,n,o);f.y=c(u.y,v.y,t.y,x.y,h,n,o);f.z=c(u.z,v.z,t.z,x.z,h,n,o);return f};this.getControlPointsArray=function(){var b,e,c=this.points.length,f=[];for(b=0;b<c;b++)e=this.points[b],f[b]=[e.x,e.y,e.z];return f};this.getLength=function(b){var e,c,f=e=e=0,k=new THREE.Vector3,m=new THREE.Vector3,h=[],n=0;h[0]=0;b||(b=100);c=this.points.length*b;k.copy(this.points[0]);for(b=1;b<c;b++)e=b/c,position=this.getPoint(e),m.copy(position),
 n+=m.distanceTo(k),k.copy(position),e*=this.points.length-1,e=Math.floor(e),e!=f&&(h[e]=n,f=e);h[h.length]=n;return{chunks:h,total:n}};this.reparametrizeByArcLength=function(b){var e,c,f,k,m,h,n=[],t=new THREE.Vector3,u=this.getLength();n.push(t.copy(this.points[0]).clone());for(e=1;e<this.points.length;e++){c=u.chunks[e]-u.chunks[e-1];h=Math.ceil(b*c/u.total);k=(e-1)/(this.points.length-1);m=e/(this.points.length-1);for(c=1;c<h-1;c++)f=k+c*(1/h)*(m-k),position=this.getPoint(f),n.push(t.copy(position).clone());
@@ -147,28 +148,28 @@ THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light
 THREE.Scene.prototype.addChild=function(b){console.warn("DEPRECATED: Scene.addChild() is now Scene.add().");this.add(b)};THREE.Scene.prototype.addObject=function(b){console.warn("DEPRECATED: Scene.addObject() is now Scene.add().");this.add(b)};THREE.Scene.prototype.addLight=function(b){console.warn("DEPRECATED: Scene.addLight() is now Scene.add().");this.add(b)};THREE.Scene.prototype.removeChild=function(b){console.warn("DEPRECATED: Scene.removeChild() is now Scene.remove().");this.remove(b)};
 THREE.Scene.prototype.removeObject=function(b){console.warn("DEPRECATED: Scene.removeObject() is now Scene.remove().");this.remove(b)};THREE.Scene.prototype.removeLight=function(b){console.warn("DEPRECATED: Scene.removeLight() is now Scene.remove().");this.remove(b)};THREE.Fog=function(b,c,e){this.color=new THREE.Color(b);this.near=c!==void 0?c:1;this.far=e!==void 0?e:1E3};THREE.FogExp2=function(b,c){this.color=new THREE.Color(b);this.density=c!==void 0?c:2.5E-4};
 THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,m,k;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;m=e/2;k=f/2};this.render=function(e,f){var o,u,v,t,x,w,y,A;b=c.projectScene(e,f);o=0;for(u=b.length;o<u;o++)if(x=b[o],x instanceof THREE.RenderableParticle){y=x.x*m+m;A=x.y*k+k;v=0;for(t=x.material.length;v<t;v++)if(w=x.material[v],w instanceof THREE.ParticleDOMMaterial)w=w.domElement,w.style.left=y+"px",w.style.top=A+"px"}}};
-THREE.CanvasRenderer=function(b){function c(b){if(z!=b)w.globalAlpha=z=b}function e(b){if(D!=b){switch(b){case THREE.NormalBlending:w.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:w.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:w.globalCompositeOperation="darker"}D=b}}function f(b){if(F!=b)w.strokeStyle=F=b}function m(b){if(C!=b)w.fillStyle=C=b}var k=this,h=null,n=new THREE.Projector,b=b||{},o=b.canvas!==void 0?b.canvas:document.createElement("canvas"),
-u,v,t,x,w=o.getContext("2d"),y=new THREE.Color(0),A=0,z=1,D=0,F=null,C=null,G=null,N=null,R=null,H,J,I,X,E=new THREE.RenderableVertex,O=new THREE.RenderableVertex,P,U,V,p,ea,S,ka,$,ia,ca,ma,fa,da=new THREE.Color(0),T=new THREE.Color(0),Y=new THREE.Color(0),ga=new THREE.Color(0),ja=new THREE.Color(0),sa=[],M,la,pa,qa,wa,ua,Da,za,Ba,Fa,L=new THREE.Rectangle,aa=new THREE.Rectangle,W=new THREE.Rectangle,oa=!1,ha=new THREE.Color,ra=new THREE.Color,Ca=new THREE.Color,va=new THREE.Color,na=new THREE.Vector3,
+THREE.CanvasRenderer=function(b){function c(b){if(z!=b)w.globalAlpha=z=b}function e(b){if(D!=b){switch(b){case THREE.NormalBlending:w.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:w.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:w.globalCompositeOperation="darker"}D=b}}function f(b){if(C!=b)w.strokeStyle=C=b}function m(b){if(F!=b)w.fillStyle=F=b}var k=this,h=null,n=new THREE.Projector,b=b||{},o=b.canvas!==void 0?b.canvas:document.createElement("canvas"),
+u,v,t,x,w=o.getContext("2d"),y=new THREE.Color(0),A=0,z=1,D=0,C=null,F=null,G=null,N=null,R=null,H,J,I,X,E=new THREE.RenderableVertex,O=new THREE.RenderableVertex,P,U,V,p,ea,S,ka,$,ia,ca,ma,fa,da=new THREE.Color(0),T=new THREE.Color(0),Y=new THREE.Color(0),ga=new THREE.Color(0),ja=new THREE.Color(0),sa=[],M,la,pa,qa,wa,ua,Da,za,Ba,Fa,L=new THREE.Rectangle,aa=new THREE.Rectangle,W=new THREE.Rectangle,oa=!1,ha=new THREE.Color,ra=new THREE.Color,Ca=new THREE.Color,va=new THREE.Color,na=new THREE.Vector3,
 Ia,xa,Ka,Aa,Ga,Z,b=16;Ia=document.createElement("canvas");Ia.width=Ia.height=2;xa=Ia.getContext("2d");xa.fillStyle="rgba(0,0,0,1)";xa.fillRect(0,0,2,2);Ka=xa.getImageData(0,0,2,2);Aa=Ka.data;Ga=document.createElement("canvas");Ga.width=Ga.height=b;Z=Ga.getContext("2d");Z.translate(-b/2,-b/2);Z.scale(b,b);b--;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(b,e){u=b;v=e;t=Math.floor(u/2);x=Math.floor(v/2);o.width=u;
-o.height=v;L.set(-t,-x,t,x);aa.set(-t,-x,t,x);z=1;D=0;R=N=G=C=F=null};this.setClearColor=function(b,e){y.copy(b);A=e;aa.set(-t,-x,t,x)};this.setClearColorHex=function(b,e){y.setHex(b);A=e;aa.set(-t,-x,t,x)};this.clear=function(){w.setTransform(1,0,0,-1,t,x);aa.isEmpty()||(aa.minSelf(L),aa.inflate(2),A<1&&w.clearRect(Math.floor(aa.getX()),Math.floor(aa.getY()),Math.floor(aa.getWidth()),Math.floor(aa.getHeight())),A>0&&(e(THREE.NormalBlending),c(1),m("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+
+o.height=v;L.set(-t,-x,t,x);aa.set(-t,-x,t,x);z=1;D=0;R=N=G=F=C=null};this.setClearColor=function(b,e){y.copy(b);A=e;aa.set(-t,-x,t,x)};this.setClearColorHex=function(b,e){y.setHex(b);A=e;aa.set(-t,-x,t,x)};this.clear=function(){w.setTransform(1,0,0,-1,t,x);aa.isEmpty()||(aa.minSelf(L),aa.inflate(2),A<1&&w.clearRect(Math.floor(aa.getX()),Math.floor(aa.getY()),Math.floor(aa.getWidth()),Math.floor(aa.getHeight())),A>0&&(e(THREE.NormalBlending),c(1),m("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+
 ","+Math.floor(y.b*255)+","+A+")"),w.fillRect(Math.floor(aa.getX()),Math.floor(aa.getY()),Math.floor(aa.getWidth()),Math.floor(aa.getHeight()))),aa.empty())};this.render=function(b,u){function o(b){var e,c,f,k=b.lights;ra.setRGB(0,0,0);Ca.setRGB(0,0,0);va.setRGB(0,0,0);b=0;for(e=k.length;b<e;b++)c=k[b],f=c.color,c instanceof THREE.AmbientLight?(ra.r+=f.r,ra.g+=f.g,ra.b+=f.b):c instanceof THREE.DirectionalLight?(Ca.r+=f.r,Ca.g+=f.g,Ca.b+=f.b):c instanceof THREE.PointLight&&(va.r+=f.r,va.g+=f.g,va.b+=
 f.b)}function v(b,e,c,f){var k,m,h,p,n=b.lights,b=0;for(k=n.length;b<k;b++)m=n[b],h=m.color,m instanceof THREE.DirectionalLight?(p=c.dot(m.position),p<=0||(p*=m.intensity,f.r+=h.r*p,f.g+=h.g*p,f.b+=h.b*p)):m instanceof THREE.PointLight&&(p=c.dot(na.sub(m.position,e).normalize()),p<=0||(p*=m.distance==0?1:1-Math.min(e.distanceTo(m.position)/m.distance,1),p!=0&&(p*=m.intensity,f.r+=h.r*p,f.g+=h.g*p,f.b+=h.b*p)))}function Xa(b,k,h){c(h.opacity);e(h.blending);var p,n,u,o,Ea,v;if(h instanceof THREE.ParticleBasicMaterial){if(h.map)o=
 h.map.image,Ea=o.width>>1,v=o.height>>1,h=k.scale.x*t,u=k.scale.y*x,p=h*Ea,n=u*v,W.set(b.x-p,b.y-n,b.x+p,b.y+n),L.intersects(W)&&(w.save(),w.translate(b.x,b.y),w.rotate(-k.rotation),w.scale(h,-u),w.translate(-Ea,-v),w.drawImage(o,0,0),w.restore())}else h instanceof THREE.ParticleCanvasMaterial&&(p=k.scale.x*t,n=k.scale.y*x,W.set(b.x-p,b.y-n,b.x+p,b.y+n),L.intersects(W)&&(f(h.color.getContextStyle()),m(h.color.getContextStyle()),w.save(),w.translate(b.x,b.y),w.rotate(-k.rotation),w.scale(p,n),h.program(w),
-w.restore()))}function y(b,k,h,m){c(m.opacity);e(m.blending);w.beginPath();w.moveTo(b.positionScreen.x,b.positionScreen.y);w.lineTo(k.positionScreen.x,k.positionScreen.y);w.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(G!=b)w.lineWidth=G=b;b=m.linecap;if(N!=b)w.lineCap=N=b;b=m.linejoin;if(R!=b)w.lineJoin=R=b;f(m.color.getContextStyle());w.stroke();W.inflate(m.linewidth*2)}}function z(b,f,m,h,n,t,o,w,x){k.info.render.vertices+=3;k.info.render.faces++;c(w.opacity);e(w.blending);
-P=b.positionScreen.x;U=b.positionScreen.y;V=f.positionScreen.x;p=f.positionScreen.y;ea=m.positionScreen.x;S=m.positionScreen.y;D(P,U,V,p,ea,S);if(w instanceof THREE.MeshBasicMaterial)if(w.map)w.map.mapping instanceof THREE.UVMapping&&(qa=o.uvs[0],ab(P,U,V,p,ea,S,qa[h].u,qa[h].v,qa[n].u,qa[n].v,qa[t].u,qa[t].v,w.map));else if(w.envMap){if(w.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=u.matrixWorldInverse,na.copy(o.vertexNormalsWorld[0]),wa=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,
-ua=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(o.vertexNormalsWorld[1]),Da=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,za=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(o.vertexNormalsWorld[2]),Ba=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,Fa=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,ab(P,U,V,p,ea,S,wa,ua,Da,za,Ba,Fa,w.envMap)}else w.wireframe?C(w.color,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):Na(w.color);else if(w instanceof THREE.MeshLambertMaterial)w.map&&!w.wireframe&&
-(w.map.mapping instanceof THREE.UVMapping&&(qa=o.uvs[0],ab(P,U,V,p,ea,S,qa[h].u,qa[h].v,qa[n].u,qa[n].v,qa[t].u,qa[t].v,w.map)),e(THREE.SubtractiveBlending)),oa?!w.wireframe&&w.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==3?(T.r=Y.r=ga.r=ra.r,T.g=Y.g=ga.g=ra.g,T.b=Y.b=ga.b=ra.b,v(x,o.v1.positionWorld,o.vertexNormalsWorld[0],T),v(x,o.v2.positionWorld,o.vertexNormalsWorld[1],Y),v(x,o.v3.positionWorld,o.vertexNormalsWorld[2],ga),T.r=Math.max(0,Math.min(w.color.r*T.r,1)),T.g=Math.max(0,
+w.restore()))}function y(b,k,m,h){c(h.opacity);e(h.blending);w.beginPath();w.moveTo(b.positionScreen.x,b.positionScreen.y);w.lineTo(k.positionScreen.x,k.positionScreen.y);w.closePath();if(h instanceof THREE.LineBasicMaterial){b=h.linewidth;if(G!=b)w.lineWidth=G=b;b=h.linecap;if(N!=b)w.lineCap=N=b;b=h.linejoin;if(R!=b)w.lineJoin=R=b;f(h.color.getContextStyle());w.stroke();W.inflate(h.linewidth*2)}}function z(b,f,h,m,n,t,o,w,x){k.info.render.vertices+=3;k.info.render.faces++;c(w.opacity);e(w.blending);
+P=b.positionScreen.x;U=b.positionScreen.y;V=f.positionScreen.x;p=f.positionScreen.y;ea=h.positionScreen.x;S=h.positionScreen.y;D(P,U,V,p,ea,S);if(w instanceof THREE.MeshBasicMaterial)if(w.map)w.map.mapping instanceof THREE.UVMapping&&(qa=o.uvs[0],ab(P,U,V,p,ea,S,qa[m].u,qa[m].v,qa[n].u,qa[n].v,qa[t].u,qa[t].v,w.map));else if(w.envMap){if(w.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=u.matrixWorldInverse,na.copy(o.vertexNormalsWorld[0]),wa=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,
+ua=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(o.vertexNormalsWorld[1]),Da=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,za=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,na.copy(o.vertexNormalsWorld[2]),Ba=(na.x*b.n11+na.y*b.n12+na.z*b.n13)*0.5+0.5,Fa=-(na.x*b.n21+na.y*b.n22+na.z*b.n23)*0.5+0.5,ab(P,U,V,p,ea,S,wa,ua,Da,za,Ba,Fa,w.envMap)}else w.wireframe?F(w.color,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):Na(w.color);else if(w instanceof THREE.MeshLambertMaterial)w.map&&!w.wireframe&&
+(w.map.mapping instanceof THREE.UVMapping&&(qa=o.uvs[0],ab(P,U,V,p,ea,S,qa[m].u,qa[m].v,qa[n].u,qa[n].v,qa[t].u,qa[t].v,w.map)),e(THREE.SubtractiveBlending)),oa?!w.wireframe&&w.shading==THREE.SmoothShading&&o.vertexNormalsWorld.length==3?(T.r=Y.r=ga.r=ra.r,T.g=Y.g=ga.g=ra.g,T.b=Y.b=ga.b=ra.b,v(x,o.v1.positionWorld,o.vertexNormalsWorld[0],T),v(x,o.v2.positionWorld,o.vertexNormalsWorld[1],Y),v(x,o.v3.positionWorld,o.vertexNormalsWorld[2],ga),T.r=Math.max(0,Math.min(w.color.r*T.r,1)),T.g=Math.max(0,
 Math.min(w.color.g*T.g,1)),T.b=Math.max(0,Math.min(w.color.b*T.b,1)),Y.r=Math.max(0,Math.min(w.color.r*Y.r,1)),Y.g=Math.max(0,Math.min(w.color.g*Y.g,1)),Y.b=Math.max(0,Math.min(w.color.b*Y.b,1)),ga.r=Math.max(0,Math.min(w.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(w.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(w.color.b*ga.b,1)),ja.r=(Y.r+ga.r)*0.5,ja.g=(Y.g+ga.g)*0.5,ja.b=(Y.b+ga.b)*0.5,pa=Ya(T,Y,ga,ja),Ua(P,U,V,p,ea,S,0,0,1,0,0,1,pa)):(ha.r=ra.r,ha.g=ra.g,ha.b=ra.b,v(x,o.centroidWorld,o.normalWorld,
-ha),da.r=Math.max(0,Math.min(w.color.r*ha.r,1)),da.g=Math.max(0,Math.min(w.color.g*ha.g,1)),da.b=Math.max(0,Math.min(w.color.b*ha.b,1)),w.wireframe?C(da,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):Na(da)):w.wireframe?C(w.color,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):Na(w.color);else if(w instanceof THREE.MeshDepthMaterial)M=u.near,la=u.far,T.r=T.g=T.b=1-Qa(b.positionScreen.z,M,la),Y.r=Y.g=Y.b=1-Qa(f.positionScreen.z,M,la),ga.r=ga.g=ga.b=1-Qa(m.positionScreen.z,
-M,la),ja.r=(Y.r+ga.r)*0.5,ja.g=(Y.g+ga.g)*0.5,ja.b=(Y.b+ga.b)*0.5,pa=Ya(T,Y,ga,ja),Ua(P,U,V,p,ea,S,0,0,1,0,0,1,pa);else if(w instanceof THREE.MeshNormalMaterial)da.r=Va(o.normalWorld.x),da.g=Va(o.normalWorld.y),da.b=Va(o.normalWorld.z),w.wireframe?C(da,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):Na(da)}function A(b,f,m,h,n,t,w,o,x){k.info.render.vertices+=4;k.info.render.faces++;c(o.opacity);e(o.blending);if(o.map||o.envMap)z(b,f,h,0,1,3,w,o,x),z(n,m,t,1,2,3,w,o,x);else if(P=b.positionScreen.x,
-U=b.positionScreen.y,V=f.positionScreen.x,p=f.positionScreen.y,ea=m.positionScreen.x,S=m.positionScreen.y,ka=h.positionScreen.x,$=h.positionScreen.y,ia=n.positionScreen.x,ca=n.positionScreen.y,ma=t.positionScreen.x,fa=t.positionScreen.y,o instanceof THREE.MeshBasicMaterial)F(P,U,V,p,ea,S,ka,$),o.wireframe?C(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(o.color);else if(o instanceof THREE.MeshLambertMaterial)oa?!o.wireframe&&o.shading==THREE.SmoothShading&&w.vertexNormalsWorld.length==
+ha),da.r=Math.max(0,Math.min(w.color.r*ha.r,1)),da.g=Math.max(0,Math.min(w.color.g*ha.g,1)),da.b=Math.max(0,Math.min(w.color.b*ha.b,1)),w.wireframe?F(da,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):Na(da)):w.wireframe?F(w.color,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):Na(w.color);else if(w instanceof THREE.MeshDepthMaterial)M=u.near,la=u.far,T.r=T.g=T.b=1-Qa(b.positionScreen.z,M,la),Y.r=Y.g=Y.b=1-Qa(f.positionScreen.z,M,la),ga.r=ga.g=ga.b=1-Qa(h.positionScreen.z,
+M,la),ja.r=(Y.r+ga.r)*0.5,ja.g=(Y.g+ga.g)*0.5,ja.b=(Y.b+ga.b)*0.5,pa=Ya(T,Y,ga,ja),Ua(P,U,V,p,ea,S,0,0,1,0,0,1,pa);else if(w instanceof THREE.MeshNormalMaterial)da.r=Va(o.normalWorld.x),da.g=Va(o.normalWorld.y),da.b=Va(o.normalWorld.z),w.wireframe?F(da,w.wireframeLinewidth,w.wireframeLinecap,w.wireframeLinejoin):Na(da)}function A(b,f,h,m,n,t,w,o,x){k.info.render.vertices+=4;k.info.render.faces++;c(o.opacity);e(o.blending);if(o.map||o.envMap)z(b,f,m,0,1,3,w,o,x),z(n,h,t,1,2,3,w,o,x);else if(P=b.positionScreen.x,
+U=b.positionScreen.y,V=f.positionScreen.x,p=f.positionScreen.y,ea=h.positionScreen.x,S=h.positionScreen.y,ka=m.positionScreen.x,$=m.positionScreen.y,ia=n.positionScreen.x,ca=n.positionScreen.y,ma=t.positionScreen.x,fa=t.positionScreen.y,o instanceof THREE.MeshBasicMaterial)C(P,U,V,p,ea,S,ka,$),o.wireframe?F(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(o.color);else if(o instanceof THREE.MeshLambertMaterial)oa?!o.wireframe&&o.shading==THREE.SmoothShading&&w.vertexNormalsWorld.length==
 4?(T.r=Y.r=ga.r=ja.r=ra.r,T.g=Y.g=ga.g=ja.g=ra.g,T.b=Y.b=ga.b=ja.b=ra.b,v(x,w.v1.positionWorld,w.vertexNormalsWorld[0],T),v(x,w.v2.positionWorld,w.vertexNormalsWorld[1],Y),v(x,w.v4.positionWorld,w.vertexNormalsWorld[3],ga),v(x,w.v3.positionWorld,w.vertexNormalsWorld[2],ja),T.r=Math.max(0,Math.min(o.color.r*T.r,1)),T.g=Math.max(0,Math.min(o.color.g*T.g,1)),T.b=Math.max(0,Math.min(o.color.b*T.b,1)),Y.r=Math.max(0,Math.min(o.color.r*Y.r,1)),Y.g=Math.max(0,Math.min(o.color.g*Y.g,1)),Y.b=Math.max(0,Math.min(o.color.b*
 Y.b,1)),ga.r=Math.max(0,Math.min(o.color.r*ga.r,1)),ga.g=Math.max(0,Math.min(o.color.g*ga.g,1)),ga.b=Math.max(0,Math.min(o.color.b*ga.b,1)),ja.r=Math.max(0,Math.min(o.color.r*ja.r,1)),ja.g=Math.max(0,Math.min(o.color.g*ja.g,1)),ja.b=Math.max(0,Math.min(o.color.b*ja.b,1)),pa=Ya(T,Y,ga,ja),D(P,U,V,p,ka,$),Ua(P,U,V,p,ka,$,0,0,1,0,0,1,pa),D(ia,ca,ea,S,ma,fa),Ua(ia,ca,ea,S,ma,fa,1,0,1,1,0,1,pa)):(ha.r=ra.r,ha.g=ra.g,ha.b=ra.b,v(x,w.centroidWorld,w.normalWorld,ha),da.r=Math.max(0,Math.min(o.color.r*ha.r,
-1)),da.g=Math.max(0,Math.min(o.color.g*ha.g,1)),da.b=Math.max(0,Math.min(o.color.b*ha.b,1)),F(P,U,V,p,ea,S,ka,$),o.wireframe?C(da,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(da)):(F(P,U,V,p,ea,S,ka,$),o.wireframe?C(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(o.color));else if(o instanceof THREE.MeshNormalMaterial)da.r=Va(w.normalWorld.x),da.g=Va(w.normalWorld.y),da.b=Va(w.normalWorld.z),F(P,U,V,p,ea,S,ka,$),o.wireframe?C(da,o.wireframeLinewidth,o.wireframeLinecap,
-o.wireframeLinejoin):Na(da);else if(o instanceof THREE.MeshDepthMaterial)M=u.near,la=u.far,T.r=T.g=T.b=1-Qa(b.positionScreen.z,M,la),Y.r=Y.g=Y.b=1-Qa(f.positionScreen.z,M,la),ga.r=ga.g=ga.b=1-Qa(h.positionScreen.z,M,la),ja.r=ja.g=ja.b=1-Qa(m.positionScreen.z,M,la),pa=Ya(T,Y,ga,ja),D(P,U,V,p,ka,$),Ua(P,U,V,p,ka,$,0,0,1,0,0,1,pa),D(ia,ca,ea,S,ma,fa),Ua(ia,ca,ea,S,ma,fa,1,0,1,1,0,1,pa)}function D(b,e,c,f,k,m){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(k,m);w.lineTo(b,e);w.closePath()}function F(b,
-e,c,f,k,m,h,p){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(k,m);w.lineTo(h,p);w.lineTo(b,e);w.closePath()}function C(b,e,c,k){if(G!=e)w.lineWidth=G=e;if(N!=c)w.lineCap=N=c;if(R!=k)w.lineJoin=R=k;f(b.getContextStyle());w.stroke();W.inflate(e*2)}function Na(b){m(b.getContextStyle());w.fill()}function ab(b,e,c,f,k,h,p,n,o,t,u,Ea,v){if(v.image.width!=0){if(v.needsUpdate==!0||sa[v.id]==void 0){var x=v.wrapS==THREE.RepeatWrapping,L=v.wrapT==THREE.RepeatWrapping;sa[v.id]=w.createPattern(v.image,x&&
-L?"repeat":x&&!L?"repeat-x":!x&&L?"repeat-y":"no-repeat");v.needsUpdate=!1}m(sa[v.id]);var x=v.offset.x/v.repeat.x,L=v.offset.y/v.repeat.y,Xa=(v.image.width-1)*v.repeat.x,v=(v.image.height-1)*v.repeat.y,p=(p+x)*Xa,n=(n+L)*v,o=(o+x)*Xa,t=(t+L)*v,u=(u+x)*Xa,Ea=(Ea+L)*v;c-=b;f-=e;k-=b;h-=e;o-=p;t-=n;u-=p;Ea-=n;x=1/(o*Ea-u*t);v=(Ea*c-t*k)*x;t=(Ea*f-t*h)*x;c=(o*k-u*c)*x;f=(o*h-u*f)*x;b=b-v*p-c*n;e=e-t*p-f*n;w.save();w.transform(v,t,c,f,b,e);w.fill();w.restore()}}function Ua(b,e,c,f,k,m,h,p,n,o,t,u,Ea){var v,
-x;v=Ea.width-1;x=Ea.height-1;h*=v;p*=x;n*=v;o*=x;t*=v;u*=x;c-=b;f-=e;k-=b;m-=e;n-=h;o-=p;t-=h;u-=p;x=1/(n*u-t*o);v=(u*c-o*k)*x;o=(u*f-o*m)*x;c=(n*k-t*c)*x;f=(n*m-t*f)*x;b=b-v*h-c*p;e=e-o*h-f*p;w.save();w.transform(v,o,c,f,b,e);w.clip();w.drawImage(Ea,0,0);w.restore()}function Ya(b,e,c,f){var k=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),m=~~(e.r*255),p=~~(e.g*255),e=~~(e.b*255),n=~~(c.r*255),o=~~(c.g*255),c=~~(c.b*255),t=~~(f.r*255),w=~~(f.g*255),f=~~(f.b*255);Aa[0]=k<0?0:k>255?255:k;Aa[1]=h<0?0:h>255?
+1)),da.g=Math.max(0,Math.min(o.color.g*ha.g,1)),da.b=Math.max(0,Math.min(o.color.b*ha.b,1)),C(P,U,V,p,ea,S,ka,$),o.wireframe?F(da,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(da)):(C(P,U,V,p,ea,S,ka,$),o.wireframe?F(o.color,o.wireframeLinewidth,o.wireframeLinecap,o.wireframeLinejoin):Na(o.color));else if(o instanceof THREE.MeshNormalMaterial)da.r=Va(w.normalWorld.x),da.g=Va(w.normalWorld.y),da.b=Va(w.normalWorld.z),C(P,U,V,p,ea,S,ka,$),o.wireframe?F(da,o.wireframeLinewidth,o.wireframeLinecap,
+o.wireframeLinejoin):Na(da);else if(o instanceof THREE.MeshDepthMaterial)M=u.near,la=u.far,T.r=T.g=T.b=1-Qa(b.positionScreen.z,M,la),Y.r=Y.g=Y.b=1-Qa(f.positionScreen.z,M,la),ga.r=ga.g=ga.b=1-Qa(m.positionScreen.z,M,la),ja.r=ja.g=ja.b=1-Qa(h.positionScreen.z,M,la),pa=Ya(T,Y,ga,ja),D(P,U,V,p,ka,$),Ua(P,U,V,p,ka,$,0,0,1,0,0,1,pa),D(ia,ca,ea,S,ma,fa),Ua(ia,ca,ea,S,ma,fa,1,0,1,1,0,1,pa)}function D(b,e,c,f,k,h){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(k,h);w.lineTo(b,e);w.closePath()}function C(b,
+e,c,f,k,h,m,p){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(k,h);w.lineTo(m,p);w.lineTo(b,e);w.closePath()}function F(b,e,c,k){if(G!=e)w.lineWidth=G=e;if(N!=c)w.lineCap=N=c;if(R!=k)w.lineJoin=R=k;f(b.getContextStyle());w.stroke();W.inflate(e*2)}function Na(b){m(b.getContextStyle());w.fill()}function ab(b,e,c,f,k,h,p,n,o,t,u,Ea,v){if(v.image.width!=0){if(v.needsUpdate==!0||sa[v.id]==void 0){var x=v.wrapS==THREE.RepeatWrapping,L=v.wrapT==THREE.RepeatWrapping;sa[v.id]=w.createPattern(v.image,x&&
+L?"repeat":x&&!L?"repeat-x":!x&&L?"repeat-y":"no-repeat");v.needsUpdate=!1}m(sa[v.id]);var x=v.offset.x/v.repeat.x,L=v.offset.y/v.repeat.y,Xa=(v.image.width-1)*v.repeat.x,v=(v.image.height-1)*v.repeat.y,p=(p+x)*Xa,n=(n+L)*v,o=(o+x)*Xa,t=(t+L)*v,u=(u+x)*Xa,Ea=(Ea+L)*v;c-=b;f-=e;k-=b;h-=e;o-=p;t-=n;u-=p;Ea-=n;x=1/(o*Ea-u*t);v=(Ea*c-t*k)*x;t=(Ea*f-t*h)*x;c=(o*k-u*c)*x;f=(o*h-u*f)*x;b=b-v*p-c*n;e=e-t*p-f*n;w.save();w.transform(v,t,c,f,b,e);w.fill();w.restore()}}function Ua(b,e,c,f,k,h,m,p,n,o,t,u,Ea){var v,
+x;v=Ea.width-1;x=Ea.height-1;m*=v;p*=x;n*=v;o*=x;t*=v;u*=x;c-=b;f-=e;k-=b;h-=e;n-=m;o-=p;t-=m;u-=p;x=1/(n*u-t*o);v=(u*c-o*k)*x;o=(u*f-o*h)*x;c=(n*k-t*c)*x;f=(n*h-t*f)*x;b=b-v*m-c*p;e=e-o*m-f*p;w.save();w.transform(v,o,c,f,b,e);w.clip();w.drawImage(Ea,0,0);w.restore()}function Ya(b,e,c,f){var k=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),m=~~(e.r*255),p=~~(e.g*255),e=~~(e.b*255),n=~~(c.r*255),o=~~(c.g*255),c=~~(c.b*255),t=~~(f.r*255),w=~~(f.g*255),f=~~(f.b*255);Aa[0]=k<0?0:k>255?255:k;Aa[1]=h<0?0:h>255?
 255:h;Aa[2]=b<0?0:b>255?255:b;Aa[4]=m<0?0:m>255?255:m;Aa[5]=p<0?0:p>255?255:p;Aa[6]=e<0?0:e>255?255:e;Aa[8]=n<0?0:n>255?255:n;Aa[9]=o<0?0:o>255?255:o;Aa[10]=c<0?0:c>255?255:c;Aa[12]=t<0?0:t>255?255:t;Aa[13]=w<0?0:w>255?255:w;Aa[14]=f<0?0:f>255?255:f;xa.putImageData(Ka,0,0);Z.drawImage(Ia,0,0);return Ga}function Qa(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Va(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Oa(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,ta,Ha,Pa,Wa,$a,ya;this.autoClear?this.clear():w.setTransform(1,0,0,-1,t,x);k.info.render.vertices=0;k.info.render.faces=0;h=n.projectScene(b,u,this.sortElements);(oa=b.lights.length>0)&&o(b);Za=0;for(bb=h.length;Za<bb;Za++){ta=h[Za];W.empty();if(ta instanceof THREE.RenderableParticle){H=ta;H.x*=t;H.y*=x;Ha=0;for(Pa=ta.materials.length;Ha<Pa;)ya=ta.materials[Ha++],ya.opacity!=0&&Xa(H,ta,ya,b)}else if(ta instanceof THREE.RenderableLine){if(H=ta.v1,J=ta.v2,H.positionScreen.x*=
 t,H.positionScreen.y*=x,J.positionScreen.x*=t,J.positionScreen.y*=x,W.addPoint(H.positionScreen.x,H.positionScreen.y),W.addPoint(J.positionScreen.x,J.positionScreen.y),L.intersects(W)){Ha=0;for(Pa=ta.materials.length;Ha<Pa;)ya=ta.materials[Ha++],ya.opacity!=0&&y(H,J,ta,ya,b)}}else if(ta instanceof THREE.RenderableFace3){if(H=ta.v1,J=ta.v2,I=ta.v3,H.positionScreen.x*=t,H.positionScreen.y*=x,J.positionScreen.x*=t,J.positionScreen.y*=x,I.positionScreen.x*=t,I.positionScreen.y*=x,ta.overdraw&&(Oa(H.positionScreen,
@@ -177,18 +178,18 @@ THREE.RenderableFace4&&(H=ta.v1,J=ta.v2,I=ta.v3,X=ta.v4,H.positionScreen.x*=t,H.
 W.addPoint(H.positionScreen.x,H.positionScreen.y),W.addPoint(J.positionScreen.x,J.positionScreen.y),W.addPoint(I.positionScreen.x,I.positionScreen.y),W.addPoint(X.positionScreen.x,X.positionScreen.y),L.intersects(W))){Ha=0;for(Pa=ta.meshMaterials.length;Ha<Pa;)if(ya=ta.meshMaterials[Ha++],ya instanceof THREE.MeshFaceMaterial){Wa=0;for($a=ta.faceMaterials.length;Wa<$a;)(ya=ta.faceMaterials[Wa++])&&ya.opacity!=0&&A(H,J,I,X,E,O,ta,ya,b)}else ya.opacity!=0&&A(H,J,I,X,E,O,ta,ya,b)}aa.addRectangle(W)}w.setTransform(1,
 0,0,1,0,0)}};
 THREE.SVGRenderer=function(){function b(b,e,c){var f,k,h,m;f=0;for(k=b.lights.length;f<k;f++)h=b.lights[f],h instanceof THREE.DirectionalLight?(m=e.normalWorld.dot(h.position)*h.intensity,m>0&&(c.r+=h.color.r*m,c.g+=h.color.g*m,c.b+=h.color.b*m)):h instanceof THREE.PointLight&&(X.sub(h.position,e.centroidWorld),X.normalize(),m=e.normalWorld.dot(X)*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,h,p,n,t){k.info.render.vertices+=3;k.info.render.faces++;P=f(U++);
-P.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?G.copy(n.color):n instanceof THREE.MeshLambertMaterial?C?(N.r=R.r,N.g=R.g,N.b=R.b,b(t,p,N),G.r=Math.max(0,Math.min(n.color.r*N.r,1)),G.g=Math.max(0,Math.min(n.color.g*N.g,1)),G.b=Math.max(0,Math.min(n.color.b*N.b,1))):G.copy(n.color):n instanceof THREE.MeshDepthMaterial?(I=1-n.__2near/(n.__farPlusNear-
+P.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?G.copy(n.color):n instanceof THREE.MeshLambertMaterial?F?(N.r=R.r,N.g=R.g,N.b=R.b,b(t,p,N),G.r=Math.max(0,Math.min(n.color.r*N.r,1)),G.g=Math.max(0,Math.min(n.color.g*N.g,1)),G.b=Math.max(0,Math.min(n.color.b*N.b,1))):G.copy(n.color):n instanceof THREE.MeshDepthMaterial?(I=1-n.__2near/(n.__farPlusNear-
 p.z*n.__farMinusNear),G.setRGB(I,I,I)):n instanceof THREE.MeshNormalMaterial&&G.setRGB(m(p.normalWorld.x),m(p.normalWorld.y),m(p.normalWorld.z));n.wireframe?P.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):P.setAttribute("style","fill: "+G.getContextStyle()+"; fill-opacity: "+n.opacity);o.appendChild(P)}function e(e,c,h,p,n,t,w){k.info.render.vertices+=
-4;k.info.render.faces++;P=f(U++);P.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+" L "+p.positionScreen.x+","+p.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?G.copy(t.color):t instanceof THREE.MeshLambertMaterial?C?(N.r=R.r,N.g=R.g,N.b=R.b,b(w,n,N),G.r=Math.max(0,Math.min(t.color.r*N.r,1)),G.g=Math.max(0,Math.min(t.color.g*N.g,1)),G.b=Math.max(0,Math.min(t.color.b*N.b,1))):
+4;k.info.render.faces++;P=f(U++);P.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+h.positionScreen.x+","+h.positionScreen.y+" L "+p.positionScreen.x+","+p.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?G.copy(t.color):t instanceof THREE.MeshLambertMaterial?F?(N.r=R.r,N.g=R.g,N.b=R.b,b(w,n,N),G.r=Math.max(0,Math.min(t.color.r*N.r,1)),G.g=Math.max(0,Math.min(t.color.g*N.g,1)),G.b=Math.max(0,Math.min(t.color.b*N.b,1))):
 G.copy(t.color):t instanceof THREE.MeshDepthMaterial?(I=1-t.__2near/(t.__farPlusNear-n.z*t.__farMinusNear),G.setRGB(I,I,I)):t instanceof THREE.MeshNormalMaterial&&G.setRGB(m(n.normalWorld.x),m(n.normalWorld.y),m(n.normalWorld.z));t.wireframe?P.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):P.setAttribute("style","fill: "+G.getContextStyle()+
-"; fill-opacity: "+t.opacity);o.appendChild(P)}function f(b){E[b]==null&&(E[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),p==0&&E[b].setAttribute("shape-rendering","crispEdges"));return E[b]}function m(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var k=this,h=null,n=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),u,v,t,x,w,y,A,z,D=new THREE.Rectangle,F=new THREE.Rectangle,C=!1,G=new THREE.Color(16777215),N=new THREE.Color(16777215),R=new THREE.Color(0),
+"; fill-opacity: "+t.opacity);o.appendChild(P)}function f(b){E[b]==null&&(E[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),p==0&&E[b].setAttribute("shape-rendering","crispEdges"));return E[b]}function m(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var k=this,h=null,n=new THREE.Projector,o=document.createElementNS("http://www.w3.org/2000/svg","svg"),u,v,t,x,w,y,A,z,D=new THREE.Rectangle,C=new THREE.Rectangle,F=!1,G=new THREE.Color(16777215),N=new THREE.Color(16777215),R=new THREE.Color(0),
 H=new THREE.Color(0),J=new THREE.Color(0),I,X=new THREE.Vector3,E=[],O=[],P,U,V,p=1;this.domElement=o;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(b){switch(b){case "high":p=1;break;case "low":p=0}};this.setSize=function(b,e){u=b;v=e;t=u/2;x=v/2;o.setAttribute("viewBox",-t+" "+-x+" "+u+" "+v);o.setAttribute("width",u);o.setAttribute("height",v);D.set(-t,-x,t,x)};this.clear=function(){for(;o.childNodes.length>0;)o.removeChild(o.childNodes[0])};
-this.render=function(b,f){var m,u,v,G,N,E,I,T;this.autoClear&&this.clear();k.info.render.vertices=0;k.info.render.faces=0;h=n.projectScene(b,f,this.sortElements);V=U=0;if(C=b.lights.length>0){I=b.lights;R.setRGB(0,0,0);H.setRGB(0,0,0);J.setRGB(0,0,0);m=0;for(u=I.length;m<u;m++)v=I[m],G=v.color,v instanceof THREE.AmbientLight?(R.r+=G.r,R.g+=G.g,R.b+=G.b):v instanceof THREE.DirectionalLight?(H.r+=G.r,H.g+=G.g,H.b+=G.b):v instanceof THREE.PointLight&&(J.r+=G.r,J.g+=G.g,J.b+=G.b)}m=0;for(u=h.length;m<
-u;m++)if(I=h[m],F.empty(),I instanceof THREE.RenderableParticle){w=I;w.x*=t;w.y*=-x;v=0;for(G=I.materials.length;v<G;)v++}else if(I instanceof THREE.RenderableLine){if(w=I.v1,y=I.v2,w.positionScreen.x*=t,w.positionScreen.y*=-x,y.positionScreen.x*=t,y.positionScreen.y*=-x,F.addPoint(w.positionScreen.x,w.positionScreen.y),F.addPoint(y.positionScreen.x,y.positionScreen.y),D.intersects(F)){v=0;for(G=I.materials.length;v<G;)if((T=I.materials[v++])&&T.opacity!=0){N=w;E=y;var Y=V++;O[Y]==null&&(O[Y]=document.createElementNS("http://www.w3.org/2000/svg",
+this.render=function(b,f){var m,u,v,G,N,E,I,T;this.autoClear&&this.clear();k.info.render.vertices=0;k.info.render.faces=0;h=n.projectScene(b,f,this.sortElements);V=U=0;if(F=b.lights.length>0){I=b.lights;R.setRGB(0,0,0);H.setRGB(0,0,0);J.setRGB(0,0,0);m=0;for(u=I.length;m<u;m++)v=I[m],G=v.color,v instanceof THREE.AmbientLight?(R.r+=G.r,R.g+=G.g,R.b+=G.b):v instanceof THREE.DirectionalLight?(H.r+=G.r,H.g+=G.g,H.b+=G.b):v instanceof THREE.PointLight&&(J.r+=G.r,J.g+=G.g,J.b+=G.b)}m=0;for(u=h.length;m<
+u;m++)if(I=h[m],C.empty(),I instanceof THREE.RenderableParticle){w=I;w.x*=t;w.y*=-x;v=0;for(G=I.materials.length;v<G;)v++}else if(I instanceof THREE.RenderableLine){if(w=I.v1,y=I.v2,w.positionScreen.x*=t,w.positionScreen.y*=-x,y.positionScreen.x*=t,y.positionScreen.y*=-x,C.addPoint(w.positionScreen.x,w.positionScreen.y),C.addPoint(y.positionScreen.x,y.positionScreen.y),D.intersects(C)){v=0;for(G=I.materials.length;v<G;)if((T=I.materials[v++])&&T.opacity!=0){N=w;E=y;var Y=V++;O[Y]==null&&(O[Y]=document.createElementNS("http://www.w3.org/2000/svg",
 "line"),p==0&&O[Y].setAttribute("shape-rendering","crispEdges"));P=O[Y];P.setAttribute("x1",N.positionScreen.x);P.setAttribute("y1",N.positionScreen.y);P.setAttribute("x2",E.positionScreen.x);P.setAttribute("y2",E.positionScreen.y);T instanceof THREE.LineBasicMaterial&&(P.setAttribute("style","fill: none; stroke: "+T.color.getContextStyle()+"; stroke-width: "+T.linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+T.linecap+"; stroke-linejoin: "+T.linejoin),o.appendChild(P))}}}else if(I instanceof
-THREE.RenderableFace3){if(w=I.v1,y=I.v2,A=I.v3,w.positionScreen.x*=t,w.positionScreen.y*=-x,y.positionScreen.x*=t,y.positionScreen.y*=-x,A.positionScreen.x*=t,A.positionScreen.y*=-x,F.addPoint(w.positionScreen.x,w.positionScreen.y),F.addPoint(y.positionScreen.x,y.positionScreen.y),F.addPoint(A.positionScreen.x,A.positionScreen.y),D.intersects(F)){v=0;for(G=I.meshMaterials.length;v<G;)if(T=I.meshMaterials[v++],T instanceof THREE.MeshFaceMaterial){N=0;for(E=I.faceMaterials.length;N<E;)(T=I.faceMaterials[N++])&&
-T.opacity!=0&&c(w,y,A,I,T,b)}else T&&T.opacity!=0&&c(w,y,A,I,T,b)}}else if(I instanceof THREE.RenderableFace4&&(w=I.v1,y=I.v2,A=I.v3,z=I.v4,w.positionScreen.x*=t,w.positionScreen.y*=-x,y.positionScreen.x*=t,y.positionScreen.y*=-x,A.positionScreen.x*=t,A.positionScreen.y*=-x,z.positionScreen.x*=t,z.positionScreen.y*=-x,F.addPoint(w.positionScreen.x,w.positionScreen.y),F.addPoint(y.positionScreen.x,y.positionScreen.y),F.addPoint(A.positionScreen.x,A.positionScreen.y),F.addPoint(z.positionScreen.x,z.positionScreen.y),
-D.intersects(F))){v=0;for(G=I.meshMaterials.length;v<G;)if(T=I.meshMaterials[v++],T instanceof THREE.MeshFaceMaterial){N=0;for(E=I.faceMaterials.length;N<E;)(T=I.faceMaterials[N++])&&T.opacity!=0&&e(w,y,A,z,I,T,b)}else T&&T.opacity!=0&&e(w,y,A,z,I,T,b)}}};
+THREE.RenderableFace3){if(w=I.v1,y=I.v2,A=I.v3,w.positionScreen.x*=t,w.positionScreen.y*=-x,y.positionScreen.x*=t,y.positionScreen.y*=-x,A.positionScreen.x*=t,A.positionScreen.y*=-x,C.addPoint(w.positionScreen.x,w.positionScreen.y),C.addPoint(y.positionScreen.x,y.positionScreen.y),C.addPoint(A.positionScreen.x,A.positionScreen.y),D.intersects(C)){v=0;for(G=I.meshMaterials.length;v<G;)if(T=I.meshMaterials[v++],T instanceof THREE.MeshFaceMaterial){N=0;for(E=I.faceMaterials.length;N<E;)(T=I.faceMaterials[N++])&&
+T.opacity!=0&&c(w,y,A,I,T,b)}else T&&T.opacity!=0&&c(w,y,A,I,T,b)}}else if(I instanceof THREE.RenderableFace4&&(w=I.v1,y=I.v2,A=I.v3,z=I.v4,w.positionScreen.x*=t,w.positionScreen.y*=-x,y.positionScreen.x*=t,y.positionScreen.y*=-x,A.positionScreen.x*=t,A.positionScreen.y*=-x,z.positionScreen.x*=t,z.positionScreen.y*=-x,C.addPoint(w.positionScreen.x,w.positionScreen.y),C.addPoint(y.positionScreen.x,y.positionScreen.y),C.addPoint(A.positionScreen.x,A.positionScreen.y),C.addPoint(z.positionScreen.x,z.positionScreen.y),
+D.intersects(C))){v=0;for(G=I.meshMaterials.length;v<G;)if(T=I.meshMaterials[v++],T instanceof THREE.MeshFaceMaterial){N=0;for(E=I.faceMaterials.length;N<E;)(T=I.faceMaterials[N++])&&T.opacity!=0&&e(w,y,A,z,I,T,b)}else T&&T.opacity!=0&&e(w,y,A,z,I,T,b)}}};
 THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[ 0 ].xyz, objectMatrix[ 1 ].xyz, objectMatrix[ 2 ].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",
@@ -254,8 +255,8 @@ L.customDepthMaterial:L.geometry.morphTargets.length?Ka:xa,f(va,z,null,y,buffer,
 p.enableVertexAttribArray(Z.attributes.uv),Ja=!0);p.disable(p.CULL_FACE);p.enable(p.BLEND);p.depthMask(!0);p.bindBuffer(p.ARRAY_BUFFER,Z.vertexBuffer);p.vertexAttribPointer(c.position,2,p.FLOAT,!1,16,0);p.vertexAttribPointer(c.uv,2,p.FLOAT,!1,16,8);p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,Z.elementBuffer);p.uniformMatrix4fv(k.projectionMatrix,!1,Da);p.activeTexture(p.TEXTURE0);p.uniform1i(k.map,0);c=0;for(f=b.__webglSprites.length;c<f;c++)if(h=b.__webglSprites[c],h.visible&&h.opacity!=0)h.useScreenCoordinates?
 h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(y);c=0;for(f=b.__webglSprites.length;c<f;c++)h=b.__webglSprites[c],h.visible&&h.opacity!=0&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(p.uniform1i(k.useScreenCoordinates,1),p.uniform3f(k.screenPosition,(h.position.x-t)/t,(w-h.position.y)/w,Math.max(0,Math.min(1,h.position.z)))):(p.uniform1i(k.useScreenCoordinates,
 0),p.uniform1i(k.affectedByDistance,h.affectedByDistance?1:0),p.uniformMatrix4fv(k.modelViewMatrix,!1,h._modelViewMatrixArray)),n=h.map.image.width/(h.scaleByViewport?qa:1),o[0]=n*m*h.scale.x,o[1]=n*h.scale.y,p.uniform2f(k.uvScale,h.uvScale.x,h.uvScale.y),p.uniform2f(k.uvOffset,h.uvOffset.x,h.uvOffset.y),p.uniform2f(k.alignment,h.alignment.x,h.alignment.y),p.uniform1f(k.opacity,h.opacity),p.uniform3f(k.color,h.color.r,h.color.g,h.color.b),p.uniform1f(k.rotation,h.rotation),p.uniform2fv(k.scale,o),
-h.mergeWith3D&&!u?(p.enable(p.DEPTH_TEST),u=!0):!h.mergeWith3D&&u&&(p.disable(p.DEPTH_TEST),u=!1),H(h.blending),I(h.map,0),p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0));p.enable(p.CULL_FACE);p.enable(p.DEPTH_TEST);p.depthMask(Y)}function D(b,e,c){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function F(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b<
-c;b++)if(f=h[b],f.attributes)for(e in f.attributes)if(f.attributes[e].needsUpdate)return!0;return!1}function C(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b<c;b++)if(f=h[b],f.attributes)for(e in f.attributes)f.attributes[e].needsUpdate=!1}function G(b,e){var c;for(c=b.length-1;c>=0;c--)b[c].object==e&&b.splice(c,1)}function N(b){function e(b){var h=[];c=0;for(f=b.length;c<f;c++)b[c]==void 0?h.push("undefined"):h.push(b[c].id);return h.join("_")}var c,f,h,k,m,n,p,o,t={},w=b.morphTargets!==void 0?
+h.mergeWith3D&&!u?(p.enable(p.DEPTH_TEST),u=!0):!h.mergeWith3D&&u&&(p.disable(p.DEPTH_TEST),u=!1),H(h.blending),I(h.map,0),p.drawElements(p.TRIANGLES,6,p.UNSIGNED_SHORT,0));p.enable(p.CULL_FACE);p.enable(p.DEPTH_TEST);p.depthMask(Y)}function D(b,e,c){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function C(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b<
+c;b++)if(f=h[b],f.attributes)for(e in f.attributes)if(f.attributes[e].needsUpdate)return!0;return!1}function F(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b<c;b++)if(f=h[b],f.attributes)for(e in f.attributes)f.attributes[e].needsUpdate=!1}function G(b,e){var c;for(c=b.length-1;c>=0;c--)b[c].object==e&&b.splice(c,1)}function N(b){function e(b){var h=[];c=0;for(f=b.length;c<f;c++)b[c]==void 0?h.push("undefined"):h.push(b[c].id);return h.join("_")}var c,f,h,k,m,n,p,o,t={},w=b.morphTargets!==void 0?
 b.morphTargets.length:0;b.geometryGroups={};h=0;for(k=b.faces.length;h<k;h++)m=b.faces[h],n=m.materials,p=e(n),t[p]==void 0&&(t[p]={hash:p,counter:0}),o=t[p].hash+"_"+t[p].counter,b.geometryGroups[o]==void 0&&(b.geometryGroups[o]={faces:[],materials:n,vertices:0,numMorphTargets:w}),m=m instanceof THREE.Face3?3:4,b.geometryGroups[o].vertices+m>65535&&(t[p].counter+=1,o=t[p].hash+"_"+t[p].counter,b.geometryGroups[o]==void 0&&(b.geometryGroups[o]={faces:[],materials:n,vertices:0,numMorphTargets:w})),
 b.geometryGroups[o].faces.push(h),b.geometryGroups[o].vertices+=m;b.geometryGroupsList=[];for(var u in b.geometryGroups)b.geometryGroups[u].id=ca++,b.geometryGroupsList.push(b.geometryGroups[u])}function R(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function H(b){if(b!=da){switch(b){case THREE.AdditiveBlending:p.blendEquation(p.FUNC_ADD);p.blendFunc(p.SRC_ALPHA,p.ONE);break;case THREE.SubtractiveBlending:p.blendEquation(p.FUNC_ADD);p.blendFunc(p.ZERO,
 p.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:p.blendEquation(p.FUNC_ADD);p.blendFunc(p.ZERO,p.SRC_COLOR);break;default:p.blendEquationSeparate(p.FUNC_ADD,p.FUNC_ADD),p.blendFuncSeparate(p.SRC_ALPHA,p.ONE_MINUS_SRC_ALPHA,p.ONE,p.ONE_MINUS_SRC_ALPHA)}da=b}}function J(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(p.texParameteri(b,p.TEXTURE_WRAP_S,U(e.wrapS)),p.texParameteri(b,p.TEXTURE_WRAP_T,U(e.wrapT)),p.texParameteri(b,p.TEXTURE_MAG_FILTER,U(e.magFilter)),p.texParameteri(b,
@@ -292,7 +293,7 @@ x=f;y=0;for(e=x.length;y<e;y++)c=x[y],L.attributes[c]=p.getAttribLocation(L,c);L
 p.enableVertexAttribArray(x.skinVertexB),p.enableVertexAttribArray(x.skinIndex),p.enableVertexAttribArray(x.skinWeight));if(b.attributes)for(k in b.attributes)x[k]!==void 0&&x[k]>=0&&p.enableVertexAttribArray(x[k]);if(b.morphTargets)for(k=b.numSupportedMorphTargets=0;k<this.maxMorphTargets;k++)y="morphTarget"+k,x[y]>=0&&(p.enableVertexAttribArray(x[y]),b.numSupportedMorphTargets++);b.uniformsList=[];for(h in b.uniforms)b.uniformsList.push([b.uniforms[h],h])};this.clearTarget=function(b,e,c,f){X(b);
 b=0;e&&(b|=p.COLOR_BUFFER_BIT);c&&(b|=p.DEPTH_BUFFER_BIT);f&&(b|=p.STENCIL_BUFFER_BIT);p.clear(b)};this.render=function(b,c,p,t){var L,W,aa,C,F,G,M,N,J=b.lights,oa=b.fog;$=-1;this.shadowMapEnabled&&A(b,c);V.info.render.calls=0;V.info.render.vertices=0;V.info.render.faces=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(za);c.projectionMatrix.flattenToArray(Da);ua.multiply(c.projectionMatrix,c.matrixWorldInverse);u(ua);this.initWebGLObjects(b);X(p);
 (this.autoClear||t)&&this.clear();F=b.__webglObjects.length;for(t=0;t<F;t++)if(L=b.__webglObjects[t],M=L.object,M.visible)if(!(M instanceof THREE.Mesh)||!M.frustumCulled||v(M)){if(M.matrixWorld.flattenToArray(M._objectMatrixArray),D(M,c,!0),w(L),L.render=!0,this.sortObjects)L.object.renderDepth?L.z=L.object.renderDepth:(Ba.copy(M.position),ua.multiplyVector3(Ba),L.z=Ba.z)}else L.render=!1;else L.render=!1;this.sortObjects&&b.__webglObjects.sort(y);G=b.__webglObjectsImmediate.length;for(t=0;t<G;t++)L=
-b.__webglObjectsImmediate[t],M=L.object,M.visible&&(M.matrixAutoUpdate&&M.matrixWorld.flattenToArray(M._objectMatrixArray),D(M,c,!0),x(L));if(b.overrideMaterial){h(b.overrideMaterial.depthTest);H(b.overrideMaterial.blending);for(t=0;t<F;t++)if(L=b.__webglObjects[t],L.render)M=L.object,N=L.buffer,k(M),f(c,J,oa,b.overrideMaterial,N,M);for(t=0;t<G;t++)L=b.__webglObjectsImmediate[t],M=L.object,M.visible&&(k(M),W=e(c,J,oa,b.overrideMaterial,M),M.render(function(c){m(c,W,b.overrideMaterial.shading)}))}else{H(THREE.NormalBlending);
+b.__webglObjectsImmediate[t],M=L.object,M.visible&&(M.matrixAutoUpdate&&M.matrixWorld.flattenToArray(M._objectMatrixArray),D(M,c,!0),x(L));if(b.overrideMaterial){h(b.overrideMaterial.depthTest);H(b.overrideMaterial.blending);for(t=0;t<F;t++)if(L=b.__webglObjects[t],L.render)M=L.object,N=L.buffer,k(M),f(c,J,oa,b.overrideMaterial,N,M);for(t=0;t<G;t++)L=b.__webglObjectsImmediate[t],M=L.object,M.visible&&(k(M),W=e(c,J,oa,b.overrideMaterial,M),M.render(function(e){m(e,W,b.overrideMaterial.shading)}))}else{H(THREE.NormalBlending);
 for(t=F-1;t>=0;t--)if(L=b.__webglObjects[t],L.render){M=L.object;N=L.buffer;aa=L.opaque;k(M);for(L=0;L<aa.count;L++)C=aa.list[L],h(C.depthTest),n(C.depthWrite),o(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),f(c,J,oa,C,N,M)}for(t=0;t<G;t++)if(L=b.__webglObjectsImmediate[t],M=L.object,M.visible){aa=L.opaque;k(M);for(L=0;L<aa.count;L++)C=aa.list[L],h(C.depthTest),n(C.depthWrite),o(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),W=e(c,J,oa,C,M),M.render(function(b){m(b,W,C.shading)})}for(t=
 0;t<F;t++)if(L=b.__webglObjects[t],L.render){M=L.object;N=L.buffer;aa=L.transparent;k(M);for(L=0;L<aa.count;L++)C=aa.list[L],H(C.blending),h(C.depthTest),n(C.depthWrite),o(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),f(c,J,oa,C,N,M)}for(t=0;t<G;t++)if(L=b.__webglObjectsImmediate[t],M=L.object,M.visible){aa=L.transparent;k(M);for(L=0;L<aa.count;L++)C=aa.list[L],H(C.blending),h(C.depthTest),n(C.depthWrite),o(C.polygonOffset,C.polygonOffsetFactor,C.polygonOffsetUnits),W=e(c,J,oa,C,M),
 M.render(function(b){m(b,W,C.shading)})}}b.__webglSprites.length&&z(b,c);p&&p.minFilter!==THREE.NearestFilter&&p.minFilter!==THREE.LinearFilter&&E(p)};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var e=b.__objectsAdded[0],f=b,h=void 0,k=void 0,m=void 0;if(!e.__webglInit)if(e.__webglInit=!0,e._modelViewMatrix=new THREE.Matrix4,e._normalMatrixArray=new Float32Array(9),e._modelViewMatrixArray=
@@ -309,7 +310,7 @@ new Float32Array(o*3);m.__sortArray=[];m.__webglParticleCount=o;m.__materials=n.
 "v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(o*size),attribute.buffer=p.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;m.__webglCustomAttributes[a]=attribute}}k.__dirtyVertices=!0;k.__dirtyColors=!0}if(!e.__webglActive){if(e instanceof THREE.Mesh)for(h in k=e.geometry,k.geometryGroups)m=k.geometryGroups[h],R(f.__webglObjects,
 m,e);else e instanceof THREE.Ribbon||e instanceof THREE.Line||e instanceof THREE.ParticleSystem?(k=e.geometry,R(f.__webglObjects,k,e)):THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes?f.__webglObjectsImmediate.push({object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}}):e instanceof THREE.Sprite&&f.__webglSprites.push(e);e.__webglActive=!0}b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){e=b.__objectsRemoved[0];f=b;if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||
 e instanceof THREE.Ribbon||e instanceof THREE.Line)G(f.__webglObjects,e);else if(e instanceof THREE.Sprite){f=f.__webglSprites;h=e;k=void 0;for(k=f.length-1;k>=0;k--)f[k]==h&&f.splice(k,1)}else e instanceof THREE.MarchingCubes&&G(f.__webglObjectsImmediate,e);e.__webglActive=!1;b.__objectsRemoved.splice(0,1)}e=0;for(f=b.__webglObjects.length;e<f;e++)if(k=b.__webglObjects[e].object,t=m=h=void 0,k instanceof THREE.Mesh){h=k.geometry;n=0;for(o=h.geometryGroupsList.length;n<o;n++)if(m=h.geometryGroupsList[n],
-t=F(m),h.__dirtyVertices||h.__dirtyMorphTargets||h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||t)if(t=m,y=p.DYNAMIC_DRAW,z=!h.dynamic,t.__inittedArrays){var D=w=x=void 0,M=void 0,J=D=void 0,oa=void 0,ra=void 0,I=void 0,ha=A=aa=v=W=L=u=void 0,H=void 0,la=void 0,K=M=I=M=ra=oa=void 0,B=void 0,E=B=K=oa=void 0,Y=void 0,pa=E=B=K=D=D=J=I=M=E=B=K=Y=E=B=K=Y=E=B=K=void 0,T=0,O=0,qa=0,Ca=0,Z=0,S=0,P=0,na=0,X=0,Q=0,U=0,E=K=0,E=void 0,ga=t.__vertexArray,va=t.__uvArray,
+t=C(m),h.__dirtyVertices||h.__dirtyMorphTargets||h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||t)if(t=m,y=p.DYNAMIC_DRAW,z=!h.dynamic,t.__inittedArrays){var D=w=x=void 0,M=void 0,J=D=void 0,oa=void 0,ra=void 0,I=void 0,ha=A=aa=v=W=L=u=void 0,H=void 0,la=void 0,K=M=I=M=ra=oa=void 0,B=void 0,E=B=K=oa=void 0,Y=void 0,pa=E=B=K=D=D=J=I=M=E=B=K=Y=E=B=K=Y=E=B=K=void 0,T=0,O=0,qa=0,Ca=0,Z=0,S=0,P=0,na=0,X=0,Q=0,U=0,E=K=0,E=void 0,ga=t.__vertexArray,va=t.__uvArray,
 wa=t.__uv2Array,ja=t.__normalArray,ia=t.__tangentArray,da=t.__colorArray,ca=t.__skinVertexAArray,$=t.__skinVertexBArray,ea=t.__skinIndexArray,fa=t.__skinWeightArray,ma=t.__morphTargetsArrays,xa=t.__webglCustomAttributes,B=void 0,ka=t.__faceArray,sa=t.__lineArray,Ia=t.__needsSmoothNormals,L=t.__vertexColorType,u=t.__uvType,W=t.__normalType,ua=k.geometry,Da=ua.__dirtyVertices,Aa=ua.__dirtyElements,za=ua.__dirtyUvs,Ga=ua.__dirtyNormals,Ka=ua.__dirtyTangents,Ba=ua.__dirtyColors,Fa=ua.__dirtyMorphTargets,
 Ja=ua.vertices,cb=t.faces,fb=ua.faces,db=ua.faceVertexUvs[0],eb=ua.faceVertexUvs[1],Ra=ua.skinVerticesA,Sa=ua.skinVerticesB,Ta=ua.skinIndices,Ma=ua.skinWeights,La=ua.morphTargets;if(xa)for(pa in xa)xa[pa].offset=0,xa[pa].offsetSrc=0;x=0;for(w=cb.length;x<w;x++)if(D=cb[x],M=fb[D],db&&(v=db[D]),eb&&(aa=eb[D]),D=M.vertexNormals,J=M.normal,oa=M.vertexColors,ra=M.color,I=M.vertexTangents,M instanceof THREE.Face3){if(Da)A=Ja[M.a].position,ha=Ja[M.b].position,H=Ja[M.c].position,ga[O]=A.x,ga[O+1]=A.y,ga[O+
 2]=A.z,ga[O+3]=ha.x,ga[O+4]=ha.y,ga[O+5]=ha.z,ga[O+6]=H.x,ga[O+7]=H.y,ga[O+8]=H.z,O+=9;if(xa)for(pa in xa)if(B=xa[pa],B.__original.needsUpdate)K=B.offset,E=B.offsetSrc,B.size===1?(B.boundTo===void 0||B.boundTo==="vertices"?(B.array[K]=B.value[M.a],B.array[K+1]=B.value[M.b],B.array[K+2]=B.value[M.c]):B.boundTo==="faces"?(E=B.value[E],B.array[K]=E,B.array[K+1]=E,B.array[K+2]=E,B.offsetSrc++):B.boundTo==="faceVertices"&&(B.array[K]=B.value[E],B.array[K+1]=B.value[E+1],B.array[K+2]=B.value[E+2],B.offsetSrc+=
@@ -330,10 +331,10 @@ J.y,ja[S+2]=J.z,S+=3;if(za&&v!==void 0&&u)for(I=0;I<4;I++)D=v[I],va[qa]=D.u,va[q
 (p.bindBuffer(p.ARRAY_BUFFER,B.buffer),p.bufferData(p.ARRAY_BUFFER,B.array,y));if(Fa){K=0;for(B=La.length;K<B;K++)p.bindBuffer(p.ARRAY_BUFFER,t.__webglMorphTargetsBuffers[K]),p.bufferData(p.ARRAY_BUFFER,ma[K],y)}Ba&&X>0&&(p.bindBuffer(p.ARRAY_BUFFER,t.__webglColorBuffer),p.bufferData(p.ARRAY_BUFFER,da,y));Ga&&(p.bindBuffer(p.ARRAY_BUFFER,t.__webglNormalBuffer),p.bufferData(p.ARRAY_BUFFER,ja,y));Ka&&ua.hasTangents&&(p.bindBuffer(p.ARRAY_BUFFER,t.__webglTangentBuffer),p.bufferData(p.ARRAY_BUFFER,ia,
 y));za&&qa>0&&(p.bindBuffer(p.ARRAY_BUFFER,t.__webglUVBuffer),p.bufferData(p.ARRAY_BUFFER,va,y));za&&Ca>0&&(p.bindBuffer(p.ARRAY_BUFFER,t.__webglUV2Buffer),p.bufferData(p.ARRAY_BUFFER,wa,y));Aa&&(p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,t.__webglFaceBuffer),p.bufferData(p.ELEMENT_ARRAY_BUFFER,ka,y),p.bindBuffer(p.ELEMENT_ARRAY_BUFFER,t.__webglLineBuffer),p.bufferData(p.ELEMENT_ARRAY_BUFFER,sa,y));Q>0&&(p.bindBuffer(p.ARRAY_BUFFER,t.__webglSkinVertexABuffer),p.bufferData(p.ARRAY_BUFFER,ca,y),p.bindBuffer(p.ARRAY_BUFFER,
 t.__webglSkinVertexBBuffer),p.bufferData(p.ARRAY_BUFFER,$,y),p.bindBuffer(p.ARRAY_BUFFER,t.__webglSkinIndicesBuffer),p.bufferData(p.ARRAY_BUFFER,ea,y),p.bindBuffer(p.ARRAY_BUFFER,t.__webglSkinWeightsBuffer),p.bufferData(p.ARRAY_BUFFER,fa,y));z&&(delete t.__inittedArrays,delete t.__colorArray,delete t.__normalArray,delete t.__tangentArray,delete t.__uvArray,delete t.__uv2Array,delete t.__faceArray,delete t.__vertexArray,delete t.__lineArray,delete t.__skinVertexAArray,delete t.__skinVertexBArray,delete t.__skinIndexArray,
-delete t.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;C(m)}else if(k instanceof THREE.Ribbon){h=k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=p.DYNAMIC_DRAW;n=x=z=z=void 0;w=k.vertices;o=k.colors;u=w.length;t=o.length;L=k.__vertexArray;y=k.__colorArray;W=k.__dirtyColors;if(k.__dirtyVertices){for(z=0;z<u;z++)x=w[z].position,n=z*3,L[n]=x.x,L[n+1]=x.y,L[n+2]=x.z;p.bindBuffer(p.ARRAY_BUFFER,
+delete t.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;F(m)}else if(k instanceof THREE.Ribbon){h=k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=p.DYNAMIC_DRAW;n=x=z=z=void 0;w=k.vertices;o=k.colors;u=w.length;t=o.length;L=k.__vertexArray;y=k.__colorArray;W=k.__dirtyColors;if(k.__dirtyVertices){for(z=0;z<u;z++)x=w[z].position,n=z*3,L[n]=x.x,L[n+1]=x.y,L[n+2]=x.z;p.bindBuffer(p.ARRAY_BUFFER,
 k.__webglVertexBuffer);p.bufferData(p.ARRAY_BUFFER,L,m)}if(W){for(z=0;z<t;z++)color=o[z],n=z*3,y[n]=color.r,y[n+1]=color.g,y[n+2]=color.b;p.bindBuffer(p.ARRAY_BUFFER,k.__webglColorBuffer);p.bufferData(p.ARRAY_BUFFER,y,m)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(k instanceof THREE.Line){h=k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=p.DYNAMIC_DRAW;n=x=z=z=void 0;w=k.vertices;o=k.colors;u=w.length;t=o.length;L=k.__vertexArray;y=k.__colorArray;W=k.__dirtyColors;if(k.__dirtyVertices){for(z=
-0;z<u;z++)x=w[z].position,n=z*3,L[n]=x.x,L[n+1]=x.y,L[n+2]=x.z;p.bindBuffer(p.ARRAY_BUFFER,k.__webglVertexBuffer);p.bufferData(p.ARRAY_BUFFER,L,m)}if(W){for(z=0;z<t;z++)color=o[z],n=z*3,y[n]=color.r,y[n+1]=color.g,y[n+2]=color.b;p.bindBuffer(p.ARRAY_BUFFER,k.__webglColorBuffer);p.bufferData(p.ARRAY_BUFFER,y,m)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(k instanceof THREE.ParticleSystem)h=k.geometry,t=F(h),(h.__dirtyVertices||h.__dirtyColors||k.sortParticles||t)&&c(h,p.DYNAMIC_DRAW,k),h.__dirtyVertices=
-!1,h.__dirtyColors=!1,C(h)};this.setFaceCulling=function(b,e){b?(!e||e=="ccw"?p.frontFace(p.CCW):p.frontFace(p.CW),b=="back"?p.cullFace(p.BACK):b=="front"?p.cullFace(p.FRONT):p.cullFace(p.FRONT_AND_BACK),p.enable(p.CULL_FACE)):p.disable(p.CULL_FACE)};this.supportsVertexTextures=function(){return Ga}};
+0;z<u;z++)x=w[z].position,n=z*3,L[n]=x.x,L[n+1]=x.y,L[n+2]=x.z;p.bindBuffer(p.ARRAY_BUFFER,k.__webglVertexBuffer);p.bufferData(p.ARRAY_BUFFER,L,m)}if(W){for(z=0;z<t;z++)color=o[z],n=z*3,y[n]=color.r,y[n+1]=color.g,y[n+2]=color.b;p.bindBuffer(p.ARRAY_BUFFER,k.__webglColorBuffer);p.bufferData(p.ARRAY_BUFFER,y,m)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(k instanceof THREE.ParticleSystem)h=k.geometry,t=C(h),(h.__dirtyVertices||h.__dirtyColors||k.sortParticles||t)&&c(h,p.DYNAMIC_DRAW,k),h.__dirtyVertices=
+!1,h.__dirtyColors=!1,F(h)};this.setFaceCulling=function(b,e){b?(!e||e=="ccw"?p.frontFace(p.CCW):p.frontFace(p.CW),b=="back"?p.cullFace(p.BACK):b=="front"?p.cullFace(p.FRONT):p.cullFace(p.FRONT_AND_BACK),p.enable(p.CULL_FACE)):p.disable(p.CULL_FACE)};this.supportsVertexTextures=function(){return Ga}};
 THREE.WebGLRenderTarget=function(b,c,e){this.width=b;this.height=c;e=e||{};this.wrapS=e.wrapS!==void 0?e.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=e.wrapT!==void 0?e.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=e.magFilter!==void 0?e.magFilter:THREE.LinearFilter;this.minFilter=e.minFilter!==void 0?e.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=e.format!==void 0?e.format:THREE.RGBAFormat;this.type=e.type!==void 0?e.type:
 THREE.UnsignedByteType;this.depthBuffer=e.depthBuffer!==void 0?e.depthBuffer:!0;this.stencilBuffer=e.stencilBuffer!==void 0?e.stencilBuffer:!0};
 THREE.WebGLRenderTarget.prototype.clone=function(){var b=new THREE.WebGLRenderTarget(this.width,this.height);b.wrapS=this.wrapS;b.wrapT=this.wrapT;b.magFilter=this.magFilter;b.minFilter=this.minFilter;b.offset.copy(this.offset);b.repeat.copy(this.repeat);b.format=this.format;b.type=this.type;b.depthBuffer=this.depthBuffer;b.stencilBuffer=this.stencilBuffer;return b};THREE.WebGLRenderTargetCube=function(b,c,e){THREE.WebGLRenderTarget.call(this,b,c,e);this.activeCubeFace=0};
@@ -354,7 +355,7 @@ u[m]=o}f=[];h={};for(m=0;m<c;m++)n=THREE.GeometryUtils.random()*o,n=e(n),f[m]=TH
 (b.boundingBox.x[1]+b.boundingBox.x[0]),-0.5*(b.boundingBox.y[1]+b.boundingBox.y[0]),-0.5*(b.boundingBox.z[1]+b.boundingBox.z[0]));b.applyMatrix(c);b.computeBoundingBox()}};THREE.GeometryUtils.random=THREE.GeometryUtils.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
 THREE.ImageUtils={loadTexture:function(b,c,e){var f=new Image,m=new THREE.Texture(f,c);f.onload=function(){m.needsUpdate=!0;e&&e(this)};f.crossOrigin="";f.src=b;return m},loadTextureCube:function(b,c,e){var f,m=[],k=new THREE.Texture(m,c),c=m.loadCount=0;for(f=b.length;c<f;++c)m[c]=new Image,m[c].onload=function(){m.loadCount+=1;if(m.loadCount==6)k.needsUpdate=!0;e&&e(this)},m[c].crossOrigin="",m[c].src=b[c];return k},getNormalMap:function(b,c){var e=function(b){var e=Math.sqrt(b[0]*b[0]+b[1]*b[1]+
 b[2]*b[2]);return[b[0]/e,b[1]/e,b[2]/e]};c|=1;var f=b.width,m=b.height,k=document.createElement("canvas");k.width=f;k.height=m;var h=k.getContext("2d");h.drawImage(b,0,0);for(var n=h.getImageData(0,0,f,m).data,o=h.createImageData(f,m),u=o.data,v=0;v<f;v++)for(var t=1;t<m;t++){var x=t-1<0?m-1:t-1,w=(t+1)%m,y=v-1<0?f-1:v-1,A=(v+1)%f,z=[],D=[0,0,n[(t*f+v)*4]/255*c];z.push([-1,0,n[(t*f+y)*4]/255*c]);z.push([-1,-1,n[(x*f+y)*4]/255*c]);z.push([0,-1,n[(x*f+v)*4]/255*c]);z.push([1,-1,n[(x*f+A)*4]/255*c]);
-z.push([1,0,n[(t*f+A)*4]/255*c]);z.push([1,1,n[(w*f+A)*4]/255*c]);z.push([0,1,n[(w*f+v)*4]/255*c]);z.push([-1,1,n[(w*f+y)*4]/255*c]);x=[];y=z.length;for(w=0;w<y;w++){var A=z[w],F=z[(w+1)%y],A=[A[0]-D[0],A[1]-D[1],A[2]-D[2]],F=[F[0]-D[0],F[1]-D[1],F[2]-D[2]];x.push(e([A[1]*F[2]-A[2]*F[1],A[2]*F[0]-A[0]*F[2],A[0]*F[1]-A[1]*F[0]]))}z=[0,0,0];for(w=0;w<x.length;w++)z[0]+=x[w][0],z[1]+=x[w][1],z[2]+=x[w][2];z[0]/=x.length;z[1]/=x.length;z[2]/=x.length;D=(t*f+v)*4;u[D]=(z[0]+1)/2*255|0;u[D+1]=(z[1]+0.5)*
+z.push([1,0,n[(t*f+A)*4]/255*c]);z.push([1,1,n[(w*f+A)*4]/255*c]);z.push([0,1,n[(w*f+v)*4]/255*c]);z.push([-1,1,n[(w*f+y)*4]/255*c]);x=[];y=z.length;for(w=0;w<y;w++){var A=z[w],C=z[(w+1)%y],A=[A[0]-D[0],A[1]-D[1],A[2]-D[2]],C=[C[0]-D[0],C[1]-D[1],C[2]-D[2]];x.push(e([A[1]*C[2]-A[2]*C[1],A[2]*C[0]-A[0]*C[2],A[0]*C[1]-A[1]*C[0]]))}z=[0,0,0];for(w=0;w<x.length;w++)z[0]+=x[w][0],z[1]+=x[w][1],z[2]+=x[w][2];z[0]/=x.length;z[1]/=x.length;z[2]/=x.length;D=(t*f+v)*4;u[D]=(z[0]+1)/2*255|0;u[D+1]=(z[1]+0.5)*
 255|0;u[D+2]=z[2]*255|0;u[D+3]=255}h.putImageData(o,0,0);return k}};THREE.SceneUtils={showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var e,f,m=b.children.length;for(f=0;f<m;f++)e=b.children[f],c(e),THREE.SceneUtils.traverseHierarchy(e,c)}};
 if(THREE.WebGLRenderer)THREE.ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
 vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
@@ -434,7 +435,7 @@ this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this
 c*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/(Math.PI-0)+this.verticalMin;b=this.target.position;m=this.position;b.x=m.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=m.y+100*Math.cos(this.phi);b.z=m.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},
 !1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;
 THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;THREE.FirstPersonCamera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(b));this.target.position.addSelf(c.multiplyScalar(b))};
-THREE.PathCamera=function(b){function c(b,e,c,f){var h={name:c,fps:0.6,length:f,hierarchy:[]},k,m=e.getControlPointsArray(),n=e.getLength(),o=m.length,F=0;k=o-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:m[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[k]={time:f,pos:m[k],rot:[0,0,0,1],scl:[1,1,1]};for(k=1;k<o-1;k++)F=f*n.chunks[k]/n.total,e.keys[k]={time:F,pos:m[k]};h.hierarchy[0]=e;THREE.AnimationHandler.add(h);return new THREE.Animation(b,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(b,e){var c,
+THREE.PathCamera=function(b){function c(b,e,c,f){var h={name:c,fps:0.6,length:f,hierarchy:[]},k,m=e.getControlPointsArray(),n=e.getLength(),o=m.length,C=0;k=o-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:m[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[k]={time:f,pos:m[k],rot:[0,0,0,1],scl:[1,1,1]};for(k=1;k<o-1;k++)C=f*n.chunks[k]/n.total,e.keys[k]={time:C,pos:m[k]};h.hierarchy[0]=e;THREE.AnimationHandler.add(h);return new THREE.Animation(b,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(b,e){var c,
 f,h=new THREE.Geometry;for(c=0;c<b.points.length*e;c++)f=c/(b.points.length*e),f=b.getPoint(f),h.vertices[c]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return h}function f(b,c){var f=e(c,10),h=e(c,10),k=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(f,k);particleObj=new THREE.ParticleSystem(h,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);b.addChild(lineObj);particleObj.scale.set(1,1,1);b.addChild(particleObj);h=new THREE.SphereGeometry(1,
 16,8);k=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)f=new THREE.Mesh(h,k),f.position.copy(c.points[i]),f.updateMatrix(),b.addChild(f)}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=
 this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.domElement=document;if(b){if(b.duration!==void 0)this.duration=b.duration*1E3;if(b.waypoints!==void 0)this.waypoints=b.waypoints;if(b.useConstantSpeed!==void 0)this.useConstantSpeed=b.useConstantSpeed;if(b.resamplingCoef!==void 0)this.resamplingCoef=b.resamplingCoef;if(b.createDebugPath!==void 0)this.createDebugPath=b.createDebugPath;
@@ -466,35 +467,35 @@ THREE.TrackballCamera=function(b){function c(b,c){return function(){c.apply(b,ar
 !1;this.staticMoving=b.staticMoving||!1;this.dynamicDampingFactor=b.dynamicDampingFactor||0.2;this.minDistance=b.minDistance||0;this.maxDistance=b.maxDistance||Infinity;this.keys=b.keys||[65,83,68];this.useTarget=!0;var e=!1,f=this.STATE.NONE,m=new THREE.Vector3,k=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector2,o=new THREE.Vector2,u=new THREE.Vector2,v=new THREE.Vector2;this.handleEvent=function(b){if(typeof this[b.type]=="function")this[b.type](b)};this.getMouseOnScreen=function(b,c){return new THREE.Vector2((b-
 this.screen.offsetLeft)/this.radius*0.5,(c-this.screen.offsetTop)/this.radius*0.5)};this.getMouseProjectionOnBall=function(b,c){var e=new THREE.Vector3((b-this.screen.width*0.5-this.screen.offsetLeft)/this.radius,(this.screen.height*0.5+this.screen.offsetTop-c)/this.radius,0),f=e.length();f>1?e.normalize():e.z=Math.sqrt(1-f*f);m=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(e.y);f.addSelf(this.up.clone().crossSelf(m).setLength(e.x));f.addSelf(m.setLength(e.z));return f};
 this.rotateCamera=function(){var b=Math.acos(k.dot(h)/k.length()/h.length());if(b){var c=(new THREE.Vector3).cross(k,h).normalize(),e=new THREE.Quaternion;b*=this.rotateSpeed;e.setFromAxisAngle(c,-b);e.multiplyVector3(m);e.multiplyVector3(this.up);e.multiplyVector3(h);this.staticMoving?k=h:(e.setFromAxisAngle(c,b*(this.dynamicDampingFactor-1)),e.multiplyVector3(k))}};this.zoomCamera=function(){var b=1+(o.y-n.y)*this.zoomSpeed;b!==1&&b>0&&(m.multiplyScalar(b),this.staticMoving?n=o:n.y+=(o.y-n.y)*this.dynamicDampingFactor)};
-this.panCamera=function(){var b=v.clone().subSelf(u);if(b.lengthSq()){b.multiplyScalar(m.length()*this.panSpeed);var c=m.clone().crossSelf(this.up).setLength(b.x);c.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?u=v:u.addSelf(b.sub(v,u).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance),
-m.lengthSq()<this.minDistance*this.minDistance&&this.position.add(this.target.position,m.setLength(this.minDistance))};this.update=function(b,c,e){m=this.position.clone().subSelf(this.target.position);this.rotateCamera();this.noZoom||this.zoomCamera();this.noPan||this.panCamera();this.position.add(this.target.position,m);this.checkDistances();this.supr.update.call(this,b,c,e)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
+this.panCamera=function(){var b=v.clone().subSelf(u);if(b.lengthSq()){b.multiplyScalar(m.length()*this.panSpeed);var e=m.clone().crossSelf(this.up).setLength(b.x);e.addSelf(this.up.clone().setLength(b.y));this.position.addSelf(e);this.target.position.addSelf(e);this.staticMoving?u=v:u.addSelf(b.sub(v,u).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance),
+m.lengthSq()<this.minDistance*this.minDistance&&this.position.add(this.target.position,m.setLength(this.minDistance))};this.update=function(b,e,c){m=this.position.clone().subSelf(this.target.position);this.rotateCamera();this.noZoom||this.zoomCamera();this.noPan||this.panCamera();this.position.add(this.target.position,m);this.checkDistances();this.supr.update.call(this,b,e,c)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
 c(this,function(b){e&&(k=h=this.getMouseProjectionOnBall(b.clientX,b.clientY),n=o=this.getMouseOnScreen(b.clientX,b.clientY),u=v=this.getMouseOnScreen(b.clientX,b.clientY),e=!1);f!==this.STATE.NONE&&(f===this.STATE.ROTATE?h=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?o=this.getMouseOnScreen(b.clientX,b.clientY):f===this.STATE.PAN&&!this.noPan&&(v=this.getMouseOnScreen(b.clientX,b.clientY)))}),!1);this.domElement.addEventListener("mousedown",c(this,function(b){b.preventDefault();
 b.stopPropagation();if(f===this.STATE.NONE)f=b.button,f===this.STATE.ROTATE?k=h=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?n=o=this.getMouseOnScreen(b.clientX,b.clientY):this.noPan||(u=v=this.getMouseOnScreen(b.clientX,b.clientY))}),!1);this.domElement.addEventListener("mouseup",c(this,function(b){b.preventDefault();b.stopPropagation();f=this.STATE.NONE}),!1);window.addEventListener("keydown",c(this,function(b){if(f===this.STATE.NONE){if(b.keyCode===this.keys[this.STATE.ROTATE])f=
 this.STATE.ROTATE;else if(b.keyCode===this.keys[this.STATE.ZOOM]&&!this.noZoom)f=this.STATE.ZOOM;else if(b.keyCode===this.keys[this.STATE.PAN]&&!this.noPan)f=this.STATE.PAN;f!==this.STATE.NONE&&(e=!0)}}),!1);window.addEventListener("keyup",c(this,function(){if(f!==this.STATE.NONE)f=this.STATE.NONE}),!1)};THREE.TrackballCamera.prototype=new THREE.Camera;THREE.TrackballCamera.prototype.constructor=THREE.TrackballCamera;THREE.TrackballCamera.prototype.supr=THREE.Camera.prototype;
 THREE.TrackballCamera.prototype.STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2};THREE.QuakeCamera=THREE.FirstPersonCamera;
-THREE.CubeGeometry=function(b,c,e,f,m,k,h,n,o){function u(b,c,e,h,n,o,t,u){var w,x,y=f||1,A=m||1,O=n/2,P=o/2,U=v.vertices.length;if(b=="x"&&c=="y"||b=="y"&&c=="x")w="z";else if(b=="x"&&c=="z"||b=="z"&&c=="x")w="y",A=k||1;else if(b=="z"&&c=="y"||b=="y"&&c=="z")w="x",y=k||1;var V=y+1,p=A+1;n/=y;var ea=o/A;for(x=0;x<p;x++)for(o=0;o<V;o++){var S=new THREE.Vector3;S[b]=(o*n-O)*e;S[c]=(x*ea-P)*h;S[w]=t;v.vertices.push(new THREE.Vertex(S))}for(x=0;x<A;x++)for(o=0;o<y;o++)v.faces.push(new THREE.Face4(o+V*
+THREE.CubeGeometry=function(b,c,e,f,m,k,h,n,o){function u(b,e,c,h,n,o,t,u){var w,x,y=f||1,A=m||1,O=n/2,P=o/2,U=v.vertices.length;if(b=="x"&&e=="y"||b=="y"&&e=="x")w="z";else if(b=="x"&&e=="z"||b=="z"&&e=="x")w="y",A=k||1;else if(b=="z"&&e=="y"||b=="y"&&e=="z")w="x",y=k||1;var V=y+1,p=A+1;n/=y;var ea=o/A;for(x=0;x<p;x++)for(o=0;o<V;o++){var S=new THREE.Vector3;S[b]=(o*n-O)*c;S[e]=(x*ea-P)*h;S[w]=t;v.vertices.push(new THREE.Vertex(S))}for(x=0;x<A;x++)for(o=0;o<y;o++)v.faces.push(new THREE.Face4(o+V*
 x+U,o+V*(x+1)+U,o+1+V*(x+1)+U,o+1+V*x+U,null,null,u)),v.faceVertexUvs[0].push([new THREE.UV(o/y,x/A),new THREE.UV(o/y,(x+1)/A),new THREE.UV((o+1)/y,(x+1)/A),new THREE.UV((o+1)/y,x/A)])}THREE.Geometry.call(this);var v=this,t=b/2,x=c/2,w=e/2,n=n?-1:1;if(h!==void 0)if(h instanceof Array)this.materials=h;else{this.materials=[];for(var y=0;y<6;y++)this.materials.push([h])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(o!=void 0)for(var A in o)this.sides[A]!=void 0&&(this.sides[A]=
-o[A]);this.sides.px&&u("z","y",1*n,-1,e,c,-t,this.materials[0]);this.sides.nx&&u("z","y",-1*n,-1,e,c,t,this.materials[1]);this.sides.py&&u("x","z",1*n,1,b,e,x,this.materials[2]);this.sides.ny&&u("x","z",1*n,-1,b,e,-x,this.materials[3]);this.sides.pz&&u("x","y",1*n,-1,b,c,w,this.materials[4]);this.sides.nz&&u("x","y",-1*n,-1,b,c,-w,this.materials[5]);(function(){for(var b=[],c=[],e=0,f=v.vertices.length;e<f;e++){for(var h=v.vertices[e],k=!1,m=0,n=b.length;m<n;m++){var o=b[m];if(h.position.x==o.position.x&&
-h.position.y==o.position.y&&h.position.z==o.position.z){c[e]=m;k=!0;break}}if(!k)c[e]=b.length,b.push(new THREE.Vertex(h.position.clone()))}e=0;for(f=v.faces.length;e<f;e++)h=v.faces[e],h.a=c[h.a],h.b=c[h.b],h.c=c[h.c],h.d=c[h.d];v.vertices=b})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
+o[A]);this.sides.px&&u("z","y",1*n,-1,e,c,-t,this.materials[0]);this.sides.nx&&u("z","y",-1*n,-1,e,c,t,this.materials[1]);this.sides.py&&u("x","z",1*n,1,b,e,x,this.materials[2]);this.sides.ny&&u("x","z",1*n,-1,b,e,-x,this.materials[3]);this.sides.pz&&u("x","y",1*n,-1,b,c,w,this.materials[4]);this.sides.nz&&u("x","y",-1*n,-1,b,c,-w,this.materials[5]);(function(){for(var b=[],e=[],c=0,f=v.vertices.length;c<f;c++){for(var h=v.vertices[c],k=!1,m=0,n=b.length;m<n;m++){var o=b[m];if(h.position.x==o.position.x&&
+h.position.y==o.position.y&&h.position.z==o.position.z){e[c]=m;k=!0;break}}if(!k)e[c]=b.length,b.push(new THREE.Vertex(h.position.clone()))}c=0;for(f=v.faces.length;c<f;c++)h=v.faces[c],h.a=e[h.a],h.b=e[h.b],h.c=e[h.c],h.d=e[h.d];v.vertices=b})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
 THREE.CylinderGeometry=function(b,c,e,f,m,k){THREE.Geometry.call(this);var b=b!=null?b:20,c=c!=null?c:20,e=e||100,h=e/2,f=f||8,m=m||1,n,o,u=[],v=[];for(o=0;o<=m;o++){var t=[],x=[],w=o/m,y=w*(c-b)+b;for(n=0;n<=f;n++){var A=n/f;this.vertices.push(new THREE.Vertex(new THREE.Vector3(y*Math.sin(A*Math.PI*2),-w*e+h,y*Math.cos(A*Math.PI*2))));t.push(this.vertices.length-1);x.push(new THREE.UV(A,w))}u.push(t);v.push(x)}for(o=0;o<m;o++)for(n=0;n<f;n++){var e=u[o][n],t=u[o+1][n],x=u[o+1][n+1],w=u[o][n+1],y=
-this.vertices[e].position.clone().setY(0).normalize(),A=this.vertices[t].position.clone().setY(0).normalize(),z=this.vertices[x].position.clone().setY(0).normalize(),D=this.vertices[w].position.clone().setY(0).normalize(),F=v[o][n].clone(),C=v[o+1][n].clone(),G=v[o+1][n+1].clone(),N=v[o][n+1].clone();this.faces.push(new THREE.Face4(e,t,x,w,[y,A,z,D]));this.faceVertexUvs[0].push([F,C,G,N])}if(!k&&b>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,h,0)));for(n=0;n<f;n++)e=u[0][n],t=u[0][n+
-1],x=this.vertices.length-1,y=new THREE.Vector3(0,1,0),A=new THREE.Vector3(0,1,0),z=new THREE.Vector3(0,1,0),F=v[0][n].clone(),C=v[0][n+1].clone(),G=new THREE.UV(C.u,0),this.faces.push(new THREE.Face3(e,t,x,[y,A,z])),this.faceVertexUvs[0].push([F,C,G])}if(!k&&c>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-h,0)));for(n=0;n<f;n++)e=u[o][n+1],t=u[o][n],x=this.vertices.length-1,y=new THREE.Vector3(0,-1,0),A=new THREE.Vector3(0,-1,0),z=new THREE.Vector3(0,-1,0),F=v[o][n+1].clone(),C=v[o][n].clone(),
-G=new THREE.UV(C.u,1),this.faces.push(new THREE.Face3(e,t,x,[y,A,z])),this.faceVertexUvs[0].push([F,C,G])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
+this.vertices[e].position.clone().setY(0).normalize(),A=this.vertices[t].position.clone().setY(0).normalize(),z=this.vertices[x].position.clone().setY(0).normalize(),D=this.vertices[w].position.clone().setY(0).normalize(),C=v[o][n].clone(),F=v[o+1][n].clone(),G=v[o+1][n+1].clone(),N=v[o][n+1].clone();this.faces.push(new THREE.Face4(e,t,x,w,[y,A,z,D]));this.faceVertexUvs[0].push([C,F,G,N])}if(!k&&b>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,h,0)));for(n=0;n<f;n++)e=u[0][n],t=u[0][n+
+1],x=this.vertices.length-1,y=new THREE.Vector3(0,1,0),A=new THREE.Vector3(0,1,0),z=new THREE.Vector3(0,1,0),C=v[0][n].clone(),F=v[0][n+1].clone(),G=new THREE.UV(F.u,0),this.faces.push(new THREE.Face3(e,t,x,[y,A,z])),this.faceVertexUvs[0].push([C,F,G])}if(!k&&c>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-h,0)));for(n=0;n<f;n++)e=u[o][n+1],t=u[o][n],x=this.vertices.length-1,y=new THREE.Vector3(0,-1,0),A=new THREE.Vector3(0,-1,0),z=new THREE.Vector3(0,-1,0),C=v[o][n+1].clone(),F=v[o][n].clone(),
+G=new THREE.UV(F.u,1),this.faces.push(new THREE.Face3(e,t,x,[y,A,z])),this.faceVertexUvs[0].push([C,F,G])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
 THREE.ExtrudeGeometry=function(b,c){if(typeof b!="undefined"){THREE.Geometry.call(this);var b=b instanceof Array?b:[b],e,f=b.length,m;this.shapebb=b[f-1].getBoundingBox();for(e=0;e<f;e++)m=b[e],this.addShape(m,c);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
-THREE.ExtrudeGeometry.prototype.addShape=function(b,c){function e(b,c,e){c||console.log("die");return c.clone().multiplyScalar(e).addSelf(b)}function f(b,c,e){var f=THREE.ExtrudeGeometry.__v1,h=THREE.ExtrudeGeometry.__v2,k=THREE.ExtrudeGeometry.__v3,m=THREE.ExtrudeGeometry.__v4,n=THREE.ExtrudeGeometry.__v5,o=THREE.ExtrudeGeometry.__v6;f.set(b.x-c.x,b.y-c.y);h.set(b.x-e.x,b.y-e.y);f=f.normalize();h=h.normalize();k.set(-f.y,f.x);m.set(h.y,-h.x);n.copy(b).addSelf(k);o.copy(b).addSelf(m);if(n.equals(o))return m.clone();
-n.copy(c).addSelf(k);o.copy(e).addSelf(m);k=f.dot(m);m=o.subSelf(n).dot(m);k==0&&(console.log("Either infinite or no solutions!"),m==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));m/=k;if(m<0)return c=Math.atan2(c.y-b.y,c.x-b.x),b=Math.atan2(e.y-b.y,e.x-b.x),c>b&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(m).addSelf(n).subSelf(b).clone()}function m(b){for(E=b.length;--E>=0;){ma=E;fa=E-1;fa<0&&(fa=b.length-
-1);for(var c=0,e=w+v*2,c=0;c<e;c++){var f=ea*c,h=ea*(c+1),k=da+ma+f,m=da+ma+h,p=k,f=da+fa+f,h=da+fa+h,t=m;p+=X;f+=X;h+=X;t+=X;I.faces.push(new THREE.Face4(p,f,h,t,null,null,G));G&&(p=c/e,f=(c+1)/e,h=n+o*2,k=(I.vertices[k].position.z+o)/h,m=(I.vertices[m].position.z+o)/h,I.faceVertexUvs[0].push([new THREE.UV(k,p),new THREE.UV(m,p),new THREE.UV(m,f),new THREE.UV(k,f)]))}}}function k(b,c,e){I.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}function h(b,c,e){b+=X;c+=X;e+=X;I.faces.push(new THREE.Face3(b,
-c,e,null,null,C));if(C){var f=N.maxY,h=N.maxX,k=I.vertices[c].position.x,c=I.vertices[c].position.y,m=I.vertices[e].position.x,e=I.vertices[e].position.y;I.faceVertexUvs[0].push([new THREE.UV(I.vertices[b].position.x/h,I.vertices[b].position.y/f),new THREE.UV(k/h,c/f),new THREE.UV(m/h,e/f)])}}var n=c.amount!==void 0?c.amount:100,o=c.bevelThickness!==void 0?c.bevelThickness:6,u=c.bevelSize!==void 0?c.bevelSize:o-2,v=c.bevelSegments!==void 0?c.bevelSegments:3,t=c.bevelEnabled!==void 0?c.bevelEnabled:
-!0,x=c.curveSegments!==void 0?c.curveSegments:12,w=c.steps!==void 0?c.steps:1,y=c.bendPath,A=c.extrudePath,z,D=!1,F=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1,C=c.material,G=c.extrudeMaterial,N=this.shapebb;if(A)z=A.getPoints(x),w=z.length,D=!0,t=!1;t||(u=o=v=0);var R,H,J,I=this,X=this.vertices.length;y&&b.addWrapPath(y);x=F?b.extractAllSpacedPoints(x):b.extractAllPoints(x);y=x.shape;x=x.holes;if(A=!THREE.Shape.Utils.isClockWise(y)){y=y.reverse();H=0;for(J=x.length;H<J;H++)R=x[H],THREE.Shape.Utils.isClockWise(R)&&
-(x[H]=R.reverse());A=!1}A=THREE.Shape.Utils.triangulateShape(y,x);F=y;H=0;for(J=x.length;H<J;H++)R=x[H],y=y.concat(R);var E,O,P,U,V,p,ea=y.length,S=A.length,ka=[];E=0;O=F.length;ma=O-1;for(fa=E+1;E<O;E++,ma++,fa++)ma==O&&(ma=0),fa==O&&(fa=0),ka[E]=f(F[E],F[ma],F[fa]);var $=[],ia,ca=ka.concat();H=0;for(J=x.length;H<J;H++){R=x[H];ia=[];E=0;O=R.length;ma=O-1;for(fa=E+1;E<O;E++,ma++,fa++)ma==O&&(ma=0),fa==O&&(fa=0),ia[E]=f(R[E],R[ma],R[fa]);$.push(ia);ca=ca.concat(ia)}for(P=0;P<v;P++){U=P/v;V=o*(1-U);
-U=u*Math.sin(U*Math.PI/2);E=0;for(O=F.length;E<O;E++)p=e(F[E],ka[E],U),k(p.x,p.y,-V);H=0;for(J=x.length;H<J;H++){R=x[H];ia=$[H];E=0;for(O=R.length;E<O;E++)p=e(R[E],ia[E],U),k(p.x,p.y,-V)}}U=u;for(E=0;E<ea;E++)p=t?e(y[E],ca[E],U):y[E],D?k(p.x,p.y+z[0].y,z[0].x):k(p.x,p.y,0);for(P=1;P<=w;P++)for(E=0;E<ea;E++)p=t?e(y[E],ca[E],U):y[E],D?k(p.x,p.y+z[P-1].y,z[P-1].x):k(p.x,p.y,n/w*P);for(P=v-1;P>=0;P--){U=P/v;V=o*(1-U);U=u*Math.sin(U*Math.PI/2);E=0;for(O=F.length;E<O;E++)p=e(F[E],ka[E],U),k(p.x,p.y,n+V);
-H=0;for(J=x.length;H<J;H++){R=x[H];ia=$[H];E=0;for(O=R.length;E<O;E++)p=e(R[E],ia[E],U),D?k(p.x,p.y+z[w-1].y,z[w-1].x+V):k(p.x,p.y,n+V)}}if(t){t=ea*0;for(E=0;E<S;E++)u=A[E],h(u[2]+t,u[1]+t,u[0]+t);t=ea*(w+v*2);for(E=0;E<S;E++)u=A[E],h(u[0]+t,u[1]+t,u[2]+t)}else{for(E=0;E<S;E++)u=A[E],h(u[2],u[1],u[0]);for(E=0;E<S;E++)u=A[E],h(u[0]+ea*w,u[1]+ea*w,u[2]+ea*w)}var ma,fa,da=0;m(F);da+=F.length;H=0;for(J=x.length;H<J;H++)R=x[H],m(R),da+=R.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;
+THREE.ExtrudeGeometry.prototype.addShape=function(b,c){function e(b,e,c){e||console.log("die");return e.clone().multiplyScalar(c).addSelf(b)}function f(b,e,c){var f=THREE.ExtrudeGeometry.__v1,h=THREE.ExtrudeGeometry.__v2,k=THREE.ExtrudeGeometry.__v3,m=THREE.ExtrudeGeometry.__v4,n=THREE.ExtrudeGeometry.__v5,o=THREE.ExtrudeGeometry.__v6;f.set(b.x-e.x,b.y-e.y);h.set(b.x-c.x,b.y-c.y);f=f.normalize();h=h.normalize();k.set(-f.y,f.x);m.set(h.y,-h.x);n.copy(b).addSelf(k);o.copy(b).addSelf(m);if(n.equals(o))return m.clone();
+n.copy(e).addSelf(k);o.copy(c).addSelf(m);k=f.dot(m);m=o.subSelf(n).dot(m);k==0&&(console.log("Either infinite or no solutions!"),m==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));m/=k;if(m<0)return e=Math.atan2(e.y-b.y,e.x-b.x),b=Math.atan2(c.y-b.y,c.x-b.x),e>b&&(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 m(b){for(E=b.length;--E>=0;){ma=E;fa=E-1;fa<0&&(fa=b.length-
+1);for(var e=0,c=w+v*2,e=0;e<c;e++){var f=ea*e,h=ea*(e+1),k=da+ma+f,m=da+ma+h,p=k,f=da+fa+f,h=da+fa+h,t=m;p+=X;f+=X;h+=X;t+=X;I.faces.push(new THREE.Face4(p,f,h,t,null,null,G));G&&(p=e/c,f=(e+1)/c,h=n+o*2,k=(I.vertices[k].position.z+o)/h,m=(I.vertices[m].position.z+o)/h,I.faceVertexUvs[0].push([new THREE.UV(k,p),new THREE.UV(m,p),new THREE.UV(m,f),new THREE.UV(k,f)]))}}}function k(b,e,c){I.vertices.push(new THREE.Vertex(new THREE.Vector3(b,e,c)))}function h(b,e,c){b+=X;e+=X;c+=X;I.faces.push(new THREE.Face3(b,
+e,c,null,null,F));if(F){var f=N.maxY,h=N.maxX,k=I.vertices[e].position.x,e=I.vertices[e].position.y,m=I.vertices[c].position.x,c=I.vertices[c].position.y;I.faceVertexUvs[0].push([new THREE.UV(I.vertices[b].position.x/h,I.vertices[b].position.y/f),new THREE.UV(k/h,e/f),new THREE.UV(m/h,c/f)])}}var n=c.amount!==void 0?c.amount:100,o=c.bevelThickness!==void 0?c.bevelThickness:6,u=c.bevelSize!==void 0?c.bevelSize:o-2,v=c.bevelSegments!==void 0?c.bevelSegments:3,t=c.bevelEnabled!==void 0?c.bevelEnabled:
+!0,x=c.curveSegments!==void 0?c.curveSegments:12,w=c.steps!==void 0?c.steps:1,y=c.bendPath,A=c.extrudePath,z,D=!1,C=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1,F=c.material,G=c.extrudeMaterial,N=this.shapebb;if(A)z=A.getPoints(x),w=z.length,D=!0,t=!1;t||(u=o=v=0);var R,H,J,I=this,X=this.vertices.length;y&&b.addWrapPath(y);x=C?b.extractAllSpacedPoints(x):b.extractAllPoints(x);y=x.shape;x=x.holes;if(A=!THREE.Shape.Utils.isClockWise(y)){y=y.reverse();H=0;for(J=x.length;H<J;H++)R=x[H],THREE.Shape.Utils.isClockWise(R)&&
+(x[H]=R.reverse());A=!1}A=THREE.Shape.Utils.triangulateShape(y,x);C=y;H=0;for(J=x.length;H<J;H++)R=x[H],y=y.concat(R);var E,O,P,U,V,p,ea=y.length,S=A.length,ka=[];E=0;O=C.length;ma=O-1;for(fa=E+1;E<O;E++,ma++,fa++)ma==O&&(ma=0),fa==O&&(fa=0),ka[E]=f(C[E],C[ma],C[fa]);var $=[],ia,ca=ka.concat();H=0;for(J=x.length;H<J;H++){R=x[H];ia=[];E=0;O=R.length;ma=O-1;for(fa=E+1;E<O;E++,ma++,fa++)ma==O&&(ma=0),fa==O&&(fa=0),ia[E]=f(R[E],R[ma],R[fa]);$.push(ia);ca=ca.concat(ia)}for(P=0;P<v;P++){U=P/v;V=o*(1-U);
+U=u*Math.sin(U*Math.PI/2);E=0;for(O=C.length;E<O;E++)p=e(C[E],ka[E],U),k(p.x,p.y,-V);H=0;for(J=x.length;H<J;H++){R=x[H];ia=$[H];E=0;for(O=R.length;E<O;E++)p=e(R[E],ia[E],U),k(p.x,p.y,-V)}}U=u;for(E=0;E<ea;E++)p=t?e(y[E],ca[E],U):y[E],D?k(p.x,p.y+z[0].y,z[0].x):k(p.x,p.y,0);for(P=1;P<=w;P++)for(E=0;E<ea;E++)p=t?e(y[E],ca[E],U):y[E],D?k(p.x,p.y+z[P-1].y,z[P-1].x):k(p.x,p.y,n/w*P);for(P=v-1;P>=0;P--){U=P/v;V=o*(1-U);U=u*Math.sin(U*Math.PI/2);E=0;for(O=C.length;E<O;E++)p=e(C[E],ka[E],U),k(p.x,p.y,n+V);
+H=0;for(J=x.length;H<J;H++){R=x[H];ia=$[H];E=0;for(O=R.length;E<O;E++)p=e(R[E],ia[E],U),D?k(p.x,p.y+z[w-1].y,z[w-1].x+V):k(p.x,p.y,n+V)}}if(t){t=ea*0;for(E=0;E<S;E++)u=A[E],h(u[2]+t,u[1]+t,u[0]+t);t=ea*(w+v*2);for(E=0;E<S;E++)u=A[E],h(u[0]+t,u[1]+t,u[2]+t)}else{for(E=0;E<S;E++)u=A[E],h(u[2],u[1],u[0]);for(E=0;E<S;E++)u=A[E],h(u[0]+ea*w,u[1]+ea*w,u[2]+ea*w)}var ma,fa,da=0;m(C);da+=C.length;H=0;for(J=x.length;H<J;H++)R=x[H],m(R),da+=R.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;
 THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
-THREE.SubdivisionGeometry=function(b){function c(b,c,e,h){f.faces.push(new THREE.Face4(b,c,e,h))}function e(b,c){return Math.min(b,c)+"_"+Math.max(b,c)}THREE.Geometry.call(this);var f=this,m=b.vertices,k=b.faces,h=m.concat(),n=[],o={},u,v,t;u=0;for(v=k.length;u<v;u++)t=k[u],n.push(t.centroid),h.push(new THREE.Vertex(t.centroid));b.computeEdgeFaces();var x,w,b=b.vfMap,y=0,A=m.length,z;for(u in b)t=b[u],t=t.array,x=t[0],t=t[1],w=new THREE.Vector3,w.addSelf(n[x]),w.addSelf(n[t]),z=u.split("_"),v=z[0],
+THREE.SubdivisionGeometry=function(b){function c(b,e,c,h){f.faces.push(new THREE.Face4(b,e,c,h))}function e(b,e){return Math.min(b,e)+"_"+Math.max(b,e)}THREE.Geometry.call(this);var f=this,m=b.vertices,k=b.faces,h=m.concat(),n=[],o={},u,v,t;u=0;for(v=k.length;u<v;u++)t=k[u],n.push(t.centroid),h.push(new THREE.Vertex(t.centroid));b.computeEdgeFaces();var x,w,b=b.vfMap,y=0,A=m.length,z;for(u in b)t=b[u],t=t.array,x=t[0],t=t[1],w=new THREE.Vector3,w.addSelf(n[x]),w.addSelf(n[t]),z=u.split("_"),v=z[0],
 z=z[1],w.addSelf(m[v].position),w.addSelf(m[z].position),w.multiplyScalar(0.25),o[u]=A+k.length+y,h.push(new THREE.Vertex(w)),y++;var D;u=0;for(v=n.length;u<v;u++)t=k[u],z=A+u,t instanceof THREE.Face3?(x=e(t.a,t.b),y=e(t.b,t.c),w=e(t.c,t.a),c(z,o[x],t.b,o[y]),c(z,o[y],t.c,o[w]),c(z,o[w],t.a,o[x])):t instanceof THREE.Face4?(x=e(t.a,t.b),y=e(t.b,t.c),w=e(t.c,t.d),D=e(t.d,t.a),c(z,o[x],t.b,o[y]),c(z,o[y],t.c,o[w]),c(z,o[w],t.d,o[D]),c(z,o[D],t.a,o[x])):console.log("face should be a face!",t);f.vertices=
-h;var F={},C={},k=function(b,c){F[b]===void 0&&(F[b]=[]);F[b].push(c)},h=function(b,c){C[b]===void 0&&(C[b]={});C[b][c]=null};for(u in b)t=b[u],z=u.split("_"),v=z[0],z=z[1],k(v,[v,z]),k(z,[v,z]),t=t.array,x=t[0],t=t[1],h(v,x),h(v,t),h(z,x),h(z,t);var b=new THREE.Vector3,k=new THREE.Vector3,G;u=0;for(v=m.length;u<v;u++){b.set(0,0,0);k.set(0,0,0);h=new THREE.Vector3(0,0,0);o=0;for(G in C[u])b.addSelf(n[G]),o++;b.divideScalar(o);o=F[u].length;for(G=0;G<o;G++)t=F[u][G],A=m[t[0]].position.clone().addSelf(m[t[1]].position).divideScalar(2),
+h;var C={},F={},k=function(b,e){C[b]===void 0&&(C[b]=[]);C[b].push(e)},h=function(b,e){F[b]===void 0&&(F[b]={});F[b][e]=null};for(u in b)t=b[u],z=u.split("_"),v=z[0],z=z[1],k(v,[v,z]),k(z,[v,z]),t=t.array,x=t[0],t=t[1],h(v,x),h(v,t),h(z,x),h(z,t);var b=new THREE.Vector3,k=new THREE.Vector3,G;u=0;for(v=m.length;u<v;u++)if(C[u]!==void 0){b.set(0,0,0);k.set(0,0,0);h=new THREE.Vector3(0,0,0);o=0;for(G in F[u])b.addSelf(n[G]),o++;b.divideScalar(o);o=C[u].length;for(G=0;G<o;G++)t=C[u][G],A=m[t[0]].position.clone().addSelf(m[t[1]].position).divideScalar(2),
 k.addSelf(A);k.divideScalar(o);h.addSelf(m[u].position);h.multiplyScalar(o-3);h.addSelf(b);h.addSelf(k.multiplyScalar(2));h.divideScalar(o);this.vertices[u].position=h}this.computeCentroids();this.computeFaceNormals()};THREE.SubdivisionGeometry.prototype=new THREE.Geometry;THREE.SubdivisionGeometry.prototype.constructor=THREE.SubdivisionGeometry;
-THREE.IcosahedronGeometry=function(b){function c(b,c,e){var f=Math.sqrt(b*b+c*c+e*e);return m.vertices.push(new THREE.Vertex(new THREE.Vector3(b/f,c/f,e/f)))-1}function e(b,c,e,f){f.faces.push(new THREE.Face3(b,c,e))}function f(b,e){var f=m.vertices[b].position,h=m.vertices[e].position;return c((f.x+h.x)/2,(f.y+h.y)/2,(f.z+h.z)/2)}var m=this,k=new THREE.Geometry;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;c(-1,b,0);c(1,b,0);c(-1,-b,0);c(1,-b,0);c(0,-1,b);c(0,1,b);c(0,-1,
+THREE.IcosahedronGeometry=function(b){function c(b,e,c){var f=Math.sqrt(b*b+e*e+c*c);return m.vertices.push(new THREE.Vertex(new THREE.Vector3(b/f,e/f,c/f)))-1}function e(b,e,c,f){f.faces.push(new THREE.Face3(b,e,c))}function f(b,e){var f=m.vertices[b].position,h=m.vertices[e].position;return c((f.x+h.x)/2,(f.y+h.y)/2,(f.z+h.z)/2)}var m=this,k=new THREE.Geometry;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;c(-1,b,0);c(1,b,0);c(-1,-b,0);c(1,-b,0);c(0,-1,b);c(0,1,b);c(0,-1,
 -b);c(0,1,-b);c(b,0,-1);c(b,0,1);c(-b,0,-1);c(-b,0,1);e(0,11,5,k);e(0,5,1,k);e(0,1,7,k);e(0,7,10,k);e(0,10,11,k);e(1,5,9,k);e(5,11,4,k);e(11,10,2,k);e(10,7,6,k);e(7,1,8,k);e(3,9,4,k);e(3,4,2,k);e(3,2,6,k);e(3,6,8,k);e(3,8,9,k);e(4,9,5,k);e(2,4,11,k);e(6,2,10,k);e(8,6,7,k);e(9,8,1,k);for(var h=0;h<this.subdivisions;h++){var b=new THREE.Geometry,n;for(n in k.faces){var o=f(k.faces[n].a,k.faces[n].b),u=f(k.faces[n].b,k.faces[n].c),v=f(k.faces[n].c,k.faces[n].a);e(k.faces[n].a,o,v,b);e(k.faces[n].b,u,
 o,b);e(k.faces[n].c,v,u,b);e(o,u,v,b)}k.faces=b.faces}m.faces=k.faces;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
 THREE.LatheGeometry=function(b,c,e){THREE.Geometry.call(this);this.steps=c||12;this.angle=e||2*Math.PI;for(var c=this.angle/this.steps,e=[],f=[],m=[],k=[],h=(new THREE.Matrix4).setRotationZ(c),n=0;n<b.length;n++)this.vertices.push(new THREE.Vertex(b[n])),e[n]=b[n].clone(),f[n]=this.vertices.length-1;for(var o=0;o<=this.angle+0.0010;o+=c){for(n=0;n<e.length;n++)o<this.angle?(e[n]=h.multiplyVector3(e[n].clone()),this.vertices.push(new THREE.Vertex(e[n])),m[n]=this.vertices.length-1):m=k;o==0&&(k=f);
@@ -509,15 +510,15 @@ THREE.TextGeometry=function(b,c){var e=(new THREE.TextPath(b,c)).toShapes();c.am
 THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
 THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(b,c){return(new TextPath(b,c)).toShapes()},loadFace:function(b){var c=b.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][b.cssFontWeight]=this.faces[c][b.cssFontWeight]||{};this.faces[c][b.cssFontWeight][b.cssFontStyle]=b;return this.faces[c][b.cssFontWeight][b.cssFontStyle]=b},drawText:function(b){for(var c=
 this.getFace(),e=this.size/c.resolution,f=0,m=String(b).split(""),k=m.length,h=[],b=0;b<k;b++){var n=new THREE.Path,n=this.extractGlyphPoints(m[b],c,e,f,n);f+=n.offset;h.push(n.path)}return{paths:h,offset:f/2}},extractGlyphPoints:function(b,c,e,f,m){var k=[],h,n,o,u,v,t,x,w,y,A,z=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(z){if(z.o){c=z._cachedOutline||(z._cachedOutline=z.o.split(" "));o=c.length;for(b=0;b<o;)switch(n=c[b++],n){case "m":n=c[b++]*e+f;u=c[b++]*e;k.push(new THREE.Vector2(n,
-u));m.moveTo(n,u);break;case "l":n=c[b++]*e+f;u=c[b++]*e;k.push(new THREE.Vector2(n,u));m.lineTo(n,u);break;case "q":n=c[b++]*e+f;u=c[b++]*e;x=c[b++]*e+f;w=c[b++]*e;m.quadraticCurveTo(x,w,n,u);if(h=k[k.length-1]){v=h.x;t=h.y;h=1;for(divisions=this.divisions;h<=divisions;h++){var D=h/divisions,F=THREE.Shape.Utils.b2(D,v,x,n),D=THREE.Shape.Utils.b2(D,t,w,u);k.push(new THREE.Vector2(F,D))}}break;case "b":if(n=c[b++]*e+f,u=c[b++]*e,x=c[b++]*e+f,w=c[b++]*-e,y=c[b++]*e+f,A=c[b++]*-e,m.bezierCurveTo(n,u,
-x,w,y,A),h=k[k.length-1]){v=h.x;t=h.y;h=1;for(divisions=this.divisions;h<=divisions;h++)D=h/divisions,F=THREE.Shape.Utils.b3(D,v,x,y,n),D=THREE.Shape.Utils.b3(D,t,w,A,u),k.push(new THREE.Vector2(F,D))}}}return{offset:z.ha*e,points:k,path:m}}}};
-(function(b){var c=function(b){for(var c=b.length,m=0,k=c-1,h=0;h<c;k=h++)m+=b[k].x*b[h].y-b[h].x*b[k].y;return m*0.5};b.Triangulate=function(b,f){var m=b.length;if(m<3)return null;var k=[],h=[],n=[],o,u,v;if(c(b)>0)for(u=0;u<m;u++)h[u]=u;else for(u=0;u<m;u++)h[u]=m-1-u;var t=2*m;for(u=m-1;m>2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return n;return k}o=u;m<=o&&(o=0);u=o+1;m<=u&&(u=0);v=u+1;m<=v&&(v=0);var x;a:{x=b;var w=o,y=u,A=v,z=m,D=h,F=void 0,C=void 0,G=void 0,
-N=void 0,R=void 0,H=void 0,J=void 0,I=void 0,X=void 0,C=x[D[w]].x,G=x[D[w]].y,N=x[D[y]].x,R=x[D[y]].y,H=x[D[A]].x,J=x[D[A]].y;if(1.0E-10>(N-C)*(J-G)-(R-G)*(H-C))x=!1;else{for(F=0;F<z;F++)if(!(F==w||F==y||F==A)){var I=x[D[F]].x,X=x[D[F]].y,E=void 0,O=void 0,P=void 0,U=void 0,V=void 0,p=void 0,ea=void 0,S=void 0,ka=void 0,$=void 0,ia=void 0,ca=void 0,E=P=V=void 0,E=H-N,O=J-R,P=C-H,U=G-J,V=N-C,p=R-G,ea=I-C,S=X-G,ka=I-N,$=X-R,ia=I-H,ca=X-J,E=E*$-O*ka,V=V*S-p*ea,P=P*ca-U*ia;if(E>=0&&P>=0&&V>=0){x=!1;break a}}x=
+u));m.moveTo(n,u);break;case "l":n=c[b++]*e+f;u=c[b++]*e;k.push(new THREE.Vector2(n,u));m.lineTo(n,u);break;case "q":n=c[b++]*e+f;u=c[b++]*e;x=c[b++]*e+f;w=c[b++]*e;m.quadraticCurveTo(x,w,n,u);if(h=k[k.length-1]){v=h.x;t=h.y;h=1;for(divisions=this.divisions;h<=divisions;h++){var D=h/divisions,C=THREE.Shape.Utils.b2(D,v,x,n),D=THREE.Shape.Utils.b2(D,t,w,u);k.push(new THREE.Vector2(C,D))}}break;case "b":if(n=c[b++]*e+f,u=c[b++]*e,x=c[b++]*e+f,w=c[b++]*-e,y=c[b++]*e+f,A=c[b++]*-e,m.bezierCurveTo(n,u,
+x,w,y,A),h=k[k.length-1]){v=h.x;t=h.y;h=1;for(divisions=this.divisions;h<=divisions;h++)D=h/divisions,C=THREE.Shape.Utils.b3(D,v,x,y,n),D=THREE.Shape.Utils.b3(D,t,w,A,u),k.push(new THREE.Vector2(C,D))}}}return{offset:z.ha*e,points:k,path:m}}}};
+(function(b){var c=function(b){for(var c=b.length,m=0,k=c-1,h=0;h<c;k=h++)m+=b[k].x*b[h].y-b[h].x*b[k].y;return m*0.5};b.Triangulate=function(b,f){var m=b.length;if(m<3)return null;var k=[],h=[],n=[],o,u,v;if(c(b)>0)for(u=0;u<m;u++)h[u]=u;else for(u=0;u<m;u++)h[u]=m-1-u;var t=2*m;for(u=m-1;m>2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return n;return k}o=u;m<=o&&(o=0);u=o+1;m<=u&&(u=0);v=u+1;m<=v&&(v=0);var x;a:{x=b;var w=o,y=u,A=v,z=m,D=h,C=void 0,F=void 0,G=void 0,
+N=void 0,R=void 0,H=void 0,J=void 0,I=void 0,X=void 0,F=x[D[w]].x,G=x[D[w]].y,N=x[D[y]].x,R=x[D[y]].y,H=x[D[A]].x,J=x[D[A]].y;if(1.0E-10>(N-F)*(J-G)-(R-G)*(H-F))x=!1;else{for(C=0;C<z;C++)if(!(C==w||C==y||C==A)){var I=x[D[C]].x,X=x[D[C]].y,E=void 0,O=void 0,P=void 0,U=void 0,V=void 0,p=void 0,ea=void 0,S=void 0,ka=void 0,$=void 0,ia=void 0,ca=void 0,E=P=V=void 0,E=H-N,O=J-R,P=F-H,U=G-J,V=N-F,p=R-G,ea=I-F,S=X-G,ka=I-N,$=X-R,ia=I-H,ca=X-J,E=E*$-O*ka,V=V*S-p*ea,P=P*ca-U*ia;if(E>=0&&P>=0&&V>=0){x=!1;break a}}x=
 !0}}if(x){k.push([b[h[o]],b[h[u]],b[h[v]]]);n.push([h[o],h[u],h[v]]);o=u;for(v=u+1;v<m;o++,v++)h[o]=h[v];m--;t=2*m}}if(f)return n;return k};b.Triangulate.area=c;return b})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
 THREE.TorusGeometry=function(b,c,e,f,m){THREE.Geometry.call(this);this.radius=b||100;this.tube=c||40;this.segmentsR=e||8;this.segmentsT=f||6;this.arc=m||Math.PI*2;m=new THREE.Vector3;b=[];c=[];for(e=0;e<=this.segmentsR;e++)for(f=0;f<=this.segmentsT;f++){var k=f/this.segmentsT*this.arc,h=e/this.segmentsR*Math.PI*2;m.x=this.radius*Math.cos(k);m.y=this.radius*Math.sin(k);var n=new THREE.Vector3;n.x=(this.radius+this.tube*Math.cos(h))*Math.cos(k);n.y=(this.radius+this.tube*Math.cos(h))*Math.sin(k);n.z=
 this.tube*Math.sin(h);this.vertices.push(new THREE.Vertex(n));b.push(new THREE.UV(f/this.segmentsT,1-e/this.segmentsR));c.push(n.clone().subSelf(m).normalize())}for(e=1;e<=this.segmentsR;e++)for(f=1;f<=this.segmentsT;f++){var m=(this.segmentsT+1)*e+f-1,k=(this.segmentsT+1)*(e-1)+f-1,h=(this.segmentsT+1)*(e-1)+f,n=(this.segmentsT+1)*e+f,o=new THREE.Face4(m,k,h,n,[c[m],c[k],c[h],c[n]]);o.normal.addSelf(c[m]);o.normal.addSelf(c[k]);o.normal.addSelf(c[h]);o.normal.addSelf(c[n]);o.normal.normalize();this.faces.push(o);
 this.faceVertexUvs[0].push([b[m].clone(),b[k].clone(),b[h].clone(),b[n].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=new THREE.Geometry;THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
-THREE.TorusKnotGeometry=function(b,c,e,f,m,k,h){function n(b,c,e,f,h,k){c=e/f*b;e=Math.cos(c);return new THREE.Vector3(h*(2+e)*0.5*Math.cos(b),h*(2+e)*Math.sin(b)*0.5,k*h*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=e||64;this.segmentsT=f||8;this.p=m||2;this.q=k||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);e=new THREE.Vector3;f=new THREE.Vector3;k=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<
+THREE.TorusKnotGeometry=function(b,c,e,f,m,k,h){function n(b,e,c,f,h,k){e=c/f*b;c=Math.cos(e);return new THREE.Vector3(h*(2+c)*0.5*Math.cos(b),h*(2+c)*Math.sin(b)*0.5,k*h*Math.sin(e)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=c||40;this.segmentsR=e||64;this.segmentsT=f||8;this.p=m||2;this.q=k||3;this.heightScale=h||1;this.grid=Array(this.segmentsR);e=new THREE.Vector3;f=new THREE.Vector3;k=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(c=0;c<
 this.segmentsT;++c){var o=b/this.segmentsR*2*this.p*Math.PI,h=c/this.segmentsT*2*Math.PI,m=n(o,h,this.q,this.p,this.radius,this.heightScale),o=n(o+0.01,h,this.q,this.p,this.radius,this.heightScale);e.x=o.x-m.x;e.y=o.y-m.y;e.z=o.z-m.z;f.x=o.x+m.x;f.y=o.y+m.y;f.z=o.z+m.z;k.cross(e,f);f.cross(k,e);k.normalize();f.normalize();o=-this.tube*Math.cos(h);h=this.tube*Math.sin(h);m.x+=o*f.x+h*k.x;m.y+=o*f.y+h*k.y;m.z+=o*f.z+h*k.z;this.grid[b][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(m.x,m.y,
 m.z)))-1}}for(b=0;b<this.segmentsR;++b)for(c=0;c<this.segmentsT;++c){var f=(b+1)%this.segmentsR,k=(c+1)%this.segmentsT,m=this.grid[b][c],e=this.grid[f][c],f=this.grid[f][k],k=this.grid[b][k],h=new THREE.UV(b/this.segmentsR,c/this.segmentsT),o=new THREE.UV((b+1)/this.segmentsR,c/this.segmentsT),u=new THREE.UV((b+1)/this.segmentsR,(c+1)/this.segmentsT),v=new THREE.UV(b/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(m,e,f,k));this.faceVertexUvs[0].push([h,o,u,v])}this.computeCentroids();
 this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;THREE.Loader=function(b){this.statusDomElement=(this.showStatus=b)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
@@ -534,86 +535,86 @@ THREE.BinaryLoader.prototype.load=function(b){var c=b.model,e=b.callback,f=b.tex
 c.postMessage(b)};
 THREE.BinaryLoader.prototype.loadAjaxBuffers=function(b,c,e,f,m,k){var h=new XMLHttpRequest,n=f+"/"+b,o=0;h.onreadystatechange=function(){h.readyState==4?h.status==200||h.status==0?THREE.BinaryLoader.prototype.createBinModel(h.responseText,e,m,c):alert("Couldn't load ["+n+"] ["+h.status+"]"):h.readyState==3?k&&(o==0&&(o=h.getResponseHeader("Content-Length")),k({total:o,loaded:h.responseText.length})):h.readyState==2&&(o=h.getResponseHeader("Content-Length"))};h.open("GET",n,!0);h.overrideMimeType("text/plain; charset=x-user-defined");
 h.setRequestHeader("Content-Type","text/plain");h.send(null)};
-THREE.BinaryLoader.prototype.createBinModel=function(b,c,e,f){var m=function(c){function e(b,c){var f=v(b,c),h=v(b,c+1),k=v(b,c+2),m=v(b,c+3),n=(m<<1&255|k>>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 m(b,c){var e=v(b,c),f=v(b,c+1),h=v(b,c+2);return(v(b,c+3)<<24)+(h<<16)+(f<<8)+e}function o(b,c){var e=v(b,c);return(v(b,c+1)<<8)+e}function u(b,c){var e=v(b,c);return e>127?e-256:e}function v(b,c){return b.charCodeAt(c)&255}function t(c){var e,
-f,h;e=m(b,c);f=m(b,c+R);h=m(b,c+H);c=o(b,c+J);D.faces.push(new THREE.Face3(e,f,h,null,null,D.materials[c]))}function x(c){var e,f,h,k,p,t;e=m(b,c);f=m(b,c+R);h=m(b,c+H);k=o(b,c+J);p=m(b,c+I);t=m(b,c+X);c=m(b,c+E);k=D.materials[k];var u=G[t*3],w=G[t*3+1];t=G[t*3+2];var v=G[c*3],x=G[c*3+1],c=G[c*3+2];D.faces.push(new THREE.Face3(e,f,h,[new THREE.Vector3(G[p*3],G[p*3+1],G[p*3+2]),new THREE.Vector3(u,w,t),new THREE.Vector3(v,x,c)],null,k))}function w(c){var e,f,h,k;e=m(b,c);f=m(b,c+O);h=m(b,c+P);k=m(b,
-c+U);c=o(b,c+V);D.faces.push(new THREE.Face4(e,f,h,k,null,null,D.materials[c]))}function y(c){var e,f,h,k,t,u,w,v;e=m(b,c);f=m(b,c+O);h=m(b,c+P);k=m(b,c+U);t=o(b,c+V);u=m(b,c+p);w=m(b,c+ea);v=m(b,c+S);c=m(b,c+ka);t=D.materials[t];var x=G[w*3],L=G[w*3+1];w=G[w*3+2];var y=G[v*3],W=G[v*3+1];v=G[v*3+2];var z=G[c*3],A=G[c*3+1],c=G[c*3+2];D.faces.push(new THREE.Face4(e,f,h,k,[new THREE.Vector3(G[u*3],G[u*3+1],G[u*3+2]),new THREE.Vector3(x,L,w),new THREE.Vector3(y,W,v),new THREE.Vector3(z,A,c)],null,t))}
-function A(c){var e,f,h,k;e=m(b,c);f=m(b,c+$);h=m(b,c+ia);c=N[e*2];k=N[e*2+1];e=N[f*2];var p=D.faceVertexUvs[0];f=N[f*2+1];var o=N[h*2];h=N[h*2+1];var t=[];t.push(new THREE.UV(c,k));t.push(new THREE.UV(e,f));t.push(new THREE.UV(o,h));p.push(t)}function z(c){var e,f,h,k,p,o;e=m(b,c);f=m(b,c+ca);h=m(b,c+ma);k=m(b,c+fa);c=N[e*2];p=N[e*2+1];e=N[f*2];o=N[f*2+1];f=N[h*2];var t=D.faceVertexUvs[0];h=N[h*2+1];var u=N[k*2];k=N[k*2+1];var w=[];w.push(new THREE.UV(c,p));w.push(new THREE.UV(e,o));w.push(new THREE.UV(f,
-h));w.push(new THREE.UV(u,k));t.push(w)}var D=this,F=0,C,G=[],N=[],R,H,J,I,X,E,O,P,U,V,p,ea,S,ka,$,ia,ca,ma,fa,da,T,Y,ga,ja,sa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(D,f,c);C={signature:b.substr(F,8),header_bytes:v(b,F+8),vertex_coordinate_bytes:v(b,F+9),normal_coordinate_bytes:v(b,F+10),uv_coordinate_bytes:v(b,F+11),vertex_index_bytes:v(b,F+12),normal_index_bytes:v(b,F+13),uv_index_bytes:v(b,F+14),material_index_bytes:v(b,F+15),nvertices:m(b,F+16),nnormals:m(b,F+16+4),nuvs:m(b,
-F+16+8),ntri_flat:m(b,F+16+12),ntri_smooth:m(b,F+16+16),ntri_flat_uv:m(b,F+16+20),ntri_smooth_uv:m(b,F+16+24),nquad_flat:m(b,F+16+28),nquad_smooth:m(b,F+16+32),nquad_flat_uv:m(b,F+16+36),nquad_smooth_uv:m(b,F+16+40)};F+=C.header_bytes;R=C.vertex_index_bytes;H=C.vertex_index_bytes*2;J=C.vertex_index_bytes*3;I=C.vertex_index_bytes*3+C.material_index_bytes;X=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes;E=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*2;O=C.vertex_index_bytes;
-P=C.vertex_index_bytes*2;U=C.vertex_index_bytes*3;V=C.vertex_index_bytes*4;p=C.vertex_index_bytes*4+C.material_index_bytes;ea=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes;S=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*2;ka=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*3;$=C.uv_index_bytes;ia=C.uv_index_bytes*2;ca=C.uv_index_bytes;ma=C.uv_index_bytes*2;fa=C.uv_index_bytes*3;c=C.vertex_index_bytes*3+C.material_index_bytes;sa=C.vertex_index_bytes*
-4+C.material_index_bytes;da=C.ntri_flat*c;T=C.ntri_smooth*(c+C.normal_index_bytes*3);Y=C.ntri_flat_uv*(c+C.uv_index_bytes*3);ga=C.ntri_smooth_uv*(c+C.normal_index_bytes*3+C.uv_index_bytes*3);ja=C.nquad_flat*sa;c=C.nquad_smooth*(sa+C.normal_index_bytes*4);sa=C.nquad_flat_uv*(sa+C.uv_index_bytes*4);F+=function(c){for(var f,k,m,n=C.vertex_coordinate_bytes*3,p=c+C.nvertices*n;c<p;c+=n)f=e(b,c),k=e(b,c+C.vertex_coordinate_bytes),m=e(b,c+C.vertex_coordinate_bytes*2),D.vertices.push(new THREE.Vertex(new THREE.Vector3(f,
-k,m)));return C.nvertices*n}(F);F+=function(c){for(var e,f,h,k=C.normal_coordinate_bytes*3,m=c+C.nnormals*k;c<m;c+=k)e=u(b,c),f=u(b,c+C.normal_coordinate_bytes),h=u(b,c+C.normal_coordinate_bytes*2),G.push(e/127,f/127,h/127);return C.nnormals*k}(F);F+=function(c){for(var f,k,m=C.uv_coordinate_bytes*2,n=c+C.nuvs*m;c<n;c+=m)f=e(b,c),k=e(b,c+C.uv_coordinate_bytes),N.push(f,k);return C.nuvs*m}(F);da=F+da;T=da+T;Y=T+Y;ga=Y+ga;ja=ga+ja;c=ja+c;sa=c+sa;(function(b){var c,e=C.vertex_index_bytes*3+C.material_index_bytes,
-f=e+C.uv_index_bytes*3,h=b+C.ntri_flat_uv*f;for(c=b;c<h;c+=f)t(c),A(c+e);return h-b})(T);(function(b){var c,e=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*3,f=e+C.uv_index_bytes*3,h=b+C.ntri_smooth_uv*f;for(c=b;c<h;c+=f)x(c),A(c+e);return h-b})(Y);(function(b){var c,e=C.vertex_index_bytes*4+C.material_index_bytes,f=e+C.uv_index_bytes*4,h=b+C.nquad_flat_uv*f;for(c=b;c<h;c+=f)w(c),z(c+e);return h-b})(c);(function(b){var c,e=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*
-4,f=e+C.uv_index_bytes*4,h=b+C.nquad_smooth_uv*f;for(c=b;c<h;c+=f)y(c),z(c+e);return h-b})(sa);(function(b){var c,e=C.vertex_index_bytes*3+C.material_index_bytes,f=b+C.ntri_flat*e;for(c=b;c<f;c+=e)t(c);return f-b})(F);(function(b){var c,e=C.vertex_index_bytes*3+C.material_index_bytes+C.normal_index_bytes*3,f=b+C.ntri_smooth*e;for(c=b;c<f;c+=e)x(c);return f-b})(da);(function(b){var c,e=C.vertex_index_bytes*4+C.material_index_bytes,f=b+C.nquad_flat*e;for(c=b;c<f;c+=e)w(c);return f-b})(ga);(function(b){var c,
-e=C.vertex_index_bytes*4+C.material_index_bytes+C.normal_index_bytes*4,f=b+C.nquad_smooth*e;for(c=b;c<f;c+=e)y(c);return f-b})(ja);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};m.prototype=new THREE.Geometry;m.prototype.constructor=m;c(new m(e))};
-THREE.ColladaLoader=function(){function b(b,c,e){for(var b=da.evaluate(b,da,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),f={},h=b.iterateNext(),k=0;h;){h=(new c).parse(h);if(h.id.length==0)h.id=e+k++;f[h.id]=h;h=b.iterateNext()}return f}function c(){var b=1E6,c=-b,e=0,f;for(f in M)for(var h=M[f],k=0;k<h.sampler.length;k++){var m=h.sampler[k];m.create();b=Math.min(b,m.startTime);c=Math.max(c,m.endTime);e=Math.max(e,m.input.length)}return{start:b,end:c,frames:e}}function e(b,c,f,h){b.world=b.world||
+THREE.BinaryLoader.prototype.createBinModel=function(b,c,e,f){var m=function(e){function c(b,e){var f=v(b,e),h=v(b,e+1),k=v(b,e+2),m=v(b,e+3),n=(m<<1&255|k>>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 m(b,e){var c=v(b,e),f=v(b,e+1),h=v(b,e+2);return(v(b,e+3)<<24)+(h<<16)+(f<<8)+c}function o(b,e){var c=v(b,e);return(v(b,e+1)<<8)+c}function u(b,e){var c=v(b,e);return c>127?c-256:c}function v(b,e){return b.charCodeAt(e)&255}function t(e){var c,
+f,h;c=m(b,e);f=m(b,e+R);h=m(b,e+H);e=o(b,e+J);D.faces.push(new THREE.Face3(c,f,h,null,null,D.materials[e]))}function x(e){var c,f,h,k,p,t;c=m(b,e);f=m(b,e+R);h=m(b,e+H);k=o(b,e+J);p=m(b,e+I);t=m(b,e+X);e=m(b,e+E);k=D.materials[k];var u=G[t*3],w=G[t*3+1];t=G[t*3+2];var v=G[e*3],x=G[e*3+1],e=G[e*3+2];D.faces.push(new THREE.Face3(c,f,h,[new THREE.Vector3(G[p*3],G[p*3+1],G[p*3+2]),new THREE.Vector3(u,w,t),new THREE.Vector3(v,x,e)],null,k))}function w(e){var c,f,h,k;c=m(b,e);f=m(b,e+O);h=m(b,e+P);k=m(b,
+e+U);e=o(b,e+V);D.faces.push(new THREE.Face4(c,f,h,k,null,null,D.materials[e]))}function y(e){var c,f,h,k,t,u,w,v;c=m(b,e);f=m(b,e+O);h=m(b,e+P);k=m(b,e+U);t=o(b,e+V);u=m(b,e+p);w=m(b,e+ea);v=m(b,e+S);e=m(b,e+ka);t=D.materials[t];var x=G[w*3],L=G[w*3+1];w=G[w*3+2];var y=G[v*3],W=G[v*3+1];v=G[v*3+2];var z=G[e*3],A=G[e*3+1],e=G[e*3+2];D.faces.push(new THREE.Face4(c,f,h,k,[new THREE.Vector3(G[u*3],G[u*3+1],G[u*3+2]),new THREE.Vector3(x,L,w),new THREE.Vector3(y,W,v),new THREE.Vector3(z,A,e)],null,t))}
+function A(e){var c,f,h,k;c=m(b,e);f=m(b,e+$);h=m(b,e+ia);e=N[c*2];k=N[c*2+1];c=N[f*2];var p=D.faceVertexUvs[0];f=N[f*2+1];var o=N[h*2];h=N[h*2+1];var t=[];t.push(new THREE.UV(e,k));t.push(new THREE.UV(c,f));t.push(new THREE.UV(o,h));p.push(t)}function z(e){var c,f,h,k,p,o;c=m(b,e);f=m(b,e+ca);h=m(b,e+ma);k=m(b,e+fa);e=N[c*2];p=N[c*2+1];c=N[f*2];o=N[f*2+1];f=N[h*2];var t=D.faceVertexUvs[0];h=N[h*2+1];var u=N[k*2];k=N[k*2+1];var w=[];w.push(new THREE.UV(e,p));w.push(new THREE.UV(c,o));w.push(new THREE.UV(f,
+h));w.push(new THREE.UV(u,k));t.push(w)}var D=this,C=0,F,G=[],N=[],R,H,J,I,X,E,O,P,U,V,p,ea,S,ka,$,ia,ca,ma,fa,da,T,Y,ga,ja,sa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(D,f,e);F={signature:b.substr(C,8),header_bytes:v(b,C+8),vertex_coordinate_bytes:v(b,C+9),normal_coordinate_bytes:v(b,C+10),uv_coordinate_bytes:v(b,C+11),vertex_index_bytes:v(b,C+12),normal_index_bytes:v(b,C+13),uv_index_bytes:v(b,C+14),material_index_bytes:v(b,C+15),nvertices:m(b,C+16),nnormals:m(b,C+16+4),nuvs:m(b,
+C+16+8),ntri_flat:m(b,C+16+12),ntri_smooth:m(b,C+16+16),ntri_flat_uv:m(b,C+16+20),ntri_smooth_uv:m(b,C+16+24),nquad_flat:m(b,C+16+28),nquad_smooth:m(b,C+16+32),nquad_flat_uv:m(b,C+16+36),nquad_smooth_uv:m(b,C+16+40)};C+=F.header_bytes;R=F.vertex_index_bytes;H=F.vertex_index_bytes*2;J=F.vertex_index_bytes*3;I=F.vertex_index_bytes*3+F.material_index_bytes;X=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes;E=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*2;O=F.vertex_index_bytes;
+P=F.vertex_index_bytes*2;U=F.vertex_index_bytes*3;V=F.vertex_index_bytes*4;p=F.vertex_index_bytes*4+F.material_index_bytes;ea=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes;S=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*2;ka=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*3;$=F.uv_index_bytes;ia=F.uv_index_bytes*2;ca=F.uv_index_bytes;ma=F.uv_index_bytes*2;fa=F.uv_index_bytes*3;e=F.vertex_index_bytes*3+F.material_index_bytes;sa=F.vertex_index_bytes*
+4+F.material_index_bytes;da=F.ntri_flat*e;T=F.ntri_smooth*(e+F.normal_index_bytes*3);Y=F.ntri_flat_uv*(e+F.uv_index_bytes*3);ga=F.ntri_smooth_uv*(e+F.normal_index_bytes*3+F.uv_index_bytes*3);ja=F.nquad_flat*sa;e=F.nquad_smooth*(sa+F.normal_index_bytes*4);sa=F.nquad_flat_uv*(sa+F.uv_index_bytes*4);C+=function(e){for(var f,k,m,n=F.vertex_coordinate_bytes*3,p=e+F.nvertices*n;e<p;e+=n)f=c(b,e),k=c(b,e+F.vertex_coordinate_bytes),m=c(b,e+F.vertex_coordinate_bytes*2),D.vertices.push(new THREE.Vertex(new THREE.Vector3(f,
+k,m)));return F.nvertices*n}(C);C+=function(e){for(var c,f,h,k=F.normal_coordinate_bytes*3,m=e+F.nnormals*k;e<m;e+=k)c=u(b,e),f=u(b,e+F.normal_coordinate_bytes),h=u(b,e+F.normal_coordinate_bytes*2),G.push(c/127,f/127,h/127);return F.nnormals*k}(C);C+=function(e){for(var f,k,m=F.uv_coordinate_bytes*2,n=e+F.nuvs*m;e<n;e+=m)f=c(b,e),k=c(b,e+F.uv_coordinate_bytes),N.push(f,k);return F.nuvs*m}(C);da=C+da;T=da+T;Y=T+Y;ga=Y+ga;ja=ga+ja;e=ja+e;sa=e+sa;(function(b){var e,c=F.vertex_index_bytes*3+F.material_index_bytes,
+f=c+F.uv_index_bytes*3,h=b+F.ntri_flat_uv*f;for(e=b;e<h;e+=f)t(e),A(e+c);return h-b})(T);(function(b){var e,c=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*3,f=c+F.uv_index_bytes*3,h=b+F.ntri_smooth_uv*f;for(e=b;e<h;e+=f)x(e),A(e+c);return h-b})(Y);(function(b){var e,c=F.vertex_index_bytes*4+F.material_index_bytes,f=c+F.uv_index_bytes*4,h=b+F.nquad_flat_uv*f;for(e=b;e<h;e+=f)w(e),z(e+c);return h-b})(e);(function(b){var e,c=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*
+4,f=c+F.uv_index_bytes*4,h=b+F.nquad_smooth_uv*f;for(e=b;e<h;e+=f)y(e),z(e+c);return h-b})(sa);(function(b){var e,c=F.vertex_index_bytes*3+F.material_index_bytes,f=b+F.ntri_flat*c;for(e=b;e<f;e+=c)t(e);return f-b})(C);(function(b){var e,c=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*3,f=b+F.ntri_smooth*c;for(e=b;e<f;e+=c)x(e);return f-b})(da);(function(b){var e,c=F.vertex_index_bytes*4+F.material_index_bytes,f=b+F.nquad_flat*c;for(e=b;e<f;e+=c)w(e);return f-b})(ga);(function(b){var e,
+c=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*4,f=b+F.nquad_smooth*c;for(e=b;e<f;e+=c)y(e);return f-b})(ja);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};m.prototype=new THREE.Geometry;m.prototype.constructor=m;c(new m(e))};
+THREE.ColladaLoader=function(){function b(b,e,c){for(var b=da.evaluate(b,da,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),f={},h=b.iterateNext(),k=0;h;){h=(new e).parse(h);if(h.id.length==0)h.id=c+k++;f[h.id]=h;h=b.iterateNext()}return f}function c(){var b=1E6,e=-b,c=0,f;for(f in M)for(var h=M[f],k=0;k<h.sampler.length;k++){var m=h.sampler[k];m.create();b=Math.min(b,m.startTime);e=Math.max(e,m.endTime);c=Math.max(c,m.input.length)}return{start:b,end:e,frames:c}}function e(b,c,f,h){b.world=b.world||
 new THREE.Matrix4;b.world.copy(b.matrix);if(b.channels&&b.channels.length){var k=b.channels[0].sampler.output[f];k instanceof THREE.Matrix4&&b.world.copy(k)}h&&b.world.multiply(h,b.world);c.push(b);for(h=0;h<b.nodes.length;h++)e(b.nodes[h],c,f,b.world)}function f(b,f,h){var k=la[f.url];if(!k||!k.skin)console.log("could not find skin controller!");else if(!f.skeleton||!f.skeleton.length)console.log("could not find the skeleton for the skin!");else{var m=c(),f=Y.getChildById(f.skeleton[0],!0)||Y.getChildBySid(f.skeleton[0],
 !0),n,p,o,t,u=new THREE.Vector3,w;for(n=0;n<b.vertices.length;n++)k.skin.bindShapeMatrix.multiplyVector3(b.vertices[n].position);for(h=0;h<m.frames;h++){var v=[],x=[];for(n=0;n<b.vertices.length;n++)x.push(new THREE.Vertex(new THREE.Vector3));e(f,v,h);n=v;p=k.skin;for(t=0;t<n.length;t++){o=n[t];w=-1;for(var y=0;y<p.joints.length;y++)if(o.sid==p.joints[y]){w=y;break}if(w>=0){y=p.invBindMatrices[w];o.invBindMatrix=y;o.skinningMatrix=new THREE.Matrix4;o.skinningMatrix.multiply(o.world,y);o.weights=[];
-for(y=0;y<p.weights.length;y++)for(var z=0;z<p.weights[y].length;z++){var A=p.weights[y][z];A.joint==w&&o.weights.push(A)}}else throw"could not find joint!";}for(n=0;n<v.length;n++)for(p=0;p<v[n].weights.length;p++)o=v[n].weights[p],t=o.index,o=o.weight,w=b.vertices[t],t=x[t],u.x=w.position.x,u.y=w.position.y,u.z=w.position.z,v[n].skinningMatrix.multiplyVector3(u),t.position.x+=u.x*o,t.position.y+=u.y*o,t.position.z+=u.z*o;b.morphTargets.push({name:"target_"+h,vertices:x})}}}function m(b){var c=new THREE.Object3D,
-e,h,k;c.name=b.id||"";c.matrixAutoUpdate=!1;c.matrix=b.matrix;for(k=0;k<b.controllers.length;k++){var n=la[b.controllers[k].url];switch(n.type){case "skin":if(pa[n.skin.source]){var o=new y;o.url=n.skin.source;o.instance_material=b.controllers[k].instance_material;b.geometries.push(o);e=b.controllers[k]}else if(la[n.skin.source]&&(h=n=la[n.skin.source],n.morph&&pa[n.morph.source]))o=new y,o.url=n.morph.source,o.instance_material=b.controllers[k].instance_material,b.geometries.push(o);break;case "morph":if(pa[n.morph.source])o=
-new y,o.url=n.morph.source,o.instance_material=b.controllers[k].instance_material,b.geometries.push(o),h=b.controllers[k];console.log("DAE: morph-controller partially supported.")}}for(k=0;k<b.geometries.length;k++){var n=b.geometries[k],o=n.instance_material,n=pa[n.url],p={},t=0,u;if(n&&n.mesh&&n.mesh.primitives){if(c.name.length==0)c.name=n.id;if(o)for(j=0;j<o.length;j++){u=o[j];var w=wa[qa[u.target].instance_effect.url].shader;w.material.opacity=!w.material.opacity?1:w.material.opacity;u=p[u.symbol]=
-w.material;t++}o=u||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});n=n.mesh.geometry3js;if(t>1){o=new THREE.MeshFaceMaterial;for(j=0;j<n.faces.length;j++)t=n.faces[j],t.materials=[p[t.daeMaterial]]}if(e!==void 0)f(n,e),o.morphTargets=!0,o=new THREE.SkinnedMesh(n,o),o.skeleton=e.skeleton,o.skinController=la[e.url],o.skinInstanceController=e,o.name="skin_"+Ba.length,Ba.push(o);else if(h!==void 0){p=n;t=h instanceof x?la[h.url]:h;if(!t||!t.morph)console.log("could not find morph controller!");
-else{t=t.morph;for(w=0;w<t.targets.length;w++){var v=pa[t.targets[w]];if(v.mesh&&v.mesh.primitives&&v.mesh.primitives.length)v=v.mesh.primitives[0].geometry,v.vertices.length===p.vertices.length&&p.morphTargets.push({name:"target_1",vertices:v.vertices})}p.morphTargets.push({name:"target_Z",vertices:p.vertices})}o.morphTargets=!0;o=new THREE.Mesh(n,o);o.name="morph_"+za.length;za.push(o)}else o=new THREE.Mesh(n,o);c.add(o)}}for(k=0;k<b.nodes.length;k++)c.add(m(b.nodes[k],b));return c}function k(){this.init_from=
+for(y=0;y<p.weights.length;y++)for(var z=0;z<p.weights[y].length;z++){var A=p.weights[y][z];A.joint==w&&o.weights.push(A)}}else throw"could not find joint!";}for(n=0;n<v.length;n++)for(p=0;p<v[n].weights.length;p++)o=v[n].weights[p],t=o.index,o=o.weight,w=b.vertices[t],t=x[t],u.x=w.position.x,u.y=w.position.y,u.z=w.position.z,v[n].skinningMatrix.multiplyVector3(u),t.position.x+=u.x*o,t.position.y+=u.y*o,t.position.z+=u.z*o;b.morphTargets.push({name:"target_"+h,vertices:x})}}}function m(b){var e=new THREE.Object3D,
+c,h,k;e.name=b.id||"";e.matrixAutoUpdate=!1;e.matrix=b.matrix;for(k=0;k<b.controllers.length;k++){var n=la[b.controllers[k].url];switch(n.type){case "skin":if(pa[n.skin.source]){var o=new y;o.url=n.skin.source;o.instance_material=b.controllers[k].instance_material;b.geometries.push(o);c=b.controllers[k]}else if(la[n.skin.source]&&(h=n=la[n.skin.source],n.morph&&pa[n.morph.source]))o=new y,o.url=n.morph.source,o.instance_material=b.controllers[k].instance_material,b.geometries.push(o);break;case "morph":if(pa[n.morph.source])o=
+new y,o.url=n.morph.source,o.instance_material=b.controllers[k].instance_material,b.geometries.push(o),h=b.controllers[k];console.log("DAE: morph-controller partially supported.")}}for(k=0;k<b.geometries.length;k++){var n=b.geometries[k],o=n.instance_material,n=pa[n.url],p={},t=0,u;if(n&&n.mesh&&n.mesh.primitives){if(e.name.length==0)e.name=n.id;if(o)for(j=0;j<o.length;j++){u=o[j];var w=wa[qa[u.target].instance_effect.url].shader;w.material.opacity=!w.material.opacity?1:w.material.opacity;u=p[u.symbol]=
+w.material;t++}o=u||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});n=n.mesh.geometry3js;if(t>1){o=new THREE.MeshFaceMaterial;for(j=0;j<n.faces.length;j++)t=n.faces[j],t.materials=[p[t.daeMaterial]]}if(c!==void 0)f(n,c),o.morphTargets=!0,o=new THREE.SkinnedMesh(n,o),o.skeleton=c.skeleton,o.skinController=la[c.url],o.skinInstanceController=c,o.name="skin_"+Ba.length,Ba.push(o);else if(h!==void 0){p=n;t=h instanceof x?la[h.url]:h;if(!t||!t.morph)console.log("could not find morph controller!");
+else{t=t.morph;for(w=0;w<t.targets.length;w++){var v=pa[t.targets[w]];if(v.mesh&&v.mesh.primitives&&v.mesh.primitives.length)v=v.mesh.primitives[0].geometry,v.vertices.length===p.vertices.length&&p.morphTargets.push({name:"target_1",vertices:v.vertices})}p.morphTargets.push({name:"target_Z",vertices:p.vertices})}o.morphTargets=!0;o=new THREE.Mesh(n,o);o.name="morph_"+za.length;za.push(o)}else o=new THREE.Mesh(n,o);e.add(o)}}for(k=0;k<b.nodes.length;k++)e.add(m(b.nodes[k],b));return e}function k(){this.init_from=
 this.id=""}function h(){this.type=this.name=this.id="";this.morph=this.skin=null}function n(){this.weights=this.targets=this.source=this.method=null}function o(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];this.joints=[];this.weights=[]}function u(){this.name=this.id="";this.nodes=[];this.scene=new THREE.Object3D}function v(){this.sid=this.name=this.id="";this.nodes=[];this.controllers=[];this.transforms=[];this.geometries=[];this.channels=[];this.matrix=new THREE.Matrix4}function t(){this.type=
-this.sid="";this.data=[];this.matrix=new THREE.Matrix4}function x(){this.url="";this.skeleton=[];this.instance_material=[]}function w(){this.target=this.symbol=""}function y(){this.url="";this.instance_material=[]}function A(){this.id="";this.mesh=null}function z(b){this.geometry=b.id;this.primitives=[];this.geometry3js=this.vertices=null}function D(){}function F(){this.material="";this.count=0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function C(){this.source="";
-this.stride=this.count=0;this.params=[]}function G(){this.input={}}function N(){this.semantic="";this.offset=0;this.source="";this.set=0}function R(b){this.id=b;this.type=null}function H(){this.name=this.id="";this.instance_effect=null}function J(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texcoord=this.texture=null}function I(b,c){this.type=b;this.effect=c;this.material=null}function X(b){this.effect=b;this.format=this.init_from=
+this.sid="";this.data=[];this.matrix=new THREE.Matrix4}function x(){this.url="";this.skeleton=[];this.instance_material=[]}function w(){this.target=this.symbol=""}function y(){this.url="";this.instance_material=[]}function A(){this.id="";this.mesh=null}function z(b){this.geometry=b.id;this.primitives=[];this.geometry3js=this.vertices=null}function D(){}function C(){this.material="";this.count=0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function F(){this.source="";
+this.stride=this.count=0;this.params=[]}function G(){this.input={}}function N(){this.semantic="";this.offset=0;this.source="";this.set=0}function R(b){this.id=b;this.type=null}function H(){this.name=this.id="";this.instance_effect=null}function J(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texcoord=this.texture=null}function I(b,e){this.type=b;this.effect=e;this.material=null}function X(b){this.effect=b;this.format=this.init_from=
 null}function E(b){this.effect=b;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function O(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function P(){this.url=""}function U(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function V(b){this.animation=b;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=this.dotSyntax=this.sid=null}function p(b){this.id="";this.animation=b;this.inputs=[];this.endTime=
-this.startTime=this.interpolation=this.output=this.input=null;this.duration=0}function ea(b){var c=b.getAttribute("id");if(ja[c]!=void 0)return ja[c];ja[c]=(new R(c)).parse(b);return ja[c]}function S(b){if(b=="dae")return"http://www.collada.org/2005/11/COLLADASchema";return null}function ka(b){for(var b=ia(b),c=[],e=0;e<b.length;e++)c.push(parseFloat(b[e]));return c}function $(b){for(var b=ia(b),c=[],e=0;e<b.length;e++)c.push(parseInt(b[e],10));return c}function ia(b){return b.replace(/^\s+/,"").replace(/\s+$/,
-"").split(/\s+/)}function ca(b,c,e){return b.hasAttribute(c)?parseInt(b.getAttribute(c),10):e}function ma(b,c){if(b===void 0){for(var e="0.";e.length<c+2;)e+="0";return e}c=c||2;e=b.toString().split(".");for(e[1]=e.length>1?e[1].substr(0,c):"0";e[1].length<c;)e[1]+="0";return e.join(".")}function fa(b,c){var e="";e+=ma(b.x,c)+",";e+=ma(b.y,c)+",";e+=ma(b.z,c);return e}var da=null,T=null,Y,ga=null,ja={},sa={},M={},la={},pa={},qa={},wa={},ua,Da,za,Ba,Fa=THREE.SmoothShading;k.prototype.parse=function(b){this.id=
-b.getAttribute("id");for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeName=="init_from")this.init_from=e.textContent}return this};h.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");this.type="none";for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];switch(e.nodeName){case "skin":this.skin=(new o).parse(e);this.type=e.nodeName;break;case "morph":this.morph=(new n).parse(e),this.type=e.nodeName}}return this};n.prototype.parse=function(b){var c=
-{},e=[],f;this.method=b.getAttribute("method");this.source=b.getAttribute("source").replace(/^#/,"");for(f=0;f<b.childNodes.length;f++){var h=b.childNodes[f];if(h.nodeType==1)switch(h.nodeName){case "source":h=(new R).parse(h);c[h.id]=h;break;case "targets":e=this.parseInputs(h);break;default:console.log(h.nodeName)}}for(f=0;f<e.length;f++)switch(b=e[f],h=c[b.source],b.semantic){case "MORPH_TARGET":this.targets=h.read();break;case "MORPH_WEIGHT":this.weights=h.read()}return this};n.prototype.parseInputs=
-function(b){for(var c=[],e=0;e<b.childNodes.length;e++){var f=b.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "input":c.push((new N).parse(f))}}return c};o.prototype.parse=function(b){var c={},e,f;this.source=b.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var h=0;h<b.childNodes.length;h++){var k=b.childNodes[h];if(k.nodeType==1)switch(k.nodeName){case "bind_shape_matrix":k=ka(k.textContent);this.bindShapeMatrix=new THREE.Matrix4;this.bindShapeMatrix.set(k[0],
-k[1],k[2],k[3],k[4],k[5],k[6],k[7],k[8],k[9],k[10],k[11],k[12],k[13],k[14],k[15]);break;case "source":k=(new R).parse(k);c[k.id]=k;break;case "joints":e=k;break;case "vertex_weights":f=k;break;default:console.log(k.nodeName)}}this.parseJoints(e,c);this.parseWeights(f,c);return this};o.prototype.parseJoints=function(b,c){for(var e=0;e<b.childNodes.length;e++){var f=b.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "input":var f=(new N).parse(f),h=c[f.source];if(f.semantic=="JOINT")this.joints=
-h.read();else if(f.semantic=="INV_BIND_MATRIX")this.invBindMatrices=h.read()}}};o.prototype.parseWeights=function(b,c){for(var e,f,h=[],k=0;k<b.childNodes.length;k++){var m=b.childNodes[k];if(m.nodeType==1)switch(m.nodeName){case "input":h.push((new N).parse(m));break;case "v":e=$(m.textContent);break;case "vcount":f=$(m.textContent)}}for(k=m=0;k<f.length;k++){for(var n=f[k],o=[],p=0;p<n;p++){for(var t={},u=0;u<h.length;u++){var w=h[u],v=e[m+w.offset];switch(w.semantic){case "JOINT":t.joint=v;break;
-case "WEIGHT":t.weight=c[w.source].data[v]}}o.push(t);m+=h.length}for(p=0;p<o.length;p++)o[p].index=k;this.weights.push(o)}};u.prototype.getChildById=function(b,c){for(var e=0;e<this.nodes.length;e++){var f=this.nodes[e].getChildById(b,c);if(f)return f}return null};u.prototype.getChildBySid=function(b,c){for(var e=0;e<this.nodes.length;e++){var f=this.nodes[e].getChildBySid(b,c);if(f)return f}return null};u.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");
-this.nodes=[];for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "node":this.nodes.push((new v).parse(e))}}return this};v.prototype.getChannelForTransform=function(b){for(var c=0;c<this.channels.length;c++){var e=this.channels[c],f=e.target.split("/");f.shift();var h=f.shift(),k=h.indexOf(".")>=0,m=h.indexOf("(")>=0,n;if(k)f=h.split("."),h=f.shift(),f.shift();else if(m){n=h.split("(");h=n.shift();for(f=0;f<n.length;f++)n[f]=parseInt(n[f].replace(/\)/,
-""))}if(h==b)return e.info={sid:h,dotSyntax:k,arrSyntax:m,arrIndices:n},e}return null};v.prototype.getChildById=function(b,c){if(this.id==b)return this;if(c)for(var e=0;e<this.nodes.length;e++){var f=this.nodes[e].getChildById(b,c);if(f)return f}return null};v.prototype.getChildBySid=function(b,c){if(this.sid==b)return this;if(c)for(var e=0;e<this.nodes.length;e++){var f=this.nodes[e].getChildBySid(b,c);if(f)return f}return null};v.prototype.getTransformBySid=function(b){for(var c=0;c<this.transforms.length;c++)if(this.transforms[c].sid==
-b)return this.transforms[c];return null};v.prototype.parse=function(b){var c;this.id=b.getAttribute("id");this.sid=b.getAttribute("sid");this.name=b.getAttribute("name");this.type=b.getAttribute("type");this.type=this.type=="JOINT"?this.type:"NODE";this.nodes=[];this.transforms=[];this.geometries=[];this.controllers=[];this.matrix=new THREE.Matrix4;for(var e=0;e<b.childNodes.length;e++)if(c=b.childNodes[e],c.nodeType==1)switch(c.nodeName){case "node":this.nodes.push((new v).parse(c));break;case "instance_camera":break;
-case "instance_controller":this.controllers.push((new x).parse(c));break;case "instance_geometry":this.geometries.push((new y).parse(c));break;case "instance_light":break;case "instance_node":c=c.getAttribute("url").replace(/^#/,"");(c=da.evaluate(".//dae:library_nodes//dae:node[@id='"+c+"']",da,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new v).parse(c));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new t).parse(c));
-break;case "extra":break;default:console.log(c.nodeName)}b=[];e=1E6;c=-1E6;for(var f in M)for(var h=M[f],k=0;k<h.channel.length;k++){var m=h.channel[k],n=h.sampler[k];f=m.target.split("/")[0];if(f==this.id)n.create(),m.sampler=n,e=Math.min(e,n.startTime),c=Math.max(c,n.endTime),b.push(m)}if(b.length)this.startTime=e,this.endTime=c;if((this.channels=b)&&this.channels.length){f=1E7;for(i=0;i<this.channels.length;i++){b=this.channels[i].sampler;for(e=0;e<b.input.length-1;e++)f=Math.min(f,b.input[e+1]-
-b.input[e])}e=[];for(b=this.startTime;b<this.endTime;b+=f){c=b;for(var h={},o=k=void 0,k=0;k<this.channels.length;k++)o=this.channels[k],h[o.sid]=o;m=new THREE.Matrix4;for(k=0;k<this.transforms.length;k++)if(n=this.transforms[k],o=h[n.sid],o!==void 0){for(var p=o.sampler,u,o=0;o<p.input.length-1;o++)if(p.input[o+1]>c){u=p.output[o];break}m=u!==void 0?u instanceof THREE.Matrix4?m.multiply(m,u):m.multiply(m,n.matrix):m.multiply(m,n.matrix)}else m=m.multiply(m,n.matrix);c=m;e.push({time:b,pos:[c.n14,
-c.n24,c.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=e}this.updateMatrix();return this};v.prototype.updateMatrix=function(){this.matrix.identity();for(var b=0;b<this.transforms.length;b++)this.matrix.multiply(this.matrix,this.transforms[b].matrix)};t.prototype.parse=function(b){this.sid=b.getAttribute("sid");this.type=b.nodeName;this.data=ka(b.textContent);this.updateMatrix();return this};t.prototype.updateMatrix=function(){var b=0;this.matrix.identity();switch(this.type){case "matrix":this.matrix.set(this.data[0],
+this.startTime=this.interpolation=this.output=this.input=null;this.duration=0}function ea(b){var e=b.getAttribute("id");if(ja[e]!=void 0)return ja[e];ja[e]=(new R(e)).parse(b);return ja[e]}function S(b){if(b=="dae")return"http://www.collada.org/2005/11/COLLADASchema";return null}function ka(b){for(var b=ia(b),e=[],c=0;c<b.length;c++)e.push(parseFloat(b[c]));return e}function $(b){for(var b=ia(b),e=[],c=0;c<b.length;c++)e.push(parseInt(b[c],10));return e}function ia(b){return b.replace(/^\s+/,"").replace(/\s+$/,
+"").split(/\s+/)}function ca(b,e,c){return b.hasAttribute(e)?parseInt(b.getAttribute(e),10):c}function ma(b,e){if(b===void 0){for(var c="0.";c.length<e+2;)c+="0";return c}e=e||2;c=b.toString().split(".");for(c[1]=c.length>1?c[1].substr(0,e):"0";c[1].length<e;)c[1]+="0";return c.join(".")}function fa(b,e){var c="";c+=ma(b.x,e)+",";c+=ma(b.y,e)+",";c+=ma(b.z,e);return c}var da=null,T=null,Y,ga=null,ja={},sa={},M={},la={},pa={},qa={},wa={},ua,Da,za,Ba,Fa=THREE.SmoothShading;k.prototype.parse=function(b){this.id=
+b.getAttribute("id");for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];if(c.nodeName=="init_from")this.init_from=c.textContent}return this};h.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");this.type="none";for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];switch(c.nodeName){case "skin":this.skin=(new o).parse(c);this.type=c.nodeName;break;case "morph":this.morph=(new n).parse(c),this.type=c.nodeName}}return this};n.prototype.parse=function(b){var e=
+{},c=[],f;this.method=b.getAttribute("method");this.source=b.getAttribute("source").replace(/^#/,"");for(f=0;f<b.childNodes.length;f++){var h=b.childNodes[f];if(h.nodeType==1)switch(h.nodeName){case "source":h=(new R).parse(h);e[h.id]=h;break;case "targets":c=this.parseInputs(h);break;default:console.log(h.nodeName)}}for(f=0;f<c.length;f++)switch(b=c[f],h=e[b.source],b.semantic){case "MORPH_TARGET":this.targets=h.read();break;case "MORPH_WEIGHT":this.weights=h.read()}return this};n.prototype.parseInputs=
+function(b){for(var e=[],c=0;c<b.childNodes.length;c++){var f=b.childNodes[c];if(f.nodeType==1)switch(f.nodeName){case "input":e.push((new N).parse(f))}}return e};o.prototype.parse=function(b){var e={},c,f;this.source=b.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var h=0;h<b.childNodes.length;h++){var k=b.childNodes[h];if(k.nodeType==1)switch(k.nodeName){case "bind_shape_matrix":k=ka(k.textContent);this.bindShapeMatrix=new THREE.Matrix4;this.bindShapeMatrix.set(k[0],
+k[1],k[2],k[3],k[4],k[5],k[6],k[7],k[8],k[9],k[10],k[11],k[12],k[13],k[14],k[15]);break;case "source":k=(new R).parse(k);e[k.id]=k;break;case "joints":c=k;break;case "vertex_weights":f=k;break;default:console.log(k.nodeName)}}this.parseJoints(c,e);this.parseWeights(f,e);return this};o.prototype.parseJoints=function(b,e){for(var c=0;c<b.childNodes.length;c++){var f=b.childNodes[c];if(f.nodeType==1)switch(f.nodeName){case "input":var f=(new N).parse(f),h=e[f.source];if(f.semantic=="JOINT")this.joints=
+h.read();else if(f.semantic=="INV_BIND_MATRIX")this.invBindMatrices=h.read()}}};o.prototype.parseWeights=function(b,e){for(var c,f,h=[],k=0;k<b.childNodes.length;k++){var m=b.childNodes[k];if(m.nodeType==1)switch(m.nodeName){case "input":h.push((new N).parse(m));break;case "v":c=$(m.textContent);break;case "vcount":f=$(m.textContent)}}for(k=m=0;k<f.length;k++){for(var n=f[k],o=[],p=0;p<n;p++){for(var t={},u=0;u<h.length;u++){var w=h[u],v=c[m+w.offset];switch(w.semantic){case "JOINT":t.joint=v;break;
+case "WEIGHT":t.weight=e[w.source].data[v]}}o.push(t);m+=h.length}for(p=0;p<o.length;p++)o[p].index=k;this.weights.push(o)}};u.prototype.getChildById=function(b,e){for(var c=0;c<this.nodes.length;c++){var f=this.nodes[c].getChildById(b,e);if(f)return f}return null};u.prototype.getChildBySid=function(b,e){for(var c=0;c<this.nodes.length;c++){var f=this.nodes[c].getChildBySid(b,e);if(f)return f}return null};u.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");
+this.nodes=[];for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];if(c.nodeType==1)switch(c.nodeName){case "node":this.nodes.push((new v).parse(c))}}return this};v.prototype.getChannelForTransform=function(b){for(var e=0;e<this.channels.length;e++){var c=this.channels[e],f=c.target.split("/");f.shift();var h=f.shift(),k=h.indexOf(".")>=0,m=h.indexOf("(")>=0,n;if(k)f=h.split("."),h=f.shift(),f.shift();else if(m){n=h.split("(");h=n.shift();for(f=0;f<n.length;f++)n[f]=parseInt(n[f].replace(/\)/,
+""))}if(h==b)return c.info={sid:h,dotSyntax:k,arrSyntax:m,arrIndices:n},c}return null};v.prototype.getChildById=function(b,e){if(this.id==b)return this;if(e)for(var c=0;c<this.nodes.length;c++){var f=this.nodes[c].getChildById(b,e);if(f)return f}return null};v.prototype.getChildBySid=function(b,e){if(this.sid==b)return this;if(e)for(var c=0;c<this.nodes.length;c++){var f=this.nodes[c].getChildBySid(b,e);if(f)return f}return null};v.prototype.getTransformBySid=function(b){for(var e=0;e<this.transforms.length;e++)if(this.transforms[e].sid==
+b)return this.transforms[e];return null};v.prototype.parse=function(b){var e;this.id=b.getAttribute("id");this.sid=b.getAttribute("sid");this.name=b.getAttribute("name");this.type=b.getAttribute("type");this.type=this.type=="JOINT"?this.type:"NODE";this.nodes=[];this.transforms=[];this.geometries=[];this.controllers=[];this.matrix=new THREE.Matrix4;for(var c=0;c<b.childNodes.length;c++)if(e=b.childNodes[c],e.nodeType==1)switch(e.nodeName){case "node":this.nodes.push((new v).parse(e));break;case "instance_camera":break;
+case "instance_controller":this.controllers.push((new x).parse(e));break;case "instance_geometry":this.geometries.push((new y).parse(e));break;case "instance_light":break;case "instance_node":e=e.getAttribute("url").replace(/^#/,"");(e=da.evaluate(".//dae:library_nodes//dae:node[@id='"+e+"']",da,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new v).parse(e));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new t).parse(e));
+break;case "extra":break;default:console.log(e.nodeName)}b=[];c=1E6;e=-1E6;for(var f in M)for(var h=M[f],k=0;k<h.channel.length;k++){var m=h.channel[k],n=h.sampler[k];f=m.target.split("/")[0];if(f==this.id)n.create(),m.sampler=n,c=Math.min(c,n.startTime),e=Math.max(e,n.endTime),b.push(m)}if(b.length)this.startTime=c,this.endTime=e;if((this.channels=b)&&this.channels.length){f=1E7;for(i=0;i<this.channels.length;i++){b=this.channels[i].sampler;for(c=0;c<b.input.length-1;c++)f=Math.min(f,b.input[c+1]-
+b.input[c])}c=[];for(b=this.startTime;b<this.endTime;b+=f){e=b;for(var h={},o=k=void 0,k=0;k<this.channels.length;k++)o=this.channels[k],h[o.sid]=o;m=new THREE.Matrix4;for(k=0;k<this.transforms.length;k++)if(n=this.transforms[k],o=h[n.sid],o!==void 0){for(var p=o.sampler,u,o=0;o<p.input.length-1;o++)if(p.input[o+1]>e){u=p.output[o];break}m=u!==void 0?u instanceof THREE.Matrix4?m.multiply(m,u):m.multiply(m,n.matrix):m.multiply(m,n.matrix)}else m=m.multiply(m,n.matrix);e=m;c.push({time:b,pos:[e.n14,
+e.n24,e.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=c}this.updateMatrix();return this};v.prototype.updateMatrix=function(){this.matrix.identity();for(var b=0;b<this.transforms.length;b++)this.matrix.multiply(this.matrix,this.transforms[b].matrix)};t.prototype.parse=function(b){this.sid=b.getAttribute("sid");this.type=b.nodeName;this.data=ka(b.textContent);this.updateMatrix();return this};t.prototype.updateMatrix=function(){var b=0;this.matrix.identity();switch(this.type){case "matrix":this.matrix.set(this.data[0],
 this.data[1],this.data[2],this.data[3],this.data[4],this.data[5],this.data[6],this.data[7],this.data[8],this.data[9],this.data[10],this.data[11],this.data[12],this.data[13],this.data[14],this.data[15]);break;case "translate":this.matrix.setTranslation(this.data[0],this.data[1],this.data[2]);break;case "rotate":b=this.data[3]*(Math.PI/180);this.matrix.setRotationAxis(new THREE.Vector3(this.data[0],this.data[1],this.data[2]),b);break;case "scale":this.matrix.setScale(this.data[0],this.data[1],this.data[2])}return this.matrix};
-x.prototype.parse=function(b){this.url=b.getAttribute("url").replace(/^#/,"");this.skeleton=[];this.instance_material=[];for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "skeleton":this.skeleton.push(e.textContent.replace(/^#/,""));break;case "bind_material":if(e=da.evaluate(".//dae:instance_material",e,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(var f=e.iterateNext();f;)this.instance_material.push((new w).parse(f)),f=e.iterateNext()}}return this};
-w.prototype.parse=function(b){this.symbol=b.getAttribute("symbol");this.target=b.getAttribute("target").replace(/^#/,"");return this};y.prototype.parse=function(b){this.url=b.getAttribute("url").replace(/^#/,"");this.instance_material=[];for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1&&e.nodeName=="bind_material"){if(b=da.evaluate(".//dae:instance_material",e,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(c=b.iterateNext();c;)this.instance_material.push((new w).parse(c)),
-c=b.iterateNext();break}}return this};A.prototype.parse=function(b){this.id=b.getAttribute("id");for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];switch(e.nodeName){case "mesh":this.mesh=(new z(this)).parse(e)}}return this};z.prototype.parse=function(b){function c(b,e){var f=fa(b.position);h[f]===void 0&&(h[f]={v:b,index:e});return h[f]}this.primitives=[];var e;for(e=0;e<b.childNodes.length;e++){var f=b.childNodes[e];switch(f.nodeName){case "source":ea(f);break;case "vertices":this.vertices=
-(new G).parse(f);break;case "triangles":this.primitives.push((new F).parse(f));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new D).parse(f))}}var h={};this.geometry3js=new THREE.Geometry;f=ja[this.vertices.input.POSITION.source].data;for(b=e=0;e<f.length;e+=3,b++){var k=new THREE.Vertex(new THREE.Vector3(f[e],f[e+1],f[e+2]));c(k,b);this.geometry3js.vertices.push(k)}for(e=0;e<this.primitives.length;e++)primitive=this.primitives[e],primitive.setVertices(this.vertices),
-this.handlePrimitive(primitive,this.geometry3js,h);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();return this};z.prototype.handlePrimitive=function(b,c,e){var f=0,h,k,m=b.p,n=b.inputs,o,p,t,u=0,w=3,v=[];for(h=0;h<n.length;h++)switch(o=n[h],o.semantic){case "TEXCOORD":v.push(o.set)}for(;f<m.length;){var x=[],y=[],z={},A=[];b.vcount&&(w=b.vcount[u++]);for(h=0;h<w;h++)for(k=0;k<n.length;k++)switch(o=
-n[k],source=ja[o.source],p=m[f+h*n.length+o.offset],numParams=source.accessor.params.length,t=p*numParams,o.semantic){case "VERTEX":o=fa(c.vertices[p].position);x.push(e[o].index);break;case "NORMAL":y.push(new THREE.Vector3(source.data[t],source.data[t+1],source.data[t+2]));break;case "TEXCOORD":z[o.set]===void 0&&(z[o.set]=[]);z[o.set].push(new THREE.UV(source.data[t],source.data[t+1]));break;case "COLOR":A.push((new THREE.Color).setRGB(source.data[t],source.data[t+1],source.data[t+2]))}var C;w==
-3?C=new THREE.Face3(x[0],x[1],x[2],[y[0],y[1],y[2]],A.length?A:new THREE.Color):w==4&&(C=new THREE.Face4(x[0],x[1],x[2],x[3],[y[0],y[1],y[2],y[3]],A.length?A:new THREE.Color));C.daeMaterial=b.material;c.faces.push(C);for(k=0;k<v.length;k++)h=z[v[k]],c.faceVertexUvs[k].push([h[0],h[1],h[2]]);f+=n.length*w}};D.prototype=new F;D.prototype.constructor=D;F.prototype.setVertices=function(b){for(var c=0;c<this.inputs.length;c++)if(this.inputs[c].source==b.id)this.inputs[c].source=b.input.POSITION.source};
-F.prototype.parse=function(b){this.inputs=[];this.material=b.getAttribute("material");this.count=ca(b,"count",0);for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];switch(e.nodeName){case "input":this.inputs.push((new N).parse(b.childNodes[c]));break;case "vcount":this.vcount=$(e.textContent);break;case "p":this.p=$(e.textContent)}}return this};C.prototype.parse=function(b){this.params=[];this.source=b.getAttribute("source");this.count=ca(b,"count",0);this.stride=ca(b,"stride",0);for(var c=
-0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeName=="param"){var f={};f.name=e.getAttribute("name");f.type=e.getAttribute("type");this.params.push(f)}}return this};G.prototype.parse=function(b){this.id=b.getAttribute("id");for(var c=0;c<b.childNodes.length;c++)b.childNodes[c].nodeName=="input"&&(input=(new N).parse(b.childNodes[c]),this.input[input.semantic]=input);return this};N.prototype.parse=function(b){this.semantic=b.getAttribute("semantic");this.source=b.getAttribute("source").replace(/^#/,
-"");this.set=ca(b,"set",-1);this.offset=ca(b,"offset",0);if(this.semantic=="TEXCOORD"&&this.set<0)this.set=0;return this};R.prototype.parse=function(b){this.id=b.getAttribute("id");for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];switch(e.nodeName){case "bool_array":for(var f=ia(e.textContent),h=[],k=0;k<f.length;k++)h.push(f[k]=="true"||f[k]=="1"?!0:!1);this.data=h;this.type=e.nodeName;break;case "float_array":this.data=ka(e.textContent);this.type=e.nodeName;break;case "int_array":this.data=
-$(e.textContent);this.type=e.nodeName;break;case "IDREF_array":case "Name_array":this.data=ia(e.textContent);this.type=e.nodeName;break;case "technique_common":for(f=0;f<e.childNodes.length;f++)if(e.childNodes[f].nodeName=="accessor"){this.accessor=(new C).parse(e.childNodes[f]);break}}}return this};R.prototype.read=function(){var b=[],c=this.accessor.params[0];switch(c.type){case "IDREF":case "Name":case "name":case "float":return this.data;case "float4x4":for(c=0;c<this.data.length;c+=16){var e=
-this.data.slice(c,c+16),f=new THREE.Matrix4;f.set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]);b.push(f)}break;default:console.log("Dae::Source:read dont know how to read "+c.type)}return b};H.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");for(var c=0;c<b.childNodes.length;c++)if(b.childNodes[c].nodeName=="instance_effect"){this.instance_effect=(new P).parse(b.childNodes[c]);break}return this};J.prototype.isColor=
-function(){return this.texture==null};J.prototype.isTexture=function(){return this.texture!=null};J.prototype.parse=function(b){for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "color":e=ka(e.textContent);this.color=new THREE.Color(0);this.color.setRGB(e[0],e[1],e[2]);this.color.a=e[3];break;case "texture":this.texture=e.getAttribute("texture"),this.texcoord=e.getAttribute("texcoord")}}return this};I.prototype.parse=function(b){for(var c=0;c<b.childNodes.length;c++){var e=
-b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[e.nodeName]=(new J).parse(e);break;case "shininess":case "reflectivity":case "transparency":var f;f=da.evaluate(".//dae:float",e,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var h=f.iterateNext(),k=[];h;)k.push(h),h=f.iterateNext();f=k;f.length>0&&(this[e.nodeName]=parseFloat(f[0].textContent))}}this.create();return this};I.prototype.create=function(){var b=
-{},c=this.transparency!==void 0&&this.transparency<1,e;for(e in this)switch(e){case "ambient":case "emission":case "diffuse":case "specular":var f=this[e];if(f instanceof J)if(f.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(f=sa[this.effect.surface.init_from]))b.map=THREE.ImageUtils.loadTexture(Da+f.init_from),b.map.wrapS=THREE.RepeatWrapping,b.map.wrapT=THREE.RepeatWrapping,b.map.repeat.x=1,b.map.repeat.y=-1}else e=="diffuse"?b.color=
-f.color.getHex():c||(b[e]=f.color.getHex());break;case "shininess":case "reflectivity":b[e]=this[e];break;case "transparency":if(c)b.transparent=!0,b.opacity=this[e],c=!0}b.shading=Fa;return this.material=new THREE.MeshLambertMaterial(b)};X.prototype.parse=function(b){for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "init_from":this.init_from=e.textContent;break;case "format":this.format=e.textContent;break;default:console.log("unhandled Surface prop: "+
-e.nodeName)}}return this};E.prototype.parse=function(b){for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "source":this.source=e.textContent;break;case "minfilter":this.minfilter=e.textContent;break;case "magfilter":this.magfilter=e.textContent;break;case "mipfilter":this.mipfilter=e.textContent;break;case "wrap_s":this.wrap_s=e.textContent;break;case "wrap_t":this.wrap_t=e.textContent;break;default:console.log("unhandled Sampler2D prop: "+e.nodeName)}}return this};
-O.prototype.create=function(){if(this.shader==null)return null};O.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");this.shader=null;for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(e))}}return this};O.prototype.parseNewparam=function(b){for(var c=b.getAttribute("sid"),e=0;e<b.childNodes.length;e++){var f=b.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "surface":this.surface=
-(new X(this)).parse(f);this.surface.sid=c;break;case "sampler2D":this.sampler=(new E(this)).parse(f);this.sampler.sid=c;break;case "extra":break;default:console.log(f.nodeName)}}};O.prototype.parseProfileCOMMON=function(b){for(var c,e=0;e<b.childNodes.length;e++){var f=b.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "profile_COMMON":this.parseProfileCOMMON(f);break;case "technique":c=f;break;case "newparam":this.parseNewparam(f);break;case "extra":break;default:console.log(f.nodeName)}}return c};
-O.prototype.parseTechnique=function(b){for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "lambert":case "blinn":case "phong":this.shader=(new I(e.nodeName,this)).parse(e)}}};P.prototype.parse=function(b){this.url=b.getAttribute("url").replace(/^#/,"");return this};U.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");this.source={};for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "source":e=
-(new R).parse(e);this.source[e.id]=e;break;case "sampler":this.sampler.push((new p(this)).parse(e));break;case "channel":this.channel.push((new V(this)).parse(e))}}return this};V.prototype.parse=function(b){this.source=b.getAttribute("source").replace(/^#/,"");this.target=b.getAttribute("target");var c=this.target.split("/");c.shift();var b=c.shift(),e=b.indexOf(".")>=0,f=b.indexOf("(")>=0,h,k;if(e)c=b.split("."),b=c.shift(),k=c.shift();else if(f){h=b.split("(");b=h.shift();for(c=0;c<h.length;c++)h[c]=
-parseInt(h[c].replace(/\)/,""))}this.sid=b;this.dotSyntax=e;this.arrSyntax=f;this.arrIndices=h;this.member=k;return this};p.prototype.parse=function(b){this.id=b.getAttribute("id");this.inputs=[];for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "input":this.inputs.push((new N).parse(e))}}return this};p.prototype.create=function(){for(var b=0;b<this.inputs.length;b++){var c=this.inputs[b],e=this.animation.source[c.source];switch(c.semantic){case "INPUT":this.input=
-e.read();break;case "OUTPUT":this.output=e.read();break;case "INTERPOLATION":this.interpolation=e.read();break;case "IN_TANGENT":break;case "OUT_TANGENT":break;default:console.log(c.semantic)}}this.duration=this.endTime=this.startTime=0;if(this.input.length){this.startTime=1E8;this.endTime=-1E8;for(b=0;b<this.input.length;b++)this.startTime=Math.min(this.startTime,this.input[b]),this.endTime=Math.max(this.endTime,this.input[b]);this.duration=this.endTime-this.startTime}};return{load:function(e,f){if(document.implementation&&
+x.prototype.parse=function(b){this.url=b.getAttribute("url").replace(/^#/,"");this.skeleton=[];this.instance_material=[];for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];if(c.nodeType==1)switch(c.nodeName){case "skeleton":this.skeleton.push(c.textContent.replace(/^#/,""));break;case "bind_material":if(c=da.evaluate(".//dae:instance_material",c,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(var f=c.iterateNext();f;)this.instance_material.push((new w).parse(f)),f=c.iterateNext()}}return this};
+w.prototype.parse=function(b){this.symbol=b.getAttribute("symbol");this.target=b.getAttribute("target").replace(/^#/,"");return this};y.prototype.parse=function(b){this.url=b.getAttribute("url").replace(/^#/,"");this.instance_material=[];for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];if(c.nodeType==1&&c.nodeName=="bind_material"){if(b=da.evaluate(".//dae:instance_material",c,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(e=b.iterateNext();e;)this.instance_material.push((new w).parse(e)),
+e=b.iterateNext();break}}return this};A.prototype.parse=function(b){this.id=b.getAttribute("id");for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];switch(c.nodeName){case "mesh":this.mesh=(new z(this)).parse(c)}}return this};z.prototype.parse=function(b){function e(b,c){var f=fa(b.position);h[f]===void 0&&(h[f]={v:b,index:c});return h[f]}this.primitives=[];var c;for(c=0;c<b.childNodes.length;c++){var f=b.childNodes[c];switch(f.nodeName){case "source":ea(f);break;case "vertices":this.vertices=
+(new G).parse(f);break;case "triangles":this.primitives.push((new C).parse(f));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new D).parse(f))}}var h={};this.geometry3js=new THREE.Geometry;f=ja[this.vertices.input.POSITION.source].data;for(b=c=0;c<f.length;c+=3,b++){var k=new THREE.Vertex(new THREE.Vector3(f[c],f[c+1],f[c+2]));e(k,b);this.geometry3js.vertices.push(k)}for(c=0;c<this.primitives.length;c++)primitive=this.primitives[c],primitive.setVertices(this.vertices),
+this.handlePrimitive(primitive,this.geometry3js,h);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();return this};z.prototype.handlePrimitive=function(b,e,c){var f=0,h,k,m=b.p,n=b.inputs,o,p,t,u=0,w=3,v=[];for(h=0;h<n.length;h++)switch(o=n[h],o.semantic){case "TEXCOORD":v.push(o.set)}for(;f<m.length;){var x=[],y=[],z={},A=[];b.vcount&&(w=b.vcount[u++]);for(h=0;h<w;h++)for(k=0;k<n.length;k++)switch(o=
+n[k],source=ja[o.source],p=m[f+h*n.length+o.offset],numParams=source.accessor.params.length,t=p*numParams,o.semantic){case "VERTEX":o=fa(e.vertices[p].position);x.push(c[o].index);break;case "NORMAL":y.push(new THREE.Vector3(source.data[t],source.data[t+1],source.data[t+2]));break;case "TEXCOORD":z[o.set]===void 0&&(z[o.set]=[]);z[o.set].push(new THREE.UV(source.data[t],source.data[t+1]));break;case "COLOR":A.push((new THREE.Color).setRGB(source.data[t],source.data[t+1],source.data[t+2]))}var D;w==
+3?D=new THREE.Face3(x[0],x[1],x[2],[y[0],y[1],y[2]],A.length?A:new THREE.Color):w==4&&(D=new THREE.Face4(x[0],x[1],x[2],x[3],[y[0],y[1],y[2],y[3]],A.length?A:new THREE.Color));D.daeMaterial=b.material;e.faces.push(D);for(k=0;k<v.length;k++)h=z[v[k]],e.faceVertexUvs[k].push([h[0],h[1],h[2]]);f+=n.length*w}};D.prototype=new C;D.prototype.constructor=D;C.prototype.setVertices=function(b){for(var e=0;e<this.inputs.length;e++)if(this.inputs[e].source==b.id)this.inputs[e].source=b.input.POSITION.source};
+C.prototype.parse=function(b){this.inputs=[];this.material=b.getAttribute("material");this.count=ca(b,"count",0);for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];switch(c.nodeName){case "input":this.inputs.push((new N).parse(b.childNodes[e]));break;case "vcount":this.vcount=$(c.textContent);break;case "p":this.p=$(c.textContent)}}return this};F.prototype.parse=function(b){this.params=[];this.source=b.getAttribute("source");this.count=ca(b,"count",0);this.stride=ca(b,"stride",0);for(var e=
+0;e<b.childNodes.length;e++){var c=b.childNodes[e];if(c.nodeName=="param"){var f={};f.name=c.getAttribute("name");f.type=c.getAttribute("type");this.params.push(f)}}return this};G.prototype.parse=function(b){this.id=b.getAttribute("id");for(var e=0;e<b.childNodes.length;e++)b.childNodes[e].nodeName=="input"&&(input=(new N).parse(b.childNodes[e]),this.input[input.semantic]=input);return this};N.prototype.parse=function(b){this.semantic=b.getAttribute("semantic");this.source=b.getAttribute("source").replace(/^#/,
+"");this.set=ca(b,"set",-1);this.offset=ca(b,"offset",0);if(this.semantic=="TEXCOORD"&&this.set<0)this.set=0;return this};R.prototype.parse=function(b){this.id=b.getAttribute("id");for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];switch(c.nodeName){case "bool_array":for(var f=ia(c.textContent),h=[],k=0;k<f.length;k++)h.push(f[k]=="true"||f[k]=="1"?!0:!1);this.data=h;this.type=c.nodeName;break;case "float_array":this.data=ka(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=
+$(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=ia(c.textContent);this.type=c.nodeName;break;case "technique_common":for(f=0;f<c.childNodes.length;f++)if(c.childNodes[f].nodeName=="accessor"){this.accessor=(new F).parse(c.childNodes[f]);break}}}return this};R.prototype.read=function(){var b=[],e=this.accessor.params[0];switch(e.type){case "IDREF":case "Name":case "name":case "float":return this.data;case "float4x4":for(e=0;e<this.data.length;e+=16){var c=
+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};H.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");for(var e=0;e<b.childNodes.length;e++)if(b.childNodes[e].nodeName=="instance_effect"){this.instance_effect=(new P).parse(b.childNodes[e]);break}return this};J.prototype.isColor=
+function(){return this.texture==null};J.prototype.isTexture=function(){return this.texture!=null};J.prototype.parse=function(b){for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];if(c.nodeType==1)switch(c.nodeName){case "color":c=ka(c.textContent);this.color=new THREE.Color(0);this.color.setRGB(c[0],c[1],c[2]);this.color.a=c[3];break;case "texture":this.texture=c.getAttribute("texture"),this.texcoord=c.getAttribute("texcoord")}}return this};I.prototype.parse=function(b){for(var e=0;e<b.childNodes.length;e++){var c=
+b.childNodes[e];if(c.nodeType==1)switch(c.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[c.nodeName]=(new J).parse(c);break;case "shininess":case "reflectivity":case "transparency":var f;f=da.evaluate(".//dae:float",c,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var h=f.iterateNext(),k=[];h;)k.push(h),h=f.iterateNext();f=k;f.length>0&&(this[c.nodeName]=parseFloat(f[0].textContent))}}this.create();return this};I.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 J)if(f.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(f=sa[this.effect.surface.init_from]))b.map=THREE.ImageUtils.loadTexture(Da+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)};X.prototype.parse=function(b){for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];if(c.nodeType==1)switch(c.nodeName){case "init_from":this.init_from=c.textContent;break;case "format":this.format=c.textContent;break;default:console.log("unhandled Surface prop: "+
+c.nodeName)}}return this};E.prototype.parse=function(b){for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];if(c.nodeType==1)switch(c.nodeName){case "source":this.source=c.textContent;break;case "minfilter":this.minfilter=c.textContent;break;case "magfilter":this.magfilter=c.textContent;break;case "mipfilter":this.mipfilter=c.textContent;break;case "wrap_s":this.wrap_s=c.textContent;break;case "wrap_t":this.wrap_t=c.textContent;break;default:console.log("unhandled Sampler2D prop: "+c.nodeName)}}return this};
+O.prototype.create=function(){if(this.shader==null)return null};O.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");this.shader=null;for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];if(c.nodeType==1)switch(c.nodeName){case "profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(c))}}return this};O.prototype.parseNewparam=function(b){for(var e=b.getAttribute("sid"),c=0;c<b.childNodes.length;c++){var f=b.childNodes[c];if(f.nodeType==1)switch(f.nodeName){case "surface":this.surface=
+(new X(this)).parse(f);this.surface.sid=e;break;case "sampler2D":this.sampler=(new E(this)).parse(f);this.sampler.sid=e;break;case "extra":break;default:console.log(f.nodeName)}}};O.prototype.parseProfileCOMMON=function(b){for(var e,c=0;c<b.childNodes.length;c++){var f=b.childNodes[c];if(f.nodeType==1)switch(f.nodeName){case "profile_COMMON":this.parseProfileCOMMON(f);break;case "technique":e=f;break;case "newparam":this.parseNewparam(f);break;case "extra":break;default:console.log(f.nodeName)}}return e};
+O.prototype.parseTechnique=function(b){for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];if(c.nodeType==1)switch(c.nodeName){case "lambert":case "blinn":case "phong":this.shader=(new I(c.nodeName,this)).parse(c)}}};P.prototype.parse=function(b){this.url=b.getAttribute("url").replace(/^#/,"");return this};U.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");this.source={};for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];if(c.nodeType==1)switch(c.nodeName){case "source":c=
+(new R).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new p(this)).parse(c));break;case "channel":this.channel.push((new V(this)).parse(c))}}return this};V.prototype.parse=function(b){this.source=b.getAttribute("source").replace(/^#/,"");this.target=b.getAttribute("target");var e=this.target.split("/");e.shift();var b=e.shift(),c=b.indexOf(".")>=0,f=b.indexOf("(")>=0,h,k;if(c)e=b.split("."),b=e.shift(),k=e.shift();else if(f){h=b.split("(");b=h.shift();for(e=0;e<h.length;e++)h[e]=
+parseInt(h[e].replace(/\)/,""))}this.sid=b;this.dotSyntax=c;this.arrSyntax=f;this.arrIndices=h;this.member=k;return this};p.prototype.parse=function(b){this.id=b.getAttribute("id");this.inputs=[];for(var e=0;e<b.childNodes.length;e++){var c=b.childNodes[e];if(c.nodeType==1)switch(c.nodeName){case "input":this.inputs.push((new N).parse(c))}}return this};p.prototype.create=function(){for(var b=0;b<this.inputs.length;b++){var e=this.inputs[b],c=this.animation.source[e.source];switch(e.semantic){case "INPUT":this.input=
+c.read();break;case "OUTPUT":this.output=c.read();break;case "INTERPOLATION":this.interpolation=c.read();break;case "IN_TANGENT":break;case "OUT_TANGENT":break;default:console.log(e.semantic)}}this.duration=this.endTime=this.startTime=0;if(this.input.length){this.startTime=1E8;this.endTime=-1E8;for(b=0;b<this.input.length;b++)this.startTime=Math.min(this.startTime,this.input[b]),this.endTime=Math.max(this.endTime,this.input[b]);this.duration=this.endTime-this.startTime}};return{load:function(e,f){if(document.implementation&&
 document.implementation.createDocument){document.implementation.createDocument("http://www.collada.org/2005/11/COLLADASchema","COLLADA",null);e+="?rnd="+Math.random();var n=new XMLHttpRequest;n.overrideMimeType&&n.overrideMimeType("text/xml");n.onreadystatechange=function(){if(n.readyState==4&&(n.status==0||n.status==200)){ga=f;var o,p=e;da=n.responseXML;o=ga;p!==void 0&&(p=p.split("/"),p.pop(),Da=p.join("/")+"/");sa=b("//dae:library_images/dae:image",k,"image");qa=b("//dae:library_materials/dae:material",
 H,"material");wa=b("//dae:library_effects/dae:effect",O,"effect");pa=b("//dae:library_geometries/dae:geometry",A,"geometry");la=b("//dae:library_controllers/dae:controller",h,"controller");M=b("//dae:library_animations/dae:animation",U,"animation");ua=b(".//dae:library_visual_scenes/dae:visual_scene",u,"visual_scene");za=[];Ba=[];(p=da.evaluate(".//dae:scene/dae:instance_visual_scene",da,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(p=p.getAttribute("url").replace(/^#/,""),Y=ua[p]):
 Y=null;T=new THREE.Object3D;for(p=0;p<Y.nodes.length;p++)T.add(m(Y.nodes[p]));c();for(var t in M);t={scene:T,morphs:za,skins:Ba,dae:{images:sa,materials:qa,effects:wa,geometries:pa,controllers:la,animations:M,visualScenes:ua,scene:Y}};o&&o(t)}};n.open("GET",e,!0);n.send(null)}else alert("Don't know how to parse XML!")},setPreferredShading:function(b){Fa=b},applySkin:f,geometries:pa}};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;
 THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;THREE.JSONLoader.prototype.load=function(b){var c=this,e=b.model,f=b.callback,m=b.texture_path?b.texture_path:this.extractUrlbase(e),b=new Worker(e);b.onmessage=function(b){c.createModel(b.data,f,m);c.onLoadComplete()};this.onLoadStart();b.postMessage((new Date).getTime())};
-THREE.JSONLoader.prototype.createModel=function(b,c,e){var f=new THREE.Geometry,m=b.scale!==void 0?1/b.scale:1;this.init_materials(f,b.materials,e);(function(c){if(b.version===void 0||b.version!=2)console.error("Deprecated file format.");else{var e,m,o,u,v,t,x,w,y,A,z,D,F,C,G=b.faces;t=b.vertices;var N=b.normals,R=b.colors,H=0;for(e=0;e<b.uvs.length;e++)b.uvs[e].length&&H++;for(e=0;e<H;e++)f.faceUvs[e]=[],f.faceVertexUvs[e]=[];u=0;for(v=t.length;u<v;)x=new THREE.Vertex,x.position.x=t[u++]*c,x.position.y=
-t[u++]*c,x.position.z=t[u++]*c,f.vertices.push(x);u=0;for(v=G.length;u<v;){c=G[u++];t=c&1;o=c&2;e=c&4;m=c&8;w=c&16;x=c&32;A=c&64;c&=128;t?(z=new THREE.Face4,z.a=G[u++],z.b=G[u++],z.c=G[u++],z.d=G[u++],t=4):(z=new THREE.Face3,z.a=G[u++],z.b=G[u++],z.c=G[u++],t=3);if(o)o=G[u++],z.materials=f.materials[o];o=f.faces.length;if(e)for(e=0;e<H;e++)D=b.uvs[e],y=G[u++],C=D[y*2],y=D[y*2+1],f.faceUvs[e][o]=new THREE.UV(C,y);if(m)for(e=0;e<H;e++){D=b.uvs[e];F=[];for(m=0;m<t;m++)y=G[u++],C=D[y*2],y=D[y*2+1],F[m]=
-new THREE.UV(C,y);f.faceVertexUvs[e][o]=F}if(w)w=G[u++]*3,m=new THREE.Vector3,m.x=N[w++],m.y=N[w++],m.z=N[w],z.normal=m;if(x)for(e=0;e<t;e++)w=G[u++]*3,m=new THREE.Vector3,m.x=N[w++],m.y=N[w++],m.z=N[w],z.vertexNormals.push(m);if(A)x=G[u++],x=new THREE.Color(R[x]),z.color=x;if(c)for(e=0;e<t;e++)x=G[u++],x=new THREE.Color(R[x]),z.vertexColors.push(x);f.faces.push(z)}}})(m);(function(){var c,e,m,o;if(b.skinWeights){c=0;for(e=b.skinWeights.length;c<e;c+=2)m=b.skinWeights[c],o=b.skinWeights[c+1],f.skinWeights.push(new THREE.Vector4(m,
-o,0,0))}if(b.skinIndices){c=0;for(e=b.skinIndices.length;c<e;c+=2)m=b.skinIndices[c],o=b.skinIndices[c+1],f.skinIndices.push(new THREE.Vector4(m,o,0,0))}f.bones=b.bones;f.animation=b.animation})();(function(c){if(b.morphTargets!==void 0){var e,m,o,u,v,t,x,w,y;e=0;for(m=b.morphTargets.length;e<m;e++){f.morphTargets[e]={};f.morphTargets[e].name=b.morphTargets[e].name;f.morphTargets[e].vertices=[];w=f.morphTargets[e].vertices;y=b.morphTargets[e].vertices;o=0;for(u=y.length;o<u;o+=3)v=y[o]*c,t=y[o+1]*
-c,x=y[o+2]*c,w.push(new THREE.Vertex(new THREE.Vector3(v,t,x)))}}if(b.morphColors!==void 0){e=0;for(m=b.morphColors.length;e<m;e++){f.morphColors[e]={};f.morphColors[e].name=b.morphColors[e].name;f.morphColors[e].colors=[];u=f.morphColors[e].colors;v=b.morphColors[e].colors;c=0;for(o=v.length;c<o;c+=3)t=new THREE.Color(16755200),t.setRGB(v[c],v[c+1],v[c+2]),u.push(t)}}})(m);(function(){if(b.edges!==void 0){var c,e,m;for(c=0;c<b.edges.length;c+=2)e=b.edges[c],m=b.edges[c+1],f.edges.push(new THREE.Edge(f.vertices[e],
-f.vertices[m],e,m))}})();f.computeCentroids();f.computeFaceNormals();this.hasNormals(f)&&f.computeTangents();c(f)};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
-THREE.SceneLoader.prototype={load:function(b,c){var e=this,f=new Worker(b);f.postMessage(0);var m=THREE.Loader.prototype.extractUrlbase(b);f.onmessage=function(b){function f(b,c){return c=="relativeToHTML"?b:m+"/"+b}function n(){for(w in O.objects)if(!S.objects[w])if(F=O.objects[w],F.geometry!==void 0){if(R=S.geometries[F.geometry]){var b=!1;X=[];for($=0;$<F.materials.length;$++)X[$]=S.materials[F.materials[$]],b=X[$]instanceof THREE.ShaderMaterial;b&&R.computeTangents();C=F.position;r=F.rotation;
-q=F.quaternion;s=F.scale;q=0;X.length==0&&(X[0]=new THREE.MeshFaceMaterial);X.length>1&&(X=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(R,X);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=F.visible;S.scene.add(object);S.objects[w]=object;F.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),S.scene.collisions.colliders.push(b));
-if(F.castsShadow)b=new THREE.ShadowVolume(R),S.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},S.triggers[object.name]=b)}}else C=F.position,r=F.rotation,q=F.quaternion,s=F.scale,q=0,object=new THREE.Object3D,object.name=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=F.visible!==void 0?F.visible:!1,S.scene.add(object),S.objects[w]=object,S.empties[w]=object,F.trigger&&F.trigger.toLowerCase()!="none"&&(b={type:F.trigger,object:F},S.triggers[object.name]=b)}function o(b){return function(c){S.geometries[b]=c;n();U-=1;e.onLoadComplete();v()}}function u(b){return function(c){S.geometries[b]=c}}function v(){e.callbackProgress({totalModels:p,totalTextures:ea,loadedModels:p-U,loadedTextures:ea-V},S);e.onLoadProgress();U==0&&V==0&&c(S)}var t,
-x,w,y,A,z,D,F,C,G,N,R,H,J,I,X,E,O,P,U,V,p,ea,S;O=b.data;I=new THREE.BinaryLoader;P=new THREE.JSONLoader;V=U=0;S={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(w in O.objects)if(F=O.objects[w],F.meshCollider){b=!0;break}if(b)S.scene.collisions=new THREE.CollisionSystem;if(O.transform){b=O.transform.position;G=O.transform.rotation;var ka=O.transform.scale;b&&S.scene.position.set(b[0],b[1],b[2]);G&&S.scene.rotation.set(G[0],
-G[1],G[2]);ka&&S.scene.scale.set(ka[0],ka[1],ka[2]);(b||G||ka)&&S.scene.updateMatrix()}b=function(){V-=1;v();e.onLoadComplete()};for(A in O.cameras){G=O.cameras[A];if(G.type=="perspective")H=new THREE.Camera(G.fov,G.aspect,G.near,G.far);else if(G.type=="ortho")H=new THREE.Camera,H.projectionMatrix=THREE.Matrix4.makeOrtho(G.left,G.right,G.top,G.bottom,G.near,G.far);C=G.position;G=G.target;H.position.set(C[0],C[1],C[2]);H.target.position.set(G[0],G[1],G[2]);S.cameras[A]=H}for(y in O.lights)A=O.lights[y],
-H=A.color!==void 0?A.color:16777215,G=A.intensity!==void 0?A.intensity:1,A.type=="directional"?(C=A.direction,E=new THREE.DirectionalLight(H,G),E.position.set(C[0],C[1],C[2]),E.position.normalize()):A.type=="point"?(C=A.position,d=A.distance,E=new THREE.PointLight(H,G,d),E.position.set(C[0],C[1],C[2])):A.type=="ambient"&&(E=new THREE.AmbientLight(H)),S.scene.add(E),S.lights[y]=E;for(z in O.fogs)y=O.fogs[z],y.type=="linear"?J=new THREE.Fog(0,y.near,y.far):y.type=="exp2"&&(J=new THREE.FogExp2(0,y.density)),
+THREE.JSONLoader.prototype.createModel=function(b,c,e){var f=new THREE.Geometry,m=b.scale!==void 0?1/b.scale:1;this.init_materials(f,b.materials,e);(function(e){if(b.version===void 0||b.version!=2)console.error("Deprecated file format.");else{var c,m,o,u,v,t,x,w,y,A,z,D,C,F,G=b.faces;t=b.vertices;var N=b.normals,R=b.colors,H=0;for(c=0;c<b.uvs.length;c++)b.uvs[c].length&&H++;for(c=0;c<H;c++)f.faceUvs[c]=[],f.faceVertexUvs[c]=[];u=0;for(v=t.length;u<v;)x=new THREE.Vertex,x.position.x=t[u++]*e,x.position.y=
+t[u++]*e,x.position.z=t[u++]*e,f.vertices.push(x);u=0;for(v=G.length;u<v;){e=G[u++];t=e&1;o=e&2;c=e&4;m=e&8;w=e&16;x=e&32;A=e&64;e&=128;t?(z=new THREE.Face4,z.a=G[u++],z.b=G[u++],z.c=G[u++],z.d=G[u++],t=4):(z=new THREE.Face3,z.a=G[u++],z.b=G[u++],z.c=G[u++],t=3);if(o)o=G[u++],z.materials=f.materials[o];o=f.faces.length;if(c)for(c=0;c<H;c++)D=b.uvs[c],y=G[u++],F=D[y*2],y=D[y*2+1],f.faceUvs[c][o]=new THREE.UV(F,y);if(m)for(c=0;c<H;c++){D=b.uvs[c];C=[];for(m=0;m<t;m++)y=G[u++],F=D[y*2],y=D[y*2+1],C[m]=
+new THREE.UV(F,y);f.faceVertexUvs[c][o]=C}if(w)w=G[u++]*3,m=new THREE.Vector3,m.x=N[w++],m.y=N[w++],m.z=N[w],z.normal=m;if(x)for(c=0;c<t;c++)w=G[u++]*3,m=new THREE.Vector3,m.x=N[w++],m.y=N[w++],m.z=N[w],z.vertexNormals.push(m);if(A)x=G[u++],x=new THREE.Color(R[x]),z.color=x;if(e)for(c=0;c<t;c++)x=G[u++],x=new THREE.Color(R[x]),z.vertexColors.push(x);f.faces.push(z)}}})(m);(function(){var e,c,m,o;if(b.skinWeights){e=0;for(c=b.skinWeights.length;e<c;e+=2)m=b.skinWeights[e],o=b.skinWeights[e+1],f.skinWeights.push(new THREE.Vector4(m,
+o,0,0))}if(b.skinIndices){e=0;for(c=b.skinIndices.length;e<c;e+=2)m=b.skinIndices[e],o=b.skinIndices[e+1],f.skinIndices.push(new THREE.Vector4(m,o,0,0))}f.bones=b.bones;f.animation=b.animation})();(function(e){if(b.morphTargets!==void 0){var c,m,o,u,v,t,x,w,y;c=0;for(m=b.morphTargets.length;c<m;c++){f.morphTargets[c]={};f.morphTargets[c].name=b.morphTargets[c].name;f.morphTargets[c].vertices=[];w=f.morphTargets[c].vertices;y=b.morphTargets[c].vertices;o=0;for(u=y.length;o<u;o+=3)v=y[o]*e,t=y[o+1]*
+e,x=y[o+2]*e,w.push(new THREE.Vertex(new THREE.Vector3(v,t,x)))}}if(b.morphColors!==void 0){c=0;for(m=b.morphColors.length;c<m;c++){f.morphColors[c]={};f.morphColors[c].name=b.morphColors[c].name;f.morphColors[c].colors=[];u=f.morphColors[c].colors;v=b.morphColors[c].colors;e=0;for(o=v.length;e<o;e+=3)t=new THREE.Color(16755200),t.setRGB(v[e],v[e+1],v[e+2]),u.push(t)}}})(m);(function(){if(b.edges!==void 0){var e,c,m;for(e=0;e<b.edges.length;e+=2)c=b.edges[e],m=b.edges[e+1],f.edges.push(new THREE.Edge(f.vertices[c],
+f.vertices[m],c,m))}})();f.computeCentroids();f.computeFaceNormals();this.hasNormals(f)&&f.computeTangents();c(f)};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
+THREE.SceneLoader.prototype={load:function(b,c){var e=this,f=new Worker(b);f.postMessage(0);var m=THREE.Loader.prototype.extractUrlbase(b);f.onmessage=function(b){function f(b,e){return e=="relativeToHTML"?b:m+"/"+b}function n(){for(w in O.objects)if(!S.objects[w])if(C=O.objects[w],C.geometry!==void 0){if(R=S.geometries[C.geometry]){var b=!1;X=[];for($=0;$<C.materials.length;$++)X[$]=S.materials[C.materials[$]],b=X[$]instanceof THREE.ShaderMaterial;b&&R.computeTangents();F=C.position;r=C.rotation;
+q=C.quaternion;s=C.scale;q=0;X.length==0&&(X[0]=new THREE.MeshFaceMaterial);X.length>1&&(X=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(R,X);object.name=w;object.position.set(F[0],F[1],F[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=C.visible;S.scene.add(object);S.objects[w]=object;C.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),S.scene.collisions.colliders.push(b));
+if(C.castsShadow)b=new THREE.ShadowVolume(R),S.scene.add(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;C.trigger&&C.trigger.toLowerCase()!="none"&&(b={type:C.trigger,object:C},S.triggers[object.name]=b)}}else F=C.position,r=C.rotation,q=C.quaternion,s=C.scale,q=0,object=new THREE.Object3D,object.name=w,object.position.set(F[0],F[1],F[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=C.visible!==void 0?C.visible:!1,S.scene.add(object),S.objects[w]=object,S.empties[w]=object,C.trigger&&C.trigger.toLowerCase()!="none"&&(b={type:C.trigger,object:C},S.triggers[object.name]=b)}function o(b){return function(c){S.geometries[b]=c;n();U-=1;e.onLoadComplete();v()}}function u(b){return function(e){S.geometries[b]=e}}function v(){e.callbackProgress({totalModels:p,totalTextures:ea,loadedModels:p-U,loadedTextures:ea-V},S);e.onLoadProgress();U==0&&V==0&&c(S)}var t,
+x,w,y,A,z,D,C,F,G,N,R,H,J,I,X,E,O,P,U,V,p,ea,S;O=b.data;I=new THREE.BinaryLoader;P=new THREE.JSONLoader;V=U=0;S={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(w in O.objects)if(C=O.objects[w],C.meshCollider){b=!0;break}if(b)S.scene.collisions=new THREE.CollisionSystem;if(O.transform){b=O.transform.position;G=O.transform.rotation;var ka=O.transform.scale;b&&S.scene.position.set(b[0],b[1],b[2]);G&&S.scene.rotation.set(G[0],
+G[1],G[2]);ka&&S.scene.scale.set(ka[0],ka[1],ka[2]);(b||G||ka)&&S.scene.updateMatrix()}b=function(){V-=1;v();e.onLoadComplete()};for(A in O.cameras){G=O.cameras[A];if(G.type=="perspective")H=new THREE.Camera(G.fov,G.aspect,G.near,G.far);else if(G.type=="ortho")H=new THREE.Camera,H.projectionMatrix=THREE.Matrix4.makeOrtho(G.left,G.right,G.top,G.bottom,G.near,G.far);F=G.position;G=G.target;H.position.set(F[0],F[1],F[2]);H.target.position.set(G[0],G[1],G[2]);S.cameras[A]=H}for(y in O.lights)A=O.lights[y],
+H=A.color!==void 0?A.color:16777215,G=A.intensity!==void 0?A.intensity:1,A.type=="directional"?(F=A.direction,E=new THREE.DirectionalLight(H,G),E.position.set(F[0],F[1],F[2]),E.position.normalize()):A.type=="point"?(F=A.position,d=A.distance,E=new THREE.PointLight(H,G,d),E.position.set(F[0],F[1],F[2])):A.type=="ambient"&&(E=new THREE.AmbientLight(H)),S.scene.add(E),S.lights[y]=E;for(z in O.fogs)y=O.fogs[z],y.type=="linear"?J=new THREE.Fog(0,y.near,y.far):y.type=="exp2"&&(J=new THREE.FogExp2(0,y.density)),
 G=y.color,J.color.setRGB(G[0],G[1],G[2]),S.fogs[z]=J;if(S.cameras&&O.defaults.camera)S.currentCamera=S.cameras[O.defaults.camera];if(S.fogs&&O.defaults.fog)S.scene.fog=S.fogs[O.defaults.fog];G=O.defaults.bgcolor;S.bgColor=new THREE.Color;S.bgColor.setRGB(G[0],G[1],G[2]);S.bgColorAlpha=O.defaults.bgalpha;for(t in O.geometries)if(z=O.geometries[t],z.type=="bin_mesh"||z.type=="ascii_mesh")U+=1,e.onLoadStart();p=U;for(t in O.geometries)z=O.geometries[t],z.type=="cube"?(R=new THREE.CubeGeometry(z.width,
 z.height,z.depth,z.segmentsWidth,z.segmentsHeight,z.segmentsDepth,null,z.flipped,z.sides),S.geometries[t]=R):z.type=="plane"?(R=new THREE.PlaneGeometry(z.width,z.height,z.segmentsWidth,z.segmentsHeight),S.geometries[t]=R):z.type=="sphere"?(R=new THREE.SphereGeometry(z.radius,z.segmentsWidth,z.segmentsHeight),S.geometries[t]=R):z.type=="cylinder"?(R=new THREE.CylinderGeometry(z.topRad,z.botRad,z.height,z.radSegs,z.heightSegs),S.geometries[t]=R):z.type=="torus"?(R=new THREE.TorusGeometry(z.radius,z.tube,
 z.segmentsR,z.segmentsT),S.geometries[t]=R):z.type=="icosahedron"?(R=new THREE.IcosahedronGeometry(z.subdivisions),S.geometries[t]=R):z.type=="bin_mesh"?I.load({model:f(z.url,O.urlBaseType),callback:o(t)}):z.type=="ascii_mesh"?P.load({model:f(z.url,O.urlBaseType),callback:o(t)}):z.type=="embedded_mesh"&&(z=O.embeds[z.id])&&P.createModel(z,u(t),"");for(D in O.textures)if(t=O.textures[D],t.url instanceof Array){V+=t.url.length;for(I=0;I<t.url.length;I++)e.onLoadStart()}else V+=1,e.onLoadStart();ea=
@@ -625,19 +626,19 @@ S.textures[D.parameters.specularMap],b.enableSpecular.value=!0;b.uDiffuseColor.v
 THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
 THREE.UTF8Loader.prototype.load=function(b){var c=new XMLHttpRequest,e=b.model,f=b.callback,m=b.scale!==void 0?b.scale:1,k=b.offsetX!==void 0?b.offsetX:0,h=b.offsetY!==void 0?b.offsetY:0,n=b.offsetZ!==void 0?b.offsetZ:0;c.onreadystatechange=function(){c.readyState==4?c.status==200||c.status==0?THREE.UTF8Loader.prototype.createModel(c.responseText,f,m,k,h,n):alert("Couldn't load ["+e+"] ["+c.status+"]"):c.readyState!=3&&c.readyState==2&&c.getResponseHeader("Content-Length")};c.open("GET",e,!0);c.send(null)};
 THREE.UTF8Loader.prototype.decompressMesh=function(b){var c=b.charCodeAt(0);c>=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,m=0;m<8;m++){for(var k=0,h=0;h<c;++h){var n=b.charCodeAt(h+f);k+=n>>1^-(n&1);e[8*h+m]=k}f+=c}c=b.length-f;k=new Uint16Array(c);for(m=h=0;m<c;m++)n=b.charCodeAt(m+f),k[m]=h-n,n==0&&h++;return[e,k]};
-THREE.UTF8Loader.prototype.createModel=function(b,c,e,f,m,k){var h=function(){var c=this;c.materials=[];THREE.Geometry.call(this);var h=THREE.UTF8Loader.prototype.decompressMesh(b),u=[],v=[];(function(b,h,o){for(var u,v,z,D=b.length;o<D;o+=h)u=b[o],v=b[o+1],z=b[o+2],u=u/16383*e,v=v/16383*e,z=z/16383*e,u+=f,v+=m,z+=k,c.vertices.push(new THREE.Vertex(new THREE.Vector3(u,v,z)))})(h[0],8,0);(function(b,c,e){for(var f,h,k=b.length;e<k;e+=c)f=b[e],h=b[e+1],f/=1023,h/=1023,v.push(f,1-h)})(h[0],8,3);(function(b,
-c,e){for(var f,h,k,m=b.length;e<m;e+=c)f=b[e],h=b[e+1],k=b[e+2],f=(f-512)/511,h=(h-512)/511,k=(k-512)/511,u.push(f,h,k)})(h[0],8,5);(function(b){var e,f,h,k,m,o,F,C,G,N=b.length;for(e=0;e<N;e+=3){f=b[e];h=b[e+1];k=b[e+2];m=c;C=f;G=h;o=k;F=f;var R=h,H=k,J=m.materials[0],I=u[R*3],X=u[R*3+1],R=u[R*3+2],E=u[H*3],O=u[H*3+1],H=u[H*3+2];F=new THREE.Vector3(u[F*3],u[F*3+1],u[F*3+2]);R=new THREE.Vector3(I,X,R);H=new THREE.Vector3(E,O,H);m.faces.push(new THREE.Face3(C,G,o,[F,R,H],null,J));m=v[f*2];f=v[f*2+
-1];o=v[h*2];F=v[h*2+1];C=v[k*2];G=v[k*2+1];k=c.faceVertexUvs[0];h=o;o=F;F=[];F.push(new THREE.UV(m,f));F.push(new THREE.UV(h,o));F.push(new THREE.UV(C,G));k.push(F)}})(h[1]);this.computeCentroids();this.computeFaceNormals()};h.prototype=new THREE.Geometry;h.prototype.constructor=h;c(new h)};
+THREE.UTF8Loader.prototype.createModel=function(b,c,e,f,m,k){var h=function(){var c=this;c.materials=[];THREE.Geometry.call(this);var h=THREE.UTF8Loader.prototype.decompressMesh(b),u=[],v=[];(function(b,h,o){for(var u,v,z,D=b.length;o<D;o+=h)u=b[o],v=b[o+1],z=b[o+2],u=u/16383*e,v=v/16383*e,z=z/16383*e,u+=f,v+=m,z+=k,c.vertices.push(new THREE.Vertex(new THREE.Vector3(u,v,z)))})(h[0],8,0);(function(b,e,c){for(var f,h,k=b.length;c<k;c+=e)f=b[c],h=b[c+1],f/=1023,h/=1023,v.push(f,1-h)})(h[0],8,3);(function(b,
+e,c){for(var f,h,k,m=b.length;c<m;c+=e)f=b[c],h=b[c+1],k=b[c+2],f=(f-512)/511,h=(h-512)/511,k=(k-512)/511,u.push(f,h,k)})(h[0],8,5);(function(b){var e,f,h,k,m,o,C,F,G,N=b.length;for(e=0;e<N;e+=3){f=b[e];h=b[e+1];k=b[e+2];m=c;F=f;G=h;o=k;C=f;var R=h,H=k,J=m.materials[0],I=u[R*3],X=u[R*3+1],R=u[R*3+2],E=u[H*3],O=u[H*3+1],H=u[H*3+2];C=new THREE.Vector3(u[C*3],u[C*3+1],u[C*3+2]);R=new THREE.Vector3(I,X,R);H=new THREE.Vector3(E,O,H);m.faces.push(new THREE.Face3(F,G,o,[C,R,H],null,J));m=v[f*2];f=v[f*2+
+1];o=v[h*2];C=v[h*2+1];F=v[k*2];G=v[k*2+1];k=c.faceVertexUvs[0];h=o;o=C;C=[];C.push(new THREE.UV(m,f));C.push(new THREE.UV(h,o));C.push(new THREE.UV(F,G));k.push(C)}})(h[1]);this.computeCentroids();this.computeFaceNormals()};h.prototype=new THREE.Geometry;h.prototype.constructor=h;c(new h)};
 THREE.MarchingCubes=function(b,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
 0;this.hasNormal=this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,c,m){return b+(c-b)*m};this.VIntX=function(b,c,m,k,h,n,o,u,v,t){h=(h-v)/(t-v);v=this.normal_cache;c[k]=n+h*this.delta;c[k+1]=o;c[k+2]=u;m[k]=this.lerp(v[b],v[b+3],h);m[k+1]=this.lerp(v[b+1],v[b+4],h);m[k+2]=this.lerp(v[b+2],v[b+5],h)};this.VIntY=function(b,c,m,k,h,n,o,u,v,t){h=(h-v)/(t-v);v=this.normal_cache;c[k]=n;c[k+1]=o+h*this.delta;c[k+
 2]=u;c=b+this.yd*3;m[k]=this.lerp(v[b],v[c],h);m[k+1]=this.lerp(v[b+1],v[c+1],h);m[k+2]=this.lerp(v[b+2],v[c+2],h)};this.VIntZ=function(b,c,m,k,h,n,o,u,v,t){h=(h-v)/(t-v);v=this.normal_cache;c[k]=n;c[k+1]=o;c[k+2]=u+h*this.delta;c=b+this.zd*3;m[k]=this.lerp(v[b],v[c],h);m[k+1]=this.lerp(v[b+1],v[c+1],h);m[k+2]=this.lerp(v[b+2],v[c+2],h)};this.compNorm=function(b){var c=b*3;this.normal_cache[c]==0&&(this.normal_cache[c]=this.field[b-1]-this.field[b+1],this.normal_cache[c+1]=this.field[b-this.yd]-this.field[b+
-this.yd],this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd])};this.polygonize=function(b,c,m,k,h,n){var o=k+1,u=k+this.yd,v=k+this.zd,t=o+this.yd,x=o+this.zd,w=k+this.yd+this.zd,y=o+this.yd+this.zd,A=0,z=this.field[k],D=this.field[o],F=this.field[u],C=this.field[t],G=this.field[v],N=this.field[x],R=this.field[w],H=this.field[y];z<h&&(A|=1);D<h&&(A|=2);F<h&&(A|=8);C<h&&(A|=4);G<h&&(A|=16);N<h&&(A|=32);R<h&&(A|=128);H<h&&(A|=64);var J=THREE.edgeTable[A];if(J==0)return 0;var I=this.delta,
-X=b+I,E=c+I,I=m+I;J&1&&(this.compNorm(k),this.compNorm(o),this.VIntX(k*3,this.vlist,this.nlist,0,h,b,c,m,z,D));J&2&&(this.compNorm(o),this.compNorm(t),this.VIntY(o*3,this.vlist,this.nlist,3,h,X,c,m,D,C));J&4&&(this.compNorm(u),this.compNorm(t),this.VIntX(u*3,this.vlist,this.nlist,6,h,b,E,m,F,C));J&8&&(this.compNorm(k),this.compNorm(u),this.VIntY(k*3,this.vlist,this.nlist,9,h,b,c,m,z,F));J&16&&(this.compNorm(v),this.compNorm(x),this.VIntX(v*3,this.vlist,this.nlist,12,h,b,c,I,G,N));J&32&&(this.compNorm(x),
+this.yd],this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd])};this.polygonize=function(b,c,m,k,h,n){var o=k+1,u=k+this.yd,v=k+this.zd,t=o+this.yd,x=o+this.zd,w=k+this.yd+this.zd,y=o+this.yd+this.zd,A=0,z=this.field[k],D=this.field[o],C=this.field[u],F=this.field[t],G=this.field[v],N=this.field[x],R=this.field[w],H=this.field[y];z<h&&(A|=1);D<h&&(A|=2);C<h&&(A|=8);F<h&&(A|=4);G<h&&(A|=16);N<h&&(A|=32);R<h&&(A|=128);H<h&&(A|=64);var J=THREE.edgeTable[A];if(J==0)return 0;var I=this.delta,
+X=b+I,E=c+I,I=m+I;J&1&&(this.compNorm(k),this.compNorm(o),this.VIntX(k*3,this.vlist,this.nlist,0,h,b,c,m,z,D));J&2&&(this.compNorm(o),this.compNorm(t),this.VIntY(o*3,this.vlist,this.nlist,3,h,X,c,m,D,F));J&4&&(this.compNorm(u),this.compNorm(t),this.VIntX(u*3,this.vlist,this.nlist,6,h,b,E,m,C,F));J&8&&(this.compNorm(k),this.compNorm(u),this.VIntY(k*3,this.vlist,this.nlist,9,h,b,c,m,z,C));J&16&&(this.compNorm(v),this.compNorm(x),this.VIntX(v*3,this.vlist,this.nlist,12,h,b,c,I,G,N));J&32&&(this.compNorm(x),
 this.compNorm(y),this.VIntY(x*3,this.vlist,this.nlist,15,h,X,c,I,N,H));J&64&&(this.compNorm(w),this.compNorm(y),this.VIntX(w*3,this.vlist,this.nlist,18,h,b,E,I,R,H));J&128&&(this.compNorm(v),this.compNorm(w),this.VIntY(v*3,this.vlist,this.nlist,21,h,b,c,I,G,R));J&256&&(this.compNorm(k),this.compNorm(v),this.VIntZ(k*3,this.vlist,this.nlist,24,h,b,c,m,z,G));J&512&&(this.compNorm(o),this.compNorm(x),this.VIntZ(o*3,this.vlist,this.nlist,27,h,X,c,m,D,N));J&1024&&(this.compNorm(t),this.compNorm(y),this.VIntZ(t*
-3,this.vlist,this.nlist,30,h,X,E,m,C,H));J&2048&&(this.compNorm(u),this.compNorm(w),this.VIntZ(u*3,this.vlist,this.nlist,33,h,b,E,m,F,R));A<<=4;for(h=k=0;THREE.triTable[A+h]!=-1;)b=A+h,c=b+1,m=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[m],n),h+=3,k++;return k};this.posnormtriv=function(b,c,m,k,h,n){var o=this.count*3;this.positionArray[o]=b[m];this.positionArray[o+1]=b[m+1];this.positionArray[o+2]=b[m+2];this.positionArray[o+3]=b[k];this.positionArray[o+
+3,this.vlist,this.nlist,30,h,X,E,m,F,H));J&2048&&(this.compNorm(u),this.compNorm(w),this.VIntZ(u*3,this.vlist,this.nlist,33,h,b,E,m,C,R));A<<=4;for(h=k=0;THREE.triTable[A+h]!=-1;)b=A+h,c=b+1,m=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[m],n),h+=3,k++;return k};this.posnormtriv=function(b,c,m,k,h,n){var o=this.count*3;this.positionArray[o]=b[m];this.positionArray[o+1]=b[m+1];this.positionArray[o+2]=b[m+2];this.positionArray[o+3]=b[k];this.positionArray[o+
 4]=b[k+1];this.positionArray[o+5]=b[k+2];this.positionArray[o+6]=b[h];this.positionArray[o+7]=b[h+1];this.positionArray[o+8]=b[h+2];this.normalArray[o]=c[m];this.normalArray[o+1]=c[m+1];this.normalArray[o+2]=c[m+2];this.normalArray[o+3]=c[k];this.normalArray[o+4]=c[k+1];this.normalArray[o+5]=c[k+2];this.normalArray[o+6]=c[h];this.normalArray[o+7]=c[h+1];this.normalArray[o+8]=c[h+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=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;c<this.positionArray.length;c++)this.positionArray[c]=0;b(this)}};this.addBall=function(b,c,m,k,h){var n=this.size*Math.sqrt(k/h),o=m*this.size,u=c*this.size,v=b*this.size,t=Math.floor(o-n);t<1&&(t=1);o=Math.floor(o+n);o>this.size-1&&(o=this.size-1);var x=Math.floor(u-n);x<1&&(x=1);u=Math.floor(u+n);u>this.size-1&&(u=this.size-1);var w=Math.floor(v-n);w<1&&(w=1);n=Math.floor(v+n);n>this.size-1&&(n=this.size-
-1);for(var y,A,z,D,F,C;t<o;t++){v=this.size2*t;A=t/this.size-m;F=A*A;for(A=x;A<u;A++){z=v+this.size*A;y=A/this.size-c;C=y*y;for(y=w;y<n;y++)D=y/this.size-b,D=k/(1.0E-6+D*D+C+F)-h,D>0&&(this.field[z+y]+=D)}}};this.addPlaneX=function(b,c){var m,k,h,n,o,u=this.size,v=this.yd,t=this.zd,x=this.field,w=u*Math.sqrt(b/c);w>u&&(w=u);for(m=0;m<w;m++)if(k=m/u,k*=k,n=b/(1.0E-4+k)-c,n>0)for(k=0;k<u;k++){o=m+k*v;for(h=0;h<u;h++)x[t*h+o]+=n}};this.addPlaneY=function(b,c){var m,k,h,n,o,u,v=this.size,t=this.yd,x=
+1);for(var y,A,z,D,C,F;t<o;t++){v=this.size2*t;A=t/this.size-m;C=A*A;for(A=x;A<u;A++){z=v+this.size*A;y=A/this.size-c;F=y*y;for(y=w;y<n;y++)D=y/this.size-b,D=k/(1.0E-6+D*D+F+C)-h,D>0&&(this.field[z+y]+=D)}}};this.addPlaneX=function(b,c){var m,k,h,n,o,u=this.size,v=this.yd,t=this.zd,x=this.field,w=u*Math.sqrt(b/c);w>u&&(w=u);for(m=0;m<w;m++)if(k=m/u,k*=k,n=b/(1.0E-4+k)-c,n>0)for(k=0;k<u;k++){o=m+k*v;for(h=0;h<u;h++)x[t*h+o]+=n}};this.addPlaneY=function(b,c){var m,k,h,n,o,u,v=this.size,t=this.yd,x=
 this.zd,w=this.field,y=v*Math.sqrt(b/c);y>v&&(y=v);for(k=0;k<y;k++)if(m=k/v,m*=m,n=b/(1.0E-4+m)-c,n>0){o=k*t;for(m=0;m<v;m++){u=o+m;for(h=0;h<v;h++)w[x*h+u]+=n}}};this.addPlaneZ=function(b,c){var m,k,h,n,o,u;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(h=0;h<dist;h++)if(m=h/size,m*=m,n=b/(1.0E-4+m)-c,n>0){o=zd*h;for(k=0;k<size;k++){u=o+k*yd;for(m=0;m<size;m++)field[u+m]+=n}}};this.reset=function(){var b;for(b=0;b<this.size3;b++)this.normal_cache[b*
 3]=0,this.field[b]=0};this.render=function(b){this.begin();var c,m,k,h,n,o,u,v,t,x=this.size-2;for(h=1;h<x;h++){t=this.size2*h;u=(h-this.halfsize)/this.halfsize;for(k=1;k<x;k++){v=t+this.size*k;o=(k-this.halfsize)/this.halfsize;for(m=1;m<x;m++)n=(m-this.halfsize)/this.halfsize,c=v+m,this.polygonize(n,o,u,c,this.isolation,b)}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry,m=[];this.render(function(k){var h,n,o,u,v,t,x,w;for(h=0;h<k.count;h++)x=h*3,v=x+1,w=x+2,n=k.positionArray[x],
 o=k.positionArray[v],u=k.positionArray[w],t=new THREE.Vector3(n,o,u),n=k.normalArray[x],o=k.normalArray[v],u=k.normalArray[w],x=new THREE.Vector3(n,o,u),x.normalize(),v=new THREE.Vertex(t),c.vertices.push(v),m.push(x);nfaces=k.count/3;for(h=0;h<nfaces;h++)x=(b+h)*3,v=x+1,w=x+2,t=m[x],n=m[v],o=m[w],x=new THREE.Face3(x,v,w,[t,n,o]),c.faces.push(x);b+=nfaces;k.count=0});return c};this.init(b)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
@@ -684,7 +685,7 @@ THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionU
 THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))};
 if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,m=new THREE.Camera,k=new THREE.Camera,h=new THREE.Matrix4,n=new THREE.Matrix4,o,u,v;m.useTarget=k.useTarget=!1;m.matrixAutoUpdate=k.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},t=new THREE.WebGLRenderTarget(512,512,b),x=new THREE.WebGLRenderTarget(512,512,b),w=new THREE.Camera(53,1,1,1E4);w.position.z=
 2;_material=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:t},mapRight:{type:"t",value:1,texture:x}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"});
-var y=new THREE.Scene;y.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);t.width=b;t.height=f;x.width=b;x.height=f};this.render=function(b,e){e.update(null,!0);if(o!==e.aspect||u!==e.near||v!==e.fov){o=e.aspect;u=e.near;v=e.fov;var D=e.projectionMatrix.clone(),F=125/30*0.5,C=F*u/125,G=u*Math.tan(v*Math.PI/360),N;h.n14=F;n.n14=-F;F=-G*o+C;N=G*o+C;D.n11=2*u/(N-F);D.n13=(N+F)/(N-F);m.projectionMatrix=D.clone();F=-G*o-C;N=G*o-C;D.n11=2*u/(N-F);D.n13=
-(N+F)/(N-F);k.projectionMatrix=D.clone()}m.matrix=e.matrixWorld.clone().multiplySelf(n);m.update(null,!0);m.position.copy(e.position);m.near=u;m.far=e.far;f.call(c,b,m,t,!0);k.matrix=e.matrixWorld.clone().multiplySelf(h);k.update(null,!0);k.position.copy(e.position);k.near=u;k.far=e.far;f.call(c,b,k,x,!0);f.call(c,y,w)}};
+var y=new THREE.Scene;y.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);t.width=b;t.height=f;x.width=b;x.height=f};this.render=function(b,e){e.update(null,!0);if(o!==e.aspect||u!==e.near||v!==e.fov){o=e.aspect;u=e.near;v=e.fov;var D=e.projectionMatrix.clone(),C=125/30*0.5,F=C*u/125,G=u*Math.tan(v*Math.PI/360),N;h.n14=C;n.n14=-C;C=-G*o+F;N=G*o+F;D.n11=2*u/(N-C);D.n13=(N+C)/(N-C);m.projectionMatrix=D.clone();C=-G*o-F;N=G*o-F;D.n11=2*u/(N-C);D.n13=
+(N+C)/(N-C);k.projectionMatrix=D.clone()}m.matrix=e.matrixWorld.clone().multiplySelf(n);m.update(null,!0);m.position.copy(e.position);m.near=u;m.far=e.far;f.call(c,b,m,t,!0);k.matrix=e.matrixWorld.clone().multiplySelf(h);k.update(null,!0);k.position.copy(e.position);k.near=u;k.far=e.far;f.call(c,b,k,x,!0);f.call(c,y,w)}};
 if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,m,k,h=new THREE.Camera,n=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,f){e.call(c,b,f);m=b/2;k=f};this.render=function(b,e){this.clear();h.fov=e.fov;h.aspect=0.5*e.aspect;h.near=e.near;h.far=e.far;
 h.updateProjectionMatrix();h.position.copy(e.position);h.target.position.copy(e.target.position);h.translateX(c.separation);n.projectionMatrix=h.projectionMatrix;n.position.copy(e.position);n.target.position.copy(e.target.position);n.translateX(-c.separation);this.setViewport(0,0,m,k);f.call(c,b,h);this.setViewport(m,0,m,k);f.call(c,b,n,!1)}};

+ 58 - 10
examples/canvas_geometry_subdivison.html

@@ -22,7 +22,11 @@
 		
 		<script src="../src/core/Geometry.js"></script>
 		<script src="../src/extras/geometries/CubeGeometry.js"></script>
-
+		<script src="../src/extras/geometries/CylinderGeometry.js"></script>
+		<script src="../src/extras/geometries/SubdivisionGeometry.js"></script>
+		
+		<script src="fonts/helvetiker_regular.typeface.js"></script>
+		
 		<script>
 
 			var container, stats;
@@ -87,7 +91,22 @@
 
 				}
 				
-				geometry = new THREE.CubeGeometry( 200, 200, 200, 1, 1, 1, materials );
+				geometry = new THREE.CubeGeometry( 200, 200, 200, 2, 2, 2, materials );
+				
+				//geometry = new THREE.SphereGeometry( 200, 1, 1);
+				//geometry = new THREE.CylinderGeometry( 50, 50, 200 );
+				// geometry = new THREE.TextGeometry( '&', {
+				// 						size: 200,
+				// 						height: 50,
+				// 						curveSegments: 1,
+				// 						font: "helvetiker"
+				// 
+				// 					});
+					
+				//PlaneGeometry not supported
+				
+				// quick fix for duplicated vertices
+				geometry.checkDupVertices();
 				
 				smooth = createSubdivision(geometry, 2);
 				
@@ -100,19 +119,48 @@
 					context.fill();
 
 				}
+				
+				var drawText = function(i) {
+					
+					return function ( context ) {
+
+						context.beginPath();
+						context.scale(0.1,-0.1);
+
+						context.fillText(i, 0,0);
+						
+						
+						
+					};
+					
+
+				}
+
+
 
 				group = new THREE.Object3D();
 				group.position.y = 150;
 				scene.add( group );
 
-				for ( var i = 0; i < smooth.vertices.length; i++ ) {
-
-					particle = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: Math.random() * 0x808008 + 0x808080, program: program } ) );
-					particle.position = smooth.vertices[i].position;
-					var pos = smooth.vertices.position
-					particle.scale.x = particle.scale.y = 5;
-					group.add( particle );
-				}
+				// Debug new Points
+				// for ( var i = 0; i < smooth.vertices.length; i++ ) {
+				// 
+				// 	particle = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: Math.random() * 0x808008 + 0x808080, program: program } ) );
+				// 	particle.position = smooth.vertices[i].position;
+				// 	var pos = smooth.vertices.position
+				// 	particle.scale.x = particle.scale.y = 5;
+				// 	group.add( particle );
+				// }
+				
+				// Debug original points
+				// for ( var i = 0; i < geometry.vertices.length; i++ ) {
+				// 
+				// 	particle = new THREE.Particle( new THREE.ParticleCanvasMaterial( { color: Math.random() * 0x808008 + 0x808080, program: drawText(i) } ) );
+				// 	particle.position = smooth.vertices[i].position;
+				// 	var pos = geometry.vertices.position
+				// 	particle.scale.x = particle.scale.y = 30;
+				// 	group.add( particle );
+				// }
 				
 
 				cube = new THREE.Mesh( smooth, new THREE.MeshBasicMaterial( { color: 0x405040, wireframe:true,  opacity:0.8 } ) ); //new THREE.MeshFaceMaterial()

+ 62 - 17
src/core/Geometry.js

@@ -450,19 +450,11 @@ THREE.Geometry.prototype = {
 			if ( map[ hash ] === undefined ) {
 
 				map[ hash ] = { "set": {}, "array": [] };
-				map[ hash ].set[ i ] = 1;
-				map[ hash ].array.push( i );
-
-			} else {
-
-				if( map[ hash ].set[ i ] === undefined ) {
-
-					map[ hash ].set[ i ] = 1;
-					map[ hash ].array.push( i );
-
-				}
-
-			}
+				
+			} 
+			
+			map[ hash ].set[ i ] = 1;
+			map[ hash ].array.push( i );
 
 		};
 
@@ -486,7 +478,7 @@ THREE.Geometry.prototype = {
 				hash = edge_hash( face.b, face.c );
 				addToMap( vfMap, hash, i );
 
-				hash = edge_hash( face.a, face.c );
+				hash = edge_hash( face.c, face.a );
 				addToMap( vfMap, hash, i );
 
 			} else if ( face instanceof THREE.Face4 ) {
@@ -504,14 +496,14 @@ THREE.Geometry.prototype = {
 				hash = edge_hash( face.a, face.b );
 				addToMap( vfMap, hash, i );
 
-				hash = edge_hash( face.a, face.d );
-				addToMap( vfMap, hash, i );
-
 				hash = edge_hash( face.b, face.c );
 				addToMap( vfMap, hash, i );
 
 				hash = edge_hash( face.c, face.d );
 				addToMap( vfMap, hash, i );
+				
+				hash = edge_hash( face.d, face.a );
+				addToMap( vfMap, hash, i );
 
 			}
 
@@ -553,6 +545,59 @@ THREE.Geometry.prototype = {
 		// 
 		// }
 
+	}, 
+	
+	checkDupVertices: function() {
+		var uniqueVertices = {}, patch = {};
+		var v, key;
+		var precision = 1;
+		var i,il, face;
+		
+		for (i=0,il=this.vertices.length;i<il;i++) {
+			
+			v = this.vertices[i].position;
+			//key = [v.x.toFixed(precision), v.y.toFixed(precision), v.z.toFixed(precision)].join('_');
+			key = [Math.round(v.x * 1000), Math.round(v.y* 1000), Math.round(v.z* 1000)].join('_');
+			
+			if (uniqueVertices[key]===undefined) {
+				uniqueVertices[key] = i;
+			} else {
+				//console.log('HEY ', i, 'should be using ', uniqueVertices[key]);
+				patch[i] = uniqueVertices[key];
+			}
+			
+		};
+		
+		// Start to patch.
+		//console.log(patch);
+		
+		var runPatch = function(i) {
+			if (patch[i] !== undefined) {
+				//console.log('fixing',i, 'to', patch[i]);
+				return patch[i];
+			}
+			return i;
+		};
+		for( i = 0, il = this.faces.length; i < il; i ++ ) {
+
+			face = this.faces[ i ];
+
+			if ( face instanceof THREE.Face3 ) {
+				face.a = runPatch(face.a);
+				face.b = runPatch(face.b);
+				face.c = runPatch(face.c);
+			
+			} if ( face instanceof THREE.Face4 ) {
+
+				face.a = runPatch(face.a);
+				face.b = runPatch(face.b);
+				face.c = runPatch(face.c);
+				face.d = runPatch(face.d);
+			
+			}
+		}
+		
+		//console.log(this);
 	}
 
 };

+ 0 - 248
src/extras/geometries/SubdivisonGeometry.js

@@ -1,248 +0,0 @@
-/*
- * @author zz85 / http://twitter.com/blurspline / http://www.lab4games.net/zz85/blog 
- * Smooth Geometry (SmoothMesh) using Catmull-Clark Subdivision Surfaces
- * Readings: 
- *	http://en.wikipedia.org/wiki/Catmull%E2%80%93Clark_subdivision_surface
- *	http://www.rorydriscoll.com/2008/08/01/catmull-clark-subdivision-the-basics/
- */
-// 
-THREE.SubdivisionGeometry = function( oldGeometry ) {
-	THREE.Geometry.call( this );
-
-	var scope = this;
-	
-	function v( x, y, z ) {
-		scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
-	}
-
-	function f4( a, b, c, d ) {
-		scope.faces.push( new THREE.Face4( a, b, c, d ) );
-	}
-	
-	function edge_hash( a, b ) {
-
-		return Math.min( a, b ) + "_" + Math.max( a, b );
-
-	};
-	
-	var originalPoints = oldGeometry.vertices;
-	var originalFaces = oldGeometry.faces;
-	
-	var newPoints = originalPoints.concat(); // Vertices
-		
-	var facePoints = [], edgePoints = {};
-	
-	// Step 1
-	//	For each face, add a face point
-	//	Set each face point to be the centroid of all original points for the respective face.
-	
-	var i, il, face;
-	
-	for (i=0, il = originalFaces.length; i<il ;i++) {
-		face = originalFaces[i];
-		facePoints.push(face.centroid);
-		newPoints.push( new THREE.Vertex(face.centroid) );
-	}
-
-	// Step 2
-	//	For each edge, add an edge point.
-	//	Set each edge point to be the average of the two neighbouring face points and its two original endpoints.
-	oldGeometry.computeEdgeFaces();
-	
-	var edge, faceIndexA, faceIndexB, avg;
-	var vfMap = oldGeometry.vfMap;
-	
-	// var edges = oldGeometry.edges;
-	// console.log('edges', edges.length);
-	// console.log('vfMap', vfMap);
-	
-	var edgeInfo;
-	var edgeCount = 0;
-	var originalVerticesLength = originalPoints.length;
-	var edgeVertex, edgeVertexA, edgeVertexB;
-	for (i in vfMap) {
-		edgeInfo = vfMap[i];
-		edge = edgeInfo.array;
-		faceIndexA = edge[0]; // face index a
-		faceIndexB = edge[1]; // face index b
-		
-		avg = new THREE.Vector3();
-		
-		avg.addSelf(facePoints[faceIndexA]);
-		avg.addSelf(facePoints[faceIndexB]);
-		
-		
-		edgeVertex = i.split('_');
-		edgeVertexA = edgeVertex[0];
-		edgeVertexB = edgeVertex[1];
-		
-		avg.addSelf(originalPoints[edgeVertexA].position);
-		avg.addSelf(originalPoints[edgeVertexB].position);
-		
-		
-		
-		avg.multiplyScalar(0.25);
-		
-		edgePoints[i] = originalVerticesLength + originalFaces.length + edgeCount;
-		
-		newPoints.push( new THREE.Vertex(avg) );
-	
-		edgeCount ++;
-		
-	}
-	
-	// Step 3
-	//	For each face point, add an edge for every edge of the face, 
-	//	connecting the face point to each edge point for the face.
-	
-	
-	var facePt, currentVerticeIndex;
-	
-	var hashAB, hashBC, hashCD, hashDA, hashCA;
-	
-	
-	for (i=0, il = facePoints.length; i<il ;i++) { // for every face
-		facePt = facePoints[i];
-		face = originalFaces[i];
-		currentVerticeIndex = originalVerticesLength+ i;
-		
-		if ( face instanceof THREE.Face3 ) {
-			
-			// create 3 face4s
-			
-			hashAB = edge_hash( face.a, face.b );
-			hashBC = edge_hash( face.b, face.c );
-			hashCA = edge_hash( face.c, face.a );
-
-			
-			f4( currentVerticeIndex, edgePoints[hashAB], face.b, edgePoints[hashBC]);
-			f4( currentVerticeIndex, edgePoints[hashBC], face.c, edgePoints[hashCA]);
-			f4( currentVerticeIndex, edgePoints[hashCA], face.a, edgePoints[hashAB]);
-			
-		} else if ( face instanceof THREE.Face4 ) {
-			// create 4 face4s
-			
-			hashAB = edge_hash( face.a, face.b );
-			hashBC = edge_hash( face.b, face.c );
-			hashCD = edge_hash( face.c, face.d );
-			hashDA = edge_hash( face.d, face.a );
-			
-			f4( currentVerticeIndex, edgePoints[hashAB], face.b, edgePoints[hashBC]);
-			f4( currentVerticeIndex, edgePoints[hashBC], face.c, edgePoints[hashCD]);
-			f4( currentVerticeIndex, edgePoints[hashCD], face.d, edgePoints[hashDA]);
-			f4( currentVerticeIndex, edgePoints[hashDA], face.a, edgePoints[hashAB]);
-
-				
-		} else {
-			console.log('face should be a face!', face);
-		}
-	}
-	
-	
-	scope.vertices = newPoints;
-	
-	// console.log('original ', oldGeometry.vertices.length, oldGeometry.faces.length );
-	// console.log('new points', newPoints.length, 'faces', this.faces.length );
-	
-	// Step 4
-	
-	//	For each original point P, 
-	//		take the average F of all n face points for faces touching P, 
-	//		and take the average R of all n edge midpoints for edges touching P, 
-	//		where each edge midpoint is the average of its two endpoint vertices. 
-	//	Move each original point to the point
-	
-	
-	
-	var vertexEdgeMap = {};
-	var vertexFaceMap = {};
-	
-	var addVertexEdgeMap = function(vertex, edge) {
-		if (vertexEdgeMap[vertex]===undefined) {
-			vertexEdgeMap[vertex] = [];
-		}
-		
-		vertexEdgeMap[vertex].push(edge);
-	};
-	
-	var addVertexFaceMap = function(vertex, face) {
-		if (vertexFaceMap[vertex]===undefined) {
-			vertexFaceMap[vertex] = {};
-		}
-		
-		vertexFaceMap[vertex][face] = null;
-	};
-	
-	// Prepares vertexEdgeMap and vertexFaceMap
-	for (i in vfMap) {
-		edgeInfo = vfMap[i];
-		
-		edgeVertex = i.split('_');
-		edgeVertexA = edgeVertex[0];
-		edgeVertexB = edgeVertex[1];
-		
-		addVertexEdgeMap(edgeVertexA, [edgeVertexA, edgeVertexB] );
-		addVertexEdgeMap(edgeVertexB, [edgeVertexA, edgeVertexB] );
-		
-		edge = edgeInfo.array;
-		faceIndexA = edge[0]; // face index a
-		faceIndexB = edge[1]; // face index b
-		
-		addVertexFaceMap(edgeVertexA, faceIndexA);
-		addVertexFaceMap(edgeVertexA, faceIndexB);
-		addVertexFaceMap(edgeVertexB, faceIndexA);
-		addVertexFaceMap(edgeVertexB, faceIndexB);
-		
-	}
-	
-	//console.log('vertexEdgeMap',vertexEdgeMap, 'vertexFaceMap', vertexFaceMap);
-	
-	var F = new THREE.Vector3();
-	var R = new THREE.Vector3();
-
-	var j, n;
-	for (i=0, il = originalPoints.length; i<il; i++) {
-		// (F + 2R + (n-3)P) / n
-		
-		F.set(0,0,0);
-		R.set(0,0,0);
-		var newPos =  new THREE.Vector3(0,0,0);
-		
-		var f =0;
-		for (j in vertexFaceMap[i]) {
-			F.addSelf(facePoints[j]);
-			f++;
-		}
-		
-		F.divideScalar(f);
-		
-		n = vertexEdgeMap[i].length;
-		
-		for (j=0; j<n;j++) {
-			edge = vertexEdgeMap[i][j];
-			var midPt = originalPoints[edge[0]].position.clone().addSelf(originalPoints[edge[1]].position).divideScalar(2);
-			R.addSelf(midPt);
-			// R.addSelf(originalPoints[edge[0]].position);
-			// R.addSelf(originalPoints[edge[1]].position);
-		}
-		
-		R.divideScalar(n)
-		
-		newPos.addSelf(originalPoints[i].position);
-		newPos.multiplyScalar(n - 3);
-		
-		newPos.addSelf(F);
-		newPos.addSelf(R.multiplyScalar(2));
-		newPos.divideScalar(n);
-		
-		this.vertices[i].position = newPos;
-		
-		
-	}
-	
-	this.computeCentroids();
-	this.computeFaceNormals();
-};
-
-THREE.SubdivisionGeometry.prototype = new THREE.Geometry();
-THREE.SubdivisionGeometry.prototype.constructor = THREE.SubdivisionGeometry;

+ 1 - 1
utils/build.py

@@ -102,7 +102,7 @@ EXTRAS_FILES = [
 'extras/geometries/CubeGeometry.js',
 'extras/geometries/CylinderGeometry.js',
 'extras/geometries/ExtrudeGeometry.js',
-'extras/geometries/SubdivisonGeometry.js',
+'extras/geometries/SubdivisionGeometry.js',
 'extras/geometries/IcosahedronGeometry.js',
 'extras/geometries/LatheGeometry.js',
 'extras/geometries/PlaneGeometry.js',