Kaynağa Gözat

Small marching cube freeze optimization.

alteredq 14 yıl önce
ebeveyn
işleme
a8ab2336b3
2 değiştirilmiş dosya ile 140 ekleme ve 136 silme
  1. 128 128
      build/ThreeExtras.js
  2. 12 8
      src/extras/objects/MarchingCubes.js

+ 128 - 128
build/ThreeExtras.js

@@ -13,30 +13,30 @@ THREE.Vector4=function(a,c,d,e){this.x=a||0;this.y=c||0;this.z=d||0;this.w=e||1}
 THREE.Vector4.prototype={set:function(a,c,d,e){this.x=a;this.y=c;this.z=d;this.w=e;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w||1;return this},add:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},sub:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;
 return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},divideScalar:function(a){this.x/=a;this.y/=a;this.z/=a;this.w/=a;return this},lerpSelf:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)},toString:function(){return"THREE.Vector4 ("+this.x+", "+this.y+", "+this.z+", "+this.w+")"}};
 THREE.Ray=function(a,c){this.origin=a||new THREE.Vector3;this.direction=c||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,f=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(b,g){return b.distance-g.distance});return f},intersectObject:function(a){function c(G,w,H,p){p=p.clone().subSelf(w);H=H.clone().subSelf(w);var l=G.clone().subSelf(w);G=p.dot(p);w=p.dot(H);p=p.dot(l);var u=H.dot(H);H=H.dot(l);l=1/(G*u-w*w);u=(u*p-w*H)*l;G=(G*H-w*p)*l;return u>0&&G>0&&u+G<1}var d,e,f,b,g,j,h,m,n,A,
-v,o=a.geometry,z=o.vertices,C=[];d=0;for(e=o.faces.length;d<e;d++){f=o.faces[d];A=this.origin.clone();v=this.direction.clone();b=a.matrix.multiplyVector3(z[f.a].position.clone());g=a.matrix.multiplyVector3(z[f.b].position.clone());j=a.matrix.multiplyVector3(z[f.c].position.clone());h=f instanceof THREE.Face4?a.matrix.multiplyVector3(z[f.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(f.normal.clone());n=v.dot(m);if(n<0){m=m.dot((new THREE.Vector3).sub(b,A))/n;A=A.addSelf(v.multiplyScalar(m));
-if(f instanceof THREE.Face3){if(c(A,b,g,j)){f={distance:this.origin.distanceTo(A),point:A,face:f,object:a};C.push(f)}}else if(f instanceof THREE.Face4)if(c(A,b,g,h)||c(A,g,j,h)){f={distance:this.origin.distanceTo(A),point:A,face:f,object:a};C.push(f)}}}return C}};
-THREE.Rectangle=function(){function a(){b=e-c;g=f-d}var c,d,e,f,b,g,j=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return g};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(h,m,n,A){j=false;c=h;d=m;e=n;f=A;a()};this.addPoint=function(h,m){if(j){j=false;c=h;d=m;e=h;f=m}else{c=c<h?c:h;d=d<m?d:m;e=e>h?e:h;f=f>m?
-f:m}a()};this.add3Points=function(h,m,n,A,v,o){if(j){j=false;c=h<n?h<v?h:v:n<v?n:v;d=m<A?m<o?m:o:A<o?A:o;e=h>n?h>v?h:v:n>v?n:v;f=m>A?m>o?m:o:A>o?A:o}else{c=h<n?h<v?h<c?h:c:v<c?v:c:n<v?n<c?n:c:v<c?v:c;d=m<A?m<o?m<d?m:d:o<d?o:d:A<o?A<d?A:d:o<d?o:d;e=h>n?h>v?h>e?h:e:v>e?v:e:n>v?n>e?n:e:v>e?v:e;f=m>A?m>o?m>f?m:f:o>f?o:f:A>o?A>f?A:f:o>f?o:f}a()};this.addRectangle=function(h){if(j){j=false;c=h.getLeft();d=h.getTop();e=h.getRight();f=h.getBottom()}else{c=c<h.getLeft()?c:h.getLeft();d=d<h.getTop()?d:h.getTop();
+THREE.Ray.prototype={intersectScene:function(a){var c,d,e=a.objects,f=[];a=0;for(c=e.length;a<c;a++){d=e[a];if(d instanceof THREE.Mesh)f=f.concat(this.intersectObject(d))}f.sort(function(b,g){return b.distance-g.distance});return f},intersectObject:function(a){function c(G,w,H,p){p=p.clone().subSelf(w);H=H.clone().subSelf(w);var l=G.clone().subSelf(w);G=p.dot(p);w=p.dot(H);p=p.dot(l);var v=H.dot(H);H=H.dot(l);l=1/(G*v-w*w);v=(v*p-w*H)*l;G=(G*H-w*p)*l;return v>0&&G>0&&v+G<1}var d,e,f,b,g,j,h,m,n,y,
+u,o=a.geometry,A=o.vertices,C=[];d=0;for(e=o.faces.length;d<e;d++){f=o.faces[d];y=this.origin.clone();u=this.direction.clone();b=a.matrix.multiplyVector3(A[f.a].position.clone());g=a.matrix.multiplyVector3(A[f.b].position.clone());j=a.matrix.multiplyVector3(A[f.c].position.clone());h=f instanceof THREE.Face4?a.matrix.multiplyVector3(A[f.d].position.clone()):null;m=a.rotationMatrix.multiplyVector3(f.normal.clone());n=u.dot(m);if(n<0){m=m.dot((new THREE.Vector3).sub(b,y))/n;y=y.addSelf(u.multiplyScalar(m));
+if(f instanceof THREE.Face3){if(c(y,b,g,j)){f={distance:this.origin.distanceTo(y),point:y,face:f,object:a};C.push(f)}}else if(f instanceof THREE.Face4)if(c(y,b,g,h)||c(y,g,j,h)){f={distance:this.origin.distanceTo(y),point:y,face:f,object:a};C.push(f)}}}return C}};
+THREE.Rectangle=function(){function a(){b=e-c;g=f-d}var c,d,e,f,b,g,j=true;this.getX=function(){return c};this.getY=function(){return d};this.getWidth=function(){return b};this.getHeight=function(){return g};this.getLeft=function(){return c};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return f};this.set=function(h,m,n,y){j=false;c=h;d=m;e=n;f=y;a()};this.addPoint=function(h,m){if(j){j=false;c=h;d=m;e=h;f=m}else{c=c<h?c:h;d=d<m?d:m;e=e>h?e:h;f=f>m?
+f:m}a()};this.add3Points=function(h,m,n,y,u,o){if(j){j=false;c=h<n?h<u?h:u:n<u?n:u;d=m<y?m<o?m:o:y<o?y:o;e=h>n?h>u?h:u:n>u?n:u;f=m>y?m>o?m:o:y>o?y:o}else{c=h<n?h<u?h<c?h:c:u<c?u:c:n<u?n<c?n:c:u<c?u:c;d=m<y?m<o?m<d?m:d:o<d?o:d:y<o?y<d?y:d:o<d?o:d;e=h>n?h>u?h>e?h:e:u>e?u:e:n>u?n>e?n:e:u>e?u:e;f=m>y?m>o?m>f?m:f:o>f?o:f:y>o?y>f?y:f:o>f?o:f}a()};this.addRectangle=function(h){if(j){j=false;c=h.getLeft();d=h.getTop();e=h.getRight();f=h.getBottom()}else{c=c<h.getLeft()?c:h.getLeft();d=d<h.getTop()?d:h.getTop();
 e=e>h.getRight()?e:h.getRight();f=f>h.getBottom()?f:h.getBottom()}a()};this.inflate=function(h){c-=h;d-=h;e+=h;f+=h;a()};this.minSelf=function(h){c=c>h.getLeft()?c:h.getLeft();d=d>h.getTop()?d:h.getTop();e=e<h.getRight()?e:h.getRight();f=f<h.getBottom()?f:h.getBottom();a()};this.instersects=function(h){return Math.min(e,h.getRight())-Math.max(c,h.getLeft())>=0&&Math.min(f,h.getBottom())-Math.max(d,h.getTop())>=0};this.empty=function(){j=true;f=e=d=c=0;a()};this.isEmpty=function(){return j};this.toString=
 function(){return"THREE.Rectangle ( left: "+c+", right: "+e+", top: "+d+", bottom: "+f+", width: "+b+", height: "+g+" )"}};THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,c=this.m;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this}};
-THREE.Matrix4=function(a,c,d,e,f,b,g,j,h,m,n,A,v,o,z,C){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=b||1;this.n23=g||0;this.n24=j||0;this.n31=h||0;this.n32=m||0;this.n33=n||1;this.n34=A||0;this.n41=v||0;this.n42=o||0;this.n43=z||0;this.n44=C||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,f,b,g,j,h,m,n,A,v,o,z,C){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=b;this.n23=g;this.n24=j;this.n31=h;this.n32=m;this.n33=n;this.n34=A;this.n41=v;this.n42=o;this.n43=z;this.n44=C;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
+THREE.Matrix4=function(a,c,d,e,f,b,g,j,h,m,n,y,u,o,A,C){this.n11=a||1;this.n12=c||0;this.n13=d||0;this.n14=e||0;this.n21=f||0;this.n22=b||1;this.n23=g||0;this.n24=j||0;this.n31=h||0;this.n32=m||0;this.n33=n||1;this.n34=y||0;this.n41=u||0;this.n42=o||0;this.n43=A||0;this.n44=C||1;this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={identity:function(){this.n11=1;this.n21=this.n14=this.n13=this.n12=0;this.n22=1;this.n32=this.n31=this.n24=this.n23=0;this.n33=1;this.n43=this.n42=this.n41=this.n34=0;this.n44=1;return this},set:function(a,c,d,e,f,b,g,j,h,m,n,y,u,o,A,C){this.n11=a;this.n12=c;this.n13=d;this.n14=e;this.n21=f;this.n22=b;this.n23=g;this.n24=j;this.n31=h;this.n32=m;this.n33=n;this.n34=y;this.n41=u;this.n42=o;this.n43=A;this.n44=C;return this},copy:function(a){this.n11=a.n11;this.n12=a.n12;this.n13=
 a.n13;this.n14=a.n14;this.n21=a.n21;this.n22=a.n22;this.n23=a.n23;this.n24=a.n24;this.n31=a.n31;this.n32=a.n32;this.n33=a.n33;this.n34=a.n34;this.n41=a.n41;this.n42=a.n42;this.n43=a.n43;this.n44=a.n44;return this},lookAt:function(a,c,d){var e=THREE.Matrix4.__tmpVec1,f=THREE.Matrix4.__tmpVec2,b=THREE.Matrix4.__tmpVec3;b.sub(a,c).normalize();e.cross(d,b).normalize();f.cross(b,e).normalize();this.n11=e.x;this.n12=e.y;this.n13=e.z;this.n14=-e.dot(a);this.n21=f.x;this.n22=f.y;this.n23=f.z;this.n24=-f.dot(a);
 this.n31=b.x;this.n32=b.y;this.n33=b.z;this.n34=-b.dot(a);this.n43=this.n42=this.n41=0;this.n44=1;return this},multiplyVector3:function(a){var c=a.x,d=a.y,e=a.z,f=1/(this.n41*c+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*c+this.n12*d+this.n13*e+this.n14)*f;a.y=(this.n21*c+this.n22*d+this.n23*e+this.n24)*f;a.z=(this.n31*c+this.n32*d+this.n33*e+this.n34)*f;return a},multiplyVector4:function(a){var c=a.x,d=a.y,e=a.z,f=a.w;a.x=this.n11*c+this.n12*d+this.n13*e+this.n14*f;a.y=this.n21*c+this.n22*d+this.n23*
 e+this.n24*f;a.z=this.n31*c+this.n32*d+this.n33*e+this.n34*f;a.w=this.n41*c+this.n42*d+this.n43*e+this.n44*f;return a},crossVector:function(a){var c=new THREE.Vector4;c.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;c.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;c.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;c.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return c},multiply:function(a,c){var d=a.n11,e=a.n12,f=a.n13,b=a.n14,g=a.n21,j=a.n22,h=a.n23,m=a.n24,n=a.n31,
-A=a.n32,v=a.n33,o=a.n34,z=a.n41,C=a.n42,G=a.n43,w=a.n44,H=c.n11,p=c.n12,l=c.n13,u=c.n14,t=c.n21,k=c.n22,q=c.n23,x=c.n24,y=c.n31,F=c.n32,B=c.n33,D=c.n34,I=c.n41,N=c.n42,O=c.n43,Q=c.n44;this.n11=d*H+e*t+f*y+b*I;this.n12=d*p+e*k+f*F+b*N;this.n13=d*l+e*q+f*B+b*O;this.n14=d*u+e*x+f*D+b*Q;this.n21=g*H+j*t+h*y+m*I;this.n22=g*p+j*k+h*F+m*N;this.n23=g*l+j*q+h*B+m*O;this.n24=g*u+j*x+h*D+m*Q;this.n31=n*H+A*t+v*y+o*I;this.n32=n*p+A*k+v*F+o*N;this.n33=n*l+A*q+v*B+o*O;this.n34=n*u+A*x+v*D+o*Q;this.n41=z*H+C*t+
-G*y+w*I;this.n42=z*p+C*k+G*F+w*N;this.n43=z*l+C*q+G*B+w*O;this.n44=z*u+C*x+G*D+w*Q;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,f=this.n14,b=this.n21,g=this.n22,j=this.n23,h=this.n24,m=this.n31,n=this.n32,A=this.n33,v=this.n34,o=this.n41,z=this.n42,C=this.n43,G=this.n44,w=a.n11,H=a.n21,p=a.n31,l=a.n41,u=a.n12,t=a.n22,k=a.n32,q=a.n42,x=a.n13,y=a.n23,F=a.n33,B=a.n43,D=a.n14,I=a.n24,N=a.n34;a=a.n44;this.n11=c*w+d*H+e*p+f*l;this.n12=c*u+d*t+e*k+f*q;this.n13=c*x+d*y+e*F+f*
-B;this.n14=c*D+d*I+e*N+f*a;this.n21=b*w+g*H+j*p+h*l;this.n22=b*u+g*t+j*k+h*q;this.n23=b*x+g*y+j*F+h*B;this.n24=b*D+g*I+j*N+h*a;this.n31=m*w+n*H+A*p+v*l;this.n32=m*u+n*t+A*k+v*q;this.n33=m*x+n*y+A*F+v*B;this.n34=m*D+n*I+A*N+v*a;this.n41=o*w+z*H+C*p+G*l;this.n42=o*u+z*t+C*k+G*q;this.n43=o*x+z*y+C*F+G*B;this.n44=o*D+z*I+C*N+G*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
-a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,b=this.n22,g=this.n23,j=this.n24,h=this.n31,m=this.n32,n=this.n33,A=this.n34,v=this.n41,o=this.n42,z=this.n43,C=this.n44;return e*g*m*v-d*j*m*v-e*b*n*v+c*j*n*v+d*b*A*v-c*g*A*v-e*g*h*o+d*j*h*o+e*f*n*o-a*j*n*o-d*f*A*o+a*g*A*o+e*b*h*z-c*j*h*z-e*f*m*z+a*j*m*z+c*f*A*z-a*b*A*z-d*b*h*C+c*g*h*C+d*f*m*C-a*g*m*C-c*f*n*C+a*b*n*C},transpose:function(){function a(c,d,
+y=a.n32,u=a.n33,o=a.n34,A=a.n41,C=a.n42,G=a.n43,w=a.n44,H=c.n11,p=c.n12,l=c.n13,v=c.n14,t=c.n21,k=c.n22,q=c.n23,x=c.n24,z=c.n31,F=c.n32,B=c.n33,D=c.n34,I=c.n41,N=c.n42,O=c.n43,Q=c.n44;this.n11=d*H+e*t+f*z+b*I;this.n12=d*p+e*k+f*F+b*N;this.n13=d*l+e*q+f*B+b*O;this.n14=d*v+e*x+f*D+b*Q;this.n21=g*H+j*t+h*z+m*I;this.n22=g*p+j*k+h*F+m*N;this.n23=g*l+j*q+h*B+m*O;this.n24=g*v+j*x+h*D+m*Q;this.n31=n*H+y*t+u*z+o*I;this.n32=n*p+y*k+u*F+o*N;this.n33=n*l+y*q+u*B+o*O;this.n34=n*v+y*x+u*D+o*Q;this.n41=A*H+C*t+
+G*z+w*I;this.n42=A*p+C*k+G*F+w*N;this.n43=A*l+C*q+G*B+w*O;this.n44=A*v+C*x+G*D+w*Q;return this},multiplySelf:function(a){var c=this.n11,d=this.n12,e=this.n13,f=this.n14,b=this.n21,g=this.n22,j=this.n23,h=this.n24,m=this.n31,n=this.n32,y=this.n33,u=this.n34,o=this.n41,A=this.n42,C=this.n43,G=this.n44,w=a.n11,H=a.n21,p=a.n31,l=a.n41,v=a.n12,t=a.n22,k=a.n32,q=a.n42,x=a.n13,z=a.n23,F=a.n33,B=a.n43,D=a.n14,I=a.n24,N=a.n34;a=a.n44;this.n11=c*w+d*H+e*p+f*l;this.n12=c*v+d*t+e*k+f*q;this.n13=c*x+d*z+e*F+f*
+B;this.n14=c*D+d*I+e*N+f*a;this.n21=b*w+g*H+j*p+h*l;this.n22=b*v+g*t+j*k+h*q;this.n23=b*x+g*z+j*F+h*B;this.n24=b*D+g*I+j*N+h*a;this.n31=m*w+n*H+y*p+u*l;this.n32=m*v+n*t+y*k+u*q;this.n33=m*x+n*z+y*F+u*B;this.n34=m*D+n*I+y*N+u*a;this.n41=o*w+A*H+C*p+G*l;this.n42=o*v+A*t+C*k+G*q;this.n43=o*x+A*z+C*F+G*B;this.n44=o*D+A*I+C*N+G*a;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=
+a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,b=this.n22,g=this.n23,j=this.n24,h=this.n31,m=this.n32,n=this.n33,y=this.n34,u=this.n41,o=this.n42,A=this.n43,C=this.n44;return e*g*m*u-d*j*m*u-e*b*n*u+c*j*n*u+d*b*y*u-c*g*y*u-e*g*h*o+d*j*h*o+e*f*n*o-a*j*n*o-d*f*y*o+a*g*y*o+e*b*h*A-c*j*h*A-e*f*m*A+a*j*m*A+c*f*y*A-a*b*y*A-d*b*h*C+c*g*h*C+d*f*m*C-a*g*m*C-c*f*n*C+a*b*n*C},transpose:function(){function a(c,d,
 e){var f=c[d];c[d]=c[e];c[e]=f}a(this,"n21","n12");a(this,"n31","n13");a(this,"n32","n23");a(this,"n41","n14");a(this,"n42","n24");a(this,"n43","n34");return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){var a=this.flat;a[0]=this.n11;
 a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},setTranslation:function(a,c,d){this.set(1,0,0,a,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(a,c,d){this.set(a,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},setRotY:function(a){var c=
 Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},setRotZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,c){var d=Math.cos(c),e=Math.sin(c),f=1-d,b=a.x,g=a.y,j=a.z,h=f*b,m=f*g;this.set(h*b+d,h*g-e*j,h*j+e*g,0,h*g+e*j,m*g+d,m*j-e*b,0,h*j-e*g,m*j+e*b,f*j*j+d,0,0,0,0,1);return this},toString:function(){return"| "+this.n11+" "+this.n12+" "+this.n13+" "+this.n14+" |\n| "+this.n21+" "+this.n22+" "+
 this.n23+" "+this.n24+" |\n| "+this.n31+" "+this.n32+" "+this.n33+" "+this.n34+" |\n| "+this.n41+" "+this.n42+" "+this.n43+" "+this.n44+" |"}};THREE.Matrix4.translationMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setTranslation(a,c,d);return e};THREE.Matrix4.scaleMatrix=function(a,c,d){var e=new THREE.Matrix4;e.setScale(a,c,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var c=new THREE.Matrix4;c.setRotX(a);return c};
 THREE.Matrix4.rotationYMatrix=function(a){var c=new THREE.Matrix4;c.setRotY(a);return c};THREE.Matrix4.rotationZMatrix=function(a){var c=new THREE.Matrix4;c.setRotZ(a);return c};THREE.Matrix4.rotationAxisAngleMatrix=function(a,c){var d=new THREE.Matrix4;d.setRotAxis(a,c);return d};
-THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,b=a.n21,g=a.n22,j=a.n23,h=a.n24,m=a.n31,n=a.n32,A=a.n33,v=a.n34,o=a.n41,z=a.n42,C=a.n43,G=a.n44,w=new THREE.Matrix4;w.n11=j*v*z-h*A*z+h*n*C-g*v*C-j*n*G+g*A*G;w.n12=f*A*z-e*v*z-f*n*C+d*v*C+e*n*G-d*A*G;w.n13=e*h*z-f*j*z+f*g*C-d*h*C-e*g*G+d*j*G;w.n14=f*j*n-e*h*n-f*g*A+d*h*A+e*g*v-d*j*v;w.n21=h*A*o-j*v*o-h*m*C+b*v*C+j*m*G-b*A*G;w.n22=e*v*o-f*A*o+f*m*C-c*v*C-e*m*G+c*A*G;w.n23=f*j*o-e*h*o-f*b*C+c*h*C+e*b*G-c*j*G;w.n24=e*h*m-f*j*m+
-f*b*A-c*h*A-e*b*v+c*j*v;w.n31=g*v*o-h*n*o+h*m*z-b*v*z-g*m*G+b*n*G;w.n32=f*n*o-d*v*o-f*m*z+c*v*z+d*m*G-c*n*G;w.n33=e*h*o-f*g*o+f*b*z-c*h*z-d*b*G+c*g*G;w.n34=f*g*m-d*h*m-f*b*n+c*h*n+d*b*v-c*g*v;w.n41=j*n*o-g*A*o-j*m*z+b*A*z+g*m*C-b*n*C;w.n42=d*A*o-e*n*o+e*m*z-c*A*z-d*m*C+c*n*C;w.n43=e*g*o-d*j*o-e*b*z+c*j*z+d*b*C-c*g*C;w.n44=d*j*m-e*g*m+e*b*n-c*j*n-d*b*A+c*g*A;w.multiplyScalar(1/a.determinant());return w};
-THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],g=-c[10]*c[4]+c[6]*c[8],j=c[10]*c[0]-c[2]*c[8],h=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],n=-c[9]*c[0]+c[1]*c[8],A=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*g+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*f;d[2]=c*b;d[3]=c*g;d[4]=c*j;d[5]=c*h;d[6]=c*m;d[7]=c*n;d[8]=c*A;return a};
+THREE.Matrix4.makeInvert=function(a){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,b=a.n21,g=a.n22,j=a.n23,h=a.n24,m=a.n31,n=a.n32,y=a.n33,u=a.n34,o=a.n41,A=a.n42,C=a.n43,G=a.n44,w=new THREE.Matrix4;w.n11=j*u*A-h*y*A+h*n*C-g*u*C-j*n*G+g*y*G;w.n12=f*y*A-e*u*A-f*n*C+d*u*C+e*n*G-d*y*G;w.n13=e*h*A-f*j*A+f*g*C-d*h*C-e*g*G+d*j*G;w.n14=f*j*n-e*h*n-f*g*y+d*h*y+e*g*u-d*j*u;w.n21=h*y*o-j*u*o-h*m*C+b*u*C+j*m*G-b*y*G;w.n22=e*u*o-f*y*o+f*m*C-c*u*C-e*m*G+c*y*G;w.n23=f*j*o-e*h*o-f*b*C+c*h*C+e*b*G-c*j*G;w.n24=e*h*m-f*j*m+
+f*b*y-c*h*y-e*b*u+c*j*u;w.n31=g*u*o-h*n*o+h*m*A-b*u*A-g*m*G+b*n*G;w.n32=f*n*o-d*u*o-f*m*A+c*u*A+d*m*G-c*n*G;w.n33=e*h*o-f*g*o+f*b*A-c*h*A-d*b*G+c*g*G;w.n34=f*g*m-d*h*m-f*b*n+c*h*n+d*b*u-c*g*u;w.n41=j*n*o-g*y*o-j*m*A+b*y*A+g*m*C-b*n*C;w.n42=d*y*o-e*n*o+e*m*A-c*y*A-d*m*C+c*n*C;w.n43=e*g*o-d*j*o-e*b*A+c*j*A+d*b*C-c*g*C;w.n44=d*j*m-e*g*m+e*b*n-c*j*n-d*b*y+c*g*y;w.multiplyScalar(1/a.determinant());return w};
+THREE.Matrix4.makeInvert3x3=function(a){var c=a.flatten();a=a.m33;var d=a.m,e=c[10]*c[5]-c[6]*c[9],f=-c[10]*c[1]+c[2]*c[9],b=c[6]*c[1]-c[2]*c[5],g=-c[10]*c[4]+c[6]*c[8],j=c[10]*c[0]-c[2]*c[8],h=-c[6]*c[0]+c[2]*c[4],m=c[9]*c[4]-c[5]*c[8],n=-c[9]*c[0]+c[1]*c[8],y=c[5]*c[0]-c[1]*c[4];c=c[0]*e+c[1]*g+c[2]*m;if(c==0)throw"matrix not invertible";c=1/c;d[0]=c*e;d[1]=c*f;d[2]=c*b;d[3]=c*g;d[4]=c*j;d[5]=c*h;d[6]=c*m;d[7]=c*n;d[8]=c*y;return a};
 THREE.Matrix4.makeFrustum=function(a,c,d,e,f,b){var g,j,h;g=new THREE.Matrix4;j=2*f/(c-a);h=2*f/(e-d);a=(c+a)/(c-a);d=(e+d)/(e-d);e=-(b+f)/(b-f);f=-2*b*f/(b-f);g.n11=j;g.n12=0;g.n13=a;g.n14=0;g.n21=0;g.n22=h;g.n23=d;g.n24=0;g.n31=0;g.n32=0;g.n33=e;g.n34=f;g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,c,d,e){var f;a=d*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*c,a*c,f,a,d,e)};
 THREE.Matrix4.makeOrtho=function(a,c,d,e,f,b){var g,j,h,m;g=new THREE.Matrix4;j=c-a;h=d-e;m=b-f;a=(c+a)/j;d=(d+e)/h;f=(b+f)/m;g.n11=2/j;g.n12=0;g.n13=0;g.n14=-a;g.n21=0;g.n22=2/h;g.n23=0;g.n24=-d;g.n31=0;g.n32=0;g.n33=-2/m;g.n34=-f;g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Vertex=function(a,c){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=c||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=true};THREE.Vertex.prototype={toString:function(){return"THREE.Vertex ( position: "+this.position+", normal: "+this.normal+" )"}};
@@ -47,12 +47,12 @@ THREE.Geometry.prototype={computeCentroids:function(){var a,c,d;a=0;for(c=this.f
 d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var c,d,e,f,b,g,j=new THREE.Vector3,h=new THREE.Vector3;e=0;for(f=this.vertices.length;e<f;e++){b=this.vertices[e];b.normal.set(0,0,0)}e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];if(a&&b.vertexNormals.length){j.set(0,0,0);c=0;for(d=b.normal.length;c<d;c++)j.addSelf(b.vertexNormals[c]);j.divideScalar(3)}else{c=this.vertices[b.a];d=this.vertices[b.b];g=this.vertices[b.c];j.sub(g.position,
 d.position);h.sub(c.position,d.position);j.crossSelf(h)}j.isZero()||j.normalize();b.normal.copy(j)}},computeVertexNormals:function(){var a,c,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(c=this.vertices.length;a<c;a++)e[a]=new THREE.Vector3;a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{e=this.__tmpVertices;a=0;for(c=this.vertices.length;a<c;a++)e[a].set(0,0,0)}a=0;for(c=this.faces.length;a<c;a++){d=this.faces[a];if(d instanceof THREE.Face3){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal)}else if(d instanceof THREE.Face4){e[d.a].addSelf(d.normal);e[d.b].addSelf(d.normal);e[d.c].addSelf(d.normal);e[d.d].addSelf(d.normal)}}a=0;for(c=this.vertices.length;a<c;a++)e[a].normalize();a=0;for(c=this.faces.length;a<
-c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(D,I,N,O,Q,T,U){b=D.vertices[I].position;g=D.vertices[N].position;j=D.vertices[O].position;h=f[Q];m=f[T];n=f[U];A=g.x-b.x;v=j.x-b.x;o=g.y-b.y;z=j.y-b.y;
-C=g.z-b.z;G=j.z-b.z;w=m.u-h.u;H=n.u-h.u;p=m.v-h.v;l=n.v-h.v;u=1/(w*l-H*p);q.set((l*A-p*v)*u,(l*o-p*z)*u,(l*C-p*G)*u);x.set((w*v-H*A)*u,(w*z-H*o)*u,(w*G-H*C)*u);t[I].addSelf(q);t[N].addSelf(q);t[O].addSelf(q);k[I].addSelf(x);k[N].addSelf(x);k[O].addSelf(x)}var c,d,e,f,b,g,j,h,m,n,A,v,o,z,C,G,w,H,p,l,u,t=[],k=[],q=new THREE.Vector3,x=new THREE.Vector3,y=new THREE.Vector3,F=new THREE.Vector3,B=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){t[c]=new THREE.Vector3;k[c]=new THREE.Vector3}c=0;
+c;a++){d=this.faces[a];if(d instanceof THREE.Face3){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c])}else if(d instanceof THREE.Face4){d.vertexNormals[0].copy(e[d.a]);d.vertexNormals[1].copy(e[d.b]);d.vertexNormals[2].copy(e[d.c]);d.vertexNormals[3].copy(e[d.d])}}},computeTangents:function(){function a(D,I,N,O,Q,T,U){b=D.vertices[I].position;g=D.vertices[N].position;j=D.vertices[O].position;h=f[Q];m=f[T];n=f[U];y=g.x-b.x;u=j.x-b.x;o=g.y-b.y;A=j.y-b.y;
+C=g.z-b.z;G=j.z-b.z;w=m.u-h.u;H=n.u-h.u;p=m.v-h.v;l=n.v-h.v;v=1/(w*l-H*p);q.set((l*y-p*u)*v,(l*o-p*A)*v,(l*C-p*G)*v);x.set((w*u-H*y)*v,(w*A-H*o)*v,(w*G-H*C)*v);t[I].addSelf(q);t[N].addSelf(q);t[O].addSelf(q);k[I].addSelf(x);k[N].addSelf(x);k[O].addSelf(x)}var c,d,e,f,b,g,j,h,m,n,y,u,o,A,C,G,w,H,p,l,v,t=[],k=[],q=new THREE.Vector3,x=new THREE.Vector3,z=new THREE.Vector3,F=new THREE.Vector3,B=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++){t[c]=new THREE.Vector3;k[c]=new THREE.Vector3}c=0;
 for(d=this.faces.length;c<d;c++){e=this.faces[c];f=this.uvs[c];if(e instanceof THREE.Face3){a(this,e.a,e.b,e.c,0,1,2);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2])}else if(e instanceof THREE.Face4){a(this,e.a,e.b,e.c,0,1,2);a(this,e.a,e.b,e.d,0,1,3);this.vertices[e.a].normal.copy(e.vertexNormals[0]);this.vertices[e.b].normal.copy(e.vertexNormals[1]);this.vertices[e.c].normal.copy(e.vertexNormals[2]);
-this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){B.copy(this.vertices[c].normal);e=t[c];y.copy(e);y.subSelf(B.multiplyScalar(B.dot(e))).normalize();F.cross(this.vertices[c].normal,e);e=F.dot(k[c]);e=e<0?-1:1;this.vertices[c].tangent.set(y.x,y.y,y.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
+this.vertices[e.d].normal.copy(e.vertexNormals[3])}}c=0;for(d=this.vertices.length;c<d;c++){B.copy(this.vertices[c].normal);e=t[c];z.copy(e);z.subSelf(B.multiplyScalar(B.dot(e))).normalize();F.cross(this.vertices[c].normal,e);e=F.dot(k[c]);e=e<0?-1:1;this.vertices[c].tangent.set(z.x,z.y,z.z,e)}this.hasTangents=true},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var c=1,d=this.vertices.length;c<d;c++){a=this.vertices[c];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var A=[];c=0;for(d=n.length;c<d;c++)n[c]==undefined?A.push("undefined"):A.push(n[c].toString());return A.join("_")}var c,d,e,f,b,g,j,h,m={};e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,c=0,d=this.vertices.length;c<d;c++)a=Math.max(a,this.vertices[c].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var y=[];c=0;for(d=n.length;c<d;c++)n[c]==undefined?y.push("undefined"):y.push(n[c].toString());return y.join("_")}var c,d,e,f,b,g,j,h,m={};e=0;for(f=this.faces.length;e<f;e++){b=this.faces[e];
 g=b.materials;j=a(g);if(m[j]==undefined)m[j]={hash:j,counter:0};h=m[j].hash+"_"+m[j].counter;if(this.geometryChunks[h]==undefined)this.geometryChunks[h]={faces:[],materials:g,vertices:0};b=b instanceof THREE.Face3?3:4;if(this.geometryChunks[h].vertices+b>65535){m[j].counter+=1;h=m[j].hash+"_"+m[j].counter;if(this.geometryChunks[h]==undefined)this.geometryChunks[h]={faces:[],materials:g,vertices:0}}this.geometryChunks[h].faces.push(e);this.geometryChunks[h].vertices+=b}},toString:function(){return"THREE.Geometry ( vertices: "+
 this.vertices+", faces: "+this.faces+", uvs: "+this.uvs+" )"}};
 THREE.Camera=function(a,c,d,e){this.fov=a;this.aspect=c;this.near=d;this.far=e;this.position=new THREE.Vector3;this.target={position:new THREE.Vector3};this.autoUpdateMatrix=true;this.projectionMatrix=null;this.matrix=new THREE.Matrix4;this.up=new THREE.Vector3(0,1,0);this.tmpVec=new THREE.Vector3;this.translateX=function(f){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);this.position.addSelf(this.tmpVec);this.target.position.addSelf(this.tmpVec)};
