Browse Source

Merging with alteredq's dev.

Mr.doob 14 years ago
parent
commit
d1f5c68066

File diff suppressed because it is too large
+ 107 - 107
build/Three.js


+ 38 - 38
build/custom/ThreeCanvas.js

@@ -15,8 +15,8 @@ a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},multiplyScalar:function(a){
 setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
 THREE.Ray.prototype={intersectScene:function(a){return this.intersectObjects(a.objects)},intersectObjects:function(a){var b,c,d=[];b=0;for(c=a.length;b<c;b++)d=d.concat(this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d},intersectObject:function(a){function b(a,b,c){var d,c=c.matrixWorld.getPosition();d=c.clone().subSelf(a).dot(b);a=a.clone().addSelf(b.clone().multiplyScalar(d));return c.distanceTo(a)}function c(a,b,c,d){var d=d.clone().subSelf(b),c=c.clone().subSelf(b),
 f=a.clone().subSelf(b),a=d.dot(d),b=d.dot(c),d=d.dot(f),e=c.dot(c),c=c.dot(f),f=1/(a*e-b*b),e=(e*d-b*c)*f,a=(a*c-b*d)*f;return e>0&&a>0&&e+a<1}if(a instanceof THREE.Particle){var d=b(this.origin,this.direction,a);if(!d||d>a.scale.x)return[];return[{distance:d,point:a.position,face:null,object:a}]}else if(a instanceof THREE.Mesh){d=b(this.origin,this.direction,a);if(!d||d>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return[];var f,g,e,h,i,l,m,n,j,o,k=a.geometry,
-q=k.vertices,w=[],d=0;for(f=k.faces.length;d<f;d++)if(g=k.faces[d],j=this.origin.clone(),o=this.direction.clone(),l=a.matrixWorld,e=l.multiplyVector3(q[g.a].position.clone()),h=l.multiplyVector3(q[g.b].position.clone()),i=l.multiplyVector3(q[g.c].position.clone()),l=g instanceof THREE.Face4?l.multiplyVector3(q[g.d].position.clone()):null,m=a.matrixRotationWorld.multiplyVector3(g.normal.clone()),n=o.dot(m),a.doubleSided||(a.flipSided?n>0:n<0))if(m=m.dot((new THREE.Vector3).sub(e,j))/n,j=j.addSelf(o.multiplyScalar(m)),
-g instanceof THREE.Face3)c(j,e,h,i)&&(g={distance:this.origin.distanceTo(j),point:j,face:g,object:a},w.push(g));else if(g instanceof THREE.Face4&&(c(j,e,h,l)||c(j,h,i,l)))g={distance:this.origin.distanceTo(j),point:j,face:g,object:a},w.push(g);return w}else return[]}};
+q=k.vertices,v=[],d=0;for(f=k.faces.length;d<f;d++)if(g=k.faces[d],j=this.origin.clone(),o=this.direction.clone(),l=a.matrixWorld,e=l.multiplyVector3(q[g.a].position.clone()),h=l.multiplyVector3(q[g.b].position.clone()),i=l.multiplyVector3(q[g.c].position.clone()),l=g instanceof THREE.Face4?l.multiplyVector3(q[g.d].position.clone()):null,m=a.matrixRotationWorld.multiplyVector3(g.normal.clone()),n=o.dot(m),a.doubleSided||(a.flipSided?n>0:n<0))if(m=m.dot((new THREE.Vector3).sub(e,j))/n,j=j.addSelf(o.multiplyScalar(m)),
+g instanceof THREE.Face3)c(j,e,h,i)&&(g={distance:this.origin.distanceTo(j),point:j,face:g,object:a},v.push(g));else if(g instanceof THREE.Face4&&(c(j,e,h,l)||c(j,h,i,l)))g={distance:this.origin.distanceTo(j),point:j,face:g,object:a},v.push(g);return v}else return[]}};
 THREE.Rectangle=function(){function a(){g=d-b;e=f-c}var b,c,d,f,g,e,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return e};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(e,g,m,n){h=!1;b=e;c=g;d=m;f=n;a()};this.addPoint=function(e,g){h?(h=!1,b=e,c=g,d=e,f=g):(b=b<e?b:e,c=c<g?c:g,d=d>e?d:e,f=f>g?f:g);a()};this.add3Points=
 function(e,g,m,n,j,o){h?(h=!1,b=e<m?e<j?e:j:m<j?m:j,c=g<n?g<o?g:o:n<o?n:o,d=e>m?e>j?e:j:m>j?m:j,f=g>n?g>o?g:o:n>o?n:o):(b=e<m?e<j?e<b?e:b:j<b?j:b:m<j?m<b?m:b:j<b?j:b,c=g<n?g<o?g<c?g:c:o<c?o:c:n<o?n<c?n:c:o<c?o:c,d=e>m?e>j?e>d?e:d:j>d?j:d:m>j?m>d?m:d:j>d?j:d,f=g>n?g>o?g>f?g:f:o>f?o:f:n>o?n>f?n:f:o>f?o:f);a()};this.addRectangle=function(e){h?(h=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),f=e.getBottom()):(b=b<e.getLeft()?b:e.getLeft(),c=c<e.getTop()?c:e.getTop(),d=d>e.getRight()?d:e.getRight(),f=f>
 e.getBottom()?f:e.getBottom());a()};this.inflate=function(e){b-=e;c-=e;d+=e;f+=e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d<e.getRight()?d:e.getRight();f=f<e.getBottom()?f:e.getBottom();a()};this.instersects=function(a){return Math.min(d,a.getRight())-Math.max(b,a.getLeft())>=0&&Math.min(f,a.getBottom())-Math.max(c,a.getTop())>=0};this.empty=function(){h=!0;f=d=c=b=0;a()};this.isEmpty=function(){return h}};THREE.Matrix3=function(){this.m=[]};
@@ -24,8 +24,8 @@ THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[
 THREE.Matrix4.prototype={set:function(a,b,c,d,f,g,e,h,i,l,m,n,j,o,k,q){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=g;this.n23=e;this.n24=h;this.n31=i;this.n32=l;this.n33=m;this.n34=n;this.n41=j;this.n42=o;this.n43=k;this.n44=q;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__v1,
 f=THREE.Matrix4.__v2,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(g.length()===0)g.z=1;d.cross(c,g).normalize();d.length()===0&&(g.x+=1.0E-4,d.cross(c,g).normalize());f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f;a.y=(this.n21*b+this.n22*c+this.n23*
 d+this.n24)*f;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();
-return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,e=a.n21,h=a.n22,i=a.n23,l=a.n24,m=a.n31,n=a.n32,j=a.n33,o=a.n34,k=a.n41,q=a.n42,w=a.n43,s=a.n44,J=b.n11,N=b.n12,v=b.n13,B=b.n14,p=b.n21,O=b.n22,
-r=b.n23,u=b.n24,y=b.n31,R=b.n32,aa=b.n33,$=b.n34,C=b.n41,F=b.n42,L=b.n43,D=b.n44;this.n11=c*J+d*p+f*y+g*C;this.n12=c*N+d*O+f*R+g*F;this.n13=c*v+d*r+f*aa+g*L;this.n14=c*B+d*u+f*$+g*D;this.n21=e*J+h*p+i*y+l*C;this.n22=e*N+h*O+i*R+l*F;this.n23=e*v+h*r+i*aa+l*L;this.n24=e*B+h*u+i*$+l*D;this.n31=m*J+n*p+j*y+o*C;this.n32=m*N+n*O+j*R+o*F;this.n33=m*v+n*r+j*aa+o*L;this.n34=m*B+n*u+j*$+o*D;this.n41=k*J+q*p+w*y+s*C;this.n42=k*N+q*O+w*R+s*F;this.n43=k*v+q*r+w*aa+s*L;this.n44=k*B+q*u+w*$+s*D;return this},multiplyToArray:function(a,
+return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,e=a.n21,h=a.n22,i=a.n23,l=a.n24,m=a.n31,n=a.n32,j=a.n33,o=a.n34,k=a.n41,q=a.n42,v=a.n43,s=a.n44,J=b.n11,N=b.n12,x=b.n13,B=b.n14,p=b.n21,O=b.n22,
+r=b.n23,u=b.n24,y=b.n31,R=b.n32,aa=b.n33,$=b.n34,C=b.n41,F=b.n42,L=b.n43,D=b.n44;this.n11=c*J+d*p+f*y+g*C;this.n12=c*N+d*O+f*R+g*F;this.n13=c*x+d*r+f*aa+g*L;this.n14=c*B+d*u+f*$+g*D;this.n21=e*J+h*p+i*y+l*C;this.n22=e*N+h*O+i*R+l*F;this.n23=e*x+h*r+i*aa+l*L;this.n24=e*B+h*u+i*$+l*D;this.n31=m*J+n*p+j*y+o*C;this.n32=m*N+n*O+j*R+o*F;this.n33=m*x+n*r+j*aa+o*L;this.n34=m*B+n*u+j*$+o*D;this.n41=k*J+q*p+v*y+s*C;this.n42=k*N+q*O+v*R+s*F;this.n43=k*x+q*r+v*aa+s*L;this.n44=k*B+q*u+v*$+s*D;return this},multiplyToArray:function(a,
 b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){this.multiply(this,a);return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=
 a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,g=this.n22,e=this.n23,h=this.n24,i=this.n31,l=this.n32,m=this.n33,n=this.n34,j=this.n41,o=this.n42,k=this.n43,q=this.n44;return d*e*l*j-c*h*l*j-d*g*m*j+b*h*m*j+c*g*n*j-b*e*n*j-d*e*i*o+c*h*i*o+d*f*m*o-a*h*m*o-c*f*n*o+a*e*n*o+d*g*i*k-b*h*i*k-d*f*l*k+a*h*l*k+b*f*n*k-a*g*n*k-c*g*i*q+b*e*i*q+c*f*l*q-a*e*l*q-b*f*m*q+a*g*m*q},transpose:function(){var a;a=this.n21;this.n21=
 this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=
@@ -38,8 +38,8 @@ m*c-l;this.n13=g*d;this.n21=g*f;this.n22=g*h;this.n23=-c;this.n31=l*c-m;this.n32
 m*f+l;this.n21=f;this.n22=g*h;this.n23=-c*h;this.n31=-d*h;this.n32=l*f+m;this.n33=i-n*f;break;case "XZY":i=g*e;l=g*d;m=c*e;n=c*d;this.n11=e*h;this.n12=-f;this.n13=d*h;this.n21=i*f+n;this.n22=g*h;this.n23=l*f-m;this.n31=m*f-l;this.n32=c*h;this.n33=n*f+i;break;default:i=g*h,l=g*f,m=c*h,n=c*f,this.n11=e*h,this.n12=-e*f,this.n13=d,this.n21=l+m*d,this.n22=i-n*d,this.n23=-c*e,this.n31=n-i*d,this.n32=m+l*d,this.n33=g*e}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,f=a.w,g=b+b,
 e=c+c,h=d+d,a=b*g,i=b*e;b*=h;var l=c*e;c*=h;d*=h;g*=f;e*=f;f*=h;this.n11=1-(l+d);this.n12=i-f;this.n13=b+e;this.n21=i+f;this.n22=1-(a+d);this.n23=c-g;this.n31=b-e;this.n32=c+g;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34},extractRotation:function(a,
 b){var c=1/b.x,d=1/b.y,f=1/b.z;this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*f;this.n23=a.n23*f;this.n33=a.n33*f}};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,e=a.n21,h=a.n22,i=a.n23,l=a.n24,m=a.n31,n=a.n32,j=a.n33,o=a.n34,k=a.n41,q=a.n42,w=a.n43,s=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=i*o*q-l*j*q+l*n*w-h*o*w-i*n*s+h*j*s;b.n12=g*j*q-f*o*q-g*n*w+d*o*w+f*n*s-d*j*s;b.n13=f*l*q-g*i*q+g*h*w-d*l*w-f*h*s+d*i*s;b.n14=g*i*n-f*l*n-g*h*j+d*l*j+f*h*o-d*i*o;b.n21=l*j*k-i*o*k-l*m*w+e*o*w+i*m*s-e*j*s;b.n22=f*o*k-g*j*k+g*m*w-c*o*w-f*m*s+c*j*s;b.n23=g*i*k-f*l*k-g*e*w+c*l*w+f*e*s-c*i*s;b.n24=
-f*l*m-g*i*m+g*e*j-c*l*j-f*e*o+c*i*o;b.n31=h*o*k-l*n*k+l*m*q-e*o*q-h*m*s+e*n*s;b.n32=g*n*k-d*o*k-g*m*q+c*o*q+d*m*s-c*n*s;b.n33=f*l*k-g*h*k+g*e*q-c*l*q-d*e*s+c*h*s;b.n34=g*h*m-d*l*m-g*e*n+c*l*n+d*e*o-c*h*o;b.n41=i*n*k-h*j*k-i*m*q+e*j*q+h*m*w-e*n*w;b.n42=d*j*k-f*n*k+f*m*q-c*j*q-d*m*w+c*n*w;b.n43=f*h*k-d*i*k-f*e*q+c*i*q+d*e*w-c*h*w;b.n44=d*i*m-f*h*m+f*e*n-c*i*n-d*e*j+c*h*j;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,e=a.n21,h=a.n22,i=a.n23,l=a.n24,m=a.n31,n=a.n32,j=a.n33,o=a.n34,k=a.n41,q=a.n42,v=a.n43,s=a.n44;b===void 0&&(b=new THREE.Matrix4);b.n11=i*o*q-l*j*q+l*n*v-h*o*v-i*n*s+h*j*s;b.n12=g*j*q-f*o*q-g*n*v+d*o*v+f*n*s-d*j*s;b.n13=f*l*q-g*i*q+g*h*v-d*l*v-f*h*s+d*i*s;b.n14=g*i*n-f*l*n-g*h*j+d*l*j+f*h*o-d*i*o;b.n21=l*j*k-i*o*k-l*m*v+e*o*v+i*m*s-e*j*s;b.n22=f*o*k-g*j*k+g*m*v-c*o*v-f*m*s+c*j*s;b.n23=g*i*k-f*l*k-g*e*v+c*l*v+f*e*s-c*i*s;b.n24=
+f*l*m-g*i*m+g*e*j-c*l*j-f*e*o+c*i*o;b.n31=h*o*k-l*n*k+l*m*q-e*o*q-h*m*s+e*n*s;b.n32=g*n*k-d*o*k-g*m*q+c*o*q+d*m*s-c*n*s;b.n33=f*l*k-g*h*k+g*e*q-c*l*q-d*e*s+c*h*s;b.n34=g*h*m-d*l*m-g*e*n+c*l*n+d*e*o-c*h*o;b.n41=i*n*k-h*j*k-i*m*q+e*j*q+h*m*v-e*n*v;b.n42=d*j*k-f*n*k+f*m*q-c*j*q-d*m*v+c*n*v;b.n43=f*h*k-d*i*k-f*e*q+c*i*q+d*e*v-c*h*v;b.n44=d*i*m-f*h*m+f*e*n-c*i*n-d*e*j+c*h*j;b.multiplyScalar(1/a.determinant());return b};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,e=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,i=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,m=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*e+a.n31*l;a==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*e;c[4]=a*h;c[5]=a*i;c[6]=a*l;c[7]=a*m;c[8]=a*n;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,f,g){var e;e=new THREE.Matrix4;e.n11=2*f/(b-a);e.n12=0;e.n13=(b+a)/(b-a);e.n14=0;e.n21=0;e.n22=2*f/(d-c);e.n23=(d+c)/(d-c);e.n24=0;e.n31=0;e.n32=0;e.n33=-(g+f)/(g-f);e.n34=-2*g*f/(g-f);e.n41=0;e.n42=0;e.n43=-1;e.n44=0;return e};THREE.Matrix4.makePerspective=function(a,b,c,d){var f,a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)};
 THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var e,h,i,l;e=new THREE.Matrix4;h=b-a;i=c-d;l=g-f;e.n11=2/h;e.n12=0;e.n13=0;e.n14=-((b+a)/h);e.n21=0;e.n22=2/i;e.n23=0;e.n24=-((c+d)/i);e.n31=0;e.n32=0;e.n33=-2/l;e.n34=-((g+f)/l);e.n41=0;e.n42=0;e.n43=0;e.n44=1;return e};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
@@ -53,7 +53,7 @@ THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;thi
 d;this.z=a.z*d;this.w=Math.cos(c);return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);a==0?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},
 multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,g=a.x,e=a.y,h=a.z,a=a.w;this.x=b*a+f*g+c*h-d*e;this.y=c*a+f*e+d*g-b*h;this.z=d*a+f*h+b*e-c*g;this.w=f*a-b*g-c*e-d*h;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,e=this.y,h=this.z,i=this.w,l=i*c+e*f-h*d,m=
 i*d+h*c-g*f,n=i*f+g*d-e*c,c=-g*c-e*d-h*f;b.x=l*i+c*-g+m*-h-n*-e;b.y=m*i+c*-e+n*-g-l*-h;b.z=n*i+c*-h+l*-e-m*-g;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.001)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;f=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1)return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(f),e=Math.sqrt(1-f*f);if(Math.abs(e)<0.0010)return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;f=Math.sin((1-d)*g)/e;d=Math.sin(d*g)/e;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,d,f,g){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,f,g,e){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=e instanceof Array?e:[e];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.edges=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
@@ -61,8 +61,8 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.f
 c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(a){var b,c,d,f,g,e,h=new THREE.Vector3,i=new THREE.Vector3;d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];if(a&&g.vertexNormals.length){h.set(0,0,0);b=0;for(c=g.vertexNormals.length;b<c;b++)h.addSelf(g.vertexNormals[b]);h.divideScalar(3)}else b=this.vertices[g.a],c=this.vertices[g.b],e=this.vertices[g.c],h.sub(e.position,c.position),i.sub(b.position,c.position),h.crossSelf(i);h.isZero()||
 h.normalize();g.normal.copy(h)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==void 0){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++)if(c=this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=
 this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),
-c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,f,g,r){h=a.vertices[b].position;i=a.vertices[c].position;l=a.vertices[d].position;m=e[f];n=e[g];j=e[r];o=i.x-h.x;k=l.x-h.x;q=i.y-h.y;w=l.y-h.y;s=i.z-h.z;J=l.z-h.z;N=n.u-m.u;v=j.u-m.u;B=n.v-m.v;p=j.v-m.v;O=1/(N*p-v*B);R.set((p*o-B*k)*
-O,(p*q-B*w)*O,(p*s-B*J)*O);aa.set((N*k-v*o)*O,(N*w-v*q)*O,(N*J-v*s)*O);u[b].addSelf(R);u[c].addSelf(R);u[d].addSelf(R);y[b].addSelf(aa);y[c].addSelf(aa);y[d].addSelf(aa)}var b,c,d,f,g,e,h,i,l,m,n,j,o,k,q,w,s,J,N,v,B,p,O,r,u=[],y=[],R=new THREE.Vector3,aa=new THREE.Vector3,$=new THREE.Vector3,C=new THREE.Vector3,F=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)u[b]=new THREE.Vector3,y[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)g=this.faces[b],e=this.faceVertexUvs[0][b],g instanceof
+c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,b,c,d,f,g,r){h=a.vertices[b].position;i=a.vertices[c].position;l=a.vertices[d].position;m=e[f];n=e[g];j=e[r];o=i.x-h.x;k=l.x-h.x;q=i.y-h.y;v=l.y-h.y;s=i.z-h.z;J=l.z-h.z;N=n.u-m.u;x=j.u-m.u;B=n.v-m.v;p=j.v-m.v;O=1/(N*p-x*B);R.set((p*o-B*k)*
+O,(p*q-B*v)*O,(p*s-B*J)*O);aa.set((N*k-x*o)*O,(N*v-x*q)*O,(N*J-x*s)*O);u[b].addSelf(R);u[c].addSelf(R);u[d].addSelf(R);y[b].addSelf(aa);y[c].addSelf(aa);y[d].addSelf(aa)}var b,c,d,f,g,e,h,i,l,m,n,j,o,k,q,v,s,J,N,x,B,p,O,r,u=[],y=[],R=new THREE.Vector3,aa=new THREE.Vector3,$=new THREE.Vector3,C=new THREE.Vector3,F=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++)u[b]=new THREE.Vector3,y[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)g=this.faces[b],e=this.faceVertexUvs[0][b],g instanceof
 THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):g instanceof THREE.Face4&&(a(this,g.a,g.b,g.c,0,1,2),a(this,g.a,g.b,g.d,0,1,3));var L=["a","b","c","d"];b=0;for(c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++)F.copy(g.vertexNormals[d]),f=g[L[d]],r=u[f],$.copy(r),$.subSelf(F.multiplyScalar(F.dot(r))).normalize(),C.cross(g.vertexNormals[d],r),f=C.dot(y[f]),f=f<0?-1:1,g.vertexTangents[d]=new THREE.Vector4($.x,$.y,$.z,f)}this.hasTangents=!0},computeBoundingBox:function(){var a;
 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 b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;
 else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=0,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},computeEdgeFaces:function(){function a(a,b){return Math.min(a,b)+"_"+Math.max(a,b)}function b(a,b,c){a[b]===
@@ -104,42 +104,42 @@ b,c)};THREE.Bone.prototype.addChild=function(a){if(this.children.indexOf(a)===-1
 THREE.Scene.prototype.supr=THREE.Object3D.prototype;THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&this.objects.indexOf(a)===-1)this.objects.push(a),this.__objectsAdded.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),b!==-1&&(this.objects.splice(b,1),this.__objectsRemoved.push(a)));for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(){var a=i[h]=i[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return e>=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,f,g=[],e,h,i=[],l,m,n=[],j,o=[],k,q,w=[],s,J,N=[],v=new THREE.Vector4,B=new THREE.Vector4,
+THREE.Projector=function(){function a(){var a=i[h]=i[h]||new THREE.RenderableVertex;h++;return a}function b(a,b){return b.z-a.z}function c(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;return e>=0&&f>=0&&g>=0&&h>=0?!0:e<0&&f<0||g<0&&h<0?!1:(e<0?c=Math.max(c,e/(e-f)):f<0&&(d=Math.min(d,e/(e-f))),g<0?c=Math.max(c,g/(g-h)):h<0&&(d=Math.min(d,g/(g-h))),d<c?!1:(a.lerpSelf(b,c),b.lerpSelf(a,1-d),!0))}var d,f,g=[],e,h,i=[],l,m,n=[],j,o=[],k,q,v=[],s,J,N=[],x=new THREE.Vector4,B=new THREE.Vector4,
 p=new THREE.Matrix4,O=new THREE.Matrix4,r=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],u=new THREE.Vector4,y=new THREE.Vector4;this.projectVector=function(a,b){p.multiply(b.projectionMatrix,b.matrixWorldInverse);p.multiplyVector3(a);return a};this.unprojectVector=function(a,b){p.multiply(b.matrixWorld,THREE.Matrix4.makeInvert(b.projectionMatrix));p.multiplyVector3(a);return a};this.projectObjects=function(a,c,e){var c=[],h,l,k;f=0;l=
-a.objects;a=0;for(h=l.length;a<h;a++){k=l[a];var i;if(!(i=!k.visible))if(i=k instanceof THREE.Mesh){a:{i=void 0;for(var j=k.matrixWorld,m=-k.geometry.boundingSphere.radius*Math.max(k.scale.x,Math.max(k.scale.y,k.scale.z)),n=0;n<6;n++)if(i=r[n].x*j.n14+r[n].y*j.n24+r[n].z*j.n34+r[n].w,i<=m){i=!1;break a}i=!0}i=!i}if(!i)i=g[f]=g[f]||new THREE.RenderableObject,f++,d=i,v.copy(k.position),p.multiplyVector3(v),d.object=k,d.z=v.z,c.push(d)}e&&c.sort(b);return c};this.projectScene=function(d,f,g){var C=[],
-F=f.near,L=f.far,D,G,z,P,x,M,K,v,V,t,H,E,I,S,W,da,X;J=q=j=m=0;f.matrixAutoUpdate&&f.update(void 0,!0);d.update(void 0,!1,f);p.multiply(f.projectionMatrix,f.matrixWorldInverse);r[0].set(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);r[1].set(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);r[2].set(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);r[3].set(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);r[4].set(p.n41-p.n31,p.n42-p.n32,p.n43-p.n33,p.n44-p.n34);r[5].set(p.n41+p.n31,p.n42+p.n32,p.n43+
-p.n33,p.n44+p.n34);for(D=0;D<6;D++)V=r[D],V.divideScalar(Math.sqrt(V.x*V.x+V.y*V.y+V.z*V.z));V=this.projectObjects(d,f,!0);d=0;for(D=V.length;d<D;d++)if(t=V[d].object,t.visible)if(H=t.matrixWorld,E=t.matrixRotationWorld,I=t.materials,S=t.overdraw,h=0,t instanceof THREE.Mesh){W=t.geometry;P=W.vertices;da=W.faces;W=W.faceVertexUvs;G=0;for(z=P.length;G<z;G++)e=a(),e.positionWorld.copy(P[G].position),H.multiplyVector3(e.positionWorld),e.positionScreen.copy(e.positionWorld),p.multiplyVector4(e.positionScreen),
-e.positionScreen.x/=e.positionScreen.w,e.positionScreen.y/=e.positionScreen.w,e.visible=e.positionScreen.z>F&&e.positionScreen.z<L;P=0;for(G=da.length;P<G;P++){z=da[P];if(z instanceof THREE.Face3)if(x=i[z.a],M=i[z.b],K=i[z.c],x.visible&&M.visible&&K.visible&&(t.doubleSided||t.flipSided!=(K.positionScreen.x-x.positionScreen.x)*(M.positionScreen.y-x.positionScreen.y)-(K.positionScreen.y-x.positionScreen.y)*(M.positionScreen.x-x.positionScreen.x)<0))v=n[m]=n[m]||new THREE.RenderableFace3,m++,l=v,l.v1.copy(x),
-l.v2.copy(M),l.v3.copy(K);else continue;else if(z instanceof THREE.Face4)if(x=i[z.a],M=i[z.b],K=i[z.c],v=i[z.d],x.visible&&M.visible&&K.visible&&v.visible&&(t.doubleSided||t.flipSided!=((v.positionScreen.x-x.positionScreen.x)*(M.positionScreen.y-x.positionScreen.y)-(v.positionScreen.y-x.positionScreen.y)*(M.positionScreen.x-x.positionScreen.x)<0||(M.positionScreen.x-K.positionScreen.x)*(v.positionScreen.y-K.positionScreen.y)-(M.positionScreen.y-K.positionScreen.y)*(v.positionScreen.x-K.positionScreen.x)<
-0)))X=o[j]=o[j]||new THREE.RenderableFace4,j++,l=X,l.v1.copy(x),l.v2.copy(M),l.v3.copy(K),l.v4.copy(v);else continue;l.normalWorld.copy(z.normal);E.multiplyVector3(l.normalWorld);l.centroidWorld.copy(z.centroid);H.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);p.multiplyVector3(l.centroidScreen);K=z.vertexNormals;x=0;for(M=K.length;x<M;x++)v=l.vertexNormalsWorld[x],v.copy(K[x]),E.multiplyVector3(v);x=0;for(M=W.length;x<M;x++)if(X=W[x][P]){K=0;for(v=X.length;K<v;K++)l.uvs[x][K]=
-X[K]}l.meshMaterials=I;l.faceMaterials=z.materials;l.overdraw=S;l.z=l.centroidScreen.z;C.push(l)}}else if(t instanceof THREE.Line){O.multiply(p,H);P=t.geometry.vertices;x=a();x.positionScreen.copy(P[0].position);O.multiplyVector4(x.positionScreen);G=1;for(z=P.length;G<z;G++)if(x=a(),x.positionScreen.copy(P[G].position),O.multiplyVector4(x.positionScreen),M=i[h-2],u.copy(x.positionScreen),y.copy(M.positionScreen),c(u,y))u.multiplyScalar(1/u.w),y.multiplyScalar(1/y.w),H=w[q]=w[q]||new THREE.RenderableLine,
+a.objects;a=0;for(h=l.length;a<h;a++){k=l[a];var i;if(!(i=!k.visible))if(i=k instanceof THREE.Mesh){a:{i=void 0;for(var j=k.matrixWorld,m=-k.geometry.boundingSphere.radius*Math.max(k.scale.x,Math.max(k.scale.y,k.scale.z)),n=0;n<6;n++)if(i=r[n].x*j.n14+r[n].y*j.n24+r[n].z*j.n34+r[n].w,i<=m){i=!1;break a}i=!0}i=!i}if(!i)i=g[f]=g[f]||new THREE.RenderableObject,f++,d=i,x.copy(k.position),p.multiplyVector3(x),d.object=k,d.z=x.z,c.push(d)}e&&c.sort(b);return c};this.projectScene=function(d,f,g){var C=[],
+F=f.near,L=f.far,D,G,z,P,w,M,K,S,x,t,H,E,I,T,W,da,X;J=q=j=m=0;f.matrixAutoUpdate&&f.update(void 0,!0);d.update(void 0,!1,f);p.multiply(f.projectionMatrix,f.matrixWorldInverse);r[0].set(p.n41-p.n11,p.n42-p.n12,p.n43-p.n13,p.n44-p.n14);r[1].set(p.n41+p.n11,p.n42+p.n12,p.n43+p.n13,p.n44+p.n14);r[2].set(p.n41+p.n21,p.n42+p.n22,p.n43+p.n23,p.n44+p.n24);r[3].set(p.n41-p.n21,p.n42-p.n22,p.n43-p.n23,p.n44-p.n24);r[4].set(p.n41-p.n31,p.n42-p.n32,p.n43-p.n33,p.n44-p.n34);r[5].set(p.n41+p.n31,p.n42+p.n32,p.n43+
+p.n33,p.n44+p.n34);for(D=0;D<6;D++)x=r[D],x.divideScalar(Math.sqrt(x.x*x.x+x.y*x.y+x.z*x.z));x=this.projectObjects(d,f,!0);d=0;for(D=x.length;d<D;d++)if(t=x[d].object,t.visible)if(H=t.matrixWorld,E=t.matrixRotationWorld,I=t.materials,T=t.overdraw,h=0,t instanceof THREE.Mesh){W=t.geometry;P=W.vertices;da=W.faces;W=W.faceVertexUvs;G=0;for(z=P.length;G<z;G++)e=a(),e.positionWorld.copy(P[G].position),H.multiplyVector3(e.positionWorld),e.positionScreen.copy(e.positionWorld),p.multiplyVector4(e.positionScreen),
+e.positionScreen.x/=e.positionScreen.w,e.positionScreen.y/=e.positionScreen.w,e.visible=e.positionScreen.z>F&&e.positionScreen.z<L;P=0;for(G=da.length;P<G;P++){z=da[P];if(z instanceof THREE.Face3)if(w=i[z.a],M=i[z.b],K=i[z.c],w.visible&&M.visible&&K.visible&&(t.doubleSided||t.flipSided!=(K.positionScreen.x-w.positionScreen.x)*(M.positionScreen.y-w.positionScreen.y)-(K.positionScreen.y-w.positionScreen.y)*(M.positionScreen.x-w.positionScreen.x)<0))S=n[m]=n[m]||new THREE.RenderableFace3,m++,l=S,l.v1.copy(w),
+l.v2.copy(M),l.v3.copy(K);else continue;else if(z instanceof THREE.Face4)if(w=i[z.a],M=i[z.b],K=i[z.c],S=i[z.d],w.visible&&M.visible&&K.visible&&S.visible&&(t.doubleSided||t.flipSided!=((S.positionScreen.x-w.positionScreen.x)*(M.positionScreen.y-w.positionScreen.y)-(S.positionScreen.y-w.positionScreen.y)*(M.positionScreen.x-w.positionScreen.x)<0||(M.positionScreen.x-K.positionScreen.x)*(S.positionScreen.y-K.positionScreen.y)-(M.positionScreen.y-K.positionScreen.y)*(S.positionScreen.x-K.positionScreen.x)<
+0)))X=o[j]=o[j]||new THREE.RenderableFace4,j++,l=X,l.v1.copy(w),l.v2.copy(M),l.v3.copy(K),l.v4.copy(S);else continue;l.normalWorld.copy(z.normal);E.multiplyVector3(l.normalWorld);l.centroidWorld.copy(z.centroid);H.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);p.multiplyVector3(l.centroidScreen);K=z.vertexNormals;w=0;for(M=K.length;w<M;w++)S=l.vertexNormalsWorld[w],S.copy(K[w]),E.multiplyVector3(S);w=0;for(M=W.length;w<M;w++)if(X=W[w][P]){K=0;for(S=X.length;K<S;K++)l.uvs[w][K]=
+X[K]}l.meshMaterials=I;l.faceMaterials=z.materials;l.overdraw=T;l.z=l.centroidScreen.z;C.push(l)}}else if(t instanceof THREE.Line){O.multiply(p,H);P=t.geometry.vertices;w=a();w.positionScreen.copy(P[0].position);O.multiplyVector4(w.positionScreen);G=1;for(z=P.length;G<z;G++)if(w=a(),w.positionScreen.copy(P[G].position),O.multiplyVector4(w.positionScreen),M=i[h-2],u.copy(w.positionScreen),y.copy(M.positionScreen),c(u,y))u.multiplyScalar(1/u.w),y.multiplyScalar(1/y.w),H=v[q]=v[q]||new THREE.RenderableLine,
 q++,k=H,k.v1.positionScreen.copy(u),k.v2.positionScreen.copy(y),k.z=Math.max(u.z,y.z),k.materials=t.materials,C.push(k)}else if(t instanceof THREE.Particle&&(B.set(t.matrixWorld.n14,t.matrixWorld.n24,t.matrixWorld.n34,1),p.multiplyVector4(B),B.z/=B.w,B.z>0&&B.z<1))H=N[J]=N[J]||new THREE.RenderableParticle,J++,s=H,s.x=B.x/B.w,s.y=B.y/B.w,s.z=B.z,s.rotation=t.rotation.z,s.scale.x=t.scale.x*Math.abs(s.x-(B.x+f.projectionMatrix.n11)/(B.w+f.projectionMatrix.n14)),s.scale.y=t.scale.y*Math.abs(s.y-(B.y+
 f.projectionMatrix.n22)/(B.w+f.projectionMatrix.n24)),s.materials=t.materials,C.push(s);g&&C.sort(b);return C}};
-THREE.CanvasRenderer=function(a){function b(a){if(s!=a)k.globalAlpha=s=a}function c(a){if(J!=a){switch(a){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}J=a}}function d(a){if(N!=a.hex)N=a.hex,k.strokeStyle="#"+g(N.toString(16))}function f(a){if(v!=a.hex)v=a.hex,k.fillStyle="#"+g(v.toString(16))}function g(a){for(;a.length<6;)a="0"+a;return a}
-var e=this,h=null,i=new THREE.Projector,a=a||{},l=a.canvas!==void 0?a.canvas:document.createElement("canvas"),m,n,j,o,k=l.getContext("2d"),q=new THREE.Color(0),w=0,s=1,J=0,N=null,v=null,B=null,p=null,O=null,r,u,y,R,aa=new THREE.RenderableVertex,$=new THREE.RenderableVertex,C,F,L,D,G,z,P,x,M,K,oa,V,t=new THREE.Color(0),H=new THREE.Color(0),E=new THREE.Color(0),I=new THREE.Color(0),S=new THREE.Color(0),W,da,X,ba,Ba,Ca,Da,Ea,Fa,Ga,ka=new THREE.Rectangle,Y=new THREE.Rectangle,U=new THREE.Rectangle,ya=
+THREE.CanvasRenderer=function(a){function b(a){if(s!=a)k.globalAlpha=s=a}function c(a){if(J!=a){switch(a){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}J=a}}function d(a){if(N!=a.hex)N=a.hex,k.strokeStyle="#"+g(N.toString(16))}function f(a){if(x!=a.hex)x=a.hex,k.fillStyle="#"+g(x.toString(16))}function g(a){for(;a.length<6;)a="0"+a;return a}
+var e=this,h=null,i=new THREE.Projector,a=a||{},l=a.canvas!==void 0?a.canvas:document.createElement("canvas"),m,n,j,o,k=l.getContext("2d"),q=new THREE.Color(0),v=0,s=1,J=0,N=null,x=null,B=null,p=null,O=null,r,u,y,R,aa=new THREE.RenderableVertex,$=new THREE.RenderableVertex,C,F,L,D,G,z,P,w,M,K,S,oa,t=new THREE.Color(0),H=new THREE.Color(0),E=new THREE.Color(0),I=new THREE.Color(0),T=new THREE.Color(0),W,da,X,ba,Ba,Ca,Da,Ea,Fa,Ga,ka=new THREE.Rectangle,Y=new THREE.Rectangle,V=new THREE.Rectangle,ya=
 !1,ca=new THREE.Color,Z=new THREE.Color,sa=new THREE.Color,ta=new THREE.Color,Q=new THREE.Vector3,pa,qa,za,ea,ra,ua,a=16;pa=document.createElement("canvas");pa.width=pa.height=2;qa=pa.getContext("2d");qa.fillStyle="rgba(0,0,0,1)";qa.fillRect(0,0,2,2);za=qa.getImageData(0,0,2,2);ea=za.data;ra=document.createElement("canvas");ra.width=ra.height=a;ua=ra.getContext("2d");ua.translate(-a/2,-a/2);ua.scale(a,a);a--;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=!0;this.data={vertices:0,
-faces:0};this.setSize=function(a,b){m=a;n=b;j=m/2;o=n/2;l.width=m;l.height=n;ka.set(-j,-o,j,o);Y.set(-j,-o,j,o);s=1;J=0;O=p=B=v=N=null};this.setClearColor=function(a,b){q=a;w=b;Y.set(-j,-o,j,o)};this.setClearColorHex=function(a,b){q.setHex(a);w=b;Y.set(-j,-o,j,o)};this.clear=function(){k.setTransform(1,0,0,-1,j,o);if(!Y.isEmpty())Y.inflate(1),Y.minSelf(ka),w==0?k.clearRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight()):(c(THREE.NormalBlending),b(1),v="rgba("+Math.floor(q.r*255)+","+Math.floor(q.g*
-255)+","+Math.floor(q.b*255)+","+w+")",k.fillStyle=v,k.fillRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight())),Y.empty()};this.render=function(a,g){function l(a){var b,c,d,f=a.lights;Z.setRGB(0,0,0);sa.setRGB(0,0,0);ta.setRGB(0,0,0);a=0;for(b=f.length;a<b;a++)c=f[a],d=c.color,c instanceof THREE.AmbientLight?(Z.r+=d.r,Z.g+=d.g,Z.b+=d.b):c instanceof THREE.DirectionalLight?(sa.r+=d.r,sa.g+=d.g,sa.b+=d.b):c instanceof THREE.PointLight&&(ta.r+=d.r,ta.g+=d.g,ta.b+=d.b)}function m(a,b,c,d){var f,e,g,h,
-l=a.lights,a=0;for(f=l.length;a<f;a++)e=l[a],g=e.color,e instanceof THREE.DirectionalLight?(h=c.dot(e.position),h<=0||(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)):e instanceof THREE.PointLight&&(h=c.dot(Q.sub(e.position,b).normalize()),h<=0||(h*=e.distance==0?1:1-Math.min(b.distanceTo(e.position)/e.distance,1),h!=0&&(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)))}function n(a,e,g){b(g.opacity);c(g.blending);var h,l,i,m,Aa,p;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)m=g.map.image,
-Aa=m.width>>1,p=m.height>>1,g=e.scale.x*j,i=e.scale.y*o,h=g*Aa,l=i*p,U.set(a.x-h,a.y-l,a.x+h,a.y+l),ka.instersects(U)&&(k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(g,-i),k.translate(-Aa,-p),k.drawImage(m,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=e.scale.x*j,l=e.scale.y*o,U.set(a.x-h,a.y-l,a.x+h,a.y+l),ka.instersects(U)&&(d(g.color),f(g.color),k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(h,l),g.program(k),k.restore()))}function q(a,e,f,g){b(g.opacity);
-c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(B!=a)k.lineWidth=B=a;a=g.linecap;if(p!=a)k.lineCap=p=a;a=g.linejoin;if(O!=a)k.lineJoin=O=a;d(g.color);k.stroke();U.inflate(g.linewidth*2)}}function s(a,d,f,h,l,i,k,j,n){e.data.vertices+=3;e.data.faces++;b(j.opacity);c(j.blending);C=a.positionScreen.x;F=a.positionScreen.y;L=d.positionScreen.x;D=d.positionScreen.y;
-G=f.positionScreen.x;z=f.positionScreen.y;v(C,F,L,D,G,z);if(j instanceof THREE.MeshBasicMaterial)if(j.map)j.map.mapping instanceof THREE.UVMapping&&(ba=k.uvs[0],ga(C,F,L,D,G,z,j.map.image,ba[h].u,ba[h].v,ba[l].u,ba[l].v,ba[i].u,ba[i].v));else if(j.envMap){if(j.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=g.matrixWorldInverse,Q.copy(k.vertexNormalsWorld[0]),Ba=(Q.x*a.n11+Q.y*a.n12+Q.z*a.n13)*0.5+0.5,Ca=-(Q.x*a.n21+Q.y*a.n22+Q.z*a.n23)*0.5+0.5,Q.copy(k.vertexNormalsWorld[1]),Da=(Q.x*
+faces:0};this.setSize=function(a,b){m=a;n=b;j=m/2;o=n/2;l.width=m;l.height=n;ka.set(-j,-o,j,o);Y.set(-j,-o,j,o);s=1;J=0;O=p=B=x=N=null};this.setClearColor=function(a,b){q=a;v=b;Y.set(-j,-o,j,o)};this.setClearColorHex=function(a,b){q.setHex(a);v=b;Y.set(-j,-o,j,o)};this.clear=function(){k.setTransform(1,0,0,-1,j,o);if(!Y.isEmpty())Y.inflate(1),Y.minSelf(ka),q.hex==0&&v==0?k.clearRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight()):(c(THREE.NormalBlending),b(1),k.fillStyle="rgba("+Math.floor(q.r*255)+
+","+Math.floor(q.g*255)+","+Math.floor(q.b*255)+","+v+")",k.fillRect(Y.getX(),Y.getY(),Y.getWidth(),Y.getHeight())),Y.empty()};this.render=function(a,g){function l(a){var b,c,d,f=a.lights;Z.setRGB(0,0,0);sa.setRGB(0,0,0);ta.setRGB(0,0,0);a=0;for(b=f.length;a<b;a++)c=f[a],d=c.color,c instanceof THREE.AmbientLight?(Z.r+=d.r,Z.g+=d.g,Z.b+=d.b):c instanceof THREE.DirectionalLight?(sa.r+=d.r,sa.g+=d.g,sa.b+=d.b):c instanceof THREE.PointLight&&(ta.r+=d.r,ta.g+=d.g,ta.b+=d.b)}function m(a,b,c,d){var f,e,
+g,h,l=a.lights,a=0;for(f=l.length;a<f;a++)e=l[a],g=e.color,e instanceof THREE.DirectionalLight?(h=c.dot(e.position),h<=0||(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)):e instanceof THREE.PointLight&&(h=c.dot(Q.sub(e.position,b).normalize()),h<=0||(h*=e.distance==0?1:1-Math.min(b.distanceTo(e.position)/e.distance,1),h!=0&&(h*=e.intensity,d.r+=g.r*h,d.g+=g.g*h,d.b+=g.b*h)))}function n(a,e,g){b(g.opacity);c(g.blending);var h,l,i,m,Aa,p;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)m=g.map.image,
+Aa=m.width>>1,p=m.height>>1,g=e.scale.x*j,i=e.scale.y*o,h=g*Aa,l=i*p,V.set(a.x-h,a.y-l,a.x+h,a.y+l),ka.instersects(V)&&(k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(g,-i),k.translate(-Aa,-p),k.drawImage(m,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=e.scale.x*j,l=e.scale.y*o,V.set(a.x-h,a.y-l,a.x+h,a.y+l),ka.instersects(V)&&(d(g.color),f(g.color),k.save(),k.translate(a.x,a.y),k.rotate(-e.rotation),k.scale(h,l),g.program(k),k.restore()))}function q(a,e,f,g){b(g.opacity);
+c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(B!=a)k.lineWidth=B=a;a=g.linecap;if(p!=a)k.lineCap=p=a;a=g.linejoin;if(O!=a)k.lineJoin=O=a;d(g.color);k.stroke();V.inflate(g.linewidth*2)}}function s(a,d,f,h,l,i,k,j,n){e.data.vertices+=3;e.data.faces++;b(j.opacity);c(j.blending);C=a.positionScreen.x;F=a.positionScreen.y;L=d.positionScreen.x;D=d.positionScreen.y;
+G=f.positionScreen.x;z=f.positionScreen.y;x(C,F,L,D,G,z);if(j instanceof THREE.MeshBasicMaterial)if(j.map)j.map.mapping instanceof THREE.UVMapping&&(ba=k.uvs[0],ga(C,F,L,D,G,z,j.map.image,ba[h].u,ba[h].v,ba[l].u,ba[l].v,ba[i].u,ba[i].v));else if(j.envMap){if(j.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=g.matrixWorldInverse,Q.copy(k.vertexNormalsWorld[0]),Ba=(Q.x*a.n11+Q.y*a.n12+Q.z*a.n13)*0.5+0.5,Ca=-(Q.x*a.n21+Q.y*a.n22+Q.z*a.n23)*0.5+0.5,Q.copy(k.vertexNormalsWorld[1]),Da=(Q.x*
 a.n11+Q.y*a.n12+Q.z*a.n13)*0.5+0.5,Ea=-(Q.x*a.n21+Q.y*a.n22+Q.z*a.n23)*0.5+0.5,Q.copy(k.vertexNormalsWorld[2]),Fa=(Q.x*a.n11+Q.y*a.n12+Q.z*a.n13)*0.5+0.5,Ga=-(Q.x*a.n21+Q.y*a.n22+Q.z*a.n23)*0.5+0.5,ga(C,F,L,D,G,z,j.envMap.image,Ba,Ca,Da,Ea,Fa,Ga)}else j.wireframe?J(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(j.color);else if(j instanceof THREE.MeshLambertMaterial)j.map&&!j.wireframe&&(j.map.mapping instanceof THREE.UVMapping&&(ba=k.uvs[0],ga(C,F,L,D,G,z,j.map.image,ba[h].u,
-ba[h].v,ba[l].u,ba[l].v,ba[i].u,ba[i].v)),c(THREE.SubtractiveBlending)),ya?!j.wireframe&&j.shading==THREE.SmoothShading&&k.vertexNormalsWorld.length==3?(H.r=E.r=I.r=Z.r,H.g=E.g=I.g=Z.g,H.b=E.b=I.b=Z.b,m(n,k.v1.positionWorld,k.vertexNormalsWorld[0],H),m(n,k.v2.positionWorld,k.vertexNormalsWorld[1],E),m(n,k.v3.positionWorld,k.vertexNormalsWorld[2],I),S.r=(E.r+I.r)*0.5,S.g=(E.g+I.g)*0.5,S.b=(E.b+I.b)*0.5,X=va(H,E,I,S),ga(C,F,L,D,G,z,X,0,0,1,0,0,1)):(ca.r=Z.r,ca.g=Z.g,ca.b=Z.b,m(n,k.centroidWorld,k.normalWorld,
+ba[h].v,ba[l].u,ba[l].v,ba[i].u,ba[i].v)),c(THREE.SubtractiveBlending)),ya?!j.wireframe&&j.shading==THREE.SmoothShading&&k.vertexNormalsWorld.length==3?(H.r=E.r=I.r=Z.r,H.g=E.g=I.g=Z.g,H.b=E.b=I.b=Z.b,m(n,k.v1.positionWorld,k.vertexNormalsWorld[0],H),m(n,k.v2.positionWorld,k.vertexNormalsWorld[1],E),m(n,k.v3.positionWorld,k.vertexNormalsWorld[2],I),T.r=(E.r+I.r)*0.5,T.g=(E.g+I.g)*0.5,T.b=(E.b+I.b)*0.5,X=va(H,E,I,T),ga(C,F,L,D,G,z,X,0,0,1,0,0,1)):(ca.r=Z.r,ca.g=Z.g,ca.b=Z.b,m(n,k.centroidWorld,k.normalWorld,
 ca),t.r=Math.max(0,Math.min(j.color.r*ca.r,1)),t.g=Math.max(0,Math.min(j.color.g*ca.g,1)),t.b=Math.max(0,Math.min(j.color.b*ca.b,1)),t.updateHex(),j.wireframe?J(t,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(t)):j.wireframe?J(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(j.color);else if(j instanceof THREE.MeshDepthMaterial)W=g.near,da=g.far,H.r=H.g=H.b=1-la(a.positionScreen.z,W,da),E.r=E.g=E.b=1-la(d.positionScreen.z,W,da),I.r=I.g=I.b=1-la(f.positionScreen.z,
-W,da),S.r=(E.r+I.r)*0.5,S.g=(E.g+I.g)*0.5,S.b=(E.b+I.b)*0.5,X=va(H,E,I,S),ga(C,F,L,D,G,z,X,0,0,1,0,0,1);else if(j instanceof THREE.MeshNormalMaterial)t.r=ma(k.normalWorld.x),t.g=ma(k.normalWorld.y),t.b=ma(k.normalWorld.z),t.updateHex(),j.wireframe?J(t,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(t)}function w(a,d,f,h,j,l,k,i,n){e.data.vertices+=4;e.data.faces++;b(i.opacity);c(i.blending);if(i.map||i.envMap)s(a,d,h,0,1,3,k,i,n),s(j,f,l,1,2,3,k,i,n);else if(C=a.positionScreen.x,F=
-a.positionScreen.y,L=d.positionScreen.x,D=d.positionScreen.y,G=f.positionScreen.x,z=f.positionScreen.y,P=h.positionScreen.x,x=h.positionScreen.y,M=j.positionScreen.x,K=j.positionScreen.y,oa=l.positionScreen.x,V=l.positionScreen.y,i instanceof THREE.MeshBasicMaterial)N(C,F,L,D,G,z,P,x),i.wireframe?J(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(i.color);else if(i instanceof THREE.MeshLambertMaterial)ya?!i.wireframe&&i.shading==THREE.SmoothShading&&k.vertexNormalsWorld.length==
-4?(H.r=E.r=I.r=S.r=Z.r,H.g=E.g=I.g=S.g=Z.g,H.b=E.b=I.b=S.b=Z.b,m(n,k.v1.positionWorld,k.vertexNormalsWorld[0],H),m(n,k.v2.positionWorld,k.vertexNormalsWorld[1],E),m(n,k.v4.positionWorld,k.vertexNormalsWorld[3],I),m(n,k.v3.positionWorld,k.vertexNormalsWorld[2],S),X=va(H,E,I,S),v(C,F,L,D,P,x),ga(C,F,L,D,P,x,X,0,0,1,0,0,1),v(M,K,G,z,oa,V),ga(M,K,G,z,oa,V,X,1,0,1,1,0,1)):(ca.r=Z.r,ca.g=Z.g,ca.b=Z.b,m(n,k.centroidWorld,k.normalWorld,ca),t.r=Math.max(0,Math.min(i.color.r*ca.r,1)),t.g=Math.max(0,Math.min(i.color.g*
-ca.g,1)),t.b=Math.max(0,Math.min(i.color.b*ca.b,1)),t.updateHex(),N(C,F,L,D,G,z,P,x),i.wireframe?J(t,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(t)):(N(C,F,L,D,G,z,P,x),i.wireframe?J(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(i.color));else if(i instanceof THREE.MeshNormalMaterial)t.r=ma(k.normalWorld.x),t.g=ma(k.normalWorld.y),t.b=ma(k.normalWorld.z),t.updateHex(),N(C,F,L,D,G,z,P,x),i.wireframe?J(t,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):
-ha(t);else if(i instanceof THREE.MeshDepthMaterial)W=g.near,da=g.far,H.r=H.g=H.b=1-la(a.positionScreen.z,W,da),E.r=E.g=E.b=1-la(d.positionScreen.z,W,da),I.r=I.g=I.b=1-la(h.positionScreen.z,W,da),S.r=S.g=S.b=1-la(f.positionScreen.z,W,da),X=va(H,E,I,S),v(C,F,L,D,P,x),ga(C,F,L,D,P,x,X,0,0,1,0,0,1),v(M,K,G,z,oa,V),ga(M,K,G,z,oa,V,X,1,0,1,1,0,1)}function v(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function N(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,
-b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function J(a,b,c,e){if(B!=b)k.lineWidth=B=b;if(p!=c)k.lineCap=p=c;if(O!=e)k.lineJoin=O=e;d(a);k.stroke();U.inflate(b*2)}function ha(a){f(a);k.fill()}function ga(a,b,c,d,e,f,g,h,i,j,l,m,n){var o,p;o=g.width-1;p=g.height-1;h*=o;i*=p;j*=o;l*=p;m*=o;n*=p;c-=a;d-=b;e-=a;f-=b;j-=h;l-=i;m-=h;n-=i;o=j*n-m*l;if(!((o<0?-o:o)<1))p=1/o,o=(n*c-l*e)*p,l=(n*d-l*f)*p,c=(j*e-m*c)*p,d=(j*f-m*d)*p,a=a-o*h-c*i,b=b-l*h-d*i,k.save(),k.transform(o,
+W,da),T.r=(E.r+I.r)*0.5,T.g=(E.g+I.g)*0.5,T.b=(E.b+I.b)*0.5,X=va(H,E,I,T),ga(C,F,L,D,G,z,X,0,0,1,0,0,1);else if(j instanceof THREE.MeshNormalMaterial)t.r=ma(k.normalWorld.x),t.g=ma(k.normalWorld.y),t.b=ma(k.normalWorld.z),t.updateHex(),j.wireframe?J(t,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(t)}function v(a,d,f,h,j,l,k,i,n){e.data.vertices+=4;e.data.faces++;b(i.opacity);c(i.blending);if(i.map||i.envMap)s(a,d,h,0,1,3,k,i,n),s(j,f,l,1,2,3,k,i,n);else if(C=a.positionScreen.x,F=
+a.positionScreen.y,L=d.positionScreen.x,D=d.positionScreen.y,G=f.positionScreen.x,z=f.positionScreen.y,P=h.positionScreen.x,w=h.positionScreen.y,M=j.positionScreen.x,K=j.positionScreen.y,S=l.positionScreen.x,oa=l.positionScreen.y,i instanceof THREE.MeshBasicMaterial)N(C,F,L,D,G,z,P,w),i.wireframe?J(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(i.color);else if(i instanceof THREE.MeshLambertMaterial)ya?!i.wireframe&&i.shading==THREE.SmoothShading&&k.vertexNormalsWorld.length==
+4?(H.r=E.r=I.r=T.r=Z.r,H.g=E.g=I.g=T.g=Z.g,H.b=E.b=I.b=T.b=Z.b,m(n,k.v1.positionWorld,k.vertexNormalsWorld[0],H),m(n,k.v2.positionWorld,k.vertexNormalsWorld[1],E),m(n,k.v4.positionWorld,k.vertexNormalsWorld[3],I),m(n,k.v3.positionWorld,k.vertexNormalsWorld[2],T),X=va(H,E,I,T),x(C,F,L,D,P,w),ga(C,F,L,D,P,w,X,0,0,1,0,0,1),x(M,K,G,z,S,oa),ga(M,K,G,z,S,oa,X,1,0,1,1,0,1)):(ca.r=Z.r,ca.g=Z.g,ca.b=Z.b,m(n,k.centroidWorld,k.normalWorld,ca),t.r=Math.max(0,Math.min(i.color.r*ca.r,1)),t.g=Math.max(0,Math.min(i.color.g*
+ca.g,1)),t.b=Math.max(0,Math.min(i.color.b*ca.b,1)),t.updateHex(),N(C,F,L,D,G,z,P,w),i.wireframe?J(t,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(t)):(N(C,F,L,D,G,z,P,w),i.wireframe?J(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(i.color));else if(i instanceof THREE.MeshNormalMaterial)t.r=ma(k.normalWorld.x),t.g=ma(k.normalWorld.y),t.b=ma(k.normalWorld.z),t.updateHex(),N(C,F,L,D,G,z,P,w),i.wireframe?J(t,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):
+ha(t);else if(i instanceof THREE.MeshDepthMaterial)W=g.near,da=g.far,H.r=H.g=H.b=1-la(a.positionScreen.z,W,da),E.r=E.g=E.b=1-la(d.positionScreen.z,W,da),I.r=I.g=I.b=1-la(h.positionScreen.z,W,da),T.r=T.g=T.b=1-la(f.positionScreen.z,W,da),X=va(H,E,I,T),x(C,F,L,D,P,w),ga(C,F,L,D,P,w,X,0,0,1,0,0,1),x(M,K,G,z,S,oa),ga(M,K,G,z,S,oa,X,1,0,1,1,0,1)}function x(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function N(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,
+b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function J(a,b,c,e){if(B!=b)k.lineWidth=B=b;if(p!=c)k.lineCap=p=c;if(O!=e)k.lineJoin=O=e;d(a);k.stroke();V.inflate(b*2)}function ha(a){f(a);k.fill()}function ga(a,b,c,d,e,f,g,h,i,j,l,m,n){var o,p;o=g.width-1;p=g.height-1;h*=o;i*=p;j*=o;l*=p;m*=o;n*=p;c-=a;d-=b;e-=a;f-=b;j-=h;l-=i;m-=h;n-=i;o=j*n-m*l;if(!((o<0?-o:o)<1))p=1/o,o=(n*c-l*e)*p,l=(n*d-l*f)*p,c=(j*e-m*c)*p,d=(j*f-m*d)*p,a=a-o*h-c*i,b=b-l*h-d*i,k.save(),k.transform(o,
 l,c,d,a,b),k.clip(),k.drawImage(g,0,0),k.restore()}function va(a,b,c,d){var e=~~(a.r*255),f=~~(a.g*255),a=~~(a.b*255),g=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),i=~~(c.r*255),j=~~(c.g*255),c=~~(c.b*255),k=~~(d.r*255),l=~~(d.g*255),d=~~(d.b*255);ea[0]=e<0?0:e>255?255:e;ea[1]=f<0?0:f>255?255:f;ea[2]=a<0?0:a>255?255:a;ea[4]=g<0?0:g>255?255:g;ea[5]=h<0?0:h>255?255:h;ea[6]=b<0?0:b>255?255:b;ea[8]=i<0?0:i>255?255:i;ea[9]=j<0?0:j>255?255:j;ea[10]=c<0?0:c>255?255:c;ea[12]=k<0?0:k>255?255:k;ea[13]=l<0?0:l>
-255?255:l;ea[14]=d<0?0:d>255?255:d;qa.putImageData(za,0,0);ua.drawImage(pa,0,0);return ra}function la(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function ma(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ia(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var wa,Ha,A,fa,ja,na,xa,T;this.autoClear?this.clear():k.setTransform(1,0,0,-1,j,o);e.data.vertices=0;e.data.faces=0;h=i.projectScene(a,g,this.sortElements);(ya=a.lights.length>0)&&l(a);wa=0;for(Ha=
-h.length;wa<Ha;wa++){A=h[wa];U.empty();if(A instanceof THREE.RenderableParticle){r=A;r.x*=j;r.y*=o;fa=0;for(ja=A.materials.length;fa<ja;)T=A.materials[fa++],T.opacity!=0&&n(r,A,T,a)}else if(A instanceof THREE.RenderableLine){if(r=A.v1,u=A.v2,r.positionScreen.x*=j,r.positionScreen.y*=o,u.positionScreen.x*=j,u.positionScreen.y*=o,U.addPoint(r.positionScreen.x,r.positionScreen.y),U.addPoint(u.positionScreen.x,u.positionScreen.y),ka.instersects(U)){fa=0;for(ja=A.materials.length;fa<ja;)T=A.materials[fa++],
-T.opacity!=0&&q(r,u,A,T,a)}}else if(A instanceof THREE.RenderableFace3){if(r=A.v1,u=A.v2,y=A.v3,r.positionScreen.x*=j,r.positionScreen.y*=o,u.positionScreen.x*=j,u.positionScreen.y*=o,y.positionScreen.x*=j,y.positionScreen.y*=o,A.overdraw&&(ia(r.positionScreen,u.positionScreen),ia(u.positionScreen,y.positionScreen),ia(y.positionScreen,r.positionScreen)),U.add3Points(r.positionScreen.x,r.positionScreen.y,u.positionScreen.x,u.positionScreen.y,y.positionScreen.x,y.positionScreen.y),ka.instersects(U)){fa=
-0;for(ja=A.meshMaterials.length;fa<ja;)if(T=A.meshMaterials[fa++],T instanceof THREE.MeshFaceMaterial){na=0;for(xa=A.faceMaterials.length;na<xa;)(T=A.faceMaterials[na++])&&T.opacity!=0&&s(r,u,y,0,1,2,A,T,a)}else T.opacity!=0&&s(r,u,y,0,1,2,A,T,a)}}else if(A instanceof THREE.RenderableFace4&&(r=A.v1,u=A.v2,y=A.v3,R=A.v4,r.positionScreen.x*=j,r.positionScreen.y*=o,u.positionScreen.x*=j,u.positionScreen.y*=o,y.positionScreen.x*=j,y.positionScreen.y*=o,R.positionScreen.x*=j,R.positionScreen.y*=o,aa.positionScreen.copy(u.positionScreen),
-$.positionScreen.copy(R.positionScreen),A.overdraw&&(ia(r.positionScreen,u.positionScreen),ia(u.positionScreen,R.positionScreen),ia(R.positionScreen,r.positionScreen),ia(y.positionScreen,aa.positionScreen),ia(y.positionScreen,$.positionScreen)),U.addPoint(r.positionScreen.x,r.positionScreen.y),U.addPoint(u.positionScreen.x,u.positionScreen.y),U.addPoint(y.positionScreen.x,y.positionScreen.y),U.addPoint(R.positionScreen.x,R.positionScreen.y),ka.instersects(U))){fa=0;for(ja=A.meshMaterials.length;fa<
-ja;)if(T=A.meshMaterials[fa++],T instanceof THREE.MeshFaceMaterial){na=0;for(xa=A.faceMaterials.length;na<xa;)(T=A.faceMaterials[na++])&&T.opacity!=0&&w(r,u,y,R,aa,$,A,T,a)}else T.opacity!=0&&w(r,u,y,R,aa,$,A,T,a)}Y.addRectangle(U)}k.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
+255?255:l;ea[14]=d<0?0:d>255?255:d;qa.putImageData(za,0,0);ua.drawImage(pa,0,0);return ra}function la(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function ma(a){a=(a+1)*0.5;return a<0?0:a>1?1:a}function ia(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;e!=0&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var wa,Ha,A,fa,ja,na,xa,U;this.autoClear?this.clear():k.setTransform(1,0,0,-1,j,o);e.data.vertices=0;e.data.faces=0;h=i.projectScene(a,g,this.sortElements);(ya=a.lights.length>0)&&l(a);wa=0;for(Ha=
+h.length;wa<Ha;wa++){A=h[wa];V.empty();if(A instanceof THREE.RenderableParticle){r=A;r.x*=j;r.y*=o;fa=0;for(ja=A.materials.length;fa<ja;)U=A.materials[fa++],U.opacity!=0&&n(r,A,U,a)}else if(A instanceof THREE.RenderableLine){if(r=A.v1,u=A.v2,r.positionScreen.x*=j,r.positionScreen.y*=o,u.positionScreen.x*=j,u.positionScreen.y*=o,V.addPoint(r.positionScreen.x,r.positionScreen.y),V.addPoint(u.positionScreen.x,u.positionScreen.y),ka.instersects(V)){fa=0;for(ja=A.materials.length;fa<ja;)U=A.materials[fa++],
+U.opacity!=0&&q(r,u,A,U,a)}}else if(A instanceof THREE.RenderableFace3){if(r=A.v1,u=A.v2,y=A.v3,r.positionScreen.x*=j,r.positionScreen.y*=o,u.positionScreen.x*=j,u.positionScreen.y*=o,y.positionScreen.x*=j,y.positionScreen.y*=o,A.overdraw&&(ia(r.positionScreen,u.positionScreen),ia(u.positionScreen,y.positionScreen),ia(y.positionScreen,r.positionScreen)),V.add3Points(r.positionScreen.x,r.positionScreen.y,u.positionScreen.x,u.positionScreen.y,y.positionScreen.x,y.positionScreen.y),ka.instersects(V)){fa=
+0;for(ja=A.meshMaterials.length;fa<ja;)if(U=A.meshMaterials[fa++],U instanceof THREE.MeshFaceMaterial){na=0;for(xa=A.faceMaterials.length;na<xa;)(U=A.faceMaterials[na++])&&U.opacity!=0&&s(r,u,y,0,1,2,A,U,a)}else U.opacity!=0&&s(r,u,y,0,1,2,A,U,a)}}else if(A instanceof THREE.RenderableFace4&&(r=A.v1,u=A.v2,y=A.v3,R=A.v4,r.positionScreen.x*=j,r.positionScreen.y*=o,u.positionScreen.x*=j,u.positionScreen.y*=o,y.positionScreen.x*=j,y.positionScreen.y*=o,R.positionScreen.x*=j,R.positionScreen.y*=o,aa.positionScreen.copy(u.positionScreen),
+$.positionScreen.copy(R.positionScreen),A.overdraw&&(ia(r.positionScreen,u.positionScreen),ia(u.positionScreen,R.positionScreen),ia(R.positionScreen,r.positionScreen),ia(y.positionScreen,aa.positionScreen),ia(y.positionScreen,$.positionScreen)),V.addPoint(r.positionScreen.x,r.positionScreen.y),V.addPoint(u.positionScreen.x,u.positionScreen.y),V.addPoint(y.positionScreen.x,y.positionScreen.y),V.addPoint(R.positionScreen.x,R.positionScreen.y),ka.instersects(V))){fa=0;for(ja=A.meshMaterials.length;fa<
+ja;)if(U=A.meshMaterials[fa++],U instanceof THREE.MeshFaceMaterial){na=0;for(xa=A.faceMaterials.length;na<xa;)(U=A.faceMaterials[na++])&&U.opacity!=0&&v(r,u,y,R,aa,$,A,U,a)}else U.opacity!=0&&v(r,u,y,R,aa,$,A,U,a)}Y.addRectangle(V)}k.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};

+ 211 - 188
build/custom/ThreeExtras.js

@@ -1,10 +1,12 @@
 // ThreeExtras.js r42 - http://github.com/mrdoob/three.js
-THREE.ColorUtils={adjustHSV:function(a,b,c,g){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.ColorUtils.clamp(e.h+b,0,1);e.s=THREE.ColorUtils.clamp(e.s+c,0,1);e.v=THREE.ColorUtils.clamp(e.v+g,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,g=a.g,e=a.b,h=Math.max(Math.max(c,g),e),f=Math.min(Math.min(c,g),e);if(f==h)f=c=0;else{var j=h-f,f=j/h,c=c==h?(g-e)/j:g==h?2+(e-c)/j:4+(c-g)/j;c/=6;c<0&&(c+=1);c>1&&(c-=1)}b===void 0&&(b={h:0,s:0,v:0});b.h=c;b.s=f;b.v=h;return b},
-clamp:function(a,b,c){return a<b?b:a>c?c:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
-THREE.GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,g=a.vertices.length,e=c?b.geometry:b,h=a.vertices,f=e.vertices,j=a.faces,k=e.faces,l=a.faceVertexUvs[0],e=e.faceVertexUvs[0];c&&b.matrixAutoUpdate&&b.updateMatrix();for(var m=0,o=f.length;m<o;m++){var n=new THREE.Vertex(f[m].position.clone());c&&b.matrix.multiplyVector3(n.position);h.push(n)}m=0;for(o=k.length;m<o;m++){var f=k[m],t,v,y=f.vertexNormals,n=f.vertexColors;f instanceof THREE.Face3?t=new THREE.Face3(f.a+g,f.b+g,f.c+
-g):f instanceof THREE.Face4&&(t=new THREE.Face4(f.a+g,f.b+g,f.c+g,f.d+g));t.normal.copy(f.normal);c=0;for(h=y.length;c<h;c++)v=y[c],t.vertexNormals.push(v.clone());t.color.copy(f.color);c=0;for(h=n.length;c<h;c++)v=n[c],t.vertexColors.push(v.clone());t.materials=f.materials.slice();t.centroid.copy(f.centroid);j.push(t)}m=0;for(o=e.length;m<o;m++){g=e[m];j=[];c=0;for(h=g.length;c<h;c++)j.push(new THREE.UV(g[c].u,g[c].v));l.push(j)}}};
-THREE.ImageUtils={loadTexture:function(a,b,c){var g=new Image,e=new THREE.Texture(g,b);g.onload=function(){e.needsUpdate=!0;c&&c(this)};g.crossOrigin="";g.src=a;return e},loadTextureCube:function(a,b,c){var g,e=[],h=new THREE.Texture(e,b),b=e.loadCount=0;for(g=a.length;b<g;++b)e[b]=new Image,e[b].onload=function(){e.loadCount+=1;if(e.loadCount==6)h.needsUpdate=!0;c&&c(this)},e[b].crossOrigin="",e[b].src=a[b];return h}};
-THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=b})},traverseHierarchy:function(a,b){var c,g,e=a.children.length;for(g=0;g<e;g++)c=a.children[g],b(c),THREE.SceneUtils.traverseHierarchy(c,b)}};
+THREE.ColorUtils={adjustHSV:function(a,c,b,g){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,f);f.h=THREE.ColorUtils.clamp(f.h+c,0,1);f.s=THREE.ColorUtils.clamp(f.s+b,0,1);f.v=THREE.ColorUtils.clamp(f.v+g,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,c){var b=a.r,g=a.g,f=a.b,h=Math.max(Math.max(b,g),f),e=Math.min(Math.min(b,g),f);if(e==h)e=b=0;else{var j=h-e,e=j/h,b=b==h?(g-f)/j:g==h?2+(f-b)/j:4+(b-g)/j;b/=6;b<0&&(b+=1);b>1&&(b-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=b;c.s=e;c.v=h;return c},
+clamp:function(a,c,b){return a<c?c:a>b?b:a}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
+THREE.GeometryUtils={merge:function(a,c){var b=c instanceof THREE.Mesh,g=a.vertices.length,f=b?c.geometry:c,h=a.vertices,e=f.vertices,j=a.faces,k=f.faces,l=a.faceVertexUvs[0],f=f.faceVertexUvs[0];b&&c.matrixAutoUpdate&&c.updateMatrix();for(var m=0,n=e.length;m<n;m++){var o=new THREE.Vertex(e[m].position.clone());b&&c.matrix.multiplyVector3(o.position);h.push(o)}m=0;for(n=k.length;m<n;m++){var e=k[m],p,w,t=e.vertexNormals,o=e.vertexColors;e instanceof THREE.Face3?p=new THREE.Face3(e.a+g,e.b+g,e.c+
+g):e instanceof THREE.Face4&&(p=new THREE.Face4(e.a+g,e.b+g,e.c+g,e.d+g));p.normal.copy(e.normal);b=0;for(h=t.length;b<h;b++)w=t[b],p.vertexNormals.push(w.clone());p.color.copy(e.color);b=0;for(h=o.length;b<h;b++)w=o[b],p.vertexColors.push(w.clone());p.materials=e.materials.slice();p.centroid.copy(e.centroid);j.push(p)}m=0;for(n=f.length;m<n;m++){g=f[m];j=[];b=0;for(h=g.length;b<h;b++)j.push(new THREE.UV(g[b].u,g[b].v));l.push(j)}},clone:function(a){var c=new THREE.Geometry,b,g=a.vertices,f=a.faces,
+h=a.faceVertexUvs[0],a=0;for(b=g.length;a<b;a++){var e=new THREE.Vertex(g[a].position.clone());c.vertices.push(e)}a=0;for(b=f.length;a<b;a++){var j=f[a],k,l,m=j.vertexNormals,n=j.vertexColors;j instanceof THREE.Face3?k=new THREE.Face3(j.a,j.b,j.c):j instanceof THREE.Face4&&(k=new THREE.Face4(j.a,j.b,j.c,j.d));k.normal.copy(j.normal);g=0;for(e=m.length;g<e;g++)l=m[g],k.vertexNormals.push(l.clone());k.color.copy(j.color);g=0;for(e=n.length;g<e;g++)l=n[g],k.vertexColors.push(l.clone());k.materials=j.materials.slice();
+k.centroid.copy(j.centroid);c.faces.push(k)}a=0;for(b=h.length;a<b;a++){f=h[a];k=[];g=0;for(e=f.length;g<e;g++)k.push(new THREE.UV(f[g].u,f[g].v));c.faceVertexUvs[0].push(k)}return c}};
+THREE.ImageUtils={loadTexture:function(a,c,b){var g=new Image,f=new THREE.Texture(g,c);g.onload=function(){f.needsUpdate=!0;b&&b(this)};g.crossOrigin="";g.src=a;return f},loadTextureCube:function(a,c,b){var g,f=[],h=new THREE.Texture(f,c),c=f.loadCount=0;for(g=a.length;c<g;++c)f[c]=new Image,f[c].onload=function(){f.loadCount+=1;if(f.loadCount==6)h.needsUpdate=!0;b&&b(this)},f[c].crossOrigin="",f[c].src=a[c];return h}};
+THREE.SceneUtils={showHierarchy:function(a,c){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=c})},traverseHierarchy:function(a,c){var b,g,f=a.children.length;for(g=0;g<f;g++)b=a.children[g],c(b),THREE.SceneUtils.traverseHierarchy(b,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}"},
 normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:5,texture:null},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},uDiffuseColor:{type:"c",
 value:new THREE.Color(15658734)},uSpecularColor:{type:"c",value:new THREE.Color(1118481)},uAmbientColor:{type:"c",value:new THREE.Color(328965)},uShininess:{type:"f",value:30},uOpacity:{type:"f",value:1}}]),fragmentShader:["uniform vec3 uAmbientColor;\nuniform vec3 uDiffuseColor;\nuniform vec3 uSpecularColor;\nuniform float uShininess;\nuniform float uOpacity;\nuniform bool enableDiffuse;\nuniform bool enableSpecular;\nuniform bool enableAO;\nuniform sampler2D tDiffuse;\nuniform sampler2D tNormal;\nuniform sampler2D tSpecular;\nuniform sampler2D tAO;\nuniform float uNormalScale;\nvarying vec3 vTangent;\nvarying vec3 vBinormal;\nvarying vec3 vNormal;\nvarying vec2 vUv;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nvarying vec4 vPointLight[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;",
@@ -14,184 +16,205 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec
 value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
-fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,g,e,h=2*Math.ceil(a*3)+1;h>25&&(h=25);e=(h-1)*0.5;c=Array(h);for(b=g=0;b<h;++b)c[b]=Math.exp(-((b-e)*(b-e))/(2*a*a)),g+=c[b];for(b=0;b<h;++b)c[b]/=g;return c}};
-THREE.AnimationHandler=function(){var a=[],b={},c={update:function(c){for(var b=0;b<a.length;b++)a[b].update(c)},addToUpdate:function(c){a.indexOf(c)===-1&&a.push(c)},removeFromUpdate:function(c){c=a.indexOf(c);c!==-1&&a.splice(c,1)},add:function(a){b[a.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");b[a.name]=a;if(a.initialized!==!0){for(var c=0;c<a.hierarchy.length;c++){for(var f=0;f<a.hierarchy[c].keys.length;f++){if(a.hierarchy[c].keys[f].time<
-0)a.hierarchy[c].keys[f].time=0;if(a.hierarchy[c].keys[f].rot!==void 0&&!(a.hierarchy[c].keys[f].rot instanceof THREE.Quaternion)){var g=a.hierarchy[c].keys[f].rot;a.hierarchy[c].keys[f].rot=new THREE.Quaternion(g[0],g[1],g[2],g[3])}}if(a.hierarchy[c].keys[0].morphTargets!==void 0){g={};for(f=0;f<a.hierarchy[c].keys.length;f++)for(var k=0;k<a.hierarchy[c].keys[f].morphTargets.length;k++){var l=a.hierarchy[c].keys[f].morphTargets[k];g[l]=-1}a.hierarchy[c].usedMorphTargets=g;for(f=0;f<a.hierarchy[c].keys.length;f++){var m=
-{};for(l in g){for(k=0;k<a.hierarchy[c].keys[f].morphTargets.length;k++)if(a.hierarchy[c].keys[f].morphTargets[k]===l){m[l]=a.hierarchy[c].keys[f].morphTargetsInfluences[k];break}k===a.hierarchy[c].keys[f].morphTargets.length&&(m[l]=0)}a.hierarchy[c].keys[f].morphTargetsInfluences=m}}for(f=1;f<a.hierarchy[c].keys.length;f++)a.hierarchy[c].keys[f].time===a.hierarchy[c].keys[f-1].time&&(a.hierarchy[c].keys.splice(f,1),f--);for(f=1;f<a.hierarchy[c].keys.length;f++)a.hierarchy[c].keys[f].index=f}f=parseInt(a.length*
-a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(c=0;c<a.hierarchy.length;c++)a.JIT.hierarchy.push(Array(f));a.initialized=!0}},get:function(a){if(typeof a==="string")return b[a]?b[a]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+a),null)},parse:function(a){var c=[];if(a instanceof THREE.SkinnedMesh)for(var b=0;b<a.bones.length;b++)c.push(a.bones[b]);else g(a,c);return c}},g=function(a,c){c.push(a);for(var b=0;b<a.children.length;b++)g(a.children[b],c)};c.LINEAR=0;c.CATMULLROM=1;c.CATMULLROM_FORWARD=
-2;return c}();THREE.Animation=function(a,b,c,g){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=c!==void 0?c:THREE.AnimationHandler.LINEAR;this.JITCompile=g!==void 0?g:!0;this.points=[];this.target=new THREE.Vector3};
-THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==void 0?a:!0;this.currentTime=b!==void 0?b:0;var c,g=this.hierarchy.length,e;for(c=0;c<g;c++){e=this.hierarchy[c];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)e.useQuaternion=!0;e.matrixAutoUpdate=!0;if(e.animationCache===void 0)e.animationCache={},e.animationCache.prevKey={pos:0,rot:0,scl:0},e.animationCache.nextKey={pos:0,rot:0,scl:0},e.animationCache.originalMatrix=e instanceof
-THREE.Bone?e.skinMatrix:e.matrix;var h=e.animationCache.prevKey;e=e.animationCache.nextKey;h.pos=this.data.hierarchy[c].keys[0];h.rot=this.data.hierarchy[c].keys[0];h.scl=this.data.hierarchy[c].keys[0];e.pos=this.getNextKeyWith("pos",c,1);e.rot=this.getNextKeyWith("rot",c,1);e.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
+fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,b,g,f,h=2*Math.ceil(a*3)+1;h>25&&(h=25);f=(h-1)*0.5;b=Array(h);for(c=g=0;c<h;++c)b[c]=Math.exp(-((c-f)*(c-f))/(2*a*a)),g+=b[c];for(c=0;c<h;++c)b[c]/=g;return b}};
+THREE.AnimationHandler=function(){var a=[],c={},b={update:function(b){for(var c=0;c<a.length;c++)a[c].update(b)},addToUpdate:function(b){a.indexOf(b)===-1&&a.push(b)},removeFromUpdate:function(b){b=a.indexOf(b);b!==-1&&a.splice(b,1)},add:function(a){c[a.name]!==void 0&&console.log("THREE.AnimationHandler.add: Warning! "+a.name+" already exists in library. Overwriting.");c[a.name]=a;if(a.initialized!==!0){for(var b=0;b<a.hierarchy.length;b++){for(var e=0;e<a.hierarchy[b].keys.length;e++){if(a.hierarchy[b].keys[e].time<
+0)a.hierarchy[b].keys[e].time=0;if(a.hierarchy[b].keys[e].rot!==void 0&&!(a.hierarchy[b].keys[e].rot instanceof THREE.Quaternion)){var g=a.hierarchy[b].keys[e].rot;a.hierarchy[b].keys[e].rot=new THREE.Quaternion(g[0],g[1],g[2],g[3])}}if(a.hierarchy[b].keys[0].morphTargets!==void 0){g={};for(e=0;e<a.hierarchy[b].keys.length;e++)for(var k=0;k<a.hierarchy[b].keys[e].morphTargets.length;k++){var l=a.hierarchy[b].keys[e].morphTargets[k];g[l]=-1}a.hierarchy[b].usedMorphTargets=g;for(e=0;e<a.hierarchy[b].keys.length;e++){var m=
+{};for(l in g){for(k=0;k<a.hierarchy[b].keys[e].morphTargets.length;k++)if(a.hierarchy[b].keys[e].morphTargets[k]===l){m[l]=a.hierarchy[b].keys[e].morphTargetsInfluences[k];break}k===a.hierarchy[b].keys[e].morphTargets.length&&(m[l]=0)}a.hierarchy[b].keys[e].morphTargetsInfluences=m}}for(e=1;e<a.hierarchy[b].keys.length;e++)a.hierarchy[b].keys[e].time===a.hierarchy[b].keys[e-1].time&&(a.hierarchy[b].keys.splice(e,1),e--);for(e=1;e<a.hierarchy[b].keys.length;e++)a.hierarchy[b].keys[e].index=e}e=parseInt(a.length*
+a.fps,10);a.JIT={};a.JIT.hierarchy=[];for(b=0;b<a.hierarchy.length;b++)a.JIT.hierarchy.push(Array(e));a.initialized=!0}},get:function(a){if(typeof a==="string")return c[a]?c[a]:(console.log("THREE.AnimationHandler.get: Couldn't find animation "+a),null)},parse:function(a){var b=[];if(a instanceof THREE.SkinnedMesh)for(var c=0;c<a.bones.length;c++)b.push(a.bones[c]);else g(a,b);return b}},g=function(a,b){b.push(a);for(var c=0;c<a.children.length;c++)g(a.children[c],b)};b.LINEAR=0;b.CATMULLROM=1;b.CATMULLROM_FORWARD=
+2;return b}();THREE.Animation=function(a,c,b,g){this.root=a;this.data=THREE.AnimationHandler.get(c);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.loop=this.isPaused=!0;this.interpolationType=b!==void 0?b:THREE.AnimationHandler.LINEAR;this.JITCompile=g!==void 0?g:!0;this.points=[];this.target=new THREE.Vector3};
+THREE.Animation.prototype.play=function(a,c){if(!this.isPlaying){this.isPlaying=!0;this.loop=a!==void 0?a:!0;this.currentTime=c!==void 0?c:0;var b,g=this.hierarchy.length,f;for(b=0;b<g;b++){f=this.hierarchy[b];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)f.useQuaternion=!0;f.matrixAutoUpdate=!0;if(f.animationCache===void 0)f.animationCache={},f.animationCache.prevKey={pos:0,rot:0,scl:0},f.animationCache.nextKey={pos:0,rot:0,scl:0},f.animationCache.originalMatrix=f instanceof
+THREE.Bone?f.skinMatrix:f.matrix;var h=f.animationCache.prevKey;f=f.animationCache.nextKey;h.pos=this.data.hierarchy[b].keys[0];h.rot=this.data.hierarchy[b].keys[0];h.scl=this.data.hierarchy[b].keys[0];f.pos=this.getNextKeyWith("pos",b,1);f.rot=this.getNextKeyWith("rot",b,1);f.scl=this.getNextKeyWith("scl",b,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(this.hierarchy[a].animationCache!==void 0)this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix:this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix,delete this.hierarchy[a].animationCache};
-THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,g,e,h,f,j,k,l,m=this.data.JIT.hierarchy,o,n;this.currentTime+=a*this.timeScale;n=this.currentTime;o=this.currentTime%=this.data.length;l=parseInt(Math.min(o*this.data.fps,this.data.length*this.data.fps),10);for(var t=0,v=this.hierarchy.length;t<v;t++)if(a=this.hierarchy[t],k=a.animationCache,this.JITCompile&&m[t][l]!==void 0)a instanceof THREE.Bone?(a.skinMatrix=m[t][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=
-!1):(a.matrix=m[t][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var y=0;y<3;y++){c=b[y];f=k.prevKey[c];j=k.nextKey[c];if(j.time<=n){if(o<n)if(this.loop){f=this.data.hierarchy[t].keys[0];for(j=this.getNextKeyWith(c,t,1);j.time<o;)f=j,j=this.getNextKeyWith(c,t,j.index+1)}else{this.stop();return}else{do f=j,j=this.getNextKeyWith(c,t,j.index+1);while(j.time<
-o)}k.prevKey[c]=f;k.nextKey[c]=j}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;g=(o-f.time)/(j.time-f.time);e=f[c];h=j[c];if(g<0||g>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+g+" on bone "+t),g=g<0?0:1;if(c==="pos")if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(h[0]-e[0])*g,c.y=e[1]+(h[1]-e[1])*g,c.z=e[2]+(h[2]-e[2])*g;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
-this.getPrevKeyWith("pos",t,f.index-1).pos,this.points[1]=e,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",t,j.index+1).pos,g=g*0.33+0.33,e=this.interpolateCatmullRom(this.points,g),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)g=this.interpolateCatmullRom(this.points,g*1.01),this.target.set(g[0],g[1],g[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),g=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,g,0)}else if(c===
-"rot")THREE.Quaternion.slerp(e,h,a.quaternion,g);else if(c==="scl")c=a.scale,c.x=e[0]+(h[0]-e[0])*g,c.y=e[1]+(h[1]-e[1])*g,c.z=e[2]+(h[2]-e[2])*g}}if(this.JITCompile&&m[0][l]===void 0){this.hierarchy[0].update(void 0,!0);for(t=0;t<this.hierarchy.length;t++)m[t][l]=this.hierarchy[t]instanceof THREE.Bone?this.hierarchy[t].skinMatrix.clone():this.hierarchy[t].matrix.clone()}}};
-THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],g=[],e,h,f,j,k,l;e=(a.length-1)*b;h=Math.floor(e);e-=h;c[0]=h==0?h:h-1;c[1]=h;c[2]=h>a.length-2?h:h+1;c[3]=h>a.length-3?h:h+2;h=a[c[0]];j=a[c[1]];k=a[c[2]];l=a[c[3]];c=e*e;f=e*c;g[0]=this.interpolate(h[0],j[0],k[0],l[0],e,c,f);g[1]=this.interpolate(h[1],j[1],k[1],l[1],e,c,f);g[2]=this.interpolate(h[2],j[2],k[2],l[2],e,c,f);return g};
-THREE.Animation.prototype.interpolate=function(a,b,c,g,e,h,f){a=(c-a)*0.5;g=(g-b)*0.5;return(2*(b-c)+a+g)*f+(-3*(b-c)-2*a-g)*h+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){var g=this.data.hierarchy[b].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c=c<g.length-1?c:g.length-1:c%=g.length;c<g.length;c++)if(g[c][a]!==void 0)return g[c];return this.data.hierarchy[b].keys[0]};
-THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var g=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+g.length;c>=0;c--)if(g[c][a]!==void 0)return g[c];return this.data.hierarchy[b].keys[g.length-1]};
-THREE.FirstPersonCamera=function(a){function b(a,b){return function(){b.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=
+THREE.Animation.prototype.update=function(a){if(this.isPlaying){var c=["pos","rot","scl"],b,g,f,h,e,j,k,l,m=this.data.JIT.hierarchy,n,o;this.currentTime+=a*this.timeScale;o=this.currentTime;n=this.currentTime%=this.data.length;l=parseInt(Math.min(n*this.data.fps,this.data.length*this.data.fps),10);for(var p=0,w=this.hierarchy.length;p<w;p++)if(a=this.hierarchy[p],k=a.animationCache,this.JITCompile&&m[p][l]!==void 0)a instanceof THREE.Bone?(a.skinMatrix=m[p][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=
+!1):(a.matrix=m[p][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var t=0;t<3;t++){b=c[t];e=k.prevKey[b];j=k.nextKey[b];if(j.time<=o){if(n<o)if(this.loop){e=this.data.hierarchy[p].keys[0];for(j=this.getNextKeyWith(b,p,1);j.time<n;)e=j,j=this.getNextKeyWith(b,p,j.index+1)}else{this.stop();return}else{do e=j,j=this.getNextKeyWith(b,p,j.index+1);while(j.time<
+n)}k.prevKey[b]=e;k.nextKey[b]=j}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;g=(n-e.time)/(j.time-e.time);f=e[b];h=j[b];if(g<0||g>1)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+g+" on bone "+p),g=g<0?0:1;if(b==="pos")if(b=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)b.x=f[0]+(h[0]-f[0])*g,b.y=f[1]+(h[1]-f[1])*g,b.z=f[2]+(h[2]-f[2])*g;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
+this.getPrevKeyWith("pos",p,e.index-1).pos,this.points[1]=f,this.points[2]=h,this.points[3]=this.getNextKeyWith("pos",p,j.index+1).pos,g=g*0.33+0.33,f=this.interpolateCatmullRom(this.points,g),b.x=f[0],b.y=f[1],b.z=f[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)g=this.interpolateCatmullRom(this.points,g*1.01),this.target.set(g[0],g[1],g[2]),this.target.subSelf(b),this.target.y=0,this.target.normalize(),g=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,g,0)}else if(b===
+"rot")THREE.Quaternion.slerp(f,h,a.quaternion,g);else if(b==="scl")b=a.scale,b.x=f[0]+(h[0]-f[0])*g,b.y=f[1]+(h[1]-f[1])*g,b.z=f[2]+(h[2]-f[2])*g}}if(this.JITCompile&&m[0][l]===void 0){this.hierarchy[0].update(void 0,!0);for(p=0;p<this.hierarchy.length;p++)m[p][l]=this.hierarchy[p]instanceof THREE.Bone?this.hierarchy[p].skinMatrix.clone():this.hierarchy[p].matrix.clone()}}};
+THREE.Animation.prototype.interpolateCatmullRom=function(a,c){var b=[],g=[],f,h,e,j,k,l;f=(a.length-1)*c;h=Math.floor(f);f-=h;b[0]=h==0?h:h-1;b[1]=h;b[2]=h>a.length-2?h:h+1;b[3]=h>a.length-3?h:h+2;h=a[b[0]];j=a[b[1]];k=a[b[2]];l=a[b[3]];b=f*f;e=f*b;g[0]=this.interpolate(h[0],j[0],k[0],l[0],f,b,e);g[1]=this.interpolate(h[1],j[1],k[1],l[1],f,b,e);g[2]=this.interpolate(h[2],j[2],k[2],l[2],f,b,e);return g};
+THREE.Animation.prototype.interpolate=function(a,c,b,g,f,h,e){a=(b-a)*0.5;g=(g-c)*0.5;return(2*(c-b)+a+g)*e+(-3*(c-b)-2*a-g)*h+a*f+c};THREE.Animation.prototype.getNextKeyWith=function(a,c,b){var g=this.data.hierarchy[c].keys;for(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b=b<g.length-1?b:g.length-1:b%=g.length;b<g.length;b++)if(g[b][a]!==void 0)return g[b];return this.data.hierarchy[c].keys[0]};
+THREE.Animation.prototype.getPrevKeyWith=function(a,c,b){for(var g=this.data.hierarchy[c].keys,b=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?b>0?b:0:b>=0?b:b+g.length;b>=0;b--)if(g[b][a]!==void 0)return g[b];return this.data.hierarchy[c].keys[g.length-1]};
+THREE.FirstPersonCamera=function(a){function c(a,c){return function(){c.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;this.lastUpdate=(new Date).getTime();this.tdiff=0;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=
 a.movementSpeed;if(a.lookSpeed!==void 0)this.lookSpeed=a.lookSpeed;if(a.noFly!==void 0)this.noFly=a.noFly;if(a.lookVertical!==void 0)this.lookVertical=a.lookVertical;if(a.autoForward!==void 0)this.autoForward=a.autoForward;if(a.activeLook!==void 0)this.activeLook=a.activeLook;if(a.heightSpeed!==void 0)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==void 0)this.heightCoef=a.heightCoef;if(a.heightMin!==void 0)this.heightMin=a.heightMin;if(a.heightMax!==void 0)this.heightMax=a.heightMax;if(a.constrainVertical!==
 void 0)this.constrainVertical=a.constrainVertical;if(a.verticalMin!==void 0)this.verticalMin=a.verticalMin;if(a.verticalMax!==void 0)this.verticalMax=a.verticalMax;if(a.domElement!==void 0)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(a){a.preventDefault();
 a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.mouseX=a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.onKeyDown=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=
 !0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){var a=(new Date).getTime();this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;if(!this.freeze){this.autoSpeedFactor=
-this.heightSpeed?this.tdiff*((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var b=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(b+this.autoSpeedFactor));this.moveBackward&&this.translateZ(b);this.moveLeft&&this.translateX(-b);this.moveRight&&this.translateX(b);b=this.tdiff*this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVertical&&
-(this.lat-=this.mouseY*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;var a=this.target.position,e=this.position;a.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=e.y+100*Math.cos(this.phi);a.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*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)/3.14+this.verticalMin;a=this.target.position;e=this.position;a.x=e.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=e.y+100*Math.cos(this.phi);a.z=e.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",b(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",b(this,this.onMouseDown),
-!1);this.domElement.addEventListener("mouseup",b(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",b(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",b(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(a,b){this.matrix.rotateAxis(b);if(this.noFly)b.y=0;this.position.addSelf(b.multiplyScalar(a));this.target.position.addSelf(b.multiplyScalar(a))};
-THREE.PathCamera=function(a){function b(a,c,b,f){var g={name:b,fps:0.6,length:f,hierarchy:[]},e,h=c.getControlPointsArray(),j=c.getLength(),k=h.length,x=0;e=k-1;c={parent:-1,keys:[]};c.keys[0]={time:0,pos:h[0],rot:[0,0,0,1],scl:[1,1,1]};c.keys[e]={time:f,pos:h[e],rot:[0,0,0,1],scl:[1,1,1]};for(e=1;e<k-1;e++)x=f*j.chunks[e]/j.total,c.keys[e]={time:x,pos:h[e]};g.hierarchy[0]=c;THREE.AnimationHandler.add(g);return new THREE.Animation(a,b,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function c(a,c){var b,
-f,e=new THREE.Geometry;for(b=0;b<a.points.length*c;b++)f=b/(a.points.length*c),f=a.getPoint(f),e.vertices[b]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return e}function g(a,b){var f=c(b,10),e=c(b,10),g=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(f,g);particleObj=new THREE.ParticleSystem(e,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);a.addChild(lineObj);particleObj.scale.set(1,1,1);a.addChild(particleObj);e=new THREE.SphereGeometry(1,
-16,8);g=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<b.points.length;i++)f=new THREE.Mesh(e,g),f.position.copy(b.points[i]),f.updateMatrix(),a.addChild(f)}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.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.heightSpeed?this.tdiff*((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;var c=this.tdiff*this.movementSpeed;(this.moveForward||this.autoForward&&!this.moveBackward)&&this.translateZ(-(c+this.autoSpeedFactor));this.moveBackward&&this.translateZ(c);this.moveLeft&&this.translateX(-c);this.moveRight&&this.translateX(c);c=this.tdiff*this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&
+(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var a=this.target.position,f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=
+(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;a=this.target.position;f=this.position;a.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);a.y=f.y+100*Math.cos(this.phi);a.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(a){a.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(a,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(a));this.target.position.addSelf(c.multiplyScalar(a))};
+THREE.PathCamera=function(a){function c(a,b,c,e){var g={name:c,fps:0.6,length:e,hierarchy:[]},h,f=b.getControlPointsArray(),j=b.getLength(),k=f.length,y=0;h=k-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[h]={time:e,pos:f[h],rot:[0,0,0,1],scl:[1,1,1]};for(h=1;h<k-1;h++)y=e*j.chunks[h]/j.total,b.keys[h]={time:y,pos:f[h]};g.hierarchy[0]=b;THREE.AnimationHandler.add(g);return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(a,b){var c,
+e,g=new THREE.Geometry;for(c=0;c<a.points.length*b;c++)e=c/(a.points.length*b),e=a.getPoint(e),g.vertices[c]=new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z));return g}function g(a,c){var e=b(c,10),g=b(c,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(e,h);particleObj=new THREE.ParticleSystem(g,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);a.addChild(lineObj);particleObj.scale.set(1,1,1);a.addChild(particleObj);g=new THREE.SphereGeometry(1,
+16,8);h=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)e=new THREE.Mesh(g,h),e.position.copy(c.points[i]),e.updateMatrix(),a.addChild(e)}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.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,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==void 0)this.duration=a.duration*1E3;if(a.waypoints!==void 0)this.waypoints=a.waypoints;if(a.useConstantSpeed!==void 0)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==void 0)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==void 0)this.createDebugPath=a.createDebugPath;if(a.createDebugDummy!==
 void 0)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==void 0)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==void 0)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==void 0)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==void 0)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==void 0)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==void 0)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=
-window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var e=Math.PI*2,h=Math.PI/180;this.update=function(a,c,b){var f,g;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;f=this.phi%e;this.phi=f>=0?f:f+e;f=this.verticalAngleMap.srcRange;g=this.verticalAngleMap.dstRange;var j=g[1]-g[0];this.phi=
-TWEEN.Easing.Quadratic.EaseInOut(((this.phi-f[0])*(g[1]-g[0])/(f[1]-f[0])+g[0]-g[0])/j)*j+g[0];f=this.horizontalAngleMap.srcRange;g=this.horizontalAngleMap.dstRange;j=g[1]-g[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-f[0])*(g[1]-g[0])/(f[1]-f[0])+g[0]-g[0])/j)*j+g[0];f=this.target.position;f.x=100*Math.sin(this.phi)*Math.cos(this.theta);f.y=100*Math.cos(this.phi);f.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,a,c,b)};this.onMouseMove=function(a){this.mouseX=
-a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),f=new THREE.MeshLambertMaterial({color:65280}),j=new THREE.CubeGeometry(10,10,20),k=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(k,f);a.position.set(0,10,0);this.animation=
-b(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else this.animation=b(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&g(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(a,c){return function(){c.apply(a,arguments)}}(this,this.onMouseMove),
+window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var f=Math.PI*2,h=Math.PI/180;this.update=function(a,b,c){var e,g;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;e=this.phi%f;this.phi=e>=0?e:e+f;e=this.verticalAngleMap.srcRange;g=this.verticalAngleMap.dstRange;var j=g[1]-g[0];this.phi=
+TWEEN.Easing.Quadratic.EaseInOut(((this.phi-e[0])*(g[1]-g[0])/(e[1]-e[0])+g[0]-g[0])/j)*j+g[0];e=this.horizontalAngleMap.srcRange;g=this.horizontalAngleMap.dstRange;j=g[1]-g[0];this.theta=TWEEN.Easing.Quadratic.EaseInOut(((this.theta-e[0])*(g[1]-g[0])/(e[1]-e[0])+g[0]-g[0])/j)*j+g[0];e=this.target.position;e.x=100*Math.sin(this.phi)*Math.cos(this.theta);e.y=100*Math.cos(this.phi);e.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,a,b,c)};this.onMouseMove=function(a){this.mouseX=
+a.clientX-this.windowHalfX;this.mouseY=a.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),e=new THREE.MeshLambertMaterial({color:65280}),j=new THREE.CubeGeometry(10,10,20),k=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(j,a);a=new THREE.Mesh(k,e);a.position.set(0,10,0);this.animation=
+c(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else this.animation=c(this.animationParent,this.spline,this.id,this.duration),this.animationParent.addChild(this.target),this.animationParent.addChild(this);this.createDebugPath&&g(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(a,b){return function(){b.apply(a,arguments)}}(this,this.onMouseMove),
 !1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
-THREE.FlyCamera=function(a){function b(a,b){return function(){b.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.domElement=document;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==void 0)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==void 0)this.dragToLook=a.dragToLook;if(a.autoForward!==void 0)this.autoForward=
+THREE.FlyCamera=function(a){function c(a,c){return function(){c.apply(a,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.tmpQuaternion=new THREE.Quaternion;this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.domElement=document;if(a){if(a.movementSpeed!==void 0)this.movementSpeed=a.movementSpeed;if(a.rollSpeed!==void 0)this.rollSpeed=a.rollSpeed;if(a.dragToLook!==void 0)this.dragToLook=a.dragToLook;if(a.autoForward!==void 0)this.autoForward=
 a.autoForward;if(a.domElement!==void 0)this.domElement=a.domElement}this.useTarget=!1;this.useQuaternion=!0;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.lastUpdate=-1;this.tdiff=0;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=
 0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};
 this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;
-case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var b=this.getContainerDimensions(),e=b.size[0]/2,h=b.size[1]/2;this.moveState.yawLeft=-(a.clientX-b.offset[0]-e)/e;this.moveState.pitchDown=(a.clientY-
-b.offset[1]-h)/h;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;var a=this.tdiff*this.movementSpeed,b=this.tdiff*
-this.rollSpeed;this.translateX(this.moveVector.x*a);this.translateY(this.moveVector.y*a);this.translateZ(this.moveVector.z*a);this.tmpQuaternion.set(this.rotationVector.x*b,this.rotationVector.y*b,this.rotationVector.z*b,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var a=this.moveState.forward||
+case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}};this.mousemove=function(a){if(!this.dragToLook||this.mouseStatus>0){var c=this.getContainerDimensions(),f=c.size[0]/2,h=c.size[1]/2;this.moveState.yawLeft=-(a.clientX-c.offset[0]-f)/f;this.moveState.pitchDown=(a.clientY-
+c.offset[1]-h)/h;this.updateRotationVector()}};this.mouseup=function(a){a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus--,this.moveState.yawLeft=this.moveState.pitchDown=0;else switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.updateRotationVector()};this.update=function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.tdiff=(a-this.lastUpdate)/1E3;this.lastUpdate=a;var a=this.tdiff*this.movementSpeed,c=this.tdiff*
+this.rollSpeed;this.translateX(this.moveVector.x*a);this.translateY(this.moveVector.y*a);this.translateZ(this.moveVector.z*a);this.tmpQuaternion.set(this.rotationVector.x*c,this.rotationVector.y*c,this.rotationVector.z*c,1).normalize();this.quaternion.multiplySelf(this.tmpQuaternion);this.matrix.setPosition(this.position);this.matrix.setRotationFromQuaternion(this.quaternion);this.matrixWorldNeedsUpdate=!0;this.supr.update.call(this)};this.updateMovementVector=function(){var a=this.moveState.forward||
 this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-a+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=-this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=
-document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",b(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",b(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",b(this,this.mouseup),!1);window.addEventListener("keydown",b(this,this.keydown),!1);window.addEventListener("keyup",b(this,
+document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,this.mouseup),!1);window.addEventListener("keydown",c(this,this.keydown),!1);window.addEventListener("keyup",c(this,
 this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype;
-THREE.RollCamera=function(a,b,c,g){THREE.Camera.call(this,a,b,c,g);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var e=new THREE.Vector3,h=new THREE.Vector3,f=new THREE.Vector3,j=new THREE.Matrix4,k=!1,l=1,m=0,o=0,n=0,t=0,v=0,y=window.innerWidth/2,u=window.innerHeight/2;this.update=
-function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.delta=(a-this.lastUpdate)/1E3;this.lastUpdate=a;this.mouseLook&&(a=this.delta*this.lookSpeed,this.rotateHorizontally(a*t),this.rotateVertically(a*v));a=this.delta*this.movementSpeed;this.translateZ(a*(m>0||this.autoForward&&!(m<0)?1:m));this.translateX(a*o);this.translateY(a*n);k&&(this.roll+=this.rollSpeed*this.delta*l);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();
-else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();f.copy(this.forward);h.set(0,1,0);e.cross(h,f).normalize();h.cross(f,e).normalize();this.matrix.n11=e.x;this.matrix.n12=h.x;this.matrix.n13=f.x;this.matrix.n21=e.y;this.matrix.n22=h.y;this.matrix.n23=f.y;this.matrix.n31=e.z;this.matrix.n32=h.z;this.matrix.n33=f.z;j.identity();j.n11=Math.cos(this.roll);j.n12=-Math.sin(this.roll);j.n21=Math.sin(this.roll);j.n22=Math.cos(this.roll);this.matrix.multiplySelf(j);
+THREE.RollCamera=function(a,c,b,g){THREE.Camera.call(this,a,c,b,g);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var f=new THREE.Vector3,h=new THREE.Vector3,e=new THREE.Vector3,j=new THREE.Matrix4,k=!1,l=1,m=0,n=0,o=0,p=0,w=0,t=window.innerWidth/2,v=window.innerHeight/2;this.update=
+function(){var a=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=a;this.delta=(a-this.lastUpdate)/1E3;this.lastUpdate=a;this.mouseLook&&(a=this.delta*this.lookSpeed,this.rotateHorizontally(a*p),this.rotateVertically(a*w));a=this.delta*this.movementSpeed;this.translateZ(a*(m>0||this.autoForward&&!(m<0)?1:m));this.translateX(a*n);this.translateY(a*o);k&&(this.roll+=this.rollSpeed*this.delta*l);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();
+else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();e.copy(this.forward);h.set(0,1,0);f.cross(h,e).normalize();h.cross(e,f).normalize();this.matrix.n11=f.x;this.matrix.n12=h.x;this.matrix.n13=e.x;this.matrix.n21=f.y;this.matrix.n22=h.y;this.matrix.n23=e.y;this.matrix.n31=f.z;this.matrix.n32=h.z;this.matrix.n33=e.z;j.identity();j.n11=Math.cos(this.roll);j.n12=-Math.sin(this.roll);j.n21=Math.sin(this.roll);j.n22=Math.cos(this.roll);this.matrix.multiplySelf(j);
 this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(a){this.position.x+=this.matrix.n11*a;this.position.y+=this.matrix.n21*a;this.position.z+=this.matrix.n31*a};this.translateY=function(a){this.position.x+=this.matrix.n12*a;this.position.y+=this.matrix.n22*a;this.position.z+=this.matrix.n32*a};this.translateZ=function(a){this.position.x-=this.matrix.n13*a;this.position.y-=
-this.matrix.n23*a;this.position.z-=this.matrix.n33*a};this.rotateHorizontally=function(a){e.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);e.multiplyScalar(a);this.forward.subSelf(e);this.forward.normalize()};this.rotateVertically=function(a){h.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);h.multiplyScalar(a);this.forward.addSelf(h);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",
-function(a){t=(a.clientX-y)/window.innerWidth;v=(a.clientY-u)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:m=1;break;case 2:m=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:m=0;break;case 2:m=0}},!1);this.domElement.addEventListener("keydown",function(a){switch(a.keyCode){case 38:case 87:m=1;break;case 37:case 65:o=-1;break;
-case 40:case 83:m=-1;break;case 39:case 68:o=1;break;case 81:k=!0;l=1;break;case 69:k=!0;l=-1;break;case 82:n=1;break;case 70:n=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:m=0;break;case 37:case 65:o=0;break;case 40:case 83:m=0;break;case 39:case 68:o=0;break;case 81:k=!1;break;case 69:k=!1;break;case 82:n=0;break;case 70:n=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
+this.matrix.n23*a;this.position.z-=this.matrix.n33*a};this.rotateHorizontally=function(a){f.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);f.multiplyScalar(a);this.forward.subSelf(f);this.forward.normalize()};this.rotateVertically=function(a){h.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);h.multiplyScalar(a);this.forward.addSelf(h);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",
+function(a){p=(a.clientX-t)/window.innerWidth;w=(a.clientY-v)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:m=1;break;case 2:m=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:m=0;break;case 2:m=0}},!1);this.domElement.addEventListener("keydown",function(a){switch(a.keyCode){case 38:case 87:m=1;break;case 37:case 65:n=-1;break;
+case 40:case 83:m=-1;break;case 39:case 68:n=1;break;case 81:k=!0;l=1;break;case 69:k=!0;l=-1;break;case 82:o=1;break;case 70:o=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:m=0;break;case 37:case 65:n=0;break;case 40:case 83:m=0;break;case 39:case 68:n=0;break;case 81:k=!1;break;case 69:k=!1;break;case 82:o=0;break;case 70:o=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
 THREE.RollCamera.prototype.supr=THREE.Camera.prototype;
-THREE.TrackballCamera=function(a){function b(a,c){return function(){c.apply(a,arguments)}}a=a||{};THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.domElement=a.domElement||document;this.screen=a.screen||{width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=a.radius||(this.screen.width+this.screen.height)/4;this.rotateSpeed=a.rotateSpeed||1;this.zoomSpeed=a.zoomSpeed||1.2;this.panSpeed=a.panSpeed||0.3;this.noZoom=a.noZoom||!1;this.noPan=a.noPan||
-!1;this.staticMoving=a.staticMoving||!1;this.dynamicDampingFactor=a.dynamicDampingFactor||0.2;this.minDistance=a.minDistance||0;this.maxDistance=a.maxDistance||Infinity;this.keys=a.keys||[65,83,68];this.useTarget=!0;var c=!1,g=this.STATE.NONE,e=new THREE.Vector3,h=new THREE.Vector3,f=new THREE.Vector3,j=new THREE.Vector2,k=new THREE.Vector2,l=new THREE.Vector2,m=new THREE.Vector2;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,c){return new THREE.Vector2((a-
-this.screen.offsetLeft)/this.radius*0.5,(c-this.screen.offsetTop)/this.radius*0.5)};this.getMouseProjectionOnBall=function(a,c){var b=new THREE.Vector3((a-this.screen.width*0.5-this.screen.offsetLeft)/this.radius,(this.screen.height*0.5+this.screen.offsetTop-c)/this.radius,0),f=b.length();f>1?b.normalize():b.z=Math.sqrt(1-f*f);e=this.position.clone().subSelf(this.target.position);f=this.up.clone().setLength(b.y);f.addSelf(this.up.clone().crossSelf(e).setLength(b.x));f.addSelf(e.setLength(b.z));return f};
-this.rotateCamera=function(){var a=Math.acos(h.dot(f)/h.length()/f.length());if(a){var c=(new THREE.Vector3).cross(h,f).normalize(),b=new THREE.Quaternion;a*=this.rotateSpeed;b.setFromAxisAngle(c,-a);b.multiplyVector3(e);b.multiplyVector3(this.up);b.multiplyVector3(f);this.staticMoving?h=f:(b.setFromAxisAngle(c,a*(this.dynamicDampingFactor-1)),b.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-j.y)*this.zoomSpeed;a!==1&&a>0&&(e.multiplyScalar(a),this.staticMoving?j=k:j.y+=(k.y-j.y)*this.dynamicDampingFactor)};
-this.panCamera=function(){var a=m.clone().subSelf(l);if(a.lengthSq()){a.multiplyScalar(e.length()*this.panSpeed);var c=e.clone().crossSelf(this.up).setLength(a.x);c.addSelf(this.up.clone().setLength(a.y));this.position.addSelf(c);this.target.position.addSelf(c);this.staticMoving?l=m:l.addSelf(a.sub(m,l).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance),
-e.lengthSq()<this.minDistance*this.minDistance&&this.position.add(this.target.position,e.setLength(this.minDistance))};this.update=function(a,c,b){e=this.position.clone().subSelf(this.target.position);this.rotateCamera();this.noZoom||this.zoomCamera();this.noPan||this.panCamera();this.position.add(this.target.position,e);this.checkDistances();this.supr.update.call(this,a,c,b)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",
-b(this,function(a){c&&(h=f=this.getMouseProjectionOnBall(a.clientX,a.clientY),j=k=this.getMouseOnScreen(a.clientX,a.clientY),l=m=this.getMouseOnScreen(a.clientX,a.clientY),c=!1);g!==this.STATE.NONE&&(g===this.STATE.ROTATE?f=this.getMouseProjectionOnBall(a.clientX,a.clientY):g===this.STATE.ZOOM&&!this.noZoom?k=this.getMouseOnScreen(a.clientX,a.clientY):g===this.STATE.PAN&&!this.noPan&&(m=this.getMouseOnScreen(a.clientX,a.clientY)))}),!1);this.domElement.addEventListener("mousedown",b(this,function(a){a.preventDefault();
-a.stopPropagation();if(g===this.STATE.NONE)g=a.button,g===this.STATE.ROTATE?h=f=this.getMouseProjectionOnBall(a.clientX,a.clientY):g===this.STATE.ZOOM&&!this.noZoom?j=k=this.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(l=m=this.getMouseOnScreen(a.clientX,a.clientY))}),!1);this.domElement.addEventListener("mouseup",b(this,function(a){a.preventDefault();a.stopPropagation();g=this.STATE.NONE}),!1);window.addEventListener("keydown",b(this,function(a){if(g===this.STATE.NONE){if(a.keyCode===this.keys[this.STATE.ROTATE])g=
-this.STATE.ROTATE;else if(a.keyCode===this.keys[this.STATE.ZOOM]&&!this.noZoom)g=this.STATE.ZOOM;else if(a.keyCode===this.keys[this.STATE.PAN]&&!this.noPan)g=this.STATE.PAN;g!==this.STATE.NONE&&(c=!0)}}),!1);window.addEventListener("keyup",b(this,function(){if(g!==this.STATE.NONE)g=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.Path=function(a){this.actions=[];a&&this.fromPoints(a)};THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru"};THREE.Path.prototype.fromPoints=function(a){var b=0,c=a.length;this.moveTo(a[0].x,a[0].y);for(b=1;b<c;b++)this.lineTo(a[b].x,a[b].y)};
-THREE.Path.prototype.moveTo=function(){var a=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:a})};THREE.Path.prototype.lineTo=function(){var a=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.LINE_TO,args:a})};THREE.Path.prototype.quadraticCurveTo=function(){var a=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:a})};
-THREE.Path.prototype.bezierCurveTo=function(){var a=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:a})};THREE.Path.prototype.splineThru=function(){var a=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:a})};
-THREE.Path.prototype.getPoints=function(a){var a=a||12,b=[],c,g,e,h,f,j,k,l,m,o,n,t,v;c=0;for(g=this.actions.length;c<g;c++)switch(e=this.actions[c],h=e.action,e=e.args,h){case THREE.PathActions.LINE_TO:b.push(new THREE.Vector2(e[0],e[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=e[2];f=e[3];l=e[0];m=e[1];b.length>0?(n=b[b.length-1],o=n.x,n=n.y):(n=this.actions[c-1].args,o=n[n.length-2],n=n[n.length-1]);for(e=1;e<=a;e++)t=e/a,v=THREE.FontUtils.b2(t,o,l,h),t=THREE.FontUtils.b2(t,n,m,f),b.push(new THREE.Vector2(v,
-t));break;case THREE.PathActions.BEZIER_CURVE_TO:h=e[4];f=e[5];l=e[0];m=e[1];j=e[2];k=e[3];b.length>0?(n=b[b.length-1],o=n.x,n=n.y):(n=this.actions[c-1].args,o=n[n.length-2],n=n[n.length-1]);for(e=1;e<=a;e++)t=e/a,v=THREE.FontUtils.b3(t,o,l,j,h),t=THREE.FontUtils.b3(t,n,m,k,f),b.push(new THREE.Vector2(v,t));break;case THREE.PathActions.CSPLINE_THRU:n=this.actions[c-1].args;j=new THREE.Vector2(n[n.length-2],n[n.length-1]);h=e[0];f=a*h.length;h.unshift(j);j=new Spline2;for(e=0;e<f;e++)b.push(j.get2DPoint(h,
-e/f))}return b};var Spline2=function(){function a(a,c,b,e,g){var a=(b-a)*0.5,e=(e-c)*0.5,h=g*g;return(2*c-2*b+a+e)*g*h+(-3*c+3*b-2*a-e)*h+a*g+c}var b=[],c,g,e,h;this.get2DPoint=function(f,j){c=new THREE.Vector2;g=(f.length-1)*j;e=Math.floor(g);h=g-e;b[0]=e==0?e:e-1;b[1]=e;b[2]=e>f.length-2?e:e+1;b[3]=e>f.length-3?e:e+2;c.x=a(f[b[0]].x,f[b[1]].x,f[b[2]].x,f[b[3]].x,h);c.y=a(f[b[0]].y,f[b[1]].y,f[b[2]].y,f[b[3]].y,h);return c}};
-THREE.Path.prototype.getMinAndMax=function(){var a=this.getPoints(),b,c,g,e;b=c=Number.NEGATIVE_INFINITY;g=e=Number.POSITIVE_INFINITY;var h,f,j;f=0;for(j=a.length;f<j;f++){h=a[f];if(h.x>b)b=h.x;else if(h.x<g)g=h.x;if(h.y>c)c=h.y;else if(h.y<c)e=h.y}return{minX:g,minY:e,maxX:b,maxY:c}};
-THREE.Path.prototype.debug=function(a){var b=this.getMinAndMax();a||(a=document.createElement("canvas"),a.setAttribute("width",b.maxX+100),a.setAttribute("height",b.maxY+100),document.body.appendChild(a));b=a.getContext("2d");b.fillStyle="white";b.fillRect(0,0,a.width,a.height);b.strokeStyle="black";b.beginPath();var c,g,e,a=0;for(c=this.actions.length;a<c;a++)g=this.actions[a],e=g.args,g=g.action,g!=THREE.PathActions.CSPLINE_THRU&&b[g].apply(b,e);b.stroke();b.closePath();b.strokeStyle="red";g=this.getPoints();
-a=0;for(c=g.length;a<c;a++)e=g[a],b.beginPath(),b.arc(e.x,e.y,1.5,0,Math.PI*2,!1),b.stroke(),b.closePath()};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=new THREE.Path;THREE.Shape.prototype.constructor=THREE.Path;THREE.Shape.prototype.triangulate=function(){var a=this.getPoints();THREE.FontUtils.Triangulate.area(a)>0&&(a=a.reverse());return THREE.FontUtils.Triangulate(a,!0)};
-THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)};
-THREE.CubeGeometry=function(a,b,c,g,e,h,f,j,k){function l(a,c,b,f,j,k,l,o){var t,n,v=g||1,y=e||1,C=j/2,J=k/2,L=m.vertices.length;if(a=="x"&&c=="y"||a=="y"&&c=="x")t="z";else if(a=="x"&&c=="z"||a=="z"&&c=="x")t="y",y=h||1;else if(a=="z"&&c=="y"||a=="y"&&c=="z")t="x",v=h||1;var H=v+1,N=y+1;j/=v;var O=k/y;for(n=0;n<N;n++)for(k=0;k<H;k++){var B=new THREE.Vector3;B[a]=(k*j-C)*b;B[c]=(n*O-J)*f;B[t]=l;m.vertices.push(new THREE.Vertex(B))}for(n=0;n<y;n++)for(k=0;k<v;k++)m.faces.push(new THREE.Face4(k+H*n+
-L,k+H*(n+1)+L,k+1+H*(n+1)+L,k+1+H*n+L,null,null,o)),m.faceVertexUvs[0].push([new THREE.UV(k/v,n/y),new THREE.UV(k/v,(n+1)/y),new THREE.UV((k+1)/v,(n+1)/y),new THREE.UV((k+1)/v,n/y)])}THREE.Geometry.call(this);var m=this,o=a/2,n=b/2,t=c/2,j=j?-1:1;if(f!==void 0)if(f instanceof Array)this.materials=f;else{this.materials=[];for(var v=0;v<6;v++)this.materials.push([f])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=void 0)for(var y in k)this.sides[y]!=void 0&&(this.sides[y]=
-k[y]);this.sides.px&&l("z","y",1*j,-1,c,b,-o,this.materials[0]);this.sides.nx&&l("z","y",-1*j,-1,c,b,o,this.materials[1]);this.sides.py&&l("x","z",1*j,1,a,c,n,this.materials[2]);this.sides.ny&&l("x","z",1*j,-1,a,c,-n,this.materials[3]);this.sides.pz&&l("x","y",1*j,-1,a,b,t,this.materials[4]);this.sides.nz&&l("x","y",-1*j,-1,a,b,-t,this.materials[5]);(function(){for(var a=[],c=[],b=0,f=m.vertices.length;b<f;b++){for(var e=m.vertices[b],g=!1,h=0,j=a.length;h<j;h++){var k=a[h];if(e.position.x==k.position.x&&
-e.position.y==k.position.y&&e.position.z==k.position.z){c[b]=h;g=!0;break}}if(!g)c[b]=a.length,a.push(new THREE.Vertex(e.position.clone()))}b=0;for(f=m.faces.length;b<f;b++)e=m.faces[b],e.a=c[e.a],e.b=c[e.b],e.c=c[e.c],e.d=c[e.d];m.vertices=a})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
-THREE.CylinderGeometry=function(a,b,c,g,e,h){function f(a,c,b){j.vertices.push(new THREE.Vertex(new THREE.Vector3(a,c,b)))}THREE.Geometry.call(this);var j=this,k,l=Math.PI*2,m=g/2;for(k=0;k<a;k++)f(Math.sin(l*k/a)*b,Math.cos(l*k/a)*b,-m);for(k=0;k<a;k++)f(Math.sin(l*k/a)*c,Math.cos(l*k/a)*c,m);for(k=0;k<a;k++)j.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(c>0){f(0,0,-m-(h||0));for(k=a;k<a+a/2;k++)j.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(b>0){f(0,0,m+
-(e||0));for(k=a+a/2;k<2*a;k++)j.faces.push(new THREE.Face4(2*a+1,(2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a))}k=0;for(a=this.faces.length;k<a;k++){var b=[],c=this.faces[k],e=this.vertices[c.a],h=this.vertices[c.b],m=this.vertices[c.c],o=this.vertices[c.d];b.push(new THREE.UV(0.5+Math.atan2(e.position.x,e.position.y)/l,0.5+e.position.z/g));b.push(new THREE.UV(0.5+Math.atan2(h.position.x,h.position.y)/l,0.5+h.position.z/g));b.push(new THREE.UV(0.5+Math.atan2(m.position.x,m.position.y)/l,0.5+m.position.z/
-g));c instanceof THREE.Face4&&b.push(new THREE.UV(0.5+Math.atan2(o.position.x,o.position.y)/l,0.5+o.position.z/g));this.faceVertexUvs[0].push(b)}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
-THREE.ExtrudeGeometry=function(a,b){function c(a,c,b){t.vertices.push(new THREE.Vertex(new THREE.Vector3(a,c,b)))}function g(a,c,b){y?t.faces.push(new THREE.Face3(b,c,a)):t.faces.push(new THREE.Face3(a,c,b))}function e(a,c,b,f){y?t.faces.push(new THREE.Face4(f,b,c,a)):t.faces.push(new THREE.Face4(a,c,b,f))}var h=b.amount!==void 0?b.amount:100,f=b.bezelThickness!==void 0?b.bezelThickness:10,j=b.bezelEnabled!==void 0?b.bezelEnabled:!1,k=b.steps!==void 0?b.steps:1,l=b.path!==void 0?b.path:null,m,o=!1;
-if(l)m=l.getPoints(),k=m.length,o=!0;THREE.Geometry.call(this);var l=a.getPoints(),n=a.triangulate(),t=this,v=[],y=THREE.FontUtils.Triangulate.area(l)>0,u,w,x=l.length,p,z=n.length,A=v.length;for(u=0;u<x;u++)w=l[u],c(w.x,w.y,0);for(p=1;p<=k;p++)for(u=0;u<x;u++)w=l[u],o?c(w.x,w.y+m[p-1].y,m[p-1].x):c(w.x,w.y,h/k*p);if(j){for(u=0;u<A;u++)p=v[u],c(p.x,p.y,f);for(u=0;u<A;u++)p=v[u],c(p.x,p.y,h-f)}for(u=0;u<z;u++)p=n[u],g(p[2],p[1],p[0]);for(u=0;u<z;u++)p=n[u],g(p[0]+x*k,p[1]+x*k,p[2]+x*k);for(u=l.length;--u>=
-0;){h=u;f=u-1;f<0&&(f=l.length-1);for(p=0;p<k;p++)n=x*p,z=x*(p+1),e(h+n,f+n,f+z,h+z)}this.computeCentroids();this.computeFaceNormals()};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
-THREE.IcosahedronGeometry=function(a){function b(a,c,b){var f=Math.sqrt(a*a+c*c+b*b);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(a/f,c/f,b/f)))-1}function c(a,c,b,f){f.faces.push(new THREE.Face3(a,c,b))}function g(a,c){var f=e.vertices[a].position,g=e.vertices[c].position;return b((f.x+g.x)/2,(f.y+g.y)/2,(f.z+g.z)/2)}var e=this,h=new THREE.Geometry,f;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,
--a);b(0,1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,h);c(0,5,1,h);c(0,1,7,h);c(0,7,10,h);c(0,10,11,h);c(1,5,9,h);c(5,11,4,h);c(11,10,2,h);c(10,7,6,h);c(7,1,8,h);c(3,9,4,h);c(3,4,2,h);c(3,2,6,h);c(3,6,8,h);c(3,8,9,h);c(4,9,5,h);c(2,4,11,h);c(6,2,10,h);c(8,6,7,h);c(9,8,1,h);for(a=0;a<this.subdivisions;a++){f=new THREE.Geometry;for(var j in h.faces){var k=g(h.faces[j].a,h.faces[j].b),l=g(h.faces[j].b,h.faces[j].c),m=g(h.faces[j].c,h.faces[j].a);c(h.faces[j].a,k,m,f);c(h.faces[j].b,l,k,f);
-c(h.faces[j].c,m,l,f);c(k,l,m,f)}h.faces=f.faces}e.faces=h.faces;delete h;delete f;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
-THREE.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;this.angle=c||2*Math.PI;for(var b=this.angle/this.steps,c=[],g=[],e=[],h=[],f=(new THREE.Matrix4).setRotationZ(b),j=0;j<a.length;j++)this.vertices.push(new THREE.Vertex(a[j])),c[j]=a[j].clone(),g[j]=this.vertices.length-1;for(var k=0;k<=this.angle+0.0010;k+=b){for(j=0;j<c.length;j++)k<this.angle?(c[j]=f.multiplyVector3(c[j].clone()),this.vertices.push(new THREE.Vertex(c[j])),e[j]=this.vertices.length-1):e=h;k==0&&(h=g);
-for(j=0;j<g.length-1;j++)this.faces.push(new THREE.Face4(e[j],e[j+1],g[j+1],g[j])),this.faceVertexUvs[0].push([new THREE.UV(1-k/this.angle,j/a.length),new THREE.UV(1-k/this.angle,(j+1)/a.length),new THREE.UV(1-(k-b)/this.angle,(j+1)/a.length),new THREE.UV(1-(k-b)/this.angle,j/a.length)]);g=e;e=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
-THREE.PlaneGeometry=function(a,b,c,g){THREE.Geometry.call(this);var e,h=a/2,f=b/2,c=c||1,g=g||1,j=c+1,k=g+1;a/=c;var l=b/g;for(e=0;e<k;e++)for(b=0;b<j;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-h,-(e*l-f),0)));for(e=0;e<g;e++)for(b=0;b<c;b++)this.faces.push(new THREE.Face4(b+j*e,b+j*(e+1),b+1+j*(e+1),b+1+j*e)),this.faceVertexUvs[0].push([new THREE.UV(b/c,e/g),new THREE.UV(b/c,(e+1)/g),new THREE.UV((b+1)/c,(e+1)/g),new THREE.UV((b+1)/c,e/g)]);this.computeCentroids();this.computeFaceNormals()};
+THREE.TrackballCamera=function(a){function c(a,b){return function(){b.apply(a,arguments)}}a=a||{};THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.domElement=a.domElement||document;this.screen=a.screen||{width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=a.radius||(this.screen.width+this.screen.height)/4;this.rotateSpeed=a.rotateSpeed||1;this.zoomSpeed=a.zoomSpeed||1.2;this.panSpeed=a.panSpeed||0.3;this.noZoom=a.noZoom||!1;this.noPan=a.noPan||
+!1;this.staticMoving=a.staticMoving||!1;this.dynamicDampingFactor=a.dynamicDampingFactor||0.2;this.minDistance=a.minDistance||0;this.maxDistance=a.maxDistance||Infinity;this.keys=a.keys||[65,83,68];this.useTarget=!0;var b=!1,g=this.STATE.NONE,f=new THREE.Vector3,h=new THREE.Vector3,e=new THREE.Vector3,j=new THREE.Vector2,k=new THREE.Vector2,l=new THREE.Vector2,m=new THREE.Vector2;this.handleEvent=function(a){if(typeof this[a.type]=="function")this[a.type](a)};this.getMouseOnScreen=function(a,b){return new THREE.Vector2((a-
+this.screen.offsetLeft)/this.radius*0.5,(b-this.screen.offsetTop)/this.radius*0.5)};this.getMouseProjectionOnBall=function(a,b){var c=new THREE.Vector3((a-this.screen.width*0.5-this.screen.offsetLeft)/this.radius,(this.screen.height*0.5+this.screen.offsetTop-b)/this.radius,0),e=c.length();e>1?c.normalize():c.z=Math.sqrt(1-e*e);f=this.position.clone().subSelf(this.target.position);e=this.up.clone().setLength(c.y);e.addSelf(this.up.clone().crossSelf(f).setLength(c.x));e.addSelf(f.setLength(c.z));return e};
+this.rotateCamera=function(){var a=Math.acos(h.dot(e)/h.length()/e.length());if(a){var b=(new THREE.Vector3).cross(h,e).normalize(),c=new THREE.Quaternion;a*=this.rotateSpeed;c.setFromAxisAngle(b,-a);c.multiplyVector3(f);c.multiplyVector3(this.up);c.multiplyVector3(e);this.staticMoving?h=e:(c.setFromAxisAngle(b,a*(this.dynamicDampingFactor-1)),c.multiplyVector3(h))}};this.zoomCamera=function(){var a=1+(k.y-j.y)*this.zoomSpeed;a!==1&&a>0&&(f.multiplyScalar(a),this.staticMoving?j=k:j.y+=(k.y-j.y)*this.dynamicDampingFactor)};
+this.panCamera=function(){var a=m.clone().subSelf(l);if(a.lengthSq()){a.multiplyScalar(f.length()*this.panSpeed);var b=f.clone().crossSelf(this.up).setLength(a.x);b.addSelf(this.up.clone().setLength(a.y));this.position.addSelf(b);this.target.position.addSelf(b);this.staticMoving?l=m:l.addSelf(a.sub(m,l).multiplyScalar(this.dynamicDampingFactor))}};this.checkDistances=function(){if(!this.noZoom||!this.noPan)this.position.lengthSq()>this.maxDistance*this.maxDistance&&this.position.setLength(this.maxDistance),
+f.lengthSq()<this.minDistance*this.minDistance&&this.position.add(this.target.position,f.setLength(this.minDistance))};this.update=function(a,b,c){f=this.position.clone().subSelf(this.target.position);this.rotateCamera();this.noZoom||this.zoomCamera();this.noPan||this.panCamera();this.position.add(this.target.position,f);this.checkDistances();this.supr.update.call(this,a,b,c)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",
+c(this,function(a){b&&(h=e=this.getMouseProjectionOnBall(a.clientX,a.clientY),j=k=this.getMouseOnScreen(a.clientX,a.clientY),l=m=this.getMouseOnScreen(a.clientX,a.clientY),b=!1);g!==this.STATE.NONE&&(g===this.STATE.ROTATE?e=this.getMouseProjectionOnBall(a.clientX,a.clientY):g===this.STATE.ZOOM&&!this.noZoom?k=this.getMouseOnScreen(a.clientX,a.clientY):g===this.STATE.PAN&&!this.noPan&&(m=this.getMouseOnScreen(a.clientX,a.clientY)))}),!1);this.domElement.addEventListener("mousedown",c(this,function(a){a.preventDefault();
+a.stopPropagation();if(g===this.STATE.NONE)g=a.button,g===this.STATE.ROTATE?h=e=this.getMouseProjectionOnBall(a.clientX,a.clientY):g===this.STATE.ZOOM&&!this.noZoom?j=k=this.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(l=m=this.getMouseOnScreen(a.clientX,a.clientY))}),!1);this.domElement.addEventListener("mouseup",c(this,function(a){a.preventDefault();a.stopPropagation();g=this.STATE.NONE}),!1);window.addEventListener("keydown",c(this,function(a){if(g===this.STATE.NONE){if(a.keyCode===this.keys[this.STATE.ROTATE])g=
+this.STATE.ROTATE;else if(a.keyCode===this.keys[this.STATE.ZOOM]&&!this.noZoom)g=this.STATE.ZOOM;else if(a.keyCode===this.keys[this.STATE.PAN]&&!this.noPan)g=this.STATE.PAN;g!==this.STATE.NONE&&(b=!0)}}),!1);window.addEventListener("keyup",c(this,function(){if(g!==this.STATE.NONE)g=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.Curve=function(){};THREE.Curve.prototype.getPoint=function(){console.log("Warning, getPoint() not implemented!");return null};THREE.Curve.prototype.getPointAt=function(a){return this.getPoint(this.getUtoTmapping(a))};THREE.Curve.prototype.getPoints=function(a){a||(a=5);var c,b=[];for(c=0;c<=a;c++)b.push(this.getPoint(c/a));return b};
+THREE.Curve.prototype.getSpacedPoints=function(a){a||(a=5);var c,b=[];for(c=0;c<=a;c++)b.push(this.getPointAt(c/a));return b};THREE.Curve.prototype.getLength=function(){var a=this.getLengths();return a[a.length-1]};THREE.Curve.prototype.getLengths=function(a){a||(a=200);if(this.cacheLengths&&this.cacheLengths.length==a)return this.cacheLengths;var c=[],b,g=this.getPoint(0),f,h=0;for(f=1;f<=a;f++)b=this.getPoint(f/a),h+=b.distanceTo(g),c.push(h),g=b;return this.cacheLengths=c};
+THREE.Curve.prototype.getUtoTmapping=function(a,c){var b=this.getLengths(),g=0,f=b.length,h;for(h=c?c:a*b[f-1];g<f;){if(b[g]>h)break;g++}return g/f};THREE.LineCurve=function(a,c,b,g){this.x1=a;this.y1=c;this.x2=b;this.y2=g};THREE.LineCurve.prototype=new THREE.Curve;THREE.LineCurve.prototype.constructor=THREE.LineCurve;THREE.LineCurve.prototype.getPoint=function(a){return new THREE.Vector2(this.x1+(this.x2-this.x1)*a,this.y1+(this.y2-this.y1)*a)};
+THREE.QuadraticBezierCurve=function(a,c,b,g,f,h){this.x0=a;this.y0=c;this.x1=b;this.y1=g;this.x2=f;this.y2=h};THREE.QuadraticBezierCurve.prototype=new THREE.Curve;THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve;THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var c;c=THREE.FontUtils.b2(a,this.x0,this.x1,this.x2);a=THREE.FontUtils.b2(a,this.y0,this.y1,this.y2);return new THREE.Vector2(c,a)};
+THREE.QuadraticBezierCurve.prototype.getNormalVector=function(a){var c;c=THREE.Curve.Utils.tangentQuadraticBezier(a,this.x0,this.x1,this.x2);a=THREE.Curve.Utils.tangentQuadraticBezier(a,this.y0,this.y1,this.y2);return(new THREE.Vector2(-a,c)).unit()};THREE.CubicBezierCurve=function(a,c,b,g,f,h,e,j){this.x0=a;this.y0=c;this.x1=b;this.y1=g;this.x2=f;this.y2=h;this.x3=e;this.y3=j};THREE.CubicBezierCurve.prototype=new THREE.Curve;THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve;
+THREE.CubicBezierCurve.prototype.getPoint=function(a){var c;c=THREE.FontUtils.b3(a,this.x0,this.x1,this.x2,this.x3);a=THREE.FontUtils.b3(a,this.y0,this.y1,this.y2,this.y3);return new THREE.Vector2(c,a)};THREE.SplineCurve=function(a){this.points=a};THREE.SplineCurve.prototype=new THREE.Curve;THREE.SplineCurve.prototype.constructor=THREE.SplineCurve;
+THREE.SplineCurve.prototype.getPoint=function(a){var c=new THREE.Vector2,b=[],g=this.points,f;f=(g.length-1)*a;a=Math.floor(f);f-=a;b[0]=a==0?a:a-1;b[1]=a;b[2]=a>g.length-2?a:a+1;b[3]=a>g.length-3?a:a+2;c.x=THREE.Curve.Utils.interpolate(g[b[0]].x,g[b[1]].x,g[b[2]].x,g[b[3]].x,f);c.y=THREE.Curve.Utils.interpolate(g[b[0]].y,g[b[1]].y,g[b[2]].y,g[b[3]].y,f);return c};THREE.ArcCurve=function(a,c,b,g,f,h){this.aX=a;this.aY=c;this.aRadius=b;this.aStartAngle=g;this.aEndAngle=f;this.aClockwise=h};
+THREE.ArcCurve.prototype=new THREE.Curve;THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.ArcCurve.prototype.getPoint=function(a){var c=this.aEndAngle-this.aStartAngle;this.aClockwise||(a=1-a);a=this.aStartAngle+a*c;return new THREE.Vector2(this.aX+this.aRadius*Math.cos(a),this.aY+this.aRadius*Math.sin(a))};
+THREE.Curve.Utils={tangentQuadraticBezier:function(a,c,b,g){return 2*(1-a)*(b-c)+2*a*(g-b)},tangentSpline:function(){},interpolate:function(a,c,b,g,f){var a=(b-a)*0.5,g=(g-c)*0.5,h=f*f;return(2*c-2*b+a+g)*f*h+(-3*c+3*b-2*a-g)*h+a*f+c}};THREE.Path=function(a){this.actions=[];this.curves=[];a&&this.fromPoints(a)};THREE.PathActions={MOVE_TO:"moveTo",LINE_TO:"lineTo",QUADRATIC_CURVE_TO:"quadraticCurveTo",BEZIER_CURVE_TO:"bezierCurveTo",CSPLINE_THRU:"splineThru",ARC:"arc"};
+THREE.Path.prototype.fromPoints=function(a){this.moveTo(a[0].x,a[0].y);var c,b=a.length;for(c=1;c<b;c++)this.lineTo(a[c].x,a[c].y)};THREE.Path.prototype.moveTo=function(){var a=Array.prototype.slice.call(arguments);this.actions.push({action:THREE.PathActions.MOVE_TO,args:a})};
+THREE.Path.prototype.lineTo=function(a,c){var b=Array.prototype.slice.call(arguments),g=this.actions[this.actions.length-1].args,g=new THREE.LineCurve(g[g.length-2],g[g.length-1],a,c);this.curves.push(g);this.actions.push({action:THREE.PathActions.LINE_TO,args:b,curve:g})};
+THREE.Path.prototype.quadraticCurveTo=function(a,c,b,g){var f=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args,h=new THREE.QuadraticBezierCurve(h[h.length-2],h[h.length-1],a,c,b,g);this.curves.push(h);this.actions.push({action:THREE.PathActions.QUADRATIC_CURVE_TO,args:f,curve:h})};
+THREE.Path.prototype.bezierCurveTo=function(a,c,b,g,f,h){var e=Array.prototype.slice.call(arguments),j=this.actions[this.actions.length-1].args,j=new THREE.CubicBezierCurve(j[j.length-2],j[j.length-1],a,c,b,g,f,h);this.curves.push(j);this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:e,curve:j})};
+THREE.Path.prototype.splineThru=function(a){var c=Array.prototype.slice.call(arguments),b=this.actions[this.actions.length-1].args,b=[new THREE.Vector2(b[b.length-2],b[b.length-1])],b=b.concat(a),b=new THREE.SplineCurve(b);this.curves.push(b);this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:c,curve:b})};
+THREE.Path.prototype.arc=function(a,c,b,g,f,h){var e=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(a,c,b,g,f,h));this.actions.push({action:THREE.PathActions.ARC,args:e})};THREE.Path.prototype.getSpacedPoints=function(a,c){a||(a=40);for(var b=[],g=0;g<a;g++)b.push(this.getPoint(g/a));c&&b.push(b[0]);return b};
+THREE.Path.prototype.getPoints=function(a,c){var a=a||12,b=[],g,f,h,e,j,k,l,m,n,o,p,w,t;g=0;for(f=this.actions.length;g<f;g++)switch(h=this.actions[g],e=h.action,h=h.args,e){case THREE.PathActions.LINE_TO:b.push(new THREE.Vector2(h[0],h[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:j=h[2];k=h[3];n=h[0];o=h[1];b.length>0?(e=b[b.length-1],p=e.x,w=e.y):(e=this.actions[g-1].args,p=e[e.length-2],w=e[e.length-1]);for(e=1;e<=a;e++)t=e/a,h=THREE.FontUtils.b2(t,p,n,j),t=THREE.FontUtils.b2(t,w,o,k),
+b.push(new THREE.Vector2(h,t));break;case THREE.PathActions.BEZIER_CURVE_TO:j=h[4];k=h[5];n=h[0];o=h[1];l=h[2];m=h[3];b.length>0?(e=b[b.length-1],p=e.x,w=e.y):(e=this.actions[g-1].args,p=e[e.length-2],w=e[e.length-1]);for(e=1;e<=a;e++)t=e/a,h=THREE.FontUtils.b3(t,p,n,l,j),t=THREE.FontUtils.b3(t,w,o,m,k),b.push(new THREE.Vector2(h,t));break;case THREE.PathActions.CSPLINE_THRU:e=this.actions[g-1].args;e=[new THREE.Vector2(e[e.length-2],e[e.length-1])];t=a*h[0].length;e=e.concat(h[0]);h=new THREE.SplineCurve(e);
+for(e=1;e<=t;e++)b.push(h.getPointAt(e/t));break;case THREE.PathActions.ARC:e=this.actions[g-1].args;j=h[0];k=h[1];l=h[2];n=h[3];t=h[4];o=!!h[5];m=e[e.length-2];p=e[e.length-1];e.length==0&&(m=p=0);w=t-n;var v=a*2;for(e=1;e<=v;e++)t=e/v,o||(t=1-t),t=n+t*w,h=m+j+l*Math.cos(t),t=p+k+l*Math.sin(t),b.push(new THREE.Vector2(h,t))}c&&b.push(b[0]);return b};
+THREE.Path.prototype.getMinAndMax=function(){var a=this.getPoints(),c,b,g,f;c=b=Number.NEGATIVE_INFINITY;g=f=Number.POSITIVE_INFINITY;var h,e,j;e=0;for(j=a.length;e<j;e++){h=a[e];if(h.x>c)c=h.x;else if(h.x<g)g=h.x;if(h.y>b)b=h.y;else if(h.y<b)f=h.y}return{minX:g,minY:f,maxX:c,maxY:b}};THREE.Path.prototype.getPoint=function(a){for(var c=a*this.getLength(),b=this.sums,a=0;a<b.length;){if(b[a]>=c)return c=b[a]-c,a=this.curves[a],c=1-c/a.getLength(),a.getPointAt(c);a++}return null};
+THREE.Path.prototype.getLength=function(){var a=[],c=0,b,g=this.curves.length;for(b=0;b<g;b++)c+=this.curves[b].getLength(),a.push(c);this.sums=a;return c};THREE.Path.prototype.createPointsGeometry=function(a){return this.createGeometry(this.getPoints(a,!0))};THREE.Path.prototype.createSpacedPointsGeometry=function(a){return this.createGeometry(this.getSpacedPoints(a,!0))};
+THREE.Path.prototype.createGeometry=function(a){for(var c=new THREE.Geometry,b=0;b<a.length;b++)c.vertices.push(new THREE.Vertex(new THREE.Vector3(a[b].x,a[b].y,0)));return c};
+THREE.Path.prototype.transform=function(a){a=new THREE.Path;a.moveTo(0,0);a.quadraticCurveTo(100,20,140,80);console.log(a.cacheArcLengths());var c=this.getMinAndMax(),b=this.getPoints(),g,f,h,e,j,k;g=0;for(f=b.length;g<f;g++)h=b[g],e=h.x,j=h.y,k=e/c.maxX,e=a.getPoint(k),j=a.getNormalVector(k).multiplyScalar(j),h.x=e.x+j.x,h.y=e.y+j.y;return b};
+THREE.Path.prototype.nltransform=function(a,c,b,g,f,h){var e=this.getPoints(),j,k,l,m,n;j=0;for(k=e.length;j<k;j++)l=e[j],m=l.x,n=l.y,l.x=a*m+c*n+b,l.y=g*n+f*m+h;return e};
+THREE.Path.prototype.debug=function(a){var c=this.getMinAndMax();a||(a=document.createElement("canvas"),a.setAttribute("width",c.maxX+100),a.setAttribute("height",c.maxY+100),document.body.appendChild(a));c=a.getContext("2d");c.fillStyle="white";c.fillRect(0,0,a.width,a.height);c.strokeStyle="black";c.beginPath();var b,g,f,a=0;for(b=this.actions.length;a<b;a++)g=this.actions[a],f=g.args,g=g.action,g!=THREE.PathActions.CSPLINE_THRU&&c[g].apply(c,f);c.stroke();c.closePath();c.strokeStyle="red";g=this.transform(0.866,
+-0.866,0,0.5,0.5,-50);a=0;for(b=g.length;a<b;a++)f=g[a],c.beginPath(),c.arc(f.x,f.y,1.5,0,Math.PI*2,!1),c.stroke(),c.closePath()};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=new THREE.Path;THREE.Shape.prototype.constructor=THREE.Path;THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)};THREE.Shape.prototype.getPointsHoles=function(){var a,c=this.holes.length,b=[];for(a=0;a<c;a++)b[a]=this.holes[a].getPoints();return b};
+THREE.Shape.prototype.getSpacedPointsHoles=function(){var a,c=this.holes.length,b=[];for(a=0;a<c;a++)b[a]=this.holes[a].getSpacedPoints();return b};THREE.Shape.prototype.extractAllPoints=function(){return{shape:this.getPoints(),holes:this.getPointsHoles()}};THREE.Shape.prototype.extractAllSpacedPoints=function(){return{shape:this.getSpacedPoints(),holes:this.getSpacedPointsHoles()}};
+THREE.Shape.Utils={removeHoles:function(a,c){var b=a.concat(),g=b.concat(),f,h,e,j,k,l,m,n,o,p,w=[];for(k=0;k<c.length;k++){l=c[k];g=g.concat(l);h=Number.POSITIVE_INFINITY;for(f=0;f<l.length;f++){o=l[f];p=[];for(n=0;n<b.length;n++)m=b[n],m=o.distanceTo(m),p.push(m),m<h&&(h=m,e=f,j=n)}f=j-1>=0?j-1:b.length-1;h=e-1>=0?e-1:l.length-1;var t=[l[e],b[j],b[f]];n=THREE.FontUtils.Triangulate.area(t);var v=[l[e],l[h],b[j]];o=THREE.FontUtils.Triangulate.area(v);p=j;m=e;j+=1;e+=-1;j<0&&(j+=b.length);j%=b.length;
+e<0&&(e+=l.length);e%=l.length;f=j-1>=0?j-1:b.length-1;h=e-1>=0?e-1:l.length-1;t=[l[e],b[j],b[f]];t=THREE.FontUtils.Triangulate.area(t);v=[l[e],l[h],b[j]];v=THREE.FontUtils.Triangulate.area(v);n+o>t+v&&(j=p,e=m,j<0&&(j+=b.length),j%=b.length,e<0&&(e+=l.length),e%=l.length,f=j-1>=0?j-1:b.length-1,h=e-1>=0?e-1:l.length-1);n=b.slice(0,j);o=b.slice(j);p=l.slice(e);m=l.slice(0,e);h=[l[e],l[h],b[j]];w.push([l[e],b[j],b[f]]);w.push(h);b=n.concat(p).concat(m).concat(o)}return{shape:b,isolatedPts:w,allpoints:g}},
+triangulateShape:function(a,c){var b=THREE.Shape.Utils.removeHoles(a,c),g=b.allpoints,f=b.isolatedPts,b=THREE.FontUtils.Triangulate(b.shape,!1),h,e,j,k;for(h=0;h<b.length;h++){k=b[h];for(e=0;e<3;e++)for(j=0;j<g.length;j++)g[j].equals(k[e])&&(k[e]=j)}for(h=0;h<f.length;h++){k=f[h];for(e=0;e<3;e++)for(j=0;j<g.length;j++)g[j].equals(k[e])&&(k[e]=j)}return b.concat(f)},isClockWise:function(a){return THREE.FontUtils.Triangulate.area(a)<0}};
+THREE.CubeGeometry=function(a,c,b,g,f,h,e,j,k){function l(a,b,c,e,j,k,l,n){var p,o,t=g||1,w=f||1,D=j/2,K=k/2,F=m.vertices.length;if(a=="x"&&b=="y"||a=="y"&&b=="x")p="z";else if(a=="x"&&b=="z"||a=="z"&&b=="x")p="y",w=h||1;else if(a=="z"&&b=="y"||a=="y"&&b=="z")p="x",t=h||1;var I=t+1,O=w+1;j/=t;var M=k/w;for(o=0;o<O;o++)for(k=0;k<I;k++){var C=new THREE.Vector3;C[a]=(k*j-D)*c;C[b]=(o*M-K)*e;C[p]=l;m.vertices.push(new THREE.Vertex(C))}for(o=0;o<w;o++)for(k=0;k<t;k++)m.faces.push(new THREE.Face4(k+I*o+
+F,k+I*(o+1)+F,k+1+I*(o+1)+F,k+1+I*o+F,null,null,n)),m.faceVertexUvs[0].push([new THREE.UV(k/t,o/w),new THREE.UV(k/t,(o+1)/w),new THREE.UV((k+1)/t,(o+1)/w),new THREE.UV((k+1)/t,o/w)])}THREE.Geometry.call(this);var m=this,n=a/2,o=c/2,p=b/2,j=j?-1:1;if(e!==void 0)if(e instanceof Array)this.materials=e;else{this.materials=[];for(var w=0;w<6;w++)this.materials.push([e])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=void 0)for(var t in k)this.sides[t]!=void 0&&(this.sides[t]=
+k[t]);this.sides.px&&l("z","y",1*j,-1,b,c,-n,this.materials[0]);this.sides.nx&&l("z","y",-1*j,-1,b,c,n,this.materials[1]);this.sides.py&&l("x","z",1*j,1,a,b,o,this.materials[2]);this.sides.ny&&l("x","z",1*j,-1,a,b,-o,this.materials[3]);this.sides.pz&&l("x","y",1*j,-1,a,c,p,this.materials[4]);this.sides.nz&&l("x","y",-1*j,-1,a,c,-p,this.materials[5]);(function(){for(var a=[],b=[],c=0,e=m.vertices.length;c<e;c++){for(var g=m.vertices[c],h=!1,f=0,j=a.length;f<j;f++){var k=a[f];if(g.position.x==k.position.x&&
+g.position.y==k.position.y&&g.position.z==k.position.z){b[c]=f;h=!0;break}}if(!h)b[c]=a.length,a.push(new THREE.Vertex(g.position.clone()))}c=0;for(e=m.faces.length;c<e;c++)g=m.faces[c],g.a=b[g.a],g.b=b[g.b],g.c=b[g.c],g.d=b[g.d];m.vertices=a})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
+THREE.CylinderGeometry=function(a,c,b,g,f,h){function e(a,b,c){j.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}THREE.Geometry.call(this);var j=this,k,l=Math.PI*2,m=g/2;for(k=0;k<a;k++)e(Math.sin(l*k/a)*c,Math.cos(l*k/a)*c,-m);for(k=0;k<a;k++)e(Math.sin(l*k/a)*b,Math.cos(l*k/a)*b,m);for(k=0;k<a;k++)j.faces.push(new THREE.Face4(k,k+a,a+(k+1)%a,(k+1)%a));if(b>0){e(0,0,-m-(h||0));for(k=a;k<a+a/2;k++)j.faces.push(new THREE.Face4(2*a,(2*k-2*a)%a,(2*k-2*a+1)%a,(2*k-2*a+2)%a))}if(c>0){e(0,0,m+
+(f||0));for(k=a+a/2;k<2*a;k++)j.faces.push(new THREE.Face4(2*a+1,(2*k-2*a+2)%a+a,(2*k-2*a+1)%a+a,(2*k-2*a)%a+a))}k=0;for(a=this.faces.length;k<a;k++){var c=[],b=this.faces[k],f=this.vertices[b.a],h=this.vertices[b.b],m=this.vertices[b.c],n=this.vertices[b.d];c.push(new THREE.UV(0.5+Math.atan2(f.position.x,f.position.y)/l,0.5+f.position.z/g));c.push(new THREE.UV(0.5+Math.atan2(h.position.x,h.position.y)/l,0.5+h.position.z/g));c.push(new THREE.UV(0.5+Math.atan2(m.position.x,m.position.y)/l,0.5+m.position.z/
+g));b instanceof THREE.Face4&&c.push(new THREE.UV(0.5+Math.atan2(n.position.x,n.position.y)/l,0.5+n.position.z/g));this.faceVertexUvs[0].push(c)}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
+THREE.ExtrudeGeometry=function(a,c){function b(a,b,c,e){a=a.clone().subSelf(b);c/=a.length();return a.multiplyScalar(e?1+c:1-c).addSelf(b)}function g(a){for(A=a.length;--A>=0;){O=A;M=A-1;M<0&&(M=a.length-1);for(var b=0,b=0;b<n+m*2;b++){var c=I*b,e=I*(b+1);y.faces.push(new THREE.Face4(C+O+c,C+M+c,C+M+e,C+O+e))}}}function f(a,b,c){y.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function h(a,b,c){y.faces.push(new THREE.Face3(a,b,c))}var e=c.amount!==void 0?c.amount:100,j=c.bevelThickness!==
+void 0?c.bevelThickness:8,k=c.bevelSize!==void 0?c.bevelSize:j,l=c.bevelEnabled!==void 0?c.bevelEnabled:!0,m=c.bevelSegments!==void 0?c.bevelSegments:3;l||(m=0);var n=c.steps!==void 0?c.steps:1,o=c.path!==void 0?c.path:null,p,w=!1;if(o)p=o.getPoints(),n=p.length,w=!0;THREE.Geometry.call(this);var t,v,x,y=this,o=a.extractAllPoints(),u=o.shape,o=o.holes,z=!THREE.Shape.Utils.isClockWise(u);if(z){u=u.reverse();v=0;for(x=o.length;v<x;v++)t=o[v],THREE.Shape.Utils.isClockWise(t)&&(o[v]=t.reverse());z=!1}var z=
+THREE.Shape.Utils.triangulateShape(u,o),B=u;v=0;for(x=o.length;v<x;v++)t=o[v],u=u.concat(t);var A,E,G=new THREE.Vector2;A=0;for(E=B.length;A<E;A++)G.addSelf(B[A]);var H=G.divideScalar(B.length),L=[];v=0;for(x=o.length;v<x;v++){G=new THREE.Vector2;t=o[v];A=0;for(E=t.length;A<E;A++)G.addSelf(t[A]);L[v]=G.divideScalar(t.length)}var J,D,K,F,I=u.length,G=z.length;for(J=m;J>0;J--){t=J/m;K=j*t;D=k*(1-Math.sin((1-t)*Math.PI/2));A=0;for(E=B.length;A<E;A++)F=b(B[A],H,D,!1),f(F.x,F.y,-K);v=0;for(x=o.length;v<
+x;v++){t=o[v];A=0;for(E=t.length;A<E;A++)F=b(t[A],L[v],D,!0),f(F.x,F.y,-K)}}for(A=0;A<I;A++)F=u[A],w?f(F.x,F.y+p[0].y,p[0].x):f(F.x,F.y,0);for(t=1;t<=n;t++)for(A=0;A<I;A++)F=u[A],w?f(F.x,F.y+p[t-1].y,p[t-1].x):f(F.x,F.y,e/n*t);for(J=1;J<=m;J++){t=J/m;K=j*t;D=k*(1-Math.sin((1-t)*Math.PI/2));A=0;for(E=B.length;A<E;A++)F=b(B[A],H,D,!1),f(F.x,F.y,e+K);v=0;for(x=o.length;v<x;v++){t=o[v];A=0;for(E=t.length;A<E;A++)F=b(t[A],L[v],D,!0),w?f(F.x,F.y+p[n-1].y,p[n-1].x+K):f(F.x,F.y,e+K)}}if(l){j=I*0;for(A=0;A<
+G;A++)e=z[A],h(e[2]+j,e[1]+j,e[0]+j);j=I*(n+m*2);for(A=0;A<G;A++)e=z[A],h(e[0]+j,e[1]+j,e[2]+j)}else{for(A=0;A<G;A++)e=z[A],h(e[2],e[1],e[0]);for(A=0;A<G;A++)e=z[A],h(e[0]+I*n,e[1]+I*n,e[2]+I*n)}var O,M,C=0;g(B);C+=B.length;v=0;for(x=o.length;v<x;v++)t=o[v],g(t),C+=t.length;this.computeCentroids();this.computeFaceNormals()};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
+THREE.IcosahedronGeometry=function(a){function c(a,b,c){var e=Math.sqrt(a*a+b*b+c*c);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(a/e,b/e,c/e)))-1}function b(a,b,c,e){e.faces.push(new THREE.Face3(a,b,c))}function g(a,b){var e=f.vertices[a].position,g=f.vertices[b].position;return c((e.x+g.x)/2,(e.y+g.y)/2,(e.z+g.z)/2)}var f=this,h=new THREE.Geometry,e;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,
+-a);c(0,1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);b(0,11,5,h);b(0,5,1,h);b(0,1,7,h);b(0,7,10,h);b(0,10,11,h);b(1,5,9,h);b(5,11,4,h);b(11,10,2,h);b(10,7,6,h);b(7,1,8,h);b(3,9,4,h);b(3,4,2,h);b(3,2,6,h);b(3,6,8,h);b(3,8,9,h);b(4,9,5,h);b(2,4,11,h);b(6,2,10,h);b(8,6,7,h);b(9,8,1,h);for(a=0;a<this.subdivisions;a++){e=new THREE.Geometry;for(var j in h.faces){var k=g(h.faces[j].a,h.faces[j].b),l=g(h.faces[j].b,h.faces[j].c),m=g(h.faces[j].c,h.faces[j].a);b(h.faces[j].a,k,m,e);b(h.faces[j].b,l,k,e);
+b(h.faces[j].c,m,l,e);b(k,l,m,e)}h.faces=e.faces}f.faces=h.faces;delete h;delete e;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.IcosahedronGeometry.prototype=new THREE.Geometry;THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;
+THREE.LatheGeometry=function(a,c,b){THREE.Geometry.call(this);this.steps=c||12;this.angle=b||2*Math.PI;for(var c=this.angle/this.steps,b=[],g=[],f=[],h=[],e=(new THREE.Matrix4).setRotationZ(c),j=0;j<a.length;j++)this.vertices.push(new THREE.Vertex(a[j])),b[j]=a[j].clone(),g[j]=this.vertices.length-1;for(var k=0;k<=this.angle+0.0010;k+=c){for(j=0;j<b.length;j++)k<this.angle?(b[j]=e.multiplyVector3(b[j].clone()),this.vertices.push(new THREE.Vertex(b[j])),f[j]=this.vertices.length-1):f=h;k==0&&(h=g);
+for(j=0;j<g.length-1;j++)this.faces.push(new THREE.Face4(f[j],f[j+1],g[j+1],g[j])),this.faceVertexUvs[0].push([new THREE.UV(1-k/this.angle,j/a.length),new THREE.UV(1-k/this.angle,(j+1)/a.length),new THREE.UV(1-(k-c)/this.angle,(j+1)/a.length),new THREE.UV(1-(k-c)/this.angle,j/a.length)]);g=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
+THREE.PlaneGeometry=function(a,c,b,g){THREE.Geometry.call(this);var f,h=a/2,e=c/2,b=b||1,g=g||1,j=b+1,k=g+1;a/=b;var l=c/g;for(f=0;f<k;f++)for(c=0;c<j;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-h,-(f*l-e),0)));for(f=0;f<g;f++)for(c=0;c<b;c++)this.faces.push(new THREE.Face4(c+j*f,c+j*(f+1),c+1+j*(f+1),c+1+j*f)),this.faceVertexUvs[0].push([new THREE.UV(c/b,f/g),new THREE.UV(c/b,(f+1)/g),new THREE.UV((c+1)/b,(f+1)/g),new THREE.UV((c+1)/b,f/g)]);this.computeCentroids();this.computeFaceNormals()};
 THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
-THREE.SphereGeometry=function(a,b,c){THREE.Geometry.call(this);for(var a=a||50,g,e=Math.PI,h=Math.max(3,b||8),f=Math.max(2,c||6),b=[],c=0;c<f+1;c++){g=c/f;var j=a*Math.cos(g*e),k=a*Math.sin(g*e),l=[],m=0;for(g=0;g<h;g++){var o=2*g/h,n=k*Math.sin(o*e),o=k*Math.cos(o*e);(c==0||c==f)&&g>0||(m=this.vertices.push(new THREE.Vertex(new THREE.Vector3(o,j,n)))-1);l.push(m)}b.push(l)}for(var t,v,y,e=b.length,c=0;c<e;c++)if(h=b[c].length,c>0)for(g=0;g<h;g++){l=g==h-1;f=b[c][l?0:g+1];j=b[c][l?h-1:g];k=b[c-1][l?
-h-1:g];l=b[c-1][l?0:g+1];n=c/(e-1);t=(c-1)/(e-1);v=(g+1)/h;var o=g/h,m=new THREE.UV(1-v,n),n=new THREE.UV(1-o,n),o=new THREE.UV(1-o,t),u=new THREE.UV(1-v,t);c<b.length-1&&(t=this.vertices[f].position.clone(),v=this.vertices[j].position.clone(),y=this.vertices[k].position.clone(),t.normalize(),v.normalize(),y.normalize(),this.faces.push(new THREE.Face3(f,j,k,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(y.x,y.y,y.z)])),this.faceVertexUvs[0].push([m,n,o]));c>1&&(t=
-this.vertices[f].position.clone(),v=this.vertices[k].position.clone(),y=this.vertices[l].position.clone(),t.normalize(),v.normalize(),y.normalize(),this.faces.push(new THREE.Face3(f,k,l,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(y.x,y.y,y.z)])),this.faceVertexUvs[0].push([m,o,u]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;
-THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;THREE.TextGeometry=function(a,b){THREE.Geometry.call(this);this.parameters=b||{};this.set(a)};THREE.TextGeometry.prototype=new THREE.Geometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
-THREE.TextGeometry.prototype.set=function(a,b){function c(a,c,b){v.vertices.push(new THREE.Vertex(new THREE.Vector3(a,c,b)))}function g(a,c,b,f){v.faces.push(new THREE.Face4(a,c,b,f))}this.text=a;var b=b||this.parameters,e=b.height!==void 0?b.height:50,h=b.curveSegments!==void 0?b.curveSegments:4,f=b.font!==void 0?b.font:"helvetiker",j=b.weight!==void 0?b.weight:"normal",k=b.style!==void 0?b.style:"normal",l=b.bezelThickness!==void 0?b.bezelThickness:10,m=b.bezelSize!==void 0?b.bezelSize:8,o=b.bezelEnabled!==
-void 0?b.bezelEnabled:!1;THREE.FontUtils.size=b.size!==void 0?b.size:100;THREE.FontUtils.divisions=h;THREE.FontUtils.face=f;THREE.FontUtils.weight=j;THREE.FontUtils.style=k;THREE.FontUtils.bezelSize=m;var j=THREE.FontUtils.drawText(a),h=j.points,n=j.faces,f=j.contour,t=j.bezel,v=this;v.vertices=[];v.faces=[];for(var y,k=h.length,u=n.length,m=t.length,j=0;j<k;j++)y=h[j],c(y.x,y.y,0);for(j=0;j<k;j++)y=h[j],c(y.x,y.y,e);if(o){for(j=0;j<m;j++)y=t[j],c(y.x,y.y,l);for(j=0;j<m;j++)y=t[j],c(y.x,y.y,e-l)}for(j=
-0;j<u;j++)e=n[j],v.faces.push(new THREE.Face3(e[2],e[1],e[0]));for(j=0;j<u;j++)e=n[j],v.faces.push(new THREE.Face3(e[0]+k,e[1]+k,e[2]+k));var w;if(o)for(j=t.length;--j>0;){if(w){if(w.equals(f[j])){w=null;continue}}else w=f[j];l=k*2+j;n=l-1;g(l,n,n+m,l+m);for(o=0;o<k;o++)if(h[o].equals(f[j]))break;for(e=0;e<k;e++)if(h[e].equals(f[j-1]))break;g(o,e,n,l);g(l+m,n+m,e+k,o+k)}else for(j=f.length;--j>0;){if(w){if(w.equals(f[j])){w=null;continue}}else w=f[j];for(o=0;o<k;o++)if(h[o].equals(f[j]))break;for(e=
-0;e<k;e++)if(h[e].equals(f[j-1]))break;g(o,e,e+k,o+k)}this.computeCentroids();this.computeFaceNormals()};
-THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},extractPoints:function(a,b){if(a.length<3)return console.log("not valid polygon"),
-{points:a,faces:[]};for(var c,g,e,h,f,j=[],k=0;k<b.length;k++){f=b[k];h=[];for(c=0;c<f.length;c++)g=f[c],h.push(g.x+","+g.y);var l;c=h.slice(1).indexOf(h[0]);var m=this.Triangulate.area(f.slice(0,c+1))<0;g=[];for(c=-1;c<h.length;){l=c+1;c=h[l];c=h.slice(l+1).indexOf(c)+l;if(c<=l)break;var o=f.slice(l,c+1);m?this.Triangulate.area(o)<0?(l>0&&j.push({shape:e,holes:g}),e=o,g=[]):g.push(o):this.Triangulate.area(o)<0?(j.push({shape:o,holes:g}),g=[]):g.push(o);c++}m&&j.push({shape:e,holes:g})}var n,t,v,
-y,u,w;h=[];for(f=0;f<j.length;f++){k=j[f];e=k.shape;g=k.holes;for(l=0;l<g.length;l++){m=g[l];v=Number.POSITIVE_INFINITY;for(o=0;o<m.length;o++){u=m[o];for(c=0;c<e.length;c++)y=e[c],y=u.distanceTo(y),y<v&&(v=y,n=o,t=c)}c=t-1>=0?t-1:e.length-1;var o=n-1>=0?n-1:m.length-1,x=[];x.push(m[n]);x.push(e[t]);x.push(e[c]);v=this.Triangulate.area(x);var p=[];p.push(m[n]);p.push(m[o]);p.push(e[t]);u=this.Triangulate.area(p);y=t;w=n;t+=1;n+=-1;t<0&&(t+=e.length);t%=e.length;n<0&&(n+=m.length);n%=e.length;c=t-
-1>=0?t-1:e.length-1;o=n-1>=0?n-1:m.length-1;x=[];x.push(m[n]);x.push(e[t]);x.push(e[c]);x=this.Triangulate.area(x);p=[];p.push(m[n]);p.push(m[o]);p.push(e[t]);p=this.Triangulate.area(p);v+u>x+p&&(t=y,n=w,t<0&&(t+=e.length),t%=e.length,n<0&&(n+=m.length),n%=e.length,c=t-1>=0?t-1:e.length-1,o=n-1>=0?n-1:m.length-1);v=e.slice(0,t);u=e.slice(t);y=m.slice(n);w=m.slice(0,n);h.push(m[n]);h.push(e[t]);h.push(e[c]);h.push(m[n]);h.push(m[o]);h.push(e[t]);e=v.concat(y).concat(w).concat(u)}k.shape=e}n=[];t=[];
-for(f=l=0;f<j.length;f++){k=j[f];e=k.shape;n=n.concat(e);m=THREE.FontUtils.Triangulate(e,!0);for(g=0;g<m.length;g++)k=m[g],k[0]+=l,k[1]+=l,k[2]+=l;t=t.concat(m);l+=e.length}var z;for(g=0;g<h.length/3;g++){k=[];for(j=0;j<3;j++){f=!1;for(e=0;e<n.length&&!f;e++)z=g*3+j,n[e].equals(h[z])&&(k.push(e),f=!0);f||(n.push(h[z]),k.push(n.length-1),console.log("not found"))}t.push(k)}return{points:n,faces:t}},drawText:function(a){var b=[],c=[],g,e=this.getFace(),h=this.size/e.resolution,f=0;g=String(a).split("");
-for(var j=g.length,k=[],a=0;a<j;a++){var l=this.extractGlyphPoints(g[a],e,h,f);f+=l.offset;b.push(l.points);c=c.concat(l.points);k.push(l.path)}a=f/2;for(g=0;g<c.length;g++)c[g].x-=a;b=this.extractPoints(c,b);b.contour=c;e=[];h=[];g=[];for(var f=[],j=new THREE.Vector2,m,a=c.length;--a>=0;){if(m){if(m.equals(c[a])){m=null;k=this.Triangulate.area(g)>0;f.push(k);h.push(j.divideScalar(g.length));g=[];j=new THREE.Vector2;continue}}else m=c[a];j.addSelf(c[a]);g.push(c[a])}a=c.length;for(g=0;--a>=0;)k=c[a],
-j=h[g],k=k.clone().subSelf(j),l=this.bezelSize/k.length(),f[g]?l+=1:l=1-l,l=k.multiplyScalar(l).addSelf(j),e.unshift(l),m?m.equals(c[a])&&(m=null,g++):m=c[a];b.bezel=e;return b},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,g){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,g)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,
-b){return a*a*a*b},b3:function(a,b,c,g,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,g)+this.b3p3(a,e)},extractGlyphPoints:function(a,b,c,g){var e=[],h=new THREE.Path,f,j,k,l,m,o,n,t,v,y,u=b.glyphs[a]||b.glyphs[ctxt.options.fallbackCharacter];if(u){if(u.o){b=u._cachedOutline||(u._cachedOutline=u.o.split(" "));k=b.length;for(a=0;a<k;)switch(j=b[a++],j){case "m":j=b[a++]*c+g;l=b[a++]*c;e.push(new THREE.Vector2(j,l));h.moveTo(j,l);break;case "l":j=b[a++]*c+g;l=b[a++]*c;e.push(new THREE.Vector2(j,
-l));h.lineTo(j,l);break;case "q":j=b[a++]*c+g;l=b[a++]*c;n=b[a++]*c+g;t=b[a++]*c;h.quadraticCurveTo(n,t,j,l);if(f=e[e.length-1]){m=f.x;o=f.y;f=1;for(divisions=this.divisions;f<=divisions;f++){var w=f/divisions,x=THREE.FontUtils.b2(w,m,n,j),w=THREE.FontUtils.b2(w,o,t,l);e.push(new THREE.Vector2(x,w))}}break;case "b":if(j=b[a++]*c+g,l=b[a++]*c,n=b[a++]*c+g,t=b[a++]*-c,v=b[a++]*c+g,y=b[a++]*-c,h.quadraticCurveTo(j,l,n,t,v,y),f=e[e.length-1]){m=f.x;o=f.y;f=1;for(divisions=this.divisions;f<=divisions;f++)w=
-f/divisions,x=THREE.FontUtils.b3(w,m,n,v,j),w=THREE.FontUtils.b3(w,o,t,y,l),e.push(new THREE.Vector2(x,w))}}}h.debug(document.getElementById("boo"));console.log(h);return{offset:u.ha*c,points:e,path:h}}}};
-(function(a){var b=function(a){for(var b=a.length,e=0,h=b-1,f=0;f<b;h=f++)e+=a[h].x*a[f].y-a[f].x*a[h].y;return e*0.5};a.Triangulate=function(a,g){var e=a.length;if(e<3)return null;var h=[],f=[],j=[],k,l,m;if(b(a)>0)for(l=0;l<e;l++)f[l]=l;else for(l=0;l<e;l++)f[l]=e-1-l;var o=2*e;for(l=e-1;e>2;){if(o--<=0){console.log("Warning, unable to triangulate polygon!");if(g)return j;return h}k=l;e<=k&&(k=0);l=k+1;e<=l&&(l=0);m=l+1;e<=m&&(m=0);var n;a:{n=a;var t=k,v=l,y=m,u=e,w=f,x=void 0,p=void 0,z=void 0,
-A=void 0,E=void 0,F=void 0,G=void 0,D=void 0,K=void 0,p=n[w[t]].x,z=n[w[t]].y,A=n[w[v]].x,E=n[w[v]].y,F=n[w[y]].x,G=n[w[y]].y;if(1.0E-10>(A-p)*(G-z)-(E-z)*(F-p))n=!1;else{for(x=0;x<u;x++)if(!(x==t||x==v||x==y)){var D=n[w[x]].x,K=n[w[x]].y,I=void 0,C=void 0,J=void 0,L=void 0,H=void 0,N=void 0,O=void 0,B=void 0,P=void 0,M=void 0,R=void 0,S=void 0,I=J=H=void 0,I=F-A,C=G-E,J=p-F,L=z-G,H=A-p,N=E-z,O=D-p,B=K-z,P=D-A,M=K-E,R=D-F,S=K-G,I=I*M-C*P,H=H*B-N*O,J=J*S-L*R;if(I>=0&&J>=0&&H>=0){n=!1;break a}}n=!0}}if(n){o=
-f[k];n=f[l];t=f[m];h.push(a[o]);h.push(a[n]);h.push(a[t]);j.push([f[k],f[l],f[m]]);k=l;for(m=l+1;m<e;k++,m++)f[k]=f[m];e--;o=2*e}}if(g)return j;return h};a.Triangulate.area=b;return a})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
-THREE.TorusGeometry=function(a,b,c,g){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=g||6;a=[];for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){var g=c/this.segmentsT*2*Math.PI,e=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(g),(this.radius+this.tube*Math.cos(e))*Math.sin(g),this.tube*Math.sin(e))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
-1;c<=this.segmentsT;++c){var g=(this.segmentsT+1)*b+c,e=(this.segmentsT+1)*b+c-1,h=(this.segmentsT+1)*(b-1)+c-1,f=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(g,e,h,f));this.faceVertexUvs[0].push([new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[h][0],a[h][1]),new THREE.UV(a[f][0],a[f][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusGeometry.prototype=new THREE.Geometry;
+THREE.SphereGeometry=function(a,c,b){THREE.Geometry.call(this);for(var a=a||50,g,f=Math.PI,h=Math.max(3,c||8),e=Math.max(2,b||6),c=[],b=0;b<e+1;b++){g=b/e;var j=a*Math.cos(g*f),k=a*Math.sin(g*f),l=[],m=0;for(g=0;g<h;g++){var n=2*g/h,o=k*Math.sin(n*f),n=k*Math.cos(n*f);(b==0||b==e)&&g>0||(m=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,j,o)))-1);l.push(m)}c.push(l)}for(var p,w,t,f=c.length,b=0;b<f;b++)if(h=c[b].length,b>0)for(g=0;g<h;g++){l=g==h-1;e=c[b][l?0:g+1];j=c[b][l?h-1:g];k=c[b-1][l?
+h-1:g];l=c[b-1][l?0:g+1];o=b/(f-1);p=(b-1)/(f-1);w=(g+1)/h;var n=g/h,m=new THREE.UV(1-w,o),o=new THREE.UV(1-n,o),n=new THREE.UV(1-n,p),v=new THREE.UV(1-w,p);b<c.length-1&&(p=this.vertices[e].position.clone(),w=this.vertices[j].position.clone(),t=this.vertices[k].position.clone(),p.normalize(),w.normalize(),t.normalize(),this.faces.push(new THREE.Face3(e,j,k,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(t.x,t.y,t.z)])),this.faceVertexUvs[0].push([m,o,n]));b>1&&(p=
+this.vertices[e].position.clone(),w=this.vertices[k].position.clone(),t=this.vertices[l].position.clone(),p.normalize(),w.normalize(),t.normalize(),this.faces.push(new THREE.Face3(e,k,l,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(t.x,t.y,t.z)])),this.faceVertexUvs[0].push([m,n,v]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;
+THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;THREE.TextGeometry=function(a,c){THREE.Geometry.call(this);this.parameters=c||{};this.set(a)};THREE.TextGeometry.prototype=new THREE.Geometry;THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
+THREE.TextGeometry.prototype.set=function(a,c){function b(a,b,c){w.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function g(a,b,c,e){w.faces.push(new THREE.Face4(a,b,c,e))}this.text=a;var c=c||this.parameters,f=c.height!==void 0?c.height:50,h=c.curveSegments!==void 0?c.curveSegments:4,e=c.font!==void 0?c.font:"helvetiker",j=c.weight!==void 0?c.weight:"normal",k=c.style!==void 0?c.style:"normal",l=c.bevelThickness!==void 0?c.bevelThickness:10,m=c.bevelSize!==void 0?c.bevelSize:8,n=c.bevelEnabled!==
+void 0?c.bevelEnabled:!1;THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=h;THREE.FontUtils.face=e;THREE.FontUtils.weight=j;THREE.FontUtils.style=k;THREE.FontUtils.bevelSize=m;var j=THREE.FontUtils.drawText(a),h=j.points,o=j.faces,e=j.contour,p=j.bevel,w=this;w.vertices=[];w.faces=[];for(var t,k=h.length,v=o.length,m=p.length,j=0;j<k;j++)t=h[j],b(t.x,t.y,0);for(j=0;j<k;j++)t=h[j],b(t.x,t.y,f);if(n){for(j=0;j<m;j++)t=p[j],b(t.x,t.y,l);for(j=0;j<m;j++)t=p[j],b(t.x,t.y,f-l)}for(j=
+0;j<v;j++)f=o[j],w.faces.push(new THREE.Face3(f[2],f[1],f[0]));for(j=0;j<v;j++)f=o[j],w.faces.push(new THREE.Face3(f[0]+k,f[1]+k,f[2]+k));var x;if(n)for(j=p.length;--j>0;){if(x){if(x.equals(e[j])){x=null;continue}}else x=e[j];l=k*2+j;o=l-1;g(l,o,o+m,l+m);for(n=0;n<k;n++)if(h[n].equals(e[j]))break;for(f=0;f<k;f++)if(h[f].equals(e[j-1]))break;g(n,f,o,l);g(l+m,o+m,f+k,n+k)}else for(j=e.length;--j>0;){if(x){if(x.equals(e[j])){x=null;continue}}else x=e[j];for(n=0;n<k;n++)if(h[n].equals(e[j]))break;for(f=
+0;f<k;f++)if(h[f].equals(e[j-1]))break;g(n,f,f+k,n+k)}this.computeCentroids();this.computeFaceNormals()};
+THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},loadFace:function(a){var c=a.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][a.cssFontWeight]=this.faces[c][a.cssFontWeight]||{};this.faces[c][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[c][a.cssFontWeight][a.cssFontStyle]=a},extractPoints:function(a,c){if(a.length<3)return console.log("not valid polygon"),
+{points:a,faces:[]};for(var b,g,f,h,e,j=[],k=0;k<c.length;k++){e=c[k];h=[];for(b=0;b<e.length;b++)g=e[b],h.push(g.x+","+g.y);var l;b=h.slice(1).indexOf(h[0]);var m=this.Triangulate.area(e.slice(0,b+1))<0;g=[];for(b=-1;b<h.length;){l=b+1;b=h[l];b=h.slice(l+1).indexOf(b)+l;if(b<=l)break;var n=e.slice(l,b+1);m?this.Triangulate.area(n)<0?(l>0&&j.push({shape:f,holes:g}),f=n,g=[]):g.push(n):this.Triangulate.area(n)<0?(j.push({shape:n,holes:g}),g=[]):g.push(n);b++}m&&j.push({shape:f,holes:g})}var o,p,w,
+t,v,x;h=[];for(e=0;e<j.length;e++){k=j[e];f=k.shape;g=k.holes;for(l=0;l<g.length;l++){m=g[l];w=Number.POSITIVE_INFINITY;for(n=0;n<m.length;n++){v=m[n];for(b=0;b<f.length;b++)t=f[b],t=v.distanceTo(t),t<w&&(w=t,o=n,p=b)}b=p-1>=0?p-1:f.length-1;var n=o-1>=0?o-1:m.length-1,y=[];y.push(m[o]);y.push(f[p]);y.push(f[b]);w=this.Triangulate.area(y);var u=[];u.push(m[o]);u.push(m[n]);u.push(f[p]);v=this.Triangulate.area(u);t=p;x=o;p+=1;o+=-1;p<0&&(p+=f.length);p%=f.length;o<0&&(o+=m.length);o%=f.length;b=p-
+1>=0?p-1:f.length-1;n=o-1>=0?o-1:m.length-1;y=[];y.push(m[o]);y.push(f[p]);y.push(f[b]);y=this.Triangulate.area(y);u=[];u.push(m[o]);u.push(m[n]);u.push(f[p]);u=this.Triangulate.area(u);w+v>y+u&&(p=t,o=x,p<0&&(p+=f.length),p%=f.length,o<0&&(o+=m.length),o%=f.length,b=p-1>=0?p-1:f.length-1,n=o-1>=0?o-1:m.length-1);w=f.slice(0,p);v=f.slice(p);t=m.slice(o);x=m.slice(0,o);h.push(m[o]);h.push(f[p]);h.push(f[b]);h.push(m[o]);h.push(m[n]);h.push(f[p]);f=w.concat(t).concat(x).concat(v)}k.shape=f}o=[];p=[];
+for(e=l=0;e<j.length;e++){k=j[e];f=k.shape;o=o.concat(f);m=THREE.FontUtils.Triangulate(f,!0);for(g=0;g<m.length;g++)k=m[g],k[0]+=l,k[1]+=l,k[2]+=l;p=p.concat(m);l+=f.length}var z;for(g=0;g<h.length/3;g++){k=[];for(j=0;j<3;j++){e=!1;for(f=0;f<o.length&&!e;f++)z=g*3+j,o[f].equals(h[z])&&(k.push(f),e=!0);e||(o.push(h[z]),k.push(o.length-1),console.log("not found"))}p.push(k)}return{points:o,faces:p}},drawText:function(a){var c=[],b=[],g,f=this.getFace(),h=this.size/f.resolution,e=0;g=String(a).split("");
+for(var j=g.length,k=new THREE.Path,a=0;a<j;a++){var l=this.extractGlyphPoints(g[a],f,h,e,k);e+=l.offset;c.push(l.points);b=b.concat(l.points)}console.log(k);a=e/2;for(g=0;g<b.length;g++)b[g].x-=a;c=this.extractPoints(b,c);c.contour=b;f=[];h=[];g=[];for(var e=[],j=new THREE.Vector2,m,a=b.length;--a>=0;){if(m){if(m.equals(b[a])){m=null;k=this.Triangulate.area(g)>0;e.push(k);h.push(j.divideScalar(g.length));g=[];j=new THREE.Vector2;continue}}else m=b[a];j.addSelf(b[a]);g.push(b[a])}a=b.length;for(g=
+0;--a>=0;)k=b[a],j=h[g],k=k.clone().subSelf(j),l=this.bevelSize/k.length(),e[g]?l+=1:l=1-l,l=k.multiplyScalar(l).addSelf(j),f.unshift(l),m?m.equals(b[a])&&(m=null,g++):m=b[a];c.bevel=f;return c},b2p0:function(a,c){var b=1-a;return b*b*c},b2p1:function(a,c){return 2*(1-a)*a*c},b2p2:function(a,c){return a*a*c},b2:function(a,c,b,g){return this.b2p0(a,c)+this.b2p1(a,b)+this.b2p2(a,g)},b3p0:function(a,c){var b=1-a;return b*b*b*c},b3p1:function(a,c){var b=1-a;return 3*b*b*a*c},b3p2:function(a,c){return 3*
+(1-a)*a*a*c},b3p3:function(a,c){return a*a*a*c},b3:function(a,c,b,g,f){return this.b3p0(a,c)+this.b3p1(a,b)+this.b3p2(a,g)+this.b3p3(a,f)},extractGlyphPoints:function(a,c,b,g,f){var h=[],e,j,k,l,m,n,o,p,w,t,v=c.glyphs[a]||c.glyphs[ctxt.options.fallbackCharacter];if(v){if(v.o){c=v._cachedOutline||(v._cachedOutline=v.o.split(" "));k=c.length;for(a=0;a<k;)switch(j=c[a++],j){case "m":j=c[a++]*b+g;l=c[a++]*b;h.push(new THREE.Vector2(j,l));f.moveTo(j,l);break;case "l":j=c[a++]*b+g;l=c[a++]*b;h.push(new THREE.Vector2(j,
+l));f.lineTo(j,l);break;case "q":j=c[a++]*b+g;l=c[a++]*b;o=c[a++]*b+g;p=c[a++]*b;f.quadraticCurveTo(o,p,j,l);if(e=h[h.length-1]){m=e.x;n=e.y;e=1;for(divisions=this.divisions;e<=divisions;e++){var x=e/divisions,y=THREE.FontUtils.b2(x,m,o,j),x=THREE.FontUtils.b2(x,n,p,l);h.push(new THREE.Vector2(y,x))}}break;case "b":if(j=c[a++]*b+g,l=c[a++]*b,o=c[a++]*b+g,p=c[a++]*-b,w=c[a++]*b+g,t=c[a++]*-b,f.bezierCurveTo(j,l,o,p,w,t),e=h[h.length-1]){m=e.x;n=e.y;e=1;for(divisions=this.divisions;e<=divisions;e++)x=
+e/divisions,y=THREE.FontUtils.b3(x,m,o,w,j),x=THREE.FontUtils.b3(x,n,p,t,l),h.push(new THREE.Vector2(y,x))}}}return{offset:v.ha*b,points:h,path:f}}}};
+(function(a){var c=function(a){for(var c=a.length,f=0,h=c-1,e=0;e<c;h=e++)f+=a[h].x*a[e].y-a[e].x*a[h].y;return f*0.5};a.Triangulate=function(a,g){var f=a.length;if(f<3)return null;var h=[],e=[],j=[],k,l,m;if(c(a)>0)for(l=0;l<f;l++)e[l]=l;else for(l=0;l<f;l++)e[l]=f-1-l;var n=2*f;for(l=f-1;f>2;){if(n--<=0){console.log("Warning, unable to triangulate polygon!");if(g)return j;return h}k=l;f<=k&&(k=0);l=k+1;f<=l&&(l=0);m=l+1;f<=m&&(m=0);var o;a:{o=a;var p=k,w=l,t=m,v=f,x=e,y=void 0,u=void 0,z=void 0,
+B=void 0,A=void 0,E=void 0,G=void 0,H=void 0,L=void 0,u=o[x[p]].x,z=o[x[p]].y,B=o[x[w]].x,A=o[x[w]].y,E=o[x[t]].x,G=o[x[t]].y;if(1.0E-10>(B-u)*(G-z)-(A-z)*(E-u))o=!1;else{for(y=0;y<v;y++)if(!(y==p||y==w||y==t)){var H=o[x[y]].x,L=o[x[y]].y,J=void 0,D=void 0,K=void 0,F=void 0,I=void 0,O=void 0,M=void 0,C=void 0,P=void 0,N=void 0,R=void 0,S=void 0,J=K=I=void 0,J=E-B,D=G-A,K=u-E,F=z-G,I=B-u,O=A-z,M=H-u,C=L-z,P=H-B,N=L-A,R=H-E,S=L-G,J=J*N-D*P,I=I*C-O*M,K=K*S-F*R;if(J>=0&&K>=0&&I>=0){o=!1;break a}}o=!0}}if(o){h.push([a[e[k]],
+a[e[l]],a[e[m]]]);j.push([e[k],e[l],e[m]]);k=l;for(m=l+1;m<f;k++,m++)e[k]=e[m];f--;n=2*f}}if(g)return j;return h};a.Triangulate.area=c;return a})(THREE.FontUtils);window._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
+THREE.TorusGeometry=function(a,c,b,g){THREE.Geometry.call(this);this.radius=a||100;this.tube=c||40;this.segmentsR=b||8;this.segmentsT=g||6;a=[];for(c=0;c<=this.segmentsR;++c)for(b=0;b<=this.segmentsT;++b){var g=b/this.segmentsT*2*Math.PI,f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(g),(this.radius+this.tube*Math.cos(f))*Math.sin(g),this.tube*Math.sin(f))));a.push([b/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(b=
+1;b<=this.segmentsT;++b){var g=(this.segmentsT+1)*c+b,f=(this.segmentsT+1)*c+b-1,h=(this.segmentsT+1)*(c-1)+b-1,e=(this.segmentsT+1)*(c-1)+b;this.faces.push(new THREE.Face4(g,f,h,e));this.faceVertexUvs[0].push([new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[h][0],a[h][1]),new THREE.UV(a[e][0],a[e][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusGeometry.prototype=new THREE.Geometry;
 THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
-THREE.TorusKnotGeometry=function(a,b,c,g,e,h,f){function j(a,c,b,f,e,g){c=b/f*a;b=Math.cos(c);return new THREE.Vector3(e*(2+b)*0.5*Math.cos(a),e*(2+b)*Math.sin(a)*0.5,g*e*Math.sin(c)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=b||40;this.segmentsR=c||64;this.segmentsT=g||8;this.p=e||2;this.q=h||3;this.heightScale=f||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;g=new THREE.Vector3;h=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(b=0;b<
-this.segmentsT;++b){var k=a/this.segmentsR*2*this.p*Math.PI,f=b/this.segmentsT*2*Math.PI,e=j(k,f,this.q,this.p,this.radius,this.heightScale),k=j(k+0.01,f,this.q,this.p,this.radius,this.heightScale);c.x=k.x-e.x;c.y=k.y-e.y;c.z=k.z-e.z;g.x=k.x+e.x;g.y=k.y+e.y;g.z=k.z+e.z;h.cross(c,g);g.cross(h,c);h.normalize();g.normalize();k=-this.tube*Math.cos(f);f=this.tube*Math.sin(f);e.x+=k*g.x+f*h.x;e.y+=k*g.y+f*h.y;e.z+=k*g.z+f*h.z;this.grid[a][b]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(e.x,e.y,
-e.z)))-1}}for(a=0;a<this.segmentsR;++a)for(b=0;b<this.segmentsT;++b){var g=(a+1)%this.segmentsR,h=(b+1)%this.segmentsT,e=this.grid[a][b],c=this.grid[g][b],g=this.grid[g][h],h=this.grid[a][h],f=new THREE.UV(a/this.segmentsR,b/this.segmentsT),k=new THREE.UV((a+1)/this.segmentsR,b/this.segmentsT),l=new THREE.UV((a+1)/this.segmentsR,(b+1)/this.segmentsT),m=new THREE.UV(a/this.segmentsR,(b+1)/this.segmentsT);this.faces.push(new THREE.Face4(e,c,g,h));this.faceVertexUvs[0].push([f,k,l,m])}this.computeCentroids();
+THREE.TorusKnotGeometry=function(a,c,b,g,f,h,e){function j(a,b,c,e,g,h){b=c/e*a;c=Math.cos(b);return new THREE.Vector3(g*(2+c)*0.5*Math.cos(a),g*(2+c)*Math.sin(a)*0.5,h*g*Math.sin(b)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=c||40;this.segmentsR=b||64;this.segmentsT=g||8;this.p=f||2;this.q=h||3;this.heightScale=e||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;g=new THREE.Vector3;h=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(c=0;c<
+this.segmentsT;++c){var k=a/this.segmentsR*2*this.p*Math.PI,e=c/this.segmentsT*2*Math.PI,f=j(k,e,this.q,this.p,this.radius,this.heightScale),k=j(k+0.01,e,this.q,this.p,this.radius,this.heightScale);b.x=k.x-f.x;b.y=k.y-f.y;b.z=k.z-f.z;g.x=k.x+f.x;g.y=k.y+f.y;g.z=k.z+f.z;h.cross(b,g);g.cross(h,b);h.normalize();g.normalize();k=-this.tube*Math.cos(e);e=this.tube*Math.sin(e);f.x+=k*g.x+e*h.x;f.y+=k*g.y+e*h.y;f.z+=k*g.z+e*h.z;this.grid[a][c]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(f.x,f.y,
+f.z)))-1}}for(a=0;a<this.segmentsR;++a)for(c=0;c<this.segmentsT;++c){var g=(a+1)%this.segmentsR,h=(c+1)%this.segmentsT,f=this.grid[a][c],b=this.grid[g][c],g=this.grid[g][h],h=this.grid[a][h],e=new THREE.UV(a/this.segmentsR,c/this.segmentsT),k=new THREE.UV((a+1)/this.segmentsR,c/this.segmentsT),l=new THREE.UV((a+1)/this.segmentsR,(c+1)/this.segmentsT),m=new THREE.UV(a/this.segmentsR,(c+1)/this.segmentsT);this.faces.push(new THREE.Face4(f,b,g,h));this.faceVertexUvs[0].push([e,k,l,m])}this.computeCentroids();
 this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
-THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ";b+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";
-this.statusDomElement.innerHTML=b},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,b,c){a.materials=[];for(var g=0;g<b.length;++g)a.materials[g]=[THREE.Loader.prototype.createMaterial(b[g],c)]},hasNormals:function(a){var b,c,g=a.materials.length;for(c=0;c<g;c++)if(b=a.materials[c][0],b instanceof THREE.MeshShaderMaterial)return!0;return!1},createMaterial:function(a,b){function c(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==a}function g(a,b){var f=
-new Image;f.onload=function(){if(!c(this.width)||!c(this.height)){var b=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),f=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));a.image.width=b;a.image.height=f;a.image.getContext("2d").drawImage(this,0,0,b,f)}else a.image=this;a.needsUpdate=!0};f.src=b}function e(a,c,f,e,h,j){var k=document.createElement("canvas");a[c]=new THREE.Texture(k);a[c].sourceFile=f;if(e){a[c].repeat.set(e[0],e[1]);if(e[0]!=1)a[c].wrapS=THREE.RepeatWrapping;if(e[1]!=
-1)a[c].wrapT=THREE.RepeatWrapping}h&&a[c].offset.set(h[0],h[1]);if(j){e={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(e[j[0]]!==void 0)a[c].wrapS=e[j[0]];if(e[j[1]]!==void 0)a[c].wrapT=e[j[1]]}g(a[c],b+"/"+f)}function h(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255}var f,j,k;j="MeshLambertMaterial";f={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};a.shading&&(a.shading=="Phong"?j="MeshPhongMaterial":a.shading=="Basic"&&(j="MeshBasicMaterial"));
-if(a.blending)if(a.blending=="Additive")f.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")f.blending=THREE.SubtractiveBlending;else if(a.blending=="Multiply")f.blending=THREE.MultiplyBlending;if(a.transparent!==void 0||a.opacity<1)f.transparent=a.transparent;if(a.depthTest!==void 0)f.depthTest=a.depthTest;if(a.vertexColors!==void 0)if(a.vertexColors=="face")f.vertexColors=THREE.FaceColors;else if(a.vertexColors)f.vertexColors=THREE.VertexColors;if(a.colorDiffuse)f.color=h(a.colorDiffuse);
-else if(a.DbgColor)f.color=a.DbgColor;if(a.colorSpecular)f.specular=h(a.colorSpecular);if(a.colorAmbient)f.ambient=h(a.colorAmbient);if(a.transparency)f.opacity=a.transparency;if(a.specularCoef)f.shininess=a.specularCoef;a.mapDiffuse&&b&&e(f,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&b&&e(f,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&b&&e(f,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap);
-a.mapSpecular&&b&&e(f,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var l=THREE.ShaderUtils.lib.normal,m=THREE.UniformsUtils.clone(l.uniforms),o=f.color;j=f.specular;k=f.ambient;var n=f.shininess;m.tNormal.texture=f.normalMap;if(a.mapNormalFactor)m.uNormalScale.value=a.mapNormalFactor;if(f.map)m.tDiffuse.texture=f.map,m.enableDiffuse.value=!0;if(f.specularMap)m.tSpecular.texture=f.specularMap,m.enableSpecular.value=!0;if(f.lightMap)m.tAO.texture=
-f.lightMap,m.enableAO.value=!0;m.uDiffuseColor.value.setHex(o);m.uSpecularColor.value.setHex(j);m.uAmbientColor.value.setHex(k);m.uShininess.value=n;if(f.opacity)m.uOpacity.value=f.opacity;f=new THREE.MeshShaderMaterial({fragmentShader:l.fragmentShader,vertexShader:l.vertexShader,uniforms:m,lights:!0,fog:!0})}else f=new THREE[j](f);return f}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;
-THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;THREE.JSONLoader.prototype.load=function(a){var b=this,c=a.model,g=a.callback,e=a.texture_path?a.texture_path:this.extractUrlbase(c),a=new Worker(c);a.onmessage=function(a){b.createModel(a.data,g,e);b.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
-THREE.JSONLoader.prototype.createModel=function(a,b,c){var g=new THREE.Geometry,e=a.scale!==void 0?1/a.scale:1;this.init_materials(g,a.materials,c);(function(c){if(a.version===void 0||a.version!=2)console.error("Deprecated file format.");else{var b,e,k,l,m,o,n,t,v,y,u,w,x,p,z=a.faces;o=a.vertices;var A=a.normals,E=a.colors,F=0;for(b=0;b<a.uvs.length;b++)a.uvs[b].length&&F++;for(b=0;b<F;b++)g.faceUvs[b]=[],g.faceVertexUvs[b]=[];l=0;for(m=o.length;l<m;)n=new THREE.Vertex,n.position.x=o[l++]*c,n.position.y=
-o[l++]*c,n.position.z=o[l++]*c,g.vertices.push(n);l=0;for(m=z.length;l<m;){c=z[l++];o=c&1;k=c&2;b=c&4;e=c&8;t=c&16;n=c&32;y=c&64;c&=128;o?(u=new THREE.Face4,u.a=z[l++],u.b=z[l++],u.c=z[l++],u.d=z[l++],o=4):(u=new THREE.Face3,u.a=z[l++],u.b=z[l++],u.c=z[l++],o=3);if(k)k=z[l++],u.materials=g.materials[k];k=g.faces.length;if(b)for(b=0;b<F;b++)w=a.uvs[b],v=z[l++],p=w[v*2],v=w[v*2+1],g.faceUvs[b][k]=new THREE.UV(p,v);if(e)for(b=0;b<F;b++){w=a.uvs[b];x=[];for(e=0;e<o;e++)v=z[l++],p=w[v*2],v=w[v*2+1],x[e]=
-new THREE.UV(p,v);g.faceVertexUvs[b][k]=x}if(t)t=z[l++]*3,e=new THREE.Vector3,e.x=A[t++],e.y=A[t++],e.z=A[t],u.normal=e;if(n)for(b=0;b<o;b++)t=z[l++]*3,e=new THREE.Vector3,e.x=A[t++],e.y=A[t++],e.z=A[t],u.vertexNormals.push(e);if(y)n=z[l++],n=new THREE.Color(E[n]),u.color=n;if(c)for(b=0;b<o;b++)n=z[l++],n=new THREE.Color(E[n]),u.vertexColors.push(n);g.faces.push(u)}}})(e);(function(){var c,b,e,k;if(a.skinWeights){c=0;for(b=a.skinWeights.length;c<b;c+=2)e=a.skinWeights[c],k=a.skinWeights[c+1],g.skinWeights.push(new THREE.Vector4(e,
-k,0,0))}if(a.skinIndices){c=0;for(b=a.skinIndices.length;c<b;c+=2)e=a.skinIndices[c],k=a.skinIndices[c+1],g.skinIndices.push(new THREE.Vector4(e,k,0,0))}g.bones=a.bones;g.animation=a.animation})();(function(c){if(a.morphTargets!==void 0){var b,e,k,l,m,o,n,t,v;b=0;for(e=a.morphTargets.length;b<e;b++){g.morphTargets[b]={};g.morphTargets[b].name=a.morphTargets[b].name;g.morphTargets[b].vertices=[];t=g.morphTargets[b].vertices;v=a.morphTargets[b].vertices;k=0;for(l=v.length;k<l;k+=3)m=v[k]*c,o=v[k+1]*
-c,n=v[k+2]*c,t.push(new THREE.Vertex(new THREE.Vector3(m,o,n)))}}if(a.morphColors!==void 0){b=0;for(e=a.morphColors.length;b<e;b++){g.morphColors[b]={};g.morphColors[b].name=a.morphColors[b].name;g.morphColors[b].colors=[];l=g.morphColors[b].colors;m=a.morphColors[b].colors;c=0;for(k=m.length;c<k;c+=3)o=new THREE.Color(16755200),o.setRGB(m[c],m[c+1],m[c+2]),l.push(o)}}})(e);(function(){if(a.edges!==void 0){var c,b,e;for(c=0;c<a.edges.length;c+=2)b=a.edges[c],e=a.edges[c+1],g.edges.push(new THREE.Edge(g.vertices[b],
-g.vertices[e],b,e))}})();g.computeCentroids();g.computeFaceNormals();this.hasNormals(g)&&g.computeTangents();b(g)};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
-THREE.BinaryLoader.prototype={load:function(a){var b=a.model,c=a.callback,g=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b),e=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b),a=(new Date).getTime(),b=new Worker(b),h=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(a){THREE.BinaryLoader.prototype.loadAjaxBuffers(a.data.buffers,a.data.materials,c,e,g,h)};b.onerror=function(a){alert("worker.onerror: "+a.message+"\n"+a.data);a.preventDefault()};
-b.postMessage(a)},loadAjaxBuffers:function(a,b,c,g,e,h){var f=new XMLHttpRequest,j=g+"/"+a,k=0;f.onreadystatechange=function(){f.readyState==4?f.status==200||f.status==0?THREE.BinaryLoader.prototype.createBinModel(f.responseText,c,e,b):alert("Couldn't load ["+j+"] ["+f.status+"]"):f.readyState==3?h&&(k==0&&(k=f.getResponseHeader("Content-Length")),h({total:k,loaded:f.responseText.length})):f.readyState==2&&(k=f.getResponseHeader("Content-Length"))};f.open("GET",j,!0);f.overrideMimeType("text/plain; charset=x-user-defined");
-f.setRequestHeader("Content-Type","text/plain");f.send(null)},createBinModel:function(a,b,c,g){var e=function(c){function b(a,c){var e=m(a,c),g=m(a,c+1),f=m(a,c+2),h=m(a,c+3),j=(h<<1&255|f>>7)-127;e|=(f&127)<<16|g<<8;if(e==0&&j==-127)return 0;return(1-2*(h>>7))*(1+e*Math.pow(2,-23))*Math.pow(2,j)}function e(a,c){var b=m(a,c),g=m(a,c+1),f=m(a,c+2);return(m(a,c+3)<<24)+(f<<16)+(g<<8)+b}function k(a,c){var b=m(a,c);return(m(a,c+1)<<8)+b}function l(a,c){var b=m(a,c);return b>127?b-256:b}function m(a,
-c){return a.charCodeAt(c)&255}function o(c){var b,g,f;b=e(a,c);g=e(a,c+E);f=e(a,c+F);c=k(a,c+G);THREE.BinaryLoader.prototype.f3(w,b,g,f,c)}function n(c){var b,g,f,h,l,m;b=e(a,c);g=e(a,c+E);f=e(a,c+F);h=k(a,c+G);l=e(a,c+D);m=e(a,c+K);c=e(a,c+I);THREE.BinaryLoader.prototype.f3n(w,z,b,g,f,h,l,m,c)}function t(c){var b,g,f,h;b=e(a,c);g=e(a,c+C);f=e(a,c+J);h=e(a,c+L);c=k(a,c+H);THREE.BinaryLoader.prototype.f4(w,b,g,f,h,c)}function v(c){var b,g,f,h,l,m,n,o;b=e(a,c);g=e(a,c+C);f=e(a,c+J);h=e(a,c+L);l=k(a,
-c+H);m=e(a,c+N);n=e(a,c+O);o=e(a,c+B);c=e(a,c+P);THREE.BinaryLoader.prototype.f4n(w,z,b,g,f,h,l,m,n,o,c)}function y(c){var b,g;b=e(a,c);g=e(a,c+M);c=e(a,c+R);THREE.BinaryLoader.prototype.uv3(w.faceVertexUvs[0],A[b*2],A[b*2+1],A[g*2],A[g*2+1],A[c*2],A[c*2+1])}function u(c){var b,g,f;b=e(a,c);g=e(a,c+S);f=e(a,c+Y);c=e(a,c+Z);THREE.BinaryLoader.prototype.uv4(w.faceVertexUvs[0],A[b*2],A[b*2+1],A[g*2],A[g*2+1],A[f*2],A[f*2+1],A[c*2],A[c*2+1])}var w=this,x=0,p,z=[],A=[],E,F,G,D,K,I,C,J,L,H,N,O,B,P,M,R,
-S,Y,Z,T,U,V,W,X,Q;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,g,c);p={signature:a.substr(x,8),header_bytes:m(a,x+8),vertex_coordinate_bytes:m(a,x+9),normal_coordinate_bytes:m(a,x+10),uv_coordinate_bytes:m(a,x+11),vertex_index_bytes:m(a,x+12),normal_index_bytes:m(a,x+13),uv_index_bytes:m(a,x+14),material_index_bytes:m(a,x+15),nvertices:e(a,x+16),nnormals:e(a,x+16+4),nuvs:e(a,x+16+8),ntri_flat:e(a,x+16+12),ntri_smooth:e(a,x+16+16),ntri_flat_uv:e(a,x+16+20),ntri_smooth_uv:e(a,x+
-16+24),nquad_flat:e(a,x+16+28),nquad_smooth:e(a,x+16+32),nquad_flat_uv:e(a,x+16+36),nquad_smooth_uv:e(a,x+16+40)};x+=p.header_bytes;E=p.vertex_index_bytes;F=p.vertex_index_bytes*2;G=p.vertex_index_bytes*3;D=p.vertex_index_bytes*3+p.material_index_bytes;K=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes;I=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*2;C=p.vertex_index_bytes;J=p.vertex_index_bytes*2;L=p.vertex_index_bytes*3;H=p.vertex_index_bytes*4;N=p.vertex_index_bytes*
-4+p.material_index_bytes;O=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes;B=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*2;P=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*3;M=p.uv_index_bytes;R=p.uv_index_bytes*2;S=p.uv_index_bytes;Y=p.uv_index_bytes*2;Z=p.uv_index_bytes*3;c=p.vertex_index_bytes*3+p.material_index_bytes;Q=p.vertex_index_bytes*4+p.material_index_bytes;T=p.ntri_flat*c;U=p.ntri_smooth*(c+p.normal_index_bytes*3);V=p.ntri_flat_uv*
-(c+p.uv_index_bytes*3);W=p.ntri_smooth_uv*(c+p.normal_index_bytes*3+p.uv_index_bytes*3);X=p.nquad_flat*Q;c=p.nquad_smooth*(Q+p.normal_index_bytes*4);Q=p.nquad_flat_uv*(Q+p.uv_index_bytes*4);x+=function(c){for(var e,g,h,j=p.vertex_coordinate_bytes*3,k=c+p.nvertices*j;c<k;c+=j)e=b(a,c),g=b(a,c+p.vertex_coordinate_bytes),h=b(a,c+p.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(w,e,g,h);return p.nvertices*j}(x);x+=function(c){for(var b,e,g,f=p.normal_coordinate_bytes*3,h=c+p.nnormals*f;c<h;c+=
-f)b=l(a,c),e=l(a,c+p.normal_coordinate_bytes),g=l(a,c+p.normal_coordinate_bytes*2),z.push(b/127,e/127,g/127);return p.nnormals*f}(x);x+=function(c){for(var e,g,h=p.uv_coordinate_bytes*2,j=c+p.nuvs*h;c<j;c+=h)e=b(a,c),g=b(a,c+p.uv_coordinate_bytes),A.push(e,g);return p.nuvs*h}(x);T=x+T;U=T+U;V=U+V;W=V+W;X=W+X;c=X+c;Q=c+Q;(function(a){var c,b=p.vertex_index_bytes*3+p.material_index_bytes,e=b+p.uv_index_bytes*3,g=a+p.ntri_flat_uv*e;for(c=a;c<g;c+=e)o(c),y(c+b);return g-a})(U);(function(a){var c,b=p.vertex_index_bytes*
-3+p.material_index_bytes+p.normal_index_bytes*3,e=b+p.uv_index_bytes*3,g=a+p.ntri_smooth_uv*e;for(c=a;c<g;c+=e)n(c),y(c+b);return g-a})(V);(function(a){var c,b=p.vertex_index_bytes*4+p.material_index_bytes,e=b+p.uv_index_bytes*4,g=a+p.nquad_flat_uv*e;for(c=a;c<g;c+=e)t(c),u(c+b);return g-a})(c);(function(a){var c,b=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,e=b+p.uv_index_bytes*4,g=a+p.nquad_smooth_uv*e;for(c=a;c<g;c+=e)v(c),u(c+b);return g-a})(Q);(function(a){var c,b=p.vertex_index_bytes*
-3+p.material_index_bytes,e=a+p.ntri_flat*b;for(c=a;c<e;c+=b)o(c);return e-a})(x);(function(a){var c,b=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*3,e=a+p.ntri_smooth*b;for(c=a;c<e;c+=b)n(c);return e-a})(T);(function(a){var c,b=p.vertex_index_bytes*4+p.material_index_bytes,e=a+p.nquad_flat*b;for(c=a;c<e;c+=b)t(c);return e-a})(W);(function(a){var c,b=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,e=a+p.nquad_smooth*b;for(c=a;c<e;c+=b)v(c);return e-a})(X);
-this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))},v:function(a,b,c,g){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,g)))},f3:function(a,b,c,g,e){a.faces.push(new THREE.Face3(b,c,g,null,null,a.materials[e]))},f4:function(a,b,c,g,e,h){a.faces.push(new THREE.Face4(b,c,g,e,null,null,a.materials[h]))},f3n:function(a,b,c,g,e,h,f,j,k){var h=a.materials[h],l=b[j*
-3],m=b[j*3+1],j=b[j*3+2],o=b[k*3],n=b[k*3+1],k=b[k*3+2];a.faces.push(new THREE.Face3(c,g,e,[new THREE.Vector3(b[f*3],b[f*3+1],b[f*3+2]),new THREE.Vector3(l,m,j),new THREE.Vector3(o,n,k)],null,h))},f4n:function(a,b,c,g,e,h,f,j,k,l,m){var f=a.materials[f],o=b[k*3],n=b[k*3+1],k=b[k*3+2],t=b[l*3],v=b[l*3+1],l=b[l*3+2],y=b[m*3],u=b[m*3+1],m=b[m*3+2];a.faces.push(new THREE.Face4(c,g,e,h,[new THREE.Vector3(b[j*3],b[j*3+1],b[j*3+2]),new THREE.Vector3(o,n,k),new THREE.Vector3(t,v,l),new THREE.Vector3(y,u,
-m)],null,f))},uv3:function(a,b,c,g,e,h,f){var j=[];j.push(new THREE.UV(b,c));j.push(new THREE.UV(g,e));j.push(new THREE.UV(h,f));a.push(j)},uv4:function(a,b,c,g,e,h,f,j,k){var l=[];l.push(new THREE.UV(b,c));l.push(new THREE.UV(g,e));l.push(new THREE.UV(h,f));l.push(new THREE.UV(j,k));a.push(l)}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
-THREE.SceneLoader.prototype={load:function(a,b){var c=this,g=new Worker(a);g.postMessage(0);var e=THREE.Loader.prototype.extractUrlbase(a);g.onmessage=function(a){function g(a,c){return c=="relativeToHTML"?a:e+"/"+a}function j(){for(t in C.objects)if(!B.objects[t])if(x=C.objects[t],x.geometry!==void 0){if(E=B.geometries[x.geometry]){var a=!1;K=[];for(M=0;M<x.materials.length;M++)K[M]=B.materials[x.materials[M]],a=K[M]instanceof THREE.MeshShaderMaterial;a&&E.computeTangents();p=x.position;r=x.rotation;
-q=x.quaternion;s=x.scale;q=0;K.length==0&&(K[0]=new THREE.MeshFaceMaterial);K.length>1&&(K=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(E,K);object.name=t;object.position.set(p[0],p[1],p[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=x.visible;B.scene.addObject(object);B.objects[t]=object;x.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),B.scene.collisions.colliders.push(a));
-if(x.castsShadow)a=new THREE.ShadowVolume(E),B.scene.addChild(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;x.trigger&&x.trigger.toLowerCase()!="none"&&(a={type:x.trigger,object:x},B.triggers[object.name]=a)}}else p=x.position,r=x.rotation,q=x.quaternion,s=x.scale,q=0,object=new THREE.Object3D,object.name=t,object.position.set(p[0],p[1],p[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=x.visible!==void 0?x.visible:!1,B.scene.addObject(object),B.objects[t]=object,B.empties[t]=object,x.trigger&&x.trigger.toLowerCase()!="none"&&(a={type:x.trigger,object:x},B.triggers[object.name]=a)}function k(a){return function(b){B.geometries[a]=b;j();L-=1;c.onLoadComplete();m()}}function l(a){return function(c){B.geometries[a]=c}}function m(){c.callbackProgress({totalModels:N,totalTextures:O,loadedModels:N-L,loadedTextures:O-H},B);c.onLoadProgress();L==0&&H==0&&b(B)}var o,
-n,t,v,y,u,w,x,p,z,A,E,F,G,D,K,I,C,J,L,H,N,O,B;C=a.data;D=new THREE.BinaryLoader;J=new THREE.JSONLoader;H=L=0;B={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(t in C.objects)if(x=C.objects[t],x.meshCollider){a=!0;break}if(a)B.scene.collisions=new THREE.CollisionSystem;if(C.transform){a=C.transform.position;z=C.transform.rotation;var P=C.transform.scale;a&&B.scene.position.set(a[0],a[1],a[2]);z&&B.scene.rotation.set(z[0],
-z[1],z[2]);P&&B.scene.scale.set(P[0],P[1],P[2]);(a||z||P)&&B.scene.updateMatrix()}a=function(){H-=1;m();c.onLoadComplete()};for(y in C.cameras){z=C.cameras[y];if(z.type=="perspective")F=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho")F=new THREE.Camera,F.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far);p=z.position;z=z.target;F.position.set(p[0],p[1],p[2]);F.target.position.set(z[0],z[1],z[2]);B.cameras[y]=F}for(v in C.lights)y=C.lights[v],
-F=y.color!==void 0?y.color:16777215,z=y.intensity!==void 0?y.intensity:1,y.type=="directional"?(p=y.direction,I=new THREE.DirectionalLight(F,z),I.position.set(p[0],p[1],p[2]),I.position.normalize()):y.type=="point"?(p=y.position,d=y.distance,I=new THREE.PointLight(F,z,d),I.position.set(p[0],p[1],p[2])):y.type=="ambient"&&(I=new THREE.AmbientLight(F)),B.scene.addLight(I),B.lights[v]=I;for(u in C.fogs)v=C.fogs[u],v.type=="linear"?G=new THREE.Fog(0,v.near,v.far):v.type=="exp2"&&(G=new THREE.FogExp2(0,
-v.density)),z=v.color,G.color.setRGB(z[0],z[1],z[2]),B.fogs[u]=G;if(B.cameras&&C.defaults.camera)B.currentCamera=B.cameras[C.defaults.camera];if(B.fogs&&C.defaults.fog)B.scene.fog=B.fogs[C.defaults.fog];z=C.defaults.bgcolor;B.bgColor=new THREE.Color;B.bgColor.setRGB(z[0],z[1],z[2]);B.bgColorAlpha=C.defaults.bgalpha;for(o in C.geometries)if(u=C.geometries[o],u.type=="bin_mesh"||u.type=="ascii_mesh")L+=1,c.onLoadStart();N=L;for(o in C.geometries)u=C.geometries[o],u.type=="cube"?(E=new THREE.CubeGeometry(u.width,
-u.height,u.depth,u.segmentsWidth,u.segmentsHeight,u.segmentsDepth,null,u.flipped,u.sides),B.geometries[o]=E):u.type=="plane"?(E=new THREE.PlaneGeometry(u.width,u.height,u.segmentsWidth,u.segmentsHeight),B.geometries[o]=E):u.type=="sphere"?(E=new THREE.SphereGeometry(u.radius,u.segmentsWidth,u.segmentsHeight),B.geometries[o]=E):u.type=="cylinder"?(E=new THREE.CylinderGeometry(u.numSegs,u.topRad,u.botRad,u.height,u.topOffset,u.botOffset),B.geometries[o]=E):u.type=="torus"?(E=new THREE.TorusGeometry(u.radius,
-u.tube,u.segmentsR,u.segmentsT),B.geometries[o]=E):u.type=="icosahedron"?(E=new THREE.IcosahedronGeometry(u.subdivisions),B.geometries[o]=E):u.type=="bin_mesh"?D.load({model:g(u.url,C.urlBaseType),callback:k(o)}):u.type=="ascii_mesh"?J.load({model:g(u.url,C.urlBaseType),callback:k(o)}):u.type=="embedded_mesh"&&(u=C.embeds[u.id])&&J.createModel(u,l(o),"");for(w in C.textures)if(o=C.textures[w],o.url instanceof Array){H+=o.url.length;for(D=0;D<o.url.length;D++)c.onLoadStart()}else H+=1,c.onLoadStart();
-O=H;for(w in C.textures){o=C.textures[w];if(o.mapping!=void 0&&THREE[o.mapping]!=void 0)o.mapping=new THREE[o.mapping];if(o.url instanceof Array){D=[];for(var M=0;M<o.url.length;M++)D[M]=g(o.url[M],C.urlBaseType);D=THREE.ImageUtils.loadTextureCube(D,o.mapping,a)}else{D=THREE.ImageUtils.loadTexture(g(o.url,C.urlBaseType),o.mapping,a);if(THREE[o.minFilter]!=void 0)D.minFilter=THREE[o.minFilter];if(THREE[o.magFilter]!=void 0)D.magFilter=THREE[o.magFilter];if(o.repeat){D.repeat.set(o.repeat[0],o.repeat[1]);
-if(o.repeat[0]!=1)D.wrapS=THREE.RepeatWrapping;if(o.repeat[1]!=1)D.wrapT=THREE.RepeatWrapping}o.offset&&D.offset.set(o.offset[0],o.offset[1]);if(o.wrap){J={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(J[o.wrap[0]]!==void 0)D.wrapS=J[o.wrap[0]];if(J[o.wrap[1]]!==void 0)D.wrapT=J[o.wrap[1]]}}B.textures[w]=D}for(n in C.materials){w=C.materials[n];for(A in w.parameters)if(A=="envMap"||A=="map"||A=="lightMap")w.parameters[A]=B.textures[w.parameters[A]];else if(A=="shading")w.parameters[A]=
-w.parameters[A]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(A=="blending")w.parameters[A]=THREE[w.parameters[A]]?THREE[w.parameters[A]]:THREE.NormalBlending;else if(A=="combine")w.parameters[A]=w.parameters[A]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(A=="vertexColors")if(w.parameters[A]=="face")w.parameters[A]=THREE.FaceColors;else if(w.parameters[A])w.parameters[A]=THREE.VertexColors;if(w.parameters.opacity!==void 0&&w.parameters.opacity<1)w.parameters.transparent=
-!0;if(w.parameters.normalMap){o=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(o.uniforms);D=w.parameters.color;J=w.parameters.specular;u=w.parameters.ambient;G=w.parameters.shininess;a.tNormal.texture=B.textures[w.parameters.normalMap];if(w.parameters.normalMapFactor)a.uNormalScale.value=w.parameters.normalMapFactor;if(w.parameters.map)a.tDiffuse.texture=w.parameters.map,a.enableDiffuse.value=!0;if(w.parameters.lightMap)a.tAO.texture=w.parameters.lightMap,a.enableAO.value=!0;if(w.parameters.specularMap)a.tSpecular.texture=
-B.textures[w.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(D);a.uSpecularColor.value.setHex(J);a.uAmbientColor.value.setHex(u);a.uShininess.value=G;if(w.parameters.opacity)a.uOpacity.value=w.parameters.opacity;w=new THREE.MeshShaderMaterial({fragmentShader:o.fragmentShader,vertexShader:o.vertexShader,uniforms:a,lights:!0,fog:!0})}else w=new THREE[w.type](w.parameters);B.materials[n]=w}j();c.callbackSync(B)}}};
-THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(a){this.isolation=80;this.size=a;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(a,b,e){return a+(b-a)*e};this.VIntX=function(a,b,e,h,f,j,k,l,m,o){f=(f-m)/(o-m);m=this.normal_cache;b[h]=j+f*this.delta;b[h+1]=k;b[h+2]=l;e[h]=this.lerp(m[a],m[a+3],f);e[h+1]=this.lerp(m[a+1],m[a+4],f);e[h+2]=this.lerp(m[a+2],m[a+5],f)};this.VIntY=function(a,b,e,h,f,j,k,l,m,o){f=(f-m)/(o-m);m=this.normal_cache;b[h]=j;b[h+1]=k+f*this.delta;b[h+
-2]=l;b=a+this.yd*3;e[h]=this.lerp(m[a],m[b],f);e[h+1]=this.lerp(m[a+1],m[b+1],f);e[h+2]=this.lerp(m[a+2],m[b+2],f)};this.VIntZ=function(a,b,e,h,f,j,k,l,m,o){f=(f-m)/(o-m);m=this.normal_cache;b[h]=j;b[h+1]=k;b[h+2]=l+f*this.delta;b=a+this.zd*3;e[h]=this.lerp(m[a],m[b],f);e[h+1]=this.lerp(m[a+1],m[b+1],f);e[h+2]=this.lerp(m[a+2],m[b+2],f)};this.compNorm=function(a){var b=a*3;this.normal_cache[b]==0&&(this.normal_cache[b]=this.field[a-1]-this.field[a+1],this.normal_cache[b+1]=this.field[a-this.yd]-this.field[a+
-this.yd],this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,e,h,f,j){var k=h+1,l=h+this.yd,m=h+this.zd,o=k+this.yd,n=k+this.zd,t=h+this.yd+this.zd,v=k+this.yd+this.zd,y=0,u=this.field[h],w=this.field[k],x=this.field[l],p=this.field[o],z=this.field[m],A=this.field[n],E=this.field[t],F=this.field[v];u<f&&(y|=1);w<f&&(y|=2);x<f&&(y|=8);p<f&&(y|=4);z<f&&(y|=16);A<f&&(y|=32);E<f&&(y|=128);F<f&&(y|=64);var G=THREE.edgeTable[y];if(G==0)return 0;var D=this.delta,
-K=a+D,I=b+D,D=e+D;G&1&&(this.compNorm(h),this.compNorm(k),this.VIntX(h*3,this.vlist,this.nlist,0,f,a,b,e,u,w));G&2&&(this.compNorm(k),this.compNorm(o),this.VIntY(k*3,this.vlist,this.nlist,3,f,K,b,e,w,p));G&4&&(this.compNorm(l),this.compNorm(o),this.VIntX(l*3,this.vlist,this.nlist,6,f,a,I,e,x,p));G&8&&(this.compNorm(h),this.compNorm(l),this.VIntY(h*3,this.vlist,this.nlist,9,f,a,b,e,u,x));G&16&&(this.compNorm(m),this.compNorm(n),this.VIntX(m*3,this.vlist,this.nlist,12,f,a,b,D,z,A));G&32&&(this.compNorm(n),
-this.compNorm(v),this.VIntY(n*3,this.vlist,this.nlist,15,f,K,b,D,A,F));G&64&&(this.compNorm(t),this.compNorm(v),this.VIntX(t*3,this.vlist,this.nlist,18,f,a,I,D,E,F));G&128&&(this.compNorm(m),this.compNorm(t),this.VIntY(m*3,this.vlist,this.nlist,21,f,a,b,D,z,E));G&256&&(this.compNorm(h),this.compNorm(m),this.VIntZ(h*3,this.vlist,this.nlist,24,f,a,b,e,u,z));G&512&&(this.compNorm(k),this.compNorm(n),this.VIntZ(k*3,this.vlist,this.nlist,27,f,K,b,e,w,A));G&1024&&(this.compNorm(o),this.compNorm(v),this.VIntZ(o*
-3,this.vlist,this.nlist,30,f,K,I,e,p,F));G&2048&&(this.compNorm(l),this.compNorm(t),this.VIntZ(l*3,this.vlist,this.nlist,33,f,a,I,e,x,E));y<<=4;for(f=h=0;THREE.triTable[y+f]!=-1;)a=y+f,b=a+1,e=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[e],j),f+=3,h++;return h};this.posnormtriv=function(a,b,e,h,f,j){var k=this.count*3;this.positionArray[k]=a[e];this.positionArray[k+1]=a[e+1];this.positionArray[k+2]=a[e+2];this.positionArray[k+3]=a[h];this.positionArray[k+
-4]=a[h+1];this.positionArray[k+5]=a[h+2];this.positionArray[k+6]=a[f];this.positionArray[k+7]=a[f+1];this.positionArray[k+8]=a[f+2];this.normalArray[k]=b[e];this.normalArray[k+1]=b[e+1];this.normalArray[k+2]=b[e+2];this.normalArray[k+3]=b[h];this.normalArray[k+4]=b[h+1];this.normalArray[k+5]=b[h+2];this.normalArray[k+6]=b[f];this.normalArray[k+7]=b[f+1];this.normalArray[k+8]=b[f+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&j(this)};this.begin=function(){this.count=0;
-this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var b=this.count*3;b<this.positionArray.length;b++)this.positionArray[b]=0;a(this)}};this.addBall=function(a,b,e,h,f){var j=this.size*Math.sqrt(h/f),k=e*this.size,l=b*this.size,m=a*this.size,o=Math.floor(k-j);o<1&&(o=1);k=Math.floor(k+j);k>this.size-1&&(k=this.size-1);var n=Math.floor(l-j);n<1&&(n=1);l=Math.floor(l+j);l>this.size-1&&(l=this.size-1);var t=Math.floor(m-j);t<1&&(t=1);j=Math.floor(m+j);j>this.size-1&&(j=this.size-
-1);for(var v,y,u,w,x,p;o<k;o++){m=this.size2*o;y=o/this.size-e;x=y*y;for(y=n;y<l;y++){u=m+this.size*y;v=y/this.size-b;p=v*v;for(v=t;v<j;v++)w=v/this.size-a,w=h/(1.0E-6+w*w+p+x)-f,w>0&&(this.field[u+v]+=w)}}};this.addPlaneX=function(a,b){var e,h,f,j,k,l=this.size,m=this.yd,o=this.zd,n=this.field,t=l*Math.sqrt(a/b);t>l&&(t=l);for(e=0;e<t;e++)if(h=e/l,h*=h,j=a/(1.0E-4+h)-b,j>0)for(h=0;h<l;h++){k=e+h*m;for(f=0;f<l;f++)n[o*f+k]+=j}};this.addPlaneY=function(a,b){var e,h,f,j,k,l,m=this.size,o=this.yd,n=
-this.zd,t=this.field,v=m*Math.sqrt(a/b);v>m&&(v=m);for(h=0;h<v;h++)if(e=h/m,e*=e,j=a/(1.0E-4+e)-b,j>0){k=h*o;for(e=0;e<m;e++){l=k+e;for(f=0;f<m;f++)t[n*f+l]+=j}}};this.addPlaneZ=function(a,b){var e,h,f,j,k,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(a/b);dist>size&&(dist=size);for(f=0;f<dist;f++)if(e=f/size,e*=e,j=a/(1.0E-4+e)-b,j>0){k=zd*f;for(h=0;h<size;h++){l=k+h*yd;for(e=0;e<size;e++)field[l+e]+=j}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[a*
-3]=0,this.field[a]=0};this.render=function(a){this.begin();var b,e,h,f,j,k,l,m,o,n=this.size-2;for(f=1;f<n;f++){o=this.size2*f;l=(f-this.halfsize)/this.halfsize;for(h=1;h<n;h++){m=o+this.size*h;k=(h-this.halfsize)/this.halfsize;for(e=1;e<n;e++)j=(e-this.halfsize)/this.halfsize,b=m+e,this.polygonize(j,k,l,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,e=[];this.render(function(h){var f,j,k,l,m,o,n,t;for(f=0;f<h.count;f++)n=f*3,m=n+1,t=n+2,j=h.positionArray[n],
-k=h.positionArray[m],l=h.positionArray[t],o=new THREE.Vector3(j,k,l),j=h.normalArray[n],k=h.normalArray[m],l=h.normalArray[t],n=new THREE.Vector3(j,k,l),n.normalize(),m=new THREE.Vertex(o),b.vertices.push(m),e.push(n);nfaces=h.count/3;for(f=0;f<nfaces;f++)n=(a+f)*3,m=n+1,t=n+2,o=e[n],j=e[m],k=e[t],n=new THREE.Face3(n,m,t,[o,j,k]),b.faces.push(n);a+=nfaces;h.count=0});return b};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
+THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var c="Loaded ";c+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";
+this.statusDomElement.innerHTML=c},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,c,b){a.materials=[];for(var g=0;g<c.length;++g)a.materials[g]=[THREE.Loader.prototype.createMaterial(c[g],b)]},hasNormals:function(a){var c,b,g=a.materials.length;for(b=0;b<g;b++)if(c=a.materials[b][0],c instanceof THREE.MeshShaderMaterial)return!0;return!1},createMaterial:function(a,c){function b(a){a=Math.log(a)/Math.LN2;return Math.floor(a)==a}function g(a,c){var e=
+new Image;e.onload=function(){if(!b(this.width)||!b(this.height)){var c=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),e=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));a.image.width=c;a.image.height=e;a.image.getContext("2d").drawImage(this,0,0,c,e)}else a.image=this;a.needsUpdate=!0};e.src=c}function f(a,b,e,h,f,j){var k=document.createElement("canvas");a[b]=new THREE.Texture(k);a[b].sourceFile=e;if(h){a[b].repeat.set(h[0],h[1]);if(h[0]!=1)a[b].wrapS=THREE.RepeatWrapping;if(h[1]!=
+1)a[b].wrapT=THREE.RepeatWrapping}f&&a[b].offset.set(f[0],f[1]);if(j){h={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(h[j[0]]!==void 0)a[b].wrapS=h[j[0]];if(h[j[1]]!==void 0)a[b].wrapT=h[j[1]]}g(a[b],c+"/"+e)}function h(a){return(a[0]*255<<16)+(a[1]*255<<8)+a[2]*255}var e,j,k;j="MeshLambertMaterial";e={color:15658734,opacity:1,map:null,lightMap:null,normalMap:null,wireframe:a.wireframe};a.shading&&(a.shading=="Phong"?j="MeshPhongMaterial":a.shading=="Basic"&&(j="MeshBasicMaterial"));
+if(a.blending)if(a.blending=="Additive")e.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")e.blending=THREE.SubtractiveBlending;else if(a.blending=="Multiply")e.blending=THREE.MultiplyBlending;if(a.transparent!==void 0||a.opacity<1)e.transparent=a.transparent;if(a.depthTest!==void 0)e.depthTest=a.depthTest;if(a.vertexColors!==void 0)if(a.vertexColors=="face")e.vertexColors=THREE.FaceColors;else if(a.vertexColors)e.vertexColors=THREE.VertexColors;if(a.colorDiffuse)e.color=h(a.colorDiffuse);
+else if(a.DbgColor)e.color=a.DbgColor;if(a.colorSpecular)e.specular=h(a.colorSpecular);if(a.colorAmbient)e.ambient=h(a.colorAmbient);if(a.transparency)e.opacity=a.transparency;if(a.specularCoef)e.shininess=a.specularCoef;a.mapDiffuse&&c&&f(e,"map",a.mapDiffuse,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap);a.mapLight&&c&&f(e,"lightMap",a.mapLight,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap);a.mapNormal&&c&&f(e,"normalMap",a.mapNormal,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap);
+a.mapSpecular&&c&&f(e,"specularMap",a.mapSpecular,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap);if(a.mapNormal){var l=THREE.ShaderUtils.lib.normal,m=THREE.UniformsUtils.clone(l.uniforms),n=e.color;j=e.specular;k=e.ambient;var o=e.shininess;m.tNormal.texture=e.normalMap;if(a.mapNormalFactor)m.uNormalScale.value=a.mapNormalFactor;if(e.map)m.tDiffuse.texture=e.map,m.enableDiffuse.value=!0;if(e.specularMap)m.tSpecular.texture=e.specularMap,m.enableSpecular.value=!0;if(e.lightMap)m.tAO.texture=
+e.lightMap,m.enableAO.value=!0;m.uDiffuseColor.value.setHex(n);m.uSpecularColor.value.setHex(j);m.uAmbientColor.value.setHex(k);m.uShininess.value=o;if(e.opacity)m.uOpacity.value=e.opacity;e=new THREE.MeshShaderMaterial({fragmentShader:l.fragmentShader,vertexShader:l.vertexShader,uniforms:m,lights:!0,fog:!0})}else e=new THREE[j](e);return e}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;
+THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;THREE.JSONLoader.prototype.load=function(a){var c=this,b=a.model,g=a.callback,f=a.texture_path?a.texture_path:this.extractUrlbase(b),a=new Worker(b);a.onmessage=function(a){c.createModel(a.data,g,f);c.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
+THREE.JSONLoader.prototype.createModel=function(a,c,b){var g=new THREE.Geometry,f=a.scale!==void 0?1/a.scale:1;this.init_materials(g,a.materials,b);(function(b){if(a.version===void 0||a.version!=2)console.error("Deprecated file format.");else{var c,f,k,l,m,n,o,p,w,t,v,x,y,u,z=a.faces;n=a.vertices;var B=a.normals,A=a.colors,E=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&E++;for(c=0;c<E;c++)g.faceUvs[c]=[],g.faceVertexUvs[c]=[];l=0;for(m=n.length;l<m;)o=new THREE.Vertex,o.position.x=n[l++]*b,o.position.y=
+n[l++]*b,o.position.z=n[l++]*b,g.vertices.push(o);l=0;for(m=z.length;l<m;){b=z[l++];n=b&1;k=b&2;c=b&4;f=b&8;p=b&16;o=b&32;t=b&64;b&=128;n?(v=new THREE.Face4,v.a=z[l++],v.b=z[l++],v.c=z[l++],v.d=z[l++],n=4):(v=new THREE.Face3,v.a=z[l++],v.b=z[l++],v.c=z[l++],n=3);if(k)k=z[l++],v.materials=g.materials[k];k=g.faces.length;if(c)for(c=0;c<E;c++)x=a.uvs[c],w=z[l++],u=x[w*2],w=x[w*2+1],g.faceUvs[c][k]=new THREE.UV(u,w);if(f)for(c=0;c<E;c++){x=a.uvs[c];y=[];for(f=0;f<n;f++)w=z[l++],u=x[w*2],w=x[w*2+1],y[f]=
+new THREE.UV(u,w);g.faceVertexUvs[c][k]=y}if(p)p=z[l++]*3,f=new THREE.Vector3,f.x=B[p++],f.y=B[p++],f.z=B[p],v.normal=f;if(o)for(c=0;c<n;c++)p=z[l++]*3,f=new THREE.Vector3,f.x=B[p++],f.y=B[p++],f.z=B[p],v.vertexNormals.push(f);if(t)o=z[l++],o=new THREE.Color(A[o]),v.color=o;if(b)for(c=0;c<n;c++)o=z[l++],o=new THREE.Color(A[o]),v.vertexColors.push(o);g.faces.push(v)}}})(f);(function(){var b,c,f,k;if(a.skinWeights){b=0;for(c=a.skinWeights.length;b<c;b+=2)f=a.skinWeights[b],k=a.skinWeights[b+1],g.skinWeights.push(new THREE.Vector4(f,
+k,0,0))}if(a.skinIndices){b=0;for(c=a.skinIndices.length;b<c;b+=2)f=a.skinIndices[b],k=a.skinIndices[b+1],g.skinIndices.push(new THREE.Vector4(f,k,0,0))}g.bones=a.bones;g.animation=a.animation})();(function(b){if(a.morphTargets!==void 0){var c,f,k,l,m,n,o,p,w;c=0;for(f=a.morphTargets.length;c<f;c++){g.morphTargets[c]={};g.morphTargets[c].name=a.morphTargets[c].name;g.morphTargets[c].vertices=[];p=g.morphTargets[c].vertices;w=a.morphTargets[c].vertices;k=0;for(l=w.length;k<l;k+=3)m=w[k]*b,n=w[k+1]*
+b,o=w[k+2]*b,p.push(new THREE.Vertex(new THREE.Vector3(m,n,o)))}}if(a.morphColors!==void 0){c=0;for(f=a.morphColors.length;c<f;c++){g.morphColors[c]={};g.morphColors[c].name=a.morphColors[c].name;g.morphColors[c].colors=[];l=g.morphColors[c].colors;m=a.morphColors[c].colors;b=0;for(k=m.length;b<k;b+=3)n=new THREE.Color(16755200),n.setRGB(m[b],m[b+1],m[b+2]),l.push(n)}}})(f);(function(){if(a.edges!==void 0){var b,c,f;for(b=0;b<a.edges.length;b+=2)c=a.edges[b],f=a.edges[b+1],g.edges.push(new THREE.Edge(g.vertices[c],
+g.vertices[f],c,f))}})();g.computeCentroids();g.computeFaceNormals();this.hasNormals(g)&&g.computeTangents();c(g)};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
+THREE.BinaryLoader.prototype={load:function(a){var c=a.model,b=a.callback,g=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c),a=(new Date).getTime(),c=new Worker(c),h=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(a){THREE.BinaryLoader.prototype.loadAjaxBuffers(a.data.buffers,a.data.materials,b,f,g,h)};c.onerror=function(a){alert("worker.onerror: "+a.message+"\n"+a.data);a.preventDefault()};
+c.postMessage(a)},loadAjaxBuffers:function(a,c,b,g,f,h){var e=new XMLHttpRequest,j=g+"/"+a,k=0;e.onreadystatechange=function(){e.readyState==4?e.status==200||e.status==0?THREE.BinaryLoader.prototype.createBinModel(e.responseText,b,f,c):alert("Couldn't load ["+j+"] ["+e.status+"]"):e.readyState==3?h&&(k==0&&(k=e.getResponseHeader("Content-Length")),h({total:k,loaded:e.responseText.length})):e.readyState==2&&(k=e.getResponseHeader("Content-Length"))};e.open("GET",j,!0);e.overrideMimeType("text/plain; charset=x-user-defined");
+e.setRequestHeader("Content-Type","text/plain");e.send(null)},createBinModel:function(a,c,b,g){var f=function(b){function c(a,b){var g=m(a,b),e=m(a,b+1),f=m(a,b+2),h=m(a,b+3),j=(h<<1&255|f>>7)-127;g|=(f&127)<<16|e<<8;if(g==0&&j==-127)return 0;return(1-2*(h>>7))*(1+g*Math.pow(2,-23))*Math.pow(2,j)}function f(a,b){var c=m(a,b),g=m(a,b+1),e=m(a,b+2);return(m(a,b+3)<<24)+(e<<16)+(g<<8)+c}function k(a,b){var c=m(a,b);return(m(a,b+1)<<8)+c}function l(a,b){var c=m(a,b);return c>127?c-256:c}function m(a,
+b){return a.charCodeAt(b)&255}function n(b){var c,g,e;c=f(a,b);g=f(a,b+A);e=f(a,b+E);b=k(a,b+G);THREE.BinaryLoader.prototype.f3(x,c,g,e,b)}function o(b){var c,g,e,h,l,m;c=f(a,b);g=f(a,b+A);e=f(a,b+E);h=k(a,b+G);l=f(a,b+H);m=f(a,b+L);b=f(a,b+J);THREE.BinaryLoader.prototype.f3n(x,z,c,g,e,h,l,m,b)}function p(b){var c,g,e,h;c=f(a,b);g=f(a,b+D);e=f(a,b+K);h=f(a,b+F);b=k(a,b+I);THREE.BinaryLoader.prototype.f4(x,c,g,e,h,b)}function w(b){var c,g,e,h,l,m,n,o;c=f(a,b);g=f(a,b+D);e=f(a,b+K);h=f(a,b+F);l=k(a,
+b+I);m=f(a,b+O);n=f(a,b+M);o=f(a,b+C);b=f(a,b+P);THREE.BinaryLoader.prototype.f4n(x,z,c,g,e,h,l,m,n,o,b)}function t(b){var c,g;c=f(a,b);g=f(a,b+N);b=f(a,b+R);THREE.BinaryLoader.prototype.uv3(x.faceVertexUvs[0],B[c*2],B[c*2+1],B[g*2],B[g*2+1],B[b*2],B[b*2+1])}function v(b){var c,g,e;c=f(a,b);g=f(a,b+S);e=f(a,b+Y);b=f(a,b+Z);THREE.BinaryLoader.prototype.uv4(x.faceVertexUvs[0],B[c*2],B[c*2+1],B[g*2],B[g*2+1],B[e*2],B[e*2+1],B[b*2],B[b*2+1])}var x=this,y=0,u,z=[],B=[],A,E,G,H,L,J,D,K,F,I,O,M,C,P,N,R,
+S,Y,Z,T,U,V,W,X,Q;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(x,g,b);u={signature:a.substr(y,8),header_bytes:m(a,y+8),vertex_coordinate_bytes:m(a,y+9),normal_coordinate_bytes:m(a,y+10),uv_coordinate_bytes:m(a,y+11),vertex_index_bytes:m(a,y+12),normal_index_bytes:m(a,y+13),uv_index_bytes:m(a,y+14),material_index_bytes:m(a,y+15),nvertices:f(a,y+16),nnormals:f(a,y+16+4),nuvs:f(a,y+16+8),ntri_flat:f(a,y+16+12),ntri_smooth:f(a,y+16+16),ntri_flat_uv:f(a,y+16+20),ntri_smooth_uv:f(a,y+
+16+24),nquad_flat:f(a,y+16+28),nquad_smooth:f(a,y+16+32),nquad_flat_uv:f(a,y+16+36),nquad_smooth_uv:f(a,y+16+40)};y+=u.header_bytes;A=u.vertex_index_bytes;E=u.vertex_index_bytes*2;G=u.vertex_index_bytes*3;H=u.vertex_index_bytes*3+u.material_index_bytes;L=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes;J=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes*2;D=u.vertex_index_bytes;K=u.vertex_index_bytes*2;F=u.vertex_index_bytes*3;I=u.vertex_index_bytes*4;O=u.vertex_index_bytes*
+4+u.material_index_bytes;M=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes;C=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*2;P=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*3;N=u.uv_index_bytes;R=u.uv_index_bytes*2;S=u.uv_index_bytes;Y=u.uv_index_bytes*2;Z=u.uv_index_bytes*3;b=u.vertex_index_bytes*3+u.material_index_bytes;Q=u.vertex_index_bytes*4+u.material_index_bytes;T=u.ntri_flat*b;U=u.ntri_smooth*(b+u.normal_index_bytes*3);V=u.ntri_flat_uv*
+(b+u.uv_index_bytes*3);W=u.ntri_smooth_uv*(b+u.normal_index_bytes*3+u.uv_index_bytes*3);X=u.nquad_flat*Q;b=u.nquad_smooth*(Q+u.normal_index_bytes*4);Q=u.nquad_flat_uv*(Q+u.uv_index_bytes*4);y+=function(b){for(var g,f,h,j=u.vertex_coordinate_bytes*3,k=b+u.nvertices*j;b<k;b+=j)g=c(a,b),f=c(a,b+u.vertex_coordinate_bytes),h=c(a,b+u.vertex_coordinate_bytes*2),THREE.BinaryLoader.prototype.v(x,g,f,h);return u.nvertices*j}(y);y+=function(b){for(var c,g,e,f=u.normal_coordinate_bytes*3,h=b+u.nnormals*f;b<h;b+=
+f)c=l(a,b),g=l(a,b+u.normal_coordinate_bytes),e=l(a,b+u.normal_coordinate_bytes*2),z.push(c/127,g/127,e/127);return u.nnormals*f}(y);y+=function(b){for(var g,f,h=u.uv_coordinate_bytes*2,j=b+u.nuvs*h;b<j;b+=h)g=c(a,b),f=c(a,b+u.uv_coordinate_bytes),B.push(g,f);return u.nuvs*h}(y);T=y+T;U=T+U;V=U+V;W=V+W;X=W+X;b=X+b;Q=b+Q;(function(a){var b,c=u.vertex_index_bytes*3+u.material_index_bytes,g=c+u.uv_index_bytes*3,e=a+u.ntri_flat_uv*g;for(b=a;b<e;b+=g)n(b),t(b+c);return e-a})(U);(function(a){var b,c=u.vertex_index_bytes*
+3+u.material_index_bytes+u.normal_index_bytes*3,g=c+u.uv_index_bytes*3,e=a+u.ntri_smooth_uv*g;for(b=a;b<e;b+=g)o(b),t(b+c);return e-a})(V);(function(a){var b,c=u.vertex_index_bytes*4+u.material_index_bytes,g=c+u.uv_index_bytes*4,e=a+u.nquad_flat_uv*g;for(b=a;b<e;b+=g)p(b),v(b+c);return e-a})(b);(function(a){var b,c=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*4,g=c+u.uv_index_bytes*4,e=a+u.nquad_smooth_uv*g;for(b=a;b<e;b+=g)w(b),v(b+c);return e-a})(Q);(function(a){var b,c=u.vertex_index_bytes*
+3+u.material_index_bytes,g=a+u.ntri_flat*c;for(b=a;b<g;b+=c)n(b);return g-a})(y);(function(a){var b,c=u.vertex_index_bytes*3+u.material_index_bytes+u.normal_index_bytes*3,g=a+u.ntri_smooth*c;for(b=a;b<g;b+=c)o(b);return g-a})(T);(function(a){var b,c=u.vertex_index_bytes*4+u.material_index_bytes,g=a+u.nquad_flat*c;for(b=a;b<g;b+=c)p(b);return g-a})(W);(function(a){var b,c=u.vertex_index_bytes*4+u.material_index_bytes+u.normal_index_bytes*4,g=a+u.nquad_smooth*c;for(b=a;b<g;b+=c)w(b);return g-a})(X);
+this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(b))},v:function(a,c,b,g){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,b,g)))},f3:function(a,c,b,g,f){a.faces.push(new THREE.Face3(c,b,g,null,null,a.materials[f]))},f4:function(a,c,b,g,f,h){a.faces.push(new THREE.Face4(c,b,g,f,null,null,a.materials[h]))},f3n:function(a,c,b,g,f,h,e,j,k){var h=a.materials[h],l=c[j*
+3],m=c[j*3+1],j=c[j*3+2],n=c[k*3],o=c[k*3+1],k=c[k*3+2];a.faces.push(new THREE.Face3(b,g,f,[new THREE.Vector3(c[e*3],c[e*3+1],c[e*3+2]),new THREE.Vector3(l,m,j),new THREE.Vector3(n,o,k)],null,h))},f4n:function(a,c,b,g,f,h,e,j,k,l,m){var e=a.materials[e],n=c[k*3],o=c[k*3+1],k=c[k*3+2],p=c[l*3],w=c[l*3+1],l=c[l*3+2],t=c[m*3],v=c[m*3+1],m=c[m*3+2];a.faces.push(new THREE.Face4(b,g,f,h,[new THREE.Vector3(c[j*3],c[j*3+1],c[j*3+2]),new THREE.Vector3(n,o,k),new THREE.Vector3(p,w,l),new THREE.Vector3(t,v,
+m)],null,e))},uv3:function(a,c,b,g,f,h,e){var j=[];j.push(new THREE.UV(c,b));j.push(new THREE.UV(g,f));j.push(new THREE.UV(h,e));a.push(j)},uv4:function(a,c,b,g,f,h,e,j,k){var l=[];l.push(new THREE.UV(c,b));l.push(new THREE.UV(g,f));l.push(new THREE.UV(h,e));l.push(new THREE.UV(j,k));a.push(l)}};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
+THREE.SceneLoader.prototype={load:function(a,c){var b=this,g=new Worker(a);g.postMessage(0);var f=THREE.Loader.prototype.extractUrlbase(a);g.onmessage=function(a){function g(a,b){return b=="relativeToHTML"?a:f+"/"+a}function j(){for(p in D.objects)if(!C.objects[p])if(y=D.objects[p],y.geometry!==void 0){if(A=C.geometries[y.geometry]){var a=!1;L=[];for(N=0;N<y.materials.length;N++)L[N]=C.materials[y.materials[N]],a=L[N]instanceof THREE.MeshShaderMaterial;a&&A.computeTangents();u=y.position;r=y.rotation;
+q=y.quaternion;s=y.scale;q=0;L.length==0&&(L[0]=new THREE.MeshFaceMaterial);L.length>1&&(L=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(A,L);object.name=p;object.position.set(u[0],u[1],u[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=y.visible;C.scene.addObject(object);C.objects[p]=object;y.meshCollider&&(a=THREE.CollisionUtils.MeshColliderWBox(object),C.scene.collisions.colliders.push(a));
+if(y.castsShadow)a=new THREE.ShadowVolume(A),C.scene.addChild(a),a.position=object.position,a.rotation=object.rotation,a.scale=object.scale;y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},C.triggers[object.name]=a)}}else u=y.position,r=y.rotation,q=y.quaternion,s=y.scale,q=0,object=new THREE.Object3D,object.name=p,object.position.set(u[0],u[1],u[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=y.visible!==void 0?y.visible:!1,C.scene.addObject(object),C.objects[p]=object,C.empties[p]=object,y.trigger&&y.trigger.toLowerCase()!="none"&&(a={type:y.trigger,object:y},C.triggers[object.name]=a)}function k(a){return function(c){C.geometries[a]=c;j();F-=1;b.onLoadComplete();m()}}function l(a){return function(b){C.geometries[a]=b}}function m(){b.callbackProgress({totalModels:O,totalTextures:M,loadedModels:O-F,loadedTextures:M-I},C);b.onLoadProgress();F==0&&I==0&&c(C)}var n,
+o,p,w,t,v,x,y,u,z,B,A,E,G,H,L,J,D,K,F,I,O,M,C;D=a.data;H=new THREE.BinaryLoader;K=new THREE.JSONLoader;I=F=0;C={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};a=!1;for(p in D.objects)if(y=D.objects[p],y.meshCollider){a=!0;break}if(a)C.scene.collisions=new THREE.CollisionSystem;if(D.transform){a=D.transform.position;z=D.transform.rotation;var P=D.transform.scale;a&&C.scene.position.set(a[0],a[1],a[2]);z&&C.scene.rotation.set(z[0],
+z[1],z[2]);P&&C.scene.scale.set(P[0],P[1],P[2]);(a||z||P)&&C.scene.updateMatrix()}a=function(){I-=1;m();b.onLoadComplete()};for(t in D.cameras){z=D.cameras[t];if(z.type=="perspective")E=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho")E=new THREE.Camera,E.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far);u=z.position;z=z.target;E.position.set(u[0],u[1],u[2]);E.target.position.set(z[0],z[1],z[2]);C.cameras[t]=E}for(w in D.lights)t=D.lights[w],
+E=t.color!==void 0?t.color:16777215,z=t.intensity!==void 0?t.intensity:1,t.type=="directional"?(u=t.direction,J=new THREE.DirectionalLight(E,z),J.position.set(u[0],u[1],u[2]),J.position.normalize()):t.type=="point"?(u=t.position,d=t.distance,J=new THREE.PointLight(E,z,d),J.position.set(u[0],u[1],u[2])):t.type=="ambient"&&(J=new THREE.AmbientLight(E)),C.scene.addLight(J),C.lights[w]=J;for(v in D.fogs)w=D.fogs[v],w.type=="linear"?G=new THREE.Fog(0,w.near,w.far):w.type=="exp2"&&(G=new THREE.FogExp2(0,
+w.density)),z=w.color,G.color.setRGB(z[0],z[1],z[2]),C.fogs[v]=G;if(C.cameras&&D.defaults.camera)C.currentCamera=C.cameras[D.defaults.camera];if(C.fogs&&D.defaults.fog)C.scene.fog=C.fogs[D.defaults.fog];z=D.defaults.bgcolor;C.bgColor=new THREE.Color;C.bgColor.setRGB(z[0],z[1],z[2]);C.bgColorAlpha=D.defaults.bgalpha;for(n in D.geometries)if(v=D.geometries[n],v.type=="bin_mesh"||v.type=="ascii_mesh")F+=1,b.onLoadStart();O=F;for(n in D.geometries)v=D.geometries[n],v.type=="cube"?(A=new THREE.CubeGeometry(v.width,
+v.height,v.depth,v.segmentsWidth,v.segmentsHeight,v.segmentsDepth,null,v.flipped,v.sides),C.geometries[n]=A):v.type=="plane"?(A=new THREE.PlaneGeometry(v.width,v.height,v.segmentsWidth,v.segmentsHeight),C.geometries[n]=A):v.type=="sphere"?(A=new THREE.SphereGeometry(v.radius,v.segmentsWidth,v.segmentsHeight),C.geometries[n]=A):v.type=="cylinder"?(A=new THREE.CylinderGeometry(v.numSegs,v.topRad,v.botRad,v.height,v.topOffset,v.botOffset),C.geometries[n]=A):v.type=="torus"?(A=new THREE.TorusGeometry(v.radius,
+v.tube,v.segmentsR,v.segmentsT),C.geometries[n]=A):v.type=="icosahedron"?(A=new THREE.IcosahedronGeometry(v.subdivisions),C.geometries[n]=A):v.type=="bin_mesh"?H.load({model:g(v.url,D.urlBaseType),callback:k(n)}):v.type=="ascii_mesh"?K.load({model:g(v.url,D.urlBaseType),callback:k(n)}):v.type=="embedded_mesh"&&(v=D.embeds[v.id])&&K.createModel(v,l(n),"");for(x in D.textures)if(n=D.textures[x],n.url instanceof Array){I+=n.url.length;for(H=0;H<n.url.length;H++)b.onLoadStart()}else I+=1,b.onLoadStart();
+M=I;for(x in D.textures){n=D.textures[x];if(n.mapping!=void 0&&THREE[n.mapping]!=void 0)n.mapping=new THREE[n.mapping];if(n.url instanceof Array){H=[];for(var N=0;N<n.url.length;N++)H[N]=g(n.url[N],D.urlBaseType);H=THREE.ImageUtils.loadTextureCube(H,n.mapping,a)}else{H=THREE.ImageUtils.loadTexture(g(n.url,D.urlBaseType),n.mapping,a);if(THREE[n.minFilter]!=void 0)H.minFilter=THREE[n.minFilter];if(THREE[n.magFilter]!=void 0)H.magFilter=THREE[n.magFilter];if(n.repeat){H.repeat.set(n.repeat[0],n.repeat[1]);
+if(n.repeat[0]!=1)H.wrapS=THREE.RepeatWrapping;if(n.repeat[1]!=1)H.wrapT=THREE.RepeatWrapping}n.offset&&H.offset.set(n.offset[0],n.offset[1]);if(n.wrap){K={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(K[n.wrap[0]]!==void 0)H.wrapS=K[n.wrap[0]];if(K[n.wrap[1]]!==void 0)H.wrapT=K[n.wrap[1]]}}C.textures[x]=H}for(o in D.materials){x=D.materials[o];for(B in x.parameters)if(B=="envMap"||B=="map"||B=="lightMap")x.parameters[B]=C.textures[x.parameters[B]];else if(B=="shading")x.parameters[B]=
+x.parameters[B]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(B=="blending")x.parameters[B]=THREE[x.parameters[B]]?THREE[x.parameters[B]]:THREE.NormalBlending;else if(B=="combine")x.parameters[B]=x.parameters[B]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(B=="vertexColors")if(x.parameters[B]=="face")x.parameters[B]=THREE.FaceColors;else if(x.parameters[B])x.parameters[B]=THREE.VertexColors;if(x.parameters.opacity!==void 0&&x.parameters.opacity<1)x.parameters.transparent=
+!0;if(x.parameters.normalMap){n=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(n.uniforms);H=x.parameters.color;K=x.parameters.specular;v=x.parameters.ambient;G=x.parameters.shininess;a.tNormal.texture=C.textures[x.parameters.normalMap];if(x.parameters.normalMapFactor)a.uNormalScale.value=x.parameters.normalMapFactor;if(x.parameters.map)a.tDiffuse.texture=x.parameters.map,a.enableDiffuse.value=!0;if(x.parameters.lightMap)a.tAO.texture=x.parameters.lightMap,a.enableAO.value=!0;if(x.parameters.specularMap)a.tSpecular.texture=
+C.textures[x.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(H);a.uSpecularColor.value.setHex(K);a.uAmbientColor.value.setHex(v);a.uShininess.value=G;if(x.parameters.opacity)a.uOpacity.value=x.parameters.opacity;x=new THREE.MeshShaderMaterial({fragmentShader:n.fragmentShader,vertexShader:n.vertexShader,uniforms:a,lights:!0,fog:!0})}else x=new THREE[x.type](x.parameters);C.materials[o]=x}j();b.callbackSync(C)}}};
+THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(a){this.isolation=80;this.size=a;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(a,c,f){return a+(c-a)*f};this.VIntX=function(a,c,f,h,e,j,k,l,m,n){e=(e-m)/(n-m);m=this.normal_cache;c[h]=j+e*this.delta;c[h+1]=k;c[h+2]=l;f[h]=this.lerp(m[a],m[a+3],e);f[h+1]=this.lerp(m[a+1],m[a+4],e);f[h+2]=this.lerp(m[a+2],m[a+5],e)};this.VIntY=function(a,c,f,h,e,j,k,l,m,n){e=(e-m)/(n-m);m=this.normal_cache;c[h]=j;c[h+1]=k+e*this.delta;c[h+
+2]=l;c=a+this.yd*3;f[h]=this.lerp(m[a],m[c],e);f[h+1]=this.lerp(m[a+1],m[c+1],e);f[h+2]=this.lerp(m[a+2],m[c+2],e)};this.VIntZ=function(a,c,f,h,e,j,k,l,m,n){e=(e-m)/(n-m);m=this.normal_cache;c[h]=j;c[h+1]=k;c[h+2]=l+e*this.delta;c=a+this.zd*3;f[h]=this.lerp(m[a],m[c],e);f[h+1]=this.lerp(m[a+1],m[c+1],e);f[h+2]=this.lerp(m[a+2],m[c+2],e)};this.compNorm=function(a){var c=a*3;this.normal_cache[c]==0&&(this.normal_cache[c]=this.field[a-1]-this.field[a+1],this.normal_cache[c+1]=this.field[a-this.yd]-this.field[a+
+this.yd],this.normal_cache[c+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,c,f,h,e,j){var k=h+1,l=h+this.yd,m=h+this.zd,n=k+this.yd,o=k+this.zd,p=h+this.yd+this.zd,w=k+this.yd+this.zd,t=0,v=this.field[h],x=this.field[k],y=this.field[l],u=this.field[n],z=this.field[m],B=this.field[o],A=this.field[p],E=this.field[w];v<e&&(t|=1);x<e&&(t|=2);y<e&&(t|=8);u<e&&(t|=4);z<e&&(t|=16);B<e&&(t|=32);A<e&&(t|=128);E<e&&(t|=64);var G=THREE.edgeTable[t];if(G==0)return 0;var H=this.delta,
+L=a+H,J=c+H,H=f+H;G&1&&(this.compNorm(h),this.compNorm(k),this.VIntX(h*3,this.vlist,this.nlist,0,e,a,c,f,v,x));G&2&&(this.compNorm(k),this.compNorm(n),this.VIntY(k*3,this.vlist,this.nlist,3,e,L,c,f,x,u));G&4&&(this.compNorm(l),this.compNorm(n),this.VIntX(l*3,this.vlist,this.nlist,6,e,a,J,f,y,u));G&8&&(this.compNorm(h),this.compNorm(l),this.VIntY(h*3,this.vlist,this.nlist,9,e,a,c,f,v,y));G&16&&(this.compNorm(m),this.compNorm(o),this.VIntX(m*3,this.vlist,this.nlist,12,e,a,c,H,z,B));G&32&&(this.compNorm(o),
+this.compNorm(w),this.VIntY(o*3,this.vlist,this.nlist,15,e,L,c,H,B,E));G&64&&(this.compNorm(p),this.compNorm(w),this.VIntX(p*3,this.vlist,this.nlist,18,e,a,J,H,A,E));G&128&&(this.compNorm(m),this.compNorm(p),this.VIntY(m*3,this.vlist,this.nlist,21,e,a,c,H,z,A));G&256&&(this.compNorm(h),this.compNorm(m),this.VIntZ(h*3,this.vlist,this.nlist,24,e,a,c,f,v,z));G&512&&(this.compNorm(k),this.compNorm(o),this.VIntZ(k*3,this.vlist,this.nlist,27,e,L,c,f,x,B));G&1024&&(this.compNorm(n),this.compNorm(w),this.VIntZ(n*
+3,this.vlist,this.nlist,30,e,L,J,f,u,E));G&2048&&(this.compNorm(l),this.compNorm(p),this.VIntZ(l*3,this.vlist,this.nlist,33,e,a,J,f,y,A));t<<=4;for(e=h=0;THREE.triTable[t+e]!=-1;)a=t+e,c=a+1,f=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[c],3*THREE.triTable[f],j),e+=3,h++;return h};this.posnormtriv=function(a,c,f,h,e,j){var k=this.count*3;this.positionArray[k]=a[f];this.positionArray[k+1]=a[f+1];this.positionArray[k+2]=a[f+2];this.positionArray[k+3]=a[h];this.positionArray[k+
+4]=a[h+1];this.positionArray[k+5]=a[h+2];this.positionArray[k+6]=a[e];this.positionArray[k+7]=a[e+1];this.positionArray[k+8]=a[e+2];this.normalArray[k]=c[f];this.normalArray[k+1]=c[f+1];this.normalArray[k+2]=c[f+2];this.normalArray[k+3]=c[h];this.normalArray[k+4]=c[h+1];this.normalArray[k+5]=c[h+2];this.normalArray[k+6]=c[e];this.normalArray[k+7]=c[e+1];this.normalArray[k+8]=c[e+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&j(this)};this.begin=function(){this.count=0;
+this.hasNormal=this.hasPos=!1};this.end=function(a){if(this.count!=0){for(var c=this.count*3;c<this.positionArray.length;c++)this.positionArray[c]=0;a(this)}};this.addBall=function(a,c,f,h,e){var j=this.size*Math.sqrt(h/e),k=f*this.size,l=c*this.size,m=a*this.size,n=Math.floor(k-j);n<1&&(n=1);k=Math.floor(k+j);k>this.size-1&&(k=this.size-1);var o=Math.floor(l-j);o<1&&(o=1);l=Math.floor(l+j);l>this.size-1&&(l=this.size-1);var p=Math.floor(m-j);p<1&&(p=1);j=Math.floor(m+j);j>this.size-1&&(j=this.size-
+1);for(var w,t,v,x,y,u;n<k;n++){m=this.size2*n;t=n/this.size-f;y=t*t;for(t=o;t<l;t++){v=m+this.size*t;w=t/this.size-c;u=w*w;for(w=p;w<j;w++)x=w/this.size-a,x=h/(1.0E-6+x*x+u+y)-e,x>0&&(this.field[v+w]+=x)}}};this.addPlaneX=function(a,c){var f,h,e,j,k,l=this.size,m=this.yd,n=this.zd,o=this.field,p=l*Math.sqrt(a/c);p>l&&(p=l);for(f=0;f<p;f++)if(h=f/l,h*=h,j=a/(1.0E-4+h)-c,j>0)for(h=0;h<l;h++){k=f+h*m;for(e=0;e<l;e++)o[n*e+k]+=j}};this.addPlaneY=function(a,c){var f,h,e,j,k,l,m=this.size,n=this.yd,o=
+this.zd,p=this.field,w=m*Math.sqrt(a/c);w>m&&(w=m);for(h=0;h<w;h++)if(f=h/m,f*=f,j=a/(1.0E-4+f)-c,j>0){k=h*n;for(f=0;f<m;f++){l=k+f;for(e=0;e<m;e++)p[o*e+l]+=j}}};this.addPlaneZ=function(a,c){var f,h,e,j,k,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(a/c);dist>size&&(dist=size);for(e=0;e<dist;e++)if(f=e/size,f*=f,j=a/(1.0E-4+f)-c,j>0){k=zd*e;for(h=0;h<size;h++){l=k+h*yd;for(f=0;f<size;f++)field[l+f]+=j}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[a*
+3]=0,this.field[a]=0};this.render=function(a){this.begin();var c,f,h,e,j,k,l,m,n,o=this.size-2;for(e=1;e<o;e++){n=this.size2*e;l=(e-this.halfsize)/this.halfsize;for(h=1;h<o;h++){m=n+this.size*h;k=(h-this.halfsize)/this.halfsize;for(f=1;f<o;f++)j=(f-this.halfsize)/this.halfsize,c=m+f,this.polygonize(j,k,l,c,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,c=new THREE.Geometry,f=[];this.render(function(h){var e,j,k,l,m,n,o,p;for(e=0;e<h.count;e++)o=e*3,m=o+1,p=o+2,j=h.positionArray[o],
+k=h.positionArray[m],l=h.positionArray[p],n=new THREE.Vector3(j,k,l),j=h.normalArray[o],k=h.normalArray[m],l=h.normalArray[p],o=new THREE.Vector3(j,k,l),o.normalize(),m=new THREE.Vertex(n),c.vertices.push(m),f.push(o);nfaces=h.count/3;for(e=0;e<nfaces;e++)o=(a+e)*3,m=o+1,p=o+2,n=f[o],j=f[m],k=f[p],o=new THREE.Face3(o,m,p,[n,j,k]),c.faces.push(o);a+=nfaces;h.count=0});return c};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
 419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
@@ -216,27 +239,27 @@ THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0
 4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,
 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);
-THREE.Trident=function(a){function b(b){return new THREE.Mesh(new THREE.CylinderGeometry(30,0.1,a.length/20,a.length/5),new THREE.MeshBasicMaterial({color:b}))}function c(a,b){var c=new THREE.Geometry;c.vertices=[new THREE.Vertex,new THREE.Vertex(a)];return new THREE.Line(c,new THREE.LineBasicMaterial({color:b}))}THREE.Object3D.call(this);var g=Math.PI/2,e,a=a||THREE.Trident.defaultParams;if(a!==THREE.Trident.defaultParams)for(e in THREE.Trident.defaultParams)a.hasOwnProperty(e)||(a[e]=THREE.Trident.defaultParams[e]);
-this.scale=new THREE.Vector3(a.scale,a.scale,a.scale);this.addChild(c(new THREE.Vector3(a.length,0,0),a.xAxisColor));this.addChild(c(new THREE.Vector3(0,a.length,0),a.yAxisColor));this.addChild(c(new THREE.Vector3(0,0,a.length),a.zAxisColor));if(a.showArrows)e=b(a.xAxisColor),e.rotation.y=-g,e.position.x=a.length,this.addChild(e),e=b(a.yAxisColor),e.rotation.x=g,e.position.y=a.length,this.addChild(e),e=b(a.zAxisColor),e.rotation.y=Math.PI,e.position.z=a.length,this.addChild(e)};
-THREE.Trident.prototype=new THREE.Object3D;THREE.Trident.prototype.constructor=THREE.Trident;THREE.Trident.defaultParams={xAxisColor:16711680,yAxisColor:65280,zAxisColor:255,showArrows:!0,length:100,scale:1};THREE.PlaneCollider=function(a,b){this.point=a;this.normal=b};THREE.SphereCollider=function(a,b){this.center=a;this.radius=b;this.radiusSq=b*b};THREE.BoxCollider=function(a,b){this.min=a;this.max=b;this.dynamic=!0;this.normal=new THREE.Vector3};
-THREE.MeshCollider=function(a,b){this.mesh=a;this.box=b;this.numFaces=this.mesh.geometry.faces.length;this.normal=new THREE.Vector3};THREE.CollisionSystem=function(){this.collisionNormal=new THREE.Vector3;this.colliders=[];this.hits=[]};THREE.Collisions=new THREE.CollisionSystem;THREE.CollisionSystem.prototype.merge=function(a){this.colliders=this.colliders.concat(a.colliders);this.hits=this.hits.concat(a.hits)};
-THREE.CollisionSystem.prototype.rayCastAll=function(a){a.direction.normalize();this.hits.length=0;var b,c,g,e,h=0;b=0;for(c=this.colliders.length;b<c;b++)if(e=this.colliders[b],g=this.rayCast(a,e),g<Number.MAX_VALUE)e.distance=g,g>h?this.hits.push(e):this.hits.unshift(e),h=g;return this.hits};
-THREE.CollisionSystem.prototype.rayCastNearest=function(a){var b=this.rayCastAll(a);if(b.length==0)return null;for(var c=0;b[c]instanceof THREE.MeshCollider;){var g=this.rayMesh(a,b[c]);if(g.dist<Number.MAX_VALUE){b[c].distance=g.dist;b[c].faceIndex=g.faceIndex;break}c++}if(c>b.length)return null;return b[c]};
-THREE.CollisionSystem.prototype.rayCast=function(a,b){if(b instanceof THREE.PlaneCollider)return this.rayPlane(a,b);else if(b instanceof THREE.SphereCollider)return this.raySphere(a,b);else if(b instanceof THREE.BoxCollider)return this.rayBox(a,b);else if(b instanceof THREE.MeshCollider&&b.box)return this.rayBox(a,b.box)};
-THREE.CollisionSystem.prototype.rayMesh=function(a,b){for(var c=this.makeRayLocal(a,b.mesh),g=Number.MAX_VALUE,e,h=0;h<b.numFaces;h++){var f=b.mesh.geometry.faces[h],j=b.mesh.geometry.vertices[f.a].position,k=b.mesh.geometry.vertices[f.b].position,l=b.mesh.geometry.vertices[f.c].position,m=f instanceof THREE.Face4?b.mesh.geometry.vertices[f.d].position:null;f instanceof THREE.Face3?(f=this.rayTriangle(c,j,k,l,g,this.collisionNormal,b.mesh),f<g&&(g=f,e=h,b.normal.copy(this.collisionNormal),b.normal.normalize())):
-f instanceof THREE.Face4&&(f=this.rayTriangle(c,j,k,m,g,this.collisionNormal,b.mesh),f<g&&(g=f,e=h,b.normal.copy(this.collisionNormal),b.normal.normalize()),f=this.rayTriangle(c,k,l,m,g,this.collisionNormal,b.mesh),f<g&&(g=f,e=h,b.normal.copy(this.collisionNormal),b.normal.normalize()))}return{dist:g,faceIndex:e}};
-THREE.CollisionSystem.prototype.rayTriangle=function(a,b,c,g,e,h,f){var j=THREE.CollisionSystem.__v1,k=THREE.CollisionSystem.__v2;h.set(0,0,0);j.sub(c,b);k.sub(g,c);h.cross(j,k);j=h.dot(a.direction);if(!(j<0))if(f.doubleSided||f.flipSided)h.multiplyScalar(-1),j*=-1;else return Number.MAX_VALUE;f=h.dot(b)-h.dot(a.origin);if(!(f<=0))return Number.MAX_VALUE;if(!(f>=j*e))return Number.MAX_VALUE;f/=j;j=THREE.CollisionSystem.__v3;j.copy(a.direction);j.multiplyScalar(f);j.addSelf(a.origin);Math.abs(h.x)>
-Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(a=j.y-b.y,h=c.y-b.y,e=g.y-b.y,j=j.z-b.z,c=c.z-b.z,g=g.z-b.z):(a=j.x-b.x,h=c.x-b.x,e=g.x-b.x,j=j.y-b.y,c=c.y-b.y,g=g.y-b.y):Math.abs(h.y)>Math.abs(h.z)?(a=j.x-b.x,h=c.x-b.x,e=g.x-b.x,j=j.z-b.z,c=c.z-b.z,g=g.z-b.z):(a=j.x-b.x,h=c.x-b.x,e=g.x-b.x,j=j.y-b.y,c=c.y-b.y,g=g.y-b.y);b=h*g-c*e;if(b==0)return Number.MAX_VALUE;b=1/b;g=(a*g-j*e)*b;if(!(g>=0))return Number.MAX_VALUE;b*=h*j-c*a;if(!(b>=0))return Number.MAX_VALUE;if(!(1-g-b>=0))return Number.MAX_VALUE;return f};
-THREE.CollisionSystem.prototype.makeRayLocal=function(a,b){var c=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(b.matrixWorld,c);var g=THREE.CollisionSystem.__r;g.origin.copy(a.origin);g.direction.copy(a.direction);c.multiplyVector3(g.origin);c.rotateAxis(g.direction);g.direction.normalize();return g};
-THREE.CollisionSystem.prototype.rayBox=function(a,b){var c;b.dynamic&&b.mesh&&b.mesh.matrixWorld?c=this.makeRayLocal(a,b.mesh):(c=THREE.CollisionSystem.__r,c.origin.copy(a.origin),c.direction.copy(a.direction));var g=0,e=0,h=0,f=0,j=0,k=0,l=!0;c.origin.x<b.min.x?(g=b.min.x-c.origin.x,g/=c.direction.x,l=!1,f=-1):c.origin.x>b.max.x&&(g=b.max.x-c.origin.x,g/=c.direction.x,l=!1,f=1);c.origin.y<b.min.y?(e=b.min.y-c.origin.y,e/=c.direction.y,l=!1,j=-1):c.origin.y>b.max.y&&(e=b.max.y-c.origin.y,e/=c.direction.y,
-l=!1,j=1);c.origin.z<b.min.z?(h=b.min.z-c.origin.z,h/=c.direction.z,l=!1,k=-1):c.origin.z>b.max.z&&(h=b.max.z-c.origin.z,h/=c.direction.z,l=!1,k=1);if(l)return-1;l=0;e>g&&(l=1,g=e);h>g&&(l=2,g=h);switch(l){case 0:j=c.origin.y+c.direction.y*g;if(j<b.min.y||j>b.max.y)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*g;if(c<b.min.z||c>b.max.z)return Number.MAX_VALUE;b.normal.set(f,0,0);break;case 1:f=c.origin.x+c.direction.x*g;if(f<b.min.x||f>b.max.x)return Number.MAX_VALUE;c=c.origin.z+c.direction.z*
-g;if(c<b.min.z||c>b.max.z)return Number.MAX_VALUE;b.normal.set(0,j,0);break;case 2:f=c.origin.x+c.direction.x*g;if(f<b.min.x||f>b.max.x)return Number.MAX_VALUE;j=c.origin.y+c.direction.y*g;if(j<b.min.y||j>b.max.y)return Number.MAX_VALUE;b.normal.set(0,0,k)}return g};THREE.CollisionSystem.prototype.rayPlane=function(a,b){var c=a.direction.dot(b.normal),g=b.point.dot(b.normal);if(c<0)c=(g-a.origin.dot(b.normal))/c;else return Number.MAX_VALUE;return c>0?c:Number.MAX_VALUE};
-THREE.CollisionSystem.prototype.raySphere=function(a,b){var c=b.center.clone().subSelf(a.origin);if(c.lengthSq<b.radiusSq)return-1;var g=c.dot(a.direction.clone());if(g<=0)return Number.MAX_VALUE;c=b.radiusSq-(c.lengthSq()-g*g);if(c>=0)return Math.abs(g)-Math.sqrt(c);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4;
-THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var b=a.geometry.boundingBox,c=new THREE.Vector3(b.x[0],b.y[0],b.z[0]),b=new THREE.Vector3(b.x[1],b.y[1],b.z[1]),c=new THREE.BoxCollider(c,b);c.mesh=a;return c};THREE.CollisionUtils.MeshAABB=function(a){var b=THREE.CollisionUtils.MeshOBB(a);b.min.addSelf(a.position);b.max.addSelf(a.position);b.dynamic=!1;return b};
+THREE.Trident=function(a){function c(b){return new THREE.Mesh(new THREE.CylinderGeometry(30,0.1,a.length/20,a.length/5),new THREE.MeshBasicMaterial({color:b}))}function b(a,b){var c=new THREE.Geometry;c.vertices=[new THREE.Vertex,new THREE.Vertex(a)];return new THREE.Line(c,new THREE.LineBasicMaterial({color:b}))}THREE.Object3D.call(this);var g=Math.PI/2,f,a=a||THREE.Trident.defaultParams;if(a!==THREE.Trident.defaultParams)for(f in THREE.Trident.defaultParams)a.hasOwnProperty(f)||(a[f]=THREE.Trident.defaultParams[f]);
+this.scale=new THREE.Vector3(a.scale,a.scale,a.scale);this.addChild(b(new THREE.Vector3(a.length,0,0),a.xAxisColor));this.addChild(b(new THREE.Vector3(0,a.length,0),a.yAxisColor));this.addChild(b(new THREE.Vector3(0,0,a.length),a.zAxisColor));if(a.showArrows)f=c(a.xAxisColor),f.rotation.y=-g,f.position.x=a.length,this.addChild(f),f=c(a.yAxisColor),f.rotation.x=g,f.position.y=a.length,this.addChild(f),f=c(a.zAxisColor),f.rotation.y=Math.PI,f.position.z=a.length,this.addChild(f)};
+THREE.Trident.prototype=new THREE.Object3D;THREE.Trident.prototype.constructor=THREE.Trident;THREE.Trident.defaultParams={xAxisColor:16711680,yAxisColor:65280,zAxisColor:255,showArrows:!0,length:100,scale:1};THREE.PlaneCollider=function(a,c){this.point=a;this.normal=c};THREE.SphereCollider=function(a,c){this.center=a;this.radius=c;this.radiusSq=c*c};THREE.BoxCollider=function(a,c){this.min=a;this.max=c;this.dynamic=!0;this.normal=new THREE.Vector3};
+THREE.MeshCollider=function(a,c){this.mesh=a;this.box=c;this.numFaces=this.mesh.geometry.faces.length;this.normal=new THREE.Vector3};THREE.CollisionSystem=function(){this.collisionNormal=new THREE.Vector3;this.colliders=[];this.hits=[]};THREE.Collisions=new THREE.CollisionSystem;THREE.CollisionSystem.prototype.merge=function(a){this.colliders=this.colliders.concat(a.colliders);this.hits=this.hits.concat(a.hits)};
+THREE.CollisionSystem.prototype.rayCastAll=function(a){a.direction.normalize();this.hits.length=0;var c,b,g,f,h=0;c=0;for(b=this.colliders.length;c<b;c++)if(f=this.colliders[c],g=this.rayCast(a,f),g<Number.MAX_VALUE)f.distance=g,g>h?this.hits.push(f):this.hits.unshift(f),h=g;return this.hits};
+THREE.CollisionSystem.prototype.rayCastNearest=function(a){var c=this.rayCastAll(a);if(c.length==0)return null;for(var b=0;c[b]instanceof THREE.MeshCollider;){var g=this.rayMesh(a,c[b]);if(g.dist<Number.MAX_VALUE){c[b].distance=g.dist;c[b].faceIndex=g.faceIndex;break}b++}if(b>c.length)return null;return c[b]};
+THREE.CollisionSystem.prototype.rayCast=function(a,c){if(c instanceof THREE.PlaneCollider)return this.rayPlane(a,c);else if(c instanceof THREE.SphereCollider)return this.raySphere(a,c);else if(c instanceof THREE.BoxCollider)return this.rayBox(a,c);else if(c instanceof THREE.MeshCollider&&c.box)return this.rayBox(a,c.box)};
+THREE.CollisionSystem.prototype.rayMesh=function(a,c){for(var b=this.makeRayLocal(a,c.mesh),g=Number.MAX_VALUE,f,h=0;h<c.numFaces;h++){var e=c.mesh.geometry.faces[h],j=c.mesh.geometry.vertices[e.a].position,k=c.mesh.geometry.vertices[e.b].position,l=c.mesh.geometry.vertices[e.c].position,m=e instanceof THREE.Face4?c.mesh.geometry.vertices[e.d].position:null;e instanceof THREE.Face3?(e=this.rayTriangle(b,j,k,l,g,this.collisionNormal,c.mesh),e<g&&(g=e,f=h,c.normal.copy(this.collisionNormal),c.normal.normalize())):
+e instanceof THREE.Face4&&(e=this.rayTriangle(b,j,k,m,g,this.collisionNormal,c.mesh),e<g&&(g=e,f=h,c.normal.copy(this.collisionNormal),c.normal.normalize()),e=this.rayTriangle(b,k,l,m,g,this.collisionNormal,c.mesh),e<g&&(g=e,f=h,c.normal.copy(this.collisionNormal),c.normal.normalize()))}return{dist:g,faceIndex:f}};
+THREE.CollisionSystem.prototype.rayTriangle=function(a,c,b,g,f,h,e){var j=THREE.CollisionSystem.__v1,k=THREE.CollisionSystem.__v2;h.set(0,0,0);j.sub(b,c);k.sub(g,b);h.cross(j,k);j=h.dot(a.direction);if(!(j<0))if(e.doubleSided||e.flipSided)h.multiplyScalar(-1),j*=-1;else return Number.MAX_VALUE;e=h.dot(c)-h.dot(a.origin);if(!(e<=0))return Number.MAX_VALUE;if(!(e>=j*f))return Number.MAX_VALUE;e/=j;j=THREE.CollisionSystem.__v3;j.copy(a.direction);j.multiplyScalar(e);j.addSelf(a.origin);Math.abs(h.x)>
+Math.abs(h.y)?Math.abs(h.x)>Math.abs(h.z)?(a=j.y-c.y,h=b.y-c.y,f=g.y-c.y,j=j.z-c.z,b=b.z-c.z,g=g.z-c.z):(a=j.x-c.x,h=b.x-c.x,f=g.x-c.x,j=j.y-c.y,b=b.y-c.y,g=g.y-c.y):Math.abs(h.y)>Math.abs(h.z)?(a=j.x-c.x,h=b.x-c.x,f=g.x-c.x,j=j.z-c.z,b=b.z-c.z,g=g.z-c.z):(a=j.x-c.x,h=b.x-c.x,f=g.x-c.x,j=j.y-c.y,b=b.y-c.y,g=g.y-c.y);c=h*g-b*f;if(c==0)return Number.MAX_VALUE;c=1/c;g=(a*g-j*f)*c;if(!(g>=0))return Number.MAX_VALUE;c*=h*j-b*a;if(!(c>=0))return Number.MAX_VALUE;if(!(1-g-c>=0))return Number.MAX_VALUE;return e};
+THREE.CollisionSystem.prototype.makeRayLocal=function(a,c){var b=THREE.CollisionSystem.__m;THREE.Matrix4.makeInvert(c.matrixWorld,b);var g=THREE.CollisionSystem.__r;g.origin.copy(a.origin);g.direction.copy(a.direction);b.multiplyVector3(g.origin);b.rotateAxis(g.direction);g.direction.normalize();return g};
+THREE.CollisionSystem.prototype.rayBox=function(a,c){var b;c.dynamic&&c.mesh&&c.mesh.matrixWorld?b=this.makeRayLocal(a,c.mesh):(b=THREE.CollisionSystem.__r,b.origin.copy(a.origin),b.direction.copy(a.direction));var g=0,f=0,h=0,e=0,j=0,k=0,l=!0;b.origin.x<c.min.x?(g=c.min.x-b.origin.x,g/=b.direction.x,l=!1,e=-1):b.origin.x>c.max.x&&(g=c.max.x-b.origin.x,g/=b.direction.x,l=!1,e=1);b.origin.y<c.min.y?(f=c.min.y-b.origin.y,f/=b.direction.y,l=!1,j=-1):b.origin.y>c.max.y&&(f=c.max.y-b.origin.y,f/=b.direction.y,
+l=!1,j=1);b.origin.z<c.min.z?(h=c.min.z-b.origin.z,h/=b.direction.z,l=!1,k=-1):b.origin.z>c.max.z&&(h=c.max.z-b.origin.z,h/=b.direction.z,l=!1,k=1);if(l)return-1;l=0;f>g&&(l=1,g=f);h>g&&(l=2,g=h);switch(l){case 0:j=b.origin.y+b.direction.y*g;if(j<c.min.y||j>c.max.y)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*g;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(e,0,0);break;case 1:e=b.origin.x+b.direction.x*g;if(e<c.min.x||e>c.max.x)return Number.MAX_VALUE;b=b.origin.z+b.direction.z*
+g;if(b<c.min.z||b>c.max.z)return Number.MAX_VALUE;c.normal.set(0,j,0);break;case 2:e=b.origin.x+b.direction.x*g;if(e<c.min.x||e>c.max.x)return Number.MAX_VALUE;j=b.origin.y+b.direction.y*g;if(j<c.min.y||j>c.max.y)return Number.MAX_VALUE;c.normal.set(0,0,k)}return g};THREE.CollisionSystem.prototype.rayPlane=function(a,c){var b=a.direction.dot(c.normal),g=c.point.dot(c.normal);if(b<0)b=(g-a.origin.dot(c.normal))/b;else return Number.MAX_VALUE;return b>0?b:Number.MAX_VALUE};
+THREE.CollisionSystem.prototype.raySphere=function(a,c){var b=c.center.clone().subSelf(a.origin);if(b.lengthSq<c.radiusSq)return-1;var g=b.dot(a.direction.clone());if(g<=0)return Number.MAX_VALUE;b=c.radiusSq-(b.lengthSq()-g*g);if(b>=0)return Math.abs(g)-Math.sqrt(b);return Number.MAX_VALUE};THREE.CollisionSystem.__v1=new THREE.Vector3;THREE.CollisionSystem.__v2=new THREE.Vector3;THREE.CollisionSystem.__v3=new THREE.Vector3;THREE.CollisionSystem.__nr=new THREE.Vector3;THREE.CollisionSystem.__m=new THREE.Matrix4;
+THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionUtils.MeshOBB=function(a){a.geometry.computeBoundingBox();var c=a.geometry.boundingBox,b=new THREE.Vector3(c.x[0],c.y[0],c.z[0]),c=new THREE.Vector3(c.x[1],c.y[1],c.z[1]),b=new THREE.BoxCollider(b,c);b.mesh=a;return b};THREE.CollisionUtils.MeshAABB=function(a){var c=THREE.CollisionUtils.MeshOBB(a);c.min.addSelf(a.position);c.max.addSelf(a.position);c.dynamic=!1;return c};
 THREE.CollisionUtils.MeshColliderWBox=function(a){return new THREE.MeshCollider(a,THREE.CollisionUtils.MeshOBB(a))};
-if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);var b=this,c=this.setSize,g=this.render,e=new THREE.Camera,h=new THREE.Camera,f=new THREE.Matrix4,j=new THREE.Matrix4,k,l,m;e.useTarget=h.useTarget=!1;e.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},o=new THREE.WebGLRenderTarget(512,512,a),n=new THREE.WebGLRenderTarget(512,512,a),t=new THREE.Camera(53,1,1,1E4);t.position.z=
-2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:o},mapRight:{type:"t",value:1,texture:n}},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 v=new THREE.Scene;v.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){c.call(b,a,e);o.width=a;o.height=e;n.width=a;n.height=e};this.render=function(a,c){c.update(null,!0);if(k!==c.aspect||l!==c.near||m!==c.fov){k=c.aspect;l=c.near;m=c.fov;var w=c.projectionMatrix.clone(),x=125/30*0.5,p=x*l/125,z=l*Math.tan(m*Math.PI/360),A;f.n14=x;j.n14=-x;x=-z*k+p;A=z*k+p;w.n11=2*l/(A-x);w.n13=(A+x)/(A-x);e.projectionMatrix=w.clone();x=-z*k-p;A=z*k-p;w.n11=2*l/(A-x);
-w.n13=(A+x)/(A-x);h.projectionMatrix=w.clone()}e.matrix=c.matrixWorld.clone().multiplySelf(j);e.update(null,!0);e.position.copy(c.position);e.near=l;e.far=c.far;g.call(b,a,e,o,!0);h.matrix=c.matrixWorld.clone().multiplySelf(f);h.update(null,!0);h.position.copy(c.position);h.near=l;h.far=c.far;g.call(b,a,h,n,!0);g.call(b,v,t)}};
-if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,g=this.render,e,h,f=new THREE.Camera,j=new THREE.Camera;b.separation=10;if(a&&a.separation!==void 0)b.separation=a.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(a,f){c.call(b,a,f);e=a/2;h=f};this.render=function(a,c){this.clear();f.fov=c.fov;f.aspect=0.5*c.aspect;f.near=c.near;f.far=c.far;
-f.updateProjectionMatrix();f.position.copy(c.position);f.target.position.copy(c.target.position);f.translateX(b.separation);j.projectionMatrix=f.projectionMatrix;j.position.copy(c.position);j.target.position.copy(c.target.position);j.translateX(-b.separation);this.setViewport(0,0,e,h);g.call(b,a,f);this.setViewport(e,0,e,h);g.call(b,a,j,!1)}};
+if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);var c=this,b=this.setSize,g=this.render,f=new THREE.Camera,h=new THREE.Camera,e=new THREE.Matrix4,j=new THREE.Matrix4,k,l,m;f.useTarget=h.useTarget=!1;f.matrixAutoUpdate=h.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},n=new THREE.WebGLRenderTarget(512,512,a),o=new THREE.WebGLRenderTarget(512,512,a),p=new THREE.Camera(53,1,1,1E4);p.position.z=
+2;_material=new THREE.MeshShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:n},mapRight:{type:"t",value:1,texture:o}},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 w=new THREE.Scene;w.addObject(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(a,e){b.call(c,a,e);n.width=a;n.height=e;o.width=a;o.height=e};this.render=function(a,b){b.update(null,!0);if(k!==b.aspect||l!==b.near||m!==b.fov){k=b.aspect;l=b.near;m=b.fov;var x=b.projectionMatrix.clone(),y=125/30*0.5,u=y*l/125,z=l*Math.tan(m*Math.PI/360),B;e.n14=y;j.n14=-y;y=-z*k+u;B=z*k+u;x.n11=2*l/(B-y);x.n13=(B+y)/(B-y);f.projectionMatrix=x.clone();y=-z*k-u;B=z*k-u;x.n11=2*l/(B-y);
+x.n13=(B+y)/(B-y);h.projectionMatrix=x.clone()}f.matrix=b.matrixWorld.clone().multiplySelf(j);f.update(null,!0);f.position.copy(b.position);f.near=l;f.far=b.far;g.call(c,a,f,n,!0);h.matrix=b.matrixWorld.clone().multiplySelf(e);h.update(null,!0);h.position.copy(b.position);h.near=l;h.far=b.far;g.call(c,a,h,o,!0);g.call(c,w,p)}};
+if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var c=this,b=this.setSize,g=this.render,f,h,e=new THREE.Camera,j=new THREE.Camera;c.separation=10;if(a&&a.separation!==void 0)c.separation=a.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(a,e){b.call(c,a,e);f=a/2;h=e};this.render=function(a,b){this.clear();e.fov=b.fov;e.aspect=0.5*b.aspect;e.near=b.near;e.far=b.far;
+e.updateProjectionMatrix();e.position.copy(b.position);e.target.position.copy(b.target.position);e.translateX(c.separation);j.projectionMatrix=e.projectionMatrix;j.position.copy(b.position);j.target.position.copy(b.target.position);j.translateX(-c.separation);this.setViewport(0,0,f,h);g.call(c,a,e);this.setViewport(f,0,f,h);g.call(c,a,j,!1)}};

+ 104 - 16
examples/canvas_geometry_shape.html → examples/webgl_geometry_shapes.html

@@ -62,21 +62,70 @@
 
 				scene = new THREE.Scene();
 
+				var light = new THREE.DirectionalLight( 0xffffff );
+				light.position.set( 0, 0, 1 );
+				light.position.normalize();
+				scene.addLight( light );
+
 				parent = new THREE.Object3D();
 				parent.position.y = 50;
 				scene.addChild( parent );
 
-				function addGeometry( geometry, color, x, y, z, rx, ry, rz, s ) {
+				function addGeometry( geometry, points, spacedPoints, color, x, y, z, rx, ry, rz, s ) {
+
+					// 3d shape
 
-					var mesh = new THREE.Mesh( geometry, [ new THREE.MeshBasicMaterial( { color: color } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true } ) ] );
-					mesh.position.set( x, y, z );
+					var mesh = new THREE.Mesh( geometry, [ new THREE.MeshLambertMaterial( { color: color } ), new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true } ) ] );
+					mesh.position.set( x, y, z - 75 );
 					mesh.rotation.set( rx, ry, rz );
 					mesh.scale.set( s, s, s );
 					parent.addChild( mesh );
 
+					// solid line
+
+					var line = new THREE.Line( points, new THREE.LineBasicMaterial( { color: color, linewidth: 2 } ) );
+					line.position.set( x, y, z + 25 );
+					line.rotation.set( rx, ry, rz );
+					line.scale.set( s, s, s );
+					parent.addChild( line );
+
+					// transparent line from real points
+
+					var line = new THREE.Line( points, new THREE.LineBasicMaterial( { color: color, opacity: 0.5 } ) );
+					line.position.set( x, y, z + 75 );
+					line.rotation.set( rx, ry, rz );
+					line.scale.set( s, s, s );
+					parent.addChild( line );
+
+					// vertices from real points
+
+					var pgeo = THREE.GeometryUtils.clone( points );
+					var particles = new THREE.ParticleSystem( pgeo, new THREE.ParticleBasicMaterial( { color: color, size: 2, opacity: 0.75 } ) );
+					particles.position.set( x, y, z + 75 );
+					particles.rotation.set( rx, ry, rz );
+					particles.scale.set( s, s, s );
+					parent.addChild( particles );
+
+					// transparent line from equidistance sampled points
+
+					var line = new THREE.Line( spacedPoints, new THREE.LineBasicMaterial( { color: color, opacity: 0.2 } ) );
+					line.position.set( x, y, z + 100 );
+					line.rotation.set( rx, ry, rz );
+					line.scale.set( s, s, s );
+					parent.addChild( line );
+
+					// equidistance sampled points
+
+					var pgeo = THREE.GeometryUtils.clone( spacedPoints );
+					var particles2 = new THREE.ParticleSystem( pgeo, new THREE.ParticleBasicMaterial( { color: color, size: 2, opacity: 0.5 } ) );
+					particles2.position.set( x, y, z + 100 );
+					particles2.rotation.set( rx, ry, rz );
+					particles2.scale.set( s, s, s );
+					parent.addChild( particles2 );
+
 				}
 
-				var extrudeSettings = {	amount: 20 };
+				var extrudeSettings = {	amount: 20,  bevelEnabled: true, bevelSegments: 2, steps: 2 }; // amount: 40, steps: 2
 
 				// California
 
@@ -106,7 +155,10 @@
 				californiaPts.push( new THREE.Vector2 ( 610, 320 ) );
 
 				var californiaShape = new THREE.Shape( californiaPts );
+
 				var california3d = new THREE.ExtrudeGeometry( californiaShape, { amount: 20	} );
+				var californiaPoints = californiaShape.createPointsGeometry();
+				var californiaSpacedPoints = californiaShape.createSpacedPointsGeometry( 100 );
 
 				// Triangle
 
@@ -117,6 +169,8 @@
 				triangleShape.lineTo(  80, 20 ); // close path
 
 				var triangle3d = triangleShape.extrude( extrudeSettings );
+				var trianglePoints = triangleShape.createPointsGeometry();
+				var triangleSpacedPoints = triangleShape.createSpacedPointsGeometry();
 
 
 				// Heart
@@ -134,6 +188,8 @@
 				heartShape.bezierCurveTo( x + 35, y, x + 25, y + 25, x + 25, y + 25 );
 
 				var heart3d = heartShape.extrude( extrudeSettings );
+				var heartPoints = heartShape.createPointsGeometry();
+				var heartSpacedPoints = heartShape.createSpacedPointsGeometry();
 
 				//heartShape.debug( document.getElementById("debug") );
 
@@ -149,6 +205,8 @@
 				squareShape.lineTo( 0, 0 );
 
 				var square3d = squareShape.extrude( extrudeSettings );
+				var squarePoints = squareShape.createPointsGeometry();
+				var squareSpacedPoints = squareShape.createSpacedPointsGeometry();
 
 				// Rectangle
 
@@ -162,6 +220,8 @@
 				rectShape.lineTo( 0, 0 );
 
 				var rect3d = rectShape.extrude( extrudeSettings );
+				var rectPoints = rectShape.createPointsGeometry();
+				var rectSpacedPoints = rectShape.createSpacedPointsGeometry();
 
 				// Rounded rectangle
 
@@ -169,6 +229,8 @@
 				roundedRect( roundedRectShape, 0, 0, 50, 50, 20 );
 
 				var roundedRect3d = roundedRectShape.extrude( extrudeSettings );
+				var roundedRectPoints = roundedRectShape.createPointsGeometry();
+				var roundedRectSpacedPoints = roundedRectShape.createSpacedPointsGeometry();
 
 				function roundedRect( ctx, x, y, width, height, radius ){
 
@@ -195,6 +257,8 @@
 				circleShape.quadraticCurveTo( -circleRadius, circleRadius, 0, circleRadius );
 
 				var circle3d = circleShape.extrude( extrudeSettings );
+				var circlePoints = circleShape.createPointsGeometry();
+				var circleSpacedPoints = circleShape.createSpacedPointsGeometry();
 
 				// Fish
 
@@ -210,8 +274,25 @@
 				fishShape.quadraticCurveTo( x + 50, y - 80, x, y );
 
 				var fish3d = fishShape.extrude( extrudeSettings );
+				var fishPoints = fishShape.createPointsGeometry();
+				var fishSpacedPoints = fishShape.createSpacedPointsGeometry();
+
+				// Arc circle
+
+				var arcShape = new THREE.Shape();
+				arcShape.moveTo( 0, 0 );
+				arcShape.arc( 10, 10, 40, 0, Math.PI*2, false );
 
-				// Spline shape + Path Extrusion
+				var holePath = new THREE.Path();
+				holePath.moveTo( 0, 0 );
+				holePath.arc( 10, 10, 10, 0, Math.PI*2, true );
+				arcShape.holes.push( holePath );
+
+				var arc3d = arcShape.extrude( extrudeSettings );
+				var arcPoints = arcShape.createPointsGeometry();
+				var arcSpacedPoints = arcShape.createSpacedPointsGeometry();
+
+				// Spline shape + path extrusion
 
 				var splinepts = [];
 				splinepts.push( new THREE.Vector2 ( 350, 100 ) );
@@ -227,24 +308,31 @@
 
 				var extrudePath = new THREE.Path();
 
+				extrudePath.moveTo( 0, 0 );
 				extrudePath.lineTo( 10, 10 );
 				extrudePath.quadraticCurveTo( 80, 60, 160, 10 );
 				extrudePath.quadraticCurveTo( 240, -40, 320, 10 );
 
 				extrudeSettings.path = extrudePath;
+				extrudeSettings.bevelEnabled = false;
 
 				var splineShape3d = splineShape.extrude( extrudeSettings );
-
-				addGeometry( california3d, 	0xffaa00, -300, -100, 0,     0, 0, 0, 0.25 );
-				addGeometry( triangle3d, 	0xffee00, -180,    0, 0,     0, 0, 0, 1 );
-				addGeometry( roundedRect3d, 0x005500, -150,  150, 0,     0, 0, 0, 1 );
-				addGeometry( square3d, 		0x0055ff,  150,  100, 0,     0, 0, 0, 1 );
-				addGeometry( heart3d, 		0xff1100,    0,  100, 0,   3.14, 0, 0, 1 );
-				addGeometry( circle3d, 		0x00ff11,  150,    0, 0,     0, 0, 0, 1 );
-				addGeometry( fish3d, 		0x222222,  -50,  200, 0,     0, 0, 0, 1 );
-				addGeometry( splineShape3d, 0x888888,  -50,  -100, -50,     0, 0, 0, 0.2 );
-
-				renderer = new THREE.CanvasRenderer();
+				var splinePoints = splineShape.createPointsGeometry( );
+				var splineSpacedPoints = splineShape.createSpacedPointsGeometry( );
+
+				addGeometry( california3d, californiaPoints, californiaSpacedPoints,	0xffaa00, -300, -100, 0,     0, 0, 0, 0.25 );
+				addGeometry( triangle3d, trianglePoints, triangleSpacedPoints, 			0xffee00, -180,    0, 0,     0, 0, 0, 1 );
+				addGeometry( roundedRect3d, roundedRectPoints, roundedRectSpacedPoints,	0x005500, -150,  150, 0,     0, 0, 0, 1 );
+				addGeometry( square3d, squarePoints, squareSpacedPoints,				0x0055ff,  150,  100, 0,     0, 0, 0, 1 );
+				addGeometry( heart3d, heartPoints, heartSpacedPoints,					0xff1100,    0,  100, 0,   3.14, 0, 0, 1 );
+				addGeometry( circle3d, circlePoints, circleSpacedPoints,				0x00ff11,  120,  250, 0,     0, 0, 0, 1 );
+				addGeometry( fish3d, fishPoints, fishSpacedPoints,						0x222222,  -50,  200, 0,     0, 0, 0, 1 );
+				addGeometry( splineShape3d, splinePoints, splineSpacedPoints,			0x888888,  -50,  -100, -50,  0, 0, 0, 0.2 );
+				addGeometry( arc3d, arcPoints, arcSpacedPoints,							0xbb4422,  150,    0, 0,     0, 0, 0, 1 );
+
+				//
+
+				renderer = new THREE.WebGLRenderer( { antialias: true } );
                 renderer.setSize( window.innerWidth, window.innerHeight );
 
 				container.appendChild( renderer.domElement );

+ 80 - 80
examples/webgl_geometry_text.html

@@ -26,14 +26,14 @@
 	<body>
 
 		<div id="info">
-		<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - procedural 3D text by <a href="http://www.lab4games.net/zz85/blog" target="_blank">zz85</a> &amp; alteredq 
+		<a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - procedural 3D text by <a href="http://www.lab4games.net/zz85/blog" target="_blank">zz85</a> &amp; alteredq
 		(fonts from <a href="http://typeface.neocracy.org/">typeface.js</a> and <a href="http://en.wikipedia.org/wiki/Droid_%28font%29">Droid</a>)
 		<br/>type to enter new text, drag to spin the text
-		<br/><span class="button" id="color">change color</span>, 
-			<span class="button" id="font">change font</span>, 
+		<br/><span class="button" id="color">change color</span>,
+			<span class="button" id="font">change font</span>,
 			<span class="button" id="weight">change weight</span>,
-			<span class="button" id="bezel">change bezel</span>,
-			<span class="button" id="postprocessing">change postprocessing</span>, 
+			<span class="button" id="bevel">change bevel</span>,
+			<span class="button" id="postprocessing">change postprocessing</span>,
 			<a id="permalink" href="#">permalink</a>
 		</div>
 
@@ -43,12 +43,12 @@
 		<script type="text/javascript" src="js/Detector.js"></script>
 		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
 		<script type="text/javascript" src="js/Stats.js"></script>
-			  
+
 		<!-- load the font file from canvas-text -->
 
 		<!--
-		
-		
+
+
 		-->
 		<script type="text/javascript" src="fonts/gentilis_bold.typeface.js"></script>
 		<script type="text/javascript" src="fonts/gentilis_regular.typeface.js"></script>
@@ -60,7 +60,7 @@
 		<script type="text/javascript" src="fonts/droid/droid_sans_bold.typeface.js"></script>
 		<script type="text/javascript" src="fonts/droid/droid_serif_regular.typeface.js"></script>
 		<script type="text/javascript" src="fonts/droid/droid_serif_bold.typeface.js"></script>
-		
+
 
 		<script type="text/javascript">
 
@@ -82,9 +82,9 @@
 
 				curveSegments = 6,
 
-				bezelThickness = 2,
-				bezelSize = 1.5,
-				bezelEnabled = true,
+				bevelThickness = 2,
+				bevelSize = 1.5,
+				bevelEnabled = true,
 
 				font = "optimer", 		// helvetiker, optimer, gentilis, droid sans, droid serif
 				weight = "bold",		// normal bold
@@ -134,9 +134,9 @@
 			}
 
 			function decimalToHex( d ) {
-  
+
 				var hex = Number( d ).toString( 16 );
-				hex = "000000".substr( 0, 6 - hex.length ) + hex; 
+				hex = "000000".substr( 0, 6 - hex.length ) + hex;
 				return hex.toUpperCase();
 
 			}
@@ -180,7 +180,7 @@
 					var fonthash   = hash.substring( 6, 7 );
 					var weighthash = hash.substring( 7, 8 );
 					var pphash 	   = hash.substring( 8, 9 );
-					var bezelhash  = hash.substring( 9, 10 );
+					var bevelhash  = hash.substring( 9, 10 );
 					var texthash   = hash.substring( 11 );
 
 					hex = colorhash;
@@ -190,7 +190,7 @@
 					weight = reverseWeightMap[ parseInt( weighthash ) ];
 
 					postprocessing.enabled = parseInt( pphash );
-					bezelEnabled = parseInt( bezelhash );
+					bevelEnabled = parseInt( bevelhash );
 
 					text = decodeURI( texthash );
 
@@ -206,7 +206,7 @@
 
 				textGeo = new THREE.TextGeometry( text, {
 
-					size: size, 
+					size: size,
 					height: height,
 					curveSegments: curveSegments,
 
@@ -214,16 +214,16 @@
 					weight: weight,
 					style: style,
 
-					bezelThickness: bezelThickness,
-					bezelSize: bezelSize,
-					bezelEnabled: bezelEnabled
+					bevelThickness: bevelThickness,
+					bevelSize: bevelSize,
+					bevelEnabled: bevelEnabled
 
 				});
-				
+
 				textMaterial = new THREE.MeshPhongMaterial( { color: 0xffffff, wireframe: false } );
 
 				parent = new THREE.Object3D();
-				
+
 				textMesh1 = new THREE.Mesh( textGeo, textMaterial );
 
 				textMesh1.position.x = 0;
@@ -247,7 +247,7 @@
 					textMesh2.rotation.y = Math.PI * 2;
 
 					parent.addChild( textMesh2 );
-					
+
 				}
 
 				parent.position.y = 100;
@@ -260,7 +260,7 @@
 
 				renderer = new THREE.WebGLRenderer( { antialias: false } );
 				renderer.setSize( window.innerWidth, window.innerHeight );
-				
+
 				renderer.setClearColor( scene.fog.color, 1 );
 
 				container.appendChild( renderer.domElement );
@@ -277,91 +277,91 @@
 				document.addEventListener( 'keydown', onDocumentKeyDown, false );
 
 				document.getElementById( "color" ).addEventListener( 'click', function() {
-				
+
 					pointLight.color.setHSV( Math.random(), 0.95, 0.85 );
 					pointLight.color.updateHex();
 					hex = decimalToHex( pointLight.color.hex );
-					
+
 					updatePermalink();
-					
+
 				}, false );
 
 				document.getElementById( "font" ).addEventListener( 'click', function() {
-				
+
 					if ( font == "helvetiker" ) {
 
 						font = "optimer";
 
 					} else if ( font == "optimer" ) {
-						
+
 						font = "gentilis";
-						
+
 					} else if ( font == "gentilis" ) {
-						
+
 						font = "droid sans";
-						
+
 					} else if ( font == "droid sans" ) {
-						
+
 						font = "droid serif";
 
 					} else {
-					
+
 						font = "helvetiker";
-						
+
 					}
-					
+
 					refreshText();
-					
+
 				}, false );
 
 				document.getElementById( "weight" ).addEventListener( 'click', function() {
-				
+
 					if ( weight == "bold" ) {
 
 						weight = "normal";
 
 					} else {
-					
+
 						weight = "bold";
-						
+
 					}
-					
+
 					refreshText();
-					
+
 				}, false );
 
-				document.getElementById( "bezel" ).addEventListener( 'click', function() {
-				
-					bezelEnabled = !bezelEnabled;
-					
+				document.getElementById( "bevel" ).addEventListener( 'click', function() {
+
+					bevelEnabled = !bevelEnabled;
+
 					refreshText();
-					
+
 				}, false );
 
 				document.getElementById( "postprocessing" ).addEventListener( 'click', function() {
-				
+
 					postprocessing.enabled = !postprocessing.enabled;
 					updatePermalink();
-					
+
 				}, false );
 
 				initPostprocessing();
 				renderer.autoClear = false;
 
 			}
-			
+
 			//
-			
+
 			function boolToNum( b ) {
-				
+
 				return b ? 1 : 0;
 
 			}
-			
+
 			function updatePermalink() {
-			
-				var link = hex + fontMap[ font ] + weightMap[ weight ] + boolToNum( postprocessing.enabled ) + boolToNum( bezelEnabled ) + "#" + encodeURI( text );
-				
+
+				var link = hex + fontMap[ font ] + weightMap[ weight ] + boolToNum( postprocessing.enabled ) + boolToNum( bevelEnabled ) + "#" + encodeURI( text );
+
 				permalink.href = "#" + link;
 				window.location.hash = link;
 
@@ -370,14 +370,14 @@
 			function onDocumentKeyDown( event ) {
 
 				if ( firstLetter ) {
-				
+
 					firstLetter = false;
 					text = "";
 
 				}
-				
+
 				var keyCode = event.keyCode;
-				
+
 				// backspace
 
 				if ( keyCode == 8 ) {
@@ -388,23 +388,23 @@
 					refreshText();
 
 					return false;
-					
+
 				}
 
 			}
-			
+
 			function onDocumentKeyPress( event ) {
-				
+
 				var keyCode = event.which;
-				
+
 				// backspace
 
 				if ( keyCode == 8 ) {
-					
+
 					event.preventDefault();
-					
+
 				} else {
-				
+
 					var ch = String.fromCharCode( keyCode );
 					text += ch;
 
@@ -413,16 +413,16 @@
 				}
 
 			}
-			
+
 			function refreshText() {
 
 				updatePermalink();
-				
+
 				scene.removeChild( textMesh1 );
 
 				textGeo = new THREE.TextGeometry( text, {
 
-					size: size, 
+					size: size,
 					height: height,
 					curveSegments: curveSegments,
 
@@ -430,9 +430,9 @@
 					weight: weight,
 					style: style,
 
-					bezelThickness: bezelThickness,
-					bezelSize: bezelSize,
-					bezelEnabled: bezelEnabled
+					bevelThickness: bevelThickness,
+					bevelSize: bevelSize,
+					bevelEnabled: bevelEnabled
 
 				});
 
@@ -459,14 +459,14 @@
 
 					textMesh2.rotation.x = Math.PI;
 					textMesh2.rotation.y = Math.PI * 2;
-					
-					
+
+
 					parent.addChild( textMesh2 );
-					
+
 				}
 
 			}
-			
+
 			function onDocumentMouseDown( event ) {
 
 				event.preventDefault();
@@ -531,7 +531,7 @@
 			}
 
 			//
-			
+
 			function initPostprocessing() {
 
 				postprocessing.scene = new THREE.Scene();
@@ -621,9 +621,9 @@
 				time = new Date().getTime();
 				delta = 0.1 * ( time - oldTime );
 				oldTime = time;
-				
+
 				parent.rotation.y += ( targetRotation - parent.rotation.y ) * 0.05;
-				
+
 				if ( postprocessing.enabled ) {
 
 					renderer.clear();
@@ -669,7 +669,7 @@
 					renderer.clear();
 					renderer.render( scene, camera );
 
-				}				
+				}
 
 			}
 

+ 8 - 0
src/core/Matrix4.js

@@ -518,7 +518,9 @@ THREE.Matrix4.prototype = {
 		e = Math.cos( z ), f = Math.sin( z );
 
 		switch ( order ) {
+
 			case 'YXZ':
+
 				var ce = c * e, cf = c * f, de = d * e, df = d * f;
 
 				this.n11 = ce + df * b;
@@ -535,6 +537,7 @@ THREE.Matrix4.prototype = {
 				break;
 
 			case 'ZXY':
+
 				var ce = c * e, cf = c * f, de = d * e, df = d * f;
 
 				this.n11 = ce - df * b;
@@ -551,6 +554,7 @@ THREE.Matrix4.prototype = {
 				break;
 
 			case 'ZYX':
+
 				var ae = a * e, af = a * f, be = b * e, bf = b * f;
 
 				this.n11 = c * e;
@@ -567,6 +571,7 @@ THREE.Matrix4.prototype = {
 				break;
 
 			case 'YZX':
+
 				var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
 
 				this.n11 = c * e;
@@ -583,6 +588,7 @@ THREE.Matrix4.prototype = {
 				break;
 
 			case 'XZY':
+
 				var ac = a * c, ad = a * d, bc = b * c, bd = b * d;
 
 				this.n11 = c * e;
@@ -599,6 +605,7 @@ THREE.Matrix4.prototype = {
 				break;
 
 			default: // 'XYZ'
+
 				var ae = a * e, af = a * f, be = b * e, bf = b * f;
 
 				this.n11 = c * e;
@@ -613,6 +620,7 @@ THREE.Matrix4.prototype = {
 				this.n32 = be + af * d;
 				this.n33 = a * c;
 				break;
+
 		}
 
 		return this;

+ 92 - 0
src/extras/GeometryUtils.js

@@ -1,5 +1,6 @@
 /**
  * @author mrdoob / http://mrdoob.com/
+ * @author alteredq / http://alteredqualia.com/
  */
 
 THREE.GeometryUtils = {
@@ -19,6 +20,8 @@ THREE.GeometryUtils = {
 
 		isMesh && object2.matrixAutoUpdate && object2.updateMatrix();
 
+		// vertices
+
 		for ( var i = 0, il = vertices2.length; i < il; i ++ ) {
 
 			var vertex = vertices2[ i ];
@@ -31,6 +34,8 @@ THREE.GeometryUtils = {
 
 		}
 
+		// faces
+
 		for ( i = 0, il = faces2.length; i < il; i ++ ) {
 
 			var face = faces2[ i ], faceCopy, normal, color,
@@ -73,6 +78,8 @@ THREE.GeometryUtils = {
 
 		}
 
+		// uvs
+
 		for ( i = 0, il = uvs2.length; i < il; i ++ ) {
 
 			var uv = uvs2[ i ], uvCopy = [];
@@ -87,6 +94,91 @@ THREE.GeometryUtils = {
 
 		}
 
+	},
+
+	clone: function ( geometry ) {
+
+		var cloneGeo = new THREE.Geometry();
+
+		var i, il;
+
+		var vertices = geometry.vertices,
+			faces = geometry.faces,
+			uvs = geometry.faceVertexUvs[ 0 ];
+
+		// vertices
+
+		for ( i = 0, il = vertices.length; i < il; i ++ ) {
+
+			var vertex = vertices[ i ];
+			var vertexCopy = new THREE.Vertex( vertex.position.clone() );
+
+			cloneGeo.vertices.push( vertexCopy );
+
+		}
+
+		// faces
+
+		for ( i = 0, il = faces.length; i < il; i ++ ) {
+
+			var face = faces[ i ], faceCopy, normal, color,
+			faceVertexNormals = face.vertexNormals,
+			faceVertexColors = face.vertexColors;
+
+			if ( face instanceof THREE.Face3 ) {
+
+				faceCopy = new THREE.Face3( face.a, face.b, face.c );
+
+			} else if ( face instanceof THREE.Face4 ) {
+
+				faceCopy = new THREE.Face4( face.a, face.b, face.c, face.d );
+
+			}
+
+			faceCopy.normal.copy( face.normal );
+
+			for ( var j = 0, jl = faceVertexNormals.length; j < jl; j ++ ) {
+
+				normal = faceVertexNormals[ j ];
+				faceCopy.vertexNormals.push( normal.clone() );
+
+			}
+
+			faceCopy.color.copy( face.color );
+
+			for ( var j = 0, jl = faceVertexColors.length; j < jl; j ++ ) {
+
+				color = faceVertexColors[ j ];
+				faceCopy.vertexColors.push( color.clone() );
+
+			}
+
+			faceCopy.materials = face.materials.slice();
+
+			faceCopy.centroid.copy( face.centroid );
+
+			cloneGeo.faces.push( faceCopy );
+
+		}
+
+		// uvs
+
+		for ( i = 0, il = uvs.length; i < il; i ++ ) {
+
+			var uv = uvs[ i ], uvCopy = [];
+
+			for ( var j = 0, jl = uv.length; j < jl; j ++ ) {
+
+				uvCopy.push( new THREE.UV( uv[ j ].u, uv[ j ].v ) );
+
+			}
+
+			cloneGeo.faceVertexUvs[ 0 ].push( uvCopy );
+
+		}
+
+		return cloneGeo;
+
 	}
 
 };

+ 406 - 0
src/extras/geometries/Curve.js

@@ -0,0 +1,406 @@
+/**
+ * @author zz85 / http://www.lab4games.net/zz85/blog
+ * Extensible curve object
+ *
+ * This file contains following classes:
+ *
+ * THREE.Curve
+ * THREE.LineCurve
+ * THREE.QuadraticBezierCurve
+ * THREE.CubicBezierCurve
+ * THREE.SplineCurve
+ * THREE.ArcCurve
+ *
+ **/
+
+/**************************************************************
+ *	Abstract Curve base class
+ **************************************************************/
+
+THREE.Curve = function () {
+
+};
+
+// Virtual base class method to overwrite and implement in subclasses
+//	- t [0 .. 1]
+
+THREE.Curve.prototype.getPoint = function ( t ) {
+
+	console.log( "Warning, getPoint() not implemented!" );
+	return null;
+
+};
+
+// Get point at relative position in curve according to arc length
+// - u [0 .. 1]
+
+THREE.Curve.prototype.getPointAt = function ( u ) {
+
+	var t = this.getUtoTmapping( u );
+	return this.getPoint( t );
+
+};
+
+// Get sequence of points using getPoint( t )
+
+THREE.Curve.prototype.getPoints = function ( divisions ) {
+
+	if ( !divisions ) divisions = 5;
+
+	var d, pts = [];
+
+	for ( d = 0; d <= divisions; d ++ ) {
+
+		pts.push( this.getPoint( d / divisions ) );
+
+	};
+
+	return pts;
+
+};
+
+// Get sequence of points using getPointAt( u )
+
+THREE.Curve.prototype.getSpacedPoints = function ( divisions ) {
+
+	if ( !divisions ) divisions = 5;
+
+	var d, pts = [];
+
+	for ( d = 0; d <= divisions; d ++ ) {
+
+		pts.push( this.getPointAt( d / divisions ) );
+
+	};
+
+	return pts;
+
+};
+
+// Get total curve length
+
+THREE.Curve.prototype.getLength = function () {
+
+	var lengths = this.getLengths();
+	return lengths[ lengths.length - 1 ];
+
+};
+
+// Get list of cumulative segment lengths
+
+THREE.Curve.prototype.getLengths = function ( divisions ) {
+
+	if ( !divisions ) divisions = 200;
+
+	if ( this.cacheLengths && ( this.cacheLengths.length == divisions ) ) {
+
+		//console.log( "cached", this.cacheLengths );
+		return this.cacheLengths;
+
+	}
+
+	var cache = [];
+	var current, last = this.getPoint( 0 );
+	var p, sum = 0;
+
+	for ( p = 1; p <= divisions; p++ ) {
+
+		current = this.getPoint ( p / divisions );
+		sum += current.distanceTo( last );
+		cache.push( sum );
+		last = current;
+
+	}
+
+	this.cacheLengths = cache;
+	return cache; // { sums: cache, sum:sum }; Sum is in the last element.
+
+};
+
+// Given u ( 0 .. 1 ), get a t to find p. This gives you points which are equi distance
+
+THREE.Curve.prototype.getUtoTmapping = function ( u, distance ) {
+
+	var lengths = this.getLengths();
+	var i = 0, il = lengths.length;
+
+	var distanceForU;
+
+	if ( distance ) {
+
+		distanceForU = distance;
+
+	} else {
+
+		distanceForU = u * lengths[ il - 1 ];
+
+	}
+
+	// TODO Should do binary search + sub division + interpolation when needed
+
+	while ( i < il ) {
+
+		if ( lengths[ i ] > distanceForU ) break;
+
+		i++;
+
+	}
+
+	var t = i / il;
+	return t;
+
+};
+
+
+/**************************************************************
+ *	Line
+ **************************************************************/
+
+THREE.LineCurve = function ( x1, y1, x2, y2 ) {
+
+	this.x1 = x1;
+	this.y1 = y1;
+
+	this.x2 = x2;
+	this.y2 = y2;
+
+};
+
+THREE.LineCurve.prototype = new THREE.Curve();
+THREE.LineCurve.prototype.constructor = THREE.LineCurve;
+
+THREE.LineCurve.prototype.getPoint = function ( t ) {
+
+	var dx = this.x2 - this.x1;
+	var dy = this.y2 - this.y1;
+
+	var tx = this.x1 + dx * t;
+	var ty = this.y1 + dy * t;
+
+	return new THREE.Vector2( tx, ty );
+
+};
+
+/**************************************************************
+ *	Quadratic Bezier curve
+ **************************************************************/
+
+THREE.QuadraticBezierCurve = function ( x0, y0, x1, y1, x2, y2 ) {
+
+	this.x0 = x0;
+	this.y0 = y0;
+
+	this.x1 = x1;
+	this.y1 = y1;
+
+	this.x2 = x2;
+	this.y2 = y2;
+
+};
+
+THREE.QuadraticBezierCurve.prototype = new THREE.Curve();
+THREE.QuadraticBezierCurve.prototype.constructor = THREE.QuadraticBezierCurve;
+
+
+THREE.QuadraticBezierCurve.prototype.getPoint = function ( t ) {
+
+	var tx, ty;
+
+	tx = THREE.FontUtils.b2( t, this.x0, this.x1, this.x2 );
+	ty = THREE.FontUtils.b2( t, this.y0, this.y1, this.y2 );
+
+	return new THREE.Vector2( tx, ty );
+
+};
+
+
+THREE.QuadraticBezierCurve.prototype.getNormalVector = function( t ) {
+
+	// iterate sub segments
+	// 	get lengths for sub segments
+	// 	if segment is bezier
+	//		perform subdivisions or perform integrals
+
+	var x0, y0, x1, y1, x2, y2;
+
+	x0 = this.actions[ 0 ].args[ 0 ];
+	y0 = this.actions[ 0 ].args[ 1 ];
+
+	x1 = this.actions[ 1 ].args[ 0 ];
+	y1 = this.actions[ 1 ].args[ 1 ];
+
+	x2 = this.actions[ 1 ].args[ 2 ];
+	y2 = this.actions[ 1 ].args[ 3 ];
+
+	var tx, ty;
+
+	tx = THREE.Curve.Utils.tangentQuadraticBezier( t, this.x0, this.x1, this.x2 );
+	ty = THREE.Curve.Utils.tangentQuadraticBezier( t, this.y0, this.y1, this.y2 );
+
+	// return normal unit vector
+	return new THREE.Vector2( -ty , tx ).unit();
+
+};
+
+
+/**************************************************************
+ *	Cubic Bezier curve
+ **************************************************************/
+
+THREE.CubicBezierCurve = function ( x0, y0, x1, y1, x2, y2, x3, y3 ) {
+
+	this.x0 = x0;
+	this.y0 = y0;
+
+	this.x1 = x1;
+	this.y1 = y1;
+
+	this.x2 = x2;
+	this.y2 = y2;
+
+	this.x3 = x3;
+	this.y3 = y3;
+
+};
+
+THREE.CubicBezierCurve.prototype = new THREE.Curve();
+THREE.CubicBezierCurve.prototype.constructor = THREE.CubicBezierCurve;
+
+THREE.CubicBezierCurve.prototype.getPoint = function ( t ) {
+
+	var tx, ty;
+
+	tx = THREE.FontUtils.b3( t, this.x0, this.x1, this.x2, this.x3 );
+	ty = THREE.FontUtils.b3( t, this.y0, this.y1, this.y2, this.y3 );
+
+	return new THREE.Vector2( tx, ty );
+
+};
+
+/**************************************************************
+ *	Spline curve
+ **************************************************************/
+
+THREE.SplineCurve = function ( points ) {
+
+	this.points = points;
+
+};
+
+THREE.SplineCurve.prototype = new THREE.Curve();
+THREE.SplineCurve.prototype.constructor = THREE.SplineCurve;
+
+THREE.SplineCurve.prototype.getPoint = function ( t ) {
+
+	var v = new THREE.Vector2();
+	var c = [];
+	var points = this.points, point, intPoint, weight;
+	point = ( points.length - 1 ) * t;
+
+	intPoint = Math.floor( point );
+	weight = point - intPoint;
+
+	c[ 0 ] = intPoint == 0 ? intPoint : intPoint - 1;
+	c[ 1 ] = intPoint;
+	c[ 2 ] = intPoint > points.length - 2 ? intPoint : intPoint + 1;
+	c[ 3 ] = intPoint > points.length - 3 ? intPoint : intPoint + 2;
+
+	v.x = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].x, points[ c[ 1 ] ].x, points[ c[ 2 ] ].x, points[ c[ 3 ] ].x, weight );
+	v.y = THREE.Curve.Utils.interpolate( points[ c[ 0 ] ].y, points[ c[ 1 ] ].y, points[ c[ 2 ] ].y, points[ c[ 3 ] ].y, weight );
+
+	return v;
+
+};
+
+/**************************************************************
+ *	Arc curve
+ **************************************************************/
+
+THREE.ArcCurve = function ( aX, aY, aRadius,
+							aStartAngle, aEndAngle,
+							aClockwise ) {
+
+	this.aX = aX;
+	this.aY = aY;
+
+	this.aRadius = aRadius;
+
+	this.aStartAngle = aStartAngle;
+	this.aEndAngle = aEndAngle;
+
+	this.aClockwise = aClockwise;
+
+};
+
+THREE.ArcCurve.prototype = new THREE.Curve();
+THREE.ArcCurve.prototype.constructor = THREE.ArcCurve;
+
+THREE.ArcCurve.prototype.getPoint = function ( t ) {
+
+	var deltaAngle = this.aEndAngle - this.aStartAngle;
+
+	if ( !this.aClockwise ) {
+
+		t = 1 - t;
+
+	}
+
+	var angle = this.aStartAngle + t * deltaAngle;
+
+	var tx = this.aX + this.aRadius * Math.cos( angle );
+	var ty = this.aY + this.aRadius * Math.sin( angle );
+
+	return new THREE.Vector2( tx, ty );
+
+};
+
+/**************************************************************
+ *	Utils
+ **************************************************************/
+
+THREE.Curve.Utils = {
+
+	tangentQuadraticBezier: function ( t, p0, p1, p2 ) {
+
+		return 2 * ( 1 - t ) * ( p1 - p0 ) + 2 * t * ( p2 - p1 );
+
+	},
+
+	tangentSpline: function ( t, p0, p1, p2, p3 ) {
+
+		// To check if my formulas are correct
+
+		var h00 = 6 * t * t - 6 * t; 	// derived from 2t^3 − 3t^2 + 1
+		var h10 = 3 * t * t - 4 * t + 1; // t^3 − 2t^2 + t
+		var h01 = -6 * t * t + 6 * t; 	// − 2t3 + 3t2
+		var h11 = 3 * t * t - 2 * t;	// t3 − t2
+
+	},
+
+	// Catmull-Rom
+
+	interpolate: function( p0, p1, p2, p3, t ) {
+
+		var v0 = ( p2 - p0 ) * 0.5;
+		var v1 = ( p3 - p1 ) * 0.5;
+		var t2 = t * t;
+		var t3 = t * t2;
+		return ( 2 * p1 - 2 * p2 + v0 + v1 ) * t3 + ( - 3 * p1 + 3 * p2 - 2 * v0 - v1 ) * t2 + v0 * t + p1;
+
+	}
+
+};
+
+
+
+
+/*
+getPoint DONE
+getLength DONE
+getLengths DONE
+
+curve.getPoints(); DONE
+curve.getPointAtArcLength(t); DONE
+curve.transform(params);
+curve.getTangentAt(t)
+*/

+ 276 - 98
src/extras/geometries/ExtrudeGeometry.js

@@ -1,21 +1,27 @@
 /**
  * @author zz85 / http://www.lab4games.net/zz85/blog
- * Creates extruded geometry form path.
+ * Creates extruded geometry from a path shape.
  **/
 
-THREE.ExtrudeGeometry = function( shape, options ) {
+THREE.ExtrudeGeometry = function ( shape, options ) {
 
 	var amount = options.amount !== undefined ? options.amount : 100;
 
-	// todo: bezel
+	// todo: bevel
+
+	var bevelThickness = options.bevelThickness !== undefined ? options.bevelThickness : 8; // 10
+	var bevelSize = options.bevelSize !== undefined ? options.bevelSize : bevelThickness; // 8
+	var bevelEnabled = options.bevelEnabled !== undefined ? options.bevelEnabled : true; // false
+	var bevelSegments = options.bevelSegments !== undefined ? options.bevelSegments : 3;
+
+	// We should set bevel segments to 0 if bevel is not enabled.
+
+	if ( !bevelEnabled ) bevelSegments = 0;
 
-	var bezelThickness = options.bezelThickness !== undefined ? options.bezelThickness : 10;
-	var bezelSize = options.bezelSize !== undefined ? options.bezelSize : 8;
-	var bezelEnabled = options.bezelEnabled !== undefined ? options.bezelEnabled : false;
 
 	var steps = options.steps !== undefined ? options.steps : 1;
-	var extrudePath = options.path !== undefined ? options.path : null;
 
+	var extrudePath = options.path !== undefined ? options.path : null;
 	var extrudePts, extrudeByPath = false;
 
 	if ( extrudePath ) {
@@ -26,41 +32,184 @@ THREE.ExtrudeGeometry = function( shape, options ) {
 
 	}
 
+
 	// TODO, extrude by path's tangents? also via 3d path?
 
 	THREE.Geometry.call( this );
 
-    var vertices = shape.getPoints();
-    var faces = shape.triangulate();
-    var contour = vertices;
+	// Variables initalization
+
+	var ahole, h, hl; // looping of holes
+	var scope = this;
+	var bevelPoints = [];
+
+	var shapePoints = shape.extractAllPoints(); // use shape.extractAllSpacedPoints() for points with equal divisions
+
+    var vertices = shapePoints.shape;
+	var holes = shapePoints.holes;
+
+	var reverse = !THREE.Shape.Utils.isClockWise( vertices ) ;
+
+	if ( reverse ) {
+
+		vertices = vertices.reverse();
+
+		// Maybe we should also check if holes are in the opposite direction, just to be safe ...
+
+		for ( h = 0, hl = holes.length;  h < hl; h ++ ) {
+
+			ahole = holes[ h ];
+
+			if ( THREE.Shape.Utils.isClockWise( ahole ) ) {
+
+				holes[ h ] = ahole.reverse();
+
+			}
+
+		}
+
+		reverse = false; // If vertices are in order now, we shouldn't need to worry about them again (hopefully)!
+
+	}
+
+
+	var faces = THREE.Shape.Utils.triangulateShape ( vertices, holes );
+	//var faces = THREE.Shape.Utils.triangulate2( vertices, holes );
+
+	//console.log(faces);
+
+	////
+	///   Handle Vertices
+	////
+
+	var contour = vertices; // vertices has all points but contour has only points of circumference
+
+	for ( h = 0, hl = holes.length;  h < hl; h ++ ) {
+
+		ahole = holes[ h ];
+
+		vertices = vertices.concat( ahole );
+
+	}
+
+	// Find all centroids of shapes and holes
+
+	var i, il;
+	var sum = new THREE.Vector2();
 
-    var scope = this;
+	for ( i = 0, il = contour.length; i < il; i ++ ) {
 
-	var bezelPoints = [];
+		sum.addSelf( contour[ i ] );
 
-	var reverse = THREE.FontUtils.Triangulate.area( vertices ) > 0 ;
+	}
+
+	var contourCentroid = sum.divideScalar( contour.length );
+
+	var holesCentroids = [];
+
+	for ( h = 0, hl = holes.length; h < hl; h ++ ) {
+
+		sum = new THREE.Vector2();
+		ahole = holes[ h ];
+
+		for ( i=0, il = ahole.length; i < il; i ++ ) {
+
+			sum.addSelf( ahole[ i ] );
+
+		}
+
+		holesCentroids[ h ] = sum.divideScalar( ahole.length );
+
+	}
+
+	function scalePt ( pt, centroid, size, expandOutwards /* Boolean */ ) {
+
+		var vectorFromCentroid = pt.clone().subSelf( centroid );
+		var adj = size / vectorFromCentroid.length();
+
+		if ( expandOutwards ) {
+
+			adj = 1 + adj;
+
+		}  else {
+
+			adj = 1 - adj;
+
+		}
+
+		return vectorFromCentroid.multiplyScalar( adj ).addSelf( centroid );
+
+	}
 
-	//console.log(reverse);
 
-	var i,
+	var b, bs, t, z,
 		vert, vlen = vertices.length,
 		face, flen = faces.length,
-		bezelPt, blen = bezelPoints.length;
+		cont, clen = contour.length;
+
+	// Loop bevelSegments, 1 for the front, 1 for the back
+
+	for ( b = bevelSegments; b > 0; b -- ) {
+
+		t = b / bevelSegments;
+		z = bevelThickness * t;
+
+		// Formula could probably be simplified
+
+		bs = bevelSize * ( 1 - Math.sin ( ( 1 - t ) * Math.PI/2 ) ) ; // bevelSize * t ;
+
+		// contract shape
+
+		for ( i = 0, il = contour.length; i < il; i ++ ) {
+
+			vert = scalePt( contour[ i ], contourCentroid, bs, false );
+			v( vert.x, vert.y, -z );
+
+		}
+
+		// expand holes
+
+		for ( h = 0, hl = holes.length; h < hl; h++ ) {
+
+			ahole = holes[ h ];
+
+			for ( i = 0, il = ahole.length; i < il; i++ ) {
+
+				vert = scalePt( ahole[ i ], holesCentroids[ h ], bs, true );
+				v( vert.x, vert.y,  -z );
+
+			}
+
+		}
+
+	}
+
 
 	// Back facing vertices
 
-	for ( i = 0; i < vlen; i++ ) {
+	for ( i = 0; i < vlen; i ++ ) {
 
 		vert = vertices[ i ];
-		v( vert.x, vert.y, 0 );
+		//v( vert.x, vert.y, 0 );
+
+		if ( !extrudeByPath ) {
+
+			v( vert.x, vert.y, 0 );
+
+		} else {
+
+			v( vert.x, vert.y + extrudePts[ 0 ].y, extrudePts[ 0 ].x );
+
+		}
 
 	}
 
-	// Add steped vertices...
+	// Add stepped vertices...
 	// Including front facing vertices
 
-	var s = 1;
-	for ( ; s <= steps; s++ ) {
+	var s;
+
+	for ( s = 1; s <= steps; s ++ ) {
 
 		for ( i = 0; i < vlen; i ++ ) {
 
@@ -68,7 +217,7 @@ THREE.ExtrudeGeometry = function( shape, options ) {
 
 			if ( !extrudeByPath ) {
 
-				v( vert.x, vert.y, amount/steps * s );
+				v( vert.x, vert.y, amount / steps * s );
 
 			} else {
 
@@ -80,119 +229,155 @@ THREE.ExtrudeGeometry = function( shape, options ) {
 
 	}
 
-	/*
-	// Front facing vertices
-
-	for ( i = 0; i < vlen; i++ ) {
 
-		vert = vertices[ i ];
-		v( vert.x, vert.y, amount );
+	// Add bevel segments planes
 
-	}
-	*/
+	for ( b = 1; b <= bevelSegments; b ++ ) {
 
+		t = b / bevelSegments;
+		z = bevelThickness * t;
+		bs = bevelSize * ( 1-Math.sin ( ( 1 - t ) * Math.PI/2 ) );
 
-	if ( bezelEnabled ) {
+		// contract shape
 
-		for ( i = 0; i < blen; i++ ) {
+		for ( i = 0, il = contour.length; i < il; i++ ) {
 
-			bezelPt = bezelPoints[ i ];
-			v( bezelPt.x, bezelPt.y, bezelThickness );
+			vert = scalePt( contour[ i ], contourCentroid, bs, false );
+			v( vert.x, vert.y,  amount + z);
 
 		}
 
-		for ( i = 0; i < blen; i++ ) {
+		// expand holes
+
+		for ( h = 0, hl = holes.length; h < hl; h++ ) {
+
+			ahole = holes[ h ];
+
+			for ( i = 0, il = ahole.length; i < il; i++ ) {
+
+				vert = scalePt( ahole[ i ], holesCentroids[h], bs, true );
+
+				if ( !extrudeByPath ) {
+
+					v( vert.x, vert.y,  amount + z );
+
+				} else {
 
-			bezelPt = bezelPoints[ i ];
-			v( bezelPt.x, bezelPt.y, amount - bezelThickness );
+					v( vert.x, vert.y + extrudePts[ steps - 1 ].y, extrudePts[ steps - 1 ].x +z );
+
+				}
+
+			}
 
 		}
 
 	}
 
-	// Bottom faces
 
-	for ( i = 0; i < flen; i++ ) {
+	////
+	///   Handle Faces
+	////
 
-		face = faces[ i ];
-		f3( face[ 2 ], face[ 1 ], face[ 0 ] );
+	// not used anywhere
+	// var layers = ( steps + bevelSegments * 2 ) * vlen;
 
-	}
+	// Bottom faces
 
-	// Top faces
+	if ( bevelEnabled ) {
 
-	for ( i = 0; i < flen; i++ ) {
+		var layer = 0 ; // steps + 1
+		var offset = vlen * layer;
 
-		face = faces[ i ];
-		f3( face[ 0 ] + vlen* steps, face[ 1 ] + vlen * steps, face[ 2 ] + vlen * steps );
+		for ( i = 0; i < flen; i ++ ) {
 
-	}
+			face = faces[ i ];
+			f3( face[ 2 ]+ offset, face[ 1 ]+ offset, face[ 0 ] + offset );
 
-	var lastV;
-	var j, k, l, m;
+		}
 
-	// Sides faces
+		layer = steps + bevelSegments * 2;
+		offset = vlen * layer;
 
-	//contour.push( contour[ 0 ] ); // in order not to check for boundary indices every time
+		// Top faces
 
-	i = contour.length;
+		for ( i = 0; i < flen; i ++ ) {
 
-	while ( --i >= 0 ) {
+			face = faces[ i ];
+			f3( face[ 0 ] + offset, face[ 1 ] + offset, face[ 2 ] + offset );
 
-		lastV = contour[ i ];
+		}
 
-		// TO OPTIMISE. Reduce this step of checking vertices.
+	} else {
 
-		/*
-		for ( j = 0; j < vlen; j++ ) {
+		for ( i = 0; i < flen; i++ ) {
 
-			if ( vertices[ j ].equals( contour[ i ] ) ) break;
+			face = faces[ i ];
+			f3( face[ 2 ], face[ 1 ], face[ 0 ] );
 
 		}
 
-		for ( k = 0; k < vlen; k++ ) {
+		// Top faces
+
+		for ( i = 0; i < flen; i ++ ) {
 
-			if ( vertices[ k ].equals( contour[ i - 1 ] ) ) break;
+			face = faces[ i ];
+			f3( face[ 0 ] + vlen * steps, face[ 1 ] + vlen * steps, face[ 2 ] + vlen * steps );
 
 		}
-		*/
 
-		//TOREMOVE
-		//console.log('a', i,j, i-1, k);
+	}
 
-		j = i;
-		//if (j==vertices.length) j = 0;
+	var tmpPt;
+	var j, k, l, m;
 
-		k = i - 1;
+	var layeroffset = 0;
 
-		if ( k < 0 ) k = vertices.length - 1;
+	// Sides faces
 
-		//console.log('b', i,j, i-1, k,vertices.length);
+	sidewalls( contour );
+	layeroffset += contour.length;
 
-		// Create faces for the z-sides of the text
+	for ( h = 0, hl = holes.length;  h < hl; h ++ ) {
 
-		//f4( j, k, k + vlen, j + vlen );
+		ahole = holes[ h ];
+		sidewalls( ahole );
 
-		// Reverse
-		//f4( k, j, j + vlen, k + vlen);
+		//, true
+		layeroffset += ahole.length;
 
-		//
+	}
 
-		var s = 0;
+	// Create faces for the z-sides of the shape
 
-		for ( ; s < steps; s++ ) {
+	function sidewalls( contour ) {
 
-			var slen1 = vlen * s;
-			var slen2 = vlen * ( s + 1 );
+		i = contour.length;
 
-			f4( j + slen1, k + slen1, k + slen2, j + slen2 );
+		while ( --i >= 0 ) {
 
-		}
+			tmpPt = contour[ i ];
 
-		//
+			j = i;
+			k = i - 1;
 
-	}
+			if ( k < 0 ) k = contour.length - 1;
+
+			//console.log('b', i,j, i-1, k,vertices.length);
+
+			var s = 0;
+
+			for ( s = 0; s < ( steps  + bevelSegments * 2 ); s ++ ) {
+
+				var slen1 = vlen * s;
+				var slen2 = vlen * ( s + 1 );
+
+				f4( layeroffset + j + slen1, layeroffset + k + slen1, layeroffset + k + slen2, layeroffset + j + slen2 );
+
+			}
 
+		}
+
+	}
 
 	// UVs to be added
 
@@ -208,29 +393,22 @@ THREE.ExtrudeGeometry = function( shape, options ) {
 
 	function f3( a, b, c ) {
 
-		if ( reverse ) {
-
-			scope.faces.push( new THREE.Face3( c, b, a ) );
-
-		} else {
-
-			scope.faces.push( new THREE.Face3( a, b, c ) );
-
-		}
+		// if ( reverse ) { // Can now be removed
+		//
+		// 		scope.faces.push( new THREE.Face3( c, b, a ) );
+		//
+		// 	} else {
+		//
+		 		scope.faces.push( new THREE.Face3( a, b, c ) );
+		//
+		// 	}
 
 	}
 
 	function f4( a, b, c, d ) {
 
-		if ( reverse ) {
-
-			scope.faces.push( new THREE.Face4( d, c, b, a ) );
 
-		} else {
-
-			scope.faces.push( new THREE.Face4( a, b, c, d ) );
-
-		}
+ 		scope.faces.push( new THREE.Face4( a, b, c, d ) );
 
 	}
 

+ 381 - 61
src/extras/geometries/Path.js

@@ -1,11 +1,13 @@
 /**
  * @author zz85 / http://www.lab4games.net/zz85/blog
- * Creates free form path.
+ * Creates free form 2d path using series of points, lines or curves.
+ *
  **/
 
 THREE.Path = function ( points ) {
 
 	this.actions = [];
+	this.curves = [];
 
 	if ( points ) {
 
@@ -19,20 +21,24 @@ THREE.PathActions = {
 
 	MOVE_TO: 'moveTo',
 	LINE_TO: 'lineTo',
-	QUADRATIC_CURVE_TO: 'quadraticCurveTo', // BEZIER quadratic CURVE
-	BEZIER_CURVE_TO: 'bezierCurveTo', 		// BEZIER cubic CURVE
-	CSPLINE_THRU: 'splineThru' 				// TODO cardinal splines
+	QUADRATIC_CURVE_TO: 'quadraticCurveTo', // Bezier quadratic curve
+	BEZIER_CURVE_TO: 'bezierCurveTo', 		// Bezier cubic curve
+	CSPLINE_THRU: 'splineThru',				// Catmull-rom spline
+	ARC: 'arc'								// Circle
 
 };
 
-/* Create path using straight lines to connect all points */
+// TODO Clean up PATH API
 
-THREE.Path.prototype.fromPoints = function( vectors /*Array of Vector*/ ) {
+// Create path using straight lines to connect all points
+// - vectors: array of Vector2
 
-	var v = 0, vlen = vectors.length;
+THREE.Path.prototype.fromPoints = function ( vectors ) {
 
 	this.moveTo( vectors[ 0 ].x, vectors[ 0 ].y );
 
+	var v, vlen = vectors.length;
+
 	for ( v = 1; v < vlen; v++ ) {
 
 		this.lineTo( vectors[ v ].x, vectors[ v ].y );
@@ -41,48 +47,151 @@ THREE.Path.prototype.fromPoints = function( vectors /*Array of Vector*/ ) {
 
 };
 
-THREE.Path.prototype.moveTo = function( x, y ) {
+// startPath() endPath()?
+
+THREE.Path.prototype.moveTo = function ( x, y ) {
 
 	var args = Array.prototype.slice.call( arguments );
 	this.actions.push( { action: THREE.PathActions.MOVE_TO, args: args } );
 
 };
 
-THREE.Path.prototype.lineTo = function( x, y ) {
+THREE.Path.prototype.lineTo = function ( x, y ) {
 
 	var args = Array.prototype.slice.call( arguments );
-	this.actions.push( { action: THREE.PathActions.LINE_TO, args: args } );
+
+	var lastargs = this.actions[ this.actions.length - 1 ].args;
+
+	var x0 = lastargs[ lastargs.length - 2 ];
+	var y0 = lastargs[ lastargs.length - 1 ];
+
+	var curve = new THREE.LineCurve( x0, y0, x, y );
+	this.curves.push( curve );
+
+	this.actions.push( { action: THREE.PathActions.LINE_TO, args: args, curve: curve } );
 
 };
 
 THREE.Path.prototype.quadraticCurveTo = function( aCPx, aCPy, aX, aY ) {
 
 	var args = Array.prototype.slice.call( arguments );
-	this.actions.push( { action: THREE.PathActions.QUADRATIC_CURVE_TO, args: args });
+
+	var lastargs = this.actions[ this.actions.length - 1 ].args;
+
+	var x0 = lastargs[ lastargs.length - 2 ];
+	var y0 = lastargs[ lastargs.length - 1 ];
+
+	var curve = new THREE.QuadraticBezierCurve( x0, y0, aCPx, aCPy, aX, aY );
+	this.curves.push( curve );
+
+	this.actions.push( { action: THREE.PathActions.QUADRATIC_CURVE_TO, args: args, curve: curve } );
+
+	//console.log( curve, curve.getPoints(), curve.getSpacedPoints() );
+	//console.log( curve.getPointAt(0), curve.getPointAt(0), curve.getUtoTmapping(0), curve.getSpacedPoints() );
 
 };
 
 THREE.Path.prototype.bezierCurveTo = function( aCP1x, aCP1y,
                                                aCP2x, aCP2y,
-                                               aX, aY) {
+                                               aX, aY ) {
 
 	var args = Array.prototype.slice.call( arguments );
-	this.actions.push( { action: THREE.PathActions.BEZIER_CURVE_TO, args: args } );
+
+	var lastargs = this.actions[ this.actions.length - 1 ].args;
+
+	var x0 = lastargs[ lastargs.length - 2 ];
+	var y0 = lastargs[ lastargs.length - 1 ];
+
+	var curve = new THREE.CubicBezierCurve( x0, y0, aCP1x, aCP1y,
+	                                                aCP2x, aCP2y,
+	                                                aX, aY );
+	this.curves.push( curve );
+
+	this.actions.push( { action: THREE.PathActions.BEZIER_CURVE_TO, args: args, curve: curve } );
 
 };
 
 THREE.Path.prototype.splineThru = function( pts /*Array of Vector*/ ) {
 
 	var args = Array.prototype.slice.call( arguments );
-	this.actions.push( { action: THREE.PathActions.CSPLINE_THRU, args: args } );
+	var lastargs = this.actions[ this.actions.length - 1 ].args;
+
+	var x0 = lastargs[ lastargs.length - 2 ];
+	var y0 = lastargs[ lastargs.length - 1 ];
+
+	var npts = [ new THREE.Vector2( x0, y0 ) ];
+	npts =  npts.concat( pts );
+
+	var curve = new THREE.SplineCurve( npts );
+	this.curves.push( curve );
+
+	this.actions.push( { action: THREE.PathActions.CSPLINE_THRU, args: args, curve: curve } );
+
+	//console.log( curve, curve.getPoints(), curve.getSpacedPoints() );
+
+};
 
-}
+// FUTURE: Change the API or follow canvas API?
+// TODO ARC ( x, y, x - radius, y - radius, startAngle, endAngle )
+
+THREE.Path.prototype.arc = function ( aX, aY, aRadius,
+									  aStartAngle, aEndAngle, aClockwise ) {
+
+	var args = Array.prototype.slice.call( arguments );
+
+	var curve = new THREE.ArcCurve( aX, aY, aRadius,
+									aStartAngle, aEndAngle, aClockwise );
+	this.curves.push( curve );
+
+	// console.log( 'arc', args );
+
+	this.actions.push( { action: THREE.PathActions.ARC, args: args } );
+
+ };
+
+/*
+// FUTURE ENHANCEMENTS
+
+ example usage?
+
+ Path.addExprFunc('sineCurveTo', sineCurveGetPtFunction)
+ Path.sineCurveTo(x,y, amptitude);
+ sineCurve.getPoint(t);
+ return sine(disnt) * ampt
+
+ // Create a new func eg. sin (theta) x
+ THREE.Path.prototype.addExprFunc = function(exprName, func) {
+ };
+*/
+
+
+THREE.Path.prototype.getSpacedPoints = function ( divisions, closedPath ) {
+
+	if ( !divisions ) divisions = 40;
+
+	var points = [];
+
+	for ( var i = 0; i < divisions; i++ ) {
+
+		points.push( this.getPoint( i / divisions ) );
+
+		//if( !this.getPoint( i / divisions ) ) throw "DIE";
+
+	}
 
-// TODO ARC
+	if ( closedPath ) {
+
+		points.push( points[ 0 ] );
+
+	}
+
+	return points;
+
+};
 
 /* Return an array of vectors based on contour of the path */
 
-THREE.Path.prototype.getPoints = function( divisions ) {
+THREE.Path.prototype.getPoints = function( divisions, closedPath ) {
 
 	divisions = divisions || 12;
 
@@ -104,7 +213,7 @@ THREE.Path.prototype.getPoints = function( divisions ) {
 
 		case THREE.PathActions.MOVE_TO:
 
-			//points.push( new THREE.Vector2( args[ 0 ], args[ 1 ] ) );
+			// points.push( new THREE.Vector2( args[ 0 ], args[ 1 ] ) );
 
 			break;
 
@@ -140,8 +249,6 @@ THREE.Path.prototype.getPoints = function( divisions ) {
 
 			for ( j = 1; j <= divisions; j ++ ) {
 
-				// TODO use LOD for divisions
-
 				t = j / divisions;
 
 				tx = THREE.FontUtils.b2( t, cpx0, cpx1, cpx );
@@ -197,73 +304,87 @@ THREE.Path.prototype.getPoints = function( divisions ) {
 		case THREE.PathActions.CSPLINE_THRU:
 
 			laste = this.actions[ i - 1 ].args;
+
 			var last = new THREE.Vector2( laste[ laste.length - 2 ], laste[ laste.length - 1 ] );
-			var spts = args[ 0 ];
-			var n = divisions * spts.length;
+			var spts = [ last ];
 
-			spts.unshift( last );
+			var n = divisions * args[ 0 ].length;
 
-			var spline = new Spline2();
+			spts = spts.concat( args[ 0 ] );
 
-			for ( j = 0; j < n; j ++ ) {
+			var spline = new THREE.SplineCurve( spts );
+			for ( j = 1; j <= n; j ++ ) {
 
-				points.push( spline.get2DPoint( spts, j / n ) ) ;
+				points.push( spline.getPointAt( j / n ) ) ;
 
 			}
 
 			break;
 
-		}
+		case THREE.PathActions.ARC:
 
-	}
+			laste = this.actions[ i - 1 ].args;
 
-	return points;
+			var aX = args[ 0 ], aY = args[ 1 ],
+				aRadius = args[ 2 ],
+				aStartAngle = args[ 3 ], aEndAngle = args[ 4 ],
+				aClockwise = !!args[ 5 ];
 
-};
+			var lastx = laste[ laste.length - 2 ],
+				lasty = laste[ laste.length - 1 ];
 
-var Spline2 = function () {
+			if ( laste.length == 0 ) {
 
-	var c = [], v2,
-		point, intPoint, weight;
+				lastx = lasty = 0;
 
-	this.get2DPoint = function ( points, k ) {
+			}
 
-		v2 = new THREE.Vector2();
-		point = ( points.length - 1 ) * k;
 
-		intPoint = Math.floor( point );
-		weight = point - intPoint;
+			var deltaAngle = aEndAngle - aStartAngle;
+			var angle;
+			var tdivisions = divisions * 2;
+			var t;
 
-		c[ 0 ] = intPoint == 0 ? intPoint : intPoint - 1;
-		c[ 1 ] = intPoint;
-		c[ 2 ] = intPoint > points.length - 2 ? intPoint : intPoint + 1;
-		c[ 3 ] = intPoint > points.length - 3 ? intPoint : intPoint + 2;
+			for ( j = 1; j <= tdivisions; j ++ ) {
 
-		v2.x = interpolate( points[ c[ 0 ] ].x, points[ c[ 1 ] ].x, points[ c[ 2 ] ].x, points[ c[ 3 ] ].x, weight );
-		v2.y = interpolate( points[ c[ 0 ] ].y, points[ c[ 1 ] ].y, points[ c[ 2 ] ].y, points[ c[ 3 ] ].y, weight );
+				t = j / tdivisions;
 
-		//console.log('point',point, v2);
+				if ( !aClockwise ) {
 
-		return v2;
+					t = 1 - t;
 
-	}
+				}
+
+				angle = aStartAngle + t * deltaAngle;
+
+				tx = lastx + aX + aRadius * Math.cos( angle );
+				ty = lasty + aY + aRadius * Math.sin( angle );
+
+				//console.log('t', t, 'angle', angle, 'tx', tx, 'ty', ty);
+
+				points.push( new THREE.Vector2( tx, ty ) );
 
-	// Catmull-Rom
+			}
+
+			//console.log(points);
 
-	function interpolate( p0, p1, p2, p3, t ) {
+		  break;
 
-		var v0 = ( p2 - p0 ) * 0.5;
-		var v1 = ( p3 - p1 ) * 0.5;
-		var t2 = t * t;
-		var t3 = t * t2;
-		return ( 2 * p1 - 2 * p2 + v0 + v1 ) * t3 + ( - 3 * p1 + 3 * p2 - 2 * v0 - v1 ) * t2 + v0 * t + p1;
+		} // end switch
 
 	}
 
-};
+	if ( closedPath ) {
 
+		points.push( points[ 0 ] );
 
-THREE.Path.prototype.getMinAndMax = function() {
+	}
+
+	return points;
+
+};
+
+THREE.Path.prototype.getMinAndMax = function () {
 
 	var points = this.getPoints();
 
@@ -287,7 +408,7 @@ THREE.Path.prototype.getMinAndMax = function() {
 
 	}
 
-	// TODO find mid-pt?
+	// TODO Include CG or find mid-pt?
 
 	return {
 
@@ -300,12 +421,190 @@ THREE.Path.prototype.getMinAndMax = function() {
 
 };
 
+
+// To get accurate point with reference to
+// entire path distance at time t,
+// following has to be done
+
+// 1. Length of each sub path have to be known
+// 2. Locate and identify type of curve
+// 3. Get t for the curve
+// 4. Return curve.getPointAt(t')
+
+THREE.Path.prototype.getPoint = function( t ) {
+
+	var d = t * this.getLength();
+	var curveLengths = this.sums;
+	var i = 0, diff, curve;
+
+	// To think about boundaries points.
+
+	while ( i < curveLengths.length ) {
+
+		if ( curveLengths[ i ] >= d ) {
+
+			diff = curveLengths[ i ] - d;
+			curve = this.curves[ i ];
+
+			var u = 1 - diff / curve.getLength();
+
+			return curve.getPointAt( u );
+
+			break;
+		}
+
+		i++;
+
+	}
+
+	return null;
+
+	// loop where sum != 0, sum > d , sum+1 <d
+
+};
+
+// Compute lengths and cache them
+
+THREE.Path.prototype.getLength = function() {
+
+	// Loop all actions/path
+	// Push sums into cached array
+
+	var lengths = [], sums = 0;
+	var i, il = this.curves.length;
+
+	for ( i = 0; i < il ; i++ ) {
+
+		sums += this.curves[ i ].getLength();
+		lengths.push( sums );
+
+	}
+
+	this.sums = lengths;
+
+	return sums;
+
+};
+
+
+/// Generate geometry from path points (for Line or ParticleSystem objects)
+
+THREE.Path.prototype.createPointsGeometry = function( divisions ) {
+
+    var pts = this.getPoints( divisions, true );
+	return this.createGeometry( pts );
+
+};
+
+// Generate geometry from equidistance sampling along the path
+
+THREE.Path.prototype.createSpacedPointsGeometry = function( divisions ) {
+
+    var pts = this.getSpacedPoints( divisions, true );
+	return this.createGeometry( pts );
+
+};
+
+THREE.Path.prototype.createGeometry = function( points ) {
+
+	var geometry = new THREE.Geometry();
+
+    for( var i = 0; i < points.length; i ++ ) {
+
+        geometry.vertices.push( new THREE.Vertex( new THREE.Vector3( points[ i ].x, points[ i ].y, 0 ) ) );
+
+    }
+
+    return geometry;
+
+};
+
+
+// ALL THINGS BELOW TO BE REFACTORED
+// QN: Transform final pts or transform ACTIONS or add transform filters?
+
+// FUTURE refactor path = an array of lines -> straight, bezier, splines, arc, funcexpr lines
+// Read http://www.planetclegg.com/projects/WarpingTextToSplines.html
+
+THREE.Path.prototype.transform = function( path ) {
+
+	path = new THREE.Path();
+	path.moveTo( 0, 0 );
+	path.quadraticCurveTo( 100, 20, 140, 80 );
+
+	console.log( path.cacheArcLengths() );
+
+	var thisBounds = this.getMinAndMax();
+	var oldPts = this.getPoints();
+
+	var i, il, p, oldX, oldY, xNorm;
+
+	for ( i = 0, il = oldPts.length; i < il; i ++ ) {
+
+		p = oldPts[ i ];
+
+		oldX = p.x;
+		oldY = p.y;
+
+		var xNorm = oldX/ thisBounds.maxX;
+
+		// If using actual distance, for length > path, requires line extrusions
+		//xNorm = path.getUtoTmapping(xNorm, oldX); // 3 styles. 1) wrap stretched. 2) wrap stretch by arc length 3) warp by actual distance
+
+		var pathPt = path.getPoint( xNorm );
+		var normal = path.getNormalVector( xNorm ).multiplyScalar( oldY );
+
+		p.x = pathPt.x + normal.x;
+		p.y = pathPt.y + normal.y;
+
+		//p.x = a * oldX + b * oldY + c;
+		//p.y = d * oldY + e * oldX + f;
+
+	}
+
+	return oldPts;
+
+};
+
+// Read http://www.tinaja.com/glib/nonlingr.pdf
+// nonlinear transforms
+
+THREE.Path.prototype.nltransform = function( a, b, c, d, e, f ) {
+
+	// a - horizontal size
+	// b - lean
+	// c - x offset
+	// d - vertical size
+	// e - climb
+	// f - y offset
+
+	var oldPts = this.getPoints();
+
+	var i, il, p, oldX, oldY;
+
+	for ( i = 0, il = oldPts.length; i < il; i ++ ) {
+
+		p = oldPts[i];
+
+		oldX = p.x;
+		oldY = p.y;
+
+		p.x = a * oldX + b * oldY + c;
+		p.y = d * oldY + e * oldX + f;
+
+	}
+
+	return oldPts;
+
+};
+
+
+// FUTURE Export JSON Format
+
 /* Draws this path onto a 2d canvas easily */
 
 THREE.Path.prototype.debug = function( canvas ) {
 
-	// JUST A STUB
-
 	var bounds = this.getMinAndMax();
 
 	if ( !canvas ) {
@@ -376,11 +675,32 @@ THREE.Path.prototype.debug = function( canvas ) {
 	ctx.stroke();
 	ctx.closePath();
 
-	// DebugPoints
+	// Debug Points
 
 	ctx.strokeStyle = "red";
 
-	var p, points = this.getPoints();
+	/* TO CLEAN UP */
+
+	//var p, points = this.getPoints();
+
+	var theta = -90 /180 * Math.PI;
+	var p, points = this.transform( 0.866, - 0.866,0, 0.500 , 0.50,-50 );
+
+	//0.866, - 0.866,0, 0.500 , 0.50,-50
+
+	// Math.cos(theta),Math.sin(theta),100,
+	// Math.cos(theta),-Math.sin(theta),-50
+
+	// translate, scale, rotation
+
+	// a - horizontal size
+	// b - lean
+	// c - x offset
+	// d - vertical size
+	// e - climb
+	// f - y offset
+	// 1,0,0,
+	// -1,0,100
 
 	for ( i = 0, il = points.length; i < il; i ++ ) {
 

+ 381 - 12
src/extras/geometries/Shape.js

@@ -5,9 +5,9 @@
 
 // STEP 1 Create a path.
 // STEP 2 Turn path into shape.
-// STEP 3 Extrude Geometry takes in Shape/Shapes
+// STEP 3 ExtrudeGeometry takes in Shape/Shapes
 // STEP 3a - Extract points from each shape, turn to vertices
-// STEP 3b - Triangulate Each Shape
+// STEP 3b - Triangulate each shape
 
 THREE.Shape = function ( ) {
 
@@ -19,27 +19,396 @@ THREE.Shape = function ( ) {
 THREE.Shape.prototype = new THREE.Path();
 THREE.Shape.prototype.constructor = THREE.Path;
 
-/* Returns vertices of triangulated faces | get faces */
+// Convenience method to return ExtrudeGeometry
 
-THREE.Shape.prototype.triangulate = function() {
+THREE.Shape.prototype.extrude = function ( options ) {
 
-	var pts = this.getPoints();
+	var extruded = new THREE.ExtrudeGeometry( this, options );
+	return extruded;
+
+};
+
+// Get points of holes
+
+THREE.Shape.prototype.getPointsHoles = function () {
+
+	var i, il = this.holes.length, holesPts = [];
+
+	for ( i = 0; i < il; i ++ ) {
+
+		holesPts[ i ] = this.holes[ i ].getPoints();
+
+	}
+
+	return holesPts;
+
+};
+
+// Get points of holes (spaced by regular distance)
+
+THREE.Shape.prototype.getSpacedPointsHoles = function () {
+
+	var i, il = this.holes.length, holesPts = [];
+
+	for ( i = 0; i < il; i ++ ) {
+
+		holesPts[ i ] = this.holes[ i ].getSpacedPoints();
+
+	}
 
-	if ( THREE.FontUtils.Triangulate.area( pts ) > 0 ) {
+	return holesPts;
 
-		pts = pts.reverse();
+};
+
+// Get points of shape and holes (keypoints based on segments parameter)
+
+THREE.Shape.prototype.extractAllPoints = function () {
+
+	return {
+
+		shape: this.getPoints(),
+		holes: this.getPointsHoles()
 
 	};
 
-	return THREE.FontUtils.Triangulate( pts, true );
+};
+
+// Get points of shape and holes (spaced by regular distance)
+
+THREE.Shape.prototype.extractAllSpacedPoints = function () {
+
+	return {
+
+		shape: this.getSpacedPoints(),
+		holes: this.getSpacedPointsHoles()
+
+	};
 
 };
 
-/* Convenience method to return ExtrudeGeometry */
+THREE.Shape.Utils = {
 
-THREE.Shape.prototype.extrude = function( options ) {
+	/*
+		contour - array of vector2 for contour
+		holes   - array of array of vector2
+	*/
 
-	var extruded =  new THREE.ExtrudeGeometry( this, options );
-	return extruded;
+	removeHoles: function ( contour, holes ) {
+
+		var shape = contour.concat(); // work on this shape
+		var allpoints = shape.concat();
+
+		/* For each isolated shape, find the closest points and break to the hole to allow triangulation */
+
+
+		var prevShapeVert, nextShapeVert,
+			prevHoleVert, nextHoleVert,
+			holeIndex, shapeIndex,
+			shapeId, shapeGroup,
+			h, h2,
+			hole, shortest, d,
+			p, pts1, pts2,
+			tmpShape1, tmpShape2,
+			tmpHole1, tmpHole2,
+			verts = [];
+
+		for ( h = 0; h < holes.length; h++ ) {
+		//for ( h = holes.length; h-- > 0; ) {
+
+			hole = holes[ h ];
+
+			/*
+			shapeholes[ h ].concat(); // preserves original
+			holes.push( hole );
+			*/
+
+			allpoints = allpoints.concat( hole );
+
+			shortest = Number.POSITIVE_INFINITY;
+
+			// THIS THING NEEDS TO BE DONE CORRECTLY AGAIN :(
+
+			// Find the shortest pair of pts between shape and hole
+
+			// TODO we could optimize with
+			// http://en.wikipedia.org/wiki/Proximity_problems
+			// http://en.wikipedia.org/wiki/Closest_pair_of_points
+			// http://stackoverflow.com/questions/1602164/shortest-distance-between-points-algorithm
+
+			for ( h2 = 0; h2 < hole.length; h2 ++ ) {
+
+				pts1 = hole[ h2 ];
+				var dist = [];
+
+				for ( p = 0; p < shape.length; p++ ) {
+
+					pts2 = shape[ p ];
+					d = pts1.distanceTo( pts2 );
+					dist.push( d );
+
+					if ( d < shortest ) {
+
+						shortest = d;
+						holeIndex = h2;
+						shapeIndex = p;
+
+					}
+
+				}
+
+			}
+
+			//console.log("shortest", shortest, dist);
+
+			prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1;
+			prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1;
+
+			var areaapts = [
+
+				hole[ holeIndex ],
+				shape[ shapeIndex ],
+				shape[ prevShapeVert ]
+
+			];
+
+			var areaa = THREE.FontUtils.Triangulate.area( areaapts );
+
+			var areabpts = [
+
+				hole[ holeIndex ],
+				hole[ prevHoleVert ],
+				shape[ shapeIndex ]
+
+			];
+
+			var areab = THREE.FontUtils.Triangulate.area( areabpts );
+
+			var shapeOffset = 1;
+			var holeOffset = -1;
+
+			var oldShapeIndex = shapeIndex, oldHoleIndex = holeIndex;
+			shapeIndex += shapeOffset;
+			holeIndex += holeOffset;
+
+			if ( shapeIndex < 0 ) { shapeIndex += shape.length;  }
+			shapeIndex %= shape.length;
+
+			if ( holeIndex < 0 ) { holeIndex += hole.length;  }
+			holeIndex %= hole.length;
+
+			prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1;
+			prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1;
+
+			areaapts = [
+
+				hole[ holeIndex ],
+				shape[ shapeIndex ],
+				shape[ prevShapeVert ]
+
+			];
+
+			var areaa2 = THREE.FontUtils.Triangulate.area( areaapts );
+
+			areabpts = [
+
+				hole[ holeIndex ],
+				hole[ prevHoleVert ],
+				shape[ shapeIndex ]
+
+			];
+
+			var areab2 = THREE.FontUtils.Triangulate.area( areabpts );
+			//console.log(areaa,areab ,areaa2,areab2, ( areaa + areab ),  ( areaa2 + areab2 ));
+
+			if ( ( areaa + areab ) > ( areaa2 + areab2 ) ) {
+
+				// In case areas are not correct.
+				//console.log("USE THIS");
+
+				shapeIndex = oldShapeIndex;
+				holeIndex = oldHoleIndex ;
+
+				if ( shapeIndex < 0 ) { shapeIndex += shape.length;  }
+				shapeIndex %= shape.length;
+
+				if ( holeIndex < 0 ) { holeIndex += hole.length;  }
+				holeIndex %= hole.length;
+
+				prevShapeVert = ( shapeIndex - 1 ) >= 0 ? shapeIndex - 1 : shape.length - 1;
+				prevHoleVert = ( holeIndex - 1 ) >= 0 ? holeIndex - 1 : hole.length - 1;
+
+			} else {
+
+				//console.log("USE THAT ")
+
+			}
+
+			tmpShape1 = shape.slice( 0, shapeIndex );
+			tmpShape2 = shape.slice( shapeIndex );
+			tmpHole1 = hole.slice( holeIndex );
+			tmpHole2 = hole.slice( 0, holeIndex );
+
+			// Should check orders here again?
+
+			var trianglea = [
+
+				hole[ holeIndex ],
+				shape[ shapeIndex ],
+				shape[ prevShapeVert ]
+
+			];
+
+			var triangleb = [
+
+				hole[ holeIndex ] ,
+				hole[ prevHoleVert ],
+				shape[ shapeIndex ]
+
+			];
+
+			verts.push( trianglea );
+			verts.push( triangleb );
+
+			shape = tmpShape1.concat( tmpHole1 ).concat( tmpHole2 ).concat( tmpShape2 );
+			//shape = tmpHole1.concat( tmpHole2 );
+
+		}
+
+		return {
+
+			shape:shape, 		/* shape with no holes */
+			isolatedPts: verts, /* isolated faces */
+			allpoints: allpoints
+
+		}
+
+
+	},
+
+	triangulateShape: function ( contour, holes ) {
+
+		var shapeWithoutHoles = THREE.Shape.Utils.removeHoles( contour, holes );
+
+		var shape = shapeWithoutHoles.shape,
+			allpoints = shapeWithoutHoles.allpoints,
+			isolatedPts = shapeWithoutHoles.isolatedPts;
+
+		var triangles = THREE.FontUtils.Triangulate( shape, false ); // True returns indices for points of spooled shape
+
+		// To maintain reference to old shape, one must match coordinates, or offset the indices from original arrays. It's probably easier to do the first.
+
+		//console.log("triangles",triangles, triangles.length);
+		//console.log("allpoints",allpoints, allpoints.length);
+
+		var v, f, i, face;
+
+		for ( v = 0; v < triangles.length; v++ ) {
+
+			face = triangles[ v ];
+
+			for ( f = 0; f < 3; f++ ) { // For 3 pts in faces
+
+				for ( i = 0; i < allpoints.length; i++ ) { // Go through all points
+
+					if ( allpoints[ i ].equals( face[ f ] ) ) { // If matches
+
+						face[ f ] = i; // face now has reference to index
+
+					}
+
+				}
+
+			}
+
+		}
+
+		for ( v = 0; v < isolatedPts.length; v++ ) {
+
+			face = isolatedPts[ v ];
+
+			for ( f = 0; f < 3; f++ ) { // For 3 pts in faces
+
+				for ( i = 0; i < allpoints.length; i++ ) { // Go thru all points
+
+					if ( allpoints[ i ].equals( face[ f ] ) ) { // If matches
+
+						face[ f ] = i; // face now has reference to index
+
+					}
+
+				}
+
+			}
+
+		}
+
+		//console.log("edited?" , triangles);
+		return triangles.concat( isolatedPts );
+
+	}, // end triangulate shapes
+
+	/*
+	triangulate2 : function( pts, holes ) {
+
+		// For use Poly2Tri.js
+
+		//var pts = this.getPoints();
+		var allpts = pts.concat();
+		var shape = [];
+		for (var p in pts) {
+			shape.push(new js.poly2tri.Point(pts[p].x, pts[p].y));
+		}
+
+		var swctx = new js.poly2tri.SweepContext(shape);
+
+		for (var h in holes) {
+			var aHole = holes[h];
+			var newHole = []
+			for (i in aHole) {
+				newHole.push(new js.poly2tri.Point(aHole[i].x, aHole[i].y));
+				allpts.push(aHole[i]);
+			}
+			swctx.AddHole(newHole);
+		}
+
+		var find;
+		var findIndexForPt = function (pt) {
+			find = new THREE.Vector2(pt.x, pt.y);
+			var p;
+			for (p=0, pl = allpts.length; p<pl; p++) {
+				if (allpts[p].equals(find)) return p;
+			}
+			return -1;
+		};
+		// triangulate
+		js.poly2tri.sweep.Triangulate(swctx);
+
+		var triangles =  swctx.GetTriangles();
+		var tr ;
+		var facesPts = [];
+		for (var t in triangles) {
+			tr =  triangles[t];
+			facesPts.push([
+				findIndexForPt(tr.GetPoint(0)),
+				findIndexForPt(tr.GetPoint(1)),
+				findIndexForPt(tr.GetPoint(2))
+					]);
+		}
+
+
+	//	console.log(facesPts);
+	//	console.log("triangles", triangles.length, triangles);
+
+		// Returns array of faces with 3 element each
+	return facesPts;
+	},
+	*/
+
+	isClockWise: function ( pts ) {
+
+		return THREE.FontUtils.Triangulate.area( pts ) < 0;
+
+	}
 
 };
+

+ 39 - 29
src/extras/geometries/TextGeometry.js

@@ -15,9 +15,9 @@
  *  weight: 		<string>,		// font weight (normal, bold)
  *  style: 			<string>,		// font style  (normal, italics)
  *
- *  bezelEnabled:	<bool>,			// turn on bezel
- *  bezelThickness: <float>, 		// how deep into text bezel goes
- *  bezelSize:		<float>, 		// how far from text outline is bezel
+ *  bevelEnabled:	<bool>,			// turn on bevel
+ *  bevelThickness: <float>, 		// how deep into text bevel goes
+ *  bevelSize:		<float>, 		// how far from text outline is bevel
  *  }
  *
  * It uses techniques used in:
@@ -60,9 +60,9 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) {
 	var weight = parameters.weight !== undefined ? parameters.weight : "normal";
 	var style = parameters.style !== undefined ? parameters.style : "normal";
 
-	var bezelThickness = parameters.bezelThickness !== undefined ? parameters.bezelThickness : 10;
-	var bezelSize = parameters.bezelSize !== undefined ? parameters.bezelSize : 8;
-	var bezelEnabled = parameters.bezelEnabled !== undefined ? parameters.bezelEnabled : false;
+	var bevelThickness = parameters.bevelThickness !== undefined ? parameters.bevelThickness : 10;
+	var bevelSize = parameters.bevelSize !== undefined ? parameters.bevelSize : 8;
+	var bevelEnabled = parameters.bevelEnabled !== undefined ? parameters.bevelEnabled : false;
 
 	THREE.FontUtils.size = size;
 	THREE.FontUtils.divisions = curveSegments;
@@ -71,7 +71,7 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) {
 	THREE.FontUtils.weight = weight;
 	THREE.FontUtils.style = style;
 
-	THREE.FontUtils.bezelSize = bezelSize;
+	THREE.FontUtils.bevelSize = bevelSize;
 
 	// Get a Font data json object
 
@@ -80,7 +80,7 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) {
 	var vertices = data.points;
 	var faces = data.faces;
 	var contour = data.contour;
-	var bezelPoints = data.bezel;
+	var bevelPoints = data.bevel;
 
 	var scope = this;
 
@@ -90,7 +90,7 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) {
 	var i,
 		vert, vlen = vertices.length,
 		face, flen = faces.length,
-		bezelPt, blen = bezelPoints.length;
+		bevelPt, blen = bevelPoints.length;
 
 	// Back facing vertices
 
@@ -110,19 +110,19 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) {
 
 	}
 
-	if ( bezelEnabled ) {
+	if ( bevelEnabled ) {
 
 		for ( i = 0; i < blen; i++ ) {
 
-			bezelPt = bezelPoints[ i ];
-			v( bezelPt.x, bezelPt.y, bezelThickness );
+			bevelPt = bevelPoints[ i ];
+			v( bevelPt.x, bevelPt.y, bevelThickness );
 
 		}
 
 		for ( i = 0; i < blen; i++ ) {
 
-			bezelPt = bezelPoints[ i ];
-			v( bezelPt.x, bezelPt.y, height - bezelThickness );
+			bevelPt = bevelPoints[ i ];
+			v( bevelPt.x, bevelPt.y, height - bevelThickness );
 
 		}
 
@@ -149,9 +149,9 @@ THREE.TextGeometry.prototype.set = function ( text, parameters ) {
 	var lastV;
 	var j, k, l, m;
 
-	if ( bezelEnabled ) {
+	if ( bevelEnabled ) {
 
-		i = bezelPoints.length;
+		i = bevelPoints.length;
 
 		while ( --i > 0 ) {
 
@@ -666,16 +666,21 @@ THREE.FontUtils = {
 
 		var fontPaths = [];
 
+		var path = new THREE.Path();
 		for ( i = 0; i < length; i++ ) {
 
-			var ret = this.extractGlyphPoints( chars[ i ], face, scale, offset );
+			var ret = this.extractGlyphPoints( chars[ i ], face, scale, offset, path );
 			offset += ret.offset;
 			characterPts.push( ret.points );
 			allPts = allPts.concat( ret.points );
-			fontPaths.push( ret.path );
+			//fontPaths.push( ret.path );
 
 		}
 
+		//path.debug(document.getElementById("boo"));
+		console.log(path);
+
+
 		// get the width
 
 		var width = offset / 2;
@@ -689,7 +694,7 @@ THREE.FontUtils = {
 		var extract = this.extractPoints( allPts, characterPts );
 		extract.contour = allPts;
 
-		var bezelPoints = [];
+		var bevelPoints = [];
 
 		var centroids = [], forCentroids = [], expandOutwards = [], sum = new THREE.Vector2(), lastV;
 
@@ -734,7 +739,7 @@ THREE.FontUtils = {
 			centroid = centroids[ p ];
 
 			dirV = pt.clone().subSelf( centroid );
-			adj = this.bezelSize / dirV.length();
+			adj = this.bevelSize / dirV.length();
 
 			if ( expandOutwards[ p ] ) {
 
@@ -747,7 +752,7 @@ THREE.FontUtils = {
 			}
 
 			adj = dirV.multiplyScalar( adj ).addSelf( centroid );
-			bezelPoints.unshift( adj );
+			bevelPoints.unshift( adj );
 
 
 			if ( !lastV ) {
@@ -771,12 +776,12 @@ THREE.FontUtils = {
 		for ( p = 0; p < allPts.length; p++ ) {
 
 			pt = allPts[ p ];
-			bezelPoints.push( new THREE.Vector2( pt.x + this.bezelSize, pt.y + this.bezelSize ) );
+			bevelPoints.push( new THREE.Vector2( pt.x + this.bevelSize, pt.y + this.bevelSize ) );
 
 		}
 		*/
 
-		extract.bezel = bezelPoints;
+		extract.bevel = bevelPoints;
 
 		return extract;
 
@@ -849,10 +854,10 @@ THREE.FontUtils = {
 	},
 
 
-	extractGlyphPoints : function( c, face, scale, offset ) {
+	extractGlyphPoints : function( c, face, scale, offset, path ) {
 
 		var pts = [];
-		var path = new THREE.Path();
+
 
 
 		var i, i2,
@@ -875,7 +880,7 @@ THREE.FontUtils = {
 			for ( i = 0; i < length; ) {
 
 				action = outline[ i++ ];
-
+				//console.log(action);
 				switch( action ) {
 
 				case 'm':
@@ -941,7 +946,7 @@ THREE.FontUtils = {
 					cpx2 = outline[ i++ ] *  scaleX + offset;
 					cpy2 = outline[ i++ ] * -scaleY;
 
-					path.quadraticCurveTo( cpx, cpy, cpx1, cpy1, cpx2, cpy2 );
+					path.bezierCurveTo( cpx, cpy, cpx1, cpy1, cpx2, cpy2 );
 
 					laste = pts[ pts.length - 1 ];
 
@@ -968,8 +973,7 @@ THREE.FontUtils = {
 			}
 		}
 
-		path.debug(document.getElementById("boo"));
-		console.log(path);
+
 
 		return { offset: glyph.ha*scale, points:pts, path:path};
 	}
@@ -1065,9 +1069,15 @@ THREE.FontUtils = {
 
 				/* output Triangle */
 
+				/*
 				result.push( contour[ a ] );
 				result.push( contour[ b ] );
 				result.push( contour[ c ] );
+				*/
+				result.push( [ contour[ a ],
+					contour[ b ],
+					contour[ c ] ] );
+
 
 				vertIndices.push( [ verts[ u ], verts[ v ], verts[ w ] ] );
 

+ 1 - 0
utils/build.py

@@ -93,6 +93,7 @@ EXTRAS_FILES = [
 'extras/cameras/RollCamera.js',
 'extras/cameras/TrackballCamera.js',
 'extras/cameras/QuakeCamera.js',
+'extras/geometries/Curve.js',
 'extras/geometries/Path.js',
 'extras/geometries/Shape.js',
 'extras/geometries/CubeGeometry.js',

Some files were not shown because too many files changed in this diff