Browse Source

Fleshed out more face color pipeline (OBJ converter, Blender importer and loaders).

- OBJ converter now has "-b" option for baking materials' diffuse colors into face colors
  (if there are morph colormap OBJs/MTLs, first colormap will be used)
  (material will get "vertexColors" property set to "face")

- Blender importer now bakes JSON face colors into Blender vertex colors

- Loader now handles "material.vertexColors" with more options
    - nonexistant property or false will set material to THREE.NoColors
    - "face" will set material to THREE.FaceColors
    - anything else will get THREE.VertexColors

- fixed bug in JSONLoader where face colors were not properly initialized
alteredq 14 years ago
parent
commit
00b0f6df41

+ 116 - 116
build/Three.js

@@ -13,20 +13,20 @@ this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPosit
 THREE.Vector4.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z,b.w+d.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z,b.w-d.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x*
 b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,d){this.set(this.x+(b.x-this.x)*d,this.y+(b.y-this.y)*d,this.z+(b.z-this.z)*d,this.w+(b.w-this.w)*d)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3};
 THREE.Ray.prototype={intersectScene:function(b){var d,c,f=b.objects,g=[];b=0;for(d=f.length;b<d;b++){c=f[b];c instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(c)))}g.sort(function(h,j){return h.distance-j.distance});return g},intersectObject:function(b){function d(E,J,U,y){y=y.clone().subSelf(J);U=U.clone().subSelf(J);var L=E.clone().subSelf(J);E=y.dot(y);J=y.dot(U);y=y.dot(L);var N=U.dot(U);U=U.dot(L);L=1/(E*N-J*J);N=(N*y-J*U)*L;E=(E*U-J*y)*L;return N>0&&E>0&&N+E<1}var c,f,g,h,j,k,n,p,o,t,
-x,v=b.geometry,z=v.vertices,C=[];c=0;for(f=v.faces.length;c<f;c++){g=v.faces[c];t=this.origin.clone();x=this.direction.clone();n=b.matrixWorld;h=n.multiplyVector3(z[g.a].position.clone());j=n.multiplyVector3(z[g.b].position.clone());k=n.multiplyVector3(z[g.c].position.clone());n=g instanceof THREE.Face4?n.multiplyVector3(z[g.d].position.clone()):null;p=b.matrixRotationWorld.multiplyVector3(g.normal.clone());o=x.dot(p);if(o<0){p=p.dot((new THREE.Vector3).sub(h,t))/o;t=t.addSelf(x.multiplyScalar(p));
+x,u=b.geometry,z=u.vertices,C=[];c=0;for(f=u.faces.length;c<f;c++){g=u.faces[c];t=this.origin.clone();x=this.direction.clone();n=b.matrixWorld;h=n.multiplyVector3(z[g.a].position.clone());j=n.multiplyVector3(z[g.b].position.clone());k=n.multiplyVector3(z[g.c].position.clone());n=g instanceof THREE.Face4?n.multiplyVector3(z[g.d].position.clone()):null;p=b.matrixRotationWorld.multiplyVector3(g.normal.clone());o=x.dot(p);if(o<0){p=p.dot((new THREE.Vector3).sub(h,t))/o;t=t.addSelf(x.multiplyScalar(p));
 if(g instanceof THREE.Face3){if(d(t,h,j,k)){g={distance:this.origin.distanceTo(t),point:t,face:g,object:b};C.push(g)}}else if(g instanceof THREE.Face4&&(d(t,h,j,n)||d(t,j,k,n))){g={distance:this.origin.distanceTo(t),point:t,face:g,object:b};C.push(g)}}}return C}};
 THREE.Rectangle=function(){function b(){h=f-d;j=g-c}var d,c,f,g,h,j,k=!0;this.getX=function(){return d};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return d};this.getTop=function(){return c};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(n,p,o,t){k=!1;d=n;c=p;f=o;g=t;b()};this.addPoint=function(n,p){if(k){k=!1;d=n;c=p;f=n;g=p}else{d=d<n?d:n;c=c<p?c:p;f=f>n?f:n;g=g>p?g:p}b()};
-this.add3Points=function(n,p,o,t,x,v){if(k){k=!1;d=n<o?n<x?n:x:o<x?o:x;c=p<t?p<v?p:v:t<v?t:v;f=n>o?n>x?n:x:o>x?o:x;g=p>t?p>v?p:v:t>v?t:v}else{d=n<o?n<x?n<d?n:d:x<d?x:d:o<x?o<d?o:d:x<d?x:d;c=p<t?p<v?p<c?p:c:v<c?v:c:t<v?t<c?t:c:v<c?v:c;f=n>o?n>x?n>f?n:f:x>f?x:f:o>x?o>f?o:f:x>f?x:f;g=p>t?p>v?p>g?p:g:v>g?v:g:t>v?t>g?t:g:v>g?v:g}b()};this.addRectangle=function(n){if(k){k=!1;d=n.getLeft();c=n.getTop();f=n.getRight();g=n.getBottom()}else{d=d<n.getLeft()?d:n.getLeft();c=c<n.getTop()?c:n.getTop();f=f>n.getRight()?
+this.add3Points=function(n,p,o,t,x,u){if(k){k=!1;d=n<o?n<x?n:x:o<x?o:x;c=p<t?p<u?p:u:t<u?t:u;f=n>o?n>x?n:x:o>x?o:x;g=p>t?p>u?p:u:t>u?t:u}else{d=n<o?n<x?n<d?n:d:x<d?x:d:o<x?o<d?o:d:x<d?x:d;c=p<t?p<u?p<c?p:c:u<c?u:c:t<u?t<c?t:c:u<c?u:c;f=n>o?n>x?n>f?n:f:x>f?x:f:o>x?o>f?o:f:x>f?x:f;g=p>t?p>u?p>g?p:g:u>g?u:g:t>u?t>g?t:g:u>g?u:g}b()};this.addRectangle=function(n){if(k){k=!1;d=n.getLeft();c=n.getTop();f=n.getRight();g=n.getBottom()}else{d=d<n.getLeft()?d:n.getLeft();c=c<n.getTop()?c:n.getTop();f=f>n.getRight()?
 f:n.getRight();g=g>n.getBottom()?g:n.getBottom()}b()};this.inflate=function(n){d-=n;c-=n;f+=n;g+=n;b()};this.minSelf=function(n){d=d>n.getLeft()?d:n.getLeft();c=c>n.getTop()?c:n.getTop();f=f<n.getRight()?f:n.getRight();g=g<n.getBottom()?g:n.getBottom();b()};this.instersects=function(n){return Math.min(f,n.getRight())-Math.max(d,n.getLeft())>=0&&Math.min(g,n.getBottom())-Math.max(c,n.getTop())>=0};this.empty=function(){k=!0;g=f=c=d=0;b()};this.isEmpty=function(){return k}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}};
-THREE.Matrix4=function(b,d,c,f,g,h,j,k,n,p,o,t,x,v,z,C){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,n||0,p||0,o||1,t||0,x||0,v||0,z||0,C||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(b,d,c,f,g,h,j,k,n,p,o,t,x,v,z,C){this.n11=b;this.n12=d;this.n13=c;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=n;this.n32=p;this.n33=o;this.n34=t;this.n41=x;this.n42=v;this.n43=z;this.n44=C;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,c){var f=THREE.Matrix4.__v1,
+THREE.Matrix4=function(b,d,c,f,g,h,j,k,n,p,o,t,x,u,z,C){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,n||0,p||0,o||1,t||0,x||0,u||0,z||0,C||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(b,d,c,f,g,h,j,k,n,p,o,t,x,u,z,C){this.n11=b;this.n12=d;this.n13=c;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=n;this.n32=p;this.n33=o;this.n34=t;this.n41=x;this.n42=u;this.n43=z;this.n44=C;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,c){var f=THREE.Matrix4.__v1,
 g=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,d).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x+=1.0E-4;f.cross(c,h).normalize()}g.cross(h,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=h.x;this.n21=f.y;this.n22=g.y;this.n23=h.y;this.n31=f.z;this.n32=g.z;this.n33=h.z;return this},multiplyVector3:function(b){var d=b.x,c=b.y,f=b.z,g=1/(this.n41*d+this.n42*c+this.n43*f+this.n44);b.x=(this.n11*d+this.n12*c+this.n13*f+this.n14)*g;b.y=(this.n21*d+this.n22*c+this.n23*
 f+this.n24)*g;b.z=(this.n31*d+this.n32*c+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var d=b.x,c=b.y,f=b.z,g=b.w;b.x=this.n11*d+this.n12*c+this.n13*f+this.n14*g;b.y=this.n21*d+this.n22*c+this.n23*f+this.n24*g;b.z=this.n31*d+this.n32*c+this.n33*f+this.n34*g;b.w=this.n41*d+this.n42*c+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var d=b.x,c=b.y,f=b.z;b.x=d*this.n11+c*this.n12+f*this.n13;b.y=d*this.n21+c*this.n22+f*this.n23;b.z=d*this.n31+c*this.n32+f*this.n33;b.normalize();
-return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,x=b.n33,v=b.n34,z=b.n41,C=b.n42,E=b.n43,J=b.n44,U=d.n11,y=d.n12,L=d.n13,N=d.n14,P=d.n21,za=d.n22,
-va=d.n23,ta=d.n24,e=d.n31,fa=d.n32,ea=d.n33,Aa=d.n34;this.n11=c*U+f*P+g*e;this.n12=c*y+f*za+g*fa;this.n13=c*L+f*va+g*ea;this.n14=c*N+f*ta+g*Aa+h;this.n21=j*U+k*P+n*e;this.n22=j*y+k*za+n*fa;this.n23=j*L+k*va+n*ea;this.n24=j*N+k*ta+n*Aa+p;this.n31=o*U+t*P+x*e;this.n32=o*y+t*za+x*fa;this.n33=o*L+t*va+x*ea;this.n34=o*N+t*ta+x*Aa+v;this.n41=z*U+C*P+E*e;this.n42=z*y+C*za+E*fa;this.n43=z*L+C*va+E*ea;this.n44=z*N+C*ta+E*Aa+J;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);c[0]=this.n11;c[1]=
+return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,x=b.n33,u=b.n34,z=b.n41,C=b.n42,E=b.n43,J=b.n44,U=d.n11,y=d.n12,L=d.n13,N=d.n14,P=d.n21,za=d.n22,
+va=d.n23,ta=d.n24,e=d.n31,fa=d.n32,ea=d.n33,Aa=d.n34;this.n11=c*U+f*P+g*e;this.n12=c*y+f*za+g*fa;this.n13=c*L+f*va+g*ea;this.n14=c*N+f*ta+g*Aa+h;this.n21=j*U+k*P+n*e;this.n22=j*y+k*za+n*fa;this.n23=j*L+k*va+n*ea;this.n24=j*N+k*ta+n*Aa+p;this.n31=o*U+t*P+x*e;this.n32=o*y+t*za+x*fa;this.n33=o*L+t*va+x*ea;this.n34=o*N+t*ta+x*Aa+u;this.n41=z*U+C*P+E*e;this.n42=z*y+C*za+E*fa;this.n43=z*L+C*va+E*ea;this.n44=z*N+C*ta+E*Aa+J;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);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(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=
-b;return this},determinant:function(){var b=this.n11,d=this.n12,c=this.n13,f=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,n=this.n31,p=this.n32,o=this.n33,t=this.n34,x=this.n41,v=this.n42,z=this.n43,C=this.n44;return f*j*p*x-c*k*p*x-f*h*o*x+d*k*o*x+c*h*t*x-d*j*t*x-f*j*n*v+c*k*n*v+f*g*o*v-b*k*o*v-c*g*t*v+b*j*t*v+f*h*n*z-d*k*n*z-f*g*p*z+b*k*p*z+d*g*t*z-b*h*t*z-c*h*n*C+d*j*n*C+c*g*p*C-b*j*p*C-d*g*o*C+b*h*o*C},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=
+b;return this},determinant:function(){var b=this.n11,d=this.n12,c=this.n13,f=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,n=this.n31,p=this.n32,o=this.n33,t=this.n34,x=this.n41,u=this.n42,z=this.n43,C=this.n44;return f*j*p*x-c*k*p*x-f*h*o*x+d*k*o*x+c*h*t*x-d*j*t*x-f*j*n*u+c*k*n*u+f*g*o*u-b*k*o*u-c*g*t*u+b*j*t*u+f*h*n*z-d*k*n*z-f*g*p*z+b*k*p*z+d*g*t*z-b*h*t*z-c*h*n*C+d*j*n*C+c*g*p*C-b*j*p*C-d*g*o*C+b*h*o*C},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=
 this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=
 this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;
 b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,c){this.set(1,0,0,b,0,1,0,d,0,0,1,c,0,0,
@@ -34,8 +34,8 @@ b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=t
 1-c,h=b.x,j=b.y,k=b.z,n=g*h,p=g*j;this.set(n*h+c,n*j-f*k,n*k+f*j,0,n*j+f*k,p*j+c,p*k-f*h,0,n*k-f*j,p*k+f*h,g*k*k+c,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var d=b.x,c=b.y,f=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(c);c=Math.sin(c);var h=Math.cos(f);f=Math.sin(f);var j=b*c,k=d*c;this.n11=g*h;this.n12=-g*f;this.n13=c;this.n21=k*h+b*f;this.n22=-k*f+b*h;this.n23=-d*g;this.n31=-j*h+d*f;this.n32=j*f+d*h;this.n33=
 b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,c=b.y,f=b.z,g=b.w,h=d+d,j=c+c,k=f+f;b=d*h;var n=d*j;d*=k;var p=c*j;c*=k;f*=k;h*=g;j*=g;g*=k;this.n11=1-(p+f);this.n12=n-g;this.n13=d+j;this.n21=n+g;this.n22=1-(b+f);this.n23=c-h;this.n31=d-j;this.n32=c+h;this.n33=1-(b+p);return this},scale:function(b){var d=b.x,c=b.y;b=b.z;this.n11*=d;this.n12*=c;this.n13*=b;this.n21*=d;this.n22*=c;this.n23*=b;this.n31*=d;this.n32*=c;this.n33*=b;this.n41*=d;this.n42*=c;this.n43*=b;return this},extractPosition:function(b){this.n14=
 b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,d){var c=1/d.x,f=1/d.y,g=1/d.z;this.n11=b.n11*c;this.n21=b.n21*c;this.n31=b.n31*c;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}};
-THREE.Matrix4.makeInvert=function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,x=b.n33,v=b.n34,z=b.n41,C=b.n42,E=b.n43,J=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=n*v*C-p*x*C+p*t*E-k*v*E-n*t*J+k*x*J;d.n12=h*x*C-g*v*C-h*t*E+f*v*E+g*t*J-f*x*J;d.n13=g*p*C-h*n*C+h*k*E-f*p*E-g*k*J+f*n*J;d.n14=h*n*t-g*p*t-h*k*x+f*p*x+g*k*v-f*n*v;d.n21=p*x*z-n*v*z-p*o*E+j*v*E+n*o*J-j*x*J;d.n22=g*v*z-h*x*z+h*o*E-c*v*E-g*o*J+c*x*J;d.n23=h*n*z-g*p*z-h*j*E+c*p*E+g*j*J-c*n*J;
-d.n24=g*p*o-h*n*o+h*j*x-c*p*x-g*j*v+c*n*v;d.n31=k*v*z-p*t*z+p*o*C-j*v*C-k*o*J+j*t*J;d.n32=h*t*z-f*v*z-h*o*C+c*v*C+f*o*J-c*t*J;d.n33=g*p*z-h*k*z+h*j*C-c*p*C-f*j*J+c*k*J;d.n34=h*k*o-f*p*o-h*j*t+c*p*t+f*j*v-c*k*v;d.n41=n*t*z-k*x*z-n*o*C+j*x*C+k*o*E-j*t*E;d.n42=f*x*z-g*t*z+g*o*C-c*x*C-f*o*E+c*t*E;d.n43=g*k*z-f*n*z-g*j*C+c*n*C+f*j*E-c*k*E;d.n44=f*n*o-g*k*o+g*j*t-c*n*t-f*j*x+c*k*x;d.multiplyScalar(1/b.determinant());return d};
+THREE.Matrix4.makeInvert=function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,n=b.n23,p=b.n24,o=b.n31,t=b.n32,x=b.n33,u=b.n34,z=b.n41,C=b.n42,E=b.n43,J=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=n*u*C-p*x*C+p*t*E-k*u*E-n*t*J+k*x*J;d.n12=h*x*C-g*u*C-h*t*E+f*u*E+g*t*J-f*x*J;d.n13=g*p*C-h*n*C+h*k*E-f*p*E-g*k*J+f*n*J;d.n14=h*n*t-g*p*t-h*k*x+f*p*x+g*k*u-f*n*u;d.n21=p*x*z-n*u*z-p*o*E+j*u*E+n*o*J-j*x*J;d.n22=g*u*z-h*x*z+h*o*E-c*u*E-g*o*J+c*x*J;d.n23=h*n*z-g*p*z-h*j*E+c*p*E+g*j*J-c*n*J;
+d.n24=g*p*o-h*n*o+h*j*x-c*p*x-g*j*u+c*n*u;d.n31=k*u*z-p*t*z+p*o*C-j*u*C-k*o*J+j*t*J;d.n32=h*t*z-f*u*z-h*o*C+c*u*C+f*o*J-c*t*J;d.n33=g*p*z-h*k*z+h*j*C-c*p*C-f*j*J+c*k*J;d.n34=h*k*o-f*p*o-h*j*t+c*p*t+f*j*u-c*k*u;d.n41=n*t*z-k*x*z-n*o*C+j*x*C+k*o*E-j*t*E;d.n42=f*x*z-g*t*z+g*o*C-c*x*C-f*o*E+c*t*E;d.n43=g*k*z-f*n*z-g*j*C+c*n*C+f*j*E-c*k*E;d.n44=f*n*o-g*k*o+g*j*t-c*n*t-f*j*x+c*k*x;d.multiplyScalar(1/b.determinant());return d};
 THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,c=d.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,n=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12;b=b.n11*f+b.n21*j+b.n31*p;if(b==0)throw"matrix not invertible";b=1/b;c[0]=b*f;c[1]=b*g;c[2]=b*h;c[3]=b*j;c[4]=b*k;c[5]=b*n;c[6]=b*p;c[7]=b*o;c[8]=b*t;return d};
 THREE.Matrix4.makeFrustum=function(b,d,c,f,g,h){var j;j=new THREE.Matrix4;j.n11=2*g/(d-b);j.n12=0;j.n13=(d+b)/(d-b);j.n14=0;j.n21=0;j.n22=2*g/(f-c);j.n23=(f+c)/(f-c);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+g)/(h-g);j.n34=-2*h*g/(h-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,d,c,f){var g;b=c*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,c,f)};
 THREE.Matrix4.makeOrtho=function(b,d,c,f,g,h){var j,k,n,p;j=new THREE.Matrix4;k=d-b;n=c-f;p=h-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((d+b)/k);j.n21=0;j.n22=2/n;j.n23=0;j.n24=-((c+f)/n);j.n31=0;j.n32=0;j.n33=-2/p;j.n34=-((h+g)/p);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
@@ -56,15 +56,15 @@ THREE.Geometry.prototype={computeCentroids:function(){var b,d,c;b=0;for(d=this.f
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(b){var d,c,f,g,h,j,k=new THREE.Vector3,n=new THREE.Vector3;f=0;for(g=this.faces.length;f<g;f++){h=this.faces[f];if(b&&h.vertexNormals.length){k.set(0,0,0);d=0;for(c=h.vertexNormals.length;d<c;d++)k.addSelf(h.vertexNormals[d]);k.divideScalar(3)}else{d=this.vertices[h.a];c=this.vertices[h.b];j=this.vertices[h.c];k.sub(j.position,c.position);n.sub(d.position,c.position);k.crossSelf(n)}k.isZero()||
 k.normalize();h.normal.copy(k)}},computeVertexNormals:function(){var b,d,c,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);b=0;for(d=this.vertices.length;b<d;b++)f[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++){c=this.faces[b];if(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{f=
 this.__tmpVertices;b=0;for(d=this.vertices.length;b<d;b++)f[b].set(0,0,0)}b=0;for(d=this.faces.length;b<d;b++){c=this.faces[b];if(c instanceof THREE.Face3){f[c.a].addSelf(c.normal);f[c.b].addSelf(c.normal);f[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){f[c.a].addSelf(c.normal);f[c.b].addSelf(c.normal);f[c.c].addSelf(c.normal);f[c.d].addSelf(c.normal)}}b=0;for(d=this.vertices.length;b<d;b++)f[b].normalize();b=0;for(d=this.faces.length;b<d;b++){c=this.faces[b];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(f[c.a]);
-c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(f[c.a]);c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c]);c.vertexNormals[3].copy(f[c.d])}}},computeTangents:function(){function b(ca,sa,Ba,ja,$,pa,Fa){k=ca.vertices[sa].position;n=ca.vertices[Ba].position;p=ca.vertices[ja].position;o=j[$];t=j[pa];x=j[Fa];v=n.x-k.x;z=p.x-k.x;C=n.y-k.y;E=p.y-k.y;J=n.z-k.z;U=p.z-k.z;y=t.u-o.u;L=x.u-o.u;N=t.v-o.v;P=x.v-o.v;za=1/(y*P-
-L*N);fa.set((P*v-N*z)*za,(P*C-N*E)*za,(P*J-N*U)*za);ea.set((y*z-L*v)*za,(y*E-L*C)*za,(y*U-L*J)*za);ta[sa].addSelf(fa);ta[Ba].addSelf(fa);ta[ja].addSelf(fa);e[sa].addSelf(ea);e[Ba].addSelf(ea);e[ja].addSelf(ea)}var d,c,f,g,h,j,k,n,p,o,t,x,v,z,C,E,J,U,y,L,N,P,za,va,ta=[],e=[],fa=new THREE.Vector3,ea=new THREE.Vector3,Aa=new THREE.Vector3,Ha=new THREE.Vector3,Ia=new THREE.Vector3;d=0;for(c=this.vertices.length;d<c;d++){ta[d]=new THREE.Vector3;e[d]=new THREE.Vector3}d=0;for(c=this.faces.length;d<c;d++){h=
+c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(f[c.a]);c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c]);c.vertexNormals[3].copy(f[c.d])}}},computeTangents:function(){function b(ca,sa,Ba,ja,$,pa,Fa){k=ca.vertices[sa].position;n=ca.vertices[Ba].position;p=ca.vertices[ja].position;o=j[$];t=j[pa];x=j[Fa];u=n.x-k.x;z=p.x-k.x;C=n.y-k.y;E=p.y-k.y;J=n.z-k.z;U=p.z-k.z;y=t.u-o.u;L=x.u-o.u;N=t.v-o.v;P=x.v-o.v;za=1/(y*P-
+L*N);fa.set((P*u-N*z)*za,(P*C-N*E)*za,(P*J-N*U)*za);ea.set((y*z-L*u)*za,(y*E-L*C)*za,(y*U-L*J)*za);ta[sa].addSelf(fa);ta[Ba].addSelf(fa);ta[ja].addSelf(fa);e[sa].addSelf(ea);e[Ba].addSelf(ea);e[ja].addSelf(ea)}var d,c,f,g,h,j,k,n,p,o,t,x,u,z,C,E,J,U,y,L,N,P,za,va,ta=[],e=[],fa=new THREE.Vector3,ea=new THREE.Vector3,Aa=new THREE.Vector3,Ha=new THREE.Vector3,Ia=new THREE.Vector3;d=0;for(c=this.vertices.length;d<c;d++){ta[d]=new THREE.Vector3;e[d]=new THREE.Vector3}d=0;for(c=this.faces.length;d<c;d++){h=
 this.faces[d];j=this.faceVertexUvs[0][d];if(h instanceof THREE.Face3)b(this,h.a,h.b,h.c,0,1,2);else if(h instanceof THREE.Face4){b(this,h.a,h.b,h.c,0,1,2);b(this,h.a,h.b,h.d,0,1,3)}}var ua=["a","b","c","d"];d=0;for(c=this.faces.length;d<c;d++){h=this.faces[d];for(f=0;f<h.vertexNormals.length;f++){Ia.copy(h.vertexNormals[f]);g=h[ua[f]];va=ta[g];Aa.copy(va);Aa.subSelf(Ia.multiplyScalar(Ia.dot(va))).normalize();Ha.cross(h.vertexNormals[f],va);g=Ha.dot(e[g]);g=g<0?-1:1;h.vertexTangents[f]=new THREE.Vector4(Aa.x,
 Aa.y,Aa.z,g)}}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,c=this.vertices.length;d<c;d++){b=this.vertices[d];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;
 if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,d=0,c=this.vertices.length;d<c;d++)b=Math.max(b,this.vertices[d].position.length());this.boundingSphere=
 {radius:b}}};THREE.GeometryIdCounter=0;
-THREE.Spline=function(b){function d(v,z,C,E,J,U,y){v=(C-v)*0.5;E=(E-z)*0.5;return(2*(z-C)+v+E)*y+(-3*(z-C)-2*v-E)*U+v*J+z}this.points=b;var c=[],f={x:0,y:0,z:0},g,h,j,k,n,p,o,t,x;this.initFromArray=function(v){this.points=[];for(var z=0;z<v.length;z++)this.points[z]={x:v[z][0],y:v[z][1],z:v[z][2]}};this.getPoint=function(v){g=(this.points.length-1)*v;h=Math.floor(g);j=g-h;c[0]=h==0?h:h-1;c[1]=h;c[2]=h>this.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;p=this.points[c[0]];o=this.points[c[1]];
-t=this.points[c[2]];x=this.points[c[3]];k=j*j;n=j*k;f.x=d(p.x,o.x,t.x,x.x,j,k,n);f.y=d(p.y,o.y,t.y,x.y,j,k,n);f.z=d(p.z,o.z,t.z,x.z,j,k,n);return f};this.getControlPointsArray=function(){var v,z,C=this.points.length,E=[];for(v=0;v<C;v++){z=this.points[v];E[v]=[z.x,z.y,z.z]}return E};this.getLength=function(v){var z,C,E=z=z=0,J=new THREE.Vector3,U=new THREE.Vector3,y=[],L=0;y[0]=0;v||(v=100);C=this.points.length*v;J.copy(this.points[0]);for(v=1;v<C;v++){z=v/C;position=this.getPoint(z);U.copy(position);
-L+=U.distanceTo(J);J.copy(position);z*=this.points.length-1;z=Math.floor(z);if(z!=E){y[z]=L;E=z}}y[y.length]=L;return{chunks:y,total:L}};this.reparametrizeByArcLength=function(v){var z,C,E,J,U,y,L=[],N=new THREE.Vector3,P=this.getLength();L.push(N.copy(this.points[0]).clone());for(z=1;z<this.points.length;z++){C=P.chunks[z]-P.chunks[z-1];y=Math.ceil(v*C/P.total);J=(z-1)/(this.points.length-1);U=z/(this.points.length-1);for(C=1;C<y-1;C++){E=J+C*(1/y)*(U-J);position=this.getPoint(E);L.push(N.copy(position).clone())}L.push(N.copy(this.points[z]).clone())}this.points=
+THREE.Spline=function(b){function d(u,z,C,E,J,U,y){u=(C-u)*0.5;E=(E-z)*0.5;return(2*(z-C)+u+E)*y+(-3*(z-C)-2*u-E)*U+u*J+z}this.points=b;var c=[],f={x:0,y:0,z:0},g,h,j,k,n,p,o,t,x;this.initFromArray=function(u){this.points=[];for(var z=0;z<u.length;z++)this.points[z]={x:u[z][0],y:u[z][1],z:u[z][2]}};this.getPoint=function(u){g=(this.points.length-1)*u;h=Math.floor(g);j=g-h;c[0]=h==0?h:h-1;c[1]=h;c[2]=h>this.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;p=this.points[c[0]];o=this.points[c[1]];
+t=this.points[c[2]];x=this.points[c[3]];k=j*j;n=j*k;f.x=d(p.x,o.x,t.x,x.x,j,k,n);f.y=d(p.y,o.y,t.y,x.y,j,k,n);f.z=d(p.z,o.z,t.z,x.z,j,k,n);return f};this.getControlPointsArray=function(){var u,z,C=this.points.length,E=[];for(u=0;u<C;u++){z=this.points[u];E[u]=[z.x,z.y,z.z]}return E};this.getLength=function(u){var z,C,E=z=z=0,J=new THREE.Vector3,U=new THREE.Vector3,y=[],L=0;y[0]=0;u||(u=100);C=this.points.length*u;J.copy(this.points[0]);for(u=1;u<C;u++){z=u/C;position=this.getPoint(z);U.copy(position);
+L+=U.distanceTo(J);J.copy(position);z*=this.points.length-1;z=Math.floor(z);if(z!=E){y[z]=L;E=z}}y[y.length]=L;return{chunks:y,total:L}};this.reparametrizeByArcLength=function(u){var z,C,E,J,U,y,L=[],N=new THREE.Vector3,P=this.getLength();L.push(N.copy(this.points[0]).clone());for(z=1;z<this.points.length;z++){C=P.chunks[z]-P.chunks[z-1];y=Math.ceil(u*C/P.total);J=(z-1)/(this.points.length-1);U=z/(this.points.length-1);for(C=1;C<y-1;C++){E=J+C*(1/y)*(U-J);position=this.getPoint(E);L.push(N.copy(position).clone())}L.push(N.copy(this.points[z]).clone())}this.points=
 L}};
 THREE.AnimationHandler=function(){var b=[],d={},c={};c.update=function(g){for(var h=0;h<b.length;h++)b[h].update(g)};c.addToUpdate=function(g){b.indexOf(g)===-1&&b.push(g)};c.removeFromUpdate=function(g){g=b.indexOf(g);g!==-1&&b.splice(g,1)};c.add=function(g){d[g.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+g.name+" already exists in library. Overwriting.");d[g.name]=g;if(g.initialized!==!0){for(var h=0;h<g.hierarchy.length;h++){for(var j=0;j<g.hierarchy[h].keys.length;j++){if(g.hierarchy[h].keys[j].time<0)g.hierarchy[h].keys[j].time=
 0;if(g.hierarchy[h].keys[j].rot!==undefined&&!(g.hierarchy[h].keys[j].rot instanceof THREE.Quaternion)){var k=g.hierarchy[h].keys[j].rot;g.hierarchy[h].keys[j].rot=new THREE.Quaternion(k[0],k[1],k[2],k[3])}}if(g.hierarchy[h].keys[0].morphTargets!==undefined){k={};for(j=0;j<g.hierarchy[h].keys.length;j++)for(var n=0;n<g.hierarchy[h].keys[j].morphTargets.length;n++){var p=g.hierarchy[h].keys[j].morphTargets[n];k[p]=-1}g.hierarchy[h].usedMorphTargets=k;for(j=0;j<g.hierarchy[h].keys.length;j++){var o=
@@ -75,11 +75,11 @@ THREE.Animation.prototype.play=function(b,d){if(!this.isPlaying){this.isPlaying=
 g instanceof THREE.Bone?g.skinMatrix:g.matrix}var h=g.animationCache.prevKey;g=g.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];g.pos=this.getNextKeyWith("pos",c,1);g.rot=this.getNextKeyWith("rot",c,1);g.scl=this.getNextKeyWith("scl",c,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.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var b=0;b<this.hierarchy.length;b++)if(this.hierarchy[b].animationCache!==undefined){if(this.hierarchy[b]instanceof THREE.Bone)this.hierarchy[b].skinMatrix=this.hierarchy[b].animationCache.originalMatrix;else this.hierarchy[b].matrix=this.hierarchy[b].animationCache.originalMatrix;delete this.hierarchy[b].animationCache}};
-THREE.Animation.prototype.update=function(b){if(this.isPlaying){var d=["pos","rot","scl"],c,f,g,h,j,k,n,p,o=this.data.JIT.hierarchy,t,x;this.currentTime+=b*this.timeScale;x=this.currentTime;t=this.currentTime%=this.data.length;p=parseInt(Math.min(t*this.data.fps,this.data.length*this.data.fps),10);for(var v=0,z=this.hierarchy.length;v<z;v++){b=this.hierarchy[v];n=b.animationCache;if(this.JITCompile&&o[v][p]!==undefined)if(b instanceof THREE.Bone){b.skinMatrix=o[v][p];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=
-!1}else{b.matrix=o[v][p];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(b instanceof THREE.Bone)b.skinMatrix=b.animationCache.originalMatrix;else b.matrix=b.animationCache.originalMatrix;for(var C=0;C<3;C++){c=d[C];j=n.prevKey[c];k=n.nextKey[c];if(k.time<=x){if(t<x)if(this.loop){j=this.data.hierarchy[v].keys[0];for(k=this.getNextKeyWith(c,v,1);k.time<t;){j=k;k=this.getNextKeyWith(c,v,k.index+1)}}else{this.stop();return}else{do{j=k;k=this.getNextKeyWith(c,v,k.index+1)}while(k.time<
-t)}n.prevKey[c]=j;n.nextKey[c]=k}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(t-j.time)/(k.time-j.time);g=j[c];h=k[c];if(f<0||f>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+v);f=f<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
-this.getPrevKeyWith("pos",v,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",v,k.index+1).pos;f=f*0.33+0.33;g=this.interpolateCatmullRom(this.points,f);c.x=g[0];c.y=g[1];c.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){f=this.interpolateCatmullRom(this.points,f*1.01);this.target.set(f[0],f[1],f[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();f=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,f,0)}}}else if(c===
-"rot")THREE.Quaternion.slerp(g,h,b.quaternion,f);else if(c==="scl"){c=b.scale;c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}}}}if(this.JITCompile&&o[0][p]===undefined){this.hierarchy[0].update(undefined,!0);for(v=0;v<this.hierarchy.length;v++)o[v][p]=this.hierarchy[v]instanceof THREE.Bone?this.hierarchy[v].skinMatrix.clone():this.hierarchy[v].matrix.clone()}}};
+THREE.Animation.prototype.update=function(b){if(this.isPlaying){var d=["pos","rot","scl"],c,f,g,h,j,k,n,p,o=this.data.JIT.hierarchy,t,x;this.currentTime+=b*this.timeScale;x=this.currentTime;t=this.currentTime%=this.data.length;p=parseInt(Math.min(t*this.data.fps,this.data.length*this.data.fps),10);for(var u=0,z=this.hierarchy.length;u<z;u++){b=this.hierarchy[u];n=b.animationCache;if(this.JITCompile&&o[u][p]!==undefined)if(b instanceof THREE.Bone){b.skinMatrix=o[u][p];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=
+!1}else{b.matrix=o[u][p];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(b instanceof THREE.Bone)b.skinMatrix=b.animationCache.originalMatrix;else b.matrix=b.animationCache.originalMatrix;for(var C=0;C<3;C++){c=d[C];j=n.prevKey[c];k=n.nextKey[c];if(k.time<=x){if(t<x)if(this.loop){j=this.data.hierarchy[u].keys[0];for(k=this.getNextKeyWith(c,u,1);k.time<t;){j=k;k=this.getNextKeyWith(c,u,k.index+1)}}else{this.stop();return}else{do{j=k;k=this.getNextKeyWith(c,u,k.index+1)}while(k.time<
+t)}n.prevKey[c]=j;n.nextKey[c]=k}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(t-j.time)/(k.time-j.time);g=j[c];h=k[c];if(f<0||f>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+u);f=f<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
+this.getPrevKeyWith("pos",u,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",u,k.index+1).pos;f=f*0.33+0.33;g=this.interpolateCatmullRom(this.points,f);c.x=g[0];c.y=g[1];c.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){f=this.interpolateCatmullRom(this.points,f*1.01);this.target.set(f[0],f[1],f[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();f=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,f,0)}}}else if(c===
+"rot")THREE.Quaternion.slerp(g,h,b.quaternion,f);else if(c==="scl"){c=b.scale;c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}}}}if(this.JITCompile&&o[0][p]===undefined){this.hierarchy[0].update(undefined,!0);for(u=0;u<this.hierarchy.length;u++)o[u][p]=this.hierarchy[u]instanceof THREE.Bone?this.hierarchy[u].skinMatrix.clone():this.hierarchy[u].matrix.clone()}}};
 THREE.Animation.prototype.interpolateCatmullRom=function(b,d){var c=[],f=[],g,h,j,k,n,p;g=(b.length-1)*d;h=Math.floor(g);g-=h;c[0]=h==0?h:h-1;c[1]=h;c[2]=h>b.length-2?h:h+1;c[3]=h>b.length-3?h:h+2;h=b[c[0]];k=b[c[1]];n=b[c[2]];p=b[c[3]];c=g*g;j=g*c;f[0]=this.interpolate(h[0],k[0],n[0],p[0],g,c,j);f[1]=this.interpolate(h[1],k[1],n[1],p[1],g,c,j);f[2]=this.interpolate(h[2],k[2],n[2],p[2],g,c,j);return f};
 THREE.Animation.prototype.interpolate=function(b,d,c,f,g,h,j){b=(c-b)*0.5;f=(f-d)*0.5;return(2*(d-c)+b+f)*j+(-3*(d-c)-2*b-f)*h+b*g+d};THREE.Animation.prototype.getNextKeyWith=function(b,d,c){var f=this.data.hierarchy[d].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c<f.length-1?c:f.length-1;else c%=f.length;for(;c<f.length;c++)if(f[c][b]!==undefined)return f[c];return this.data.hierarchy[d].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(b,d,c){var f=this.data.hierarchy[d].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+f.length;c>=0;c--)if(f[c][b]!==undefined)return f[c];return this.data.hierarchy[d].keys[f.length-1]};
@@ -140,26 +140,26 @@ THREE.LOD.prototype.update=function(b,d,c){this.matrixAutoUpdate&&(d|=this.updat
 THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
 THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var d=this.geometry.vertices,c=this.geometry.faces,f=this.geometry.edgeFaces,g=b.faces;b=b.vertices;var h=g.length,j,k,n,p,o,t=["a","b","c","d"];for(n=0;n<h;n++){k=d.length;j=g[n];if(j instanceof THREE.Face4){p=4;k=new THREE.Face4(k,k+1,k+2,k+3)}else{p=3;k=new THREE.Face3(k,k+1,k+2)}k.normal.copy(j.normal);c.push(k);for(k=
 0;k<p;k++){o=b[j[t[k]]];d.push(new THREE.Vertex(o.position.clone()))}}for(h=0;h<g.length-1;h++){b=c[h];for(j=h+1;j<g.length;j++){k=c[j];k=this.facesShareEdge(d,b,k);if(k!==undefined){k=new THREE.Face4(k.indices[0],k.indices[3],k.indices[2],k.indices[1]);k.normal.set(1,0,0);f.push(k)}}}};
-THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,c){var f,g,h,j,k,n,p,o,t,x,v,z,C,E=0,J=["a","b","c","d"];f=d instanceof THREE.Face4?4:3;g=c instanceof THREE.Face4?4:3;for(z=0;z<f;z++){h=d[J[z]];k=b[h];for(C=0;C<g;C++){j=c[J[C]];n=b[j];if(Math.abs(k.position.x-n.position.x)<1.0E-4&&Math.abs(k.position.y-n.position.y)<1.0E-4&&Math.abs(k.position.z-n.position.z)<1.0E-4){E++;if(E===1){p=k;o=n;t=h;x=j;v=J[z]}if(E===2){v+=J[z];return v==="ad"||v==="ac"?{faces:[d,c],vertices:[p,o,n,k],indices:[t,
+THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,c){var f,g,h,j,k,n,p,o,t,x,u,z,C,E=0,J=["a","b","c","d"];f=d instanceof THREE.Face4?4:3;g=c instanceof THREE.Face4?4:3;for(z=0;z<f;z++){h=d[J[z]];k=b[h];for(C=0;C<g;C++){j=c[J[C]];n=b[j];if(Math.abs(k.position.x-n.position.x)<1.0E-4&&Math.abs(k.position.y-n.position.y)<1.0E-4&&Math.abs(k.position.z-n.position.z)<1.0E-4){E++;if(E===1){p=k;o=n;t=h;x=j;u=J[z]}if(E===2){u+=J[z];return u==="ad"||u==="ac"?{faces:[d,c],vertices:[p,o,n,k],indices:[t,
 x,j,h],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[d,c],vertices:[p,k,n,o],indices:[t,h,j,x],vertexTypes:[1,1,2,2],extrudable:!0}}}}}};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;
 THREE.Scene.prototype.addChild=function(b){this.supr.addChild.call(this,b);this.addChildRecurse(b)};THREE.Scene.prototype.addChildRecurse=function(b){if(b instanceof THREE.Light)this.lights.indexOf(b)===-1&&this.lights.push(b);else if(b instanceof THREE.Sound)this.sounds.indexOf(b)===-1&&this.sounds.push(b);else if(!(b instanceof THREE.Camera||b instanceof THREE.Bone)&&this.objects.indexOf(b)===-1){this.objects.push(b);this.__objectsAdded.push(b)}for(var d=0;d<b.children.length;d++)this.addChildRecurse(b.children[d])};
 THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var d=this.lights.indexOf(b);d!==-1&&this.lights.splice(d,1)}else if(b instanceof THREE.Sound){d=this.sounds.indexOf(b);d!==-1&&this.sounds.splice(d,1)}else if(!(b instanceof THREE.Camera)){d=this.objects.indexOf(b);if(d!==-1){this.objects.splice(d,1);this.__objectsRemoved.push(b)}}for(d=0;d<b.children.length;d++)this.removeChildRecurse(b.children[d])};
 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.Fog=function(b,d,c){this.color=new THREE.Color(b);this.near=d||1;this.far=c||1E3};THREE.FogExp2=function(b,d){this.color=new THREE.Color(b);this.density=d!==undefined?d:2.5E-4};
 THREE.Projector=function(){function b(){var fa=n[k]=n[k]||new THREE.RenderableVertex;k++;return fa}function d(fa,ea){return ea.z-fa.z}function c(fa,ea){var Aa=0,Ha=1,Ia=fa.z+fa.w,ua=ea.z+ea.w,ca=-fa.z+fa.w,sa=-ea.z+ea.w;if(Ia>=0&&ua>=0&&ca>=0&&sa>=0)return!0;else if(Ia<0&&ua<0||ca<0&&sa<0)return!1;else{if(Ia<0)Aa=Math.max(Aa,Ia/(Ia-ua));else ua<0&&(Ha=Math.min(Ha,Ia/(Ia-ua)));if(ca<0)Aa=Math.max(Aa,ca/(ca-sa));else sa<0&&(Ha=Math.min(Ha,ca/(ca-sa)));if(Ha<Aa)return!1;else{fa.lerpSelf(ea,Aa);ea.lerpSelf(fa,
-1-Ha);return!0}}}var f,g,h=[],j,k,n=[],p,o,t=[],x,v=[],z,C,E=[],J,U,y=[],L=new THREE.Vector4,N=new THREE.Vector4,P=new THREE.Matrix4,za=new THREE.Matrix4,va=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ta=new THREE.Vector4,e=new THREE.Vector4;this.projectVector=function(fa,ea){P.multiply(ea.projectionMatrix,ea.matrixWorldInverse);P.multiplyVector3(fa);return fa};this.unprojectVector=function(fa,ea){P.multiply(ea.matrixWorld,THREE.Matrix4.makeInvert(ea.projectionMatrix));
+1-Ha);return!0}}}var f,g,h=[],j,k,n=[],p,o,t=[],x,u=[],z,C,E=[],J,U,y=[],L=new THREE.Vector4,N=new THREE.Vector4,P=new THREE.Matrix4,za=new THREE.Matrix4,va=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ta=new THREE.Vector4,e=new THREE.Vector4;this.projectVector=function(fa,ea){P.multiply(ea.projectionMatrix,ea.matrixWorldInverse);P.multiplyVector3(fa);return fa};this.unprojectVector=function(fa,ea){P.multiply(ea.matrixWorld,THREE.Matrix4.makeInvert(ea.projectionMatrix));
 P.multiplyVector3(fa);return fa};this.projectObjects=function(fa,ea,Aa){ea=[];var Ha,Ia,ua;g=0;Ia=fa.objects;fa=0;for(Ha=Ia.length;fa<Ha;fa++){ua=Ia[fa];var ca;if(!(ca=!ua.visible))if(ca=ua instanceof THREE.Mesh){a:{ca=void 0;for(var sa=ua.matrixWorld,Ba=-ua.geometry.boundingSphere.radius*Math.max(ua.scale.x,Math.max(ua.scale.y,ua.scale.z)),ja=0;ja<6;ja++){ca=va[ja].x*sa.n14+va[ja].y*sa.n24+va[ja].z*sa.n34+va[ja].w;if(ca<=Ba){ca=!1;break a}}ca=!0}ca=!ca}if(!ca){ca=h[g]=h[g]||new THREE.RenderableObject;
 g++;f=ca;L.copy(ua.position);P.multiplyVector3(L);f.object=ua;f.z=L.z;ea.push(f)}}Aa&&ea.sort(d);return ea};this.projectScene=function(fa,ea,Aa){var Ha=[],Ia=ea.near,ua=ea.far,ca,sa,Ba,ja,$,pa,Fa,ka,oa,Ga,Ra,Za,Va,Sa,O,aa,qa;U=C=x=o=0;ea.matrixAutoUpdate&&ea.updateMatrix();fa.update(undefined,!1,ea);P.multiply(ea.projectionMatrix,ea.matrixWorldInverse);va[0].set(P.n41-P.n11,P.n42-P.n12,P.n43-P.n13,P.n44-P.n14);va[1].set(P.n41+P.n11,P.n42+P.n12,P.n43+P.n13,P.n44+P.n14);va[2].set(P.n41+P.n21,P.n42+
 P.n22,P.n43+P.n23,P.n44+P.n24);va[3].set(P.n41-P.n21,P.n42-P.n22,P.n43-P.n23,P.n44-P.n24);va[4].set(P.n41-P.n31,P.n42-P.n32,P.n43-P.n33,P.n44-P.n34);va[5].set(P.n41+P.n31,P.n42+P.n32,P.n43+P.n33,P.n44+P.n34);for(ca=0;ca<6;ca++){oa=va[ca];oa.divideScalar(Math.sqrt(oa.x*oa.x+oa.y*oa.y+oa.z*oa.z))}oa=this.projectObjects(fa,ea,!0);fa=0;for(ca=oa.length;fa<ca;fa++){Ga=oa[fa].object;if(Ga.visible){Ra=Ga.matrixWorld;Za=Ga.matrixRotationWorld;Va=Ga.materials;Sa=Ga.overdraw;k=0;if(Ga instanceof THREE.Mesh){O=
 Ga.geometry;ja=O.vertices;aa=O.faces;O=O.faceVertexUvs;sa=0;for(Ba=ja.length;sa<Ba;sa++){j=b();j.positionWorld.copy(ja[sa].position);Ra.multiplyVector3(j.positionWorld);j.positionScreen.copy(j.positionWorld);P.multiplyVector4(j.positionScreen);j.positionScreen.x/=j.positionScreen.w;j.positionScreen.y/=j.positionScreen.w;j.visible=j.positionScreen.z>Ia&&j.positionScreen.z<ua}ja=0;for(sa=aa.length;ja<sa;ja++){Ba=aa[ja];if(Ba instanceof THREE.Face3){$=n[Ba.a];pa=n[Ba.b];Fa=n[Ba.c];if($.visible&&pa.visible&&
 Fa.visible&&(Ga.doubleSided||Ga.flipSided!=(Fa.positionScreen.x-$.positionScreen.x)*(pa.positionScreen.y-$.positionScreen.y)-(Fa.positionScreen.y-$.positionScreen.y)*(pa.positionScreen.x-$.positionScreen.x)<0)){ka=t[o]=t[o]||new THREE.RenderableFace3;o++;p=ka;p.v1.copy($);p.v2.copy(pa);p.v3.copy(Fa)}else continue}else if(Ba instanceof THREE.Face4){$=n[Ba.a];pa=n[Ba.b];Fa=n[Ba.c];ka=n[Ba.d];if($.visible&&pa.visible&&Fa.visible&&ka.visible&&(Ga.doubleSided||Ga.flipSided!=((ka.positionScreen.x-$.positionScreen.x)*
-(pa.positionScreen.y-$.positionScreen.y)-(ka.positionScreen.y-$.positionScreen.y)*(pa.positionScreen.x-$.positionScreen.x)<0||(pa.positionScreen.x-Fa.positionScreen.x)*(ka.positionScreen.y-Fa.positionScreen.y)-(pa.positionScreen.y-Fa.positionScreen.y)*(ka.positionScreen.x-Fa.positionScreen.x)<0))){qa=v[x]=v[x]||new THREE.RenderableFace4;x++;p=qa;p.v1.copy($);p.v2.copy(pa);p.v3.copy(Fa);p.v4.copy(ka)}else continue}p.normalWorld.copy(Ba.normal);Za.multiplyVector3(p.normalWorld);p.centroidWorld.copy(Ba.centroid);
+(pa.positionScreen.y-$.positionScreen.y)-(ka.positionScreen.y-$.positionScreen.y)*(pa.positionScreen.x-$.positionScreen.x)<0||(pa.positionScreen.x-Fa.positionScreen.x)*(ka.positionScreen.y-Fa.positionScreen.y)-(pa.positionScreen.y-Fa.positionScreen.y)*(ka.positionScreen.x-Fa.positionScreen.x)<0))){qa=u[x]=u[x]||new THREE.RenderableFace4;x++;p=qa;p.v1.copy($);p.v2.copy(pa);p.v3.copy(Fa);p.v4.copy(ka)}else continue}p.normalWorld.copy(Ba.normal);Za.multiplyVector3(p.normalWorld);p.centroidWorld.copy(Ba.centroid);
 Ra.multiplyVector3(p.centroidWorld);p.centroidScreen.copy(p.centroidWorld);P.multiplyVector3(p.centroidScreen);Fa=Ba.vertexNormals;$=0;for(pa=Fa.length;$<pa;$++){ka=p.vertexNormalsWorld[$];ka.copy(Fa[$]);Za.multiplyVector3(ka)}$=0;for(pa=O.length;$<pa;$++)if(qa=O[$][ja]){Fa=0;for(ka=qa.length;Fa<ka;Fa++)p.uvs[$][Fa]=qa[Fa]}p.meshMaterials=Va;p.faceMaterials=Ba.materials;p.overdraw=Sa;p.z=p.centroidScreen.z;Ha.push(p)}}else if(Ga instanceof THREE.Line){za.multiply(P,Ra);ja=Ga.geometry.vertices;$=b();
 $.positionScreen.copy(ja[0].position);za.multiplyVector4($.positionScreen);sa=1;for(Ba=ja.length;sa<Ba;sa++){$=b();$.positionScreen.copy(ja[sa].position);za.multiplyVector4($.positionScreen);pa=n[k-2];ta.copy($.positionScreen);e.copy(pa.positionScreen);if(c(ta,e)){ta.multiplyScalar(1/ta.w);e.multiplyScalar(1/e.w);Ra=E[C]=E[C]||new THREE.RenderableLine;C++;z=Ra;z.v1.positionScreen.copy(ta);z.v2.positionScreen.copy(e);z.z=Math.max(ta.z,e.z);z.materials=Ga.materials;Ha.push(z)}}}else if(Ga instanceof
 THREE.Particle){N.set(Ga.position.x,Ga.position.y,Ga.position.z,1);P.multiplyVector4(N);N.z/=N.w;if(N.z>0&&N.z<1){Ra=y[U]=y[U]||new THREE.RenderableParticle;U++;J=Ra;J.x=N.x/N.w;J.y=N.y/N.w;J.z=N.z;J.rotation=Ga.rotation.z;J.scale.x=Ga.scale.x*Math.abs(J.x-(N.x+ea.projectionMatrix.n11)/(N.w+ea.projectionMatrix.n14));J.scale.y=Ga.scale.y*Math.abs(J.y-(N.y+ea.projectionMatrix.n22)/(N.w+ea.projectionMatrix.n24));J.materials=Ga.materials;Ha.push(J)}}}}Aa&&Ha.sort(d);return Ha}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,d=new THREE.Projector,c,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,k){c=j;f=k;g=c/2;h=f/2};this.render=function(j,k){var n,p,o,t,x,v,z,C;b=d.projectScene(j,k);n=0;for(p=b.length;n<p;n++){x=b[n];if(x instanceof THREE.RenderableParticle){z=x.x*g+g;C=x.y*h+h;o=0;for(t=x.material.length;o<t;o++){v=x.material[o];if(v instanceof THREE.ParticleDOMMaterial){v=v.domElement;v.style.left=z+"px";v.style.top=C+"px"}}}}}};
-THREE.CanvasRenderer=function(){function b(ra){if(v!=ra)o.globalAlpha=v=ra}function d(ra){if(z!=ra){switch(ra){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}z=ra}}function c(ra){if(C!=ra)o.strokeStyle=C=ra}var f=null,g=new THREE.Projector,h=document.createElement("canvas"),j,k,n,p,o=h.getContext("2d"),t=new THREE.Color(0),x=0,v=1,z=0,
-C=null,E=null,J=null,U=null,y=null,L,N,P,za,va=new THREE.RenderableVertex,ta=new THREE.RenderableVertex,e,fa,ea,Aa,Ha,Ia,ua,ca,sa,Ba,ja,$,pa=new THREE.Color,Fa=new THREE.Color,ka=new THREE.Color,oa=new THREE.Color,Ga=new THREE.Color,Ra,Za,Va,Sa,O,aa,qa,Da,ha,la,m=new THREE.Rectangle,B=new THREE.Rectangle,w=new THREE.Rectangle,u=!1,A=new THREE.Color,M=new THREE.Color,G=new THREE.Color,I=new THREE.Color,F=new THREE.Vector3,D,H,K,X,T,Ea,Ja=16;D=document.createElement("canvas");D.width=D.height=2;H=D.getContext("2d");
-H.fillStyle="rgba(0,0,0,1)";H.fillRect(0,0,2,2);K=H.getImageData(0,0,2,2);X=K.data;T=document.createElement("canvas");T.width=T.height=Ja;Ea=T.getContext("2d");Ea.translate(-Ja/2,-Ja/2);Ea.scale(Ja,Ja);Ja--;this.domElement=h;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(ra,ya){j=ra;k=ya;n=j/2;p=k/2;h.width=j;h.height=k;m.set(-n,-p,n,p);v=1;z=0;y=U=J=E=C=null};this.setClearColor=function(ra,ya){t=ra;x=ya};this.setClearColorHex=function(ra,ya){t.setHex(ra);x=ya};this.clear=
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,d=new THREE.Projector,c,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,k){c=j;f=k;g=c/2;h=f/2};this.render=function(j,k){var n,p,o,t,x,u,z,C;b=d.projectScene(j,k);n=0;for(p=b.length;n<p;n++){x=b[n];if(x instanceof THREE.RenderableParticle){z=x.x*g+g;C=x.y*h+h;o=0;for(t=x.material.length;o<t;o++){u=x.material[o];if(u instanceof THREE.ParticleDOMMaterial){u=u.domElement;u.style.left=z+"px";u.style.top=C+"px"}}}}}};
+THREE.CanvasRenderer=function(){function b(ra){if(u!=ra)o.globalAlpha=u=ra}function d(ra){if(z!=ra){switch(ra){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}z=ra}}function c(ra){if(C!=ra)o.strokeStyle=C=ra}var f=null,g=new THREE.Projector,h=document.createElement("canvas"),j,k,n,p,o=h.getContext("2d"),t=new THREE.Color(0),x=0,u=1,z=0,
+C=null,E=null,J=null,U=null,y=null,L,N,P,za,va=new THREE.RenderableVertex,ta=new THREE.RenderableVertex,e,fa,ea,Aa,Ha,Ia,ua,ca,sa,Ba,ja,$,pa=new THREE.Color,Fa=new THREE.Color,ka=new THREE.Color,oa=new THREE.Color,Ga=new THREE.Color,Ra,Za,Va,Sa,O,aa,qa,Da,ha,la,m=new THREE.Rectangle,B=new THREE.Rectangle,w=new THREE.Rectangle,v=!1,A=new THREE.Color,M=new THREE.Color,G=new THREE.Color,I=new THREE.Color,F=new THREE.Vector3,D,H,K,X,T,Ea,Ja=16;D=document.createElement("canvas");D.width=D.height=2;H=D.getContext("2d");
+H.fillStyle="rgba(0,0,0,1)";H.fillRect(0,0,2,2);K=H.getImageData(0,0,2,2);X=K.data;T=document.createElement("canvas");T.width=T.height=Ja;Ea=T.getContext("2d");Ea.translate(-Ja/2,-Ja/2);Ea.scale(Ja,Ja);Ja--;this.domElement=h;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(ra,ya){j=ra;k=ya;n=j/2;p=k/2;h.width=j;h.height=k;m.set(-n,-p,n,p);u=1;z=0;y=U=J=E=C=null};this.setClearColor=function(ra,ya){t=ra;x=ya};this.setClearColorHex=function(ra,ya){t.setHex(ra);x=ya};this.clear=
 function(){o.setTransform(1,0,0,-1,n,p);if(!B.isEmpty()){B.inflate(1);B.minSelf(m);if(t.hex==0&&x==0)o.clearRect(B.getX(),B.getY(),B.getWidth(),B.getHeight());else{d(THREE.NormalBlending);b(1);o.fillStyle="rgba("+Math.floor(t.r*255)+","+Math.floor(t.g*255)+","+Math.floor(t.b*255)+","+x+")";o.fillRect(B.getX(),B.getY(),B.getWidth(),B.getHeight())}B.empty()}};this.render=function(ra,ya){function bb(S){var ia,ma,W,xa=S.lights;M.setRGB(0,0,0);G.setRGB(0,0,0);I.setRGB(0,0,0);S=0;for(ia=xa.length;S<ia;S++){ma=
 xa[S];W=ma.color;if(ma instanceof THREE.AmbientLight){M.r+=W.r;M.g+=W.g;M.b+=W.b}else if(ma instanceof THREE.DirectionalLight){G.r+=W.r;G.g+=W.g;G.b+=W.b}else if(ma instanceof THREE.PointLight){I.r+=W.r;I.g+=W.g;I.b+=W.b}}}function Y(S,ia,ma,W){var xa,wa,ga,V,Ka=S.lights;S=0;for(xa=Ka.length;S<xa;S++){wa=Ka[S];ga=wa.color;if(wa instanceof THREE.DirectionalLight){V=ma.dot(wa.position);if(!(V<=0)){V*=wa.intensity;W.r+=ga.r*V;W.g+=ga.g*V;W.b+=ga.b*V}}else if(wa instanceof THREE.PointLight){V=ma.dot(F.sub(wa.position,
 ia).normalize());if(!(V<=0)){V*=wa.distance==0?1:1-Math.min(ia.distanceTo(wa.position)/wa.distance,1);if(V!=0){V*=wa.intensity;W.r+=ga.r*V;W.g+=ga.g*V;W.b+=ga.b*V}}}}}function da(S,ia,ma){b(ma.opacity);d(ma.blending);var W,xa,wa,ga,V,Ka;if(ma instanceof THREE.ParticleBasicMaterial){if(ma.map){ga=ma.map.image;V=ga.width>>1;Ka=ga.height>>1;ma=ia.scale.x*n;wa=ia.scale.y*p;W=ma*V;xa=wa*Ka;w.set(S.x-W,S.y-xa,S.x+W,S.y+xa);if(m.instersects(w)){o.save();o.translate(S.x,S.y);o.rotate(-ia.rotation);o.scale(ma,
@@ -167,17 +167,17 @@ ia).normalize());if(!(V<=0)){V*=wa.distance==0?1:1-Math.min(ia.distanceTo(wa.pos
 ia.positionScreen.y);o.closePath();if(W instanceof THREE.LineBasicMaterial){pa.__styleString=W.color.__styleString;S=W.linewidth;if(J!=S)o.lineWidth=J=S;S=W.linecap;if(U!=S)o.lineCap=U=S;S=W.linejoin;if(y!=S)o.lineJoin=y=S;c(pa.__styleString);o.stroke();w.inflate(W.linewidth*2)}}function La(S,ia,ma,W,xa,wa,ga,V,Ka){b(V.opacity);d(V.blending);e=S.positionScreen.x;fa=S.positionScreen.y;ea=ia.positionScreen.x;Aa=ia.positionScreen.y;Ha=ma.positionScreen.x;Ia=ma.positionScreen.y;Q(e,fa,ea,Aa,Ha,Ia);if(V instanceof
 THREE.MeshBasicMaterial)if(V.map){if(V.map.mapping instanceof THREE.UVMapping){Sa=ga.uvs[0];Oa(e,fa,ea,Aa,Ha,Ia,V.map.image,Sa[W].u,Sa[W].v,Sa[xa].u,Sa[xa].v,Sa[wa].u,Sa[wa].v)}}else if(V.envMap){if(V.envMap.mapping instanceof THREE.SphericalReflectionMapping){S=ya.matrixWorldInverse;F.copy(ga.vertexNormalsWorld[0]);O=(F.x*S.n11+F.y*S.n12+F.z*S.n13)*0.5+0.5;aa=-(F.x*S.n21+F.y*S.n22+F.z*S.n23)*0.5+0.5;F.copy(ga.vertexNormalsWorld[1]);qa=(F.x*S.n11+F.y*S.n12+F.z*S.n13)*0.5+0.5;Da=-(F.x*S.n21+F.y*S.n22+
 F.z*S.n23)*0.5+0.5;F.copy(ga.vertexNormalsWorld[2]);ha=(F.x*S.n11+F.y*S.n12+F.z*S.n13)*0.5+0.5;la=-(F.x*S.n21+F.y*S.n22+F.z*S.n23)*0.5+0.5;Oa(e,fa,ea,Aa,Ha,Ia,V.envMap.image,O,aa,qa,Da,ha,la)}}else V.wireframe?db(V.color.__styleString,V.wireframeLinewidth,V.wireframeLinecap,V.wireframeLinejoin):Na(V.color.__styleString);else if(V instanceof THREE.MeshLambertMaterial){if(V.map&&!V.wireframe){if(V.map.mapping instanceof THREE.UVMapping){Sa=ga.uvs[0];Oa(e,fa,ea,Aa,Ha,Ia,V.map.image,Sa[W].u,Sa[W].v,Sa[xa].u,
-Sa[xa].v,Sa[wa].u,Sa[wa].v)}d(THREE.SubtractiveBlending)}if(u)if(!V.wireframe&&V.shading==THREE.SmoothShading&&ga.vertexNormalsWorld.length==3){Fa.r=ka.r=oa.r=M.r;Fa.g=ka.g=oa.g=M.g;Fa.b=ka.b=oa.b=M.b;Y(Ka,ga.v1.positionWorld,ga.vertexNormalsWorld[0],Fa);Y(Ka,ga.v2.positionWorld,ga.vertexNormalsWorld[1],ka);Y(Ka,ga.v3.positionWorld,ga.vertexNormalsWorld[2],oa);Ga.r=(ka.r+oa.r)*0.5;Ga.g=(ka.g+oa.g)*0.5;Ga.b=(ka.b+oa.b)*0.5;Va=hb(Fa,ka,oa,Ga);Oa(e,fa,ea,Aa,Ha,Ia,Va,0,0,1,0,0,1)}else{A.r=M.r;A.g=M.g;
+Sa[xa].v,Sa[wa].u,Sa[wa].v)}d(THREE.SubtractiveBlending)}if(v)if(!V.wireframe&&V.shading==THREE.SmoothShading&&ga.vertexNormalsWorld.length==3){Fa.r=ka.r=oa.r=M.r;Fa.g=ka.g=oa.g=M.g;Fa.b=ka.b=oa.b=M.b;Y(Ka,ga.v1.positionWorld,ga.vertexNormalsWorld[0],Fa);Y(Ka,ga.v2.positionWorld,ga.vertexNormalsWorld[1],ka);Y(Ka,ga.v3.positionWorld,ga.vertexNormalsWorld[2],oa);Ga.r=(ka.r+oa.r)*0.5;Ga.g=(ka.g+oa.g)*0.5;Ga.b=(ka.b+oa.b)*0.5;Va=hb(Fa,ka,oa,Ga);Oa(e,fa,ea,Aa,Ha,Ia,Va,0,0,1,0,0,1)}else{A.r=M.r;A.g=M.g;
 A.b=M.b;Y(Ka,ga.centroidWorld,ga.normalWorld,A);pa.r=V.color.r*A.r;pa.g=V.color.g*A.g;pa.b=V.color.b*A.b;pa.updateStyleString();V.wireframe?db(pa.__styleString,V.wireframeLinewidth,V.wireframeLinecap,V.wireframeLinejoin):Na(pa.__styleString)}else V.wireframe?db(V.color.__styleString,V.wireframeLinewidth,V.wireframeLinecap,V.wireframeLinejoin):Na(V.color.__styleString)}else if(V instanceof THREE.MeshDepthMaterial){Ra=ya.near;Za=ya.far;Fa.r=Fa.g=Fa.b=1-eb(S.positionScreen.z,Ra,Za);ka.r=ka.g=ka.b=1-
 eb(ia.positionScreen.z,Ra,Za);oa.r=oa.g=oa.b=1-eb(ma.positionScreen.z,Ra,Za);Ga.r=(ka.r+oa.r)*0.5;Ga.g=(ka.g+oa.g)*0.5;Ga.b=(ka.b+oa.b)*0.5;Va=hb(Fa,ka,oa,Ga);Oa(e,fa,ea,Aa,Ha,Ia,Va,0,0,1,0,0,1)}else if(V instanceof THREE.MeshNormalMaterial){pa.r=$a(ga.normalWorld.x);pa.g=$a(ga.normalWorld.y);pa.b=$a(ga.normalWorld.z);pa.updateStyleString();V.wireframe?db(pa.__styleString,V.wireframeLinewidth,V.wireframeLinecap,V.wireframeLinejoin):Na(pa.__styleString)}}function Z(S,ia,ma,W,xa,wa,ga,V,Ka){b(V.opacity);
 d(V.blending);if(V.map||V.envMap){La(S,ia,W,0,1,3,ga,V,Ka);La(xa,ma,wa,1,2,3,ga,V,Ka)}else{e=S.positionScreen.x;fa=S.positionScreen.y;ea=ia.positionScreen.x;Aa=ia.positionScreen.y;Ha=ma.positionScreen.x;Ia=ma.positionScreen.y;ua=W.positionScreen.x;ca=W.positionScreen.y;sa=xa.positionScreen.x;Ba=xa.positionScreen.y;ja=wa.positionScreen.x;$=wa.positionScreen.y;if(V instanceof THREE.MeshBasicMaterial){Qa(e,fa,ea,Aa,Ha,Ia,ua,ca);V.wireframe?db(V.color.__styleString,V.wireframeLinewidth,V.wireframeLinecap,
-V.wireframeLinejoin):Na(V.color.__styleString)}else if(V instanceof THREE.MeshLambertMaterial)if(u)if(!V.wireframe&&V.shading==THREE.SmoothShading&&ga.vertexNormalsWorld.length==4){Fa.r=ka.r=oa.r=Ga.r=M.r;Fa.g=ka.g=oa.g=Ga.g=M.g;Fa.b=ka.b=oa.b=Ga.b=M.b;Y(Ka,ga.v1.positionWorld,ga.vertexNormalsWorld[0],Fa);Y(Ka,ga.v2.positionWorld,ga.vertexNormalsWorld[1],ka);Y(Ka,ga.v4.positionWorld,ga.vertexNormalsWorld[3],oa);Y(Ka,ga.v3.positionWorld,ga.vertexNormalsWorld[2],Ga);Va=hb(Fa,ka,oa,Ga);Q(e,fa,ea,Aa,
+V.wireframeLinejoin):Na(V.color.__styleString)}else if(V instanceof THREE.MeshLambertMaterial)if(v)if(!V.wireframe&&V.shading==THREE.SmoothShading&&ga.vertexNormalsWorld.length==4){Fa.r=ka.r=oa.r=Ga.r=M.r;Fa.g=ka.g=oa.g=Ga.g=M.g;Fa.b=ka.b=oa.b=Ga.b=M.b;Y(Ka,ga.v1.positionWorld,ga.vertexNormalsWorld[0],Fa);Y(Ka,ga.v2.positionWorld,ga.vertexNormalsWorld[1],ka);Y(Ka,ga.v4.positionWorld,ga.vertexNormalsWorld[3],oa);Y(Ka,ga.v3.positionWorld,ga.vertexNormalsWorld[2],Ga);Va=hb(Fa,ka,oa,Ga);Q(e,fa,ea,Aa,
 ua,ca);Oa(e,fa,ea,Aa,ua,ca,Va,0,0,1,0,0,1);Q(sa,Ba,Ha,Ia,ja,$);Oa(sa,Ba,Ha,Ia,ja,$,Va,1,0,1,1,0,1)}else{A.r=M.r;A.g=M.g;A.b=M.b;Y(Ka,ga.centroidWorld,ga.normalWorld,A);pa.r=V.color.r*A.r;pa.g=V.color.g*A.g;pa.b=V.color.b*A.b;pa.updateStyleString();Qa(e,fa,ea,Aa,Ha,Ia,ua,ca);V.wireframe?db(pa.__styleString,V.wireframeLinewidth,V.wireframeLinecap,V.wireframeLinejoin):Na(pa.__styleString)}else{Qa(e,fa,ea,Aa,Ha,Ia,ua,ca);V.wireframe?db(V.color.__styleString,V.wireframeLinewidth,V.wireframeLinecap,V.wireframeLinejoin):
 Na(V.color.__styleString)}else if(V instanceof THREE.MeshNormalMaterial){pa.r=$a(ga.normalWorld.x);pa.g=$a(ga.normalWorld.y);pa.b=$a(ga.normalWorld.z);pa.updateStyleString();Qa(e,fa,ea,Aa,Ha,Ia,ua,ca);V.wireframe?db(pa.__styleString,V.wireframeLinewidth,V.wireframeLinecap,V.wireframeLinejoin):Na(pa.__styleString)}else if(V instanceof THREE.MeshDepthMaterial){Ra=ya.near;Za=ya.far;Fa.r=Fa.g=Fa.b=1-eb(S.positionScreen.z,Ra,Za);ka.r=ka.g=ka.b=1-eb(ia.positionScreen.z,Ra,Za);oa.r=oa.g=oa.b=1-eb(W.positionScreen.z,
 Ra,Za);Ga.r=Ga.g=Ga.b=1-eb(ma.positionScreen.z,Ra,Za);Va=hb(Fa,ka,oa,Ga);Q(e,fa,ea,Aa,ua,ca);Oa(e,fa,ea,Aa,ua,ca,Va,0,0,1,0,0,1);Q(sa,Ba,Ha,Ia,ja,$);Oa(sa,Ba,Ha,Ia,ja,$,Va,1,0,1,1,0,1)}}}function Q(S,ia,ma,W,xa,wa){o.beginPath();o.moveTo(S,ia);o.lineTo(ma,W);o.lineTo(xa,wa);o.lineTo(S,ia);o.closePath()}function Qa(S,ia,ma,W,xa,wa,ga,V){o.beginPath();o.moveTo(S,ia);o.lineTo(ma,W);o.lineTo(xa,wa);o.lineTo(ga,V);o.lineTo(S,ia);o.closePath()}function db(S,ia,ma,W){if(J!=ia)o.lineWidth=J=ia;if(U!=ma)o.lineCap=
 U=ma;if(y!=W)o.lineJoin=y=W;c(S);o.stroke();w.inflate(ia*2)}function Na(S){if(E!=S)o.fillStyle=E=S;o.fill()}function Oa(S,ia,ma,W,xa,wa,ga,V,Ka,Wa,Ua,ib,Xa){var fb,gb;fb=ga.width-1;gb=ga.height-1;V*=fb;Ka*=gb;Wa*=fb;Ua*=gb;ib*=fb;Xa*=gb;ma-=S;W-=ia;xa-=S;wa-=ia;Wa-=V;Ua-=Ka;ib-=V;Xa-=Ka;fb=Wa*Xa-ib*Ua;if(fb!=0){gb=1/fb;fb=(Xa*ma-Ua*xa)*gb;Ua=(Xa*W-Ua*wa)*gb;ma=(Wa*xa-ib*ma)*gb;W=(Wa*wa-ib*W)*gb;S=S-fb*V-ma*Ka;ia=ia-Ua*V-W*Ka;o.save();o.transform(fb,Ua,ma,W,S,ia);o.clip();o.drawImage(ga,0,0);o.restore()}}
 function hb(S,ia,ma,W){var xa=~~(S.r*255),wa=~~(S.g*255);S=~~(S.b*255);var ga=~~(ia.r*255),V=~~(ia.g*255);ia=~~(ia.b*255);var Ka=~~(ma.r*255),Wa=~~(ma.g*255);ma=~~(ma.b*255);var Ua=~~(W.r*255),ib=~~(W.g*255);W=~~(W.b*255);X[0]=xa<0?0:xa>255?255:xa;X[1]=wa<0?0:wa>255?255:wa;X[2]=S<0?0:S>255?255:S;X[4]=ga<0?0:ga>255?255:ga;X[5]=V<0?0:V>255?255:V;X[6]=ia<0?0:ia>255?255:ia;X[8]=Ka<0?0:Ka>255?255:Ka;X[9]=Wa<0?0:Wa>255?255:Wa;X[10]=ma<0?0:ma>255?255:ma;X[12]=Ua<0?0:Ua>255?255:Ua;X[13]=ib<0?0:ib>255?255:
-ib;X[14]=W<0?0:W>255?255:W;H.putImageData(K,0,0);Ea.drawImage(D,0,0);return T}function eb(S,ia,ma){S=(S-ia)/(ma-ia);return S*S*(3-2*S)}function $a(S){S=(S+1)*0.5;return S<0?0:S>1?1:S}function ab(S,ia){var ma=ia.x-S.x,W=ia.y-S.y,xa=1/Math.sqrt(ma*ma+W*W);ma*=xa;W*=xa;ia.x+=ma;ia.y+=W;S.x-=ma;S.y-=W}var Ma,cb,Ca,R,Pa,Ta,jb,Ya;this.autoClear?this.clear():o.setTransform(1,0,0,-1,n,p);f=g.projectScene(ra,ya,this.sortElements);(u=ra.lights.length>0)&&bb(ra);Ma=0;for(cb=f.length;Ma<cb;Ma++){Ca=f[Ma];w.empty();
+ib;X[14]=W<0?0:W>255?255:W;H.putImageData(K,0,0);Ea.drawImage(D,0,0);return T}function eb(S,ia,ma){S=(S-ia)/(ma-ia);return S*S*(3-2*S)}function $a(S){S=(S+1)*0.5;return S<0?0:S>1?1:S}function ab(S,ia){var ma=ia.x-S.x,W=ia.y-S.y,xa=1/Math.sqrt(ma*ma+W*W);ma*=xa;W*=xa;ia.x+=ma;ia.y+=W;S.x-=ma;S.y-=W}var Ma,cb,Ca,R,Pa,Ta,jb,Ya;this.autoClear?this.clear():o.setTransform(1,0,0,-1,n,p);f=g.projectScene(ra,ya,this.sortElements);(v=ra.lights.length>0)&&bb(ra);Ma=0;for(cb=f.length;Ma<cb;Ma++){Ca=f[Ma];w.empty();
 if(Ca instanceof THREE.RenderableParticle){L=Ca;L.x*=n;L.y*=p;R=0;for(Pa=Ca.materials.length;R<Pa;){Ya=Ca.materials[R++];Ya.opacity!=0&&da(L,Ca,Ya,ra)}}else if(Ca instanceof THREE.RenderableLine){L=Ca.v1;N=Ca.v2;L.positionScreen.x*=n;L.positionScreen.y*=p;N.positionScreen.x*=n;N.positionScreen.y*=p;w.addPoint(L.positionScreen.x,L.positionScreen.y);w.addPoint(N.positionScreen.x,N.positionScreen.y);if(m.instersects(w)){R=0;for(Pa=Ca.materials.length;R<Pa;){Ya=Ca.materials[R++];Ya.opacity!=0&&na(L,N,
 Ca,Ya,ra)}}}else if(Ca instanceof THREE.RenderableFace3){L=Ca.v1;N=Ca.v2;P=Ca.v3;L.positionScreen.x*=n;L.positionScreen.y*=p;N.positionScreen.x*=n;N.positionScreen.y*=p;P.positionScreen.x*=n;P.positionScreen.y*=p;if(Ca.overdraw){ab(L.positionScreen,N.positionScreen);ab(N.positionScreen,P.positionScreen);ab(P.positionScreen,L.positionScreen)}w.add3Points(L.positionScreen.x,L.positionScreen.y,N.positionScreen.x,N.positionScreen.y,P.positionScreen.x,P.positionScreen.y);if(m.instersects(w)){R=0;for(Pa=
 Ca.meshMaterials.length;R<Pa;){Ya=Ca.meshMaterials[R++];if(Ya instanceof THREE.MeshFaceMaterial){Ta=0;for(jb=Ca.faceMaterials.length;Ta<jb;)(Ya=Ca.faceMaterials[Ta++])&&Ya.opacity!=0&&La(L,N,P,0,1,2,Ca,Ya,ra)}else Ya.opacity!=0&&La(L,N,P,0,1,2,Ca,Ya,ra)}}}else if(Ca instanceof THREE.RenderableFace4){L=Ca.v1;N=Ca.v2;P=Ca.v3;za=Ca.v4;L.positionScreen.x*=n;L.positionScreen.y*=p;N.positionScreen.x*=n;N.positionScreen.y*=p;P.positionScreen.x*=n;P.positionScreen.y*=p;za.positionScreen.x*=n;za.positionScreen.y*=
@@ -188,15 +188,15 @@ f(Aa++);ea.setAttribute("d","M "+ua.positionScreen.x+" "+ua.positionScreen.y+" L
 1-ja.__2near/(ja.__farPlusNear-Ba.z*ja.__farMinusNear);y.setRGB(va,va,va)}else ja instanceof THREE.MeshNormalMaterial&&y.setRGB(g(Ba.normalWorld.x),g(Ba.normalWorld.y),g(Ba.normalWorld.z));ja.wireframe?ea.setAttribute("style","fill: none; stroke: "+y.__styleString+"; stroke-width: "+ja.wireframeLinewidth+"; stroke-opacity: "+ja.opacity+"; stroke-linecap: "+ja.wireframeLinecap+"; stroke-linejoin: "+ja.wireframeLinejoin):ea.setAttribute("style","fill: "+y.__styleString+"; fill-opacity: "+ja.opacity);
 k.appendChild(ea)}function c(ua,ca,sa,Ba,ja,$,pa){ea=f(Aa++);ea.setAttribute("d","M "+ua.positionScreen.x+" "+ua.positionScreen.y+" L "+ca.positionScreen.x+" "+ca.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+" L "+Ba.positionScreen.x+","+Ba.positionScreen.y+"z");if($ instanceof THREE.MeshBasicMaterial)y.__styleString=$.color.__styleString;else if($ instanceof THREE.MeshLambertMaterial)if(U){L.r=N.r;L.g=N.g;L.b=N.b;b(pa,ja,L);y.r=$.color.r*L.r;y.g=$.color.g*L.g;y.b=$.color.b*
 L.b;y.updateStyleString()}else y.__styleString=$.color.__styleString;else if($ instanceof THREE.MeshDepthMaterial){va=1-$.__2near/($.__farPlusNear-ja.z*$.__farMinusNear);y.setRGB(va,va,va)}else $ instanceof THREE.MeshNormalMaterial&&y.setRGB(g(ja.normalWorld.x),g(ja.normalWorld.y),g(ja.normalWorld.z));$.wireframe?ea.setAttribute("style","fill: none; stroke: "+y.__styleString+"; stroke-width: "+$.wireframeLinewidth+"; stroke-opacity: "+$.opacity+"; stroke-linecap: "+$.wireframeLinecap+"; stroke-linejoin: "+
-$.wireframeLinejoin):ea.setAttribute("style","fill: "+y.__styleString+"; fill-opacity: "+$.opacity);k.appendChild(ea)}function f(ua){if(e[ua]==null){e[ua]=document.createElementNS("http://www.w3.org/2000/svg","path");Ia==0&&e[ua].setAttribute("shape-rendering","crispEdges")}return e[ua]}function g(ua){return ua<0?Math.min((1+ua)*0.5,0.5):0.5+Math.min(ua*0.5,0.5)}var h=null,j=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,p,o,t,x,v,z,C,E=new THREE.Rectangle,J=
+$.wireframeLinejoin):ea.setAttribute("style","fill: "+y.__styleString+"; fill-opacity: "+$.opacity);k.appendChild(ea)}function f(ua){if(e[ua]==null){e[ua]=document.createElementNS("http://www.w3.org/2000/svg","path");Ia==0&&e[ua].setAttribute("shape-rendering","crispEdges")}return e[ua]}function g(ua){return ua<0?Math.min((1+ua)*0.5,0.5):0.5+Math.min(ua*0.5,0.5)}var h=null,j=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,p,o,t,x,u,z,C,E=new THREE.Rectangle,J=
 new THREE.Rectangle,U=!1,y=new THREE.Color(16777215),L=new THREE.Color(16777215),N=new THREE.Color(0),P=new THREE.Color(0),za=new THREE.Color(0),va,ta=new THREE.Vector3,e=[],fa=[],ea,Aa,Ha,Ia=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ua){switch(ua){case "high":Ia=1;break;case "low":Ia=0}};this.setSize=function(ua,ca){n=ua;p=ca;o=n/2;t=p/2;k.setAttribute("viewBox",-o+" "+-t+" "+n+" "+p);k.setAttribute("width",n);k.setAttribute("height",
 p);E.set(-o,-t,o,t)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(ua,ca){var sa,Ba,ja,$,pa,Fa,ka,oa;this.autoClear&&this.clear();h=j.projectScene(ua,ca,this.sortElements);Ha=Aa=0;if(U=ua.lights.length>0){ka=ua.lights;N.setRGB(0,0,0);P.setRGB(0,0,0);za.setRGB(0,0,0);sa=0;for(Ba=ka.length;sa<Ba;sa++){ja=ka[sa];$=ja.color;if(ja instanceof THREE.AmbientLight){N.r+=$.r;N.g+=$.g;N.b+=$.b}else if(ja instanceof THREE.DirectionalLight){P.r+=$.r;P.g+=
-$.g;P.b+=$.b}else if(ja instanceof THREE.PointLight){za.r+=$.r;za.g+=$.g;za.b+=$.b}}}sa=0;for(Ba=h.length;sa<Ba;sa++){ka=h[sa];J.empty();if(ka instanceof THREE.RenderableParticle){x=ka;x.x*=o;x.y*=-t;ja=0;for($=ka.materials.length;ja<$;)ja++}else if(ka instanceof THREE.RenderableLine){x=ka.v1;v=ka.v2;x.positionScreen.x*=o;x.positionScreen.y*=-t;v.positionScreen.x*=o;v.positionScreen.y*=-t;J.addPoint(x.positionScreen.x,x.positionScreen.y);J.addPoint(v.positionScreen.x,v.positionScreen.y);if(E.instersects(J)){ja=
-0;for($=ka.materials.length;ja<$;)if((oa=ka.materials[ja++])&&oa.opacity!=0){pa=x;Fa=v;var Ga=Ha++;if(fa[Ga]==null){fa[Ga]=document.createElementNS("http://www.w3.org/2000/svg","line");Ia==0&&fa[Ga].setAttribute("shape-rendering","crispEdges")}ea=fa[Ga];ea.setAttribute("x1",pa.positionScreen.x);ea.setAttribute("y1",pa.positionScreen.y);ea.setAttribute("x2",Fa.positionScreen.x);ea.setAttribute("y2",Fa.positionScreen.y);if(oa instanceof THREE.LineBasicMaterial){y.__styleString=oa.color.__styleString;
-ea.setAttribute("style","fill: none; stroke: "+y.__styleString+"; stroke-width: "+oa.linewidth+"; stroke-opacity: "+oa.opacity+"; stroke-linecap: "+oa.linecap+"; stroke-linejoin: "+oa.linejoin);k.appendChild(ea)}}}}else if(ka instanceof THREE.RenderableFace3){x=ka.v1;v=ka.v2;z=ka.v3;x.positionScreen.x*=o;x.positionScreen.y*=-t;v.positionScreen.x*=o;v.positionScreen.y*=-t;z.positionScreen.x*=o;z.positionScreen.y*=-t;J.addPoint(x.positionScreen.x,x.positionScreen.y);J.addPoint(v.positionScreen.x,v.positionScreen.y);
-J.addPoint(z.positionScreen.x,z.positionScreen.y);if(E.instersects(J)){ja=0;for($=ka.meshMaterials.length;ja<$;){oa=ka.meshMaterials[ja++];if(oa instanceof THREE.MeshFaceMaterial){pa=0;for(Fa=ka.faceMaterials.length;pa<Fa;)(oa=ka.faceMaterials[pa++])&&oa.opacity!=0&&d(x,v,z,ka,oa,ua)}else oa&&oa.opacity!=0&&d(x,v,z,ka,oa,ua)}}}else if(ka instanceof THREE.RenderableFace4){x=ka.v1;v=ka.v2;z=ka.v3;C=ka.v4;x.positionScreen.x*=o;x.positionScreen.y*=-t;v.positionScreen.x*=o;v.positionScreen.y*=-t;z.positionScreen.x*=
-o;z.positionScreen.y*=-t;C.positionScreen.x*=o;C.positionScreen.y*=-t;J.addPoint(x.positionScreen.x,x.positionScreen.y);J.addPoint(v.positionScreen.x,v.positionScreen.y);J.addPoint(z.positionScreen.x,z.positionScreen.y);J.addPoint(C.positionScreen.x,C.positionScreen.y);if(E.instersects(J)){ja=0;for($=ka.meshMaterials.length;ja<$;){oa=ka.meshMaterials[ja++];if(oa instanceof THREE.MeshFaceMaterial){pa=0;for(Fa=ka.faceMaterials.length;pa<Fa;)(oa=ka.faceMaterials[pa++])&&oa.opacity!=0&&c(x,v,z,C,ka,oa,
-ua)}else oa&&oa.opacity!=0&&c(x,v,z,C,ka,oa,ua)}}}}}};
+$.g;P.b+=$.b}else if(ja instanceof THREE.PointLight){za.r+=$.r;za.g+=$.g;za.b+=$.b}}}sa=0;for(Ba=h.length;sa<Ba;sa++){ka=h[sa];J.empty();if(ka instanceof THREE.RenderableParticle){x=ka;x.x*=o;x.y*=-t;ja=0;for($=ka.materials.length;ja<$;)ja++}else if(ka instanceof THREE.RenderableLine){x=ka.v1;u=ka.v2;x.positionScreen.x*=o;x.positionScreen.y*=-t;u.positionScreen.x*=o;u.positionScreen.y*=-t;J.addPoint(x.positionScreen.x,x.positionScreen.y);J.addPoint(u.positionScreen.x,u.positionScreen.y);if(E.instersects(J)){ja=
+0;for($=ka.materials.length;ja<$;)if((oa=ka.materials[ja++])&&oa.opacity!=0){pa=x;Fa=u;var Ga=Ha++;if(fa[Ga]==null){fa[Ga]=document.createElementNS("http://www.w3.org/2000/svg","line");Ia==0&&fa[Ga].setAttribute("shape-rendering","crispEdges")}ea=fa[Ga];ea.setAttribute("x1",pa.positionScreen.x);ea.setAttribute("y1",pa.positionScreen.y);ea.setAttribute("x2",Fa.positionScreen.x);ea.setAttribute("y2",Fa.positionScreen.y);if(oa instanceof THREE.LineBasicMaterial){y.__styleString=oa.color.__styleString;
+ea.setAttribute("style","fill: none; stroke: "+y.__styleString+"; stroke-width: "+oa.linewidth+"; stroke-opacity: "+oa.opacity+"; stroke-linecap: "+oa.linecap+"; stroke-linejoin: "+oa.linejoin);k.appendChild(ea)}}}}else if(ka instanceof THREE.RenderableFace3){x=ka.v1;u=ka.v2;z=ka.v3;x.positionScreen.x*=o;x.positionScreen.y*=-t;u.positionScreen.x*=o;u.positionScreen.y*=-t;z.positionScreen.x*=o;z.positionScreen.y*=-t;J.addPoint(x.positionScreen.x,x.positionScreen.y);J.addPoint(u.positionScreen.x,u.positionScreen.y);
+J.addPoint(z.positionScreen.x,z.positionScreen.y);if(E.instersects(J)){ja=0;for($=ka.meshMaterials.length;ja<$;){oa=ka.meshMaterials[ja++];if(oa instanceof THREE.MeshFaceMaterial){pa=0;for(Fa=ka.faceMaterials.length;pa<Fa;)(oa=ka.faceMaterials[pa++])&&oa.opacity!=0&&d(x,u,z,ka,oa,ua)}else oa&&oa.opacity!=0&&d(x,u,z,ka,oa,ua)}}}else if(ka instanceof THREE.RenderableFace4){x=ka.v1;u=ka.v2;z=ka.v3;C=ka.v4;x.positionScreen.x*=o;x.positionScreen.y*=-t;u.positionScreen.x*=o;u.positionScreen.y*=-t;z.positionScreen.x*=
+o;z.positionScreen.y*=-t;C.positionScreen.x*=o;C.positionScreen.y*=-t;J.addPoint(x.positionScreen.x,x.positionScreen.y);J.addPoint(u.positionScreen.x,u.positionScreen.y);J.addPoint(z.positionScreen.x,z.positionScreen.y);J.addPoint(C.positionScreen.x,C.positionScreen.y);if(E.instersects(J)){ja=0;for($=ka.meshMaterials.length;ja<$;){oa=ka.meshMaterials[ja++];if(oa instanceof THREE.MeshFaceMaterial){pa=0;for(Fa=ka.faceMaterials.length;pa<Fa;)(oa=ka.faceMaterials[pa++])&&oa.opacity!=0&&c(x,u,z,C,ka,oa,
+ua)}else oa&&oa.opacity!=0&&c(x,u,z,C,ka,oa,ua)}}}}}};
 THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
@@ -222,41 +222,41 @@ THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.
 vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
 THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",
 THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
-THREE.WebGLRenderer=function(b){function d(m,B,w){var u,A,M,G=m.vertices,I=G.length,F=m.colors,D=F.length,H=m.__vertexArray,K=m.__colorArray,X=m.__sortArray,T=m.__dirtyVertices,Ea=m.__dirtyColors;if(w.sortParticles){Ga.multiplySelf(w.matrixWorld);for(u=0;u<I;u++){A=G[u].position;Va.copy(A);Ga.multiplyVector3(Va);X[u]=[Va.z,u]}X.sort(function(Ja,ra){return ra[0]-Ja[0]});for(u=0;u<I;u++){A=G[X[u][1]].position;M=u*3;H[M]=A.x;H[M+1]=A.y;H[M+2]=A.z}for(u=0;u<D;u++){M=u*3;color=F[X[u][1]];K[M]=color.r;
-K[M+1]=color.g;K[M+2]=color.b}}else{if(T)for(u=0;u<I;u++){A=G[u].position;M=u*3;H[M]=A.x;H[M+1]=A.y;H[M+2]=A.z}if(Ea)for(u=0;u<D;u++){color=F[u];M=u*3;K[M]=color.r;K[M+1]=color.g;K[M+2]=color.b}}if(T||w.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,H,B)}if(Ea||w.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,K,B)}}function c(m,B,w,u,A){u.program||ua.initMaterial(u,B,w,A);var M=u.program,G=M.uniforms,I=u.uniforms;
-if(M!=Aa){e.useProgram(M);Aa=M}e.uniformMatrix4fv(G.projectionMatrix,!1,Ra);if(w&&(u instanceof THREE.MeshBasicMaterial||u instanceof THREE.MeshLambertMaterial||u instanceof THREE.MeshPhongMaterial||u instanceof THREE.LineBasicMaterial||u instanceof THREE.ParticleBasicMaterial||u.fog)){I.fogColor.value.setHex(w.color.hex);if(w instanceof THREE.Fog){I.fogNear.value=w.near;I.fogFar.value=w.far}else if(w instanceof THREE.FogExp2)I.fogDensity.value=w.density}if(u instanceof THREE.MeshPhongMaterial||u instanceof
-THREE.MeshLambertMaterial||u.lights){var F,D,H=0,K=0,X=0,T,Ea,Ja,ra,ya=Sa,bb=ya.directional.colors,Y=ya.directional.positions,da=ya.point.colors,na=ya.point.positions,La=ya.point.distances,Z=0,Q=0;w=D=ra=0;for(F=B.length;w<F;w++){D=B[w];T=D.color;Ea=D.position;Ja=D.intensity;ra=D.distance;if(D instanceof THREE.AmbientLight){H+=T.r;K+=T.g;X+=T.b}else if(D instanceof THREE.DirectionalLight){ra=Z*3;bb[ra]=T.r*Ja;bb[ra+1]=T.g*Ja;bb[ra+2]=T.b*Ja;Y[ra]=Ea.x;Y[ra+1]=Ea.y;Y[ra+2]=Ea.z;Z+=1}else if(D instanceof
+THREE.WebGLRenderer=function(b){function d(m,B,w){var v,A,M,G=m.vertices,I=G.length,F=m.colors,D=F.length,H=m.__vertexArray,K=m.__colorArray,X=m.__sortArray,T=m.__dirtyVertices,Ea=m.__dirtyColors;if(w.sortParticles){Ga.multiplySelf(w.matrixWorld);for(v=0;v<I;v++){A=G[v].position;Va.copy(A);Ga.multiplyVector3(Va);X[v]=[Va.z,v]}X.sort(function(Ja,ra){return ra[0]-Ja[0]});for(v=0;v<I;v++){A=G[X[v][1]].position;M=v*3;H[M]=A.x;H[M+1]=A.y;H[M+2]=A.z}for(v=0;v<D;v++){M=v*3;color=F[X[v][1]];K[M]=color.r;
+K[M+1]=color.g;K[M+2]=color.b}}else{if(T)for(v=0;v<I;v++){A=G[v].position;M=v*3;H[M]=A.x;H[M+1]=A.y;H[M+2]=A.z}if(Ea)for(v=0;v<D;v++){color=F[v];M=v*3;K[M]=color.r;K[M+1]=color.g;K[M+2]=color.b}}if(T||w.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,H,B)}if(Ea||w.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,K,B)}}function c(m,B,w,v,A){v.program||ua.initMaterial(v,B,w,A);var M=v.program,G=M.uniforms,I=v.uniforms;
+if(M!=Aa){e.useProgram(M);Aa=M}e.uniformMatrix4fv(G.projectionMatrix,!1,Ra);if(w&&(v instanceof THREE.MeshBasicMaterial||v instanceof THREE.MeshLambertMaterial||v instanceof THREE.MeshPhongMaterial||v instanceof THREE.LineBasicMaterial||v instanceof THREE.ParticleBasicMaterial||v.fog)){I.fogColor.value.setHex(w.color.hex);if(w instanceof THREE.Fog){I.fogNear.value=w.near;I.fogFar.value=w.far}else if(w instanceof THREE.FogExp2)I.fogDensity.value=w.density}if(v instanceof THREE.MeshPhongMaterial||v instanceof
+THREE.MeshLambertMaterial||v.lights){var F,D,H=0,K=0,X=0,T,Ea,Ja,ra,ya=Sa,bb=ya.directional.colors,Y=ya.directional.positions,da=ya.point.colors,na=ya.point.positions,La=ya.point.distances,Z=0,Q=0;w=D=ra=0;for(F=B.length;w<F;w++){D=B[w];T=D.color;Ea=D.position;Ja=D.intensity;ra=D.distance;if(D instanceof THREE.AmbientLight){H+=T.r;K+=T.g;X+=T.b}else if(D instanceof THREE.DirectionalLight){ra=Z*3;bb[ra]=T.r*Ja;bb[ra+1]=T.g*Ja;bb[ra+2]=T.b*Ja;Y[ra]=Ea.x;Y[ra+1]=Ea.y;Y[ra+2]=Ea.z;Z+=1}else if(D instanceof
 THREE.PointLight){D=Q*3;da[D]=T.r*Ja;da[D+1]=T.g*Ja;da[D+2]=T.b*Ja;na[D]=Ea.x;na[D+1]=Ea.y;na[D+2]=Ea.z;La[Q]=ra;Q+=1}}for(w=Z*3;w<bb.length;w++)bb[w]=0;for(w=Q*3;w<da.length;w++)da[w]=0;ya.point.length=Q;ya.directional.length=Z;ya.ambient[0]=H;ya.ambient[1]=K;ya.ambient[2]=X;w=Sa;I.enableLighting.value=w.directional.length+w.point.length;I.ambientLightColor.value=w.ambient;I.directionalLightColor.value=w.directional.colors;I.directionalLightDirection.value=w.directional.positions;I.pointLightColor.value=
-w.point.colors;I.pointLightPosition.value=w.point.positions;I.pointLightDistance.value=w.point.distances}if(u instanceof THREE.MeshBasicMaterial||u instanceof THREE.MeshLambertMaterial||u instanceof THREE.MeshPhongMaterial){I.diffuse.value.setRGB(u.color.r,u.color.g,u.color.b);I.opacity.value=u.opacity;I.map.texture=u.map;I.lightMap.texture=u.lightMap;I.envMap.texture=u.envMap;I.reflectivity.value=u.reflectivity;I.refractionRatio.value=u.refractionRatio;I.combine.value=u.combine;I.useRefract.value=
-u.envMap&&u.envMap.mapping instanceof THREE.CubeRefractionMapping}if(u instanceof THREE.LineBasicMaterial){I.diffuse.value.setRGB(u.color.r,u.color.g,u.color.b);I.opacity.value=u.opacity}else if(u instanceof THREE.ParticleBasicMaterial){I.psColor.value.setRGB(u.color.r,u.color.g,u.color.b);I.opacity.value=u.opacity;I.size.value=u.size;I.scale.value=fa.height/2;I.map.texture=u.map}else if(u instanceof THREE.MeshPhongMaterial){I.ambient.value.setRGB(u.ambient.r,u.ambient.g,u.ambient.b);I.specular.value.setRGB(u.specular.r,
-u.specular.g,u.specular.b);I.shininess.value=u.shininess}else if(u instanceof THREE.MeshDepthMaterial){I.mNear.value=m.near;I.mFar.value=m.far;I.opacity.value=u.opacity}else if(u instanceof THREE.MeshNormalMaterial)I.opacity.value=u.opacity;for(var Qa in I)if(K=M.uniforms[Qa]){F=I[Qa];H=F.type;w=F.value;if(H=="i")e.uniform1i(K,w);else if(H=="f")e.uniform1f(K,w);else if(H=="fv1")e.uniform1fv(K,w);else if(H=="fv")e.uniform3fv(K,w);else if(H=="v2")e.uniform2f(K,w.x,w.y);else if(H=="v3")e.uniform3f(K,
+w.point.colors;I.pointLightPosition.value=w.point.positions;I.pointLightDistance.value=w.point.distances}if(v instanceof THREE.MeshBasicMaterial||v instanceof THREE.MeshLambertMaterial||v instanceof THREE.MeshPhongMaterial){I.diffuse.value.setRGB(v.color.r,v.color.g,v.color.b);I.opacity.value=v.opacity;I.map.texture=v.map;I.lightMap.texture=v.lightMap;I.envMap.texture=v.envMap;I.reflectivity.value=v.reflectivity;I.refractionRatio.value=v.refractionRatio;I.combine.value=v.combine;I.useRefract.value=
+v.envMap&&v.envMap.mapping instanceof THREE.CubeRefractionMapping}if(v instanceof THREE.LineBasicMaterial){I.diffuse.value.setRGB(v.color.r,v.color.g,v.color.b);I.opacity.value=v.opacity}else if(v instanceof THREE.ParticleBasicMaterial){I.psColor.value.setRGB(v.color.r,v.color.g,v.color.b);I.opacity.value=v.opacity;I.size.value=v.size;I.scale.value=fa.height/2;I.map.texture=v.map}else if(v instanceof THREE.MeshPhongMaterial){I.ambient.value.setRGB(v.ambient.r,v.ambient.g,v.ambient.b);I.specular.value.setRGB(v.specular.r,
+v.specular.g,v.specular.b);I.shininess.value=v.shininess}else if(v instanceof THREE.MeshDepthMaterial){I.mNear.value=m.near;I.mFar.value=m.far;I.opacity.value=v.opacity}else if(v instanceof THREE.MeshNormalMaterial)I.opacity.value=v.opacity;for(var Qa in I)if(K=M.uniforms[Qa]){F=I[Qa];H=F.type;w=F.value;if(H=="i")e.uniform1i(K,w);else if(H=="f")e.uniform1f(K,w);else if(H=="fv1")e.uniform1fv(K,w);else if(H=="fv")e.uniform3fv(K,w);else if(H=="v2")e.uniform2f(K,w.x,w.y);else if(H=="v3")e.uniform3f(K,
 w.x,w.y,w.z);else if(H=="v4")e.uniform4f(K,w.x,w.y,w.z,w.w);else if(H=="c")e.uniform3f(K,w.r,w.g,w.b);else if(H=="t"){e.uniform1i(K,w);if(F=F.texture)if(F.image instanceof Array&&F.image.length==6){if(F.image.length==6){if(F.needsUpdate){if(F.__webglInit){e.bindTexture(e.TEXTURE_CUBE_MAP,F.image.__webglTextureCube);for(H=0;H<6;++H)e.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+H,0,0,0,e.RGBA,e.UNSIGNED_BYTE,F.image[H])}else{F.image.__webglTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,
-F.image.__webglTextureCube);for(H=0;H<6;++H)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+H,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,F.image[H]);F.__webglInit=!0}L(e.TEXTURE_CUBE_MAP,F,F.image[0]);e.bindTexture(e.TEXTURE_CUBE_MAP,null);F.needsUpdate=!1}e.activeTexture(e.TEXTURE0+w);e.bindTexture(e.TEXTURE_CUBE_MAP,F.image.__webglTextureCube)}}else N(F,w)}}e.uniformMatrix4fv(G.modelViewMatrix,!1,A._modelViewMatrixArray);e.uniformMatrix3fv(G.normalMatrix,!1,A._normalMatrixArray);(u instanceof THREE.MeshShaderMaterial||
-u instanceof THREE.MeshPhongMaterial||u.envMap)&&e.uniform3f(G.cameraPosition,m.position.x,m.position.y,m.position.z);(u instanceof THREE.MeshShaderMaterial||u.envMap||u.skinning)&&e.uniformMatrix4fv(G.objectMatrix,!1,A._objectMatrixArray);(u instanceof THREE.MeshPhongMaterial||u instanceof THREE.MeshLambertMaterial||u instanceof THREE.MeshShaderMaterial||u.skinning)&&e.uniformMatrix4fv(G.viewMatrix,!1,Za);if(u instanceof THREE.ShadowVolumeDynamicMaterial){m=I.directionalLightDirection.value;m[0]=
--B.position.x;m[1]=-B.position.y;m[2]=-B.position.z;e.uniform3fv(G.directionalLightDirection,m);e.uniformMatrix4fv(G.objectMatrix,!1,A._objectMatrixArray);e.uniformMatrix4fv(G.viewMatrix,!1,Za)}if(u.skinning){e.uniformMatrix4fv(G.cameraInverseMatrix,!1,Za);e.uniformMatrix4fv(G.boneGlobalMatrices,!1,A.boneMatrices)}return M}function f(m,B,w,u,A,M){if(u.opacity!=0){var G;m=c(m,B,w,u,M).attributes;if(u.morphTargets){B=u.program.attributes;M.morphTargetBase!==-1?e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[M.morphTargetBase]):
-e.bindBuffer(e.ARRAY_BUFFER,A.__webglVertexBuffer);e.vertexAttribPointer(B.position,3,e.FLOAT,!1,0,0);if(M.morphTargetForcedOrder.length){w=0;for(var I=M.morphTargetForcedOrder,F=M.morphTargetInfluences;w<u.numSupportedMorphTargets&&w<I.length;){e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[I[w]]);e.vertexAttribPointer(B["morphTarget"+w],3,e.FLOAT,!1,0,0);M.__webglMorphTargetInfluences[w]=F[I[w]];w++}}else{I=[];var D=-1,H=0;F=M.morphTargetInfluences;var K,X=F.length;w=0;for(M.morphTargetBase!==
--1&&(I[M.morphTargetBase]=!0);w<u.numSupportedMorphTargets;){for(K=0;K<X;K++)if(!I[K]&&F[K]>D){H=K;D=F[H]}e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[H]);e.vertexAttribPointer(B["morphTarget"+w],3,e.FLOAT,!1,0,0);M.__webglMorphTargetInfluences[w]=D;I[H]=1;D=-1;w++}}e.uniform1fv(u.program.uniforms.morphTargetInfluences,M.__webglMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,A.__webglVertexBuffer);e.vertexAttribPointer(m.position,3,e.FLOAT,!1,0,0)}if(A.__webglCustomAttributes)for(G in A.__webglCustomAttributes)if(m[G]>=
+F.image.__webglTextureCube);for(H=0;H<6;++H)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+H,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,F.image[H]);F.__webglInit=!0}L(e.TEXTURE_CUBE_MAP,F,F.image[0]);e.bindTexture(e.TEXTURE_CUBE_MAP,null);F.needsUpdate=!1}e.activeTexture(e.TEXTURE0+w);e.bindTexture(e.TEXTURE_CUBE_MAP,F.image.__webglTextureCube)}}else N(F,w)}}e.uniformMatrix4fv(G.modelViewMatrix,!1,A._modelViewMatrixArray);e.uniformMatrix3fv(G.normalMatrix,!1,A._normalMatrixArray);(v instanceof THREE.MeshShaderMaterial||
+v instanceof THREE.MeshPhongMaterial||v.envMap)&&e.uniform3f(G.cameraPosition,m.position.x,m.position.y,m.position.z);(v instanceof THREE.MeshShaderMaterial||v.envMap||v.skinning)&&e.uniformMatrix4fv(G.objectMatrix,!1,A._objectMatrixArray);(v instanceof THREE.MeshPhongMaterial||v instanceof THREE.MeshLambertMaterial||v instanceof THREE.MeshShaderMaterial||v.skinning)&&e.uniformMatrix4fv(G.viewMatrix,!1,Za);if(v instanceof THREE.ShadowVolumeDynamicMaterial){m=I.directionalLightDirection.value;m[0]=
+-B.position.x;m[1]=-B.position.y;m[2]=-B.position.z;e.uniform3fv(G.directionalLightDirection,m);e.uniformMatrix4fv(G.objectMatrix,!1,A._objectMatrixArray);e.uniformMatrix4fv(G.viewMatrix,!1,Za)}if(v.skinning){e.uniformMatrix4fv(G.cameraInverseMatrix,!1,Za);e.uniformMatrix4fv(G.boneGlobalMatrices,!1,A.boneMatrices)}return M}function f(m,B,w,v,A,M){if(v.opacity!=0){var G;m=c(m,B,w,v,M).attributes;if(v.morphTargets){B=v.program.attributes;M.morphTargetBase!==-1?e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[M.morphTargetBase]):
+e.bindBuffer(e.ARRAY_BUFFER,A.__webglVertexBuffer);e.vertexAttribPointer(B.position,3,e.FLOAT,!1,0,0);if(M.morphTargetForcedOrder.length){w=0;for(var I=M.morphTargetForcedOrder,F=M.morphTargetInfluences;w<v.numSupportedMorphTargets&&w<I.length;){e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[I[w]]);e.vertexAttribPointer(B["morphTarget"+w],3,e.FLOAT,!1,0,0);M.__webglMorphTargetInfluences[w]=F[I[w]];w++}}else{I=[];var D=-1,H=0;F=M.morphTargetInfluences;var K,X=F.length;w=0;for(M.morphTargetBase!==
+-1&&(I[M.morphTargetBase]=!0);w<v.numSupportedMorphTargets;){for(K=0;K<X;K++)if(!I[K]&&F[K]>D){H=K;D=F[H]}e.bindBuffer(e.ARRAY_BUFFER,A.__webglMorphTargetsBuffers[H]);e.vertexAttribPointer(B["morphTarget"+w],3,e.FLOAT,!1,0,0);M.__webglMorphTargetInfluences[w]=D;I[H]=1;D=-1;w++}}e.uniform1fv(v.program.uniforms.morphTargetInfluences,M.__webglMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,A.__webglVertexBuffer);e.vertexAttribPointer(m.position,3,e.FLOAT,!1,0,0)}if(A.__webglCustomAttributes)for(G in A.__webglCustomAttributes)if(m[G]>=
 0){B=A.__webglCustomAttributes[G];e.bindBuffer(e.ARRAY_BUFFER,B.buffer);e.vertexAttribPointer(m[G],B.size,e.FLOAT,!1,0,0)}if(m.color>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglColorBuffer);e.vertexAttribPointer(m.color,3,e.FLOAT,!1,0,0)}if(m.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglNormalBuffer);e.vertexAttribPointer(m.normal,3,e.FLOAT,!1,0,0)}if(m.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglTangentBuffer);e.vertexAttribPointer(m.tangent,4,e.FLOAT,!1,0,0)}if(m.uv>=0)if(A.__webglUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,
-A.__webglUVBuffer);e.vertexAttribPointer(m.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv)}else e.disableVertexAttribArray(m.uv);if(m.uv2>=0)if(A.__webglUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,A.__webglUV2Buffer);e.vertexAttribPointer(m.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv2)}else e.disableVertexAttribArray(m.uv2);if(u.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinVertexABuffer);e.vertexAttribPointer(m.skinVertexA,
-4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinVertexBBuffer);e.vertexAttribPointer(m.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinIndicesBuffer);e.vertexAttribPointer(m.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinWeightsBuffer);e.vertexAttribPointer(m.skinWeight,4,e.FLOAT,!1,0,0)}if(M instanceof THREE.Mesh)if(u.wireframe){e.lineWidth(u.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webglLineBuffer);e.drawElements(e.LINES,
-A.__webglLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webglFaceBuffer);e.drawElements(e.TRIANGLES,A.__webglFaceCount,e.UNSIGNED_SHORT,0)}else if(M instanceof THREE.Line){M=M.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(u.linewidth);e.drawArrays(M,0,A.__webglLineCount)}else if(M instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,A.__webglParticleCount);else M instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,A.__webglVertexCount)}}function g(m,B){if(!m.__webglVertexBuffer)m.__webglVertexBuffer=
+A.__webglUVBuffer);e.vertexAttribPointer(m.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv)}else e.disableVertexAttribArray(m.uv);if(m.uv2>=0)if(A.__webglUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,A.__webglUV2Buffer);e.vertexAttribPointer(m.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv2)}else e.disableVertexAttribArray(m.uv2);if(v.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinVertexABuffer);e.vertexAttribPointer(m.skinVertexA,
+4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinVertexBBuffer);e.vertexAttribPointer(m.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinIndicesBuffer);e.vertexAttribPointer(m.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,A.__webglSkinWeightsBuffer);e.vertexAttribPointer(m.skinWeight,4,e.FLOAT,!1,0,0)}if(M instanceof THREE.Mesh)if(v.wireframe){e.lineWidth(v.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webglLineBuffer);e.drawElements(e.LINES,
+A.__webglLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,A.__webglFaceBuffer);e.drawElements(e.TRIANGLES,A.__webglFaceCount,e.UNSIGNED_SHORT,0)}else if(M instanceof THREE.Line){M=M.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(v.linewidth);e.drawArrays(M,0,A.__webglLineCount)}else if(M instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,A.__webglParticleCount);else M instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,A.__webglVertexCount)}}function g(m,B){if(!m.__webglVertexBuffer)m.__webglVertexBuffer=
 e.createBuffer();if(!m.__webglNormalBuffer)m.__webglNormalBuffer=e.createBuffer();if(m.hasPos){e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,m.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(B.attributes.position);e.vertexAttribPointer(B.attributes.position,3,e.FLOAT,!1,0,0)}if(m.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,m.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,m.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(B.attributes.normal);e.vertexAttribPointer(B.attributes.normal,
 3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,m.count);m.count=0}function h(m){if(ca!=m.doubleSided){m.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);ca=m.doubleSided}if(sa!=m.flipSided){m.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);sa=m.flipSided}}function j(m){if(ja!=m){m?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);ja=m}}function k(m){oa[0].set(m.n41-m.n11,m.n42-m.n12,m.n43-m.n13,m.n44-m.n14);oa[1].set(m.n41+m.n11,m.n42+m.n12,m.n43+m.n13,m.n44+m.n14);oa[2].set(m.n41+m.n21,m.n42+m.n22,
-m.n43+m.n23,m.n44+m.n24);oa[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);oa[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);oa[5].set(m.n41+m.n31,m.n42+m.n32,m.n43+m.n33,m.n44+m.n34);var B;for(m=0;m<6;m++){B=oa[m];B.divideScalar(Math.sqrt(B.x*B.x+B.y*B.y+B.z*B.z))}}function n(m){for(var B=m.matrixWorld,w=-m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)),u=0;u<6;u++){m=oa[u].x*B.n14+oa[u].y*B.n24+oa[u].z*B.n34+oa[u].w;if(m<=w)return!1}return!0}function p(m,
-B){m.list[m.count]=B;m.count+=1}function o(m){var B,w,u=m.object,A=m.opaque,M=m.transparent;M.count=0;m=A.count=0;for(B=u.materials.length;m<B;m++){w=u.materials[m];w.transparent?p(M,w):p(A,w)}}function t(m){var B,w,u,A,M=m.object,G=m.buffer,I=m.opaque,F=m.transparent;F.count=0;m=I.count=0;for(u=M.materials.length;m<u;m++){B=M.materials[m];if(B instanceof THREE.MeshFaceMaterial){B=0;for(w=G.materials.length;B<w;B++)(A=G.materials[B])&&(A.transparent?p(F,A):p(I,A))}else(A=B)&&(A.transparent?p(F,A):
-p(I,A))}}function x(m,B){return B.z-m.z}function v(m){e.enable(e.POLYGON_OFFSET_FILL);e.polygonOffset(0.1,1);e.enable(e.STENCIL_TEST);e.depthMask(!1);e.colorMask(!1,!1,!1,!1);e.stencilFunc(e.ALWAYS,1,255);e.stencilOpSeparate(e.BACK,e.KEEP,e.INCR,e.KEEP);e.stencilOpSeparate(e.FRONT,e.KEEP,e.DECR,e.KEEP);var B,w=m.lights.length,u,A=m.lights,M=[],G,I,F,D,H,K=m.__webglShadowVolumes.length;for(B=0;B<w;B++){u=m.lights[B];if(u instanceof THREE.DirectionalLight){M[0]=-u.position.x;M[1]=-u.position.y;M[2]=
--u.position.z;for(H=0;H<K;H++){u=m.__webglShadowVolumes[H].object;G=m.__webglShadowVolumes[H].buffer;I=u.materials[0];I.program||ua.initMaterial(I,A,undefined,u);I=I.program;F=I.uniforms;D=I.attributes;if(Aa!==I){e.useProgram(I);Aa=I;e.uniformMatrix4fv(F.projectionMatrix,!1,Ra);e.uniformMatrix4fv(F.viewMatrix,!1,Za);e.uniform3fv(F.directionalLightDirection,M)}u.matrixWorld.flattenToArray(u._objectMatrixArray);e.uniformMatrix4fv(F.objectMatrix,!1,u._objectMatrixArray);e.bindBuffer(e.ARRAY_BUFFER,G.__webglVertexBuffer);
+m.n43+m.n23,m.n44+m.n24);oa[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);oa[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);oa[5].set(m.n41+m.n31,m.n42+m.n32,m.n43+m.n33,m.n44+m.n34);var B;for(m=0;m<6;m++){B=oa[m];B.divideScalar(Math.sqrt(B.x*B.x+B.y*B.y+B.z*B.z))}}function n(m){for(var B=m.matrixWorld,w=-m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)),v=0;v<6;v++){m=oa[v].x*B.n14+oa[v].y*B.n24+oa[v].z*B.n34+oa[v].w;if(m<=w)return!1}return!0}function p(m,
+B){m.list[m.count]=B;m.count+=1}function o(m){var B,w,v=m.object,A=m.opaque,M=m.transparent;M.count=0;m=A.count=0;for(B=v.materials.length;m<B;m++){w=v.materials[m];w.transparent?p(M,w):p(A,w)}}function t(m){var B,w,v,A,M=m.object,G=m.buffer,I=m.opaque,F=m.transparent;F.count=0;m=I.count=0;for(v=M.materials.length;m<v;m++){B=M.materials[m];if(B instanceof THREE.MeshFaceMaterial){B=0;for(w=G.materials.length;B<w;B++)(A=G.materials[B])&&(A.transparent?p(F,A):p(I,A))}else(A=B)&&(A.transparent?p(F,A):
+p(I,A))}}function x(m,B){return B.z-m.z}function u(m){e.enable(e.POLYGON_OFFSET_FILL);e.polygonOffset(0.1,1);e.enable(e.STENCIL_TEST);e.depthMask(!1);e.colorMask(!1,!1,!1,!1);e.stencilFunc(e.ALWAYS,1,255);e.stencilOpSeparate(e.BACK,e.KEEP,e.INCR,e.KEEP);e.stencilOpSeparate(e.FRONT,e.KEEP,e.DECR,e.KEEP);var B,w=m.lights.length,v,A=m.lights,M=[],G,I,F,D,H,K=m.__webglShadowVolumes.length;for(B=0;B<w;B++){v=m.lights[B];if(v instanceof THREE.DirectionalLight){M[0]=-v.position.x;M[1]=-v.position.y;M[2]=
+-v.position.z;for(H=0;H<K;H++){v=m.__webglShadowVolumes[H].object;G=m.__webglShadowVolumes[H].buffer;I=v.materials[0];I.program||ua.initMaterial(I,A,undefined,v);I=I.program;F=I.uniforms;D=I.attributes;if(Aa!==I){e.useProgram(I);Aa=I;e.uniformMatrix4fv(F.projectionMatrix,!1,Ra);e.uniformMatrix4fv(F.viewMatrix,!1,Za);e.uniform3fv(F.directionalLightDirection,M)}v.matrixWorld.flattenToArray(v._objectMatrixArray);e.uniformMatrix4fv(F.objectMatrix,!1,v._objectMatrixArray);e.bindBuffer(e.ARRAY_BUFFER,G.__webglVertexBuffer);
 e.vertexAttribPointer(D.position,3,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,G.__webglNormalBuffer);e.vertexAttribPointer(D.normal,3,e.FLOAT,!1,0,0);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,G.__webglFaceBuffer);e.cullFace(e.FRONT);e.drawElements(e.TRIANGLES,G.__webglFaceCount,e.UNSIGNED_SHORT,0);e.cullFace(e.BACK);e.drawElements(e.TRIANGLES,G.__webglFaceCount,e.UNSIGNED_SHORT,0)}}}e.disable(e.POLYGON_OFFSET_FILL);e.colorMask(!0,!0,!0,!0);e.stencilFunc(e.NOTEQUAL,0,255);e.stencilOp(e.KEEP,e.KEEP,e.KEEP);
 e.disable(e.DEPTH_TEST);Ba="";Aa=ha.program;e.useProgram(ha.program);e.uniformMatrix4fv(ha.projectionLocation,!1,Ra);e.uniform1f(ha.darknessLocation,ha.darkness);e.bindBuffer(e.ARRAY_BUFFER,ha.vertexBuffer);e.vertexAttribPointer(ha.vertexLocation,3,e.FLOAT,!1,0,0);e.enableVertexAttribArray(ha.vertexLocation);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.blendEquation(e.FUNC_ADD);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ha.elementBuffer);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);e.disable(e.STENCIL_TEST);
-e.enable(e.DEPTH_TEST);e.depthMask(Ia)}function z(m,B){var w,u,A,M=m.__webglLensFlares.length,G,I,F;G=new THREE.Vector3;var D=ka/Fa;I=Fa*0.5;F=ka*0.5;var H=16/ka,K=[H*D,H],X=[1,1,0];H=[1,1];var T,Ea=la.readBackPixels,Ja,ra,ya=la.uniforms;w=la.attributes;e.useProgram(la.program);Aa=la.program;Ba="";e.uniform1i(ya.map,0);e.activeTexture(e.TEXTURE0);e.uniform1f(ya.opacity,1);e.uniform1f(ya.rotation,0);e.uniform2fv(ya.scale,K);e.bindBuffer(e.ARRAY_BUFFER,la.vertexBuffer);e.vertexAttribPointer(w.vertex,
-2,e.FLOAT,!1,16,0);e.vertexAttribPointer(w.uv,2,e.FLOAT,!1,16,8);e.bindTexture(e.TEXTURE_2D,la.tempTexture);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,la.elementBuffer);e.disable(e.CULL_FACE);e.depthMask(!1);for(A=0;A<M;A++){w=m.__webglLensFlares[A].object;G.set(w.matrixWorld.n14,w.matrixWorld.n24,w.matrixWorld.n34);B.matrixWorldInverse.multiplyVector3(G);u=G.z;B.projectionMatrix.multiplyVector3(G);X[0]=G.x;X[1]=G.y;X[2]=G.z;H[0]=X[0]*I+I;H[1]=X[1]*F+F;e.copyTexSubImage2D(e.TEXTURE_2D,0,0,0,H[0]-8,H[1]-
-8,16,16);e.uniform3fv(ya.screenPosition,X);e.uniform1i(ya.renderPink,1);e.enable(e.DEPTH_TEST);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);try{e.readPixels(H[0]-8,H[1]-8,16,16,e.RGBA,e.UNSIGNED_BYTE,la.readBackPixels)}catch(bb){console.log("WebGLRenderer.renderLensFlare: readPixels failed!")}e.getError()&&console.log("WebGLRenderer.renderLensFlare: readPixels failed!");sampleDistance=parseInt(5*(1-Math.max(0,Math.min(-u,B.far))/B.far),10)+2;u=sampleDistance*4;T=sampleDistance*64;ra=0;Ja=28-u+
-(448-T);la.readBackPixels[Ja+0]===255&&la.readBackPixels[Ja+1]===0&&la.readBackPixels[Ja+2]===255&&(ra+=0.2);Ja=28+u+(448-T);Ea[Ja+0]===255&&Ea[Ja+1]===0&&Ea[Ja+2]===255&&(ra+=0.2);Ja=28+u+(448+T);Ea[Ja+0]===255&&Ea[Ja+1]===0&&Ea[Ja+2]===255&&(ra+=0.2);Ja=28-u+(448+T);Ea[Ja+0]===255&&Ea[Ja+1]===0&&Ea[Ja+2]===255&&(ra+=0.2);Ja=476;Ea[Ja+0]===255&&Ea[Ja+1]===0&&Ea[Ja+2]===255&&(ra+=0.2);w.positionScreen.x=X[0];w.positionScreen.y=X[1];w.positionScreen.z=X[2];w.customUpdateCallback?w.customUpdateCallback(ra,
+e.enable(e.DEPTH_TEST);e.depthMask(Ia)}function z(m,B){var w,v,A,M=m.__webglLensFlares.length,G,I,F;G=new THREE.Vector3;var D=ka/Fa;I=Fa*0.5;F=ka*0.5;var H=16/ka,K=[H*D,H],X=[1,1,0];H=[1,1];var T,Ea=la.readBackPixels,Ja,ra,ya=la.uniforms;w=la.attributes;e.useProgram(la.program);Aa=la.program;Ba="";e.uniform1i(ya.map,0);e.activeTexture(e.TEXTURE0);e.uniform1f(ya.opacity,1);e.uniform1f(ya.rotation,0);e.uniform2fv(ya.scale,K);e.bindBuffer(e.ARRAY_BUFFER,la.vertexBuffer);e.vertexAttribPointer(w.vertex,
+2,e.FLOAT,!1,16,0);e.vertexAttribPointer(w.uv,2,e.FLOAT,!1,16,8);e.bindTexture(e.TEXTURE_2D,la.tempTexture);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,la.elementBuffer);e.disable(e.CULL_FACE);e.depthMask(!1);for(A=0;A<M;A++){w=m.__webglLensFlares[A].object;G.set(w.matrixWorld.n14,w.matrixWorld.n24,w.matrixWorld.n34);B.matrixWorldInverse.multiplyVector3(G);v=G.z;B.projectionMatrix.multiplyVector3(G);X[0]=G.x;X[1]=G.y;X[2]=G.z;H[0]=X[0]*I+I;H[1]=X[1]*F+F;e.copyTexSubImage2D(e.TEXTURE_2D,0,0,0,H[0]-8,H[1]-
+8,16,16);e.uniform3fv(ya.screenPosition,X);e.uniform1i(ya.renderPink,1);e.enable(e.DEPTH_TEST);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);try{e.readPixels(H[0]-8,H[1]-8,16,16,e.RGBA,e.UNSIGNED_BYTE,la.readBackPixels)}catch(bb){console.log("WebGLRenderer.renderLensFlare: readPixels failed!")}e.getError()&&console.log("WebGLRenderer.renderLensFlare: readPixels failed!");sampleDistance=parseInt(5*(1-Math.max(0,Math.min(-v,B.far))/B.far),10)+2;v=sampleDistance*4;T=sampleDistance*64;ra=0;Ja=28-v+
+(448-T);la.readBackPixels[Ja+0]===255&&la.readBackPixels[Ja+1]===0&&la.readBackPixels[Ja+2]===255&&(ra+=0.2);Ja=28+v+(448-T);Ea[Ja+0]===255&&Ea[Ja+1]===0&&Ea[Ja+2]===255&&(ra+=0.2);Ja=28+v+(448+T);Ea[Ja+0]===255&&Ea[Ja+1]===0&&Ea[Ja+2]===255&&(ra+=0.2);Ja=28-v+(448+T);Ea[Ja+0]===255&&Ea[Ja+1]===0&&Ea[Ja+2]===255&&(ra+=0.2);Ja=476;Ea[Ja+0]===255&&Ea[Ja+1]===0&&Ea[Ja+2]===255&&(ra+=0.2);w.positionScreen.x=X[0];w.positionScreen.y=X[1];w.positionScreen.z=X[2];w.customUpdateCallback?w.customUpdateCallback(ra,
 w):w.updateLensFlares(ra);e.uniform1i(ya.renderPink,0);e.disable(e.DEPTH_TEST);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}for(A=0;A<M;A++){w=m.__webglLensFlares[A].object;G=0;for(I=w.lensFlares.length;G<I;G++){F=w.lensFlares[G];if(F.opacity>0.0010&&F.scale>0.0010){X[0]=F.x;X[1]=F.y;X[2]=F.z;H=F.size*F.scale/ka;K[0]=H*D;K[1]=H;e.uniform3fv(ya.screenPosition,X);e.uniform1f(ya.rotation,F.rotation);e.uniform2fv(ya.scale,K);e.uniform1f(ya.opacity,F.opacity);y(F.blending);N(F.texture,0);e.drawElements(e.TRIANGLES,
-6,e.UNSIGNED_SHORT,0)}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(Ia)}function C(m,B){m._modelViewMatrix.multiplyToArray(B.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(m._modelViewMatrix).transposeIntoArray(m._normalMatrixArray)}function E(m){var B,w,u,A,M;if(m instanceof THREE.Mesh){w=m.geometry;for(B in w.geometryGroups){u=w.geometryGroups[B];M=!1;for(A in u.__webglCustomAttributes)if(u.__webglCustomAttributes[A].needsUpdate){M=!0;break}if(w.__dirtyVertices||
+6,e.UNSIGNED_SHORT,0)}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(Ia)}function C(m,B){m._modelViewMatrix.multiplyToArray(B.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(m._modelViewMatrix).transposeIntoArray(m._normalMatrixArray)}function E(m){var B,w,v,A,M;if(m instanceof THREE.Mesh){w=m.geometry;for(B in w.geometryGroups){v=w.geometryGroups[B];M=!1;for(A in v.__webglCustomAttributes)if(v.__webglCustomAttributes[A].needsUpdate){M=!0;break}if(w.__dirtyVertices||
 w.__dirtyMorphTargets||w.__dirtyElements||w.__dirtyUvs||w.__dirtyNormals||w.__dirtyColors||w.__dirtyTangents||M){M=e.DYNAMIC_DRAW;var G=void 0,I=void 0,F=void 0,D=void 0;F=void 0;var H=void 0,K=void 0,X=void 0,T=void 0,Ea=void 0,Ja=void 0,ra=void 0,ya=void 0,bb=void 0,Y=void 0,da=void 0,na=void 0,La=void 0;K=void 0;X=void 0;D=void 0;T=void 0;D=void 0;Y=void 0;da=void 0;K=void 0;Y=void 0;da=void 0;na=void 0;La=void 0;Y=void 0;da=void 0;na=void 0;La=void 0;Y=void 0;da=void 0;na=void 0;La=void 0;Y=void 0;
-da=void 0;na=void 0;D=void 0;T=void 0;H=void 0;F=void 0;F=void 0;var Z=void 0,Q=void 0,Qa=void 0,db=void 0,Na=0,Oa=0,hb=0,eb=0,$a=0,ab=0,Ma=0,cb=0,Ca=0,R=0,Pa=0;Z=0;var Ta=u.__vertexArray,jb=u.__uvArray,Ya=u.__uv2Array,S=u.__normalArray,ia=u.__tangentArray,ma=u.__colorArray,W=u.__skinVertexAArray,xa=u.__skinVertexBArray,wa=u.__skinIndexArray,ga=u.__skinWeightArray,V=u.__morphTargetsArrays,Ka=u.__webglCustomAttributes;Q=void 0;var Wa=u.__faceArray,Ua=u.__lineArray,ib=u.__needsSmoothNormals;Ja=u.__vertexColorType;
-Ea=u.__uvType;ra=u.__normalType;var Xa=m.geometry,fb=Xa.__dirtyVertices,gb=Xa.__dirtyElements,rb=Xa.__dirtyUvs,sb=Xa.__dirtyNormals,tb=Xa.__dirtyTangents,ub=Xa.__dirtyColors,vb=Xa.__dirtyMorphTargets,nb=Xa.vertices,wb=u.faces,zb=Xa.faces,xb=Xa.faceVertexUvs[0],yb=Xa.faceVertexUvs[1],ob=Xa.skinVerticesA,pb=Xa.skinVerticesB,qb=Xa.skinIndices,lb=Xa.skinWeights,mb=Xa.edgeFaces,kb=Xa.morphTargets;if(Ka)for(db in Ka)Ka[db].offset=0;G=0;for(I=wb.length;G<I;G++){F=wb[G];D=zb[F];xb&&(ya=xb[F]);yb&&(bb=yb[F]);
+da=void 0;na=void 0;D=void 0;T=void 0;H=void 0;F=void 0;F=void 0;var Z=void 0,Q=void 0,Qa=void 0,db=void 0,Na=0,Oa=0,hb=0,eb=0,$a=0,ab=0,Ma=0,cb=0,Ca=0,R=0,Pa=0;Z=0;var Ta=v.__vertexArray,jb=v.__uvArray,Ya=v.__uv2Array,S=v.__normalArray,ia=v.__tangentArray,ma=v.__colorArray,W=v.__skinVertexAArray,xa=v.__skinVertexBArray,wa=v.__skinIndexArray,ga=v.__skinWeightArray,V=v.__morphTargetsArrays,Ka=v.__webglCustomAttributes;Q=void 0;var Wa=v.__faceArray,Ua=v.__lineArray,ib=v.__needsSmoothNormals;Ja=v.__vertexColorType;
+Ea=v.__uvType;ra=v.__normalType;var Xa=m.geometry,fb=Xa.__dirtyVertices,gb=Xa.__dirtyElements,rb=Xa.__dirtyUvs,sb=Xa.__dirtyNormals,tb=Xa.__dirtyTangents,ub=Xa.__dirtyColors,vb=Xa.__dirtyMorphTargets,nb=Xa.vertices,wb=v.faces,zb=Xa.faces,xb=Xa.faceVertexUvs[0],yb=Xa.faceVertexUvs[1],ob=Xa.skinVerticesA,pb=Xa.skinVerticesB,qb=Xa.skinIndices,lb=Xa.skinWeights,mb=Xa.edgeFaces,kb=Xa.morphTargets;if(Ka)for(db in Ka)Ka[db].offset=0;G=0;for(I=wb.length;G<I;G++){F=wb[G];D=zb[F];xb&&(ya=xb[F]);yb&&(bb=yb[F]);
 F=D.vertexNormals;H=D.normal;K=D.vertexColors;X=D.color;T=D.vertexTangents;if(D instanceof THREE.Face3){if(fb){Y=nb[D.a].position;da=nb[D.b].position;na=nb[D.c].position;Ta[Oa]=Y.x;Ta[Oa+1]=Y.y;Ta[Oa+2]=Y.z;Ta[Oa+3]=da.x;Ta[Oa+4]=da.y;Ta[Oa+5]=da.z;Ta[Oa+6]=na.x;Ta[Oa+7]=na.y;Ta[Oa+8]=na.z;Oa+=9}if(Ka)for(db in Ka){Q=Ka[db];if(Q.needsUpdate){Z=Q.offset;if(Q.size===1){Q.array[Z+0]=Q.value[D.a];Q.array[Z+1]=Q.value[D.b];Q.array[Z+2]=Q.value[D.c];Q.offset+=3}else{Y=Q.value[D.a];da=Q.value[D.b];na=Q.value[D.c];
 if(Q.size===2){Q.array[Z+0]=Y.x;Q.array[Z+1]=Y.y;Q.array[Z+2]=da.x;Q.array[Z+3]=da.y;Q.array[Z+4]=na.x;Q.array[Z+5]=na.y;Q.offset+=6}else if(Q.size===3){Q.array[Z+0]=Y.x;Q.array[Z+1]=Y.y;Q.array[Z+2]=Y.z;Q.array[Z+3]=da.x;Q.array[Z+4]=da.y;Q.array[Z+5]=da.z;Q.array[Z+6]=na.x;Q.array[Z+7]=na.y;Q.array[Z+8]=na.z;Q.offset+=9}else{Q.array[Z+0]=Y.x;Q.array[Z+1]=Y.y;Q.array[Z+2]=Y.z;Q.array[Z+3]=Y.w;Q.array[Z+4]=da.x;Q.array[Z+5]=da.y;Q.array[Z+6]=da.z;Q.array[Z+7]=da.w;Q.array[Z+8]=na.x;Q.array[Z+9]=na.y;
 Q.array[Z+10]=na.z;Q.array[Z+11]=na.w;Q.offset+=12}}}}if(vb){Z=0;for(Q=kb.length;Z<Q;Z++){Y=kb[Z].vertices[D.a].position;da=kb[Z].vertices[D.b].position;na=kb[Z].vertices[D.c].position;Qa=V[Z];Qa[Pa+0]=Y.x;Qa[Pa+1]=Y.y;Qa[Pa+2]=Y.z;Qa[Pa+3]=da.x;Qa[Pa+4]=da.y;Qa[Pa+5]=da.z;Qa[Pa+6]=na.x;Qa[Pa+7]=na.y;Qa[Pa+8]=na.z}Pa+=9}if(lb.length){Y=lb[D.a];da=lb[D.b];na=lb[D.c];ga[R]=Y.x;ga[R+1]=Y.y;ga[R+2]=Y.z;ga[R+3]=Y.w;ga[R+4]=da.x;ga[R+5]=da.y;ga[R+6]=da.z;ga[R+7]=da.w;ga[R+8]=na.x;ga[R+9]=na.y;ga[R+10]=
@@ -270,13 +270,13 @@ La.y;Qa[Pa+11]=La.z}Pa+=12}if(lb.length){Y=lb[D.a];da=lb[D.b];na=lb[D.c];La=lb[D
 wa[R+13]=La.y;wa[R+14]=La.z;wa[R+15]=La.w;Y=ob[D.a];da=ob[D.b];na=ob[D.c];La=ob[D.d];W[R]=Y.x;W[R+1]=Y.y;W[R+2]=Y.z;W[R+3]=1;W[R+4]=da.x;W[R+5]=da.y;W[R+6]=da.z;W[R+7]=1;W[R+8]=na.x;W[R+9]=na.y;W[R+10]=na.z;W[R+11]=1;W[R+12]=La.x;W[R+13]=La.y;W[R+14]=La.z;W[R+15]=1;Y=pb[D.a];da=pb[D.b];na=pb[D.c];D=pb[D.d];xa[R]=Y.x;xa[R+1]=Y.y;xa[R+2]=Y.z;xa[R+3]=1;xa[R+4]=da.x;xa[R+5]=da.y;xa[R+6]=da.z;xa[R+7]=1;xa[R+8]=na.x;xa[R+9]=na.y;xa[R+10]=na.z;xa[R+11]=1;xa[R+12]=D.x;xa[R+13]=D.y;xa[R+14]=D.z;xa[R+15]=1;
 R+=16}if(ub&&Ja){if(K.length==4&&Ja==THREE.VertexColors){D=K[0];Y=K[1];da=K[2];K=K[3]}else K=da=Y=D=X;ma[Ca]=D.r;ma[Ca+1]=D.g;ma[Ca+2]=D.b;ma[Ca+3]=Y.r;ma[Ca+4]=Y.g;ma[Ca+5]=Y.b;ma[Ca+6]=da.r;ma[Ca+7]=da.g;ma[Ca+8]=da.b;ma[Ca+9]=K.r;ma[Ca+10]=K.g;ma[Ca+11]=K.b;Ca+=12}if(tb&&Xa.hasTangents){K=T[0];X=T[1];D=T[2];T=T[3];ia[Ma]=K.x;ia[Ma+1]=K.y;ia[Ma+2]=K.z;ia[Ma+3]=K.w;ia[Ma+4]=X.x;ia[Ma+5]=X.y;ia[Ma+6]=X.z;ia[Ma+7]=X.w;ia[Ma+8]=D.x;ia[Ma+9]=D.y;ia[Ma+10]=D.z;ia[Ma+11]=D.w;ia[Ma+12]=T.x;ia[Ma+13]=T.y;
 ia[Ma+14]=T.z;ia[Ma+15]=T.w;Ma+=16}if(sb&&ra)if(F.length==4&&ib)for(T=0;T<4;T++){H=F[T];S[ab]=H.x;S[ab+1]=H.y;S[ab+2]=H.z;ab+=3}else for(T=0;T<4;T++){S[ab]=H.x;S[ab+1]=H.y;S[ab+2]=H.z;ab+=3}if(rb&&ya!==undefined&&Ea)for(T=0;T<4;T++){F=ya[T];jb[hb]=F.u;jb[hb+1]=F.v;hb+=2}if(rb&&bb!==undefined&&Ea)for(T=0;T<4;T++){F=bb[T];Ya[eb]=F.u;Ya[eb+1]=F.v;eb+=2}if(gb){Wa[$a]=Na;Wa[$a+1]=Na+1;Wa[$a+2]=Na+3;Wa[$a+3]=Na+1;Wa[$a+4]=Na+2;Wa[$a+5]=Na+3;$a+=6;Ua[cb]=Na;Ua[cb+1]=Na+1;Ua[cb+2]=Na;Ua[cb+3]=Na+3;Ua[cb+
-4]=Na+1;Ua[cb+5]=Na+2;Ua[cb+6]=Na+2;Ua[cb+7]=Na+3;cb+=8;Na+=4}}}if(mb){G=0;for(I=mb.length;G<I;G++){Wa[$a]=mb[G].a;Wa[$a+1]=mb[G].b;Wa[$a+2]=mb[G].c;Wa[$a+3]=mb[G].a;Wa[$a+4]=mb[G].c;Wa[$a+5]=mb[G].d;$a+=6}}if(fb){e.bindBuffer(e.ARRAY_BUFFER,u.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ta,M)}if(Ka)for(db in Ka){Q=Ka[db];if(Q.needsUpdate){e.bindBuffer(e.ARRAY_BUFFER,Q.buffer);e.bufferData(e.ARRAY_BUFFER,Q.array,M);Q.needsUpdate=!1}}if(vb){Z=0;for(Q=kb.length;Z<Q;Z++){e.bindBuffer(e.ARRAY_BUFFER,
-u.__webglMorphTargetsBuffers[Z]);e.bufferData(e.ARRAY_BUFFER,V[Z],M)}}if(ub&&Ca>0){e.bindBuffer(e.ARRAY_BUFFER,u.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,ma,M)}if(sb){e.bindBuffer(e.ARRAY_BUFFER,u.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,S,M)}if(tb&&Xa.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,u.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,ia,M)}if(rb&&hb>0){e.bindBuffer(e.ARRAY_BUFFER,u.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,jb,M)}if(rb&&eb>0){e.bindBuffer(e.ARRAY_BUFFER,
-u.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Ya,M)}if(gb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Wa,M);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,u.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ua,M)}if(R>0){e.bindBuffer(e.ARRAY_BUFFER,u.__webglSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,W,M);e.bindBuffer(e.ARRAY_BUFFER,u.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,xa,M);e.bindBuffer(e.ARRAY_BUFFER,u.__webglSkinIndicesBuffer);
-e.bufferData(e.ARRAY_BUFFER,wa,M);e.bindBuffer(e.ARRAY_BUFFER,u.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,ga,M)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=!1}else if(m instanceof THREE.Ribbon){w=m.geometry;if(w.__dirtyVertices||w.__dirtyColors){m=w;B=e.DYNAMIC_DRAW;Ja=m.vertices;u=m.colors;ra=Ja.length;M=u.length;ya=m.__vertexArray;G=m.__colorArray;bb=m.__dirtyColors;if(m.__dirtyVertices){for(I=
-0;I<ra;I++){Ea=Ja[I].position;A=I*3;ya[A]=Ea.x;ya[A+1]=Ea.y;ya[A+2]=Ea.z}e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,ya,B)}if(bb){for(I=0;I<M;I++){color=u[I];A=I*3;G[A]=color.r;G[A+1]=color.g;G[A+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,G,B)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(m instanceof THREE.Line){w=m.geometry;if(w.__dirtyVertices||w.__dirtyColors){m=w;B=e.DYNAMIC_DRAW;Ja=m.vertices;u=m.colors;ra=Ja.length;
-M=u.length;ya=m.__vertexArray;G=m.__colorArray;bb=m.__dirtyColors;if(m.__dirtyVertices){for(I=0;I<ra;I++){Ea=Ja[I].position;A=I*3;ya[A]=Ea.x;ya[A+1]=Ea.y;ya[A+2]=Ea.z}e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,ya,B)}if(bb){for(I=0;I<M;I++){color=u[I];A=I*3;G[A]=color.r;G[A+1]=color.g;G[A+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,G,B)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(m instanceof THREE.ParticleSystem){w=
-m.geometry;(w.__dirtyVertices||w.__dirtyColors||m.sortParticles)&&d(w,e.DYNAMIC_DRAW,m);w.__dirtyVertices=!1;w.__dirtyColors=!1}}function J(m){function B(X){var T=[];w=0;for(u=X.length;w<u;w++)X[w]==undefined?T.push("undefined"):T.push(X[w].id);return T.join("_")}var w,u,A,M,G,I,F,D,H={},K=m.morphTargets!==undefined?m.morphTargets.length:0;m.geometryGroups={};A=0;for(M=m.faces.length;A<M;A++){G=m.faces[A];I=G.materials;F=B(I);H[F]==undefined&&(H[F]={hash:F,counter:0});D=H[F].hash+"_"+H[F].counter;
+4]=Na+1;Ua[cb+5]=Na+2;Ua[cb+6]=Na+2;Ua[cb+7]=Na+3;cb+=8;Na+=4}}}if(mb){G=0;for(I=mb.length;G<I;G++){Wa[$a]=mb[G].a;Wa[$a+1]=mb[G].b;Wa[$a+2]=mb[G].c;Wa[$a+3]=mb[G].a;Wa[$a+4]=mb[G].c;Wa[$a+5]=mb[G].d;$a+=6}}if(fb){e.bindBuffer(e.ARRAY_BUFFER,v.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ta,M)}if(Ka)for(db in Ka){Q=Ka[db];if(Q.needsUpdate){e.bindBuffer(e.ARRAY_BUFFER,Q.buffer);e.bufferData(e.ARRAY_BUFFER,Q.array,M);Q.needsUpdate=!1}}if(vb){Z=0;for(Q=kb.length;Z<Q;Z++){e.bindBuffer(e.ARRAY_BUFFER,
+v.__webglMorphTargetsBuffers[Z]);e.bufferData(e.ARRAY_BUFFER,V[Z],M)}}if(ub&&Ca>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,ma,M)}if(sb){e.bindBuffer(e.ARRAY_BUFFER,v.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,S,M)}if(tb&&Xa.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,v.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,ia,M)}if(rb&&hb>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,jb,M)}if(rb&&eb>0){e.bindBuffer(e.ARRAY_BUFFER,
+v.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Ya,M)}if(gb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Wa,M);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ua,M)}if(R>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,W,M);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,xa,M);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinIndicesBuffer);
+e.bufferData(e.ARRAY_BUFFER,wa,M);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,ga,M)}}}w.__dirtyVertices=!1;w.__dirtyMorphTargets=!1;w.__dirtyElements=!1;w.__dirtyUvs=!1;w.__dirtyNormals=!1;w.__dirtyTangents=!1;w.__dirtyColors=!1}else if(m instanceof THREE.Ribbon){w=m.geometry;if(w.__dirtyVertices||w.__dirtyColors){m=w;B=e.DYNAMIC_DRAW;Ja=m.vertices;v=m.colors;ra=Ja.length;M=v.length;ya=m.__vertexArray;G=m.__colorArray;bb=m.__dirtyColors;if(m.__dirtyVertices){for(I=
+0;I<ra;I++){Ea=Ja[I].position;A=I*3;ya[A]=Ea.x;ya[A+1]=Ea.y;ya[A+2]=Ea.z}e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,ya,B)}if(bb){for(I=0;I<M;I++){color=v[I];A=I*3;G[A]=color.r;G[A+1]=color.g;G[A+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,G,B)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(m instanceof THREE.Line){w=m.geometry;if(w.__dirtyVertices||w.__dirtyColors){m=w;B=e.DYNAMIC_DRAW;Ja=m.vertices;v=m.colors;ra=Ja.length;
+M=v.length;ya=m.__vertexArray;G=m.__colorArray;bb=m.__dirtyColors;if(m.__dirtyVertices){for(I=0;I<ra;I++){Ea=Ja[I].position;A=I*3;ya[A]=Ea.x;ya[A+1]=Ea.y;ya[A+2]=Ea.z}e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,ya,B)}if(bb){for(I=0;I<M;I++){color=v[I];A=I*3;G[A]=color.r;G[A+1]=color.g;G[A+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,G,B)}}w.__dirtyVertices=!1;w.__dirtyColors=!1}else if(m instanceof THREE.ParticleSystem){w=
+m.geometry;(w.__dirtyVertices||w.__dirtyColors||m.sortParticles)&&d(w,e.DYNAMIC_DRAW,m);w.__dirtyVertices=!1;w.__dirtyColors=!1}}function J(m){function B(X){var T=[];w=0;for(v=X.length;w<v;w++)X[w]==undefined?T.push("undefined"):T.push(X[w].id);return T.join("_")}var w,v,A,M,G,I,F,D,H={},K=m.morphTargets!==undefined?m.morphTargets.length:0;m.geometryGroups={};A=0;for(M=m.faces.length;A<M;A++){G=m.faces[A];I=G.materials;F=B(I);H[F]==undefined&&(H[F]={hash:F,counter:0});D=H[F].hash+"_"+H[F].counter;
 m.geometryGroups[D]==undefined&&(m.geometryGroups[D]={faces:[],materials:I,vertices:0,numMorphTargets:K});G=G instanceof THREE.Face3?3:4;if(m.geometryGroups[D].vertices+G>65535){H[F].counter+=1;D=H[F].hash+"_"+H[F].counter;m.geometryGroups[D]==undefined&&(m.geometryGroups[D]={faces:[],materials:I,vertices:0,numMorphTargets:K})}m.geometryGroups[D].faces.push(A);m.geometryGroups[D].vertices+=G}}function U(m,B,w){m.push({buffer:B,object:w,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function y(m){if(m!=
 Ba){switch(m){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD);e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}Ba=m}}function L(m,B,w){if((w.width&w.width-1)==0&&(w.height&
 w.height-1)==0){e.texParameteri(m,e.TEXTURE_WRAP_S,ta(B.wrapS));e.texParameteri(m,e.TEXTURE_WRAP_T,ta(B.wrapT));e.texParameteri(m,e.TEXTURE_MAG_FILTER,ta(B.magFilter));e.texParameteri(m,e.TEXTURE_MIN_FILTER,ta(B.minFilter));e.generateMipmap(m)}else{e.texParameteri(m,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(m,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(m,e.TEXTURE_MAG_FILTER,va(B.magFilter));e.texParameteri(m,e.TEXTURE_MIN_FILTER,va(B.minFilter))}}function N(m,B){if(m.needsUpdate){if(m.__webglInit){e.bindTexture(e.TEXTURE_2D,
@@ -287,17 +287,17 @@ Ha){e.bindFramebuffer(e.FRAMEBUFFER,B);e.viewport($,pa,w,m);Ha=B}}function za(m,
 function ta(m){switch(m){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;
 case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}
 var e,fa=document.createElement("canvas"),ea=[],Aa=null,Ha=null,Ia=!0,ua=this,ca=null,sa=null,Ba=null,ja=null,$=0,pa=0,Fa=0,ka=0,oa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ga=new THREE.Matrix4,Ra=new Float32Array(16),Za=new Float32Array(16),Va=new THREE.Vector4,Sa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},O=!0,aa=!0,qa=new THREE.Color(0),Da=0;if(b){if(b.stencil!=
-undefined)O=b.stencil;if(b.antialias!==undefined)aa=b.antialias;b.clearColor!==undefined&&qa.setHex(b.clearColor);if(b.clearAlpha!==undefined)Da=b.clearAlpha}this.maxMorphTargets=8;this.domElement=fa;this.autoClear=!0;this.sortObjects=!0;(function(m,B,w,u){try{if(!(e=fa.getContext("experimental-webgl",{antialias:m,stencil:u})))throw"Error creating WebGL context.";}catch(A){console.error(A)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);
+undefined)O=b.stencil;if(b.antialias!==undefined)aa=b.antialias;b.clearColor!==undefined&&qa.setHex(b.clearColor);if(b.clearAlpha!==undefined)Da=b.clearAlpha}this.maxMorphTargets=8;this.domElement=fa;this.autoClear=!0;this.sortObjects=!0;(function(m,B,w,v){try{if(!(e=fa.getContext("experimental-webgl",{antialias:m,stencil:v})))throw"Error creating WebGL context.";}catch(A){console.error(A)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);
 e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(B.r,B.g,B.b,w)})(aa,qa,Da,O);this.context=e;if(O){var ha={};ha.vertices=new Float32Array(12);ha.faces=new Uint16Array(6);ha.darkness=0.5;ha.vertices[0]=-2;ha.vertices[1]=-1;ha.vertices[2]=-1;ha.vertices[3]=2;ha.vertices[4]=-1;ha.vertices[5]=-1;ha.vertices[6]=2;ha.vertices[7]=1;ha.vertices[8]=-1;ha.vertices[9]=-2;ha.vertices[10]=1;ha.vertices[11]=-1;ha.faces[0]=0;ha.faces[1]=
 1;ha.faces[2]=2;ha.faces[3]=0;ha.faces[4]=2;ha.faces[5]=3;ha.vertexBuffer=e.createBuffer();ha.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,ha.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,ha.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ha.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ha.faces,e.STATIC_DRAW);ha.program=e.createProgram();e.attachShader(ha.program,za("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(ha.program,za("vertex",THREE.ShaderLib.shadowPost.vertexShader));
 e.linkProgram(ha.program);ha.vertexLocation=e.getAttribLocation(ha.program,"position");ha.projectionLocation=e.getUniformLocation(ha.program,"projectionMatrix");ha.darknessLocation=e.getUniformLocation(ha.program,"darkness")}var la={};la.vertices=new Float32Array(16);la.faces=new Uint16Array(6);la.transparency=0.5;b=0;la.vertices[b++]=-1;la.vertices[b++]=-1;la.vertices[b++]=0;la.vertices[b++]=0;la.vertices[b++]=1;la.vertices[b++]=-1;la.vertices[b++]=1;la.vertices[b++]=0;la.vertices[b++]=1;la.vertices[b++]=
 1;la.vertices[b++]=1;la.vertices[b++]=1;la.vertices[b++]=-1;la.vertices[b++]=1;la.vertices[b++]=0;la.vertices[b++]=1;b=0;la.faces[b++]=0;la.faces[b++]=1;la.faces[b++]=2;la.faces[b++]=0;la.faces[b++]=2;la.faces[b++]=3;la.vertexBuffer=e.createBuffer();la.elementBuffer=e.createBuffer();la.tempTexture=e.createTexture();la.readBackPixels=new Uint8Array(1024);e.bindBuffer(e.ARRAY_BUFFER,la.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,la.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,la.elementBuffer);
 e.bufferData(e.ELEMENT_ARRAY_BUFFER,la.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,la.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);la.program=e.createProgram();e.attachShader(la.program,za("fragment",THREE.ShaderLib.lensFlare.fragmentShader));
 e.attachShader(la.program,za("vertex",THREE.ShaderLib.lensFlare.vertexShader));e.linkProgram(la.program);la.attributes={};la.uniforms={};la.attributes.vertex=e.getAttribLocation(la.program,"position");la.attributes.uv=e.getAttribLocation(la.program,"UV");la.uniforms.map=e.getUniformLocation(la.program,"map");la.uniforms.opacity=e.getUniformLocation(la.program,"opacity");la.uniforms.scale=e.getUniformLocation(la.program,"scale");la.uniforms.rotation=e.getUniformLocation(la.program,"rotation");la.uniforms.screenPosition=
-e.getUniformLocation(la.program,"screenPosition");la.uniforms.renderPink=e.getUniformLocation(la.program,"renderPink");this.setSize=function(m,B){fa.width=m;fa.height=B;this.setViewport(0,0,fa.width,fa.height)};this.setViewport=function(m,B,w,u){$=m;pa=B;Fa=w;ka=u;e.viewport($,pa,Fa,ka)};this.setScissor=function(m,B,w,u){e.scissor(m,B,w,u)};this.enableScissorTest=function(m){m?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(m){Ia=m;e.depthMask(m)};this.setClearColorHex=
-function(m,B){var w=new THREE.Color(m);e.clearColor(w.r,w.g,w.b,B)};this.setClearColor=function(m,B){e.clearColor(m.r,m.g,m.b,B)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(m){ha.darkness=m};this.initMaterial=function(m,B,w,u){var A,M,G;if(m instanceof THREE.MeshDepthMaterial)G="depth";else if(m instanceof THREE.ShadowVolumeDynamicMaterial)G="shadowVolumeDynamic";else if(m instanceof THREE.MeshNormalMaterial)G=
+e.getUniformLocation(la.program,"screenPosition");la.uniforms.renderPink=e.getUniformLocation(la.program,"renderPink");this.setSize=function(m,B){fa.width=m;fa.height=B;this.setViewport(0,0,fa.width,fa.height)};this.setViewport=function(m,B,w,v){$=m;pa=B;Fa=w;ka=v;e.viewport($,pa,Fa,ka)};this.setScissor=function(m,B,w,v){e.scissor(m,B,w,v)};this.enableScissorTest=function(m){m?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(m){Ia=m;e.depthMask(m)};this.setClearColorHex=
+function(m,B){var w=new THREE.Color(m);e.clearColor(w.r,w.g,w.b,B)};this.setClearColor=function(m,B){e.clearColor(m.r,m.g,m.b,B)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(m){ha.darkness=m};this.initMaterial=function(m,B,w,v){var A,M,G;if(m instanceof THREE.MeshDepthMaterial)G="depth";else if(m instanceof THREE.ShadowVolumeDynamicMaterial)G="shadowVolumeDynamic";else if(m instanceof THREE.MeshNormalMaterial)G=
 "normal";else if(m instanceof THREE.MeshBasicMaterial)G="basic";else if(m instanceof THREE.MeshLambertMaterial)G="lambert";else if(m instanceof THREE.MeshPhongMaterial)G="phong";else if(m instanceof THREE.LineBasicMaterial)G="basic";else m instanceof THREE.ParticleBasicMaterial&&(G="particle_basic");if(G){var I=THREE.ShaderLib[G];m.uniforms=Uniforms.clone(I.uniforms);m.vertexShader=I.vertexShader;m.fragmentShader=I.fragmentShader}var F,D,H;F=H=I=0;for(D=B.length;F<D;F++){M=B[F];M instanceof THREE.DirectionalLight&&
-H++;M instanceof THREE.PointLight&&I++}if(I+H<=4)B=H;else{B=Math.ceil(4*H/(I+H));I=4-B}M={directional:B,point:I};H=50;if(u!==undefined&&u instanceof THREE.SkinnedMesh)H=u.bones.length;var K;a:{F=m.fragmentShader;D=m.vertexShader;I=m.uniforms;B=m.attributes;w={map:!!m.map,envMap:!!m.envMap,lightMap:!!m.lightMap,vertexColors:m.vertexColors,fog:w,sizeAttenuation:m.sizeAttenuation,skinning:m.skinning,morphTargets:m.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:M.directional,maxPointLights:M.point,
+H++;M instanceof THREE.PointLight&&I++}if(I+H<=4)B=H;else{B=Math.ceil(4*H/(I+H));I=4-B}M={directional:B,point:I};H=50;if(v!==undefined&&v instanceof THREE.SkinnedMesh)H=v.bones.length;var K;a:{F=m.fragmentShader;D=m.vertexShader;I=m.uniforms;B=m.attributes;w={map:!!m.map,envMap:!!m.envMap,lightMap:!!m.lightMap,vertexColors:m.vertexColors,fog:w,sizeAttenuation:m.sizeAttenuation,skinning:m.skinning,morphTargets:m.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:M.directional,maxPointLights:M.point,
 maxBones:H};var X;M=[];if(G)M.push(G);else{M.push(F);M.push(D)}for(X in w){M.push(X);M.push(w[X])}G=M.join();X=0;for(M=ea.length;X<M;X++)if(ea[X].code==G){K=ea[X].program;break a}X=e.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,w.fog?"#define USE_FOG":"",w.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",w.map?"#define USE_MAP":"",w.envMap?"#define USE_ENVMAP":"",w.lightMap?"#define USE_LIGHTMAP":
 "",w.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+w.maxDirLights,"#define MAX_POINT_LIGHTS "+w.maxPointLights,"#define MAX_BONES "+w.maxBones,w.map?"#define USE_MAP":"",w.envMap?"#define USE_ENVMAP":"",w.lightMap?"#define USE_LIGHTMAP":"",w.vertexColors?"#define USE_COLOR":"",w.skinning?"#define USE_SKINNING":"",w.morphTargets?
 "#define USE_MORPHTARGETS":"",w.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
@@ -305,22 +305,22 @@ e.attachShader(X,za("fragment",prefix_fragment+F));e.attachShader(X,za("vertex",
 T=F;I=0;for(F=T.length;I<F;I++){D=T[I];X.uniforms[D]=e.getUniformLocation(X,D)}F=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(T=0;T<w.maxMorphTargets;T++)F.push("morphTarget"+T);for(K in B)F.push(K);K=F;T=0;for(B=K.length;T<B;T++){w=K[T];X.attributes[w]=e.getAttribLocation(X,w)}ea.push({program:X,code:G});K=X}m.program=K;K=m.program.attributes;e.enableVertexAttribArray(K.position);K.color>=0&&e.enableVertexAttribArray(K.color);K.normal>=
 0&&e.enableVertexAttribArray(K.normal);K.tangent>=0&&e.enableVertexAttribArray(K.tangent);if(m.skinning&&K.skinVertexA>=0&&K.skinVertexB>=0&&K.skinIndex>=0&&K.skinWeight>=0){e.enableVertexAttribArray(K.skinVertexA);e.enableVertexAttribArray(K.skinVertexB);e.enableVertexAttribArray(K.skinIndex);e.enableVertexAttribArray(K.skinWeight)}for(A in m.attributes)K[A]>=0&&e.enableVertexAttribArray(K[A]);if(m.morphTargets){m.numSupportedMorphTargets=0;if(K.morphTarget0>=0){e.enableVertexAttribArray(K.morphTarget0);
 m.numSupportedMorphTargets++}if(K.morphTarget1>=0){e.enableVertexAttribArray(K.morphTarget1);m.numSupportedMorphTargets++}if(K.morphTarget2>=0){e.enableVertexAttribArray(K.morphTarget2);m.numSupportedMorphTargets++}if(K.morphTarget3>=0){e.enableVertexAttribArray(K.morphTarget3);m.numSupportedMorphTargets++}if(K.morphTarget4>=0){e.enableVertexAttribArray(K.morphTarget4);m.numSupportedMorphTargets++}if(K.morphTarget5>=0){e.enableVertexAttribArray(K.morphTarget5);m.numSupportedMorphTargets++}if(K.morphTarget6>=
-0){e.enableVertexAttribArray(K.morphTarget6);m.numSupportedMorphTargets++}if(K.morphTarget7>=0){e.enableVertexAttribArray(K.morphTarget7);m.numSupportedMorphTargets++}u.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);m=0;for(A=this.maxMorphTargets;m<A;m++)u.__webglMorphTargetInfluences[m]=0}};this.render=function(m,B,w,u){var A,M,G,I,F,D,H,K,X=m.lights,T=m.fog;B.matrixAutoUpdate&&B.updateMatrix();m.update(undefined,!1,B);B.matrixWorldInverse.flattenToArray(Za);B.projectionMatrix.flattenToArray(Ra);
-Ga.multiply(B.projectionMatrix,B.matrixWorldInverse);k(Ga);this.initWebGLObjects(m);P(w);(this.autoClear||u)&&this.clear();F=m.__webglObjects.length;for(u=0;u<F;u++){A=m.__webglObjects[u];H=A.object;if(H.visible)if(!(H instanceof THREE.Mesh)||n(H)){H.matrixWorld.flattenToArray(H._objectMatrixArray);C(H,B);t(A);A.render=!0;if(this.sortObjects){Va.copy(H.position);Ga.multiplyVector3(Va);A.z=Va.z}}else A.render=!1;else A.render=!1}this.sortObjects&&m.__webglObjects.sort(x);D=m.__webglObjectsImmediate.length;
-for(u=0;u<D;u++){A=m.__webglObjectsImmediate[u];H=A.object;if(H.visible){H.matrixAutoUpdate&&H.matrixWorld.flattenToArray(H._objectMatrixArray);C(H,B);o(A)}}y(THREE.NormalBlending);for(u=0;u<F;u++){A=m.__webglObjects[u];if(A.render){H=A.object;K=A.buffer;G=A.opaque;h(H);for(A=0;A<G.count;A++){I=G.list[A];j(I.depthTest);f(B,X,T,I,K,H)}}}for(u=0;u<D;u++){A=m.__webglObjectsImmediate[u];H=A.object;if(H.visible){G=A.opaque;h(H);for(A=0;A<G.count;A++){I=G.list[A];j(I.depthTest);M=c(B,X,T,I,H);H.render(function(Ea){g(Ea,
-M)})}}}for(u=0;u<F;u++){A=m.__webglObjects[u];if(A.render){H=A.object;K=A.buffer;G=A.transparent;h(H);for(A=0;A<G.count;A++){I=G.list[A];y(I.blending);j(I.depthTest);f(B,X,T,I,K,H)}}}for(u=0;u<D;u++){A=m.__webglObjectsImmediate[u];H=A.object;if(H.visible){G=A.transparent;h(H);for(A=0;A<G.count;A++){I=G.list[A];y(I.blending);j(I.depthTest);M=c(B,X,T,I,H);H.render(function(Ea){g(Ea,M)})}}}O&&m.__webglShadowVolumes.length&&m.lights.length&&v(m);m.__webglLensFlares.length&&z(m,B);if(w&&w.minFilter!==
-THREE.NearestFilter&&w.minFilter!==THREE.LinearFilter){e.bindTexture(e.TEXTURE_2D,w.__webglTexture);e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}};this.initWebGLObjects=function(m){if(!m.__webglObjects){m.__webglObjects=[];m.__webglObjectsImmediate=[];m.__webglShadowVolumes=[];m.__webglLensFlares=[]}for(;m.__objectsAdded.length;){var B=m.__objectsAdded[0],w=m,u=void 0,A=void 0,M=void 0;if(B._modelViewMatrix==undefined){B._modelViewMatrix=new THREE.Matrix4;B._normalMatrixArray=new Float32Array(9);
-B._modelViewMatrixArray=new Float32Array(16);B._objectMatrixArray=new Float32Array(16);B.matrixWorld.flattenToArray(B._objectMatrixArray)}if(B instanceof THREE.Mesh){A=B.geometry;A.geometryGroups==undefined&&J(A);for(u in A.geometryGroups){M=A.geometryGroups[u];if(!M.__webglVertexBuffer){var G=M;G.__webglVertexBuffer=e.createBuffer();G.__webglNormalBuffer=e.createBuffer();G.__webglTangentBuffer=e.createBuffer();G.__webglColorBuffer=e.createBuffer();G.__webglUVBuffer=e.createBuffer();G.__webglUV2Buffer=
+0){e.enableVertexAttribArray(K.morphTarget6);m.numSupportedMorphTargets++}if(K.morphTarget7>=0){e.enableVertexAttribArray(K.morphTarget7);m.numSupportedMorphTargets++}v.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);m=0;for(A=this.maxMorphTargets;m<A;m++)v.__webglMorphTargetInfluences[m]=0}};this.render=function(m,B,w,v){var A,M,G,I,F,D,H,K,X=m.lights,T=m.fog;B.matrixAutoUpdate&&B.updateMatrix();m.update(undefined,!1,B);B.matrixWorldInverse.flattenToArray(Za);B.projectionMatrix.flattenToArray(Ra);
+Ga.multiply(B.projectionMatrix,B.matrixWorldInverse);k(Ga);this.initWebGLObjects(m);P(w);(this.autoClear||v)&&this.clear();F=m.__webglObjects.length;for(v=0;v<F;v++){A=m.__webglObjects[v];H=A.object;if(H.visible)if(!(H instanceof THREE.Mesh)||n(H)){H.matrixWorld.flattenToArray(H._objectMatrixArray);C(H,B);t(A);A.render=!0;if(this.sortObjects){Va.copy(H.position);Ga.multiplyVector3(Va);A.z=Va.z}}else A.render=!1;else A.render=!1}this.sortObjects&&m.__webglObjects.sort(x);D=m.__webglObjectsImmediate.length;
+for(v=0;v<D;v++){A=m.__webglObjectsImmediate[v];H=A.object;if(H.visible){H.matrixAutoUpdate&&H.matrixWorld.flattenToArray(H._objectMatrixArray);C(H,B);o(A)}}y(THREE.NormalBlending);for(v=0;v<F;v++){A=m.__webglObjects[v];if(A.render){H=A.object;K=A.buffer;G=A.opaque;h(H);for(A=0;A<G.count;A++){I=G.list[A];j(I.depthTest);f(B,X,T,I,K,H)}}}for(v=0;v<D;v++){A=m.__webglObjectsImmediate[v];H=A.object;if(H.visible){G=A.opaque;h(H);for(A=0;A<G.count;A++){I=G.list[A];j(I.depthTest);M=c(B,X,T,I,H);H.render(function(Ea){g(Ea,
+M)})}}}for(v=0;v<F;v++){A=m.__webglObjects[v];if(A.render){H=A.object;K=A.buffer;G=A.transparent;h(H);for(A=0;A<G.count;A++){I=G.list[A];y(I.blending);j(I.depthTest);f(B,X,T,I,K,H)}}}for(v=0;v<D;v++){A=m.__webglObjectsImmediate[v];H=A.object;if(H.visible){G=A.transparent;h(H);for(A=0;A<G.count;A++){I=G.list[A];y(I.blending);j(I.depthTest);M=c(B,X,T,I,H);H.render(function(Ea){g(Ea,M)})}}}O&&m.__webglShadowVolumes.length&&m.lights.length&&u(m);m.__webglLensFlares.length&&z(m,B);if(w&&w.minFilter!==
+THREE.NearestFilter&&w.minFilter!==THREE.LinearFilter){e.bindTexture(e.TEXTURE_2D,w.__webglTexture);e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}};this.initWebGLObjects=function(m){if(!m.__webglObjects){m.__webglObjects=[];m.__webglObjectsImmediate=[];m.__webglShadowVolumes=[];m.__webglLensFlares=[]}for(;m.__objectsAdded.length;){var B=m.__objectsAdded[0],w=m,v=void 0,A=void 0,M=void 0;if(B._modelViewMatrix==undefined){B._modelViewMatrix=new THREE.Matrix4;B._normalMatrixArray=new Float32Array(9);
+B._modelViewMatrixArray=new Float32Array(16);B._objectMatrixArray=new Float32Array(16);B.matrixWorld.flattenToArray(B._objectMatrixArray)}if(B instanceof THREE.Mesh){A=B.geometry;A.geometryGroups==undefined&&J(A);for(v in A.geometryGroups){M=A.geometryGroups[v];if(!M.__webglVertexBuffer){var G=M;G.__webglVertexBuffer=e.createBuffer();G.__webglNormalBuffer=e.createBuffer();G.__webglTangentBuffer=e.createBuffer();G.__webglColorBuffer=e.createBuffer();G.__webglUVBuffer=e.createBuffer();G.__webglUV2Buffer=
 e.createBuffer();G.__webglSkinVertexABuffer=e.createBuffer();G.__webglSkinVertexBBuffer=e.createBuffer();G.__webglSkinIndicesBuffer=e.createBuffer();G.__webglSkinWeightsBuffer=e.createBuffer();G.__webglFaceBuffer=e.createBuffer();G.__webglLineBuffer=e.createBuffer();if(G.numMorphTargets){var I=void 0,F=void 0;G.__webglMorphTargetsBuffers=[];I=0;for(F=G.numMorphTargets;I<F;I++)G.__webglMorphTargetsBuffers.push(e.createBuffer())}G=M;I=B;var D=void 0,H=void 0,K=void 0;K=void 0;var X=void 0,T=void 0,
 Ea=void 0,Ja=Ea=F=0;H=void 0;K=void 0;var ra=void 0;D=void 0;H=void 0;X=I.geometry;ra=X.faces;T=G.faces;D=0;for(H=T.length;D<H;D++){K=T[D];K=ra[K];if(K instanceof THREE.Face3){F+=3;Ea+=1;Ja+=3}else if(K instanceof THREE.Face4){F+=4;Ea+=2;Ja+=4}}D=G;H=I;ra=void 0;T=void 0;var ya=void 0,bb=void 0;ya=void 0;K=[];ra=0;for(T=H.materials.length;ra<T;ra++){ya=H.materials[ra];if(ya instanceof THREE.MeshFaceMaterial){ya=0;for(l=D.materials.length;ya<l;ya++)(bb=D.materials[ya])&&K.push(bb)}else(bb=ya)&&K.push(bb)}D=
 K;a:{H=void 0;ra=void 0;T=D.length;for(H=0;H<T;H++){ra=D[H];if(ra.map||ra.lightMap||ra instanceof THREE.MeshShaderMaterial){H=!0;break a}}H=!1}a:{ra=D;T=void 0;K=void 0;ya=ra.length;for(T=0;T<ya;T++){K=ra[T];if(!(K instanceof THREE.MeshBasicMaterial&&!K.envMap||K instanceof THREE.MeshDepthMaterial)){ra=K&&K.shading!=undefined&&K.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}ra=!1}a:{T=void 0;K=void 0;ya=D.length;for(T=0;T<ya;T++){K=D[T];if(K.vertexColors){K=K.vertexColors;
 break a}}K=!1}G.__vertexArray=new Float32Array(F*3);if(ra)G.__normalArray=new Float32Array(F*3);if(X.hasTangents)G.__tangentArray=new Float32Array(F*4);if(K)G.__colorArray=new Float32Array(F*3);if(H){if(X.faceUvs.length>0||X.faceVertexUvs.length>0)G.__uvArray=new Float32Array(F*2);if(X.faceUvs.length>1||X.faceVertexUvs.length>1)G.__uv2Array=new Float32Array(F*2)}if(I.geometry.skinWeights.length&&I.geometry.skinIndices.length){G.__skinVertexAArray=new Float32Array(F*4);G.__skinVertexBArray=new Float32Array(F*
 4);G.__skinIndexArray=new Float32Array(F*4);G.__skinWeightArray=new Float32Array(F*4)}G.__faceArray=new Uint16Array(Ea*3+(I.geometry.edgeFaces?I.geometry.edgeFaces.length*6:0));G.__lineArray=new Uint16Array(Ja*2);if(G.numMorphTargets){G.__morphTargetsArrays=[];X=0;for(T=G.numMorphTargets;X<T;X++)G.__morphTargetsArrays.push(new Float32Array(F*3))}G.__needsSmoothNormals=ra==THREE.SmoothShading;G.__uvType=H;G.__vertexColorType=K;G.__normalType=ra;G.__webglFaceCount=Ea*3+(I.geometry.edgeFaces?I.geometry.edgeFaces.length*
 6:0);G.__webglLineCount=Ja*2;X=0;for(T=D.length;X<T;X++)if(D[X].attributes){G.__webglCustomAttributes={};for(a in D[X].attributes){H=D[X].attributes[a];Ea=1;if(H.type==="v2")Ea=2;else if(H.type==="v3")Ea=3;else if(H.type==="v4")Ea=4;else H.type==="c"&&(Ea=3);H.size=Ea;H.needsUpdate=!0;H.array=new Float32Array(F*Ea);H.buffer=e.createBuffer();G.__webglCustomAttributes[a]=H}}A.__dirtyVertices=!0;A.__dirtyMorphTargets=!0;A.__dirtyElements=!0;A.__dirtyUvs=!0;A.__dirtyNormals=!0;A.__dirtyTangents=!0;A.__dirtyColors=
-!0}B instanceof THREE.ShadowVolume?U(w.__webglShadowVolumes,M,B):U(w.__webglObjects,M,B)}}else if(B instanceof THREE.LensFlare)U(w.__webglLensFlares,undefined,B);else if(B instanceof THREE.Ribbon){A=B.geometry;if(!A.__webglVertexBuffer){u=A;u.__webglVertexBuffer=e.createBuffer();u.__webglColorBuffer=e.createBuffer();u=A;M=u.vertices.length;u.__vertexArray=new Float32Array(M*3);u.__colorArray=new Float32Array(M*3);u.__webglVertexCount=M;A.__dirtyVertices=!0;A.__dirtyColors=!0}U(w.__webglObjects,A,
-B)}else if(B instanceof THREE.Line){A=B.geometry;if(!A.__webglVertexBuffer){u=A;u.__webglVertexBuffer=e.createBuffer();u.__webglColorBuffer=e.createBuffer();u=A;M=u.vertices.length;u.__vertexArray=new Float32Array(M*3);u.__colorArray=new Float32Array(M*3);u.__webglLineCount=M;A.__dirtyVertices=!0;A.__dirtyColors=!0}U(w.__webglObjects,A,B)}else if(B instanceof THREE.ParticleSystem){A=B.geometry;if(!A.__webglVertexBuffer){u=A;u.__webglVertexBuffer=e.createBuffer();u.__webglColorBuffer=e.createBuffer();
-u=A;M=u.vertices.length;u.__vertexArray=new Float32Array(M*3);u.__colorArray=new Float32Array(M*3);u.__sortArray=[];u.__webglParticleCount=M;A.__dirtyVertices=!0;A.__dirtyColors=!0}U(w.__webglObjects,A,B)}else THREE.MarchingCubes!==undefined&&B instanceof THREE.MarchingCubes&&w.__webglObjectsImmediate.push({object:B,opaque:{list:[],count:0},transparent:{list:[],count:0}});m.__objectsAdded.splice(0,1)}for(;m.__objectsRemoved.length;){B=m.__objectsRemoved[0];w=m;A=void 0;u=void 0;for(A=w.__webglObjects.length-
-1;A>=0;A--){u=w.__webglObjects[A].object;B==u&&w.__webglObjects.splice(A,1)}m.__objectsRemoved.splice(0,1)}B=0;for(w=m.__webglObjects.length;B<w;B++)E(m.__webglObjects[B].object,m);B=0;for(w=m.__webglShadowVolumes.length;B<w;B++)E(m.__webglShadowVolumes[B].object,m);B=0;for(w=m.__webglLensFlares.length;B<w;B++)E(m.__webglLensFlares[B].object,m)};this.setFaceCulling=function(m,B){if(m){!B||B=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(m=="back")e.cullFace(e.BACK);else m=="front"?e.cullFace(e.FRONT):
+!0}B instanceof THREE.ShadowVolume?U(w.__webglShadowVolumes,M,B):U(w.__webglObjects,M,B)}}else if(B instanceof THREE.LensFlare)U(w.__webglLensFlares,undefined,B);else if(B instanceof THREE.Ribbon){A=B.geometry;if(!A.__webglVertexBuffer){v=A;v.__webglVertexBuffer=e.createBuffer();v.__webglColorBuffer=e.createBuffer();v=A;M=v.vertices.length;v.__vertexArray=new Float32Array(M*3);v.__colorArray=new Float32Array(M*3);v.__webglVertexCount=M;A.__dirtyVertices=!0;A.__dirtyColors=!0}U(w.__webglObjects,A,
+B)}else if(B instanceof THREE.Line){A=B.geometry;if(!A.__webglVertexBuffer){v=A;v.__webglVertexBuffer=e.createBuffer();v.__webglColorBuffer=e.createBuffer();v=A;M=v.vertices.length;v.__vertexArray=new Float32Array(M*3);v.__colorArray=new Float32Array(M*3);v.__webglLineCount=M;A.__dirtyVertices=!0;A.__dirtyColors=!0}U(w.__webglObjects,A,B)}else if(B instanceof THREE.ParticleSystem){A=B.geometry;if(!A.__webglVertexBuffer){v=A;v.__webglVertexBuffer=e.createBuffer();v.__webglColorBuffer=e.createBuffer();
+v=A;M=v.vertices.length;v.__vertexArray=new Float32Array(M*3);v.__colorArray=new Float32Array(M*3);v.__sortArray=[];v.__webglParticleCount=M;A.__dirtyVertices=!0;A.__dirtyColors=!0}U(w.__webglObjects,A,B)}else THREE.MarchingCubes!==undefined&&B instanceof THREE.MarchingCubes&&w.__webglObjectsImmediate.push({object:B,opaque:{list:[],count:0},transparent:{list:[],count:0}});m.__objectsAdded.splice(0,1)}for(;m.__objectsRemoved.length;){B=m.__objectsRemoved[0];w=m;A=void 0;v=void 0;for(A=w.__webglObjects.length-
+1;A>=0;A--){v=w.__webglObjects[A].object;B==v&&w.__webglObjects.splice(A,1)}m.__objectsRemoved.splice(0,1)}B=0;for(w=m.__webglObjects.length;B<w;B++)E(m.__webglObjects[B].object,m);B=0;for(w=m.__webglShadowVolumes.length;B<w;B++)E(m.__webglShadowVolumes[B].object,m);B=0;for(w=m.__webglLensFlares.length;B<w;B++)E(m.__webglLensFlares[B].object,m)};this.setFaceCulling=function(m,B){if(m){!B||B=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(m=="back")e.cullFace(e.BACK);else m=="front"?e.cullFace(e.FRONT):
 e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.WebGLRenderTarget=function(b,d,c){this.width=b;this.height=d;c=c||{};this.wrapS=c.wrapS!==undefined?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==undefined?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==undefined?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==undefined?c.minFilter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(b,d,c){c&&b.update(undefined,!1,d);c=b.sounds;var f,g=c.length;for(f=0;f<g;f++){b=c[f];this.soundPosition.set(b.matrixWorld.n14,b.matrixWorld.n24,b.matrixWorld.n34);this.soundPosition.subSelf(d.position);if(b.isPlaying&&b.isLoaded){b.isAddedToDOM||b.addToDOM(this.domElement);b.calculateVolumeAndPan(this.soundPosition)}}}};
@@ -328,11 +328,11 @@ THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.posi
 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};
-var GeometryUtils={merge:function(b,d){var c=d instanceof THREE.Mesh,f=b.vertices.length,g=c?d.geometry:d,h=b.vertices,j=g.vertices,k=b.faces,n=g.faces,p=b.faceVertexUvs[0];g=g.faceVertexUvs[0];c&&d.matrixAutoUpdate&&d.updateMatrix();for(var o=0,t=j.length;o<t;o++){var x=new THREE.Vertex(j[o].position.clone());c&&d.matrix.multiplyVector3(x.position);h.push(x)}o=0;for(t=n.length;o<t;o++){j=n[o];var v,z,C=j.vertexNormals;x=j.vertexColors;if(j instanceof THREE.Face3)v=new THREE.Face3(j.a+f,j.b+f,j.c+
-f);else j instanceof THREE.Face4&&(v=new THREE.Face4(j.a+f,j.b+f,j.c+f,j.d+f));v.normal.copy(j.normal);c=0;for(h=C.length;c<h;c++){z=C[c];v.vertexNormals.push(z.clone())}v.color.copy(j.color);c=0;for(h=x.length;c<h;c++){z=x[c];v.vertexColors.push(z.clone())}v.materials=j.materials.slice();v.centroid.copy(j.centroid);k.push(v)}o=0;for(t=g.length;o<t;o++){f=g[o];k=[];c=0;for(h=f.length;c<h;c++)k.push(new THREE.UV(f[c].u,f[c].v));p.push(k)}}},ImageUtils={loadTexture:function(b,d,c){var f=new Image,g=
+var GeometryUtils={merge:function(b,d){var c=d instanceof THREE.Mesh,f=b.vertices.length,g=c?d.geometry:d,h=b.vertices,j=g.vertices,k=b.faces,n=g.faces,p=b.faceVertexUvs[0];g=g.faceVertexUvs[0];c&&d.matrixAutoUpdate&&d.updateMatrix();for(var o=0,t=j.length;o<t;o++){var x=new THREE.Vertex(j[o].position.clone());c&&d.matrix.multiplyVector3(x.position);h.push(x)}o=0;for(t=n.length;o<t;o++){j=n[o];var u,z,C=j.vertexNormals;x=j.vertexColors;if(j instanceof THREE.Face3)u=new THREE.Face3(j.a+f,j.b+f,j.c+
+f);else j instanceof THREE.Face4&&(u=new THREE.Face4(j.a+f,j.b+f,j.c+f,j.d+f));u.normal.copy(j.normal);c=0;for(h=C.length;c<h;c++){z=C[c];u.vertexNormals.push(z.clone())}u.color.copy(j.color);c=0;for(h=x.length;c<h;c++){z=x[c];u.vertexColors.push(z.clone())}u.materials=j.materials.slice();u.centroid.copy(j.centroid);k.push(u)}o=0;for(t=g.length;o<t;o++){f=g[o];k=[];c=0;for(h=f.length;c<h;c++)k.push(new THREE.UV(f[c].u,f[c].v));p.push(k)}}},ImageUtils={loadTexture:function(b,d,c){var f=new Image,g=
 new THREE.Texture(f,d);f.onload=function(){g.needsUpdate=!0;c&&c(this)};f.src=b;return g},loadTextureCube:function(b,d,c){var f,g=[],h=new THREE.Texture(g,d);d=g.loadCount=0;for(f=b.length;d<f;++d){g[d]=new Image;g[d].onload=function(){g.loadCount+=1;if(g.loadCount==6)h.needsUpdate=!0;c&&c(this)};g[d].src=b[d]}return h}},SceneUtils={loadScene:function(b,d,c,f){var g=new Worker(b);g.postMessage(0);var h=THREE.Loader.prototype.extractUrlbase(b);g.onmessage=function(j){function k(Ba,ja){return ja=="relativeToHTML"?
-Ba:h+"/"+Ba}function n(){for(v in e.objects)if(!ca.objects[v]){U=e.objects[v];if(P=ca.geometries[U.geometry]){ta=[];for(sa=0;sa<U.materials.length;sa++)ta[sa]=ca.materials[U.materials[sa]];y=U.position;r=U.rotation;q=U.quaternion;s=U.scale;q=0;ta.length==0&&(ta[0]=new THREE.MeshFaceMaterial);object=new THREE.Mesh(P,ta);object.position.set(y[0],y[1],y[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);
-object.visible=U.visible;ca.scene.addObject(object);ca.objects[v]=object}}}function p(Ba){return function(ja){ca.geometries[Ba]=ja;n();Aa-=1;o()}}function o(){f({total_models:Ia,total_textures:ua,loaded_models:Ia-Aa,loaded_textures:ua-Ha},ca);Aa==0&&Ha==0&&c(ca)}var t,x,v,z,C,E,J,U,y,L,N,P,za,va,ta,e,fa,ea,Aa,Ha,Ia,ua,ca;e=j.data;fa=new THREE.BinaryLoader;ea=new THREE.JSONLoader;Ha=Aa=0;ca={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};j=function(){Ha-=
+Ba:h+"/"+Ba}function n(){for(u in e.objects)if(!ca.objects[u]){U=e.objects[u];if(P=ca.geometries[U.geometry]){ta=[];for(sa=0;sa<U.materials.length;sa++)ta[sa]=ca.materials[U.materials[sa]];y=U.position;r=U.rotation;q=U.quaternion;s=U.scale;q=0;ta.length==0&&(ta[0]=new THREE.MeshFaceMaterial);object=new THREE.Mesh(P,ta);object.position.set(y[0],y[1],y[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);
+object.visible=U.visible;ca.scene.addObject(object);ca.objects[u]=object}}}function p(Ba){return function(ja){ca.geometries[Ba]=ja;n();Aa-=1;o()}}function o(){f({total_models:Ia,total_textures:ua,loaded_models:Ia-Aa,loaded_textures:ua-Ha},ca);Aa==0&&Ha==0&&c(ca)}var t,x,u,z,C,E,J,U,y,L,N,P,za,va,ta,e,fa,ea,Aa,Ha,Ia,ua,ca;e=j.data;fa=new THREE.BinaryLoader;ea=new THREE.JSONLoader;Ha=Aa=0;ca={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};j=function(){Ha-=
 1;o()};for(C in e.cameras){L=e.cameras[C];if(L.type=="perspective")za=new THREE.Camera(L.fov,L.aspect,L.near,L.far);else if(L.type=="ortho"){za=new THREE.Camera;za.projectionMatrix=THREE.Matrix4.makeOrtho(L.left,L.right,L.top,L.bottom,L.near,L.far)}y=L.position;L=L.target;za.position.set(y[0],y[1],y[2]);za.target.position.set(L[0],L[1],L[2]);ca.cameras[C]=za}for(z in e.lights){C=e.lights[z];za=C.color!==undefined?C.color:16777215;L=C.intensity!==undefined?C.intensity:1;if(C.type=="directional"){y=
 C.direction;light=new THREE.DirectionalLight(za,L);light.position.set(y[0],y[1],y[2]);light.position.normalize()}else if(C.type=="point"){y=C.position;light=new THREE.PointLight(za,L);light.position.set(y[0],y[1],y[2])}ca.scene.addLight(light);ca.lights[z]=light}for(E in e.fogs){z=e.fogs[E];if(z.type=="linear")va=new THREE.Fog(0,z.near,z.far);else z.type=="exp2"&&(va=new THREE.FogExp2(0,z.density));L=z.color;va.color.setRGB(L[0],L[1],L[2]);ca.fogs[E]=va}if(ca.cameras&&e.defaults.camera)ca.currentCamera=
 ca.cameras[e.defaults.camera];if(ca.fogs&&e.defaults.fog)ca.scene.fog=ca.fogs[e.defaults.fog];L=e.defaults.bgcolor;ca.bgColor=new THREE.Color;ca.bgColor.setRGB(L[0],L[1],L[2]);ca.bgColorAlpha=e.defaults.bgalpha;for(t in e.geometries){E=e.geometries[t];if(E.type=="bin_mesh"||E.type=="ascii_mesh")Aa+=1}Ia=Aa;for(t in e.geometries){E=e.geometries[t];if(E.type=="cube"){P=new Cube(E.width,E.height,E.depth,E.segmentsWidth,E.segmentsHeight,E.segmentsDepth,null,E.flipped,E.sides);ca.geometries[t]=P}else if(E.type==
@@ -362,53 +362,53 @@ this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.tra
 Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;c=this.target.position;var f=this.position;c.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);c.y=f.y+100*Math.cos(this.phi);c.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(c){c.preventDefault()},!1);this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",
 d(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",d(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",d(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",d(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
 THREE.QuakeCamera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);if(this.noFly)d.y=0;this.position.addSelf(d.multiplyScalar(b));this.target.position.addSelf(d.multiplyScalar(b))};
-THREE.PathCamera=function(b){function d(p,o,t,x){var v={name:t,fps:0.6,length:x,hierarchy:[]},z,C=o.getControlPointsArray(),E=o.getLength(),J=C.length,U=0;z=J-1;o={parent:-1,keys:[]};o.keys[0]={time:0,pos:C[0],rot:[0,0,0,1],scl:[1,1,1]};o.keys[z]={time:x,pos:C[z],rot:[0,0,0,1],scl:[1,1,1]};for(z=1;z<J-1;z++){U=x*E.chunks[z]/E.total;o.keys[z]={time:U,pos:C[z]}}v.hierarchy[0]=o;THREE.AnimationHandler.add(v);return new THREE.Animation(p,t,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function c(p,o){var t,
-x,v=new THREE.Geometry;for(t=0;t<p.points.length*o;t++){x=t/(p.points.length*o);x=p.getPoint(x);v.vertices[t]=new THREE.Vertex(new THREE.Vector3(x.x,x.y,x.z))}return v}function f(p,o){var t=c(o,10),x=c(o,10),v=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(t,v);particleObj=new THREE.ParticleSystem(x,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);p.addChild(lineObj);particleObj.scale.set(1,1,1);p.addChild(particleObj);x=new Sphere(1,
-16,8);v=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<o.points.length;i++){t=new THREE.Mesh(x,v);t.position.copy(o.points[i]);t.updateMatrix();p.addChild(t)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
+THREE.PathCamera=function(b){function d(p,o,t,x){var u={name:t,fps:0.6,length:x,hierarchy:[]},z,C=o.getControlPointsArray(),E=o.getLength(),J=C.length,U=0;z=J-1;o={parent:-1,keys:[]};o.keys[0]={time:0,pos:C[0],rot:[0,0,0,1],scl:[1,1,1]};o.keys[z]={time:x,pos:C[z],rot:[0,0,0,1],scl:[1,1,1]};for(z=1;z<J-1;z++){U=x*E.chunks[z]/E.total;o.keys[z]={time:U,pos:C[z]}}u.hierarchy[0]=o;THREE.AnimationHandler.add(u);return new THREE.Animation(p,t,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function c(p,o){var t,
+x,u=new THREE.Geometry;for(t=0;t<p.points.length*o;t++){x=t/(p.points.length*o);x=p.getPoint(x);u.vertices[t]=new THREE.Vertex(new THREE.Vector3(x.x,x.y,x.z))}return u}function f(p,o){var t=c(o,10),x=c(o,10),u=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(t,u);particleObj=new THREE.ParticleSystem(x,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);p.addChild(lineObj);particleObj.scale.set(1,1,1);p.addChild(particleObj);x=new Sphere(1,
+16,8);u=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<o.points.length;i++){t=new THREE.Mesh(x,u);t.position.copy(o.points[i]);t.updateMatrix();p.addChild(t)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
 !0;this.lookHorizontal=!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(b){if(b.duration!==undefined)this.duration=b.duration*1E3;if(b.waypoints!==undefined)this.waypoints=b.waypoints;if(b.useConstantSpeed!==undefined)this.useConstantSpeed=b.useConstantSpeed;if(b.resamplingCoef!==undefined)this.resamplingCoef=b.resamplingCoef;if(b.createDebugPath!==undefined)this.createDebugPath=b.createDebugPath;
 if(b.createDebugDummy!==undefined)this.createDebugDummy=b.createDebugDummy;if(b.lookSpeed!==undefined)this.lookSpeed=b.lookSpeed;if(b.lookVertical!==undefined)this.lookVertical=b.lookVertical;if(b.lookHorizontal!==undefined)this.lookHorizontal=b.lookHorizontal;if(b.verticalAngleMap!==undefined)this.verticalAngleMap=b.verticalAngleMap;if(b.horizontalAngleMap!==undefined)this.horizontalAngleMap=b.horizontalAngleMap;if(b.domElement!==undefined)this.domElement=b.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 g=Math.PI*2,h=Math.PI/180;this.update=function(p,o,t){var x,v;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;x=this.phi%g;this.phi=x>=0?x:x+g;x=this.verticalAngleMap.srcRange;v=this.verticalAngleMap.dstRange;
-this.phi=(this.phi-x[0])*(v[1]-v[0])/(x[1]-x[0])+v[0];x=this.horizontalAngleMap.srcRange;v=this.horizontalAngleMap.dstRange;this.theta=(this.theta-x[0])*(v[1]-v[0])/(x[1]-x[0])+v[0];x=this.target.position;x.x=100*Math.sin(this.phi)*Math.cos(this.theta);x.y=100*Math.cos(this.phi);x.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,p,o,t)};this.onMouseMove=function(p){this.mouseX=p.clientX-this.windowHalfX;this.mouseY=p.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
+this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,h=Math.PI/180;this.update=function(p,o,t){var x,u;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;x=this.phi%g;this.phi=x>=0?x:x+g;x=this.verticalAngleMap.srcRange;u=this.verticalAngleMap.dstRange;
+this.phi=(this.phi-x[0])*(u[1]-u[0])/(x[1]-x[0])+u[0];x=this.horizontalAngleMap.srcRange;u=this.horizontalAngleMap.dstRange;this.theta=(this.theta-x[0])*(u[1]-u[0])/(x[1]-x[0])+u[0];x=this.target.position;x.x=100*Math.sin(this.phi)*Math.cos(this.theta);x.y=100*Math.cos(this.phi);x.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,p,o,t)};this.onMouseMove=function(p){this.mouseX=p.clientX-this.windowHalfX;this.mouseY=p.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
 this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){b=new THREE.MeshLambertMaterial({color:30719});var j=new THREE.MeshLambertMaterial({color:65280}),k=new Cube(10,10,20),n=new Cube(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(n,j);b.position.set(0,10,0);this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else{this.animation=
 d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(p,o){return function(){o.apply(p,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;
 var Cube=function(b,d,c,f,g,h,j,k,n){function p(E,J,U,y,L,N,P,za){var va,ta,e=f||1,fa=g||1,ea=L/2,Aa=N/2,Ha=o.vertices.length;if(E=="x"&&J=="y"||E=="y"&&J=="x")va="z";else if(E=="x"&&J=="z"||E=="z"&&J=="x"){va="y";fa=h||1}else if(E=="z"&&J=="y"||E=="y"&&J=="z"){va="x";e=h||1}var Ia=e+1,ua=fa+1;L/=e;var ca=N/fa;for(ta=0;ta<ua;ta++)for(N=0;N<Ia;N++){var sa=new THREE.Vector3;sa[E]=(N*L-ea)*U;sa[J]=(ta*ca-Aa)*y;sa[va]=P;o.vertices.push(new THREE.Vertex(sa))}for(ta=0;ta<fa;ta++)for(N=0;N<e;N++){o.faces.push(new THREE.Face4(N+
-Ia*ta+Ha,N+Ia*(ta+1)+Ha,N+1+Ia*(ta+1)+Ha,N+1+Ia*ta+Ha,null,null,za));o.faceVertexUvs[0].push([new THREE.UV(N/e,ta/fa),new THREE.UV(N/e,(ta+1)/fa),new THREE.UV((N+1)/e,(ta+1)/fa),new THREE.UV((N+1)/e,ta/fa)])}}THREE.Geometry.call(this);var o=this,t=b/2,x=d/2,v=c/2;k=k?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var z=0;z<6;z++)this.materials.push([j])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(n!=undefined)for(var C in n)this.sides[C]!=
-undefined&&(this.sides[C]=n[C]);this.sides.px&&p("z","y",1*k,-1,c,d,-t,this.materials[0]);this.sides.nx&&p("z","y",-1*k,-1,c,d,t,this.materials[1]);this.sides.py&&p("x","z",1*k,1,b,c,x,this.materials[2]);this.sides.ny&&p("x","z",1*k,-1,b,c,-x,this.materials[3]);this.sides.pz&&p("x","y",1*k,-1,b,d,v,this.materials[4]);this.sides.nz&&p("x","y",-1*k,-1,b,d,-v,this.materials[5]);(function(){for(var E=[],J=[],U=0,y=o.vertices.length;U<y;U++){for(var L=o.vertices[U],N=!1,P=0,za=E.length;P<za;P++){var va=
+Ia*ta+Ha,N+Ia*(ta+1)+Ha,N+1+Ia*(ta+1)+Ha,N+1+Ia*ta+Ha,null,null,za));o.faceVertexUvs[0].push([new THREE.UV(N/e,ta/fa),new THREE.UV(N/e,(ta+1)/fa),new THREE.UV((N+1)/e,(ta+1)/fa),new THREE.UV((N+1)/e,ta/fa)])}}THREE.Geometry.call(this);var o=this,t=b/2,x=d/2,u=c/2;k=k?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var z=0;z<6;z++)this.materials.push([j])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(n!=undefined)for(var C in n)this.sides[C]!=
+undefined&&(this.sides[C]=n[C]);this.sides.px&&p("z","y",1*k,-1,c,d,-t,this.materials[0]);this.sides.nx&&p("z","y",-1*k,-1,c,d,t,this.materials[1]);this.sides.py&&p("x","z",1*k,1,b,c,x,this.materials[2]);this.sides.ny&&p("x","z",1*k,-1,b,c,-x,this.materials[3]);this.sides.pz&&p("x","y",1*k,-1,b,d,u,this.materials[4]);this.sides.nz&&p("x","y",-1*k,-1,b,d,-u,this.materials[5]);(function(){for(var E=[],J=[],U=0,y=o.vertices.length;U<y;U++){for(var L=o.vertices[U],N=!1,P=0,za=E.length;P<za;P++){var va=
 E[P];if(L.position.x==va.position.x&&L.position.y==va.position.y&&L.position.z==va.position.z){J[U]=P;N=!0;break}}if(!N){J[U]=E.length;E.push(new THREE.Vertex(L.position.clone()))}}U=0;for(y=o.faces.length;U<y;U++){L=o.faces[U];L.a=J[L.a];L.b=J[L.b];L.c=J[L.c];L.d=J[L.d]}o.vertices=E})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
 var Cylinder=function(b,d,c,f,g,h){function j(o,t,x){k.vertices.push(new THREE.Vertex(new THREE.Vector3(o,t,x)))}THREE.Geometry.call(this);var k=this,n=Math.PI,p=f/2;for(f=0;f<b;f++)j(Math.sin(2*n*f/b)*d,Math.cos(2*n*f/b)*d,-p);for(f=0;f<b;f++)j(Math.sin(2*n*f/b)*c,Math.cos(2*n*f/b)*c,p);for(f=0;f<b;f++)k.faces.push(new THREE.Face4(f,f+b,b+(f+1)%b,(f+1)%b));if(c>0){j(0,0,-p-(h||0));for(f=b;f<b+b/2;f++)k.faces.push(new THREE.Face4(2*b,(2*f-2*b)%b,(2*f-2*b+1)%b,(2*f-2*b+2)%b))}if(d>0){j(0,0,p+(g||0));
 for(f=b+b/2;f<2*b;f++)k.faces.push(new THREE.Face4(2*b+1,(2*f-2*b+2)%b+b,(2*f-2*b+1)%b+b,(2*f-2*b)%b+b))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
-var Icosahedron=function(b){function d(t,x,v){var z=Math.sqrt(t*t+x*x+v*v);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(t/z,x/z,v/z)))-1}function c(t,x,v,z){z.faces.push(new THREE.Face3(t,x,v))}function f(t,x){var v=g.vertices[t].position,z=g.vertices[x].position;return d((v.x+z.x)/2,(v.y+z.y)/2,(v.z+z.z)/2)}var g=this,h=new THREE.Geometry,j;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;d(-1,b,0);d(1,b,0);d(-1,-b,0);d(1,-b,0);d(0,-1,b);d(0,1,b);d(0,-1,-b);d(0,
+var Icosahedron=function(b){function d(t,x,u){var z=Math.sqrt(t*t+x*x+u*u);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(t/z,x/z,u/z)))-1}function c(t,x,u,z){z.faces.push(new THREE.Face3(t,x,u))}function f(t,x){var u=g.vertices[t].position,z=g.vertices[x].position;return d((u.x+z.x)/2,(u.y+z.y)/2,(u.z+z.z)/2)}var g=this,h=new THREE.Geometry,j;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;d(-1,b,0);d(1,b,0);d(-1,-b,0);d(1,-b,0);d(0,-1,b);d(0,1,b);d(0,-1,-b);d(0,
 1,-b);d(b,0,-1);d(b,0,1);d(-b,0,-1);d(-b,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(b=0;b<this.subdivisions;b++){j=new THREE.Geometry;for(var k in h.faces){var n=f(h.faces[k].a,h.faces[k].b),p=f(h.faces[k].b,h.faces[k].c),o=f(h.faces[k].c,h.faces[k].a);c(h.faces[k].a,n,o,j);c(h.faces[k].b,p,n,j);c(h.faces[k].c,
 o,p,j);c(n,p,o,j)}h.faces=j.faces}g.faces=h.faces;delete h;delete j;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
 function Lathe(b,d,c){THREE.Geometry.call(this);this.steps=d||12;this.angle=c||2*Math.PI;d=this.angle/this.steps;for(var f=[],g=[],h=[],j=[],k=0;k<b.length;k++){this.vertices.push(new THREE.Vertex(b[k]));f[k]=b[k].clone();g[k]=this.vertices.length-1}for(var n=(new THREE.Matrix4).setRotationZ(d),p=0;p<=this.angle+0.0010;p+=d){for(k=0;k<f.length;k++)if(p<this.angle){f[k]=n.multiplyVector3(f[k].clone());this.vertices.push(new THREE.Vertex(f[k]));h[k]=this.vertices.length-1}else h=j;p==0&&(j=g);for(k=
 0;k<g.length-1;k++){this.faces.push(new THREE.Face4(h[k],h[k+1],g[k+1],g[k]));this.faceVertexUvs[0].push([new THREE.UV(p/c,k/b.length),new THREE.UV(p/c,(k+1)/b.length),new THREE.UV((p-d)/c,(k+1)/b.length),new THREE.UV((p-d)/c,k/b.length)])}g=h;h=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
 var Plane=function(b,d,c,f){THREE.Geometry.call(this);var g,h=b/2,j=d/2;c=c||1;f=f||1;var k=c+1,n=f+1;b/=c;var p=d/f;for(g=0;g<n;g++)for(d=0;d<k;d++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(d*b-h,-(g*p-j),0)));for(g=0;g<f;g++)for(d=0;d<c;d++){this.faces.push(new THREE.Face4(d+k*g,d+k*(g+1),d+1+k*(g+1),d+1+k*g));this.faceVertexUvs[0].push([new THREE.UV(d/c,g/f),new THREE.UV(d/c,(g+1)/f),new THREE.UV((d+1)/c,(g+1)/f),new THREE.UV((d+1)/c,g/f)])}this.computeCentroids();this.computeFaceNormals()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(b,d,c){THREE.Geometry.call(this);var f,g=Math.PI,h=Math.max(3,d||8),j=Math.max(2,c||6);d=[];for(c=0;c<j+1;c++){f=c/j;var k=b*Math.cos(f*g),n=b*Math.sin(f*g),p=[],o=0;for(f=0;f<h;f++){var t=2*f/h,x=n*Math.sin(t*g);t=n*Math.cos(t*g);(c==0||c==j)&&f>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,k,x)))-1);p.push(o)}d.push(p)}var v,z,C;g=d.length;for(c=0;c<g;c++){h=d[c].length;if(c>0)for(f=0;f<h;f++){p=f==h-1;j=d[c][p?0:f+1];k=d[c][p?h-1:f];n=d[c-1][p?h-1:f];p=d[c-1][p?
-0:f+1];x=c/(g-1);v=(c-1)/(g-1);z=(f+1)/h;t=f/h;o=new THREE.UV(1-z,x);x=new THREE.UV(1-t,x);t=new THREE.UV(1-t,v);var E=new THREE.UV(1-z,v);if(c<d.length-1){v=this.vertices[j].position.clone();z=this.vertices[k].position.clone();C=this.vertices[n].position.clone();v.normalize();z.normalize();C.normalize();this.faces.push(new THREE.Face3(j,k,n,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(C.x,C.y,C.z)]));this.faceVertexUvs[0].push([o,x,t])}if(c>1){v=this.vertices[j].position.clone();
-z=this.vertices[n].position.clone();C=this.vertices[p].position.clone();v.normalize();z.normalize();C.normalize();this.faces.push(new THREE.Face3(j,n,p,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(C.x,C.y,C.z)]));this.faceVertexUvs[0].push([o,t,E])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
+var Sphere=function(b,d,c){THREE.Geometry.call(this);var f,g=Math.PI,h=Math.max(3,d||8),j=Math.max(2,c||6);d=[];for(c=0;c<j+1;c++){f=c/j;var k=b*Math.cos(f*g),n=b*Math.sin(f*g),p=[],o=0;for(f=0;f<h;f++){var t=2*f/h,x=n*Math.sin(t*g);t=n*Math.cos(t*g);(c==0||c==j)&&f>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,k,x)))-1);p.push(o)}d.push(p)}var u,z,C;g=d.length;for(c=0;c<g;c++){h=d[c].length;if(c>0)for(f=0;f<h;f++){p=f==h-1;j=d[c][p?0:f+1];k=d[c][p?h-1:f];n=d[c-1][p?h-1:f];p=d[c-1][p?
+0:f+1];x=c/(g-1);u=(c-1)/(g-1);z=(f+1)/h;t=f/h;o=new THREE.UV(1-z,x);x=new THREE.UV(1-t,x);t=new THREE.UV(1-t,u);var E=new THREE.UV(1-z,u);if(c<d.length-1){u=this.vertices[j].position.clone();z=this.vertices[k].position.clone();C=this.vertices[n].position.clone();u.normalize();z.normalize();C.normalize();this.faces.push(new THREE.Face3(j,k,n,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(C.x,C.y,C.z)]));this.faceVertexUvs[0].push([o,x,t])}if(c>1){u=this.vertices[j].position.clone();
+z=this.vertices[n].position.clone();C=this.vertices[p].position.clone();u.normalize();z.normalize();C.normalize();this.faces.push(new THREE.Face3(j,n,p,[new THREE.Vector3(u.x,u.y,u.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(C.x,C.y,C.z)]));this.faceVertexUvs[0].push([o,t,E])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 var Torus=function(b,d,c,f){this.radius=b||100;this.tube=d||40;this.segmentsR=c||8;this.segmentsT=f||6;b=[];THREE.Geometry.call(this);for(d=0;d<=this.segmentsR;++d)for(c=0;c<=this.segmentsT;++c){f=c/this.segmentsT*2*Math.PI;var g=d/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));b.push([c/this.segmentsT,1-d/this.segmentsR])}for(d=1;d<=this.segmentsR;++d)for(c=
 1;c<=this.segmentsT;++c){f=(this.segmentsT+1)*d+c;g=(this.segmentsT+1)*d+c-1;var h=(this.segmentsT+1)*(d-1)+c-1,j=(this.segmentsT+1)*(d-1)+c;this.faces.push(new THREE.Face4(f,g,h,j));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[j][0],b[j][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
-var TorusKnot=function(b,d,c,f,g,h,j){function k(t,x,v,z,C,E){x=v/z*t;v=Math.cos(x);return new THREE.Vector3(C*(2+v)*0.5*Math.cos(t),C*(2+v)*Math.sin(t)*0.5,E*C*Math.sin(x)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=d||40;this.segmentsR=c||64;this.segmentsT=f||8;this.p=g||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;f=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(d=0;d<this.segmentsT;++d){var n=
+var TorusKnot=function(b,d,c,f,g,h,j){function k(t,x,u,z,C,E){x=u/z*t;u=Math.cos(x);return new THREE.Vector3(C*(2+u)*0.5*Math.cos(t),C*(2+u)*Math.sin(t)*0.5,E*C*Math.sin(x)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=d||40;this.segmentsR=c||64;this.segmentsT=f||8;this.p=g||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;f=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(d=0;d<this.segmentsT;++d){var n=
 b/this.segmentsR*2*this.p*Math.PI;j=d/this.segmentsT*2*Math.PI;g=k(n,j,this.q,this.p,this.radius,this.heightScale);n=k(n+0.01,j,this.q,this.p,this.radius,this.heightScale);c.x=n.x-g.x;c.y=n.y-g.y;c.z=n.z-g.z;f.x=n.x+g.x;f.y=n.y+g.y;f.z=n.z+g.z;h.cross(c,f);f.cross(h,c);h.normalize();f.normalize();n=this.tube*Math.cos(j);j=this.tube*Math.sin(j);g.x+=n*f.x+j*h.x;g.y+=n*f.y+j*h.y;g.z+=n*f.z+j*h.z;this.grid[b][d]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,g.z)))-1}}for(b=0;b<this.segmentsR;++b)for(d=
 0;d<this.segmentsT;++d){h=(b+1)%this.segmentsR;j=(d+1)%this.segmentsT;g=this.grid[b][d];c=this.grid[h][d];f=this.grid[b][j];h=this.grid[h][j];j=new THREE.UV(b/this.segmentsR,d/this.segmentsT);n=new THREE.UV((b+1)/this.segmentsR,d/this.segmentsT);var p=new THREE.UV(b/this.segmentsR,(d+1)/this.segmentsT),o=new THREE.UV((b+1)/this.segmentsR,(d+1)/this.segmentsT);this.faces.push(new THREE.Face3(g,c,f));this.faceVertexUvs[0].push([j,n,p]);this.faces.push(new THREE.Face3(h,f,c));this.faceVertexUvs[0].push([o,
 p,n])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;THREE.Loader=function(b){this.statusDomElement=(this.showStatus=b)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
 THREE.Loader.prototype={addStatusElement:function(){var b=document.createElement("div");b.style.position="absolute";b.style.right="0px";b.style.top="0px";b.style.fontSize="0.8em";b.style.textAlign="left";b.style.background="rgba(0,0,0,0.25)";b.style.color="#fff";b.style.width="120px";b.style.padding="0.5em 0.5em 0.5em 0.5em";b.style.zIndex=1E3;b.innerHTML="Loading ...";return b},updateProgress:function(b){var d="Loaded ";d+=b.total?(100*b.loaded/b.total).toFixed(0)+"%":(b.loaded/1E3).toFixed(2)+" KB";
 this.statusDomElement.innerHTML=d},extractUrlbase:function(b){b=b.split("/");b.pop();return b.join("/")},init_materials:function(b,d,c){b.materials=[];for(var f=0;f<d.length;++f)b.materials[f]=[THREE.Loader.prototype.createMaterial(d[f],c)]},createMaterial:function(b,d){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function f(k,n){var p=new Image;p.onload=function(){if(!c(this.width)||!c(this.height)){var o=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),t=Math.pow(2,Math.round(Math.log(this.height)/
-Math.LN2));k.image.width=o;k.image.height=t;k.image.getContext("2d").drawImage(this,0,0,o,t)}else k.image=this;k.needsUpdate=!0};p.src=n}var g,h,j;g="MeshLambertMaterial";h={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:b.vertexColors?THREE.VertexColors:!1,wireframe:b.wireframe};if(b.shading)if(b.shading=="Phong")g="MeshPhongMaterial";else b.shading=="Basic"&&(g="MeshBasicMaterial");if(b.blending)if(b.blending=="Additive")h.blending=THREE.AdditiveBlending;else if(b.blending=="Subtractive")h.blending=
-THREE.SubtractiveBlending;else if(b.blending=="Multiply")h.blending=THREE.MultiplyBlending;if(b.transparent!==undefined)h.transparent=b.transparent;if(b.depthTest!==undefined)h.depthTest=b.depthTest;if(b.mapDiffuse&&d){j=document.createElement("canvas");h.map=new THREE.Texture(j);h.map.sourceFile=b.mapDiffuse;f(h.map,d+"/"+b.mapDiffuse)}else if(b.colorDiffuse){j=(b.colorDiffuse[0]*255<<16)+(b.colorDiffuse[1]*255<<8)+b.colorDiffuse[2]*255;h.color=j;h.opacity=b.transparency}else if(b.DbgColor)h.color=
-b.DbgColor;if(b.mapLightmap&&d){j=document.createElement("canvas");h.lightMap=new THREE.Texture(j);h.lightMap.sourceFile=b.mapLightmap;f(h.lightMap,d+"/"+b.mapLightmap)}return new THREE[g](h)}};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
+Math.LN2));k.image.width=o;k.image.height=t;k.image.getContext("2d").drawImage(this,0,0,o,t)}else k.image=this;k.needsUpdate=!0};p.src=n}var g,h,j;g="MeshLambertMaterial";h={color:15658734,opacity:1,map:null,lightMap:null,wireframe:b.wireframe};if(b.shading)if(b.shading=="Phong")g="MeshPhongMaterial";else b.shading=="Basic"&&(g="MeshBasicMaterial");if(b.blending)if(b.blending=="Additive")h.blending=THREE.AdditiveBlending;else if(b.blending=="Subtractive")h.blending=THREE.SubtractiveBlending;else if(b.blending==
+"Multiply")h.blending=THREE.MultiplyBlending;if(b.transparent!==undefined)h.transparent=b.transparent;if(b.depthTest!==undefined)h.depthTest=b.depthTest;if(b.vertexColors!==undefined)if(b.vertexColors=="face")h.vertexColors=THREE.FaceColors;else if(b.vertexColors)h.vertexColors=THREE.VertexColors;if(b.mapDiffuse&&d){j=document.createElement("canvas");h.map=new THREE.Texture(j);h.map.sourceFile=b.mapDiffuse;f(h.map,d+"/"+b.mapDiffuse)}else if(b.colorDiffuse){j=(b.colorDiffuse[0]*255<<16)+(b.colorDiffuse[1]*
+255<<8)+b.colorDiffuse[2]*255;h.color=j;h.opacity=b.transparency}else if(b.DbgColor)h.color=b.DbgColor;if(b.mapLightmap&&d){j=document.createElement("canvas");h.lightMap=new THREE.Texture(j);h.lightMap.sourceFile=b.mapLightmap;f(h.lightMap,d+"/"+b.mapLightmap)}return new THREE[g](h)}};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
 THREE.JSONLoader.prototype.load=function(b){var d=this,c=b.model,f=b.callback,g=b.texture_path?b.texture_path:this.extractUrlbase(c);b=new Worker(c);b.onmessage=function(h){d.createModel(h.data,f,g);d.onLoadComplete()};this.onLoadStart();b.postMessage((new Date).getTime())};
-THREE.JSONLoader.prototype.createModel=function(b,d,c){var f=new THREE.Geometry;this.init_materials(f,b.materials,c);(function(){if(b.version===undefined||b.version!=2)console.error("Deprecated file format.");else{var g,h,j,k,n,p,o,t,x,v,z,C,E,J,U,y=b.faces;p=b.vertices;var L=b.normals,N=b.colors;o=b.scale!==undefined?b.scale:1;var P=0;for(g=0;g<b.uvs.length;g++)b.uvs[g].length&&P++;for(g=0;g<P;g++){f.faceUvs[g]=[];f.faceVertexUvs[g]=[]}k=0;for(n=p.length;k<n;){z=new THREE.Vertex;z.position.x=p[k++]/
-o;z.position.y=p[k++]/o;z.position.z=p[k++]/o;f.vertices.push(z)}k=0;for(n=y.length;k<n;){v=y[k++];p=v&1;j=v&2;g=v&4;h=v&8;t=v&16;o=v&32;z=v&64;v&=128;if(p){C=new THREE.Face4;C.a=y[k++];C.b=y[k++];C.c=y[k++];C.d=y[k++];p=4}else{C=new THREE.Face3;C.a=y[k++];C.b=y[k++];C.c=y[k++];p=3}if(j){j=y[k++];C.materials=f.materials[j]}j=f.faces.length;if(g)for(g=0;g<P;g++){E=b.uvs[g];x=y[k++];U=E[x*2];x=E[x*2+1];f.faceUvs[g][j]=new THREE.UV(U,x)}if(h)for(g=0;g<P;g++){E=b.uvs[g];J=[];for(h=0;h<p;h++){x=y[k++];
-U=E[x*2];x=E[x*2+1];J[h]=new THREE.UV(U,x)}f.faceVertexUvs[g][j]=J}if(t){t=y[k++]*3;h=new THREE.Vector3;h.x=L[t++];h.y=L[t++];h.z=L[t];C.normal=h}if(o)for(g=0;g<p;g++){t=y[k++]*3;h=new THREE.Vector3;h.x=L[t++];h.y=L[t++];h.z=L[t];C.vertexNormals.push(h)}if(z){o=new THREE.Color(y[k++]);C.color=o}if(v)for(g=0;g<p;g++){o=y[k++];o=new THREE.Color(N[o]);C.vertexColors.push(o)}f.faces.push(C)}}})();(function(){var g,h,j,k;if(b.skinWeights){g=0;for(h=b.skinWeights.length;g<h;g+=2){j=b.skinWeights[g];k=b.skinWeights[g+
-1];f.skinWeights.push(new THREE.Vector4(j,k,0,0))}}if(b.skinIndices){g=0;for(h=b.skinIndices.length;g<h;g+=2){j=b.skinIndices[g];k=b.skinIndices[g+1];f.skinIndices.push(new THREE.Vector4(j,k,0,0))}}f.bones=b.bones;f.animation=b.animation})();(function(){if(b.morphTargets!==undefined){var g,h,j,k,n,p;g=0;for(h=b.morphTargets.length;g<h;g++){f.morphTargets[g]={};f.morphTargets[g].name=b.morphTargets[g].name;f.morphTargets[g].vertices=[];n=f.morphTargets[g].vertices;p=b.morphTargets[g].vertices;j=0;
-for(k=p.length;j<k;j+=3)n.push(new THREE.Vertex(new THREE.Vector3(p[j],p[j+1],p[j+2])))}}if(b.morphColors!==undefined){var o,t;g=0;for(h=b.morphColors.length;g<h;g++){f.morphColors[g]={};f.morphColors[g].name=b.morphColors[g].name;f.morphColors[g].colors=[];p=f.morphColors[g].colors;o=b.morphColors[g].colors;k=0;for(n=o.length;k<n;k+=3){t=new THREE.Color(16755200);t.setRGB(o[j],o[j+1],o[j+2]);p.push(t)}}}})();f.computeCentroids();f.computeFaceNormals();d(f)};
+THREE.JSONLoader.prototype.createModel=function(b,d,c){var f=new THREE.Geometry;this.init_materials(f,b.materials,c);(function(){if(b.version===undefined||b.version!=2)console.error("Deprecated file format.");else{var g,h,j,k,n,p,o,t,x,u,z,C,E,J,U,y=b.faces;u=b.vertices;var L=b.normals,N=b.colors;p=b.scale!==undefined?b.scale:1;var P=0;for(g=0;g<b.uvs.length;g++)b.uvs[g].length&&P++;for(g=0;g<P;g++){f.faceUvs[g]=[];f.faceVertexUvs[g]=[]}k=0;for(n=u.length;k<n;){o=new THREE.Vertex;o.position.x=u[k++]/
+p;o.position.y=u[k++]/p;o.position.z=u[k++]/p;f.vertices.push(o)}k=0;for(n=y.length;k<n;){u=y[k++];p=u&1;j=u&2;g=u&4;h=u&8;t=u&16;o=u&32;z=u&64;u&=128;if(p){C=new THREE.Face4;C.a=y[k++];C.b=y[k++];C.c=y[k++];C.d=y[k++];p=4}else{C=new THREE.Face3;C.a=y[k++];C.b=y[k++];C.c=y[k++];p=3}if(j){j=y[k++];C.materials=f.materials[j]}j=f.faces.length;if(g)for(g=0;g<P;g++){E=b.uvs[g];x=y[k++];U=E[x*2];x=E[x*2+1];f.faceUvs[g][j]=new THREE.UV(U,x)}if(h)for(g=0;g<P;g++){E=b.uvs[g];J=[];for(h=0;h<p;h++){x=y[k++];
+U=E[x*2];x=E[x*2+1];J[h]=new THREE.UV(U,x)}f.faceVertexUvs[g][j]=J}if(t){t=y[k++]*3;h=new THREE.Vector3;h.x=L[t++];h.y=L[t++];h.z=L[t];C.normal=h}if(o)for(g=0;g<p;g++){t=y[k++]*3;h=new THREE.Vector3;h.x=L[t++];h.y=L[t++];h.z=L[t];C.vertexNormals.push(h)}if(z){o=y[k++];o=new THREE.Color(N[o]);C.color=o}if(u)for(g=0;g<p;g++){o=y[k++];o=new THREE.Color(N[o]);C.vertexColors.push(o)}f.faces.push(C)}}})();(function(){var g,h,j,k;if(b.skinWeights){g=0;for(h=b.skinWeights.length;g<h;g+=2){j=b.skinWeights[g];
+k=b.skinWeights[g+1];f.skinWeights.push(new THREE.Vector4(j,k,0,0))}}if(b.skinIndices){g=0;for(h=b.skinIndices.length;g<h;g+=2){j=b.skinIndices[g];k=b.skinIndices[g+1];f.skinIndices.push(new THREE.Vector4(j,k,0,0))}}f.bones=b.bones;f.animation=b.animation})();(function(){if(b.morphTargets!==undefined){var g,h,j,k,n,p;g=0;for(h=b.morphTargets.length;g<h;g++){f.morphTargets[g]={};f.morphTargets[g].name=b.morphTargets[g].name;f.morphTargets[g].vertices=[];n=f.morphTargets[g].vertices;p=b.morphTargets[g].vertices;
+j=0;for(k=p.length;j<k;j+=3)n.push(new THREE.Vertex(new THREE.Vector3(p[j],p[j+1],p[j+2])))}}if(b.morphColors!==undefined){var o,t;g=0;for(h=b.morphColors.length;g<h;g++){f.morphColors[g]={};f.morphColors[g].name=b.morphColors[g].name;f.morphColors[g].colors=[];p=f.morphColors[g].colors;o=b.morphColors[g].colors;k=0;for(n=o.length;k<n;k+=3){t=new THREE.Color(16755200);t.setRGB(o[j],o[j+1],o[j+2]);p.push(t)}}}})();f.computeCentroids();f.computeFaceNormals();d(f)};
 THREE.BinaryLoader=function(b){THREE.Loader.call(this,b)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
 THREE.BinaryLoader.prototype={load:function(b){var d=b.model,c=b.callback,f=b.texture_path?b.texture_path:THREE.Loader.prototype.extractUrlbase(d),g=b.bin_path?b.bin_path:THREE.Loader.prototype.extractUrlbase(d);b=(new Date).getTime();d=new Worker(d);var h=this.showProgress?THREE.Loader.prototype.updateProgress:null;d.onmessage=function(j){THREE.BinaryLoader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,c,g,f,h)};d.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};
 d.postMessage(b)},loadAjaxBuffers:function(b,d,c,f,g,h){var j=new XMLHttpRequest,k=f+"/"+b,n=0;j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.BinaryLoader.prototype.createBinModel(j.responseText,c,g,d):alert("Couldn't load ["+k+"] ["+j.status+"]");else if(j.readyState==3){if(h){n==0&&(n=j.getResponseHeader("Content-Length"));h({total:n,loaded:j.responseText.length})}}else j.readyState==2&&(n=j.getResponseHeader("Content-Length"))};j.open("GET",k,!0);j.overrideMimeType("text/plain; charset=x-user-defined");
 j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(b,d,c,f){var g=function(h){function j(O,aa){var qa=o(O,aa),Da=o(O,aa+1),ha=o(O,aa+2),la=o(O,aa+3),m=(la<<1&255|ha>>7)-127;qa|=(ha&127)<<16|Da<<8;if(qa==0&&m==-127)return 0;return(1-2*(la>>7))*(1+qa*Math.pow(2,-23))*Math.pow(2,m)}function k(O,aa){var qa=o(O,aa),Da=o(O,aa+1),ha=o(O,aa+2);return(o(O,aa+3)<<24)+(ha<<16)+(Da<<8)+qa}function n(O,aa){var qa=o(O,aa);return(o(O,aa+1)<<8)+qa}function p(O,aa){var qa=o(O,aa);
-return qa>127?qa-256:qa}function o(O,aa){return O.charCodeAt(aa)&255}function t(O){var aa,qa,Da;aa=k(b,O);qa=k(b,O+P);Da=k(b,O+za);O=n(b,O+va);THREE.BinaryLoader.prototype.f3(J,aa,qa,Da,O)}function x(O){var aa,qa,Da,ha,la,m;aa=k(b,O);qa=k(b,O+P);Da=k(b,O+za);ha=n(b,O+va);la=k(b,O+ta);m=k(b,O+e);O=k(b,O+fa);THREE.BinaryLoader.prototype.f3n(J,L,aa,qa,Da,ha,la,m,O)}function v(O){var aa,qa,Da,ha;aa=k(b,O);qa=k(b,O+ea);Da=k(b,O+Aa);ha=k(b,O+Ha);O=n(b,O+Ia);THREE.BinaryLoader.prototype.f4(J,aa,qa,Da,ha,
+return qa>127?qa-256:qa}function o(O,aa){return O.charCodeAt(aa)&255}function t(O){var aa,qa,Da;aa=k(b,O);qa=k(b,O+P);Da=k(b,O+za);O=n(b,O+va);THREE.BinaryLoader.prototype.f3(J,aa,qa,Da,O)}function x(O){var aa,qa,Da,ha,la,m;aa=k(b,O);qa=k(b,O+P);Da=k(b,O+za);ha=n(b,O+va);la=k(b,O+ta);m=k(b,O+e);O=k(b,O+fa);THREE.BinaryLoader.prototype.f3n(J,L,aa,qa,Da,ha,la,m,O)}function u(O){var aa,qa,Da,ha;aa=k(b,O);qa=k(b,O+ea);Da=k(b,O+Aa);ha=k(b,O+Ha);O=n(b,O+Ia);THREE.BinaryLoader.prototype.f4(J,aa,qa,Da,ha,
 O)}function z(O){var aa,qa,Da,ha,la,m,B,w;aa=k(b,O);qa=k(b,O+ea);Da=k(b,O+Aa);ha=k(b,O+Ha);la=n(b,O+Ia);m=k(b,O+ua);B=k(b,O+ca);w=k(b,O+sa);O=k(b,O+Ba);THREE.BinaryLoader.prototype.f4n(J,L,aa,qa,Da,ha,la,m,B,w,O)}function C(O){var aa,qa;aa=k(b,O);qa=k(b,O+ja);O=k(b,O+$);THREE.BinaryLoader.prototype.uv3(J.faceVertexUvs[0],N[aa*2],N[aa*2+1],N[qa*2],N[qa*2+1],N[O*2],N[O*2+1])}function E(O){var aa,qa,Da;aa=k(b,O);qa=k(b,O+pa);Da=k(b,O+Fa);O=k(b,O+ka);THREE.BinaryLoader.prototype.uv4(J.faceVertexUvs[0],
 N[aa*2],N[aa*2+1],N[qa*2],N[qa*2+1],N[Da*2],N[Da*2+1],N[O*2],N[O*2+1])}var J=this,U=0,y,L=[],N=[],P,za,va,ta,e,fa,ea,Aa,Ha,Ia,ua,ca,sa,Ba,ja,$,pa,Fa,ka,oa,Ga,Ra,Za,Va,Sa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(J,f,h);y={signature:b.substr(U,8),header_bytes:o(b,U+8),vertex_coordinate_bytes:o(b,U+9),normal_coordinate_bytes:o(b,U+10),uv_coordinate_bytes:o(b,U+11),vertex_index_bytes:o(b,U+12),normal_index_bytes:o(b,U+13),uv_index_bytes:o(b,U+14),material_index_bytes:o(b,U+15),
 nvertices:k(b,U+16),nnormals:k(b,U+16+4),nuvs:k(b,U+16+8),ntri_flat:k(b,U+16+12),ntri_smooth:k(b,U+16+16),ntri_flat_uv:k(b,U+16+20),ntri_smooth_uv:k(b,U+16+24),nquad_flat:k(b,U+16+28),nquad_smooth:k(b,U+16+32),nquad_flat_uv:k(b,U+16+36),nquad_smooth_uv:k(b,U+16+40)};U+=y.header_bytes;P=y.vertex_index_bytes;za=y.vertex_index_bytes*2;va=y.vertex_index_bytes*3;ta=y.vertex_index_bytes*3+y.material_index_bytes;e=y.vertex_index_bytes*3+y.material_index_bytes+y.normal_index_bytes;fa=y.vertex_index_bytes*
@@ -416,22 +416,22 @@ nvertices:k(b,U+16),nnormals:k(b,U+16+4),nuvs:k(b,U+16+8),ntri_flat:k(b,U+16+12)
 3;h=y.vertex_index_bytes*3+y.material_index_bytes;Sa=y.vertex_index_bytes*4+y.material_index_bytes;oa=y.ntri_flat*h;Ga=y.ntri_smooth*(h+y.normal_index_bytes*3);Ra=y.ntri_flat_uv*(h+y.uv_index_bytes*3);Za=y.ntri_smooth_uv*(h+y.normal_index_bytes*3+y.uv_index_bytes*3);Va=y.nquad_flat*Sa;h=y.nquad_smooth*(Sa+y.normal_index_bytes*4);Sa=y.nquad_flat_uv*(Sa+y.uv_index_bytes*4);U+=function(O){for(var aa,qa,Da,ha=y.vertex_coordinate_bytes*3,la=O+y.nvertices*ha;O<la;O+=ha){aa=j(b,O);qa=j(b,O+y.vertex_coordinate_bytes);
 Da=j(b,O+y.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(J,aa,qa,Da)}return y.nvertices*ha}(U);U+=function(O){for(var aa,qa,Da,ha=y.normal_coordinate_bytes*3,la=O+y.nnormals*ha;O<la;O+=ha){aa=p(b,O);qa=p(b,O+y.normal_coordinate_bytes);Da=p(b,O+y.normal_coordinate_bytes*2);L.push(aa/127,qa/127,Da/127)}return y.nnormals*ha}(U);U+=function(O){for(var aa,qa,Da=y.uv_coordinate_bytes*2,ha=O+y.nuvs*Da;O<ha;O+=Da){aa=j(b,O);qa=j(b,O+y.uv_coordinate_bytes);N.push(aa,qa)}return y.nuvs*Da}(U);oa=
 U+oa;Ga=oa+Ga;Ra=Ga+Ra;Za=Ra+Za;Va=Za+Va;h=Va+h;Sa=h+Sa;(function(O){var aa,qa=y.vertex_index_bytes*3+y.material_index_bytes,Da=qa+y.uv_index_bytes*3,ha=O+y.ntri_flat_uv*Da;for(aa=O;aa<ha;aa+=Da){t(aa);C(aa+qa)}return ha-O})(Ga);(function(O){var aa,qa=y.vertex_index_bytes*3+y.material_index_bytes+y.normal_index_bytes*3,Da=qa+y.uv_index_bytes*3,ha=O+y.ntri_smooth_uv*Da;for(aa=O;aa<ha;aa+=Da){x(aa);C(aa+qa)}return ha-O})(Ra);(function(O){var aa,qa=y.vertex_index_bytes*4+y.material_index_bytes,Da=qa+
-y.uv_index_bytes*4,ha=O+y.nquad_flat_uv*Da;for(aa=O;aa<ha;aa+=Da){v(aa);E(aa+qa)}return ha-O})(h);(function(O){var aa,qa=y.vertex_index_bytes*4+y.material_index_bytes+y.normal_index_bytes*4,Da=qa+y.uv_index_bytes*4,ha=O+y.nquad_smooth_uv*Da;for(aa=O;aa<ha;aa+=Da){z(aa);E(aa+qa)}return ha-O})(Sa);(function(O){var aa,qa=y.vertex_index_bytes*3+y.material_index_bytes,Da=O+y.ntri_flat*qa;for(aa=O;aa<Da;aa+=qa)t(aa);return Da-O})(U);(function(O){var aa,qa=y.vertex_index_bytes*3+y.material_index_bytes+y.normal_index_bytes*
-3,Da=O+y.ntri_smooth*qa;for(aa=O;aa<Da;aa+=qa)x(aa);return Da-O})(oa);(function(O){var aa,qa=y.vertex_index_bytes*4+y.material_index_bytes,Da=O+y.nquad_flat*qa;for(aa=O;aa<Da;aa+=qa)v(aa);return Da-O})(Za);(function(O){var aa,qa=y.vertex_index_bytes*4+y.material_index_bytes+y.normal_index_bytes*4,Da=O+y.nquad_smooth*qa;for(aa=O;aa<Da;aa+=qa)z(aa);return Da-O})(Va);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;d(new g(c))},v:function(b,
+y.uv_index_bytes*4,ha=O+y.nquad_flat_uv*Da;for(aa=O;aa<ha;aa+=Da){u(aa);E(aa+qa)}return ha-O})(h);(function(O){var aa,qa=y.vertex_index_bytes*4+y.material_index_bytes+y.normal_index_bytes*4,Da=qa+y.uv_index_bytes*4,ha=O+y.nquad_smooth_uv*Da;for(aa=O;aa<ha;aa+=Da){z(aa);E(aa+qa)}return ha-O})(Sa);(function(O){var aa,qa=y.vertex_index_bytes*3+y.material_index_bytes,Da=O+y.ntri_flat*qa;for(aa=O;aa<Da;aa+=qa)t(aa);return Da-O})(U);(function(O){var aa,qa=y.vertex_index_bytes*3+y.material_index_bytes+y.normal_index_bytes*
+3,Da=O+y.ntri_smooth*qa;for(aa=O;aa<Da;aa+=qa)x(aa);return Da-O})(oa);(function(O){var aa,qa=y.vertex_index_bytes*4+y.material_index_bytes,Da=O+y.nquad_flat*qa;for(aa=O;aa<Da;aa+=qa)u(aa);return Da-O})(Za);(function(O){var aa,qa=y.vertex_index_bytes*4+y.material_index_bytes+y.normal_index_bytes*4,Da=O+y.nquad_smooth*qa;for(aa=O;aa<Da;aa+=qa)z(aa);return Da-O})(Va);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;d(new g(c))},v:function(b,
 d,c,f){b.vertices.push(new THREE.Vertex(new THREE.Vector3(d,c,f)))},f3:function(b,d,c,f,g){b.faces.push(new THREE.Face3(d,c,f,null,null,b.materials[g]))},f4:function(b,d,c,f,g,h){b.faces.push(new THREE.Face4(d,c,f,g,null,null,b.materials[h]))},f3n:function(b,d,c,f,g,h,j,k,n){h=b.materials[h];var p=d[k*3],o=d[k*3+1];k=d[k*3+2];var t=d[n*3],x=d[n*3+1];n=d[n*3+2];b.faces.push(new THREE.Face3(c,f,g,[new THREE.Vector3(d[j*3],d[j*3+1],d[j*3+2]),new THREE.Vector3(p,o,k),new THREE.Vector3(t,x,n)],null,h))},
-f4n:function(b,d,c,f,g,h,j,k,n,p,o){j=b.materials[j];var t=d[n*3],x=d[n*3+1];n=d[n*3+2];var v=d[p*3],z=d[p*3+1];p=d[p*3+2];var C=d[o*3],E=d[o*3+1];o=d[o*3+2];b.faces.push(new THREE.Face4(c,f,g,h,[new THREE.Vector3(d[k*3],d[k*3+1],d[k*3+2]),new THREE.Vector3(t,x,n),new THREE.Vector3(v,z,p),new THREE.Vector3(C,E,o)],null,j))},uv3:function(b,d,c,f,g,h,j){var k=[];k.push(new THREE.UV(d,c));k.push(new THREE.UV(f,g));k.push(new THREE.UV(h,j));b.push(k)},uv4:function(b,d,c,f,g,h,j,k,n){var p=[];p.push(new THREE.UV(d,
+f4n:function(b,d,c,f,g,h,j,k,n,p,o){j=b.materials[j];var t=d[n*3],x=d[n*3+1];n=d[n*3+2];var u=d[p*3],z=d[p*3+1];p=d[p*3+2];var C=d[o*3],E=d[o*3+1];o=d[o*3+2];b.faces.push(new THREE.Face4(c,f,g,h,[new THREE.Vector3(d[k*3],d[k*3+1],d[k*3+2]),new THREE.Vector3(t,x,n),new THREE.Vector3(u,z,p),new THREE.Vector3(C,E,o)],null,j))},uv3:function(b,d,c,f,g,h,j){var k=[];k.push(new THREE.UV(d,c));k.push(new THREE.UV(f,g));k.push(new THREE.UV(h,j));b.push(k)},uv4:function(b,d,c,f,g,h,j,k,n){var p=[];p.push(new THREE.UV(d,
 c));p.push(new THREE.UV(f,g));p.push(new THREE.UV(h,j));p.push(new THREE.UV(k,n));b.push(p)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 THREE.MarchingCubes=function(b,d){THREE.Object3D.call(this);this.materials=d instanceof Array?d:[d];this.init=function(c){this.isolation=80;this.size=c;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.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,f,g){return c+(f-c)*g};this.VIntX=function(c,f,g,h,j,k,n,p,o,t){j=(j-o)/(t-o);o=this.normal_cache;f[h]=k+j*this.delta;f[h+1]=n;f[h+2]=p;g[h]=this.lerp(o[c],o[c+3],j);g[h+1]=this.lerp(o[c+1],o[c+4],j);g[h+2]=this.lerp(o[c+2],o[c+5],j)};this.VIntY=function(c,f,g,h,j,k,n,p,o,t){j=(j-o)/(t-o);o=this.normal_cache;f[h]=k;f[h+1]=n+j*this.delta;f[h+
 2]=p;f=c+this.yd*3;g[h]=this.lerp(o[c],o[f],j);g[h+1]=this.lerp(o[c+1],o[f+1],j);g[h+2]=this.lerp(o[c+2],o[f+2],j)};this.VIntZ=function(c,f,g,h,j,k,n,p,o,t){j=(j-o)/(t-o);o=this.normal_cache;f[h]=k;f[h+1]=n;f[h+2]=p+j*this.delta;f=c+this.zd*3;g[h]=this.lerp(o[c],o[f],j);g[h+1]=this.lerp(o[c+1],o[f+1],j);g[h+2]=this.lerp(o[c+2],o[f+2],j)};this.compNorm=function(c){var f=c*3;if(this.normal_cache[f]==0){this.normal_cache[f]=this.field[c-1]-this.field[c+1];this.normal_cache[f+1]=this.field[c-this.yd]-
-this.field[c+this.yd];this.normal_cache[f+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,f,g,h,j,k){var n=h+1,p=h+this.yd,o=h+this.zd,t=n+this.yd,x=n+this.zd,v=h+this.yd+this.zd,z=n+this.yd+this.zd,C=0,E=this.field[h],J=this.field[n],U=this.field[p],y=this.field[t],L=this.field[o],N=this.field[x],P=this.field[v],za=this.field[z];E<j&&(C|=1);J<j&&(C|=2);U<j&&(C|=8);y<j&&(C|=4);L<j&&(C|=16);N<j&&(C|=32);P<j&&(C|=128);za<j&&(C|=64);var va=THREE.edgeTable[C];if(va==0)return 0;
+this.field[c+this.yd];this.normal_cache[f+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,f,g,h,j,k){var n=h+1,p=h+this.yd,o=h+this.zd,t=n+this.yd,x=n+this.zd,u=h+this.yd+this.zd,z=n+this.yd+this.zd,C=0,E=this.field[h],J=this.field[n],U=this.field[p],y=this.field[t],L=this.field[o],N=this.field[x],P=this.field[u],za=this.field[z];E<j&&(C|=1);J<j&&(C|=2);U<j&&(C|=8);y<j&&(C|=4);L<j&&(C|=16);N<j&&(C|=32);P<j&&(C|=128);za<j&&(C|=64);var va=THREE.edgeTable[C];if(va==0)return 0;
 var ta=this.delta,e=c+ta,fa=f+ta;ta=g+ta;if(va&1){this.compNorm(h);this.compNorm(n);this.VIntX(h*3,this.vlist,this.nlist,0,j,c,f,g,E,J)}if(va&2){this.compNorm(n);this.compNorm(t);this.VIntY(n*3,this.vlist,this.nlist,3,j,e,f,g,J,y)}if(va&4){this.compNorm(p);this.compNorm(t);this.VIntX(p*3,this.vlist,this.nlist,6,j,c,fa,g,U,y)}if(va&8){this.compNorm(h);this.compNorm(p);this.VIntY(h*3,this.vlist,this.nlist,9,j,c,f,g,E,U)}if(va&16){this.compNorm(o);this.compNorm(x);this.VIntX(o*3,this.vlist,this.nlist,
-12,j,c,f,ta,L,N)}if(va&32){this.compNorm(x);this.compNorm(z);this.VIntY(x*3,this.vlist,this.nlist,15,j,e,f,ta,N,za)}if(va&64){this.compNorm(v);this.compNorm(z);this.VIntX(v*3,this.vlist,this.nlist,18,j,c,fa,ta,P,za)}if(va&128){this.compNorm(o);this.compNorm(v);this.VIntY(o*3,this.vlist,this.nlist,21,j,c,f,ta,L,P)}if(va&256){this.compNorm(h);this.compNorm(o);this.VIntZ(h*3,this.vlist,this.nlist,24,j,c,f,g,E,L)}if(va&512){this.compNorm(n);this.compNorm(x);this.VIntZ(n*3,this.vlist,this.nlist,27,j,e,
-f,g,J,N)}if(va&1024){this.compNorm(t);this.compNorm(z);this.VIntZ(t*3,this.vlist,this.nlist,30,j,e,fa,g,y,za)}if(va&2048){this.compNorm(p);this.compNorm(v);this.VIntZ(p*3,this.vlist,this.nlist,33,j,c,fa,g,U,P)}C<<=4;for(j=h=0;THREE.triTable[C+j]!=-1;){c=C+j;f=c+1;g=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[f],3*THREE.triTable[g],k);j+=3;h++}return h};this.posnormtriv=function(c,f,g,h,j,k){var n=this.count*3;this.positionArray[n]=c[g];this.positionArray[n+1]=c[g+
+12,j,c,f,ta,L,N)}if(va&32){this.compNorm(x);this.compNorm(z);this.VIntY(x*3,this.vlist,this.nlist,15,j,e,f,ta,N,za)}if(va&64){this.compNorm(u);this.compNorm(z);this.VIntX(u*3,this.vlist,this.nlist,18,j,c,fa,ta,P,za)}if(va&128){this.compNorm(o);this.compNorm(u);this.VIntY(o*3,this.vlist,this.nlist,21,j,c,f,ta,L,P)}if(va&256){this.compNorm(h);this.compNorm(o);this.VIntZ(h*3,this.vlist,this.nlist,24,j,c,f,g,E,L)}if(va&512){this.compNorm(n);this.compNorm(x);this.VIntZ(n*3,this.vlist,this.nlist,27,j,e,
+f,g,J,N)}if(va&1024){this.compNorm(t);this.compNorm(z);this.VIntZ(t*3,this.vlist,this.nlist,30,j,e,fa,g,y,za)}if(va&2048){this.compNorm(p);this.compNorm(u);this.VIntZ(p*3,this.vlist,this.nlist,33,j,c,fa,g,U,P)}C<<=4;for(j=h=0;THREE.triTable[C+j]!=-1;){c=C+j;f=c+1;g=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[f],3*THREE.triTable[g],k);j+=3;h++}return h};this.posnormtriv=function(c,f,g,h,j,k){var n=this.count*3;this.positionArray[n]=c[g];this.positionArray[n+1]=c[g+
 1];this.positionArray[n+2]=c[g+2];this.positionArray[n+3]=c[h];this.positionArray[n+4]=c[h+1];this.positionArray[n+5]=c[h+2];this.positionArray[n+6]=c[j];this.positionArray[n+7]=c[j+1];this.positionArray[n+8]=c[j+2];this.normalArray[n]=f[g];this.normalArray[n+1]=f[g+1];this.normalArray[n+2]=f[g+2];this.normalArray[n+3]=f[h];this.normalArray[n+4]=f[h+1];this.normalArray[n+5]=f[h+2];this.normalArray[n+6]=f[j];this.normalArray[n+7]=f[j+1];this.normalArray[n+8]=f[j+2];this.hasPos=!0;this.hasNormal=!0;
 this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var f=this.count*3;f<this.positionArray.length;f++)this.positionArray[f]=0;c(this)}};this.addBall=function(c,f,g,h,j){var k=this.size*Math.sqrt(h/j),n=g*this.size,p=f*this.size,o=c*this.size,t=Math.floor(n-k);t<1&&(t=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var x=Math.floor(p-k);x<1&&(x=1);p=Math.floor(p+k);p>this.size-1&&(p=
-this.size-1);var v=Math.floor(o-k);v<1&&(v=1);k=Math.floor(o+k);k>this.size-1&&(k=this.size-1);for(var z,C,E,J,U,y;t<n;t++){o=this.size2*t;C=t/this.size-g;U=C*C;for(C=x;C<p;C++){E=o+this.size*C;z=C/this.size-f;y=z*z;for(z=v;z<k;z++){J=z/this.size-c;J=h/(1.0E-6+J*J+y+U)-j;J>0&&(this.field[E+z]+=J)}}}};this.addPlaneX=function(c,f){var g,h,j,k,n,p=this.size,o=this.yd,t=this.zd,x=this.field,v=p*Math.sqrt(c/f);v>p&&(v=p);for(g=0;g<v;g++){h=g/p;h*=h;k=c/(1.0E-4+h)-f;if(k>0)for(h=0;h<p;h++){n=g+h*o;for(j=
-0;j<p;j++)x[t*j+n]+=k}}};this.addPlaneY=function(c,f){var g,h,j,k,n,p,o=this.size,t=this.yd,x=this.zd,v=this.field,z=o*Math.sqrt(c/f);z>o&&(z=o);for(h=0;h<z;h++){g=h/o;g*=g;k=c/(1.0E-4+g)-f;if(k>0){n=h*t;for(g=0;g<o;g++){p=n+g;for(j=0;j<o;j++)v[x*j+p]+=k}}}};this.addPlaneZ=function(c,f){var g,h,j,k,n,p;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/f);dist>size&&(dist=size);for(j=0;j<dist;j++){g=j/size;g*=g;k=c/(1.0E-4+g)-f;if(k>0){n=zd*j;for(h=0;h<size;h++){p=n+h*yd;
+this.size-1);var u=Math.floor(o-k);u<1&&(u=1);k=Math.floor(o+k);k>this.size-1&&(k=this.size-1);for(var z,C,E,J,U,y;t<n;t++){o=this.size2*t;C=t/this.size-g;U=C*C;for(C=x;C<p;C++){E=o+this.size*C;z=C/this.size-f;y=z*z;for(z=u;z<k;z++){J=z/this.size-c;J=h/(1.0E-6+J*J+y+U)-j;J>0&&(this.field[E+z]+=J)}}}};this.addPlaneX=function(c,f){var g,h,j,k,n,p=this.size,o=this.yd,t=this.zd,x=this.field,u=p*Math.sqrt(c/f);u>p&&(u=p);for(g=0;g<u;g++){h=g/p;h*=h;k=c/(1.0E-4+h)-f;if(k>0)for(h=0;h<p;h++){n=g+h*o;for(j=
+0;j<p;j++)x[t*j+n]+=k}}};this.addPlaneY=function(c,f){var g,h,j,k,n,p,o=this.size,t=this.yd,x=this.zd,u=this.field,z=o*Math.sqrt(c/f);z>o&&(z=o);for(h=0;h<z;h++){g=h/o;g*=g;k=c/(1.0E-4+g)-f;if(k>0){n=h*t;for(g=0;g<o;g++){p=n+g;for(j=0;j<o;j++)u[x*j+p]+=k}}}};this.addPlaneZ=function(c,f){var g,h,j,k,n,p;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/f);dist>size&&(dist=size);for(j=0;j<dist;j++){g=j/size;g*=g;k=c/(1.0E-4+g)-f;if(k>0){n=zd*j;for(h=0;h<size;h++){p=n+h*yd;
 for(g=0;g<size;g++)field[p+g]+=k}}}};this.reset=function(){var c;for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var f,g,h,j,k,n,p,o,t,x=this.size-2;for(j=1;j<x;j++){t=this.size2*j;p=(j-this.halfsize)/this.halfsize;for(h=1;h<x;h++){o=t+this.size*h;n=(h-this.halfsize)/this.halfsize;for(g=1;g<x;g++){k=(g-this.halfsize)/this.halfsize;f=o+g;this.polygonize(k,n,p,f,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,f=new THREE.Geometry;
 this.render(function(g){var h,j,k,n,p,o,t,x;for(h=0;h<g.count;h++){p=h*3;t=p+1;x=p+2;j=g.positionArray[p];k=g.positionArray[t];n=g.positionArray[x];o=new THREE.Vector3(j,k,n);j=g.normalArray[p];k=g.normalArray[t];n=g.normalArray[x];p=new THREE.Vector3(j,k,n);p.normalize();p=new THREE.Vertex(o,p);f.vertices.push(p)}nfaces=g.count/3;for(h=0;h<nfaces;h++){p=(c+h)*3;t=p+1;x=p+2;o=f.vertices[p].normal;j=f.vertices[t].normal;k=f.vertices[x].normal;p=new THREE.Face3(p,t,x,[o,j,k]);f.faces.push(p)}c+=nfaces;
 g.count=0});return f};this.init(b)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;

+ 65 - 65
build/custom/ThreeExtras.js

@@ -1,19 +1,19 @@
 // ThreeExtras.js r38 - http://github.com/mrdoob/three.js
-var GeometryUtils={merge:function(a,f){var b=f instanceof THREE.Mesh,c=a.vertices.length,d=b?f.geometry:f,e=a.vertices,g=d.vertices,h=a.faces,l=d.faces,k=a.faceVertexUvs[0];d=d.faceVertexUvs[0];b&&f.matrixAutoUpdate&&f.updateMatrix();for(var j=0,n=g.length;j<n;j++){var p=new THREE.Vertex(g[j].position.clone());b&&f.matrix.multiplyVector3(p.position);e.push(p)}j=0;for(n=l.length;j<n;j++){g=l[j];var t,w,x=g.vertexNormals;p=g.vertexColors;if(g instanceof THREE.Face3)t=new THREE.Face3(g.a+c,g.b+c,g.c+
-c);else g instanceof THREE.Face4&&(t=new THREE.Face4(g.a+c,g.b+c,g.c+c,g.d+c));t.normal.copy(g.normal);b=0;for(e=x.length;b<e;b++){w=x[b];t.vertexNormals.push(w.clone())}t.color.copy(g.color);b=0;for(e=p.length;b<e;b++){w=p[b];t.vertexColors.push(w.clone())}t.materials=g.materials.slice();t.centroid.copy(g.centroid);h.push(t)}j=0;for(n=d.length;j<n;j++){c=d[j];h=[];b=0;for(e=c.length;b<e;b++)h.push(new THREE.UV(c[b].u,c[b].v));k.push(h)}}},ImageUtils={loadTexture:function(a,f,b){var c=new Image,d=
-new THREE.Texture(c,f);c.onload=function(){d.needsUpdate=!0;b&&b(this)};c.src=a;return d},loadTextureCube:function(a,f,b){var c,d=[],e=new THREE.Texture(d,f);f=d.loadCount=0;for(c=a.length;f<c;++f){d[f]=new Image;d[f].onload=function(){d.loadCount+=1;if(d.loadCount==6)e.needsUpdate=!0;b&&b(this)};d[f].src=a[f]}return e}},SceneUtils={loadScene:function(a,f,b,c){var d=new Worker(a);d.postMessage(0);var e=THREE.Loader.prototype.extractUrlbase(a);d.onmessage=function(g){function h(V,W){return W=="relativeToHTML"?
-V:e+"/"+V}function l(){for(t in E.objects)if(!F.objects[t]){y=E.objects[t];if(G=F.geometries[y.geometry]){I=[];for(M=0;M<y.materials.length;M++)I[M]=F.materials[y.materials[M]];m=y.position;r=y.rotation;q=y.quaternion;s=y.scale;q=0;I.length==0&&(I[0]=new THREE.MeshFaceMaterial);object=new THREE.Mesh(G,I);object.position.set(m[0],m[1],m[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=
-y.visible;F.scene.addObject(object);F.objects[t]=object}}}function k(V){return function(W){F.geometries[V]=W;l();P-=1;j()}}function j(){c({total_models:O,total_textures:R,loaded_models:O-P,loaded_textures:R-N},F);P==0&&N==0&&b(F)}var n,p,t,w,x,u,B,y,m,z,C,G,K,J,I,E,L,S,P,N,O,R,F;E=g.data;L=new THREE.BinaryLoader;S=new THREE.JSONLoader;N=P=0;F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};g=function(){N-=1;j()};for(x in E.cameras){z=E.cameras[x];
-if(z.type=="perspective")K=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho"){K=new THREE.Camera;K.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far)}m=z.position;z=z.target;K.position.set(m[0],m[1],m[2]);K.target.position.set(z[0],z[1],z[2]);F.cameras[x]=K}for(w in E.lights){x=E.lights[w];K=x.color!==undefined?x.color:16777215;z=x.intensity!==undefined?x.intensity:1;if(x.type=="directional"){m=x.direction;light=new THREE.DirectionalLight(K,z);
-light.position.set(m[0],m[1],m[2]);light.position.normalize()}else if(x.type=="point"){m=x.position;light=new THREE.PointLight(K,z);light.position.set(m[0],m[1],m[2])}F.scene.addLight(light);F.lights[w]=light}for(u in E.fogs){w=E.fogs[u];if(w.type=="linear")J=new THREE.Fog(0,w.near,w.far);else w.type=="exp2"&&(J=new THREE.FogExp2(0,w.density));z=w.color;J.color.setRGB(z[0],z[1],z[2]);F.fogs[u]=J}if(F.cameras&&E.defaults.camera)F.currentCamera=F.cameras[E.defaults.camera];if(F.fogs&&E.defaults.fog)F.scene.fog=
+var GeometryUtils={merge:function(a,f){var b=f instanceof THREE.Mesh,c=a.vertices.length,e=b?f.geometry:f,d=a.vertices,g=e.vertices,h=a.faces,l=e.faces,k=a.faceVertexUvs[0];e=e.faceVertexUvs[0];b&&f.matrixAutoUpdate&&f.updateMatrix();for(var j=0,n=g.length;j<n;j++){var p=new THREE.Vertex(g[j].position.clone());b&&f.matrix.multiplyVector3(p.position);d.push(p)}j=0;for(n=l.length;j<n;j++){g=l[j];var t,x,w=g.vertexNormals;p=g.vertexColors;if(g instanceof THREE.Face3)t=new THREE.Face3(g.a+c,g.b+c,g.c+
+c);else g instanceof THREE.Face4&&(t=new THREE.Face4(g.a+c,g.b+c,g.c+c,g.d+c));t.normal.copy(g.normal);b=0;for(d=w.length;b<d;b++){x=w[b];t.vertexNormals.push(x.clone())}t.color.copy(g.color);b=0;for(d=p.length;b<d;b++){x=p[b];t.vertexColors.push(x.clone())}t.materials=g.materials.slice();t.centroid.copy(g.centroid);h.push(t)}j=0;for(n=e.length;j<n;j++){c=e[j];h=[];b=0;for(d=c.length;b<d;b++)h.push(new THREE.UV(c[b].u,c[b].v));k.push(h)}}},ImageUtils={loadTexture:function(a,f,b){var c=new Image,e=
+new THREE.Texture(c,f);c.onload=function(){e.needsUpdate=!0;b&&b(this)};c.src=a;return e},loadTextureCube:function(a,f,b){var c,e=[],d=new THREE.Texture(e,f);f=e.loadCount=0;for(c=a.length;f<c;++f){e[f]=new Image;e[f].onload=function(){e.loadCount+=1;if(e.loadCount==6)d.needsUpdate=!0;b&&b(this)};e[f].src=a[f]}return d}},SceneUtils={loadScene:function(a,f,b,c){var e=new Worker(a);e.postMessage(0);var d=THREE.Loader.prototype.extractUrlbase(a);e.onmessage=function(g){function h(V,W){return W=="relativeToHTML"?
+V:d+"/"+V}function l(){for(t in E.objects)if(!F.objects[t]){y=E.objects[t];if(G=F.geometries[y.geometry]){I=[];for(M=0;M<y.materials.length;M++)I[M]=F.materials[y.materials[M]];m=y.position;r=y.rotation;q=y.quaternion;s=y.scale;q=0;I.length==0&&(I[0]=new THREE.MeshFaceMaterial);object=new THREE.Mesh(G,I);object.position.set(m[0],m[1],m[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=
+y.visible;F.scene.addObject(object);F.objects[t]=object}}}function k(V){return function(W){F.geometries[V]=W;l();P-=1;j()}}function j(){c({total_models:O,total_textures:R,loaded_models:O-P,loaded_textures:R-N},F);P==0&&N==0&&b(F)}var n,p,t,x,w,u,B,y,m,z,C,G,K,J,I,E,L,S,P,N,O,R,F;E=g.data;L=new THREE.BinaryLoader;S=new THREE.JSONLoader;N=P=0;F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};g=function(){N-=1;j()};for(w in E.cameras){z=E.cameras[w];
+if(z.type=="perspective")K=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho"){K=new THREE.Camera;K.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far)}m=z.position;z=z.target;K.position.set(m[0],m[1],m[2]);K.target.position.set(z[0],z[1],z[2]);F.cameras[w]=K}for(x in E.lights){w=E.lights[x];K=w.color!==undefined?w.color:16777215;z=w.intensity!==undefined?w.intensity:1;if(w.type=="directional"){m=w.direction;light=new THREE.DirectionalLight(K,z);
+light.position.set(m[0],m[1],m[2]);light.position.normalize()}else if(w.type=="point"){m=w.position;light=new THREE.PointLight(K,z);light.position.set(m[0],m[1],m[2])}F.scene.addLight(light);F.lights[x]=light}for(u in E.fogs){x=E.fogs[u];if(x.type=="linear")J=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(J=new THREE.FogExp2(0,x.density));z=x.color;J.color.setRGB(z[0],z[1],z[2]);F.fogs[u]=J}if(F.cameras&&E.defaults.camera)F.currentCamera=F.cameras[E.defaults.camera];if(F.fogs&&E.defaults.fog)F.scene.fog=
 F.fogs[E.defaults.fog];z=E.defaults.bgcolor;F.bgColor=new THREE.Color;F.bgColor.setRGB(z[0],z[1],z[2]);F.bgColorAlpha=E.defaults.bgalpha;for(n in E.geometries){u=E.geometries[n];if(u.type=="bin_mesh"||u.type=="ascii_mesh")P+=1}O=P;for(n in E.geometries){u=E.geometries[n];if(u.type=="cube"){G=new Cube(u.width,u.height,u.depth,u.segmentsWidth,u.segmentsHeight,u.segmentsDepth,null,u.flipped,u.sides);F.geometries[n]=G}else if(u.type=="plane"){G=new Plane(u.width,u.height,u.segmentsWidth,u.segmentsHeight);
 F.geometries[n]=G}else if(u.type=="sphere"){G=new Sphere(u.radius,u.segmentsWidth,u.segmentsHeight);F.geometries[n]=G}else if(u.type=="cylinder"){G=new Cylinder(u.numSegs,u.topRad,u.botRad,u.height,u.topOffset,u.botOffset);F.geometries[n]=G}else if(u.type=="torus"){G=new Torus(u.radius,u.tube,u.segmentsR,u.segmentsT);F.geometries[n]=G}else if(u.type=="icosahedron"){G=new Icosahedron(u.subdivisions);F.geometries[n]=G}else if(u.type=="bin_mesh")L.load({model:h(u.url,E.urlBaseType),callback:k(n)});else u.type==
 "ascii_mesh"&&S.load({model:h(u.url,E.urlBaseType),callback:k(n)})}for(B in E.textures){n=E.textures[B];N+=n.url instanceof Array?n.url.length:1}R=N;for(B in E.textures){n=E.textures[B];if(n.mapping!=undefined&&THREE[n.mapping]!=undefined)n.mapping=new THREE[n.mapping];if(n.url instanceof Array){u=[];for(var M=0;M<n.url.length;M++)u[M]=h(n.url[M],E.urlBaseType);u=ImageUtils.loadTextureCube(u,n.mapping,g)}else{u=ImageUtils.loadTexture(h(n.url,E.urlBaseType),n.mapping,g);if(THREE[n.minFilter]!=undefined)u.minFilter=
 THREE[n.minFilter];if(THREE[n.magFilter]!=undefined)u.magFilter=THREE[n.magFilter]}F.textures[B]=u}for(p in E.materials){B=E.materials[p];for(C in B.parameters)if(C=="envMap"||C=="map"||C=="lightMap")B.parameters[C]=F.textures[B.parameters[C]];else if(C=="shading")B.parameters[C]=B.parameters[C]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(C=="blending")B.parameters[C]=THREE[B.parameters[C]]?THREE[B.parameters[C]]:THREE.NormalBlending;else C=="combine"&&(B.parameters[C]=B.parameters[C]==
-"MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);B=new THREE[B.type](B.parameters);F.materials[p]=B}l();f(F)}},addMesh:function(a,f,b,c,d,e,g,h,l,k){f=new THREE.Mesh(f,k);f.scale.x=f.scale.y=f.scale.z=b;f.position.x=c;f.position.y=d;f.position.z=e;f.rotation.x=g;f.rotation.y=h;f.rotation.z=l;a.addObject(f);return f},addPanoramaCubeWebGL:function(a,f,b){var c=ShaderUtils.lib.cube;c.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:c.fragmentShader,vertexShader:c.vertexShader,
+"MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);B=new THREE[B.type](B.parameters);F.materials[p]=B}l();f(F)}},addMesh:function(a,f,b,c,e,d,g,h,l,k){f=new THREE.Mesh(f,k);f.scale.x=f.scale.y=f.scale.z=b;f.position.x=c;f.position.y=e;f.position.z=d;f.rotation.x=g;f.rotation.y=h;f.rotation.z=l;a.addObject(f);return f},addPanoramaCubeWebGL:function(a,f,b){var c=ShaderUtils.lib.cube;c.uniforms.tCube.texture=b;b=new THREE.MeshShaderMaterial({fragmentShader:c.fragmentShader,vertexShader:c.vertexShader,
 uniforms:c.uniforms});f=new THREE.Mesh(new Cube(f,f,f,1,1,1,null,!0),b);a.addObject(f);return f},addPanoramaCube:function(a,f,b){var c=[];c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[4])}));c.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));
-f=new THREE.Mesh(new Cube(f,f,f,1,1,c,!0),new THREE.MeshFaceMaterial);a.addObject(f);return f},addPanoramaCubePlanes:function(a,f,b){var c=f/2;f=new Plane(f,f);var d=Math.PI,e=Math.PI/2;SceneUtils.addMesh(a,f,1,0,0,-c,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,f,1,-c,0,0,0,e,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,f,1,c,0,0,0,-e,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,
-f,1,0,c,0,e,0,d,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));SceneUtils.addMesh(a,f,1,0,-c,0,-e,0,d,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,f){SceneUtils.traverseHierarchy(a,function(b){b.visible=f})},traverseHierarchy:function(a,f){var b,c,d=a.children.length;for(c=0;c<d;c++){b=a.children[c];f(b);SceneUtils.traverseHierarchy(b,f)}}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},
+f=new THREE.Mesh(new Cube(f,f,f,1,1,c,!0),new THREE.MeshFaceMaterial);a.addObject(f);return f},addPanoramaCubePlanes:function(a,f,b){var c=f/2;f=new Plane(f,f);var e=Math.PI,d=Math.PI/2;SceneUtils.addMesh(a,f,1,0,0,-c,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[5])}));SceneUtils.addMesh(a,f,1,-c,0,0,0,d,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[0])}));SceneUtils.addMesh(a,f,1,c,0,0,0,-d,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[1])}));SceneUtils.addMesh(a,
+f,1,0,c,0,d,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[2])}));SceneUtils.addMesh(a,f,1,0,-c,0,-d,0,e,new THREE.MeshBasicMaterial({map:new THREE.Texture(b[3])}))},showHierarchy:function(a,f){SceneUtils.traverseHierarchy(a,function(b){b.visible=f})},traverseHierarchy:function(a,f){var b,c,e=a.children.length;for(c=0;c<e;c++){b=a.children[c];f(b);SceneUtils.traverseHierarchy(b,f)}}},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:{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tAO:{type:"t",value:3,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:4,texture:null},uDisplacementBias:{type:"f",value:-0.5},uDisplacementScale:{type:"f",value:2.5},uPointLightPos:{type:"v3",value:new THREE.Vector3},uPointLightColor:{type:"c",value:new THREE.Color(15658734)},uDirLightPos:{type:"v3",value:new THREE.Vector3},
@@ -23,7 +23,7 @@ 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 f,b,c,d,e=2*Math.ceil(a*3)+1;e>25&&(e=25);d=(e-1)*0.5;b=Array(e);for(f=c=0;f<e;++f){b[f]=Math.exp(-((f-d)*(f-d))/(2*a*a));c+=b[f]}for(f=0;f<e;++f)b[f]/=c;return b}};
+fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var f,b,c,e,d=2*Math.ceil(a*3)+1;d>25&&(d=25);e=(d-1)*0.5;b=Array(d);for(f=c=0;f<d;++f){b[f]=Math.exp(-((f-e)*(f-e))/(2*a*a));c+=b[f]}for(f=0;f<d;++f)b[f]/=c;return b}};
 THREE.QuakeCamera=function(a){function f(b,c){return function(){c.apply(b,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;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=
 a.lookSpeed;if(a.noFly!==undefined)this.noFly=a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.activeLook!==undefined)this.activeLook=a.activeLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.constrainVertical!==undefined)this.constrainVertical=
 a.constrainVertical;if(a.verticalMin!==undefined)this.verticalMin=a.verticalMin;if(a.verticalMax!==undefined)this.verticalMax=a.verticalMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();
@@ -33,77 +33,77 @@ this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.tra
 Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;var c=this.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",f(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",
 f(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",f(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",f(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",f(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
 THREE.QuakeCamera.prototype.translate=function(a,f){this.matrix.rotateAxis(f);if(this.noFly)f.y=0;this.position.addSelf(f.multiplyScalar(a));this.target.position.addSelf(f.multiplyScalar(a))};
-THREE.PathCamera=function(a){function f(k,j,n,p){var t={name:n,fps:0.6,length:p,hierarchy:[]},w,x=j.getControlPointsArray(),u=j.getLength(),B=x.length,y=0;w=B-1;j={parent:-1,keys:[]};j.keys[0]={time:0,pos:x[0],rot:[0,0,0,1],scl:[1,1,1]};j.keys[w]={time:p,pos:x[w],rot:[0,0,0,1],scl:[1,1,1]};for(w=1;w<B-1;w++){y=p*u.chunks[w]/u.total;j.keys[w]={time:y,pos:x[w]}}t.hierarchy[0]=j;THREE.AnimationHandler.add(t);return new THREE.Animation(k,n,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(k,j){var n,
+THREE.PathCamera=function(a){function f(k,j,n,p){var t={name:n,fps:0.6,length:p,hierarchy:[]},x,w=j.getControlPointsArray(),u=j.getLength(),B=w.length,y=0;x=B-1;j={parent:-1,keys:[]};j.keys[0]={time:0,pos:w[0],rot:[0,0,0,1],scl:[1,1,1]};j.keys[x]={time:p,pos:w[x],rot:[0,0,0,1],scl:[1,1,1]};for(x=1;x<B-1;x++){y=p*u.chunks[x]/u.total;j.keys[x]={time:y,pos:w[x]}}t.hierarchy[0]=j;THREE.AnimationHandler.add(t);return new THREE.Animation(k,n,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(k,j){var n,
 p,t=new THREE.Geometry;for(n=0;n<k.points.length*j;n++){p=n/(k.points.length*j);p=k.getPoint(p);t.vertices[n]=new THREE.Vertex(new THREE.Vector3(p.x,p.y,p.z))}return t}function c(k,j){var n=b(j,10),p=b(j,10),t=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(n,t);particleObj=new THREE.ParticleSystem(p,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);k.addChild(lineObj);particleObj.scale.set(1,1,1);k.addChild(particleObj);p=new Sphere(1,
 16,8);t=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<j.points.length;i++){n=new THREE.Mesh(p,t);n.position.copy(j.points[i]);n.updateMatrix();k.addChild(n)}}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.lookVertical=
 !0;this.lookHorizontal=!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!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
 if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)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 d=Math.PI*2,e=Math.PI/180;this.update=function(k,j,n){var p,t;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)*e;this.theta=this.lon*e;p=this.phi%d;this.phi=p>=0?p:p+d;p=this.verticalAngleMap.srcRange;t=this.verticalAngleMap.dstRange;
+this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var e=Math.PI*2,d=Math.PI/180;this.update=function(k,j,n){var p,t;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)*d;this.theta=this.lon*d;p=this.phi%e;this.phi=p>=0?p:p+e;p=this.verticalAngleMap.srcRange;t=this.verticalAngleMap.dstRange;
 this.phi=(this.phi-p[0])*(t[1]-t[0])/(p[1]-p[0])+t[0];p=this.horizontalAngleMap.srcRange;t=this.horizontalAngleMap.dstRange;this.theta=(this.theta-p[0])*(t[1]-t[0])/(p[1]-p[0])+t[0];p=this.target.position;p.x=100*Math.sin(this.phi)*Math.cos(this.theta);p.y=100*Math.cos(this.phi);p.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,k,j,n)};this.onMouseMove=function(k){this.mouseX=k.clientX-this.windowHalfX;this.mouseY=k.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
 this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var g=new THREE.MeshLambertMaterial({color:65280}),h=new Cube(10,10,20),l=new Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(l,g);a.position.set(0,10,0);this.animation=f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=
 f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&c(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(k,j){return function(){j.apply(k,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;
-var Cube=function(a,f,b,c,d,e,g,h,l){function k(u,B,y,m,z,C,G,K){var J,I,E=c||1,L=d||1,S=z/2,P=C/2,N=j.vertices.length;if(u=="x"&&B=="y"||u=="y"&&B=="x")J="z";else if(u=="x"&&B=="z"||u=="z"&&B=="x"){J="y";L=e||1}else if(u=="z"&&B=="y"||u=="y"&&B=="z"){J="x";E=e||1}var O=E+1,R=L+1;z/=E;var F=C/L;for(I=0;I<R;I++)for(C=0;C<O;C++){var M=new THREE.Vector3;M[u]=(C*z-S)*y;M[B]=(I*F-P)*m;M[J]=G;j.vertices.push(new THREE.Vertex(M))}for(I=0;I<L;I++)for(C=0;C<E;C++){j.faces.push(new THREE.Face4(C+O*I+N,C+O*
-(I+1)+N,C+1+O*(I+1)+N,C+1+O*I+N,null,null,K));j.faceVertexUvs[0].push([new THREE.UV(C/E,I/L),new THREE.UV(C/E,(I+1)/L),new THREE.UV((C+1)/E,(I+1)/L),new THREE.UV((C+1)/E,I/L)])}}THREE.Geometry.call(this);var j=this,n=a/2,p=f/2,t=b/2;h=h?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var w=0;w<6;w++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(l!=undefined)for(var x in l)this.sides[x]!=undefined&&(this.sides[x]=
-l[x]);this.sides.px&&k("z","y",1*h,-1,b,f,-n,this.materials[0]);this.sides.nx&&k("z","y",-1*h,-1,b,f,n,this.materials[1]);this.sides.py&&k("x","z",1*h,1,a,b,p,this.materials[2]);this.sides.ny&&k("x","z",1*h,-1,a,b,-p,this.materials[3]);this.sides.pz&&k("x","y",1*h,-1,a,f,t,this.materials[4]);this.sides.nz&&k("x","y",-1*h,-1,a,f,-t,this.materials[5]);(function(){for(var u=[],B=[],y=0,m=j.vertices.length;y<m;y++){for(var z=j.vertices[y],C=!1,G=0,K=u.length;G<K;G++){var J=u[G];if(z.position.x==J.position.x&&
+var Cube=function(a,f,b,c,e,d,g,h,l){function k(u,B,y,m,z,C,G,K){var J,I,E=c||1,L=e||1,S=z/2,P=C/2,N=j.vertices.length;if(u=="x"&&B=="y"||u=="y"&&B=="x")J="z";else if(u=="x"&&B=="z"||u=="z"&&B=="x"){J="y";L=d||1}else if(u=="z"&&B=="y"||u=="y"&&B=="z"){J="x";E=d||1}var O=E+1,R=L+1;z/=E;var F=C/L;for(I=0;I<R;I++)for(C=0;C<O;C++){var M=new THREE.Vector3;M[u]=(C*z-S)*y;M[B]=(I*F-P)*m;M[J]=G;j.vertices.push(new THREE.Vertex(M))}for(I=0;I<L;I++)for(C=0;C<E;C++){j.faces.push(new THREE.Face4(C+O*I+N,C+O*
+(I+1)+N,C+1+O*(I+1)+N,C+1+O*I+N,null,null,K));j.faceVertexUvs[0].push([new THREE.UV(C/E,I/L),new THREE.UV(C/E,(I+1)/L),new THREE.UV((C+1)/E,(I+1)/L),new THREE.UV((C+1)/E,I/L)])}}THREE.Geometry.call(this);var j=this,n=a/2,p=f/2,t=b/2;h=h?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var x=0;x<6;x++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(l!=undefined)for(var w in l)this.sides[w]!=undefined&&(this.sides[w]=
+l[w]);this.sides.px&&k("z","y",1*h,-1,b,f,-n,this.materials[0]);this.sides.nx&&k("z","y",-1*h,-1,b,f,n,this.materials[1]);this.sides.py&&k("x","z",1*h,1,a,b,p,this.materials[2]);this.sides.ny&&k("x","z",1*h,-1,a,b,-p,this.materials[3]);this.sides.pz&&k("x","y",1*h,-1,a,f,t,this.materials[4]);this.sides.nz&&k("x","y",-1*h,-1,a,f,-t,this.materials[5]);(function(){for(var u=[],B=[],y=0,m=j.vertices.length;y<m;y++){for(var z=j.vertices[y],C=!1,G=0,K=u.length;G<K;G++){var J=u[G];if(z.position.x==J.position.x&&
 z.position.y==J.position.y&&z.position.z==J.position.z){B[y]=G;C=!0;break}}if(!C){B[y]=u.length;u.push(new THREE.Vertex(z.position.clone()))}}y=0;for(m=j.faces.length;y<m;y++){z=j.faces[y];z.a=B[z.a];z.b=B[z.b];z.c=B[z.c];z.d=B[z.d]}j.vertices=u})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
-var Cylinder=function(a,f,b,c,d,e){function g(j,n,p){h.vertices.push(new THREE.Vertex(new THREE.Vector3(j,n,p)))}THREE.Geometry.call(this);var h=this,l=Math.PI,k=c/2;for(c=0;c<a;c++)g(Math.sin(2*l*c/a)*f,Math.cos(2*l*c/a)*f,-k);for(c=0;c<a;c++)g(Math.sin(2*l*c/a)*b,Math.cos(2*l*c/a)*b,k);for(c=0;c<a;c++)h.faces.push(new THREE.Face4(c,c+a,a+(c+1)%a,(c+1)%a));if(b>0){g(0,0,-k-(e||0));for(c=a;c<a+a/2;c++)h.faces.push(new THREE.Face4(2*a,(2*c-2*a)%a,(2*c-2*a+1)%a,(2*c-2*a+2)%a))}if(f>0){g(0,0,k+(d||0));
+var Cylinder=function(a,f,b,c,e,d){function g(j,n,p){h.vertices.push(new THREE.Vertex(new THREE.Vector3(j,n,p)))}THREE.Geometry.call(this);var h=this,l=Math.PI,k=c/2;for(c=0;c<a;c++)g(Math.sin(2*l*c/a)*f,Math.cos(2*l*c/a)*f,-k);for(c=0;c<a;c++)g(Math.sin(2*l*c/a)*b,Math.cos(2*l*c/a)*b,k);for(c=0;c<a;c++)h.faces.push(new THREE.Face4(c,c+a,a+(c+1)%a,(c+1)%a));if(b>0){g(0,0,-k-(d||0));for(c=a;c<a+a/2;c++)h.faces.push(new THREE.Face4(2*a,(2*c-2*a)%a,(2*c-2*a+1)%a,(2*c-2*a+2)%a))}if(f>0){g(0,0,k+(e||0));
 for(c=a+a/2;c<2*a;c++)h.faces.push(new THREE.Face4(2*a+1,(2*c-2*a+2)%a+a,(2*c-2*a+1)%a+a,(2*c-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
-var Icosahedron=function(a){function f(n,p,t){var w=Math.sqrt(n*n+p*p+t*t);return d.vertices.push(new THREE.Vertex(new THREE.Vector3(n/w,p/w,t/w)))-1}function b(n,p,t,w){w.faces.push(new THREE.Face3(n,p,t))}function c(n,p){var t=d.vertices[n].position,w=d.vertices[p].position;return f((t.x+w.x)/2,(t.y+w.y)/2,(t.z+w.z)/2)}var d=this,e=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;f(-1,a,0);f(1,a,0);f(-1,-a,0);f(1,-a,0);f(0,-1,a);f(0,1,a);f(0,-1,-a);f(0,
-1,-a);f(a,0,-1);f(a,0,1);f(-a,0,-1);f(-a,0,1);b(0,11,5,e);b(0,5,1,e);b(0,1,7,e);b(0,7,10,e);b(0,10,11,e);b(1,5,9,e);b(5,11,4,e);b(11,10,2,e);b(10,7,6,e);b(7,1,8,e);b(3,9,4,e);b(3,4,2,e);b(3,2,6,e);b(3,6,8,e);b(3,8,9,e);b(4,9,5,e);b(2,4,11,e);b(6,2,10,e);b(8,6,7,e);b(9,8,1,e);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var h in e.faces){var l=c(e.faces[h].a,e.faces[h].b),k=c(e.faces[h].b,e.faces[h].c),j=c(e.faces[h].c,e.faces[h].a);b(e.faces[h].a,l,j,g);b(e.faces[h].b,k,l,g);b(e.faces[h].c,
-j,k,g);b(l,k,j,g)}e.faces=g.faces}d.faces=e.faces;delete e;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
-function Lathe(a,f,b){THREE.Geometry.call(this);this.steps=f||12;this.angle=b||2*Math.PI;f=this.angle/this.steps;for(var c=[],d=[],e=[],g=[],h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));c[h]=a[h].clone();d[h]=this.vertices.length-1}for(var l=(new THREE.Matrix4).setRotationZ(f),k=0;k<=this.angle+0.0010;k+=f){for(h=0;h<c.length;h++)if(k<this.angle){c[h]=l.multiplyVector3(c[h].clone());this.vertices.push(new THREE.Vertex(c[h]));e[h]=this.vertices.length-1}else e=g;k==0&&(g=d);for(h=
-0;h<d.length-1;h++){this.faces.push(new THREE.Face4(e[h],e[h+1],d[h+1],d[h]));this.faceVertexUvs[0].push([new THREE.UV(k/b,h/a.length),new THREE.UV(k/b,(h+1)/a.length),new THREE.UV((k-f)/b,(h+1)/a.length),new THREE.UV((k-f)/b,h/a.length)])}d=e;e=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
-var Plane=function(a,f,b,c){THREE.Geometry.call(this);var d,e=a/2,g=f/2;b=b||1;c=c||1;var h=b+1,l=c+1;a/=b;var k=f/c;for(d=0;d<l;d++)for(f=0;f<h;f++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(f*a-e,-(d*k-g),0)));for(d=0;d<c;d++)for(f=0;f<b;f++){this.faces.push(new THREE.Face4(f+h*d,f+h*(d+1),f+1+h*(d+1),f+1+h*d));this.faceVertexUvs[0].push([new THREE.UV(f/b,d/c),new THREE.UV(f/b,(d+1)/c),new THREE.UV((f+1)/b,(d+1)/c),new THREE.UV((f+1)/b,d/c)])}this.computeCentroids();this.computeFaceNormals()};
+var Icosahedron=function(a){function f(n,p,t){var x=Math.sqrt(n*n+p*p+t*t);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(n/x,p/x,t/x)))-1}function b(n,p,t,x){x.faces.push(new THREE.Face3(n,p,t))}function c(n,p){var t=e.vertices[n].position,x=e.vertices[p].position;return f((t.x+x.x)/2,(t.y+x.y)/2,(t.z+x.z)/2)}var e=this,d=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;f(-1,a,0);f(1,a,0);f(-1,-a,0);f(1,-a,0);f(0,-1,a);f(0,1,a);f(0,-1,-a);f(0,
+1,-a);f(a,0,-1);f(a,0,1);f(-a,0,-1);f(-a,0,1);b(0,11,5,d);b(0,5,1,d);b(0,1,7,d);b(0,7,10,d);b(0,10,11,d);b(1,5,9,d);b(5,11,4,d);b(11,10,2,d);b(10,7,6,d);b(7,1,8,d);b(3,9,4,d);b(3,4,2,d);b(3,2,6,d);b(3,6,8,d);b(3,8,9,d);b(4,9,5,d);b(2,4,11,d);b(6,2,10,d);b(8,6,7,d);b(9,8,1,d);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var h in d.faces){var l=c(d.faces[h].a,d.faces[h].b),k=c(d.faces[h].b,d.faces[h].c),j=c(d.faces[h].c,d.faces[h].a);b(d.faces[h].a,l,j,g);b(d.faces[h].b,k,l,g);b(d.faces[h].c,
+j,k,g);b(l,k,j,g)}d.faces=g.faces}e.faces=d.faces;delete d;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
+function Lathe(a,f,b){THREE.Geometry.call(this);this.steps=f||12;this.angle=b||2*Math.PI;f=this.angle/this.steps;for(var c=[],e=[],d=[],g=[],h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));c[h]=a[h].clone();e[h]=this.vertices.length-1}for(var l=(new THREE.Matrix4).setRotationZ(f),k=0;k<=this.angle+0.0010;k+=f){for(h=0;h<c.length;h++)if(k<this.angle){c[h]=l.multiplyVector3(c[h].clone());this.vertices.push(new THREE.Vertex(c[h]));d[h]=this.vertices.length-1}else d=g;k==0&&(g=e);for(h=
+0;h<e.length-1;h++){this.faces.push(new THREE.Face4(d[h],d[h+1],e[h+1],e[h]));this.faceVertexUvs[0].push([new THREE.UV(k/b,h/a.length),new THREE.UV(k/b,(h+1)/a.length),new THREE.UV((k-f)/b,(h+1)/a.length),new THREE.UV((k-f)/b,h/a.length)])}e=d;d=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
+var Plane=function(a,f,b,c){THREE.Geometry.call(this);var e,d=a/2,g=f/2;b=b||1;c=c||1;var h=b+1,l=c+1;a/=b;var k=f/c;for(e=0;e<l;e++)for(f=0;f<h;f++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(f*a-d,-(e*k-g),0)));for(e=0;e<c;e++)for(f=0;f<b;f++){this.faces.push(new THREE.Face4(f+h*e,f+h*(e+1),f+1+h*(e+1),f+1+h*e));this.faceVertexUvs[0].push([new THREE.UV(f/b,e/c),new THREE.UV(f/b,(e+1)/c),new THREE.UV((f+1)/b,(e+1)/c),new THREE.UV((f+1)/b,e/c)])}this.computeCentroids();this.computeFaceNormals()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(a,f,b){THREE.Geometry.call(this);var c,d=Math.PI,e=Math.max(3,f||8),g=Math.max(2,b||6);f=[];for(b=0;b<g+1;b++){c=b/g;var h=a*Math.cos(c*d),l=a*Math.sin(c*d),k=[],j=0;for(c=0;c<e;c++){var n=2*c/e,p=l*Math.sin(n*d);n=l*Math.cos(n*d);(b==0||b==g)&&c>0||(j=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,h,p)))-1);k.push(j)}f.push(k)}var t,w,x;d=f.length;for(b=0;b<d;b++){e=f[b].length;if(b>0)for(c=0;c<e;c++){k=c==e-1;g=f[b][k?0:c+1];h=f[b][k?e-1:c];l=f[b-1][k?e-1:c];k=f[b-1][k?
-0:c+1];p=b/(d-1);t=(b-1)/(d-1);w=(c+1)/e;n=c/e;j=new THREE.UV(1-w,p);p=new THREE.UV(1-n,p);n=new THREE.UV(1-n,t);var u=new THREE.UV(1-w,t);if(b<f.length-1){t=this.vertices[g].position.clone();w=this.vertices[h].position.clone();x=this.vertices[l].position.clone();t.normalize();w.normalize();x.normalize();this.faces.push(new THREE.Face3(g,h,l,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(x.x,x.y,x.z)]));this.faceVertexUvs[0].push([j,p,n])}if(b>1){t=this.vertices[g].position.clone();
-w=this.vertices[l].position.clone();x=this.vertices[k].position.clone();t.normalize();w.normalize();x.normalize();this.faces.push(new THREE.Face3(g,l,k,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(x.x,x.y,x.z)]));this.faceVertexUvs[0].push([j,n,u])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
-var Torus=function(a,f,b,c){this.radius=a||100;this.tube=f||40;this.segmentsR=b||8;this.segmentsT=c||6;a=[];THREE.Geometry.call(this);for(f=0;f<=this.segmentsR;++f)for(b=0;b<=this.segmentsT;++b){c=b/this.segmentsT*2*Math.PI;var d=f/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(d))*Math.cos(c),(this.radius+this.tube*Math.cos(d))*Math.sin(c),this.tube*Math.sin(d))));a.push([b/this.segmentsT,1-f/this.segmentsR])}for(f=1;f<=this.segmentsR;++f)for(b=
-1;b<=this.segmentsT;++b){c=(this.segmentsT+1)*f+b;d=(this.segmentsT+1)*f+b-1;var e=(this.segmentsT+1)*(f-1)+b-1,g=(this.segmentsT+1)*(f-1)+b;this.faces.push(new THREE.Face4(c,d,e,g));this.faceVertexUvs[0].push([new THREE.UV(a[c][0],a[c][1]),new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[g][0],a[g][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
-var TorusKnot=function(a,f,b,c,d,e,g){function h(n,p,t,w,x,u){p=t/w*n;t=Math.cos(p);return new THREE.Vector3(x*(2+t)*0.5*Math.cos(n),x*(2+t)*Math.sin(n)*0.5,u*x*Math.sin(p)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=f||40;this.segmentsR=b||64;this.segmentsT=c||8;this.p=d||2;this.q=e||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;c=new THREE.Vector3;e=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(f=0;f<this.segmentsT;++f){var l=
-a/this.segmentsR*2*this.p*Math.PI;g=f/this.segmentsT*2*Math.PI;d=h(l,g,this.q,this.p,this.radius,this.heightScale);l=h(l+0.01,g,this.q,this.p,this.radius,this.heightScale);b.x=l.x-d.x;b.y=l.y-d.y;b.z=l.z-d.z;c.x=l.x+d.x;c.y=l.y+d.y;c.z=l.z+d.z;e.cross(b,c);c.cross(e,b);e.normalize();c.normalize();l=this.tube*Math.cos(g);g=this.tube*Math.sin(g);d.x+=l*c.x+g*e.x;d.y+=l*c.y+g*e.y;d.z+=l*c.z+g*e.z;this.grid[a][f]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.z)))-1}}for(a=0;a<this.segmentsR;++a)for(f=
-0;f<this.segmentsT;++f){e=(a+1)%this.segmentsR;g=(f+1)%this.segmentsT;d=this.grid[a][f];b=this.grid[e][f];c=this.grid[a][g];e=this.grid[e][g];g=new THREE.UV(a/this.segmentsR,f/this.segmentsT);l=new THREE.UV((a+1)/this.segmentsR,f/this.segmentsT);var k=new THREE.UV(a/this.segmentsR,(f+1)/this.segmentsT),j=new THREE.UV((a+1)/this.segmentsR,(f+1)/this.segmentsT);this.faces.push(new THREE.Face3(d,b,c));this.faceVertexUvs[0].push([g,l,k]);this.faces.push(new THREE.Face3(e,c,b));this.faceVertexUvs[0].push([j,
+var Sphere=function(a,f,b){THREE.Geometry.call(this);var c,e=Math.PI,d=Math.max(3,f||8),g=Math.max(2,b||6);f=[];for(b=0;b<g+1;b++){c=b/g;var h=a*Math.cos(c*e),l=a*Math.sin(c*e),k=[],j=0;for(c=0;c<d;c++){var n=2*c/d,p=l*Math.sin(n*e);n=l*Math.cos(n*e);(b==0||b==g)&&c>0||(j=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,h,p)))-1);k.push(j)}f.push(k)}var t,x,w;e=f.length;for(b=0;b<e;b++){d=f[b].length;if(b>0)for(c=0;c<d;c++){k=c==d-1;g=f[b][k?0:c+1];h=f[b][k?d-1:c];l=f[b-1][k?d-1:c];k=f[b-1][k?
+0:c+1];p=b/(e-1);t=(b-1)/(e-1);x=(c+1)/d;n=c/d;j=new THREE.UV(1-x,p);p=new THREE.UV(1-n,p);n=new THREE.UV(1-n,t);var u=new THREE.UV(1-x,t);if(b<f.length-1){t=this.vertices[g].position.clone();x=this.vertices[h].position.clone();w=this.vertices[l].position.clone();t.normalize();x.normalize();w.normalize();this.faces.push(new THREE.Face3(g,h,l,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(w.x,w.y,w.z)]));this.faceVertexUvs[0].push([j,p,n])}if(b>1){t=this.vertices[g].position.clone();
+x=this.vertices[l].position.clone();w=this.vertices[k].position.clone();t.normalize();x.normalize();w.normalize();this.faces.push(new THREE.Face3(g,l,k,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(w.x,w.y,w.z)]));this.faceVertexUvs[0].push([j,n,u])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
+var Torus=function(a,f,b,c){this.radius=a||100;this.tube=f||40;this.segmentsR=b||8;this.segmentsT=c||6;a=[];THREE.Geometry.call(this);for(f=0;f<=this.segmentsR;++f)for(b=0;b<=this.segmentsT;++b){c=b/this.segmentsT*2*Math.PI;var e=f/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(c),(this.radius+this.tube*Math.cos(e))*Math.sin(c),this.tube*Math.sin(e))));a.push([b/this.segmentsT,1-f/this.segmentsR])}for(f=1;f<=this.segmentsR;++f)for(b=
+1;b<=this.segmentsT;++b){c=(this.segmentsT+1)*f+b;e=(this.segmentsT+1)*f+b-1;var d=(this.segmentsT+1)*(f-1)+b-1,g=(this.segmentsT+1)*(f-1)+b;this.faces.push(new THREE.Face4(c,e,d,g));this.faceVertexUvs[0].push([new THREE.UV(a[c][0],a[c][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[g][0],a[g][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
+var TorusKnot=function(a,f,b,c,e,d,g){function h(n,p,t,x,w,u){p=t/x*n;t=Math.cos(p);return new THREE.Vector3(w*(2+t)*0.5*Math.cos(n),w*(2+t)*Math.sin(n)*0.5,u*w*Math.sin(p)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=f||40;this.segmentsR=b||64;this.segmentsT=c||8;this.p=e||2;this.q=d||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;c=new THREE.Vector3;d=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(f=0;f<this.segmentsT;++f){var l=
+a/this.segmentsR*2*this.p*Math.PI;g=f/this.segmentsT*2*Math.PI;e=h(l,g,this.q,this.p,this.radius,this.heightScale);l=h(l+0.01,g,this.q,this.p,this.radius,this.heightScale);b.x=l.x-e.x;b.y=l.y-e.y;b.z=l.z-e.z;c.x=l.x+e.x;c.y=l.y+e.y;c.z=l.z+e.z;d.cross(b,c);c.cross(d,b);d.normalize();c.normalize();l=this.tube*Math.cos(g);g=this.tube*Math.sin(g);e.x+=l*c.x+g*d.x;e.y+=l*c.y+g*d.y;e.z+=l*c.z+g*d.z;this.grid[a][f]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z)))-1}}for(a=0;a<this.segmentsR;++a)for(f=
+0;f<this.segmentsT;++f){d=(a+1)%this.segmentsR;g=(f+1)%this.segmentsT;e=this.grid[a][f];b=this.grid[d][f];c=this.grid[a][g];d=this.grid[d][g];g=new THREE.UV(a/this.segmentsR,f/this.segmentsT);l=new THREE.UV((a+1)/this.segmentsR,f/this.segmentsT);var k=new THREE.UV(a/this.segmentsR,(f+1)/this.segmentsT),j=new THREE.UV((a+1)/this.segmentsR,(f+1)/this.segmentsT);this.faces.push(new THREE.Face3(e,b,c));this.faceVertexUvs[0].push([g,l,k]);this.faces.push(new THREE.Face3(d,c,b));this.faceVertexUvs[0].push([j,
 k,l])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;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 f="Loaded ";f+=a.total?(100*a.loaded/a.total).toFixed(0)+"%":(a.loaded/1E3).toFixed(2)+" KB";
 this.statusDomElement.innerHTML=f},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")},init_materials:function(a,f,b){a.materials=[];for(var c=0;c<f.length;++c)a.materials[c]=[THREE.Loader.prototype.createMaterial(f[c],b)]},createMaterial:function(a,f){function b(h){h=Math.log(h)/Math.LN2;return Math.floor(h)==h}function c(h,l){var k=new Image;k.onload=function(){if(!b(this.width)||!b(this.height)){var j=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),n=Math.pow(2,Math.round(Math.log(this.height)/
-Math.LN2));h.image.width=j;h.image.height=n;h.image.getContext("2d").drawImage(this,0,0,j,n)}else h.image=this;h.needsUpdate=!0};k.src=l}var d,e,g;d="MeshLambertMaterial";e={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors?THREE.VertexColors:!1,wireframe:a.wireframe};if(a.shading)if(a.shading=="Phong")d="MeshPhongMaterial";else a.shading=="Basic"&&(d="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!==undefined)e.transparent=a.transparent;if(a.depthTest!==undefined)e.depthTest=a.depthTest;if(a.mapDiffuse&&f){g=document.createElement("canvas");e.map=new THREE.Texture(g);e.map.sourceFile=a.mapDiffuse;c(e.map,f+"/"+a.mapDiffuse)}else if(a.colorDiffuse){g=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;e.color=g;e.opacity=a.transparency}else if(a.DbgColor)e.color=
-a.DbgColor;if(a.mapLightmap&&f){g=document.createElement("canvas");e.lightMap=new THREE.Texture(g);e.lightMap.sourceFile=a.mapLightmap;c(e.lightMap,f+"/"+a.mapLightmap)}return new THREE[d](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 f=this,b=a.model,c=a.callback,d=a.texture_path?a.texture_path:this.extractUrlbase(b);a=new Worker(b);a.onmessage=function(e){f.createModel(e.data,c,d);f.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
-THREE.JSONLoader.prototype.createModel=function(a,f,b){var c=new THREE.Geometry;this.init_materials(c,a.materials,b);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var d,e,g,h,l,k,j,n,p,t,w,x,u,B,y,m=a.faces;k=a.vertices;var z=a.normals,C=a.colors;j=a.scale!==undefined?a.scale:1;var G=0;for(d=0;d<a.uvs.length;d++)a.uvs[d].length&&G++;for(d=0;d<G;d++){c.faceUvs[d]=[];c.faceVertexUvs[d]=[]}h=0;for(l=k.length;h<l;){w=new THREE.Vertex;w.position.x=k[h++]/
-j;w.position.y=k[h++]/j;w.position.z=k[h++]/j;c.vertices.push(w)}h=0;for(l=m.length;h<l;){t=m[h++];k=t&1;g=t&2;d=t&4;e=t&8;n=t&16;j=t&32;w=t&64;t&=128;if(k){x=new THREE.Face4;x.a=m[h++];x.b=m[h++];x.c=m[h++];x.d=m[h++];k=4}else{x=new THREE.Face3;x.a=m[h++];x.b=m[h++];x.c=m[h++];k=3}if(g){g=m[h++];x.materials=c.materials[g]}g=c.faces.length;if(d)for(d=0;d<G;d++){u=a.uvs[d];p=m[h++];y=u[p*2];p=u[p*2+1];c.faceUvs[d][g]=new THREE.UV(y,p)}if(e)for(d=0;d<G;d++){u=a.uvs[d];B=[];for(e=0;e<k;e++){p=m[h++];
-y=u[p*2];p=u[p*2+1];B[e]=new THREE.UV(y,p)}c.faceVertexUvs[d][g]=B}if(n){n=m[h++]*3;e=new THREE.Vector3;e.x=z[n++];e.y=z[n++];e.z=z[n];x.normal=e}if(j)for(d=0;d<k;d++){n=m[h++]*3;e=new THREE.Vector3;e.x=z[n++];e.y=z[n++];e.z=z[n];x.vertexNormals.push(e)}if(w){j=new THREE.Color(m[h++]);x.color=j}if(t)for(d=0;d<k;d++){j=m[h++];j=new THREE.Color(C[j]);x.vertexColors.push(j)}c.faces.push(x)}}})();(function(){var d,e,g,h;if(a.skinWeights){d=0;for(e=a.skinWeights.length;d<e;d+=2){g=a.skinWeights[d];h=a.skinWeights[d+
-1];c.skinWeights.push(new THREE.Vector4(g,h,0,0))}}if(a.skinIndices){d=0;for(e=a.skinIndices.length;d<e;d+=2){g=a.skinIndices[d];h=a.skinIndices[d+1];c.skinIndices.push(new THREE.Vector4(g,h,0,0))}}c.bones=a.bones;c.animation=a.animation})();(function(){if(a.morphTargets!==undefined){var d,e,g,h,l,k;d=0;for(e=a.morphTargets.length;d<e;d++){c.morphTargets[d]={};c.morphTargets[d].name=a.morphTargets[d].name;c.morphTargets[d].vertices=[];l=c.morphTargets[d].vertices;k=a.morphTargets[d].vertices;g=0;
-for(h=k.length;g<h;g+=3)l.push(new THREE.Vertex(new THREE.Vector3(k[g],k[g+1],k[g+2])))}}if(a.morphColors!==undefined){var j,n;d=0;for(e=a.morphColors.length;d<e;d++){c.morphColors[d]={};c.morphColors[d].name=a.morphColors[d].name;c.morphColors[d].colors=[];k=c.morphColors[d].colors;j=a.morphColors[d].colors;h=0;for(l=j.length;h<l;h+=3){n=new THREE.Color(16755200);n.setRGB(j[g],j[g+1],j[g+2]);k.push(n)}}}})();c.computeCentroids();c.computeFaceNormals();f(c)};
+Math.LN2));h.image.width=j;h.image.height=n;h.image.getContext("2d").drawImage(this,0,0,j,n)}else h.image=this;h.needsUpdate=!0};k.src=l}var e,d,g;e="MeshLambertMaterial";d={color:15658734,opacity:1,map:null,lightMap:null,wireframe:a.wireframe};if(a.shading)if(a.shading=="Phong")e="MeshPhongMaterial";else a.shading=="Basic"&&(e="MeshBasicMaterial");if(a.blending)if(a.blending=="Additive")d.blending=THREE.AdditiveBlending;else if(a.blending=="Subtractive")d.blending=THREE.SubtractiveBlending;else if(a.blending==
+"Multiply")d.blending=THREE.MultiplyBlending;if(a.transparent!==undefined)d.transparent=a.transparent;if(a.depthTest!==undefined)d.depthTest=a.depthTest;if(a.vertexColors!==undefined)if(a.vertexColors=="face")d.vertexColors=THREE.FaceColors;else if(a.vertexColors)d.vertexColors=THREE.VertexColors;if(a.mapDiffuse&&f){g=document.createElement("canvas");d.map=new THREE.Texture(g);d.map.sourceFile=a.mapDiffuse;c(d.map,f+"/"+a.mapDiffuse)}else if(a.colorDiffuse){g=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*
+255<<8)+a.colorDiffuse[2]*255;d.color=g;d.opacity=a.transparency}else if(a.DbgColor)d.color=a.DbgColor;if(a.mapLightmap&&f){g=document.createElement("canvas");d.lightMap=new THREE.Texture(g);d.lightMap.sourceFile=a.mapLightmap;c(d.lightMap,f+"/"+a.mapLightmap)}return new THREE[e](d)}};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 f=this,b=a.model,c=a.callback,e=a.texture_path?a.texture_path:this.extractUrlbase(b);a=new Worker(b);a.onmessage=function(d){f.createModel(d.data,c,e);f.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
+THREE.JSONLoader.prototype.createModel=function(a,f,b){var c=new THREE.Geometry;this.init_materials(c,a.materials,b);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var e,d,g,h,l,k,j,n,p,t,x,w,u,B,y,m=a.faces;t=a.vertices;var z=a.normals,C=a.colors;k=a.scale!==undefined?a.scale:1;var G=0;for(e=0;e<a.uvs.length;e++)a.uvs[e].length&&G++;for(e=0;e<G;e++){c.faceUvs[e]=[];c.faceVertexUvs[e]=[]}h=0;for(l=t.length;h<l;){j=new THREE.Vertex;j.position.x=t[h++]/
+k;j.position.y=t[h++]/k;j.position.z=t[h++]/k;c.vertices.push(j)}h=0;for(l=m.length;h<l;){t=m[h++];k=t&1;g=t&2;e=t&4;d=t&8;n=t&16;j=t&32;x=t&64;t&=128;if(k){w=new THREE.Face4;w.a=m[h++];w.b=m[h++];w.c=m[h++];w.d=m[h++];k=4}else{w=new THREE.Face3;w.a=m[h++];w.b=m[h++];w.c=m[h++];k=3}if(g){g=m[h++];w.materials=c.materials[g]}g=c.faces.length;if(e)for(e=0;e<G;e++){u=a.uvs[e];p=m[h++];y=u[p*2];p=u[p*2+1];c.faceUvs[e][g]=new THREE.UV(y,p)}if(d)for(e=0;e<G;e++){u=a.uvs[e];B=[];for(d=0;d<k;d++){p=m[h++];
+y=u[p*2];p=u[p*2+1];B[d]=new THREE.UV(y,p)}c.faceVertexUvs[e][g]=B}if(n){n=m[h++]*3;d=new THREE.Vector3;d.x=z[n++];d.y=z[n++];d.z=z[n];w.normal=d}if(j)for(e=0;e<k;e++){n=m[h++]*3;d=new THREE.Vector3;d.x=z[n++];d.y=z[n++];d.z=z[n];w.vertexNormals.push(d)}if(x){j=m[h++];j=new THREE.Color(C[j]);w.color=j}if(t)for(e=0;e<k;e++){j=m[h++];j=new THREE.Color(C[j]);w.vertexColors.push(j)}c.faces.push(w)}}})();(function(){var e,d,g,h;if(a.skinWeights){e=0;for(d=a.skinWeights.length;e<d;e+=2){g=a.skinWeights[e];
+h=a.skinWeights[e+1];c.skinWeights.push(new THREE.Vector4(g,h,0,0))}}if(a.skinIndices){e=0;for(d=a.skinIndices.length;e<d;e+=2){g=a.skinIndices[e];h=a.skinIndices[e+1];c.skinIndices.push(new THREE.Vector4(g,h,0,0))}}c.bones=a.bones;c.animation=a.animation})();(function(){if(a.morphTargets!==undefined){var e,d,g,h,l,k;e=0;for(d=a.morphTargets.length;e<d;e++){c.morphTargets[e]={};c.morphTargets[e].name=a.morphTargets[e].name;c.morphTargets[e].vertices=[];l=c.morphTargets[e].vertices;k=a.morphTargets[e].vertices;
+g=0;for(h=k.length;g<h;g+=3)l.push(new THREE.Vertex(new THREE.Vector3(k[g],k[g+1],k[g+2])))}}if(a.morphColors!==undefined){var j,n;e=0;for(d=a.morphColors.length;e<d;e++){c.morphColors[e]={};c.morphColors[e].name=a.morphColors[e].name;c.morphColors[e].colors=[];k=c.morphColors[e].colors;j=a.morphColors[e].colors;h=0;for(l=j.length;h<l;h+=3){n=new THREE.Color(16755200);n.setRGB(j[g],j[g+1],j[g+2]);k.push(n)}}}})();c.computeCentroids();c.computeFaceNormals();f(c)};
 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 f=a.model,b=a.callback,c=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(f),d=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(f);a=(new Date).getTime();f=new Worker(f);var e=this.showProgress?THREE.Loader.prototype.updateProgress:null;f.onmessage=function(g){THREE.BinaryLoader.prototype.loadAjaxBuffers(g.data.buffers,g.data.materials,b,d,c,e)};f.onerror=function(g){alert("worker.onerror: "+g.message+"\n"+g.data);g.preventDefault()};
-f.postMessage(a)},loadAjaxBuffers:function(a,f,b,c,d,e){var g=new XMLHttpRequest,h=c+"/"+a,l=0;g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.BinaryLoader.prototype.createBinModel(g.responseText,b,d,f):alert("Couldn't load ["+h+"] ["+g.status+"]");else if(g.readyState==3){if(e){l==0&&(l=g.getResponseHeader("Content-Length"));e({total:l,loaded:g.responseText.length})}}else g.readyState==2&&(l=g.getResponseHeader("Content-Length"))};g.open("GET",h,!0);g.overrideMimeType("text/plain; charset=x-user-defined");
-g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(a,f,b,c){var d=function(e){function g(o,v){var A=j(o,v),D=j(o,v+1),H=j(o,v+2),Q=j(o,v+3),T=(Q<<1&255|H>>7)-127;A|=(H&127)<<16|D<<8;if(A==0&&T==-127)return 0;return(1-2*(Q>>7))*(1+A*Math.pow(2,-23))*Math.pow(2,T)}function h(o,v){var A=j(o,v),D=j(o,v+1),H=j(o,v+2);return(j(o,v+3)<<24)+(H<<16)+(D<<8)+A}function l(o,v){var A=j(o,v);return(j(o,v+1)<<8)+A}function k(o,v){var A=j(o,v);return A>127?A-256:A}function j(o,
-v){return o.charCodeAt(v)&255}function n(o){var v,A,D;v=h(a,o);A=h(a,o+G);D=h(a,o+K);o=l(a,o+J);THREE.BinaryLoader.prototype.f3(B,v,A,D,o)}function p(o){var v,A,D,H,Q,T;v=h(a,o);A=h(a,o+G);D=h(a,o+K);H=l(a,o+J);Q=h(a,o+I);T=h(a,o+E);o=h(a,o+L);THREE.BinaryLoader.prototype.f3n(B,z,v,A,D,H,Q,T,o)}function t(o){var v,A,D,H;v=h(a,o);A=h(a,o+S);D=h(a,o+P);H=h(a,o+N);o=l(a,o+O);THREE.BinaryLoader.prototype.f4(B,v,A,D,H,o)}function w(o){var v,A,D,H,Q,T,ba,ca;v=h(a,o);A=h(a,o+S);D=h(a,o+P);H=h(a,o+N);Q=l(a,
-o+O);T=h(a,o+R);ba=h(a,o+F);ca=h(a,o+M);o=h(a,o+V);THREE.BinaryLoader.prototype.f4n(B,z,v,A,D,H,Q,T,ba,ca,o)}function x(o){var v,A;v=h(a,o);A=h(a,o+W);o=h(a,o+da);THREE.BinaryLoader.prototype.uv3(B.faceVertexUvs[0],C[v*2],C[v*2+1],C[A*2],C[A*2+1],C[o*2],C[o*2+1])}function u(o){var v,A,D;v=h(a,o);A=h(a,o+ea);D=h(a,o+fa);o=h(a,o+ga);THREE.BinaryLoader.prototype.uv4(B.faceVertexUvs[0],C[v*2],C[v*2+1],C[A*2],C[A*2+1],C[D*2],C[D*2+1],C[o*2],C[o*2+1])}var B=this,y=0,m,z=[],C=[],G,K,J,I,E,L,S,P,N,O,R,F,
-M,V,W,da,ea,fa,ga,X,Y,Z,$,aa,U;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(B,c,e);m={signature:a.substr(y,8),header_bytes:j(a,y+8),vertex_coordinate_bytes:j(a,y+9),normal_coordinate_bytes:j(a,y+10),uv_coordinate_bytes:j(a,y+11),vertex_index_bytes:j(a,y+12),normal_index_bytes:j(a,y+13),uv_index_bytes:j(a,y+14),material_index_bytes:j(a,y+15),nvertices:h(a,y+16),nnormals:h(a,y+16+4),nuvs:h(a,y+16+8),ntri_flat:h(a,y+16+12),ntri_smooth:h(a,y+16+16),ntri_flat_uv:h(a,y+16+20),ntri_smooth_uv:h(a,
+THREE.BinaryLoader.prototype={load:function(a){var f=a.model,b=a.callback,c=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(f),e=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(f);a=(new Date).getTime();f=new Worker(f);var d=this.showProgress?THREE.Loader.prototype.updateProgress:null;f.onmessage=function(g){THREE.BinaryLoader.prototype.loadAjaxBuffers(g.data.buffers,g.data.materials,b,e,c,d)};f.onerror=function(g){alert("worker.onerror: "+g.message+"\n"+g.data);g.preventDefault()};
+f.postMessage(a)},loadAjaxBuffers:function(a,f,b,c,e,d){var g=new XMLHttpRequest,h=c+"/"+a,l=0;g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.BinaryLoader.prototype.createBinModel(g.responseText,b,e,f):alert("Couldn't load ["+h+"] ["+g.status+"]");else if(g.readyState==3){if(d){l==0&&(l=g.getResponseHeader("Content-Length"));d({total:l,loaded:g.responseText.length})}}else g.readyState==2&&(l=g.getResponseHeader("Content-Length"))};g.open("GET",h,!0);g.overrideMimeType("text/plain; charset=x-user-defined");
+g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(a,f,b,c){var e=function(d){function g(o,v){var A=j(o,v),D=j(o,v+1),H=j(o,v+2),Q=j(o,v+3),T=(Q<<1&255|H>>7)-127;A|=(H&127)<<16|D<<8;if(A==0&&T==-127)return 0;return(1-2*(Q>>7))*(1+A*Math.pow(2,-23))*Math.pow(2,T)}function h(o,v){var A=j(o,v),D=j(o,v+1),H=j(o,v+2);return(j(o,v+3)<<24)+(H<<16)+(D<<8)+A}function l(o,v){var A=j(o,v);return(j(o,v+1)<<8)+A}function k(o,v){var A=j(o,v);return A>127?A-256:A}function j(o,
+v){return o.charCodeAt(v)&255}function n(o){var v,A,D;v=h(a,o);A=h(a,o+G);D=h(a,o+K);o=l(a,o+J);THREE.BinaryLoader.prototype.f3(B,v,A,D,o)}function p(o){var v,A,D,H,Q,T;v=h(a,o);A=h(a,o+G);D=h(a,o+K);H=l(a,o+J);Q=h(a,o+I);T=h(a,o+E);o=h(a,o+L);THREE.BinaryLoader.prototype.f3n(B,z,v,A,D,H,Q,T,o)}function t(o){var v,A,D,H;v=h(a,o);A=h(a,o+S);D=h(a,o+P);H=h(a,o+N);o=l(a,o+O);THREE.BinaryLoader.prototype.f4(B,v,A,D,H,o)}function x(o){var v,A,D,H,Q,T,ba,ca;v=h(a,o);A=h(a,o+S);D=h(a,o+P);H=h(a,o+N);Q=l(a,
+o+O);T=h(a,o+R);ba=h(a,o+F);ca=h(a,o+M);o=h(a,o+V);THREE.BinaryLoader.prototype.f4n(B,z,v,A,D,H,Q,T,ba,ca,o)}function w(o){var v,A;v=h(a,o);A=h(a,o+W);o=h(a,o+da);THREE.BinaryLoader.prototype.uv3(B.faceVertexUvs[0],C[v*2],C[v*2+1],C[A*2],C[A*2+1],C[o*2],C[o*2+1])}function u(o){var v,A,D;v=h(a,o);A=h(a,o+ea);D=h(a,o+fa);o=h(a,o+ga);THREE.BinaryLoader.prototype.uv4(B.faceVertexUvs[0],C[v*2],C[v*2+1],C[A*2],C[A*2+1],C[D*2],C[D*2+1],C[o*2],C[o*2+1])}var B=this,y=0,m,z=[],C=[],G,K,J,I,E,L,S,P,N,O,R,F,
+M,V,W,da,ea,fa,ga,X,Y,Z,$,aa,U;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(B,c,d);m={signature:a.substr(y,8),header_bytes:j(a,y+8),vertex_coordinate_bytes:j(a,y+9),normal_coordinate_bytes:j(a,y+10),uv_coordinate_bytes:j(a,y+11),vertex_index_bytes:j(a,y+12),normal_index_bytes:j(a,y+13),uv_index_bytes:j(a,y+14),material_index_bytes:j(a,y+15),nvertices:h(a,y+16),nnormals:h(a,y+16+4),nuvs:h(a,y+16+8),ntri_flat:h(a,y+16+12),ntri_smooth:h(a,y+16+16),ntri_flat_uv:h(a,y+16+20),ntri_smooth_uv:h(a,
 y+16+24),nquad_flat:h(a,y+16+28),nquad_smooth:h(a,y+16+32),nquad_flat_uv:h(a,y+16+36),nquad_smooth_uv:h(a,y+16+40)};y+=m.header_bytes;G=m.vertex_index_bytes;K=m.vertex_index_bytes*2;J=m.vertex_index_bytes*3;I=m.vertex_index_bytes*3+m.material_index_bytes;E=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes;L=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*2;S=m.vertex_index_bytes;P=m.vertex_index_bytes*2;N=m.vertex_index_bytes*3;O=m.vertex_index_bytes*4;R=m.vertex_index_bytes*
-4+m.material_index_bytes;F=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;M=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;V=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;W=m.uv_index_bytes;da=m.uv_index_bytes*2;ea=m.uv_index_bytes;fa=m.uv_index_bytes*2;ga=m.uv_index_bytes*3;e=m.vertex_index_bytes*3+m.material_index_bytes;U=m.vertex_index_bytes*4+m.material_index_bytes;X=m.ntri_flat*e;Y=m.ntri_smooth*(e+m.normal_index_bytes*3);Z=m.ntri_flat_uv*
-(e+m.uv_index_bytes*3);$=m.ntri_smooth_uv*(e+m.normal_index_bytes*3+m.uv_index_bytes*3);aa=m.nquad_flat*U;e=m.nquad_smooth*(U+m.normal_index_bytes*4);U=m.nquad_flat_uv*(U+m.uv_index_bytes*4);y+=function(o){for(var v,A,D,H=m.vertex_coordinate_bytes*3,Q=o+m.nvertices*H;o<Q;o+=H){v=g(a,o);A=g(a,o+m.vertex_coordinate_bytes);D=g(a,o+m.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(B,v,A,D)}return m.nvertices*H}(y);y+=function(o){for(var v,A,D,H=m.normal_coordinate_bytes*3,Q=o+m.nnormals*H;o<
-Q;o+=H){v=k(a,o);A=k(a,o+m.normal_coordinate_bytes);D=k(a,o+m.normal_coordinate_bytes*2);z.push(v/127,A/127,D/127)}return m.nnormals*H}(y);y+=function(o){for(var v,A,D=m.uv_coordinate_bytes*2,H=o+m.nuvs*D;o<H;o+=D){v=g(a,o);A=g(a,o+m.uv_coordinate_bytes);C.push(v,A)}return m.nuvs*D}(y);X=y+X;Y=X+Y;Z=Y+Z;$=Z+$;aa=$+aa;e=aa+e;U=e+U;(function(o){var v,A=m.vertex_index_bytes*3+m.material_index_bytes,D=A+m.uv_index_bytes*3,H=o+m.ntri_flat_uv*D;for(v=o;v<H;v+=D){n(v);x(v+A)}return H-o})(Y);(function(o){var v,
-A=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,D=A+m.uv_index_bytes*3,H=o+m.ntri_smooth_uv*D;for(v=o;v<H;v+=D){p(v);x(v+A)}return H-o})(Z);(function(o){var v,A=m.vertex_index_bytes*4+m.material_index_bytes,D=A+m.uv_index_bytes*4,H=o+m.nquad_flat_uv*D;for(v=o;v<H;v+=D){t(v);u(v+A)}return H-o})(e);(function(o){var v,A=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,D=A+m.uv_index_bytes*4,H=o+m.nquad_smooth_uv*D;for(v=o;v<H;v+=D){w(v);u(v+A)}return H-o})(U);
+4+m.material_index_bytes;F=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes;M=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*2;V=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*3;W=m.uv_index_bytes;da=m.uv_index_bytes*2;ea=m.uv_index_bytes;fa=m.uv_index_bytes*2;ga=m.uv_index_bytes*3;d=m.vertex_index_bytes*3+m.material_index_bytes;U=m.vertex_index_bytes*4+m.material_index_bytes;X=m.ntri_flat*d;Y=m.ntri_smooth*(d+m.normal_index_bytes*3);Z=m.ntri_flat_uv*
+(d+m.uv_index_bytes*3);$=m.ntri_smooth_uv*(d+m.normal_index_bytes*3+m.uv_index_bytes*3);aa=m.nquad_flat*U;d=m.nquad_smooth*(U+m.normal_index_bytes*4);U=m.nquad_flat_uv*(U+m.uv_index_bytes*4);y+=function(o){for(var v,A,D,H=m.vertex_coordinate_bytes*3,Q=o+m.nvertices*H;o<Q;o+=H){v=g(a,o);A=g(a,o+m.vertex_coordinate_bytes);D=g(a,o+m.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(B,v,A,D)}return m.nvertices*H}(y);y+=function(o){for(var v,A,D,H=m.normal_coordinate_bytes*3,Q=o+m.nnormals*H;o<
+Q;o+=H){v=k(a,o);A=k(a,o+m.normal_coordinate_bytes);D=k(a,o+m.normal_coordinate_bytes*2);z.push(v/127,A/127,D/127)}return m.nnormals*H}(y);y+=function(o){for(var v,A,D=m.uv_coordinate_bytes*2,H=o+m.nuvs*D;o<H;o+=D){v=g(a,o);A=g(a,o+m.uv_coordinate_bytes);C.push(v,A)}return m.nuvs*D}(y);X=y+X;Y=X+Y;Z=Y+Z;$=Z+$;aa=$+aa;d=aa+d;U=d+U;(function(o){var v,A=m.vertex_index_bytes*3+m.material_index_bytes,D=A+m.uv_index_bytes*3,H=o+m.ntri_flat_uv*D;for(v=o;v<H;v+=D){n(v);w(v+A)}return H-o})(Y);(function(o){var v,
+A=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,D=A+m.uv_index_bytes*3,H=o+m.ntri_smooth_uv*D;for(v=o;v<H;v+=D){p(v);w(v+A)}return H-o})(Z);(function(o){var v,A=m.vertex_index_bytes*4+m.material_index_bytes,D=A+m.uv_index_bytes*4,H=o+m.nquad_flat_uv*D;for(v=o;v<H;v+=D){t(v);u(v+A)}return H-o})(d);(function(o){var v,A=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,D=A+m.uv_index_bytes*4,H=o+m.nquad_smooth_uv*D;for(v=o;v<H;v+=D){x(v);u(v+A)}return H-o})(U);
 (function(o){var v,A=m.vertex_index_bytes*3+m.material_index_bytes,D=o+m.ntri_flat*A;for(v=o;v<D;v+=A)n(v);return D-o})(y);(function(o){var v,A=m.vertex_index_bytes*3+m.material_index_bytes+m.normal_index_bytes*3,D=o+m.ntri_smooth*A;for(v=o;v<D;v+=A)p(v);return D-o})(X);(function(o){var v,A=m.vertex_index_bytes*4+m.material_index_bytes,D=o+m.nquad_flat*A;for(v=o;v<D;v+=A)t(v);return D-o})($);(function(o){var v,A=m.vertex_index_bytes*4+m.material_index_bytes+m.normal_index_bytes*4,D=o+m.nquad_smooth*
-A;for(v=o;v<D;v+=A)w(v);return D-o})(aa);this.computeCentroids();this.computeFaceNormals()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;f(new d(b))},v:function(a,f,b,c){a.vertices.push(new THREE.Vertex(new THREE.Vector3(f,b,c)))},f3:function(a,f,b,c,d){a.faces.push(new THREE.Face3(f,b,c,null,null,a.materials[d]))},f4:function(a,f,b,c,d,e){a.faces.push(new THREE.Face4(f,b,c,d,null,null,a.materials[e]))},f3n:function(a,f,b,c,d,e,g,h,l){e=a.materials[e];var k=f[h*3],j=f[h*3+1];h=f[h*3+2];
-var n=f[l*3],p=f[l*3+1];l=f[l*3+2];a.faces.push(new THREE.Face3(b,c,d,[new THREE.Vector3(f[g*3],f[g*3+1],f[g*3+2]),new THREE.Vector3(k,j,h),new THREE.Vector3(n,p,l)],null,e))},f4n:function(a,f,b,c,d,e,g,h,l,k,j){g=a.materials[g];var n=f[l*3],p=f[l*3+1];l=f[l*3+2];var t=f[k*3],w=f[k*3+1];k=f[k*3+2];var x=f[j*3],u=f[j*3+1];j=f[j*3+2];a.faces.push(new THREE.Face4(b,c,d,e,[new THREE.Vector3(f[h*3],f[h*3+1],f[h*3+2]),new THREE.Vector3(n,p,l),new THREE.Vector3(t,w,k),new THREE.Vector3(x,u,j)],null,g))},
-uv3:function(a,f,b,c,d,e,g){var h=[];h.push(new THREE.UV(f,b));h.push(new THREE.UV(c,d));h.push(new THREE.UV(e,g));a.push(h)},uv4:function(a,f,b,c,d,e,g,h,l){var k=[];k.push(new THREE.UV(f,b));k.push(new THREE.UV(c,d));k.push(new THREE.UV(e,g));k.push(new THREE.UV(h,l));a.push(k)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
+A;for(v=o;v<D;v+=A)x(v);return D-o})(aa);this.computeCentroids();this.computeFaceNormals()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;f(new e(b))},v:function(a,f,b,c){a.vertices.push(new THREE.Vertex(new THREE.Vector3(f,b,c)))},f3:function(a,f,b,c,e){a.faces.push(new THREE.Face3(f,b,c,null,null,a.materials[e]))},f4:function(a,f,b,c,e,d){a.faces.push(new THREE.Face4(f,b,c,e,null,null,a.materials[d]))},f3n:function(a,f,b,c,e,d,g,h,l){d=a.materials[d];var k=f[h*3],j=f[h*3+1];h=f[h*3+2];
+var n=f[l*3],p=f[l*3+1];l=f[l*3+2];a.faces.push(new THREE.Face3(b,c,e,[new THREE.Vector3(f[g*3],f[g*3+1],f[g*3+2]),new THREE.Vector3(k,j,h),new THREE.Vector3(n,p,l)],null,d))},f4n:function(a,f,b,c,e,d,g,h,l,k,j){g=a.materials[g];var n=f[l*3],p=f[l*3+1];l=f[l*3+2];var t=f[k*3],x=f[k*3+1];k=f[k*3+2];var w=f[j*3],u=f[j*3+1];j=f[j*3+2];a.faces.push(new THREE.Face4(b,c,e,d,[new THREE.Vector3(f[h*3],f[h*3+1],f[h*3+2]),new THREE.Vector3(n,p,l),new THREE.Vector3(t,x,k),new THREE.Vector3(w,u,j)],null,g))},
+uv3:function(a,f,b,c,e,d,g){var h=[];h.push(new THREE.UV(f,b));h.push(new THREE.UV(c,e));h.push(new THREE.UV(d,g));a.push(h)},uv4:function(a,f,b,c,e,d,g,h,l){var k=[];k.push(new THREE.UV(f,b));k.push(new THREE.UV(c,e));k.push(new THREE.UV(d,g));k.push(new THREE.UV(h,l));a.push(k)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 THREE.MarchingCubes=function(a,f){THREE.Object3D.call(this);this.materials=f instanceof Array?f:[f];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
-0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,c,d){return b+(c-b)*d};this.VIntX=function(b,c,d,e,g,h,l,k,j,n){g=(g-j)/(n-j);j=this.normal_cache;c[e]=h+g*this.delta;c[e+1]=l;c[e+2]=k;d[e]=this.lerp(j[b],j[b+3],g);d[e+1]=this.lerp(j[b+1],j[b+4],g);d[e+2]=this.lerp(j[b+2],j[b+5],g)};this.VIntY=function(b,c,d,e,g,h,l,k,j,n){g=(g-j)/(n-j);j=this.normal_cache;c[e]=h;c[e+1]=l+g*this.delta;c[e+
-2]=k;c=b+this.yd*3;d[e]=this.lerp(j[b],j[c],g);d[e+1]=this.lerp(j[b+1],j[c+1],g);d[e+2]=this.lerp(j[b+2],j[c+2],g)};this.VIntZ=function(b,c,d,e,g,h,l,k,j,n){g=(g-j)/(n-j);j=this.normal_cache;c[e]=h;c[e+1]=l;c[e+2]=k+g*this.delta;c=b+this.zd*3;d[e]=this.lerp(j[b],j[c],g);d[e+1]=this.lerp(j[b+1],j[c+1],g);d[e+2]=this.lerp(j[b+2],j[c+2],g)};this.compNorm=function(b){var c=b*3;if(this.normal_cache[c]==0){this.normal_cache[c]=this.field[b-1]-this.field[b+1];this.normal_cache[c+1]=this.field[b-this.yd]-
-this.field[b+this.yd];this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,c,d,e,g,h){var l=e+1,k=e+this.yd,j=e+this.zd,n=l+this.yd,p=l+this.zd,t=e+this.yd+this.zd,w=l+this.yd+this.zd,x=0,u=this.field[e],B=this.field[l],y=this.field[k],m=this.field[n],z=this.field[j],C=this.field[p],G=this.field[t],K=this.field[w];u<g&&(x|=1);B<g&&(x|=2);y<g&&(x|=8);m<g&&(x|=4);z<g&&(x|=16);C<g&&(x|=32);G<g&&(x|=128);K<g&&(x|=64);var J=THREE.edgeTable[x];if(J==0)return 0;
-var I=this.delta,E=b+I,L=c+I;I=d+I;if(J&1){this.compNorm(e);this.compNorm(l);this.VIntX(e*3,this.vlist,this.nlist,0,g,b,c,d,u,B)}if(J&2){this.compNorm(l);this.compNorm(n);this.VIntY(l*3,this.vlist,this.nlist,3,g,E,c,d,B,m)}if(J&4){this.compNorm(k);this.compNorm(n);this.VIntX(k*3,this.vlist,this.nlist,6,g,b,L,d,y,m)}if(J&8){this.compNorm(e);this.compNorm(k);this.VIntY(e*3,this.vlist,this.nlist,9,g,b,c,d,u,y)}if(J&16){this.compNorm(j);this.compNorm(p);this.VIntX(j*3,this.vlist,this.nlist,12,g,b,c,I,
-z,C)}if(J&32){this.compNorm(p);this.compNorm(w);this.VIntY(p*3,this.vlist,this.nlist,15,g,E,c,I,C,K)}if(J&64){this.compNorm(t);this.compNorm(w);this.VIntX(t*3,this.vlist,this.nlist,18,g,b,L,I,G,K)}if(J&128){this.compNorm(j);this.compNorm(t);this.VIntY(j*3,this.vlist,this.nlist,21,g,b,c,I,z,G)}if(J&256){this.compNorm(e);this.compNorm(j);this.VIntZ(e*3,this.vlist,this.nlist,24,g,b,c,d,u,z)}if(J&512){this.compNorm(l);this.compNorm(p);this.VIntZ(l*3,this.vlist,this.nlist,27,g,E,c,d,B,C)}if(J&1024){this.compNorm(n);
-this.compNorm(w);this.VIntZ(n*3,this.vlist,this.nlist,30,g,E,L,d,m,K)}if(J&2048){this.compNorm(k);this.compNorm(t);this.VIntZ(k*3,this.vlist,this.nlist,33,g,b,L,d,y,G)}x<<=4;for(g=e=0;THREE.triTable[x+g]!=-1;){b=x+g;c=b+1;d=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[d],h);g+=3;e++}return e};this.posnormtriv=function(b,c,d,e,g,h){var l=this.count*3;this.positionArray[l]=b[d];this.positionArray[l+1]=b[d+1];this.positionArray[l+2]=b[d+2];this.positionArray[l+
-3]=b[e];this.positionArray[l+4]=b[e+1];this.positionArray[l+5]=b[e+2];this.positionArray[l+6]=b[g];this.positionArray[l+7]=b[g+1];this.positionArray[l+8]=b[g+2];this.normalArray[l]=c[d];this.normalArray[l+1]=c[d+1];this.normalArray[l+2]=c[d+2];this.normalArray[l+3]=c[e];this.normalArray[l+4]=c[e+1];this.normalArray[l+5]=c[e+2];this.normalArray[l+6]=c[g];this.normalArray[l+7]=c[g+1];this.normalArray[l+8]=c[g+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=
-function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;c<this.positionArray.length;c++)this.positionArray[c]=0;b(this)}};this.addBall=function(b,c,d,e,g){var h=this.size*Math.sqrt(e/g),l=d*this.size,k=c*this.size,j=b*this.size,n=Math.floor(l-h);n<1&&(n=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var p=Math.floor(k-h);p<1&&(p=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var t=Math.floor(j-h);t<1&&(t=1);h=Math.floor(j+h);
-h>this.size-1&&(h=this.size-1);for(var w,x,u,B,y,m;n<l;n++){j=this.size2*n;x=n/this.size-d;y=x*x;for(x=p;x<k;x++){u=j+this.size*x;w=x/this.size-c;m=w*w;for(w=t;w<h;w++){B=w/this.size-b;B=e/(1.0E-6+B*B+m+y)-g;B>0&&(this.field[u+w]+=B)}}}};this.addPlaneX=function(b,c){var d,e,g,h,l,k=this.size,j=this.yd,n=this.zd,p=this.field,t=k*Math.sqrt(b/c);t>k&&(t=k);for(d=0;d<t;d++){e=d/k;e*=e;h=b/(1.0E-4+e)-c;if(h>0)for(e=0;e<k;e++){l=d+e*j;for(g=0;g<k;g++)p[n*g+l]+=h}}};this.addPlaneY=function(b,c){var d,e,
-g,h,l,k,j=this.size,n=this.yd,p=this.zd,t=this.field,w=j*Math.sqrt(b/c);w>j&&(w=j);for(e=0;e<w;e++){d=e/j;d*=d;h=b/(1.0E-4+d)-c;if(h>0){l=e*n;for(d=0;d<j;d++){k=l+d;for(g=0;g<j;g++)t[p*g+k]+=h}}}};this.addPlaneZ=function(b,c){var d,e,g,h,l,k;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(g=0;g<dist;g++){d=g/size;d*=d;h=b/(1.0E-4+d)-c;if(h>0){l=zd*g;for(e=0;e<size;e++){k=l+e*yd;for(d=0;d<size;d++)field[k+d]+=h}}}};this.reset=function(){var b;
-for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var c,d,e,g,h,l,k,j,n,p=this.size-2;for(g=1;g<p;g++){n=this.size2*g;k=(g-this.halfsize)/this.halfsize;for(e=1;e<p;e++){j=n+this.size*e;l=(e-this.halfsize)/this.halfsize;for(d=1;d<p;d++){h=(d-this.halfsize)/this.halfsize;c=j+d;this.polygonize(h,l,k,c,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry;this.render(function(d){var e,g,h,l,k,j,n,p;for(e=
-0;e<d.count;e++){k=e*3;n=k+1;p=k+2;g=d.positionArray[k];h=d.positionArray[n];l=d.positionArray[p];j=new THREE.Vector3(g,h,l);g=d.normalArray[k];h=d.normalArray[n];l=d.normalArray[p];k=new THREE.Vector3(g,h,l);k.normalize();k=new THREE.Vertex(j,k);c.vertices.push(k)}nfaces=d.count/3;for(e=0;e<nfaces;e++){k=(b+e)*3;n=k+1;p=k+2;j=c.vertices[k].normal;g=c.vertices[n].normal;h=c.vertices[p].normal;k=new THREE.Face3(k,n,p,[j,g,h]);c.faces.push(k)}b+=nfaces;d.count=0});return c};this.init(a)};
+0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,c,e){return b+(c-b)*e};this.VIntX=function(b,c,e,d,g,h,l,k,j,n){g=(g-j)/(n-j);j=this.normal_cache;c[d]=h+g*this.delta;c[d+1]=l;c[d+2]=k;e[d]=this.lerp(j[b],j[b+3],g);e[d+1]=this.lerp(j[b+1],j[b+4],g);e[d+2]=this.lerp(j[b+2],j[b+5],g)};this.VIntY=function(b,c,e,d,g,h,l,k,j,n){g=(g-j)/(n-j);j=this.normal_cache;c[d]=h;c[d+1]=l+g*this.delta;c[d+
+2]=k;c=b+this.yd*3;e[d]=this.lerp(j[b],j[c],g);e[d+1]=this.lerp(j[b+1],j[c+1],g);e[d+2]=this.lerp(j[b+2],j[c+2],g)};this.VIntZ=function(b,c,e,d,g,h,l,k,j,n){g=(g-j)/(n-j);j=this.normal_cache;c[d]=h;c[d+1]=l;c[d+2]=k+g*this.delta;c=b+this.zd*3;e[d]=this.lerp(j[b],j[c],g);e[d+1]=this.lerp(j[b+1],j[c+1],g);e[d+2]=this.lerp(j[b+2],j[c+2],g)};this.compNorm=function(b){var c=b*3;if(this.normal_cache[c]==0){this.normal_cache[c]=this.field[b-1]-this.field[b+1];this.normal_cache[c+1]=this.field[b-this.yd]-
+this.field[b+this.yd];this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,c,e,d,g,h){var l=d+1,k=d+this.yd,j=d+this.zd,n=l+this.yd,p=l+this.zd,t=d+this.yd+this.zd,x=l+this.yd+this.zd,w=0,u=this.field[d],B=this.field[l],y=this.field[k],m=this.field[n],z=this.field[j],C=this.field[p],G=this.field[t],K=this.field[x];u<g&&(w|=1);B<g&&(w|=2);y<g&&(w|=8);m<g&&(w|=4);z<g&&(w|=16);C<g&&(w|=32);G<g&&(w|=128);K<g&&(w|=64);var J=THREE.edgeTable[w];if(J==0)return 0;
+var I=this.delta,E=b+I,L=c+I;I=e+I;if(J&1){this.compNorm(d);this.compNorm(l);this.VIntX(d*3,this.vlist,this.nlist,0,g,b,c,e,u,B)}if(J&2){this.compNorm(l);this.compNorm(n);this.VIntY(l*3,this.vlist,this.nlist,3,g,E,c,e,B,m)}if(J&4){this.compNorm(k);this.compNorm(n);this.VIntX(k*3,this.vlist,this.nlist,6,g,b,L,e,y,m)}if(J&8){this.compNorm(d);this.compNorm(k);this.VIntY(d*3,this.vlist,this.nlist,9,g,b,c,e,u,y)}if(J&16){this.compNorm(j);this.compNorm(p);this.VIntX(j*3,this.vlist,this.nlist,12,g,b,c,I,
+z,C)}if(J&32){this.compNorm(p);this.compNorm(x);this.VIntY(p*3,this.vlist,this.nlist,15,g,E,c,I,C,K)}if(J&64){this.compNorm(t);this.compNorm(x);this.VIntX(t*3,this.vlist,this.nlist,18,g,b,L,I,G,K)}if(J&128){this.compNorm(j);this.compNorm(t);this.VIntY(j*3,this.vlist,this.nlist,21,g,b,c,I,z,G)}if(J&256){this.compNorm(d);this.compNorm(j);this.VIntZ(d*3,this.vlist,this.nlist,24,g,b,c,e,u,z)}if(J&512){this.compNorm(l);this.compNorm(p);this.VIntZ(l*3,this.vlist,this.nlist,27,g,E,c,e,B,C)}if(J&1024){this.compNorm(n);
+this.compNorm(x);this.VIntZ(n*3,this.vlist,this.nlist,30,g,E,L,e,m,K)}if(J&2048){this.compNorm(k);this.compNorm(t);this.VIntZ(k*3,this.vlist,this.nlist,33,g,b,L,e,y,G)}w<<=4;for(g=d=0;THREE.triTable[w+g]!=-1;){b=w+g;c=b+1;e=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[e],h);g+=3;d++}return d};this.posnormtriv=function(b,c,e,d,g,h){var l=this.count*3;this.positionArray[l]=b[e];this.positionArray[l+1]=b[e+1];this.positionArray[l+2]=b[e+2];this.positionArray[l+
+3]=b[d];this.positionArray[l+4]=b[d+1];this.positionArray[l+5]=b[d+2];this.positionArray[l+6]=b[g];this.positionArray[l+7]=b[g+1];this.positionArray[l+8]=b[g+2];this.normalArray[l]=c[e];this.normalArray[l+1]=c[e+1];this.normalArray[l+2]=c[e+2];this.normalArray[l+3]=c[d];this.normalArray[l+4]=c[d+1];this.normalArray[l+5]=c[d+2];this.normalArray[l+6]=c[g];this.normalArray[l+7]=c[g+1];this.normalArray[l+8]=c[g+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=
+function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;c<this.positionArray.length;c++)this.positionArray[c]=0;b(this)}};this.addBall=function(b,c,e,d,g){var h=this.size*Math.sqrt(d/g),l=e*this.size,k=c*this.size,j=b*this.size,n=Math.floor(l-h);n<1&&(n=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var p=Math.floor(k-h);p<1&&(p=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var t=Math.floor(j-h);t<1&&(t=1);h=Math.floor(j+h);
+h>this.size-1&&(h=this.size-1);for(var x,w,u,B,y,m;n<l;n++){j=this.size2*n;w=n/this.size-e;y=w*w;for(w=p;w<k;w++){u=j+this.size*w;x=w/this.size-c;m=x*x;for(x=t;x<h;x++){B=x/this.size-b;B=d/(1.0E-6+B*B+m+y)-g;B>0&&(this.field[u+x]+=B)}}}};this.addPlaneX=function(b,c){var e,d,g,h,l,k=this.size,j=this.yd,n=this.zd,p=this.field,t=k*Math.sqrt(b/c);t>k&&(t=k);for(e=0;e<t;e++){d=e/k;d*=d;h=b/(1.0E-4+d)-c;if(h>0)for(d=0;d<k;d++){l=e+d*j;for(g=0;g<k;g++)p[n*g+l]+=h}}};this.addPlaneY=function(b,c){var e,d,
+g,h,l,k,j=this.size,n=this.yd,p=this.zd,t=this.field,x=j*Math.sqrt(b/c);x>j&&(x=j);for(d=0;d<x;d++){e=d/j;e*=e;h=b/(1.0E-4+e)-c;if(h>0){l=d*n;for(e=0;e<j;e++){k=l+e;for(g=0;g<j;g++)t[p*g+k]+=h}}}};this.addPlaneZ=function(b,c){var e,d,g,h,l,k;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(g=0;g<dist;g++){e=g/size;e*=e;h=b/(1.0E-4+e)-c;if(h>0){l=zd*g;for(d=0;d<size;d++){k=l+d*yd;for(e=0;e<size;e++)field[k+e]+=h}}}};this.reset=function(){var b;
+for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var c,e,d,g,h,l,k,j,n,p=this.size-2;for(g=1;g<p;g++){n=this.size2*g;k=(g-this.halfsize)/this.halfsize;for(d=1;d<p;d++){j=n+this.size*d;l=(d-this.halfsize)/this.halfsize;for(e=1;e<p;e++){h=(e-this.halfsize)/this.halfsize;c=j+e;this.polygonize(h,l,k,c,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry;this.render(function(e){var d,g,h,l,k,j,n,p;for(d=
+0;d<e.count;d++){k=d*3;n=k+1;p=k+2;g=e.positionArray[k];h=e.positionArray[n];l=e.positionArray[p];j=new THREE.Vector3(g,h,l);g=e.normalArray[k];h=e.normalArray[n];l=e.normalArray[p];k=new THREE.Vector3(g,h,l);k.normalize();k=new THREE.Vertex(j,k);c.vertices.push(k)}nfaces=e.count/3;for(d=0;d<nfaces;d++){k=(b+d)*3;n=k+1;p=k+2;j=c.vertices[k].normal;g=c.vertices[n].normal;h=c.vertices[p].normal;k=new THREE.Face3(k,n,p,[j,g,h]);c.faces.push(k)}b+=nfaces;e.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,

File diff suppressed because it is too large
+ 1 - 0
examples/obj/female02/Female02_slim.js


File diff suppressed because it is too large
+ 3 - 0
examples/obj/lucy/Lucy100k_slim.js


File diff suppressed because it is too large
+ 1 - 0
examples/obj/male02/Male02_slim.js


File diff suppressed because it is too large
+ 1 - 0
examples/obj/torus/Torus_slim.js


File diff suppressed because it is too large
+ 1 - 0
examples/obj/walt/WaltHead_slim.js


+ 3 - 1
src/extras/io/JSONLoader.js

@@ -258,7 +258,9 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 			if ( hasFaceColor ) {
 
-				color = new THREE.Color( faces[ offset ++ ] );
+				colorIndex = faces[ offset ++ ];
+
+				color = new THREE.Color( colors[ colorIndex ] );
 				face.color = color;
 
 			}

+ 18 - 2
src/extras/io/Loader.js

@@ -120,13 +120,15 @@ THREE.Loader.prototype = {
 
 		}
 
-		var material, mtype, mpars, texture, color;
+		var material, mtype, mpars, texture, color, vertexColors;
 
 		// defaults
 
 		mtype = "MeshLambertMaterial";
 
-		mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, vertexColors: m.vertexColors ? THREE.VertexColors : false, wireframe: m.wireframe };
+		vertexColors
+		
+		mpars = { color: 0xeeeeee, opacity: 1.0, map: null, lightMap: null, wireframe: m.wireframe };
 		
 		// parameters from model file
 
@@ -157,6 +159,20 @@ THREE.Loader.prototype = {
 
 		}
 		
+		if ( m.vertexColors !== undefined ) {
+			
+			if ( m.vertexColors == "face" ) {
+				
+				mpars.vertexColors = THREE.FaceColors;
+
+			} else if ( m.vertexColors ) {
+				
+				mpars.vertexColors = THREE.VertexColors;
+
+			}
+
+		}
+		
 		if ( m.mapDiffuse && texture_path ) {
 
 			texture = document.createElement( 'canvas' );

+ 28 - 3
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/import_threejs.py

@@ -108,11 +108,12 @@ def create_materials(data, modelpath):
     
 def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate_normals):
 
-    faces   = face_data["faces"]
+    faces         = face_data["faces"]
     vertexNormals = face_data["vertexNormals"]
-    vertexColors = face_data["vertexColors"]
-    vertexUVs = face_data["vertexUVs"]
+    vertexColors  = face_data["vertexColors"]
+    vertexUVs     = face_data["vertexUVs"]
     faceMaterials = face_data["materials"]
+    faceColors    = face_data["faceColors"]
     
     edges = []
     
@@ -200,7 +201,29 @@ def create_mesh_object(name, vertices, materials, face_data, flipYZ, recalculate
                     face_colors[vi].r = r
                     face_colors[vi].g = g
                     face_colors[vi].b = b
+                    
+    elif face_data["hasFaceColors"]:
+
+        print("setting vertex colors from face colors")
+
+        me.vertex_colors.new("vertex_color_layer_0")
+        
+        for fi in range(len(faces)):
+
+            if faceColors[fi]:
+
+                r = faceColors[fi][0]
+                g = faceColors[fi][1]
+                b = faceColors[fi][2]
 
+                face_colors = me.vertex_colors[0].data[fi]
+                face_colors = face_colors.color1, face_colors.color2, face_colors.color3, face_colors.color4
+                
+                for vi in range(len(faces[fi])):
+                
+                    face_colors[vi].r = r
+                    face_colors[vi].g = g
+                    face_colors[vi].b = b
 
     # Handle uvs
     
@@ -284,6 +307,7 @@ def extract_faces(data):
     "hasVertexNormals"  : False,
     "hasVertexUVs"      : False,
     "hasVertexColors"   : False,
+    "hasFaceColors"     : False,
     "hasMaterials"      : False
     }
     
@@ -325,6 +349,7 @@ def extract_faces(data):
         result["hasVertexUVs"] = result["hasVertexUVs"] or hasFaceVertexUv
         result["hasVertexNormals"] = result["hasVertexNormals"] or hasFaceVertexNormal
         result["hasVertexColors"] = result["hasVertexColors"] or hasFaceVertexColor
+        result["hasFaceColors"] = result["hasFaceColors"] or hasFaceColor
         result["hasMaterials"] = result["hasMaterials"] or hasMaterial
         
         # vertices

+ 74 - 17
utils/exporters/convert_obj_three.py

@@ -4,7 +4,7 @@
 How to use this converter
 -------------------------
 
-python convert_obj_three.py -i infile.obj -o outfile.js [-m morphfiles*.obj] [-c morphcolors*.obj] [-a center|centerxz|top|bottom|none] [-s smooth|flat] [-t ascii|binary] [-d invert|normal]
+python convert_obj_three.py -i infile.obj -o outfile.js [-m morphfiles*.obj] [-c morphcolors*.obj] [-a center|centerxz|top|bottom|none] [-s smooth|flat] [-t ascii|binary] [-d invert|normal] [-b]
 
 Notes: 
 
@@ -137,6 +137,8 @@ SHADING = "smooth"      # smooth flat
 TYPE = "ascii"          # ascii binary
 TRANSPARENCY = "normal" # normal invert
 
+BAKE_COLORS = False
+
 # default colors for debugging (each material gets one distinct color): 
 # white, red, green, blue, yellow, cyan, magenta
 COLORS = [0xeeeeee, 0xee0000, 0x00ee00, 0x0000ee, 0xeeee00, 0x00eeee, 0xee00ee]
@@ -149,6 +151,7 @@ TEMPLATE_FILE_ASCII = u"""\
 //  vertices: %(nvertex)d
 //  faces: %(nface)d 
 //  normals: %(nnormal)d
+//  colors: %(ncolor)d
 //  uvs: %(nuv)d 
 //  materials: %(nmaterial)d
 //
@@ -170,6 +173,8 @@ var model = {
 
     "normals": [%(normals)s],
 
+    "colors": [%(colors)s],
+
     "uvs": [[%(uvs)s]],
 
     "faces": [%(faces)s]
@@ -207,6 +212,7 @@ TEMPLATE_VERTEX = "%f,%f,%f"
 TEMPLATE_N = "%f,%f,%f"
 TEMPLATE_UV = "%f,%f"
 TEMPLATE_COLOR = "%.3f,%.3f,%.3f"
+TEMPLATE_COLOR_DEC = "%d"
 
 TEMPLATE_MORPH_VERTICES = '\t{ "name": "%s", "vertices": [%s] }'
 TEMPLATE_MORPH_COLORS   = '\t{ "name": "%s", "colors": [%s] }'
@@ -579,7 +585,7 @@ def setBit(value, position, on):
         mask = ~(1 << position)
         return (value & mask)    
     
-def generate_face(f):
+def generate_face(f, fc):
     isTriangle = ( len(f['vertex']) == 3 )
     
     if isTriangle:
@@ -595,7 +601,7 @@ def generate_face(f):
     hasFaceNormals = False # don't export any face normals (as they are computed in engine)
     hasFaceVertexNormals = ( len(f["normal"]) >= nVertices and SHADING == "smooth" )
     
-    hasFaceColors = False       # not supported in OBJ
+    hasFaceColors = BAKE_COLORS
     hasFaceVertexColors = False # not supported in OBJ
 
     faceType = 0
@@ -617,12 +623,15 @@ def generate_face(f):
     # material index
     # face uvs index
     # face vertex uvs indices
+    # face normal index
+    # face vertex normals indices
     # face color index
     # face vertex colors indices
     
     faceData.append(faceType)    
     
     # must clamp in case on polygons bigger than quads
+
     for i in xrange(nVertices):
         index = f['vertex'][i] - 1
         faceData.append(index)
@@ -638,12 +647,19 @@ def generate_face(f):
         for i in xrange(nVertices):
             index = f['normal'][i] - 1
             faceData.append(index)
+            
+    if hasFaceColors:
+        index = fc['material']
+        faceData.append(index)        
 
     return ",".join( map(str, faceData) )
 
 # #####################################################
 # Generator - chunks
 # #####################################################
+def hexcolor(c):
+    return ( int(c[0] * 255) << 16  ) + ( int(c[1] * 255) << 8 ) + int(c[2] * 255)
+
 def generate_vertex(v):
     return TEMPLATE_VERTEX % (v[0], v[1], v[2])
 
@@ -656,6 +672,9 @@ def generate_uv(uv):
 def generate_color_rgb(c):
     return TEMPLATE_COLOR % (c[0], c[1], c[2])
     
+def generate_color_decimal(c):
+    return TEMPLATE_COLOR_DEC % hexcolor(c)
+    
 # #####################################################
 # Morphs
 # #####################################################
@@ -667,31 +686,36 @@ def generate_morph_color(name, colors):
     color_string = ",".join(generate_color_rgb(c) for c in colors)
     return TEMPLATE_MORPH_COLORS % (name, color_string)
 
-def extract_face_colors(faces, materials, mtlfilename, basename):
-    
-    # extract diffuse colors from MTL materials
+def extract_material_colors(materials, mtlfilename, basename):
+    """Extract diffuse colors from MTL materials
+    """
 
     if not materials:
         materials = { 'default': 0 }
 
     mtl = create_materials(materials, mtlfilename, basename)
     
-    mtl_array = []
+    mtlColorArraySrt = []
     for m in mtl:
         if m in materials:
             index = materials[m]
             color = mtl[m].get("colorDiffuse", [1,0,0])
-            mtl_array.append([index, color])
+            mtlColorArraySrt.append([index, color])
        
-    mtl_array.sort()
+    mtlColorArraySrt.sort()
+    mtlColorArray = [x[1] for x in mtlColorArraySrt]
 
-    # assign colors to faces
+    return mtlColorArray
 
+def extract_face_colors(faces, material_colors):
+    """Extract colors from materials and assign them to faces
+    """
+    
     faceColors = []
 
     for face in faces:
         material_index = face['material']
-        faceColors.append(mtl_array[material_index][1])
+        faceColors.append(material_colors[material_index])
 
     return faceColors
 
@@ -744,7 +768,9 @@ def generate_morph_targets(morphfiles, n_vertices, infile):
     
 def generate_morph_colors(colorfiles, n_vertices, n_faces):
     morphColorData = []
-
+    colorFaces = []
+    materialColors = []
+    
     for mfilepattern in colorfiles.split():
 
         matches = glob.glob(mfilepattern)
@@ -768,15 +794,23 @@ def generate_morph_colors(colorfiles, n_vertices, n_faces):
 
             else:
 
-                morphFaceColors = extract_face_colors(morphFaces, morphMaterials, morphMtllib, normpath)
+                morphMaterialColors = extract_material_colors(morphMaterials, morphMtllib, normpath)  
+                morphFaceColors = extract_face_colors(morphFaces, morphMaterialColors)
                 morphColorData.append((get_name(name), morphFaceColors))
+
+                # take first color map for baking into face colors
+
+                if len(colorFaces) == 0:
+                    colorFaces = morphFaces
+                    materialColors = morphMaterialColors
+
                 print "adding [%s] with %d face colors" % (name, len(morphFaceColors))
 
     morphColors = ""
     if len(morphColorData):
         morphColors = "\n%s\n\t" % ",\n".join(generate_morph_color(name, colors) for name, colors in morphColorData)
     
-    return morphColors
+    return morphColors, colorFaces, materialColors
 
 # #####################################################
 # Materials
@@ -800,6 +834,8 @@ def generate_color(i):
 def value2string(v):
     if type(v)==str and v[0:2] != "0x":
         return '"%s"' % v
+    elif type(v) == bool:
+        return str(v).lower()
     return str(v)
     
 def generate_materials(mtl, materials):
@@ -822,6 +858,9 @@ def generate_materials(mtl, materials):
             mtl[m]['DbgIndex'] = index
             mtl[m]['DbgColor'] = generate_color(index)
             
+            if BAKE_COLORS:
+                mtl[m]['vertexColors'] = "face"
+            
             mtl_raw = ",\n".join(['\t"%s" : %s' % (n, value2string(v)) for n,v in sorted(mtl[m].items())])
             mtl_string = "\t{\n%s\n\t}" % mtl_raw
             mtl_array.append([index, mtl_string])
@@ -992,8 +1031,21 @@ def convert_ascii(infile, morphfiles, colorfiles, outfile):
     
     # extract morph colors
 
-    morphColors = generate_morph_colors(colorfiles, n_vertices, n_faces)
+    morphColors, colorFaces, materialColors = generate_morph_colors(colorfiles, n_vertices, n_faces)    
+
+    # generate colors string
+    
+    ncolor = 0
+    colors_string = ""
+    
+    if len(colorFaces) < len(faces):
+        colorFaces = faces
+        materialColors = extract_material_colors(materials, mtllib, infile)
     
+    if BAKE_COLORS:
+        colors_string = ",".join(generate_color_decimal(c) for c in materialColors)
+        ncolor = len(materialColors)
+        
     # generate ascii model string
 
     text = TEMPLATE_FILE_ASCII % {
@@ -1003,18 +1055,20 @@ def convert_ascii(infile, morphfiles, colorfiles, outfile):
     "nface"     : len(faces),
     "nuv"       : len(uvs),
     "nnormal"   : nnormal,
+    "ncolor"    : ncolor,
     "nmaterial" : len(materials),
 
     "materials" : generate_materials_string(materials, mtllib, infile),
 
     "normals"       : normals_string,
+    "colors"        : colors_string,
     "uvs"           : ",".join(generate_uv(uv) for uv in uvs),
     "vertices"      : ",".join(generate_vertex(v) for v in vertices),
     
     "morphTargets"  : morphTargets,
     "morphColors"   : morphColors,
     
-    "faces"     : ",".join(generate_face(f) for f in faces)
+    "faces"     : ",".join(generate_face(f, fc) for f, fc in zip(faces, colorFaces))
     }
     
     out = open(outfile, "w")
@@ -1349,7 +1403,7 @@ if __name__ == "__main__":
     
     # get parameters from the command line
     try:
-        opts, args = getopt.getopt(sys.argv[1:], "hi:m:c:o:a:s:t:d:", ["help", "input=", "morphs=", "colors=", "output=", "align=", "shading=", "type=", "dissolve="])
+        opts, args = getopt.getopt(sys.argv[1:], "hbi:m:c:b:o:a:s:t:d:", ["help", "bakecolors", "input=", "morphs=", "colors=", "output=", "align=", "shading=", "type=", "dissolve="])
     
     except getopt.GetoptError:
         usage()
@@ -1392,6 +1446,9 @@ if __name__ == "__main__":
             if a in ("normal", "invert"):
                 TRANSPARENCY = a
 
+        elif o in ("-b", "--bakecolors"):
+            BAKE_COLORS = True
+
     if infile == "" or outfile == "":
         usage()
         sys.exit(2)

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