@@ -98,33 +98,33 @@ var Uniforms={clone:function(a){var c,d,e,f={};for(c in a){f[c]={};for(d in a[c]
 THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};
 THREE.Scene=function(){this.objects=[];this.lights=[];this.fog=null;this.addObject=function(a){this.objects.indexOf(a)===-1&&this.objects.push(a)};this.removeObject=function(a){a=this.objects.indexOf(a);a!==-1&&this.objects.splice(a,1)};this.addLight=function(a){this.lights.indexOf(a)===-1&&this.lights.push(a)};this.removeLight=function(a){a=this.lights.indexOf(a);a!==-1&&this.lights.splice(a,1)};this.toString=function(){return"THREE.Scene ( "+this.objects+" )"}};
 THREE.Fog=function(a,c,d){this.color=new THREE.Color(a);this.near=c||1;this.far=d||1E3};THREE.FogExp2=function(a,c){this.color=new THREE.Color(a);this.density=c||2.5E-4};
-THREE.Projector=function(){function a(k,q){return q.z-k.z}function c(k,q){var x=0,y=1,F=k.z+k.w,B=q.z+q.w,D=-k.z+k.w,I=-q.z+q.w;if(F>=0&&B>=0&&D>=0&&I>=0)return true;else if(F<0&&B<0||D<0&&I<0)return false;else{if(F<0)x=Math.max(x,F/(F-B));else if(B<0)y=Math.min(y,F/(F-B));if(D<0)x=Math.max(x,D/(D-I));else if(I<0)y=Math.min(y,D/(D-I));if(y<x)return false;else{k.lerpSelf(q,x);q.lerpSelf(k,1-y);return true}}}var d,e,f=[],b,g,j,h=[],m,n,A=[],v,o,z=[],C=new THREE.Vector4,G=new THREE.Vector4,w=new THREE.Matrix4,
-H=new THREE.Matrix4,p=[],l=new THREE.Vector4,u=new THREE.Vector4,t;this.projectObjects=function(k,q,x){var y=[],F,B;e=0;w.multiply(q.projectionMatrix,q.matrix);p[0]=new THREE.Vector4(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);p[1]=new THREE.Vector4(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);p[2]=new THREE.Vector4(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);p[3]=new THREE.Vector4(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);p[4]=new THREE.Vector4(w.n41-w.n31,w.n42-w.n32,w.n43-
+THREE.Projector=function(){function a(k,q){return q.z-k.z}function c(k,q){var x=0,z=1,F=k.z+k.w,B=q.z+q.w,D=-k.z+k.w,I=-q.z+q.w;if(F>=0&&B>=0&&D>=0&&I>=0)return true;else if(F<0&&B<0||D<0&&I<0)return false;else{if(F<0)x=Math.max(x,F/(F-B));else if(B<0)z=Math.min(z,F/(F-B));if(D<0)x=Math.max(x,D/(D-I));else if(I<0)z=Math.min(z,D/(D-I));if(z<x)return false;else{k.lerpSelf(q,x);q.lerpSelf(k,1-z);return true}}}var d,e,f=[],b,g,j,h=[],m,n,y=[],u,o,A=[],C=new THREE.Vector4,G=new THREE.Vector4,w=new THREE.Matrix4,
+H=new THREE.Matrix4,p=[],l=new THREE.Vector4,v=new THREE.Vector4,t;this.projectObjects=function(k,q,x){var z=[],F,B;e=0;w.multiply(q.projectionMatrix,q.matrix);p[0]=new THREE.Vector4(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);p[1]=new THREE.Vector4(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);p[2]=new THREE.Vector4(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);p[3]=new THREE.Vector4(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);p[4]=new THREE.Vector4(w.n41-w.n31,w.n42-w.n32,w.n43-
 w.n33,w.n44-w.n34);p[5]=new THREE.Vector4(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);q=0;for(F=p.length;q<F;q++){B=p[q];B.divideScalar(Math.sqrt(B.x*B.x+B.y*B.y+B.z*B.z))}F=k.objects;k=0;for(q=F.length;k<q;k++){B=F[k];var D;if(!(D=!B.visible)){if(D=B instanceof THREE.Mesh){a:{D=void 0;for(var I=B.position,N=-B.geometry.boundingSphere.radius*Math.max(B.scale.x,Math.max(B.scale.y,B.scale.z)),O=0;O<6;O++){D=p[O].x*I.x+p[O].y*I.y+p[O].z*I.z+p[O].w;if(D<=N){D=false;break a}}D=true}D=!D}D=D}if(!D){d=
-f[e]=f[e]||new THREE.RenderableObject;C.copy(B.position);w.multiplyVector3(C);d.object=B;d.z=C.z;y.push(d);e++}}x&&y.sort(a);return y};this.projectScene=function(k,q,x){var y=[],F=q.near,B=q.far,D,I,N,O,Q,T,U,ba,ca,S,K,Z,V,P,W,$;j=n=o=0;q.autoUpdateMatrix&&q.updateMatrix();w.multiply(q.projectionMatrix,q.matrix);T=this.projectObjects(k,q,true);k=0;for(D=T.length;k<D;k++){U=T[k].object;if(U.visible){U.autoUpdateMatrix&&U.updateMatrix();ba=U.matrix;ca=U.rotationMatrix;S=U.materials;K=U.overdraw;if(U instanceof
+f[e]=f[e]||new THREE.RenderableObject;C.copy(B.position);w.multiplyVector3(C);d.object=B;d.z=C.z;z.push(d);e++}}x&&z.sort(a);return z};this.projectScene=function(k,q,x){var z=[],F=q.near,B=q.far,D,I,N,O,Q,T,U,ba,ca,S,K,Z,V,P,W,$;j=n=o=0;q.autoUpdateMatrix&&q.updateMatrix();w.multiply(q.projectionMatrix,q.matrix);T=this.projectObjects(k,q,true);k=0;for(D=T.length;k<D;k++){U=T[k].object;if(U.visible){U.autoUpdateMatrix&&U.updateMatrix();ba=U.matrix;ca=U.rotationMatrix;S=U.materials;K=U.overdraw;if(U instanceof
 THREE.Mesh){Z=U.geometry;V=Z.vertices;I=0;for(N=V.length;I<N;I++){P=V[I];P.positionWorld.copy(P.position);ba.multiplyVector3(P.positionWorld);O=P.positionScreen;O.copy(P.positionWorld);w.multiplyVector4(O);O.x/=O.w;O.y/=O.w;P.__visible=O.z>F&&O.z<B}Z=Z.faces;I=0;for(N=Z.length;I<N;I++){P=Z[I];if(P instanceof THREE.Face3){O=V[P.a];Q=V[P.b];W=V[P.c];if(O.__visible&&Q.__visible&&W.__visible)if(U.doubleSided||U.flipSided!=(W.positionScreen.x-O.positionScreen.x)*(Q.positionScreen.y-O.positionScreen.y)-
 (W.positionScreen.y-O.positionScreen.y)*(Q.positionScreen.x-O.positionScreen.x)<0){b=h[j]=h[j]||new THREE.RenderableFace3;b.v1.positionWorld.copy(O.positionWorld);b.v2.positionWorld.copy(Q.positionWorld);b.v3.positionWorld.copy(W.positionWorld);b.v1.positionScreen.copy(O.positionScreen);b.v2.positionScreen.copy(Q.positionScreen);b.v3.positionScreen.copy(W.positionScreen);b.normalWorld.copy(P.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(P.centroid);ba.multiplyVector3(b.centroidWorld);
-b.centroidScreen.copy(b.centroidWorld);w.multiplyVector3(b.centroidScreen);W=P.vertexNormals;t=b.vertexNormalsWorld;O=0;for(Q=W.length;O<Q;O++){$=t[O]=t[O]||new THREE.Vector3;$.copy(W[O]);ca.multiplyVector3($)}b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=P.materials;b.overdraw=K;if(U.geometry.uvs[I]){b.uvs[0]=U.geometry.uvs[I][0];b.uvs[1]=U.geometry.uvs[I][1];b.uvs[2]=U.geometry.uvs[I][2]}y.push(b);j++}}else if(P instanceof THREE.Face4){O=V[P.a];Q=V[P.b];W=V[P.c];$=V[P.d];if(O.__visible&&
+b.centroidScreen.copy(b.centroidWorld);w.multiplyVector3(b.centroidScreen);W=P.vertexNormals;t=b.vertexNormalsWorld;O=0;for(Q=W.length;O<Q;O++){$=t[O]=t[O]||new THREE.Vector3;$.copy(W[O]);ca.multiplyVector3($)}b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=P.materials;b.overdraw=K;if(U.geometry.uvs[I]){b.uvs[0]=U.geometry.uvs[I][0];b.uvs[1]=U.geometry.uvs[I][1];b.uvs[2]=U.geometry.uvs[I][2]}z.push(b);j++}}else if(P instanceof THREE.Face4){O=V[P.a];Q=V[P.b];W=V[P.c];$=V[P.d];if(O.__visible&&
 Q.__visible&&W.__visible&&$.__visible)if(U.doubleSided||U.flipSided!=(($.positionScreen.x-O.positionScreen.x)*(Q.positionScreen.y-O.positionScreen.y)-($.positionScreen.y-O.positionScreen.y)*(Q.positionScreen.x-O.positionScreen.x)<0||(Q.positionScreen.x-W.positionScreen.x)*($.positionScreen.y-W.positionScreen.y)-(Q.positionScreen.y-W.positionScreen.y)*($.positionScreen.x-W.positionScreen.x)<0)){b=h[j]=h[j]||new THREE.RenderableFace3;b.v1.positionWorld.copy(O.positionWorld);b.v2.positionWorld.copy(Q.positionWorld);
 b.v3.positionWorld.copy($.positionWorld);b.v1.positionScreen.copy(O.positionScreen);b.v2.positionScreen.copy(Q.positionScreen);b.v3.positionScreen.copy($.positionScreen);b.normalWorld.copy(P.normal);ca.multiplyVector3(b.normalWorld);b.centroidWorld.copy(P.centroid);ba.multiplyVector3(b.centroidWorld);b.centroidScreen.copy(b.centroidWorld);w.multiplyVector3(b.centroidScreen);b.z=b.centroidScreen.z;b.meshMaterials=S;b.faceMaterials=P.materials;b.overdraw=K;if(U.geometry.uvs[I]){b.uvs[0]=U.geometry.uvs[I][0];
-b.uvs[1]=U.geometry.uvs[I][1];b.uvs[2]=U.geometry.uvs[I][3]}y.push(b);j++;g=h[j]=h[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(Q.positionWorld);g.v2.positionWorld.copy(W.positionWorld);g.v3.positionWorld.copy($.positionWorld);g.v1.positionScreen.copy(Q.positionScreen);g.v2.positionScreen.copy(W.positionScreen);g.v3.positionScreen.copy($.positionScreen);g.normalWorld.copy(b.normalWorld);g.centroidWorld.copy(b.centroidWorld);g.centroidScreen.copy(b.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=
-S;g.faceMaterials=P.materials;g.overdraw=K;if(U.geometry.uvs[I]){g.uvs[0]=U.geometry.uvs[I][1];g.uvs[1]=U.geometry.uvs[I][2];g.uvs[2]=U.geometry.uvs[I][3]}y.push(g);j++}}}}else if(U instanceof THREE.Line){H.multiply(w,ba);V=U.geometry.vertices;P=V[0];P.positionScreen.copy(P.position);H.multiplyVector4(P.positionScreen);I=1;for(N=V.length;I<N;I++){O=V[I];O.positionScreen.copy(O.position);H.multiplyVector4(O.positionScreen);Q=V[I-1];l.copy(O.positionScreen);u.copy(Q.positionScreen);if(c(l,u)){l.multiplyScalar(1/
-l.w);u.multiplyScalar(1/u.w);m=A[n]=A[n]||new THREE.RenderableLine;m.v1.positionScreen.copy(l);m.v2.positionScreen.copy(u);m.z=Math.max(l.z,u.z);m.materials=U.materials;y.push(m);n++}}}else if(U instanceof THREE.Particle){G.set(U.position.x,U.position.y,U.position.z,1);w.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){v=z[o]=z[o]||new THREE.RenderableParticle;v.x=G.x/G.w;v.y=G.y/G.w;v.z=G.z;v.rotation=U.rotation.z;v.scale.x=U.scale.x*Math.abs(v.x-(G.x+q.projectionMatrix.n11)/(G.w+q.projectionMatrix.n14));
-v.scale.y=U.scale.y*Math.abs(v.y-(G.y+q.projectionMatrix.n22)/(G.w+q.projectionMatrix.n24));v.materials=U.materials;y.push(v);o++}}}}x&&y.sort(a);return y};this.unprojectVector=function(k,q){var x=THREE.Matrix4.makeInvert(q.matrix);x.multiplySelf(THREE.Matrix4.makeInvert(q.projectionMatrix));x.multiplyVector3(k);return k}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,f,b;this.domElement=document.createElement("div");this.setSize=function(g,j){d=g;e=j;f=d/2;b=e/2};this.render=function(g,j){var h,m,n,A,v,o,z,C;a=c.projectScene(g,j);h=0;for(m=a.length;h<m;h++){v=a[h];if(v instanceof THREE.RenderableParticle){z=v.x*f+f;C=v.y*b+b;n=0;for(A=v.material.length;n<A;n++){o=v.material[n];if(o instanceof THREE.ParticleDOMMaterial){o=o.domElement;o.style.left=z+"px";o.style.top=C+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(ma){if(v!=ma)m.globalAlpha=v=ma}function c(ma){if(o!=ma){switch(ma){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}o=ma}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),b,g,j,h,m=f.getContext("2d"),n=new THREE.Color(0),A=0,v=1,o=0,z=null,C=null,G=1,w,H,p,l,u,t,k,q,x,y=new THREE.Color,
+b.uvs[1]=U.geometry.uvs[I][1];b.uvs[2]=U.geometry.uvs[I][3]}z.push(b);j++;g=h[j]=h[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(Q.positionWorld);g.v2.positionWorld.copy(W.positionWorld);g.v3.positionWorld.copy($.positionWorld);g.v1.positionScreen.copy(Q.positionScreen);g.v2.positionScreen.copy(W.positionScreen);g.v3.positionScreen.copy($.positionScreen);g.normalWorld.copy(b.normalWorld);g.centroidWorld.copy(b.centroidWorld);g.centroidScreen.copy(b.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=
+S;g.faceMaterials=P.materials;g.overdraw=K;if(U.geometry.uvs[I]){g.uvs[0]=U.geometry.uvs[I][1];g.uvs[1]=U.geometry.uvs[I][2];g.uvs[2]=U.geometry.uvs[I][3]}z.push(g);j++}}}}else if(U instanceof THREE.Line){H.multiply(w,ba);V=U.geometry.vertices;P=V[0];P.positionScreen.copy(P.position);H.multiplyVector4(P.positionScreen);I=1;for(N=V.length;I<N;I++){O=V[I];O.positionScreen.copy(O.position);H.multiplyVector4(O.positionScreen);Q=V[I-1];l.copy(O.positionScreen);v.copy(Q.positionScreen);if(c(l,v)){l.multiplyScalar(1/
+l.w);v.multiplyScalar(1/v.w);m=y[n]=y[n]||new THREE.RenderableLine;m.v1.positionScreen.copy(l);m.v2.positionScreen.copy(v);m.z=Math.max(l.z,v.z);m.materials=U.materials;z.push(m);n++}}}else if(U instanceof THREE.Particle){G.set(U.position.x,U.position.y,U.position.z,1);w.multiplyVector4(G);G.z/=G.w;if(G.z>0&&G.z<1){u=A[o]=A[o]||new THREE.RenderableParticle;u.x=G.x/G.w;u.y=G.y/G.w;u.z=G.z;u.rotation=U.rotation.z;u.scale.x=U.scale.x*Math.abs(u.x-(G.x+q.projectionMatrix.n11)/(G.w+q.projectionMatrix.n14));
+u.scale.y=U.scale.y*Math.abs(u.y-(G.y+q.projectionMatrix.n22)/(G.w+q.projectionMatrix.n24));u.materials=U.materials;z.push(u);o++}}}}x&&z.sort(a);return z};this.unprojectVector=function(k,q){var x=THREE.Matrix4.makeInvert(q.matrix);x.multiplySelf(THREE.Matrix4.makeInvert(q.projectionMatrix));x.multiplyVector3(k);return k}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,c=new THREE.Projector,d,e,f,b;this.domElement=document.createElement("div");this.setSize=function(g,j){d=g;e=j;f=d/2;b=e/2};this.render=function(g,j){var h,m,n,y,u,o,A,C;a=c.projectScene(g,j);h=0;for(m=a.length;h<m;h++){u=a[h];if(u instanceof THREE.RenderableParticle){A=u.x*f+f;C=u.y*b+b;n=0;for(y=u.material.length;n<y;n++){o=u.material[n];if(o instanceof THREE.ParticleDOMMaterial){o=o.domElement;o.style.left=A+"px";o.style.top=C+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(ma){if(u!=ma)m.globalAlpha=u=ma}function c(ma){if(o!=ma){switch(ma){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}o=ma}}var d=null,e=new THREE.Projector,f=document.createElement("canvas"),b,g,j,h,m=f.getContext("2d"),n=new THREE.Color(0),y=0,u=1,o=0,A=null,C=null,G=1,w,H,p,l,v,t,k,q,x,z=new THREE.Color,
 F=new THREE.Color,B=new THREE.Color,D=new THREE.Color,I=new THREE.Color,N,O,Q,T,U,ba,ca,S,K,Z=new THREE.Rectangle,V=new THREE.Rectangle,P=new THREE.Rectangle,W=false,$=new THREE.Color,da=new THREE.Color,ha=new THREE.Color,E=new THREE.Color,L=Math.PI*2,J=new THREE.Vector3,X,ea,ja,ia,qa,la,ua=16;X=document.createElement("canvas");X.width=X.height=2;ea=X.getContext("2d");ea.fillStyle="rgba(0,0,0,1)";ea.fillRect(0,0,2,2);ja=ea.getImageData(0,0,2,2);ia=ja.data;qa=document.createElement("canvas");qa.width=
-qa.height=ua;la=qa.getContext("2d");la.translate(-ua/2,-ua/2);la.scale(ua,ua);ua--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ma,sa){b=ma;g=sa;j=b/2;h=g/2;f.width=b;f.height=g;Z.set(-j,-h,j,h);v=1;o=0;C=z=null;G=1};this.setClearColor=function(ma,sa){n.setHex(ma);A=sa;V.set(-j,-h,j,h);m.setTransform(1,0,0,-1,j,h);this.clear()};this.clear=function(){m.setTransform(1,0,0,-1,j,h);if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(n.hex==0&&A==0)m.clearRect(V.getX(),
-V.getY(),V.getWidth(),V.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+A+")";m.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight())}V.empty()}};this.render=function(ma,sa){function Ha(M){var fa,aa,R,Y=M.lights;da.setRGB(0,0,0);ha.setRGB(0,0,0);E.setRGB(0,0,0);M=0;for(fa=Y.length;M<fa;M++){aa=Y[M];R=aa.color;if(aa instanceof THREE.AmbientLight){da.r+=R.r;da.g+=R.g;da.b+=R.b}else if(aa instanceof THREE.DirectionalLight){ha.r+=
+qa.height=ua;la=qa.getContext("2d");la.translate(-ua/2,-ua/2);la.scale(ua,ua);ua--;this.domElement=f;this.sortElements=this.sortObjects=this.autoClear=true;this.setSize=function(ma,sa){b=ma;g=sa;j=b/2;h=g/2;f.width=b;f.height=g;Z.set(-j,-h,j,h);u=1;o=0;C=A=null;G=1};this.setClearColor=function(ma,sa){n.setHex(ma);y=sa;V.set(-j,-h,j,h);m.setTransform(1,0,0,-1,j,h);this.clear()};this.clear=function(){m.setTransform(1,0,0,-1,j,h);if(!V.isEmpty()){V.inflate(1);V.minSelf(Z);if(n.hex==0&&y==0)m.clearRect(V.getX(),
+V.getY(),V.getWidth(),V.getHeight());else{c(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+y+")";m.fillRect(V.getX(),V.getY(),V.getWidth(),V.getHeight())}V.empty()}};this.render=function(ma,sa){function Ha(M){var fa,aa,R,Y=M.lights;da.setRGB(0,0,0);ha.setRGB(0,0,0);E.setRGB(0,0,0);M=0;for(fa=Y.length;M<fa;M++){aa=Y[M];R=aa.color;if(aa instanceof THREE.AmbientLight){da.r+=R.r;da.g+=R.g;da.b+=R.b}else if(aa instanceof THREE.DirectionalLight){ha.r+=
 R.r;ha.g+=R.g;ha.b+=R.b}else if(aa instanceof THREE.PointLight){E.r+=R.r;E.g+=R.g;E.b+=R.b}}}function Da(M,fa,aa,R){var Y,ga,na,oa,pa=M.lights;M=0;for(Y=pa.length;M<Y;M++){ga=pa[M];na=ga.color;oa=ga.intensity;if(ga instanceof THREE.DirectionalLight){ga=aa.dot(ga.position)*oa;if(ga>0){R.r+=na.r*ga;R.g+=na.g*ga;R.b+=na.b*ga}}else if(ga instanceof THREE.PointLight){J.sub(ga.position,fa);J.normalize();ga=aa.dot(J)*oa;if(ga>0){R.r+=na.r*ga;R.g+=na.g*ga;R.b+=na.b*ga}}}}function Qa(M,fa,aa){if(aa.opacity!=
 0){a(aa.opacity);c(aa.blending);var R,Y,ga,na,oa,pa;if(aa instanceof THREE.ParticleBasicMaterial){if(aa.map&&aa.map.image.loaded){na=aa.map.image;oa=na.width>>1;pa=na.height>>1;Y=fa.scale.x*j;ga=fa.scale.y*h;aa=Y*oa;R=ga*pa;P.set(M.x-aa,M.y-R,M.x+aa,M.y+R);if(Z.instersects(P)){m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(Y,-ga);m.translate(-oa,-pa);m.drawImage(na,0,0);m.restore()}}}else if(aa instanceof THREE.ParticleCircleMaterial){if(W){$.r=da.r+ha.r+E.r;$.g=da.g+ha.g+E.g;$.b=da.b+
-ha.b+E.b;y.r=aa.color.r*$.r;y.g=aa.color.g*$.g;y.b=aa.color.b*$.b;y.updateStyleString()}else y.__styleString=aa.color.__styleString;aa=fa.scale.x*j;R=fa.scale.y*h;P.set(M.x-aa,M.y-R,M.x+aa,M.y+R);if(Z.instersects(P)){Y=y.__styleString;if(C!=Y)m.fillStyle=C=Y;m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(aa,R);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function Ra(M,fa,aa,R){if(R.opacity!=0){a(R.opacity);c(R.blending);m.beginPath();m.moveTo(M.positionScreen.x,
-M.positionScreen.y);m.lineTo(fa.positionScreen.x,fa.positionScreen.y);m.closePath();if(R instanceof THREE.LineBasicMaterial){y.__styleString=R.color.__styleString;M=R.linewidth;if(G!=M)m.lineWidth=G=M;M=y.__styleString;if(z!=M)m.strokeStyle=z=M;m.stroke();P.inflate(R.linewidth*2)}}}function Ma(M,fa,aa,R,Y,ga){if(Y.opacity!=0){a(Y.opacity);c(Y.blending);l=M.positionScreen.x;u=M.positionScreen.y;t=fa.positionScreen.x;k=fa.positionScreen.y;q=aa.positionScreen.x;x=aa.positionScreen.y;m.beginPath();m.moveTo(l,
-u);m.lineTo(t,k);m.lineTo(q,x);m.lineTo(l,u);m.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.image.loaded&&Y.map.mapping instanceof THREE.UVMapping&&Aa(l,u,t,k,q,x,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);else if(Y.env_map){if(Y.env_map.image.loaded)if(Y.env_map.mapping instanceof THREE.SphericalReflectionMapping){M=sa.matrix;J.copy(R.vertexNormalsWorld[0]);T=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;U=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;
-J.copy(R.vertexNormalsWorld[1]);ba=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;ca=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;J.copy(R.vertexNormalsWorld[2]);S=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;K=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;Aa(l,u,t,k,q,x,Y.env_map.image,T,U,ba,ca,S,K)}}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&!Y.wireframe){Y.map.mapping instanceof THREE.UVMapping&&Aa(l,u,t,k,q,
-x,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);c(THREE.SubtractiveBlending)}if(W)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&R.vertexNormalsWorld.length==3){F.r=B.r=D.r=da.r;F.g=B.g=D.g=da.g;F.b=B.b=D.b=da.b;Da(ga,R.v1.positionWorld,R.vertexNormalsWorld[0],F);Da(ga,R.v2.positionWorld,R.vertexNormalsWorld[1],B);Da(ga,R.v3.positionWorld,R.vertexNormalsWorld[2],D);I.r=(B.r+D.r)*0.5;I.g=(B.g+D.g)*0.5;I.b=(B.b+D.b)*0.5;Q=Na(F,B,D,I);Aa(l,u,t,k,q,x,Q,0,0,1,0,0,1)}else{$.r=
-da.r;$.g=da.g;$.b=da.b;Da(ga,R.centroidWorld,R.normalWorld,$);y.r=Y.color.r*$.r;y.g=Y.color.g*$.g;y.b=Y.color.b*$.b;y.updateStyleString();Y.wireframe?Ea(y.__styleString,Y.wireframe_linewidth):Fa(y.__styleString)}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){N=sa.near;O=sa.far;F.r=F.g=F.b=1-Ia(M.positionScreen.z,N,O);B.r=B.g=B.b=1-Ia(fa.positionScreen.z,N,O);D.r=D.g=D.b=1-Ia(aa.positionScreen.z,N,O);I.r=(B.r+
-D.r)*0.5;I.g=(B.g+D.g)*0.5;I.b=(B.b+D.b)*0.5;Q=Na(F,B,D,I);Aa(l,u,t,k,q,x,Q,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){y.r=Ja(R.normalWorld.x);y.g=Ja(R.normalWorld.y);y.b=Ja(R.normalWorld.z);y.updateStyleString();Y.wireframe?Ea(y.__styleString,Y.wireframe_linewidth):Fa(y.__styleString)}}}function Ea(M,fa){if(z!=M)m.strokeStyle=z=M;if(G!=fa)m.lineWidth=G=fa;m.stroke();P.inflate(fa*2)}function Fa(M){if(C!=M)m.fillStyle=C=M;m.fill()}function Aa(M,fa,aa,R,Y,ga,na,oa,pa,va,ra,wa,Ba){var ya,
+ha.b+E.b;z.r=aa.color.r*$.r;z.g=aa.color.g*$.g;z.b=aa.color.b*$.b;z.updateStyleString()}else z.__styleString=aa.color.__styleString;aa=fa.scale.x*j;R=fa.scale.y*h;P.set(M.x-aa,M.y-R,M.x+aa,M.y+R);if(Z.instersects(P)){Y=z.__styleString;if(C!=Y)m.fillStyle=C=Y;m.save();m.translate(M.x,M.y);m.rotate(-fa.rotation);m.scale(aa,R);m.beginPath();m.arc(0,0,1,0,L,true);m.closePath();m.fill();m.restore()}}}}function Ra(M,fa,aa,R){if(R.opacity!=0){a(R.opacity);c(R.blending);m.beginPath();m.moveTo(M.positionScreen.x,
+M.positionScreen.y);m.lineTo(fa.positionScreen.x,fa.positionScreen.y);m.closePath();if(R instanceof THREE.LineBasicMaterial){z.__styleString=R.color.__styleString;M=R.linewidth;if(G!=M)m.lineWidth=G=M;M=z.__styleString;if(A!=M)m.strokeStyle=A=M;m.stroke();P.inflate(R.linewidth*2)}}}function Ma(M,fa,aa,R,Y,ga){if(Y.opacity!=0){a(Y.opacity);c(Y.blending);l=M.positionScreen.x;v=M.positionScreen.y;t=fa.positionScreen.x;k=fa.positionScreen.y;q=aa.positionScreen.x;x=aa.positionScreen.y;m.beginPath();m.moveTo(l,
+v);m.lineTo(t,k);m.lineTo(q,x);m.lineTo(l,v);m.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.image.loaded&&Y.map.mapping instanceof THREE.UVMapping&&Aa(l,v,t,k,q,x,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);else if(Y.env_map){if(Y.env_map.image.loaded)if(Y.env_map.mapping instanceof THREE.SphericalReflectionMapping){M=sa.matrix;J.copy(R.vertexNormalsWorld[0]);T=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;U=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;
+J.copy(R.vertexNormalsWorld[1]);ba=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;ca=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;J.copy(R.vertexNormalsWorld[2]);S=(J.x*M.n11+J.y*M.n12+J.z*M.n13)*0.5+0.5;K=-(J.x*M.n21+J.y*M.n22+J.z*M.n23)*0.5+0.5;Aa(l,v,t,k,q,x,Y.env_map.image,T,U,ba,ca,S,K)}}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&!Y.wireframe){Y.map.mapping instanceof THREE.UVMapping&&Aa(l,v,t,k,q,
+x,Y.map.image,R.uvs[0].u,R.uvs[0].v,R.uvs[1].u,R.uvs[1].v,R.uvs[2].u,R.uvs[2].v);c(THREE.SubtractiveBlending)}if(W)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&R.vertexNormalsWorld.length==3){F.r=B.r=D.r=da.r;F.g=B.g=D.g=da.g;F.b=B.b=D.b=da.b;Da(ga,R.v1.positionWorld,R.vertexNormalsWorld[0],F);Da(ga,R.v2.positionWorld,R.vertexNormalsWorld[1],B);Da(ga,R.v3.positionWorld,R.vertexNormalsWorld[2],D);I.r=(B.r+D.r)*0.5;I.g=(B.g+D.g)*0.5;I.b=(B.b+D.b)*0.5;Q=Na(F,B,D,I);Aa(l,v,t,k,q,x,Q,0,0,1,0,0,1)}else{$.r=
+da.r;$.g=da.g;$.b=da.b;Da(ga,R.centroidWorld,R.normalWorld,$);z.r=Y.color.r*$.r;z.g=Y.color.g*$.g;z.b=Y.color.b*$.b;z.updateStyleString();Y.wireframe?Ea(z.__styleString,Y.wireframe_linewidth):Fa(z.__styleString)}else Y.wireframe?Ea(Y.color.__styleString,Y.wireframe_linewidth):Fa(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){N=sa.near;O=sa.far;F.r=F.g=F.b=1-Ia(M.positionScreen.z,N,O);B.r=B.g=B.b=1-Ia(fa.positionScreen.z,N,O);D.r=D.g=D.b=1-Ia(aa.positionScreen.z,N,O);I.r=(B.r+
+D.r)*0.5;I.g=(B.g+D.g)*0.5;I.b=(B.b+D.b)*0.5;Q=Na(F,B,D,I);Aa(l,v,t,k,q,x,Q,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){z.r=Ja(R.normalWorld.x);z.g=Ja(R.normalWorld.y);z.b=Ja(R.normalWorld.z);z.updateStyleString();Y.wireframe?Ea(z.__styleString,Y.wireframe_linewidth):Fa(z.__styleString)}}}function Ea(M,fa){if(A!=M)m.strokeStyle=A=M;if(G!=fa)m.lineWidth=G=fa;m.stroke();P.inflate(fa*2)}function Fa(M){if(C!=M)m.fillStyle=C=M;m.fill()}function Aa(M,fa,aa,R,Y,ga,na,oa,pa,va,ra,wa,Ba){var ya,
 xa;ya=na.width-1;xa=na.height-1;oa*=ya;pa*=xa;va*=ya;ra*=xa;wa*=ya;Ba*=xa;aa-=M;R-=fa;Y-=M;ga-=fa;va-=oa;ra-=pa;wa-=oa;Ba-=pa;xa=1/(va*Ba-wa*ra);ya=(Ba*aa-ra*Y)*xa;ra=(Ba*R-ra*ga)*xa;aa=(va*Y-wa*aa)*xa;R=(va*ga-wa*R)*xa;M=M-ya*oa-aa*pa;fa=fa-ra*oa-R*pa;m.save();m.transform(ya,ra,aa,R,M,fa);m.clip();m.drawImage(na,0,0);m.restore()}function Na(M,fa,aa,R){var Y=~~(M.r*255),ga=~~(M.g*255);M=~~(M.b*255);var na=~~(fa.r*255),oa=~~(fa.g*255);fa=~~(fa.b*255);var pa=~~(aa.r*255),va=~~(aa.g*255);aa=~~(aa.b*
 255);var ra=~~(R.r*255),wa=~~(R.g*255);R=~~(R.b*255);ia[0]=Y<0?0:Y>255?255:Y;ia[1]=ga<0?0:ga>255?255:ga;ia[2]=M<0?0:M>255?255:M;ia[4]=na<0?0:na>255?255:na;ia[5]=oa<0?0:oa>255?255:oa;ia[6]=fa<0?0:fa>255?255:fa;ia[8]=pa<0?0:pa>255?255:pa;ia[9]=va<0?0:va>255?255:va;ia[10]=aa<0?0:aa>255?255:aa;ia[12]=ra<0?0:ra>255?255:ra;ia[13]=wa<0?0:wa>255?255:wa;ia[14]=R<0?0:R>255?255:R;ea.putImageData(ja,0,0);la.drawImage(X,0,0);return qa}function Ia(M,fa,aa){M=(M-fa)/(aa-fa);return M*M*(3-2*M)}function Ja(M){M=(M+
 1)*0.5;return M<0?0:M>1?1:M}function Ka(M,fa){var aa=fa.x-M.x,R=fa.y-M.y,Y=1/Math.sqrt(aa*aa+R*R);aa*=Y;R*=Y;fa.x+=aa;fa.y+=R;M.x-=aa;M.y-=R}var Ga,Oa,ka,ta,za,La,Pa,Ca;this.autoClear?this.clear():m.setTransform(1,0,0,-1,j,h);d=e.projectScene(ma,sa,this.sortElements);(W=ma.lights.length>0)&&Ha(ma);Ga=0;for(Oa=d.length;Ga<Oa;Ga++){ka=d[Ga];P.empty();if(ka instanceof THREE.RenderableParticle){w=ka;w.x*=j;w.y*=h;ta=0;for(za=ka.materials.length;ta<za;ta++)Qa(w,ka,ka.materials[ta],ma)}else if(ka instanceof
@@ -132,69 +132,69 @@ THREE.RenderableLine){w=ka.v1;H=ka.v2;w.positionScreen.x*=j;w.positionScreen.y*=
 h;if(ka.overdraw){Ka(w.positionScreen,H.positionScreen);Ka(H.positionScreen,p.positionScreen);Ka(p.positionScreen,w.positionScreen)}P.add3Points(w.positionScreen.x,w.positionScreen.y,H.positionScreen.x,H.positionScreen.y,p.positionScreen.x,p.positionScreen.y);if(Z.instersects(P)){ta=0;for(za=ka.meshMaterials.length;ta<za;){Ca=ka.meshMaterials[ta++];if(Ca instanceof THREE.MeshFaceMaterial){La=0;for(Pa=ka.faceMaterials.length;La<Pa;)(Ca=ka.faceMaterials[La++])&&Ma(w,H,p,ka,Ca,ma)}else Ma(w,H,p,ka,Ca,
 ma)}}}V.addRectangle(P)}m.setTransform(1,0,0,1,0,0)}};
 THREE.SVGRenderer=function(){function a(T,U,ba){var ca,S,K,Z;ca=0;for(S=T.lights.length;ca<S;ca++){K=T.lights[ca];if(K instanceof THREE.DirectionalLight){Z=U.normalWorld.dot(K.position)*K.intensity;if(Z>0){ba.r+=K.color.r*Z;ba.g+=K.color.g*Z;ba.b+=K.color.b*Z}}else if(K instanceof THREE.PointLight){x.sub(K.position,U.centroidWorld);x.normalize();Z=U.normalWorld.dot(x)*K.intensity;if(Z>0){ba.r+=K.color.r*Z;ba.g+=K.color.g*Z;ba.b+=K.color.b*Z}}}}function c(T,U,ba,ca,S,K){D=e(I++);D.setAttribute("d",
-"M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)p.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(H){l.r=u.r;l.g=u.g;l.b=u.b;a(K,ca,l);p.r=S.color.r*l.r;p.g=S.color.g*l.g;p.b=S.color.b*l.b;p.updateStyleString()}else p.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){q=1-S.__2near/(S.__farPlusNear-
+"M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+"z");if(S instanceof THREE.MeshBasicMaterial)p.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshLambertMaterial)if(H){l.r=v.r;l.g=v.g;l.b=v.b;a(K,ca,l);p.r=S.color.r*l.r;p.g=S.color.g*l.g;p.b=S.color.b*l.b;p.updateStyleString()}else p.__styleString=S.color.__styleString;else if(S instanceof THREE.MeshDepthMaterial){q=1-S.__2near/(S.__farPlusNear-
 ca.z*S.__farMinusNear);p.setRGB(q,q,q)}else S instanceof THREE.MeshNormalMaterial&&p.setRGB(f(ca.normalWorld.x),f(ca.normalWorld.y),f(ca.normalWorld.z));S.wireframe?D.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+S.wireframe_linewidth+"; stroke-opacity: "+S.opacity+"; stroke-linecap: "+S.wireframe_linecap+"; stroke-linejoin: "+S.wireframe_linejoin):D.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+S.opacity);j.appendChild(D)}function d(T,U,ba,ca,S,
-K,Z){D=e(I++);D.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(K instanceof THREE.MeshBasicMaterial)p.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshLambertMaterial)if(H){l.r=u.r;l.g=u.g;l.b=u.b;a(Z,S,l);p.r=K.color.r*l.r;p.g=K.color.g*l.g;p.b=K.color.b*l.b;p.updateStyleString()}else p.__styleString=K.color.__styleString;
+K,Z){D=e(I++);D.setAttribute("d","M "+T.positionScreen.x+" "+T.positionScreen.y+" L "+U.positionScreen.x+" "+U.positionScreen.y+" L "+ba.positionScreen.x+","+ba.positionScreen.y+" L "+ca.positionScreen.x+","+ca.positionScreen.y+"z");if(K instanceof THREE.MeshBasicMaterial)p.__styleString=K.color.__styleString;else if(K instanceof THREE.MeshLambertMaterial)if(H){l.r=v.r;l.g=v.g;l.b=v.b;a(Z,S,l);p.r=K.color.r*l.r;p.g=K.color.g*l.g;p.b=K.color.b*l.b;p.updateStyleString()}else p.__styleString=K.color.__styleString;
 else if(K instanceof THREE.MeshDepthMaterial){q=1-K.__2near/(K.__farPlusNear-S.z*K.__farMinusNear);p.setRGB(q,q,q)}else K instanceof THREE.MeshNormalMaterial&&p.setRGB(f(S.normalWorld.x),f(S.normalWorld.y),f(S.normalWorld.z));K.wireframe?D.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+K.wireframe_linewidth+"; stroke-opacity: "+K.opacity+"; stroke-linecap: "+K.wireframe_linecap+"; stroke-linejoin: "+K.wireframe_linejoin):D.setAttribute("style","fill: "+p.__styleString+
-"; fill-opacity: "+K.opacity);j.appendChild(D)}function e(T){if(y[T]==null){y[T]=document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&y[T].setAttribute("shape-rendering","crispEdges");return y[T]}return y[T]}function f(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var b=null,g=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,m,n,A,v,o,z,C,G=new THREE.Rectangle,w=new THREE.Rectangle,H=false,p=new THREE.Color(16777215),l=new THREE.Color(16777215),
-u=new THREE.Color(0),t=new THREE.Color(0),k=new THREE.Color(0),q,x=new THREE.Vector3,y=[],F=[],B=[],D,I,N,O,Q=1;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(T,U){h=T;m=U;n=h/2;A=m/2;j.setAttribute("viewBox",-n+" "+-A+" "+h+" "+m);j.setAttribute("width",h);j.setAttribute("height",m);G.set(-n,-A,n,A)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};
-this.render=function(T,U){var ba,ca,S,K,Z,V,P,W;this.autoClear&&this.clear();b=g.projectScene(T,U,this.sortElements);O=N=I=0;if(H=T.lights.length>0){P=T.lights;u.setRGB(0,0,0);t.setRGB(0,0,0);k.setRGB(0,0,0);ba=0;for(ca=P.length;ba<ca;ba++){S=P[ba];K=S.color;if(S instanceof THREE.AmbientLight){u.r+=K.r;u.g+=K.g;u.b+=K.b}else if(S instanceof THREE.DirectionalLight){t.r+=K.r;t.g+=K.g;t.b+=K.b}else if(S instanceof THREE.PointLight){k.r+=K.r;k.g+=K.g;k.b+=K.b}}}ba=0;for(ca=b.length;ba<ca;ba++){P=b[ba];
-w.empty();if(P instanceof THREE.RenderableParticle){v=P;v.x*=n;v.y*=-A;S=0;for(K=P.materials.length;S<K;S++)if(W=P.materials[S]){Z=v;V=P;W=W;var $=N++;if(F[$]==null){F[$]=document.createElementNS("http://www.w3.org/2000/svg","circle");Q==0&&F[$].setAttribute("shape-rendering","crispEdges")}D=F[$];D.setAttribute("cx",Z.x);D.setAttribute("cy",Z.y);D.setAttribute("r",V.scale.x*n);if(W instanceof THREE.ParticleCircleMaterial){if(H){l.r=u.r+t.r+k.r;l.g=u.g+t.g+k.g;l.b=u.b+t.b+k.b;p.r=W.color.r*l.r;p.g=
-W.color.g*l.g;p.b=W.color.b*l.b;p.updateStyleString()}else p=W.color;D.setAttribute("style","fill: "+p.__styleString)}j.appendChild(D)}}else if(P instanceof THREE.RenderableLine){v=P.v1;o=P.v2;v.positionScreen.x*=n;v.positionScreen.y*=-A;o.positionScreen.x*=n;o.positionScreen.y*=-A;w.addPoint(v.positionScreen.x,v.positionScreen.y);w.addPoint(o.positionScreen.x,o.positionScreen.y);if(G.instersects(w)){S=0;for(K=P.materials.length;S<K;)if(W=P.materials[S++]){Z=v;V=o;W=W;$=O++;if(B[$]==null){B[$]=document.createElementNS("http://www.w3.org/2000/svg",
+"; fill-opacity: "+K.opacity);j.appendChild(D)}function e(T){if(z[T]==null){z[T]=document.createElementNS("http://www.w3.org/2000/svg","path");Q==0&&z[T].setAttribute("shape-rendering","crispEdges");return z[T]}return z[T]}function f(T){return T<0?Math.min((1+T)*0.5,0.5):0.5+Math.min(T*0.5,0.5)}var b=null,g=new THREE.Projector,j=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,m,n,y,u,o,A,C,G=new THREE.Rectangle,w=new THREE.Rectangle,H=false,p=new THREE.Color(16777215),l=new THREE.Color(16777215),
+v=new THREE.Color(0),t=new THREE.Color(0),k=new THREE.Color(0),q,x=new THREE.Vector3,z=[],F=[],B=[],D,I,N,O,Q=1;this.domElement=j;this.sortElements=this.sortObjects=this.autoClear=true;this.setQuality=function(T){switch(T){case "high":Q=1;break;case "low":Q=0}};this.setSize=function(T,U){h=T;m=U;n=h/2;y=m/2;j.setAttribute("viewBox",-n+" "+-y+" "+h+" "+m);j.setAttribute("width",h);j.setAttribute("height",m);G.set(-n,-y,n,y)};this.clear=function(){for(;j.childNodes.length>0;)j.removeChild(j.childNodes[0])};
+this.render=function(T,U){var ba,ca,S,K,Z,V,P,W;this.autoClear&&this.clear();b=g.projectScene(T,U,this.sortElements);O=N=I=0;if(H=T.lights.length>0){P=T.lights;v.setRGB(0,0,0);t.setRGB(0,0,0);k.setRGB(0,0,0);ba=0;for(ca=P.length;ba<ca;ba++){S=P[ba];K=S.color;if(S instanceof THREE.AmbientLight){v.r+=K.r;v.g+=K.g;v.b+=K.b}else if(S instanceof THREE.DirectionalLight){t.r+=K.r;t.g+=K.g;t.b+=K.b}else if(S instanceof THREE.PointLight){k.r+=K.r;k.g+=K.g;k.b+=K.b}}}ba=0;for(ca=b.length;ba<ca;ba++){P=b[ba];
+w.empty();if(P instanceof THREE.RenderableParticle){u=P;u.x*=n;u.y*=-y;S=0;for(K=P.materials.length;S<K;S++)if(W=P.materials[S]){Z=u;V=P;W=W;var $=N++;if(F[$]==null){F[$]=document.createElementNS("http://www.w3.org/2000/svg","circle");Q==0&&F[$].setAttribute("shape-rendering","crispEdges")}D=F[$];D.setAttribute("cx",Z.x);D.setAttribute("cy",Z.y);D.setAttribute("r",V.scale.x*n);if(W instanceof THREE.ParticleCircleMaterial){if(H){l.r=v.r+t.r+k.r;l.g=v.g+t.g+k.g;l.b=v.b+t.b+k.b;p.r=W.color.r*l.r;p.g=
+W.color.g*l.g;p.b=W.color.b*l.b;p.updateStyleString()}else p=W.color;D.setAttribute("style","fill: "+p.__styleString)}j.appendChild(D)}}else if(P instanceof THREE.RenderableLine){u=P.v1;o=P.v2;u.positionScreen.x*=n;u.positionScreen.y*=-y;o.positionScreen.x*=n;o.positionScreen.y*=-y;w.addPoint(u.positionScreen.x,u.positionScreen.y);w.addPoint(o.positionScreen.x,o.positionScreen.y);if(G.instersects(w)){S=0;for(K=P.materials.length;S<K;)if(W=P.materials[S++]){Z=u;V=o;W=W;$=O++;if(B[$]==null){B[$]=document.createElementNS("http://www.w3.org/2000/svg",
 "line");Q==0&&B[$].setAttribute("shape-rendering","crispEdges")}D=B[$];D.setAttribute("x1",Z.positionScreen.x);D.setAttribute("y1",Z.positionScreen.y);D.setAttribute("x2",V.positionScreen.x);D.setAttribute("y2",V.positionScreen.y);if(W instanceof THREE.LineBasicMaterial){p.__styleString=W.color.__styleString;D.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+W.linewidth+"; stroke-opacity: "+W.opacity+"; stroke-linecap: "+W.linecap+"; stroke-linejoin: "+W.linejoin);j.appendChild(D)}}}}else if(P instanceof
-THREE.RenderableFace3){v=P.v1;o=P.v2;z=P.v3;v.positionScreen.x*=n;v.positionScreen.y*=-A;o.positionScreen.x*=n;o.positionScreen.y*=-A;z.positionScreen.x*=n;z.positionScreen.y*=-A;w.addPoint(v.positionScreen.x,v.positionScreen.y);w.addPoint(o.positionScreen.x,o.positionScreen.y);w.addPoint(z.positionScreen.x,z.positionScreen.y);if(G.instersects(w)){S=0;for(K=P.meshMaterials.length;S<K;){W=P.meshMaterials[S++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=P.faceMaterials.length;Z<V;)(W=P.faceMaterials[Z++])&&
-c(v,o,z,P,W,T)}else W&&c(v,o,z,P,W,T)}}}else if(P instanceof THREE.RenderableFace4){v=P.v1;o=P.v2;z=P.v3;C=P.v4;v.positionScreen.x*=n;v.positionScreen.y*=-A;o.positionScreen.x*=n;o.positionScreen.y*=-A;z.positionScreen.x*=n;z.positionScreen.y*=-A;C.positionScreen.x*=n;C.positionScreen.y*=-A;w.addPoint(v.positionScreen.x,v.positionScreen.y);w.addPoint(o.positionScreen.x,o.positionScreen.y);w.addPoint(z.positionScreen.x,z.positionScreen.y);w.addPoint(C.positionScreen.x,C.positionScreen.y);if(G.instersects(w)){S=
-0;for(K=P.meshMaterials.length;S<K;){W=P.meshMaterials[S++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=P.faceMaterials.length;Z<V;)(W=P.faceMaterials[Z++])&&d(v,o,z,C,P,W,T)}else W&&d(v,o,z,C,P,W,T)}}}}}};
-THREE.WebGLRenderer=function(a){function c(l,u){l.fragment_shader=u.fragment_shader;l.vertex_shader=u.vertex_shader;l.uniforms=Uniforms.clone(u.uniforms)}function d(l,u){var t;if(l=="fragment")t=b.createShader(b.FRAGMENT_SHADER);else if(l=="vertex")t=b.createShader(b.VERTEX_SHADER);b.shaderSource(t,u);b.compileShader(t);if(!b.getShaderParameter(t,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(t));return null}return t}function e(l){switch(l){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
+THREE.RenderableFace3){u=P.v1;o=P.v2;A=P.v3;u.positionScreen.x*=n;u.positionScreen.y*=-y;o.positionScreen.x*=n;o.positionScreen.y*=-y;A.positionScreen.x*=n;A.positionScreen.y*=-y;w.addPoint(u.positionScreen.x,u.positionScreen.y);w.addPoint(o.positionScreen.x,o.positionScreen.y);w.addPoint(A.positionScreen.x,A.positionScreen.y);if(G.instersects(w)){S=0;for(K=P.meshMaterials.length;S<K;){W=P.meshMaterials[S++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=P.faceMaterials.length;Z<V;)(W=P.faceMaterials[Z++])&&
+c(u,o,A,P,W,T)}else W&&c(u,o,A,P,W,T)}}}else if(P instanceof THREE.RenderableFace4){u=P.v1;o=P.v2;A=P.v3;C=P.v4;u.positionScreen.x*=n;u.positionScreen.y*=-y;o.positionScreen.x*=n;o.positionScreen.y*=-y;A.positionScreen.x*=n;A.positionScreen.y*=-y;C.positionScreen.x*=n;C.positionScreen.y*=-y;w.addPoint(u.positionScreen.x,u.positionScreen.y);w.addPoint(o.positionScreen.x,o.positionScreen.y);w.addPoint(A.positionScreen.x,A.positionScreen.y);w.addPoint(C.positionScreen.x,C.positionScreen.y);if(G.instersects(w)){S=
+0;for(K=P.meshMaterials.length;S<K;){W=P.meshMaterials[S++];if(W instanceof THREE.MeshFaceMaterial){Z=0;for(V=P.faceMaterials.length;Z<V;)(W=P.faceMaterials[Z++])&&d(u,o,A,C,P,W,T)}else W&&d(u,o,A,C,P,W,T)}}}}}};
+THREE.WebGLRenderer=function(a){function c(l,v){l.fragment_shader=v.fragment_shader;l.vertex_shader=v.vertex_shader;l.uniforms=Uniforms.clone(v.uniforms)}function d(l,v){var t;if(l=="fragment")t=b.createShader(b.FRAGMENT_SHADER);else if(l=="vertex")t=b.createShader(b.VERTEX_SHADER);b.shaderSource(t,v);b.compileShader(t);if(!b.getShaderParameter(t,b.COMPILE_STATUS)){alert(b.getShaderInfoLog(t));return null}return t}function e(l){switch(l){case THREE.RepeatWrapping:return b.REPEAT;case THREE.ClampToEdgeWrapping:return b.CLAMP_TO_EDGE;
 case THREE.MirroredRepeatWrapping:return b.MIRRORED_REPEAT;case THREE.NearestFilter:return b.NEAREST;case THREE.NearestMipMapNearestFilter:return b.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return b.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return b.LINEAR;case THREE.LinearMipMapNearestFilter:return b.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return b.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return b.BYTE;case THREE.UnsignedByteType:return b.UNSIGNED_BYTE;case THREE.ShortType:return b.SHORT;
-case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var f=document.createElement("canvas"),b,g=null,j=null,h=new THREE.Matrix4,m,n=new Float32Array(16),A=new Float32Array(16),
-v=new Float32Array(16),o=new Float32Array(9),z=new Float32Array(16),C=new THREE.Matrix4,G=new THREE.Vector4,w=true,H=new THREE.Color(0),p=0;if(a){if(a.antialias!==undefined)w=a.antialias;a.clearColor!==undefined&&H.setHex(a.clearColor);if(a.clearAlpha!==undefined)p=a.clearAlpha}this.domElement=f;this.autoClear=true;(function(l,u,t){try{b=f.getContext("experimental-webgl",{antialias:l})}catch(k){console.log(k)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,
-0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(u.r,u.g,u.b,t)})(w,H,p);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,u){f.width=l;f.height=u;b.viewport(0,0,f.width,f.height)};this.setClearColor=function(l,u){var t=new THREE.Color(l);b.clearColor(t.r,
-t.g,t.b,u)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(l,u){var t,k,q,x=0,y=0,F=0,B,D,I,N=this.lights,O=N.directional.colors,Q=N.directional.positions,T=N.point.colors,U=N.point.positions,ba=0,ca=0;t=0;for(k=u.length;t<k;t++){q=u[t];B=q.color;D=q.position;I=q.intensity;if(q instanceof THREE.AmbientLight){x+=B.r;y+=B.g;F+=B.b}else if(q instanceof THREE.DirectionalLight){O[ba*3]=B.r*I;O[ba*3+1]=B.g*I;O[ba*3+2]=B.b*I;Q[ba*3]=D.x;Q[ba*3+1]=D.y;Q[ba*
-3+2]=D.z;ba+=1}else if(q instanceof THREE.PointLight){T[ca*3]=B.r*I;T[ca*3+1]=B.g*I;T[ca*3+2]=B.b*I;U[ca*3]=D.x;U[ca*3+1]=D.y;U[ca*3+2]=D.z;ca+=1}}N.point.length=ca;N.directional.length=ba;N.ambient[0]=x;N.ambient[1]=y;N.ambient[2]=F};this.createParticleBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLParticleBuffer=b.createBuffer();l.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};
-this.createMeshBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLNormalBuffer=b.createBuffer();l.__webGLTangentBuffer=b.createBuffer();l.__webGLUVBuffer=b.createBuffer();l.__webGLUV2Buffer=b.createBuffer();l.__webGLFaceBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(l){var u=l.vertices.length;l.__vertexArray=new Float32Array(u*3);l.__lineArray=new Uint16Array(u);l.__webGLLineCount=u};this.initParticleBuffers=function(l){var u=l.vertices.length;
-l.__vertexArray=new Float32Array(u*3);l.__colorArray=new Float32Array(u*3);l.__particleArray=new Uint16Array(u);l.__sortArray=[];l.__webGLParticleCount=u};this.initMeshBuffers=function(l,u){var t,k,q=0,x=0,y=0,F=u.geometry.faces,B=l.faces;t=0;for(k=B.length;t<k;t++){fi=B[t];face=F[fi];if(face instanceof THREE.Face3){q+=3;x+=1;y+=3}else if(face instanceof THREE.Face4){q+=4;x+=2;y+=4}}l.__vertexArray=new Float32Array(q*3);l.__normalArray=new Float32Array(q*3);l.__tangentArray=new Float32Array(q*4);
-l.__uvArray=new Float32Array(q*2);l.__uv2Array=new Float32Array(q*2);l.__faceArray=new Uint16Array(x*3);l.__lineArray=new Uint16Array(y*2);q=false;t=0;for(k=u.materials.length;t<k;t++){F=u.materials[t];if(F instanceof THREE.MeshFaceMaterial){F=0;for(B=l.materials.length;F<B;F++)if(l.materials[F]&&l.materials[F].shading!=undefined&&l.materials[F].shading==THREE.SmoothShading){q=true;break}}else if(F&&F.shading!=undefined&&F.shading==THREE.SmoothShading){q=true;break}if(q)break}l.__needsSmoothNormals=
-q;l.__webGLFaceCount=x*3;l.__webGLLineCount=y*2};this.setMeshBuffers=function(l,u,t){var k,q,x,y,F,B,D,I,N,O,Q=0,T=0,U=0,ba=0,ca=0,S=0,K=0,Z=0,V=l.__vertexArray,P=l.__uvArray,W=l.__uv2Array,$=l.__normalArray,da=l.__tangentArray,ha=l.__faceArray,E=l.__lineArray,L=l.__needsSmoothNormals,J=u.geometry,X=J.__dirtyVertices,ea=J.__dirtyElements,ja=J.__dirtyUvs,ia=J.__dirtyNormals,qa=J.__dirtyTangents,la=J.vertices,ua=l.faces,ma=J.faces,sa=J.uvs,Ha=J.uvs2;u=0;for(k=ua.length;u<k;u++){q=ua[u];x=ma[q];B=sa[q];
-q=Ha[q];y=x.vertexNormals;F=x.normal;if(x instanceof THREE.Face3){if(X){D=la[x.a].position;I=la[x.b].position;N=la[x.c].position;V[T]=D.x;V[T+1]=D.y;V[T+2]=D.z;V[T+3]=I.x;V[T+4]=I.y;V[T+5]=I.z;V[T+6]=N.x;V[T+7]=N.y;V[T+8]=N.z;T+=9}if(qa&&J.hasTangents){D=la[x.a].tangent;I=la[x.b].tangent;N=la[x.c].tangent;da[K]=D.x;da[K+1]=D.y;da[K+2]=D.z;da[K+3]=D.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=N.x;da[K+9]=N.y;da[K+10]=N.z;da[K+11]=N.w;K+=12}if(ia)if(y.length==3&&L)for(x=0;x<3;x++){F=y[x];
-$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}else for(x=0;x<3;x++){$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}if(ja&&B)for(x=0;x<3;x++){y=B[x];P[U]=y.u;P[U+1]=y.v;U+=2}if(ja&&q)for(x=0;x<3;x++){B=q[x];W[ba]=B.u;W[ba+1]=B.v;ba+=2}if(ea){ha[ca]=Q;ha[ca+1]=Q+1;ha[ca+2]=Q+2;ca+=3;E[Z]=Q;E[Z+1]=Q+1;E[Z+2]=Q;E[Z+3]=Q+2;E[Z+4]=Q+1;E[Z+5]=Q+2;Z+=6;Q+=3}}else if(x instanceof THREE.Face4){if(X){D=la[x.a].position;I=la[x.b].position;N=la[x.c].position;O=la[x.d].position;V[T]=D.x;V[T+1]=D.y;V[T+2]=D.z;V[T+3]=I.x;V[T+4]=I.y;
-V[T+5]=I.z;V[T+6]=N.x;V[T+7]=N.y;V[T+8]=N.z;V[T+9]=O.x;V[T+10]=O.y;V[T+11]=O.z;T+=12}if(qa&&J.hasTangents){D=la[x.a].tangent;I=la[x.b].tangent;N=la[x.c].tangent;x=la[x.d].tangent;da[K]=D.x;da[K+1]=D.y;da[K+2]=D.z;da[K+3]=D.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=N.x;da[K+9]=N.y;da[K+10]=N.z;da[K+11]=N.w;da[K+12]=x.x;da[K+13]=x.y;da[K+14]=x.z;da[K+15]=x.w;K+=16}if(ia)if(y.length==4&&L)for(x=0;x<4;x++){F=y[x];$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}else for(x=0;x<4;x++){$[S]=F.x;$[S+1]=
-F.y;$[S+2]=F.z;S+=3}if(ja&&B)for(x=0;x<4;x++){y=B[x];P[U]=y.u;P[U+1]=y.v;U+=2}if(ja&&q)for(x=0;x<4;x++){B=q[x];W[ba]=B.u;W[ba+1]=B.v;ba+=2}if(ea){ha[ca]=Q;ha[ca+1]=Q+1;ha[ca+2]=Q+2;ha[ca+3]=Q;ha[ca+4]=Q+2;ha[ca+5]=Q+3;ca+=6;E[Z]=Q;E[Z+1]=Q+1;E[Z+2]=Q;E[Z+3]=Q+3;E[Z+4]=Q+1;E[Z+5]=Q+2;E[Z+6]=Q+2;E[Z+7]=Q+3;Z+=8;Q+=4}}}if(X){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,V,t)}if(ia){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,$,t)}if(qa&&
+case THREE.UnsignedShortType:return b.UNSIGNED_SHORT;case THREE.IntType:return b.INT;case THREE.UnsignedShortType:return b.UNSIGNED_INT;case THREE.FloatType:return b.FLOAT;case THREE.AlphaFormat:return b.ALPHA;case THREE.RGBFormat:return b.RGB;case THREE.RGBAFormat:return b.RGBA;case THREE.LuminanceFormat:return b.LUMINANCE;case THREE.LuminanceAlphaFormat:return b.LUMINANCE_ALPHA}return 0}var f=document.createElement("canvas"),b,g=null,j=null,h=new THREE.Matrix4,m,n=new Float32Array(16),y=new Float32Array(16),
+u=new Float32Array(16),o=new Float32Array(9),A=new Float32Array(16),C=new THREE.Matrix4,G=new THREE.Vector4,w=true,H=new THREE.Color(0),p=0;if(a){if(a.antialias!==undefined)w=a.antialias;a.clearColor!==undefined&&H.setHex(a.clearColor);if(a.clearAlpha!==undefined)p=a.clearAlpha}this.domElement=f;this.autoClear=true;(function(l,v,t){try{b=f.getContext("experimental-webgl",{antialias:l})}catch(k){console.log(k)}if(!b){alert("WebGL not supported");throw"cannot create webgl context";}b.clearColor(0,0,
+0,1);b.clearDepth(1);b.enable(b.DEPTH_TEST);b.depthFunc(b.LEQUAL);b.frontFace(b.CCW);b.cullFace(b.BACK);b.enable(b.CULL_FACE);b.enable(b.BLEND);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA);b.clearColor(v.r,v.g,v.b,t)})(w,H,p);this.context=b;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,v){f.width=l;f.height=v;b.viewport(0,0,f.width,f.height)};this.setClearColor=function(l,v){var t=new THREE.Color(l);b.clearColor(t.r,
+t.g,t.b,v)};this.clear=function(){b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT)};this.setupLights=function(l,v){var t,k,q,x=0,z=0,F=0,B,D,I,N=this.lights,O=N.directional.colors,Q=N.directional.positions,T=N.point.colors,U=N.point.positions,ba=0,ca=0;t=0;for(k=v.length;t<k;t++){q=v[t];B=q.color;D=q.position;I=q.intensity;if(q instanceof THREE.AmbientLight){x+=B.r;z+=B.g;F+=B.b}else if(q instanceof THREE.DirectionalLight){O[ba*3]=B.r*I;O[ba*3+1]=B.g*I;O[ba*3+2]=B.b*I;Q[ba*3]=D.x;Q[ba*3+1]=D.y;Q[ba*
+3+2]=D.z;ba+=1}else if(q instanceof THREE.PointLight){T[ca*3]=B.r*I;T[ca*3+1]=B.g*I;T[ca*3+2]=B.b*I;U[ca*3]=D.x;U[ca*3+1]=D.y;U[ca*3+2]=D.z;ca+=1}}N.point.length=ca;N.directional.length=ba;N.ambient[0]=x;N.ambient[1]=z;N.ambient[2]=F};this.createParticleBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLParticleBuffer=b.createBuffer();l.__webGLColorBuffer=b.createBuffer()};this.createLineBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};
+this.createMeshBuffers=function(l){l.__webGLVertexBuffer=b.createBuffer();l.__webGLNormalBuffer=b.createBuffer();l.__webGLTangentBuffer=b.createBuffer();l.__webGLUVBuffer=b.createBuffer();l.__webGLUV2Buffer=b.createBuffer();l.__webGLFaceBuffer=b.createBuffer();l.__webGLLineBuffer=b.createBuffer()};this.initLineBuffers=function(l){var v=l.vertices.length;l.__vertexArray=new Float32Array(v*3);l.__lineArray=new Uint16Array(v);l.__webGLLineCount=v};this.initParticleBuffers=function(l){var v=l.vertices.length;
+l.__vertexArray=new Float32Array(v*3);l.__colorArray=new Float32Array(v*3);l.__particleArray=new Uint16Array(v);l.__sortArray=[];l.__webGLParticleCount=v};this.initMeshBuffers=function(l,v){var t,k,q=0,x=0,z=0,F=v.geometry.faces,B=l.faces;t=0;for(k=B.length;t<k;t++){fi=B[t];face=F[fi];if(face instanceof THREE.Face3){q+=3;x+=1;z+=3}else if(face instanceof THREE.Face4){q+=4;x+=2;z+=4}}l.__vertexArray=new Float32Array(q*3);l.__normalArray=new Float32Array(q*3);l.__tangentArray=new Float32Array(q*4);
+l.__uvArray=new Float32Array(q*2);l.__uv2Array=new Float32Array(q*2);l.__faceArray=new Uint16Array(x*3);l.__lineArray=new Uint16Array(z*2);q=false;t=0;for(k=v.materials.length;t<k;t++){F=v.materials[t];if(F instanceof THREE.MeshFaceMaterial){F=0;for(B=l.materials.length;F<B;F++)if(l.materials[F]&&l.materials[F].shading!=undefined&&l.materials[F].shading==THREE.SmoothShading){q=true;break}}else if(F&&F.shading!=undefined&&F.shading==THREE.SmoothShading){q=true;break}if(q)break}l.__needsSmoothNormals=
+q;l.__webGLFaceCount=x*3;l.__webGLLineCount=z*2};this.setMeshBuffers=function(l,v,t){var k,q,x,z,F,B,D,I,N,O,Q=0,T=0,U=0,ba=0,ca=0,S=0,K=0,Z=0,V=l.__vertexArray,P=l.__uvArray,W=l.__uv2Array,$=l.__normalArray,da=l.__tangentArray,ha=l.__faceArray,E=l.__lineArray,L=l.__needsSmoothNormals,J=v.geometry,X=J.__dirtyVertices,ea=J.__dirtyElements,ja=J.__dirtyUvs,ia=J.__dirtyNormals,qa=J.__dirtyTangents,la=J.vertices,ua=l.faces,ma=J.faces,sa=J.uvs,Ha=J.uvs2;v=0;for(k=ua.length;v<k;v++){q=ua[v];x=ma[q];B=sa[q];
+q=Ha[q];z=x.vertexNormals;F=x.normal;if(x instanceof THREE.Face3){if(X){D=la[x.a].position;I=la[x.b].position;N=la[x.c].position;V[T]=D.x;V[T+1]=D.y;V[T+2]=D.z;V[T+3]=I.x;V[T+4]=I.y;V[T+5]=I.z;V[T+6]=N.x;V[T+7]=N.y;V[T+8]=N.z;T+=9}if(qa&&J.hasTangents){D=la[x.a].tangent;I=la[x.b].tangent;N=la[x.c].tangent;da[K]=D.x;da[K+1]=D.y;da[K+2]=D.z;da[K+3]=D.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=N.x;da[K+9]=N.y;da[K+10]=N.z;da[K+11]=N.w;K+=12}if(ia)if(z.length==3&&L)for(x=0;x<3;x++){F=z[x];
+$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}else for(x=0;x<3;x++){$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}if(ja&&B)for(x=0;x<3;x++){z=B[x];P[U]=z.u;P[U+1]=z.v;U+=2}if(ja&&q)for(x=0;x<3;x++){B=q[x];W[ba]=B.u;W[ba+1]=B.v;ba+=2}if(ea){ha[ca]=Q;ha[ca+1]=Q+1;ha[ca+2]=Q+2;ca+=3;E[Z]=Q;E[Z+1]=Q+1;E[Z+2]=Q;E[Z+3]=Q+2;E[Z+4]=Q+1;E[Z+5]=Q+2;Z+=6;Q+=3}}else if(x instanceof THREE.Face4){if(X){D=la[x.a].position;I=la[x.b].position;N=la[x.c].position;O=la[x.d].position;V[T]=D.x;V[T+1]=D.y;V[T+2]=D.z;V[T+3]=I.x;V[T+4]=I.y;
+V[T+5]=I.z;V[T+6]=N.x;V[T+7]=N.y;V[T+8]=N.z;V[T+9]=O.x;V[T+10]=O.y;V[T+11]=O.z;T+=12}if(qa&&J.hasTangents){D=la[x.a].tangent;I=la[x.b].tangent;N=la[x.c].tangent;x=la[x.d].tangent;da[K]=D.x;da[K+1]=D.y;da[K+2]=D.z;da[K+3]=D.w;da[K+4]=I.x;da[K+5]=I.y;da[K+6]=I.z;da[K+7]=I.w;da[K+8]=N.x;da[K+9]=N.y;da[K+10]=N.z;da[K+11]=N.w;da[K+12]=x.x;da[K+13]=x.y;da[K+14]=x.z;da[K+15]=x.w;K+=16}if(ia)if(z.length==4&&L)for(x=0;x<4;x++){F=z[x];$[S]=F.x;$[S+1]=F.y;$[S+2]=F.z;S+=3}else for(x=0;x<4;x++){$[S]=F.x;$[S+1]=
+F.y;$[S+2]=F.z;S+=3}if(ja&&B)for(x=0;x<4;x++){z=B[x];P[U]=z.u;P[U+1]=z.v;U+=2}if(ja&&q)for(x=0;x<4;x++){B=q[x];W[ba]=B.u;W[ba+1]=B.v;ba+=2}if(ea){ha[ca]=Q;ha[ca+1]=Q+1;ha[ca+2]=Q+2;ha[ca+3]=Q;ha[ca+4]=Q+2;ha[ca+5]=Q+3;ca+=6;E[Z]=Q;E[Z+1]=Q+1;E[Z+2]=Q;E[Z+3]=Q+3;E[Z+4]=Q+1;E[Z+5]=Q+2;E[Z+6]=Q+2;E[Z+7]=Q+3;Z+=8;Q+=4}}}if(X){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,V,t)}if(ia){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,$,t)}if(qa&&
 J.hasTangents){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLTangentBuffer);b.bufferData(b.ARRAY_BUFFER,da,t)}if(ja&&U>0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUVBuffer);b.bufferData(b.ARRAY_BUFFER,P,t)}if(ja&&ba>0){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLUV2Buffer);b.bufferData(b.ARRAY_BUFFER,W,t)}if(ea){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,ha,t);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,E,t)}};this.setLineBuffers=
-function(l,u){var t,k,q,x=l.vertices,y=x.length,F=l.__vertexArray,B=l.__lineArray,D=l.__dirtyElements;if(l.__dirtyVertices){for(t=0;t<y;t++){k=x[t].position;q=t*3;F[q]=k.x;F[q+1]=k.y;F[q+2]=k.z}b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,F,u)}if(D){for(t=0;t<y;t++)B[t]=t;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,B,u)}};this.setParticleBuffers=function(l,u,t,k){var q,x,y;x=l.vertices;var F=x.length,B=l.colors,D=B.length,
-I=l.__vertexArray,N=l.__particleArray,O=l.__colorArray,Q=l.__sortArray,T=l.__dirtyVertices,U=l.__dirtyElements,ba=l.__dirtyColors;if(t.sortParticles){C.multiply(k.projectionMatrix,k.matrix);C.multiplySelf(t.matrix);for(q=0;q<F;q++){y=x[q].position;G.copy(y);C.multiplyVector3(G);Q[q]=[G.z,q]}Q.sort(function(ca,S){return S[0]-ca[0]});for(q=0;q<F;q++){y=x[Q[q][1]].position;k=q*3;I[k]=y.x;I[k+1]=y.y;I[k+2]=y.z}for(x=0;x<D;x++){k=x*3;color=B[Q[x][1]];O[k]=color.r;O[k+1]=color.g;O[k+2]=color.b}}else{if(T)for(q=
-0;q<F;q++){y=x[q].position;k=q*3;I[k]=y.x;I[k+1]=y.y;I[k+2]=y.z}if(ba)for(x=0;x<D;x++){color=B[x];k=x*3;O[k]=color.r;O[k+1]=color.g;O[k+2]=color.b}}if(U){for(q=0;q<F;q++)N[q]=q;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,N,u)}if(T||t.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,I,u)}if(ba||t.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,O,u)}};this.initMaterial=
-function(l,u,t){if(!l.program){var k,q;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&
-c(l,THREE.ShaderLib.particle_basic);var x,y,F,B;q=F=B=0;for(x=u.length;q<x;q++){y=u[q];y instanceof THREE.DirectionalLight&&F++;y instanceof THREE.PointLight&&B++}if(B+F<=4){u=F;B=B}else{u=Math.ceil(4*F/(B+F));B=4-u}q={directional:u,point:B};B=l.fragment_shader;u=l.vertex_shader;x={fog:t,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,maxDirLights:q.directional,maxPointLights:q.point};t=b.createProgram();q=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+
+function(l,v){var t,k,q,x=l.vertices,z=x.length,F=l.__vertexArray,B=l.__lineArray,D=l.__dirtyElements;if(l.__dirtyVertices){for(t=0;t<z;t++){k=x[t].position;q=t*3;F[q]=k.x;F[q+1]=k.y;F[q+2]=k.z}b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,F,v)}if(D){for(t=0;t<z;t++)B[t]=t;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,B,v)}};this.setParticleBuffers=function(l,v,t,k){var q,x,z;x=l.vertices;var F=x.length,B=l.colors,D=B.length,
+I=l.__vertexArray,N=l.__particleArray,O=l.__colorArray,Q=l.__sortArray,T=l.__dirtyVertices,U=l.__dirtyElements,ba=l.__dirtyColors;if(t.sortParticles){C.multiply(k.projectionMatrix,k.matrix);C.multiplySelf(t.matrix);for(q=0;q<F;q++){z=x[q].position;G.copy(z);C.multiplyVector3(G);Q[q]=[G.z,q]}Q.sort(function(ca,S){return S[0]-ca[0]});for(q=0;q<F;q++){z=x[Q[q][1]].position;k=q*3;I[k]=z.x;I[k+1]=z.y;I[k+2]=z.z}for(x=0;x<D;x++){k=x*3;color=B[Q[x][1]];O[k]=color.r;O[k+1]=color.g;O[k+2]=color.b}}else{if(T)for(q=
+0;q<F;q++){z=x[q].position;k=q*3;I[k]=z.x;I[k+1]=z.y;I[k+2]=z.z}if(ba)for(x=0;x<D;x++){color=B[x];k=x*3;O[k]=color.r;O[k+1]=color.g;O[k+2]=color.b}}if(U){for(q=0;q<F;q++)N[q]=q;b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,l.__webGLParticleBuffer);b.bufferData(b.ELEMENT_ARRAY_BUFFER,N,v)}if(T||t.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,I,v)}if(ba||t.sortParticles){b.bindBuffer(b.ARRAY_BUFFER,l.__webGLColorBuffer);b.bufferData(b.ARRAY_BUFFER,O,v)}};this.initMaterial=
+function(l,v,t){if(!l.program){var k,q;if(l instanceof THREE.MeshDepthMaterial)c(l,THREE.ShaderLib.depth);else if(l instanceof THREE.MeshNormalMaterial)c(l,THREE.ShaderLib.normal);else if(l instanceof THREE.MeshBasicMaterial)c(l,THREE.ShaderLib.basic);else if(l instanceof THREE.MeshLambertMaterial)c(l,THREE.ShaderLib.lambert);else if(l instanceof THREE.MeshPhongMaterial)c(l,THREE.ShaderLib.phong);else if(l instanceof THREE.LineBasicMaterial)c(l,THREE.ShaderLib.basic);else l instanceof THREE.ParticleBasicMaterial&&
+c(l,THREE.ShaderLib.particle_basic);var x,z,F,B;q=F=B=0;for(x=v.length;q<x;q++){z=v[q];z instanceof THREE.DirectionalLight&&F++;z instanceof THREE.PointLight&&B++}if(B+F<=4){v=F;B=B}else{v=Math.ceil(4*F/(B+F));B=4-v}q={directional:v,point:B};B=l.fragment_shader;v=l.vertex_shader;x={fog:t,map:l.map,env_map:l.env_map,light_map:l.light_map,vertex_colors:l.vertex_colors,maxDirLights:q.directional,maxPointLights:q.point};t=b.createProgram();q=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+
 x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,x.fog?"#define USE_FOG":"",x.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",x.map?"#define USE_MAP":"",x.env_map?"#define USE_ENVMAP":"",x.light_map?"#define USE_LIGHTMAP":"",x.vertex_colors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");x=[b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+
 x.maxPointLights,x.map?"#define USE_MAP":"",x.env_map?"#define USE_ENVMAP":"",x.light_map?"#define USE_LIGHTMAP":"",x.vertex_colors?"#define USE_COLOR":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\n"].join("\n");b.attachShader(t,d("fragment",q+B));b.attachShader(t,
-d("vertex",x+u));b.linkProgram(t);b.getProgramParameter(t,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(t,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");t.uniforms={};t.attributes={};l.program=t;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(k in l.uniforms)t.push(k);k=l.program;B=0;for(u=t.length;B<u;B++){q=t[B];k.uniforms[q]=b.getUniformLocation(k,q)}l=l.program;k=["position","normal",
-"uv","uv2","tangent","color"];t=0;for(B=k.length;t<B;t++){u=k[t];l.attributes[u]=b.getAttribLocation(l,u)}}};this.setProgram=function(l,u,t,k){this.initMaterial(k,u,t);var q=k.program;if(q!=g){b.useProgram(q);g=q}this.loadCamera(q,l);this.loadMatrices(q);if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial){this.setupLights(q,u);u=this.lights;k.uniforms.enableLighting.value=u.directional.length+u.point.length;k.uniforms.ambientLightColor.value=u.ambient;k.uniforms.directionalLightColor.value=
-u.directional.colors;k.uniforms.directionalLightDirection.value=u.directional.positions;k.uniforms.pointLightColor.value=u.point.colors;k.uniforms.pointLightPosition.value=u.point.positions}if(k instanceof THREE.MeshBasicMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshPhongMaterial){k.uniforms.diffuse.value.setRGB(k.color.r*k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);k.uniforms.opacity.value=k.opacity;k.uniforms.map.texture=k.map;k.uniforms.light_map.texture=k.light_map;
+d("vertex",x+v));b.linkProgram(t);b.getProgramParameter(t,b.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+b.getProgramParameter(t,b.VALIDATE_STATUS)+", gl error ["+b.getError()+"]");t.uniforms={};t.attributes={};l.program=t;t=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition"];for(k in l.uniforms)t.push(k);k=l.program;B=0;for(v=t.length;B<v;B++){q=t[B];k.uniforms[q]=b.getUniformLocation(k,q)}l=l.program;k=["position","normal",
+"uv","uv2","tangent","color"];t=0;for(B=k.length;t<B;t++){v=k[t];l.attributes[v]=b.getAttribLocation(l,v)}}};this.setProgram=function(l,v,t,k){this.initMaterial(k,v,t);var q=k.program;if(q!=g){b.useProgram(q);g=q}this.loadCamera(q,l);this.loadMatrices(q);if(k instanceof THREE.MeshPhongMaterial||k instanceof THREE.MeshLambertMaterial){this.setupLights(q,v);v=this.lights;k.uniforms.enableLighting.value=v.directional.length+v.point.length;k.uniforms.ambientLightColor.value=v.ambient;k.uniforms.directionalLightColor.value=
+v.directional.colors;k.uniforms.directionalLightDirection.value=v.directional.positions;k.uniforms.pointLightColor.value=v.point.colors;k.uniforms.pointLightPosition.value=v.point.positions}if(k instanceof THREE.MeshBasicMaterial||k instanceof THREE.MeshLambertMaterial||k instanceof THREE.MeshPhongMaterial){k.uniforms.diffuse.value.setRGB(k.color.r*k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);k.uniforms.opacity.value=k.opacity;k.uniforms.map.texture=k.map;k.uniforms.light_map.texture=k.light_map;
 k.uniforms.env_map.texture=k.env_map;k.uniforms.reflectivity.value=k.reflectivity;k.uniforms.refraction_ratio.value=k.refraction_ratio;k.uniforms.combine.value=k.combine;k.uniforms.useRefract.value=k.env_map&&k.env_map.mapping instanceof THREE.CubeRefractionMapping;if(t){k.uniforms.fogColor.value.setHex(t.color.hex);if(t instanceof THREE.Fog){k.uniforms.fogNear.value=t.near;k.uniforms.fogFar.value=t.far}else if(t instanceof THREE.FogExp2)k.uniforms.fogDensity.value=t.density}}if(k instanceof THREE.LineBasicMaterial){k.uniforms.diffuse.value.setRGB(k.color.r*
 k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);k.uniforms.opacity.value=k.opacity;if(t){k.uniforms.fogColor.value.setHex(t.color.hex);if(t instanceof THREE.Fog){k.uniforms.fogNear.value=t.near;k.uniforms.fogFar.value=t.far}else if(t instanceof THREE.FogExp2)k.uniforms.fogDensity.value=t.density}}if(k instanceof THREE.ParticleBasicMaterial){k.uniforms.psColor.value.setRGB(k.color.r*k.opacity,k.color.g*k.opacity,k.color.b*k.opacity);k.uniforms.opacity.value=k.opacity;k.uniforms.size.value=k.size;
 k.uniforms.map.texture=k.map;if(t){k.uniforms.fogColor.value.setHex(t.color.hex);if(t instanceof THREE.Fog){k.uniforms.fogNear.value=t.near;k.uniforms.fogFar.value=t.far}else if(t instanceof THREE.FogExp2)k.uniforms.fogDensity.value=t.density}}if(k instanceof THREE.MeshPhongMaterial){k.uniforms.ambient.value.setRGB(k.ambient.r,k.ambient.g,k.ambient.b);k.uniforms.specular.value.setRGB(k.specular.r,k.specular.g,k.specular.b);k.uniforms.shininess.value=k.shininess}if(k instanceof THREE.MeshDepthMaterial){k.uniforms.mNear.value=
-l.near;k.uniforms.mFar.value=l.far}l=k.uniforms;var x,y;for(x in l)if(y=q.uniforms[x]){k=l[x];u=k.type;t=k.value;if(u=="i")b.uniform1i(y,t);else if(u=="f")b.uniform1f(y,t);else if(u=="fv1")b.uniform1fv(y,t);else if(u=="fv")b.uniform3fv(y,t);else if(u=="v2")b.uniform2f(y,t.x,t.y);else if(u=="v3")b.uniform3f(y,t.x,t.y,t.z);else if(u=="c")b.uniform3f(y,t.r,t.g,t.b);else if(u=="t"){b.uniform1i(y,t);if(k=k.texture)if(k.image instanceof Array&&k.image.length==6){k=k;t=t;if(k.image.length==6){if(!k.image.__webGLTextureCube&&
-!k.image.__cubeMapInitialized&&k.image.loadCount==6){k.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(u=0;u<6;++u)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
-u,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image[u]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);k.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+t);b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube)}}else{k=k;t=t;if(!k.__webGLTexture&&k.image.loaded){k.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,k.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(k.wrap_s));
-b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(k.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(k.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(k.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+t);b.bindTexture(b.TEXTURE_2D,k.__webGLTexture)}}}return q};this.renderBuffer=function(l,u,t,k,q,x){l=this.setProgram(l,u,t,k,x).attributes;b.bindBuffer(b.ARRAY_BUFFER,q.__webGLVertexBuffer);b.vertexAttribPointer(l.position,
+l.near;k.uniforms.mFar.value=l.far}l=k.uniforms;var x,z;for(x in l)if(z=q.uniforms[x]){k=l[x];v=k.type;t=k.value;if(v=="i")b.uniform1i(z,t);else if(v=="f")b.uniform1f(z,t);else if(v=="fv1")b.uniform1fv(z,t);else if(v=="fv")b.uniform3fv(z,t);else if(v=="v2")b.uniform2f(z,t.x,t.y);else if(v=="v3")b.uniform3f(z,t.x,t.y,t.z);else if(v=="c")b.uniform3f(z,t.r,t.g,t.b);else if(v=="t"){b.uniform1i(z,t);if(k=k.texture)if(k.image instanceof Array&&k.image.length==6){k=k;t=t;if(k.image.length==6){if(!k.image.__webGLTextureCube&&
+!k.image.__cubeMapInitialized&&k.image.loadCount==6){k.image.__webGLTextureCube=b.createTexture();b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MAG_FILTER,b.LINEAR);b.texParameteri(b.TEXTURE_CUBE_MAP,b.TEXTURE_MIN_FILTER,b.LINEAR_MIPMAP_LINEAR);for(v=0;v<6;++v)b.texImage2D(b.TEXTURE_CUBE_MAP_POSITIVE_X+
+v,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image[v]);b.generateMipmap(b.TEXTURE_CUBE_MAP);b.bindTexture(b.TEXTURE_CUBE_MAP,null);k.image.__cubeMapInitialized=true}b.activeTexture(b.TEXTURE0+t);b.bindTexture(b.TEXTURE_CUBE_MAP,k.image.__webGLTextureCube)}}else{k=k;t=t;if(!k.__webGLTexture&&k.image.loaded){k.__webGLTexture=b.createTexture();b.bindTexture(b.TEXTURE_2D,k.__webGLTexture);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,b.RGBA,b.UNSIGNED_BYTE,k.image);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(k.wrap_s));
+b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(k.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,e(k.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(k.min_filter));b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}b.activeTexture(b.TEXTURE0+t);b.bindTexture(b.TEXTURE_2D,k.__webGLTexture)}}}return q};this.renderBuffer=function(l,v,t,k,q,x){l=this.setProgram(l,v,t,k,x).attributes;b.bindBuffer(b.ARRAY_BUFFER,q.__webGLVertexBuffer);b.vertexAttribPointer(l.position,
 3,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.position);if(l.color>=0){b.bindBuffer(b.ARRAY_BUFFER,q.__webGLColorBuffer);b.vertexAttribPointer(l.color,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.color)}if(l.normal>=0){b.bindBuffer(b.ARRAY_BUFFER,q.__webGLNormalBuffer);b.vertexAttribPointer(l.normal,3,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.normal)}if(l.tangent>=0){b.bindBuffer(b.ARRAY_BUFFER,q.__webGLTangentBuffer);b.vertexAttribPointer(l.tangent,4,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.tangent)}if(l.uv>=
 0)if(q.__webGLUVBuffer){b.bindBuffer(b.ARRAY_BUFFER,q.__webGLUVBuffer);b.vertexAttribPointer(l.uv,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.uv)}else b.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(q.__webGLUV2Buffer){b.bindBuffer(b.ARRAY_BUFFER,q.__webGLUV2Buffer);b.vertexAttribPointer(l.uv2,2,b.FLOAT,false,0,0);b.enableVertexAttribArray(l.uv2)}else b.disableVertexAttribArray(l.uv2);if(k.wireframe||k instanceof THREE.LineBasicMaterial){l=k.wireframe_linewidth!==undefined?k.wireframe_linewidth:
 k.linewidth!==undefined?k.linewidth:1;k=k instanceof THREE.LineBasicMaterial&&x.type==THREE.LineStrip?b.LINE_STRIP:b.LINES;b.lineWidth(l);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);b.drawElements(k,q.__webGLLineCount,b.UNSIGNED_SHORT,0)}else if(k instanceof THREE.ParticleBasicMaterial){b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,q.__webGLParticleBuffer);b.drawElements(b.POINTS,q.__webGLParticleCount,b.UNSIGNED_SHORT,0)}else{b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);b.drawElements(b.TRIANGLES,
-q.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(l,u,t,k,q,x,y){var F,B,D,I,N;D=0;for(I=k.materials.length;D<I;D++){F=k.materials[D];if(F instanceof THREE.MeshFaceMaterial){F=0;for(B=q.materials.length;F<B;F++)if((N=q.materials[F])&&N.blending==x&&N.opacity<1==y){this.setBlending(N.blending);this.renderBuffer(l,u,t,N,q,k)}}else if((N=F)&&N.blending==x&&N.opacity<1==y){this.setBlending(N.blending);this.renderBuffer(l,u,t,N,q,k)}}};this.renderPassImmediate=function(l,u,t,k,q,x){var y,
-F,B,D;y=0;for(F=k.materials.length;y<F;y++)if((B=k.materials[y])&&B.blending==q&&B.opacity<1==x){this.setBlending(B.blending);D=this.setProgram(l,u,t,B,k);k.render(function(I){var N=D;if(!I.__webGLVertexBuffer)I.__webGLVertexBuffer=b.createBuffer();if(!I.__webGLNormalBuffer)I.__webGLNormalBuffer=b.createBuffer();if(I.hasPos){b.bindBuffer(b.ARRAY_BUFFER,I.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,I.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(N.attributes.position);b.vertexAttribPointer(N.attributes.position,
-3,b.FLOAT,false,0,0)}if(I.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,I.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,I.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(N.attributes.normal);b.vertexAttribPointer(N.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,I.count);I.count=0})}};this.render=function(l,u,t,k){var q,x,y,F=l.lights,B=l.fog;u.autoUpdateMatrix&&u.updateMatrix();n.set(u.matrix.flatten());v.set(u.projectionMatrix.flatten());this.initWebGLObjects(l,u);k=k!==undefined?
+q.__webGLFaceCount,b.UNSIGNED_SHORT,0)}};this.renderPass=function(l,v,t,k,q,x,z){var F,B,D,I,N;D=0;for(I=k.materials.length;D<I;D++){F=k.materials[D];if(F instanceof THREE.MeshFaceMaterial){F=0;for(B=q.materials.length;F<B;F++)if((N=q.materials[F])&&N.blending==x&&N.opacity<1==z){this.setBlending(N.blending);this.renderBuffer(l,v,t,N,q,k)}}else if((N=F)&&N.blending==x&&N.opacity<1==z){this.setBlending(N.blending);this.renderBuffer(l,v,t,N,q,k)}}};this.renderPassImmediate=function(l,v,t,k,q,x){var z,
+F,B,D;z=0;for(F=k.materials.length;z<F;z++)if((B=k.materials[z])&&B.blending==q&&B.opacity<1==x){this.setBlending(B.blending);D=this.setProgram(l,v,t,B,k);k.render(function(I){var N=D;if(!I.__webGLVertexBuffer)I.__webGLVertexBuffer=b.createBuffer();if(!I.__webGLNormalBuffer)I.__webGLNormalBuffer=b.createBuffer();if(I.hasPos){b.bindBuffer(b.ARRAY_BUFFER,I.__webGLVertexBuffer);b.bufferData(b.ARRAY_BUFFER,I.positionArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(N.attributes.position);b.vertexAttribPointer(N.attributes.position,
+3,b.FLOAT,false,0,0)}if(I.hasNormal){b.bindBuffer(b.ARRAY_BUFFER,I.__webGLNormalBuffer);b.bufferData(b.ARRAY_BUFFER,I.normalArray,b.DYNAMIC_DRAW);b.enableVertexAttribArray(N.attributes.normal);b.vertexAttribPointer(N.attributes.normal,3,b.FLOAT,false,0,0)}b.drawArrays(b.TRIANGLES,0,I.count);I.count=0})}};this.render=function(l,v,t,k){var q,x,z,F=l.lights,B=l.fog;v.autoUpdateMatrix&&v.updateMatrix();n.set(v.matrix.flatten());u.set(v.projectionMatrix.flatten());this.initWebGLObjects(l,v);k=k!==undefined?
 k:true;if(t&&!t.__webGLFramebuffer){t.__webGLFramebuffer=b.createFramebuffer();t.__webGLRenderbuffer=b.createRenderbuffer();t.__webGLTexture=b.createTexture();b.bindRenderbuffer(b.RENDERBUFFER,t.__webGLRenderbuffer);b.renderbufferStorage(b.RENDERBUFFER,b.DEPTH_COMPONENT16,t.width,t.height);b.bindTexture(b.TEXTURE_2D,t.__webGLTexture);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,e(t.wrap_s));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,e(t.wrap_t));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,
 e(t.mag_filter));b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,e(t.min_filter));b.texImage2D(b.TEXTURE_2D,0,e(t.format),t.width,t.height,0,e(t.format),e(t.type),null);b.bindFramebuffer(b.FRAMEBUFFER,t.__webGLFramebuffer);b.framebufferTexture2D(b.FRAMEBUFFER,b.COLOR_ATTACHMENT0,b.TEXTURE_2D,t.__webGLTexture,0);b.framebufferRenderbuffer(b.FRAMEBUFFER,b.DEPTH_ATTACHMENT,b.RENDERBUFFER,t.__webGLRenderbuffer);b.bindTexture(b.TEXTURE_2D,null);b.bindRenderbuffer(b.RENDERBUFFER,null);b.bindFramebuffer(b.FRAMEBUFFER,
-null)}if(t){q=t.__webGLFramebuffer;y=t.width;x=t.height}else{q=null;y=f.width;x=f.height}if(q!=j){b.bindFramebuffer(b.FRAMEBUFFER,q);b.viewport(0,0,y,x);k&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);j=q}this.autoClear&&this.clear();q=l.__webGLObjects.length;for(k=0;k<q;k++){x=l.__webGLObjects[k];y=x.object;if(y.visible){y.autoUpdateMatrix&&y.updateMatrix();if(y.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);y.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(k=0;k<q;k++){x=l.__webGLObjects[k];
-y=x.object;x=x.buffer;if(y.visible){y.autoUpdateMatrix&&y.updateMatrix();this.setupMatrices(y,u);this.renderPass(u,F,B,y,x,THREE.NormalBlending,false)}}for(k=0;k<l.__webGLObjectsImmediate.length;k++){x=l.__webGLObjectsImmediate[k];y=x.object;if(y.visible){this.setupMatrices(y,u);this.renderPassImmediate(u,F,B,y,THREE.NormalBlending,false)}}for(k=0;k<q;k++){x=l.__webGLObjects[k];y=x.object;x=x.buffer;if(y.visible){this.setupMatrices(y,u);this.renderPass(u,F,B,y,x,THREE.AdditiveBlending,false);this.renderPass(u,
-F,B,y,x,THREE.SubtractiveBlending,false);this.renderPass(u,F,B,y,x,THREE.AdditiveBlending,true);this.renderPass(u,F,B,y,x,THREE.SubtractiveBlending,true);this.renderPass(u,F,B,y,x,THREE.NormalBlending,true);this.renderPass(u,F,B,y,x,THREE.BillboardBlending,false)}}if(t&&t.min_filter!==THREE.NearestFilter&&t.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,t.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(l,u){function t(N,
-O,Q,T){if(N[O]==undefined){l.__webGLObjects.push({buffer:Q,object:T});N[O]=1}}function k(N,O,Q){if(N[O]==undefined){l.__webGLObjectsImmediate.push({object:Q});N[O]=1}}var q,x,y,F,B,D,I;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}q=0;for(x=l.objects.length;q<x;q++){y=l.objects[q];B=y.geometry;if(l.__webGLObjectsMap[y.id]==undefined)l.__webGLObjectsMap[y.id]={};I=l.__webGLObjectsMap[y.id];if(y instanceof THREE.Mesh){for(F in B.geometryChunks){D=B.geometryChunks[F];
-if(!D.__webGLVertexBuffer){this.createMeshBuffers(D);this.initMeshBuffers(D,y);B.__dirtyVertices=true;B.__dirtyElements=true;B.__dirtyUvs=true;B.__dirtyNormals=true;B.__dirtyTangents=true}if(B.__dirtyVertices||B.__dirtyElements||B.__dirtyUvs)this.setMeshBuffers(D,y,b.DYNAMIC_DRAW);t(I,F,D,y)}B.__dirtyVertices=false;B.__dirtyElements=false;B.__dirtyUvs=false;B.__dirtyNormals=false;B.__dirtyTangents=false}else if(y instanceof THREE.Line){if(!B.__webGLVertexBuffer){this.createLineBuffers(B);this.initLineBuffers(B);
-B.__dirtyVertices=true;B.__dirtyElements=true}B.__dirtyVertices&&this.setLineBuffers(B,b.DYNAMIC_DRAW);t(I,0,B,y);B.__dirtyVertices=false;B.__dirtyElements=false}else if(y instanceof THREE.ParticleSystem){if(!B.__webGLVertexBuffer){this.createParticleBuffers(B);this.initParticleBuffers(B);B.__dirtyVertices=true;B.__dirtyColors=true;B.__dirtyElements=true}if(B.__dirtyVertices||B.__dirtyColors||y.sortParticles)this.setParticleBuffers(B,b.DYNAMIC_DRAW,y,u);t(I,0,B,y);B.__dirtyVertices=false;B.__dirtyColors=
-false;B.__dirtyElements=false}else y instanceof THREE.MarchingCubes&&k(I,0,y)}};this.removeObject=function(l,u){var t,k;for(t=l.__webGLObjects.length-1;t>=0;t--){k=l.__webGLObjects[t].object;u==k&&l.__webGLObjects.splice(t,1)}};this.setupMatrices=function(l,u){h.multiply(u.matrix,l.matrix);A.set(h.flatten());m=THREE.Matrix4.makeInvert3x3(h).transpose();o.set(m.m);z.set(l.matrix.flatten())};this.loadMatrices=function(l){b.uniformMatrix4fv(l.uniforms.viewMatrix,false,n);b.uniformMatrix4fv(l.uniforms.modelViewMatrix,
-false,A);b.uniformMatrix4fv(l.uniforms.projectionMatrix,false,v);b.uniformMatrix3fv(l.uniforms.normalMatrix,false,o);b.uniformMatrix4fv(l.uniforms.objectMatrix,false,z)};this.loadCamera=function(l,u){b.uniform3f(l.uniforms.cameraPosition,u.position.x,u.position.y,u.position.z)};this.setBlending=function(l){switch(l){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
-b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(l,u){if(l){!u||u=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(l=="back")b.cullFace(b.BACK);else l=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+null)}if(t){q=t.__webGLFramebuffer;z=t.width;x=t.height}else{q=null;z=f.width;x=f.height}if(q!=j){b.bindFramebuffer(b.FRAMEBUFFER,q);b.viewport(0,0,z,x);k&&b.clear(b.COLOR_BUFFER_BIT|b.DEPTH_BUFFER_BIT);j=q}this.autoClear&&this.clear();q=l.__webGLObjects.length;for(k=0;k<q;k++){x=l.__webGLObjects[k];z=x.object;if(z.visible){z.autoUpdateMatrix&&z.updateMatrix();if(z.doubleSided)b.disable(b.CULL_FACE);else{b.enable(b.CULL_FACE);z.flipSided?b.frontFace(b.CW):b.frontFace(b.CCW)}}}for(k=0;k<q;k++){x=l.__webGLObjects[k];
+z=x.object;x=x.buffer;if(z.visible){z.autoUpdateMatrix&&z.updateMatrix();this.setupMatrices(z,v);this.renderPass(v,F,B,z,x,THREE.NormalBlending,false)}}for(k=0;k<l.__webGLObjectsImmediate.length;k++){x=l.__webGLObjectsImmediate[k];z=x.object;if(z.visible){this.setupMatrices(z,v);this.renderPassImmediate(v,F,B,z,THREE.NormalBlending,false)}}for(k=0;k<q;k++){x=l.__webGLObjects[k];z=x.object;x=x.buffer;if(z.visible){this.setupMatrices(z,v);this.renderPass(v,F,B,z,x,THREE.AdditiveBlending,false);this.renderPass(v,
+F,B,z,x,THREE.SubtractiveBlending,false);this.renderPass(v,F,B,z,x,THREE.AdditiveBlending,true);this.renderPass(v,F,B,z,x,THREE.SubtractiveBlending,true);this.renderPass(v,F,B,z,x,THREE.NormalBlending,true);this.renderPass(v,F,B,z,x,THREE.BillboardBlending,false)}}if(t&&t.min_filter!==THREE.NearestFilter&&t.min_filter!==THREE.LinearFilter){b.bindTexture(b.TEXTURE_2D,t.__webGLTexture);b.generateMipmap(b.TEXTURE_2D);b.bindTexture(b.TEXTURE_2D,null)}};this.initWebGLObjects=function(l,v){function t(N,
+O,Q,T){if(N[O]==undefined){l.__webGLObjects.push({buffer:Q,object:T});N[O]=1}}function k(N,O,Q){if(N[O]==undefined){l.__webGLObjectsImmediate.push({object:Q});N[O]=1}}var q,x,z,F,B,D,I;if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}q=0;for(x=l.objects.length;q<x;q++){z=l.objects[q];B=z.geometry;if(l.__webGLObjectsMap[z.id]==undefined)l.__webGLObjectsMap[z.id]={};I=l.__webGLObjectsMap[z.id];if(z instanceof THREE.Mesh){for(F in B.geometryChunks){D=B.geometryChunks[F];
+if(!D.__webGLVertexBuffer){this.createMeshBuffers(D);this.initMeshBuffers(D,z);B.__dirtyVertices=true;B.__dirtyElements=true;B.__dirtyUvs=true;B.__dirtyNormals=true;B.__dirtyTangents=true}if(B.__dirtyVertices||B.__dirtyElements||B.__dirtyUvs)this.setMeshBuffers(D,z,b.DYNAMIC_DRAW);t(I,F,D,z)}B.__dirtyVertices=false;B.__dirtyElements=false;B.__dirtyUvs=false;B.__dirtyNormals=false;B.__dirtyTangents=false}else if(z instanceof THREE.Line){if(!B.__webGLVertexBuffer){this.createLineBuffers(B);this.initLineBuffers(B);
+B.__dirtyVertices=true;B.__dirtyElements=true}B.__dirtyVertices&&this.setLineBuffers(B,b.DYNAMIC_DRAW);t(I,0,B,z);B.__dirtyVertices=false;B.__dirtyElements=false}else if(z instanceof THREE.ParticleSystem){if(!B.__webGLVertexBuffer){this.createParticleBuffers(B);this.initParticleBuffers(B);B.__dirtyVertices=true;B.__dirtyColors=true;B.__dirtyElements=true}if(B.__dirtyVertices||B.__dirtyColors||z.sortParticles)this.setParticleBuffers(B,b.DYNAMIC_DRAW,z,v);t(I,0,B,z);B.__dirtyVertices=false;B.__dirtyColors=
+false;B.__dirtyElements=false}else z instanceof THREE.MarchingCubes&&k(I,0,z)}};this.removeObject=function(l,v){var t,k;for(t=l.__webGLObjects.length-1;t>=0;t--){k=l.__webGLObjects[t].object;v==k&&l.__webGLObjects.splice(t,1)}};this.setupMatrices=function(l,v){h.multiply(v.matrix,l.matrix);y.set(h.flatten());m=THREE.Matrix4.makeInvert3x3(h).transpose();o.set(m.m);A.set(l.matrix.flatten())};this.loadMatrices=function(l){b.uniformMatrix4fv(l.uniforms.viewMatrix,false,n);b.uniformMatrix4fv(l.uniforms.modelViewMatrix,
+false,y);b.uniformMatrix4fv(l.uniforms.projectionMatrix,false,u);b.uniformMatrix3fv(l.uniforms.normalMatrix,false,o);b.uniformMatrix4fv(l.uniforms.objectMatrix,false,A)};this.loadCamera=function(l,v){b.uniform3f(l.uniforms.cameraPosition,v.position.x,v.position.y,v.position.z)};this.setBlending=function(l){switch(l){case THREE.AdditiveBlending:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE);break;case THREE.SubtractiveBlending:b.blendFunc(b.DST_COLOR,b.ZERO);break;case THREE.BillboardBlending:b.blendEquation(b.FUNC_ADD);
+b.blendFunc(b.SRC_ALPHA,b.ONE_MINUS_SRC_ALPHA);break;default:b.blendEquation(b.FUNC_ADD);b.blendFunc(b.ONE,b.ONE_MINUS_SRC_ALPHA)}};this.setFaceCulling=function(l,v){if(l){!v||v=="ccw"?b.frontFace(b.CCW):b.frontFace(b.CW);if(l=="back")b.cullFace(b.BACK);else l=="front"?b.cullFace(b.FRONT):b.cullFace(b.FRONT_AND_BACK);b.enable(b.CULL_FACE)}else b.disable(b.CULL_FACE)};this.supportsVertexTextures=function(){return b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.Snippets={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 env_map;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\ncubeColor = textureCube( env_map, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = mix( gl_FragColor, cubeColor, reflectivity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refraction_ratio;\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 ), refraction_ratio );\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",
@@ -217,17 +217,17 @@ THREE.Snippets.lights_vertex,"gl_Position = projectionMatrix * mvPosition;\n}"].
 "gl_FragColor = mColor * mapColor * vertexColor;",THREE.Snippets.fog_fragment,"}"].join("\n"),vertex_shader:["uniform float size;",THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\ngl_Position = projectionMatrix * mvPosition;\ngl_PointSize = size;\n}"].join("\n")}};THREE.RenderableObject=function(){this.z=this.object=null};
 THREE.RenderableFace3=function(){this.z=null;this.v1=new THREE.Vertex;this.v2=new THREE.Vertex;this.v3=new THREE.Vertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[];this.faceMaterials=this.meshMaterials=null;this.overdraw=false;this.uvs=[null,null,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.Vertex;this.v2=new THREE.Vertex;this.materials=null};
-var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,f=d?c.geometry:c,b=a.vertices,g=f.vertices,j=a.faces,h=f.faces,m=a.uvs;f=f.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var n=0,A=g.length;n<A;n++){var v=new THREE.Vertex(g[n].position.clone());d&&c.matrix.multiplyVector3(v.position);b.push(v)}n=0;for(A=h.length;n<A;n++){g=h[n];var o,z=g.vertexNormals;if(g instanceof THREE.Face3)o=new THREE.Face3(g.a+e,g.b+e,g.c+e);else if(g instanceof THREE.Face4)o=new THREE.Face4(g.a+
-e,g.b+e,g.c+e,g.d+e);o.centroid.copy(g.centroid);o.normal.copy(g.normal);d=0;for(b=z.length;d<b;d++){v=z[d];o.vertexNormals.push(v.clone())}o.materials=g.materials.slice();j.push(o)}n=0;for(A=f.length;n<A;n++){e=f[n];j=[];d=0;for(b=e.length;d<b;d++)j.push(new THREE.UV(e[d].u,e[d].v));m.push(j)}}},ImageUtils={loadTexture:function(a,c,d){var e=new Image;e.onload=function(){this.loaded=true;d&&d(this)};e.src=a;return new THREE.Texture(e,c)},loadArray:function(a,c){var d,e,f=[];d=f.loadCount=0;for(e=
+var GeometryUtils={merge:function(a,c){var d=c instanceof THREE.Mesh,e=a.vertices.length,f=d?c.geometry:c,b=a.vertices,g=f.vertices,j=a.faces,h=f.faces,m=a.uvs;f=f.uvs;d&&c.autoUpdateMatrix&&c.updateMatrix();for(var n=0,y=g.length;n<y;n++){var u=new THREE.Vertex(g[n].position.clone());d&&c.matrix.multiplyVector3(u.position);b.push(u)}n=0;for(y=h.length;n<y;n++){g=h[n];var o,A=g.vertexNormals;if(g instanceof THREE.Face3)o=new THREE.Face3(g.a+e,g.b+e,g.c+e);else if(g instanceof THREE.Face4)o=new THREE.Face4(g.a+
+e,g.b+e,g.c+e,g.d+e);o.centroid.copy(g.centroid);o.normal.copy(g.normal);d=0;for(b=A.length;d<b;d++){u=A[d];o.vertexNormals.push(u.clone())}o.materials=g.materials.slice();j.push(o)}n=0;for(y=f.length;n<y;n++){e=f[n];j=[];d=0;for(b=e.length;d<b;d++)j.push(new THREE.UV(e[d].u,e[d].v));m.push(j)}}},ImageUtils={loadTexture:function(a,c,d){var e=new Image;e.onload=function(){this.loaded=true;d&&d(this)};e.src=a;return new THREE.Texture(e,c)},loadArray:function(a,c){var d,e,f=[];d=f.loadCount=0;for(e=
 a.length;d<e;++d){f[d]=new Image;f[d].loaded=0;f[d].onload=function(){f.loadCount+=1;this.loaded=true;c&&c(this)};f[d].src=a[d]}return f}},SceneUtils={loadScene:function(a,c,d,e){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function b(){for(n in k.objects)if(!D.objects[n]){C=k.objects[n];if(p=D.geometries[C.geometry]){t=[];for(i=0;i<C.materials.length;i++)t[i]=D.materials[C.materials[i]];G=C.position;r=C.rotation;s=C.scale;object=new THREE.Mesh(p,t);object.position.set(G[0],G[1],G[2]);
-object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=C.visible;D.scene.addObject(object);D.objects[n]=object}}}function g(I){return function(N){D.geometries[I]=N;b();x-=1;j()}}function j(){e({total_models:F,total_textures:B,loaded_models:F-x,loaded_textures:B-y},D);x==0&&y==0&&d(D)}var h,m,n,A,v,o,z,C,G,w,H,p,l,u,t,k,q,x,y,F,B,D;k=f.data;q=new THREE.Loader;y=x=0;D={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
-f=function(){y-=1;j()};for(v in k.cameras){w=k.cameras[v];if(w.type=="perspective")l=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){l=new THREE.Camera;l.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}G=w.position;w=w.target;l.position.set(G[0],G[1],G[2]);l.target.position.set(w[0],w[1],w[2]);D.cameras[v]=l}for(A in k.lights){v=k.lights[A];if(v.type=="directional"){G=v.direction;light=new THREE.DirectionalLight;light.position.set(G[0],G[1],
-G[2]);light.position.normalize()}else if(v.type=="point"){G=v.position;light=new THREE.PointLight;light.position.set(G[0],G[1],G[2])}w=v.color;i=v.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);D.scene.addLight(light);D.lights[A]=light}for(o in k.fogs){A=k.fogs[o];if(A.type=="linear")u=new THREE.Fog(0,A.near,A.far);else if(A.type=="exp2")u=new THREE.FogExp2(0,A.density);w=A.color;u.color.setRGB(w[0],w[1],w[2]);D.fogs[o]=u}if(D.cameras&&k.defaults.camera)D.currentCamera=D.cameras[k.defaults.camera];
+object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=C.visible;D.scene.addObject(object);D.objects[n]=object}}}function g(I){return function(N){D.geometries[I]=N;b();x-=1;j()}}function j(){e({total_models:F,total_textures:B,loaded_models:F-x,loaded_textures:B-z},D);x==0&&z==0&&d(D)}var h,m,n,y,u,o,A,C,G,w,H,p,l,v,t,k,q,x,z,F,B,D;k=f.data;q=new THREE.Loader;z=x=0;D={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};
+f=function(){z-=1;j()};for(u in k.cameras){w=k.cameras[u];if(w.type=="perspective")l=new THREE.Camera(w.fov,w.aspect,w.near,w.far);else if(w.type=="ortho"){l=new THREE.Camera;l.projectionMatrix=THREE.Matrix4.makeOrtho(w.left,w.right,w.top,w.bottom,w.near,w.far)}G=w.position;w=w.target;l.position.set(G[0],G[1],G[2]);l.target.position.set(w[0],w[1],w[2]);D.cameras[u]=l}for(y in k.lights){u=k.lights[y];if(u.type=="directional"){G=u.direction;light=new THREE.DirectionalLight;light.position.set(G[0],G[1],
+G[2]);light.position.normalize()}else if(u.type=="point"){G=u.position;light=new THREE.PointLight;light.position.set(G[0],G[1],G[2])}w=u.color;i=u.intensity||1;light.color.setRGB(w[0]*i,w[1]*i,w[2]*i);D.scene.addLight(light);D.lights[y]=light}for(o in k.fogs){y=k.fogs[o];if(y.type=="linear")v=new THREE.Fog(0,y.near,y.far);else if(y.type=="exp2")v=new THREE.FogExp2(0,y.density);w=y.color;v.color.setRGB(w[0],w[1],w[2]);D.fogs[o]=v}if(D.cameras&&k.defaults.camera)D.currentCamera=D.cameras[k.defaults.camera];
 if(D.fogs&&k.defaults.fog)D.scene.fog=D.fogs[k.defaults.fog];w=k.defaults.bgcolor;D.bgColor=new THREE.Color;D.bgColor.setRGB(w[0],w[1],w[2]);D.bgColorAlpha=k.defaults.bgalpha;for(h in k.geometries){o=k.geometries[h];if(o.type=="bin_mesh"||o.type=="ascii_mesh")x+=1}F=x;for(h in k.geometries){o=k.geometries[h];if(o.type=="cube"){p=new Cube(o.width,o.height,o.depth,o.segments_width,o.segments_height,null,o.flipped,o.sides);D.geometries[h]=p}else if(o.type=="plane"){p=new Plane(o.width,o.height,o.segments_width,
 o.segments_height);D.geometries[h]=p}else if(o.type=="sphere"){p=new Sphere(o.radius,o.segments_width,o.segments_height);D.geometries[h]=p}else if(o.type=="cylinder"){p=new Cylinder(o.numSegs,o.topRad,o.botRad,o.height,o.topOffset,o.botOffset);D.geometries[h]=p}else if(o.type=="torus"){p=new Torus(o.radius,o.tube,o.segmentsR,o.segmentsT);D.geometries[h]=p}else if(o.type=="icosahedron"){p=new Icosahedron(o.subdivisions);D.geometries[h]=p}else if(o.type=="bin_mesh")q.loadBinary({model:o.url,callback:g(h)});
-else o.type=="ascii_mesh"&&q.loadAscii({model:o.url,callback:g(h)})}for(z in k.textures){h=k.textures[z];y+=h.url instanceof Array?h.url.length:1}B=y;for(z in k.textures){h=k.textures[z];if(h.mapping!=undefined&&THREE[h.mapping]!=undefined)h.mapping=new THREE[h.mapping];if(h.url instanceof Array){o=ImageUtils.loadArray(h.url,f);o=new THREE.Texture(o,h.mapping)}else{o=ImageUtils.loadTexture(h.url,h.mapping,f);if(THREE[h.min_filter]!=undefined)o.min_filter=THREE[h.min_filter];if(THREE[h.mag_filter]!=
-undefined)o.mag_filter=THREE[h.mag_filter]}D.textures[z]=o}for(m in k.materials){z=k.materials[m];for(H in z.parameters)if(H=="env_map"||H=="map"||H=="light_map")z.parameters[H]=D.textures[z.parameters[H]];else if(H=="shading")z.parameters[H]=z.parameters[H]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(H=="blending")z.parameters[H]=THREE[z.parameters[H]]?THREE[z.parameters[H]]:THREE.NormalBlending;else if(H=="combine")z.parameters[H]=z.parameters[H]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
-z=new THREE[z.type](z.parameters);D.materials[m]=z}b();c(D)}},addMesh:function(a,c,d,e,f,b,g,j,h,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=f;c.position.z=b;c.rotation.x=g;c.rotation.y=j;c.rotation.z=h;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});c=new THREE.Mesh(new Cube(c,
+else o.type=="ascii_mesh"&&q.loadAscii({model:o.url,callback:g(h)})}for(A in k.textures){h=k.textures[A];z+=h.url instanceof Array?h.url.length:1}B=z;for(A in k.textures){h=k.textures[A];if(h.mapping!=undefined&&THREE[h.mapping]!=undefined)h.mapping=new THREE[h.mapping];if(h.url instanceof Array){o=ImageUtils.loadArray(h.url,f);o=new THREE.Texture(o,h.mapping)}else{o=ImageUtils.loadTexture(h.url,h.mapping,f);if(THREE[h.min_filter]!=undefined)o.min_filter=THREE[h.min_filter];if(THREE[h.mag_filter]!=
+undefined)o.mag_filter=THREE[h.mag_filter]}D.textures[A]=o}for(m in k.materials){A=k.materials[m];for(H in A.parameters)if(H=="env_map"||H=="map"||H=="light_map")A.parameters[H]=D.textures[A.parameters[H]];else if(H=="shading")A.parameters[H]=A.parameters[H]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(H=="blending")A.parameters[H]=THREE[A.parameters[H]]?THREE[A.parameters[H]]:THREE.NormalBlending;else if(H=="combine")A.parameters[H]=A.parameters[H]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;
+A=new THREE[A.type](A.parameters);D.materials[m]=A}b();c(D)}},addMesh:function(a,c,d,e,f,b,g,j,h,m){c=new THREE.Mesh(c,m);c.scale.x=c.scale.y=c.scale.z=d;c.position.x=e;c.position.y=f;c.position.z=b;c.rotation.x=g;c.rotation.y=j;c.rotation.z=h;a.addObject(c);return c},addPanoramaCubeWebGL:function(a,c,d){var e=ShaderUtils.lib.cube;e.uniforms.tCube.texture=d;d=new THREE.MeshShaderMaterial({fragment_shader:e.fragment_shader,vertex_shader:e.vertex_shader,uniforms:e.uniforms});c=new THREE.Mesh(new Cube(c,
 c,c,1,1,null,true),d);a.addObject(c);return c},addPanoramaCube:function(a,c,d){var e=[];e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[4])}));e.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));c=new THREE.Mesh(new Cube(c,
 c,c,1,1,e,true),new THREE.MeshFaceMaterial);a.addObject(c);return c},addPanoramaCubePlanes:function(a,c,d){var e=c/2;c=new Plane(c,c);var f=Math.PI/2,b=Math.PI;SceneUtils.addMesh(a,c,1,0,0,-e,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[5])}));SceneUtils.addMesh(a,c,1,-e,0,0,0,f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[0])}));SceneUtils.addMesh(a,c,1,e,0,0,0,-f,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[1])}));SceneUtils.addMesh(a,c,1,0,e,0,f,0,b,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[2])}));
 SceneUtils.addMesh(a,c,1,0,-e,0,-f,0,b,new THREE.MeshBasicMaterial({map:new THREE.Texture(d[3])}))}},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}},fragment_shader:"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}",
@@ -239,39 +239,39 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertex_shader:"varying ve
 value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertex_shader:"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}",fragment_shader:"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},grayscale:{type:"i",value:1}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nconst float fNintensity = 0.35;\nconst float fSintensity = 0.35;\nconst float fScount = 4096.0;\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 * fScount), cos(vUv.y * fScount) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * fSintensity;\ncResult = cTextureScreen.rgb + clamp( fNintensity, 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}},vertex_shader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragment_shader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertex_shader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
-fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,d,e,f,b=2*Math.ceil(a*3)+1;if(b>25)b=25;f=(b-1)*0.5;d=Array(b);for(c=e=0;c<b;++c){d[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));e+=d[c]}for(c=0;c<b;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,f,b,g,j){function h(C,G,w,H,p,l,u,t){var k,q,x=e||1,y=f||1,F=x+1,B=y+1,D=p/2,I=l/2;p=p/x;var N=l/y,O=m.vertices.length;if(C=="x"&&G=="y"||C=="y"&&G=="x")k="z";else if(C=="x"&&G=="z"||C=="z"&&G=="x")k="y";else if(C==
-"z"&&G=="y"||C=="y"&&G=="z")k="x";for(q=0;q<B;q++)for(l=0;l<F;l++){var Q=new THREE.Vector3;Q[C]=(l*p-D)*w;Q[G]=(q*N-I)*H;Q[k]=u;m.vertices.push(new THREE.Vertex(Q))}for(q=0;q<y;q++)for(l=0;l<x;l++){m.faces.push(new THREE.Face4(l+F*q+O,l+F*(q+1)+O,l+1+F*(q+1)+O,l+1+F*q+O,null,t));m.uvs.push([new THREE.UV(l/x,q/y),new THREE.UV(l/x,(q+1)/y),new THREE.UV((l+1)/x,(q+1)/y),new THREE.UV((l+1)/x,q/y)])}}THREE.Geometry.call(this);var m=this,n=a/2,A=c/2,v=d/2;g=g?-1:1;if(b!==undefined)if(b instanceof Array)this.materials=
-b;else{this.materials=[];for(var o=0;o<6;o++)this.materials.push([b])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(j!=undefined)for(var z in j)if(this.sides[z]!=undefined)this.sides[z]=j[z];this.sides.px&&h("z","y",1*g,-1,d,c,-n,this.materials[0]);this.sides.nx&&h("z","y",-1*g,-1,d,c,n,this.materials[1]);this.sides.py&&h("x","z",1*g,1,a,d,A,this.materials[2]);this.sides.ny&&h("x","z",1*g,-1,a,d,-A,this.materials[3]);this.sides.pz&&h("x","y",1*g,-1,a,c,v,this.materials[4]);
-this.sides.nz&&h("x","y",-1*g,-1,a,c,-v,this.materials[5]);(function(){for(var C=[],G=[],w=0,H=m.vertices.length;w<H;w++){for(var p=m.vertices[w],l=false,u=0,t=C.length;u<t;u++){var k=C[u];if(p.position.x==k.position.x&&p.position.y==k.position.y&&p.position.z==k.position.z){G[w]=u;l=true;break}}if(!l){G[w]=C.length;C.push(new THREE.Vertex(p.position.clone()))}}w=0;for(H=m.faces.length;w<H;w++){p=m.faces[w];p.a=G[p.a];p.b=G[p.b];p.c=G[p.c];p.d=G[p.d]}m.vertices=C})();this.computeCentroids();this.computeFaceNormals();
+fragment_shader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var c,d,e,f,b=2*Math.ceil(a*3)+1;if(b>25)b=25;f=(b-1)*0.5;d=Array(b);for(c=e=0;c<b;++c){d[c]=Math.exp(-((c-f)*(c-f))/(2*a*a));e+=d[c]}for(c=0;c<b;++c)d[c]/=e;return d}},Cube=function(a,c,d,e,f,b,g,j){function h(C,G,w,H,p,l,v,t){var k,q,x=e||1,z=f||1,F=x+1,B=z+1,D=p/2,I=l/2;p=p/x;var N=l/z,O=m.vertices.length;if(C=="x"&&G=="y"||C=="y"&&G=="x")k="z";else if(C=="x"&&G=="z"||C=="z"&&G=="x")k="y";else if(C==
+"z"&&G=="y"||C=="y"&&G=="z")k="x";for(q=0;q<B;q++)for(l=0;l<F;l++){var Q=new THREE.Vector3;Q[C]=(l*p-D)*w;Q[G]=(q*N-I)*H;Q[k]=v;m.vertices.push(new THREE.Vertex(Q))}for(q=0;q<z;q++)for(l=0;l<x;l++){m.faces.push(new THREE.Face4(l+F*q+O,l+F*(q+1)+O,l+1+F*(q+1)+O,l+1+F*q+O,null,t));m.uvs.push([new THREE.UV(l/x,q/z),new THREE.UV(l/x,(q+1)/z),new THREE.UV((l+1)/x,(q+1)/z),new THREE.UV((l+1)/x,q/z)])}}THREE.Geometry.call(this);var m=this,n=a/2,y=c/2,u=d/2;g=g?-1:1;if(b!==undefined)if(b instanceof Array)this.materials=
+b;else{this.materials=[];for(var o=0;o<6;o++)this.materials.push([b])}else this.materials=[];this.sides={px:true,nx:true,py:true,ny:true,pz:true,nz:true};if(j!=undefined)for(var A in j)if(this.sides[A]!=undefined)this.sides[A]=j[A];this.sides.px&&h("z","y",1*g,-1,d,c,-n,this.materials[0]);this.sides.nx&&h("z","y",-1*g,-1,d,c,n,this.materials[1]);this.sides.py&&h("x","z",1*g,1,a,d,y,this.materials[2]);this.sides.ny&&h("x","z",1*g,-1,a,d,-y,this.materials[3]);this.sides.pz&&h("x","y",1*g,-1,a,c,u,this.materials[4]);
+this.sides.nz&&h("x","y",-1*g,-1,a,c,-u,this.materials[5]);(function(){for(var C=[],G=[],w=0,H=m.vertices.length;w<H;w++){for(var p=m.vertices[w],l=false,v=0,t=C.length;v<t;v++){var k=C[v];if(p.position.x==k.position.x&&p.position.y==k.position.y&&p.position.z==k.position.z){G[w]=v;l=true;break}}if(!l){G[w]=C.length;C.push(new THREE.Vertex(p.position.clone()))}}w=0;for(H=m.faces.length;w<H;w++){p=m.faces[w];p.a=G[p.a];p.b=G[p.b];p.c=G[p.c];p.d=G[p.d]}m.vertices=C})();this.computeCentroids();this.computeFaceNormals();
 this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
-var Cylinder=function(a,c,d,e,f){function b(m,n,A){g.vertices.push(new THREE.Vertex(new THREE.Vector3(m,n,A)))}THREE.Geometry.call(this);var g=this,j=Math.PI,h;for(h=0;h<a;h++)b(Math.sin(2*j*h/a)*c,Math.cos(2*j*h/a)*c,0);for(h=0;h<a;h++)b(Math.sin(2*j*h/a)*d,Math.cos(2*j*h/a)*d,e);for(h=0;h<a;h++)g.faces.push(new THREE.Face4(h,h+a,a+(h+1)%a,(h+1)%a));if(d!=0){b(0,0,-f);for(h=a;h<a+a/2;h++)g.faces.push(new THREE.Face4(2*a,(2*h-2*a)%a,(2*h-2*a+1)%a,(2*h-2*a+2)%a))}if(c!=0){b(0,0,e+f);for(h=a+a/2;h<
+var Cylinder=function(a,c,d,e,f){function b(m,n,y){g.vertices.push(new THREE.Vertex(new THREE.Vector3(m,n,y)))}THREE.Geometry.call(this);var g=this,j=Math.PI,h;for(h=0;h<a;h++)b(Math.sin(2*j*h/a)*c,Math.cos(2*j*h/a)*c,0);for(h=0;h<a;h++)b(Math.sin(2*j*h/a)*d,Math.cos(2*j*h/a)*d,e);for(h=0;h<a;h++)g.faces.push(new THREE.Face4(h,h+a,a+(h+1)%a,(h+1)%a));if(d!=0){b(0,0,-f);for(h=a;h<a+a/2;h++)g.faces.push(new THREE.Face4(2*a,(2*h-2*a)%a,(2*h-2*a+1)%a,(2*h-2*a+2)%a))}if(c!=0){b(0,0,e+f);for(h=a+a/2;h<
 2*a;h++)g.faces.push(new THREE.Face4((2*h-2*a+2)%a+a,(2*h-2*a+1)%a+a,(2*h-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
 var Plane=function(a,c,d,e){THREE.Geometry.call(this);var f,b=a/2,g=c/2;d=d||1;e=e||1;var j=d+1,h=e+1;a=a/d;var m=c/e;for(f=0;f<h;f++)for(c=0;c<j;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*a-b,-(f*m-g),0)));for(f=0;f<e;f++)for(c=0;c<d;c++){this.faces.push(new THREE.Face4(c+j*f,c+j*(f+1),c+1+j*(f+1),c+1+j*f));this.uvs.push([new THREE.UV(c/d,f/e),new THREE.UV(c/d,(f+1)/e),new THREE.UV((c+1)/d,(f+1)/e),new THREE.UV((c+1)/d,f/e)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,f=Math.PI,b=Math.max(3,c||8),g=Math.max(2,d||6);c=[];for(d=0;d<g+1;d++){e=d/g;var j=a*Math.cos(e*f),h=a*Math.sin(e*f),m=[],n=0;for(e=0;e<b;e++){var A=2*e/b,v=h*Math.sin(A*f);A=h*Math.cos(A*f);(d==0||d==g)&&e>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(A,j,v)))-1);m.push(n)}c.push(m)}var o,z,C;f=c.length;for(d=0;d<f;d++){b=c[d].length;if(d>0)for(e=0;e<b;e++){m=e==b-1;g=c[d][m?0:e+1];j=c[d][m?b-1:e];h=c[d-1][m?b-1:e];m=c[d-1][m?
-0:e+1];v=d/(f-1);o=(d-1)/(f-1);z=(e+1)/b;A=e/b;n=new THREE.UV(1-z,v);v=new THREE.UV(1-A,v);A=new THREE.UV(1-A,o);var G=new THREE.UV(1-z,o);if(d<c.length-1){o=this.vertices[g].position.clone();z=this.vertices[j].position.clone();C=this.vertices[h].position.clone();o.normalize();z.normalize();C.normalize();this.faces.push(new THREE.Face3(g,j,h,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([n,v,A])}if(d>1){o=this.vertices[g].position.clone();
-z=this.vertices[h].position.clone();C=this.vertices[m].position.clone();o.normalize();z.normalize();C.normalize();this.faces.push(new THREE.Face3(g,h,m,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(z.x,z.y,z.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([n,A,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
+var Sphere=function(a,c,d){THREE.Geometry.call(this);var e,f=Math.PI,b=Math.max(3,c||8),g=Math.max(2,d||6);c=[];for(d=0;d<g+1;d++){e=d/g;var j=a*Math.cos(e*f),h=a*Math.sin(e*f),m=[],n=0;for(e=0;e<b;e++){var y=2*e/b,u=h*Math.sin(y*f);y=h*Math.cos(y*f);(d==0||d==g)&&e>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(y,j,u)))-1);m.push(n)}c.push(m)}var o,A,C;f=c.length;for(d=0;d<f;d++){b=c[d].length;if(d>0)for(e=0;e<b;e++){m=e==b-1;g=c[d][m?0:e+1];j=c[d][m?b-1:e];h=c[d-1][m?b-1:e];m=c[d-1][m?
+0:e+1];u=d/(f-1);o=(d-1)/(f-1);A=(e+1)/b;y=e/b;n=new THREE.UV(1-A,u);u=new THREE.UV(1-y,u);y=new THREE.UV(1-y,o);var G=new THREE.UV(1-A,o);if(d<c.length-1){o=this.vertices[g].position.clone();A=this.vertices[j].position.clone();C=this.vertices[h].position.clone();o.normalize();A.normalize();C.normalize();this.faces.push(new THREE.Face3(g,j,h,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([n,u,y])}if(d>1){o=this.vertices[g].position.clone();
+A=this.vertices[h].position.clone();C=this.vertices[m].position.clone();o.normalize();A.normalize();C.normalize();this.faces.push(new THREE.Face3(g,h,m,[new THREE.Vector3(o.x,o.y,o.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(C.x,C.y,C.z)]));this.uvs.push([n,y,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 var Torus=function(a,c,d,e){this.radius=a||100;this.tube=c||40;this.segmentsR=d||8;this.segmentsT=e||6;a=[];THREE.Geometry.call(this);for(c=0;c<=this.segmentsR;++c)for(d=0;d<=this.segmentsT;++d){e=d/this.segmentsT*2*Math.PI;var f=c/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(e),(this.radius+this.tube*Math.cos(f))*Math.sin(e),this.tube*Math.sin(f))));a.push([d/this.segmentsT,1-c/this.segmentsR])}for(c=1;c<=this.segmentsR;++c)for(d=
 1;d<=this.segmentsT;++d){e=(this.segmentsT+1)*c+d;f=(this.segmentsT+1)*c+d-1;var b=(this.segmentsT+1)*(c-1)+d-1,g=(this.segmentsT+1)*(c-1)+d;this.faces.push(new THREE.Face4(e,f,b,g));this.uvs.push([new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[b][0],a[b][1]),new THREE.UV(a[g][0],a[g][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
-var Icosahedron=function(a){function c(A,v,o){var z=Math.sqrt(A*A+v*v+o*o);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(A/z,v/z,o/z)))-1}function d(A,v,o,z){z.faces.push(new THREE.Face3(A,v,o))}function e(A,v){var o=f.vertices[A].position,z=f.vertices[v].position;return c((o.x+z.x)/2,(o.y+z.y)/2,(o.z+z.z)/2)}var f=this,b=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
+var Icosahedron=function(a){function c(y,u,o){var A=Math.sqrt(y*y+u*u+o*o);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(y/A,u/A,o/A)))-1}function d(y,u,o,A){A.faces.push(new THREE.Face3(y,u,o))}function e(y,u){var o=f.vertices[y].position,A=f.vertices[u].position;return c((o.x+A.x)/2,(o.y+A.y)/2,(o.z+A.z)/2)}var f=this,b=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;c(-1,a,0);c(1,a,0);c(-1,-a,0);c(1,-a,0);c(0,-1,a);c(0,1,a);c(0,-1,-a);c(0,
 1,-a);c(a,0,-1);c(a,0,1);c(-a,0,-1);c(-a,0,1);d(0,11,5,b);d(0,5,1,b);d(0,1,7,b);d(0,7,10,b);d(0,10,11,b);d(1,5,9,b);d(5,11,4,b);d(11,10,2,b);d(10,7,6,b);d(7,1,8,b);d(3,9,4,b);d(3,4,2,b);d(3,2,6,b);d(3,6,8,b);d(3,8,9,b);d(4,9,5,b);d(2,4,11,b);d(6,2,10,b);d(8,6,7,b);d(9,8,1,b);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var j in b.faces){var h=e(b.faces[j].a,b.faces[j].b),m=e(b.faces[j].b,b.faces[j].c),n=e(b.faces[j].c,b.faces[j].a);d(b.faces[j].a,h,n,g);d(b.faces[j].b,m,h,g);d(b.faces[j].c,
 n,m,g);d(h,m,n,g)}b.faces=g.faces}f.faces=b.faces;delete b;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
 function LathedObject(a,c,d){THREE.Geometry.call(this);c=c||12;d=d||2*Math.PI;c=d/c;for(var e=[],f=[],b=[],g=[],j=0;j<a.length;j++){this.vertices.push(new THREE.Vertex(a[j]));f[j]=this.vertices.length-1;e[j]=new THREE.Vector3(a[j].x,a[j].y,a[j].z)}for(var h=THREE.Matrix4.rotationZMatrix(c),m=0;m<=d+0.0010;m+=c){for(j=0;j<e.length;j++)if(m<d){e[j]=h.multiplyVector3(e[j].clone());this.vertices.push(new THREE.Vertex(e[j]));b[j]=this.vertices.length-1}else b=g;if(m==0)g=f;for(j=0;j<f.length-1;j++){this.faces.push(new THREE.Face4(b[j],
 b[j+1],f[j+1],f[j]));this.uvs.push([new THREE.UV(m/d,j/a.length),new THREE.UV(m/d,(j+1)/a.length),new THREE.UV((m-c)/d,(j+1)/a.length),new THREE.UV((m-c)/d,j/a.length)])}f=b;b=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 THREE.MarchingCubes=function(a,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];this.init=function(d){this.isolation=80;this.size=d;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=true;this.maxCount=4096;this.count=
-0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(d,e,f){return d+(e-d)*f};this.VIntX=function(d,e,f,b,g,j,h,m,n,A){g=(g-n)/(A-n);n=this.normal_cache;e[b]=j+g*this.delta;e[b+1]=h;e[b+2]=m;f[b]=this.lerp(n[d],n[d+3],g);f[b+1]=this.lerp(n[d+1],n[d+4],g);f[b+2]=this.lerp(n[d+2],n[d+5],g)};this.VIntY=function(d,e,f,b,g,j,h,m,n,A){g=(g-n)/(A-n);n=this.normal_cache;e[b]=j;e[b+1]=h+g*this.delta;e[b+
-2]=m;e=d+this.yd*3;f[b]=this.lerp(n[d],n[e],g);f[b+1]=this.lerp(n[d+1],n[e+1],g);f[b+2]=this.lerp(n[d+2],n[e+2],g)};this.VIntZ=function(d,e,f,b,g,j,h,m,n,A){g=(g-n)/(A-n);n=this.normal_cache;e[b]=j;e[b+1]=h;e[b+2]=m+g*this.delta;e=d+this.zd*3;f[b]=this.lerp(n[d],n[e],g);f[b+1]=this.lerp(n[d+1],n[e+1],g);f[b+2]=this.lerp(n[d+2],n[e+2],g)};this.compNorm=function(d){var e=d*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[d-1]-this.field[d+1];this.normal_cache[e+1]=this.field[d-this.yd]-
-this.field[d+this.yd];this.normal_cache[e+2]=this.field[d-this.zd]-this.field[d+this.zd]}};this.polygonize=function(d,e,f,b,g,j){var h=b+1,m=b+this.yd,n=b+this.zd,A=h+this.yd,v=h+this.zd,o=b+this.yd+this.zd,z=h+this.yd+this.zd,C=0,G=this.field[b],w=this.field[h],H=this.field[m],p=this.field[A],l=this.field[n],u=this.field[v],t=this.field[o],k=this.field[z];if(G<g)C|=1;if(w<g)C|=2;if(H<g)C|=8;if(p<g)C|=4;if(l<g)C|=16;if(u<g)C|=32;if(t<g)C|=128;if(k<g)C|=64;var q=THREE.edgeTable[C];if(q==0)return 0;
-var x=this.delta,y=d+x,F=e+x;x=f+x;if(q&1){this.compNorm(b);this.compNorm(h);this.VIntX(b*3,this.vlist,this.nlist,0,g,d,e,f,G,w)}if(q&2){this.compNorm(h);this.compNorm(A);this.VIntY(h*3,this.vlist,this.nlist,3,g,y,e,f,w,p)}if(q&4){this.compNorm(m);this.compNorm(A);this.VIntX(m*3,this.vlist,this.nlist,6,g,d,F,f,H,p)}if(q&8){this.compNorm(b);this.compNorm(m);this.VIntY(b*3,this.vlist,this.nlist,9,g,d,e,f,G,H)}if(q&16){this.compNorm(n);this.compNorm(v);this.VIntX(n*3,this.vlist,this.nlist,12,g,d,e,x,
-l,u)}if(q&32){this.compNorm(v);this.compNorm(z);this.VIntY(v*3,this.vlist,this.nlist,15,g,y,e,x,u,k)}if(q&64){this.compNorm(o);this.compNorm(z);this.VIntX(o*3,this.vlist,this.nlist,18,g,d,F,x,t,k)}if(q&128){this.compNorm(n);this.compNorm(o);this.VIntY(n*3,this.vlist,this.nlist,21,g,d,e,x,l,t)}if(q&256){this.compNorm(b);this.compNorm(n);this.VIntZ(b*3,this.vlist,this.nlist,24,g,d,e,f,G,l)}if(q&512){this.compNorm(h);this.compNorm(v);this.VIntZ(h*3,this.vlist,this.nlist,27,g,y,e,f,w,u)}if(q&1024){this.compNorm(A);
-this.compNorm(z);this.VIntZ(A*3,this.vlist,this.nlist,30,g,y,F,f,p,k)}if(q&2048){this.compNorm(m);this.compNorm(o);this.VIntZ(m*3,this.vlist,this.nlist,33,g,d,F,f,H,t)}C<<=4;for(g=b=0;THREE.triTable[C+g]!=-1;){d=C+g;e=d+1;f=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[f],j);g+=3;b++}return b};this.posnormtriv=function(d,e,f,b,g,j){var h=this.count*3;this.positionArray[h]=d[f];this.positionArray[h+1]=d[f+1];this.positionArray[h+2]=d[f+2];this.positionArray[h+
+0;this.hasNormal=this.hasPos=false;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(d,e,f){return d+(e-d)*f};this.VIntX=function(d,e,f,b,g,j,h,m,n,y){g=(g-n)/(y-n);n=this.normal_cache;e[b]=j+g*this.delta;e[b+1]=h;e[b+2]=m;f[b]=this.lerp(n[d],n[d+3],g);f[b+1]=this.lerp(n[d+1],n[d+4],g);f[b+2]=this.lerp(n[d+2],n[d+5],g)};this.VIntY=function(d,e,f,b,g,j,h,m,n,y){g=(g-n)/(y-n);n=this.normal_cache;e[b]=j;e[b+1]=h+g*this.delta;e[b+
+2]=m;e=d+this.yd*3;f[b]=this.lerp(n[d],n[e],g);f[b+1]=this.lerp(n[d+1],n[e+1],g);f[b+2]=this.lerp(n[d+2],n[e+2],g)};this.VIntZ=function(d,e,f,b,g,j,h,m,n,y){g=(g-n)/(y-n);n=this.normal_cache;e[b]=j;e[b+1]=h;e[b+2]=m+g*this.delta;e=d+this.zd*3;f[b]=this.lerp(n[d],n[e],g);f[b+1]=this.lerp(n[d+1],n[e+1],g);f[b+2]=this.lerp(n[d+2],n[e+2],g)};this.compNorm=function(d){var e=d*3;if(this.normal_cache[e]==0){this.normal_cache[e]=this.field[d-1]-this.field[d+1];this.normal_cache[e+1]=this.field[d-this.yd]-
+this.field[d+this.yd];this.normal_cache[e+2]=this.field[d-this.zd]-this.field[d+this.zd]}};this.polygonize=function(d,e,f,b,g,j){var h=b+1,m=b+this.yd,n=b+this.zd,y=h+this.yd,u=h+this.zd,o=b+this.yd+this.zd,A=h+this.yd+this.zd,C=0,G=this.field[b],w=this.field[h],H=this.field[m],p=this.field[y],l=this.field[n],v=this.field[u],t=this.field[o],k=this.field[A];if(G<g)C|=1;if(w<g)C|=2;if(H<g)C|=8;if(p<g)C|=4;if(l<g)C|=16;if(v<g)C|=32;if(t<g)C|=128;if(k<g)C|=64;var q=THREE.edgeTable[C];if(q==0)return 0;
+var x=this.delta,z=d+x,F=e+x;x=f+x;if(q&1){this.compNorm(b);this.compNorm(h);this.VIntX(b*3,this.vlist,this.nlist,0,g,d,e,f,G,w)}if(q&2){this.compNorm(h);this.compNorm(y);this.VIntY(h*3,this.vlist,this.nlist,3,g,z,e,f,w,p)}if(q&4){this.compNorm(m);this.compNorm(y);this.VIntX(m*3,this.vlist,this.nlist,6,g,d,F,f,H,p)}if(q&8){this.compNorm(b);this.compNorm(m);this.VIntY(b*3,this.vlist,this.nlist,9,g,d,e,f,G,H)}if(q&16){this.compNorm(n);this.compNorm(u);this.VIntX(n*3,this.vlist,this.nlist,12,g,d,e,x,
+l,v)}if(q&32){this.compNorm(u);this.compNorm(A);this.VIntY(u*3,this.vlist,this.nlist,15,g,z,e,x,v,k)}if(q&64){this.compNorm(o);this.compNorm(A);this.VIntX(o*3,this.vlist,this.nlist,18,g,d,F,x,t,k)}if(q&128){this.compNorm(n);this.compNorm(o);this.VIntY(n*3,this.vlist,this.nlist,21,g,d,e,x,l,t)}if(q&256){this.compNorm(b);this.compNorm(n);this.VIntZ(b*3,this.vlist,this.nlist,24,g,d,e,f,G,l)}if(q&512){this.compNorm(h);this.compNorm(u);this.VIntZ(h*3,this.vlist,this.nlist,27,g,z,e,f,w,v)}if(q&1024){this.compNorm(y);
+this.compNorm(A);this.VIntZ(y*3,this.vlist,this.nlist,30,g,z,F,f,p,k)}if(q&2048){this.compNorm(m);this.compNorm(o);this.VIntZ(m*3,this.vlist,this.nlist,33,g,d,F,f,H,t)}C<<=4;for(g=b=0;THREE.triTable[C+g]!=-1;){d=C+g;e=d+1;f=d+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[d],3*THREE.triTable[e],3*THREE.triTable[f],j);g+=3;b++}return b};this.posnormtriv=function(d,e,f,b,g,j){var h=this.count*3;this.positionArray[h]=d[f];this.positionArray[h+1]=d[f+1];this.positionArray[h+2]=d[f+2];this.positionArray[h+
 3]=d[b];this.positionArray[h+4]=d[b+1];this.positionArray[h+5]=d[b+2];this.positionArray[h+6]=d[g];this.positionArray[h+7]=d[g+1];this.positionArray[h+8]=d[g+2];this.normalArray[h]=e[f];this.normalArray[h+1]=e[f+1];this.normalArray[h+2]=e[f+2];this.normalArray[h+3]=e[b];this.normalArray[h+4]=e[b+1];this.normalArray[h+5]=e[b+2];this.normalArray[h+6]=e[g];this.normalArray[h+7]=e[g+1];this.normalArray[h+8]=e[g+2];this.hasNormal=this.hasPos=true;this.count+=3;this.count>=this.maxCount-3&&j(this)};this.begin=
-function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(d){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;d(this)}};this.addBall=function(d,e,f,b,g){var j=this.size*Math.sqrt(b/g),h=f*this.size,m=e*this.size,n=d*this.size,A=Math.floor(h-j);if(A<1)A=1;h=Math.floor(h+j);if(h>this.size-1)h=this.size-1;var v=Math.floor(m-j);if(v<1)v=1;m=Math.floor(m+j);if(m>this.size-1)m=this.size-1;var o=Math.floor(n-j);if(o<1)o=1;j=Math.floor(n+j);
-if(j>this.size-1)j=this.size-1;var z,C,G,w,H,p;for(A=A;A<h;A++){n=this.size*this.size*A;C=A/this.size-f;H=C*C;for(C=v;C<m;C++){G=n+this.size*C;z=C/this.size-e;p=z*z;for(z=o;z<j;z++){w=z/this.size-d;w=b/(1.0E-6+w*w+p+H)-g;if(w>0)this.field[G+z]+=w}}}};this.addPlaneX=function(d,e){var f,b,g,j,h,m=this.size,n=this.yd,A=this.zd,v=this.field,o=m*Math.sqrt(d/e);if(o>m)o=m;for(f=0;f<o;f++){b=f/m;b=b*b;j=d/(1.0E-4+b)-e;if(j>0)for(b=0;b<m;b++){h=f+b*n;for(g=0;g<m;g++)v[A*g+h]+=j}}};this.addPlaneY=function(d,
-e){var f,b,g,j,h,m,n=this.size,A=this.yd,v=this.zd,o=this.field,z=n*Math.sqrt(d/e);if(z>n)z=n;for(b=0;b<z;b++){f=b/n;f=f*f;j=d/(1.0E-4+f)-e;if(j>0){h=b*A;for(f=0;f<n;f++){m=h+f;for(g=0;g<n;g++)o[v*g+m]+=j}}}};this.addPlaneZ=function(d,e){var f,b,g,j,h,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(d/e);if(dist>size)dist=size;for(g=0;g<dist;g++){f=g/size;f=f*f;j=d/(1.0E-4+f)-e;if(j>0){h=zd*g;for(b=0;b<size;b++){m=h+b*yd;for(f=0;f<size;f++)field[m+f]+=j}}}};this.reset=function(){var d;
-for(d=0;d<this.size3;d++){this.normal_cache[d*3]=0;this.field[d]=0}};this.render=function(d){this.begin();var e,f,b,g,j,h,m,n,A,v=this.size-2;for(g=1;g<v;g++){A=this.size2*g;m=(g-this.halfsize)/this.halfsize;for(b=1;b<v;b++){n=A+this.size*b;h=(b-this.halfsize)/this.halfsize;for(f=1;f<v;f++){j=(f-this.halfsize)/this.halfsize;e=n+f;this.polygonize(j,h,m,e,this.isolation,d)}}}this.end(d)};this.generateGeometry=function(){var d=0,e=new THREE.Geometry;this.render(function(f){var b,g,j,h,m,n,A;for(b=0;b<
-f.count;b++){g=f.positionArray[b*3];j=f.positionArray[b*3+1];h=f.positionArray[b*3+2];m=new THREE.Vector3(g,j,h);g=f.normalArray[b*3];j=f.normalArray[b*3+1];h=f.normalArray[b*3+2];g=new THREE.Vector3(g,j,h);g.normalize();m=new THREE.Vertex(m,g);e.vertices.push(m)}nfaces=f.count/3;for(b=0;b<nfaces;b++){m=(d+b)*3;g=(d+b)*3+1;j=(d+b)*3+2;h=e.vertices[m].normal;n=e.vertices[g].normal;A=e.vertices[j].normal;m=new THREE.Face3(m,g,j,[h,n,A]);e.faces.push(m)}d+=nfaces;f.count=0});e.sortFacesByMaterial();
-return e};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
+function(){this.count=0;this.hasNormal=this.hasPos=false};this.end=function(d){if(this.count!=0){for(var e=this.count*3;e<this.positionArray.length;e++)this.positionArray[e]=0;d(this)}};this.addBall=function(d,e,f,b,g){var j=this.size*Math.sqrt(b/g),h=f*this.size,m=e*this.size,n=d*this.size,y=Math.floor(h-j);if(y<1)y=1;h=Math.floor(h+j);if(h>this.size-1)h=this.size-1;var u=Math.floor(m-j);if(u<1)u=1;m=Math.floor(m+j);if(m>this.size-1)m=this.size-1;var o=Math.floor(n-j);if(o<1)o=1;j=Math.floor(n+j);
+if(j>this.size-1)j=this.size-1;var A,C,G,w,H,p;for(y=y;y<h;y++){n=this.size*this.size*y;C=y/this.size-f;H=C*C;for(C=u;C<m;C++){G=n+this.size*C;A=C/this.size-e;p=A*A;for(A=o;A<j;A++){w=A/this.size-d;w=b/(1.0E-6+w*w+p+H)-g;if(w>0)this.field[G+A]+=w}}}};this.addPlaneX=function(d,e){var f,b,g,j,h,m=this.size,n=this.yd,y=this.zd,u=this.field,o=m*Math.sqrt(d/e);if(o>m)o=m;for(f=0;f<o;f++){b=f/m;b=b*b;j=d/(1.0E-4+b)-e;if(j>0)for(b=0;b<m;b++){h=f+b*n;for(g=0;g<m;g++)u[y*g+h]+=j}}};this.addPlaneY=function(d,
+e){var f,b,g,j,h,m,n=this.size,y=this.yd,u=this.zd,o=this.field,A=n*Math.sqrt(d/e);if(A>n)A=n;for(b=0;b<A;b++){f=b/n;f=f*f;j=d/(1.0E-4+f)-e;if(j>0){h=b*y;for(f=0;f<n;f++){m=h+f;for(g=0;g<n;g++)o[u*g+m]+=j}}}};this.addPlaneZ=function(d,e){var f,b,g,j,h,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(d/e);if(dist>size)dist=size;for(g=0;g<dist;g++){f=g/size;f=f*f;j=d/(1.0E-4+f)-e;if(j>0){h=zd*g;for(b=0;b<size;b++){m=h+b*yd;for(f=0;f<size;f++)field[m+f]+=j}}}};this.reset=function(){var d;
+for(d=0;d<this.size3;d++){this.normal_cache[d*3]=0;this.field[d]=0}};this.render=function(d){this.begin();var e,f,b,g,j,h,m,n,y,u=this.size-2;for(g=1;g<u;g++){y=this.size2*g;m=(g-this.halfsize)/this.halfsize;for(b=1;b<u;b++){n=y+this.size*b;h=(b-this.halfsize)/this.halfsize;for(f=1;f<u;f++){j=(f-this.halfsize)/this.halfsize;e=n+f;this.polygonize(j,h,m,e,this.isolation,d)}}}this.end(d)};this.generateGeometry=function(){var d=0,e=new THREE.Geometry;this.render(function(f){var b,g,j,h,m,n,y,u;for(b=
+0;b<f.count;b++){m=b*3;y=m+1;u=m+2;g=f.positionArray[m];j=f.positionArray[y];h=f.positionArray[u];n=new THREE.Vector3(g,j,h);g=f.normalArray[m];j=f.normalArray[y];h=f.normalArray[u];m=new THREE.Vector3(g,j,h);m.normalize();m=new THREE.Vertex(n,m);e.vertices.push(m)}nfaces=f.count/3;for(b=0;b<nfaces;b++){m=(d+b)*3;y=m+1;u=m+2;n=e.vertices[m].normal;g=e.vertices[y].normal;j=e.vertices[u].normal;m=new THREE.Face3(m,y,u,[n,g,j]);e.faces.push(m)}d+=nfaces;f.count=0});e.sortFacesByMaterial();return e};
+this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
 419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
@@ -300,23 +300,23 @@ THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement
 c},loadAsciiOld:function(a,c){var d=document.createElement("script");d.type="text/javascript";d.onload=c;d.src=a;document.getElementsByTagName("head")[0].appendChild(d)},loadAscii:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);c.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,d,e)};c.postMessage(a)},loadBinary:function(a){var c=a.model,d=a.callback,e=a.texture_path?a.texture_path:
 THREE.Loader.prototype.extractUrlbase(c),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(c);a=(new Date).getTime();c=new Worker(c);var b=this.showProgress?THREE.Loader.prototype.updateProgress:null;c.onmessage=function(g){THREE.Loader.prototype.loadAjaxBuffers(g.data.buffers,g.data.materials,d,f,e,b)};c.onerror=function(g){alert("worker.onerror: "+g.message+"\n"+g.data);g.preventDefault()};c.postMessage(a)},loadAjaxBuffers:function(a,c,d,e,f,b){var g=new XMLHttpRequest,j=e+"/"+a,h=0;
 g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.Loader.prototype.createBinModel(g.responseText,d,f,c):alert("Couldn't load ["+j+"] ["+g.status+"]");else if(g.readyState==3){if(b){if(h==0)h=g.getResponseHeader("Content-Length");b({total:h,loaded:g.responseText.length})}}else if(g.readyState==2)h=g.getResponseHeader("Content-Length")};g.open("GET",j,true);g.overrideMimeType("text/plain; charset=x-user-defined");g.setRequestHeader("Content-Type","text/plain");g.send(null)},
-createBinModel:function(a,c,d,e){var f=function(b){function g(E,L){var J=n(E,L),X=n(E,L+1),ea=n(E,L+2),ja=n(E,L+3),ia=(ja<<1&255|ea>>7)-127;J=(ea&127)<<16|X<<8|J;if(J==0&&ia==-127)return 0;return(1-2*(ja>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ia)}function j(E,L){var J=n(E,L),X=n(E,L+1),ea=n(E,L+2);return(n(E,L+3)<<24)+(ea<<16)+(X<<8)+J}function h(E,L){var J=n(E,L);return(n(E,L+1)<<8)+J}function m(E,L){var J=n(E,L);return J>127?J-256:J}function n(E,L){return E.charCodeAt(L)&255}function A(E){var L,
-J,X;L=j(a,E);J=j(a,E+t);X=j(a,E+k);E=h(a,E+q);THREE.Loader.prototype.f3(w,L,J,X,E)}function v(E){var L,J,X,ea,ja,ia;L=j(a,E);J=j(a,E+t);X=j(a,E+k);ea=h(a,E+q);ja=j(a,E+x);ia=j(a,E+y);E=j(a,E+F);THREE.Loader.prototype.f3n(w,l,L,J,X,ea,ja,ia,E)}function o(E){var L,J,X,ea;L=j(a,E);J=j(a,E+B);X=j(a,E+D);ea=j(a,E+I);E=h(a,E+N);THREE.Loader.prototype.f4(w,L,J,X,ea,E)}function z(E){var L,J,X,ea,ja,ia,qa,la;L=j(a,E);J=j(a,E+B);X=j(a,E+D);ea=j(a,E+I);ja=h(a,E+N);ia=j(a,E+O);qa=j(a,E+Q);la=j(a,E+T);E=j(a,E+
-U);THREE.Loader.prototype.f4n(w,l,L,J,X,ea,ja,ia,qa,la,E)}function C(E){var L,J;L=j(a,E);J=j(a,E+ba);E=j(a,E+ca);THREE.Loader.prototype.uv3(w.uvs,u[L*2],u[L*2+1],u[J*2],u[J*2+1],u[E*2],u[E*2+1])}function G(E){var L,J,X;L=j(a,E);J=j(a,E+S);X=j(a,E+K);E=j(a,E+Z);THREE.Loader.prototype.uv4(w.uvs,u[L*2],u[L*2+1],u[J*2],u[J*2+1],u[X*2],u[X*2+1],u[E*2],u[E*2+1])}var w=this,H=0,p,l=[],u=[],t,k,q,x,y,F,B,D,I,N,O,Q,T,U,ba,ca,S,K,Z,V,P,W,$,da,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,
+createBinModel:function(a,c,d,e){var f=function(b){function g(E,L){var J=n(E,L),X=n(E,L+1),ea=n(E,L+2),ja=n(E,L+3),ia=(ja<<1&255|ea>>7)-127;J=(ea&127)<<16|X<<8|J;if(J==0&&ia==-127)return 0;return(1-2*(ja>>7))*(1+J*Math.pow(2,-23))*Math.pow(2,ia)}function j(E,L){var J=n(E,L),X=n(E,L+1),ea=n(E,L+2);return(n(E,L+3)<<24)+(ea<<16)+(X<<8)+J}function h(E,L){var J=n(E,L);return(n(E,L+1)<<8)+J}function m(E,L){var J=n(E,L);return J>127?J-256:J}function n(E,L){return E.charCodeAt(L)&255}function y(E){var L,
+J,X;L=j(a,E);J=j(a,E+t);X=j(a,E+k);E=h(a,E+q);THREE.Loader.prototype.f3(w,L,J,X,E)}function u(E){var L,J,X,ea,ja,ia;L=j(a,E);J=j(a,E+t);X=j(a,E+k);ea=h(a,E+q);ja=j(a,E+x);ia=j(a,E+z);E=j(a,E+F);THREE.Loader.prototype.f3n(w,l,L,J,X,ea,ja,ia,E)}function o(E){var L,J,X,ea;L=j(a,E);J=j(a,E+B);X=j(a,E+D);ea=j(a,E+I);E=h(a,E+N);THREE.Loader.prototype.f4(w,L,J,X,ea,E)}function A(E){var L,J,X,ea,ja,ia,qa,la;L=j(a,E);J=j(a,E+B);X=j(a,E+D);ea=j(a,E+I);ja=h(a,E+N);ia=j(a,E+O);qa=j(a,E+Q);la=j(a,E+T);E=j(a,E+
+U);THREE.Loader.prototype.f4n(w,l,L,J,X,ea,ja,ia,qa,la,E)}function C(E){var L,J;L=j(a,E);J=j(a,E+ba);E=j(a,E+ca);THREE.Loader.prototype.uv3(w.uvs,v[L*2],v[L*2+1],v[J*2],v[J*2+1],v[E*2],v[E*2+1])}function G(E){var L,J,X;L=j(a,E);J=j(a,E+S);X=j(a,E+K);E=j(a,E+Z);THREE.Loader.prototype.uv4(w.uvs,v[L*2],v[L*2+1],v[J*2],v[J*2+1],v[X*2],v[X*2+1],v[E*2],v[E*2+1])}var w=this,H=0,p,l=[],v=[],t,k,q,x,z,F,B,D,I,N,O,Q,T,U,ba,ca,S,K,Z,V,P,W,$,da,ha;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(w,
 e,b);p={signature:a.substr(H,8),header_bytes:n(a,H+8),vertex_coordinate_bytes:n(a,H+9),normal_coordinate_bytes:n(a,H+10),uv_coordinate_bytes:n(a,H+11),vertex_index_bytes:n(a,H+12),normal_index_bytes:n(a,H+13),uv_index_bytes:n(a,H+14),material_index_bytes:n(a,H+15),nvertices:j(a,H+16),nnormals:j(a,H+16+4),nuvs:j(a,H+16+8),ntri_flat:j(a,H+16+12),ntri_smooth:j(a,H+16+16),ntri_flat_uv:j(a,H+16+20),ntri_smooth_uv:j(a,H+16+24),nquad_flat:j(a,H+16+28),nquad_smooth:j(a,H+16+32),nquad_flat_uv:j(a,H+16+36),
-nquad_smooth_uv:j(a,H+16+40)};H+=p.header_bytes;t=p.vertex_index_bytes;k=p.vertex_index_bytes*2;q=p.vertex_index_bytes*3;x=p.vertex_index_bytes*3+p.material_index_bytes;y=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes;F=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*2;B=p.vertex_index_bytes;D=p.vertex_index_bytes*2;I=p.vertex_index_bytes*3;N=p.vertex_index_bytes*4;O=p.vertex_index_bytes*4+p.material_index_bytes;Q=p.vertex_index_bytes*4+p.material_index_bytes+
+nquad_smooth_uv:j(a,H+16+40)};H+=p.header_bytes;t=p.vertex_index_bytes;k=p.vertex_index_bytes*2;q=p.vertex_index_bytes*3;x=p.vertex_index_bytes*3+p.material_index_bytes;z=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes;F=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*2;B=p.vertex_index_bytes;D=p.vertex_index_bytes*2;I=p.vertex_index_bytes*3;N=p.vertex_index_bytes*4;O=p.vertex_index_bytes*4+p.material_index_bytes;Q=p.vertex_index_bytes*4+p.material_index_bytes+
 p.normal_index_bytes;T=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*2;U=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*3;ba=p.uv_index_bytes;ca=p.uv_index_bytes*2;S=p.uv_index_bytes;K=p.uv_index_bytes*2;Z=p.uv_index_bytes*3;b=p.vertex_index_bytes*3+p.material_index_bytes;ha=p.vertex_index_bytes*4+p.material_index_bytes;V=p.ntri_flat*b;P=p.ntri_smooth*(b+p.normal_index_bytes*3);W=p.ntri_flat_uv*(b+p.uv_index_bytes*3);$=p.ntri_smooth_uv*(b+p.normal_index_bytes*
 3+p.uv_index_bytes*3);da=p.nquad_flat*ha;b=p.nquad_smooth*(ha+p.normal_index_bytes*4);ha=p.nquad_flat_uv*(ha+p.uv_index_bytes*4);H+=function(E){var L,J,X,ea=p.vertex_coordinate_bytes*3,ja=E+p.nvertices*ea;for(E=E;E<ja;E+=ea){L=g(a,E);J=g(a,E+p.vertex_coordinate_bytes);X=g(a,E+p.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,L,J,X)}return p.nvertices*ea}(H);H+=function(E){var L,J,X,ea=p.normal_coordinate_bytes*3,ja=E+p.nnormals*ea;for(E=E;E<ja;E+=ea){L=m(a,E);J=m(a,E+p.normal_coordinate_bytes);
-X=m(a,E+p.normal_coordinate_bytes*2);l.push(L/127,J/127,X/127)}return p.nnormals*ea}(H);H+=function(E){var L,J,X=p.uv_coordinate_bytes*2,ea=E+p.nuvs*X;for(E=E;E<ea;E+=X){L=g(a,E);J=g(a,E+p.uv_coordinate_bytes);u.push(L,J)}return p.nuvs*X}(H);H=H;V=H+V;P=V+P;W=P+W;$=W+$;da=$+da;b=da+b;ha=b+ha;(function(E){var L,J=p.vertex_index_bytes*3+p.material_index_bytes,X=J+p.uv_index_bytes*3,ea=E+p.ntri_flat_uv*X;for(L=E;L<ea;L+=X){A(L);C(L+J)}return ea-E})(P);(function(E){var L,J=p.vertex_index_bytes*3+p.material_index_bytes+
-p.normal_index_bytes*3,X=J+p.uv_index_bytes*3,ea=E+p.ntri_smooth_uv*X;for(L=E;L<ea;L+=X){v(L);C(L+J)}return ea-E})(W);(function(E){var L,J=p.vertex_index_bytes*4+p.material_index_bytes,X=J+p.uv_index_bytes*4,ea=E+p.nquad_flat_uv*X;for(L=E;L<ea;L+=X){o(L);G(L+J)}return ea-E})(b);(function(E){var L,J=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,X=J+p.uv_index_bytes*4,ea=E+p.nquad_smooth_uv*X;for(L=E;L<ea;L+=X){z(L);G(L+J)}return ea-E})(ha);(function(E){var L,J=p.vertex_index_bytes*
-3+p.material_index_bytes,X=E+p.ntri_flat*J;for(L=E;L<X;L+=J)A(L);return X-E})(H);(function(E){var L,J=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*3,X=E+p.ntri_smooth*J;for(L=E;L<X;L+=J)v(L);return X-E})(V);(function(E){var L,J=p.vertex_index_bytes*4+p.material_index_bytes,X=E+p.nquad_flat*J;for(L=E;L<X;L+=J)o(L);return X-E})($);(function(E){var L,J=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,X=E+p.nquad_smooth*J;for(L=E;L<X;L+=J)z(L);return X-E})(da);
-this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(d))},createModel:function(a,c,d){var e=function(f){var b=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(b,a.materials,f);(function(){var g,j,h,m,n;g=0;for(j=a.vertices.length;g<j;g+=3){h=a.vertices[g];m=a.vertices[g+1];n=a.vertices[g+2];THREE.Loader.prototype.v(b,h,m,n)}})();(function(){function g(z,C){THREE.Loader.prototype.f3(b,z[C],
-z[C+1],z[C+2],z[C+3])}function j(z,C){THREE.Loader.prototype.f3n(b,a.normals,z[C],z[C+1],z[C+2],z[C+3],z[C+4],z[C+5],z[C+6])}function h(z,C){THREE.Loader.prototype.f4(b,z[C],z[C+1],z[C+2],z[C+3],z[C+4])}function m(z,C){THREE.Loader.prototype.f4n(b,a.normals,z[C],z[C+1],z[C+2],z[C+3],z[C+4],z[C+5],z[C+6],z[C+7],z[C+8])}function n(z,C){var G,w,H,p,l,u,t,k,q;G=z[C];w=z[C+1];H=z[C+2];p=a.uvs[G*2];t=a.uvs[G*2+1];l=a.uvs[w*2];k=a.uvs[w*2+1];u=a.uvs[H*2];q=a.uvs[H*2+1];THREE.Loader.prototype.uv3(b.uvs,p,
-t,l,k,u,q);if(a.uvs2){p=a.uvs2[G*2];t=a.uvs2[G*2+1];l=a.uvs2[w*2];k=a.uvs2[w*2+1];u=a.uvs2[H*2];q=a.uvs2[H*2+1];THREE.Loader.prototype.uv3(b.uvs2,p,1-t,l,1-k,u,1-q)}}function A(z,C){var G,w,H,p,l,u,t,k,q,x,y,F;G=z[C];w=z[C+1];H=z[C+2];p=z[C+3];l=a.uvs[G*2];q=a.uvs[G*2+1];u=a.uvs[w*2];x=a.uvs[w*2+1];t=a.uvs[H*2];y=a.uvs[H*2+1];k=a.uvs[p*2];F=a.uvs[p*2+1];THREE.Loader.prototype.uv4(b.uvs,l,q,u,x,t,y,k,F);if(a.uvs2){l=a.uvs2[G*2];q=a.uvs2[G*2+1];u=a.uvs2[w*2];x=a.uvs2[w*2+1];t=a.uvs2[H*2];y=a.uvs2[H*
-2+1];k=a.uvs2[p*2];F=a.uvs2[p*2+1];THREE.Loader.prototype.uv4(b.uvs2,l,1-q,u,1-x,t,1-y,k,1-F)}}var v,o;v=0;for(o=a.triangles_uv.length;v<o;v+=7){g(a.triangles_uv,v);n(a.triangles_uv,v+4)}v=0;for(o=a.triangles_n_uv.length;v<o;v+=10){j(a.triangles_n_uv,v);n(a.triangles_n_uv,v+7)}v=0;for(o=a.quads_uv.length;v<o;v+=9){h(a.quads_uv,v);A(a.quads_uv,v+5)}v=0;for(o=a.quads_n_uv.length;v<o;v+=13){m(a.quads_n_uv,v);A(a.quads_n_uv,v+9)}v=0;for(o=a.triangles.length;v<o;v+=4)g(a.triangles,v);v=0;for(o=a.triangles_n.length;v<
-o;v+=7)j(a.triangles_n,v);v=0;for(o=a.quads.length;v<o;v+=5)h(a.quads,v);v=0;for(o=a.quads_n.length;v<o;v+=9)m(a.quads_n,v)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(d))},v:function(a,c,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(a,c,d,e,f){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[f]))},f4:function(a,c,d,e,f,b){a.faces.push(new THREE.Face4(c,d,e,f,null,
-a.materials[b]))},f3n:function(a,c,d,e,f,b,g,j,h){b=a.materials[b];var m=c[j*3],n=c[j*3+1];j=c[j*3+2];var A=c[h*3],v=c[h*3+1];h=c[h*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(c[g*3],c[g*3+1],c[g*3+2]),new THREE.Vector3(m,n,j),new THREE.Vector3(A,v,h)],b))},f4n:function(a,c,d,e,f,b,g,j,h,m,n){g=a.materials[g];var A=c[h*3],v=c[h*3+1];h=c[h*3+2];var o=c[m*3],z=c[m*3+1];m=c[m*3+2];var C=c[n*3],G=c[n*3+1];n=c[n*3+2];a.faces.push(new THREE.Face4(d,e,f,b,[new THREE.Vector3(c[j*3],c[j*3+1],
-c[j*3+2]),new THREE.Vector3(A,v,h),new THREE.Vector3(o,z,m),new THREE.Vector3(C,G,n)],g))},uv3:function(a,c,d,e,f,b,g){var j=[];j.push(new THREE.UV(c,d));j.push(new THREE.UV(e,f));j.push(new THREE.UV(b,g));a.push(j)},uv4:function(a,c,d,e,f,b,g,j,h){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,f));m.push(new THREE.UV(b,g));m.push(new THREE.UV(j,h));a.push(m)},init_materials:function(a,c,d){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],
+X=m(a,E+p.normal_coordinate_bytes*2);l.push(L/127,J/127,X/127)}return p.nnormals*ea}(H);H+=function(E){var L,J,X=p.uv_coordinate_bytes*2,ea=E+p.nuvs*X;for(E=E;E<ea;E+=X){L=g(a,E);J=g(a,E+p.uv_coordinate_bytes);v.push(L,J)}return p.nuvs*X}(H);H=H;V=H+V;P=V+P;W=P+W;$=W+$;da=$+da;b=da+b;ha=b+ha;(function(E){var L,J=p.vertex_index_bytes*3+p.material_index_bytes,X=J+p.uv_index_bytes*3,ea=E+p.ntri_flat_uv*X;for(L=E;L<ea;L+=X){y(L);C(L+J)}return ea-E})(P);(function(E){var L,J=p.vertex_index_bytes*3+p.material_index_bytes+
+p.normal_index_bytes*3,X=J+p.uv_index_bytes*3,ea=E+p.ntri_smooth_uv*X;for(L=E;L<ea;L+=X){u(L);C(L+J)}return ea-E})(W);(function(E){var L,J=p.vertex_index_bytes*4+p.material_index_bytes,X=J+p.uv_index_bytes*4,ea=E+p.nquad_flat_uv*X;for(L=E;L<ea;L+=X){o(L);G(L+J)}return ea-E})(b);(function(E){var L,J=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,X=J+p.uv_index_bytes*4,ea=E+p.nquad_smooth_uv*X;for(L=E;L<ea;L+=X){A(L);G(L+J)}return ea-E})(ha);(function(E){var L,J=p.vertex_index_bytes*
+3+p.material_index_bytes,X=E+p.ntri_flat*J;for(L=E;L<X;L+=J)y(L);return X-E})(H);(function(E){var L,J=p.vertex_index_bytes*3+p.material_index_bytes+p.normal_index_bytes*3,X=E+p.ntri_smooth*J;for(L=E;L<X;L+=J)u(L);return X-E})(V);(function(E){var L,J=p.vertex_index_bytes*4+p.material_index_bytes,X=E+p.nquad_flat*J;for(L=E;L<X;L+=J)o(L);return X-E})($);(function(E){var L,J=p.vertex_index_bytes*4+p.material_index_bytes+p.normal_index_bytes*4,X=E+p.nquad_smooth*J;for(L=E;L<X;L+=J)A(L);return X-E})(da);
+this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;c(new f(d))},createModel:function(a,c,d){var e=function(f){var b=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(b,a.materials,f);(function(){var g,j,h,m,n;g=0;for(j=a.vertices.length;g<j;g+=3){h=a.vertices[g];m=a.vertices[g+1];n=a.vertices[g+2];THREE.Loader.prototype.v(b,h,m,n)}})();(function(){function g(A,C){THREE.Loader.prototype.f3(b,A[C],
+A[C+1],A[C+2],A[C+3])}function j(A,C){THREE.Loader.prototype.f3n(b,a.normals,A[C],A[C+1],A[C+2],A[C+3],A[C+4],A[C+5],A[C+6])}function h(A,C){THREE.Loader.prototype.f4(b,A[C],A[C+1],A[C+2],A[C+3],A[C+4])}function m(A,C){THREE.Loader.prototype.f4n(b,a.normals,A[C],A[C+1],A[C+2],A[C+3],A[C+4],A[C+5],A[C+6],A[C+7],A[C+8])}function n(A,C){var G,w,H,p,l,v,t,k,q;G=A[C];w=A[C+1];H=A[C+2];p=a.uvs[G*2];t=a.uvs[G*2+1];l=a.uvs[w*2];k=a.uvs[w*2+1];v=a.uvs[H*2];q=a.uvs[H*2+1];THREE.Loader.prototype.uv3(b.uvs,p,
+t,l,k,v,q);if(a.uvs2){p=a.uvs2[G*2];t=a.uvs2[G*2+1];l=a.uvs2[w*2];k=a.uvs2[w*2+1];v=a.uvs2[H*2];q=a.uvs2[H*2+1];THREE.Loader.prototype.uv3(b.uvs2,p,1-t,l,1-k,v,1-q)}}function y(A,C){var G,w,H,p,l,v,t,k,q,x,z,F;G=A[C];w=A[C+1];H=A[C+2];p=A[C+3];l=a.uvs[G*2];q=a.uvs[G*2+1];v=a.uvs[w*2];x=a.uvs[w*2+1];t=a.uvs[H*2];z=a.uvs[H*2+1];k=a.uvs[p*2];F=a.uvs[p*2+1];THREE.Loader.prototype.uv4(b.uvs,l,q,v,x,t,z,k,F);if(a.uvs2){l=a.uvs2[G*2];q=a.uvs2[G*2+1];v=a.uvs2[w*2];x=a.uvs2[w*2+1];t=a.uvs2[H*2];z=a.uvs2[H*
+2+1];k=a.uvs2[p*2];F=a.uvs2[p*2+1];THREE.Loader.prototype.uv4(b.uvs2,l,1-q,v,1-x,t,1-z,k,1-F)}}var u,o;u=0;for(o=a.triangles_uv.length;u<o;u+=7){g(a.triangles_uv,u);n(a.triangles_uv,u+4)}u=0;for(o=a.triangles_n_uv.length;u<o;u+=10){j(a.triangles_n_uv,u);n(a.triangles_n_uv,u+7)}u=0;for(o=a.quads_uv.length;u<o;u+=9){h(a.quads_uv,u);y(a.quads_uv,u+5)}u=0;for(o=a.quads_n_uv.length;u<o;u+=13){m(a.quads_n_uv,u);y(a.quads_n_uv,u+9)}u=0;for(o=a.triangles.length;u<o;u+=4)g(a.triangles,u);u=0;for(o=a.triangles_n.length;u<
+o;u+=7)j(a.triangles_n,u);u=0;for(o=a.quads.length;u<o;u+=5)h(a.quads,u);u=0;for(o=a.quads_n.length;u<o;u+=9)m(a.quads_n,u)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;c(new e(d))},v:function(a,c,d,e){a.vertices.push(new THREE.Vertex(new THREE.Vector3(c,d,e)))},f3:function(a,c,d,e,f){a.faces.push(new THREE.Face3(c,d,e,null,a.materials[f]))},f4:function(a,c,d,e,f,b){a.faces.push(new THREE.Face4(c,d,e,f,null,
+a.materials[b]))},f3n:function(a,c,d,e,f,b,g,j,h){b=a.materials[b];var m=c[j*3],n=c[j*3+1];j=c[j*3+2];var y=c[h*3],u=c[h*3+1];h=c[h*3+2];a.faces.push(new THREE.Face3(d,e,f,[new THREE.Vector3(c[g*3],c[g*3+1],c[g*3+2]),new THREE.Vector3(m,n,j),new THREE.Vector3(y,u,h)],b))},f4n:function(a,c,d,e,f,b,g,j,h,m,n){g=a.materials[g];var y=c[h*3],u=c[h*3+1];h=c[h*3+2];var o=c[m*3],A=c[m*3+1];m=c[m*3+2];var C=c[n*3],G=c[n*3+1];n=c[n*3+2];a.faces.push(new THREE.Face4(d,e,f,b,[new THREE.Vector3(c[j*3],c[j*3+1],
+c[j*3+2]),new THREE.Vector3(y,u,h),new THREE.Vector3(o,A,m),new THREE.Vector3(C,G,n)],g))},uv3:function(a,c,d,e,f,b,g){var j=[];j.push(new THREE.UV(c,d));j.push(new THREE.UV(e,f));j.push(new THREE.UV(b,g));a.push(j)},uv4:function(a,c,d,e,f,b,g,j,h){var m=[];m.push(new THREE.UV(c,d));m.push(new THREE.UV(e,f));m.push(new THREE.UV(b,g));m.push(new THREE.UV(j,h));a.push(m)},init_materials:function(a,c,d){a.materials=[];for(var e=0;e<c.length;++e)a.materials[e]=[THREE.Loader.prototype.createMaterial(c[e],
 d)]},createMaterial:function(a,c){function d(g){g=Math.log(g)/Math.LN2;return Math.floor(g)==g}function e(g,j){var h=new Image;h.onload=function(){if(!d(this.width)||!d(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),n=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));g.image.width=m;g.image.height=n;g.image.getContext("2d").drawImage(this,0,0,m,n)}else g.image=this;g.image.loaded=1};h.src=j}var f,b;if(a.map_diffuse&&c){b=document.createElement("canvas");f=new THREE.MeshLambertMaterial({map:new THREE.Texture(b)});
 e(f.map,c+"/"+a.map_diffuse)}else if(a.col_diffuse){f=(a.col_diffuse[0]*255<<16)+(a.col_diffuse[1]*255<<8)+a.col_diffuse[2]*255;f=new THREE.MeshLambertMaterial({color:f,opacity:a.transparency})}else f=a.a_dbg_color?new THREE.MeshLambertMaterial({color:a.a_dbg_color}):new THREE.MeshLambertMaterial({color:15658734});if(a.map_lightmap&&c){b=document.createElement("canvas");f.light_map=new THREE.Texture(b);e(f.light_map,c+"/"+a.map_lightmap)}return f},extractUrlbase:function(a){a=a.split("/");a.pop();
 return a.join("/")}};

+ 12 - 8
src/extras/objects/MarchingCubes.js

@@ -611,14 +611,18 @@ THREE.MarchingCubes = function ( resolution, materials ) {
 			
 			for( i = 0; i < object.count; i++ ) {
 				
-				x = object.positionArray[ i * 3 ];
-				y = object.positionArray[ i * 3 + 1 ];
-				z = object.positionArray[ i * 3 + 2 ];
+				a = i * 3;
+				b = a + 1;
+				c = a + 2;
+				
+				x = object.positionArray[ a ];
+				y = object.positionArray[ b ];
+				z = object.positionArray[ c ];
 				position = new THREE.Vector3( x, y, z );
 
-				x = object.normalArray[ i * 3 ];
-				y = object.normalArray[ i * 3 + 1 ];
-				z = object.normalArray[ i * 3 + 2 ];
+				x = object.normalArray[ a ];
+				y = object.normalArray[ b ];
+				z = object.normalArray[ c ];
 				normal = new THREE.Vector3( x, y, z );
 				normal.normalize();
 				
@@ -633,8 +637,8 @@ THREE.MarchingCubes = function ( resolution, materials ) {
 			for( i = 0; i < nfaces; i++ ) {
 				
 				a = ( start + i ) * 3;
-				b = ( start + i ) * 3 + 1;
-				c = ( start + i ) * 3 + 2;
+				b = a + 1;
+				c = a + 2;
 
 				na = geo.vertices[ a ].normal;
 				nb = geo.vertices[ b ].normal;