Browse Source

Moved Object::sortObjectByMaterials to WebGLRenderer (so it's done automagically).
WebGLRenderer: renamed geometryChunks to geometryGroups :P

Mr.doob 14 years ago
parent
commit
88c2d7c77b

+ 204 - 204
build/Three.js

@@ -11,35 +11,35 @@ a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-th
 this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,f=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(f=f.concat(this.intersectObject(c)))}f.sort(function(g,h){return g.distance-h.distance});return f},intersectObject:function(a){function b(H,u,I,o){o=o.clone().subSelf(u);I=I.clone().subSelf(u);var M=H.clone().subSelf(u);H=o.dot(o);u=o.dot(I);o=o.dot(M);var e=I.dot(I);I=I.dot(M);M=1/(H*e-u*u);e=(e*o-u*I)*M;H=(H*I-u*o)*M;return e>0&&H>0&&e+H<1}var c,d,f,g,h,k,j,l,n,v,
-p,q=a.geometry,w=q.vertices,B=[];c=0;for(d=q.faces.length;c<d;c++){f=q.faces[c];v=this.origin.clone();p=this.direction.clone();j=a.matrixWorld;g=j.multiplyVector3(w[f.a].position.clone());h=j.multiplyVector3(w[f.b].position.clone());k=j.multiplyVector3(w[f.c].position.clone());j=f instanceof THREE.Face4?j.multiplyVector3(w[f.d].position.clone()):null;l=a.matrixRotationWorld.multiplyVector3(f.normal.clone());n=p.dot(l);if(n<0){l=l.dot((new THREE.Vector3).sub(g,v))/n;v=v.addSelf(p.multiplyScalar(l));
-if(f instanceof THREE.Face3){if(b(v,g,h,k)){f={distance:this.origin.distanceTo(v),point:v,face:f,object:a};B.push(f)}}else if(f instanceof THREE.Face4&&(b(v,g,h,j)||b(v,h,k,j))){f={distance:this.origin.distanceTo(v),point:v,face:f,object:a};B.push(f)}}}return B}};
-THREE.Rectangle=function(){function a(){g=d-b;h=f-c}var b,c,d,f,g,h,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(j,l,n,v){k=!1;b=j;c=l;d=n;f=v;a()};this.addPoint=function(j,l){if(k){k=!1;b=j;c=l;d=j;f=l}else{b=b<j?b:j;c=c<l?c:l;d=d>j?d:j;f=f>l?f:l}a()};
-this.add3Points=function(j,l,n,v,p,q){if(k){k=!1;b=j<n?j<p?j:p:n<p?n:p;c=l<v?l<q?l:q:v<q?v:q;d=j>n?j>p?j:p:n>p?n:p;f=l>v?l>q?l:q:v>q?v:q}else{b=j<n?j<p?j<b?j:b:p<b?p:b:n<p?n<b?n:b:p<b?p:b;c=l<v?l<q?l<c?l:c:q<c?q:c:v<q?v<c?v:c:q<c?q:c;d=j>n?j>p?j>d?j:d:p>d?p:d:n>p?n>d?n:d:p>d?p:d;f=l>v?l>q?l>f?l:f:q>f?q:f:v>q?v>f?v:f:q>f?q:f}a()};this.addRectangle=function(j){if(k){k=!1;b=j.getLeft();c=j.getTop();d=j.getRight();f=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();c=c<j.getTop()?c:j.getTop();d=d>j.getRight()?
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,f=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(f=f.concat(this.intersectObject(c)))}f.sort(function(g,h){return g.distance-h.distance});return f},intersectObject:function(a){function b(I,v,J,t){t=t.clone().subSelf(v);J=J.clone().subSelf(v);var K=I.clone().subSelf(v);I=t.dot(t);v=t.dot(J);t=t.dot(K);var R=J.dot(J);J=J.dot(K);K=1/(I*R-v*v);R=(R*t-v*J)*K;I=(I*J-v*t)*K;return R>0&&I>0&&R+I<1}var c,d,f,g,h,k,j,m,n,w,
+o,p=a.geometry,x=p.vertices,A=[];c=0;for(d=p.faces.length;c<d;c++){f=p.faces[c];w=this.origin.clone();o=this.direction.clone();j=a.matrixWorld;g=j.multiplyVector3(x[f.a].position.clone());h=j.multiplyVector3(x[f.b].position.clone());k=j.multiplyVector3(x[f.c].position.clone());j=f instanceof THREE.Face4?j.multiplyVector3(x[f.d].position.clone()):null;m=a.matrixRotationWorld.multiplyVector3(f.normal.clone());n=o.dot(m);if(n<0){m=m.dot((new THREE.Vector3).sub(g,w))/n;w=w.addSelf(o.multiplyScalar(m));
+if(f instanceof THREE.Face3){if(b(w,g,h,k)){f={distance:this.origin.distanceTo(w),point:w,face:f,object:a};A.push(f)}}else if(f instanceof THREE.Face4&&(b(w,g,h,j)||b(w,h,k,j))){f={distance:this.origin.distanceTo(w),point:w,face:f,object:a};A.push(f)}}}return A}};
+THREE.Rectangle=function(){function a(){g=d-b;h=f-c}var b,c,d,f,g,h,k=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return f};this.set=function(j,m,n,w){k=!1;b=j;c=m;d=n;f=w;a()};this.addPoint=function(j,m){if(k){k=!1;b=j;c=m;d=j;f=m}else{b=b<j?b:j;c=c<m?c:m;d=d>j?d:j;f=f>m?f:m}a()};
+this.add3Points=function(j,m,n,w,o,p){if(k){k=!1;b=j<n?j<o?j:o:n<o?n:o;c=m<w?m<p?m:p:w<p?w:p;d=j>n?j>o?j:o:n>o?n:o;f=m>w?m>p?m:p:w>p?w:p}else{b=j<n?j<o?j<b?j:b:o<b?o:b:n<o?n<b?n:b:o<b?o:b;c=m<w?m<p?m<c?m:c:p<c?p:c:w<p?w<c?w:c:p<c?p:c;d=j>n?j>o?j>d?j:d:o>d?o:d:n>o?n>d?n:d:o>d?o:d;f=m>w?m>p?m>f?m:f:p>f?p:f:w>p?w>f?w:f:p>f?p:f}a()};this.addRectangle=function(j){if(k){k=!1;b=j.getLeft();c=j.getTop();d=j.getRight();f=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();c=c<j.getTop()?c:j.getTop();d=d>j.getRight()?
 d:j.getRight();f=f>j.getBottom()?f:j.getBottom()}a()};this.inflate=function(j){b-=j;c-=j;d+=j;f+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();c=c>j.getTop()?c:j.getTop();d=d<j.getRight()?d:j.getRight();f=f<j.getBottom()?f:j.getBottom();a()};this.instersects=function(j){return Math.min(d,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(f,j.getBottom())-Math.max(c,j.getTop())>=0};this.empty=function(){k=!0;f=d=c=b=0;a()};this.isEmpty=function(){return k}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,d,f,g,h,k,j,l,n,v,p,q,w,B){this.set(a||1,b||0,c||0,d||0,f||0,g||1,h||0,k||0,j||0,l||0,n||1,v||0,p||0,q||0,w||0,B||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,d,f,g,h,k,j,l,n,v,p,q,w,B){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=l;this.n33=n;this.n34=v;this.n41=p;this.n42=q;this.n43=w;this.n44=B;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,
+THREE.Matrix4=function(a,b,c,d,f,g,h,k,j,m,n,w,o,p,x,A){this.set(a||1,b||0,c||0,d||0,f||0,g||1,h||0,k||0,j||0,m||0,n||1,w||0,o||0,p||0,x||0,A||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,f,g,h,k,j,m,n,w,o,p,x,A){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=f;this.n22=g;this.n23=h;this.n24=k;this.n31=j;this.n32=m;this.n33=n;this.n34=w;this.n41=o;this.n42=p;this.n43=x;this.n44=A;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,
 f=THREE.Matrix4.__tmpVec2,g=THREE.Matrix4.__tmpVec3;g.sub(a,b).normalize();d.cross(c,g).normalize();f.cross(g,d).normalize();this.n11=d.x;this.n12=f.x;this.n13=g.x;this.n14=a.x;this.n21=d.y;this.n22=f.y;this.n23=g.y;this.n24=a.y;this.n31=d.z;this.n32=f.z;this.n33=g.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,f=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*f;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*f;a.z=(this.n31*
 b+this.n32*c+this.n33*d+this.n34)*f;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,f=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*f;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*f;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*f;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*f;return a},crossVector:function(a){var b=new THREE.Vector4;
-b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,l=a.n24,n=a.n31,v=a.n32,p=a.n33,q=a.n34,w=a.n41,B=a.n42,H=a.n43,u=a.n44,I=b.n11,o=b.n12,M=b.n13,e=b.n14,ba=b.n21,O=b.n22,P=b.n23,V=b.n24,T=b.n31,Y=b.n32,da=b.n33,J=b.n34;this.n11=
-c*I+d*ba+f*T;this.n12=c*o+d*O+f*Y;this.n13=c*M+d*P+f*da;this.n14=c*e+d*V+f*J+g;this.n21=h*I+k*ba+j*T;this.n22=h*o+k*O+j*Y;this.n23=h*M+k*P+j*da;this.n24=h*e+k*V+j*J+l;this.n31=n*I+v*ba+p*T;this.n32=n*o+v*O+p*Y;this.n33=n*M+v*P+p*da;this.n34=n*e+v*V+p*J+q;this.n41=w*I+B*ba+H*T;this.n42=w*o+B*O+H*Y;this.n43=w*M+B*P+H*da;this.n44=w*e+B*V+H*J+u;return this},multiplyToArray:function(a,b,c){var d=a.n11,f=a.n12,g=a.n13,h=a.n14,k=a.n21,j=a.n22,l=a.n23,n=a.n24,v=a.n31,p=a.n32,q=a.n33,w=a.n34,B=a.n41,H=a.n42,
-u=a.n43;a=a.n44;var I=b.n11,o=b.n12,M=b.n13,e=b.n14,ba=b.n21,O=b.n22,P=b.n23,V=b.n24,T=b.n31,Y=b.n32,da=b.n33,J=b.n34,$=b.n41,ra=b.n42,Z=b.n43;b=b.n44;this.n11=d*I+f*ba+g*T+h*$;this.n12=d*o+f*O+g*Y+h*ra;this.n13=d*M+f*P+g*da+h*Z;this.n14=d*e+f*V+g*J+h*b;this.n21=k*I+j*ba+l*T+n*$;this.n22=k*o+j*O+l*Y+n*ra;this.n23=k*M+j*P+l*da+n*Z;this.n24=k*e+j*V+l*J+n*b;this.n31=v*I+p*ba+q*T+w*$;this.n32=v*o+p*O+q*Y+w*ra;this.n33=v*M+p*P+q*da+w*Z;this.n34=v*e+p*V+q*J+w*b;this.n41=B*I+H*ba+u*T+a*$;this.n42=B*o+H*
-O+u*Y+a*ra;this.n43=B*M+H*P+u*da+a*Z;this.n44=B*e+H*V+u*J+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,f=this.n14,g=this.n21,h=this.n22,k=this.n23,j=this.n24,l=this.n31,n=this.n32,v=this.n33,p=this.n34,q=this.n41,w=this.n42,B=this.n43,H=
-this.n44,u=a.n11,I=a.n21,o=a.n31,M=a.n12,e=a.n22,ba=a.n32,O=a.n13,P=a.n23,V=a.n33,T=a.n14,Y=a.n24;a=a.n34;this.n11=b*u+c*I+d*o;this.n12=b*M+c*e+d*ba;this.n13=b*O+c*P+d*V;this.n14=b*T+c*Y+d*a+f;this.n21=g*u+h*I+k*o;this.n22=g*M+h*e+k*ba;this.n23=g*O+h*P+k*V;this.n24=g*T+h*Y+k*a+j;this.n31=l*u+n*I+v*o;this.n32=l*M+n*e+v*ba;this.n33=l*O+n*P+v*V;this.n34=l*T+n*Y+v*a+p;this.n41=q*u+w*I+B*o;this.n42=q*M+w*e+B*ba;this.n43=q*O+w*P+B*V;this.n44=q*T+w*Y+B*a+H;return this},multiplyScalar:function(a){this.n11*=
-a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,l=this.n32,n=this.n33,v=this.n34,p=this.n41,q=this.n42,w=this.n43,B=this.n44;return d*h*l*p-c*k*l*p-d*g*n*p+b*k*n*p+c*g*v*p-b*h*v*p-d*h*j*q+c*k*j*q+d*f*n*q-a*k*n*q-c*f*v*q+a*h*v*q+
-d*g*j*w-b*k*j*w-d*f*l*w+a*k*l*w+b*f*v*w-a*g*v*w-c*g*j*B+b*h*j*B+c*f*l*B-a*h*l*B-b*f*n*B+a*g*n*B},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;
+b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,n=a.n31,w=a.n32,o=a.n33,p=a.n34,x=a.n41,A=a.n42,I=a.n43,v=a.n44,J=b.n11,t=b.n12,K=b.n13,R=b.n14,e=b.n21,O=b.n22,Q=b.n23,W=b.n24,U=b.n31,aa=b.n32,ea=b.n33,M=b.n34;this.n11=
+c*J+d*e+f*U;this.n12=c*t+d*O+f*aa;this.n13=c*K+d*Q+f*ea;this.n14=c*R+d*W+f*M+g;this.n21=h*J+k*e+j*U;this.n22=h*t+k*O+j*aa;this.n23=h*K+k*Q+j*ea;this.n24=h*R+k*W+j*M+m;this.n31=n*J+w*e+o*U;this.n32=n*t+w*O+o*aa;this.n33=n*K+w*Q+o*ea;this.n34=n*R+w*W+o*M+p;this.n41=x*J+A*e+I*U;this.n42=x*t+A*O+I*aa;this.n43=x*K+A*Q+I*ea;this.n44=x*R+A*W+I*M+v;return this},multiplyToArray:function(a,b,c){var d=a.n11,f=a.n12,g=a.n13,h=a.n14,k=a.n21,j=a.n22,m=a.n23,n=a.n24,w=a.n31,o=a.n32,p=a.n33,x=a.n34,A=a.n41,I=a.n42,
+v=a.n43;a=a.n44;var J=b.n11,t=b.n12,K=b.n13,R=b.n14,e=b.n21,O=b.n22,Q=b.n23,W=b.n24,U=b.n31,aa=b.n32,ea=b.n33,M=b.n34,X=b.n41,pa=b.n42,ba=b.n43;b=b.n44;this.n11=d*J+f*e+g*U+h*X;this.n12=d*t+f*O+g*aa+h*pa;this.n13=d*K+f*Q+g*ea+h*ba;this.n14=d*R+f*W+g*M+h*b;this.n21=k*J+j*e+m*U+n*X;this.n22=k*t+j*O+m*aa+n*pa;this.n23=k*K+j*Q+m*ea+n*ba;this.n24=k*R+j*W+m*M+n*b;this.n31=w*J+o*e+p*U+x*X;this.n32=w*t+o*O+p*aa+x*pa;this.n33=w*K+o*Q+p*ea+x*ba;this.n34=w*R+o*W+p*M+x*b;this.n41=A*J+I*e+v*U+a*X;this.n42=A*t+
+I*O+v*aa+a*pa;this.n43=A*K+I*Q+v*ea+a*ba;this.n44=A*R+I*W+v*M+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,f=this.n14,g=this.n21,h=this.n22,k=this.n23,j=this.n24,m=this.n31,n=this.n32,w=this.n33,o=this.n34,p=this.n41,x=this.n42,A=this.n43,
+I=this.n44,v=a.n11,J=a.n21,t=a.n31,K=a.n12,R=a.n22,e=a.n32,O=a.n13,Q=a.n23,W=a.n33,U=a.n14,aa=a.n24;a=a.n34;this.n11=b*v+c*J+d*t;this.n12=b*K+c*R+d*e;this.n13=b*O+c*Q+d*W;this.n14=b*U+c*aa+d*a+f;this.n21=g*v+h*J+k*t;this.n22=g*K+h*R+k*e;this.n23=g*O+h*Q+k*W;this.n24=g*U+h*aa+k*a+j;this.n31=m*v+n*J+w*t;this.n32=m*K+n*R+w*e;this.n33=m*O+n*Q+w*W;this.n34=m*U+n*aa+w*a+o;this.n41=p*v+x*J+A*t;this.n42=p*K+x*R+A*e;this.n43=p*O+x*Q+A*W;this.n44=p*U+x*aa+A*a+I;return this},multiplyScalar:function(a){this.n11*=
+a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,f=this.n21,g=this.n22,h=this.n23,k=this.n24,j=this.n31,m=this.n32,n=this.n33,w=this.n34,o=this.n41,p=this.n42,x=this.n43,A=this.n44;return d*h*m*o-c*k*m*o-d*g*n*o+b*k*n*o+c*g*w*o-b*h*w*o-d*h*j*p+c*k*j*p+d*f*n*p-a*k*n*p-c*f*w*p+a*h*w*p+
+d*g*j*x-b*k*j*x-d*f*m*x+a*k*m*x+b*f*w*x-a*g*w*x-c*g*j*A+b*h*j*A+c*f*m*A-a*h*m*A-b*f*n*A+a*g*n*A},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;
 a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flattenToArray(this.flat);return this.flat},flattenToArray:function(a){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},flattenToArrayOffset:function(a,
 b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,
-0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,g=a.x,h=a.y,k=a.z,j=f*g,l=f*h;this.set(j*g+c,j*h-d*k,j*k+d*h,0,j*h+d*k,l*h+c,l*k-d*g,0,j*k-d*h,l*k+d*g,f*k*k+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=
-a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=a*c,k=b*c;this.n11=f*g;this.n12=-f*d;this.n13=c;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-b*f;this.n31=-h*g+b*d;this.n32=h*d+b*g;this.n33=a*f},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,f=a.w,g=b+b,h=c+c,k=d+d;a=b*g;var j=b*h;b*=k;var l=c*h;c*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(l+d);this.n12=j-f;this.n13=
-b+h;this.n21=j+f;this.n22=1-(a+d);this.n23=c-g;this.n31=b-h;this.n32=c+g;this.n33=1-(a+l)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};
+0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),f=1-c,g=a.x,h=a.y,k=a.z,j=f*g,m=f*h;this.set(j*g+c,j*h-d*k,j*k+d*h,0,j*h+d*k,m*h+c,m*k-d*g,0,j*k-d*h,m*k+d*g,f*k*k+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=
+a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=a*c,k=b*c;this.n11=f*g;this.n12=-f*d;this.n13=c;this.n21=k*g+a*d;this.n22=-k*d+a*g;this.n23=-b*f;this.n31=-h*g+b*d;this.n32=h*d+b*g;this.n33=a*f},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,f=a.w,g=b+b,h=c+c,k=d+d;a=b*g;var j=b*h;b*=k;var m=c*h;c*=k;d*=k;g*=f;h*=f;f*=k;this.n11=1-(m+d);this.n12=j-f;this.n13=
+b+h;this.n21=j+f;this.n22=1-(a+d);this.n23=c-g;this.n31=b-h;this.n32=c+g;this.n33=1-(a+m)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};
 THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,l=a.n24,n=a.n31,v=a.n32,p=a.n33,q=a.n34,w=a.n41,B=a.n42,H=a.n43,u=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=j*q*B-l*p*B+l*v*H-k*q*H-j*v*u+k*p*u;b.n12=g*p*B-f*q*B-g*v*H+d*q*H+f*v*u-d*p*u;b.n13=f*l*B-g*j*B+g*k*H-d*l*H-f*k*u+d*j*u;b.n14=g*j*v-f*l*v-g*k*p+d*l*p+f*k*q-d*j*q;b.n21=l*p*w-j*q*w-l*n*H+h*q*H+j*n*u-h*p*u;b.n22=f*q*w-g*p*w+g*n*H-c*q*H-f*n*u+c*p*u;b.n23=g*j*w-f*l*w-g*h*H+c*l*H+f*h*u-c*j*u;
-b.n24=f*l*n-g*j*n+g*h*p-c*l*p-f*h*q+c*j*q;b.n31=k*q*w-l*v*w+l*n*B-h*q*B-k*n*u+h*v*u;b.n32=g*v*w-d*q*w-g*n*B+c*q*B+d*n*u-c*v*u;b.n33=f*l*w-g*k*w+g*h*B-c*l*B-d*h*u+c*k*u;b.n34=g*k*n-d*l*n-g*h*v+c*l*v+d*h*q-c*k*q;b.n41=j*v*w-k*p*w-j*n*B+h*p*B+k*n*H-h*v*H;b.n42=d*p*w-f*v*w+f*n*B-c*p*B-d*n*H+c*v*H;b.n43=f*k*w-d*j*w-f*h*B+c*j*B+d*h*H-c*k*H;b.n44=d*j*n-f*k*n+f*h*v-c*j*v-d*h*p+c*k*p;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,v=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*l;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*l;c[7]=a*n;c[8]=a*v;return b};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,f=a.n13,g=a.n14,h=a.n21,k=a.n22,j=a.n23,m=a.n24,n=a.n31,w=a.n32,o=a.n33,p=a.n34,x=a.n41,A=a.n42,I=a.n43,v=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=j*p*A-m*o*A+m*w*I-k*p*I-j*w*v+k*o*v;b.n12=g*o*A-f*p*A-g*w*I+d*p*I+f*w*v-d*o*v;b.n13=f*m*A-g*j*A+g*k*I-d*m*I-f*k*v+d*j*v;b.n14=g*j*w-f*m*w-g*k*o+d*m*o+f*k*p-d*j*p;b.n21=m*o*x-j*p*x-m*n*I+h*p*I+j*n*v-h*o*v;b.n22=f*p*x-g*o*x+g*n*I-c*p*I-f*n*v+c*o*v;b.n23=g*j*x-f*m*x-g*h*I+c*m*I+f*h*v-c*j*v;
+b.n24=f*m*n-g*j*n+g*h*o-c*m*o-f*h*p+c*j*p;b.n31=k*p*x-m*w*x+m*n*A-h*p*A-k*n*v+h*w*v;b.n32=g*w*x-d*p*x-g*n*A+c*p*A+d*n*v-c*w*v;b.n33=f*m*x-g*k*x+g*h*A-c*m*A-d*h*v+c*k*v;b.n34=g*k*n-d*m*n-g*h*w+c*m*w+d*h*p-c*k*p;b.n41=j*w*x-k*o*x-j*n*A+h*o*A+k*n*I-h*w*I;b.n42=d*o*x-f*w*x+f*n*A-c*o*A-d*n*I+c*w*I;b.n43=f*k*x-d*j*x-f*h*A+c*j*A+d*h*I-c*k*I;b.n44=d*j*n-f*k*n+f*h*w-c*j*w-d*h*o+c*k*o;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,f=-a.n33*a.n21+a.n31*a.n23,g=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,k=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,m=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*m;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*f;c[2]=a*g;c[3]=a*h;c[4]=a*k;c[5]=a*j;c[6]=a*m;c[7]=a*n;c[8]=a*w;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,f,g){var h;h=new THREE.Matrix4;h.n11=2*f/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*f/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+f)/(g-f);h.n34=-2*g*f/(g-f);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var f;a=c*Math.tan(a*Math.PI/360);f=-a;return THREE.Matrix4.makeFrustum(f*b,a*b,f,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var h,k,j,l;h=new THREE.Matrix4;k=b-a;j=c-d;l=g-f;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((b+a)/k);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((c+d)/j);h.n31=0;h.n32=0;h.n33=-2/l;h.n34=-((g+f)/l);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeOrtho=function(a,b,c,d,f,g){var h,k,j,m;h=new THREE.Matrix4;k=b-a;j=c-d;m=g-f;h.n11=2/k;h.n12=0;h.n13=0;h.n14=-((b+a)/k);h.n21=0;h.n22=2/j;h.n23=0;h.n24=-((c+d)/j);h.n31=0;h.n32=0;h.n33=-2/m;h.n34=-((g+f)/m);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;
 this.visible=!0};
 THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);
@@ -48,30 +48,29 @@ this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.
 THREE.Object3DCounter={value:0};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
 THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,f=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-f);f=Math.sin(-f);var g=Math.cos(c);c=Math.sin(c);var h=a*b,k=d*f;this.w=h*g-k*c;this.x=h*c+k*g;this.y=d*b*g+a*f*c;this.z=a*f*g-d*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
 -1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,f=this.w,g=a.x,h=a.y,k=a.z;a=a.w;this.x=b*a+f*g+c*k-d*h;this.y=c*a+f*h+d*g-b*k;this.z=d*a+f*k+b*h-c*g;this.w=f*a-b*g-c*h-d*k;return this},
-multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,h=this.y,k=this.z,j=this.w,l=j*c+h*f-k*d,n=j*d+k*c-g*f,v=j*f+g*d-h*c;c=-g*c-h*d-k*f;b.x=l*j+c*-g+n*-k-v*-h;b.y=n*j+c*-h+v*-g-l*-k;b.z=v*j+c*-k+l*-h-n*-g;return b}};
+multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,f=a.z,g=this.x,h=this.y,k=this.z,j=this.w,m=j*c+h*f-k*d,n=j*d+k*c-g*f,w=j*f+g*d-h*c;c=-g*c-h*d-k*f;b.x=m*j+c*-g+n*-k-w*-h;b.y=n*j+c*-h+w*-g-m*-k;b.z=w*j+c*-k+m*-h-n*-g;return b}};
 THREE.Quaternion.slerp=function(a,b,c,d){var f=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(f)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(f),h=Math.sqrt(1-f*f);if(Math.abs(h)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}f=Math.sin((1-d)*g)/h;d=Math.sin(d*g)/h;c.w=a.w*f+b.w*d;c.x=a.x*f+b.x*d;c.y=a.y*f+b.y*d;c.z=a.z*f+b.z*d;return c};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};
 THREE.Face3=function(a,b,c,d,f){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=f instanceof Array?f:[f]};THREE.Face4=function(a,b,c,d,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=f instanceof THREE.Vector3?f:new THREE.Vector3;this.vertexNormals=f instanceof Array?f:[];this.materials=g instanceof Array?g:[g]};
-THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=!1};
+THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,f,g,h,k=new THREE.Vector3,j=new THREE.Vector3;d=0;for(f=this.vertices.length;d<f;d++){g=this.vertices[d];g.normal.set(0,0,0)}d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];if(a&&g.vertexNormals.length){k.set(0,0,0);b=0;for(c=g.normal.length;b<c;b++)k.addSelf(g.vertexNormals[b]);k.divideScalar(3)}else{b=this.vertices[g.a];c=this.vertices[g.b];h=this.vertices[g.c];k.sub(h.position,
 c.position);j.sub(b.position,c.position);k.crossSelf(j)}k.isZero()||k.normalize();g.normal.copy(k)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<
-b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(J,$,ra,Z,la,ja,fa){g=J.vertices[$].position;h=J.vertices[ra].position;k=J.vertices[Z].position;j=f[la];l=f[ja];n=f[fa];v=h.x-g.x;p=k.x-g.x;q=h.y-g.y;w=
-k.y-g.y;B=h.z-g.z;H=k.z-g.z;u=l.u-j.u;I=n.u-j.u;o=l.v-j.v;M=n.v-j.v;e=1/(u*M-I*o);P.set((M*v-o*p)*e,(M*q-o*w)*e,(M*B-o*H)*e);V.set((u*p-I*v)*e,(u*w-I*q)*e,(u*H-I*B)*e);ba[$].addSelf(P);ba[ra].addSelf(P);ba[Z].addSelf(P);O[$].addSelf(V);O[ra].addSelf(V);O[Z].addSelf(V)}var b,c,d,f,g,h,k,j,l,n,v,p,q,w,B,H,u,I,o,M,e,ba=[],O=[],P=new THREE.Vector3,V=new THREE.Vector3,T=new THREE.Vector3,Y=new THREE.Vector3,da=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){ba[b]=new THREE.Vector3;O[b]=new THREE.Vector3}b=
+b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(M,X,pa,ba,la,ia,ga){g=M.vertices[X].position;h=M.vertices[pa].position;k=M.vertices[ba].position;j=f[la];m=f[ia];n=f[ga];w=h.x-g.x;o=k.x-g.x;p=h.y-g.y;
+x=k.y-g.y;A=h.z-g.z;I=k.z-g.z;v=m.u-j.u;J=n.u-j.u;t=m.v-j.v;K=n.v-j.v;R=1/(v*K-J*t);Q.set((K*w-t*o)*R,(K*p-t*x)*R,(K*A-t*I)*R);W.set((v*o-J*w)*R,(v*x-J*p)*R,(v*I-J*A)*R);e[X].addSelf(Q);e[pa].addSelf(Q);e[ba].addSelf(Q);O[X].addSelf(W);O[pa].addSelf(W);O[ba].addSelf(W)}var b,c,d,f,g,h,k,j,m,n,w,o,p,x,A,I,v,J,t,K,R,e=[],O=[],Q=new THREE.Vector3,W=new THREE.Vector3,U=new THREE.Vector3,aa=new THREE.Vector3,ea=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){e[b]=new THREE.Vector3;O[b]=new THREE.Vector3}b=
 0;for(c=this.faces.length;b<c;b++){d=this.faces[b];f=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
-this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){da.copy(this.vertices[b].normal);d=ba[b];T.copy(d);T.subSelf(da.multiplyScalar(da.dot(d))).normalize();Y.cross(this.vertices[b].normal,d);d=Y.dot(O[b]);d=d<0?-1:1;this.vertices[b].tangent.set(T.x,T.y,T.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
+this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){ea.copy(this.vertices[b].normal);d=e[b];U.copy(d);U.subSelf(ea.multiplyScalar(ea.dot(d))).normalize();aa.cross(this.vertices[b].normal,d);d=aa.dot(O[b]);d=d<0?-1:1;this.vertices[b].tangent.set(U.x,U.y,U.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var v=[];b=0;for(c=n.length;b<c;b++)n[b]==undefined?v.push("undefined"):v.push(n[b].id);return v.join("_")}var b,c,d,f,g,h,k,j,l={};d=0;for(f=this.faces.length;d<f;d++){g=this.faces[d];
-h=g.materials;k=a(h);l[k]==undefined&&(l[k]={hash:k,counter:0});j=l[k].hash+"_"+l[k].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:h,vertices:0});g=g instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+g>65535){l[k].counter+=1;j=l[k].hash+"_"+l[k].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:h,vertices:0})}this.geometryChunks[j].faces.push(d);this.geometryChunks[j].vertices+=g}}};THREE.GeometryIdCounter=0;
-THREE.Spline=function(){function a(p,q,w,B,H,u,I){p=(w-p)*0.5;B=(B-q)*0.5;return(2*(q-w)+p+B)*I+(-3*(q-w)-2*p-B)*u+p*H+q}var b=[],c={x:0,y:0,z:0},d,f,g,h,k,j,l,n,v;this.get2DPoint=function(p,q){d=(p.length-1)*q;f=Math.floor(d);g=d-f;b[0]=f==0?f:f-1;b[1]=f;b[2]=f>p.length-2?f:f+1;b[3]=f>p.length-3?f:f+2;j=p[b[0]];l=p[b[1]];n=p[b[2]];v=p[b[3]];h=g*g;k=g*h;c.x=a(j.x,l.x,n.x,v.x,g,h,k);c.y=a(j.y,l.y,n.y,v.y,g,h,k);c.z=a(j.z,l.z,n.z,v.z,g,h,k);return c}};
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
+THREE.Spline=function(){function a(o,p,x,A,I,v,J){o=(x-o)*0.5;A=(A-p)*0.5;return(2*(p-x)+o+A)*J+(-3*(p-x)-2*o-A)*v+o*I+p}var b=[],c={x:0,y:0,z:0},d,f,g,h,k,j,m,n,w;this.get2DPoint=function(o,p){d=(o.length-1)*p;f=Math.floor(d);g=d-f;b[0]=f==0?f:f-1;b[1]=f;b[2]=f>o.length-2?f:f+1;b[3]=f>o.length-3?f:f+2;j=o[b[0]];m=o[b[1]];n=o[b[2]];w=o[b[3]];h=g*g;k=g*h;c.x=a(j.x,m.x,n.x,w.x,g,h,k);c.y=a(j.y,m.y,n.y,w.y,g,h,k);c.z=a(j.z,m.z,n.z,w.z,g,h,k);return c}};
 THREE.AnimationHandler=function(){var a=[],b={};b.update=function(c){for(var d=0;d<a.length;d++)a[d].update(c)};b.add=function(c){a.indexOf(c)===-1&&a.push(c)};b.remove=function(c){a.indexOf(c)!==-1&&a.splice(childIndex,1)};b.initData=function(c){if(c.initialized!==!0){for(var d=0;d<c.hierarchy.length;d++)for(var f=0;f<c.hierarchy[d].keys.length;f++){if(c.hierarchy[d].keys[f].time<0)c.hierarchy[d].keys[f].time=0;c.hierarchy[d].keys[f].index=f;if(c.hierarchy[d].keys[f].rot!==undefined&&!(c.hierarchy[d].keys[f].rot instanceof
 THREE.Quaternion)){var g=c.hierarchy[d].keys[f].rot;c.hierarchy[d].keys[f].rot=new THREE.Quaternion(g[0],g[1],g[2],g[3])}}f=parseInt(c.length*c.fps,10);c.JIT={};c.JIT.hierarchy=[];for(d=0;d<c.hierarchy.length;d++)c.JIT.hierarchy.push(Array(f));c.initialized=!0}};return b}();
 THREE.Animation=function(a,b){this.root=a;this.data=b;this.hierarchy=[];this.startTime=0;this.isPlaying=!1;this.loop=!0;this.offset=0;this.data.initialized||THREE.AnimationHandler.initData(this.data);if(a instanceof THREE.SkinnedMesh)for(var c=0;c<this.root.bones.length;c++)this.hierarchy.push(this.root.bones[c])};
 THREE.Animation.prototype.play=function(){if(!this.isPlaying){this.isPlaying=!0;this.startTime=(new Date).getTime()*0.001;for(var a=0;a<this.hierarchy.length;a++){this.hierarchy[a].useQuaternion=!0;this.hierarchy[a].matrixAutoUpdate=!0;if(this.hierarchy[a].prevKey===undefined){this.hierarchy[a].prevKey={pos:0,rot:0,scl:0};this.hierarchy[a].nextKey={pos:0,rot:0,scl:0}}this.hierarchy[a].prevKey.pos=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.rot=this.data.hierarchy[a].keys[0];this.hierarchy[a].prevKey.scl=
 this.data.hierarchy[a].keys[0];this.hierarchy[a].nextKey.pos=this.getNextKeyWith("pos",a,1);this.hierarchy[a].nextKey.rot=this.getNextKeyWith("rot",a,1);this.hierarchy[a].nextKey.scl=this.getNextKeyWith("scl",a,1)}this.update();THREE.AnimationHandler.add(this)}};THREE.Animation.prototype.pause=function(){THREE.AnimationHandler.remove(this)};THREE.Animation.prototype.stop=function(){this.isPlaying=!1;THREE.AnimationHandler.remove(this)};
-THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,d,f,g,h,k=this.data.JIT.hierarchy,j=(new Date).getTime()*0.001-this.startTime+this.offset,l=j;if(j>this.data.length){for(;j>this.data.length;)j-=this.data.length;this.startTime=(new Date).getTime()*0.001-j;j=(new Date).getTime()*0.001-this.startTime}h=Math.min(parseInt(j*this.data.fps),parseInt(this.data.length*this.data.fps));for(var n=0,v=this.hierarchy.length;n<v;n++){g=this.hierarchy[n];if(k[n][h]!==undefined){g.skinMatrix=
-k[n][h];g.matrixAutoUpdate=!1;g.matrixNeedsUpdate=!1;g.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,n*16)}else for(var p=0;p<3;p++){c=a[p];d=g.prevKey[c];f=g.nextKey[c];if(f.time<l){if(j<l)if(this.loop){d=this.data.hierarchy[n].keys[0];f=this.getNextKeyWith(c,n,1)}else{this.stop();return}else{do{d=f;f=this.getNextKeyWith(c,n,f.index+1)}while(f.time<j)}g.prevKey[c]=d;g.nextKey[c]=f}g.matrixAutoUpdate=!0;g.matrixNeedsUpdate=!0;b=(j-d.time)/(f.time-d.time);d=d[c];f=f[c];if(c==="rot"){if(b<
+THREE.Animation.prototype.update=function(){if(this.isPlaying){var a=["pos","rot","scl"],b,c,d,f,g,h,k=this.data.JIT.hierarchy,j=(new Date).getTime()*0.001-this.startTime+this.offset,m=j;if(j>this.data.length){for(;j>this.data.length;)j-=this.data.length;this.startTime=(new Date).getTime()*0.001-j;j=(new Date).getTime()*0.001-this.startTime}h=Math.min(parseInt(j*this.data.fps),parseInt(this.data.length*this.data.fps));for(var n=0,w=this.hierarchy.length;n<w;n++){g=this.hierarchy[n];if(k[n][h]!==undefined){g.skinMatrix=
+k[n][h];g.matrixAutoUpdate=!1;g.matrixNeedsUpdate=!1;g.skinMatrix.flattenToArrayOffset(this.root.boneMatrices,n*16)}else for(var o=0;o<3;o++){c=a[o];d=g.prevKey[c];f=g.nextKey[c];if(f.time<m){if(j<m)if(this.loop){d=this.data.hierarchy[n].keys[0];f=this.getNextKeyWith(c,n,1)}else{this.stop();return}else{do{d=f;f=this.getNextKeyWith(c,n,f.index+1)}while(f.time<j)}g.prevKey[c]=d;g.nextKey[c]=f}g.matrixAutoUpdate=!0;g.matrixNeedsUpdate=!0;b=(j-d.time)/(f.time-d.time);d=d[c];f=f[c];if(c==="rot"){if(b<
 0||b>1){console.log("Scale out of bounds:"+b);b=b<0?0:1}THREE.Quaternion.slerp(d,f,g.quaternion,b)}else{c=c==="pos"?g.position:g.scale;c.x=d[0]+(f[0]-d[0])*b;c.y=d[1]+(f[1]-d[1])*b;c.z=d[2]+(f[2]-d[2])*b}}}if(k[0][h]===undefined){this.hierarchy[0].update(undefined,!0);for(n=0;n<this.hierarchy.length;n++)k[n][h]=this.hierarchy[n].skinMatrix.clone()}}};THREE.Animation.prototype.updateObject=function(){};
 THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys;c<d.length;c++)if(d[c][a]!==undefined)return d[c];return this.data.hierarchy[b].keys[0]};
 THREE.Camera=function(a,b,c,d,f){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=f||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(g,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(g);this.tmpVec.crossSelf(this.up);if(h)this.tmpVec.y=0;this.position.addSelf(this.tmpVec);
@@ -138,118 +137,119 @@ THREE.LOD.prototype.update=function(a,b,c){this.matrixAutoUpdate&&(b|=this.updat
 THREE.Scene.prototype.addChild=function(a){this.supr.addChild.call(this,a);this.addChildRecurse(a)};THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};
 THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};
 THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=b||1;this.far=c||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
-THREE.Projector=function(){function a(O,P){return P.z-O.z}function b(O,P){var V=0,T=1,Y=O.z+O.w,da=P.z+P.w,J=-O.z+O.w,$=-P.z+P.w;if(Y>=0&&da>=0&&J>=0&&$>=0)return!0;else if(Y<0&&da<0||J<0&&$<0)return!1;else{if(Y<0)V=Math.max(V,Y/(Y-da));else da<0&&(T=Math.min(T,Y/(Y-da)));if(J<0)V=Math.max(V,J/(J-$));else $<0&&(T=Math.min(T,J/(J-$)));if(T<V)return!1;else{O.lerpSelf(P,V);P.lerpSelf(O,1-T);return!0}}}var c,d,f=[],g,h,k,j=[],l,n,v=[],p,q,w=[],B=new THREE.Vector4,H=new THREE.Vector4,u=new THREE.Matrix4,
-I=new THREE.Matrix4,o=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],M=new THREE.Vector4,e=new THREE.Vector4,ba;this.projectObjects=function(O,P,V){P=[];var T,Y,da;d=0;Y=O.objects;O=0;for(T=Y.length;O<T;O++){da=Y[O];var J;if(!(J=!da.visible))if(J=da instanceof THREE.Mesh){a:{J=void 0;for(var $=da.matrixWorld,ra=-da.geometry.boundingSphere.radius*Math.max(da.scale.x,Math.max(da.scale.y,da.scale.z)),Z=0;Z<6;Z++){J=o[Z].x*$.n14+o[Z].y*$.n24+
-o[Z].z*$.n34+o[Z].w;if(J<=ra){J=!1;break a}}J=!0}J=!J}if(!J){c=f[d]=f[d]||new THREE.RenderableObject;B.copy(da.position);u.multiplyVector3(B);c.object=da;c.z=B.z;P.push(c);d++}}V&&P.sort(a);return P};this.projectScene=function(O,P,V){var T=[],Y=P.near,da=P.far,J,$,ra,Z,la,ja,fa,sa,m,A,x,t,y,C,D,E;k=n=q=0;P.matrixAutoUpdate&&P.update();u.multiply(P.projectionMatrix,P.matrixWorldInverse);o[0].set(u.n41-u.n11,u.n42-u.n12,u.n43-u.n13,u.n44-u.n14);o[1].set(u.n41+u.n11,u.n42+u.n12,u.n43+u.n13,u.n44+u.n14);
-o[2].set(u.n41+u.n21,u.n42+u.n22,u.n43+u.n23,u.n44+u.n24);o[3].set(u.n41-u.n21,u.n42-u.n22,u.n43-u.n23,u.n44-u.n24);o[4].set(u.n41-u.n31,u.n42-u.n32,u.n43-u.n33,u.n44-u.n34);o[5].set(u.n41+u.n31,u.n42+u.n32,u.n43+u.n33,u.n44+u.n34);for(J=0;J<6;J++){ja=o[J];ja.divideScalar(Math.sqrt(ja.x*ja.x+ja.y*ja.y+ja.z*ja.z))}O.update(undefined,!1,P);ja=this.projectObjects(O,P,!0);O=0;for(J=ja.length;O<J;O++){fa=ja[O].object;if(fa.visible){sa=fa.matrixWorld;x=fa.matrixRotationWorld;m=fa.materials;A=fa.overdraw;
-if(fa instanceof THREE.Mesh){t=fa.geometry;y=t.vertices;$=0;for(ra=y.length;$<ra;$++){C=y[$];C.positionWorld.copy(C.position);sa.multiplyVector3(C.positionWorld);Z=C.positionScreen;Z.copy(C.positionWorld);u.multiplyVector4(Z);Z.x/=Z.w;Z.y/=Z.w;C.__visible=Z.z>Y&&Z.z<da}t=t.faces;$=0;for(ra=t.length;$<ra;$++){C=t[$];if(C instanceof THREE.Face3){Z=y[C.a];la=y[C.b];D=y[C.c];if(Z.__visible&&la.__visible&&D.__visible&&(fa.doubleSided||fa.flipSided!=(D.positionScreen.x-Z.positionScreen.x)*(la.positionScreen.y-
-Z.positionScreen.y)-(D.positionScreen.y-Z.positionScreen.y)*(la.positionScreen.x-Z.positionScreen.x)<0)){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(Z.positionWorld);g.v2.positionWorld.copy(la.positionWorld);g.v3.positionWorld.copy(D.positionWorld);g.v1.positionScreen.copy(Z.positionScreen);g.v2.positionScreen.copy(la.positionScreen);g.v3.positionScreen.copy(D.positionScreen);g.normalWorld.copy(C.normal);x.multiplyVector3(g.normalWorld);g.centroidWorld.copy(C.centroid);sa.multiplyVector3(g.centroidWorld);
-g.centroidScreen.copy(g.centroidWorld);u.multiplyVector3(g.centroidScreen);D=C.vertexNormals;ba=g.vertexNormalsWorld;Z=0;for(la=D.length;Z<la;Z++){E=ba[Z]=ba[Z]||new THREE.Vector3;E.copy(D[Z]);x.multiplyVector3(E)}g.z=g.centroidScreen.z;g.meshMaterials=m;g.faceMaterials=C.materials;g.overdraw=A;if(fa.geometry.uvs[$]){g.uvs[0]=fa.geometry.uvs[$][0];g.uvs[1]=fa.geometry.uvs[$][1];g.uvs[2]=fa.geometry.uvs[$][2]}T.push(g);k++}}else if(C instanceof THREE.Face4){Z=y[C.a];la=y[C.b];D=y[C.c];E=y[C.d];if(Z.__visible&&
-la.__visible&&D.__visible&&E.__visible&&(fa.doubleSided||fa.flipSided!=((E.positionScreen.x-Z.positionScreen.x)*(la.positionScreen.y-Z.positionScreen.y)-(E.positionScreen.y-Z.positionScreen.y)*(la.positionScreen.x-Z.positionScreen.x)<0||(la.positionScreen.x-D.positionScreen.x)*(E.positionScreen.y-D.positionScreen.y)-(la.positionScreen.y-D.positionScreen.y)*(E.positionScreen.x-D.positionScreen.x)<0))){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(Z.positionWorld);g.v2.positionWorld.copy(la.positionWorld);
-g.v3.positionWorld.copy(E.positionWorld);g.v1.positionScreen.copy(Z.positionScreen);g.v2.positionScreen.copy(la.positionScreen);g.v3.positionScreen.copy(E.positionScreen);g.normalWorld.copy(C.normal);x.multiplyVector3(g.normalWorld);g.centroidWorld.copy(C.centroid);sa.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);u.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=m;g.faceMaterials=C.materials;g.overdraw=A;if(fa.geometry.uvs[$]){g.uvs[0]=fa.geometry.uvs[$][0];
-g.uvs[1]=fa.geometry.uvs[$][1];g.uvs[2]=fa.geometry.uvs[$][3]}T.push(g);k++;h=j[k]=j[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(la.positionWorld);h.v2.positionWorld.copy(D.positionWorld);h.v3.positionWorld.copy(E.positionWorld);h.v1.positionScreen.copy(la.positionScreen);h.v2.positionScreen.copy(D.positionScreen);h.v3.positionScreen.copy(E.positionScreen);h.normalWorld.copy(g.normalWorld);h.centroidWorld.copy(g.centroidWorld);h.centroidScreen.copy(g.centroidScreen);h.z=h.centroidScreen.z;
-h.meshMaterials=m;h.faceMaterials=C.materials;h.overdraw=A;if(fa.geometry.uvs[$]){h.uvs[0]=fa.geometry.uvs[$][1];h.uvs[1]=fa.geometry.uvs[$][2];h.uvs[2]=fa.geometry.uvs[$][3]}T.push(h);k++}}}}else if(fa instanceof THREE.Line){I.multiply(u,sa);y=fa.geometry.vertices;C=y[0];C.positionScreen.copy(C.position);I.multiplyVector4(C.positionScreen);$=1;for(ra=y.length;$<ra;$++){Z=y[$];Z.positionScreen.copy(Z.position);I.multiplyVector4(Z.positionScreen);la=y[$-1];M.copy(Z.positionScreen);e.copy(la.positionScreen);
-if(b(M,e)){M.multiplyScalar(1/M.w);e.multiplyScalar(1/e.w);l=v[n]=v[n]||new THREE.RenderableLine;l.v1.positionScreen.copy(M);l.v2.positionScreen.copy(e);l.z=Math.max(M.z,e.z);l.materials=fa.materials;T.push(l);n++}}}else if(fa instanceof THREE.Particle){H.set(fa.position.x,fa.position.y,fa.position.z,1);u.multiplyVector4(H);H.z/=H.w;if(H.z>0&&H.z<1){p=w[q]=w[q]||new THREE.RenderableParticle;p.x=H.x/H.w;p.y=H.y/H.w;p.z=H.z;p.rotation=fa.rotation.z;p.scale.x=fa.scale.x*Math.abs(p.x-(H.x+P.projectionMatrix.n11)/
-(H.w+P.projectionMatrix.n14));p.scale.y=fa.scale.y*Math.abs(p.y-(H.y+P.projectionMatrix.n22)/(H.w+P.projectionMatrix.n24));p.materials=fa.materials;T.push(p);q++}}}}V&&T.sort(a);return T};this.unprojectVector=function(O,P){var V=P.matrixWorld.clone();V.multiplySelf(THREE.Matrix4.makeInvert(P.projectionMatrix));V.multiplyVector3(O);return O}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;d=k;f=c/2;g=d/2};this.render=function(h,k){var j,l,n,v,p,q,w,B;a=b.projectScene(h,k);j=0;for(l=a.length;j<l;j++){p=a[j];if(p instanceof THREE.RenderableParticle){w=p.x*f+f;B=p.y*g+g;n=0;for(v=p.material.length;n<v;n++){q=p.material[n];if(q instanceof THREE.ParticleDOMMaterial){q=q.domElement;q.style.left=w+"px";q.style.top=B+"px"}}}}}};
-THREE.CanvasRenderer=function(){function a(va){if(p!=va)l.globalAlpha=p=va}function b(va){if(q!=va){switch(va){case THREE.NormalBlending:l.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:l.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:l.globalCompositeOperation="darker"}q=va}}var c=null,d=new THREE.Projector,f=document.createElement("canvas"),g,h,k,j,l=f.getContext("2d"),n=new THREE.Color(0),v=0,p=1,q=0,w=null,B=null,H=1,u,I,o,M,e,ba,O,P,V,T=new THREE.Color,
-Y=new THREE.Color,da=new THREE.Color,J=new THREE.Color,$=new THREE.Color,ra,Z,la,ja,fa,sa,m,A,x,t=new THREE.Rectangle,y=new THREE.Rectangle,C=new THREE.Rectangle,D=!1,E=new THREE.Color,K=new THREE.Color,W=new THREE.Color,z=new THREE.Color,F=Math.PI*2,L=new THREE.Vector3,G,U,pa,ka,oa,na,ma=16;G=document.createElement("canvas");G.width=G.height=2;U=G.getContext("2d");U.fillStyle="rgba(0,0,0,1)";U.fillRect(0,0,2,2);pa=U.getImageData(0,0,2,2);ka=pa.data;oa=document.createElement("canvas");oa.width=oa.height=
-ma;na=oa.getContext("2d");na.translate(-ma/2,-ma/2);na.scale(ma,ma);ma--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(va,Q){g=va;h=Q;k=g/2;j=h/2;f.width=g;f.height=h;t.set(-k,-j,k,j);p=1;q=0;B=w=null;H=1};this.setClearColor=function(va,Q){n=va;v=Q;y.set(-k,-j,k,j);l.setTransform(1,0,0,-1,k,j);this.clear()};this.setClearColorHex=function(va,Q){n.setHex(va);v=Q;y.set(-k,-j,k,j);l.setTransform(1,0,0,-1,k,j);this.clear()};this.clear=function(){l.setTransform(1,
-0,0,-1,k,j);if(!y.isEmpty()){y.inflate(1);y.minSelf(t);if(n.hex==0&&v==0)l.clearRect(y.getX(),y.getY(),y.getWidth(),y.getHeight());else{b(THREE.NormalBlending);a(1);l.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+v+")";l.fillRect(y.getX(),y.getY(),y.getWidth(),y.getHeight())}y.empty()}};this.render=function(va,Q){function Ia(R){var ga,ha,S,ea=R.lights;K.setRGB(0,0,0);W.setRGB(0,0,0);z.setRGB(0,0,0);R=0;for(ga=ea.length;R<ga;R++){ha=ea[R];S=ha.color;if(ha instanceof
-THREE.AmbientLight){K.r+=S.r;K.g+=S.g;K.b+=S.b}else if(ha instanceof THREE.DirectionalLight){W.r+=S.r;W.g+=S.g;W.b+=S.b}else if(ha instanceof THREE.PointLight){z.r+=S.r;z.g+=S.g;z.b+=S.b}}}function Ea(R,ga,ha,S){var ea,qa,Aa,Ga,Ha=R.lights;R=0;for(ea=Ha.length;R<ea;R++){qa=Ha[R];Aa=qa.color;Ga=qa.intensity;if(qa instanceof THREE.DirectionalLight){qa=ha.dot(qa.position)*Ga;if(qa>0){S.r+=Aa.r*qa;S.g+=Aa.g*qa;S.b+=Aa.b*qa}}else if(qa instanceof THREE.PointLight){L.sub(qa.position,ga);L.normalize();qa=
-ha.dot(L)*Ga;if(qa>0){S.r+=Aa.r*qa;S.g+=Aa.g*qa;S.b+=Aa.b*qa}}}}function Ka(R,ga,ha){if(ha.opacity!=0){a(ha.opacity);b(ha.blending);var S,ea,qa,Aa,Ga,Ha;if(ha instanceof THREE.ParticleBasicMaterial){if(ha.map){Aa=ha.map.image;Ga=Aa.width>>1;Ha=Aa.height>>1;ea=ga.scale.x*k;qa=ga.scale.y*j;ha=ea*Ga;S=qa*Ha;C.set(R.x-ha,R.y-S,R.x+ha,R.y+S);if(t.instersects(C)){l.save();l.translate(R.x,R.y);l.rotate(-ga.rotation);l.scale(ea,-qa);l.translate(-Ga,-Ha);l.drawImage(Aa,0,0);l.restore()}}}else if(ha instanceof
-THREE.ParticleCircleMaterial){if(D){E.r=K.r+W.r+z.r;E.g=K.g+W.g+z.g;E.b=K.b+W.b+z.b;T.r=ha.color.r*E.r;T.g=ha.color.g*E.g;T.b=ha.color.b*E.b;T.updateStyleString()}else T.__styleString=ha.color.__styleString;ha=ga.scale.x*k;S=ga.scale.y*j;C.set(R.x-ha,R.y-S,R.x+ha,R.y+S);if(t.instersects(C)){ea=T.__styleString;if(B!=ea)l.fillStyle=B=ea;l.save();l.translate(R.x,R.y);l.rotate(-ga.rotation);l.scale(ha,S);l.beginPath();l.arc(0,0,1,0,F,!0);l.closePath();l.fill();l.restore()}}}}function ca(R,ga,ha,S){if(S.opacity!=
-0){a(S.opacity);b(S.blending);l.beginPath();l.moveTo(R.positionScreen.x,R.positionScreen.y);l.lineTo(ga.positionScreen.x,ga.positionScreen.y);l.closePath();if(S instanceof THREE.LineBasicMaterial){T.__styleString=S.color.__styleString;R=S.linewidth;if(H!=R)l.lineWidth=H=R;R=T.__styleString;if(w!=R)l.strokeStyle=w=R;l.stroke();C.inflate(S.linewidth*2)}}}function aa(R,ga,ha,S,ea,qa){if(ea.opacity!=0){a(ea.opacity);b(ea.blending);M=R.positionScreen.x;e=R.positionScreen.y;ba=ga.positionScreen.x;O=ga.positionScreen.y;
-P=ha.positionScreen.x;V=ha.positionScreen.y;l.beginPath();l.moveTo(M,e);l.lineTo(ba,O);l.lineTo(P,V);l.lineTo(M,e);l.closePath();if(ea instanceof THREE.MeshBasicMaterial)if(ea.map)ea.map.mapping instanceof THREE.UVMapping&&Fa(M,e,ba,O,P,V,ea.map.image,S.uvs[0].u,S.uvs[0].v,S.uvs[1].u,S.uvs[1].v,S.uvs[2].u,S.uvs[2].v);else if(ea.envMap){if(ea.envMap.mapping instanceof THREE.SphericalReflectionMapping){R=Q.matrixWorldInverse;L.copy(S.vertexNormalsWorld[0]);ja=(L.x*R.n11+L.y*R.n12+L.z*R.n13)*0.5+0.5;
-fa=-(L.x*R.n21+L.y*R.n22+L.z*R.n23)*0.5+0.5;L.copy(S.vertexNormalsWorld[1]);sa=(L.x*R.n11+L.y*R.n12+L.z*R.n13)*0.5+0.5;m=-(L.x*R.n21+L.y*R.n22+L.z*R.n23)*0.5+0.5;L.copy(S.vertexNormalsWorld[2]);A=(L.x*R.n11+L.y*R.n12+L.z*R.n13)*0.5+0.5;x=-(L.x*R.n21+L.y*R.n22+L.z*R.n23)*0.5+0.5;Fa(M,e,ba,O,P,V,ea.envMap.image,ja,fa,sa,m,A,x)}}else ea.wireframe?X(ea.color.__styleString,ea.wireframeLinewidth):ta(ea.color.__styleString);else if(ea instanceof THREE.MeshLambertMaterial){if(ea.map&&!ea.wireframe){ea.map.mapping instanceof
-THREE.UVMapping&&Fa(M,e,ba,O,P,V,ea.map.image,S.uvs[0].u,S.uvs[0].v,S.uvs[1].u,S.uvs[1].v,S.uvs[2].u,S.uvs[2].v);b(THREE.SubtractiveBlending)}if(D)if(!ea.wireframe&&ea.shading==THREE.SmoothShading&&S.vertexNormalsWorld.length==3){Y.r=da.r=J.r=K.r;Y.g=da.g=J.g=K.g;Y.b=da.b=J.b=K.b;Ea(qa,S.v1.positionWorld,S.vertexNormalsWorld[0],Y);Ea(qa,S.v2.positionWorld,S.vertexNormalsWorld[1],da);Ea(qa,S.v3.positionWorld,S.vertexNormalsWorld[2],J);$.r=(da.r+J.r)*0.5;$.g=(da.g+J.g)*0.5;$.b=(da.b+J.b)*0.5;la=Ca(Y,
-da,J,$);Fa(M,e,ba,O,P,V,la,0,0,1,0,0,1)}else{E.r=K.r;E.g=K.g;E.b=K.b;Ea(qa,S.centroidWorld,S.normalWorld,E);T.r=ea.color.r*E.r;T.g=ea.color.g*E.g;T.b=ea.color.b*E.b;T.updateStyleString();ea.wireframe?X(T.__styleString,ea.wireframeLinewidth):ta(T.__styleString)}else ea.wireframe?X(ea.color.__styleString,ea.wireframeLinewidth):ta(ea.color.__styleString)}else if(ea instanceof THREE.MeshDepthMaterial){ra=Q.near;Z=Q.far;Y.r=Y.g=Y.b=1-N(R.positionScreen.z,ra,Z);da.r=da.g=da.b=1-N(ga.positionScreen.z,ra,
-Z);J.r=J.g=J.b=1-N(ha.positionScreen.z,ra,Z);$.r=(da.r+J.r)*0.5;$.g=(da.g+J.g)*0.5;$.b=(da.b+J.b)*0.5;la=Ca(Y,da,J,$);Fa(M,e,ba,O,P,V,la,0,0,1,0,0,1)}else if(ea instanceof THREE.MeshNormalMaterial){T.r=Da(S.normalWorld.x);T.g=Da(S.normalWorld.y);T.b=Da(S.normalWorld.z);T.updateStyleString();ea.wireframe?X(T.__styleString,ea.wireframeLinewidth):ta(T.__styleString)}}}function X(R,ga){if(w!=R)l.strokeStyle=w=R;if(H!=ga)l.lineWidth=H=ga;l.stroke();C.inflate(ga*2)}function ta(R){if(B!=R)l.fillStyle=B=
-R;l.fill()}function Fa(R,ga,ha,S,ea,qa,Aa,Ga,Ha,La,Ba,Ma,Ta){var Na,Oa;Na=Aa.width-1;Oa=Aa.height-1;Ga*=Na;Ha*=Oa;La*=Na;Ba*=Oa;Ma*=Na;Ta*=Oa;ha-=R;S-=ga;ea-=R;qa-=ga;La-=Ga;Ba-=Ha;Ma-=Ga;Ta-=Ha;Na=La*Ta-Ma*Ba;if(Na!=0){Oa=1/Na;Na=(Ta*ha-Ba*ea)*Oa;Ba=(Ta*S-Ba*qa)*Oa;ha=(La*ea-Ma*ha)*Oa;S=(La*qa-Ma*S)*Oa;R=R-Na*Ga-ha*Ha;ga=ga-Ba*Ga-S*Ha;l.save();l.transform(Na,Ba,ha,S,R,ga);l.clip();l.drawImage(Aa,0,0);l.restore()}}function Ca(R,ga,ha,S){var ea=~~(R.r*255),qa=~~(R.g*255);R=~~(R.b*255);var Aa=~~(ga.r*
-255),Ga=~~(ga.g*255);ga=~~(ga.b*255);var Ha=~~(ha.r*255),La=~~(ha.g*255);ha=~~(ha.b*255);var Ba=~~(S.r*255),Ma=~~(S.g*255);S=~~(S.b*255);ka[0]=ea<0?0:ea>255?255:ea;ka[1]=qa<0?0:qa>255?255:qa;ka[2]=R<0?0:R>255?255:R;ka[4]=Aa<0?0:Aa>255?255:Aa;ka[5]=Ga<0?0:Ga>255?255:Ga;ka[6]=ga<0?0:ga>255?255:ga;ka[8]=Ha<0?0:Ha>255?255:Ha;ka[9]=La<0?0:La>255?255:La;ka[10]=ha<0?0:ha>255?255:ha;ka[12]=Ba<0?0:Ba>255?255:Ba;ka[13]=Ma<0?0:Ma>255?255:Ma;ka[14]=S<0?0:S>255?255:S;U.putImageData(pa,0,0);na.drawImage(G,0,0);
-return oa}function N(R,ga,ha){R=(R-ga)/(ha-ga);return R*R*(3-2*R)}function Da(R){R=(R+1)*0.5;return R<0?0:R>1?1:R}function Ra(R,ga){var ha=ga.x-R.x,S=ga.y-R.y,ea=1/Math.sqrt(ha*ha+S*S);ha*=ea;S*=ea;ga.x+=ha;ga.y+=S;R.x-=ha;R.y-=S}var Pa,Ja,ia,xa,ua,ya,za,wa;this.autoClear?this.clear():l.setTransform(1,0,0,-1,k,j);c=d.projectScene(va,Q,this.sortElements);(D=va.lights.length>0)&&Ia(va);Pa=0;for(Ja=c.length;Pa<Ja;Pa++){ia=c[Pa];C.empty();if(ia instanceof THREE.RenderableParticle){u=ia;u.x*=k;u.y*=j;
-xa=0;for(ua=ia.materials.length;xa<ua;xa++)Ka(u,ia,ia.materials[xa],va)}else if(ia instanceof THREE.RenderableLine){u=ia.v1;I=ia.v2;u.positionScreen.x*=k;u.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;C.addPoint(u.positionScreen.x,u.positionScreen.y);C.addPoint(I.positionScreen.x,I.positionScreen.y);if(t.instersects(C)){xa=0;for(ua=ia.materials.length;xa<ua;)ca(u,I,ia,ia.materials[xa++],va)}}else if(ia instanceof THREE.RenderableFace3){u=ia.v1;I=ia.v2;o=ia.v3;u.positionScreen.x*=
-k;u.positionScreen.y*=j;I.positionScreen.x*=k;I.positionScreen.y*=j;o.positionScreen.x*=k;o.positionScreen.y*=j;if(ia.overdraw){Ra(u.positionScreen,I.positionScreen);Ra(I.positionScreen,o.positionScreen);Ra(o.positionScreen,u.positionScreen)}C.add3Points(u.positionScreen.x,u.positionScreen.y,I.positionScreen.x,I.positionScreen.y,o.positionScreen.x,o.positionScreen.y);if(t.instersects(C)){xa=0;for(ua=ia.meshMaterials.length;xa<ua;){wa=ia.meshMaterials[xa++];if(wa instanceof THREE.MeshFaceMaterial){ya=
-0;for(za=ia.faceMaterials.length;ya<za;)(wa=ia.faceMaterials[ya++])&&aa(u,I,o,ia,wa,va)}else aa(u,I,o,ia,wa,va)}}}y.addRectangle(C)}l.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(ja,fa,sa){var m,A,x,t;m=0;for(A=ja.lights.length;m<A;m++){x=ja.lights[m];if(x instanceof THREE.DirectionalLight){t=fa.normalWorld.dot(x.position)*x.intensity;if(t>0){sa.r+=x.color.r*t;sa.g+=x.color.g*t;sa.b+=x.color.b*t}}else if(x instanceof THREE.PointLight){V.sub(x.position,fa.centroidWorld);V.normalize();t=fa.normalWorld.dot(V)*x.intensity;if(t>0){sa.r+=x.color.r*t;sa.g+=x.color.g*t;sa.b+=x.color.b*t}}}}function b(ja,fa,sa,m,A,x){J=d($++);J.setAttribute("d",
-"M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+"z");if(A instanceof THREE.MeshBasicMaterial)o.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshLambertMaterial)if(I){M.r=e.r;M.g=e.g;M.b=e.b;a(x,m,M);o.r=A.color.r*M.r;o.g=A.color.g*M.g;o.b=A.color.b*M.b;o.updateStyleString()}else o.__styleString=A.color.__styleString;else if(A instanceof THREE.MeshDepthMaterial){P=1-A.__2near/(A.__farPlusNear-
-m.z*A.__farMinusNear);o.setRGB(P,P,P)}else A instanceof THREE.MeshNormalMaterial&&o.setRGB(f(m.normalWorld.x),f(m.normalWorld.y),f(m.normalWorld.z));A.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+A.wireframeLinewidth+"; stroke-opacity: "+A.opacity+"; stroke-linecap: "+A.wireframeLinecap+"; stroke-linejoin: "+A.wireframeLinejoin):J.setAttribute("style","fill: "+o.__styleString+"; fill-opacity: "+A.opacity);k.appendChild(J)}function c(ja,fa,sa,m,A,x,t){J=
-d($++);J.setAttribute("d","M "+ja.positionScreen.x+" "+ja.positionScreen.y+" L "+fa.positionScreen.x+" "+fa.positionScreen.y+" L "+sa.positionScreen.x+","+sa.positionScreen.y+" L "+m.positionScreen.x+","+m.positionScreen.y+"z");if(x instanceof THREE.MeshBasicMaterial)o.__styleString=x.color.__styleString;else if(x instanceof THREE.MeshLambertMaterial)if(I){M.r=e.r;M.g=e.g;M.b=e.b;a(t,A,M);o.r=x.color.r*M.r;o.g=x.color.g*M.g;o.b=x.color.b*M.b;o.updateStyleString()}else o.__styleString=x.color.__styleString;
-else if(x instanceof THREE.MeshDepthMaterial){P=1-x.__2near/(x.__farPlusNear-A.z*x.__farMinusNear);o.setRGB(P,P,P)}else x instanceof THREE.MeshNormalMaterial&&o.setRGB(f(A.normalWorld.x),f(A.normalWorld.y),f(A.normalWorld.z));x.wireframe?J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+x.wireframeLinewidth+"; stroke-opacity: "+x.opacity+"; stroke-linecap: "+x.wireframeLinecap+"; stroke-linejoin: "+x.wireframeLinejoin):J.setAttribute("style","fill: "+o.__styleString+
-"; fill-opacity: "+x.opacity);k.appendChild(J)}function d(ja){if(T[ja]==null){T[ja]=document.createElementNS("http://www.w3.org/2000/svg","path");la==0&&T[ja].setAttribute("shape-rendering","crispEdges")}return T[ja]}function f(ja){return ja<0?Math.min((1+ja)*0.5,0.5):0.5+Math.min(ja*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,l,n,v,p,q,w,B,H=new THREE.Rectangle,u=new THREE.Rectangle,I=!1,o=new THREE.Color(16777215),M=new THREE.Color(16777215),
-e=new THREE.Color(0),ba=new THREE.Color(0),O=new THREE.Color(0),P,V=new THREE.Vector3,T=[],Y=[],da=[],J,$,ra,Z,la=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ja){switch(ja){case "high":la=1;break;case "low":la=0}};this.setSize=function(ja,fa){j=ja;l=fa;n=j/2;v=l/2;k.setAttribute("viewBox",-n+" "+-v+" "+j+" "+l);k.setAttribute("width",j);k.setAttribute("height",l);H.set(-n,-v,n,v)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};
-this.render=function(ja,fa){var sa,m,A,x,t,y,C,D;this.autoClear&&this.clear();g=h.projectScene(ja,fa,this.sortElements);Z=ra=$=0;if(I=ja.lights.length>0){C=ja.lights;e.setRGB(0,0,0);ba.setRGB(0,0,0);O.setRGB(0,0,0);sa=0;for(m=C.length;sa<m;sa++){A=C[sa];x=A.color;if(A instanceof THREE.AmbientLight){e.r+=x.r;e.g+=x.g;e.b+=x.b}else if(A instanceof THREE.DirectionalLight){ba.r+=x.r;ba.g+=x.g;ba.b+=x.b}else if(A instanceof THREE.PointLight){O.r+=x.r;O.g+=x.g;O.b+=x.b}}}sa=0;for(m=g.length;sa<m;sa++){C=
-g[sa];u.empty();if(C instanceof THREE.RenderableParticle){p=C;p.x*=n;p.y*=-v;A=0;for(x=C.materials.length;A<x;A++)if(D=C.materials[A]){t=p;y=C;var E=ra++;if(Y[E]==null){Y[E]=document.createElementNS("http://www.w3.org/2000/svg","circle");la==0&&Y[E].setAttribute("shape-rendering","crispEdges")}J=Y[E];J.setAttribute("cx",t.x);J.setAttribute("cy",t.y);J.setAttribute("r",y.scale.x*n);if(D instanceof THREE.ParticleCircleMaterial){if(I){M.r=e.r+ba.r+O.r;M.g=e.g+ba.g+O.g;M.b=e.b+ba.b+O.b;o.r=D.color.r*
-M.r;o.g=D.color.g*M.g;o.b=D.color.b*M.b;o.updateStyleString()}else o=D.color;J.setAttribute("style","fill: "+o.__styleString)}k.appendChild(J)}}else if(C instanceof THREE.RenderableLine){p=C.v1;q=C.v2;p.positionScreen.x*=n;p.positionScreen.y*=-v;q.positionScreen.x*=n;q.positionScreen.y*=-v;u.addPoint(p.positionScreen.x,p.positionScreen.y);u.addPoint(q.positionScreen.x,q.positionScreen.y);if(H.instersects(u)){A=0;for(x=C.materials.length;A<x;)if(D=C.materials[A++]){t=p;y=q;E=Z++;if(da[E]==null){da[E]=
-document.createElementNS("http://www.w3.org/2000/svg","line");la==0&&da[E].setAttribute("shape-rendering","crispEdges")}J=da[E];J.setAttribute("x1",t.positionScreen.x);J.setAttribute("y1",t.positionScreen.y);J.setAttribute("x2",y.positionScreen.x);J.setAttribute("y2",y.positionScreen.y);if(D instanceof THREE.LineBasicMaterial){o.__styleString=D.color.__styleString;J.setAttribute("style","fill: none; stroke: "+o.__styleString+"; stroke-width: "+D.linewidth+"; stroke-opacity: "+D.opacity+"; stroke-linecap: "+
-D.linecap+"; stroke-linejoin: "+D.linejoin);k.appendChild(J)}}}}else if(C instanceof THREE.RenderableFace3){p=C.v1;q=C.v2;w=C.v3;p.positionScreen.x*=n;p.positionScreen.y*=-v;q.positionScreen.x*=n;q.positionScreen.y*=-v;w.positionScreen.x*=n;w.positionScreen.y*=-v;u.addPoint(p.positionScreen.x,p.positionScreen.y);u.addPoint(q.positionScreen.x,q.positionScreen.y);u.addPoint(w.positionScreen.x,w.positionScreen.y);if(H.instersects(u)){A=0;for(x=C.meshMaterials.length;A<x;){D=C.meshMaterials[A++];if(D instanceof
-THREE.MeshFaceMaterial){t=0;for(y=C.faceMaterials.length;t<y;)(D=C.faceMaterials[t++])&&b(p,q,w,C,D,ja)}else D&&b(p,q,w,C,D,ja)}}}else if(C instanceof THREE.RenderableFace4){p=C.v1;q=C.v2;w=C.v3;B=C.v4;p.positionScreen.x*=n;p.positionScreen.y*=-v;q.positionScreen.x*=n;q.positionScreen.y*=-v;w.positionScreen.x*=n;w.positionScreen.y*=-v;B.positionScreen.x*=n;B.positionScreen.y*=-v;u.addPoint(p.positionScreen.x,p.positionScreen.y);u.addPoint(q.positionScreen.x,q.positionScreen.y);u.addPoint(w.positionScreen.x,
-w.positionScreen.y);u.addPoint(B.positionScreen.x,B.positionScreen.y);if(H.instersects(u)){A=0;for(x=C.meshMaterials.length;A<x;){D=C.meshMaterials[A++];if(D instanceof THREE.MeshFaceMaterial){t=0;for(y=C.faceMaterials.length;t<y;)(D=C.faceMaterials[t++])&&c(p,q,w,B,C,D,ja)}else D&&c(p,q,w,B,C,D,ja)}}}}}};
-THREE.WebGLRenderer=function(a){function b(m,A,x){var t,y,C,D=m.vertices,E=D.length,K=m.colors,W=K.length,z=m.__vertexArray,F=m.__colorArray,L=m.__sortArray,G=m.__dirtyVertices,U=m.__dirtyColors;if(x.sortParticles){$.multiplySelf(x.matrixWorld);for(t=0;t<E;t++){y=D[t].position;la.copy(y);$.multiplyVector3(la);L[t]=[la.z,t]}L.sort(function(pa,ka){return ka[0]-pa[0]});for(t=0;t<E;t++){y=D[L[t][1]].position;C=t*3;z[C]=y.x;z[C+1]=y.y;z[C+2]=y.z}for(t=0;t<W;t++){C=t*3;color=K[L[t][1]];F[C]=color.r;F[C+
-1]=color.g;F[C+2]=color.b}}else{if(G)for(t=0;t<E;t++){y=D[t].position;C=t*3;z[C]=y.x;z[C+1]=y.y;z[C+2]=y.z}if(U)for(t=0;t<W;t++){color=K[t];C=t*3;F[C]=color.r;F[C+1]=color.g;F[C+2]=color.b}}if(G||x.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,z,A)}if(U||x.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,F,A)}}function c(m,A){m.fragmentShader=A.fragmentShader;m.vertexShader=A.vertexShader;m.uniforms=Uniforms.clone(A.uniforms)}
-function d(m,A,x,t,y){t.program||P.initMaterial(t,A,x);var C=t.program,D=C.uniforms,E=t.uniforms;if(C!=ba){e.useProgram(C);ba=C;e.uniformMatrix4fv(D.projectionMatrix,!1,ra)}if(x&&(t instanceof THREE.MeshBasicMaterial||t instanceof THREE.MeshLambertMaterial||t instanceof THREE.MeshPhongMaterial||t instanceof THREE.LineBasicMaterial||t instanceof THREE.ParticleBasicMaterial)){E.fogColor.value.setHex(x.color.hex);if(x instanceof THREE.Fog){E.fogNear.value=x.near;E.fogFar.value=x.far}else if(x instanceof
-THREE.FogExp2)E.fogDensity.value=x.density}if(t instanceof THREE.MeshPhongMaterial||t instanceof THREE.MeshLambertMaterial){var K,W,z=0,F=0,L=0,G,U,pa,ka=P.lights,oa=ka.directional.colors,na=ka.directional.positions,ma=ka.point.colors,va=ka.point.positions,Q=0,Ia=0;x=W=W=0;for(K=A.length;x<K;x++){W=A[x];G=W.color;U=W.position;pa=W.intensity;if(W instanceof THREE.AmbientLight){z+=G.r;F+=G.g;L+=G.b}else if(W instanceof THREE.DirectionalLight){W=Q*3;oa[W]=G.r*pa;oa[W+1]=G.g*pa;oa[W+2]=G.b*pa;na[W]=U.x;
-na[W+1]=U.y;na[W+2]=U.z;Q+=1}else if(W instanceof THREE.PointLight){W=Ia*3;ma[W]=G.r*pa;ma[W+1]=G.g*pa;ma[W+2]=G.b*pa;va[W]=U.x;va[W+1]=U.y;va[W+2]=U.z;Ia+=1}}for(x=Q*3;x<oa.length;x++)oa[x]=0;for(x=Ia*3;x<ma.length;x++)ma[x]=0;ka.point.length=Ia;ka.directional.length=Q;ka.ambient[0]=z;ka.ambient[1]=F;ka.ambient[2]=L;A=P.lights;E.enableLighting.value=A.directional.length+A.point.length;E.ambientLightColor.value=A.ambient;E.directionalLightColor.value=A.directional.colors;E.directionalLightDirection.value=
-A.directional.positions;E.pointLightColor.value=A.point.colors;E.pointLightPosition.value=A.point.positions}if(t instanceof THREE.MeshBasicMaterial||t instanceof THREE.MeshLambertMaterial||t instanceof THREE.MeshPhongMaterial){E.diffuse.value.setRGB(t.color.r*t.opacity,t.color.g*t.opacity,t.color.b*t.opacity);E.opacity.value=t.opacity;E.map.texture=t.map;E.lightMap.texture=t.lightMap;E.envMap.texture=t.envMap;E.reflectivity.value=t.reflectivity;E.refractionRatio.value=t.refractionRatio;E.combine.value=
-t.combine;E.useRefract.value=t.envMap&&t.envMap.mapping instanceof THREE.CubeRefractionMapping}if(t instanceof THREE.LineBasicMaterial){E.diffuse.value.setRGB(t.color.r*t.opacity,t.color.g*t.opacity,t.color.b*t.opacity);E.opacity.value=t.opacity}else if(t instanceof THREE.ParticleBasicMaterial){E.psColor.value.setRGB(t.color.r*t.opacity,t.color.g*t.opacity,t.color.b*t.opacity);E.opacity.value=t.opacity;E.size.value=t.size;E.map.texture=t.map}else if(t instanceof THREE.MeshPhongMaterial){E.ambient.value.setRGB(t.ambient.r,
-t.ambient.g,t.ambient.b);E.specular.value.setRGB(t.specular.r,t.specular.g,t.specular.b);E.shininess.value=t.shininess}else if(t instanceof THREE.MeshDepthMaterial){E.mNear.value=m.near;E.mFar.value=m.far;E.opacity.value=t.opacity}else if(t instanceof THREE.MeshNormalMaterial)E.opacity.value=t.opacity;for(var Ea in E)if(z=C.uniforms[Ea]){x=E[Ea];K=x.type;A=x.value;if(K=="i")e.uniform1i(z,A);else if(K=="f")e.uniform1f(z,A);else if(K=="fv1")e.uniform1fv(z,A);else if(K=="fv")e.uniform3fv(z,A);else if(K==
-"v2")e.uniform2f(z,A.x,A.y);else if(K=="v3")e.uniform3f(z,A.x,A.y,A.z);else if(K=="c")e.uniform3f(z,A.r,A.g,A.b);else if(K=="t"){e.uniform1i(z,A);if(x=x.texture)if(x.image instanceof Array&&x.image.length==6){if(x.image.length==6){if(x.needsUpdate){if(!x.image.__webGLTextureCube)x.image.__webGLTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,x.image.__webGLTextureCube);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_T,
-e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR);for(K=0;K<6;++K)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+K,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,x.image[K]);e.generateMipmap(e.TEXTURE_CUBE_MAP);e.bindTexture(e.TEXTURE_CUBE_MAP,null);x.needsUpdate=!1}e.activeTexture(e.TEXTURE0+A);e.bindTexture(e.TEXTURE_CUBE_MAP,x.image.__webGLTextureCube)}}else{if(x.needsUpdate){if(x.__wasSetOnce){e.bindTexture(e.TEXTURE_2D,
-x.__webGLTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,x.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o(x.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,o(x.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,o(x.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,o(x.minFilter));e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}else{x.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,x.__webGLTexture);e.texImage2D(e.TEXTURE_2D,
-0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,x.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o(x.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,o(x.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,o(x.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,o(x.minFilter));e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null);x.__wasSetOnce=!0}x.needsUpdate=!1}e.activeTexture(e.TEXTURE0+A);e.bindTexture(e.TEXTURE_2D,x.__webGLTexture)}}}e.uniformMatrix4fv(D.modelViewMatrix,
-!1,y._modelViewMatrixArray);e.uniformMatrix3fv(D.normalMatrix,!1,y._normalMatrixArray);(t instanceof THREE.MeshShaderMaterial||t instanceof THREE.MeshPhongMaterial||t.envMap)&&e.uniform3f(D.cameraPosition,m.position.x,m.position.y,m.position.z);(t instanceof THREE.MeshShaderMaterial||t.envMap||t.skinning)&&e.uniformMatrix4fv(D.objectMatrix,!1,y._objectMatrixArray);(t instanceof THREE.MeshPhongMaterial||t instanceof THREE.MeshLambertMaterial||t instanceof THREE.MeshShaderMaterial||t.skinning)&&e.uniformMatrix4fv(D.viewMatrix,
-!1,Z);if(t.skinning){e.uniformMatrix4fv(D.cameraInverseMatrix,!1,Z);e.uniformMatrix4fv(D.boneGlobalMatrices,!1,y.boneMatrices)}return C}function f(m,A,x,t,y,C){m=d(m,A,x,t,C).attributes;e.bindBuffer(e.ARRAY_BUFFER,y.__webGLVertexBuffer);e.vertexAttribPointer(m.position,3,e.FLOAT,!1,0,0);if(m.color>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLColorBuffer);e.vertexAttribPointer(m.color,3,e.FLOAT,!1,0,0)}if(m.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLNormalBuffer);e.vertexAttribPointer(m.normal,3,
-e.FLOAT,!1,0,0)}if(m.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLTangentBuffer);e.vertexAttribPointer(m.tangent,4,e.FLOAT,!1,0,0)}if(m.uv>=0)if(y.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLUVBuffer);e.vertexAttribPointer(m.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv)}else e.disableVertexAttribArray(m.uv);if(m.uv2>=0)if(y.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLUV2Buffer);e.vertexAttribPointer(m.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv2)}else e.disableVertexAttribArray(m.uv2);
-if(t.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinVertexABuffer);e.vertexAttribPointer(m.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinVertexBBuffer);e.vertexAttribPointer(m.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinIndicesBuffer);e.vertexAttribPointer(m.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,y.__webGLSkinWeightsBuffer);e.vertexAttribPointer(m.skinWeight,
-4,e.FLOAT,!1,0,0)}if(C instanceof THREE.Mesh)if(t.wireframe){e.lineWidth(t.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y.__webGLLineBuffer);e.drawElements(e.LINES,y.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,y.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(C instanceof THREE.Line){C=C.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(t.linewidth);e.drawArrays(C,0,y.__webGLLineCount)}else if(C instanceof
-THREE.ParticleSystem)e.drawArrays(e.POINTS,0,y.__webGLParticleCount);else C instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,y.__webGLVertexCount)}function g(m,A){if(!m.__webGLVertexBuffer)m.__webGLVertexBuffer=e.createBuffer();if(!m.__webGLNormalBuffer)m.__webGLNormalBuffer=e.createBuffer();if(m.hasPos){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,m.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(A.attributes.position);e.vertexAttribPointer(A.attributes.position,
-3,e.FLOAT,!1,0,0)}if(m.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,m.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,m.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(A.attributes.normal);e.vertexAttribPointer(A.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,m.count);m.count=0}function h(m){if(V!=m.doubleSided){m.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);V=m.doubleSided}if(T!=m.flipSided){m.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);T=m.flipSided}}function k(m){if(da!=
-m){m?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);da=m}}function j(m){J[0].set(m.n41-m.n11,m.n42-m.n12,m.n43-m.n13,m.n44-m.n14);J[1].set(m.n41+m.n11,m.n42+m.n12,m.n43+m.n13,m.n44+m.n14);J[2].set(m.n41+m.n21,m.n42+m.n22,m.n43+m.n23,m.n44+m.n24);J[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);J[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);J[5].set(m.n41+m.n31,m.n42+m.n32,m.n43+m.n33,m.n44+m.n34);var A;for(m=0;m<6;m++){A=J[m];A.divideScalar(Math.sqrt(A.x*A.x+A.y*A.y+A.z*A.z))}}
-function l(m){for(var A=m.matrixWorld,x=-m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)),t=0;t<6;t++){m=J[t].x*A.n14+J[t].y*A.n24+J[t].z*A.n34+J[t].w;if(m<=x)return!1}return!0}function n(m,A){m.list[m.count]=A;m.count+=1}function v(m){var A,x,t=m.object,y=m.opaque,C=m.transparent;C.count=0;m=y.count=0;for(A=t.materials.length;m<A;m++){x=t.materials[m];x.opacity&&x.opacity<1||x.blending!=THREE.NormalBlending?n(C,x):n(y,x)}}function p(m){var A,x,t,y,C=m.object,D=m.buffer,
-E=m.opaque,K=m.transparent;K.count=0;m=E.count=0;for(t=C.materials.length;m<t;m++){A=C.materials[m];if(A instanceof THREE.MeshFaceMaterial){A=0;for(x=D.materials.length;A<x;A++)(y=D.materials[A])&&(y.opacity&&y.opacity<1||y.blending!=THREE.NormalBlending?n(K,y):n(E,y))}else{y=A;y.opacity&&y.opacity<1||y.blending!=THREE.NormalBlending?n(K,y):n(E,y)}}}function q(m,A){return A.z-m.z}function w(m,A,x,t,y){if(A[x]==undefined){m.push({buffer:t,object:y,opaque:{list:[],count:0},transparent:{list:[],count:0}});
-A[x]=1}}function B(m,A){m._modelViewMatrix.multiplyToArray(A.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(m._modelViewMatrix).transposeIntoArray(m._normalMatrixArray)}function H(m){if(m!=Y){switch(m){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);
-break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}Y=m}}function u(m,A){if(m&&!m.__webGLFramebuffer){m.__webGLFramebuffer=e.createFramebuffer();m.__webGLRenderbuffer=e.createRenderbuffer();m.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,m.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,m.width,m.height);e.bindTexture(e.TEXTURE_2D,
-m.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o(m.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,o(m.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,o(m.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,o(m.minFilter));e.texImage2D(e.TEXTURE_2D,0,o(m.format),m.width,m.height,0,o(m.format),o(m.type),null);e.bindFramebuffer(e.FRAMEBUFFER,m.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,m.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,
-e.DEPTH_ATTACHMENT,e.RENDERBUFFER,m.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var x,t,y;if(m){x=m.__webGLFramebuffer;t=m.width;y=m.height}else{x=null;t=M.width;y=M.height}if(x!=O){e.bindFramebuffer(e.FRAMEBUFFER,x);e.viewport(0,0,t,y);A&&e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT);O=x}}function I(m,A){var x;if(m=="fragment")x=e.createShader(e.FRAGMENT_SHADER);else m=="vertex"&&(x=e.createShader(e.VERTEX_SHADER));
-e.shaderSource(x,A);e.compileShader(x);if(!e.getShaderParameter(x,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(x));return null}return x}function o(m){switch(m){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;
-case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;
-case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var M=document.createElement("canvas"),e,ba=null,O=null,P=this,V=null,T=null,Y=null,da=null,J=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],$=new THREE.Matrix4,ra=new Float32Array(16),Z=new Float32Array(16),la=new THREE.Vector4,ja=!0,fa=new THREE.Color(0),sa=0;if(a){if(a.antialias!==undefined)ja=a.antialias;a.clearColor!==undefined&&
-fa.setHex(a.clearColor);if(a.clearAlpha!==undefined)sa=a.clearAlpha}this.domElement=M;this.autoClear=!0;this.sortObjects=!1;(function(m,A,x){try{e=M.getContext("experimental-webgl",{antialias:m})}catch(t){console.log(t)}if(!e)throw"cannot create webgl context";e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.clearColor(A.r,A.g,A.b,x);_cullEnabled=
-!0})(ja,fa,sa);this.context=e;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(m,A){M.width=m;M.height=A;e.viewport(0,0,M.width,M.height)};this.setClearColorHex=function(m,A){var x=new THREE.Color(m);e.clearColor(x.r,x.g,x.b,A)};this.setClearColor=function(m,A){e.clearColor(m.r,m.g,m.b,A)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.initMaterial=function(m,A,x){var t,y;if(m instanceof
-THREE.MeshDepthMaterial)c(m,THREE.ShaderLib.depth);else if(m instanceof THREE.MeshNormalMaterial)c(m,THREE.ShaderLib.normal);else if(m instanceof THREE.MeshBasicMaterial)c(m,THREE.ShaderLib.basic);else if(m instanceof THREE.MeshLambertMaterial)c(m,THREE.ShaderLib.lambert);else if(m instanceof THREE.MeshPhongMaterial)c(m,THREE.ShaderLib.phong);else if(m instanceof THREE.LineBasicMaterial)c(m,THREE.ShaderLib.basic);else m instanceof THREE.ParticleBasicMaterial&&c(m,THREE.ShaderLib.particle_basic);var C,
-D,E,K;y=E=K=0;for(C=A.length;y<C;y++){D=A[y];D instanceof THREE.DirectionalLight&&E++;D instanceof THREE.PointLight&&K++}if(K+E<=4)A=E;else{A=Math.ceil(4*E/(K+E));K=4-A}y={directional:A,point:K};K=m.fragmentShader;A=m.vertexShader;C={fog:x,map:m.map,envMap:m.envMap,lightMap:m.lightMap,vertexColors:m.vertexColors,skinning:m.skinning,maxDirLights:y.directional,maxPointLights:y.point};x=e.createProgram();y=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+C.maxDirLights,"#define MAX_POINT_LIGHTS "+
-C.maxPointLights,C.fog?"#define USE_FOG":"",C.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",C.map?"#define USE_MAP":"",C.envMap?"#define USE_ENVMAP":"",C.lightMap?"#define USE_LIGHTMAP":"",C.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");C=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+C.maxDirLights,"#define MAX_POINT_LIGHTS "+C.maxPointLights,C.map?"#define USE_MAP":"",C.envMap?
-"#define USE_ENVMAP":"",C.lightMap?"#define USE_LIGHTMAP":"",C.vertexColors?"#define USE_COLOR":"",C.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
-e.attachShader(x,I("fragment",y+K));e.attachShader(x,I("vertex",C+A));e.linkProgram(x);e.getProgramParameter(x,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(x,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");x.uniforms={};x.attributes={};m.program=x;x=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(t in m.uniforms)x.push(t);t=m.program;K=0;for(A=x.length;K<
-A;K++){y=x[K];t.uniforms[y]=e.getUniformLocation(t,y)}t=m.program;x=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];K=0;for(A=x.length;K<A;K++){y=x[K];t.attributes[y]=e.getAttribLocation(t,y)}t=m.program.attributes;e.enableVertexAttribArray(t.position);t.color>=0&&e.enableVertexAttribArray(t.color);t.normal>=0&&e.enableVertexAttribArray(t.normal);t.tangent>=0&&e.enableVertexAttribArray(t.tangent);if(m.skinning&&t.skinVertexA>=0&&t.skinVertexB>=
-0&&t.skinIndex>=0&&t.skinWeight>=0){e.enableVertexAttribArray(t.skinVertexA);e.enableVertexAttribArray(t.skinVertexB);e.enableVertexAttribArray(t.skinIndex);e.enableVertexAttribArray(t.skinWeight)}};this.render=function(m,A,x,t){var y,C,D,E,K,W,z,F,L=m.lights,G=m.fog;A.matrixAutoUpdate&&A.update();A.matrixWorldInverse.flattenToArray(Z);A.projectionMatrix.flattenToArray(ra);$.multiply(A.projectionMatrix,A.matrixWorldInverse);j($);THREE.AnimationHandler&&THREE.AnimationHandler.update();m.update(undefined,
-!1,A);this.initWebGLObjects(m,A);u(x,t!==undefined?t:!0);this.autoClear&&this.clear();K=m.__webGLObjects.length;for(t=0;t<K;t++){y=m.__webGLObjects[t];z=y.object;if(z.visible)if(!(z instanceof THREE.Mesh)||l(z)){z.matrixWorld.flattenToArray(z._objectMatrixArray);B(z,A);p(y);y.render=!0;if(this.sortObjects){la.copy(z.position);$.multiplyVector3(la);y.z=la.z}}else y.render=!1;else y.render=!1}this.sortObjects&&m.__webGLObjects.sort(q);W=m.__webGLObjectsImmediate.length;for(t=0;t<W;t++){y=m.__webGLObjectsImmediate[t];
-z=y.object;if(z.visible){z.matrixAutoUpdate&&z.matrixWorld.flattenToArray(z._objectMatrixArray);B(z,A);v(y)}}H(THREE.NormalBlending);for(t=0;t<K;t++){y=m.__webGLObjects[t];if(y.render){z=y.object;F=y.buffer;D=y.opaque;h(z);for(y=0;y<D.count;y++){E=D.list[y];k(E.depthTest);f(A,L,G,E,F,z)}}}for(t=0;t<W;t++){y=m.__webGLObjectsImmediate[t];z=y.object;if(z.visible){D=y.opaque;h(z);for(y=0;y<D.count;y++){E=D.list[y];k(E.depthTest);C=d(A,L,G,E,z);z.render(function(U){g(U,C)})}}}for(t=0;t<K;t++){y=m.__webGLObjects[t];
-if(y.render){z=y.object;F=y.buffer;D=y.transparent;h(z);for(y=0;y<D.count;y++){E=D.list[y];H(E.blending);k(E.depthTest);f(A,L,G,E,F,z)}}}for(t=0;t<W;t++){y=m.__webGLObjectsImmediate[t];z=y.object;if(z.visible){D=y.transparent;h(z);for(y=0;y<D.count;y++){E=D.list[y];H(E.blending);k(E.depthTest);C=d(A,L,G,E,z);z.render(function(U){g(U,C)})}}}if(x&&x.minFilter!==THREE.NearestFilter&&x.minFilter!==THREE.LinearFilter){e.bindTexture(e.TEXTURE_2D,x.__webGLTexture);e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,
-null)}};this.initWebGLObjects=function(m,A){var x,t,y;if(!m.__webGLObjects){m.__webGLObjects=[];m.__webGLObjectsMap={};m.__webGLObjectsImmediate=[]}x=0;for(t=m.objects.length;x<t;x++){y=m.objects[x];var C=m,D=A,E=void 0,K=void 0,W=void 0,z=void 0;K=y.geometry;if(C.__webGLObjectsMap[y.id]==undefined){C.__webGLObjectsMap[y.id]={};y._modelViewMatrix=new THREE.Matrix4;y._normalMatrixArray=new Float32Array(9);y._modelViewMatrixArray=new Float32Array(16);y._objectMatrixArray=new Float32Array(16);y.matrixWorld.flattenToArray(y._objectMatrixArray)}z=
-C.__webGLObjectsMap[y.id];objlist=C.__webGLObjects;if(y instanceof THREE.Mesh){for(E in K.geometryChunks){W=K.geometryChunks[E];if(!W.__webGLVertexBuffer){D=W;D.__webGLVertexBuffer=e.createBuffer();D.__webGLNormalBuffer=e.createBuffer();D.__webGLTangentBuffer=e.createBuffer();D.__webGLColorBuffer=e.createBuffer();D.__webGLUVBuffer=e.createBuffer();D.__webGLUV2Buffer=e.createBuffer();D.__webGLSkinVertexABuffer=e.createBuffer();D.__webGLSkinVertexBBuffer=e.createBuffer();D.__webGLSkinIndicesBuffer=
-e.createBuffer();D.__webGLSkinWeightsBuffer=e.createBuffer();D.__webGLFaceBuffer=e.createBuffer();D.__webGLLineBuffer=e.createBuffer();D=W;var F=y,L=void 0,G=void 0,U=0,pa=C=0,ka=F.geometry.faces,oa=D.faces;L=0;for(G=oa.length;L<G;L++){fi=oa[L];face=ka[fi];if(face instanceof THREE.Face3){U+=3;C+=1;pa+=3}else if(face instanceof THREE.Face4){U+=4;C+=2;pa+=4}}D.__vertexArray=new Float32Array(U*3);D.__normalArray=new Float32Array(U*3);D.__tangentArray=new Float32Array(U*4);D.__colorArray=new Float32Array(U*
-3);D.__uvArray=new Float32Array(U*2);D.__uv2Array=new Float32Array(U*2);D.__skinVertexAArray=new Float32Array(U*4);D.__skinVertexBArray=new Float32Array(U*4);D.__skinIndexArray=new Float32Array(U*4);D.__skinWeightArray=new Float32Array(U*4);D.__faceArray=new Uint16Array(C*3);D.__lineArray=new Uint16Array(pa*2);G=L=D;U=void 0;ka=void 0;var na=void 0,ma=void 0;na=void 0;oa=!1;U=0;for(ka=F.materials.length;U<ka;U++){na=F.materials[U];if(na instanceof THREE.MeshFaceMaterial){na=0;for(ma=G.materials.length;na<
-ma;na++)if(G.materials[na]&&G.materials[na].shading!=undefined&&G.materials[na].shading==THREE.SmoothShading){oa=!0;break}}else if(na&&na.shading!=undefined&&na.shading==THREE.SmoothShading){oa=!0;break}if(oa)break}L.__needsSmoothNormals=oa;D.__webGLFaceCount=C*3;D.__webGLLineCount=pa*2;K.__dirtyVertices=!0;K.__dirtyElements=!0;K.__dirtyUvs=!0;K.__dirtyNormals=!0;K.__dirtyTangents=!0;K.__dirtyColors=!0}if(K.__dirtyVertices||K.__dirtyElements||K.__dirtyUvs||K.__dirtyNormals||K.__dirtyColors||K.__dirtyTangents){D=
-W;C=e.DYNAMIC_DRAW;pa=void 0;L=void 0;var va=void 0,Q=void 0,Ia=void 0,Ea=void 0,Ka=void 0;va=void 0;var ca=void 0,aa=void 0,X=void 0,ta=void 0;ca=void 0;aa=void 0;X=void 0;Q=void 0;ca=void 0;aa=void 0;X=void 0;ta=void 0;ca=void 0;aa=void 0;X=void 0;ta=void 0;ca=void 0;aa=void 0;X=void 0;ta=void 0;ca=void 0;aa=void 0;X=void 0;ta=void 0;ca=void 0;aa=void 0;X=void 0;ta=void 0;Q=void 0;Ea=void 0;Ia=void 0;Ka=void 0;var Fa=ma=na=oa=ka=U=F=G=0,Ca=0,N=0,Da=D.__vertexArray,Ra=D.__uvArray,Pa=D.__uv2Array,
-Ja=D.__normalArray,ia=D.__tangentArray,xa=D.__colorArray,ua=D.__skinVertexAArray,ya=D.__skinVertexBArray,za=D.__skinIndexArray,wa=D.__skinWeightArray,R=D.__faceArray,ga=D.__lineArray,ha=D.__needsSmoothNormals,S=y.geometry,ea=S.__dirtyVertices,qa=S.__dirtyElements,Aa=S.__dirtyUvs,Ga=S.__dirtyNormals,Ha=S.__dirtyTangents,La=S.__dirtyColors,Ba=S.vertices,Ma=D.faces,Ta=S.faces,Na=S.uvs,Oa=S.uvs2,Qa=S.colors,Ua=S.skinVerticesA,Va=S.skinVerticesB,Wa=S.skinIndices,Sa=S.skinWeights;pa=0;for(L=Ma.length;pa<
-L;pa++){va=Ma[pa];Q=Ta[va];Ka=Na[va];va=Oa[va];Ia=Q.vertexNormals;Ea=Q.normal;if(Q instanceof THREE.Face3){if(ea){ca=Ba[Q.a].position;aa=Ba[Q.b].position;X=Ba[Q.c].position;Da[F]=ca.x;Da[F+1]=ca.y;Da[F+2]=ca.z;Da[F+3]=aa.x;Da[F+4]=aa.y;Da[F+5]=aa.z;Da[F+6]=X.x;Da[F+7]=X.y;Da[F+8]=X.z;F+=9}if(Sa.length){ca=Sa[Q.a];aa=Sa[Q.b];X=Sa[Q.c];wa[N]=ca.x;wa[N+1]=ca.y;wa[N+2]=ca.z;wa[N+3]=ca.w;wa[N+4]=aa.x;wa[N+5]=aa.y;wa[N+6]=aa.z;wa[N+7]=aa.w;wa[N+8]=X.x;wa[N+9]=X.y;wa[N+10]=X.z;wa[N+11]=X.w;ca=Wa[Q.a];aa=
-Wa[Q.b];X=Wa[Q.c];za[N]=ca.x;za[N+1]=ca.y;za[N+2]=ca.z;za[N+3]=ca.w;za[N+4]=aa.x;za[N+5]=aa.y;za[N+6]=aa.z;za[N+7]=aa.w;za[N+8]=X.x;za[N+9]=X.y;za[N+10]=X.z;za[N+11]=X.w;ca=Ua[Q.a];aa=Ua[Q.b];X=Ua[Q.c];ua[N]=ca.x;ua[N+1]=ca.y;ua[N+2]=ca.z;ua[N+3]=1;ua[N+4]=aa.x;ua[N+5]=aa.y;ua[N+6]=aa.z;ua[N+7]=1;ua[N+8]=X.x;ua[N+9]=X.y;ua[N+10]=X.z;ua[N+11]=1;ca=Va[Q.a];aa=Va[Q.b];X=Va[Q.c];ya[N]=ca.x;ya[N+1]=ca.y;ya[N+2]=ca.z;ya[N+3]=1;ya[N+4]=aa.x;ya[N+5]=aa.y;ya[N+6]=aa.z;ya[N+7]=1;ya[N+8]=X.x;ya[N+9]=X.y;ya[N+
-10]=X.z;ya[N+11]=1;N+=12}if(La&&Qa.length){ca=Qa[Q.a];aa=Qa[Q.b];X=Qa[Q.c];xa[Ca]=ca.r;xa[Ca+1]=ca.g;xa[Ca+2]=ca.b;xa[Ca+3]=aa.r;xa[Ca+4]=aa.g;xa[Ca+5]=aa.b;xa[Ca+6]=X.r;xa[Ca+7]=X.g;xa[Ca+8]=X.b;Ca+=9}if(Ha&&S.hasTangents){ca=Ba[Q.a].tangent;aa=Ba[Q.b].tangent;X=Ba[Q.c].tangent;ia[ma]=ca.x;ia[ma+1]=ca.y;ia[ma+2]=ca.z;ia[ma+3]=ca.w;ia[ma+4]=aa.x;ia[ma+5]=aa.y;ia[ma+6]=aa.z;ia[ma+7]=aa.w;ia[ma+8]=X.x;ia[ma+9]=X.y;ia[ma+10]=X.z;ia[ma+11]=X.w;ma+=12}if(Ga)if(Ia.length==3&&ha)for(Q=0;Q<3;Q++){Ea=Ia[Q];
-Ja[na]=Ea.x;Ja[na+1]=Ea.y;Ja[na+2]=Ea.z;na+=3}else for(Q=0;Q<3;Q++){Ja[na]=Ea.x;Ja[na+1]=Ea.y;Ja[na+2]=Ea.z;na+=3}if(Aa&&Ka)for(Q=0;Q<3;Q++){Ia=Ka[Q];Ra[U]=Ia.u;Ra[U+1]=Ia.v;U+=2}if(Aa&&va)for(Q=0;Q<3;Q++){Ka=va[Q];Pa[ka]=Ka.u;Pa[ka+1]=Ka.v;ka+=2}if(qa){R[oa]=G;R[oa+1]=G+1;R[oa+2]=G+2;oa+=3;ga[Fa]=G;ga[Fa+1]=G+1;ga[Fa+2]=G;ga[Fa+3]=G+2;ga[Fa+4]=G+1;ga[Fa+5]=G+2;Fa+=6;G+=3}}else if(Q instanceof THREE.Face4){if(ea){ca=Ba[Q.a].position;aa=Ba[Q.b].position;X=Ba[Q.c].position;ta=Ba[Q.d].position;Da[F]=
-ca.x;Da[F+1]=ca.y;Da[F+2]=ca.z;Da[F+3]=aa.x;Da[F+4]=aa.y;Da[F+5]=aa.z;Da[F+6]=X.x;Da[F+7]=X.y;Da[F+8]=X.z;Da[F+9]=ta.x;Da[F+10]=ta.y;Da[F+11]=ta.z;F+=12}if(Sa.length){ca=Sa[Q.a];aa=Sa[Q.b];X=Sa[Q.c];ta=Sa[Q.d];wa[N]=ca.x;wa[N+1]=ca.y;wa[N+2]=ca.z;wa[N+3]=ca.w;wa[N+4]=aa.x;wa[N+5]=aa.y;wa[N+6]=aa.z;wa[N+7]=aa.w;wa[N+8]=X.x;wa[N+9]=X.y;wa[N+10]=X.z;wa[N+11]=X.w;wa[N+12]=ta.x;wa[N+13]=ta.y;wa[N+14]=ta.z;wa[N+15]=ta.w;ca=Wa[Q.a];aa=Wa[Q.b];X=Wa[Q.c];ta=Wa[Q.d];za[N]=ca.x;za[N+1]=ca.y;za[N+2]=ca.z;za[N+
-3]=ca.w;za[N+4]=aa.x;za[N+5]=aa.y;za[N+6]=aa.z;za[N+7]=aa.w;za[N+8]=X.x;za[N+9]=X.y;za[N+10]=X.z;za[N+11]=X.w;za[N+12]=ta.x;za[N+13]=ta.y;za[N+14]=ta.z;za[N+15]=ta.w;ca=Ua[Q.a];aa=Ua[Q.b];X=Ua[Q.c];ta=Ua[Q.d];ua[N]=ca.x;ua[N+1]=ca.y;ua[N+2]=ca.z;ua[N+3]=1;ua[N+4]=aa.x;ua[N+5]=aa.y;ua[N+6]=aa.z;ua[N+7]=1;ua[N+8]=X.x;ua[N+9]=X.y;ua[N+10]=X.z;ua[N+11]=1;ua[N+12]=ta.x;ua[N+13]=ta.y;ua[N+14]=ta.z;ua[N+15]=1;ca=Va[Q.a];aa=Va[Q.b];X=Va[Q.c];ta=Va[Q.d];ya[N]=ca.x;ya[N+1]=ca.y;ya[N+2]=ca.z;ya[N+3]=1;ya[N+
-4]=aa.x;ya[N+5]=aa.y;ya[N+6]=aa.z;ya[N+7]=1;ya[N+8]=X.x;ya[N+9]=X.y;ya[N+10]=X.z;ya[N+11]=1;ya[N+12]=ta.x;ya[N+13]=ta.y;ya[N+14]=ta.z;ya[N+15]=1;N+=16}if(La&&Qa.length){ca=Qa[Q.a];aa=Qa[Q.b];X=Qa[Q.c];ta=Qa[Q.d];xa[Ca]=ca.r;xa[Ca+1]=ca.g;xa[Ca+2]=ca.b;xa[Ca+3]=aa.r;xa[Ca+4]=aa.g;xa[Ca+5]=aa.b;xa[Ca+6]=X.r;xa[Ca+7]=X.g;xa[Ca+8]=X.b;xa[Ca+9]=ta.r;xa[Ca+10]=ta.g;xa[Ca+11]=ta.b;Ca+=12}if(Ha&&S.hasTangents){ca=Ba[Q.a].tangent;aa=Ba[Q.b].tangent;X=Ba[Q.c].tangent;Q=Ba[Q.d].tangent;ia[ma]=ca.x;ia[ma+1]=
-ca.y;ia[ma+2]=ca.z;ia[ma+3]=ca.w;ia[ma+4]=aa.x;ia[ma+5]=aa.y;ia[ma+6]=aa.z;ia[ma+7]=aa.w;ia[ma+8]=X.x;ia[ma+9]=X.y;ia[ma+10]=X.z;ia[ma+11]=X.w;ia[ma+12]=Q.x;ia[ma+13]=Q.y;ia[ma+14]=Q.z;ia[ma+15]=Q.w;ma+=16}if(Ga)if(Ia.length==4&&ha)for(Q=0;Q<4;Q++){Ea=Ia[Q];Ja[na]=Ea.x;Ja[na+1]=Ea.y;Ja[na+2]=Ea.z;na+=3}else for(Q=0;Q<4;Q++){Ja[na]=Ea.x;Ja[na+1]=Ea.y;Ja[na+2]=Ea.z;na+=3}if(Aa&&Ka)for(Q=0;Q<4;Q++){Ia=Ka[Q];Ra[U]=Ia.u;Ra[U+1]=Ia.v;U+=2}if(Aa&&va)for(Q=0;Q<4;Q++){Ka=va[Q];Pa[ka]=Ka.u;Pa[ka+1]=Ka.v;ka+=
-2}if(qa){R[oa]=G;R[oa+1]=G+1;R[oa+2]=G+2;R[oa+3]=G;R[oa+4]=G+2;R[oa+5]=G+3;oa+=6;ga[Fa]=G;ga[Fa+1]=G+1;ga[Fa+2]=G;ga[Fa+3]=G+3;ga[Fa+4]=G+1;ga[Fa+5]=G+2;ga[Fa+6]=G+2;ga[Fa+7]=G+3;Fa+=8;G+=4}}}if(ea){e.bindBuffer(e.ARRAY_BUFFER,D.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Da,C)}if(La&&Qa.length){e.bindBuffer(e.ARRAY_BUFFER,D.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,xa,C)}if(Ga){e.bindBuffer(e.ARRAY_BUFFER,D.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Ja,C)}if(Ha&&S.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,
-D.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,ia,C)}if(Aa&&U>0){e.bindBuffer(e.ARRAY_BUFFER,D.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,Ra,C)}if(Aa&&ka>0){e.bindBuffer(e.ARRAY_BUFFER,D.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Pa,C)}if(qa){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,D.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,R,C);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,D.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ga,C)}if(N>0){e.bindBuffer(e.ARRAY_BUFFER,D.__webGLSkinVertexABuffer);
-e.bufferData(e.ARRAY_BUFFER,ua,C);e.bindBuffer(e.ARRAY_BUFFER,D.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ya,C);e.bindBuffer(e.ARRAY_BUFFER,D.__webGLSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,za,C);e.bindBuffer(e.ARRAY_BUFFER,D.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,wa,C)}}w(objlist,z,E,W,y)}K.__dirtyVertices=!1;K.__dirtyElements=!1;K.__dirtyUvs=!1;K.__dirtyNormals=!1;K.__dirtyTangents=!1;K.__dirtyColors=!1}else if(y instanceof THREE.Ribbon){if(!K.__webGLVertexBuffer){E=
-K;E.__webGLVertexBuffer=e.createBuffer();E.__webGLColorBuffer=e.createBuffer();E=K;W=E.vertices.length;E.__vertexArray=new Float32Array(W*3);E.__colorArray=new Float32Array(W*3);E.__webGLVertexCount=W;K.__dirtyVertices=!0;K.__dirtyColors=!0}if(K.__dirtyVertices||K.__dirtyColors){E=K;W=e.DYNAMIC_DRAW;G=void 0;G=void 0;F=void 0;D=void 0;U=E.vertices;C=E.colors;ka=U.length;pa=C.length;oa=E.__vertexArray;L=E.__colorArray;na=E.__dirtyColors;if(E.__dirtyVertices){for(G=0;G<ka;G++){F=U[G].position;D=G*3;
-oa[D]=F.x;oa[D+1]=F.y;oa[D+2]=F.z}e.bindBuffer(e.ARRAY_BUFFER,E.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,oa,W)}if(na){for(G=0;G<pa;G++){color=C[G];D=G*3;L[D]=color.r;L[D+1]=color.g;L[D+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,E.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,L,W)}}w(objlist,z,0,K,y);K.__dirtyVertices=!1;K.__dirtyColors=!1}else if(y instanceof THREE.Line){if(!K.__webGLVertexBuffer){E=K;E.__webGLVertexBuffer=e.createBuffer();E.__webGLColorBuffer=e.createBuffer();E=K;W=E.vertices.length;
-E.__vertexArray=new Float32Array(W*3);E.__colorArray=new Float32Array(W*3);E.__webGLLineCount=W;K.__dirtyVertices=!0;K.__dirtyColors=!0}if(K.__dirtyVertices||K.__dirtyColors){E=K;W=e.DYNAMIC_DRAW;G=void 0;G=void 0;F=void 0;D=void 0;U=E.vertices;C=E.colors;ka=U.length;pa=C.length;oa=E.__vertexArray;L=E.__colorArray;na=E.__dirtyColors;if(E.__dirtyVertices){for(G=0;G<ka;G++){F=U[G].position;D=G*3;oa[D]=F.x;oa[D+1]=F.y;oa[D+2]=F.z}e.bindBuffer(e.ARRAY_BUFFER,E.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,
-oa,W)}if(na){for(G=0;G<pa;G++){color=C[G];D=G*3;L[D]=color.r;L[D+1]=color.g;L[D+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,E.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,L,W)}}w(objlist,z,0,K,y);K.__dirtyVertices=!1;K.__dirtyColors=!1}else if(y instanceof THREE.ParticleSystem){if(!K.__webGLVertexBuffer){E=K;E.__webGLVertexBuffer=e.createBuffer();E.__webGLColorBuffer=e.createBuffer();E=K;W=E.vertices.length;E.__vertexArray=new Float32Array(W*3);E.__colorArray=new Float32Array(W*3);E.__sortArray=[];
-E.__webGLParticleCount=W;K.__dirtyVertices=!0;K.__dirtyColors=!0}(K.__dirtyVertices||K.__dirtyColors||y.sortParticles)&&b(K,e.DYNAMIC_DRAW,y,D);w(objlist,z,0,K,y);K.__dirtyVertices=!1;K.__dirtyColors=!1}else if(THREE.MarchingCubes!==undefined&&y instanceof THREE.MarchingCubes){K=z;if(K[0]==undefined){C.__webGLObjectsImmediate.push({object:y,opaque:{list:[],count:0},transparent:{list:[],count:0}});K[0]=1}}}};this.removeObject=function(m,A){var x,t;for(x=m.__webGLObjects.length-1;x>=0;x--){t=m.__webGLObjects[x].object;
-A==t&&m.__webGLObjects.splice(x,1)}};this.setFaceCulling=function(m,A){if(m){!A||A=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(m=="back")e.cullFace(e.BACK);else m=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
+THREE.Projector=function(){function a(O,Q){return Q.z-O.z}function b(O,Q){var W=0,U=1,aa=O.z+O.w,ea=Q.z+Q.w,M=-O.z+O.w,X=-Q.z+Q.w;if(aa>=0&&ea>=0&&M>=0&&X>=0)return!0;else if(aa<0&&ea<0||M<0&&X<0)return!1;else{if(aa<0)W=Math.max(W,aa/(aa-ea));else ea<0&&(U=Math.min(U,aa/(aa-ea)));if(M<0)W=Math.max(W,M/(M-X));else X<0&&(U=Math.min(U,M/(M-X)));if(U<W)return!1;else{O.lerpSelf(Q,W);Q.lerpSelf(O,1-U);return!0}}}var c,d,f=[],g,h,k,j=[],m,n,w=[],o,p,x=[],A=new THREE.Vector4,I=new THREE.Vector4,v=new THREE.Matrix4,
+J=new THREE.Matrix4,t=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],K=new THREE.Vector4,R=new THREE.Vector4,e;this.projectObjects=function(O,Q,W){Q=[];var U,aa,ea;d=0;aa=O.objects;O=0;for(U=aa.length;O<U;O++){ea=aa[O];var M;if(!(M=!ea.visible))if(M=ea instanceof THREE.Mesh){a:{M=void 0;for(var X=ea.matrixWorld,pa=-ea.geometry.boundingSphere.radius*Math.max(ea.scale.x,Math.max(ea.scale.y,ea.scale.z)),ba=0;ba<6;ba++){M=t[ba].x*X.n14+t[ba].y*
+X.n24+t[ba].z*X.n34+t[ba].w;if(M<=pa){M=!1;break a}}M=!0}M=!M}if(!M){c=f[d]=f[d]||new THREE.RenderableObject;A.copy(ea.position);v.multiplyVector3(A);c.object=ea;c.z=A.z;Q.push(c);d++}}W&&Q.sort(a);return Q};this.projectScene=function(O,Q,W){var U=[],aa=Q.near,ea=Q.far,M,X,pa,ba,la,ia,ga,ua,xa,l,z,B,u,q,E,C;k=n=p=0;Q.matrixAutoUpdate&&Q.update();v.multiply(Q.projectionMatrix,Q.matrixWorldInverse);t[0].set(v.n41-v.n11,v.n42-v.n12,v.n43-v.n13,v.n44-v.n14);t[1].set(v.n41+v.n11,v.n42+v.n12,v.n43+v.n13,
+v.n44+v.n14);t[2].set(v.n41+v.n21,v.n42+v.n22,v.n43+v.n23,v.n44+v.n24);t[3].set(v.n41-v.n21,v.n42-v.n22,v.n43-v.n23,v.n44-v.n24);t[4].set(v.n41-v.n31,v.n42-v.n32,v.n43-v.n33,v.n44-v.n34);t[5].set(v.n41+v.n31,v.n42+v.n32,v.n43+v.n33,v.n44+v.n34);for(M=0;M<6;M++){ia=t[M];ia.divideScalar(Math.sqrt(ia.x*ia.x+ia.y*ia.y+ia.z*ia.z))}O.update(undefined,!1,Q);ia=this.projectObjects(O,Q,!0);O=0;for(M=ia.length;O<M;O++){ga=ia[O].object;if(ga.visible){ua=ga.matrixWorld;z=ga.matrixRotationWorld;xa=ga.materials;
+l=ga.overdraw;if(ga instanceof THREE.Mesh){B=ga.geometry;u=B.vertices;X=0;for(pa=u.length;X<pa;X++){q=u[X];q.positionWorld.copy(q.position);ua.multiplyVector3(q.positionWorld);ba=q.positionScreen;ba.copy(q.positionWorld);v.multiplyVector4(ba);ba.x/=ba.w;ba.y/=ba.w;q.__visible=ba.z>aa&&ba.z<ea}B=B.faces;X=0;for(pa=B.length;X<pa;X++){q=B[X];if(q instanceof THREE.Face3){ba=u[q.a];la=u[q.b];E=u[q.c];if(ba.__visible&&la.__visible&&E.__visible&&(ga.doubleSided||ga.flipSided!=(E.positionScreen.x-ba.positionScreen.x)*
+(la.positionScreen.y-ba.positionScreen.y)-(E.positionScreen.y-ba.positionScreen.y)*(la.positionScreen.x-ba.positionScreen.x)<0)){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(ba.positionWorld);g.v2.positionWorld.copy(la.positionWorld);g.v3.positionWorld.copy(E.positionWorld);g.v1.positionScreen.copy(ba.positionScreen);g.v2.positionScreen.copy(la.positionScreen);g.v3.positionScreen.copy(E.positionScreen);g.normalWorld.copy(q.normal);z.multiplyVector3(g.normalWorld);g.centroidWorld.copy(q.centroid);
+ua.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);E=q.vertexNormals;e=g.vertexNormalsWorld;ba=0;for(la=E.length;ba<la;ba++){C=e[ba]=e[ba]||new THREE.Vector3;C.copy(E[ba]);z.multiplyVector3(C)}g.z=g.centroidScreen.z;g.meshMaterials=xa;g.faceMaterials=q.materials;g.overdraw=l;if(ga.geometry.uvs[X]){g.uvs[0]=ga.geometry.uvs[X][0];g.uvs[1]=ga.geometry.uvs[X][1];g.uvs[2]=ga.geometry.uvs[X][2]}U.push(g);k++}}else if(q instanceof THREE.Face4){ba=
+u[q.a];la=u[q.b];E=u[q.c];C=u[q.d];if(ba.__visible&&la.__visible&&E.__visible&&C.__visible&&(ga.doubleSided||ga.flipSided!=((C.positionScreen.x-ba.positionScreen.x)*(la.positionScreen.y-ba.positionScreen.y)-(C.positionScreen.y-ba.positionScreen.y)*(la.positionScreen.x-ba.positionScreen.x)<0||(la.positionScreen.x-E.positionScreen.x)*(C.positionScreen.y-E.positionScreen.y)-(la.positionScreen.y-E.positionScreen.y)*(C.positionScreen.x-E.positionScreen.x)<0))){g=j[k]=j[k]||new THREE.RenderableFace3;g.v1.positionWorld.copy(ba.positionWorld);
+g.v2.positionWorld.copy(la.positionWorld);g.v3.positionWorld.copy(C.positionWorld);g.v1.positionScreen.copy(ba.positionScreen);g.v2.positionScreen.copy(la.positionScreen);g.v3.positionScreen.copy(C.positionScreen);g.normalWorld.copy(q.normal);z.multiplyVector3(g.normalWorld);g.centroidWorld.copy(q.centroid);ua.multiplyVector3(g.centroidWorld);g.centroidScreen.copy(g.centroidWorld);v.multiplyVector3(g.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=xa;g.faceMaterials=q.materials;g.overdraw=
+l;if(ga.geometry.uvs[X]){g.uvs[0]=ga.geometry.uvs[X][0];g.uvs[1]=ga.geometry.uvs[X][1];g.uvs[2]=ga.geometry.uvs[X][3]}U.push(g);k++;h=j[k]=j[k]||new THREE.RenderableFace3;h.v1.positionWorld.copy(la.positionWorld);h.v2.positionWorld.copy(E.positionWorld);h.v3.positionWorld.copy(C.positionWorld);h.v1.positionScreen.copy(la.positionScreen);h.v2.positionScreen.copy(E.positionScreen);h.v3.positionScreen.copy(C.positionScreen);h.normalWorld.copy(g.normalWorld);h.centroidWorld.copy(g.centroidWorld);h.centroidScreen.copy(g.centroidScreen);
+h.z=h.centroidScreen.z;h.meshMaterials=xa;h.faceMaterials=q.materials;h.overdraw=l;if(ga.geometry.uvs[X]){h.uvs[0]=ga.geometry.uvs[X][1];h.uvs[1]=ga.geometry.uvs[X][2];h.uvs[2]=ga.geometry.uvs[X][3]}U.push(h);k++}}}}else if(ga instanceof THREE.Line){J.multiply(v,ua);u=ga.geometry.vertices;q=u[0];q.positionScreen.copy(q.position);J.multiplyVector4(q.positionScreen);X=1;for(pa=u.length;X<pa;X++){ba=u[X];ba.positionScreen.copy(ba.position);J.multiplyVector4(ba.positionScreen);la=u[X-1];K.copy(ba.positionScreen);
+R.copy(la.positionScreen);if(b(K,R)){K.multiplyScalar(1/K.w);R.multiplyScalar(1/R.w);m=w[n]=w[n]||new THREE.RenderableLine;m.v1.positionScreen.copy(K);m.v2.positionScreen.copy(R);m.z=Math.max(K.z,R.z);m.materials=ga.materials;U.push(m);n++}}}else if(ga instanceof THREE.Particle){I.set(ga.position.x,ga.position.y,ga.position.z,1);v.multiplyVector4(I);I.z/=I.w;if(I.z>0&&I.z<1){o=x[p]=x[p]||new THREE.RenderableParticle;o.x=I.x/I.w;o.y=I.y/I.w;o.z=I.z;o.rotation=ga.rotation.z;o.scale.x=ga.scale.x*Math.abs(o.x-
+(I.x+Q.projectionMatrix.n11)/(I.w+Q.projectionMatrix.n14));o.scale.y=ga.scale.y*Math.abs(o.y-(I.y+Q.projectionMatrix.n22)/(I.w+Q.projectionMatrix.n24));o.materials=ga.materials;U.push(o);p++}}}}W&&U.sort(a);return U};this.unprojectVector=function(O,Q){var W=Q.matrixWorld.clone();W.multiplySelf(THREE.Matrix4.makeInvert(Q.projectionMatrix));W.multiplyVector3(O);return O}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var a=null,b=new THREE.Projector,c,d,f,g;this.domElement=document.createElement("div");this.setSize=function(h,k){c=h;d=k;f=c/2;g=d/2};this.render=function(h,k){var j,m,n,w,o,p,x,A;a=b.projectScene(h,k);j=0;for(m=a.length;j<m;j++){o=a[j];if(o instanceof THREE.RenderableParticle){x=o.x*f+f;A=o.y*g+g;n=0;for(w=o.material.length;n<w;n++){p=o.material[n];if(p instanceof THREE.ParticleDOMMaterial){p=p.domElement;p.style.left=x+"px";p.style.top=A+"px"}}}}}};
+THREE.CanvasRenderer=function(){function a(ha){if(o!=ha)m.globalAlpha=o=ha}function b(ha){if(p!=ha){switch(ha){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}p=ha}}var c=null,d=new THREE.Projector,f=document.createElement("canvas"),g,h,k,j,m=f.getContext("2d"),n=new THREE.Color(0),w=0,o=1,p=0,x=null,A=null,I=1,v,J,t,K,R,e,O,Q,W,U=new THREE.Color,
+aa=new THREE.Color,ea=new THREE.Color,M=new THREE.Color,X=new THREE.Color,pa,ba,la,ia,ga,ua,xa,l,z,B=new THREE.Rectangle,u=new THREE.Rectangle,q=new THREE.Rectangle,E=!1,C=new THREE.Color,G=new THREE.Color,H=new THREE.Color,y=new THREE.Color,D=Math.PI*2,F=new THREE.Vector3,T,P,fa,ka,ra,na,ma=16;T=document.createElement("canvas");T.width=T.height=2;P=T.getContext("2d");P.fillStyle="rgba(0,0,0,1)";P.fillRect(0,0,2,2);fa=P.getImageData(0,0,2,2);ka=fa.data;ra=document.createElement("canvas");ra.width=
+ra.height=ma;na=ra.getContext("2d");na.translate(-ma/2,-ma/2);na.scale(ma,ma);ma--;this.domElement=f;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(ha,Ca){g=ha;h=Ca;k=g/2;j=h/2;f.width=g;f.height=h;B.set(-k,-j,k,j);o=1;p=0;A=x=null;I=1};this.setClearColor=function(ha,Ca){n=ha;w=Ca;u.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.setClearColorHex=function(ha,Ca){n.setHex(ha);w=Ca;u.set(-k,-j,k,j);m.setTransform(1,0,0,-1,k,j);this.clear()};this.clear=
+function(){m.setTransform(1,0,0,-1,k,j);if(!u.isEmpty()){u.inflate(1);u.minSelf(B);if(n.hex==0&&w==0)m.clearRect(u.getX(),u.getY(),u.getWidth(),u.getHeight());else{b(THREE.NormalBlending);a(1);m.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+w+")";m.fillRect(u.getX(),u.getY(),u.getWidth(),u.getHeight())}u.empty()}};this.render=function(ha,Ca){function S(L){var ja,ca,V,Y=L.lights;G.setRGB(0,0,0);H.setRGB(0,0,0);y.setRGB(0,0,0);L=0;for(ja=Y.length;L<ja;L++){ca=
+Y[L];V=ca.color;if(ca instanceof THREE.AmbientLight){G.r+=V.r;G.g+=V.g;G.b+=V.b}else if(ca instanceof THREE.DirectionalLight){H.r+=V.r;H.g+=V.g;H.b+=V.b}else if(ca instanceof THREE.PointLight){y.r+=V.r;y.g+=V.g;y.b+=V.b}}}function Ga(L,ja,ca,V){var Y,qa,Da,Ea,Ia=L.lights;L=0;for(Y=Ia.length;L<Y;L++){qa=Ia[L];Da=qa.color;Ea=qa.intensity;if(qa instanceof THREE.DirectionalLight){qa=ca.dot(qa.position)*Ea;if(qa>0){V.r+=Da.r*qa;V.g+=Da.g*qa;V.b+=Da.b*qa}}else if(qa instanceof THREE.PointLight){F.sub(qa.position,
+ja);F.normalize();qa=ca.dot(F)*Ea;if(qa>0){V.r+=Da.r*qa;V.g+=Da.g*qa;V.b+=Da.b*qa}}}}function Ha(L,ja,ca){if(ca.opacity!=0){a(ca.opacity);b(ca.blending);var V,Y,qa,Da,Ea,Ia;if(ca instanceof THREE.ParticleBasicMaterial){if(ca.map){Da=ca.map.image;Ea=Da.width>>1;Ia=Da.height>>1;Y=ja.scale.x*k;qa=ja.scale.y*j;ca=Y*Ea;V=qa*Ia;q.set(L.x-ca,L.y-V,L.x+ca,L.y+V);if(B.instersects(q)){m.save();m.translate(L.x,L.y);m.rotate(-ja.rotation);m.scale(Y,-qa);m.translate(-Ea,-Ia);m.drawImage(Da,0,0);m.restore()}}}else if(ca instanceof
+THREE.ParticleCircleMaterial){if(E){C.r=G.r+H.r+y.r;C.g=G.g+H.g+y.g;C.b=G.b+H.b+y.b;U.r=ca.color.r*C.r;U.g=ca.color.g*C.g;U.b=ca.color.b*C.b;U.updateStyleString()}else U.__styleString=ca.color.__styleString;ca=ja.scale.x*k;V=ja.scale.y*j;q.set(L.x-ca,L.y-V,L.x+ca,L.y+V);if(B.instersects(q)){Y=U.__styleString;if(A!=Y)m.fillStyle=A=Y;m.save();m.translate(L.x,L.y);m.rotate(-ja.rotation);m.scale(ca,V);m.beginPath();m.arc(0,0,1,0,D,!0);m.closePath();m.fill();m.restore()}}}}function La(L,ja,ca,V){if(V.opacity!=
+0){a(V.opacity);b(V.blending);m.beginPath();m.moveTo(L.positionScreen.x,L.positionScreen.y);m.lineTo(ja.positionScreen.x,ja.positionScreen.y);m.closePath();if(V instanceof THREE.LineBasicMaterial){U.__styleString=V.color.__styleString;L=V.linewidth;if(I!=L)m.lineWidth=I=L;L=U.__styleString;if(x!=L)m.strokeStyle=x=L;m.stroke();q.inflate(V.linewidth*2)}}}function da(L,ja,ca,V,Y,qa){if(Y.opacity!=0){a(Y.opacity);b(Y.blending);K=L.positionScreen.x;R=L.positionScreen.y;e=ja.positionScreen.x;O=ja.positionScreen.y;
+Q=ca.positionScreen.x;W=ca.positionScreen.y;m.beginPath();m.moveTo(K,R);m.lineTo(e,O);m.lineTo(Q,W);m.lineTo(K,R);m.closePath();if(Y instanceof THREE.MeshBasicMaterial)if(Y.map)Y.map.mapping instanceof THREE.UVMapping&&sa(K,R,e,O,Q,W,Y.map.image,V.uvs[0].u,V.uvs[0].v,V.uvs[1].u,V.uvs[1].v,V.uvs[2].u,V.uvs[2].v);else if(Y.envMap){if(Y.envMap.mapping instanceof THREE.SphericalReflectionMapping){L=Ca.matrixWorldInverse;F.copy(V.vertexNormalsWorld[0]);ia=(F.x*L.n11+F.y*L.n12+F.z*L.n13)*0.5+0.5;ga=-(F.x*
+L.n21+F.y*L.n22+F.z*L.n23)*0.5+0.5;F.copy(V.vertexNormalsWorld[1]);ua=(F.x*L.n11+F.y*L.n12+F.z*L.n13)*0.5+0.5;xa=-(F.x*L.n21+F.y*L.n22+F.z*L.n23)*0.5+0.5;F.copy(V.vertexNormalsWorld[2]);l=(F.x*L.n11+F.y*L.n12+F.z*L.n13)*0.5+0.5;z=-(F.x*L.n21+F.y*L.n22+F.z*L.n23)*0.5+0.5;sa(K,R,e,O,Q,W,Y.envMap.image,ia,ga,ua,xa,l,z)}}else Y.wireframe?Z(Y.color.__styleString,Y.wireframeLinewidth):$(Y.color.__styleString);else if(Y instanceof THREE.MeshLambertMaterial){if(Y.map&&!Y.wireframe){Y.map.mapping instanceof
+THREE.UVMapping&&sa(K,R,e,O,Q,W,Y.map.image,V.uvs[0].u,V.uvs[0].v,V.uvs[1].u,V.uvs[1].v,V.uvs[2].u,V.uvs[2].v);b(THREE.SubtractiveBlending)}if(E)if(!Y.wireframe&&Y.shading==THREE.SmoothShading&&V.vertexNormalsWorld.length==3){aa.r=ea.r=M.r=G.r;aa.g=ea.g=M.g=G.g;aa.b=ea.b=M.b=G.b;Ga(qa,V.v1.positionWorld,V.vertexNormalsWorld[0],aa);Ga(qa,V.v2.positionWorld,V.vertexNormalsWorld[1],ea);Ga(qa,V.v3.positionWorld,V.vertexNormalsWorld[2],M);X.r=(ea.r+M.r)*0.5;X.g=(ea.g+M.g)*0.5;X.b=(ea.b+M.b)*0.5;la=Ja(aa,
+ea,M,X);sa(K,R,e,O,Q,W,la,0,0,1,0,0,1)}else{C.r=G.r;C.g=G.g;C.b=G.b;Ga(qa,V.centroidWorld,V.normalWorld,C);U.r=Y.color.r*C.r;U.g=Y.color.g*C.g;U.b=Y.color.b*C.b;U.updateStyleString();Y.wireframe?Z(U.__styleString,Y.wireframeLinewidth):$(U.__styleString)}else Y.wireframe?Z(Y.color.__styleString,Y.wireframeLinewidth):$(Y.color.__styleString)}else if(Y instanceof THREE.MeshDepthMaterial){pa=Ca.near;ba=Ca.far;aa.r=aa.g=aa.b=1-Aa(L.positionScreen.z,pa,ba);ea.r=ea.g=ea.b=1-Aa(ja.positionScreen.z,pa,ba);
+M.r=M.g=M.b=1-Aa(ca.positionScreen.z,pa,ba);X.r=(ea.r+M.r)*0.5;X.g=(ea.g+M.g)*0.5;X.b=(ea.b+M.b)*0.5;la=Ja(aa,ea,M,X);sa(K,R,e,O,Q,W,la,0,0,1,0,0,1)}else if(Y instanceof THREE.MeshNormalMaterial){U.r=N(V.normalWorld.x);U.g=N(V.normalWorld.y);U.b=N(V.normalWorld.z);U.updateStyleString();Y.wireframe?Z(U.__styleString,Y.wireframeLinewidth):$(U.__styleString)}}}function Z(L,ja){if(x!=L)m.strokeStyle=x=L;if(I!=ja)m.lineWidth=I=ja;m.stroke();q.inflate(ja*2)}function $(L){if(A!=L)m.fillStyle=A=L;m.fill()}
+function sa(L,ja,ca,V,Y,qa,Da,Ea,Ia,Ma,Ka,Fa,Sa){var Na,Oa;Na=Da.width-1;Oa=Da.height-1;Ea*=Na;Ia*=Oa;Ma*=Na;Ka*=Oa;Fa*=Na;Sa*=Oa;ca-=L;V-=ja;Y-=L;qa-=ja;Ma-=Ea;Ka-=Ia;Fa-=Ea;Sa-=Ia;Na=Ma*Sa-Fa*Ka;if(Na!=0){Oa=1/Na;Na=(Sa*ca-Ka*Y)*Oa;Ka=(Sa*V-Ka*qa)*Oa;ca=(Ma*Y-Fa*ca)*Oa;V=(Ma*qa-Fa*V)*Oa;L=L-Na*Ea-ca*Ia;ja=ja-Ka*Ea-V*Ia;m.save();m.transform(Na,Ka,ca,V,L,ja);m.clip();m.drawImage(Da,0,0);m.restore()}}function Ja(L,ja,ca,V){var Y=~~(L.r*255),qa=~~(L.g*255);L=~~(L.b*255);var Da=~~(ja.r*255),Ea=~~(ja.g*
+255);ja=~~(ja.b*255);var Ia=~~(ca.r*255),Ma=~~(ca.g*255);ca=~~(ca.b*255);var Ka=~~(V.r*255),Fa=~~(V.g*255);V=~~(V.b*255);ka[0]=Y<0?0:Y>255?255:Y;ka[1]=qa<0?0:qa>255?255:qa;ka[2]=L<0?0:L>255?255:L;ka[4]=Da<0?0:Da>255?255:Da;ka[5]=Ea<0?0:Ea>255?255:Ea;ka[6]=ja<0?0:ja>255?255:ja;ka[8]=Ia<0?0:Ia>255?255:Ia;ka[9]=Ma<0?0:Ma>255?255:Ma;ka[10]=ca<0?0:ca>255?255:ca;ka[12]=Ka<0?0:Ka>255?255:Ka;ka[13]=Fa<0?0:Fa>255?255:Fa;ka[14]=V<0?0:V>255?255:V;P.putImageData(fa,0,0);na.drawImage(T,0,0);return ra}function Aa(L,
+ja,ca){L=(L-ja)/(ca-ja);return L*L*(3-2*L)}function N(L){L=(L+1)*0.5;return L<0?0:L>1?1:L}function Ba(L,ja){var ca=ja.x-L.x,V=ja.y-L.y,Y=1/Math.sqrt(ca*ca+V*V);ca*=Y;V*=Y;ja.x+=ca;ja.y+=V;L.x-=ca;L.y-=V}var Pa,Ta,ta,oa,za,wa,ya,va;this.autoClear?this.clear():m.setTransform(1,0,0,-1,k,j);c=d.projectScene(ha,Ca,this.sortElements);(E=ha.lights.length>0)&&S(ha);Pa=0;for(Ta=c.length;Pa<Ta;Pa++){ta=c[Pa];q.empty();if(ta instanceof THREE.RenderableParticle){v=ta;v.x*=k;v.y*=j;oa=0;for(za=ta.materials.length;oa<
+za;oa++)Ha(v,ta,ta.materials[oa],ha)}else if(ta instanceof THREE.RenderableLine){v=ta.v1;J=ta.v2;v.positionScreen.x*=k;v.positionScreen.y*=j;J.positionScreen.x*=k;J.positionScreen.y*=j;q.addPoint(v.positionScreen.x,v.positionScreen.y);q.addPoint(J.positionScreen.x,J.positionScreen.y);if(B.instersects(q)){oa=0;for(za=ta.materials.length;oa<za;)La(v,J,ta,ta.materials[oa++],ha)}}else if(ta instanceof THREE.RenderableFace3){v=ta.v1;J=ta.v2;t=ta.v3;v.positionScreen.x*=k;v.positionScreen.y*=j;J.positionScreen.x*=
+k;J.positionScreen.y*=j;t.positionScreen.x*=k;t.positionScreen.y*=j;if(ta.overdraw){Ba(v.positionScreen,J.positionScreen);Ba(J.positionScreen,t.positionScreen);Ba(t.positionScreen,v.positionScreen)}q.add3Points(v.positionScreen.x,v.positionScreen.y,J.positionScreen.x,J.positionScreen.y,t.positionScreen.x,t.positionScreen.y);if(B.instersects(q)){oa=0;for(za=ta.meshMaterials.length;oa<za;){va=ta.meshMaterials[oa++];if(va instanceof THREE.MeshFaceMaterial){wa=0;for(ya=ta.faceMaterials.length;wa<ya;)(va=
+ta.faceMaterials[wa++])&&da(v,J,t,ta,va,ha)}else da(v,J,t,ta,va,ha)}}}u.addRectangle(q)}m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(ia,ga,ua){var xa,l,z,B;xa=0;for(l=ia.lights.length;xa<l;xa++){z=ia.lights[xa];if(z instanceof THREE.DirectionalLight){B=ga.normalWorld.dot(z.position)*z.intensity;if(B>0){ua.r+=z.color.r*B;ua.g+=z.color.g*B;ua.b+=z.color.b*B}}else if(z instanceof THREE.PointLight){W.sub(z.position,ga.centroidWorld);W.normalize();B=ga.normalWorld.dot(W)*z.intensity;if(B>0){ua.r+=z.color.r*B;ua.g+=z.color.g*B;ua.b+=z.color.b*B}}}}function b(ia,ga,ua,xa,l,z){M=d(X++);M.setAttribute("d",
+"M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+ua.positionScreen.x+","+ua.positionScreen.y+"z");if(l instanceof THREE.MeshBasicMaterial)t.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshLambertMaterial)if(J){K.r=R.r;K.g=R.g;K.b=R.b;a(z,xa,K);t.r=l.color.r*K.r;t.g=l.color.g*K.g;t.b=l.color.b*K.b;t.updateStyleString()}else t.__styleString=l.color.__styleString;else if(l instanceof THREE.MeshDepthMaterial){Q=1-l.__2near/(l.__farPlusNear-
+xa.z*l.__farMinusNear);t.setRGB(Q,Q,Q)}else l instanceof THREE.MeshNormalMaterial&&t.setRGB(f(xa.normalWorld.x),f(xa.normalWorld.y),f(xa.normalWorld.z));l.wireframe?M.setAttribute("style","fill: none; stroke: "+t.__styleString+"; stroke-width: "+l.wireframeLinewidth+"; stroke-opacity: "+l.opacity+"; stroke-linecap: "+l.wireframeLinecap+"; stroke-linejoin: "+l.wireframeLinejoin):M.setAttribute("style","fill: "+t.__styleString+"; fill-opacity: "+l.opacity);k.appendChild(M)}function c(ia,ga,ua,xa,l,
+z,B){M=d(X++);M.setAttribute("d","M "+ia.positionScreen.x+" "+ia.positionScreen.y+" L "+ga.positionScreen.x+" "+ga.positionScreen.y+" L "+ua.positionScreen.x+","+ua.positionScreen.y+" L "+xa.positionScreen.x+","+xa.positionScreen.y+"z");if(z instanceof THREE.MeshBasicMaterial)t.__styleString=z.color.__styleString;else if(z instanceof THREE.MeshLambertMaterial)if(J){K.r=R.r;K.g=R.g;K.b=R.b;a(B,l,K);t.r=z.color.r*K.r;t.g=z.color.g*K.g;t.b=z.color.b*K.b;t.updateStyleString()}else t.__styleString=z.color.__styleString;
+else if(z instanceof THREE.MeshDepthMaterial){Q=1-z.__2near/(z.__farPlusNear-l.z*z.__farMinusNear);t.setRGB(Q,Q,Q)}else z instanceof THREE.MeshNormalMaterial&&t.setRGB(f(l.normalWorld.x),f(l.normalWorld.y),f(l.normalWorld.z));z.wireframe?M.setAttribute("style","fill: none; stroke: "+t.__styleString+"; stroke-width: "+z.wireframeLinewidth+"; stroke-opacity: "+z.opacity+"; stroke-linecap: "+z.wireframeLinecap+"; stroke-linejoin: "+z.wireframeLinejoin):M.setAttribute("style","fill: "+t.__styleString+
+"; fill-opacity: "+z.opacity);k.appendChild(M)}function d(ia){if(U[ia]==null){U[ia]=document.createElementNS("http://www.w3.org/2000/svg","path");la==0&&U[ia].setAttribute("shape-rendering","crispEdges")}return U[ia]}function f(ia){return ia<0?Math.min((1+ia)*0.5,0.5):0.5+Math.min(ia*0.5,0.5)}var g=null,h=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,m,n,w,o,p,x,A,I=new THREE.Rectangle,v=new THREE.Rectangle,J=!1,t=new THREE.Color(16777215),K=new THREE.Color(16777215),
+R=new THREE.Color(0),e=new THREE.Color(0),O=new THREE.Color(0),Q,W=new THREE.Vector3,U=[],aa=[],ea=[],M,X,pa,ba,la=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ia){switch(ia){case "high":la=1;break;case "low":la=0}};this.setSize=function(ia,ga){j=ia;m=ga;n=j/2;w=m/2;k.setAttribute("viewBox",-n+" "+-w+" "+j+" "+m);k.setAttribute("width",j);k.setAttribute("height",m);I.set(-n,-w,n,w)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};
+this.render=function(ia,ga){var ua,xa,l,z,B,u,q,E;this.autoClear&&this.clear();g=h.projectScene(ia,ga,this.sortElements);ba=pa=X=0;if(J=ia.lights.length>0){q=ia.lights;R.setRGB(0,0,0);e.setRGB(0,0,0);O.setRGB(0,0,0);ua=0;for(xa=q.length;ua<xa;ua++){l=q[ua];z=l.color;if(l instanceof THREE.AmbientLight){R.r+=z.r;R.g+=z.g;R.b+=z.b}else if(l instanceof THREE.DirectionalLight){e.r+=z.r;e.g+=z.g;e.b+=z.b}else if(l instanceof THREE.PointLight){O.r+=z.r;O.g+=z.g;O.b+=z.b}}}ua=0;for(xa=g.length;ua<xa;ua++){q=
+g[ua];v.empty();if(q instanceof THREE.RenderableParticle){o=q;o.x*=n;o.y*=-w;l=0;for(z=q.materials.length;l<z;l++)if(E=q.materials[l]){B=o;u=q;var C=pa++;if(aa[C]==null){aa[C]=document.createElementNS("http://www.w3.org/2000/svg","circle");la==0&&aa[C].setAttribute("shape-rendering","crispEdges")}M=aa[C];M.setAttribute("cx",B.x);M.setAttribute("cy",B.y);M.setAttribute("r",u.scale.x*n);if(E instanceof THREE.ParticleCircleMaterial){if(J){K.r=R.r+e.r+O.r;K.g=R.g+e.g+O.g;K.b=R.b+e.b+O.b;t.r=E.color.r*
+K.r;t.g=E.color.g*K.g;t.b=E.color.b*K.b;t.updateStyleString()}else t=E.color;M.setAttribute("style","fill: "+t.__styleString)}k.appendChild(M)}}else if(q instanceof THREE.RenderableLine){o=q.v1;p=q.v2;o.positionScreen.x*=n;o.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;v.addPoint(o.positionScreen.x,o.positionScreen.y);v.addPoint(p.positionScreen.x,p.positionScreen.y);if(I.instersects(v)){l=0;for(z=q.materials.length;l<z;)if(E=q.materials[l++]){B=o;u=p;C=ba++;if(ea[C]==null){ea[C]=
+document.createElementNS("http://www.w3.org/2000/svg","line");la==0&&ea[C].setAttribute("shape-rendering","crispEdges")}M=ea[C];M.setAttribute("x1",B.positionScreen.x);M.setAttribute("y1",B.positionScreen.y);M.setAttribute("x2",u.positionScreen.x);M.setAttribute("y2",u.positionScreen.y);if(E instanceof THREE.LineBasicMaterial){t.__styleString=E.color.__styleString;M.setAttribute("style","fill: none; stroke: "+t.__styleString+"; stroke-width: "+E.linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+
+E.linecap+"; stroke-linejoin: "+E.linejoin);k.appendChild(M)}}}}else if(q instanceof THREE.RenderableFace3){o=q.v1;p=q.v2;x=q.v3;o.positionScreen.x*=n;o.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;x.positionScreen.x*=n;x.positionScreen.y*=-w;v.addPoint(o.positionScreen.x,o.positionScreen.y);v.addPoint(p.positionScreen.x,p.positionScreen.y);v.addPoint(x.positionScreen.x,x.positionScreen.y);if(I.instersects(v)){l=0;for(z=q.meshMaterials.length;l<z;){E=q.meshMaterials[l++];if(E instanceof
+THREE.MeshFaceMaterial){B=0;for(u=q.faceMaterials.length;B<u;)(E=q.faceMaterials[B++])&&b(o,p,x,q,E,ia)}else E&&b(o,p,x,q,E,ia)}}}else if(q instanceof THREE.RenderableFace4){o=q.v1;p=q.v2;x=q.v3;A=q.v4;o.positionScreen.x*=n;o.positionScreen.y*=-w;p.positionScreen.x*=n;p.positionScreen.y*=-w;x.positionScreen.x*=n;x.positionScreen.y*=-w;A.positionScreen.x*=n;A.positionScreen.y*=-w;v.addPoint(o.positionScreen.x,o.positionScreen.y);v.addPoint(p.positionScreen.x,p.positionScreen.y);v.addPoint(x.positionScreen.x,
+x.positionScreen.y);v.addPoint(A.positionScreen.x,A.positionScreen.y);if(I.instersects(v)){l=0;for(z=q.meshMaterials.length;l<z;){E=q.meshMaterials[l++];if(E instanceof THREE.MeshFaceMaterial){B=0;for(u=q.faceMaterials.length;B<u;)(E=q.faceMaterials[B++])&&c(o,p,x,A,q,E,ia)}else E&&c(o,p,x,A,q,E,ia)}}}}}};
+THREE.WebGLRenderer=function(a){function b(l,z,B){var u,q,E,C=l.vertices,G=C.length,H=l.colors,y=H.length,D=l.__vertexArray,F=l.__colorArray,T=l.__sortArray,P=l.__dirtyVertices,fa=l.__dirtyColors;if(B.sortParticles){pa.multiplySelf(B.matrixWorld);for(u=0;u<G;u++){q=C[u].position;ia.copy(q);pa.multiplyVector3(ia);T[u]=[ia.z,u]}T.sort(function(ka,ra){return ra[0]-ka[0]});for(u=0;u<G;u++){q=C[T[u][1]].position;E=u*3;D[E]=q.x;D[E+1]=q.y;D[E+2]=q.z}for(u=0;u<y;u++){E=u*3;color=H[T[u][1]];F[E]=color.r;
+F[E+1]=color.g;F[E+2]=color.b}}else{if(P)for(u=0;u<G;u++){q=C[u].position;E=u*3;D[E]=q.x;D[E+1]=q.y;D[E+2]=q.z}if(fa)for(u=0;u<y;u++){color=H[u];E=u*3;F[E]=color.r;F[E+1]=color.g;F[E+2]=color.b}}if(P||B.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,D,z)}if(fa||B.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,F,z)}}function c(l,z){l.fragmentShader=z.fragmentShader;l.vertexShader=z.vertexShader;l.uniforms=
+Uniforms.clone(z.uniforms)}function d(l,z,B,u,q){u.program||W.initMaterial(u,z,B);var E=u.program,C=E.uniforms,G=u.uniforms;if(E!=O){e.useProgram(E);O=E;e.uniformMatrix4fv(C.projectionMatrix,!1,ba)}if(B&&(u instanceof THREE.MeshBasicMaterial||u instanceof THREE.MeshLambertMaterial||u instanceof THREE.MeshPhongMaterial||u instanceof THREE.LineBasicMaterial||u instanceof THREE.ParticleBasicMaterial)){G.fogColor.value.setHex(B.color.hex);if(B instanceof THREE.Fog){G.fogNear.value=B.near;G.fogFar.value=
+B.far}else if(B instanceof THREE.FogExp2)G.fogDensity.value=B.density}if(u instanceof THREE.MeshPhongMaterial||u instanceof THREE.MeshLambertMaterial){var H,y,D=0,F=0,T=0,P,fa,ka,ra=W.lights,na=ra.directional.colors,ma=ra.directional.positions,ha=ra.point.colors,Ca=ra.point.positions,S=0,Ga=0;B=y=y=0;for(H=z.length;B<H;B++){y=z[B];P=y.color;fa=y.position;ka=y.intensity;if(y instanceof THREE.AmbientLight){D+=P.r;F+=P.g;T+=P.b}else if(y instanceof THREE.DirectionalLight){y=S*3;na[y]=P.r*ka;na[y+1]=
+P.g*ka;na[y+2]=P.b*ka;ma[y]=fa.x;ma[y+1]=fa.y;ma[y+2]=fa.z;S+=1}else if(y instanceof THREE.PointLight){y=Ga*3;ha[y]=P.r*ka;ha[y+1]=P.g*ka;ha[y+2]=P.b*ka;Ca[y]=fa.x;Ca[y+1]=fa.y;Ca[y+2]=fa.z;Ga+=1}}for(B=S*3;B<na.length;B++)na[B]=0;for(B=Ga*3;B<ha.length;B++)ha[B]=0;ra.point.length=Ga;ra.directional.length=S;ra.ambient[0]=D;ra.ambient[1]=F;ra.ambient[2]=T;z=W.lights;G.enableLighting.value=z.directional.length+z.point.length;G.ambientLightColor.value=z.ambient;G.directionalLightColor.value=z.directional.colors;
+G.directionalLightDirection.value=z.directional.positions;G.pointLightColor.value=z.point.colors;G.pointLightPosition.value=z.point.positions}if(u instanceof THREE.MeshBasicMaterial||u instanceof THREE.MeshLambertMaterial||u instanceof THREE.MeshPhongMaterial){G.diffuse.value.setRGB(u.color.r*u.opacity,u.color.g*u.opacity,u.color.b*u.opacity);G.opacity.value=u.opacity;G.map.texture=u.map;G.lightMap.texture=u.lightMap;G.envMap.texture=u.envMap;G.reflectivity.value=u.reflectivity;G.refractionRatio.value=
+u.refractionRatio;G.combine.value=u.combine;G.useRefract.value=u.envMap&&u.envMap.mapping instanceof THREE.CubeRefractionMapping}if(u instanceof THREE.LineBasicMaterial){G.diffuse.value.setRGB(u.color.r*u.opacity,u.color.g*u.opacity,u.color.b*u.opacity);G.opacity.value=u.opacity}else if(u instanceof THREE.ParticleBasicMaterial){G.psColor.value.setRGB(u.color.r*u.opacity,u.color.g*u.opacity,u.color.b*u.opacity);G.opacity.value=u.opacity;G.size.value=u.size;G.map.texture=u.map}else if(u instanceof THREE.MeshPhongMaterial){G.ambient.value.setRGB(u.ambient.r,
+u.ambient.g,u.ambient.b);G.specular.value.setRGB(u.specular.r,u.specular.g,u.specular.b);G.shininess.value=u.shininess}else if(u instanceof THREE.MeshDepthMaterial){G.mNear.value=l.near;G.mFar.value=l.far;G.opacity.value=u.opacity}else if(u instanceof THREE.MeshNormalMaterial)G.opacity.value=u.opacity;for(var Ha in G)if(D=E.uniforms[Ha]){B=G[Ha];H=B.type;z=B.value;if(H=="i")e.uniform1i(D,z);else if(H=="f")e.uniform1f(D,z);else if(H=="fv1")e.uniform1fv(D,z);else if(H=="fv")e.uniform3fv(D,z);else if(H==
+"v2")e.uniform2f(D,z.x,z.y);else if(H=="v3")e.uniform3f(D,z.x,z.y,z.z);else if(H=="c")e.uniform3f(D,z.r,z.g,z.b);else if(H=="t"){e.uniform1i(D,z);if(B=B.texture)if(B.image instanceof Array&&B.image.length==6){if(B.image.length==6){if(B.needsUpdate){if(!B.image.__webGLTextureCube)B.image.__webGLTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_T,
+e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR);e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR);for(H=0;H<6;++H)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+H,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,B.image[H]);e.generateMipmap(e.TEXTURE_CUBE_MAP);e.bindTexture(e.TEXTURE_CUBE_MAP,null);B.needsUpdate=!1}e.activeTexture(e.TEXTURE0+z);e.bindTexture(e.TEXTURE_CUBE_MAP,B.image.__webGLTextureCube)}}else{if(B.needsUpdate){if(B.__wasSetOnce){e.bindTexture(e.TEXTURE_2D,
+B.__webGLTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,B.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,K(B.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,K(B.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,K(B.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,K(B.minFilter));e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null)}else{B.__webGLTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,B.__webGLTexture);e.texImage2D(e.TEXTURE_2D,
+0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,B.image);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,K(B.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,K(B.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,K(B.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,K(B.minFilter));e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,null);B.__wasSetOnce=!0}B.needsUpdate=!1}e.activeTexture(e.TEXTURE0+z);e.bindTexture(e.TEXTURE_2D,B.__webGLTexture)}}}e.uniformMatrix4fv(C.modelViewMatrix,
+!1,q._modelViewMatrixArray);e.uniformMatrix3fv(C.normalMatrix,!1,q._normalMatrixArray);(u instanceof THREE.MeshShaderMaterial||u instanceof THREE.MeshPhongMaterial||u.envMap)&&e.uniform3f(C.cameraPosition,l.position.x,l.position.y,l.position.z);(u instanceof THREE.MeshShaderMaterial||u.envMap||u.skinning)&&e.uniformMatrix4fv(C.objectMatrix,!1,q._objectMatrixArray);(u instanceof THREE.MeshPhongMaterial||u instanceof THREE.MeshLambertMaterial||u instanceof THREE.MeshShaderMaterial||u.skinning)&&e.uniformMatrix4fv(C.viewMatrix,
+!1,la);if(u.skinning){e.uniformMatrix4fv(C.cameraInverseMatrix,!1,la);e.uniformMatrix4fv(C.boneGlobalMatrices,!1,q.boneMatrices)}return E}function f(l,z,B,u,q,E){l=d(l,z,B,u,E).attributes;e.bindBuffer(e.ARRAY_BUFFER,q.__webGLVertexBuffer);e.vertexAttribPointer(l.position,3,e.FLOAT,!1,0,0);if(l.color>=0){e.bindBuffer(e.ARRAY_BUFFER,q.__webGLColorBuffer);e.vertexAttribPointer(l.color,3,e.FLOAT,!1,0,0)}if(l.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,q.__webGLNormalBuffer);e.vertexAttribPointer(l.normal,
+3,e.FLOAT,!1,0,0)}if(l.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,q.__webGLTangentBuffer);e.vertexAttribPointer(l.tangent,4,e.FLOAT,!1,0,0)}if(l.uv>=0)if(q.__webGLUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,q.__webGLUVBuffer);e.vertexAttribPointer(l.uv,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv)}else e.disableVertexAttribArray(l.uv);if(l.uv2>=0)if(q.__webGLUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,q.__webGLUV2Buffer);e.vertexAttribPointer(l.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(l.uv2)}else e.disableVertexAttribArray(l.uv2);
+if(u.skinning&&l.skinVertexA>=0&&l.skinVertexB>=0&&l.skinIndex>=0&&l.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,q.__webGLSkinVertexABuffer);e.vertexAttribPointer(l.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,q.__webGLSkinVertexBBuffer);e.vertexAttribPointer(l.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,q.__webGLSkinIndicesBuffer);e.vertexAttribPointer(l.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,q.__webGLSkinWeightsBuffer);e.vertexAttribPointer(l.skinWeight,
+4,e.FLOAT,!1,0,0)}if(E instanceof THREE.Mesh)if(u.wireframe){e.lineWidth(u.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,q.__webGLLineBuffer);e.drawElements(e.LINES,q.__webGLLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);e.drawElements(e.TRIANGLES,q.__webGLFaceCount,e.UNSIGNED_SHORT,0)}else if(E instanceof THREE.Line){E=E.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(u.linewidth);e.drawArrays(E,0,q.__webGLLineCount)}else if(E instanceof
+THREE.ParticleSystem)e.drawArrays(e.POINTS,0,q.__webGLParticleCount);else E instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,q.__webGLVertexCount)}function g(l,z){if(!l.__webGLVertexBuffer)l.__webGLVertexBuffer=e.createBuffer();if(!l.__webGLNormalBuffer)l.__webGLNormalBuffer=e.createBuffer();if(l.hasPos){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,l.positionArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(z.attributes.position);e.vertexAttribPointer(z.attributes.position,
+3,e.FLOAT,!1,0,0)}if(l.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,l.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,l.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(z.attributes.normal);e.vertexAttribPointer(z.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,l.count);l.count=0}function h(l){if(U!=l.doubleSided){l.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);U=l.doubleSided}if(aa!=l.flipSided){l.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);aa=l.flipSided}}function k(l){if(M!=
+l){l?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);M=l}}function j(l){X[0].set(l.n41-l.n11,l.n42-l.n12,l.n43-l.n13,l.n44-l.n14);X[1].set(l.n41+l.n11,l.n42+l.n12,l.n43+l.n13,l.n44+l.n14);X[2].set(l.n41+l.n21,l.n42+l.n22,l.n43+l.n23,l.n44+l.n24);X[3].set(l.n41-l.n21,l.n42-l.n22,l.n43-l.n23,l.n44-l.n24);X[4].set(l.n41-l.n31,l.n42-l.n32,l.n43-l.n33,l.n44-l.n34);X[5].set(l.n41+l.n31,l.n42+l.n32,l.n43+l.n33,l.n44+l.n34);var z;for(l=0;l<6;l++){z=X[l];z.divideScalar(Math.sqrt(z.x*z.x+z.y*z.y+z.z*z.z))}}
+function m(l){for(var z=l.matrixWorld,B=-l.geometry.boundingSphere.radius*Math.max(l.scale.x,Math.max(l.scale.y,l.scale.z)),u=0;u<6;u++){l=X[u].x*z.n14+X[u].y*z.n24+X[u].z*z.n34+X[u].w;if(l<=B)return!1}return!0}function n(l,z){l.list[l.count]=z;l.count+=1}function w(l){var z,B,u=l.object,q=l.opaque,E=l.transparent;E.count=0;l=q.count=0;for(z=u.materials.length;l<z;l++){B=u.materials[l];B.opacity&&B.opacity<1||B.blending!=THREE.NormalBlending?n(E,B):n(q,B)}}function o(l){var z,B,u,q,E=l.object,C=l.buffer,
+G=l.opaque,H=l.transparent;H.count=0;l=G.count=0;for(u=E.materials.length;l<u;l++){z=E.materials[l];if(z instanceof THREE.MeshFaceMaterial){z=0;for(B=C.materials.length;z<B;z++)(q=C.materials[z])&&(q.opacity&&q.opacity<1||q.blending!=THREE.NormalBlending?n(H,q):n(G,q))}else{q=z;q.opacity&&q.opacity<1||q.blending!=THREE.NormalBlending?n(H,q):n(G,q)}}}function p(l,z){return z.z-l.z}function x(l){function z(F){var T=[];B=0;for(u=F.length;B<u;B++)F[B]==undefined?T.push("undefined"):T.push(F[B].id);return T.join("_")}
+var B,u,q,E,C,G,H,y,D={};l.geometryGroups={};q=0;for(E=l.faces.length;q<E;q++){C=l.faces[q];G=C.materials;H=z(G);D[H]==undefined&&(D[H]={hash:H,counter:0});y=D[H].hash+"_"+D[H].counter;l.geometryGroups[y]==undefined&&(l.geometryGroups[y]={faces:[],materials:G,vertices:0});C=C instanceof THREE.Face3?3:4;if(l.geometryGroups[y].vertices+C>65535){D[H].counter+=1;y=D[H].hash+"_"+D[H].counter;l.geometryGroups[y]==undefined&&(l.geometryGroups[y]={faces:[],materials:G,vertices:0})}l.geometryGroups[y].faces.push(q);
+l.geometryGroups[y].vertices+=C}}function A(l,z,B,u,q){if(z[B]==undefined){l.push({buffer:u,object:q,opaque:{list:[],count:0},transparent:{list:[],count:0}});z[B]=1}}function I(l,z){l._modelViewMatrix.multiplyToArray(z.matrixWorldInverse,l.matrixWorld,l._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(l._modelViewMatrix).transposeIntoArray(l._normalMatrixArray)}function v(l){if(l!=ea){switch(l){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE);break;case THREE.SubtractiveBlending:e.blendFunc(e.DST_COLOR,
+e.ZERO);break;case THREE.BillboardBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:e.blendEquation(e.FUNC_REVERSE_SUBTRACT);e.blendFunc(e.ONE,e.ONE);break;default:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA)}ea=l}}function J(l,z){if(l&&!l.__webGLFramebuffer){l.__webGLFramebuffer=e.createFramebuffer();l.__webGLRenderbuffer=e.createRenderbuffer();l.__webGLTexture=e.createTexture();e.bindRenderbuffer(e.RENDERBUFFER,
+l.__webGLRenderbuffer);e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,l.width,l.height);e.bindTexture(e.TEXTURE_2D,l.__webGLTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,K(l.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,K(l.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,K(l.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,K(l.minFilter));e.texImage2D(e.TEXTURE_2D,0,K(l.format),l.width,l.height,0,K(l.format),K(l.type),null);e.bindFramebuffer(e.FRAMEBUFFER,
+l.__webGLFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,l.__webGLTexture,0);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,l.__webGLRenderbuffer);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var B,u,q;if(l){B=l.__webGLFramebuffer;u=l.width;q=l.height}else{B=null;u=R.width;q=R.height}if(B!=Q){e.bindFramebuffer(e.FRAMEBUFFER,B);e.viewport(0,0,u,q);z&&e.clear(e.COLOR_BUFFER_BIT|
+e.DEPTH_BUFFER_BIT);Q=B}}function t(l,z){var B;if(l=="fragment")B=e.createShader(e.FRAGMENT_SHADER);else l=="vertex"&&(B=e.createShader(e.VERTEX_SHADER));e.shaderSource(B,z);e.compileShader(B);if(!e.getShaderParameter(B,e.COMPILE_STATUS)){alert(e.getShaderInfoLog(B));return null}return B}function K(l){switch(l){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;
+case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;
+case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var R=document.createElement("canvas"),e,O=null,Q=null,W=this,U=null,aa=null,ea=null,M=null,X=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],
+pa=new THREE.Matrix4,ba=new Float32Array(16),la=new Float32Array(16),ia=new THREE.Vector4,ga=!0,ua=new THREE.Color(0),xa=0;if(a){if(a.antialias!==undefined)ga=a.antialias;a.clearColor!==undefined&&ua.setHex(a.clearColor);if(a.clearAlpha!==undefined)xa=a.clearAlpha}this.domElement=R;this.autoClear=!0;this.sortObjects=!1;(function(l,z,B){try{e=R.getContext("experimental-webgl",{antialias:l})}catch(u){console.log(u)}if(!e)throw"cannot create webgl context";e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);
+e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.clearColor(z.r,z.g,z.b,B);_cullEnabled=!0})(ga,ua,xa);this.context=e;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(l,z){R.width=l;R.height=z;e.viewport(0,0,R.width,R.height)};this.setClearColorHex=function(l,z){var B=new THREE.Color(l);e.clearColor(B.r,B.g,B.b,z)};this.setClearColor=
+function(l,z){e.clearColor(l.r,l.g,l.b,z)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT)};this.initMaterial=function(l,z,B){var u,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 E,C,G,H;q=G=H=0;for(E=z.length;q<E;q++){C=z[q];C instanceof THREE.DirectionalLight&&G++;C instanceof THREE.PointLight&&H++}if(H+G<=4)z=G;else{z=Math.ceil(4*G/(H+G));H=4-z}q={directional:z,point:H};H=l.fragmentShader;z=l.vertexShader;E={fog:B,map:l.map,envMap:l.envMap,lightMap:l.lightMap,vertexColors:l.vertexColors,skinning:l.skinning,maxDirLights:q.directional,
+maxPointLights:q.point};B=e.createProgram();q=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights,E.fog?"#define USE_FOG":"",E.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",E.map?"#define USE_MAP":"",E.envMap?"#define USE_ENVMAP":"",E.lightMap?"#define USE_LIGHTMAP":"",E.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");E=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
+0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+E.maxDirLights,"#define MAX_POINT_LIGHTS "+E.maxPointLights,E.map?"#define USE_MAP":"",E.envMap?"#define USE_ENVMAP":"",E.lightMap?"#define USE_LIGHTMAP":"",E.vertexColors?"#define USE_COLOR":"",E.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
+e.attachShader(B,t("fragment",q+H));e.attachShader(B,t("vertex",E+z));e.linkProgram(B);e.getProgramParameter(B,e.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+e.getProgramParameter(B,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");B.uniforms={};B.attributes={};l.program=B;B=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(u in l.uniforms)B.push(u);u=l.program;H=0;for(z=B.length;H<
+z;H++){q=B[H];u.uniforms[q]=e.getUniformLocation(u,q)}u=l.program;B=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];H=0;for(z=B.length;H<z;H++){q=B[H];u.attributes[q]=e.getAttribLocation(u,q)}u=l.program.attributes;e.enableVertexAttribArray(u.position);u.color>=0&&e.enableVertexAttribArray(u.color);u.normal>=0&&e.enableVertexAttribArray(u.normal);u.tangent>=0&&e.enableVertexAttribArray(u.tangent);if(l.skinning&&u.skinVertexA>=0&&u.skinVertexB>=
+0&&u.skinIndex>=0&&u.skinWeight>=0){e.enableVertexAttribArray(u.skinVertexA);e.enableVertexAttribArray(u.skinVertexB);e.enableVertexAttribArray(u.skinIndex);e.enableVertexAttribArray(u.skinWeight)}};this.render=function(l,z,B,u){var q,E,C,G,H,y,D,F,T=l.lights,P=l.fog;z.matrixAutoUpdate&&z.update();z.matrixWorldInverse.flattenToArray(la);z.projectionMatrix.flattenToArray(ba);pa.multiply(z.projectionMatrix,z.matrixWorldInverse);j(pa);THREE.AnimationHandler&&THREE.AnimationHandler.update();l.update(undefined,
+!1,z);this.initWebGLObjects(l,z);J(B,u!==undefined?u:!0);this.autoClear&&this.clear();H=l.__webGLObjects.length;for(u=0;u<H;u++){q=l.__webGLObjects[u];D=q.object;if(D.visible)if(!(D instanceof THREE.Mesh)||m(D)){D.matrixWorld.flattenToArray(D._objectMatrixArray);I(D,z);o(q);q.render=!0;if(this.sortObjects){ia.copy(D.position);pa.multiplyVector3(ia);q.z=ia.z}}else q.render=!1;else q.render=!1}this.sortObjects&&l.__webGLObjects.sort(p);y=l.__webGLObjectsImmediate.length;for(u=0;u<y;u++){q=l.__webGLObjectsImmediate[u];
+D=q.object;if(D.visible){D.matrixAutoUpdate&&D.matrixWorld.flattenToArray(D._objectMatrixArray);I(D,z);w(q)}}v(THREE.NormalBlending);for(u=0;u<H;u++){q=l.__webGLObjects[u];if(q.render){D=q.object;F=q.buffer;C=q.opaque;h(D);for(q=0;q<C.count;q++){G=C.list[q];k(G.depthTest);f(z,T,P,G,F,D)}}}for(u=0;u<y;u++){q=l.__webGLObjectsImmediate[u];D=q.object;if(D.visible){C=q.opaque;h(D);for(q=0;q<C.count;q++){G=C.list[q];k(G.depthTest);E=d(z,T,P,G,D);D.render(function(fa){g(fa,E)})}}}for(u=0;u<H;u++){q=l.__webGLObjects[u];
+if(q.render){D=q.object;F=q.buffer;C=q.transparent;h(D);for(q=0;q<C.count;q++){G=C.list[q];v(G.blending);k(G.depthTest);f(z,T,P,G,F,D)}}}for(u=0;u<y;u++){q=l.__webGLObjectsImmediate[u];D=q.object;if(D.visible){C=q.transparent;h(D);for(q=0;q<C.count;q++){G=C.list[q];v(G.blending);k(G.depthTest);E=d(z,T,P,G,D);D.render(function(fa){g(fa,E)})}}}if(B&&B.minFilter!==THREE.NearestFilter&&B.minFilter!==THREE.LinearFilter){e.bindTexture(e.TEXTURE_2D,B.__webGLTexture);e.generateMipmap(e.TEXTURE_2D);e.bindTexture(e.TEXTURE_2D,
+null)}};this.initWebGLObjects=function(l,z){if(!l.__webGLObjects){l.__webGLObjects=[];l.__webGLObjectsMap={};l.__webGLObjectsImmediate=[]}for(var B=0,u=l.objects.length;B<u;B++){var q=l.objects[B],E=l,C=z,G=void 0,H=void 0,y=void 0,D=void 0;if(E.__webGLObjectsMap[q.id]==undefined){E.__webGLObjectsMap[q.id]={};q._modelViewMatrix=new THREE.Matrix4;q._normalMatrixArray=new Float32Array(9);q._modelViewMatrixArray=new Float32Array(16);q._objectMatrixArray=new Float32Array(16);q.matrixWorld.flattenToArray(q._objectMatrixArray)}D=
+E.__webGLObjectsMap[q.id];objlist=E.__webGLObjects;if(q instanceof THREE.Mesh){H=q.geometry;H.geometryGroups==undefined&&x(H);for(G in H.geometryGroups){y=H.geometryGroups[G];if(!y.__webGLVertexBuffer){C=y;C.__webGLVertexBuffer=e.createBuffer();C.__webGLNormalBuffer=e.createBuffer();C.__webGLTangentBuffer=e.createBuffer();C.__webGLColorBuffer=e.createBuffer();C.__webGLUVBuffer=e.createBuffer();C.__webGLUV2Buffer=e.createBuffer();C.__webGLSkinVertexABuffer=e.createBuffer();C.__webGLSkinVertexBBuffer=
+e.createBuffer();C.__webGLSkinIndicesBuffer=e.createBuffer();C.__webGLSkinWeightsBuffer=e.createBuffer();C.__webGLFaceBuffer=e.createBuffer();C.__webGLLineBuffer=e.createBuffer();C=y;var F=q,T=void 0,P=void 0,fa=0,ka=E=0,ra=F.geometry.faces,na=C.faces;T=0;for(P=na.length;T<P;T++){fi=na[T];face=ra[fi];if(face instanceof THREE.Face3){fa+=3;E+=1;ka+=3}else if(face instanceof THREE.Face4){fa+=4;E+=2;ka+=4}}C.__vertexArray=new Float32Array(fa*3);C.__normalArray=new Float32Array(fa*3);C.__tangentArray=
+new Float32Array(fa*4);C.__colorArray=new Float32Array(fa*3);C.__uvArray=new Float32Array(fa*2);C.__uv2Array=new Float32Array(fa*2);C.__skinVertexAArray=new Float32Array(fa*4);C.__skinVertexBArray=new Float32Array(fa*4);C.__skinIndexArray=new Float32Array(fa*4);C.__skinWeightArray=new Float32Array(fa*4);C.__faceArray=new Uint16Array(E*3);C.__lineArray=new Uint16Array(ka*2);P=T=C;fa=void 0;ra=void 0;var ma=void 0,ha=void 0;ma=void 0;na=!1;fa=0;for(ra=F.materials.length;fa<ra;fa++){ma=F.materials[fa];
+if(ma instanceof THREE.MeshFaceMaterial){ma=0;for(ha=P.materials.length;ma<ha;ma++)if(P.materials[ma]&&P.materials[ma].shading!=undefined&&P.materials[ma].shading==THREE.SmoothShading){na=!0;break}}else if(ma&&ma.shading!=undefined&&ma.shading==THREE.SmoothShading){na=!0;break}if(na)break}T.__needsSmoothNormals=na;C.__webGLFaceCount=E*3;C.__webGLLineCount=ka*2;H.__dirtyVertices=!0;H.__dirtyElements=!0;H.__dirtyUvs=!0;H.__dirtyNormals=!0;H.__dirtyTangents=!0;H.__dirtyColors=!0}if(H.__dirtyVertices||
+H.__dirtyElements||H.__dirtyUvs||H.__dirtyNormals||H.__dirtyColors||H.__dirtyTangents){C=y;E=e.DYNAMIC_DRAW;ka=void 0;T=void 0;var Ca=void 0,S=void 0,Ga=void 0,Ha=void 0,La=void 0;Ca=void 0;var da=void 0,Z=void 0,$=void 0,sa=void 0;da=void 0;Z=void 0;$=void 0;S=void 0;da=void 0;Z=void 0;$=void 0;sa=void 0;da=void 0;Z=void 0;$=void 0;sa=void 0;da=void 0;Z=void 0;$=void 0;sa=void 0;da=void 0;Z=void 0;$=void 0;sa=void 0;da=void 0;Z=void 0;$=void 0;sa=void 0;S=void 0;Ha=void 0;Ga=void 0;La=void 0;var Ja=
+ha=ma=na=ra=fa=F=P=0,Aa=0,N=0,Ba=C.__vertexArray,Pa=C.__uvArray,Ta=C.__uv2Array,ta=C.__normalArray,oa=C.__tangentArray,za=C.__colorArray,wa=C.__skinVertexAArray,ya=C.__skinVertexBArray,va=C.__skinIndexArray,L=C.__skinWeightArray,ja=C.__faceArray,ca=C.__lineArray,V=C.__needsSmoothNormals,Y=q.geometry,qa=Y.__dirtyVertices,Da=Y.__dirtyElements,Ea=Y.__dirtyUvs,Ia=Y.__dirtyNormals,Ma=Y.__dirtyTangents,Ka=Y.__dirtyColors,Fa=Y.vertices,Sa=C.faces,Na=Y.faces,Oa=Y.uvs,Xa=Y.uvs2,Qa=Y.colors,Ua=Y.skinVerticesA,
+Va=Y.skinVerticesB,Wa=Y.skinIndices,Ra=Y.skinWeights;ka=0;for(T=Sa.length;ka<T;ka++){Ca=Sa[ka];S=Na[Ca];La=Oa[Ca];Ca=Xa[Ca];Ga=S.vertexNormals;Ha=S.normal;if(S instanceof THREE.Face3){if(qa){da=Fa[S.a].position;Z=Fa[S.b].position;$=Fa[S.c].position;Ba[F]=da.x;Ba[F+1]=da.y;Ba[F+2]=da.z;Ba[F+3]=Z.x;Ba[F+4]=Z.y;Ba[F+5]=Z.z;Ba[F+6]=$.x;Ba[F+7]=$.y;Ba[F+8]=$.z;F+=9}if(Ra.length){da=Ra[S.a];Z=Ra[S.b];$=Ra[S.c];L[N]=da.x;L[N+1]=da.y;L[N+2]=da.z;L[N+3]=da.w;L[N+4]=Z.x;L[N+5]=Z.y;L[N+6]=Z.z;L[N+7]=Z.w;L[N+
+8]=$.x;L[N+9]=$.y;L[N+10]=$.z;L[N+11]=$.w;da=Wa[S.a];Z=Wa[S.b];$=Wa[S.c];va[N]=da.x;va[N+1]=da.y;va[N+2]=da.z;va[N+3]=da.w;va[N+4]=Z.x;va[N+5]=Z.y;va[N+6]=Z.z;va[N+7]=Z.w;va[N+8]=$.x;va[N+9]=$.y;va[N+10]=$.z;va[N+11]=$.w;da=Ua[S.a];Z=Ua[S.b];$=Ua[S.c];wa[N]=da.x;wa[N+1]=da.y;wa[N+2]=da.z;wa[N+3]=1;wa[N+4]=Z.x;wa[N+5]=Z.y;wa[N+6]=Z.z;wa[N+7]=1;wa[N+8]=$.x;wa[N+9]=$.y;wa[N+10]=$.z;wa[N+11]=1;da=Va[S.a];Z=Va[S.b];$=Va[S.c];ya[N]=da.x;ya[N+1]=da.y;ya[N+2]=da.z;ya[N+3]=1;ya[N+4]=Z.x;ya[N+5]=Z.y;ya[N+6]=
+Z.z;ya[N+7]=1;ya[N+8]=$.x;ya[N+9]=$.y;ya[N+10]=$.z;ya[N+11]=1;N+=12}if(Ka&&Qa.length){da=Qa[S.a];Z=Qa[S.b];$=Qa[S.c];za[Aa]=da.r;za[Aa+1]=da.g;za[Aa+2]=da.b;za[Aa+3]=Z.r;za[Aa+4]=Z.g;za[Aa+5]=Z.b;za[Aa+6]=$.r;za[Aa+7]=$.g;za[Aa+8]=$.b;Aa+=9}if(Ma&&Y.hasTangents){da=Fa[S.a].tangent;Z=Fa[S.b].tangent;$=Fa[S.c].tangent;oa[ha]=da.x;oa[ha+1]=da.y;oa[ha+2]=da.z;oa[ha+3]=da.w;oa[ha+4]=Z.x;oa[ha+5]=Z.y;oa[ha+6]=Z.z;oa[ha+7]=Z.w;oa[ha+8]=$.x;oa[ha+9]=$.y;oa[ha+10]=$.z;oa[ha+11]=$.w;ha+=12}if(Ia)if(Ga.length==
+3&&V)for(S=0;S<3;S++){Ha=Ga[S];ta[ma]=Ha.x;ta[ma+1]=Ha.y;ta[ma+2]=Ha.z;ma+=3}else for(S=0;S<3;S++){ta[ma]=Ha.x;ta[ma+1]=Ha.y;ta[ma+2]=Ha.z;ma+=3}if(Ea&&La)for(S=0;S<3;S++){Ga=La[S];Pa[fa]=Ga.u;Pa[fa+1]=Ga.v;fa+=2}if(Ea&&Ca)for(S=0;S<3;S++){La=Ca[S];Ta[ra]=La.u;Ta[ra+1]=La.v;ra+=2}if(Da){ja[na]=P;ja[na+1]=P+1;ja[na+2]=P+2;na+=3;ca[Ja]=P;ca[Ja+1]=P+1;ca[Ja+2]=P;ca[Ja+3]=P+2;ca[Ja+4]=P+1;ca[Ja+5]=P+2;Ja+=6;P+=3}}else if(S instanceof THREE.Face4){if(qa){da=Fa[S.a].position;Z=Fa[S.b].position;$=Fa[S.c].position;
+sa=Fa[S.d].position;Ba[F]=da.x;Ba[F+1]=da.y;Ba[F+2]=da.z;Ba[F+3]=Z.x;Ba[F+4]=Z.y;Ba[F+5]=Z.z;Ba[F+6]=$.x;Ba[F+7]=$.y;Ba[F+8]=$.z;Ba[F+9]=sa.x;Ba[F+10]=sa.y;Ba[F+11]=sa.z;F+=12}if(Ra.length){da=Ra[S.a];Z=Ra[S.b];$=Ra[S.c];sa=Ra[S.d];L[N]=da.x;L[N+1]=da.y;L[N+2]=da.z;L[N+3]=da.w;L[N+4]=Z.x;L[N+5]=Z.y;L[N+6]=Z.z;L[N+7]=Z.w;L[N+8]=$.x;L[N+9]=$.y;L[N+10]=$.z;L[N+11]=$.w;L[N+12]=sa.x;L[N+13]=sa.y;L[N+14]=sa.z;L[N+15]=sa.w;da=Wa[S.a];Z=Wa[S.b];$=Wa[S.c];sa=Wa[S.d];va[N]=da.x;va[N+1]=da.y;va[N+2]=da.z;va[N+
+3]=da.w;va[N+4]=Z.x;va[N+5]=Z.y;va[N+6]=Z.z;va[N+7]=Z.w;va[N+8]=$.x;va[N+9]=$.y;va[N+10]=$.z;va[N+11]=$.w;va[N+12]=sa.x;va[N+13]=sa.y;va[N+14]=sa.z;va[N+15]=sa.w;da=Ua[S.a];Z=Ua[S.b];$=Ua[S.c];sa=Ua[S.d];wa[N]=da.x;wa[N+1]=da.y;wa[N+2]=da.z;wa[N+3]=1;wa[N+4]=Z.x;wa[N+5]=Z.y;wa[N+6]=Z.z;wa[N+7]=1;wa[N+8]=$.x;wa[N+9]=$.y;wa[N+10]=$.z;wa[N+11]=1;wa[N+12]=sa.x;wa[N+13]=sa.y;wa[N+14]=sa.z;wa[N+15]=1;da=Va[S.a];Z=Va[S.b];$=Va[S.c];sa=Va[S.d];ya[N]=da.x;ya[N+1]=da.y;ya[N+2]=da.z;ya[N+3]=1;ya[N+4]=Z.x;ya[N+
+5]=Z.y;ya[N+6]=Z.z;ya[N+7]=1;ya[N+8]=$.x;ya[N+9]=$.y;ya[N+10]=$.z;ya[N+11]=1;ya[N+12]=sa.x;ya[N+13]=sa.y;ya[N+14]=sa.z;ya[N+15]=1;N+=16}if(Ka&&Qa.length){da=Qa[S.a];Z=Qa[S.b];$=Qa[S.c];sa=Qa[S.d];za[Aa]=da.r;za[Aa+1]=da.g;za[Aa+2]=da.b;za[Aa+3]=Z.r;za[Aa+4]=Z.g;za[Aa+5]=Z.b;za[Aa+6]=$.r;za[Aa+7]=$.g;za[Aa+8]=$.b;za[Aa+9]=sa.r;za[Aa+10]=sa.g;za[Aa+11]=sa.b;Aa+=12}if(Ma&&Y.hasTangents){da=Fa[S.a].tangent;Z=Fa[S.b].tangent;$=Fa[S.c].tangent;S=Fa[S.d].tangent;oa[ha]=da.x;oa[ha+1]=da.y;oa[ha+2]=da.z;oa[ha+
+3]=da.w;oa[ha+4]=Z.x;oa[ha+5]=Z.y;oa[ha+6]=Z.z;oa[ha+7]=Z.w;oa[ha+8]=$.x;oa[ha+9]=$.y;oa[ha+10]=$.z;oa[ha+11]=$.w;oa[ha+12]=S.x;oa[ha+13]=S.y;oa[ha+14]=S.z;oa[ha+15]=S.w;ha+=16}if(Ia)if(Ga.length==4&&V)for(S=0;S<4;S++){Ha=Ga[S];ta[ma]=Ha.x;ta[ma+1]=Ha.y;ta[ma+2]=Ha.z;ma+=3}else for(S=0;S<4;S++){ta[ma]=Ha.x;ta[ma+1]=Ha.y;ta[ma+2]=Ha.z;ma+=3}if(Ea&&La)for(S=0;S<4;S++){Ga=La[S];Pa[fa]=Ga.u;Pa[fa+1]=Ga.v;fa+=2}if(Ea&&Ca)for(S=0;S<4;S++){La=Ca[S];Ta[ra]=La.u;Ta[ra+1]=La.v;ra+=2}if(Da){ja[na]=P;ja[na+1]=
+P+1;ja[na+2]=P+2;ja[na+3]=P;ja[na+4]=P+2;ja[na+5]=P+3;na+=6;ca[Ja]=P;ca[Ja+1]=P+1;ca[Ja+2]=P;ca[Ja+3]=P+3;ca[Ja+4]=P+1;ca[Ja+5]=P+2;ca[Ja+6]=P+2;ca[Ja+7]=P+3;Ja+=8;P+=4}}}if(qa){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ba,E)}if(Ka&&Qa.length){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,za,E)}if(Ia){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLNormalBuffer);e.bufferData(e.ARRAY_BUFFER,ta,E)}if(Ma&&Y.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,
+C.__webGLTangentBuffer);e.bufferData(e.ARRAY_BUFFER,oa,E)}if(Ea&&fa>0){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLUVBuffer);e.bufferData(e.ARRAY_BUFFER,Pa,E)}if(Ea&&ra>0){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLUV2Buffer);e.bufferData(e.ARRAY_BUFFER,Ta,E)}if(Da){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,C.__webGLFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ja,E);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,C.__webGLLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ca,E)}if(N>0){e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinVertexABuffer);
+e.bufferData(e.ARRAY_BUFFER,wa,E);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ya,E);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,va,E);e.bindBuffer(e.ARRAY_BUFFER,C.__webGLSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,L,E)}}A(objlist,D,G,y,q)}H.__dirtyVertices=!1;H.__dirtyElements=!1;H.__dirtyUvs=!1;H.__dirtyNormals=!1;H.__dirtyTangents=!1;H.__dirtyColors=!1}else if(q instanceof THREE.Ribbon){H=q.geometry;if(!H.__webGLVertexBuffer){G=
+H;G.__webGLVertexBuffer=e.createBuffer();G.__webGLColorBuffer=e.createBuffer();G=H;y=G.vertices.length;G.__vertexArray=new Float32Array(y*3);G.__colorArray=new Float32Array(y*3);G.__webGLVertexCount=y;H.__dirtyVertices=!0;H.__dirtyColors=!0}if(H.__dirtyVertices||H.__dirtyColors){G=H;y=e.DYNAMIC_DRAW;P=void 0;P=void 0;F=void 0;C=void 0;fa=G.vertices;E=G.colors;ra=fa.length;ka=E.length;na=G.__vertexArray;T=G.__colorArray;ma=G.__dirtyColors;if(G.__dirtyVertices){for(P=0;P<ra;P++){F=fa[P].position;C=
+P*3;na[C]=F.x;na[C+1]=F.y;na[C+2]=F.z}e.bindBuffer(e.ARRAY_BUFFER,G.__webGLVertexBuffer);e.bufferData(e.ARRAY_BUFFER,na,y)}if(ma){for(P=0;P<ka;P++){color=E[P];C=P*3;T[C]=color.r;T[C+1]=color.g;T[C+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,G.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,T,y)}}A(objlist,D,0,H,q);H.__dirtyVertices=!1;H.__dirtyColors=!1}else if(q instanceof THREE.Line){H=q.geometry;if(!H.__webGLVertexBuffer){G=H;G.__webGLVertexBuffer=e.createBuffer();G.__webGLColorBuffer=e.createBuffer();
+G=H;y=G.vertices.length;G.__vertexArray=new Float32Array(y*3);G.__colorArray=new Float32Array(y*3);G.__webGLLineCount=y;H.__dirtyVertices=!0;H.__dirtyColors=!0}if(H.__dirtyVertices||H.__dirtyColors){G=H;y=e.DYNAMIC_DRAW;P=void 0;P=void 0;F=void 0;C=void 0;fa=G.vertices;E=G.colors;ra=fa.length;ka=E.length;na=G.__vertexArray;T=G.__colorArray;ma=G.__dirtyColors;if(G.__dirtyVertices){for(P=0;P<ra;P++){F=fa[P].position;C=P*3;na[C]=F.x;na[C+1]=F.y;na[C+2]=F.z}e.bindBuffer(e.ARRAY_BUFFER,G.__webGLVertexBuffer);
+e.bufferData(e.ARRAY_BUFFER,na,y)}if(ma){for(P=0;P<ka;P++){color=E[P];C=P*3;T[C]=color.r;T[C+1]=color.g;T[C+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,G.__webGLColorBuffer);e.bufferData(e.ARRAY_BUFFER,T,y)}}A(objlist,D,0,H,q);H.__dirtyVertices=!1;H.__dirtyColors=!1}else if(q instanceof THREE.ParticleSystem){H=q.geometry;if(!H.__webGLVertexBuffer){G=H;G.__webGLVertexBuffer=e.createBuffer();G.__webGLColorBuffer=e.createBuffer();G=H;y=G.vertices.length;G.__vertexArray=new Float32Array(y*3);G.__colorArray=
+new Float32Array(y*3);G.__sortArray=[];G.__webGLParticleCount=y;H.__dirtyVertices=!0;H.__dirtyColors=!0}(H.__dirtyVertices||H.__dirtyColors||q.sortParticles)&&b(H,e.DYNAMIC_DRAW,q,C);A(objlist,D,0,H,q);H.__dirtyVertices=!1;H.__dirtyColors=!1}else if(THREE.MarchingCubes!==undefined&&q instanceof THREE.MarchingCubes){H=D;if(H[0]==undefined){E.__webGLObjectsImmediate.push({object:q,opaque:{list:[],count:0},transparent:{list:[],count:0}});H[0]=1}}}};this.removeObject=function(l,z){var B,u;for(B=l.__webGLObjects.length-
+1;B>=0;B--){u=l.__webGLObjects[B].object;z==u&&l.__webGLObjects.splice(B,1)}};this.setFaceCulling=function(l,z){if(l){!z||z=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(l=="back")e.cullFace(e.BACK);else l=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.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 envMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",
 envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
@@ -274,17 +274,17 @@ THREE.Snippets.color_pars_vertex,"void main() {",THREE.Snippets.color_vertex,"ve
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,f=c.length;for(d=0;d<f;d++){a=c[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
 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=!1;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,b){var c=b instanceof THREE.Mesh,d=a.vertices.length,f=c?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,l=a.uvs;f=f.uvs;c&&b.matrixAutoUpdate&&b.updateMatrix();for(var n=0,v=h.length;n<v;n++){var p=new THREE.Vertex(h[n].position.clone());c&&b.matrix.multiplyVector3(p.position);g.push(p)}n=0;for(v=j.length;n<v;n++){h=j[n];var q,w=h.vertexNormals;if(h instanceof THREE.Face3)q=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof THREE.Face4&&(q=new THREE.Face4(h.a+
-d,h.b+d,h.c+d,h.d+d));q.centroid.copy(h.centroid);q.normal.copy(h.normal);c=0;for(g=w.length;c<g;c++){p=w[c];q.vertexNormals.push(p.clone())}q.materials=h.materials.slice();k.push(q)}n=0;for(v=f.length;n<v;n++){d=f[n];k=[];c=0;for(g=d.length;c<g;c++)k.push(new THREE.UV(d[c].u,d[c].v));l.push(k)}}},ImageUtils={loadTexture:function(a,b,c){var d=new Image,f=new THREE.Texture(d,b);d.onload=function(){f.needsUpdate=!0;c&&c(this)};d.src=a;return f},loadTextureCube:function(a,b,c){var d,f=[],g=new THREE.Texture(f,
-b);b=f.loadCount=0;for(d=a.length;b<d;++b){f[b]=new Image;f[b].onload=function(){f.loadCount+=1;if(f.loadCount==6)g.needsUpdate=!0;c&&c(this)};f[b].src=a[b]}return g}},SceneUtils={loadScene:function(a,b,c,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function g(){for(n in O.objects)if(!J.objects[n]){B=O.objects[n];if(o=J.geometries[B.geometry]){ba=[];for(i=0;i<B.materials.length;i++)ba[i]=J.materials[B.materials[i]];H=B.position;r=B.rotation;s=B.scale;object=new THREE.Mesh(o,ba);object.position.set(H[0],
-H[1],H[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=B.visible;J.scene.addObject(object);J.objects[n]=object}}}function h($){return function(ra){J.geometries[$]=ra;g();V-=1;k()}}function k(){d({total_models:Y,total_textures:da,loaded_models:Y-V,loaded_textures:da-T},J);V==0&&T==0&&c(J)}var j,l,n,v,p,q,w,B,H,u,I,o,M,e,ba,O,P,V,T,Y,da,J;O=f.data;P=new THREE.Loader;T=V=0;J={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},
-fogs:{}};f=function(){T-=1;k()};for(p in O.cameras){u=O.cameras[p];if(u.type=="perspective")M=new THREE.Camera(u.fov,u.aspect,u.near,u.far);else if(u.type=="ortho"){M=new THREE.Camera;M.projectionMatrix=THREE.Matrix4.makeOrtho(u.left,u.right,u.top,u.bottom,u.near,u.far)}H=u.position;u=u.target;M.position.set(H[0],H[1],H[2]);M.target.position.set(u[0],u[1],u[2]);J.cameras[p]=M}for(v in O.lights){p=O.lights[v];if(p.type=="directional"){H=p.direction;light=new THREE.DirectionalLight;light.position.set(H[0],
-H[1],H[2]);light.position.normalize()}else if(p.type=="point"){H=p.position;light=new THREE.PointLight;light.position.set(H[0],H[1],H[2])}u=p.color;i=p.intensity||1;light.color.setRGB(u[0]*i,u[1]*i,u[2]*i);J.scene.addLight(light);J.lights[v]=light}for(q in O.fogs){v=O.fogs[q];if(v.type=="linear")e=new THREE.Fog(0,v.near,v.far);else v.type=="exp2"&&(e=new THREE.FogExp2(0,v.density));u=v.color;e.color.setRGB(u[0],u[1],u[2]);J.fogs[q]=e}if(J.cameras&&O.defaults.camera)J.currentCamera=J.cameras[O.defaults.camera];
-if(J.fogs&&O.defaults.fog)J.scene.fog=J.fogs[O.defaults.fog];u=O.defaults.bgcolor;J.bgColor=new THREE.Color;J.bgColor.setRGB(u[0],u[1],u[2]);J.bgColorAlpha=O.defaults.bgalpha;for(j in O.geometries){q=O.geometries[j];if(q.type=="bin_mesh"||q.type=="ascii_mesh")V+=1}Y=V;for(j in O.geometries){q=O.geometries[j];if(q.type=="cube"){o=new Cube(q.width,q.height,q.depth,q.segmentsWidth,q.segmentsHeight,null,q.flipped,q.sides);J.geometries[j]=o}else if(q.type=="plane"){o=new Plane(q.width,q.height,q.segmentsWidth,
-q.segmentsHeight);J.geometries[j]=o}else if(q.type=="sphere"){o=new Sphere(q.radius,q.segmentsWidth,q.segmentsHeight);J.geometries[j]=o}else if(q.type=="cylinder"){o=new Cylinder(q.numSegs,q.topRad,q.botRad,q.height,q.topOffset,q.botOffset);J.geometries[j]=o}else if(q.type=="torus"){o=new Torus(q.radius,q.tube,q.segmentsR,q.segmentsT);J.geometries[j]=o}else if(q.type=="icosahedron"){o=new Icosahedron(q.subdivisions);J.geometries[j]=o}else if(q.type=="bin_mesh")P.loadBinary({model:q.url,callback:h(j)});
-else q.type=="ascii_mesh"&&P.loadAscii({model:q.url,callback:h(j)})}for(w in O.textures){j=O.textures[w];T+=j.url instanceof Array?j.url.length:1}da=T;for(w in O.textures){j=O.textures[w];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array)q=ImageUtils.loadTextureCube(j.url,j.mapping,f);else{q=ImageUtils.loadTexture(j.url,j.mapping,f);if(THREE[j.minFilter]!=undefined)q.minFilter=THREE[j.minFilter];if(THREE[j.magFilter]!=undefined)q.magFilter=
-THREE[j.magFilter]}J.textures[w]=q}for(l in O.materials){w=O.materials[l];for(I in w.parameters)if(I=="envMap"||I=="map"||I=="lightMap")w.parameters[I]=J.textures[w.parameters[I]];else if(I=="shading")w.parameters[I]=w.parameters[I]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(I=="blending")w.parameters[I]=THREE[w.parameters[I]]?THREE[w.parameters[I]]:THREE.NormalBlending;else I=="combine"&&(w.parameters[I]=w.parameters[I]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);w=new THREE[w.type](w.parameters);
-J.materials[l]=w}g();b(J)}},addMesh:function(a,b,c,d,f,g,h,k,j,l){b=new THREE.Mesh(b,l);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=d;b.position.y=f;b.position.z=g;b.rotation.x=h;b.rotation.y=k;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragmentShader:d.fragmentShader,vertexShader:d.vertexShader,uniforms:d.uniforms});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,!0),c);a.addObject(b);
+var GeometryUtils={merge:function(a,b){var c=b instanceof THREE.Mesh,d=a.vertices.length,f=c?b.geometry:b,g=a.vertices,h=f.vertices,k=a.faces,j=f.faces,m=a.uvs;f=f.uvs;c&&b.matrixAutoUpdate&&b.updateMatrix();for(var n=0,w=h.length;n<w;n++){var o=new THREE.Vertex(h[n].position.clone());c&&b.matrix.multiplyVector3(o.position);g.push(o)}n=0;for(w=j.length;n<w;n++){h=j[n];var p,x=h.vertexNormals;if(h instanceof THREE.Face3)p=new THREE.Face3(h.a+d,h.b+d,h.c+d);else h instanceof THREE.Face4&&(p=new THREE.Face4(h.a+
+d,h.b+d,h.c+d,h.d+d));p.centroid.copy(h.centroid);p.normal.copy(h.normal);c=0;for(g=x.length;c<g;c++){o=x[c];p.vertexNormals.push(o.clone())}p.materials=h.materials.slice();k.push(p)}n=0;for(w=f.length;n<w;n++){d=f[n];k=[];c=0;for(g=d.length;c<g;c++)k.push(new THREE.UV(d[c].u,d[c].v));m.push(k)}}},ImageUtils={loadTexture:function(a,b,c){var d=new Image,f=new THREE.Texture(d,b);d.onload=function(){f.needsUpdate=!0;c&&c(this)};d.src=a;return f},loadTextureCube:function(a,b,c){var d,f=[],g=new THREE.Texture(f,
+b);b=f.loadCount=0;for(d=a.length;b<d;++b){f[b]=new Image;f[b].onload=function(){f.loadCount+=1;if(f.loadCount==6)g.needsUpdate=!0;c&&c(this)};f[b].src=a[b]}return g}},SceneUtils={loadScene:function(a,b,c,d){a=new Worker(a);a.postMessage(0);a.onmessage=function(f){function g(){for(n in O.objects)if(!M.objects[n]){A=O.objects[n];if(t=M.geometries[A.geometry]){e=[];for(i=0;i<A.materials.length;i++)e[i]=M.materials[A.materials[i]];I=A.position;r=A.rotation;s=A.scale;object=new THREE.Mesh(t,e);object.position.set(I[0],
+I[1],I[2]);object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=A.visible;M.scene.addObject(object);M.objects[n]=object}}}function h(X){return function(pa){M.geometries[X]=pa;g();W-=1;k()}}function k(){d({total_models:aa,total_textures:ea,loaded_models:aa-W,loaded_textures:ea-U},M);W==0&&U==0&&c(M)}var j,m,n,w,o,p,x,A,I,v,J,t,K,R,e,O,Q,W,U,aa,ea,M;O=f.data;Q=new THREE.Loader;U=W=0;M={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},
+lights:{},fogs:{}};f=function(){U-=1;k()};for(o in O.cameras){v=O.cameras[o];if(v.type=="perspective")K=new THREE.Camera(v.fov,v.aspect,v.near,v.far);else if(v.type=="ortho"){K=new THREE.Camera;K.projectionMatrix=THREE.Matrix4.makeOrtho(v.left,v.right,v.top,v.bottom,v.near,v.far)}I=v.position;v=v.target;K.position.set(I[0],I[1],I[2]);K.target.position.set(v[0],v[1],v[2]);M.cameras[o]=K}for(w in O.lights){o=O.lights[w];if(o.type=="directional"){I=o.direction;light=new THREE.DirectionalLight;light.position.set(I[0],
+I[1],I[2]);light.position.normalize()}else if(o.type=="point"){I=o.position;light=new THREE.PointLight;light.position.set(I[0],I[1],I[2])}v=o.color;i=o.intensity||1;light.color.setRGB(v[0]*i,v[1]*i,v[2]*i);M.scene.addLight(light);M.lights[w]=light}for(p in O.fogs){w=O.fogs[p];if(w.type=="linear")R=new THREE.Fog(0,w.near,w.far);else w.type=="exp2"&&(R=new THREE.FogExp2(0,w.density));v=w.color;R.color.setRGB(v[0],v[1],v[2]);M.fogs[p]=R}if(M.cameras&&O.defaults.camera)M.currentCamera=M.cameras[O.defaults.camera];
+if(M.fogs&&O.defaults.fog)M.scene.fog=M.fogs[O.defaults.fog];v=O.defaults.bgcolor;M.bgColor=new THREE.Color;M.bgColor.setRGB(v[0],v[1],v[2]);M.bgColorAlpha=O.defaults.bgalpha;for(j in O.geometries){p=O.geometries[j];if(p.type=="bin_mesh"||p.type=="ascii_mesh")W+=1}aa=W;for(j in O.geometries){p=O.geometries[j];if(p.type=="cube"){t=new Cube(p.width,p.height,p.depth,p.segmentsWidth,p.segmentsHeight,null,p.flipped,p.sides);M.geometries[j]=t}else if(p.type=="plane"){t=new Plane(p.width,p.height,p.segmentsWidth,
+p.segmentsHeight);M.geometries[j]=t}else if(p.type=="sphere"){t=new Sphere(p.radius,p.segmentsWidth,p.segmentsHeight);M.geometries[j]=t}else if(p.type=="cylinder"){t=new Cylinder(p.numSegs,p.topRad,p.botRad,p.height,p.topOffset,p.botOffset);M.geometries[j]=t}else if(p.type=="torus"){t=new Torus(p.radius,p.tube,p.segmentsR,p.segmentsT);M.geometries[j]=t}else if(p.type=="icosahedron"){t=new Icosahedron(p.subdivisions);M.geometries[j]=t}else if(p.type=="bin_mesh")Q.loadBinary({model:p.url,callback:h(j)});
+else p.type=="ascii_mesh"&&Q.loadAscii({model:p.url,callback:h(j)})}for(x in O.textures){j=O.textures[x];U+=j.url instanceof Array?j.url.length:1}ea=U;for(x in O.textures){j=O.textures[x];if(j.mapping!=undefined&&THREE[j.mapping]!=undefined)j.mapping=new THREE[j.mapping];if(j.url instanceof Array)p=ImageUtils.loadTextureCube(j.url,j.mapping,f);else{p=ImageUtils.loadTexture(j.url,j.mapping,f);if(THREE[j.minFilter]!=undefined)p.minFilter=THREE[j.minFilter];if(THREE[j.magFilter]!=undefined)p.magFilter=
+THREE[j.magFilter]}M.textures[x]=p}for(m in O.materials){x=O.materials[m];for(J in x.parameters)if(J=="envMap"||J=="map"||J=="lightMap")x.parameters[J]=M.textures[x.parameters[J]];else if(J=="shading")x.parameters[J]=x.parameters[J]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(J=="blending")x.parameters[J]=THREE[x.parameters[J]]?THREE[x.parameters[J]]:THREE.NormalBlending;else J=="combine"&&(x.parameters[J]=x.parameters[J]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);x=new THREE[x.type](x.parameters);
+M.materials[m]=x}g();b(M)}},addMesh:function(a,b,c,d,f,g,h,k,j,m){b=new THREE.Mesh(b,m);b.scale.x=b.scale.y=b.scale.z=c;b.position.x=d;b.position.y=f;b.position.z=g;b.rotation.x=h;b.rotation.y=k;b.rotation.z=j;a.addObject(b);return b},addPanoramaCubeWebGL:function(a,b,c){var d=ShaderUtils.lib.cube;d.uniforms.tCube.texture=c;c=new THREE.MeshShaderMaterial({fragmentShader:d.fragmentShader,vertexShader:d.vertexShader,uniforms:d.uniforms});b=new THREE.Mesh(new Cube(b,b,b,1,1,null,!0),c);a.addObject(b);
 return b},addPanoramaCube:function(a,b,c){var d=[];d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));d.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));b=new THREE.Mesh(new Cube(b,b,b,1,1,d,!0),new THREE.MeshFaceMaterial);
 a.addObject(b);return b},addPanoramaCubePlanes:function(a,b,c){var d=b/2;b=new Plane(b,b);var f=Math.PI,g=Math.PI/2;SceneUtils.addMesh(a,b,1,0,0,-d,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(a,b,1,-d,0,0,0,g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(a,b,1,d,0,0,0,-g,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));SceneUtils.addMesh(a,b,1,0,d,0,g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));
 SceneUtils.addMesh(a,b,1,0,-d,0,-g,0,f,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[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}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
@@ -296,40 +296,40 @@ cube:{uniforms:{tCube:{type:"t",value:1,texture:null}},vertexShader:"varying vec
 value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.001953125,0)},cKernel:{type:"fv1",value:[]}},vertexShader:"varying vec2 vUv;\nuniform vec2 uImageIncrement;\nvoid main(void) {\nvUv = uv - ((KERNEL_SIZE - 1.0) / 2.0) * uImageIncrement;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform vec2 uImageIncrement;\nuniform float cKernel[KERNEL_SIZE];\nvoid main(void) {\nvec2 imageCoord = vUv;\nvec4 sum = vec4( 0.0, 0.0, 0.0, 0.0 );\nfor( int i=0; i<KERNEL_SIZE; ++i ) {\nsum += texture2D( tDiffuse, imageCoord ) * cKernel[i];\nimageCoord += uImageIncrement;\n}\ngl_FragColor = sum;\n}"},
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
-fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,d,f,g=2*Math.ceil(a*3)+1;g>25&&(g=25);f=(g-1)*0.5;c=Array(g);for(b=d=0;b<g;++b){c[b]=Math.exp(-((b-f)*(b-f))/(2*a*a));d+=c[b]}for(b=0;b<g;++b)c[b]/=d;return c}},Cube=function(a,b,c,d,f,g,h,k){function j(B,H,u,I,o,M,e,ba){var O,P,V=d||1,T=f||1,Y=V+1,da=T+1,J=o/2,$=M/2;o/=V;var ra=M/T,Z=l.vertices.length;if(B=="x"&&H=="y"||B=="y"&&H=="x")O="z";else if(B=="x"&&H=="z"||B=="z"&&H=="x")O="y";
-else if(B=="z"&&H=="y"||B=="y"&&H=="z")O="x";for(P=0;P<da;P++)for(M=0;M<Y;M++){var la=new THREE.Vector3;la[B]=(M*o-J)*u;la[H]=(P*ra-$)*I;la[O]=e;l.vertices.push(new THREE.Vertex(la))}for(P=0;P<T;P++)for(M=0;M<V;M++){l.faces.push(new THREE.Face4(M+Y*P+Z,M+Y*(P+1)+Z,M+1+Y*(P+1)+Z,M+1+Y*P+Z,null,ba));l.uvs.push([new THREE.UV(M/V,P/T),new THREE.UV(M/V,(P+1)/T),new THREE.UV((M+1)/V,(P+1)/T),new THREE.UV((M+1)/V,P/T)])}}THREE.Geometry.call(this);var l=this,n=a/2,v=b/2,p=c/2;h=h?-1:1;if(g!==undefined)if(g instanceof
-Array)this.materials=g;else{this.materials=[];for(var q=0;q<6;q++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var w in k)this.sides[w]!=undefined&&(this.sides[w]=k[w]);this.sides.px&&j("z","y",1*h,-1,c,b,-n,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,c,b,n,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,c,v,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,c,-v,this.materials[3]);this.sides.pz&&j("x","y",1*h,-1,
-a,b,p,this.materials[4]);this.sides.nz&&j("x","y",-1*h,-1,a,b,-p,this.materials[5]);(function(){for(var B=[],H=[],u=0,I=l.vertices.length;u<I;u++){for(var o=l.vertices[u],M=!1,e=0,ba=B.length;e<ba;e++){var O=B[e];if(o.position.x==O.position.x&&o.position.y==O.position.y&&o.position.z==O.position.z){H[u]=e;M=!0;break}}if(!M){H[u]=B.length;B.push(new THREE.Vertex(o.position.clone()))}}u=0;for(I=l.faces.length;u<I;u++){o=l.faces[u];o.a=H[o.a];o.b=H[o.b];o.c=H[o.c];o.d=H[o.d]}l.vertices=B})();this.computeCentroids();
-this.computeFaceNormals();this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
-var Cylinder=function(a,b,c,d,f){function g(l,n,v){h.vertices.push(new THREE.Vertex(new THREE.Vector3(l,n,v)))}THREE.Geometry.call(this);var h=this,k=Math.PI,j;for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*b,Math.cos(2*k*j/a)*b,0);for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*c,Math.cos(2*k*j/a)*c,d);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(c!=0){g(0,0,-f);for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b!=0){g(0,0,d+f);for(j=a+a/2;j<
-2*a;j++)h.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-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,b,c,d){THREE.Geometry.call(this);var f,g=a/2,h=b/2;c=c||1;d=d||1;var k=c+1,j=d+1;a/=c;var l=b/d;for(f=0;f<j;f++)for(b=0;b<k;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-g,-(f*l-h),0)));for(f=0;f<d;f++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+k*f,b+k*(f+1),b+1+k*(f+1),b+1+k*f));this.uvs.push([new THREE.UV(b/c,f/d),new THREE.UV(b/c,(f+1)/d),new THREE.UV((b+1)/c,(f+1)/d),new THREE.UV((b+1)/c,f/d)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
+fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var b,c,d,f,g=2*Math.ceil(a*3)+1;g>25&&(g=25);f=(g-1)*0.5;c=Array(g);for(b=d=0;b<g;++b){c[b]=Math.exp(-((b-f)*(b-f))/(2*a*a));d+=c[b]}for(b=0;b<g;++b)c[b]/=d;return c}},Cube=function(a,b,c,d,f,g,h,k){function j(A,I,v,J,t,K,R,e){var O,Q,W=d||1,U=f||1,aa=W+1,ea=U+1,M=t/2,X=K/2;t/=W;var pa=K/U,ba=m.vertices.length;if(A=="x"&&I=="y"||A=="y"&&I=="x")O="z";else if(A=="x"&&I=="z"||A=="z"&&I=="x")O="y";
+else if(A=="z"&&I=="y"||A=="y"&&I=="z")O="x";for(Q=0;Q<ea;Q++)for(K=0;K<aa;K++){var la=new THREE.Vector3;la[A]=(K*t-M)*v;la[I]=(Q*pa-X)*J;la[O]=R;m.vertices.push(new THREE.Vertex(la))}for(Q=0;Q<U;Q++)for(K=0;K<W;K++){m.faces.push(new THREE.Face4(K+aa*Q+ba,K+aa*(Q+1)+ba,K+1+aa*(Q+1)+ba,K+1+aa*Q+ba,null,e));m.uvs.push([new THREE.UV(K/W,Q/U),new THREE.UV(K/W,(Q+1)/U),new THREE.UV((K+1)/W,(Q+1)/U),new THREE.UV((K+1)/W,Q/U)])}}THREE.Geometry.call(this);var m=this,n=a/2,w=b/2,o=c/2;h=h?-1:1;if(g!==undefined)if(g instanceof
+Array)this.materials=g;else{this.materials=[];for(var p=0;p<6;p++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(k!=undefined)for(var x in k)this.sides[x]!=undefined&&(this.sides[x]=k[x]);this.sides.px&&j("z","y",1*h,-1,c,b,-n,this.materials[0]);this.sides.nx&&j("z","y",-1*h,-1,c,b,n,this.materials[1]);this.sides.py&&j("x","z",1*h,1,a,c,w,this.materials[2]);this.sides.ny&&j("x","z",1*h,-1,a,c,-w,this.materials[3]);this.sides.pz&&j("x","y",1*h,-1,
+a,b,o,this.materials[4]);this.sides.nz&&j("x","y",-1*h,-1,a,b,-o,this.materials[5]);(function(){for(var A=[],I=[],v=0,J=m.vertices.length;v<J;v++){for(var t=m.vertices[v],K=!1,R=0,e=A.length;R<e;R++){var O=A[R];if(t.position.x==O.position.x&&t.position.y==O.position.y&&t.position.z==O.position.z){I[v]=R;K=!0;break}}if(!K){I[v]=A.length;A.push(new THREE.Vertex(t.position.clone()))}}v=0;for(J=m.faces.length;v<J;v++){t=m.faces[v];t.a=I[t.a];t.b=I[t.b];t.c=I[t.c];t.d=I[t.d]}m.vertices=A})();this.computeCentroids();
+this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
+var Cylinder=function(a,b,c,d,f){function g(m,n,w){h.vertices.push(new THREE.Vertex(new THREE.Vector3(m,n,w)))}THREE.Geometry.call(this);var h=this,k=Math.PI,j;for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*b,Math.cos(2*k*j/a)*b,0);for(j=0;j<a;j++)g(Math.sin(2*k*j/a)*c,Math.cos(2*k*j/a)*c,d);for(j=0;j<a;j++)h.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(c!=0){g(0,0,-f);for(j=a;j<a+a/2;j++)h.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(b!=0){g(0,0,d+f);for(j=a+a/2;j<
+2*a;j++)h.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
+var Plane=function(a,b,c,d){THREE.Geometry.call(this);var f,g=a/2,h=b/2;c=c||1;d=d||1;var k=c+1,j=d+1;a/=c;var m=b/d;for(f=0;f<j;f++)for(b=0;b<k;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*a-g,-(f*m-h),0)));for(f=0;f<d;f++)for(b=0;b<c;b++){this.faces.push(new THREE.Face4(b+k*f,b+k*(f+1),b+1+k*(f+1),b+1+k*f));this.uvs.push([new THREE.UV(b/c,f/d),new THREE.UV(b/c,(f+1)/d),new THREE.UV((b+1)/c,(f+1)/d),new THREE.UV((b+1)/c,f/d)])}this.computeCentroids();this.computeFaceNormals()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(a,b,c){THREE.Geometry.call(this);var d,f=Math.PI,g=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){d=c/h;var k=a*Math.cos(d*f),j=a*Math.sin(d*f),l=[],n=0;for(d=0;d<g;d++){var v=2*d/g,p=j*Math.sin(v*f);v=j*Math.cos(v*f);(c==0||c==h)&&d>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,k,p)))-1);l.push(n)}b.push(l)}var q,w,B;f=b.length;for(c=0;c<f;c++){g=b[c].length;if(c>0)for(d=0;d<g;d++){l=d==g-1;h=b[c][l?0:d+1];k=b[c][l?g-1:d];j=b[c-1][l?g-1:d];l=b[c-1][l?
-0:d+1];p=c/(f-1);q=(c-1)/(f-1);w=(d+1)/g;v=d/g;n=new THREE.UV(1-w,p);p=new THREE.UV(1-v,p);v=new THREE.UV(1-v,q);var H=new THREE.UV(1-w,q);if(c<b.length-1){q=this.vertices[h].position.clone();w=this.vertices[k].position.clone();B=this.vertices[j].position.clone();q.normalize();w.normalize();B.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([n,p,v])}if(c>1){q=this.vertices[h].position.clone();
-w=this.vertices[j].position.clone();B=this.vertices[l].position.clone();q.normalize();w.normalize();B.normalize();this.faces.push(new THREE.Face3(h,j,l,[new THREE.Vector3(q.x,q.y,q.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(B.x,B.y,B.z)]));this.uvs.push([n,v,H])}}}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,b,c){THREE.Geometry.call(this);var d,f=Math.PI,g=Math.max(3,b||8),h=Math.max(2,c||6);b=[];for(c=0;c<h+1;c++){d=c/h;var k=a*Math.cos(d*f),j=a*Math.sin(d*f),m=[],n=0;for(d=0;d<g;d++){var w=2*d/g,o=j*Math.sin(w*f);w=j*Math.cos(w*f);(c==0||c==h)&&d>0||(n=this.vertices.push(new THREE.Vertex(new THREE.Vector3(w,k,o)))-1);m.push(n)}b.push(m)}var p,x,A;f=b.length;for(c=0;c<f;c++){g=b[c].length;if(c>0)for(d=0;d<g;d++){m=d==g-1;h=b[c][m?0:d+1];k=b[c][m?g-1:d];j=b[c-1][m?g-1:d];m=b[c-1][m?
+0:d+1];o=c/(f-1);p=(c-1)/(f-1);x=(d+1)/g;w=d/g;n=new THREE.UV(1-x,o);o=new THREE.UV(1-w,o);w=new THREE.UV(1-w,p);var I=new THREE.UV(1-x,p);if(c<b.length-1){p=this.vertices[h].position.clone();x=this.vertices[k].position.clone();A=this.vertices[j].position.clone();p.normalize();x.normalize();A.normalize();this.faces.push(new THREE.Face3(h,k,j,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([n,o,w])}if(c>1){p=this.vertices[h].position.clone();
+x=this.vertices[j].position.clone();A=this.vertices[m].position.clone();p.normalize();x.normalize();A.normalize();this.faces.push(new THREE.Face3(h,j,m,[new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(A.x,A.y,A.z)]));this.uvs.push([n,w,I])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 var Torus=function(a,b,c,d){this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;a=[];THREE.Geometry.call(this);for(b=0;b<=this.segmentsR;++b)for(c=0;c<=this.segmentsT;++c){d=c/this.segmentsT*2*Math.PI;var f=b/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(f))*Math.cos(d),(this.radius+this.tube*Math.cos(f))*Math.sin(d),this.tube*Math.sin(f))));a.push([c/this.segmentsT,1-b/this.segmentsR])}for(b=1;b<=this.segmentsR;++b)for(c=
-1;c<=this.segmentsT;++c){d=(this.segmentsT+1)*b+c;f=(this.segmentsT+1)*b+c-1;var g=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(d,f,g,h));this.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][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 b(v,p,q){var w=Math.sqrt(v*v+p*p+q*q);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(v/w,p/w,q/w)))-1}function c(v,p,q,w){w.faces.push(new THREE.Face3(v,p,q))}function d(v,p){var q=f.vertices[v].position,w=f.vertices[p].position;return b((q.x+w.x)/2,(q.y+w.y)/2,(q.z+w.z)/2)}var f=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
-1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,g);c(0,5,1,g);c(0,1,7,g);c(0,7,10,g);c(0,10,11,g);c(1,5,9,g);c(5,11,4,g);c(11,10,2,g);c(10,7,6,g);c(7,1,8,g);c(3,9,4,g);c(3,4,2,g);c(3,2,6,g);c(3,6,8,g);c(3,8,9,g);c(4,9,5,g);c(2,4,11,g);c(6,2,10,g);c(8,6,7,g);c(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in g.faces){var j=d(g.faces[k].a,g.faces[k].b),l=d(g.faces[k].b,g.faces[k].c),n=d(g.faces[k].c,g.faces[k].a);c(g.faces[k].a,j,n,h);c(g.faces[k].b,l,j,h);c(g.faces[k].c,
-n,l,h);c(j,l,n,h)}g.faces=h.faces}f.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
-function LathedObject(a,b,c){THREE.Geometry.call(this);this.nsteps=b||12;this.latheAngle=c||2*Math.PI;b=this.latheAngle/this.nsteps;for(var d=[],f=[],g=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));f[k]=this.vertices.length-1;d[k]=new THREE.Vector3(a[k].x,a[k].y,a[k].z)}for(var j=THREE.Matrix4.rotationZMatrix(this.stepSize),l=0;l<=this.latheAngle+0.001;l+=this.stepSize){for(k=0;k<d.length;k++)if(l<c){d[k]=j.multiplyVector3(d[k].clone());this.vertices.push(new THREE.Vertex(d[k]));
-g[k]=this.vertices.length-1}else g=h;l==0&&(h=f);for(k=0;k<f.length-1;k++){this.faces.push(new THREE.Face4(g[k],g[k+1],f[k+1],f[k]));this.uvs.push([new THREE.UV(l/c,k/a.length),new THREE.UV(l/c,(k+1)/a.length),new THREE.UV((l-b)/c,(k+1)/a.length),new THREE.UV((l-b)/c,k/a.length)])}f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;
+1;c<=this.segmentsT;++c){d=(this.segmentsT+1)*b+c;f=(this.segmentsT+1)*b+c-1;var g=(this.segmentsT+1)*(b-1)+c-1,h=(this.segmentsT+1)*(b-1)+c;this.faces.push(new THREE.Face4(d,f,g,h));this.uvs.push([new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[h][0],a[h][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
+var Icosahedron=function(a){function b(w,o,p){var x=Math.sqrt(w*w+o*o+p*p);return f.vertices.push(new THREE.Vertex(new THREE.Vector3(w/x,o/x,p/x)))-1}function c(w,o,p,x){x.faces.push(new THREE.Face3(w,o,p))}function d(w,o){var p=f.vertices[w].position,x=f.vertices[o].position;return b((p.x+x.x)/2,(p.y+x.y)/2,(p.z+x.z)/2)}var f=this,g=new THREE.Geometry,h;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,
+1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,g);c(0,5,1,g);c(0,1,7,g);c(0,7,10,g);c(0,10,11,g);c(1,5,9,g);c(5,11,4,g);c(11,10,2,g);c(10,7,6,g);c(7,1,8,g);c(3,9,4,g);c(3,4,2,g);c(3,2,6,g);c(3,6,8,g);c(3,8,9,g);c(4,9,5,g);c(2,4,11,g);c(6,2,10,g);c(8,6,7,g);c(9,8,1,g);for(a=0;a<this.subdivisions;a++){h=new THREE.Geometry;for(var k in g.faces){var j=d(g.faces[k].a,g.faces[k].b),m=d(g.faces[k].b,g.faces[k].c),n=d(g.faces[k].c,g.faces[k].a);c(g.faces[k].a,j,n,h);c(g.faces[k].b,m,j,h);c(g.faces[k].c,
+n,m,h);c(j,m,n,h)}g.faces=h.faces}f.faces=g.faces;delete g;delete h;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
+function LathedObject(a,b,c){THREE.Geometry.call(this);this.nsteps=b||12;this.latheAngle=c||2*Math.PI;b=this.latheAngle/this.nsteps;for(var d=[],f=[],g=[],h=[],k=0;k<a.length;k++){this.vertices.push(new THREE.Vertex(a[k]));f[k]=this.vertices.length-1;d[k]=new THREE.Vector3(a[k].x,a[k].y,a[k].z)}for(var j=THREE.Matrix4.rotationZMatrix(this.stepSize),m=0;m<=this.latheAngle+0.001;m+=this.stepSize){for(k=0;k<d.length;k++)if(m<c){d[k]=j.multiplyVector3(d[k].clone());this.vertices.push(new THREE.Vertex(d[k]));
+g[k]=this.vertices.length-1}else g=h;m==0&&(h=f);for(k=0;k<f.length-1;k++){this.faces.push(new THREE.Face4(g[k],g[k+1],f[k+1],f[k]));this.uvs.push([new THREE.UV(m/c,k/a.length),new THREE.UV(m/c,(k+1)/a.length),new THREE.UV((m-b)/c,(k+1)/a.length),new THREE.UV((m-b)/c,k/a.length)])}f=g;g=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;
 if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.materials=b instanceof Array?b:[b];this.init=function(c){this.isolation=80;this.size=c;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
-0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,d,f){return c+(d-c)*f};this.VIntX=function(c,d,f,g,h,k,j,l,n,v){h=(h-n)/(v-n);n=this.normal_cache;d[g]=k+h*this.delta;d[g+1]=j;d[g+2]=l;f[g]=this.lerp(n[c],n[c+3],h);f[g+1]=this.lerp(n[c+1],n[c+4],h);f[g+2]=this.lerp(n[c+2],n[c+5],h)};this.VIntY=function(c,d,f,g,h,k,j,l,n,v){h=(h-n)/(v-n);n=this.normal_cache;d[g]=k;d[g+1]=j+h*this.delta;d[g+
-2]=l;d=c+this.yd*3;f[g]=this.lerp(n[c],n[d],h);f[g+1]=this.lerp(n[c+1],n[d+1],h);f[g+2]=this.lerp(n[c+2],n[d+2],h)};this.VIntZ=function(c,d,f,g,h,k,j,l,n,v){h=(h-n)/(v-n);n=this.normal_cache;d[g]=k;d[g+1]=j;d[g+2]=l+h*this.delta;d=c+this.zd*3;f[g]=this.lerp(n[c],n[d],h);f[g+1]=this.lerp(n[c+1],n[d+1],h);f[g+2]=this.lerp(n[c+2],n[d+2],h)};this.compNorm=function(c){var d=c*3;if(this.normal_cache[d]==0){this.normal_cache[d]=this.field[c-1]-this.field[c+1];this.normal_cache[d+1]=this.field[c-this.yd]-
-this.field[c+this.yd];this.normal_cache[d+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,d,f,g,h,k){var j=g+1,l=g+this.yd,n=g+this.zd,v=j+this.yd,p=j+this.zd,q=g+this.yd+this.zd,w=j+this.yd+this.zd,B=0,H=this.field[g],u=this.field[j],I=this.field[l],o=this.field[v],M=this.field[n],e=this.field[p],ba=this.field[q],O=this.field[w];H<h&&(B|=1);u<h&&(B|=2);I<h&&(B|=8);o<h&&(B|=4);M<h&&(B|=16);e<h&&(B|=32);ba<h&&(B|=128);O<h&&(B|=64);var P=THREE.edgeTable[B];if(P==0)return 0;
-var V=this.delta,T=c+V,Y=d+V;V=f+V;if(P&1){this.compNorm(g);this.compNorm(j);this.VIntX(g*3,this.vlist,this.nlist,0,h,c,d,f,H,u)}if(P&2){this.compNorm(j);this.compNorm(v);this.VIntY(j*3,this.vlist,this.nlist,3,h,T,d,f,u,o)}if(P&4){this.compNorm(l);this.compNorm(v);this.VIntX(l*3,this.vlist,this.nlist,6,h,c,Y,f,I,o)}if(P&8){this.compNorm(g);this.compNorm(l);this.VIntY(g*3,this.vlist,this.nlist,9,h,c,d,f,H,I)}if(P&16){this.compNorm(n);this.compNorm(p);this.VIntX(n*3,this.vlist,this.nlist,12,h,c,d,V,
-M,e)}if(P&32){this.compNorm(p);this.compNorm(w);this.VIntY(p*3,this.vlist,this.nlist,15,h,T,d,V,e,O)}if(P&64){this.compNorm(q);this.compNorm(w);this.VIntX(q*3,this.vlist,this.nlist,18,h,c,Y,V,ba,O)}if(P&128){this.compNorm(n);this.compNorm(q);this.VIntY(n*3,this.vlist,this.nlist,21,h,c,d,V,M,ba)}if(P&256){this.compNorm(g);this.compNorm(n);this.VIntZ(g*3,this.vlist,this.nlist,24,h,c,d,f,H,M)}if(P&512){this.compNorm(j);this.compNorm(p);this.VIntZ(j*3,this.vlist,this.nlist,27,h,T,d,f,u,e)}if(P&1024){this.compNorm(v);
-this.compNorm(w);this.VIntZ(v*3,this.vlist,this.nlist,30,h,T,Y,f,o,O)}if(P&2048){this.compNorm(l);this.compNorm(q);this.VIntZ(l*3,this.vlist,this.nlist,33,h,c,Y,f,I,ba)}B<<=4;for(h=g=0;THREE.triTable[B+h]!=-1;){c=B+h;d=c+1;f=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[d],3*THREE.triTable[f],k);h+=3;g++}return g};this.posnormtriv=function(c,d,f,g,h,k){var j=this.count*3;this.positionArray[j]=c[f];this.positionArray[j+1]=c[f+1];this.positionArray[j+2]=c[f+2];this.positionArray[j+
+0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,d,f){return c+(d-c)*f};this.VIntX=function(c,d,f,g,h,k,j,m,n,w){h=(h-n)/(w-n);n=this.normal_cache;d[g]=k+h*this.delta;d[g+1]=j;d[g+2]=m;f[g]=this.lerp(n[c],n[c+3],h);f[g+1]=this.lerp(n[c+1],n[c+4],h);f[g+2]=this.lerp(n[c+2],n[c+5],h)};this.VIntY=function(c,d,f,g,h,k,j,m,n,w){h=(h-n)/(w-n);n=this.normal_cache;d[g]=k;d[g+1]=j+h*this.delta;d[g+
+2]=m;d=c+this.yd*3;f[g]=this.lerp(n[c],n[d],h);f[g+1]=this.lerp(n[c+1],n[d+1],h);f[g+2]=this.lerp(n[c+2],n[d+2],h)};this.VIntZ=function(c,d,f,g,h,k,j,m,n,w){h=(h-n)/(w-n);n=this.normal_cache;d[g]=k;d[g+1]=j;d[g+2]=m+h*this.delta;d=c+this.zd*3;f[g]=this.lerp(n[c],n[d],h);f[g+1]=this.lerp(n[c+1],n[d+1],h);f[g+2]=this.lerp(n[c+2],n[d+2],h)};this.compNorm=function(c){var d=c*3;if(this.normal_cache[d]==0){this.normal_cache[d]=this.field[c-1]-this.field[c+1];this.normal_cache[d+1]=this.field[c-this.yd]-
+this.field[c+this.yd];this.normal_cache[d+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,d,f,g,h,k){var j=g+1,m=g+this.yd,n=g+this.zd,w=j+this.yd,o=j+this.zd,p=g+this.yd+this.zd,x=j+this.yd+this.zd,A=0,I=this.field[g],v=this.field[j],J=this.field[m],t=this.field[w],K=this.field[n],R=this.field[o],e=this.field[p],O=this.field[x];I<h&&(A|=1);v<h&&(A|=2);J<h&&(A|=8);t<h&&(A|=4);K<h&&(A|=16);R<h&&(A|=32);e<h&&(A|=128);O<h&&(A|=64);var Q=THREE.edgeTable[A];if(Q==0)return 0;
+var W=this.delta,U=c+W,aa=d+W;W=f+W;if(Q&1){this.compNorm(g);this.compNorm(j);this.VIntX(g*3,this.vlist,this.nlist,0,h,c,d,f,I,v)}if(Q&2){this.compNorm(j);this.compNorm(w);this.VIntY(j*3,this.vlist,this.nlist,3,h,U,d,f,v,t)}if(Q&4){this.compNorm(m);this.compNorm(w);this.VIntX(m*3,this.vlist,this.nlist,6,h,c,aa,f,J,t)}if(Q&8){this.compNorm(g);this.compNorm(m);this.VIntY(g*3,this.vlist,this.nlist,9,h,c,d,f,I,J)}if(Q&16){this.compNorm(n);this.compNorm(o);this.VIntX(n*3,this.vlist,this.nlist,12,h,c,d,
+W,K,R)}if(Q&32){this.compNorm(o);this.compNorm(x);this.VIntY(o*3,this.vlist,this.nlist,15,h,U,d,W,R,O)}if(Q&64){this.compNorm(p);this.compNorm(x);this.VIntX(p*3,this.vlist,this.nlist,18,h,c,aa,W,e,O)}if(Q&128){this.compNorm(n);this.compNorm(p);this.VIntY(n*3,this.vlist,this.nlist,21,h,c,d,W,K,e)}if(Q&256){this.compNorm(g);this.compNorm(n);this.VIntZ(g*3,this.vlist,this.nlist,24,h,c,d,f,I,K)}if(Q&512){this.compNorm(j);this.compNorm(o);this.VIntZ(j*3,this.vlist,this.nlist,27,h,U,d,f,v,R)}if(Q&1024){this.compNorm(w);
+this.compNorm(x);this.VIntZ(w*3,this.vlist,this.nlist,30,h,U,aa,f,t,O)}if(Q&2048){this.compNorm(m);this.compNorm(p);this.VIntZ(m*3,this.vlist,this.nlist,33,h,c,aa,f,J,e)}A<<=4;for(h=g=0;THREE.triTable[A+h]!=-1;){c=A+h;d=c+1;f=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[d],3*THREE.triTable[f],k);h+=3;g++}return g};this.posnormtriv=function(c,d,f,g,h,k){var j=this.count*3;this.positionArray[j]=c[f];this.positionArray[j+1]=c[f+1];this.positionArray[j+2]=c[f+2];this.positionArray[j+
 3]=c[g];this.positionArray[j+4]=c[g+1];this.positionArray[j+5]=c[g+2];this.positionArray[j+6]=c[h];this.positionArray[j+7]=c[h+1];this.positionArray[j+8]=c[h+2];this.normalArray[j]=d[f];this.normalArray[j+1]=d[f+1];this.normalArray[j+2]=d[f+2];this.normalArray[j+3]=d[g];this.normalArray[j+4]=d[g+1];this.normalArray[j+5]=d[g+2];this.normalArray[j+6]=d[h];this.normalArray[j+7]=d[h+1];this.normalArray[j+8]=d[h+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=
-function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var d=this.count*3;d<this.positionArray.length;d++)this.positionArray[d]=0;c(this)}};this.addBall=function(c,d,f,g,h){var k=this.size*Math.sqrt(g/h),j=f*this.size,l=d*this.size,n=c*this.size,v=Math.floor(j-k);v<1&&(v=1);j=Math.floor(j+k);j>this.size-1&&(j=this.size-1);var p=Math.floor(l-k);p<1&&(p=1);l=Math.floor(l+k);l>this.size-1&&(l=this.size-1);var q=Math.floor(n-k);q<1&&(q=1);k=Math.floor(n+k);
-k>this.size-1&&(k=this.size-1);for(var w,B,H,u,I,o;v<j;v++){n=this.size2*v;B=v/this.size-f;I=B*B;for(B=p;B<l;B++){H=n+this.size*B;w=B/this.size-d;o=w*w;for(w=q;w<k;w++){u=w/this.size-c;u=g/(1.0E-6+u*u+o+I)-h;u>0&&(this.field[H+w]+=u)}}}};this.addPlaneX=function(c,d){var f,g,h,k,j,l=this.size,n=this.yd,v=this.zd,p=this.field,q=l*Math.sqrt(c/d);q>l&&(q=l);for(f=0;f<q;f++){g=f/l;g*=g;k=c/(1.0E-4+g)-d;if(k>0)for(g=0;g<l;g++){j=f+g*n;for(h=0;h<l;h++)p[v*h+j]+=k}}};this.addPlaneY=function(c,d){var f,g,
-h,k,j,l,n=this.size,v=this.yd,p=this.zd,q=this.field,w=n*Math.sqrt(c/d);w>n&&(w=n);for(g=0;g<w;g++){f=g/n;f*=f;k=c/(1.0E-4+f)-d;if(k>0){j=g*v;for(f=0;f<n;f++){l=j+f;for(h=0;h<n;h++)q[p*h+l]+=k}}}};this.addPlaneZ=function(c,d){var f,g,h,k,j,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/d);dist>size&&(dist=size);for(h=0;h<dist;h++){f=h/size;f*=f;k=c/(1.0E-4+f)-d;if(k>0){j=zd*h;for(g=0;g<size;g++){l=j+g*yd;for(f=0;f<size;f++)field[l+f]+=k}}}};this.reset=function(){var c;
-for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var d,f,g,h,k,j,l,n,v,p=this.size-2;for(h=1;h<p;h++){v=this.size2*h;l=(h-this.halfsize)/this.halfsize;for(g=1;g<p;g++){n=v+this.size*g;j=(g-this.halfsize)/this.halfsize;for(f=1;f<p;f++){k=(f-this.halfsize)/this.halfsize;d=n+f;this.polygonize(k,j,l,d,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,d=new THREE.Geometry;this.render(function(f){var g,h,k,j,l,n,v,p;for(g=
-0;g<f.count;g++){l=g*3;v=l+1;p=l+2;h=f.positionArray[l];k=f.positionArray[v];j=f.positionArray[p];n=new THREE.Vector3(h,k,j);h=f.normalArray[l];k=f.normalArray[v];j=f.normalArray[p];l=new THREE.Vector3(h,k,j);l.normalize();l=new THREE.Vertex(n,l);d.vertices.push(l)}nfaces=f.count/3;for(g=0;g<nfaces;g++){l=(c+g)*3;v=l+1;p=l+2;n=d.vertices[l].normal;h=d.vertices[v].normal;k=d.vertices[p].normal;l=new THREE.Face3(l,v,p,[n,h,k]);d.faces.push(l)}c+=nfaces;f.count=0});d.sortFacesByMaterial();return d};
-this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
+function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var d=this.count*3;d<this.positionArray.length;d++)this.positionArray[d]=0;c(this)}};this.addBall=function(c,d,f,g,h){var k=this.size*Math.sqrt(g/h),j=f*this.size,m=d*this.size,n=c*this.size,w=Math.floor(j-k);w<1&&(w=1);j=Math.floor(j+k);j>this.size-1&&(j=this.size-1);var o=Math.floor(m-k);o<1&&(o=1);m=Math.floor(m+k);m>this.size-1&&(m=this.size-1);var p=Math.floor(n-k);p<1&&(p=1);k=Math.floor(n+k);
+k>this.size-1&&(k=this.size-1);for(var x,A,I,v,J,t;w<j;w++){n=this.size2*w;A=w/this.size-f;J=A*A;for(A=o;A<m;A++){I=n+this.size*A;x=A/this.size-d;t=x*x;for(x=p;x<k;x++){v=x/this.size-c;v=g/(1.0E-6+v*v+t+J)-h;v>0&&(this.field[I+x]+=v)}}}};this.addPlaneX=function(c,d){var f,g,h,k,j,m=this.size,n=this.yd,w=this.zd,o=this.field,p=m*Math.sqrt(c/d);p>m&&(p=m);for(f=0;f<p;f++){g=f/m;g*=g;k=c/(1.0E-4+g)-d;if(k>0)for(g=0;g<m;g++){j=f+g*n;for(h=0;h<m;h++)o[w*h+j]+=k}}};this.addPlaneY=function(c,d){var f,g,
+h,k,j,m,n=this.size,w=this.yd,o=this.zd,p=this.field,x=n*Math.sqrt(c/d);x>n&&(x=n);for(g=0;g<x;g++){f=g/n;f*=f;k=c/(1.0E-4+f)-d;if(k>0){j=g*w;for(f=0;f<n;f++){m=j+f;for(h=0;h<n;h++)p[o*h+m]+=k}}}};this.addPlaneZ=function(c,d){var f,g,h,k,j,m;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/d);dist>size&&(dist=size);for(h=0;h<dist;h++){f=h/size;f*=f;k=c/(1.0E-4+f)-d;if(k>0){j=zd*h;for(g=0;g<size;g++){m=j+g*yd;for(f=0;f<size;f++)field[m+f]+=k}}}};this.reset=function(){var c;
+for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var d,f,g,h,k,j,m,n,w,o=this.size-2;for(h=1;h<o;h++){w=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<o;g++){n=w+this.size*g;j=(g-this.halfsize)/this.halfsize;for(f=1;f<o;f++){k=(f-this.halfsize)/this.halfsize;d=n+f;this.polygonize(k,j,m,d,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,d=new THREE.Geometry;this.render(function(f){var g,h,k,j,m,n,w,o;for(g=
+0;g<f.count;g++){m=g*3;w=m+1;o=m+2;h=f.positionArray[m];k=f.positionArray[w];j=f.positionArray[o];n=new THREE.Vector3(h,k,j);h=f.normalArray[m];k=f.normalArray[w];j=f.normalArray[o];m=new THREE.Vector3(h,k,j);m.normalize();m=new THREE.Vertex(n,m);d.vertices.push(m)}nfaces=f.count/3;for(g=0;g<nfaces;g++){m=(c+g)*3;w=m+1;o=m+2;n=d.vertices[m].normal;h=d.vertices[w].normal;k=d.vertices[o].normal;m=new THREE.Face3(m,w,o,[n,h,k]);d.faces.push(m)}c+=nfaces;f.count=0});return d};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]);
@@ -358,24 +358,24 @@ THREE.Loader.prototype={addStatusElement:function(){var a=document.createElement
 b},loadAsciiOld:function(a,b){var c=document.createElement("script");c.type="text/javascript";c.onload=b;c.src=a;document.getElementsByTagName("head")[0].appendChild(c)},loadAscii:function(a){var b=a.model,c=a.callback,d=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);b.onmessage=function(f){THREE.Loader.prototype.createModel(f.data,c,d)};b.postMessage(a)},loadBinary:function(a){var b=a.model,c=a.callback,d=a.texture_path?a.texture_path:
 THREE.Loader.prototype.extractUrlbase(b),f=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(b);a=(new Date).getTime();b=new Worker(b);var g=this.showProgress?THREE.Loader.prototype.updateProgress:null;b.onmessage=function(h){THREE.Loader.prototype.loadAjaxBuffers(h.data.buffers,h.data.materials,c,f,d,g)};b.onerror=function(h){alert("worker.onerror: "+h.message+"\n"+h.data);h.preventDefault()};b.postMessage(a)},loadAjaxBuffers:function(a,b,c,d,f,g){var h=new XMLHttpRequest,k=d+"/"+a,j=0;
 h.onreadystatechange=function(){if(h.readyState==4)h.status==200||h.status==0?THREE.Loader.prototype.createBinModel(h.responseText,c,f,b):alert("Couldn't load ["+k+"] ["+h.status+"]");else if(h.readyState==3){if(g){j==0&&(j=h.getResponseHeader("Content-Length"));g({total:j,loaded:h.responseText.length})}}else h.readyState==2&&(j=h.getResponseHeader("Content-Length"))};h.open("GET",k,!0);h.overrideMimeType("text/plain; charset=x-user-defined");h.setRequestHeader("Content-Type","text/plain");h.send(null)},
-createBinModel:function(a,b,c,d){var f=function(g){function h(z,F){var L=n(z,F),G=n(z,F+1),U=n(z,F+2),pa=n(z,F+3),ka=(pa<<1&255|U>>7)-127;L|=(U&127)<<16|G<<8;if(L==0&&ka==-127)return 0;return(1-2*(pa>>7))*(1+L*Math.pow(2,-23))*Math.pow(2,ka)}function k(z,F){var L=n(z,F),G=n(z,F+1),U=n(z,F+2);return(n(z,F+3)<<24)+(U<<16)+(G<<8)+L}function j(z,F){var L=n(z,F);return(n(z,F+1)<<8)+L}function l(z,F){var L=n(z,F);return L>127?L-256:L}function n(z,F){return z.charCodeAt(F)&255}function v(z){var F,L,G;F=
-k(a,z);L=k(a,z+ba);G=k(a,z+O);z=j(a,z+P);THREE.Loader.prototype.f3(u,F,L,G,z)}function p(z){var F,L,G,U,pa,ka;F=k(a,z);L=k(a,z+ba);G=k(a,z+O);U=j(a,z+P);pa=k(a,z+V);ka=k(a,z+T);z=k(a,z+Y);THREE.Loader.prototype.f3n(u,M,F,L,G,U,pa,ka,z)}function q(z){var F,L,G,U;F=k(a,z);L=k(a,z+da);G=k(a,z+J);U=k(a,z+$);z=j(a,z+ra);THREE.Loader.prototype.f4(u,F,L,G,U,z)}function w(z){var F,L,G,U,pa,ka,oa,na;F=k(a,z);L=k(a,z+da);G=k(a,z+J);U=k(a,z+$);pa=j(a,z+ra);ka=k(a,z+Z);oa=k(a,z+la);na=k(a,z+ja);z=k(a,z+fa);THREE.Loader.prototype.f4n(u,
-M,F,L,G,U,pa,ka,oa,na,z)}function B(z){var F,L;F=k(a,z);L=k(a,z+sa);z=k(a,z+m);THREE.Loader.prototype.uv3(u.uvs,e[F*2],e[F*2+1],e[L*2],e[L*2+1],e[z*2],e[z*2+1])}function H(z){var F,L,G;F=k(a,z);L=k(a,z+A);G=k(a,z+x);z=k(a,z+t);THREE.Loader.prototype.uv4(u.uvs,e[F*2],e[F*2+1],e[L*2],e[L*2+1],e[G*2],e[G*2+1],e[z*2],e[z*2+1])}var u=this,I=0,o,M=[],e=[],ba,O,P,V,T,Y,da,J,$,ra,Z,la,ja,fa,sa,m,A,x,t,y,C,D,E,K,W;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(u,d,g);o={signature:a.substr(I,
-8),header_bytes:n(a,I+8),vertex_coordinate_bytes:n(a,I+9),normal_coordinate_bytes:n(a,I+10),uv_coordinate_bytes:n(a,I+11),vertex_index_bytes:n(a,I+12),normal_index_bytes:n(a,I+13),uv_index_bytes:n(a,I+14),material_index_bytes:n(a,I+15),nvertices:k(a,I+16),nnormals:k(a,I+16+4),nuvs:k(a,I+16+8),ntri_flat:k(a,I+16+12),ntri_smooth:k(a,I+16+16),ntri_flat_uv:k(a,I+16+20),ntri_smooth_uv:k(a,I+16+24),nquad_flat:k(a,I+16+28),nquad_smooth:k(a,I+16+32),nquad_flat_uv:k(a,I+16+36),nquad_smooth_uv:k(a,I+16+40)};
-I+=o.header_bytes;ba=o.vertex_index_bytes;O=o.vertex_index_bytes*2;P=o.vertex_index_bytes*3;V=o.vertex_index_bytes*3+o.material_index_bytes;T=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes;Y=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*2;da=o.vertex_index_bytes;J=o.vertex_index_bytes*2;$=o.vertex_index_bytes*3;ra=o.vertex_index_bytes*4;Z=o.vertex_index_bytes*4+o.material_index_bytes;la=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes;ja=
-o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*2;fa=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*3;sa=o.uv_index_bytes;m=o.uv_index_bytes*2;A=o.uv_index_bytes;x=o.uv_index_bytes*2;t=o.uv_index_bytes*3;g=o.vertex_index_bytes*3+o.material_index_bytes;W=o.vertex_index_bytes*4+o.material_index_bytes;y=o.ntri_flat*g;C=o.ntri_smooth*(g+o.normal_index_bytes*3);D=o.ntri_flat_uv*(g+o.uv_index_bytes*3);E=o.ntri_smooth_uv*(g+o.normal_index_bytes*3+o.uv_index_bytes*3);
-K=o.nquad_flat*W;g=o.nquad_smooth*(W+o.normal_index_bytes*4);W=o.nquad_flat_uv*(W+o.uv_index_bytes*4);I+=function(z){for(var F,L,G,U=o.vertex_coordinate_bytes*3,pa=z+o.nvertices*U;z<pa;z+=U){F=h(a,z);L=h(a,z+o.vertex_coordinate_bytes);G=h(a,z+o.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(u,F,L,G)}return o.nvertices*U}(I);I+=function(z){for(var F,L,G,U=o.normal_coordinate_bytes*3,pa=z+o.nnormals*U;z<pa;z+=U){F=l(a,z);L=l(a,z+o.normal_coordinate_bytes);G=l(a,z+o.normal_coordinate_bytes*2);M.push(F/
-127,L/127,G/127)}return o.nnormals*U}(I);I+=function(z){for(var F,L,G=o.uv_coordinate_bytes*2,U=z+o.nuvs*G;z<U;z+=G){F=h(a,z);L=h(a,z+o.uv_coordinate_bytes);e.push(F,L)}return o.nuvs*G}(I);y=I+y;C=y+C;D=C+D;E=D+E;K=E+K;g=K+g;W=g+W;(function(z){var F,L=o.vertex_index_bytes*3+o.material_index_bytes,G=L+o.uv_index_bytes*3,U=z+o.ntri_flat_uv*G;for(F=z;F<U;F+=G){v(F);B(F+L)}return U-z})(C);(function(z){var F,L=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,G=L+o.uv_index_bytes*3,
-U=z+o.ntri_smooth_uv*G;for(F=z;F<U;F+=G){p(F);B(F+L)}return U-z})(D);(function(z){var F,L=o.vertex_index_bytes*4+o.material_index_bytes,G=L+o.uv_index_bytes*4,U=z+o.nquad_flat_uv*G;for(F=z;F<U;F+=G){q(F);H(F+L)}return U-z})(g);(function(z){var F,L=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,G=L+o.uv_index_bytes*4,U=z+o.nquad_smooth_uv*G;for(F=z;F<U;F+=G){w(F);H(F+L)}return U-z})(W);(function(z){var F,L=o.vertex_index_bytes*3+o.material_index_bytes,G=z+o.ntri_flat*L;for(F=
-z;F<G;F+=L)v(F);return G-z})(I);(function(z){var F,L=o.vertex_index_bytes*3+o.material_index_bytes+o.normal_index_bytes*3,G=z+o.ntri_smooth*L;for(F=z;F<G;F+=L)p(F);return G-z})(y);(function(z){var F,L=o.vertex_index_bytes*4+o.material_index_bytes,G=z+o.nquad_flat*L;for(F=z;F<G;F+=L)q(F);return G-z})(E);(function(z){var F,L=o.vertex_index_bytes*4+o.material_index_bytes+o.normal_index_bytes*4,G=z+o.nquad_smooth*L;for(F=z;F<G;F+=L)w(F);return G-z})(K);this.computeCentroids();this.computeFaceNormals();
-this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))},createModel:function(a,b,c){var d=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,f);(function(){var h,k,j,l,n;h=0;for(k=a.vertices.length;h<k;h+=3){j=a.vertices[h];l=a.vertices[h+1];n=a.vertices[h+2];THREE.Loader.prototype.v(g,j,l,n)}if(a.colors){h=0;for(k=a.colors.length;h<k;h+=3){j=a.colors[h];l=a.colors[h+1];n=a.colors[h+2];THREE.Loader.prototype.vc(g,
-j,l,n)}}})();(function(){function h(w,B){THREE.Loader.prototype.f3(g,w[B],w[B+1],w[B+2],w[B+3])}function k(w,B){THREE.Loader.prototype.f3n(g,a.normals,w[B],w[B+1],w[B+2],w[B+3],w[B+4],w[B+5],w[B+6])}function j(w,B){THREE.Loader.prototype.f4(g,w[B],w[B+1],w[B+2],w[B+3],w[B+4])}function l(w,B){THREE.Loader.prototype.f4n(g,a.normals,w[B],w[B+1],w[B+2],w[B+3],w[B+4],w[B+5],w[B+6],w[B+7],w[B+8])}function n(w,B){var H,u,I,o,M,e,ba,O,P;H=w[B];u=w[B+1];I=w[B+2];o=a.uvs[H*2];ba=a.uvs[H*2+1];M=a.uvs[u*2];O=
-a.uvs[u*2+1];e=a.uvs[I*2];P=a.uvs[I*2+1];THREE.Loader.prototype.uv3(g.uvs,o,ba,M,O,e,P);if(a.uvs2&&a.uvs2.length){o=a.uvs2[H*2];ba=a.uvs2[H*2+1];M=a.uvs2[u*2];O=a.uvs2[u*2+1];e=a.uvs2[I*2];P=a.uvs2[I*2+1];THREE.Loader.prototype.uv3(g.uvs2,o,1-ba,M,1-O,e,1-P)}}function v(w,B){var H,u,I,o,M,e,ba,O,P,V,T,Y;H=w[B];u=w[B+1];I=w[B+2];o=w[B+3];M=a.uvs[H*2];P=a.uvs[H*2+1];e=a.uvs[u*2];V=a.uvs[u*2+1];ba=a.uvs[I*2];T=a.uvs[I*2+1];O=a.uvs[o*2];Y=a.uvs[o*2+1];THREE.Loader.prototype.uv4(g.uvs,M,P,e,V,ba,T,O,Y);
-if(a.uvs2){M=a.uvs2[H*2];P=a.uvs2[H*2+1];e=a.uvs2[u*2];V=a.uvs2[u*2+1];ba=a.uvs2[I*2];T=a.uvs2[I*2+1];O=a.uvs2[o*2];Y=a.uvs2[o*2+1];THREE.Loader.prototype.uv4(g.uvs2,M,1-P,e,1-V,ba,1-T,O,1-Y)}}var p,q;p=0;for(q=a.trianglesUvs.length;p<q;p+=7){h(a.trianglesUvs,p);n(a.trianglesUvs,p+4)}p=0;for(q=a.trianglesNormalsUvs.length;p<q;p+=10){k(a.trianglesNormalsUvs,p);n(a.trianglesNormalsUvs,p+7)}p=0;for(q=a.quadsUvs.length;p<q;p+=9){j(a.quadsUvs,p);v(a.quadsUvs,p+5)}p=0;for(q=a.quadsNormalsUvs.length;p<q;p+=
-13){l(a.quadsNormalsUvs,p);v(a.quadsNormalsUvs,p+9)}p=0;for(q=a.triangles.length;p<q;p+=4)h(a.triangles,p);p=0;for(q=a.trianglesNormals.length;p<q;p+=7)k(a.trianglesNormals,p);p=0;for(q=a.quads.length;p<q;p+=5)j(a.quads,p);p=0;for(q=a.quadsNormals.length;p<q;p+=9)l(a.quadsNormals,p)})();(function(){var h,k,j,l;if(a.skinWeights){h=0;for(k=a.skinWeights.length;h<k;h+=2){j=a.skinWeights[h];l=a.skinWeights[h+1];THREE.Loader.prototype.sw(g,j,l,0,0)}}if(a.skinIndices){h=0;for(k=a.skinIndices.length;h<k;h+=
-2){j=a.skinIndices[h];l=a.skinIndices[h+1];THREE.Loader.prototype.si(g,j,l,0,0)}}THREE.Loader.prototype.bones(g,a.bones);THREE.Loader.prototype.animation(g,a.animation)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;b(new d(c))},bones:function(a,b){a.bones=b},animation:function(a,b){a.animation=b},si:function(a,b,c,d,f){a.skinIndices.push(new THREE.Vector4(b,c,d,f))},sw:function(a,b,c,d,f){a.skinWeights.push(new THREE.Vector4(b,
-c,d,f))},v:function(a,b,c,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,d)))},vc:function(a,b,c,d){var f=new THREE.Color(16777215);f.setRGB(b,c,d);a.colors.push(f)},f3:function(a,b,c,d,f){a.faces.push(new THREE.Face3(b,c,d,null,a.materials[f]))},f4:function(a,b,c,d,f,g){a.faces.push(new THREE.Face4(b,c,d,f,null,a.materials[g]))},f3n:function(a,b,c,d,f,g,h,k,j){g=a.materials[g];var l=b[k*3],n=b[k*3+1];k=b[k*3+2];var v=b[j*3],p=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(c,d,f,[new THREE.Vector3(b[h*
-3],b[h*3+1],b[h*3+2]),new THREE.Vector3(l,n,k),new THREE.Vector3(v,p,j)],g))},f4n:function(a,b,c,d,f,g,h,k,j,l,n){h=a.materials[h];var v=b[j*3],p=b[j*3+1];j=b[j*3+2];var q=b[l*3],w=b[l*3+1];l=b[l*3+2];var B=b[n*3],H=b[n*3+1];n=b[n*3+2];a.faces.push(new THREE.Face4(c,d,f,g,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(v,p,j),new THREE.Vector3(q,w,l),new THREE.Vector3(B,H,n)],h))},uv3:function(a,b,c,d,f,g,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(d,f));k.push(new THREE.UV(g,
-h));a.push(k)},uv4:function(a,b,c,d,f,g,h,k,j){var l=[];l.push(new THREE.UV(b,c));l.push(new THREE.UV(d,f));l.push(new THREE.UV(g,h));l.push(new THREE.UV(k,j));a.push(l)},init_materials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(b[d],c)]},createMaterial:function(a,b){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function d(k,j){var l=new Image;l.onload=function(){if(!c(this.width)||!c(this.height)){var n=Math.pow(2,
-Math.round(Math.log(this.width)/Math.LN2)),v=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));k.image.width=n;k.image.height=v;k.image.getContext("2d").drawImage(this,0,0,n,v)}else k.image=this;k.needsUpdate=!0};l.src=j}var f,g,h;f="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(f="MeshPhongMaterial");if(a.mapDiffuse&&b){h=document.createElement("canvas");g.map=new THREE.Texture(h);d(g.map,b+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=
-(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;g.color=h;g.opacity=a.transparency}else if(a.DbgColor)g.color=a.DbgColor;if(a.mapLightmap&&b){h=document.createElement("canvas");g.lightMap=new THREE.Texture(h);d(g.lightMap,b+"/"+a.mapLightmap)}return new THREE[f](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
+createBinModel:function(a,b,c,d){var f=function(g){function h(y,D){var F=n(y,D),T=n(y,D+1),P=n(y,D+2),fa=n(y,D+3),ka=(fa<<1&255|P>>7)-127;F|=(P&127)<<16|T<<8;if(F==0&&ka==-127)return 0;return(1-2*(fa>>7))*(1+F*Math.pow(2,-23))*Math.pow(2,ka)}function k(y,D){var F=n(y,D),T=n(y,D+1),P=n(y,D+2);return(n(y,D+3)<<24)+(P<<16)+(T<<8)+F}function j(y,D){var F=n(y,D);return(n(y,D+1)<<8)+F}function m(y,D){var F=n(y,D);return F>127?F-256:F}function n(y,D){return y.charCodeAt(D)&255}function w(y){var D,F,T;D=
+k(a,y);F=k(a,y+e);T=k(a,y+O);y=j(a,y+Q);THREE.Loader.prototype.f3(v,D,F,T,y)}function o(y){var D,F,T,P,fa,ka;D=k(a,y);F=k(a,y+e);T=k(a,y+O);P=j(a,y+Q);fa=k(a,y+W);ka=k(a,y+U);y=k(a,y+aa);THREE.Loader.prototype.f3n(v,K,D,F,T,P,fa,ka,y)}function p(y){var D,F,T,P;D=k(a,y);F=k(a,y+ea);T=k(a,y+M);P=k(a,y+X);y=j(a,y+pa);THREE.Loader.prototype.f4(v,D,F,T,P,y)}function x(y){var D,F,T,P,fa,ka,ra,na;D=k(a,y);F=k(a,y+ea);T=k(a,y+M);P=k(a,y+X);fa=j(a,y+pa);ka=k(a,y+ba);ra=k(a,y+la);na=k(a,y+ia);y=k(a,y+ga);THREE.Loader.prototype.f4n(v,
+K,D,F,T,P,fa,ka,ra,na,y)}function A(y){var D,F;D=k(a,y);F=k(a,y+ua);y=k(a,y+xa);THREE.Loader.prototype.uv3(v.uvs,R[D*2],R[D*2+1],R[F*2],R[F*2+1],R[y*2],R[y*2+1])}function I(y){var D,F,T;D=k(a,y);F=k(a,y+l);T=k(a,y+z);y=k(a,y+B);THREE.Loader.prototype.uv4(v.uvs,R[D*2],R[D*2+1],R[F*2],R[F*2+1],R[T*2],R[T*2+1],R[y*2],R[y*2+1])}var v=this,J=0,t,K=[],R=[],e,O,Q,W,U,aa,ea,M,X,pa,ba,la,ia,ga,ua,xa,l,z,B,u,q,E,C,G,H;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(v,d,g);t={signature:a.substr(J,
+8),header_bytes:n(a,J+8),vertex_coordinate_bytes:n(a,J+9),normal_coordinate_bytes:n(a,J+10),uv_coordinate_bytes:n(a,J+11),vertex_index_bytes:n(a,J+12),normal_index_bytes:n(a,J+13),uv_index_bytes:n(a,J+14),material_index_bytes:n(a,J+15),nvertices:k(a,J+16),nnormals:k(a,J+16+4),nuvs:k(a,J+16+8),ntri_flat:k(a,J+16+12),ntri_smooth:k(a,J+16+16),ntri_flat_uv:k(a,J+16+20),ntri_smooth_uv:k(a,J+16+24),nquad_flat:k(a,J+16+28),nquad_smooth:k(a,J+16+32),nquad_flat_uv:k(a,J+16+36),nquad_smooth_uv:k(a,J+16+40)};
+J+=t.header_bytes;e=t.vertex_index_bytes;O=t.vertex_index_bytes*2;Q=t.vertex_index_bytes*3;W=t.vertex_index_bytes*3+t.material_index_bytes;U=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes;aa=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*2;ea=t.vertex_index_bytes;M=t.vertex_index_bytes*2;X=t.vertex_index_bytes*3;pa=t.vertex_index_bytes*4;ba=t.vertex_index_bytes*4+t.material_index_bytes;la=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes;ia=
+t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*2;ga=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*3;ua=t.uv_index_bytes;xa=t.uv_index_bytes*2;l=t.uv_index_bytes;z=t.uv_index_bytes*2;B=t.uv_index_bytes*3;g=t.vertex_index_bytes*3+t.material_index_bytes;H=t.vertex_index_bytes*4+t.material_index_bytes;u=t.ntri_flat*g;q=t.ntri_smooth*(g+t.normal_index_bytes*3);E=t.ntri_flat_uv*(g+t.uv_index_bytes*3);C=t.ntri_smooth_uv*(g+t.normal_index_bytes*3+t.uv_index_bytes*
+3);G=t.nquad_flat*H;g=t.nquad_smooth*(H+t.normal_index_bytes*4);H=t.nquad_flat_uv*(H+t.uv_index_bytes*4);J+=function(y){for(var D,F,T,P=t.vertex_coordinate_bytes*3,fa=y+t.nvertices*P;y<fa;y+=P){D=h(a,y);F=h(a,y+t.vertex_coordinate_bytes);T=h(a,y+t.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(v,D,F,T)}return t.nvertices*P}(J);J+=function(y){for(var D,F,T,P=t.normal_coordinate_bytes*3,fa=y+t.nnormals*P;y<fa;y+=P){D=m(a,y);F=m(a,y+t.normal_coordinate_bytes);T=m(a,y+t.normal_coordinate_bytes*2);
+K.push(D/127,F/127,T/127)}return t.nnormals*P}(J);J+=function(y){for(var D,F,T=t.uv_coordinate_bytes*2,P=y+t.nuvs*T;y<P;y+=T){D=h(a,y);F=h(a,y+t.uv_coordinate_bytes);R.push(D,F)}return t.nuvs*T}(J);u=J+u;q=u+q;E=q+E;C=E+C;G=C+G;g=G+g;H=g+H;(function(y){var D,F=t.vertex_index_bytes*3+t.material_index_bytes,T=F+t.uv_index_bytes*3,P=y+t.ntri_flat_uv*T;for(D=y;D<P;D+=T){w(D);A(D+F)}return P-y})(q);(function(y){var D,F=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,T=F+t.uv_index_bytes*
+3,P=y+t.ntri_smooth_uv*T;for(D=y;D<P;D+=T){o(D);A(D+F)}return P-y})(E);(function(y){var D,F=t.vertex_index_bytes*4+t.material_index_bytes,T=F+t.uv_index_bytes*4,P=y+t.nquad_flat_uv*T;for(D=y;D<P;D+=T){p(D);I(D+F)}return P-y})(g);(function(y){var D,F=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*4,T=F+t.uv_index_bytes*4,P=y+t.nquad_smooth_uv*T;for(D=y;D<P;D+=T){x(D);I(D+F)}return P-y})(H);(function(y){var D,F=t.vertex_index_bytes*3+t.material_index_bytes,T=y+t.ntri_flat*F;for(D=
+y;D<T;D+=F)w(D);return T-y})(J);(function(y){var D,F=t.vertex_index_bytes*3+t.material_index_bytes+t.normal_index_bytes*3,T=y+t.ntri_smooth*F;for(D=y;D<T;D+=F)o(D);return T-y})(u);(function(y){var D,F=t.vertex_index_bytes*4+t.material_index_bytes,T=y+t.nquad_flat*F;for(D=y;D<T;D+=F)p(D);return T-y})(C);(function(y){var D,F=t.vertex_index_bytes*4+t.material_index_bytes+t.normal_index_bytes*4,T=y+t.nquad_smooth*F;for(D=y;D<T;D+=F)x(D);return T-y})(G);this.computeCentroids();this.computeFaceNormals()};
+f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))},createModel:function(a,b,c){var d=function(f){var g=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(g,a.materials,f);(function(){var h,k,j,m,n;h=0;for(k=a.vertices.length;h<k;h+=3){j=a.vertices[h];m=a.vertices[h+1];n=a.vertices[h+2];THREE.Loader.prototype.v(g,j,m,n)}if(a.colors){h=0;for(k=a.colors.length;h<k;h+=3){j=a.colors[h];m=a.colors[h+1];n=a.colors[h+2];THREE.Loader.prototype.vc(g,j,m,n)}}})();(function(){function h(x,
+A){THREE.Loader.prototype.f3(g,x[A],x[A+1],x[A+2],x[A+3])}function k(x,A){THREE.Loader.prototype.f3n(g,a.normals,x[A],x[A+1],x[A+2],x[A+3],x[A+4],x[A+5],x[A+6])}function j(x,A){THREE.Loader.prototype.f4(g,x[A],x[A+1],x[A+2],x[A+3],x[A+4])}function m(x,A){THREE.Loader.prototype.f4n(g,a.normals,x[A],x[A+1],x[A+2],x[A+3],x[A+4],x[A+5],x[A+6],x[A+7],x[A+8])}function n(x,A){var I,v,J,t,K,R,e,O,Q;I=x[A];v=x[A+1];J=x[A+2];t=a.uvs[I*2];e=a.uvs[I*2+1];K=a.uvs[v*2];O=a.uvs[v*2+1];R=a.uvs[J*2];Q=a.uvs[J*2+1];
+THREE.Loader.prototype.uv3(g.uvs,t,e,K,O,R,Q);if(a.uvs2&&a.uvs2.length){t=a.uvs2[I*2];e=a.uvs2[I*2+1];K=a.uvs2[v*2];O=a.uvs2[v*2+1];R=a.uvs2[J*2];Q=a.uvs2[J*2+1];THREE.Loader.prototype.uv3(g.uvs2,t,1-e,K,1-O,R,1-Q)}}function w(x,A){var I,v,J,t,K,R,e,O,Q,W,U,aa;I=x[A];v=x[A+1];J=x[A+2];t=x[A+3];K=a.uvs[I*2];Q=a.uvs[I*2+1];R=a.uvs[v*2];W=a.uvs[v*2+1];e=a.uvs[J*2];U=a.uvs[J*2+1];O=a.uvs[t*2];aa=a.uvs[t*2+1];THREE.Loader.prototype.uv4(g.uvs,K,Q,R,W,e,U,O,aa);if(a.uvs2){K=a.uvs2[I*2];Q=a.uvs2[I*2+1];R=
+a.uvs2[v*2];W=a.uvs2[v*2+1];e=a.uvs2[J*2];U=a.uvs2[J*2+1];O=a.uvs2[t*2];aa=a.uvs2[t*2+1];THREE.Loader.prototype.uv4(g.uvs2,K,1-Q,R,1-W,e,1-U,O,1-aa)}}var o,p;o=0;for(p=a.trianglesUvs.length;o<p;o+=7){h(a.trianglesUvs,o);n(a.trianglesUvs,o+4)}o=0;for(p=a.trianglesNormalsUvs.length;o<p;o+=10){k(a.trianglesNormalsUvs,o);n(a.trianglesNormalsUvs,o+7)}o=0;for(p=a.quadsUvs.length;o<p;o+=9){j(a.quadsUvs,o);w(a.quadsUvs,o+5)}o=0;for(p=a.quadsNormalsUvs.length;o<p;o+=13){m(a.quadsNormalsUvs,o);w(a.quadsNormalsUvs,
+o+9)}o=0;for(p=a.triangles.length;o<p;o+=4)h(a.triangles,o);o=0;for(p=a.trianglesNormals.length;o<p;o+=7)k(a.trianglesNormals,o);o=0;for(p=a.quads.length;o<p;o+=5)j(a.quads,o);o=0;for(p=a.quadsNormals.length;o<p;o+=9)m(a.quadsNormals,o)})();(function(){var h,k,j,m;if(a.skinWeights){h=0;for(k=a.skinWeights.length;h<k;h+=2){j=a.skinWeights[h];m=a.skinWeights[h+1];THREE.Loader.prototype.sw(g,j,m,0,0)}}if(a.skinIndices){h=0;for(k=a.skinIndices.length;h<k;h+=2){j=a.skinIndices[h];m=a.skinIndices[h+1];
+THREE.Loader.prototype.si(g,j,m,0,0)}}THREE.Loader.prototype.bones(g,a.bones);THREE.Loader.prototype.animation(g,a.animation)})();this.computeCentroids();this.computeFaceNormals()};d.prototype=new THREE.Geometry;d.prototype.constructor=d;b(new d(c))},bones:function(a,b){a.bones=b},animation:function(a,b){a.animation=b},si:function(a,b,c,d,f){a.skinIndices.push(new THREE.Vector4(b,c,d,f))},sw:function(a,b,c,d,f){a.skinWeights.push(new THREE.Vector4(b,c,d,f))},v:function(a,b,c,d){a.vertices.push(new THREE.Vertex(new THREE.Vector3(b,
+c,d)))},vc:function(a,b,c,d){var f=new THREE.Color(16777215);f.setRGB(b,c,d);a.colors.push(f)},f3:function(a,b,c,d,f){a.faces.push(new THREE.Face3(b,c,d,null,a.materials[f]))},f4:function(a,b,c,d,f,g){a.faces.push(new THREE.Face4(b,c,d,f,null,a.materials[g]))},f3n:function(a,b,c,d,f,g,h,k,j){g=a.materials[g];var m=b[k*3],n=b[k*3+1];k=b[k*3+2];var w=b[j*3],o=b[j*3+1];j=b[j*3+2];a.faces.push(new THREE.Face3(c,d,f,[new THREE.Vector3(b[h*3],b[h*3+1],b[h*3+2]),new THREE.Vector3(m,n,k),new THREE.Vector3(w,
+o,j)],g))},f4n:function(a,b,c,d,f,g,h,k,j,m,n){h=a.materials[h];var w=b[j*3],o=b[j*3+1];j=b[j*3+2];var p=b[m*3],x=b[m*3+1];m=b[m*3+2];var A=b[n*3],I=b[n*3+1];n=b[n*3+2];a.faces.push(new THREE.Face4(c,d,f,g,[new THREE.Vector3(b[k*3],b[k*3+1],b[k*3+2]),new THREE.Vector3(w,o,j),new THREE.Vector3(p,x,m),new THREE.Vector3(A,I,n)],h))},uv3:function(a,b,c,d,f,g,h){var k=[];k.push(new THREE.UV(b,c));k.push(new THREE.UV(d,f));k.push(new THREE.UV(g,h));a.push(k)},uv4:function(a,b,c,d,f,g,h,k,j){var m=[];m.push(new THREE.UV(b,
+c));m.push(new THREE.UV(d,f));m.push(new THREE.UV(g,h));m.push(new THREE.UV(k,j));a.push(m)},init_materials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=[THREE.Loader.prototype.createMaterial(b[d],c)]},createMaterial:function(a,b){function c(k){k=Math.log(k)/Math.LN2;return Math.floor(k)==k}function d(k,j){var m=new Image;m.onload=function(){if(!c(this.width)||!c(this.height)){var n=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),w=Math.pow(2,Math.round(Math.log(this.height)/
+Math.LN2));k.image.width=n;k.image.height=w;k.image.getContext("2d").drawImage(this,0,0,n,w)}else k.image=this;k.needsUpdate=!0};m.src=j}var f,g,h;f="MeshLambertMaterial";g={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(f="MeshPhongMaterial");if(a.mapDiffuse&&b){h=document.createElement("canvas");g.map=new THREE.Texture(h);d(g.map,b+"/"+a.mapDiffuse)}else if(a.colorDiffuse){h=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*
+255;g.color=h;g.opacity=a.transparency}else if(a.DbgColor)g.color=a.DbgColor;if(a.mapLightmap&&b){h=document.createElement("canvas");g.lightMap=new THREE.Texture(h);d(g.lightMap,b+"/"+a.mapLightmap)}return new THREE[f](g)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};

+ 57 - 58
build/custom/ThreeCanvas.js

@@ -1,6 +1,6 @@
 // ThreeCanvas.js r33 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
-THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,f,h,j,g;if(c==0)d=e=f=0;else{h=Math.floor(a*6);j=a*6-h;a=c*(1-b);g=c*(1-b*j);b=c*(1-b*(1-j));switch(h){case 1:d=g;e=c;f=a;break;case 2:d=a;e=c;f=b;break;case 3:d=a;e=g;f=c;break;case 4:d=b;e=a;f=c;break;case 5:d=c;e=a;f=g;break;case 6:case 0:d=c;e=b;f=a}}this.r=d;this.g=e;this.b=f;if(this.autoUpdate){this.updateHex();
+THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,c){var d,e,f,g,j,h;if(c==0)d=e=f=0;else{g=Math.floor(a*6);j=a*6-g;a=c*(1-b);h=c*(1-b*j);b=c*(1-b*(1-j));switch(g){case 1:d=h;e=c;f=a;break;case 2:d=a;e=c;f=b;break;case 3:d=a;e=h;f=c;break;case 4:d=b;e=a;f=c;break;case 5:d=c;e=a;f=h;break;case 6:case 0:d=c;e=b;f=a}}this.r=d;this.g=e;this.b=f;if(this.autoUpdate){this.updateHex();
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
 THREE.Vector2=function(a,b){this.set(a||0,b||0)};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
@@ -11,61 +11,60 @@ a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-th
 this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,h){return f.distance-h.distance});return e},intersectObject:function(a){function b(r,k,D,C){C=C.clone().subSelf(k);D=D.clone().subSelf(k);var I=r.clone().subSelf(k);r=C.dot(C);k=C.dot(D);C=C.dot(I);var F=D.dot(D);D=D.dot(I);I=1/(r*F-k*k);F=(F*C-k*D)*I;r=(r*D-k*C)*I;return F>0&&r>0&&F+r<1}var c,d,e,f,h,j,g,i,n,l,
-o,q=a.geometry,s=q.vertices,t=[];c=0;for(d=q.faces.length;c<d;c++){e=q.faces[c];l=this.origin.clone();o=this.direction.clone();g=a.matrixWorld;f=g.multiplyVector3(s[e.a].position.clone());h=g.multiplyVector3(s[e.b].position.clone());j=g.multiplyVector3(s[e.c].position.clone());g=e instanceof THREE.Face4?g.multiplyVector3(s[e.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(e.normal.clone());n=o.dot(i);if(n<0){i=i.dot((new THREE.Vector3).sub(f,l))/n;l=l.addSelf(o.multiplyScalar(i));
-if(e instanceof THREE.Face3){if(b(l,f,h,j)){e={distance:this.origin.distanceTo(l),point:l,face:e,object:a};t.push(e)}}else if(e instanceof THREE.Face4&&(b(l,f,h,g)||b(l,h,j,g))){e={distance:this.origin.distanceTo(l),point:l,face:e,object:a};t.push(e)}}}return t}};
-THREE.Rectangle=function(){function a(){f=d-b;h=e-c}var b,c,d,e,f,h,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,i,n,l){j=!1;b=g;c=i;d=n;e=l;a()};this.addPoint=function(g,i){if(j){j=!1;b=g;c=i;d=g;e=i}else{b=b<g?b:g;c=c<i?c:i;d=d>g?d:g;e=e>i?e:i}a()};
-this.add3Points=function(g,i,n,l,o,q){if(j){j=!1;b=g<n?g<o?g:o:n<o?n:o;c=i<l?i<q?i:q:l<q?l:q;d=g>n?g>o?g:o:n>o?n:o;e=i>l?i>q?i:q:l>q?l:q}else{b=g<n?g<o?g<b?g:b:o<b?o:b:n<o?n<b?n:b:o<b?o:b;c=i<l?i<q?i<c?i:c:q<c?q:c:l<q?l<c?l:c:q<c?q:c;d=g>n?g>o?g>d?g:d:o>d?o:d:n>o?n>d?n:d:o>d?o:d;e=i>l?i>q?i>e?i:e:q>e?q:e:l>q?l>e?l:e:q>e?q:e}a()};this.addRectangle=function(g){if(j){j=!1;b=g.getLeft();c=g.getTop();d=g.getRight();e=g.getBottom()}else{b=b<g.getLeft()?b:g.getLeft();c=c<g.getTop()?c:g.getTop();d=d>g.getRight()?
-d:g.getRight();e=e>g.getBottom()?e:g.getBottom()}a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();e=e<g.getBottom()?e:g.getBottom();a()};this.instersects=function(g){return Math.min(d,g.getRight())-Math.max(b,g.getLeft())>=0&&Math.min(e,g.getBottom())-Math.max(c,g.getTop())>=0};this.empty=function(){j=!0;e=d=c=b=0;a()};this.isEmpty=function(){return j}};
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,g){return f.distance-g.distance});return e},intersectObject:function(a){function b(r,k,D,C){C=C.clone().subSelf(k);D=D.clone().subSelf(k);var I=r.clone().subSelf(k);r=C.dot(C);k=C.dot(D);C=C.dot(I);var F=D.dot(D);D=D.dot(I);I=1/(r*F-k*k);F=(F*C-k*D)*I;r=(r*D-k*C)*I;return F>0&&r>0&&F+r<1}var c,d,e,f,g,j,h,i,n,m,
+o,q=a.geometry,s=q.vertices,t=[];c=0;for(d=q.faces.length;c<d;c++){e=q.faces[c];m=this.origin.clone();o=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(s[e.a].position.clone());g=h.multiplyVector3(s[e.b].position.clone());j=h.multiplyVector3(s[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(s[e.d].position.clone()):null;i=a.matrixRotationWorld.multiplyVector3(e.normal.clone());n=o.dot(i);if(n<0){i=i.dot((new THREE.Vector3).sub(f,m))/n;m=m.addSelf(o.multiplyScalar(i));
+if(e instanceof THREE.Face3){if(b(m,f,g,j)){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};t.push(e)}}else if(e instanceof THREE.Face4&&(b(m,f,g,h)||b(m,g,j,h))){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};t.push(e)}}}return t}};
+THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,j=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,i,n,m){j=!1;b=h;c=i;d=n;e=m;a()};this.addPoint=function(h,i){if(j){j=!1;b=h;c=i;d=h;e=i}else{b=b<h?b:h;c=c<i?c:i;d=d>h?d:h;e=e>i?e:i}a()};
+this.add3Points=function(h,i,n,m,o,q){if(j){j=!1;b=h<n?h<o?h:o:n<o?n:o;c=i<m?i<q?i:q:m<q?m:q;d=h>n?h>o?h:o:n>o?n:o;e=i>m?i>q?i:q:m>q?m:q}else{b=h<n?h<o?h<b?h:b:o<b?o:b:n<o?n<b?n:b:o<b?o:b;c=i<m?i<q?i<c?i:c:q<c?q:c:m<q?m<c?m:c:q<c?q:c;d=h>n?h>o?h>d?h:d:o>d?o:d:n>o?n>d?n:d:o>d?o:d;e=i>m?i>q?i>e?i:e:q>e?q:e:m>q?m>e?m:e:q>e?q:e}a()};this.addRectangle=function(h){if(j){j=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
+d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d<h.getRight()?d:h.getRight();e=e<h.getBottom()?e:h.getBottom();a()};this.instersects=function(h){return Math.min(d,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){j=!0;e=d=c=b=0;a()};this.isEmpty=function(){return j}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,d,e,f,h,j,g,i,n,l,o,q,s,t){this.set(a||1,b||0,c||0,d||0,e||0,f||1,h||0,j||0,g||0,i||0,n||1,l||0,o||0,q||0,s||0,t||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,h,j,g,i,n,l,o,q,s,t){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=h;this.n24=j;this.n31=g;this.n32=i;this.n33=n;this.n34=l;this.n41=o;this.n42=q;this.n43=s;this.n44=t;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,
+THREE.Matrix4=function(a,b,c,d,e,f,g,j,h,i,n,m,o,q,s,t){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,j||0,h||0,i||0,n||1,m||0,o||0,q||0,s||0,t||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,j,h,i,n,m,o,q,s,t){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=j;this.n31=h;this.n32=i;this.n33=n;this.n34=m;this.n41=o;this.n42=q;this.n43=s;this.n44=t;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,
 e=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n14=a.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n24=a.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*
 b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},crossVector:function(a){var b=new THREE.Vector4;
-b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,h=a.n21,j=a.n22,g=a.n23,i=a.n24,n=a.n31,l=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,r=a.n43,k=a.n44,D=b.n11,C=b.n12,I=b.n13,F=b.n14,N=b.n21,A=b.n22,w=b.n23,J=b.n24,u=b.n31,K=b.n32,E=b.n33,y=b.n34;this.n11=c*
-D+d*N+e*u;this.n12=c*C+d*A+e*K;this.n13=c*I+d*w+e*E;this.n14=c*F+d*J+e*y+f;this.n21=h*D+j*N+g*u;this.n22=h*C+j*A+g*K;this.n23=h*I+j*w+g*E;this.n24=h*F+j*J+g*y+i;this.n31=n*D+l*N+o*u;this.n32=n*C+l*A+o*K;this.n33=n*I+l*w+o*E;this.n34=n*F+l*J+o*y+q;this.n41=s*D+t*N+r*u;this.n42=s*C+t*A+r*K;this.n43=s*I+t*w+r*E;this.n44=s*F+t*J+r*y+k;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,h=a.n14,j=a.n21,g=a.n22,i=a.n23,n=a.n24,l=a.n31,o=a.n32,q=a.n33,s=a.n34,t=a.n41,r=a.n42,k=a.n43;
-a=a.n44;var D=b.n11,C=b.n12,I=b.n13,F=b.n14,N=b.n21,A=b.n22,w=b.n23,J=b.n24,u=b.n31,K=b.n32,E=b.n33,y=b.n34,B=b.n41,T=b.n42,x=b.n43;b=b.n44;this.n11=d*D+e*N+f*u+h*B;this.n12=d*C+e*A+f*K+h*T;this.n13=d*I+e*w+f*E+h*x;this.n14=d*F+e*J+f*y+h*b;this.n21=j*D+g*N+i*u+n*B;this.n22=j*C+g*A+i*K+n*T;this.n23=j*I+g*w+i*E+n*x;this.n24=j*F+g*J+i*y+n*b;this.n31=l*D+o*N+q*u+s*B;this.n32=l*C+o*A+q*K+s*T;this.n33=l*I+o*w+q*E+s*x;this.n34=l*F+o*J+q*y+s*b;this.n41=t*D+r*N+k*u+a*B;this.n42=t*C+r*A+k*K+a*T;this.n43=t*
-I+r*w+k*E+a*x;this.n44=t*F+r*J+k*y+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,h=this.n22,j=this.n23,g=this.n24,i=this.n31,n=this.n32,l=this.n33,o=this.n34,q=this.n41,s=this.n42,t=this.n43,r=this.n44,k=a.n11,D=a.n21,
-C=a.n31,I=a.n12,F=a.n22,N=a.n32,A=a.n13,w=a.n23,J=a.n33,u=a.n14,K=a.n24;a=a.n34;this.n11=b*k+c*D+d*C;this.n12=b*I+c*F+d*N;this.n13=b*A+c*w+d*J;this.n14=b*u+c*K+d*a+e;this.n21=f*k+h*D+j*C;this.n22=f*I+h*F+j*N;this.n23=f*A+h*w+j*J;this.n24=f*u+h*K+j*a+g;this.n31=i*k+n*D+l*C;this.n32=i*I+n*F+l*N;this.n33=i*A+n*w+l*J;this.n34=i*u+n*K+l*a+o;this.n41=q*k+s*D+t*C;this.n42=q*I+s*F+t*N;this.n43=q*A+s*w+t*J;this.n44=q*u+s*K+t*a+r;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=
-a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,h=this.n23,j=this.n24,g=this.n31,i=this.n32,n=this.n33,l=this.n34,o=this.n41,q=this.n42,s=this.n43,t=this.n44;return d*h*i*o-c*j*i*o-d*f*n*o+b*j*n*o+c*f*l*o-b*h*l*o-d*h*g*q+c*j*g*q+d*e*n*q-a*j*n*q-c*e*l*q+a*h*l*q+d*f*g*s-b*j*g*s-d*e*i*s+a*j*i*s+b*e*
-l*s-a*f*l*s-c*f*g*t+b*h*g*t+c*e*i*t-a*h*i*t-b*e*n*t+a*f*n*t},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;
+b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,n=a.n31,m=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,r=a.n43,k=a.n44,D=b.n11,C=b.n12,I=b.n13,F=b.n14,N=b.n21,A=b.n22,w=b.n23,J=b.n24,u=b.n31,K=b.n32,E=b.n33,y=b.n34;this.n11=c*
+D+d*N+e*u;this.n12=c*C+d*A+e*K;this.n13=c*I+d*w+e*E;this.n14=c*F+d*J+e*y+f;this.n21=g*D+j*N+h*u;this.n22=g*C+j*A+h*K;this.n23=g*I+j*w+h*E;this.n24=g*F+j*J+h*y+i;this.n31=n*D+m*N+o*u;this.n32=n*C+m*A+o*K;this.n33=n*I+m*w+o*E;this.n34=n*F+m*J+o*y+q;this.n41=s*D+t*N+r*u;this.n42=s*C+t*A+r*K;this.n43=s*I+t*w+r*E;this.n44=s*F+t*J+r*y+k;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,g=a.n14,j=a.n21,h=a.n22,i=a.n23,n=a.n24,m=a.n31,o=a.n32,q=a.n33,s=a.n34,t=a.n41,r=a.n42,k=a.n43;
+a=a.n44;var D=b.n11,C=b.n12,I=b.n13,F=b.n14,N=b.n21,A=b.n22,w=b.n23,J=b.n24,u=b.n31,K=b.n32,E=b.n33,y=b.n34,B=b.n41,T=b.n42,x=b.n43;b=b.n44;this.n11=d*D+e*N+f*u+g*B;this.n12=d*C+e*A+f*K+g*T;this.n13=d*I+e*w+f*E+g*x;this.n14=d*F+e*J+f*y+g*b;this.n21=j*D+h*N+i*u+n*B;this.n22=j*C+h*A+i*K+n*T;this.n23=j*I+h*w+i*E+n*x;this.n24=j*F+h*J+i*y+n*b;this.n31=m*D+o*N+q*u+s*B;this.n32=m*C+o*A+q*K+s*T;this.n33=m*I+o*w+q*E+s*x;this.n34=m*F+o*J+q*y+s*b;this.n41=t*D+r*N+k*u+a*B;this.n42=t*C+r*A+k*K+a*T;this.n43=t*
+I+r*w+k*E+a*x;this.n44=t*F+r*J+k*y+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,g=this.n22,j=this.n23,h=this.n24,i=this.n31,n=this.n32,m=this.n33,o=this.n34,q=this.n41,s=this.n42,t=this.n43,r=this.n44,k=a.n11,D=a.n21,
+C=a.n31,I=a.n12,F=a.n22,N=a.n32,A=a.n13,w=a.n23,J=a.n33,u=a.n14,K=a.n24;a=a.n34;this.n11=b*k+c*D+d*C;this.n12=b*I+c*F+d*N;this.n13=b*A+c*w+d*J;this.n14=b*u+c*K+d*a+e;this.n21=f*k+g*D+j*C;this.n22=f*I+g*F+j*N;this.n23=f*A+g*w+j*J;this.n24=f*u+g*K+j*a+h;this.n31=i*k+n*D+m*C;this.n32=i*I+n*F+m*N;this.n33=i*A+n*w+m*J;this.n34=i*u+n*K+m*a+o;this.n41=q*k+s*D+t*C;this.n42=q*I+s*F+t*N;this.n43=q*A+s*w+t*J;this.n44=q*u+s*K+t*a+r;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=
+a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,j=this.n24,h=this.n31,i=this.n32,n=this.n33,m=this.n34,o=this.n41,q=this.n42,s=this.n43,t=this.n44;return d*g*i*o-c*j*i*o-d*f*n*o+b*j*n*o+c*f*m*o-b*g*m*o-d*g*h*q+c*j*h*q+d*e*n*q-a*j*n*q-c*e*m*q+a*g*m*q+d*f*h*s-b*j*h*s-d*e*i*s+a*j*i*s+b*e*
+m*s-a*f*m*s-c*f*h*t+b*g*h*t+c*e*i*t-a*g*i*t-b*e*n*t+a*f*n*t},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;
 a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flattenToArray(this.flat);return this.flat},flattenToArray:function(a){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},flattenToArrayOffset:function(a,b){a[b]=
 this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,
-b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,h=a.y,j=a.z,g=e*f,i=e*h;this.set(g*f+c,g*h-d*j,g*j+d*h,0,g*h+d*j,i*h+c,i*j-d*f,0,g*j-d*h,i*j+d*f,e*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;
-this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var h=a*c,j=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=j*f+a*d;this.n22=-j*d+a*f;this.n23=-b*e;this.n31=-h*f+b*d;this.n32=h*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,h=c+c,j=d+d;a=b*f;var g=b*h;b*=j;var i=c*h;c*=j;d*=j;f*=e;h*=e;e*=j;this.n11=1-(i+d);this.n12=g-e;this.n13=
-b+h;this.n21=g+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-h;this.n32=c+f;this.n33=1-(a+i)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};
+b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,j=a.z,h=e*f,i=e*g;this.set(h*f+c,h*g-d*j,h*j+d*g,0,h*g+d*j,i*g+c,i*j-d*f,0,h*j-d*g,i*j+d*f,e*j*j+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;
+this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,j=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=j*f+a*d;this.n22=-j*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,j=d+d;a=b*f;var h=b*g;b*=j;var i=c*g;c*=j;d*=j;f*=e;g*=e;e*=j;this.n11=1-(i+d);this.n12=h-e;this.n13=
+b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+i)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};
 THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,h=a.n21,j=a.n22,g=a.n23,i=a.n24,n=a.n31,l=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,r=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=g*q*t-i*o*t+i*l*r-j*q*r-g*l*k+j*o*k;b.n12=f*o*t-e*q*t-f*l*r+d*q*r+e*l*k-d*o*k;b.n13=e*i*t-f*g*t+f*j*r-d*i*r-e*j*k+d*g*k;b.n14=f*g*l-e*i*l-f*j*o+d*i*o+e*j*q-d*g*q;b.n21=i*o*s-g*q*s-i*n*r+h*q*r+g*n*k-h*o*k;b.n22=e*q*s-f*o*s+f*n*r-c*q*r-e*n*k+c*o*k;b.n23=f*g*s-e*i*s-f*h*r+c*i*r+e*h*k-c*g*k;
-b.n24=e*i*n-f*g*n+f*h*o-c*i*o-e*h*q+c*g*q;b.n31=j*q*s-i*l*s+i*n*t-h*q*t-j*n*k+h*l*k;b.n32=f*l*s-d*q*s-f*n*t+c*q*t+d*n*k-c*l*k;b.n33=e*i*s-f*j*s+f*h*t-c*i*t-d*h*k+c*j*k;b.n34=f*j*n-d*i*n-f*h*l+c*i*l+d*h*q-c*j*q;b.n41=g*l*s-j*o*s-g*n*t+h*o*t+j*n*r-h*l*r;b.n42=d*o*s-e*l*s+e*n*t-c*o*t-d*n*r+c*l*r;b.n43=e*j*s-d*g*s-e*h*t+c*g*t+d*h*r-c*j*r;b.n44=d*g*n-e*j*n+e*h*l-c*g*l-d*h*o+c*j*o;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,g=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,l=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*h+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*h;c[4]=a*j;c[5]=a*g;c[6]=a*i;c[7]=a*n;c[8]=a*l;return b};
-THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var h;h=new THREE.Matrix4;h.n11=2*e/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*e/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(f+e)/(f-e);h.n34=-2*f*e/(f-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var h,j,g,i;h=new THREE.Matrix4;j=b-a;g=c-d;i=f-e;h.n11=2/j;h.n12=0;h.n13=0;h.n14=-((b+a)/j);h.n21=0;h.n22=2/g;h.n23=0;h.n24=-((c+d)/g);h.n31=0;h.n32=0;h.n33=-2/i;h.n34=-((f+e)/i);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,j=a.n22,h=a.n23,i=a.n24,n=a.n31,m=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,r=a.n43,k=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*q*t-i*o*t+i*m*r-j*q*r-h*m*k+j*o*k;b.n12=f*o*t-e*q*t-f*m*r+d*q*r+e*m*k-d*o*k;b.n13=e*i*t-f*h*t+f*j*r-d*i*r-e*j*k+d*h*k;b.n14=f*h*m-e*i*m-f*j*o+d*i*o+e*j*q-d*h*q;b.n21=i*o*s-h*q*s-i*n*r+g*q*r+h*n*k-g*o*k;b.n22=e*q*s-f*o*s+f*n*r-c*q*r-e*n*k+c*o*k;b.n23=f*h*s-e*i*s-f*g*r+c*i*r+e*g*k-c*h*k;
+b.n24=e*i*n-f*h*n+f*g*o-c*i*o-e*g*q+c*h*q;b.n31=j*q*s-i*m*s+i*n*t-g*q*t-j*n*k+g*m*k;b.n32=f*m*s-d*q*s-f*n*t+c*q*t+d*n*k-c*m*k;b.n33=e*i*s-f*j*s+f*g*t-c*i*t-d*g*k+c*j*k;b.n34=f*j*n-d*i*n-f*g*m+c*i*m+d*g*q-c*j*q;b.n41=h*m*s-j*o*s-h*n*t+g*o*t+j*n*r-g*m*r;b.n42=d*o*s-e*m*s+e*n*t-c*o*t-d*n*r+c*m*r;b.n43=e*j*s-d*h*s-e*g*t+c*h*t+d*g*r-c*j*r;b.n44=d*h*n-e*j*n+e*g*m-c*h*m-d*g*o+c*j*o;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,j=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*i;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*j;c[5]=a*h;c[6]=a*i;c[7]=a*n;c[8]=a*m;return b};
+THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
+THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,j,h,i;g=new THREE.Matrix4;j=b-a;h=c-d;i=f-e;g.n11=2/j;g.n12=0;g.n13=0;g.n14=-((b+a)/j);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/i;g.n34=-((f+e)/i);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.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;
 this.visible=!0};
 THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);
 if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0},update:function(a,b,c){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var d=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21=
 this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*d;this.matrixRotationWorld.n23=this.matrixWorld.n23*d;this.matrixRotationWorld.n33=this.matrixWorld.n33*d;this.matrixNeedsUpdate=!1;b=!0}a=0;for(d=this.children.length;a<d;a++)this.children[a].update(this.matrixWorld,b,c)}}};
 THREE.Object3DCounter={value:0};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
-THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var f=Math.cos(c);c=Math.sin(c);var h=a*b,j=d*e;this.w=h*f-j*c;this.x=h*c+j*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
--1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,h=a.y,j=a.z;a=a.w;this.x=b*a+e*f+c*j-d*h;this.y=c*a+e*h+d*f-b*j;this.z=d*a+e*j+b*h-c*f;this.w=e*a-b*f-c*h-d*j;return this},
-multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,h=this.y,j=this.z,g=this.w,i=g*c+h*e-j*d,n=g*d+j*c-f*e,l=g*e+f*d-h*c;c=-f*c-h*d-j*e;b.x=i*g+c*-f+n*-j-l*-h;b.y=n*g+c*-h+l*-f-i*-j;b.z=l*g+c*-j+i*-h-n*-f;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),h=Math.sqrt(1-e*e);if(Math.abs(h)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*f)/h;d=Math.sin(d*f)/h;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
+THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var f=Math.cos(c);c=Math.sin(c);var g=a*b,j=d*e;this.w=g*f-j*c;this.x=g*c+j*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
+-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,j=a.z;a=a.w;this.x=b*a+e*f+c*j-d*g;this.y=c*a+e*g+d*f-b*j;this.z=d*a+e*j+b*g-c*f;this.w=e*a-b*f-c*g-d*j;return this},
+multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,j=this.z,h=this.w,i=h*c+g*e-j*d,n=h*d+j*c-f*e,m=h*e+f*d-g*c;c=-f*c-g*d-j*e;b.x=i*h+c*-f+n*-j-m*-g;b.y=n*h+c*-g+m*-f-i*-j;b.z=m*h+c*-j+i*-g-n*-f;return b}};
+THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),g=Math.sqrt(1-e*e);if(Math.abs(g)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*f)/g;d=Math.sin(d*f)/g;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};
 THREE.Face3=function(a,b,c,d,e){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};
-THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=!1};
+THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
-c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,f,h,j=new THREE.Vector3,g=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){f=this.vertices[d];f.normal.set(0,0,0)}d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];if(a&&f.vertexNormals.length){j.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)j.addSelf(f.vertexNormals[b]);j.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];h=this.vertices[f.c];j.sub(h.position,
-c.position);g.sub(b.position,c.position);j.crossSelf(g)}j.isZero()||j.normalize();f.normal.copy(j)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
+c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,f,g,j=new THREE.Vector3,h=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){f=this.vertices[d];f.normal.set(0,0,0)}d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];if(a&&f.vertexNormals.length){j.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)j.addSelf(f.vertexNormals[b]);j.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];g=this.vertices[f.c];j.sub(g.position,
+c.position);h.sub(b.position,c.position);j.crossSelf(h)}j.isZero()||j.normalize();f.normal.copy(j)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<
-b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(y,B,T,x,P,Y,L){f=y.vertices[B].position;h=y.vertices[T].position;j=y.vertices[x].position;g=e[P];i=e[Y];n=e[L];l=h.x-f.x;o=j.x-f.x;q=h.y-f.y;s=j.y-f.y;
-t=h.z-f.z;r=j.z-f.z;k=i.u-g.u;D=n.u-g.u;C=i.v-g.v;I=n.v-g.v;F=1/(k*I-D*C);w.set((I*l-C*o)*F,(I*q-C*s)*F,(I*t-C*r)*F);J.set((k*o-D*l)*F,(k*s-D*q)*F,(k*r-D*t)*F);N[B].addSelf(w);N[T].addSelf(w);N[x].addSelf(w);A[B].addSelf(J);A[T].addSelf(J);A[x].addSelf(J)}var b,c,d,e,f,h,j,g,i,n,l,o,q,s,t,r,k,D,C,I,F,N=[],A=[],w=new THREE.Vector3,J=new THREE.Vector3,u=new THREE.Vector3,K=new THREE.Vector3,E=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){N[b]=new THREE.Vector3;A[b]=new THREE.Vector3}b=0;
+b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(y,B,T,x,P,Y,L){f=y.vertices[B].position;g=y.vertices[T].position;j=y.vertices[x].position;h=e[P];i=e[Y];n=e[L];m=g.x-f.x;o=j.x-f.x;q=g.y-f.y;s=j.y-f.y;
+t=g.z-f.z;r=j.z-f.z;k=i.u-h.u;D=n.u-h.u;C=i.v-h.v;I=n.v-h.v;F=1/(k*I-D*C);w.set((I*m-C*o)*F,(I*q-C*s)*F,(I*t-C*r)*F);J.set((k*o-D*m)*F,(k*s-D*q)*F,(k*r-D*t)*F);N[B].addSelf(w);N[T].addSelf(w);N[x].addSelf(w);A[B].addSelf(J);A[T].addSelf(J);A[x].addSelf(J)}var b,c,d,e,f,g,j,h,i,n,m,o,q,s,t,r,k,D,C,I,F,N=[],A=[],w=new THREE.Vector3,J=new THREE.Vector3,u=new THREE.Vector3,K=new THREE.Vector3,E=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){N[b]=new THREE.Vector3;A[b]=new THREE.Vector3}b=0;
 for(c=this.faces.length;b<c;b++){d=this.faces[b];e=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
 this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){E.copy(this.vertices[b].normal);d=N[b];u.copy(d);u.subSelf(E.multiplyScalar(E.dot(d))).normalize();K.cross(this.vertices[b].normal,d);d=K.dot(A[b]);d=d<0?-1:1;this.vertices[b].tangent.set(u.x,u.y,u.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var l=[];b=0;for(c=n.length;b<c;b++)n[b]==undefined?l.push("undefined"):l.push(n[b].id);return l.join("_")}var b,c,d,e,f,h,j,g,i={};d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];
-h=f.materials;j=a(h);i[j]==undefined&&(i[j]={hash:j,counter:0});g=i[j].hash+"_"+i[j].counter;this.geometryChunks[g]==undefined&&(this.geometryChunks[g]={faces:[],materials:h,vertices:0});f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[g].vertices+f>65535){i[j].counter+=1;g=i[j].hash+"_"+i[j].counter;this.geometryChunks[g]==undefined&&(this.geometryChunks[g]={faces:[],materials:h,vertices:0})}this.geometryChunks[g].faces.push(d);this.geometryChunks[g].vertices+=f}}};THREE.GeometryIdCounter=0;
-THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(f,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);if(h)this.tmpVec.y=0;this.position.addSelf(this.tmpVec);
-this.target.position.addSelf(this.tmpVec)};this.translateZ=function(f,h){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);if(h)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
+THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);if(g)this.tmpVec.y=0;this.position.addSelf(this.tmpVec);
+this.target.position.addSelf(this.tmpVec)};this.translateZ=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);if(g)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
 THREE.Camera.prototype.update=function(a,b,c){if(this.useTarget){this.matrix.lookAt(this.position,this.target.position,this.up);a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);THREE.Matrix4.makeInvert(this.matrixWorld,this.matrixWorldInverse);b=!0}else{this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixNeedsUpdate=!1;b=!0;THREE.Matrix4.makeInvert(this.matrixWorld,
 this.matrixWorldInverse)}}for(a=0;a<this.children.length;a++)this.children[a].update(this.matrixWorld,b,c)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
@@ -105,36 +104,36 @@ THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(A,w){return w.z-A.z}function b(A,w){var J=0,u=1,K=A.z+A.w,E=w.z+w.w,y=-A.z+A.w,B=-w.z+w.w;if(K>=0&&E>=0&&y>=0&&B>=0)return!0;else if(K<0&&E<0||y<0&&B<0)return!1;else{if(K<0)J=Math.max(J,K/(K-E));else E<0&&(u=Math.min(u,K/(K-E)));if(y<0)J=Math.max(J,y/(y-B));else B<0&&(u=Math.min(u,y/(y-B)));if(u<J)return!1;else{A.lerpSelf(w,J);w.lerpSelf(A,1-u);return!0}}}var c,d,e=[],f,h,j,g=[],i,n,l=[],o,q,s=[],t=new THREE.Vector4,r=new THREE.Vector4,k=new THREE.Matrix4,D=new THREE.Matrix4,
+THREE.Projector=function(){function a(A,w){return w.z-A.z}function b(A,w){var J=0,u=1,K=A.z+A.w,E=w.z+w.w,y=-A.z+A.w,B=-w.z+w.w;if(K>=0&&E>=0&&y>=0&&B>=0)return!0;else if(K<0&&E<0||y<0&&B<0)return!1;else{if(K<0)J=Math.max(J,K/(K-E));else E<0&&(u=Math.min(u,K/(K-E)));if(y<0)J=Math.max(J,y/(y-B));else B<0&&(u=Math.min(u,y/(y-B)));if(u<J)return!1;else{A.lerpSelf(w,J);w.lerpSelf(A,1-u);return!0}}}var c,d,e=[],f,g,j,h=[],i,n,m=[],o,q,s=[],t=new THREE.Vector4,r=new THREE.Vector4,k=new THREE.Matrix4,D=new THREE.Matrix4,
 C=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],I=new THREE.Vector4,F=new THREE.Vector4,N;this.projectObjects=function(A,w,J){w=[];var u,K,E;d=0;K=A.objects;A=0;for(u=K.length;A<u;A++){E=K[A];var y;if(!(y=!E.visible))if(y=E instanceof THREE.Mesh){a:{y=void 0;for(var B=E.matrixWorld,T=-E.geometry.boundingSphere.radius*Math.max(E.scale.x,Math.max(E.scale.y,E.scale.z)),x=0;x<6;x++){y=C[x].x*B.n14+C[x].y*B.n24+C[x].z*B.n34+C[x].w;if(y<=T){y=
 !1;break a}}y=!0}y=!y}if(!y){c=e[d]=e[d]||new THREE.RenderableObject;t.copy(E.position);k.multiplyVector3(t);c.object=E;c.z=t.z;w.push(c);d++}}J&&w.sort(a);return w};this.projectScene=function(A,w,J){var u=[],K=w.near,E=w.far,y,B,T,x,P,Y,L,ja,ka,la,ma,$,O,H,U,Q;j=n=q=0;w.matrixAutoUpdate&&w.update();k.multiply(w.projectionMatrix,w.matrixWorldInverse);C[0].set(k.n41-k.n11,k.n42-k.n12,k.n43-k.n13,k.n44-k.n14);C[1].set(k.n41+k.n11,k.n42+k.n12,k.n43+k.n13,k.n44+k.n14);C[2].set(k.n41+k.n21,k.n42+k.n22,
 k.n43+k.n23,k.n44+k.n24);C[3].set(k.n41-k.n21,k.n42-k.n22,k.n43-k.n23,k.n44-k.n24);C[4].set(k.n41-k.n31,k.n42-k.n32,k.n43-k.n33,k.n44-k.n34);C[5].set(k.n41+k.n31,k.n42+k.n32,k.n43+k.n33,k.n44+k.n34);for(y=0;y<6;y++){Y=C[y];Y.divideScalar(Math.sqrt(Y.x*Y.x+Y.y*Y.y+Y.z*Y.z))}A.update(undefined,!1,w);Y=this.projectObjects(A,w,!0);A=0;for(y=Y.length;A<y;A++){L=Y[A].object;if(L.visible){ja=L.matrixWorld;ma=L.matrixRotationWorld;ka=L.materials;la=L.overdraw;if(L instanceof THREE.Mesh){$=L.geometry;O=$.vertices;
 B=0;for(T=O.length;B<T;B++){H=O[B];H.positionWorld.copy(H.position);ja.multiplyVector3(H.positionWorld);x=H.positionScreen;x.copy(H.positionWorld);k.multiplyVector4(x);x.x/=x.w;x.y/=x.w;H.__visible=x.z>K&&x.z<E}$=$.faces;B=0;for(T=$.length;B<T;B++){H=$[B];if(H instanceof THREE.Face3){x=O[H.a];P=O[H.b];U=O[H.c];if(x.__visible&&P.__visible&&U.__visible&&(L.doubleSided||L.flipSided!=(U.positionScreen.x-x.positionScreen.x)*(P.positionScreen.y-x.positionScreen.y)-(U.positionScreen.y-x.positionScreen.y)*
-(P.positionScreen.x-x.positionScreen.x)<0)){f=g[j]=g[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(x.positionWorld);f.v2.positionWorld.copy(P.positionWorld);f.v3.positionWorld.copy(U.positionWorld);f.v1.positionScreen.copy(x.positionScreen);f.v2.positionScreen.copy(P.positionScreen);f.v3.positionScreen.copy(U.positionScreen);f.normalWorld.copy(H.normal);ma.multiplyVector3(f.normalWorld);f.centroidWorld.copy(H.centroid);ja.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);
+(P.positionScreen.x-x.positionScreen.x)<0)){f=h[j]=h[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(x.positionWorld);f.v2.positionWorld.copy(P.positionWorld);f.v3.positionWorld.copy(U.positionWorld);f.v1.positionScreen.copy(x.positionScreen);f.v2.positionScreen.copy(P.positionScreen);f.v3.positionScreen.copy(U.positionScreen);f.normalWorld.copy(H.normal);ma.multiplyVector3(f.normalWorld);f.centroidWorld.copy(H.centroid);ja.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);
 k.multiplyVector3(f.centroidScreen);U=H.vertexNormals;N=f.vertexNormalsWorld;x=0;for(P=U.length;x<P;x++){Q=N[x]=N[x]||new THREE.Vector3;Q.copy(U[x]);ma.multiplyVector3(Q)}f.z=f.centroidScreen.z;f.meshMaterials=ka;f.faceMaterials=H.materials;f.overdraw=la;if(L.geometry.uvs[B]){f.uvs[0]=L.geometry.uvs[B][0];f.uvs[1]=L.geometry.uvs[B][1];f.uvs[2]=L.geometry.uvs[B][2]}u.push(f);j++}}else if(H instanceof THREE.Face4){x=O[H.a];P=O[H.b];U=O[H.c];Q=O[H.d];if(x.__visible&&P.__visible&&U.__visible&&Q.__visible&&
-(L.doubleSided||L.flipSided!=((Q.positionScreen.x-x.positionScreen.x)*(P.positionScreen.y-x.positionScreen.y)-(Q.positionScreen.y-x.positionScreen.y)*(P.positionScreen.x-x.positionScreen.x)<0||(P.positionScreen.x-U.positionScreen.x)*(Q.positionScreen.y-U.positionScreen.y)-(P.positionScreen.y-U.positionScreen.y)*(Q.positionScreen.x-U.positionScreen.x)<0))){f=g[j]=g[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(x.positionWorld);f.v2.positionWorld.copy(P.positionWorld);f.v3.positionWorld.copy(Q.positionWorld);
+(L.doubleSided||L.flipSided!=((Q.positionScreen.x-x.positionScreen.x)*(P.positionScreen.y-x.positionScreen.y)-(Q.positionScreen.y-x.positionScreen.y)*(P.positionScreen.x-x.positionScreen.x)<0||(P.positionScreen.x-U.positionScreen.x)*(Q.positionScreen.y-U.positionScreen.y)-(P.positionScreen.y-U.positionScreen.y)*(Q.positionScreen.x-U.positionScreen.x)<0))){f=h[j]=h[j]||new THREE.RenderableFace3;f.v1.positionWorld.copy(x.positionWorld);f.v2.positionWorld.copy(P.positionWorld);f.v3.positionWorld.copy(Q.positionWorld);
 f.v1.positionScreen.copy(x.positionScreen);f.v2.positionScreen.copy(P.positionScreen);f.v3.positionScreen.copy(Q.positionScreen);f.normalWorld.copy(H.normal);ma.multiplyVector3(f.normalWorld);f.centroidWorld.copy(H.centroid);ja.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);k.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=ka;f.faceMaterials=H.materials;f.overdraw=la;if(L.geometry.uvs[B]){f.uvs[0]=L.geometry.uvs[B][0];f.uvs[1]=L.geometry.uvs[B][1];
-f.uvs[2]=L.geometry.uvs[B][3]}u.push(f);j++;h=g[j]=g[j]||new THREE.RenderableFace3;h.v1.positionWorld.copy(P.positionWorld);h.v2.positionWorld.copy(U.positionWorld);h.v3.positionWorld.copy(Q.positionWorld);h.v1.positionScreen.copy(P.positionScreen);h.v2.positionScreen.copy(U.positionScreen);h.v3.positionScreen.copy(Q.positionScreen);h.normalWorld.copy(f.normalWorld);h.centroidWorld.copy(f.centroidWorld);h.centroidScreen.copy(f.centroidScreen);h.z=h.centroidScreen.z;h.meshMaterials=ka;h.faceMaterials=
-H.materials;h.overdraw=la;if(L.geometry.uvs[B]){h.uvs[0]=L.geometry.uvs[B][1];h.uvs[1]=L.geometry.uvs[B][2];h.uvs[2]=L.geometry.uvs[B][3]}u.push(h);j++}}}}else if(L instanceof THREE.Line){D.multiply(k,ja);O=L.geometry.vertices;H=O[0];H.positionScreen.copy(H.position);D.multiplyVector4(H.positionScreen);B=1;for(T=O.length;B<T;B++){x=O[B];x.positionScreen.copy(x.position);D.multiplyVector4(x.positionScreen);P=O[B-1];I.copy(x.positionScreen);F.copy(P.positionScreen);if(b(I,F)){I.multiplyScalar(1/I.w);
-F.multiplyScalar(1/F.w);i=l[n]=l[n]||new THREE.RenderableLine;i.v1.positionScreen.copy(I);i.v2.positionScreen.copy(F);i.z=Math.max(I.z,F.z);i.materials=L.materials;u.push(i);n++}}}else if(L instanceof THREE.Particle){r.set(L.position.x,L.position.y,L.position.z,1);k.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){o=s[q]=s[q]||new THREE.RenderableParticle;o.x=r.x/r.w;o.y=r.y/r.w;o.z=r.z;o.rotation=L.rotation.z;o.scale.x=L.scale.x*Math.abs(o.x-(r.x+w.projectionMatrix.n11)/(r.w+w.projectionMatrix.n14));
+f.uvs[2]=L.geometry.uvs[B][3]}u.push(f);j++;g=h[j]=h[j]||new THREE.RenderableFace3;g.v1.positionWorld.copy(P.positionWorld);g.v2.positionWorld.copy(U.positionWorld);g.v3.positionWorld.copy(Q.positionWorld);g.v1.positionScreen.copy(P.positionScreen);g.v2.positionScreen.copy(U.positionScreen);g.v3.positionScreen.copy(Q.positionScreen);g.normalWorld.copy(f.normalWorld);g.centroidWorld.copy(f.centroidWorld);g.centroidScreen.copy(f.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=ka;g.faceMaterials=
+H.materials;g.overdraw=la;if(L.geometry.uvs[B]){g.uvs[0]=L.geometry.uvs[B][1];g.uvs[1]=L.geometry.uvs[B][2];g.uvs[2]=L.geometry.uvs[B][3]}u.push(g);j++}}}}else if(L instanceof THREE.Line){D.multiply(k,ja);O=L.geometry.vertices;H=O[0];H.positionScreen.copy(H.position);D.multiplyVector4(H.positionScreen);B=1;for(T=O.length;B<T;B++){x=O[B];x.positionScreen.copy(x.position);D.multiplyVector4(x.positionScreen);P=O[B-1];I.copy(x.positionScreen);F.copy(P.positionScreen);if(b(I,F)){I.multiplyScalar(1/I.w);
+F.multiplyScalar(1/F.w);i=m[n]=m[n]||new THREE.RenderableLine;i.v1.positionScreen.copy(I);i.v2.positionScreen.copy(F);i.z=Math.max(I.z,F.z);i.materials=L.materials;u.push(i);n++}}}else if(L instanceof THREE.Particle){r.set(L.position.x,L.position.y,L.position.z,1);k.multiplyVector4(r);r.z/=r.w;if(r.z>0&&r.z<1){o=s[q]=s[q]||new THREE.RenderableParticle;o.x=r.x/r.w;o.y=r.y/r.w;o.z=r.z;o.rotation=L.rotation.z;o.scale.x=L.scale.x*Math.abs(o.x-(r.x+w.projectionMatrix.n11)/(r.w+w.projectionMatrix.n14));
 o.scale.y=L.scale.y*Math.abs(o.y-(r.y+w.projectionMatrix.n22)/(r.w+w.projectionMatrix.n24));o.materials=L.materials;u.push(o);q++}}}}J&&u.sort(a);return u};this.unprojectVector=function(A,w){var J=w.matrixWorld.clone();J.multiplySelf(THREE.Matrix4.makeInvert(w.projectionMatrix));J.multiplyVector3(A);return A}};
-THREE.CanvasRenderer=function(){function a(V){if(o!=V)i.globalAlpha=o=V}function b(V){if(q!=V){switch(V){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}q=V}}var c=null,d=new THREE.Projector,e=document.createElement("canvas"),f,h,j,g,i=e.getContext("2d"),n=new THREE.Color(0),l=0,o=1,q=0,s=null,t=null,r=1,k,D,C,I,F,N,A,w,J,u=new THREE.Color,
+THREE.CanvasRenderer=function(){function a(V){if(o!=V)i.globalAlpha=o=V}function b(V){if(q!=V){switch(V){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}q=V}}var c=null,d=new THREE.Projector,e=document.createElement("canvas"),f,g,j,h,i=e.getContext("2d"),n=new THREE.Color(0),m=0,o=1,q=0,s=null,t=null,r=1,k,D,C,I,F,N,A,w,J,u=new THREE.Color,
 K=new THREE.Color,E=new THREE.Color,y=new THREE.Color,B=new THREE.Color,T,x,P,Y,L,ja,ka,la,ma,$=new THREE.Rectangle,O=new THREE.Rectangle,H=new THREE.Rectangle,U=!1,Q=new THREE.Color,aa=new THREE.Color,na=new THREE.Color,oa=new THREE.Color,La=Math.PI*2,R=new THREE.Vector3,ra,sa,Ca,ba,ta,xa,pa=16;ra=document.createElement("canvas");ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);Ca=sa.getImageData(0,0,2,2);ba=Ca.data;ta=document.createElement("canvas");
-ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(V,da){f=V;h=da;j=f/2;g=h/2;e.width=f;e.height=h;$.set(-j,-g,j,g);o=1;q=0;t=s=null;r=1};this.setClearColor=function(V,da){n=V;l=da;O.set(-j,-g,j,g);i.setTransform(1,0,0,-1,j,g);this.clear()};this.setClearColorHex=function(V,da){n.setHex(V);l=da;O.set(-j,-g,j,g);i.setTransform(1,0,0,-1,j,g);this.clear()};this.clear=
-function(){i.setTransform(1,0,0,-1,j,g);if(!O.isEmpty()){O.inflate(1);O.minSelf($);if(n.hex==0&&l==0)i.clearRect(O.getX(),O.getY(),O.getWidth(),O.getHeight());else{b(THREE.NormalBlending);a(1);i.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+l+")";i.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(V,da){function Ma(m){var G,z,p,v=m.lights;aa.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);m=0;for(G=v.length;m<G;m++){z=
-v[m];p=z.color;if(z instanceof THREE.AmbientLight){aa.r+=p.r;aa.g+=p.g;aa.b+=p.b}else if(z instanceof THREE.DirectionalLight){na.r+=p.r;na.g+=p.g;na.b+=p.b}else if(z instanceof THREE.PointLight){oa.r+=p.r;oa.g+=p.g;oa.b+=p.b}}}function ya(m,G,z,p){var v,M,W,X,Z=m.lights;m=0;for(v=Z.length;m<v;m++){M=Z[m];W=M.color;X=M.intensity;if(M instanceof THREE.DirectionalLight){M=z.dot(M.position)*X;if(M>0){p.r+=W.r*M;p.g+=W.g*M;p.b+=W.b*M}}else if(M instanceof THREE.PointLight){R.sub(M.position,G);R.normalize();
-M=z.dot(R)*X;if(M>0){p.r+=W.r*M;p.g+=W.g*M;p.b+=W.b*M}}}}function Na(m,G,z){if(z.opacity!=0){a(z.opacity);b(z.blending);var p,v,M,W,X,Z;if(z instanceof THREE.ParticleBasicMaterial){if(z.map){W=z.map.image;X=W.width>>1;Z=W.height>>1;v=G.scale.x*j;M=G.scale.y*g;z=v*X;p=M*Z;H.set(m.x-z,m.y-p,m.x+z,m.y+p);if($.instersects(H)){i.save();i.translate(m.x,m.y);i.rotate(-G.rotation);i.scale(v,-M);i.translate(-X,-Z);i.drawImage(W,0,0);i.restore()}}}else if(z instanceof THREE.ParticleCircleMaterial){if(U){Q.r=
-aa.r+na.r+oa.r;Q.g=aa.g+na.g+oa.g;Q.b=aa.b+na.b+oa.b;u.r=z.color.r*Q.r;u.g=z.color.g*Q.g;u.b=z.color.b*Q.b;u.updateStyleString()}else u.__styleString=z.color.__styleString;z=G.scale.x*j;p=G.scale.y*g;H.set(m.x-z,m.y-p,m.x+z,m.y+p);if($.instersects(H)){v=u.__styleString;if(t!=v)i.fillStyle=t=v;i.save();i.translate(m.x,m.y);i.rotate(-G.rotation);i.scale(z,p);i.beginPath();i.arc(0,0,1,0,La,!0);i.closePath();i.fill();i.restore()}}}}function Oa(m,G,z,p){if(p.opacity!=0){a(p.opacity);b(p.blending);i.beginPath();
-i.moveTo(m.positionScreen.x,m.positionScreen.y);i.lineTo(G.positionScreen.x,G.positionScreen.y);i.closePath();if(p instanceof THREE.LineBasicMaterial){u.__styleString=p.color.__styleString;m=p.linewidth;if(r!=m)i.lineWidth=r=m;m=u.__styleString;if(s!=m)i.strokeStyle=s=m;i.stroke();H.inflate(p.linewidth*2)}}}function Ha(m,G,z,p,v,M){if(v.opacity!=0){a(v.opacity);b(v.blending);I=m.positionScreen.x;F=m.positionScreen.y;N=G.positionScreen.x;A=G.positionScreen.y;w=z.positionScreen.x;J=z.positionScreen.y;
-i.beginPath();i.moveTo(I,F);i.lineTo(N,A);i.lineTo(w,J);i.lineTo(I,F);i.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map)v.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,A,w,J,v.map.image,p.uvs[0].u,p.uvs[0].v,p.uvs[1].u,p.uvs[1].v,p.uvs[2].u,p.uvs[2].v);else if(v.envMap){if(v.envMap.mapping instanceof THREE.SphericalReflectionMapping){m=da.matrixWorldInverse;R.copy(p.vertexNormalsWorld[0]);Y=(R.x*m.n11+R.y*m.n12+R.z*m.n13)*0.5+0.5;L=-(R.x*m.n21+R.y*m.n22+R.z*m.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[1]);
-ja=(R.x*m.n11+R.y*m.n12+R.z*m.n13)*0.5+0.5;ka=-(R.x*m.n21+R.y*m.n22+R.z*m.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[2]);la=(R.x*m.n11+R.y*m.n12+R.z*m.n13)*0.5+0.5;ma=-(R.x*m.n21+R.y*m.n22+R.z*m.n23)*0.5+0.5;ua(I,F,N,A,w,J,v.envMap.image,Y,L,ja,ka,la,ma)}}else v.wireframe?za(v.color.__styleString,v.wireframeLinewidth):Aa(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){v.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,A,w,J,v.map.image,p.uvs[0].u,p.uvs[0].v,
+ta.width=ta.height=pa;xa=ta.getContext("2d");xa.translate(-pa/2,-pa/2);xa.scale(pa,pa);pa--;this.domElement=e;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(V,da){f=V;g=da;j=f/2;h=g/2;e.width=f;e.height=g;$.set(-j,-h,j,h);o=1;q=0;t=s=null;r=1};this.setClearColor=function(V,da){n=V;m=da;O.set(-j,-h,j,h);i.setTransform(1,0,0,-1,j,h);this.clear()};this.setClearColorHex=function(V,da){n.setHex(V);m=da;O.set(-j,-h,j,h);i.setTransform(1,0,0,-1,j,h);this.clear()};this.clear=
+function(){i.setTransform(1,0,0,-1,j,h);if(!O.isEmpty()){O.inflate(1);O.minSelf($);if(n.hex==0&&m==0)i.clearRect(O.getX(),O.getY(),O.getWidth(),O.getHeight());else{b(THREE.NormalBlending);a(1);i.fillStyle="rgba("+Math.floor(n.r*255)+","+Math.floor(n.g*255)+","+Math.floor(n.b*255)+","+m+")";i.fillRect(O.getX(),O.getY(),O.getWidth(),O.getHeight())}O.empty()}};this.render=function(V,da){function Ma(l){var G,z,p,v=l.lights;aa.setRGB(0,0,0);na.setRGB(0,0,0);oa.setRGB(0,0,0);l=0;for(G=v.length;l<G;l++){z=
+v[l];p=z.color;if(z instanceof THREE.AmbientLight){aa.r+=p.r;aa.g+=p.g;aa.b+=p.b}else if(z instanceof THREE.DirectionalLight){na.r+=p.r;na.g+=p.g;na.b+=p.b}else if(z instanceof THREE.PointLight){oa.r+=p.r;oa.g+=p.g;oa.b+=p.b}}}function ya(l,G,z,p){var v,M,W,X,Z=l.lights;l=0;for(v=Z.length;l<v;l++){M=Z[l];W=M.color;X=M.intensity;if(M instanceof THREE.DirectionalLight){M=z.dot(M.position)*X;if(M>0){p.r+=W.r*M;p.g+=W.g*M;p.b+=W.b*M}}else if(M instanceof THREE.PointLight){R.sub(M.position,G);R.normalize();
+M=z.dot(R)*X;if(M>0){p.r+=W.r*M;p.g+=W.g*M;p.b+=W.b*M}}}}function Na(l,G,z){if(z.opacity!=0){a(z.opacity);b(z.blending);var p,v,M,W,X,Z;if(z instanceof THREE.ParticleBasicMaterial){if(z.map){W=z.map.image;X=W.width>>1;Z=W.height>>1;v=G.scale.x*j;M=G.scale.y*h;z=v*X;p=M*Z;H.set(l.x-z,l.y-p,l.x+z,l.y+p);if($.instersects(H)){i.save();i.translate(l.x,l.y);i.rotate(-G.rotation);i.scale(v,-M);i.translate(-X,-Z);i.drawImage(W,0,0);i.restore()}}}else if(z instanceof THREE.ParticleCircleMaterial){if(U){Q.r=
+aa.r+na.r+oa.r;Q.g=aa.g+na.g+oa.g;Q.b=aa.b+na.b+oa.b;u.r=z.color.r*Q.r;u.g=z.color.g*Q.g;u.b=z.color.b*Q.b;u.updateStyleString()}else u.__styleString=z.color.__styleString;z=G.scale.x*j;p=G.scale.y*h;H.set(l.x-z,l.y-p,l.x+z,l.y+p);if($.instersects(H)){v=u.__styleString;if(t!=v)i.fillStyle=t=v;i.save();i.translate(l.x,l.y);i.rotate(-G.rotation);i.scale(z,p);i.beginPath();i.arc(0,0,1,0,La,!0);i.closePath();i.fill();i.restore()}}}}function Oa(l,G,z,p){if(p.opacity!=0){a(p.opacity);b(p.blending);i.beginPath();
+i.moveTo(l.positionScreen.x,l.positionScreen.y);i.lineTo(G.positionScreen.x,G.positionScreen.y);i.closePath();if(p instanceof THREE.LineBasicMaterial){u.__styleString=p.color.__styleString;l=p.linewidth;if(r!=l)i.lineWidth=r=l;l=u.__styleString;if(s!=l)i.strokeStyle=s=l;i.stroke();H.inflate(p.linewidth*2)}}}function Ha(l,G,z,p,v,M){if(v.opacity!=0){a(v.opacity);b(v.blending);I=l.positionScreen.x;F=l.positionScreen.y;N=G.positionScreen.x;A=G.positionScreen.y;w=z.positionScreen.x;J=z.positionScreen.y;
+i.beginPath();i.moveTo(I,F);i.lineTo(N,A);i.lineTo(w,J);i.lineTo(I,F);i.closePath();if(v instanceof THREE.MeshBasicMaterial)if(v.map)v.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,A,w,J,v.map.image,p.uvs[0].u,p.uvs[0].v,p.uvs[1].u,p.uvs[1].v,p.uvs[2].u,p.uvs[2].v);else if(v.envMap){if(v.envMap.mapping instanceof THREE.SphericalReflectionMapping){l=da.matrixWorldInverse;R.copy(p.vertexNormalsWorld[0]);Y=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;L=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[1]);
+ja=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;ka=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;R.copy(p.vertexNormalsWorld[2]);la=(R.x*l.n11+R.y*l.n12+R.z*l.n13)*0.5+0.5;ma=-(R.x*l.n21+R.y*l.n22+R.z*l.n23)*0.5+0.5;ua(I,F,N,A,w,J,v.envMap.image,Y,L,ja,ka,la,ma)}}else v.wireframe?za(v.color.__styleString,v.wireframeLinewidth):Aa(v.color.__styleString);else if(v instanceof THREE.MeshLambertMaterial){if(v.map&&!v.wireframe){v.map.mapping instanceof THREE.UVMapping&&ua(I,F,N,A,w,J,v.map.image,p.uvs[0].u,p.uvs[0].v,
 p.uvs[1].u,p.uvs[1].v,p.uvs[2].u,p.uvs[2].v);b(THREE.SubtractiveBlending)}if(U)if(!v.wireframe&&v.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==3){K.r=E.r=y.r=aa.r;K.g=E.g=y.g=aa.g;K.b=E.b=y.b=aa.b;ya(M,p.v1.positionWorld,p.vertexNormalsWorld[0],K);ya(M,p.v2.positionWorld,p.vertexNormalsWorld[1],E);ya(M,p.v3.positionWorld,p.vertexNormalsWorld[2],y);B.r=(E.r+y.r)*0.5;B.g=(E.g+y.g)*0.5;B.b=(E.b+y.b)*0.5;P=Ia(K,E,y,B);ua(I,F,N,A,w,J,P,0,0,1,0,0,1)}else{Q.r=aa.r;Q.g=aa.g;Q.b=aa.b;ya(M,p.centroidWorld,
-p.normalWorld,Q);u.r=v.color.r*Q.r;u.g=v.color.g*Q.g;u.b=v.color.b*Q.b;u.updateStyleString();v.wireframe?za(u.__styleString,v.wireframeLinewidth):Aa(u.__styleString)}else v.wireframe?za(v.color.__styleString,v.wireframeLinewidth):Aa(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){T=da.near;x=da.far;K.r=K.g=K.b=1-Da(m.positionScreen.z,T,x);E.r=E.g=E.b=1-Da(G.positionScreen.z,T,x);y.r=y.g=y.b=1-Da(z.positionScreen.z,T,x);B.r=(E.r+y.r)*0.5;B.g=(E.g+y.g)*0.5;B.b=(E.b+y.b)*0.5;P=Ia(K,
-E,y,B);ua(I,F,N,A,w,J,P,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){u.r=Ea(p.normalWorld.x);u.g=Ea(p.normalWorld.y);u.b=Ea(p.normalWorld.z);u.updateStyleString();v.wireframe?za(u.__styleString,v.wireframeLinewidth):Aa(u.__styleString)}}}function za(m,G){if(s!=m)i.strokeStyle=s=m;if(r!=G)i.lineWidth=r=G;i.stroke();H.inflate(G*2)}function Aa(m){if(t!=m)i.fillStyle=t=m;i.fill()}function ua(m,G,z,p,v,M,W,X,Z,ga,ca,ha,va){var ea,ia;ea=W.width-1;ia=W.height-1;X*=ea;Z*=ia;ga*=ea;ca*=ia;ha*=
-ea;va*=ia;z-=m;p-=G;v-=m;M-=G;ga-=X;ca-=Z;ha-=X;va-=Z;ea=ga*va-ha*ca;if(ea!=0){ia=1/ea;ea=(va*z-ca*v)*ia;ca=(va*p-ca*M)*ia;z=(ga*v-ha*z)*ia;p=(ga*M-ha*p)*ia;m=m-ea*X-z*Z;G=G-ca*X-p*Z;i.save();i.transform(ea,ca,z,p,m,G);i.clip();i.drawImage(W,0,0);i.restore()}}function Ia(m,G,z,p){var v=~~(m.r*255),M=~~(m.g*255);m=~~(m.b*255);var W=~~(G.r*255),X=~~(G.g*255);G=~~(G.b*255);var Z=~~(z.r*255),ga=~~(z.g*255);z=~~(z.b*255);var ca=~~(p.r*255),ha=~~(p.g*255);p=~~(p.b*255);ba[0]=v<0?0:v>255?255:v;ba[1]=M<0?
-0:M>255?255:M;ba[2]=m<0?0:m>255?255:m;ba[4]=W<0?0:W>255?255:W;ba[5]=X<0?0:X>255?255:X;ba[6]=G<0?0:G>255?255:G;ba[8]=Z<0?0:Z>255?255:Z;ba[9]=ga<0?0:ga>255?255:ga;ba[10]=z<0?0:z>255?255:z;ba[12]=ca<0?0:ca>255?255:ca;ba[13]=ha<0?0:ha>255?255:ha;ba[14]=p<0?0:p>255?255:p;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(m,G,z){m=(m-G)/(z-G);return m*m*(3-2*m)}function Ea(m){m=(m+1)*0.5;return m<0?0:m>1?1:m}function Fa(m,G){var z=G.x-m.x,p=G.y-m.y,v=1/Math.sqrt(z*z+p*p);z*=v;p*=v;G.x+=
-z;G.y+=p;m.x-=z;m.y-=p}var Ba,Ja,S,fa,qa,Ga,Ka,wa;this.autoClear?this.clear():i.setTransform(1,0,0,-1,j,g);c=d.projectScene(V,da,this.sortElements);(U=V.lights.length>0)&&Ma(V);Ba=0;for(Ja=c.length;Ba<Ja;Ba++){S=c[Ba];H.empty();if(S instanceof THREE.RenderableParticle){k=S;k.x*=j;k.y*=g;fa=0;for(qa=S.materials.length;fa<qa;fa++)Na(k,S,S.materials[fa],V)}else if(S instanceof THREE.RenderableLine){k=S.v1;D=S.v2;k.positionScreen.x*=j;k.positionScreen.y*=g;D.positionScreen.x*=j;D.positionScreen.y*=g;
-H.addPoint(k.positionScreen.x,k.positionScreen.y);H.addPoint(D.positionScreen.x,D.positionScreen.y);if($.instersects(H)){fa=0;for(qa=S.materials.length;fa<qa;)Oa(k,D,S,S.materials[fa++],V)}}else if(S instanceof THREE.RenderableFace3){k=S.v1;D=S.v2;C=S.v3;k.positionScreen.x*=j;k.positionScreen.y*=g;D.positionScreen.x*=j;D.positionScreen.y*=g;C.positionScreen.x*=j;C.positionScreen.y*=g;if(S.overdraw){Fa(k.positionScreen,D.positionScreen);Fa(D.positionScreen,C.positionScreen);Fa(C.positionScreen,k.positionScreen)}H.add3Points(k.positionScreen.x,
+p.normalWorld,Q);u.r=v.color.r*Q.r;u.g=v.color.g*Q.g;u.b=v.color.b*Q.b;u.updateStyleString();v.wireframe?za(u.__styleString,v.wireframeLinewidth):Aa(u.__styleString)}else v.wireframe?za(v.color.__styleString,v.wireframeLinewidth):Aa(v.color.__styleString)}else if(v instanceof THREE.MeshDepthMaterial){T=da.near;x=da.far;K.r=K.g=K.b=1-Da(l.positionScreen.z,T,x);E.r=E.g=E.b=1-Da(G.positionScreen.z,T,x);y.r=y.g=y.b=1-Da(z.positionScreen.z,T,x);B.r=(E.r+y.r)*0.5;B.g=(E.g+y.g)*0.5;B.b=(E.b+y.b)*0.5;P=Ia(K,
+E,y,B);ua(I,F,N,A,w,J,P,0,0,1,0,0,1)}else if(v instanceof THREE.MeshNormalMaterial){u.r=Ea(p.normalWorld.x);u.g=Ea(p.normalWorld.y);u.b=Ea(p.normalWorld.z);u.updateStyleString();v.wireframe?za(u.__styleString,v.wireframeLinewidth):Aa(u.__styleString)}}}function za(l,G){if(s!=l)i.strokeStyle=s=l;if(r!=G)i.lineWidth=r=G;i.stroke();H.inflate(G*2)}function Aa(l){if(t!=l)i.fillStyle=t=l;i.fill()}function ua(l,G,z,p,v,M,W,X,Z,ga,ca,ha,va){var ea,ia;ea=W.width-1;ia=W.height-1;X*=ea;Z*=ia;ga*=ea;ca*=ia;ha*=
+ea;va*=ia;z-=l;p-=G;v-=l;M-=G;ga-=X;ca-=Z;ha-=X;va-=Z;ea=ga*va-ha*ca;if(ea!=0){ia=1/ea;ea=(va*z-ca*v)*ia;ca=(va*p-ca*M)*ia;z=(ga*v-ha*z)*ia;p=(ga*M-ha*p)*ia;l=l-ea*X-z*Z;G=G-ca*X-p*Z;i.save();i.transform(ea,ca,z,p,l,G);i.clip();i.drawImage(W,0,0);i.restore()}}function Ia(l,G,z,p){var v=~~(l.r*255),M=~~(l.g*255);l=~~(l.b*255);var W=~~(G.r*255),X=~~(G.g*255);G=~~(G.b*255);var Z=~~(z.r*255),ga=~~(z.g*255);z=~~(z.b*255);var ca=~~(p.r*255),ha=~~(p.g*255);p=~~(p.b*255);ba[0]=v<0?0:v>255?255:v;ba[1]=M<0?
+0:M>255?255:M;ba[2]=l<0?0:l>255?255:l;ba[4]=W<0?0:W>255?255:W;ba[5]=X<0?0:X>255?255:X;ba[6]=G<0?0:G>255?255:G;ba[8]=Z<0?0:Z>255?255:Z;ba[9]=ga<0?0:ga>255?255:ga;ba[10]=z<0?0:z>255?255:z;ba[12]=ca<0?0:ca>255?255:ca;ba[13]=ha<0?0:ha>255?255:ha;ba[14]=p<0?0:p>255?255:p;sa.putImageData(Ca,0,0);xa.drawImage(ra,0,0);return ta}function Da(l,G,z){l=(l-G)/(z-G);return l*l*(3-2*l)}function Ea(l){l=(l+1)*0.5;return l<0?0:l>1?1:l}function Fa(l,G){var z=G.x-l.x,p=G.y-l.y,v=1/Math.sqrt(z*z+p*p);z*=v;p*=v;G.x+=
+z;G.y+=p;l.x-=z;l.y-=p}var Ba,Ja,S,fa,qa,Ga,Ka,wa;this.autoClear?this.clear():i.setTransform(1,0,0,-1,j,h);c=d.projectScene(V,da,this.sortElements);(U=V.lights.length>0)&&Ma(V);Ba=0;for(Ja=c.length;Ba<Ja;Ba++){S=c[Ba];H.empty();if(S instanceof THREE.RenderableParticle){k=S;k.x*=j;k.y*=h;fa=0;for(qa=S.materials.length;fa<qa;fa++)Na(k,S,S.materials[fa],V)}else if(S instanceof THREE.RenderableLine){k=S.v1;D=S.v2;k.positionScreen.x*=j;k.positionScreen.y*=h;D.positionScreen.x*=j;D.positionScreen.y*=h;
+H.addPoint(k.positionScreen.x,k.positionScreen.y);H.addPoint(D.positionScreen.x,D.positionScreen.y);if($.instersects(H)){fa=0;for(qa=S.materials.length;fa<qa;)Oa(k,D,S,S.materials[fa++],V)}}else if(S instanceof THREE.RenderableFace3){k=S.v1;D=S.v2;C=S.v3;k.positionScreen.x*=j;k.positionScreen.y*=h;D.positionScreen.x*=j;D.positionScreen.y*=h;C.positionScreen.x*=j;C.positionScreen.y*=h;if(S.overdraw){Fa(k.positionScreen,D.positionScreen);Fa(D.positionScreen,C.positionScreen);Fa(C.positionScreen,k.positionScreen)}H.add3Points(k.positionScreen.x,
 k.positionScreen.y,D.positionScreen.x,D.positionScreen.y,C.positionScreen.x,C.positionScreen.y);if($.instersects(H)){fa=0;for(qa=S.meshMaterials.length;fa<qa;){wa=S.meshMaterials[fa++];if(wa instanceof THREE.MeshFaceMaterial){Ga=0;for(Ka=S.faceMaterials.length;Ga<Ka;)(wa=S.faceMaterials[Ga++])&&Ha(k,D,C,S,wa,V)}else Ha(k,D,C,S,wa,V)}}}O.addRectangle(H)}i.setTransform(1,0,0,1,0,0)}};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,e=c.length;for(d=0;d<e;d++){a=c[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
 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=!1;this.uvs=[null,null,null]};

+ 22 - 22
build/custom/ThreeExtras.js

@@ -24,22 +24,22 @@ screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",val
 fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var d,b,f,g,c=2*Math.ceil(a*3)+1;c>25&&(c=25);g=(c-1)*0.5;b=Array(c);for(d=f=0;d<c;++d){b[d]=Math.exp(-((d-g)*(d-g))/(2*a*a));f+=b[d]}for(d=0;d<c;++d)b[d]/=f;return b}},Cube=function(a,d,b,f,g,c,e,h){function j(t,z,w,x,k,D,E,J){var A,C,H=f||1,I=g||1,K=H+1,M=I+1,F=k/2,P=D/2;k/=H;var Q=D/I,R=l.vertices.length;if(t=="x"&&z=="y"||t=="y"&&z=="x")A="z";else if(t=="x"&&z=="z"||t=="z"&&z=="x")A="y";else if(t==
 "z"&&z=="y"||t=="y"&&z=="z")A="x";for(C=0;C<M;C++)for(D=0;D<K;D++){var S=new THREE.Vector3;S[t]=(D*k-F)*w;S[z]=(C*Q-P)*x;S[A]=E;l.vertices.push(new THREE.Vertex(S))}for(C=0;C<I;C++)for(D=0;D<H;D++){l.faces.push(new THREE.Face4(D+K*C+R,D+K*(C+1)+R,D+1+K*(C+1)+R,D+1+K*C+R,null,J));l.uvs.push([new THREE.UV(D/H,C/I),new THREE.UV(D/H,(C+1)/I),new THREE.UV((D+1)/H,(C+1)/I),new THREE.UV((D+1)/H,C/I)])}}THREE.Geometry.call(this);var l=this,m=a/2,v=d/2,q=b/2;e=e?-1:1;if(c!==undefined)if(c instanceof Array)this.materials=
 c;else{this.materials=[];for(var n=0;n<6;n++)this.materials.push([c])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(h!=undefined)for(var p in h)this.sides[p]!=undefined&&(this.sides[p]=h[p]);this.sides.px&&j("z","y",1*e,-1,b,d,-m,this.materials[0]);this.sides.nx&&j("z","y",-1*e,-1,b,d,m,this.materials[1]);this.sides.py&&j("x","z",1*e,1,a,b,v,this.materials[2]);this.sides.ny&&j("x","z",1*e,-1,a,b,-v,this.materials[3]);this.sides.pz&&j("x","y",1*e,-1,a,d,q,this.materials[4]);
-this.sides.nz&&j("x","y",-1*e,-1,a,d,-q,this.materials[5]);(function(){for(var t=[],z=[],w=0,x=l.vertices.length;w<x;w++){for(var k=l.vertices[w],D=!1,E=0,J=t.length;E<J;E++){var A=t[E];if(k.position.x==A.position.x&&k.position.y==A.position.y&&k.position.z==A.position.z){z[w]=E;D=!0;break}}if(!D){z[w]=t.length;t.push(new THREE.Vertex(k.position.clone()))}}w=0;for(x=l.faces.length;w<x;w++){k=l.faces[w];k.a=z[k.a];k.b=z[k.b];k.c=z[k.c];k.d=z[k.d]}l.vertices=t})();this.computeCentroids();this.computeFaceNormals();
-this.sortFacesByMaterial()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
+this.sides.nz&&j("x","y",-1*e,-1,a,d,-q,this.materials[5]);(function(){for(var t=[],z=[],w=0,x=l.vertices.length;w<x;w++){for(var k=l.vertices[w],D=!1,E=0,J=t.length;E<J;E++){var A=t[E];if(k.position.x==A.position.x&&k.position.y==A.position.y&&k.position.z==A.position.z){z[w]=E;D=!0;break}}if(!D){z[w]=t.length;t.push(new THREE.Vertex(k.position.clone()))}}w=0;for(x=l.faces.length;w<x;w++){k=l.faces[w];k.a=z[k.a];k.b=z[k.b];k.c=z[k.c];k.d=z[k.d]}l.vertices=t})();this.computeCentroids();this.computeFaceNormals()};
+Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
 var Cylinder=function(a,d,b,f,g){function c(l,m,v){e.vertices.push(new THREE.Vertex(new THREE.Vector3(l,m,v)))}THREE.Geometry.call(this);var e=this,h=Math.PI,j;for(j=0;j<a;j++)c(Math.sin(2*h*j/a)*d,Math.cos(2*h*j/a)*d,0);for(j=0;j<a;j++)c(Math.sin(2*h*j/a)*b,Math.cos(2*h*j/a)*b,f);for(j=0;j<a;j++)e.faces.push(new THREE.Face4(j,j+a,a+(j+1)%a,(j+1)%a));if(b!=0){c(0,0,-g);for(j=a;j<a+a/2;j++)e.faces.push(new THREE.Face4(2*a,(2*j-2*a)%a,(2*j-2*a+1)%a,(2*j-2*a+2)%a))}if(d!=0){c(0,0,f+g);for(j=a+a/2;j<
-2*a;j++)e.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-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,d,b,f){THREE.Geometry.call(this);var g,c=a/2,e=d/2;b=b||1;f=f||1;var h=b+1,j=f+1;a/=b;var l=d/f;for(g=0;g<j;g++)for(d=0;d<h;d++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(d*a-c,-(g*l-e),0)));for(g=0;g<f;g++)for(d=0;d<b;d++){this.faces.push(new THREE.Face4(d+h*g,d+h*(g+1),d+1+h*(g+1),d+1+h*g));this.uvs.push([new THREE.UV(d/b,g/f),new THREE.UV(d/b,(g+1)/f),new THREE.UV((d+1)/b,(g+1)/f),new THREE.UV((d+1)/b,g/f)])}this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
+2*a;j++)e.faces.push(new THREE.Face4((2*j-2*a+2)%a+a,(2*j-2*a+1)%a+a,(2*j-2*a)%a+a,2*a+1))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
+var Plane=function(a,d,b,f){THREE.Geometry.call(this);var g,c=a/2,e=d/2;b=b||1;f=f||1;var h=b+1,j=f+1;a/=b;var l=d/f;for(g=0;g<j;g++)for(d=0;d<h;d++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(d*a-c,-(g*l-e),0)));for(g=0;g<f;g++)for(d=0;d<b;d++){this.faces.push(new THREE.Face4(d+h*g,d+h*(g+1),d+1+h*(g+1),d+1+h*g));this.uvs.push([new THREE.UV(d/b,g/f),new THREE.UV(d/b,(g+1)/f),new THREE.UV((d+1)/b,(g+1)/f),new THREE.UV((d+1)/b,g/f)])}this.computeCentroids();this.computeFaceNormals()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
 var Sphere=function(a,d,b){THREE.Geometry.call(this);var f,g=Math.PI,c=Math.max(3,d||8),e=Math.max(2,b||6);d=[];for(b=0;b<e+1;b++){f=b/e;var h=a*Math.cos(f*g),j=a*Math.sin(f*g),l=[],m=0;for(f=0;f<c;f++){var v=2*f/c,q=j*Math.sin(v*g);v=j*Math.cos(v*g);(b==0||b==e)&&f>0||(m=this.vertices.push(new THREE.Vertex(new THREE.Vector3(v,h,q)))-1);l.push(m)}d.push(l)}var n,p,t;g=d.length;for(b=0;b<g;b++){c=d[b].length;if(b>0)for(f=0;f<c;f++){l=f==c-1;e=d[b][l?0:f+1];h=d[b][l?c-1:f];j=d[b-1][l?c-1:f];l=d[b-1][l?
 0:f+1];q=b/(g-1);n=(b-1)/(g-1);p=(f+1)/c;v=f/c;m=new THREE.UV(1-p,q);q=new THREE.UV(1-v,q);v=new THREE.UV(1-v,n);var z=new THREE.UV(1-p,n);if(b<d.length-1){n=this.vertices[e].position.clone();p=this.vertices[h].position.clone();t=this.vertices[j].position.clone();n.normalize();p.normalize();t.normalize();this.faces.push(new THREE.Face3(e,h,j,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(t.x,t.y,t.z)]));this.uvs.push([m,q,v])}if(b>1){n=this.vertices[e].position.clone();
-p=this.vertices[j].position.clone();t=this.vertices[l].position.clone();n.normalize();p.normalize();t.normalize();this.faces.push(new THREE.Face3(e,j,l,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(t.x,t.y,t.z)]));this.uvs.push([m,v,z])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
+p=this.vertices[j].position.clone();t=this.vertices[l].position.clone();n.normalize();p.normalize();t.normalize();this.faces.push(new THREE.Face3(e,j,l,[new THREE.Vector3(n.x,n.y,n.z),new THREE.Vector3(p.x,p.y,p.z),new THREE.Vector3(t.x,t.y,t.z)]));this.uvs.push([m,v,z])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 var Torus=function(a,d,b,f){this.radius=a||100;this.tube=d||40;this.segmentsR=b||8;this.segmentsT=f||6;a=[];THREE.Geometry.call(this);for(d=0;d<=this.segmentsR;++d)for(b=0;b<=this.segmentsT;++b){f=b/this.segmentsT*2*Math.PI;var g=d/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));a.push([b/this.segmentsT,1-d/this.segmentsR])}for(d=1;d<=this.segmentsR;++d)for(b=
-1;b<=this.segmentsT;++b){f=(this.segmentsT+1)*d+b;g=(this.segmentsT+1)*d+b-1;var c=(this.segmentsT+1)*(d-1)+b-1,e=(this.segmentsT+1)*(d-1)+b;this.faces.push(new THREE.Face4(f,g,c,e));this.uvs.push([new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[c][0],a[c][1]),new THREE.UV(a[e][0],a[e][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
+1;b<=this.segmentsT;++b){f=(this.segmentsT+1)*d+b;g=(this.segmentsT+1)*d+b-1;var c=(this.segmentsT+1)*(d-1)+b-1,e=(this.segmentsT+1)*(d-1)+b;this.faces.push(new THREE.Face4(f,g,c,e));this.uvs.push([new THREE.UV(a[f][0],a[f][1]),new THREE.UV(a[g][0],a[g][1]),new THREE.UV(a[c][0],a[c][1]),new THREE.UV(a[e][0],a[e][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
 var Icosahedron=function(a){function d(v,q,n){var p=Math.sqrt(v*v+q*q+n*n);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(v/p,q/p,n/p)))-1}function b(v,q,n,p){p.faces.push(new THREE.Face3(v,q,n))}function f(v,q){var n=g.vertices[v].position,p=g.vertices[q].position;return d((n.x+p.x)/2,(n.y+p.y)/2,(n.z+p.z)/2)}var g=this,c=new THREE.Geometry,e;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;d(-1,a,0);d(1,a,0);d(-1,-a,0);d(1,-a,0);d(0,-1,a);d(0,1,a);d(0,-1,-a);d(0,
 1,-a);d(a,0,-1);d(a,0,1);d(-a,0,-1);d(-a,0,1);b(0,11,5,c);b(0,5,1,c);b(0,1,7,c);b(0,7,10,c);b(0,10,11,c);b(1,5,9,c);b(5,11,4,c);b(11,10,2,c);b(10,7,6,c);b(7,1,8,c);b(3,9,4,c);b(3,4,2,c);b(3,2,6,c);b(3,6,8,c);b(3,8,9,c);b(4,9,5,c);b(2,4,11,c);b(6,2,10,c);b(8,6,7,c);b(9,8,1,c);for(a=0;a<this.subdivisions;a++){e=new THREE.Geometry;for(var h in c.faces){var j=f(c.faces[h].a,c.faces[h].b),l=f(c.faces[h].b,c.faces[h].c),m=f(c.faces[h].c,c.faces[h].a);b(c.faces[h].a,j,m,e);b(c.faces[h].b,l,j,e);b(c.faces[h].c,
-m,l,e);b(j,l,m,e)}c.faces=e.faces}g.faces=c.faces;delete c;delete e;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
+m,l,e);b(j,l,m,e)}c.faces=e.faces}g.faces=c.faces;delete c;delete e;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
 function LathedObject(a,d,b){THREE.Geometry.call(this);this.nsteps=d||12;this.latheAngle=b||2*Math.PI;d=this.latheAngle/this.nsteps;for(var f=[],g=[],c=[],e=[],h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));g[h]=this.vertices.length-1;f[h]=new THREE.Vector3(a[h].x,a[h].y,a[h].z)}for(var j=THREE.Matrix4.rotationZMatrix(this.stepSize),l=0;l<=this.latheAngle+0.001;l+=this.stepSize){for(h=0;h<f.length;h++)if(l<b){f[h]=j.multiplyVector3(f[h].clone());this.vertices.push(new THREE.Vertex(f[h]));
-c[h]=this.vertices.length-1}else c=e;l==0&&(e=g);for(h=0;h<g.length-1;h++){this.faces.push(new THREE.Face4(c[h],c[h+1],g[h+1],g[h]));this.uvs.push([new THREE.UV(l/b,h/a.length),new THREE.UV(l/b,(h+1)/a.length),new THREE.UV((l-d)/b,(h+1)/a.length),new THREE.UV((l-d)/b,h/a.length)])}g=c;c=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.sortFacesByMaterial()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;
+c[h]=this.vertices.length-1}else c=e;l==0&&(e=g);for(h=0;h<g.length-1;h++){this.faces.push(new THREE.Face4(c[h],c[h+1],g[h+1],g[h]));this.uvs.push([new THREE.UV(l/b,h/a.length),new THREE.UV(l/b,(h+1)/a.length),new THREE.UV((l-d)/b,(h+1)/a.length),new THREE.UV((l-d)/b,h/a.length)])}g=c;c=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}LathedObject.prototype=new THREE.Geometry;LathedObject.prototype.constructor=LathedObject;
 if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 THREE.MarchingCubes=function(a,d){THREE.Object3D.call(this);this.materials=d instanceof Array?d:[d];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
 0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,f,g){return b+(f-b)*g};this.VIntX=function(b,f,g,c,e,h,j,l,m,v){e=(e-m)/(v-m);m=this.normal_cache;f[c]=h+e*this.delta;f[c+1]=j;f[c+2]=l;g[c]=this.lerp(m[b],m[b+3],e);g[c+1]=this.lerp(m[b+1],m[b+4],e);g[c+2]=this.lerp(m[b+2],m[b+5],e)};this.VIntY=function(b,f,g,c,e,h,j,l,m,v){e=(e-m)/(v-m);m=this.normal_cache;f[c]=h;f[c+1]=j+e*this.delta;f[c+
@@ -53,8 +53,8 @@ function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){i
 h>this.size-1&&(h=this.size-1);for(var p,t,z,w,x,k;v<j;v++){m=this.size2*v;t=v/this.size-g;x=t*t;for(t=q;t<l;t++){z=m+this.size*t;p=t/this.size-f;k=p*p;for(p=n;p<h;p++){w=p/this.size-b;w=c/(1.0E-6+w*w+k+x)-e;w>0&&(this.field[z+p]+=w)}}}};this.addPlaneX=function(b,f){var g,c,e,h,j,l=this.size,m=this.yd,v=this.zd,q=this.field,n=l*Math.sqrt(b/f);n>l&&(n=l);for(g=0;g<n;g++){c=g/l;c*=c;h=b/(1.0E-4+c)-f;if(h>0)for(c=0;c<l;c++){j=g+c*m;for(e=0;e<l;e++)q[v*e+j]+=h}}};this.addPlaneY=function(b,f){var g,c,
 e,h,j,l,m=this.size,v=this.yd,q=this.zd,n=this.field,p=m*Math.sqrt(b/f);p>m&&(p=m);for(c=0;c<p;c++){g=c/m;g*=g;h=b/(1.0E-4+g)-f;if(h>0){j=c*v;for(g=0;g<m;g++){l=j+g;for(e=0;e<m;e++)n[q*e+l]+=h}}}};this.addPlaneZ=function(b,f){var g,c,e,h,j,l;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/f);dist>size&&(dist=size);for(e=0;e<dist;e++){g=e/size;g*=g;h=b/(1.0E-4+g)-f;if(h>0){j=zd*e;for(c=0;c<size;c++){l=j+c*yd;for(g=0;g<size;g++)field[l+g]+=h}}}};this.reset=function(){var b;
 for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var f,g,c,e,h,j,l,m,v,q=this.size-2;for(e=1;e<q;e++){v=this.size2*e;l=(e-this.halfsize)/this.halfsize;for(c=1;c<q;c++){m=v+this.size*c;j=(c-this.halfsize)/this.halfsize;for(g=1;g<q;g++){h=(g-this.halfsize)/this.halfsize;f=m+g;this.polygonize(h,j,l,f,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,f=new THREE.Geometry;this.render(function(g){var c,e,h,j,l,m,v,q;for(c=
-0;c<g.count;c++){l=c*3;v=l+1;q=l+2;e=g.positionArray[l];h=g.positionArray[v];j=g.positionArray[q];m=new THREE.Vector3(e,h,j);e=g.normalArray[l];h=g.normalArray[v];j=g.normalArray[q];l=new THREE.Vector3(e,h,j);l.normalize();l=new THREE.Vertex(m,l);f.vertices.push(l)}nfaces=g.count/3;for(c=0;c<nfaces;c++){l=(b+c)*3;v=l+1;q=l+2;m=f.vertices[l].normal;e=f.vertices[v].normal;h=f.vertices[q].normal;l=new THREE.Face3(l,v,q,[m,e,h]);f.faces.push(l)}b+=nfaces;g.count=0});f.sortFacesByMaterial();return f};
-this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
+0;c<g.count;c++){l=c*3;v=l+1;q=l+2;e=g.positionArray[l];h=g.positionArray[v];j=g.positionArray[q];m=new THREE.Vector3(e,h,j);e=g.normalArray[l];h=g.normalArray[v];j=g.normalArray[q];l=new THREE.Vector3(e,h,j);l.normalize();l=new THREE.Vertex(m,l);f.vertices.push(l)}nfaces=g.count/3;for(c=0;c<nfaces;c++){l=(b+c)*3;v=l+1;q=l+2;m=f.vertices[l].normal;e=f.vertices[v].normal;h=f.vertices[q].normal;l=new THREE.Face3(l,v,q,[m,e,h]);f.faces.push(l)}b+=nfaces;g.count=0});return f};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]);
@@ -92,15 +92,15 @@ x+=k.header_bytes;J=k.vertex_index_bytes;A=k.vertex_index_bytes*2;C=k.vertex_ind
 O;c=k.nquad_smooth*(O+k.normal_index_bytes*4);O=k.nquad_flat_uv*(O+k.uv_index_bytes*4);x+=function(o){for(var u,y,B,G=k.vertex_coordinate_bytes*3,L=o+k.nvertices*G;o<L;o+=G){u=e(a,o);y=e(a,o+k.vertex_coordinate_bytes);B=e(a,o+k.vertex_coordinate_bytes*2);THREE.Loader.prototype.v(w,u,y,B)}return k.nvertices*G}(x);x+=function(o){for(var u,y,B,G=k.normal_coordinate_bytes*3,L=o+k.nnormals*G;o<L;o+=G){u=l(a,o);y=l(a,o+k.normal_coordinate_bytes);B=l(a,o+k.normal_coordinate_bytes*2);D.push(u/127,y/127,B/
 127)}return k.nnormals*G}(x);x+=function(o){for(var u,y,B=k.uv_coordinate_bytes*2,G=o+k.nuvs*B;o<G;o+=B){u=e(a,o);y=e(a,o+k.uv_coordinate_bytes);E.push(u,y)}return k.nuvs*B}(x);T=x+T;U=T+U;V=U+V;W=V+W;X=W+X;c=X+c;O=c+O;(function(o){var u,y=k.vertex_index_bytes*3+k.material_index_bytes,B=y+k.uv_index_bytes*3,G=o+k.ntri_flat_uv*B;for(u=o;u<G;u+=B){v(u);t(u+y)}return G-o})(U);(function(o){var u,y=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes*3,B=y+k.uv_index_bytes*3,G=o+k.ntri_smooth_uv*
 B;for(u=o;u<G;u+=B){q(u);t(u+y)}return G-o})(V);(function(o){var u,y=k.vertex_index_bytes*4+k.material_index_bytes,B=y+k.uv_index_bytes*4,G=o+k.nquad_flat_uv*B;for(u=o;u<G;u+=B){n(u);z(u+y)}return G-o})(c);(function(o){var u,y=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes*4,B=y+k.uv_index_bytes*4,G=o+k.nquad_smooth_uv*B;for(u=o;u<G;u+=B){p(u);z(u+y)}return G-o})(O);(function(o){var u,y=k.vertex_index_bytes*3+k.material_index_bytes,B=o+k.ntri_flat*y;for(u=o;u<B;u+=y)v(u);return B-
-o})(x);(function(o){var u,y=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes*3,B=o+k.ntri_smooth*y;for(u=o;u<B;u+=y)q(u);return B-o})(T);(function(o){var u,y=k.vertex_index_bytes*4+k.material_index_bytes,B=o+k.nquad_flat*y;for(u=o;u<B;u+=y)n(u);return B-o})(W);(function(o){var u,y=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes*4,B=o+k.nquad_smooth*y;for(u=o;u<B;u+=y)p(u);return B-o})(X);this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};
-g.prototype=new THREE.Geometry;g.prototype.constructor=g;d(new g(b))},createModel:function(a,d,b){var f=function(g){var c=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(c,a.materials,g);(function(){var e,h,j,l,m;e=0;for(h=a.vertices.length;e<h;e+=3){j=a.vertices[e];l=a.vertices[e+1];m=a.vertices[e+2];THREE.Loader.prototype.v(c,j,l,m)}if(a.colors){e=0;for(h=a.colors.length;e<h;e+=3){j=a.colors[e];l=a.colors[e+1];m=a.colors[e+2];THREE.Loader.prototype.vc(c,j,l,m)}}})();(function(){function e(p,
-t){THREE.Loader.prototype.f3(c,p[t],p[t+1],p[t+2],p[t+3])}function h(p,t){THREE.Loader.prototype.f3n(c,a.normals,p[t],p[t+1],p[t+2],p[t+3],p[t+4],p[t+5],p[t+6])}function j(p,t){THREE.Loader.prototype.f4(c,p[t],p[t+1],p[t+2],p[t+3],p[t+4])}function l(p,t){THREE.Loader.prototype.f4n(c,a.normals,p[t],p[t+1],p[t+2],p[t+3],p[t+4],p[t+5],p[t+6],p[t+7],p[t+8])}function m(p,t){var z,w,x,k,D,E,J,A,C;z=p[t];w=p[t+1];x=p[t+2];k=a.uvs[z*2];J=a.uvs[z*2+1];D=a.uvs[w*2];A=a.uvs[w*2+1];E=a.uvs[x*2];C=a.uvs[x*2+1];
-THREE.Loader.prototype.uv3(c.uvs,k,J,D,A,E,C);if(a.uvs2&&a.uvs2.length){k=a.uvs2[z*2];J=a.uvs2[z*2+1];D=a.uvs2[w*2];A=a.uvs2[w*2+1];E=a.uvs2[x*2];C=a.uvs2[x*2+1];THREE.Loader.prototype.uv3(c.uvs2,k,1-J,D,1-A,E,1-C)}}function v(p,t){var z,w,x,k,D,E,J,A,C,H,I,K;z=p[t];w=p[t+1];x=p[t+2];k=p[t+3];D=a.uvs[z*2];C=a.uvs[z*2+1];E=a.uvs[w*2];H=a.uvs[w*2+1];J=a.uvs[x*2];I=a.uvs[x*2+1];A=a.uvs[k*2];K=a.uvs[k*2+1];THREE.Loader.prototype.uv4(c.uvs,D,C,E,H,J,I,A,K);if(a.uvs2){D=a.uvs2[z*2];C=a.uvs2[z*2+1];E=a.uvs2[w*
-2];H=a.uvs2[w*2+1];J=a.uvs2[x*2];I=a.uvs2[x*2+1];A=a.uvs2[k*2];K=a.uvs2[k*2+1];THREE.Loader.prototype.uv4(c.uvs2,D,1-C,E,1-H,J,1-I,A,1-K)}}var q,n;q=0;for(n=a.trianglesUvs.length;q<n;q+=7){e(a.trianglesUvs,q);m(a.trianglesUvs,q+4)}q=0;for(n=a.trianglesNormalsUvs.length;q<n;q+=10){h(a.trianglesNormalsUvs,q);m(a.trianglesNormalsUvs,q+7)}q=0;for(n=a.quadsUvs.length;q<n;q+=9){j(a.quadsUvs,q);v(a.quadsUvs,q+5)}q=0;for(n=a.quadsNormalsUvs.length;q<n;q+=13){l(a.quadsNormalsUvs,q);v(a.quadsNormalsUvs,q+9)}q=
-0;for(n=a.triangles.length;q<n;q+=4)e(a.triangles,q);q=0;for(n=a.trianglesNormals.length;q<n;q+=7)h(a.trianglesNormals,q);q=0;for(n=a.quads.length;q<n;q+=5)j(a.quads,q);q=0;for(n=a.quadsNormals.length;q<n;q+=9)l(a.quadsNormals,q)})();(function(){var e,h,j,l;if(a.skinWeights){e=0;for(h=a.skinWeights.length;e<h;e+=2){j=a.skinWeights[e];l=a.skinWeights[e+1];THREE.Loader.prototype.sw(c,j,l,0,0)}}if(a.skinIndices){e=0;for(h=a.skinIndices.length;e<h;e+=2){j=a.skinIndices[e];l=a.skinIndices[e+1];THREE.Loader.prototype.si(c,
-j,l,0,0)}}THREE.Loader.prototype.bones(c,a.bones);THREE.Loader.prototype.animation(c,a.animation)})();this.computeCentroids();this.computeFaceNormals();this.sortFacesByMaterial()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;d(new f(b))},bones:function(a,d){a.bones=d},animation:function(a,d){a.animation=d},si:function(a,d,b,f,g){a.skinIndices.push(new THREE.Vector4(d,b,f,g))},sw:function(a,d,b,f,g){a.skinWeights.push(new THREE.Vector4(d,b,f,g))},v:function(a,d,b,f){a.vertices.push(new THREE.Vertex(new THREE.Vector3(d,
-b,f)))},vc:function(a,d,b,f){var g=new THREE.Color(16777215);g.setRGB(d,b,f);a.colors.push(g)},f3:function(a,d,b,f,g){a.faces.push(new THREE.Face3(d,b,f,null,a.materials[g]))},f4:function(a,d,b,f,g,c){a.faces.push(new THREE.Face4(d,b,f,g,null,a.materials[c]))},f3n:function(a,d,b,f,g,c,e,h,j){c=a.materials[c];var l=d[h*3],m=d[h*3+1];h=d[h*3+2];var v=d[j*3],q=d[j*3+1];j=d[j*3+2];a.faces.push(new THREE.Face3(b,f,g,[new THREE.Vector3(d[e*3],d[e*3+1],d[e*3+2]),new THREE.Vector3(l,m,h),new THREE.Vector3(v,
-q,j)],c))},f4n:function(a,d,b,f,g,c,e,h,j,l,m){e=a.materials[e];var v=d[j*3],q=d[j*3+1];j=d[j*3+2];var n=d[l*3],p=d[l*3+1];l=d[l*3+2];var t=d[m*3],z=d[m*3+1];m=d[m*3+2];a.faces.push(new THREE.Face4(b,f,g,c,[new THREE.Vector3(d[h*3],d[h*3+1],d[h*3+2]),new THREE.Vector3(v,q,j),new THREE.Vector3(n,p,l),new THREE.Vector3(t,z,m)],e))},uv3:function(a,d,b,f,g,c,e){var h=[];h.push(new THREE.UV(d,b));h.push(new THREE.UV(f,g));h.push(new THREE.UV(c,e));a.push(h)},uv4:function(a,d,b,f,g,c,e,h,j){var l=[];l.push(new THREE.UV(d,
-b));l.push(new THREE.UV(f,g));l.push(new THREE.UV(c,e));l.push(new THREE.UV(h,j));a.push(l)},init_materials:function(a,d,b){a.materials=[];for(var f=0;f<d.length;++f)a.materials[f]=[THREE.Loader.prototype.createMaterial(d[f],b)]},createMaterial:function(a,d){function b(h){h=Math.log(h)/Math.LN2;return Math.floor(h)==h}function f(h,j){var l=new Image;l.onload=function(){if(!b(this.width)||!b(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),v=Math.pow(2,Math.round(Math.log(this.height)/
-Math.LN2));h.image.width=m;h.image.height=v;h.image.getContext("2d").drawImage(this,0,0,m,v)}else h.image=this;h.needsUpdate=!0};l.src=j}var g,c,e;g="MeshLambertMaterial";c={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(g="MeshPhongMaterial");if(a.mapDiffuse&&d){e=document.createElement("canvas");c.map=new THREE.Texture(e);f(c.map,d+"/"+a.mapDiffuse)}else if(a.colorDiffuse){e=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*
-255;c.color=e;c.opacity=a.transparency}else if(a.DbgColor)c.color=a.DbgColor;if(a.mapLightmap&&d){e=document.createElement("canvas");c.lightMap=new THREE.Texture(e);f(c.lightMap,d+"/"+a.mapLightmap)}return new THREE[g](c)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};
+o})(x);(function(o){var u,y=k.vertex_index_bytes*3+k.material_index_bytes+k.normal_index_bytes*3,B=o+k.ntri_smooth*y;for(u=o;u<B;u+=y)q(u);return B-o})(T);(function(o){var u,y=k.vertex_index_bytes*4+k.material_index_bytes,B=o+k.nquad_flat*y;for(u=o;u<B;u+=y)n(u);return B-o})(W);(function(o){var u,y=k.vertex_index_bytes*4+k.material_index_bytes+k.normal_index_bytes*4,B=o+k.nquad_smooth*y;for(u=o;u<B;u+=y)p(u);return B-o})(X);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;
+g.prototype.constructor=g;d(new g(b))},createModel:function(a,d,b){var f=function(g){var c=this;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(c,a.materials,g);(function(){var e,h,j,l,m;e=0;for(h=a.vertices.length;e<h;e+=3){j=a.vertices[e];l=a.vertices[e+1];m=a.vertices[e+2];THREE.Loader.prototype.v(c,j,l,m)}if(a.colors){e=0;for(h=a.colors.length;e<h;e+=3){j=a.colors[e];l=a.colors[e+1];m=a.colors[e+2];THREE.Loader.prototype.vc(c,j,l,m)}}})();(function(){function e(p,t){THREE.Loader.prototype.f3(c,
+p[t],p[t+1],p[t+2],p[t+3])}function h(p,t){THREE.Loader.prototype.f3n(c,a.normals,p[t],p[t+1],p[t+2],p[t+3],p[t+4],p[t+5],p[t+6])}function j(p,t){THREE.Loader.prototype.f4(c,p[t],p[t+1],p[t+2],p[t+3],p[t+4])}function l(p,t){THREE.Loader.prototype.f4n(c,a.normals,p[t],p[t+1],p[t+2],p[t+3],p[t+4],p[t+5],p[t+6],p[t+7],p[t+8])}function m(p,t){var z,w,x,k,D,E,J,A,C;z=p[t];w=p[t+1];x=p[t+2];k=a.uvs[z*2];J=a.uvs[z*2+1];D=a.uvs[w*2];A=a.uvs[w*2+1];E=a.uvs[x*2];C=a.uvs[x*2+1];THREE.Loader.prototype.uv3(c.uvs,
+k,J,D,A,E,C);if(a.uvs2&&a.uvs2.length){k=a.uvs2[z*2];J=a.uvs2[z*2+1];D=a.uvs2[w*2];A=a.uvs2[w*2+1];E=a.uvs2[x*2];C=a.uvs2[x*2+1];THREE.Loader.prototype.uv3(c.uvs2,k,1-J,D,1-A,E,1-C)}}function v(p,t){var z,w,x,k,D,E,J,A,C,H,I,K;z=p[t];w=p[t+1];x=p[t+2];k=p[t+3];D=a.uvs[z*2];C=a.uvs[z*2+1];E=a.uvs[w*2];H=a.uvs[w*2+1];J=a.uvs[x*2];I=a.uvs[x*2+1];A=a.uvs[k*2];K=a.uvs[k*2+1];THREE.Loader.prototype.uv4(c.uvs,D,C,E,H,J,I,A,K);if(a.uvs2){D=a.uvs2[z*2];C=a.uvs2[z*2+1];E=a.uvs2[w*2];H=a.uvs2[w*2+1];J=a.uvs2[x*
+2];I=a.uvs2[x*2+1];A=a.uvs2[k*2];K=a.uvs2[k*2+1];THREE.Loader.prototype.uv4(c.uvs2,D,1-C,E,1-H,J,1-I,A,1-K)}}var q,n;q=0;for(n=a.trianglesUvs.length;q<n;q+=7){e(a.trianglesUvs,q);m(a.trianglesUvs,q+4)}q=0;for(n=a.trianglesNormalsUvs.length;q<n;q+=10){h(a.trianglesNormalsUvs,q);m(a.trianglesNormalsUvs,q+7)}q=0;for(n=a.quadsUvs.length;q<n;q+=9){j(a.quadsUvs,q);v(a.quadsUvs,q+5)}q=0;for(n=a.quadsNormalsUvs.length;q<n;q+=13){l(a.quadsNormalsUvs,q);v(a.quadsNormalsUvs,q+9)}q=0;for(n=a.triangles.length;q<
+n;q+=4)e(a.triangles,q);q=0;for(n=a.trianglesNormals.length;q<n;q+=7)h(a.trianglesNormals,q);q=0;for(n=a.quads.length;q<n;q+=5)j(a.quads,q);q=0;for(n=a.quadsNormals.length;q<n;q+=9)l(a.quadsNormals,q)})();(function(){var e,h,j,l;if(a.skinWeights){e=0;for(h=a.skinWeights.length;e<h;e+=2){j=a.skinWeights[e];l=a.skinWeights[e+1];THREE.Loader.prototype.sw(c,j,l,0,0)}}if(a.skinIndices){e=0;for(h=a.skinIndices.length;e<h;e+=2){j=a.skinIndices[e];l=a.skinIndices[e+1];THREE.Loader.prototype.si(c,j,l,0,0)}}THREE.Loader.prototype.bones(c,
+a.bones);THREE.Loader.prototype.animation(c,a.animation)})();this.computeCentroids();this.computeFaceNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;d(new f(b))},bones:function(a,d){a.bones=d},animation:function(a,d){a.animation=d},si:function(a,d,b,f,g){a.skinIndices.push(new THREE.Vector4(d,b,f,g))},sw:function(a,d,b,f,g){a.skinWeights.push(new THREE.Vector4(d,b,f,g))},v:function(a,d,b,f){a.vertices.push(new THREE.Vertex(new THREE.Vector3(d,b,f)))},vc:function(a,d,b,f){var g=
+new THREE.Color(16777215);g.setRGB(d,b,f);a.colors.push(g)},f3:function(a,d,b,f,g){a.faces.push(new THREE.Face3(d,b,f,null,a.materials[g]))},f4:function(a,d,b,f,g,c){a.faces.push(new THREE.Face4(d,b,f,g,null,a.materials[c]))},f3n:function(a,d,b,f,g,c,e,h,j){c=a.materials[c];var l=d[h*3],m=d[h*3+1];h=d[h*3+2];var v=d[j*3],q=d[j*3+1];j=d[j*3+2];a.faces.push(new THREE.Face3(b,f,g,[new THREE.Vector3(d[e*3],d[e*3+1],d[e*3+2]),new THREE.Vector3(l,m,h),new THREE.Vector3(v,q,j)],c))},f4n:function(a,d,b,f,
+g,c,e,h,j,l,m){e=a.materials[e];var v=d[j*3],q=d[j*3+1];j=d[j*3+2];var n=d[l*3],p=d[l*3+1];l=d[l*3+2];var t=d[m*3],z=d[m*3+1];m=d[m*3+2];a.faces.push(new THREE.Face4(b,f,g,c,[new THREE.Vector3(d[h*3],d[h*3+1],d[h*3+2]),new THREE.Vector3(v,q,j),new THREE.Vector3(n,p,l),new THREE.Vector3(t,z,m)],e))},uv3:function(a,d,b,f,g,c,e){var h=[];h.push(new THREE.UV(d,b));h.push(new THREE.UV(f,g));h.push(new THREE.UV(c,e));a.push(h)},uv4:function(a,d,b,f,g,c,e,h,j){var l=[];l.push(new THREE.UV(d,b));l.push(new THREE.UV(f,
+g));l.push(new THREE.UV(c,e));l.push(new THREE.UV(h,j));a.push(l)},init_materials:function(a,d,b){a.materials=[];for(var f=0;f<d.length;++f)a.materials[f]=[THREE.Loader.prototype.createMaterial(d[f],b)]},createMaterial:function(a,d){function b(h){h=Math.log(h)/Math.LN2;return Math.floor(h)==h}function f(h,j){var l=new Image;l.onload=function(){if(!b(this.width)||!b(this.height)){var m=Math.pow(2,Math.round(Math.log(this.width)/Math.LN2)),v=Math.pow(2,Math.round(Math.log(this.height)/Math.LN2));h.image.width=
+m;h.image.height=v;h.image.getContext("2d").drawImage(this,0,0,m,v)}else h.image=this;h.needsUpdate=!0};l.src=j}var g,c,e;g="MeshLambertMaterial";c={color:15658734,opacity:1,map:null,lightMap:null,vertexColors:a.vertexColors};a.shading&&a.shading=="Phong"&&(g="MeshPhongMaterial");if(a.mapDiffuse&&d){e=document.createElement("canvas");c.map=new THREE.Texture(e);f(c.map,d+"/"+a.mapDiffuse)}else if(a.colorDiffuse){e=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;c.color=
+e;c.opacity=a.transparency}else if(a.DbgColor)c.color=a.DbgColor;if(a.mapLightmap&&d){e=document.createElement("canvas");c.lightMap=new THREE.Texture(e);f(c.lightMap,d+"/"+a.mapLightmap)}return new THREE[g](c)},extractUrlbase:function(a){a=a.split("/");a.pop();return a.join("/")}};

+ 38 - 39
build/custom/ThreeSVG.js

@@ -11,35 +11,35 @@ a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-th
 this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,c,d){this.set(a||0,b||0,c||0,d||1)};
 THREE.Vector4.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,g){return f.distance-g.distance});return e},intersectObject:function(a){function b(t,j,H,p){p=p.clone().subSelf(j);H=H.clone().subSelf(j);var y=t.clone().subSelf(j);t=p.dot(p);j=p.dot(H);p=p.dot(y);var C=H.dot(H);H=H.dot(y);y=1/(t*C-j*j);C=(C*p-j*H)*y;t=(t*H-j*p)*y;return C>0&&t>0&&C+t<1}var c,d,e,f,g,i,h,k,n,m,
-l,o=a.geometry,q=o.vertices,s=[];c=0;for(d=o.faces.length;c<d;c++){e=o.faces[c];m=this.origin.clone();l=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(q[e.a].position.clone());g=h.multiplyVector3(q[e.b].position.clone());i=h.multiplyVector3(q[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(q[e.d].position.clone()):null;k=a.matrixRotationWorld.multiplyVector3(e.normal.clone());n=l.dot(k);if(n<0){k=k.dot((new THREE.Vector3).sub(f,m))/n;m=m.addSelf(l.multiplyScalar(k));
+THREE.Ray.prototype={intersectScene:function(a){var b,c,d=a.objects,e=[];a=0;for(b=d.length;a<b;a++){c=d[a];c instanceof THREE.Mesh&&(e=e.concat(this.intersectObject(c)))}e.sort(function(f,g){return f.distance-g.distance});return e},intersectObject:function(a){function b(t,j,H,p){p=p.clone().subSelf(j);H=H.clone().subSelf(j);var y=t.clone().subSelf(j);t=p.dot(p);j=p.dot(H);p=p.dot(y);var C=H.dot(H);H=H.dot(y);y=1/(t*C-j*j);C=(C*p-j*H)*y;t=(t*H-j*p)*y;return C>0&&t>0&&C+t<1}var c,d,e,f,g,i,h,l,n,m,
+k,o=a.geometry,q=o.vertices,s=[];c=0;for(d=o.faces.length;c<d;c++){e=o.faces[c];m=this.origin.clone();k=this.direction.clone();h=a.matrixWorld;f=h.multiplyVector3(q[e.a].position.clone());g=h.multiplyVector3(q[e.b].position.clone());i=h.multiplyVector3(q[e.c].position.clone());h=e instanceof THREE.Face4?h.multiplyVector3(q[e.d].position.clone()):null;l=a.matrixRotationWorld.multiplyVector3(e.normal.clone());n=k.dot(l);if(n<0){l=l.dot((new THREE.Vector3).sub(f,m))/n;m=m.addSelf(k.multiplyScalar(l));
 if(e instanceof THREE.Face3){if(b(m,f,g,i)){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};s.push(e)}}else if(e instanceof THREE.Face4&&(b(m,f,g,h)||b(m,g,i,h))){e={distance:this.origin.distanceTo(m),point:m,face:e,object:a};s.push(e)}}}return s}};
-THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,k,n,m){i=!1;b=h;c=k;d=n;e=m;a()};this.addPoint=function(h,k){if(i){i=!1;b=h;c=k;d=h;e=k}else{b=b<h?b:h;c=c<k?c:k;d=d>h?d:h;e=e>k?e:k}a()};
-this.add3Points=function(h,k,n,m,l,o){if(i){i=!1;b=h<n?h<l?h:l:n<l?n:l;c=k<m?k<o?k:o:m<o?m:o;d=h>n?h>l?h:l:n>l?n:l;e=k>m?k>o?k:o:m>o?m:o}else{b=h<n?h<l?h<b?h:b:l<b?l:b:n<l?n<b?n:b:l<b?l:b;c=k<m?k<o?k<c?k:c:o<c?o:c:m<o?m<c?m:c:o<c?o:c;d=h>n?h>l?h>d?h:d:l>d?l:d:n>l?n>d?n:d:l>d?l:d;e=k>m?k>o?k>e?k:e:o>e?o:e:m>o?m>e?m:e:o>e?o:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
+THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(h,l,n,m){i=!1;b=h;c=l;d=n;e=m;a()};this.addPoint=function(h,l){if(i){i=!1;b=h;c=l;d=h;e=l}else{b=b<h?b:h;c=c<l?c:l;d=d>h?d:h;e=e>l?e:l}a()};
+this.add3Points=function(h,l,n,m,k,o){if(i){i=!1;b=h<n?h<k?h:k:n<k?n:k;c=l<m?l<o?l:o:m<o?m:o;d=h>n?h>k?h:k:n>k?n:k;e=l>m?l>o?l:o:m>o?m:o}else{b=h<n?h<k?h<b?h:b:k<b?k:b:n<k?n<b?n:b:k<b?k:b;c=l<m?l<o?l<c?l:c:o<c?o:c:m<o?m<c?m:c:o<c?o:c;d=h>n?h>k?h>d?h:d:k>d?k:d:n>k?n>d?n:d:k>d?k:d;e=l>m?l>o?l>e?l:e:o>e?o:e:m>o?m>e?m:e:o>e?o:e}a()};this.addRectangle=function(h){if(i){i=!1;b=h.getLeft();c=h.getTop();d=h.getRight();e=h.getBottom()}else{b=b<h.getLeft()?b:h.getLeft();c=c<h.getTop()?c:h.getTop();d=d>h.getRight()?
 d:h.getRight();e=e>h.getBottom()?e:h.getBottom()}a()};this.inflate=function(h){b-=h;c-=h;d+=h;e+=h;a()};this.minSelf=function(h){b=b>h.getLeft()?b:h.getLeft();c=c>h.getTop()?c:h.getTop();d=d<h.getRight()?d:h.getRight();e=e<h.getBottom()?e:h.getBottom();a()};this.instersects=function(h){return Math.min(d,h.getRight())-Math.max(b,h.getLeft())>=0&&Math.min(e,h.getBottom())-Math.max(c,h.getTop())>=0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,d,e,f,g,i,h,k,n,m,l,o,q,s){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,k||0,n||1,m||0,l||0,o||0,q||0,s||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,k,n,m,l,o,q,s){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=k;this.n33=n;this.n34=m;this.n41=l;this.n42=o;this.n43=q;this.n44=s;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,
+THREE.Matrix4=function(a,b,c,d,e,f,g,i,h,l,n,m,k,o,q,s){this.set(a||1,b||0,c||0,d||0,e||0,f||1,g||0,i||0,h||0,l||0,n||1,m||0,k||0,o||0,q||0,s||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,c,d,e,f,g,i,h,l,n,m,k,o,q,s){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=h;this.n32=l;this.n33=n;this.n34=m;this.n41=k;this.n42=o;this.n43=q;this.n44=s;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,c){var d=THREE.Matrix4.__tmpVec1,
 e=THREE.Matrix4.__tmpVec2,f=THREE.Matrix4.__tmpVec3;f.sub(a,b).normalize();d.cross(c,f).normalize();e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n14=a.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n24=a.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*
 b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector3OnlyZ:function(a){var b=a.x,c=a.y;a=a.z;return(this.n31*b+this.n32*c+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*c+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},crossVector:function(a){var b=new THREE.Vector4;
-b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,k=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,s=a.n42,t=a.n43,j=a.n44,H=b.n11,p=b.n12,y=b.n13,C=b.n14,L=b.n21,z=b.n22,v=b.n23,I=b.n24,E=b.n31,K=b.n32,J=b.n33,u=b.n34;this.n11=c*
-H+d*L+e*E;this.n12=c*p+d*z+e*K;this.n13=c*y+d*v+e*J;this.n14=c*C+d*I+e*u+f;this.n21=g*H+i*L+h*E;this.n22=g*p+i*z+h*K;this.n23=g*y+i*v+h*J;this.n24=g*C+i*I+h*u+k;this.n31=n*H+m*L+l*E;this.n32=n*p+m*z+l*K;this.n33=n*y+m*v+l*J;this.n34=n*C+m*I+l*u+o;this.n41=q*H+s*L+t*E;this.n42=q*p+s*z+t*K;this.n43=q*y+s*v+t*J;this.n44=q*C+s*I+t*u+j;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,g=a.n14,i=a.n21,h=a.n22,k=a.n23,n=a.n24,m=a.n31,l=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,j=a.n43;
-a=a.n44;var H=b.n11,p=b.n12,y=b.n13,C=b.n14,L=b.n21,z=b.n22,v=b.n23,I=b.n24,E=b.n31,K=b.n32,J=b.n33,u=b.n34,D=b.n41,S=b.n42,x=b.n43;b=b.n44;this.n11=d*H+e*L+f*E+g*D;this.n12=d*p+e*z+f*K+g*S;this.n13=d*y+e*v+f*J+g*x;this.n14=d*C+e*I+f*u+g*b;this.n21=i*H+h*L+k*E+n*D;this.n22=i*p+h*z+k*K+n*S;this.n23=i*y+h*v+k*J+n*x;this.n24=i*C+h*I+k*u+n*b;this.n31=m*H+l*L+o*E+q*D;this.n32=m*p+l*z+o*K+q*S;this.n33=m*y+l*v+o*J+q*x;this.n34=m*C+l*I+o*u+q*b;this.n41=s*H+t*L+j*E+a*D;this.n42=s*p+t*z+j*K+a*S;this.n43=s*
-y+t*v+j*J+a*x;this.n44=s*C+t*I+j*u+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,g=this.n22,i=this.n23,h=this.n24,k=this.n31,n=this.n32,m=this.n33,l=this.n34,o=this.n41,q=this.n42,s=this.n43,t=this.n44,j=a.n11,H=a.n21,
-p=a.n31,y=a.n12,C=a.n22,L=a.n32,z=a.n13,v=a.n23,I=a.n33,E=a.n14,K=a.n24;a=a.n34;this.n11=b*j+c*H+d*p;this.n12=b*y+c*C+d*L;this.n13=b*z+c*v+d*I;this.n14=b*E+c*K+d*a+e;this.n21=f*j+g*H+i*p;this.n22=f*y+g*C+i*L;this.n23=f*z+g*v+i*I;this.n24=f*E+g*K+i*a+h;this.n31=k*j+n*H+m*p;this.n32=k*y+n*C+m*L;this.n33=k*z+n*v+m*I;this.n34=k*E+n*K+m*a+l;this.n41=o*j+q*H+s*p;this.n42=o*y+q*C+s*L;this.n43=o*z+q*v+s*I;this.n44=o*E+q*K+s*a+t;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=
-a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,k=this.n32,n=this.n33,m=this.n34,l=this.n41,o=this.n42,q=this.n43,s=this.n44;return d*g*k*l-c*i*k*l-d*f*n*l+b*i*n*l+c*f*m*l-b*g*m*l-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+d*f*h*q-b*i*h*q-d*e*k*q+a*i*k*q+b*e*
-m*q-a*f*m*q-c*f*h*s+b*g*h*s+c*e*k*s-a*g*k*s-b*e*n*s+a*f*n*s},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;
+b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,q=a.n41,s=a.n42,t=a.n43,j=a.n44,H=b.n11,p=b.n12,y=b.n13,C=b.n14,L=b.n21,z=b.n22,v=b.n23,I=b.n24,E=b.n31,K=b.n32,J=b.n33,u=b.n34;this.n11=c*
+H+d*L+e*E;this.n12=c*p+d*z+e*K;this.n13=c*y+d*v+e*J;this.n14=c*C+d*I+e*u+f;this.n21=g*H+i*L+h*E;this.n22=g*p+i*z+h*K;this.n23=g*y+i*v+h*J;this.n24=g*C+i*I+h*u+l;this.n31=n*H+m*L+k*E;this.n32=n*p+m*z+k*K;this.n33=n*y+m*v+k*J;this.n34=n*C+m*I+k*u+o;this.n41=q*H+s*L+t*E;this.n42=q*p+s*z+t*K;this.n43=q*y+s*v+t*J;this.n44=q*C+s*I+t*u+j;return this},multiplyToArray:function(a,b,c){var d=a.n11,e=a.n12,f=a.n13,g=a.n14,i=a.n21,h=a.n22,l=a.n23,n=a.n24,m=a.n31,k=a.n32,o=a.n33,q=a.n34,s=a.n41,t=a.n42,j=a.n43;
+a=a.n44;var H=b.n11,p=b.n12,y=b.n13,C=b.n14,L=b.n21,z=b.n22,v=b.n23,I=b.n24,E=b.n31,K=b.n32,J=b.n33,u=b.n34,D=b.n41,S=b.n42,x=b.n43;b=b.n44;this.n11=d*H+e*L+f*E+g*D;this.n12=d*p+e*z+f*K+g*S;this.n13=d*y+e*v+f*J+g*x;this.n14=d*C+e*I+f*u+g*b;this.n21=i*H+h*L+l*E+n*D;this.n22=i*p+h*z+l*K+n*S;this.n23=i*y+h*v+l*J+n*x;this.n24=i*C+h*I+l*u+n*b;this.n31=m*H+k*L+o*E+q*D;this.n32=m*p+k*z+o*K+q*S;this.n33=m*y+k*v+o*J+q*x;this.n34=m*C+k*I+o*u+q*b;this.n41=s*H+t*L+j*E+a*D;this.n42=s*p+t*z+j*K+a*S;this.n43=s*
+y+t*v+j*J+a*x;this.n44=s*C+t*I+j*u+a*b;c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,c=this.n12,d=this.n13,e=this.n14,f=this.n21,g=this.n22,i=this.n23,h=this.n24,l=this.n31,n=this.n32,m=this.n33,k=this.n34,o=this.n41,q=this.n42,s=this.n43,t=this.n44,j=a.n11,H=a.n21,
+p=a.n31,y=a.n12,C=a.n22,L=a.n32,z=a.n13,v=a.n23,I=a.n33,E=a.n14,K=a.n24;a=a.n34;this.n11=b*j+c*H+d*p;this.n12=b*y+c*C+d*L;this.n13=b*z+c*v+d*I;this.n14=b*E+c*K+d*a+e;this.n21=f*j+g*H+i*p;this.n22=f*y+g*C+i*L;this.n23=f*z+g*v+i*I;this.n24=f*E+g*K+i*a+h;this.n31=l*j+n*H+m*p;this.n32=l*y+n*C+m*L;this.n33=l*z+n*v+m*I;this.n34=l*E+n*K+m*a+k;this.n41=o*j+q*H+s*p;this.n42=o*y+q*C+s*L;this.n43=o*z+q*v+s*I;this.n44=o*E+q*K+s*a+t;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=
+a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,i=this.n24,h=this.n31,l=this.n32,n=this.n33,m=this.n34,k=this.n41,o=this.n42,q=this.n43,s=this.n44;return d*g*l*k-c*i*l*k-d*f*n*k+b*i*n*k+c*f*m*k-b*g*m*k-d*g*h*o+c*i*h*o+d*e*n*o-a*i*n*o-c*e*m*o+a*g*m*o+d*f*h*q-b*i*h*q-d*e*l*q+a*i*l*q+b*e*
+m*q-a*f*m*q-c*f*h*s+b*g*h*s+c*e*l*s-a*g*l*s-b*e*n*s+a*f*n*s},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;
 a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flattenToArray(this.flat);return this.flat},flattenToArray:function(a){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},flattenToArrayOffset:function(a,b){a[b]=
 this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,
-b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,k=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,k*g+c,k*i-d*f,0,h*i-d*g,k*i+d*f,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;
-this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var k=c*g;c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(k+d);this.n12=h-e;this.n13=
-b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+k)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};
+b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,i=a.z,h=e*f,l=e*g;this.set(h*f+c,h*g-d*i,h*i+d*g,0,h*g+d*i,l*g+c,l*i-d*f,0,h*i-d*g,l*i+d*f,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;
+this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,c=a.y,d=a.z;a=Math.cos(b);b=Math.sin(b);var e=Math.cos(c);c=Math.sin(c);var f=Math.cos(d);d=Math.sin(d);var g=a*c,i=b*c;this.n11=e*f;this.n12=-e*d;this.n13=c;this.n21=i*f+a*d;this.n22=-i*d+a*f;this.n23=-b*e;this.n31=-g*f+b*d;this.n32=g*d+b*f;this.n33=a*e},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,i=d+d;a=b*f;var h=b*g;b*=i;var l=c*g;c*=i;d*=i;f*=e;g*=e;e*=i;this.n11=1-(l+d);this.n12=h-e;this.n13=
+b+g;this.n21=h+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+l)},scale:function(a){var b=a.x,c=a.y;a=a.z;this.n11*=b;this.n12*=c;this.n13*=a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setTranslation(a,b,c);return d};THREE.Matrix4.scaleMatrix=function(a,b,c){var d=new THREE.Matrix4;d.setScale(a,b,c);return d};
 THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var c=new THREE.Matrix4;c.setRotAxis(a,b);return c};
-THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,k=a.n24,n=a.n31,m=a.n32,l=a.n33,o=a.n34,q=a.n41,s=a.n42,t=a.n43,j=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*s-k*l*s+k*m*t-i*o*t-h*m*j+i*l*j;b.n12=f*l*s-e*o*s-f*m*t+d*o*t+e*m*j-d*l*j;b.n13=e*k*s-f*h*s+f*i*t-d*k*t-e*i*j+d*h*j;b.n14=f*h*m-e*k*m-f*i*l+d*k*l+e*i*o-d*h*o;b.n21=k*l*q-h*o*q-k*n*t+g*o*t+h*n*j-g*l*j;b.n22=e*o*q-f*l*q+f*n*t-c*o*t-e*n*j+c*l*j;b.n23=f*h*q-e*k*q-f*g*t+c*k*t+e*g*j-c*h*j;
-b.n24=e*k*n-f*h*n+f*g*l-c*k*l-e*g*o+c*h*o;b.n31=i*o*q-k*m*q+k*n*s-g*o*s-i*n*j+g*m*j;b.n32=f*m*q-d*o*q-f*n*s+c*o*s+d*n*j-c*m*j;b.n33=e*k*q-f*i*q+f*g*s-c*k*s-d*g*j+c*i*j;b.n34=f*i*n-d*k*n-f*g*m+c*k*m+d*g*o-c*i*o;b.n41=h*m*q-i*l*q-h*n*s+g*l*s+i*n*t-g*m*t;b.n42=d*l*q-e*m*q+e*n*s-c*l*s-d*n*t+c*m*t;b.n43=e*i*q-d*h*q-e*g*s+c*h*s+d*g*t-c*i*t;b.n44=d*h*n-e*i*n+e*g*m-c*h*m-d*g*l+c*i*l;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,k=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*k;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*k;c[7]=a*n;c[8]=a*m;return b};
+THREE.Matrix4.makeInvert=function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,h=a.n23,l=a.n24,n=a.n31,m=a.n32,k=a.n33,o=a.n34,q=a.n41,s=a.n42,t=a.n43,j=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=h*o*s-l*k*s+l*m*t-i*o*t-h*m*j+i*k*j;b.n12=f*k*s-e*o*s-f*m*t+d*o*t+e*m*j-d*k*j;b.n13=e*l*s-f*h*s+f*i*t-d*l*t-e*i*j+d*h*j;b.n14=f*h*m-e*l*m-f*i*k+d*l*k+e*i*o-d*h*o;b.n21=l*k*q-h*o*q-l*n*t+g*o*t+h*n*j-g*k*j;b.n22=e*o*q-f*k*q+f*n*t-c*o*t-e*n*j+c*k*j;b.n23=f*h*q-e*l*q-f*g*t+c*l*t+e*g*j-c*h*j;
+b.n24=e*l*n-f*h*n+f*g*k-c*l*k-e*g*o+c*h*o;b.n31=i*o*q-l*m*q+l*n*s-g*o*s-i*n*j+g*m*j;b.n32=f*m*q-d*o*q-f*n*s+c*o*s+d*n*j-c*m*j;b.n33=e*l*q-f*i*q+f*g*s-c*l*s-d*g*j+c*i*j;b.n34=f*i*n-d*l*n-f*g*m+c*l*m+d*g*o-c*i*o;b.n41=h*m*q-i*k*q-h*n*s+g*k*s+i*n*t-g*m*t;b.n42=d*k*q-e*m*q+e*n*s-c*k*s-d*n*t+c*m*t;b.n43=e*i*q-d*h*q-e*g*s+c*h*s+d*g*t-c*i*t;b.n44=d*h*n-e*i*n+e*g*m-c*h*m-d*g*k+c*i*k;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,h=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,n=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12;a=a.n11*d+a.n21*g+a.n31*l;if(a==0)throw"matrix not invertible";a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*h;c[6]=a*l;c[7]=a*n;c[8]=a*m;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var e;a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,i,h,k;g=new THREE.Matrix4;i=b-a;h=c-d;k=f-e;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/k;g.n34=-((f+e)/k);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.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,i,h,l;g=new THREE.Matrix4;i=b-a;h=c-d;l=f-e;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/h;g.n23=0;g.n24=-((c+d)/h);g.n31=0;g.n32=0;g.n33=-2/l;g.n34=-((f+e)/l);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.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;
 this.visible=!0};
 THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);
@@ -48,22 +48,21 @@ this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.
 THREE.Object3DCounter={value:0};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,d!==undefined?d:1)};
 THREE.Quaternion.prototype={set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b;a=Math.cos(d);d=Math.sin(d);b=Math.cos(-e);e=Math.sin(-e);var f=Math.cos(c);c=Math.sin(c);var g=a*b,i=d*e;this.w=g*f-i*c;this.x=g*c+i*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
 -1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,i=a.z;a=a.w;this.x=b*a+e*f+c*i-d*g;this.y=c*a+e*g+d*f-b*i;this.z=d*a+e*i+b*g-c*f;this.w=e*a-b*f-c*g-d*i;return this},
-multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,i=this.z,h=this.w,k=h*c+g*e-i*d,n=h*d+i*c-f*e,m=h*e+f*d-g*c;c=-f*c-g*d-i*e;b.x=k*h+c*-f+n*-i-m*-g;b.y=n*h+c*-g+m*-f-k*-i;b.z=m*h+c*-i+k*-g-n*-f;return b}};
+multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,i=this.z,h=this.w,l=h*c+g*e-i*d,n=h*d+i*c-f*e,m=h*e+f*d-g*c;c=-f*c-g*d-i*e;b.x=l*h+c*-f+n*-i-m*-g;b.y=n*h+c*-g+m*-f-l*-i;b.z=m*h+c*-i+l*-g-n*-f;return b}};
 THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(e)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(e),g=Math.sqrt(1-e*e);if(Math.abs(g)<0.001){c.w=0.5*(a.w+b.w);c.x=0.5*(a.x+b.x);c.y=0.5*(a.y+b.y);c.z=0.5*(a.z+b.z);return c}e=Math.sin((1-d)*f)/g;d=Math.sin(d*f)/g;c.w=a.w*e+b.w*d;c.x=a.x*e+b.x*d;c.y=a.y*e+b.y*d;c.z=a.z*e+b.z*d;return c};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};
 THREE.Face3=function(a,b,c,d,e){this.a=a;this.b=b;this.c=c;this.centroid=new THREE.Vector3;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.materials=e instanceof Array?e:[e]};THREE.Face4=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.d=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=f instanceof Array?f:[f]};
-THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=!1};
+THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,c;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];c.centroid.set(0,0,0);if(c instanceof THREE.Face3){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);c.centroid.divideScalar(3)}else if(c instanceof THREE.Face4){c.centroid.addSelf(this.vertices[c.a].position);c.centroid.addSelf(this.vertices[c.b].position);c.centroid.addSelf(this.vertices[c.c].position);
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,c,d,e,f,g,i=new THREE.Vector3,h=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){f=this.vertices[d];f.normal.set(0,0,0)}d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];if(a&&f.vertexNormals.length){i.set(0,0,0);b=0;for(c=f.normal.length;b<c;b++)i.addSelf(f.vertexNormals[b]);i.divideScalar(3)}else{b=this.vertices[f.a];c=this.vertices[f.b];g=this.vertices[f.c];i.sub(g.position,
 c.position);h.sub(b.position,c.position);i.crossSelf(h)}i.isZero()||i.normalize();f.normal.copy(i)}},computeVertexNormals:function(){var a,b,c,d;if(this.__tmpVertices==undefined){d=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,
 new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{d=this.__tmpVertices;a=0;for(b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;a++){c=this.faces[a];if(c instanceof THREE.Face3){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){d[c.a].addSelf(c.normal);d[c.b].addSelf(c.normal);d[c.c].addSelf(c.normal);d[c.d].addSelf(c.normal)}}a=0;for(b=this.vertices.length;a<b;a++)d[a].normalize();a=0;for(b=this.faces.length;a<
-b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(u,D,S,x,N,F,A){f=u.vertices[D].position;g=u.vertices[S].position;i=u.vertices[x].position;h=e[N];k=e[F];n=e[A];m=g.x-f.x;l=i.x-f.x;o=g.y-f.y;q=i.y-f.y;
-s=g.z-f.z;t=i.z-f.z;j=k.u-h.u;H=n.u-h.u;p=k.v-h.v;y=n.v-h.v;C=1/(j*y-H*p);v.set((y*m-p*l)*C,(y*o-p*q)*C,(y*s-p*t)*C);I.set((j*l-H*m)*C,(j*q-H*o)*C,(j*t-H*s)*C);L[D].addSelf(v);L[S].addSelf(v);L[x].addSelf(v);z[D].addSelf(I);z[S].addSelf(I);z[x].addSelf(I)}var b,c,d,e,f,g,i,h,k,n,m,l,o,q,s,t,j,H,p,y,C,L=[],z=[],v=new THREE.Vector3,I=new THREE.Vector3,E=new THREE.Vector3,K=new THREE.Vector3,J=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){L[b]=new THREE.Vector3;z[b]=new THREE.Vector3}b=0;
+b;a++){c=this.faces[a];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(d[c.a]);c.vertexNormals[1].copy(d[c.b]);c.vertexNormals[2].copy(d[c.c]);c.vertexNormals[3].copy(d[c.d])}}},computeTangents:function(){function a(u,D,S,x,N,F,A){f=u.vertices[D].position;g=u.vertices[S].position;i=u.vertices[x].position;h=e[N];l=e[F];n=e[A];m=g.x-f.x;k=i.x-f.x;o=g.y-f.y;q=i.y-f.y;
+s=g.z-f.z;t=i.z-f.z;j=l.u-h.u;H=n.u-h.u;p=l.v-h.v;y=n.v-h.v;C=1/(j*y-H*p);v.set((y*m-p*k)*C,(y*o-p*q)*C,(y*s-p*t)*C);I.set((j*k-H*m)*C,(j*q-H*o)*C,(j*t-H*s)*C);L[D].addSelf(v);L[S].addSelf(v);L[x].addSelf(v);z[D].addSelf(I);z[S].addSelf(I);z[x].addSelf(I)}var b,c,d,e,f,g,i,h,l,n,m,k,o,q,s,t,j,H,p,y,C,L=[],z=[],v=new THREE.Vector3,I=new THREE.Vector3,E=new THREE.Vector3,K=new THREE.Vector3,J=new THREE.Vector3;b=0;for(c=this.vertices.length;b<c;b++){L[b]=new THREE.Vector3;z[b]=new THREE.Vector3}b=0;
 for(c=this.faces.length;b<c;b++){d=this.faces[b];e=this.uvs[b];if(d instanceof THREE.Face3){a(this,d.a,d.b,d.c,0,1,2);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2])}else if(d instanceof THREE.Face4){a(this,d.a,d.b,d.c,0,1,2);a(this,d.a,d.b,d.d,0,1,3);this.vertices[d.a].normal.copy(d.vertexNormals[0]);this.vertices[d.b].normal.copy(d.vertexNormals[1]);this.vertices[d.c].normal.copy(d.vertexNormals[2]);
 this.vertices[d.d].normal.copy(d.vertexNormals[3])}}b=0;for(c=this.vertices.length;b<c;b++){J.copy(this.vertices[b].normal);d=L[b];E.copy(d);E.subSelf(J.multiplyScalar(J.dot(d))).normalize();K.cross(this.vertices[b].normal,d);d=K.dot(z[b]);d=d<0?-1:1;this.vertices[b].tangent.set(E.x,E.y,E.z,d)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,c=this.vertices.length;b<c;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(n){var m=[];b=0;for(c=n.length;b<c;b++)n[b]==undefined?m.push("undefined"):m.push(n[b].id);return m.join("_")}var b,c,d,e,f,g,i,h,k={};d=0;for(e=this.faces.length;d<e;d++){f=this.faces[d];
-g=f.materials;i=a(g);k[i]==undefined&&(k[i]={hash:i,counter:0});h=k[i].hash+"_"+k[i].counter;this.geometryChunks[h]==undefined&&(this.geometryChunks[h]={faces:[],materials:g,vertices:0});f=f instanceof THREE.Face3?3:4;if(this.geometryChunks[h].vertices+f>65535){k[i].counter+=1;h=k[i].hash+"_"+k[i].counter;this.geometryChunks[h]==undefined&&(this.geometryChunks[h]={faces:[],materials:g,vertices:0})}this.geometryChunks[h].faces.push(d);this.geometryChunks[h].vertices+=f}}};THREE.GeometryIdCounter=0;
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,c=this.vertices.length;b<c;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
 THREE.Camera=function(a,b,c,d,e){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=c||0.1;this.far=d||2E3;this.target=e||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);this.tmpVec.crossSelf(this.up);if(g)this.tmpVec.y=0;this.position.addSelf(this.tmpVec);
 this.target.position.addSelf(this.tmpVec)};this.translateZ=function(f,g){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(f);if(g)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
@@ -103,7 +102,7 @@ THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE
 THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)this.lights.indexOf(a)===-1&&this.lights.push(a);else if(a instanceof THREE.Sound)this.sounds.indexOf(a)===-1&&this.sounds.push(a);else a instanceof THREE.Camera||a instanceof THREE.Bone||this.objects.indexOf(a)===-1&&this.objects.push(a);for(var b=0;b<a.children.length;b++)this.addChildRecurse(a.children[b])};THREE.Scene.prototype.removeChild=function(a){this.supr.removeChild.call(this,a);this.removeChildRecurse(a)};
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;
-THREE.Projector=function(){function a(z,v){return v.z-z.z}function b(z,v){var I=0,E=1,K=z.z+z.w,J=v.z+v.w,u=-z.z+z.w,D=-v.z+v.w;if(K>=0&&J>=0&&u>=0&&D>=0)return!0;else if(K<0&&J<0||u<0&&D<0)return!1;else{if(K<0)I=Math.max(I,K/(K-J));else J<0&&(E=Math.min(E,K/(K-J)));if(u<0)I=Math.max(I,u/(u-D));else D<0&&(E=Math.min(E,u/(u-D)));if(E<I)return!1;else{z.lerpSelf(v,I);v.lerpSelf(z,1-E);return!0}}}var c,d,e=[],f,g,i,h=[],k,n,m=[],l,o,q=[],s=new THREE.Vector4,t=new THREE.Vector4,j=new THREE.Matrix4,H=new THREE.Matrix4,
+THREE.Projector=function(){function a(z,v){return v.z-z.z}function b(z,v){var I=0,E=1,K=z.z+z.w,J=v.z+v.w,u=-z.z+z.w,D=-v.z+v.w;if(K>=0&&J>=0&&u>=0&&D>=0)return!0;else if(K<0&&J<0||u<0&&D<0)return!1;else{if(K<0)I=Math.max(I,K/(K-J));else J<0&&(E=Math.min(E,K/(K-J)));if(u<0)I=Math.max(I,u/(u-D));else D<0&&(E=Math.min(E,u/(u-D)));if(E<I)return!1;else{z.lerpSelf(v,I);v.lerpSelf(z,1-E);return!0}}}var c,d,e=[],f,g,i,h=[],l,n,m=[],k,o,q=[],s=new THREE.Vector4,t=new THREE.Vector4,j=new THREE.Matrix4,H=new THREE.Matrix4,
 p=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],y=new THREE.Vector4,C=new THREE.Vector4,L;this.projectObjects=function(z,v,I){v=[];var E,K,J;d=0;K=z.objects;z=0;for(E=K.length;z<E;z++){J=K[z];var u;if(!(u=!J.visible))if(u=J instanceof THREE.Mesh){a:{u=void 0;for(var D=J.matrixWorld,S=-J.geometry.boundingSphere.radius*Math.max(J.scale.x,Math.max(J.scale.y,J.scale.z)),x=0;x<6;x++){u=p[x].x*D.n14+p[x].y*D.n24+p[x].z*D.n34+p[x].w;if(u<=S){u=
 !1;break a}}u=!0}u=!u}if(!u){c=e[d]=e[d]||new THREE.RenderableObject;s.copy(J.position);j.multiplyVector3(s);c.object=J;c.z=s.z;v.push(c);d++}}I&&v.sort(a);return v};this.projectScene=function(z,v,I){var E=[],K=v.near,J=v.far,u,D,S,x,N,F,A,O,Q,B,w,M,P,r,G,R;i=n=o=0;v.matrixAutoUpdate&&v.update();j.multiply(v.projectionMatrix,v.matrixWorldInverse);p[0].set(j.n41-j.n11,j.n42-j.n12,j.n43-j.n13,j.n44-j.n14);p[1].set(j.n41+j.n11,j.n42+j.n12,j.n43+j.n13,j.n44+j.n14);p[2].set(j.n41+j.n21,j.n42+j.n22,j.n43+
 j.n23,j.n44+j.n24);p[3].set(j.n41-j.n21,j.n42-j.n22,j.n43-j.n23,j.n44-j.n24);p[4].set(j.n41-j.n31,j.n42-j.n32,j.n43-j.n33,j.n44-j.n34);p[5].set(j.n41+j.n31,j.n42+j.n32,j.n43+j.n33,j.n44+j.n34);for(u=0;u<6;u++){F=p[u];F.divideScalar(Math.sqrt(F.x*F.x+F.y*F.y+F.z*F.z))}z.update(undefined,!1,v);F=this.projectObjects(z,v,!0);z=0;for(u=F.length;z<u;z++){A=F[z].object;if(A.visible){O=A.matrixWorld;w=A.matrixRotationWorld;Q=A.materials;B=A.overdraw;if(A instanceof THREE.Mesh){M=A.geometry;P=M.vertices;D=
@@ -113,23 +112,23 @@ G=r.vertexNormals;L=f.vertexNormalsWorld;x=0;for(N=G.length;x<N;x++){R=L[x]=L[x]
 x.positionScreen.x)*(N.positionScreen.y-x.positionScreen.y)-(R.positionScreen.y-x.positionScreen.y)*(N.positionScreen.x-x.positionScreen.x)<0||(N.positionScreen.x-G.positionScreen.x)*(R.positionScreen.y-G.positionScreen.y)-(N.positionScreen.y-G.positionScreen.y)*(R.positionScreen.x-G.positionScreen.x)<0))){f=h[i]=h[i]||new THREE.RenderableFace3;f.v1.positionWorld.copy(x.positionWorld);f.v2.positionWorld.copy(N.positionWorld);f.v3.positionWorld.copy(R.positionWorld);f.v1.positionScreen.copy(x.positionScreen);
 f.v2.positionScreen.copy(N.positionScreen);f.v3.positionScreen.copy(R.positionScreen);f.normalWorld.copy(r.normal);w.multiplyVector3(f.normalWorld);f.centroidWorld.copy(r.centroid);O.multiplyVector3(f.centroidWorld);f.centroidScreen.copy(f.centroidWorld);j.multiplyVector3(f.centroidScreen);f.z=f.centroidScreen.z;f.meshMaterials=Q;f.faceMaterials=r.materials;f.overdraw=B;if(A.geometry.uvs[D]){f.uvs[0]=A.geometry.uvs[D][0];f.uvs[1]=A.geometry.uvs[D][1];f.uvs[2]=A.geometry.uvs[D][3]}E.push(f);i++;g=
 h[i]=h[i]||new THREE.RenderableFace3;g.v1.positionWorld.copy(N.positionWorld);g.v2.positionWorld.copy(G.positionWorld);g.v3.positionWorld.copy(R.positionWorld);g.v1.positionScreen.copy(N.positionScreen);g.v2.positionScreen.copy(G.positionScreen);g.v3.positionScreen.copy(R.positionScreen);g.normalWorld.copy(f.normalWorld);g.centroidWorld.copy(f.centroidWorld);g.centroidScreen.copy(f.centroidScreen);g.z=g.centroidScreen.z;g.meshMaterials=Q;g.faceMaterials=r.materials;g.overdraw=B;if(A.geometry.uvs[D]){g.uvs[0]=
-A.geometry.uvs[D][1];g.uvs[1]=A.geometry.uvs[D][2];g.uvs[2]=A.geometry.uvs[D][3]}E.push(g);i++}}}}else if(A instanceof THREE.Line){H.multiply(j,O);P=A.geometry.vertices;r=P[0];r.positionScreen.copy(r.position);H.multiplyVector4(r.positionScreen);D=1;for(S=P.length;D<S;D++){x=P[D];x.positionScreen.copy(x.position);H.multiplyVector4(x.positionScreen);N=P[D-1];y.copy(x.positionScreen);C.copy(N.positionScreen);if(b(y,C)){y.multiplyScalar(1/y.w);C.multiplyScalar(1/C.w);k=m[n]=m[n]||new THREE.RenderableLine;
-k.v1.positionScreen.copy(y);k.v2.positionScreen.copy(C);k.z=Math.max(y.z,C.z);k.materials=A.materials;E.push(k);n++}}}else if(A instanceof THREE.Particle){t.set(A.position.x,A.position.y,A.position.z,1);j.multiplyVector4(t);t.z/=t.w;if(t.z>0&&t.z<1){l=q[o]=q[o]||new THREE.RenderableParticle;l.x=t.x/t.w;l.y=t.y/t.w;l.z=t.z;l.rotation=A.rotation.z;l.scale.x=A.scale.x*Math.abs(l.x-(t.x+v.projectionMatrix.n11)/(t.w+v.projectionMatrix.n14));l.scale.y=A.scale.y*Math.abs(l.y-(t.y+v.projectionMatrix.n22)/
-(t.w+v.projectionMatrix.n24));l.materials=A.materials;E.push(l);o++}}}}I&&E.sort(a);return E};this.unprojectVector=function(z,v){var I=v.matrixWorld.clone();I.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));I.multiplyVector3(z);return z}};
+A.geometry.uvs[D][1];g.uvs[1]=A.geometry.uvs[D][2];g.uvs[2]=A.geometry.uvs[D][3]}E.push(g);i++}}}}else if(A instanceof THREE.Line){H.multiply(j,O);P=A.geometry.vertices;r=P[0];r.positionScreen.copy(r.position);H.multiplyVector4(r.positionScreen);D=1;for(S=P.length;D<S;D++){x=P[D];x.positionScreen.copy(x.position);H.multiplyVector4(x.positionScreen);N=P[D-1];y.copy(x.positionScreen);C.copy(N.positionScreen);if(b(y,C)){y.multiplyScalar(1/y.w);C.multiplyScalar(1/C.w);l=m[n]=m[n]||new THREE.RenderableLine;
+l.v1.positionScreen.copy(y);l.v2.positionScreen.copy(C);l.z=Math.max(y.z,C.z);l.materials=A.materials;E.push(l);n++}}}else if(A instanceof THREE.Particle){t.set(A.position.x,A.position.y,A.position.z,1);j.multiplyVector4(t);t.z/=t.w;if(t.z>0&&t.z<1){k=q[o]=q[o]||new THREE.RenderableParticle;k.x=t.x/t.w;k.y=t.y/t.w;k.z=t.z;k.rotation=A.rotation.z;k.scale.x=A.scale.x*Math.abs(k.x-(t.x+v.projectionMatrix.n11)/(t.w+v.projectionMatrix.n14));k.scale.y=A.scale.y*Math.abs(k.y-(t.y+v.projectionMatrix.n22)/
+(t.w+v.projectionMatrix.n24));k.materials=A.materials;E.push(k);o++}}}}I&&E.sort(a);return E};this.unprojectVector=function(z,v){var I=v.matrixWorld.clone();I.multiplySelf(THREE.Matrix4.makeInvert(v.projectionMatrix));I.multiplyVector3(z);return z}};
 THREE.SVGRenderer=function(){function a(F,A,O){var Q,B,w,M;Q=0;for(B=F.lights.length;Q<B;Q++){w=F.lights[Q];if(w instanceof THREE.DirectionalLight){M=A.normalWorld.dot(w.position)*w.intensity;if(M>0){O.r+=w.color.r*M;O.g+=w.color.g*M;O.b+=w.color.b*M}}else if(w instanceof THREE.PointLight){I.sub(w.position,A.centroidWorld);I.normalize();M=A.normalWorld.dot(I)*w.intensity;if(M>0){O.r+=w.color.r*M;O.g+=w.color.g*M;O.b+=w.color.b*M}}}}function b(F,A,O,Q,B,w){u=d(D++);u.setAttribute("d","M "+F.positionScreen.x+
 " "+F.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+"z");if(B instanceof THREE.MeshBasicMaterial)p.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshLambertMaterial)if(H){y.r=C.r;y.g=C.g;y.b=C.b;a(w,Q,y);p.r=B.color.r*y.r;p.g=B.color.g*y.g;p.b=B.color.b*y.b;p.updateStyleString()}else p.__styleString=B.color.__styleString;else if(B instanceof THREE.MeshDepthMaterial){v=1-B.__2near/(B.__farPlusNear-Q.z*B.__farMinusNear);
 p.setRGB(v,v,v)}else B instanceof THREE.MeshNormalMaterial&&p.setRGB(e(Q.normalWorld.x),e(Q.normalWorld.y),e(Q.normalWorld.z));B.wireframe?u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+B.wireframeLinewidth+"; stroke-opacity: "+B.opacity+"; stroke-linecap: "+B.wireframeLinecap+"; stroke-linejoin: "+B.wireframeLinejoin):u.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+B.opacity);i.appendChild(u)}function c(F,A,O,Q,B,w,M){u=d(D++);u.setAttribute("d",
 "M "+F.positionScreen.x+" "+F.positionScreen.y+" L "+A.positionScreen.x+" "+A.positionScreen.y+" L "+O.positionScreen.x+","+O.positionScreen.y+" L "+Q.positionScreen.x+","+Q.positionScreen.y+"z");if(w instanceof THREE.MeshBasicMaterial)p.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshLambertMaterial)if(H){y.r=C.r;y.g=C.g;y.b=C.b;a(M,B,y);p.r=w.color.r*y.r;p.g=w.color.g*y.g;p.b=w.color.b*y.b;p.updateStyleString()}else p.__styleString=w.color.__styleString;else if(w instanceof THREE.MeshDepthMaterial){v=
 1-w.__2near/(w.__farPlusNear-B.z*w.__farMinusNear);p.setRGB(v,v,v)}else w instanceof THREE.MeshNormalMaterial&&p.setRGB(e(B.normalWorld.x),e(B.normalWorld.y),e(B.normalWorld.z));w.wireframe?u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+w.wireframeLinewidth+"; stroke-opacity: "+w.opacity+"; stroke-linecap: "+w.wireframeLinecap+"; stroke-linejoin: "+w.wireframeLinejoin):u.setAttribute("style","fill: "+p.__styleString+"; fill-opacity: "+w.opacity);i.appendChild(u)}
-function d(F){if(E[F]==null){E[F]=document.createElementNS("http://www.w3.org/2000/svg","path");N==0&&E[F].setAttribute("shape-rendering","crispEdges")}return E[F]}function e(F){return F<0?Math.min((1+F)*0.5,0.5):0.5+Math.min(F*0.5,0.5)}var f=null,g=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,k,n,m,l,o,q,s,t=new THREE.Rectangle,j=new THREE.Rectangle,H=!1,p=new THREE.Color(16777215),y=new THREE.Color(16777215),C=new THREE.Color(0),L=new THREE.Color(0),z=new THREE.Color(0),
-v,I=new THREE.Vector3,E=[],K=[],J=[],u,D,S,x,N=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(F){switch(F){case "high":N=1;break;case "low":N=0}};this.setSize=function(F,A){h=F;k=A;n=h/2;m=k/2;i.setAttribute("viewBox",-n+" "+-m+" "+h+" "+k);i.setAttribute("width",h);i.setAttribute("height",k);t.set(-n,-m,n,m)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(F,A){var O,Q,B,w,M,P,r,G;this.autoClear&&
-this.clear();f=g.projectScene(F,A,this.sortElements);x=S=D=0;if(H=F.lights.length>0){r=F.lights;C.setRGB(0,0,0);L.setRGB(0,0,0);z.setRGB(0,0,0);O=0;for(Q=r.length;O<Q;O++){B=r[O];w=B.color;if(B instanceof THREE.AmbientLight){C.r+=w.r;C.g+=w.g;C.b+=w.b}else if(B instanceof THREE.DirectionalLight){L.r+=w.r;L.g+=w.g;L.b+=w.b}else if(B instanceof THREE.PointLight){z.r+=w.r;z.g+=w.g;z.b+=w.b}}}O=0;for(Q=f.length;O<Q;O++){r=f[O];j.empty();if(r instanceof THREE.RenderableParticle){l=r;l.x*=n;l.y*=-m;B=0;
-for(w=r.materials.length;B<w;B++)if(G=r.materials[B]){M=l;P=r;var R=S++;if(K[R]==null){K[R]=document.createElementNS("http://www.w3.org/2000/svg","circle");N==0&&K[R].setAttribute("shape-rendering","crispEdges")}u=K[R];u.setAttribute("cx",M.x);u.setAttribute("cy",M.y);u.setAttribute("r",P.scale.x*n);if(G instanceof THREE.ParticleCircleMaterial){if(H){y.r=C.r+L.r+z.r;y.g=C.g+L.g+z.g;y.b=C.b+L.b+z.b;p.r=G.color.r*y.r;p.g=G.color.g*y.g;p.b=G.color.b*y.b;p.updateStyleString()}else p=G.color;u.setAttribute("style",
-"fill: "+p.__styleString)}i.appendChild(u)}}else if(r instanceof THREE.RenderableLine){l=r.v1;o=r.v2;l.positionScreen.x*=n;l.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;j.addPoint(l.positionScreen.x,l.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);if(t.instersects(j)){B=0;for(w=r.materials.length;B<w;)if(G=r.materials[B++]){M=l;P=o;R=x++;if(J[R]==null){J[R]=document.createElementNS("http://www.w3.org/2000/svg","line");N==0&&J[R].setAttribute("shape-rendering",
-"crispEdges")}u=J[R];u.setAttribute("x1",M.positionScreen.x);u.setAttribute("y1",M.positionScreen.y);u.setAttribute("x2",P.positionScreen.x);u.setAttribute("y2",P.positionScreen.y);if(G instanceof THREE.LineBasicMaterial){p.__styleString=G.color.__styleString;u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+G.linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.linecap+"; stroke-linejoin: "+G.linejoin);i.appendChild(u)}}}}else if(r instanceof THREE.RenderableFace3){l=
-r.v1;o=r.v2;q=r.v3;l.positionScreen.x*=n;l.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;q.positionScreen.x*=n;q.positionScreen.y*=-m;j.addPoint(l.positionScreen.x,l.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);j.addPoint(q.positionScreen.x,q.positionScreen.y);if(t.instersects(j)){B=0;for(w=r.meshMaterials.length;B<w;){G=r.meshMaterials[B++];if(G instanceof THREE.MeshFaceMaterial){M=0;for(P=r.faceMaterials.length;M<P;)(G=r.faceMaterials[M++])&&b(l,o,q,r,
-G,F)}else G&&b(l,o,q,r,G,F)}}}else if(r instanceof THREE.RenderableFace4){l=r.v1;o=r.v2;q=r.v3;s=r.v4;l.positionScreen.x*=n;l.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;q.positionScreen.x*=n;q.positionScreen.y*=-m;s.positionScreen.x*=n;s.positionScreen.y*=-m;j.addPoint(l.positionScreen.x,l.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);j.addPoint(q.positionScreen.x,q.positionScreen.y);j.addPoint(s.positionScreen.x,s.positionScreen.y);if(t.instersects(j)){B=
-0;for(w=r.meshMaterials.length;B<w;){G=r.meshMaterials[B++];if(G instanceof THREE.MeshFaceMaterial){M=0;for(P=r.faceMaterials.length;M<P;)(G=r.faceMaterials[M++])&&c(l,o,q,s,r,G,F)}else G&&c(l,o,q,s,r,G,F)}}}}}};
+function d(F){if(E[F]==null){E[F]=document.createElementNS("http://www.w3.org/2000/svg","path");N==0&&E[F].setAttribute("shape-rendering","crispEdges")}return E[F]}function e(F){return F<0?Math.min((1+F)*0.5,0.5):0.5+Math.min(F*0.5,0.5)}var f=null,g=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),h,l,n,m,k,o,q,s,t=new THREE.Rectangle,j=new THREE.Rectangle,H=!1,p=new THREE.Color(16777215),y=new THREE.Color(16777215),C=new THREE.Color(0),L=new THREE.Color(0),z=new THREE.Color(0),
+v,I=new THREE.Vector3,E=[],K=[],J=[],u,D,S,x,N=1;this.domElement=i;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(F){switch(F){case "high":N=1;break;case "low":N=0}};this.setSize=function(F,A){h=F;l=A;n=h/2;m=l/2;i.setAttribute("viewBox",-n+" "+-m+" "+h+" "+l);i.setAttribute("width",h);i.setAttribute("height",l);t.set(-n,-m,n,m)};this.clear=function(){for(;i.childNodes.length>0;)i.removeChild(i.childNodes[0])};this.render=function(F,A){var O,Q,B,w,M,P,r,G;this.autoClear&&
+this.clear();f=g.projectScene(F,A,this.sortElements);x=S=D=0;if(H=F.lights.length>0){r=F.lights;C.setRGB(0,0,0);L.setRGB(0,0,0);z.setRGB(0,0,0);O=0;for(Q=r.length;O<Q;O++){B=r[O];w=B.color;if(B instanceof THREE.AmbientLight){C.r+=w.r;C.g+=w.g;C.b+=w.b}else if(B instanceof THREE.DirectionalLight){L.r+=w.r;L.g+=w.g;L.b+=w.b}else if(B instanceof THREE.PointLight){z.r+=w.r;z.g+=w.g;z.b+=w.b}}}O=0;for(Q=f.length;O<Q;O++){r=f[O];j.empty();if(r instanceof THREE.RenderableParticle){k=r;k.x*=n;k.y*=-m;B=0;
+for(w=r.materials.length;B<w;B++)if(G=r.materials[B]){M=k;P=r;var R=S++;if(K[R]==null){K[R]=document.createElementNS("http://www.w3.org/2000/svg","circle");N==0&&K[R].setAttribute("shape-rendering","crispEdges")}u=K[R];u.setAttribute("cx",M.x);u.setAttribute("cy",M.y);u.setAttribute("r",P.scale.x*n);if(G instanceof THREE.ParticleCircleMaterial){if(H){y.r=C.r+L.r+z.r;y.g=C.g+L.g+z.g;y.b=C.b+L.b+z.b;p.r=G.color.r*y.r;p.g=G.color.g*y.g;p.b=G.color.b*y.b;p.updateStyleString()}else p=G.color;u.setAttribute("style",
+"fill: "+p.__styleString)}i.appendChild(u)}}else if(r instanceof THREE.RenderableLine){k=r.v1;o=r.v2;k.positionScreen.x*=n;k.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;j.addPoint(k.positionScreen.x,k.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);if(t.instersects(j)){B=0;for(w=r.materials.length;B<w;)if(G=r.materials[B++]){M=k;P=o;R=x++;if(J[R]==null){J[R]=document.createElementNS("http://www.w3.org/2000/svg","line");N==0&&J[R].setAttribute("shape-rendering",
+"crispEdges")}u=J[R];u.setAttribute("x1",M.positionScreen.x);u.setAttribute("y1",M.positionScreen.y);u.setAttribute("x2",P.positionScreen.x);u.setAttribute("y2",P.positionScreen.y);if(G instanceof THREE.LineBasicMaterial){p.__styleString=G.color.__styleString;u.setAttribute("style","fill: none; stroke: "+p.__styleString+"; stroke-width: "+G.linewidth+"; stroke-opacity: "+G.opacity+"; stroke-linecap: "+G.linecap+"; stroke-linejoin: "+G.linejoin);i.appendChild(u)}}}}else if(r instanceof THREE.RenderableFace3){k=
+r.v1;o=r.v2;q=r.v3;k.positionScreen.x*=n;k.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;q.positionScreen.x*=n;q.positionScreen.y*=-m;j.addPoint(k.positionScreen.x,k.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);j.addPoint(q.positionScreen.x,q.positionScreen.y);if(t.instersects(j)){B=0;for(w=r.meshMaterials.length;B<w;){G=r.meshMaterials[B++];if(G instanceof THREE.MeshFaceMaterial){M=0;for(P=r.faceMaterials.length;M<P;)(G=r.faceMaterials[M++])&&b(k,o,q,r,
+G,F)}else G&&b(k,o,q,r,G,F)}}}else if(r instanceof THREE.RenderableFace4){k=r.v1;o=r.v2;q=r.v3;s=r.v4;k.positionScreen.x*=n;k.positionScreen.y*=-m;o.positionScreen.x*=n;o.positionScreen.y*=-m;q.positionScreen.x*=n;q.positionScreen.y*=-m;s.positionScreen.x*=n;s.positionScreen.y*=-m;j.addPoint(k.positionScreen.x,k.positionScreen.y);j.addPoint(o.positionScreen.x,o.positionScreen.y);j.addPoint(q.positionScreen.x,q.positionScreen.y);j.addPoint(s.positionScreen.x,s.positionScreen.y);if(t.instersects(j)){B=
+0;for(w=r.meshMaterials.length;B<w;){G=r.meshMaterials[B++];if(G instanceof THREE.MeshFaceMaterial){M=0;for(P=r.faceMaterials.length;M<P;)(G=r.faceMaterials[M++])&&c(k,o,q,s,r,G,F)}else G&&c(k,o,q,s,r,G,F)}}}}}};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,c){c&&a.update(undefined,!1,b);c=a.sounds;var d,e=c.length;for(d=0;d<e;d++){a=c[d];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
 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=!1;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};

+ 104 - 104
build/custom/ThreeWebGL.js

@@ -1,6 +1,6 @@
 // ThreeWebGL.js r33 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(a){this.setHex(a)};
-THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,d){var e,g,k,i,n,j;if(d==0)e=g=k=0;else{i=Math.floor(a*6);n=a*6-i;a=d*(1-b);j=d*(1-b*n);b=d*(1-b*(1-n));switch(i){case 1:e=j;g=d;k=a;break;case 2:e=a;g=d;k=b;break;case 3:e=a;g=j;k=d;break;case 4:e=b;g=a;k=d;break;case 5:e=d;g=a;k=j;break;case 6:case 0:e=d;g=b;k=a}}this.r=e;this.g=g;this.b=k;if(this.autoUpdate){this.updateHex();
+THREE.Color.prototype={autoUpdate:!0,setRGB:function(a,b,d){this.r=a;this.g=b;this.b=d;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(a,b,d){var e,g,k,i,o,l;if(d==0)e=g=k=0;else{i=Math.floor(a*6);o=a*6-i;a=d*(1-b);l=d*(1-b*o);b=d*(1-b*(1-o));switch(i){case 1:e=l;g=d;k=a;break;case 2:e=a;g=d;k=b;break;case 3:e=a;g=l;k=d;break;case 4:e=b;g=a;k=d;break;case 5:e=d;g=a;k=l;break;case 6:case 0:e=d;g=b;k=a}}this.r=e;this.g=g;this.b=k;if(this.autoUpdate){this.updateHex();
 this.updateStyleString()}},setHex:function(a){this.hex=~~a&16777215;if(this.autoUpdate){this.updateRGB();this.updateStyleString()}},updateHex:function(){this.hex=~~(this.r*255)<<16^~~(this.g*255)<<8^~~(this.b*255)},updateRGB:function(){this.r=(this.hex>>16&255)/255;this.g=(this.hex>>8&255)/255;this.b=(this.hex&255)/255},updateStyleString:function(){this.__styleString="rgb("+~~(this.r*255)+","+~~(this.g*255)+","+~~(this.b*255)+")"},clone:function(){return new THREE.Color(this.hex)}};
 THREE.Vector2=function(a,b){this.set(a||0,b||0)};
 THREE.Vector2.prototype={set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.set(a.x,a.y);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y);return this},multiplyScalar:function(a){this.set(this.x*a,this.y*a);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
@@ -11,59 +11,58 @@ a,this.y/a,this.z/a);return this},negate:function(){this.set(-this.x,-this.y,-th
 this.length();a>0?this.multiplyScalar(1/a):this.set(0,0,0);return this},setLength:function(a){return this.normalize().multiplyScalar(a)},isZero:function(){return Math.abs(this.x)<1.0E-4&&Math.abs(this.y)<1.0E-4&&Math.abs(this.z)<1.0E-4},clone:function(){return new THREE.Vector3(this.x,this.y,this.z)}};THREE.Vector4=function(a,b,d,e){this.set(a||0,b||0,d||0,e||1)};
 THREE.Vector4.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},copy:function(a){this.set(a.x,a.y,a.z,a.w||1);return this},add:function(a,b){this.set(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w);return this},addSelf:function(a){this.set(this.x+a.x,this.y+a.y,this.z+a.z,this.w+a.w);return this},sub:function(a,b){this.set(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w);return this},subSelf:function(a){this.set(this.x-a.x,this.y-a.y,this.z-a.z,this.w-a.w);return this},multiplyScalar:function(a){this.set(this.x*
 a,this.y*a,this.z*a,this.w*a);return this},divideScalar:function(a){this.set(this.x/a,this.y/a,this.z/a,this.w/a);return this},lerpSelf:function(a,b){this.set(this.x+(a.x-this.x)*b,this.y+(a.y-this.y)*b,this.z+(a.z-this.z)*b,this.w+(a.w-this.w)*b)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(a,b){this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];d instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(d)))}g.sort(function(k,i){return k.distance-i.distance});return g},intersectObject:function(a){function b(K,J,R,L){L=L.clone().subSelf(J);R=R.clone().subSelf(J);var P=K.clone().subSelf(J);K=L.dot(L);J=L.dot(R);L=L.dot(P);var c=R.dot(R);R=R.dot(P);P=1/(K*c-J*J);c=(c*L-J*R)*P;K=(K*R-J*L)*P;return c>0&&K>0&&c+K<1}var d,e,g,k,i,n,j,t,x,w,
-z,A=a.geometry,E=A.vertices,H=[];d=0;for(e=A.faces.length;d<e;d++){g=A.faces[d];w=this.origin.clone();z=this.direction.clone();j=a.matrixWorld;k=j.multiplyVector3(E[g.a].position.clone());i=j.multiplyVector3(E[g.b].position.clone());n=j.multiplyVector3(E[g.c].position.clone());j=g instanceof THREE.Face4?j.multiplyVector3(E[g.d].position.clone()):null;t=a.matrixRotationWorld.multiplyVector3(g.normal.clone());x=z.dot(t);if(x<0){t=t.dot((new THREE.Vector3).sub(k,w))/x;w=w.addSelf(z.multiplyScalar(t));
-if(g instanceof THREE.Face3){if(b(w,k,i,n)){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};H.push(g)}}else if(g instanceof THREE.Face4&&(b(w,k,i,j)||b(w,i,n,j))){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};H.push(g)}}}return H}};
-THREE.Rectangle=function(){function a(){k=e-b;i=g-d}var b,d,e,g,k,i,n=!0;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return k};this.getHeight=function(){return i};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(j,t,x,w){n=!1;b=j;d=t;e=x;g=w;a()};this.addPoint=function(j,t){if(n){n=!1;b=j;d=t;e=j;g=t}else{b=b<j?b:j;d=d<t?d:t;e=e>j?e:j;g=g>t?g:t}a()};
-this.add3Points=function(j,t,x,w,z,A){if(n){n=!1;b=j<x?j<z?j:z:x<z?x:z;d=t<w?t<A?t:A:w<A?w:A;e=j>x?j>z?j:z:x>z?x:z;g=t>w?t>A?t:A:w>A?w:A}else{b=j<x?j<z?j<b?j:b:z<b?z:b:x<z?x<b?x:b:z<b?z:b;d=t<w?t<A?t<d?t:d:A<d?A:d:w<A?w<d?w:d:A<d?A:d;e=j>x?j>z?j>e?j:e:z>e?z:e:x>z?x>e?x:e:z>e?z:e;g=t>w?t>A?t>g?t:g:A>g?A:g:w>A?w>g?w:g:A>g?A:g}a()};this.addRectangle=function(j){if(n){n=!1;b=j.getLeft();d=j.getTop();e=j.getRight();g=j.getBottom()}else{b=b<j.getLeft()?b:j.getLeft();d=d<j.getTop()?d:j.getTop();e=e>j.getRight()?
-e:j.getRight();g=g>j.getBottom()?g:j.getBottom()}a()};this.inflate=function(j){b-=j;d-=j;e+=j;g+=j;a()};this.minSelf=function(j){b=b>j.getLeft()?b:j.getLeft();d=d>j.getTop()?d:j.getTop();e=e<j.getRight()?e:j.getRight();g=g<j.getBottom()?g:j.getBottom();a()};this.instersects=function(j){return Math.min(e,j.getRight())-Math.max(b,j.getLeft())>=0&&Math.min(g,j.getBottom())-Math.max(d,j.getTop())>=0};this.empty=function(){n=!0;g=e=d=b=0;a()};this.isEmpty=function(){return n}};
+THREE.Ray.prototype={intersectScene:function(a){var b,d,e=a.objects,g=[];a=0;for(b=e.length;a<b;a++){d=e[a];d instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(d)))}g.sort(function(k,i){return k.distance-i.distance});return g},intersectObject:function(a){function b(L,J,T,S){S=S.clone().subSelf(J);T=T.clone().subSelf(J);var M=L.clone().subSelf(J);L=S.dot(S);J=S.dot(T);S=S.dot(M);var O=T.dot(T);T=T.dot(M);M=1/(L*O-J*J);O=(O*S-J*T)*M;L=(L*T-J*S)*M;return O>0&&L>0&&O+L<1}var d,e,g,k,i,o,l,v,x,w,
+z,A=a.geometry,I=A.vertices,G=[];d=0;for(e=A.faces.length;d<e;d++){g=A.faces[d];w=this.origin.clone();z=this.direction.clone();l=a.matrixWorld;k=l.multiplyVector3(I[g.a].position.clone());i=l.multiplyVector3(I[g.b].position.clone());o=l.multiplyVector3(I[g.c].position.clone());l=g instanceof THREE.Face4?l.multiplyVector3(I[g.d].position.clone()):null;v=a.matrixRotationWorld.multiplyVector3(g.normal.clone());x=z.dot(v);if(x<0){v=v.dot((new THREE.Vector3).sub(k,w))/x;w=w.addSelf(z.multiplyScalar(v));
+if(g instanceof THREE.Face3){if(b(w,k,i,o)){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};G.push(g)}}else if(g instanceof THREE.Face4&&(b(w,k,i,l)||b(w,i,o,l))){g={distance:this.origin.distanceTo(w),point:w,face:g,object:a};G.push(g)}}}return G}};
+THREE.Rectangle=function(){function a(){k=e-b;i=g-d}var b,d,e,g,k,i,o=!0;this.getX=function(){return b};this.getY=function(){return d};this.getWidth=function(){return k};this.getHeight=function(){return i};this.getLeft=function(){return b};this.getTop=function(){return d};this.getRight=function(){return e};this.getBottom=function(){return g};this.set=function(l,v,x,w){o=!1;b=l;d=v;e=x;g=w;a()};this.addPoint=function(l,v){if(o){o=!1;b=l;d=v;e=l;g=v}else{b=b<l?b:l;d=d<v?d:v;e=e>l?e:l;g=g>v?g:v}a()};
+this.add3Points=function(l,v,x,w,z,A){if(o){o=!1;b=l<x?l<z?l:z:x<z?x:z;d=v<w?v<A?v:A:w<A?w:A;e=l>x?l>z?l:z:x>z?x:z;g=v>w?v>A?v:A:w>A?w:A}else{b=l<x?l<z?l<b?l:b:z<b?z:b:x<z?x<b?x:b:z<b?z:b;d=v<w?v<A?v<d?v:d:A<d?A:d:w<A?w<d?w:d:A<d?A:d;e=l>x?l>z?l>e?l:e:z>e?z:e:x>z?x>e?x:e:z>e?z:e;g=v>w?v>A?v>g?v:g:A>g?A:g:w>A?w>g?w:g:A>g?A:g}a()};this.addRectangle=function(l){if(o){o=!1;b=l.getLeft();d=l.getTop();e=l.getRight();g=l.getBottom()}else{b=b<l.getLeft()?b:l.getLeft();d=d<l.getTop()?d:l.getTop();e=e>l.getRight()?
+e:l.getRight();g=g>l.getBottom()?g:l.getBottom()}a()};this.inflate=function(l){b-=l;d-=l;e+=l;g+=l;a()};this.minSelf=function(l){b=b>l.getLeft()?b:l.getLeft();d=d>l.getTop()?d:l.getTop();e=e<l.getRight()?e:l.getRight();g=g<l.getBottom()?g:l.getBottom();a()};this.instersects=function(l){return Math.min(e,l.getRight())-Math.max(b,l.getLeft())>=0&&Math.min(g,l.getBottom())-Math.max(d,l.getTop())>=0};this.empty=function(){o=!0;g=e=d=b=0;a()};this.isEmpty=function(){return o}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,d,e,g,k,i,n,j,t,x,w,z,A,E,H){this.set(a||1,b||0,d||0,e||0,g||0,k||1,i||0,n||0,j||0,t||0,x||1,w||0,z||0,A||0,E||0,H||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(a,b,d,e,g,k,i,n,j,t,x,w,z,A,E,H){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=g;this.n22=k;this.n23=i;this.n24=n;this.n31=j;this.n32=t;this.n33=x;this.n34=w;this.n41=z;this.n42=A;this.n43=E;this.n44=H;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,d){var e=THREE.Matrix4.__tmpVec1,
+THREE.Matrix4=function(a,b,d,e,g,k,i,o,l,v,x,w,z,A,I,G){this.set(a||1,b||0,d||0,e||0,g||0,k||1,i||0,o||0,l||0,v||0,x||1,w||0,z||0,A||0,I||0,G||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(a,b,d,e,g,k,i,o,l,v,x,w,z,A,I,G){this.n11=a;this.n12=b;this.n13=d;this.n14=e;this.n21=g;this.n22=k;this.n23=i;this.n24=o;this.n31=l;this.n32=v;this.n33=x;this.n34=w;this.n41=z;this.n42=A;this.n43=I;this.n44=G;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,b,d){var e=THREE.Matrix4.__tmpVec1,
 g=THREE.Matrix4.__tmpVec2,k=THREE.Matrix4.__tmpVec3;k.sub(a,b).normalize();e.cross(d,k).normalize();g.cross(k,e).normalize();this.n11=e.x;this.n12=g.x;this.n13=k.x;this.n14=a.x;this.n21=e.y;this.n22=g.y;this.n23=k.y;this.n24=a.y;this.n31=e.z;this.n32=g.z;this.n33=k.z;this.n34=a.z;return this},multiplyVector3:function(a){var b=a.x,d=a.y,e=a.z,g=1/(this.n41*b+this.n42*d+this.n43*e+this.n44);a.x=(this.n11*b+this.n12*d+this.n13*e+this.n14)*g;a.y=(this.n21*b+this.n22*d+this.n23*e+this.n24)*g;a.z=(this.n31*
 b+this.n32*d+this.n33*e+this.n34)*g;return a},multiplyVector3OnlyZ:function(a){var b=a.x,d=a.y;a=a.z;return(this.n31*b+this.n32*d+this.n33*a+this.n34)*(1/(this.n41*b+this.n42*d+this.n43*a+this.n44))},multiplyVector4:function(a){var b=a.x,d=a.y,e=a.z,g=a.w;a.x=this.n11*b+this.n12*d+this.n13*e+this.n14*g;a.y=this.n21*b+this.n22*d+this.n23*e+this.n24*g;a.z=this.n31*b+this.n32*d+this.n33*e+this.n34*g;a.w=this.n41*b+this.n42*d+this.n43*e+this.n44*g;return a},crossVector:function(a){var b=new THREE.Vector4;
-b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,g=a.n13,k=a.n14,i=a.n21,n=a.n22,j=a.n23,t=a.n24,x=a.n31,w=a.n32,z=a.n33,A=a.n34,E=a.n41,H=a.n42,K=a.n43,J=a.n44,R=b.n11,L=b.n12,P=b.n13,c=b.n14,aa=b.n21,ba=b.n22,ca=b.n23,ga=b.n24,da=b.n31,ja=b.n32,na=b.n33,$=b.n34;this.n11=
-d*R+e*aa+g*da;this.n12=d*L+e*ba+g*ja;this.n13=d*P+e*ca+g*na;this.n14=d*c+e*ga+g*$+k;this.n21=i*R+n*aa+j*da;this.n22=i*L+n*ba+j*ja;this.n23=i*P+n*ca+j*na;this.n24=i*c+n*ga+j*$+t;this.n31=x*R+w*aa+z*da;this.n32=x*L+w*ba+z*ja;this.n33=x*P+w*ca+z*na;this.n34=x*c+w*ga+z*$+A;this.n41=E*R+H*aa+K*da;this.n42=E*L+H*ba+K*ja;this.n43=E*P+H*ca+K*na;this.n44=E*c+H*ga+K*$+J;return this},multiplyToArray:function(a,b,d){var e=a.n11,g=a.n12,k=a.n13,i=a.n14,n=a.n21,j=a.n22,t=a.n23,x=a.n24,w=a.n31,z=a.n32,A=a.n33,E=
-a.n34,H=a.n41,K=a.n42,J=a.n43;a=a.n44;var R=b.n11,L=b.n12,P=b.n13,c=b.n14,aa=b.n21,ba=b.n22,ca=b.n23,ga=b.n24,da=b.n31,ja=b.n32,na=b.n33,$=b.n34,qa=b.n41,wa=b.n42,ua=b.n43;b=b.n44;this.n11=e*R+g*aa+k*da+i*qa;this.n12=e*L+g*ba+k*ja+i*wa;this.n13=e*P+g*ca+k*na+i*ua;this.n14=e*c+g*ga+k*$+i*b;this.n21=n*R+j*aa+t*da+x*qa;this.n22=n*L+j*ba+t*ja+x*wa;this.n23=n*P+j*ca+t*na+x*ua;this.n24=n*c+j*ga+t*$+x*b;this.n31=w*R+z*aa+A*da+E*qa;this.n32=w*L+z*ba+A*ja+E*wa;this.n33=w*P+z*ca+A*na+E*ua;this.n34=w*c+z*ga+
-A*$+E*b;this.n41=H*R+K*aa+J*da+a*qa;this.n42=H*L+K*ba+J*ja+a*wa;this.n43=H*P+K*ca+J*na+a*ua;this.n44=H*c+K*ga+J*$+a*b;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,k=this.n21,i=this.n22,n=this.n23,j=this.n24,t=this.n31,x=this.n32,w=
-this.n33,z=this.n34,A=this.n41,E=this.n42,H=this.n43,K=this.n44,J=a.n11,R=a.n21,L=a.n31,P=a.n12,c=a.n22,aa=a.n32,ba=a.n13,ca=a.n23,ga=a.n33,da=a.n14,ja=a.n24;a=a.n34;this.n11=b*J+d*R+e*L;this.n12=b*P+d*c+e*aa;this.n13=b*ba+d*ca+e*ga;this.n14=b*da+d*ja+e*a+g;this.n21=k*J+i*R+n*L;this.n22=k*P+i*c+n*aa;this.n23=k*ba+i*ca+n*ga;this.n24=k*da+i*ja+n*a+j;this.n31=t*J+x*R+w*L;this.n32=t*P+x*c+w*aa;this.n33=t*ba+x*ca+w*ga;this.n34=t*da+x*ja+w*a+z;this.n41=A*J+E*R+H*L;this.n42=A*P+E*c+H*aa;this.n43=A*ba+E*
-ca+H*ga;this.n44=A*da+E*ja+H*a+K;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,g=this.n21,k=this.n22,i=this.n23,n=this.n24,j=this.n31,t=this.n32,x=this.n33,w=this.n34,z=this.n41,A=this.n42,E=this.n43,H=this.n44;return e*i*t*z-d*n*t*
-z-e*k*x*z+b*n*x*z+d*k*w*z-b*i*w*z-e*i*j*A+d*n*j*A+e*g*x*A-a*n*x*A-d*g*w*A+a*i*w*A+e*k*j*E-b*n*j*E-e*g*t*E+a*n*t*E+b*g*w*E-a*k*w*E-d*k*j*H+b*i*j*H+d*g*t*H-a*i*t*H-b*g*x*H+a*k*x*H},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=
+b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},multiply:function(a,b){var d=a.n11,e=a.n12,g=a.n13,k=a.n14,i=a.n21,o=a.n22,l=a.n23,v=a.n24,x=a.n31,w=a.n32,z=a.n33,A=a.n34,I=a.n41,G=a.n42,L=a.n43,J=a.n44,T=b.n11,S=b.n12,M=b.n13,O=b.n14,c=b.n21,aa=b.n22,fa=b.n23,ba=b.n24,ca=b.n31,ia=b.n32,na=b.n33,oa=b.n34;this.n11=
+d*T+e*c+g*ca;this.n12=d*S+e*aa+g*ia;this.n13=d*M+e*fa+g*na;this.n14=d*O+e*ba+g*oa+k;this.n21=i*T+o*c+l*ca;this.n22=i*S+o*aa+l*ia;this.n23=i*M+o*fa+l*na;this.n24=i*O+o*ba+l*oa+v;this.n31=x*T+w*c+z*ca;this.n32=x*S+w*aa+z*ia;this.n33=x*M+w*fa+z*na;this.n34=x*O+w*ba+z*oa+A;this.n41=I*T+G*c+L*ca;this.n42=I*S+G*aa+L*ia;this.n43=I*M+G*fa+L*na;this.n44=I*O+G*ba+L*oa+J;return this},multiplyToArray:function(a,b,d){var e=a.n11,g=a.n12,k=a.n13,i=a.n14,o=a.n21,l=a.n22,v=a.n23,x=a.n24,w=a.n31,z=a.n32,A=a.n33,I=
+a.n34,G=a.n41,L=a.n42,J=a.n43;a=a.n44;var T=b.n11,S=b.n12,M=b.n13,O=b.n14,c=b.n21,aa=b.n22,fa=b.n23,ba=b.n24,ca=b.n31,ia=b.n32,na=b.n33,oa=b.n34,ja=b.n41,ra=b.n42,wa=b.n43;b=b.n44;this.n11=e*T+g*c+k*ca+i*ja;this.n12=e*S+g*aa+k*ia+i*ra;this.n13=e*M+g*fa+k*na+i*wa;this.n14=e*O+g*ba+k*oa+i*b;this.n21=o*T+l*c+v*ca+x*ja;this.n22=o*S+l*aa+v*ia+x*ra;this.n23=o*M+l*fa+v*na+x*wa;this.n24=o*O+l*ba+v*oa+x*b;this.n31=w*T+z*c+A*ca+I*ja;this.n32=w*S+z*aa+A*ia+I*ra;this.n33=w*M+z*fa+A*na+I*wa;this.n34=w*O+z*ba+
+A*oa+I*b;this.n41=G*T+L*c+J*ca+a*ja;this.n42=G*S+L*aa+J*ia+a*ra;this.n43=G*M+L*fa+J*na+a*wa;this.n44=G*O+L*ba+J*oa+a*b;d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(a){var b=this.n11,d=this.n12,e=this.n13,g=this.n14,k=this.n21,i=this.n22,o=this.n23,l=this.n24,v=this.n31,x=this.n32,
+w=this.n33,z=this.n34,A=this.n41,I=this.n42,G=this.n43,L=this.n44,J=a.n11,T=a.n21,S=a.n31,M=a.n12,O=a.n22,c=a.n32,aa=a.n13,fa=a.n23,ba=a.n33,ca=a.n14,ia=a.n24;a=a.n34;this.n11=b*J+d*T+e*S;this.n12=b*M+d*O+e*c;this.n13=b*aa+d*fa+e*ba;this.n14=b*ca+d*ia+e*a+g;this.n21=k*J+i*T+o*S;this.n22=k*M+i*O+o*c;this.n23=k*aa+i*fa+o*ba;this.n24=k*ca+i*ia+o*a+l;this.n31=v*J+x*T+w*S;this.n32=v*M+x*O+w*c;this.n33=v*aa+x*fa+w*ba;this.n34=v*ca+x*ia+w*a+z;this.n41=A*J+I*T+G*S;this.n42=A*M+I*O+G*c;this.n43=A*aa+I*fa+
+G*ba;this.n44=A*ca+I*ia+G*a+L;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},determinant:function(){var a=this.n11,b=this.n12,d=this.n13,e=this.n14,g=this.n21,k=this.n22,i=this.n23,o=this.n24,l=this.n31,v=this.n32,x=this.n33,w=this.n34,z=this.n41,A=this.n42,I=this.n43,G=this.n44;return e*i*v*z-d*o*v*z-
+e*k*x*z+b*o*x*z+d*k*w*z-b*i*w*z-e*i*l*A+d*o*l*A+e*g*x*A-a*o*x*A-d*g*w*A+a*i*w*A+e*k*l*I-b*o*l*I-e*g*v*I+a*o*v*I+b*g*w*I-a*k*w*I-d*k*l*G+b*i*l*G+d*g*v*G-a*i*v*G-b*g*x*G+a*k*x*G},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n43=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=
 this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.flattenToArray(this.flat);return this.flat},flattenToArray:function(a){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},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,d){this.set(1,0,0,a,0,1,0,b,0,0,1,d,0,0,0,1);return this},setScale:function(a,b,d){this.set(a,0,0,
-0,0,b,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var d=Math.cos(b),e=Math.sin(b),g=1-d,k=a.x,i=a.y,n=a.z,j=g*k,t=g*i;this.set(j*k+d,j*i-e*n,j*n+e*i,0,j*i+e*n,t*i+
-d,t*n-e*k,0,j*n-e*i,t*n+e*k,g*n*n+d,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,d=a.y,e=a.z;a=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var k=Math.cos(e);e=Math.sin(e);var i=a*d,n=b*d;this.n11=g*k;this.n12=-g*e;this.n13=d;this.n21=n*k+a*e;this.n22=-n*e+a*k;this.n23=-b*g;this.n31=-i*k+b*e;this.n32=i*e+b*k;this.n33=a*g},setRotationFromQuaternion:function(a){var b=a.x,d=a.y,e=a.z,g=a.w,
-k=b+b,i=d+d,n=e+e;a=b*k;var j=b*i;b*=n;var t=d*i;d*=n;e*=n;k*=g;i*=g;g*=n;this.n11=1-(t+e);this.n12=j-g;this.n13=b+i;this.n21=j+g;this.n22=1-(a+e);this.n23=d-k;this.n31=b-i;this.n32=d+k;this.n33=1-(a+t)},scale:function(a){var b=a.x,d=a.y;a=a.z;this.n11*=b;this.n12*=d;this.n13*=a;this.n21*=b;this.n22*=d;this.n23*=a;this.n31*=b;this.n32*=d;this.n33*=a;this.n41*=b;this.n42*=d;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setTranslation(a,b,d);return e};
+0,0,b,0,0,0,0,d,0,0,0,0,1);return this},setRotX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotAxis:function(a,b){var d=Math.cos(b),e=Math.sin(b),g=1-d,k=a.x,i=a.y,o=a.z,l=g*k,v=g*i;this.set(l*k+d,l*i-e*o,l*o+e*i,0,l*i+e*o,v*i+
+d,v*o-e*k,0,l*o-e*i,v*o+e*k,g*o*o+d,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},setRotationFromEuler:function(a){var b=a.x,d=a.y,e=a.z;a=Math.cos(b);b=Math.sin(b);var g=Math.cos(d);d=Math.sin(d);var k=Math.cos(e);e=Math.sin(e);var i=a*d,o=b*d;this.n11=g*k;this.n12=-g*e;this.n13=d;this.n21=o*k+a*e;this.n22=-o*e+a*k;this.n23=-b*g;this.n31=-i*k+b*e;this.n32=i*e+b*k;this.n33=a*g},setRotationFromQuaternion:function(a){var b=a.x,d=a.y,e=a.z,g=a.w,
+k=b+b,i=d+d,o=e+e;a=b*k;var l=b*i;b*=o;var v=d*i;d*=o;e*=o;k*=g;i*=g;g*=o;this.n11=1-(v+e);this.n12=l-g;this.n13=b+i;this.n21=l+g;this.n22=1-(a+e);this.n23=d-k;this.n31=b-i;this.n32=d+k;this.n33=1-(a+v)},scale:function(a){var b=a.x,d=a.y;a=a.z;this.n11*=b;this.n12*=d;this.n13*=a;this.n21*=b;this.n22*=d;this.n23*=a;this.n31*=b;this.n32*=d;this.n33*=a;this.n41*=b;this.n42*=d;this.n43*=a;return this}};THREE.Matrix4.translationMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setTranslation(a,b,d);return e};
 THREE.Matrix4.scaleMatrix=function(a,b,d){var e=new THREE.Matrix4;e.setScale(a,b,d);return e};THREE.Matrix4.rotationXMatrix=function(a){var b=new THREE.Matrix4;b.setRotX(a);return b};THREE.Matrix4.rotationYMatrix=function(a){var b=new THREE.Matrix4;b.setRotY(a);return b};THREE.Matrix4.rotationZMatrix=function(a){var b=new THREE.Matrix4;b.setRotZ(a);return b};THREE.Matrix4.rotationAxisAngleMatrix=function(a,b){var d=new THREE.Matrix4;d.setRotAxis(a,b);return d};
-THREE.Matrix4.makeInvert=function(a,b){var d=a.n11,e=a.n12,g=a.n13,k=a.n14,i=a.n21,n=a.n22,j=a.n23,t=a.n24,x=a.n31,w=a.n32,z=a.n33,A=a.n34,E=a.n41,H=a.n42,K=a.n43,J=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=j*A*H-t*z*H+t*w*K-n*A*K-j*w*J+n*z*J;b.n12=k*z*H-g*A*H-k*w*K+e*A*K+g*w*J-e*z*J;b.n13=g*t*H-k*j*H+k*n*K-e*t*K-g*n*J+e*j*J;b.n14=k*j*w-g*t*w-k*n*z+e*t*z+g*n*A-e*j*A;b.n21=t*z*E-j*A*E-t*x*K+i*A*K+j*x*J-i*z*J;b.n22=g*A*E-k*z*E+k*x*K-d*A*K-g*x*J+d*z*J;b.n23=k*j*E-g*t*E-k*i*K+d*t*K+g*i*J-d*j*J;
-b.n24=g*t*x-k*j*x+k*i*z-d*t*z-g*i*A+d*j*A;b.n31=n*A*E-t*w*E+t*x*H-i*A*H-n*x*J+i*w*J;b.n32=k*w*E-e*A*E-k*x*H+d*A*H+e*x*J-d*w*J;b.n33=g*t*E-k*n*E+k*i*H-d*t*H-e*i*J+d*n*J;b.n34=k*n*x-e*t*x-k*i*w+d*t*w+e*i*A-d*n*A;b.n41=j*w*E-n*z*E-j*x*H+i*z*H+n*x*K-i*w*K;b.n42=e*z*E-g*w*E+g*x*H-d*z*H-e*x*K+d*w*K;b.n43=g*n*E-e*j*E-g*i*H+d*j*H+e*i*K-d*n*K;b.n44=e*j*x-g*n*x+g*i*w-d*j*w-e*i*z+d*n*z;b.multiplyScalar(1/a.determinant());return b};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,d=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,i=-a.n33*a.n12+a.n32*a.n13,n=a.n33*a.n11-a.n31*a.n13,j=-a.n32*a.n11+a.n31*a.n12,t=a.n23*a.n12-a.n22*a.n13,x=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*i+a.n31*t;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*e;d[1]=a*g;d[2]=a*k;d[3]=a*i;d[4]=a*n;d[5]=a*j;d[6]=a*t;d[7]=a*x;d[8]=a*w;return b};
+THREE.Matrix4.makeInvert=function(a,b){var d=a.n11,e=a.n12,g=a.n13,k=a.n14,i=a.n21,o=a.n22,l=a.n23,v=a.n24,x=a.n31,w=a.n32,z=a.n33,A=a.n34,I=a.n41,G=a.n42,L=a.n43,J=a.n44;b===undefined&&(b=new THREE.Matrix4);b.n11=l*A*G-v*z*G+v*w*L-o*A*L-l*w*J+o*z*J;b.n12=k*z*G-g*A*G-k*w*L+e*A*L+g*w*J-e*z*J;b.n13=g*v*G-k*l*G+k*o*L-e*v*L-g*o*J+e*l*J;b.n14=k*l*w-g*v*w-k*o*z+e*v*z+g*o*A-e*l*A;b.n21=v*z*I-l*A*I-v*x*L+i*A*L+l*x*J-i*z*J;b.n22=g*A*I-k*z*I+k*x*L-d*A*L-g*x*J+d*z*J;b.n23=k*l*I-g*v*I-k*i*L+d*v*L+g*i*J-d*l*J;
+b.n24=g*v*x-k*l*x+k*i*z-d*v*z-g*i*A+d*l*A;b.n31=o*A*I-v*w*I+v*x*G-i*A*G-o*x*J+i*w*J;b.n32=k*w*I-e*A*I-k*x*G+d*A*G+e*x*J-d*w*J;b.n33=g*v*I-k*o*I+k*i*G-d*v*G-e*i*J+d*o*J;b.n34=k*o*x-e*v*x-k*i*w+d*v*w+e*i*A-d*o*A;b.n41=l*w*I-o*z*I-l*x*G+i*z*G+o*x*L-i*w*L;b.n42=e*z*I-g*w*I+g*x*G-d*z*G-e*x*L+d*w*L;b.n43=g*o*I-e*l*I-g*i*G+d*l*G+e*i*L-d*o*L;b.n44=e*l*x-g*o*x+g*i*w-d*l*w-e*i*z+d*o*z;b.multiplyScalar(1/a.determinant());return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,d=b.m,e=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,k=a.n32*a.n21-a.n31*a.n22,i=-a.n33*a.n12+a.n32*a.n13,o=a.n33*a.n11-a.n31*a.n13,l=-a.n32*a.n11+a.n31*a.n12,v=a.n23*a.n12-a.n22*a.n13,x=-a.n23*a.n11+a.n21*a.n13,w=a.n22*a.n11-a.n21*a.n12;a=a.n11*e+a.n21*i+a.n31*v;if(a==0)throw"matrix not invertible";a=1/a;d[0]=a*e;d[1]=a*g;d[2]=a*k;d[3]=a*i;d[4]=a*o;d[5]=a*l;d[6]=a*v;d[7]=a*x;d[8]=a*w;return b};
 THREE.Matrix4.makeFrustum=function(a,b,d,e,g,k){var i;i=new THREE.Matrix4;i.n11=2*g/(b-a);i.n12=0;i.n13=(b+a)/(b-a);i.n14=0;i.n21=0;i.n22=2*g/(e-d);i.n23=(e+d)/(e-d);i.n24=0;i.n31=0;i.n32=0;i.n33=-(k+g)/(k-g);i.n34=-2*k*g/(k-g);i.n41=0;i.n42=0;i.n43=-1;i.n44=0;return i};THREE.Matrix4.makePerspective=function(a,b,d,e){var g;a=d*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,d,e)};
-THREE.Matrix4.makeOrtho=function(a,b,d,e,g,k){var i,n,j,t;i=new THREE.Matrix4;n=b-a;j=d-e;t=k-g;i.n11=2/n;i.n12=0;i.n13=0;i.n14=-((b+a)/n);i.n21=0;i.n22=2/j;i.n23=0;i.n24=-((d+e)/j);i.n31=0;i.n32=0;i.n33=-2/t;i.n34=-((k+g)/t);i.n41=0;i.n42=0;i.n43=0;i.n44=1;return i};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
+THREE.Matrix4.makeOrtho=function(a,b,d,e,g,k){var i,o,l,v;i=new THREE.Matrix4;o=b-a;l=d-e;v=k-g;i.n11=2/o;i.n12=0;i.n13=0;i.n14=-((b+a)/o);i.n21=0;i.n22=2/l;i.n23=0;i.n24=-((d+e)/l);i.n31=0;i.n32=0;i.n33=-2/v;i.n34=-((k+g)/v);i.n41=0;i.n42=0;i.n43=0;i.n44=1;return i};THREE.Matrix4.__tmpVec1=new THREE.Vector3;THREE.Matrix4.__tmpVec2=new THREE.Vector3;THREE.Matrix4.__tmpVec3=new THREE.Vector3;
 THREE.Object3D=function(){this.id=THREE.Object3DCounter.value++;this.parent=undefined;this.children=[];this.position=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixNeedsUpdate=!0;this.matrixAutoUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;
 this.visible=!0};
 THREE.Object3D.prototype={addChild:function(a){if(this.children.indexOf(a)===-1){a.parent!==undefined&&a.parent.removeChild(a);a.parent=this;this.children.push(a);for(var b=this;b instanceof THREE.Scene===!1&&b!==undefined;)b=b.parent;b!==undefined&&b.addChildRecurse(a)}},removeChild:function(a){var b=this.children.indexOf(a);if(b!==-1){a.parent=undefined;this.children.splice(b,1)}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation);
 if(this.scale.x!==1||this.scale.y!==1||this.scale.z!==1){this.matrix.scale(this.scale);this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z))}return!0},update:function(a,b,d){if(this.visible){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixNeedsUpdate){a?this.matrixWorld.multiply(a,this.matrix):this.matrixWorld.copy(this.matrix);b=1/this.scale.x;a=1/this.scale.y;var e=1/this.scale.z;this.matrixRotationWorld.n11=this.matrixWorld.n11*b;this.matrixRotationWorld.n21=
 this.matrixWorld.n21*b;this.matrixRotationWorld.n31=this.matrixWorld.n31*b;this.matrixRotationWorld.n12=this.matrixWorld.n12*a;this.matrixRotationWorld.n22=this.matrixWorld.n22*a;this.matrixRotationWorld.n32=this.matrixWorld.n32*a;this.matrixRotationWorld.n13=this.matrixWorld.n13*e;this.matrixRotationWorld.n23=this.matrixWorld.n23*e;this.matrixRotationWorld.n33=this.matrixWorld.n33*e;this.matrixNeedsUpdate=!1;b=!0}a=0;for(e=this.children.length;a<e;a++)this.children[a].update(this.matrixWorld,b,d)}}};
 THREE.Object3DCounter={value:0};THREE.Quaternion=function(a,b,d,e){this.set(a||0,b||0,d||0,e!==undefined?e:1)};
-THREE.Quaternion.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,d=a.x*b,e=a.y*b,g=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-g);g=Math.sin(-g);var k=Math.cos(d);d=Math.sin(d);var i=a*b,n=e*g;this.w=i*k-n*d;this.x=i*d+n*k;this.y=e*b*k+a*g*d;this.z=a*g*k-e*b*d;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
--1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,d=this.y,e=this.z,g=this.w,k=a.x,i=a.y,n=a.z;a=a.w;this.x=b*a+g*k+d*n-e*i;this.y=d*a+g*i+e*k-b*n;this.z=e*a+g*n+b*i-d*k;this.w=g*a-b*k-d*i-e*n;return this},
-multiplyVector3:function(a,b){b||(b=a);var d=a.x,e=a.y,g=a.z,k=this.x,i=this.y,n=this.z,j=this.w,t=j*d+i*g-n*e,x=j*e+n*d-k*g,w=j*g+k*e-i*d;d=-k*d-i*e-n*g;b.x=t*j+d*-k+x*-n-w*-i;b.y=x*j+d*-i+w*-k-t*-n;b.z=w*j+d*-n+t*-i-x*-k;return b}};
+THREE.Quaternion.prototype={set:function(a,b,d,e){this.x=a;this.y=b;this.z=d;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,d=a.x*b,e=a.y*b,g=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-g);g=Math.sin(-g);var k=Math.cos(d);d=Math.sin(d);var i=a*b,o=e*g;this.w=i*k-o*d;this.x=i*d+o*k;this.y=e*b*k+a*g*d;this.z=a*g*k-e*b*d;return this},calculateW:function(){this.w=-Math.sqrt(Math.abs(1-this.x*this.x-this.y*this.y-this.z*this.z));return this},inverse:function(){this.x*=-1;this.y*=
+-1;this.z*=-1;return this},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},normalize:function(){var a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(a==0)this.w=this.z=this.y=this.x=0;else{a=1/a;this.x*=a;this.y*=a;this.z*=a;this.w*=a}return this},multiplySelf:function(a){var b=this.x,d=this.y,e=this.z,g=this.w,k=a.x,i=a.y,o=a.z;a=a.w;this.x=b*a+g*k+d*o-e*i;this.y=d*a+g*i+e*k-b*o;this.z=e*a+g*o+b*i-d*k;this.w=g*a-b*k-d*i-e*o;return this},
+multiplyVector3:function(a,b){b||(b=a);var d=a.x,e=a.y,g=a.z,k=this.x,i=this.y,o=this.z,l=this.w,v=l*d+i*g-o*e,x=l*e+o*d-k*g,w=l*g+k*e-i*d;d=-k*d-i*e-o*g;b.x=v*l+d*-k+x*-o-w*-i;b.y=x*l+d*-i+w*-k-v*-o;b.z=w*l+d*-o+v*-i-x*-k;return b}};
 THREE.Quaternion.slerp=function(a,b,d,e){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(g)>=1){d.w=a.w;d.x=a.x;d.y=a.y;d.z=a.z;return d}var k=Math.acos(g),i=Math.sqrt(1-g*g);if(Math.abs(i)<0.001){d.w=0.5*(a.w+b.w);d.x=0.5*(a.x+b.x);d.y=0.5*(a.y+b.y);d.z=0.5*(a.z+b.z);return d}g=Math.sin((1-e)*k)/i;e=Math.sin(e*k)/i;d.w=a.w*g+b.w*e;d.x=a.x*g+b.x*e;d.y=a.y*g+b.y*e;d.z=a.z*g+b.z*e;return d};
 THREE.Vertex=function(a,b){this.position=a||new THREE.Vector3;this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.normal=b||new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.normalScreen=new THREE.Vector3;this.tangent=new THREE.Vector4;this.__visible=!0};
 THREE.Face3=function(a,b,d,e,g){this.a=a;this.b=b;this.c=d;this.centroid=new THREE.Vector3;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.materials=g instanceof Array?g:[g]};THREE.Face4=function(a,b,d,e,g,k){this.a=a;this.b=b;this.c=d;this.d=e;this.centroid=new THREE.Vector3;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.materials=k instanceof Array?k:[k]};
-THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.geometryChunks={};this.hasTangents=!1};
+THREE.UV=function(a,b){this.set(a||0,b||0)};THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.faces=[];this.uvs=[];this.uvs2=[];this.colors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var a,b,d;a=0;for(b=this.faces.length;a<b;a++){d=this.faces[a];d.centroid.set(0,0,0);if(d instanceof THREE.Face3){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);d.centroid.divideScalar(3)}else if(d instanceof THREE.Face4){d.centroid.addSelf(this.vertices[d.a].position);d.centroid.addSelf(this.vertices[d.b].position);d.centroid.addSelf(this.vertices[d.c].position);
-d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,g,k,i,n=new THREE.Vector3,j=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){k=this.vertices[e];k.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){k=this.faces[e];if(a&&k.vertexNormals.length){n.set(0,0,0);b=0;for(d=k.normal.length;b<d;b++)n.addSelf(k.vertexNormals[b]);n.divideScalar(3)}else{b=this.vertices[k.a];d=this.vertices[k.b];i=this.vertices[k.c];n.sub(i.position,
-d.position);j.sub(b.position,d.position);n.crossSelf(j)}n.isZero()||n.normalize();k.normal.copy(n)}},computeVertexNormals:function(){var a,b,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;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,
+d.centroid.addSelf(this.vertices[d.d].position);d.centroid.divideScalar(4)}}},computeFaceNormals:function(a){var b,d,e,g,k,i,o=new THREE.Vector3,l=new THREE.Vector3;e=0;for(g=this.vertices.length;e<g;e++){k=this.vertices[e];k.normal.set(0,0,0)}e=0;for(g=this.faces.length;e<g;e++){k=this.faces[e];if(a&&k.vertexNormals.length){o.set(0,0,0);b=0;for(d=k.normal.length;b<d;b++)o.addSelf(k.vertexNormals[b]);o.divideScalar(3)}else{b=this.vertices[k.a];d=this.vertices[k.b];i=this.vertices[k.c];o.sub(i.position,
+d.position);l.sub(b.position,d.position);o.crossSelf(l)}o.isZero()||o.normalize();k.normal.copy(o)}},computeVertexNormals:function(){var a,b,d,e;if(this.__tmpVertices==undefined){e=this.__tmpVertices=Array(this.vertices.length);a=0;for(b=this.vertices.length;a<b;a++)e[a]=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;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(b=this.vertices.length;a<b;a++)e[a].set(0,0,0)}a=0;for(b=this.faces.length;a<b;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(b=this.vertices.length;a<b;a++)e[a].normalize();a=0;for(b=this.faces.length;a<
-b;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($,qa,wa,ua,Aa,Ha,Ia){k=$.vertices[qa].position;i=$.vertices[wa].position;n=$.vertices[ua].position;j=g[Aa];t=g[Ha];x=g[Ia];w=i.x-k.x;z=n.x-k.x;A=i.y-k.y;
-E=n.y-k.y;H=i.z-k.z;K=n.z-k.z;J=t.u-j.u;R=x.u-j.u;L=t.v-j.v;P=x.v-j.v;c=1/(J*P-R*L);ca.set((P*w-L*z)*c,(P*A-L*E)*c,(P*H-L*K)*c);ga.set((J*z-R*w)*c,(J*E-R*A)*c,(J*K-R*H)*c);aa[qa].addSelf(ca);aa[wa].addSelf(ca);aa[ua].addSelf(ca);ba[qa].addSelf(ga);ba[wa].addSelf(ga);ba[ua].addSelf(ga)}var b,d,e,g,k,i,n,j,t,x,w,z,A,E,H,K,J,R,L,P,c,aa=[],ba=[],ca=new THREE.Vector3,ga=new THREE.Vector3,da=new THREE.Vector3,ja=new THREE.Vector3,na=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){aa[b]=new THREE.Vector3;
-ba[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];g=this.uvs[b];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])}}b=0;for(d=this.vertices.length;b<d;b++){na.copy(this.vertices[b].normal);e=aa[b];da.copy(e);da.subSelf(na.multiplyScalar(na.dot(e))).normalize();ja.cross(this.vertices[b].normal,e);e=ja.dot(ba[b]);e=e<0?-1:1;this.vertices[b].tangent.set(da.x,da.y,da.z,e)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
+b;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(oa,ja,ra,wa,Fa,Aa,Ia){k=oa.vertices[ja].position;i=oa.vertices[ra].position;o=oa.vertices[wa].position;l=g[Fa];v=g[Aa];x=g[Ia];w=i.x-k.x;z=o.x-k.x;A=i.y-
+k.y;I=o.y-k.y;G=i.z-k.z;L=o.z-k.z;J=v.u-l.u;T=x.u-l.u;S=v.v-l.v;M=x.v-l.v;O=1/(J*M-T*S);fa.set((M*w-S*z)*O,(M*A-S*I)*O,(M*G-S*L)*O);ba.set((J*z-T*w)*O,(J*I-T*A)*O,(J*L-T*G)*O);c[ja].addSelf(fa);c[ra].addSelf(fa);c[wa].addSelf(fa);aa[ja].addSelf(ba);aa[ra].addSelf(ba);aa[wa].addSelf(ba)}var b,d,e,g,k,i,o,l,v,x,w,z,A,I,G,L,J,T,S,M,O,c=[],aa=[],fa=new THREE.Vector3,ba=new THREE.Vector3,ca=new THREE.Vector3,ia=new THREE.Vector3,na=new THREE.Vector3;b=0;for(d=this.vertices.length;b<d;b++){c[b]=new THREE.Vector3;
+aa[b]=new THREE.Vector3}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];g=this.uvs[b];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])}}b=0;for(d=this.vertices.length;b<d;b++){na.copy(this.vertices[b].normal);e=c[b];ca.copy(e);ca.subSelf(na.multiplyScalar(na.dot(e))).normalize();ia.cross(this.vertices[b].normal,e);e=ia.dot(aa[b]);e=e<0?-1:1;this.vertices[b].tangent.set(ca.x,ca.y,ca.z,e)}this.hasTangents=!0},computeBoundingBox:function(){var a;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],
 z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var b=1,d=this.vertices.length;b<d;b++){a=this.vertices[b];if(a.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=a.position.x;else if(a.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=a.position.x;if(a.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=a.position.y;else if(a.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=a.position.y;if(a.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=a.position.z;else if(a.position.z>
-this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}},sortFacesByMaterial:function(){function a(x){var w=[];b=0;for(d=x.length;b<d;b++)x[b]==undefined?w.push("undefined"):w.push(x[b].id);return w.join("_")}var b,d,e,g,k,i,n,j,t={};e=0;for(g=this.faces.length;e<g;e++){k=this.faces[e];
-i=k.materials;n=a(i);t[n]==undefined&&(t[n]={hash:n,counter:0});j=t[n].hash+"_"+t[n].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:i,vertices:0});k=k instanceof THREE.Face3?3:4;if(this.geometryChunks[j].vertices+k>65535){t[n].counter+=1;j=t[n].hash+"_"+t[n].counter;this.geometryChunks[j]==undefined&&(this.geometryChunks[j]={faces:[],materials:i,vertices:0})}this.geometryChunks[j].faces.push(e);this.geometryChunks[j].vertices+=k}}};THREE.GeometryIdCounter=0;
+this.boundingBox.z[1])this.boundingBox.z[1]=a.position.z}}},computeBoundingSphere:function(){for(var a=this.boundingSphere===null?0:this.boundingSphere.radius,b=0,d=this.vertices.length;b<d;b++)a=Math.max(a,this.vertices[b].position.length());this.boundingSphere={radius:a}}};THREE.GeometryIdCounter=0;
 THREE.Camera=function(a,b,d,e,g){THREE.Object3D.call(this);this.fov=a||50;this.aspect=b||1;this.near=d||0.1;this.far=e||2E3;this.target=g||new THREE.Object3D;this.useTarget=!0;this.up=new THREE.Vector3(0,1,0);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.tmpVec=new THREE.Vector3;this.translateX=function(k,i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(k);this.tmpVec.crossSelf(this.up);if(i)this.tmpVec.y=0;this.position.addSelf(this.tmpVec);
 this.target.position.addSelf(this.tmpVec)};this.translateZ=function(k,i){this.tmpVec.sub(this.target.position,this.position).normalize().multiplyScalar(k);if(i)this.tmpVec.y=0;this.position.subSelf(this.tmpVec);this.target.position.subSelf(this.tmpVec)};this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
 THREE.Camera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,this.far)};
@@ -112,75 +111,76 @@ THREE.Scene.prototype.addChildRecurse=function(a){if(a instanceof THREE.Light)th
 THREE.Scene.prototype.removeChildRecurse=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);b!==-1&&this.lights.splice(b,1)}else if(a instanceof THREE.Sound){b=this.sounds.indexOf(a);b!==-1&&this.sounds.splice(b,1)}else if(!(a instanceof THREE.Camera)){b=this.objects.indexOf(a);b!==-1&&this.objects.splice(b,1)}for(b=0;b<a.children.length;b++)this.removeChildRecurse(a.children[b])};THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;
 THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(a,b,d){this.color=new THREE.Color(a);this.near=b||1;this.far=d||1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=b||2.5E-4};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(a,b,d){d&&a.update(undefined,!1,b);d=a.sounds;var e,g=d.length;for(e=0;e<g;e++){a=d[e];this.soundPosition.set(a.matrixWorld.n14,a.matrixWorld.n24,a.matrixWorld.n34);this.soundPosition.subSelf(b.position);if(a.isPlaying&&a.isLoaded){a.isAddedToDOM||a.addToDOM(this.domElement);a.calculateVolumeAndPan(this.soundPosition)}}}};
-THREE.WebGLRenderer=function(a){function b(f,o,m){var h,l,v,r=f.vertices,q=r.length,s=f.colors,G=s.length,F=f.__vertexArray,I=f.__colorArray,S=f.__sortArray,y=f.__dirtyVertices,M=f.__dirtyColors;if(m.sortParticles){qa.multiplySelf(m.matrixWorld);for(h=0;h<q;h++){l=r[h].position;Aa.copy(l);qa.multiplyVector3(Aa);S[h]=[Aa.z,h]}S.sort(function(ea,Z){return Z[0]-ea[0]});for(h=0;h<q;h++){l=r[S[h][1]].position;v=h*3;F[v]=l.x;F[v+1]=l.y;F[v+2]=l.z}for(h=0;h<G;h++){v=h*3;color=s[S[h][1]];I[v]=color.r;I[v+
-1]=color.g;I[v+2]=color.b}}else{if(y)for(h=0;h<q;h++){l=r[h].position;v=h*3;F[v]=l.x;F[v+1]=l.y;F[v+2]=l.z}if(M)for(h=0;h<G;h++){color=s[h];v=h*3;I[v]=color.r;I[v+1]=color.g;I[v+2]=color.b}}if(y||m.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,F,o)}if(M||m.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,I,o)}}function d(f,o){f.fragmentShader=o.fragmentShader;f.vertexShader=o.vertexShader;f.uniforms=Uniforms.clone(o.uniforms)}
-function e(f,o,m,h,l){h.program||ca.initMaterial(h,o,m);var v=h.program,r=v.uniforms,q=h.uniforms;if(v!=aa){c.useProgram(v);aa=v;c.uniformMatrix4fv(r.projectionMatrix,!1,wa)}if(m&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof THREE.ParticleBasicMaterial)){q.fogColor.value.setHex(m.color.hex);if(m instanceof THREE.Fog){q.fogNear.value=m.near;q.fogFar.value=m.far}else if(m instanceof
-THREE.FogExp2)q.fogDensity.value=m.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){var s,G,F=0,I=0,S=0,y,M,ea,Z=ca.lights,Q=Z.directional.colors,O=Z.directional.positions,N=Z.point.colors,ra=Z.point.positions,u=0,ma=0;m=G=G=0;for(s=o.length;m<s;m++){G=o[m];y=G.color;M=G.position;ea=G.intensity;if(G instanceof THREE.AmbientLight){F+=y.r;I+=y.g;S+=y.b}else if(G instanceof THREE.DirectionalLight){G=u*3;Q[G]=y.r*ea;Q[G+1]=y.g*ea;Q[G+2]=y.b*ea;O[G]=M.x;O[G+1]=M.y;
-O[G+2]=M.z;u+=1}else if(G instanceof THREE.PointLight){G=ma*3;N[G]=y.r*ea;N[G+1]=y.g*ea;N[G+2]=y.b*ea;ra[G]=M.x;ra[G+1]=M.y;ra[G+2]=M.z;ma+=1}}for(m=u*3;m<Q.length;m++)Q[m]=0;for(m=ma*3;m<N.length;m++)N[m]=0;Z.point.length=ma;Z.directional.length=u;Z.ambient[0]=F;Z.ambient[1]=I;Z.ambient[2]=S;o=ca.lights;q.enableLighting.value=o.directional.length+o.point.length;q.ambientLightColor.value=o.ambient;q.directionalLightColor.value=o.directional.colors;q.directionalLightDirection.value=o.directional.positions;
-q.pointLightColor.value=o.point.colors;q.pointLightPosition.value=o.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){q.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);q.opacity.value=h.opacity;q.map.texture=h.map;q.lightMap.texture=h.lightMap;q.envMap.texture=h.envMap;q.reflectivity.value=h.reflectivity;q.refractionRatio.value=h.refractionRatio;q.combine.value=h.combine;q.useRefract.value=
-h.envMap&&h.envMap.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof THREE.LineBasicMaterial){q.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);q.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){q.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);q.opacity.value=h.opacity;q.size.value=h.size;q.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){q.ambient.value.setRGB(h.ambient.r,h.ambient.g,
-h.ambient.b);q.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);q.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){q.mNear.value=f.near;q.mFar.value=f.far;q.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)q.opacity.value=h.opacity;for(var ka in q)if(F=v.uniforms[ka]){m=q[ka];s=m.type;o=m.value;if(s=="i")c.uniform1i(F,o);else if(s=="f")c.uniform1f(F,o);else if(s=="fv1")c.uniform1fv(F,o);else if(s=="fv")c.uniform3fv(F,o);else if(s=="v2")c.uniform2f(F,
-o.x,o.y);else if(s=="v3")c.uniform3f(F,o.x,o.y,o.z);else if(s=="c")c.uniform3f(F,o.r,o.g,o.b);else if(s=="t"){c.uniform1i(F,o);if(m=m.texture)if(m.image instanceof Array&&m.image.length==6){if(m.image.length==6){if(m.needsUpdate){if(!m.image.__webGLTextureCube)m.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);
-c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(s=0;s<6;++s)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,m.image[s]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);m.needsUpdate=!1}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube)}}else{if(m.needsUpdate){if(m.__wasSetOnce){c.bindTexture(c.TEXTURE_2D,
-m.__webGLTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,m.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,L(m.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,L(m.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,L(m.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,L(m.minFilter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}else{m.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,m.__webGLTexture);c.texImage2D(c.TEXTURE_2D,
-0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,m.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,L(m.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,L(m.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,L(m.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,L(m.minFilter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null);m.__wasSetOnce=!0}m.needsUpdate=!1}c.activeTexture(c.TEXTURE0+o);c.bindTexture(c.TEXTURE_2D,m.__webGLTexture)}}}c.uniformMatrix4fv(r.modelViewMatrix,
-!1,l._modelViewMatrixArray);c.uniformMatrix3fv(r.normalMatrix,!1,l._normalMatrixArray);(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||h.envMap)&&c.uniform3f(r.cameraPosition,f.position.x,f.position.y,f.position.z);(h instanceof THREE.MeshShaderMaterial||h.envMap||h.skinning)&&c.uniformMatrix4fv(r.objectMatrix,!1,l._objectMatrixArray);(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial||h.skinning)&&c.uniformMatrix4fv(r.viewMatrix,
-!1,ua);if(h.skinning){c.uniformMatrix4fv(r.cameraInverseMatrix,!1,ua);c.uniformMatrix4fv(r.boneGlobalMatrices,!1,l.boneMatrices)}return v}function g(f,o,m,h,l,v){f=e(f,o,m,h,v).attributes;c.bindBuffer(c.ARRAY_BUFFER,l.__webGLVertexBuffer);c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0);if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLNormalBuffer);c.vertexAttribPointer(f.normal,
-3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLTangentBuffer);c.vertexAttribPointer(f.tangent,4,c.FLOAT,!1,0,0)}if(f.uv>=0)if(l.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLUVBuffer);c.vertexAttribPointer(f.uv,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv)}else c.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(l.__webGLUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2);
-if(h.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,l.__webGLSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,l.__webGLSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,l.__webGLSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,l.__webGLSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight,
-4,c.FLOAT,!1,0,0)}if(v instanceof THREE.Mesh)if(h.wireframe){c.lineWidth(h.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLLineBuffer);c.drawElements(c.LINES,l.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,l.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,l.__webGLFaceCount,c.UNSIGNED_SHORT,0)}else if(v instanceof THREE.Line){v=v.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(h.linewidth);c.drawArrays(v,0,l.__webGLLineCount)}else if(v instanceof
-THREE.ParticleSystem)c.drawArrays(c.POINTS,0,l.__webGLParticleCount);else v instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,l.__webGLVertexCount)}function k(f,o){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=c.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=c.createBuffer();if(f.hasPos){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,f.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(o.attributes.position);c.vertexAttribPointer(o.attributes.position,
-3,c.FLOAT,!1,0,0)}if(f.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,f.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(o.attributes.normal);c.vertexAttribPointer(o.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,f.count);f.count=0}function i(f){if(ga!=f.doubleSided){f.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);ga=f.doubleSided}if(da!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);da=f.flipSided}}function n(f){if(na!=
-f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);na=f}}function j(f){$[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);$[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);$[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);$[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);$[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);$[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var o;for(f=0;f<6;f++){o=$[f];o.divideScalar(Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z))}}
-function t(f){for(var o=f.matrixWorld,m=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),h=0;h<6;h++){f=$[h].x*o.n14+$[h].y*o.n24+$[h].z*o.n34+$[h].w;if(f<=m)return!1}return!0}function x(f,o){f.list[f.count]=o;f.count+=1}function w(f){var o,m,h=f.object,l=f.opaque,v=f.transparent;v.count=0;f=l.count=0;for(o=h.materials.length;f<o;f++){m=h.materials[f];m.opacity&&m.opacity<1||m.blending!=THREE.NormalBlending?x(v,m):x(l,m)}}function z(f){var o,m,h,l,v=f.object,r=f.buffer,
-q=f.opaque,s=f.transparent;s.count=0;f=q.count=0;for(h=v.materials.length;f<h;f++){o=v.materials[f];if(o instanceof THREE.MeshFaceMaterial){o=0;for(m=r.materials.length;o<m;o++)(l=r.materials[o])&&(l.opacity&&l.opacity<1||l.blending!=THREE.NormalBlending?x(s,l):x(q,l))}else{l=o;l.opacity&&l.opacity<1||l.blending!=THREE.NormalBlending?x(s,l):x(q,l)}}}function A(f,o){return o.z-f.z}function E(f,o,m,h,l){if(o[m]==undefined){f.push({buffer:h,object:l,opaque:{list:[],count:0},transparent:{list:[],count:0}});
-o[m]=1}}function H(f,o){f._modelViewMatrix.multiplyToArray(o.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function K(f){if(f!=ja){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,c.ZERO);break;case THREE.BillboardBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);
-break;case THREE.ReverseSubtractiveBlending:c.blendEquation(c.FUNC_REVERSE_SUBTRACT);c.blendFunc(c.ONE,c.ONE);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}ja=f}}function J(f,o){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=c.createFramebuffer();f.__webGLRenderbuffer=c.createRenderbuffer();f.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,f.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,f.width,f.height);c.bindTexture(c.TEXTURE_2D,
-f.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,L(f.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,L(f.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,L(f.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,L(f.minFilter));c.texImage2D(c.TEXTURE_2D,0,L(f.format),f.width,f.height,0,L(f.format),L(f.type),null);c.bindFramebuffer(c.FRAMEBUFFER,f.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,f.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,
-c.DEPTH_ATTACHMENT,c.RENDERBUFFER,f.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var m,h,l;if(f){m=f.__webGLFramebuffer;h=f.width;l=f.height}else{m=null;h=P.width;l=P.height}if(m!=ba){c.bindFramebuffer(c.FRAMEBUFFER,m);c.viewport(0,0,h,l);o&&c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT);ba=m}}function R(f,o){var m;if(f=="fragment")m=c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(m=c.createShader(c.VERTEX_SHADER));
-c.shaderSource(m,o);c.compileShader(m);if(!c.getShaderParameter(m,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(m));return null}return m}function L(f){switch(f){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;
-case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;case THREE.IntType:return c.INT;case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;
-case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var P=document.createElement("canvas"),c,aa=null,ba=null,ca=this,ga=null,da=null,ja=null,na=null,$=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],qa=new THREE.Matrix4,wa=new Float32Array(16),ua=new Float32Array(16),Aa=new THREE.Vector4,Ha=!0,Ia=new THREE.Color(0),Oa=0;if(a){if(a.antialias!==undefined)Ha=a.antialias;a.clearColor!==
-undefined&&Ia.setHex(a.clearColor);if(a.clearAlpha!==undefined)Oa=a.clearAlpha}this.domElement=P;this.autoClear=!0;this.sortObjects=!1;(function(f,o,m){try{c=P.getContext("experimental-webgl",{antialias:f})}catch(h){console.log(h)}if(!c)throw"cannot create webgl context";c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(o.r,o.g,o.b,m);
-_cullEnabled=!0})(Ha,Ia,Oa);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,o){P.width=f;P.height=o;c.viewport(0,0,P.width,P.height)};this.setClearColorHex=function(f,o){var m=new THREE.Color(f);c.clearColor(m.r,m.g,m.b,o)};this.setClearColor=function(f,o){c.clearColor(f.r,f.g,f.b,o)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.initMaterial=function(f,o,m){var h,
-l;if(f instanceof THREE.MeshDepthMaterial)d(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)d(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)d(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)d(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)d(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)d(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&d(f,THREE.ShaderLib.particle_basic);
-var v,r,q,s;l=q=s=0;for(v=o.length;l<v;l++){r=o[l];r instanceof THREE.DirectionalLight&&q++;r instanceof THREE.PointLight&&s++}if(s+q<=4)o=q;else{o=Math.ceil(4*q/(s+q));s=4-o}l={directional:o,point:s};s=f.fragmentShader;o=f.vertexShader;v={fog:m,map:f.map,envMap:f.envMap,lightMap:f.lightMap,vertexColors:f.vertexColors,skinning:f.skinning,maxDirLights:l.directional,maxPointLights:l.point};m=c.createProgram();l=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+v.maxDirLights,
-"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.fog?"#define USE_FOG":"",v.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",v.map?"#define USE_MAP":"",v.envMap?"#define USE_ENVMAP":"",v.lightMap?"#define USE_LIGHTMAP":"",v.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");v=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+v.maxDirLights,"#define MAX_POINT_LIGHTS "+v.maxPointLights,v.map?
-"#define USE_MAP":"",v.envMap?"#define USE_ENVMAP":"",v.lightMap?"#define USE_LIGHTMAP":"",v.vertexColors?"#define USE_COLOR":"",v.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
-c.attachShader(m,R("fragment",l+s));c.attachShader(m,R("vertex",v+o));c.linkProgram(m);c.getProgramParameter(m,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(m,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");m.uniforms={};m.attributes={};f.program=m;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(h in f.uniforms)m.push(h);h=f.program;s=0;for(o=m.length;s<
-o;s++){l=m[s];h.uniforms[l]=c.getUniformLocation(h,l)}h=f.program;m=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];s=0;for(o=m.length;s<o;s++){l=m[s];h.attributes[l]=c.getAttribLocation(h,l)}h=f.program.attributes;c.enableVertexAttribArray(h.position);h.color>=0&&c.enableVertexAttribArray(h.color);h.normal>=0&&c.enableVertexAttribArray(h.normal);h.tangent>=0&&c.enableVertexAttribArray(h.tangent);if(f.skinning&&h.skinVertexA>=0&&h.skinVertexB>=
-0&&h.skinIndex>=0&&h.skinWeight>=0){c.enableVertexAttribArray(h.skinVertexA);c.enableVertexAttribArray(h.skinVertexB);c.enableVertexAttribArray(h.skinIndex);c.enableVertexAttribArray(h.skinWeight)}};this.render=function(f,o,m,h){var l,v,r,q,s,G,F,I,S=f.lights,y=f.fog;o.matrixAutoUpdate&&o.update();o.matrixWorldInverse.flattenToArray(ua);o.projectionMatrix.flattenToArray(wa);qa.multiply(o.projectionMatrix,o.matrixWorldInverse);j(qa);THREE.AnimationHandler&&THREE.AnimationHandler.update();f.update(undefined,
-!1,o);this.initWebGLObjects(f,o);J(m,h!==undefined?h:!0);this.autoClear&&this.clear();s=f.__webGLObjects.length;for(h=0;h<s;h++){l=f.__webGLObjects[h];F=l.object;if(F.visible)if(!(F instanceof THREE.Mesh)||t(F)){F.matrixWorld.flattenToArray(F._objectMatrixArray);H(F,o);z(l);l.render=!0;if(this.sortObjects){Aa.copy(F.position);qa.multiplyVector3(Aa);l.z=Aa.z}}else l.render=!1;else l.render=!1}this.sortObjects&&f.__webGLObjects.sort(A);G=f.__webGLObjectsImmediate.length;for(h=0;h<G;h++){l=f.__webGLObjectsImmediate[h];
-F=l.object;if(F.visible){F.matrixAutoUpdate&&F.matrixWorld.flattenToArray(F._objectMatrixArray);H(F,o);w(l)}}K(THREE.NormalBlending);for(h=0;h<s;h++){l=f.__webGLObjects[h];if(l.render){F=l.object;I=l.buffer;r=l.opaque;i(F);for(l=0;l<r.count;l++){q=r.list[l];n(q.depthTest);g(o,S,y,q,I,F)}}}for(h=0;h<G;h++){l=f.__webGLObjectsImmediate[h];F=l.object;if(F.visible){r=l.opaque;i(F);for(l=0;l<r.count;l++){q=r.list[l];n(q.depthTest);v=e(o,S,y,q,F);F.render(function(M){k(M,v)})}}}for(h=0;h<s;h++){l=f.__webGLObjects[h];
-if(l.render){F=l.object;I=l.buffer;r=l.transparent;i(F);for(l=0;l<r.count;l++){q=r.list[l];K(q.blending);n(q.depthTest);g(o,S,y,q,I,F)}}}for(h=0;h<G;h++){l=f.__webGLObjectsImmediate[h];F=l.object;if(F.visible){r=l.transparent;i(F);for(l=0;l<r.count;l++){q=r.list[l];K(q.blending);n(q.depthTest);v=e(o,S,y,q,F);F.render(function(M){k(M,v)})}}}if(m&&m.minFilter!==THREE.NearestFilter&&m.minFilter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,m.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,
-null)}};this.initWebGLObjects=function(f,o){var m,h,l;if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}m=0;for(h=f.objects.length;m<h;m++){l=f.objects[m];var v=f,r=o,q=void 0,s=void 0,G=void 0,F=void 0;s=l.geometry;if(v.__webGLObjectsMap[l.id]==undefined){v.__webGLObjectsMap[l.id]={};l._modelViewMatrix=new THREE.Matrix4;l._normalMatrixArray=new Float32Array(9);l._modelViewMatrixArray=new Float32Array(16);l._objectMatrixArray=new Float32Array(16);l.matrixWorld.flattenToArray(l._objectMatrixArray)}F=
-v.__webGLObjectsMap[l.id];objlist=v.__webGLObjects;if(l instanceof THREE.Mesh){for(q in s.geometryChunks){G=s.geometryChunks[q];if(!G.__webGLVertexBuffer){r=G;r.__webGLVertexBuffer=c.createBuffer();r.__webGLNormalBuffer=c.createBuffer();r.__webGLTangentBuffer=c.createBuffer();r.__webGLColorBuffer=c.createBuffer();r.__webGLUVBuffer=c.createBuffer();r.__webGLUV2Buffer=c.createBuffer();r.__webGLSkinVertexABuffer=c.createBuffer();r.__webGLSkinVertexBBuffer=c.createBuffer();r.__webGLSkinIndicesBuffer=
-c.createBuffer();r.__webGLSkinWeightsBuffer=c.createBuffer();r.__webGLFaceBuffer=c.createBuffer();r.__webGLLineBuffer=c.createBuffer();r=G;var I=l,S=void 0,y=void 0,M=0,ea=v=0,Z=I.geometry.faces,Q=r.faces;S=0;for(y=Q.length;S<y;S++){fi=Q[S];face=Z[fi];if(face instanceof THREE.Face3){M+=3;v+=1;ea+=3}else if(face instanceof THREE.Face4){M+=4;v+=2;ea+=4}}r.__vertexArray=new Float32Array(M*3);r.__normalArray=new Float32Array(M*3);r.__tangentArray=new Float32Array(M*4);r.__colorArray=new Float32Array(M*
-3);r.__uvArray=new Float32Array(M*2);r.__uv2Array=new Float32Array(M*2);r.__skinVertexAArray=new Float32Array(M*4);r.__skinVertexBArray=new Float32Array(M*4);r.__skinIndexArray=new Float32Array(M*4);r.__skinWeightArray=new Float32Array(M*4);r.__faceArray=new Uint16Array(v*3);r.__lineArray=new Uint16Array(ea*2);y=S=r;M=void 0;Z=void 0;var O=void 0,N=void 0;O=void 0;Q=!1;M=0;for(Z=I.materials.length;M<Z;M++){O=I.materials[M];if(O instanceof THREE.MeshFaceMaterial){O=0;for(N=y.materials.length;O<N;O++)if(y.materials[O]&&
-y.materials[O].shading!=undefined&&y.materials[O].shading==THREE.SmoothShading){Q=!0;break}}else if(O&&O.shading!=undefined&&O.shading==THREE.SmoothShading){Q=!0;break}if(Q)break}S.__needsSmoothNormals=Q;r.__webGLFaceCount=v*3;r.__webGLLineCount=ea*2;s.__dirtyVertices=!0;s.__dirtyElements=!0;s.__dirtyUvs=!0;s.__dirtyNormals=!0;s.__dirtyTangents=!0;s.__dirtyColors=!0}if(s.__dirtyVertices||s.__dirtyElements||s.__dirtyUvs||s.__dirtyNormals||s.__dirtyColors||s.__dirtyTangents){r=G;v=c.DYNAMIC_DRAW;ea=
-void 0;S=void 0;var ra=void 0,u=void 0,ma=void 0,ka=void 0,va=void 0;ra=void 0;var B=void 0,C=void 0,D=void 0,T=void 0;B=void 0;C=void 0;D=void 0;u=void 0;B=void 0;C=void 0;D=void 0;T=void 0;B=void 0;C=void 0;D=void 0;T=void 0;B=void 0;C=void 0;D=void 0;T=void 0;B=void 0;C=void 0;D=void 0;T=void 0;B=void 0;C=void 0;D=void 0;T=void 0;u=void 0;ka=void 0;ma=void 0;va=void 0;var oa=N=O=Q=Z=M=I=y=0,fa=0,p=0,ha=r.__vertexArray,Fa=r.__uvArray,Ga=r.__uv2Array,ta=r.__normalArray,U=r.__tangentArray,ia=r.__colorArray,
-V=r.__skinVertexAArray,W=r.__skinVertexBArray,X=r.__skinIndexArray,Y=r.__skinWeightArray,xa=r.__faceArray,pa=r.__lineArray,Pa=r.__needsSmoothNormals,la=l.geometry,Ja=la.__dirtyVertices,Ka=la.__dirtyElements,Ea=la.__dirtyUvs,La=la.__dirtyNormals,Ma=la.__dirtyTangents,Na=la.__dirtyColors,sa=la.vertices,Qa=r.faces,Ra=la.faces,Sa=la.uvs,Ta=la.uvs2,ya=la.colors,Ba=la.skinVerticesA,Ca=la.skinVerticesB,Da=la.skinIndices,za=la.skinWeights;ea=0;for(S=Qa.length;ea<S;ea++){ra=Qa[ea];u=Ra[ra];va=Sa[ra];ra=Ta[ra];
-ma=u.vertexNormals;ka=u.normal;if(u instanceof THREE.Face3){if(Ja){B=sa[u.a].position;C=sa[u.b].position;D=sa[u.c].position;ha[I]=B.x;ha[I+1]=B.y;ha[I+2]=B.z;ha[I+3]=C.x;ha[I+4]=C.y;ha[I+5]=C.z;ha[I+6]=D.x;ha[I+7]=D.y;ha[I+8]=D.z;I+=9}if(za.length){B=za[u.a];C=za[u.b];D=za[u.c];Y[p]=B.x;Y[p+1]=B.y;Y[p+2]=B.z;Y[p+3]=B.w;Y[p+4]=C.x;Y[p+5]=C.y;Y[p+6]=C.z;Y[p+7]=C.w;Y[p+8]=D.x;Y[p+9]=D.y;Y[p+10]=D.z;Y[p+11]=D.w;B=Da[u.a];C=Da[u.b];D=Da[u.c];X[p]=B.x;X[p+1]=B.y;X[p+2]=B.z;X[p+3]=B.w;X[p+4]=C.x;X[p+5]=
-C.y;X[p+6]=C.z;X[p+7]=C.w;X[p+8]=D.x;X[p+9]=D.y;X[p+10]=D.z;X[p+11]=D.w;B=Ba[u.a];C=Ba[u.b];D=Ba[u.c];V[p]=B.x;V[p+1]=B.y;V[p+2]=B.z;V[p+3]=1;V[p+4]=C.x;V[p+5]=C.y;V[p+6]=C.z;V[p+7]=1;V[p+8]=D.x;V[p+9]=D.y;V[p+10]=D.z;V[p+11]=1;B=Ca[u.a];C=Ca[u.b];D=Ca[u.c];W[p]=B.x;W[p+1]=B.y;W[p+2]=B.z;W[p+3]=1;W[p+4]=C.x;W[p+5]=C.y;W[p+6]=C.z;W[p+7]=1;W[p+8]=D.x;W[p+9]=D.y;W[p+10]=D.z;W[p+11]=1;p+=12}if(Na&&ya.length){B=ya[u.a];C=ya[u.b];D=ya[u.c];ia[fa]=B.r;ia[fa+1]=B.g;ia[fa+2]=B.b;ia[fa+3]=C.r;ia[fa+4]=C.g;
-ia[fa+5]=C.b;ia[fa+6]=D.r;ia[fa+7]=D.g;ia[fa+8]=D.b;fa+=9}if(Ma&&la.hasTangents){B=sa[u.a].tangent;C=sa[u.b].tangent;D=sa[u.c].tangent;U[N]=B.x;U[N+1]=B.y;U[N+2]=B.z;U[N+3]=B.w;U[N+4]=C.x;U[N+5]=C.y;U[N+6]=C.z;U[N+7]=C.w;U[N+8]=D.x;U[N+9]=D.y;U[N+10]=D.z;U[N+11]=D.w;N+=12}if(La)if(ma.length==3&&Pa)for(u=0;u<3;u++){ka=ma[u];ta[O]=ka.x;ta[O+1]=ka.y;ta[O+2]=ka.z;O+=3}else for(u=0;u<3;u++){ta[O]=ka.x;ta[O+1]=ka.y;ta[O+2]=ka.z;O+=3}if(Ea&&va)for(u=0;u<3;u++){ma=va[u];Fa[M]=ma.u;Fa[M+1]=ma.v;M+=2}if(Ea&&
-ra)for(u=0;u<3;u++){va=ra[u];Ga[Z]=va.u;Ga[Z+1]=va.v;Z+=2}if(Ka){xa[Q]=y;xa[Q+1]=y+1;xa[Q+2]=y+2;Q+=3;pa[oa]=y;pa[oa+1]=y+1;pa[oa+2]=y;pa[oa+3]=y+2;pa[oa+4]=y+1;pa[oa+5]=y+2;oa+=6;y+=3}}else if(u instanceof THREE.Face4){if(Ja){B=sa[u.a].position;C=sa[u.b].position;D=sa[u.c].position;T=sa[u.d].position;ha[I]=B.x;ha[I+1]=B.y;ha[I+2]=B.z;ha[I+3]=C.x;ha[I+4]=C.y;ha[I+5]=C.z;ha[I+6]=D.x;ha[I+7]=D.y;ha[I+8]=D.z;ha[I+9]=T.x;ha[I+10]=T.y;ha[I+11]=T.z;I+=12}if(za.length){B=za[u.a];C=za[u.b];D=za[u.c];T=za[u.d];
-Y[p]=B.x;Y[p+1]=B.y;Y[p+2]=B.z;Y[p+3]=B.w;Y[p+4]=C.x;Y[p+5]=C.y;Y[p+6]=C.z;Y[p+7]=C.w;Y[p+8]=D.x;Y[p+9]=D.y;Y[p+10]=D.z;Y[p+11]=D.w;Y[p+12]=T.x;Y[p+13]=T.y;Y[p+14]=T.z;Y[p+15]=T.w;B=Da[u.a];C=Da[u.b];D=Da[u.c];T=Da[u.d];X[p]=B.x;X[p+1]=B.y;X[p+2]=B.z;X[p+3]=B.w;X[p+4]=C.x;X[p+5]=C.y;X[p+6]=C.z;X[p+7]=C.w;X[p+8]=D.x;X[p+9]=D.y;X[p+10]=D.z;X[p+11]=D.w;X[p+12]=T.x;X[p+13]=T.y;X[p+14]=T.z;X[p+15]=T.w;B=Ba[u.a];C=Ba[u.b];D=Ba[u.c];T=Ba[u.d];V[p]=B.x;V[p+1]=B.y;V[p+2]=B.z;V[p+3]=1;V[p+4]=C.x;V[p+5]=C.y;
-V[p+6]=C.z;V[p+7]=1;V[p+8]=D.x;V[p+9]=D.y;V[p+10]=D.z;V[p+11]=1;V[p+12]=T.x;V[p+13]=T.y;V[p+14]=T.z;V[p+15]=1;B=Ca[u.a];C=Ca[u.b];D=Ca[u.c];T=Ca[u.d];W[p]=B.x;W[p+1]=B.y;W[p+2]=B.z;W[p+3]=1;W[p+4]=C.x;W[p+5]=C.y;W[p+6]=C.z;W[p+7]=1;W[p+8]=D.x;W[p+9]=D.y;W[p+10]=D.z;W[p+11]=1;W[p+12]=T.x;W[p+13]=T.y;W[p+14]=T.z;W[p+15]=1;p+=16}if(Na&&ya.length){B=ya[u.a];C=ya[u.b];D=ya[u.c];T=ya[u.d];ia[fa]=B.r;ia[fa+1]=B.g;ia[fa+2]=B.b;ia[fa+3]=C.r;ia[fa+4]=C.g;ia[fa+5]=C.b;ia[fa+6]=D.r;ia[fa+7]=D.g;ia[fa+8]=D.b;
-ia[fa+9]=T.r;ia[fa+10]=T.g;ia[fa+11]=T.b;fa+=12}if(Ma&&la.hasTangents){B=sa[u.a].tangent;C=sa[u.b].tangent;D=sa[u.c].tangent;u=sa[u.d].tangent;U[N]=B.x;U[N+1]=B.y;U[N+2]=B.z;U[N+3]=B.w;U[N+4]=C.x;U[N+5]=C.y;U[N+6]=C.z;U[N+7]=C.w;U[N+8]=D.x;U[N+9]=D.y;U[N+10]=D.z;U[N+11]=D.w;U[N+12]=u.x;U[N+13]=u.y;U[N+14]=u.z;U[N+15]=u.w;N+=16}if(La)if(ma.length==4&&Pa)for(u=0;u<4;u++){ka=ma[u];ta[O]=ka.x;ta[O+1]=ka.y;ta[O+2]=ka.z;O+=3}else for(u=0;u<4;u++){ta[O]=ka.x;ta[O+1]=ka.y;ta[O+2]=ka.z;O+=3}if(Ea&&va)for(u=
-0;u<4;u++){ma=va[u];Fa[M]=ma.u;Fa[M+1]=ma.v;M+=2}if(Ea&&ra)for(u=0;u<4;u++){va=ra[u];Ga[Z]=va.u;Ga[Z+1]=va.v;Z+=2}if(Ka){xa[Q]=y;xa[Q+1]=y+1;xa[Q+2]=y+2;xa[Q+3]=y;xa[Q+4]=y+2;xa[Q+5]=y+3;Q+=6;pa[oa]=y;pa[oa+1]=y+1;pa[oa+2]=y;pa[oa+3]=y+3;pa[oa+4]=y+1;pa[oa+5]=y+2;pa[oa+6]=y+2;pa[oa+7]=y+3;oa+=8;y+=4}}}if(Ja){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,ha,v)}if(Na&&ya.length){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,ia,v)}if(La){c.bindBuffer(c.ARRAY_BUFFER,
-r.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ta,v)}if(Ma&&la.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,U,v)}if(Ea&&M>0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,Fa,v)}if(Ea&&Z>0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLUV2Buffer);c.bufferData(c.ARRAY_BUFFER,Ga,v)}if(Ka){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,xa,v);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,r.__webGLLineBuffer);
-c.bufferData(c.ELEMENT_ARRAY_BUFFER,pa,v)}if(p>0){c.bindBuffer(c.ARRAY_BUFFER,r.__webGLSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,V,v);c.bindBuffer(c.ARRAY_BUFFER,r.__webGLSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,W,v);c.bindBuffer(c.ARRAY_BUFFER,r.__webGLSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,X,v);c.bindBuffer(c.ARRAY_BUFFER,r.__webGLSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,Y,v)}}E(objlist,F,q,G,l)}s.__dirtyVertices=!1;s.__dirtyElements=!1;s.__dirtyUvs=!1;s.__dirtyNormals=
-!1;s.__dirtyTangents=!1;s.__dirtyColors=!1}else if(l instanceof THREE.Ribbon){if(!s.__webGLVertexBuffer){q=s;q.__webGLVertexBuffer=c.createBuffer();q.__webGLColorBuffer=c.createBuffer();q=s;G=q.vertices.length;q.__vertexArray=new Float32Array(G*3);q.__colorArray=new Float32Array(G*3);q.__webGLVertexCount=G;s.__dirtyVertices=!0;s.__dirtyColors=!0}if(s.__dirtyVertices||s.__dirtyColors){q=s;G=c.DYNAMIC_DRAW;y=void 0;y=void 0;I=void 0;r=void 0;M=q.vertices;v=q.colors;Z=M.length;ea=v.length;Q=q.__vertexArray;
-S=q.__colorArray;O=q.__dirtyColors;if(q.__dirtyVertices){for(y=0;y<Z;y++){I=M[y].position;r=y*3;Q[r]=I.x;Q[r+1]=I.y;Q[r+2]=I.z}c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,Q,G)}if(O){for(y=0;y<ea;y++){color=v[y];r=y*3;S[r]=color.r;S[r+1]=color.g;S[r+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,q.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,S,G)}}E(objlist,F,0,s,l);s.__dirtyVertices=!1;s.__dirtyColors=!1}else if(l instanceof THREE.Line){if(!s.__webGLVertexBuffer){q=s;
-q.__webGLVertexBuffer=c.createBuffer();q.__webGLColorBuffer=c.createBuffer();q=s;G=q.vertices.length;q.__vertexArray=new Float32Array(G*3);q.__colorArray=new Float32Array(G*3);q.__webGLLineCount=G;s.__dirtyVertices=!0;s.__dirtyColors=!0}if(s.__dirtyVertices||s.__dirtyColors){q=s;G=c.DYNAMIC_DRAW;y=void 0;y=void 0;I=void 0;r=void 0;M=q.vertices;v=q.colors;Z=M.length;ea=v.length;Q=q.__vertexArray;S=q.__colorArray;O=q.__dirtyColors;if(q.__dirtyVertices){for(y=0;y<Z;y++){I=M[y].position;r=y*3;Q[r]=I.x;
-Q[r+1]=I.y;Q[r+2]=I.z}c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,Q,G)}if(O){for(y=0;y<ea;y++){color=v[y];r=y*3;S[r]=color.r;S[r+1]=color.g;S[r+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,q.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,S,G)}}E(objlist,F,0,s,l);s.__dirtyVertices=!1;s.__dirtyColors=!1}else if(l instanceof THREE.ParticleSystem){if(!s.__webGLVertexBuffer){q=s;q.__webGLVertexBuffer=c.createBuffer();q.__webGLColorBuffer=c.createBuffer();q=s;G=q.vertices.length;
-q.__vertexArray=new Float32Array(G*3);q.__colorArray=new Float32Array(G*3);q.__sortArray=[];q.__webGLParticleCount=G;s.__dirtyVertices=!0;s.__dirtyColors=!0}(s.__dirtyVertices||s.__dirtyColors||l.sortParticles)&&b(s,c.DYNAMIC_DRAW,l,r);E(objlist,F,0,s,l);s.__dirtyVertices=!1;s.__dirtyColors=!1}else if(THREE.MarchingCubes!==undefined&&l instanceof THREE.MarchingCubes){s=F;if(s[0]==undefined){v.__webGLObjectsImmediate.push({object:l,opaque:{list:[],count:0},transparent:{list:[],count:0}});s[0]=1}}}};
-this.removeObject=function(f,o){var m,h;for(m=f.__webGLObjects.length-1;m>=0;m--){h=f.__webGLObjects[m].object;o==h&&f.__webGLObjects.splice(m,1)}};this.setFaceCulling=function(f,o){if(f){!o||o=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.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 envMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",
-envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",
-map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",
-lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
+THREE.WebGLRenderer=function(a){function b(f,n,m){var h,j,t,q=f.vertices,r=q.length,p=f.colors,E=p.length,F=f.__vertexArray,H=f.__colorArray,Q=f.__sortArray,y=f.__dirtyVertices,K=f.__dirtyColors;if(m.sortParticles){ra.multiplySelf(m.matrixWorld);for(h=0;h<r;h++){j=q[h].position;Aa.copy(j);ra.multiplyVector3(Aa);Q[h]=[Aa.z,h]}Q.sort(function(da,$){return $[0]-da[0]});for(h=0;h<r;h++){j=q[Q[h][1]].position;t=h*3;F[t]=j.x;F[t+1]=j.y;F[t+2]=j.z}for(h=0;h<E;h++){t=h*3;color=p[Q[h][1]];H[t]=color.r;H[t+
+1]=color.g;H[t+2]=color.b}}else{if(y)for(h=0;h<r;h++){j=q[h].position;t=h*3;F[t]=j.x;F[t+1]=j.y;F[t+2]=j.z}if(K)for(h=0;h<E;h++){color=p[h];t=h*3;H[t]=color.r;H[t+1]=color.g;H[t+2]=color.b}}if(y||m.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,F,n)}if(K||m.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,H,n)}}function d(f,n){f.fragmentShader=n.fragmentShader;f.vertexShader=n.vertexShader;f.uniforms=Uniforms.clone(n.uniforms)}
+function e(f,n,m,h,j){h.program||ba.initMaterial(h,n,m);var t=h.program,q=t.uniforms,r=h.uniforms;if(t!=aa){c.useProgram(t);aa=t;c.uniformMatrix4fv(q.projectionMatrix,!1,wa)}if(m&&(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial||h instanceof THREE.LineBasicMaterial||h instanceof THREE.ParticleBasicMaterial)){r.fogColor.value.setHex(m.color.hex);if(m instanceof THREE.Fog){r.fogNear.value=m.near;r.fogFar.value=m.far}else if(m instanceof
+THREE.FogExp2)r.fogDensity.value=m.density}if(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial){var p,E,F=0,H=0,Q=0,y,K,da,$=ba.lights,R=$.directional.colors,P=$.directional.positions,N=$.point.colors,sa=$.point.positions,u=0,ma=0;m=E=E=0;for(p=n.length;m<p;m++){E=n[m];y=E.color;K=E.position;da=E.intensity;if(E instanceof THREE.AmbientLight){F+=y.r;H+=y.g;Q+=y.b}else if(E instanceof THREE.DirectionalLight){E=u*3;R[E]=y.r*da;R[E+1]=y.g*da;R[E+2]=y.b*da;P[E]=K.x;P[E+1]=K.y;
+P[E+2]=K.z;u+=1}else if(E instanceof THREE.PointLight){E=ma*3;N[E]=y.r*da;N[E+1]=y.g*da;N[E+2]=y.b*da;sa[E]=K.x;sa[E+1]=K.y;sa[E+2]=K.z;ma+=1}}for(m=u*3;m<R.length;m++)R[m]=0;for(m=ma*3;m<N.length;m++)N[m]=0;$.point.length=ma;$.directional.length=u;$.ambient[0]=F;$.ambient[1]=H;$.ambient[2]=Q;n=ba.lights;r.enableLighting.value=n.directional.length+n.point.length;r.ambientLightColor.value=n.ambient;r.directionalLightColor.value=n.directional.colors;r.directionalLightDirection.value=n.directional.positions;
+r.pointLightColor.value=n.point.colors;r.pointLightPosition.value=n.point.positions}if(h instanceof THREE.MeshBasicMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshPhongMaterial){r.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);r.opacity.value=h.opacity;r.map.texture=h.map;r.lightMap.texture=h.lightMap;r.envMap.texture=h.envMap;r.reflectivity.value=h.reflectivity;r.refractionRatio.value=h.refractionRatio;r.combine.value=h.combine;r.useRefract.value=
+h.envMap&&h.envMap.mapping instanceof THREE.CubeRefractionMapping}if(h instanceof THREE.LineBasicMaterial){r.diffuse.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);r.opacity.value=h.opacity}else if(h instanceof THREE.ParticleBasicMaterial){r.psColor.value.setRGB(h.color.r*h.opacity,h.color.g*h.opacity,h.color.b*h.opacity);r.opacity.value=h.opacity;r.size.value=h.size;r.map.texture=h.map}else if(h instanceof THREE.MeshPhongMaterial){r.ambient.value.setRGB(h.ambient.r,h.ambient.g,
+h.ambient.b);r.specular.value.setRGB(h.specular.r,h.specular.g,h.specular.b);r.shininess.value=h.shininess}else if(h instanceof THREE.MeshDepthMaterial){r.mNear.value=f.near;r.mFar.value=f.far;r.opacity.value=h.opacity}else if(h instanceof THREE.MeshNormalMaterial)r.opacity.value=h.opacity;for(var ka in r)if(F=t.uniforms[ka]){m=r[ka];p=m.type;n=m.value;if(p=="i")c.uniform1i(F,n);else if(p=="f")c.uniform1f(F,n);else if(p=="fv1")c.uniform1fv(F,n);else if(p=="fv")c.uniform3fv(F,n);else if(p=="v2")c.uniform2f(F,
+n.x,n.y);else if(p=="v3")c.uniform3f(F,n.x,n.y,n.z);else if(p=="c")c.uniform3f(F,n.r,n.g,n.b);else if(p=="t"){c.uniform1i(F,n);if(m=m.texture)if(m.image instanceof Array&&m.image.length==6){if(m.image.length==6){if(m.needsUpdate){if(!m.image.__webGLTextureCube)m.image.__webGLTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);
+c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.LINEAR_MIPMAP_LINEAR);for(p=0;p<6;++p)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+p,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,m.image[p]);c.generateMipmap(c.TEXTURE_CUBE_MAP);c.bindTexture(c.TEXTURE_CUBE_MAP,null);m.needsUpdate=!1}c.activeTexture(c.TEXTURE0+n);c.bindTexture(c.TEXTURE_CUBE_MAP,m.image.__webGLTextureCube)}}else{if(m.needsUpdate){if(m.__wasSetOnce){c.bindTexture(c.TEXTURE_2D,
+m.__webGLTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,m.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,M(m.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,M(m.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,M(m.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,M(m.minFilter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}else{m.__webGLTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,m.__webGLTexture);c.texImage2D(c.TEXTURE_2D,
+0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,m.image);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,M(m.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,M(m.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,M(m.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,M(m.minFilter));c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null);m.__wasSetOnce=!0}m.needsUpdate=!1}c.activeTexture(c.TEXTURE0+n);c.bindTexture(c.TEXTURE_2D,m.__webGLTexture)}}}c.uniformMatrix4fv(q.modelViewMatrix,
+!1,j._modelViewMatrixArray);c.uniformMatrix3fv(q.normalMatrix,!1,j._normalMatrixArray);(h instanceof THREE.MeshShaderMaterial||h instanceof THREE.MeshPhongMaterial||h.envMap)&&c.uniform3f(q.cameraPosition,f.position.x,f.position.y,f.position.z);(h instanceof THREE.MeshShaderMaterial||h.envMap||h.skinning)&&c.uniformMatrix4fv(q.objectMatrix,!1,j._objectMatrixArray);(h instanceof THREE.MeshPhongMaterial||h instanceof THREE.MeshLambertMaterial||h instanceof THREE.MeshShaderMaterial||h.skinning)&&c.uniformMatrix4fv(q.viewMatrix,
+!1,Fa);if(h.skinning){c.uniformMatrix4fv(q.cameraInverseMatrix,!1,Fa);c.uniformMatrix4fv(q.boneGlobalMatrices,!1,j.boneMatrices)}return t}function g(f,n,m,h,j,t){f=e(f,n,m,h,t).attributes;c.bindBuffer(c.ARRAY_BUFFER,j.__webGLVertexBuffer);c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0);if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLNormalBuffer);c.vertexAttribPointer(f.normal,
+3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLTangentBuffer);c.vertexAttribPointer(f.tangent,4,c.FLOAT,!1,0,0)}if(f.uv>=0)if(j.__webGLUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLUVBuffer);c.vertexAttribPointer(f.uv,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv)}else c.disableVertexAttribArray(f.uv);if(f.uv2>=0)if(j.__webGLUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2);
+if(h.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,j.__webGLSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,j.__webGLSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,j.__webGLSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,j.__webGLSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight,
+4,c.FLOAT,!1,0,0)}if(t instanceof THREE.Mesh)if(h.wireframe){c.lineWidth(h.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,j.__webGLLineBuffer);c.drawElements(c.LINES,j.__webGLLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,j.__webGLFaceBuffer);c.drawElements(c.TRIANGLES,j.__webGLFaceCount,c.UNSIGNED_SHORT,0)}else if(t instanceof THREE.Line){t=t.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(h.linewidth);c.drawArrays(t,0,j.__webGLLineCount)}else if(t instanceof
+THREE.ParticleSystem)c.drawArrays(c.POINTS,0,j.__webGLParticleCount);else t instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,j.__webGLVertexCount)}function k(f,n){if(!f.__webGLVertexBuffer)f.__webGLVertexBuffer=c.createBuffer();if(!f.__webGLNormalBuffer)f.__webGLNormalBuffer=c.createBuffer();if(f.hasPos){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,f.positionArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(n.attributes.position);c.vertexAttribPointer(n.attributes.position,
+3,c.FLOAT,!1,0,0)}if(f.hasNormal){c.bindBuffer(c.ARRAY_BUFFER,f.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,f.normalArray,c.DYNAMIC_DRAW);c.enableVertexAttribArray(n.attributes.normal);c.vertexAttribPointer(n.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,f.count);f.count=0}function i(f){if(ca!=f.doubleSided){f.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);ca=f.doubleSided}if(ia!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);ia=f.flipSided}}function o(f){if(oa!=
+f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);oa=f}}function l(f){ja[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);ja[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);ja[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);ja[3].set(f.n41-f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);ja[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);ja[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var n;for(f=0;f<6;f++){n=ja[f];n.divideScalar(Math.sqrt(n.x*n.x+n.y*n.y+n.z*
+n.z))}}function v(f){for(var n=f.matrixWorld,m=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),h=0;h<6;h++){f=ja[h].x*n.n14+ja[h].y*n.n24+ja[h].z*n.n34+ja[h].w;if(f<=m)return!1}return!0}function x(f,n){f.list[f.count]=n;f.count+=1}function w(f){var n,m,h=f.object,j=f.opaque,t=f.transparent;t.count=0;f=j.count=0;for(n=h.materials.length;f<n;f++){m=h.materials[f];m.opacity&&m.opacity<1||m.blending!=THREE.NormalBlending?x(t,m):x(j,m)}}function z(f){var n,m,h,j,t=f.object,
+q=f.buffer,r=f.opaque,p=f.transparent;p.count=0;f=r.count=0;for(h=t.materials.length;f<h;f++){n=t.materials[f];if(n instanceof THREE.MeshFaceMaterial){n=0;for(m=q.materials.length;n<m;n++)(j=q.materials[n])&&(j.opacity&&j.opacity<1||j.blending!=THREE.NormalBlending?x(p,j):x(r,j))}else{j=n;j.opacity&&j.opacity<1||j.blending!=THREE.NormalBlending?x(p,j):x(r,j)}}}function A(f,n){return n.z-f.z}function I(f){function n(H){var Q=[];m=0;for(h=H.length;m<h;m++)H[m]==undefined?Q.push("undefined"):Q.push(H[m].id);
+return Q.join("_")}var m,h,j,t,q,r,p,E,F={};f.geometryGroups={};j=0;for(t=f.faces.length;j<t;j++){q=f.faces[j];r=q.materials;p=n(r);F[p]==undefined&&(F[p]={hash:p,counter:0});E=F[p].hash+"_"+F[p].counter;f.geometryGroups[E]==undefined&&(f.geometryGroups[E]={faces:[],materials:r,vertices:0});q=q instanceof THREE.Face3?3:4;if(f.geometryGroups[E].vertices+q>65535){F[p].counter+=1;E=F[p].hash+"_"+F[p].counter;f.geometryGroups[E]==undefined&&(f.geometryGroups[E]={faces:[],materials:r,vertices:0})}f.geometryGroups[E].faces.push(j);
+f.geometryGroups[E].vertices+=q}}function G(f,n,m,h,j){if(n[m]==undefined){f.push({buffer:h,object:j,opaque:{list:[],count:0},transparent:{list:[],count:0}});n[m]=1}}function L(f,n){f._modelViewMatrix.multiplyToArray(n.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function J(f){if(f!=na){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE);break;case THREE.SubtractiveBlending:c.blendFunc(c.DST_COLOR,
+c.ZERO);break;case THREE.BillboardBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);break;case THREE.ReverseSubtractiveBlending:c.blendEquation(c.FUNC_REVERSE_SUBTRACT);c.blendFunc(c.ONE,c.ONE);break;default:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA)}na=f}}function T(f,n){if(f&&!f.__webGLFramebuffer){f.__webGLFramebuffer=c.createFramebuffer();f.__webGLRenderbuffer=c.createRenderbuffer();f.__webGLTexture=c.createTexture();c.bindRenderbuffer(c.RENDERBUFFER,
+f.__webGLRenderbuffer);c.renderbufferStorage(c.RENDERBUFFER,c.DEPTH_COMPONENT16,f.width,f.height);c.bindTexture(c.TEXTURE_2D,f.__webGLTexture);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,M(f.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,M(f.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,M(f.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,M(f.minFilter));c.texImage2D(c.TEXTURE_2D,0,M(f.format),f.width,f.height,0,M(f.format),M(f.type),null);c.bindFramebuffer(c.FRAMEBUFFER,
+f.__webGLFramebuffer);c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,f.__webGLTexture,0);c.framebufferRenderbuffer(c.FRAMEBUFFER,c.DEPTH_ATTACHMENT,c.RENDERBUFFER,f.__webGLRenderbuffer);c.bindTexture(c.TEXTURE_2D,null);c.bindRenderbuffer(c.RENDERBUFFER,null);c.bindFramebuffer(c.FRAMEBUFFER,null)}var m,h,j;if(f){m=f.__webGLFramebuffer;h=f.width;j=f.height}else{m=null;h=O.width;j=O.height}if(m!=fa){c.bindFramebuffer(c.FRAMEBUFFER,m);c.viewport(0,0,h,j);n&&c.clear(c.COLOR_BUFFER_BIT|
+c.DEPTH_BUFFER_BIT);fa=m}}function S(f,n){var m;if(f=="fragment")m=c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(m=c.createShader(c.VERTEX_SHADER));c.shaderSource(m,n);c.compileShader(m);if(!c.getShaderParameter(m,c.COMPILE_STATUS)){alert(c.getShaderInfoLog(m));return null}return m}function M(f){switch(f){case THREE.RepeatWrapping:return c.REPEAT;case THREE.ClampToEdgeWrapping:return c.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return c.MIRRORED_REPEAT;case THREE.NearestFilter:return c.NEAREST;
+case THREE.NearestMipMapNearestFilter:return c.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return c.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return c.LINEAR;case THREE.LinearMipMapNearestFilter:return c.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return c.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return c.BYTE;case THREE.UnsignedByteType:return c.UNSIGNED_BYTE;case THREE.ShortType:return c.SHORT;case THREE.UnsignedShortType:return c.UNSIGNED_SHORT;case THREE.IntType:return c.INT;
+case THREE.UnsignedShortType:return c.UNSIGNED_INT;case THREE.FloatType:return c.FLOAT;case THREE.AlphaFormat:return c.ALPHA;case THREE.RGBFormat:return c.RGB;case THREE.RGBAFormat:return c.RGBA;case THREE.LuminanceFormat:return c.LUMINANCE;case THREE.LuminanceAlphaFormat:return c.LUMINANCE_ALPHA}return 0}var O=document.createElement("canvas"),c,aa=null,fa=null,ba=this,ca=null,ia=null,na=null,oa=null,ja=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],
+ra=new THREE.Matrix4,wa=new Float32Array(16),Fa=new Float32Array(16),Aa=new THREE.Vector4,Ia=!0,Oa=new THREE.Color(0),Pa=0;if(a){if(a.antialias!==undefined)Ia=a.antialias;a.clearColor!==undefined&&Oa.setHex(a.clearColor);if(a.clearAlpha!==undefined)Pa=a.clearAlpha}this.domElement=O;this.autoClear=!0;this.sortObjects=!1;(function(f,n,m){try{c=O.getContext("experimental-webgl",{antialias:f})}catch(h){console.log(h)}if(!c)throw"cannot create webgl context";c.clearColor(0,0,0,1);c.clearDepth(1);c.enable(c.DEPTH_TEST);
+c.depthFunc(c.LEQUAL);c.frontFace(c.CCW);c.cullFace(c.BACK);c.enable(c.CULL_FACE);c.enable(c.BLEND);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.clearColor(n.r,n.g,n.b,m);_cullEnabled=!0})(Ia,Oa,Pa);this.context=c;this.lights={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[]}};this.setSize=function(f,n){O.width=f;O.height=n;c.viewport(0,0,O.width,O.height)};this.setClearColorHex=function(f,n){var m=new THREE.Color(f);c.clearColor(m.r,m.g,m.b,n)};this.setClearColor=
+function(f,n){c.clearColor(f.r,f.g,f.b,n)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT)};this.initMaterial=function(f,n,m){var h,j;if(f instanceof THREE.MeshDepthMaterial)d(f,THREE.ShaderLib.depth);else if(f instanceof THREE.MeshNormalMaterial)d(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)d(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)d(f,THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)d(f,THREE.ShaderLib.phong);
+else if(f instanceof THREE.LineBasicMaterial)d(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&d(f,THREE.ShaderLib.particle_basic);var t,q,r,p;j=r=p=0;for(t=n.length;j<t;j++){q=n[j];q instanceof THREE.DirectionalLight&&r++;q instanceof THREE.PointLight&&p++}if(p+r<=4)n=r;else{n=Math.ceil(4*r/(p+r));p=4-n}j={directional:n,point:p};p=f.fragmentShader;n=f.vertexShader;t={fog:m,map:f.map,envMap:f.envMap,lightMap:f.lightMap,vertexColors:f.vertexColors,skinning:f.skinning,maxDirLights:j.directional,
+maxPointLights:j.point};m=c.createProgram();j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.fog?"#define USE_FOG":"",t.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.lightMap?"#define USE_LIGHTMAP":"",t.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");t=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
+0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+t.maxDirLights,"#define MAX_POINT_LIGHTS "+t.maxPointLights,t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.lightMap?"#define USE_LIGHTMAP":"",t.vertexColors?"#define USE_COLOR":"",t.skinning?"#define USE_SKINNING":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\nattribute vec2 uv;\nattribute vec2 uv2;\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n"].join("\n");
+c.attachShader(m,S("fragment",j+p));c.attachShader(m,S("vertex",t+n));c.linkProgram(m);c.getProgramParameter(m,c.LINK_STATUS)||alert("Could not initialise shaders\nVALIDATE_STATUS: "+c.getProgramParameter(m,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");m.uniforms={};m.attributes={};f.program=m;m=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices"];for(h in f.uniforms)m.push(h);h=f.program;p=0;for(n=m.length;p<
+n;p++){j=m[p];h.uniforms[j]=c.getUniformLocation(h,j)}h=f.program;m=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];p=0;for(n=m.length;p<n;p++){j=m[p];h.attributes[j]=c.getAttribLocation(h,j)}h=f.program.attributes;c.enableVertexAttribArray(h.position);h.color>=0&&c.enableVertexAttribArray(h.color);h.normal>=0&&c.enableVertexAttribArray(h.normal);h.tangent>=0&&c.enableVertexAttribArray(h.tangent);if(f.skinning&&h.skinVertexA>=0&&h.skinVertexB>=
+0&&h.skinIndex>=0&&h.skinWeight>=0){c.enableVertexAttribArray(h.skinVertexA);c.enableVertexAttribArray(h.skinVertexB);c.enableVertexAttribArray(h.skinIndex);c.enableVertexAttribArray(h.skinWeight)}};this.render=function(f,n,m,h){var j,t,q,r,p,E,F,H,Q=f.lights,y=f.fog;n.matrixAutoUpdate&&n.update();n.matrixWorldInverse.flattenToArray(Fa);n.projectionMatrix.flattenToArray(wa);ra.multiply(n.projectionMatrix,n.matrixWorldInverse);l(ra);THREE.AnimationHandler&&THREE.AnimationHandler.update();f.update(undefined,
+!1,n);this.initWebGLObjects(f,n);T(m,h!==undefined?h:!0);this.autoClear&&this.clear();p=f.__webGLObjects.length;for(h=0;h<p;h++){j=f.__webGLObjects[h];F=j.object;if(F.visible)if(!(F instanceof THREE.Mesh)||v(F)){F.matrixWorld.flattenToArray(F._objectMatrixArray);L(F,n);z(j);j.render=!0;if(this.sortObjects){Aa.copy(F.position);ra.multiplyVector3(Aa);j.z=Aa.z}}else j.render=!1;else j.render=!1}this.sortObjects&&f.__webGLObjects.sort(A);E=f.__webGLObjectsImmediate.length;for(h=0;h<E;h++){j=f.__webGLObjectsImmediate[h];
+F=j.object;if(F.visible){F.matrixAutoUpdate&&F.matrixWorld.flattenToArray(F._objectMatrixArray);L(F,n);w(j)}}J(THREE.NormalBlending);for(h=0;h<p;h++){j=f.__webGLObjects[h];if(j.render){F=j.object;H=j.buffer;q=j.opaque;i(F);for(j=0;j<q.count;j++){r=q.list[j];o(r.depthTest);g(n,Q,y,r,H,F)}}}for(h=0;h<E;h++){j=f.__webGLObjectsImmediate[h];F=j.object;if(F.visible){q=j.opaque;i(F);for(j=0;j<q.count;j++){r=q.list[j];o(r.depthTest);t=e(n,Q,y,r,F);F.render(function(K){k(K,t)})}}}for(h=0;h<p;h++){j=f.__webGLObjects[h];
+if(j.render){F=j.object;H=j.buffer;q=j.transparent;i(F);for(j=0;j<q.count;j++){r=q.list[j];J(r.blending);o(r.depthTest);g(n,Q,y,r,H,F)}}}for(h=0;h<E;h++){j=f.__webGLObjectsImmediate[h];F=j.object;if(F.visible){q=j.transparent;i(F);for(j=0;j<q.count;j++){r=q.list[j];J(r.blending);o(r.depthTest);t=e(n,Q,y,r,F);F.render(function(K){k(K,t)})}}}if(m&&m.minFilter!==THREE.NearestFilter&&m.minFilter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,m.__webGLTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,
+null)}};this.initWebGLObjects=function(f,n){if(!f.__webGLObjects){f.__webGLObjects=[];f.__webGLObjectsMap={};f.__webGLObjectsImmediate=[]}for(var m=0,h=f.objects.length;m<h;m++){var j=f.objects[m],t=f,q=n,r=void 0,p=void 0,E=void 0,F=void 0;if(t.__webGLObjectsMap[j.id]==undefined){t.__webGLObjectsMap[j.id]={};j._modelViewMatrix=new THREE.Matrix4;j._normalMatrixArray=new Float32Array(9);j._modelViewMatrixArray=new Float32Array(16);j._objectMatrixArray=new Float32Array(16);j.matrixWorld.flattenToArray(j._objectMatrixArray)}F=
+t.__webGLObjectsMap[j.id];objlist=t.__webGLObjects;if(j instanceof THREE.Mesh){p=j.geometry;p.geometryGroups==undefined&&I(p);for(r in p.geometryGroups){E=p.geometryGroups[r];if(!E.__webGLVertexBuffer){q=E;q.__webGLVertexBuffer=c.createBuffer();q.__webGLNormalBuffer=c.createBuffer();q.__webGLTangentBuffer=c.createBuffer();q.__webGLColorBuffer=c.createBuffer();q.__webGLUVBuffer=c.createBuffer();q.__webGLUV2Buffer=c.createBuffer();q.__webGLSkinVertexABuffer=c.createBuffer();q.__webGLSkinVertexBBuffer=
+c.createBuffer();q.__webGLSkinIndicesBuffer=c.createBuffer();q.__webGLSkinWeightsBuffer=c.createBuffer();q.__webGLFaceBuffer=c.createBuffer();q.__webGLLineBuffer=c.createBuffer();q=E;var H=j,Q=void 0,y=void 0,K=0,da=t=0,$=H.geometry.faces,R=q.faces;Q=0;for(y=R.length;Q<y;Q++){fi=R[Q];face=$[fi];if(face instanceof THREE.Face3){K+=3;t+=1;da+=3}else if(face instanceof THREE.Face4){K+=4;t+=2;da+=4}}q.__vertexArray=new Float32Array(K*3);q.__normalArray=new Float32Array(K*3);q.__tangentArray=new Float32Array(K*
+4);q.__colorArray=new Float32Array(K*3);q.__uvArray=new Float32Array(K*2);q.__uv2Array=new Float32Array(K*2);q.__skinVertexAArray=new Float32Array(K*4);q.__skinVertexBArray=new Float32Array(K*4);q.__skinIndexArray=new Float32Array(K*4);q.__skinWeightArray=new Float32Array(K*4);q.__faceArray=new Uint16Array(t*3);q.__lineArray=new Uint16Array(da*2);y=Q=q;K=void 0;$=void 0;var P=void 0,N=void 0;P=void 0;R=!1;K=0;for($=H.materials.length;K<$;K++){P=H.materials[K];if(P instanceof THREE.MeshFaceMaterial){P=
+0;for(N=y.materials.length;P<N;P++)if(y.materials[P]&&y.materials[P].shading!=undefined&&y.materials[P].shading==THREE.SmoothShading){R=!0;break}}else if(P&&P.shading!=undefined&&P.shading==THREE.SmoothShading){R=!0;break}if(R)break}Q.__needsSmoothNormals=R;q.__webGLFaceCount=t*3;q.__webGLLineCount=da*2;p.__dirtyVertices=!0;p.__dirtyElements=!0;p.__dirtyUvs=!0;p.__dirtyNormals=!0;p.__dirtyTangents=!0;p.__dirtyColors=!0}if(p.__dirtyVertices||p.__dirtyElements||p.__dirtyUvs||p.__dirtyNormals||p.__dirtyColors||
+p.__dirtyTangents){q=E;t=c.DYNAMIC_DRAW;da=void 0;Q=void 0;var sa=void 0,u=void 0,ma=void 0,ka=void 0,va=void 0;sa=void 0;var B=void 0,C=void 0,D=void 0,U=void 0;B=void 0;C=void 0;D=void 0;u=void 0;B=void 0;C=void 0;D=void 0;U=void 0;B=void 0;C=void 0;D=void 0;U=void 0;B=void 0;C=void 0;D=void 0;U=void 0;B=void 0;C=void 0;D=void 0;U=void 0;B=void 0;C=void 0;D=void 0;U=void 0;u=void 0;ka=void 0;ma=void 0;va=void 0;var pa=N=P=R=$=K=H=y=0,ea=0,s=0,ga=q.__vertexArray,Ga=q.__uvArray,Ha=q.__uv2Array,ua=
+q.__normalArray,V=q.__tangentArray,ha=q.__colorArray,W=q.__skinVertexAArray,X=q.__skinVertexBArray,Y=q.__skinIndexArray,Z=q.__skinWeightArray,xa=q.__faceArray,qa=q.__lineArray,Qa=q.__needsSmoothNormals,la=j.geometry,Ja=la.__dirtyVertices,Ka=la.__dirtyElements,Ea=la.__dirtyUvs,La=la.__dirtyNormals,Ma=la.__dirtyTangents,Na=la.__dirtyColors,ta=la.vertices,Ra=q.faces,Sa=la.faces,Ta=la.uvs,Ua=la.uvs2,ya=la.colors,Ba=la.skinVerticesA,Ca=la.skinVerticesB,Da=la.skinIndices,za=la.skinWeights;da=0;for(Q=Ra.length;da<
+Q;da++){sa=Ra[da];u=Sa[sa];va=Ta[sa];sa=Ua[sa];ma=u.vertexNormals;ka=u.normal;if(u instanceof THREE.Face3){if(Ja){B=ta[u.a].position;C=ta[u.b].position;D=ta[u.c].position;ga[H]=B.x;ga[H+1]=B.y;ga[H+2]=B.z;ga[H+3]=C.x;ga[H+4]=C.y;ga[H+5]=C.z;ga[H+6]=D.x;ga[H+7]=D.y;ga[H+8]=D.z;H+=9}if(za.length){B=za[u.a];C=za[u.b];D=za[u.c];Z[s]=B.x;Z[s+1]=B.y;Z[s+2]=B.z;Z[s+3]=B.w;Z[s+4]=C.x;Z[s+5]=C.y;Z[s+6]=C.z;Z[s+7]=C.w;Z[s+8]=D.x;Z[s+9]=D.y;Z[s+10]=D.z;Z[s+11]=D.w;B=Da[u.a];C=Da[u.b];D=Da[u.c];Y[s]=B.x;Y[s+
+1]=B.y;Y[s+2]=B.z;Y[s+3]=B.w;Y[s+4]=C.x;Y[s+5]=C.y;Y[s+6]=C.z;Y[s+7]=C.w;Y[s+8]=D.x;Y[s+9]=D.y;Y[s+10]=D.z;Y[s+11]=D.w;B=Ba[u.a];C=Ba[u.b];D=Ba[u.c];W[s]=B.x;W[s+1]=B.y;W[s+2]=B.z;W[s+3]=1;W[s+4]=C.x;W[s+5]=C.y;W[s+6]=C.z;W[s+7]=1;W[s+8]=D.x;W[s+9]=D.y;W[s+10]=D.z;W[s+11]=1;B=Ca[u.a];C=Ca[u.b];D=Ca[u.c];X[s]=B.x;X[s+1]=B.y;X[s+2]=B.z;X[s+3]=1;X[s+4]=C.x;X[s+5]=C.y;X[s+6]=C.z;X[s+7]=1;X[s+8]=D.x;X[s+9]=D.y;X[s+10]=D.z;X[s+11]=1;s+=12}if(Na&&ya.length){B=ya[u.a];C=ya[u.b];D=ya[u.c];ha[ea]=B.r;ha[ea+
+1]=B.g;ha[ea+2]=B.b;ha[ea+3]=C.r;ha[ea+4]=C.g;ha[ea+5]=C.b;ha[ea+6]=D.r;ha[ea+7]=D.g;ha[ea+8]=D.b;ea+=9}if(Ma&&la.hasTangents){B=ta[u.a].tangent;C=ta[u.b].tangent;D=ta[u.c].tangent;V[N]=B.x;V[N+1]=B.y;V[N+2]=B.z;V[N+3]=B.w;V[N+4]=C.x;V[N+5]=C.y;V[N+6]=C.z;V[N+7]=C.w;V[N+8]=D.x;V[N+9]=D.y;V[N+10]=D.z;V[N+11]=D.w;N+=12}if(La)if(ma.length==3&&Qa)for(u=0;u<3;u++){ka=ma[u];ua[P]=ka.x;ua[P+1]=ka.y;ua[P+2]=ka.z;P+=3}else for(u=0;u<3;u++){ua[P]=ka.x;ua[P+1]=ka.y;ua[P+2]=ka.z;P+=3}if(Ea&&va)for(u=0;u<3;u++){ma=
+va[u];Ga[K]=ma.u;Ga[K+1]=ma.v;K+=2}if(Ea&&sa)for(u=0;u<3;u++){va=sa[u];Ha[$]=va.u;Ha[$+1]=va.v;$+=2}if(Ka){xa[R]=y;xa[R+1]=y+1;xa[R+2]=y+2;R+=3;qa[pa]=y;qa[pa+1]=y+1;qa[pa+2]=y;qa[pa+3]=y+2;qa[pa+4]=y+1;qa[pa+5]=y+2;pa+=6;y+=3}}else if(u instanceof THREE.Face4){if(Ja){B=ta[u.a].position;C=ta[u.b].position;D=ta[u.c].position;U=ta[u.d].position;ga[H]=B.x;ga[H+1]=B.y;ga[H+2]=B.z;ga[H+3]=C.x;ga[H+4]=C.y;ga[H+5]=C.z;ga[H+6]=D.x;ga[H+7]=D.y;ga[H+8]=D.z;ga[H+9]=U.x;ga[H+10]=U.y;ga[H+11]=U.z;H+=12}if(za.length){B=
+za[u.a];C=za[u.b];D=za[u.c];U=za[u.d];Z[s]=B.x;Z[s+1]=B.y;Z[s+2]=B.z;Z[s+3]=B.w;Z[s+4]=C.x;Z[s+5]=C.y;Z[s+6]=C.z;Z[s+7]=C.w;Z[s+8]=D.x;Z[s+9]=D.y;Z[s+10]=D.z;Z[s+11]=D.w;Z[s+12]=U.x;Z[s+13]=U.y;Z[s+14]=U.z;Z[s+15]=U.w;B=Da[u.a];C=Da[u.b];D=Da[u.c];U=Da[u.d];Y[s]=B.x;Y[s+1]=B.y;Y[s+2]=B.z;Y[s+3]=B.w;Y[s+4]=C.x;Y[s+5]=C.y;Y[s+6]=C.z;Y[s+7]=C.w;Y[s+8]=D.x;Y[s+9]=D.y;Y[s+10]=D.z;Y[s+11]=D.w;Y[s+12]=U.x;Y[s+13]=U.y;Y[s+14]=U.z;Y[s+15]=U.w;B=Ba[u.a];C=Ba[u.b];D=Ba[u.c];U=Ba[u.d];W[s]=B.x;W[s+1]=B.y;W[s+
+2]=B.z;W[s+3]=1;W[s+4]=C.x;W[s+5]=C.y;W[s+6]=C.z;W[s+7]=1;W[s+8]=D.x;W[s+9]=D.y;W[s+10]=D.z;W[s+11]=1;W[s+12]=U.x;W[s+13]=U.y;W[s+14]=U.z;W[s+15]=1;B=Ca[u.a];C=Ca[u.b];D=Ca[u.c];U=Ca[u.d];X[s]=B.x;X[s+1]=B.y;X[s+2]=B.z;X[s+3]=1;X[s+4]=C.x;X[s+5]=C.y;X[s+6]=C.z;X[s+7]=1;X[s+8]=D.x;X[s+9]=D.y;X[s+10]=D.z;X[s+11]=1;X[s+12]=U.x;X[s+13]=U.y;X[s+14]=U.z;X[s+15]=1;s+=16}if(Na&&ya.length){B=ya[u.a];C=ya[u.b];D=ya[u.c];U=ya[u.d];ha[ea]=B.r;ha[ea+1]=B.g;ha[ea+2]=B.b;ha[ea+3]=C.r;ha[ea+4]=C.g;ha[ea+5]=C.b;ha[ea+
+6]=D.r;ha[ea+7]=D.g;ha[ea+8]=D.b;ha[ea+9]=U.r;ha[ea+10]=U.g;ha[ea+11]=U.b;ea+=12}if(Ma&&la.hasTangents){B=ta[u.a].tangent;C=ta[u.b].tangent;D=ta[u.c].tangent;u=ta[u.d].tangent;V[N]=B.x;V[N+1]=B.y;V[N+2]=B.z;V[N+3]=B.w;V[N+4]=C.x;V[N+5]=C.y;V[N+6]=C.z;V[N+7]=C.w;V[N+8]=D.x;V[N+9]=D.y;V[N+10]=D.z;V[N+11]=D.w;V[N+12]=u.x;V[N+13]=u.y;V[N+14]=u.z;V[N+15]=u.w;N+=16}if(La)if(ma.length==4&&Qa)for(u=0;u<4;u++){ka=ma[u];ua[P]=ka.x;ua[P+1]=ka.y;ua[P+2]=ka.z;P+=3}else for(u=0;u<4;u++){ua[P]=ka.x;ua[P+1]=ka.y;
+ua[P+2]=ka.z;P+=3}if(Ea&&va)for(u=0;u<4;u++){ma=va[u];Ga[K]=ma.u;Ga[K+1]=ma.v;K+=2}if(Ea&&sa)for(u=0;u<4;u++){va=sa[u];Ha[$]=va.u;Ha[$+1]=va.v;$+=2}if(Ka){xa[R]=y;xa[R+1]=y+1;xa[R+2]=y+2;xa[R+3]=y;xa[R+4]=y+2;xa[R+5]=y+3;R+=6;qa[pa]=y;qa[pa+1]=y+1;qa[pa+2]=y;qa[pa+3]=y+3;qa[pa+4]=y+1;qa[pa+5]=y+2;qa[pa+6]=y+2;qa[pa+7]=y+3;pa+=8;y+=4}}}if(Ja){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,ga,t)}if(Na&&ya.length){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,
+ha,t)}if(La){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLNormalBuffer);c.bufferData(c.ARRAY_BUFFER,ua,t)}if(Ma&&la.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLTangentBuffer);c.bufferData(c.ARRAY_BUFFER,V,t)}if(Ea&&K>0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUVBuffer);c.bufferData(c.ARRAY_BUFFER,Ga,t)}if(Ea&&$>0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLUV2Buffer);c.bufferData(c.ARRAY_BUFFER,Ha,t)}if(Ka){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,q.__webGLFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,xa,t);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
+q.__webGLLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,qa,t)}if(s>0){c.bindBuffer(c.ARRAY_BUFFER,q.__webGLSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,W,t);c.bindBuffer(c.ARRAY_BUFFER,q.__webGLSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,X,t);c.bindBuffer(c.ARRAY_BUFFER,q.__webGLSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,Y,t);c.bindBuffer(c.ARRAY_BUFFER,q.__webGLSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,Z,t)}}G(objlist,F,r,E,j)}p.__dirtyVertices=!1;p.__dirtyElements=!1;p.__dirtyUvs=
+!1;p.__dirtyNormals=!1;p.__dirtyTangents=!1;p.__dirtyColors=!1}else if(j instanceof THREE.Ribbon){p=j.geometry;if(!p.__webGLVertexBuffer){r=p;r.__webGLVertexBuffer=c.createBuffer();r.__webGLColorBuffer=c.createBuffer();r=p;E=r.vertices.length;r.__vertexArray=new Float32Array(E*3);r.__colorArray=new Float32Array(E*3);r.__webGLVertexCount=E;p.__dirtyVertices=!0;p.__dirtyColors=!0}if(p.__dirtyVertices||p.__dirtyColors){r=p;E=c.DYNAMIC_DRAW;y=void 0;y=void 0;H=void 0;q=void 0;K=r.vertices;t=r.colors;
+$=K.length;da=t.length;R=r.__vertexArray;Q=r.__colorArray;P=r.__dirtyColors;if(r.__dirtyVertices){for(y=0;y<$;y++){H=K[y].position;q=y*3;R[q]=H.x;R[q+1]=H.y;R[q+2]=H.z}c.bindBuffer(c.ARRAY_BUFFER,r.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,R,E)}if(P){for(y=0;y<da;y++){color=t[y];q=y*3;Q[q]=color.r;Q[q+1]=color.g;Q[q+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,r.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,Q,E)}}G(objlist,F,0,p,j);p.__dirtyVertices=!1;p.__dirtyColors=!1}else if(j instanceof THREE.Line){p=
+j.geometry;if(!p.__webGLVertexBuffer){r=p;r.__webGLVertexBuffer=c.createBuffer();r.__webGLColorBuffer=c.createBuffer();r=p;E=r.vertices.length;r.__vertexArray=new Float32Array(E*3);r.__colorArray=new Float32Array(E*3);r.__webGLLineCount=E;p.__dirtyVertices=!0;p.__dirtyColors=!0}if(p.__dirtyVertices||p.__dirtyColors){r=p;E=c.DYNAMIC_DRAW;y=void 0;y=void 0;H=void 0;q=void 0;K=r.vertices;t=r.colors;$=K.length;da=t.length;R=r.__vertexArray;Q=r.__colorArray;P=r.__dirtyColors;if(r.__dirtyVertices){for(y=
+0;y<$;y++){H=K[y].position;q=y*3;R[q]=H.x;R[q+1]=H.y;R[q+2]=H.z}c.bindBuffer(c.ARRAY_BUFFER,r.__webGLVertexBuffer);c.bufferData(c.ARRAY_BUFFER,R,E)}if(P){for(y=0;y<da;y++){color=t[y];q=y*3;Q[q]=color.r;Q[q+1]=color.g;Q[q+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,r.__webGLColorBuffer);c.bufferData(c.ARRAY_BUFFER,Q,E)}}G(objlist,F,0,p,j);p.__dirtyVertices=!1;p.__dirtyColors=!1}else if(j instanceof THREE.ParticleSystem){p=j.geometry;if(!p.__webGLVertexBuffer){r=p;r.__webGLVertexBuffer=c.createBuffer();
+r.__webGLColorBuffer=c.createBuffer();r=p;E=r.vertices.length;r.__vertexArray=new Float32Array(E*3);r.__colorArray=new Float32Array(E*3);r.__sortArray=[];r.__webGLParticleCount=E;p.__dirtyVertices=!0;p.__dirtyColors=!0}(p.__dirtyVertices||p.__dirtyColors||j.sortParticles)&&b(p,c.DYNAMIC_DRAW,j,q);G(objlist,F,0,p,j);p.__dirtyVertices=!1;p.__dirtyColors=!1}else if(THREE.MarchingCubes!==undefined&&j instanceof THREE.MarchingCubes){p=F;if(p[0]==undefined){t.__webGLObjectsImmediate.push({object:j,opaque:{list:[],
+count:0},transparent:{list:[],count:0}});p[0]=1}}}};this.removeObject=function(f,n){var m,h;for(m=f.__webGLObjects.length-1;m>=0;m--){h=f.__webGLObjects[m].object;n==h&&f.__webGLObjects.splice(m,1)}};this.setFaceCulling=function(f,n){if(f){!n||n=="ccw"?c.frontFace(c.CCW):c.frontFace(c.CW);if(f=="back")c.cullFace(c.BACK);else f=="front"?c.cullFace(c.FRONT):c.cullFace(c.FRONT_AND_BACK);c.enable(c.CULL_FACE)}else c.disable(c.CULL_FACE)};this.supportsVertexTextures=function(){return c.getParameter(c.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 envMap;\nuniform int combine;\n#endif",
+envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
+map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
+lightmap_pars_vertex:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\ngl_FragColor = gl_FragColor * texture2D( lightMap, vUv2 );\n#endif",lightmap_vertex:"#ifdef USE_LIGHTMAP\nvUv2 = uv2;\n#endif",lights_pars_vertex:"uniform bool enableLighting;\nuniform vec3 ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightColor[ MAX_DIR_LIGHTS ];\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nuniform vec3 pointLightColor[ MAX_POINT_LIGHTS ];\nuniform vec3 pointLightPosition[ MAX_POINT_LIGHTS ];\n#ifdef PHONG\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\n#endif",
 lights_vertex:"if ( !enableLighting ) {\nvLightWeighting = vec3( 1.0 );\n} else {\nvLightWeighting = ambientLightColor;\n#if MAX_DIR_LIGHTS > 0\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nfloat directionalLightWeighting = max( dot( transformedNormal, normalize( lDirection.xyz ) ), 0.0 );\nvLightWeighting += directionalLightColor[ i ] * directionalLightWeighting;\n}\n#endif\n#if MAX_POINT_LIGHTS > 0\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec4 lPosition = viewMatrix * vec4( pointLightPosition[ i ], 1.0 );\nvec3 pointLightVector = normalize( lPosition.xyz - mvPosition.xyz );\nfloat pointLightWeighting = max( dot( transformedNormal, pointLightVector ), 0.0 );\nvLightWeighting += pointLightColor[ i ] * pointLightWeighting;\n#ifdef PHONG\nvPointLightVector[ i ] = pointLightVector;\n#endif\n}\n#endif\n}",
 lights_pars_fragment:"#if MAX_DIR_LIGHTS > 0\nuniform vec3 directionalLightDirection[ MAX_DIR_LIGHTS ];\n#endif\n#if MAX_POINT_LIGHTS > 0\nvarying vec3 vPointLightVector[ MAX_POINT_LIGHTS ];\n#endif\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",lights_fragment:"vec3 normal = normalize( vNormal );\nvec3 viewPosition = normalize( vViewPosition );\nvec4 mColor = vec4( diffuse, opacity );\nvec4 mSpecular = vec4( specular, opacity );\n#if MAX_POINT_LIGHTS > 0\nvec4 pointDiffuse  = vec4( 0.0 );\nvec4 pointSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_POINT_LIGHTS; i++ ) {\nvec3 pointVector = normalize( vPointLightVector[ i ] );\nvec3 pointHalfVector = normalize( vPointLightVector[ i ] + vViewPosition );\nfloat pointDotNormalHalf = dot( normal, pointHalfVector );\nfloat pointDiffuseWeight = max( dot( normal, pointVector ), 0.0 );\nfloat pointSpecularWeight = 0.0;\nif ( pointDotNormalHalf >= 0.0 )\npointSpecularWeight = pow( pointDotNormalHalf, shininess );\npointDiffuse  += mColor * pointDiffuseWeight;\npointSpecular += mSpecular * pointSpecularWeight;\n}\n#endif\n#if MAX_DIR_LIGHTS > 0\nvec4 dirDiffuse  = vec4( 0.0 );\nvec4 dirSpecular = vec4( 0.0 );\nfor( int i = 0; i < MAX_DIR_LIGHTS; i++ ) {\nvec4 lDirection = viewMatrix * vec4( directionalLightDirection[ i ], 0.0 );\nvec3 dirVector = normalize( lDirection.xyz );\nvec3 dirHalfVector = normalize( lDirection.xyz + vViewPosition );\nfloat dirDotNormalHalf = dot( normal, dirHalfVector );\nfloat dirDiffuseWeight = max( dot( normal, dirVector ), 0.0 );\nfloat dirSpecularWeight = 0.0;\nif ( dirDotNormalHalf >= 0.0 )\ndirSpecularWeight = pow( dirDotNormalHalf, shininess );\ndirDiffuse  += mColor * dirDiffuseWeight;\ndirSpecular += mSpecular * dirSpecularWeight;\n}\n#endif\nvec4 totalLight = vec4( ambient, opacity );\n#if MAX_DIR_LIGHTS > 0\ntotalLight += dirDiffuse + dirSpecular;\n#endif\n#if MAX_POINT_LIGHTS > 0\ntotalLight += pointDiffuse + pointSpecular;\n#endif\ngl_FragColor = gl_FragColor * totalLight;",
 color_pars_fragment:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_fragment:"#ifdef USE_COLOR\ngl_FragColor = gl_FragColor * vec4( vColor, opacity );\n#endif",color_pars_vertex:"#ifdef USE_COLOR\nvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\nvColor = color;\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\nuniform mat4 boneGlobalMatrices[20];\n#endif",skinning_vertex:"#ifdef USE_SKINNING\ngl_Position  = ( boneGlobalMatrices[ int( skinIndex.x ) ] * skinVertexA ) * skinWeight.x;\ngl_Position += ( boneGlobalMatrices[ int( skinIndex.y ) ] * skinVertexB ) * skinWeight.y;\ngl_Position  = projectionMatrix * viewMatrix * objectMatrix * gl_Position;\n#else\ngl_Position = projectionMatrix * mvPosition;\n#endif"};

+ 0 - 1
examples/misc_uqbiquity_test.html → examples/misc_ubiquity_test.html

@@ -193,7 +193,6 @@
 
 				geometry.computeFaceNormals();
 				geometry.computeCentroids();
-				geometry.sortFacesByMaterial();
 
 				mesh = new THREE.Mesh( geometry, [ new THREE.MeshFaceMaterial(), new THREE.MeshBasicMaterial( { color: 0xff0000, opacity: 0.5, wireframe: true, wireframeLinewidth: 10 } ) ] );
 				mesh.doubleSided = true;

+ 0 - 1
examples/obj/Bird.js

@@ -22,7 +22,6 @@ var Bird = function () {
 
 	this.computeCentroids();
 	this.computeFaceNormals();
-	this.sortFacesByMaterial();
 
 	function v( x, y, z ) {
 

+ 0 - 1
examples/obj/Qrcode.js

@@ -1435,7 +1435,6 @@ var Qrcode = function () {
 
 	this.computeCentroids();
 	this.computeFaceNormals();
-	this.sortFacesByMaterial();
 
 	function v( x, y, z ) {
 

+ 0 - 1
examples/obj/WaltHead.js

@@ -4885,7 +4885,6 @@ var WaltHead = function () {
 
 	this.computeCentroids();
 	this.computeFaceNormals();
-	this.sortFacesByMaterial();
 
 	function v( x, y, z ) {
 

+ 0 - 3
examples/webgl_geometry_colors.html

@@ -118,9 +118,6 @@
 				geometry3.vertices = geometry2.vertices = geometry.vertices;
 				geometry3.faces = geometry2.faces = geometry.faces;
 
-				geometry2.sortFacesByMaterial();
-				geometry3.sortFacesByMaterial();
-
 				geometry.colors = colors;
 				geometry2.colors = colors2;
 				geometry3.colors = colors3;

+ 0 - 2
examples/webgl_geometry_minecraft.html

@@ -146,8 +146,6 @@
 
 				}
 
-				geometry.sortFacesByMaterial();
-
 				mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial() );
 				scene.addObject( mesh );
 

+ 0 - 2
examples/webgl_geometry_minecraft_ao.html

@@ -434,8 +434,6 @@
 
 				}
 
-				geometry.sortFacesByMaterial();
-
 				mesh = new THREE.Mesh( geometry, new THREE.MeshFaceMaterial() );
 				scene.addObject( mesh );
 

+ 0 - 2
examples/webgl_materials.html

@@ -97,8 +97,6 @@
 
 				}
 
-				geometry_pieces.sortFacesByMaterial();
-
 				materials.push( new THREE.MeshFaceMaterial() );
 
 				objects = [];

+ 0 - 1
examples/webgl_materials_cubemap_balls_reflection.html

@@ -80,7 +80,6 @@
 				sceneCube = new THREE.Scene();
 
 				var geometry = new Sphere( 100, 32, 16 );
-				geometry.sortFacesByMaterial();
 
 				var path = "textures/cube/pisa/";
 				var format = '.png';

+ 0 - 1
examples/webgl_materials_cubemap_balls_refraction.html

@@ -80,7 +80,6 @@
 				sceneCube = new THREE.Scene();
 
 				var geometry = new Sphere( 100, 32, 16 );
-				geometry.sortFacesByMaterial();
 
 				var path = "textures/cube/skybox/";
 				var format = '.jpg';

+ 0 - 78
src/core/Geometry.js

@@ -17,14 +17,10 @@ THREE.Geometry = function () {
 
 	this.skinWeights = [];
 	this.skinIndices = [];
-	//this.skinVerticesA = [];
-	//this.skinVerticesB = [];
 
 	this.boundingBox = null;
 	this.boundingSphere = null;
 
-	this.geometryChunks = {};
-
 	this.hasTangents = false;
 
 };
@@ -391,80 +387,6 @@ THREE.Geometry.prototype = {
 
 		this.boundingSphere = { radius: radius };
 
-	},
-
-	sortFacesByMaterial: function () {
-
-		// TODO
-		// Should optimize by grouping faces with ColorFill / ColorStroke materials
-		// which could then use vertex color attributes instead of each being
-		// in its separate VBO
-
-		var i, l, f, fl, face, material, materials, vertices, mhash, ghash, hash_map = {};
-
-		function materialHash( material ) {
-
-			var hash_array = [];
-
-			for ( i = 0, l = material.length; i < l; i++ ) {
-
-				if ( material[ i ] == undefined ) {
-
-					hash_array.push( "undefined" );
-
-				} else {
-
-					hash_array.push( material[ i ].id );
-
-				}
-
-			}
-
-			return hash_array.join( '_' );
-
-		}
-
-		for ( f = 0, fl = this.faces.length; f < fl; f++ ) {
-
-			face = this.faces[ f ];
-			materials = face.materials;
-
-			mhash = materialHash( materials );
-
-			if ( hash_map[ mhash ] == undefined ) {
-
-				hash_map[ mhash ] = { 'hash': mhash, 'counter': 0 };
-
-			}
-
-			ghash = hash_map[ mhash ].hash + '_' + hash_map[ mhash ].counter;
-
-			if ( this.geometryChunks[ ghash ] == undefined ) {
-
-				this.geometryChunks[ ghash ] = { 'faces': [], 'materials': materials, 'vertices': 0 };
-
-			}
-
-			vertices = face instanceof THREE.Face3 ? 3 : 4;
-
-			if ( this.geometryChunks[ ghash ].vertices + vertices > 65535 ) {
-
-				hash_map[ mhash ].counter += 1;
-				ghash = hash_map[ mhash ].hash + '_' + hash_map[ mhash ].counter;
-
-				if ( this.geometryChunks[ ghash ] == undefined ) {
-
-					this.geometryChunks[ ghash ] = { 'faces': [], 'materials': materials, 'vertices': 0 };
-
-				}
-
-			}
-
-			this.geometryChunks[ ghash ].faces.push( f );
-			this.geometryChunks[ ghash ].vertices += vertices;
-
-		}
-
 	}
 
 };

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

@@ -300,7 +300,6 @@ THREE.Loader.prototype = {
 
 			this.computeCentroids();
 			this.computeFaceNormals();
-			this.sortFacesByMaterial();
 
 			//var e = (new Date).getTime();
 
@@ -763,7 +762,6 @@ THREE.Loader.prototype = {
 
 			this.computeCentroids();
 			this.computeFaceNormals();
-			this.sortFacesByMaterial();
 
 			function init_skin() {
 				

+ 1 - 3
src/extras/objects/MarchingCubes.js

@@ -657,9 +657,7 @@ THREE.MarchingCubes = function ( resolution, materials ) {
 		
 		this.render( geo_callback );
 		
-		geo.sortFacesByMaterial();
-		
-		//console.log( "generated " + geo.faces.length + " triangles" );
+		// console.log( "generated " + geo.faces.length + " triangles" );
 		
 		return geo;
 		

+ 0 - 1
src/extras/primitives/Cube.js

@@ -177,7 +177,6 @@ var Cube = function ( width, height, depth, segmentsWidth, segmentsHeight, mater
 
 	this.computeCentroids();
 	this.computeFaceNormals();
-	this.sortFacesByMaterial();
 
 };
 

+ 0 - 1
src/extras/primitives/Cylinder.js

@@ -68,7 +68,6 @@ var Cylinder = function ( numSegs, topRad, botRad, height, topOffset, botOffset
 
 	this.computeCentroids();
 	this.computeFaceNormals();
-	this.sortFacesByMaterial();
 
 	function v( x, y, z ) {
 

+ 0 - 2
src/extras/primitives/Icosahedron.js

@@ -90,7 +90,6 @@ var Icosahedron = function ( subdivisions ) {
 	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeVertexNormals();
-	this.sortFacesByMaterial();
 
 	function v( x, y, z ) {
 		var length = Math.sqrt(x * x + y * y + z * z);
@@ -176,4 +175,3 @@ var Icosahedron = function ( subdivisions ) {
 
 Icosahedron.prototype = new THREE.Geometry();
 Icosahedron.prototype.constructor = Icosahedron;
-

+ 0 - 1
src/extras/primitives/LathedObject.js

@@ -60,7 +60,6 @@ function LathedObject( verts, nsteps, latheAngle ) {
 	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeVertexNormals();
-	this.sortFacesByMaterial();
 
 };
 

+ 0 - 1
src/extras/primitives/Plane.js

@@ -54,7 +54,6 @@ var Plane = function ( width, height, segmentsWidth, segmentsHeight ) {
 
 	this.computeCentroids();
 	this.computeFaceNormals();
-	this.sortFacesByMaterial();
 
 };
 

+ 0 - 1
src/extras/primitives/Sphere.js

@@ -106,7 +106,6 @@ var Sphere = function ( radius, segmentsWidth, segmentsHeight ) {
 	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeVertexNormals();
-	this.sortFacesByMaterial();
 
 	this.boundingSphere = { radius: radius };
 

+ 1 - 2
src/extras/primitives/Torus.js

@@ -52,7 +52,6 @@ var Torus = function ( radius, tube, segmentsR, segmentsT ) {
 	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeVertexNormals();
-	this.sortFacesByMaterial();
 
 	function vert( x, y, z ) {
 		scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
@@ -65,4 +64,4 @@ var Torus = function ( radius, tube, segmentsR, segmentsT ) {
 }
 
 Torus.prototype = new THREE.Geometry();
-Torus.prototype.constructor = Torus;
+Torus.prototype.constructor = Torus;

+ 1 - 2
src/extras/primitives/Torusknot.js

@@ -69,7 +69,6 @@ var Torusknot = function (radius, tube, segmentsR, segmentsT, p, q, heightScale)
 	this.computeCentroids();
 	this.computeFaceNormals();
 	this.computeVertexNormals();
-	this.sortFacesByMaterial();
 
 	function vert( x, y, z ) {
 		var i = scope.vertices.push( new THREE.Vertex( new THREE.Vector3( x, y, z ) ) );
@@ -97,4 +96,4 @@ var Torusknot = function (radius, tube, segmentsR, segmentsT, p, q, heightScale)
 }
 
 Torusknot.prototype = new THREE.Geometry();
-Torusknot.prototype.constructor = Torusknot;
+Torusknot.prototype.constructor = Torusknot;

+ 199 - 113
src/renderers/WebGLRenderer.js

@@ -210,22 +210,22 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function createMeshBuffers ( geometryChunk ) {
+	function createMeshBuffers ( geometryGroup ) {
 
-		geometryChunk.__webGLVertexBuffer = _gl.createBuffer();
-		geometryChunk.__webGLNormalBuffer = _gl.createBuffer();
-		geometryChunk.__webGLTangentBuffer = _gl.createBuffer();
-		geometryChunk.__webGLColorBuffer = _gl.createBuffer();
-		geometryChunk.__webGLUVBuffer = _gl.createBuffer();
-		geometryChunk.__webGLUV2Buffer = _gl.createBuffer();
+		geometryGroup.__webGLVertexBuffer = _gl.createBuffer();
+		geometryGroup.__webGLNormalBuffer = _gl.createBuffer();
+		geometryGroup.__webGLTangentBuffer = _gl.createBuffer();
+		geometryGroup.__webGLColorBuffer = _gl.createBuffer();
+		geometryGroup.__webGLUVBuffer = _gl.createBuffer();
+		geometryGroup.__webGLUV2Buffer = _gl.createBuffer();
 
-		geometryChunk.__webGLSkinVertexABuffer = _gl.createBuffer();
-		geometryChunk.__webGLSkinVertexBBuffer = _gl.createBuffer();
-		geometryChunk.__webGLSkinIndicesBuffer = _gl.createBuffer();
-		geometryChunk.__webGLSkinWeightsBuffer = _gl.createBuffer();
+		geometryGroup.__webGLSkinVertexABuffer = _gl.createBuffer();
+		geometryGroup.__webGLSkinVertexBBuffer = _gl.createBuffer();
+		geometryGroup.__webGLSkinIndicesBuffer = _gl.createBuffer();
+		geometryGroup.__webGLSkinWeightsBuffer = _gl.createBuffer();
 
-		geometryChunk.__webGLFaceBuffer = _gl.createBuffer();
-		geometryChunk.__webGLLineBuffer = _gl.createBuffer();
+		geometryGroup.__webGLFaceBuffer = _gl.createBuffer();
+		geometryGroup.__webGLLineBuffer = _gl.createBuffer();
 
 	};
 
@@ -264,11 +264,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function initMeshBuffers ( geometryChunk, object ) {
+	function initMeshBuffers ( geometryGroup, object ) {
 
 		var f, fl, nvertices = 0, ntris = 0, nlines = 0,
 			obj_faces = object.geometry.faces,
-			chunk_faces = geometryChunk.faces;
+			chunk_faces = geometryGroup.faces;
 
 		for ( f = 0, fl = chunk_faces.length; f < fl; f++ ) {
 
@@ -293,29 +293,29 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		// TODO: only create arrays for attributes existing in the object
 
-		geometryChunk.__vertexArray  = new Float32Array( nvertices * 3 );
-		geometryChunk.__normalArray  = new Float32Array( nvertices * 3 );
-		geometryChunk.__tangentArray = new Float32Array( nvertices * 4 );
-		geometryChunk.__colorArray = new Float32Array( nvertices * 3 );
-		geometryChunk.__uvArray = new Float32Array( nvertices * 2 );
-		geometryChunk.__uv2Array = new Float32Array( nvertices * 2 );
+		geometryGroup.__vertexArray  = new Float32Array( nvertices * 3 );
+		geometryGroup.__normalArray  = new Float32Array( nvertices * 3 );
+		geometryGroup.__tangentArray = new Float32Array( nvertices * 4 );
+		geometryGroup.__colorArray = new Float32Array( nvertices * 3 );
+		geometryGroup.__uvArray = new Float32Array( nvertices * 2 );
+		geometryGroup.__uv2Array = new Float32Array( nvertices * 2 );
 
-		geometryChunk.__skinVertexAArray = new Float32Array( nvertices * 4 );
-		geometryChunk.__skinVertexBArray = new Float32Array( nvertices * 4 );
-		geometryChunk.__skinIndexArray = new Float32Array( nvertices * 4 );
-		geometryChunk.__skinWeightArray = new Float32Array( nvertices * 4 );
+		geometryGroup.__skinVertexAArray = new Float32Array( nvertices * 4 );
+		geometryGroup.__skinVertexBArray = new Float32Array( nvertices * 4 );
+		geometryGroup.__skinIndexArray = new Float32Array( nvertices * 4 );
+		geometryGroup.__skinWeightArray = new Float32Array( nvertices * 4 );
 
-		geometryChunk.__faceArray = new Uint16Array( ntris * 3 );
-		geometryChunk.__lineArray = new Uint16Array( nlines * 2 );
+		geometryGroup.__faceArray = new Uint16Array( ntris * 3 );
+		geometryGroup.__lineArray = new Uint16Array( nlines * 2 );
 
-		geometryChunk.__needsSmoothNormals = bufferNeedsSmoothNormals ( geometryChunk, object );
+		geometryGroup.__needsSmoothNormals = bufferNeedsSmoothNormals ( geometryGroup, object );
 
-		geometryChunk.__webGLFaceCount = ntris * 3;
-		geometryChunk.__webGLLineCount = nlines * 2;
+		geometryGroup.__webGLFaceCount = ntris * 3;
+		geometryGroup.__webGLLineCount = nlines * 2;
 
 	};
 
-	function setMeshBuffers ( geometryChunk, object, hint ) {
+	function setMeshBuffers ( geometryGroup, object, hint ) {
 
 		var f, fl, fi, face, vertexNormals, faceNormal, normal,
 			uv, uv2, v1, v2, v3, v4, t1, t2, t3, t4,
@@ -339,22 +339,22 @@ THREE.WebGLRenderer = function ( parameters ) {
 		offset_color = 0,
 		offset_skin = 0,
 
-		vertexArray = geometryChunk.__vertexArray,
-		uvArray = geometryChunk.__uvArray,
-		uv2Array = geometryChunk.__uv2Array,
-		normalArray = geometryChunk.__normalArray,
-		tangentArray = geometryChunk.__tangentArray,
-		colorArray = geometryChunk.__colorArray,
+		vertexArray = geometryGroup.__vertexArray,
+		uvArray = geometryGroup.__uvArray,
+		uv2Array = geometryGroup.__uv2Array,
+		normalArray = geometryGroup.__normalArray,
+		tangentArray = geometryGroup.__tangentArray,
+		colorArray = geometryGroup.__colorArray,
 
-		skinVertexAArray = geometryChunk.__skinVertexAArray,
-		skinVertexBArray = geometryChunk.__skinVertexBArray,
-		skinIndexArray = geometryChunk.__skinIndexArray,
-		skinWeightArray = geometryChunk.__skinWeightArray,
+		skinVertexAArray = geometryGroup.__skinVertexAArray,
+		skinVertexBArray = geometryGroup.__skinVertexBArray,
+		skinIndexArray = geometryGroup.__skinIndexArray,
+		skinWeightArray = geometryGroup.__skinWeightArray,
 
-		faceArray = geometryChunk.__faceArray,
-		lineArray = geometryChunk.__lineArray,
+		faceArray = geometryGroup.__faceArray,
+		lineArray = geometryGroup.__lineArray,
 
-		needsSmoothNormals = geometryChunk.__needsSmoothNormals,
+		needsSmoothNormals = geometryGroup.__needsSmoothNormals,
 
 		geometry = object.geometry, // this is shared for all chunks
 
@@ -366,7 +366,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 		dirtyColors = geometry.__dirtyColors,
 
 		vertices = geometry.vertices,
-		chunk_faces = geometryChunk.faces,
+		chunk_faces = geometryGroup.faces,
 		obj_faces = geometry.faces,
 		obj_uvs = geometry.uvs,
 		obj_uvs2 = geometry.uvs2,
@@ -933,68 +933,68 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		if ( dirtyVertices ) {
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLVertexBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLVertexBuffer );
 			_gl.bufferData( _gl.ARRAY_BUFFER, vertexArray, hint );
 
 		}
 
 		if ( dirtyColors && obj_colors.length ) {
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLColorBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLColorBuffer );
 			_gl.bufferData( _gl.ARRAY_BUFFER, colorArray, hint );
 
 		}
 
 		if ( dirtyNormals ) {
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLNormalBuffer );
 			_gl.bufferData( _gl.ARRAY_BUFFER, normalArray, hint );
 
 		}
 
 		if ( dirtyTangents && geometry.hasTangents ) {
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLTangentBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLTangentBuffer );
 			_gl.bufferData( _gl.ARRAY_BUFFER, tangentArray, hint );
 
 		}
 
 		if ( dirtyUvs && offset_uv > 0 ) {
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLUVBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLUVBuffer );
 			_gl.bufferData( _gl.ARRAY_BUFFER, uvArray, hint );
 
 		}
 
 		if ( dirtyUvs && offset_uv2 > 0 ) {
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLUV2Buffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLUV2Buffer );
 			_gl.bufferData( _gl.ARRAY_BUFFER, uv2Array, hint );
 
 		}
 
 		if( dirtyElements ) {
 
-			_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLFaceBuffer );
+			_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webGLFaceBuffer );
 			_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, faceArray, hint );
 
-			_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLLineBuffer );
+			_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webGLLineBuffer );
 			_gl.bufferData( _gl.ELEMENT_ARRAY_BUFFER, lineArray, hint );
 
 		}
 
 		if( offset_skin > 0 ) {
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinVertexABuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinVertexABuffer );
 			_gl.bufferData( _gl.ARRAY_BUFFER, skinVertexAArray, hint );
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinVertexBBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinVertexBBuffer );
 			_gl.bufferData( _gl.ARRAY_BUFFER, skinVertexBArray, hint );
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinIndicesBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinIndicesBuffer );
 			_gl.bufferData( _gl.ARRAY_BUFFER, skinIndexArray, hint );
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinWeightsBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinWeightsBuffer );
 			_gl.bufferData( _gl.ARRAY_BUFFER, skinWeightArray, hint );
 
 		}
@@ -1501,7 +1501,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function renderBuffer( camera, lights, fog, material, geometryChunk, object ) {
+	function renderBuffer( camera, lights, fog, material, geometryGroup, object ) {
 
 		var program, attributes, linewidth, primitives;
 
@@ -1511,14 +1511,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		// vertices
 
-		_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLVertexBuffer );
+		_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLVertexBuffer );
 		_gl.vertexAttribPointer( attributes.position, 3, _gl.FLOAT, false, 0, 0 );
 
 		// colors
 
 		if ( attributes.color >= 0 ) {
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLColorBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLColorBuffer );
 			_gl.vertexAttribPointer( attributes.color, 3, _gl.FLOAT, false, 0, 0 );
 
 		}
@@ -1527,7 +1527,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		if ( attributes.normal >= 0 ) {
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLNormalBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLNormalBuffer );
 			_gl.vertexAttribPointer( attributes.normal, 3, _gl.FLOAT, false, 0, 0 );
 
 		}
@@ -1536,7 +1536,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		if ( attributes.tangent >= 0 ) {
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLTangentBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLTangentBuffer );
 			_gl.vertexAttribPointer( attributes.tangent, 4, _gl.FLOAT, false, 0, 0 );
 
 		}
@@ -1545,9 +1545,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		if ( attributes.uv >= 0 ) {
 
-			if ( geometryChunk.__webGLUVBuffer ) {
+			if ( geometryGroup.__webGLUVBuffer ) {
 
-				_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLUVBuffer );
+				_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLUVBuffer );
 				_gl.vertexAttribPointer( attributes.uv, 2, _gl.FLOAT, false, 0, 0 );
 
 				_gl.enableVertexAttribArray( attributes.uv );
@@ -1562,9 +1562,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		if ( attributes.uv2 >= 0 ) {
 
-			if ( geometryChunk.__webGLUV2Buffer ) {
+			if ( geometryGroup.__webGLUV2Buffer ) {
 
-				_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLUV2Buffer );
+				_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLUV2Buffer );
 				_gl.vertexAttribPointer( attributes.uv2, 2, _gl.FLOAT, false, 0, 0 );
 
 				_gl.enableVertexAttribArray( attributes.uv2 );
@@ -1581,16 +1581,16 @@ THREE.WebGLRenderer = function ( parameters ) {
 			 attributes.skinVertexA >=0 && attributes.skinVertexB >= 0 &&
 			 attributes.skinIndex >= 0 && attributes.skinWeight >= 0 ) {
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinVertexABuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinVertexABuffer );
 			_gl.vertexAttribPointer( attributes.skinVertexA, 4, _gl.FLOAT, false, 0, 0 );
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinVertexBBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinVertexBBuffer );
 			_gl.vertexAttribPointer( attributes.skinVertexB, 4, _gl.FLOAT, false, 0, 0 );
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinIndicesBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinIndicesBuffer );
 			_gl.vertexAttribPointer( attributes.skinIndex, 4, _gl.FLOAT, false, 0, 0 );
 
-			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryChunk.__webGLSkinWeightsBuffer );
+			_gl.bindBuffer( _gl.ARRAY_BUFFER, geometryGroup.__webGLSkinWeightsBuffer );
 			_gl.vertexAttribPointer( attributes.skinWeight, 4, _gl.FLOAT, false, 0, 0 );
 
 		}
@@ -1604,15 +1604,15 @@ THREE.WebGLRenderer = function ( parameters ) {
 			if ( material.wireframe ) {
 
 				_gl.lineWidth( material.wireframeLinewidth );
-				_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLLineBuffer );
-				_gl.drawElements( _gl.LINES, geometryChunk.__webGLLineCount, _gl.UNSIGNED_SHORT, 0 );
+				_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webGLLineBuffer );
+				_gl.drawElements( _gl.LINES, geometryGroup.__webGLLineCount, _gl.UNSIGNED_SHORT, 0 );
 
 			// triangles
 
 			} else {
 
-				_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryChunk.__webGLFaceBuffer );
-				_gl.drawElements( _gl.TRIANGLES, geometryChunk.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 );
+				_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, geometryGroup.__webGLFaceBuffer );
+				_gl.drawElements( _gl.TRIANGLES, geometryGroup.__webGLFaceCount, _gl.UNSIGNED_SHORT, 0 );
 
 			}
 
@@ -1623,19 +1623,19 @@ THREE.WebGLRenderer = function ( parameters ) {
 			primitives = ( object.type == THREE.LineStrip ) ? _gl.LINE_STRIP : _gl.LINES;
 
 			_gl.lineWidth( material.linewidth );
-			_gl.drawArrays( primitives, 0, geometryChunk.__webGLLineCount );
+			_gl.drawArrays( primitives, 0, geometryGroup.__webGLLineCount );
 
 		// render particles
 
 		} else if ( object instanceof THREE.ParticleSystem ) {
 
-			_gl.drawArrays( _gl.POINTS, 0, geometryChunk.__webGLParticleCount );
+			_gl.drawArrays( _gl.POINTS, 0, geometryGroup.__webGLParticleCount );
 
 		// render ribbon
 
 		} else if ( object instanceof THREE.Ribbon ) {
 
-			_gl.drawArrays( _gl.TRIANGLE_STRIP, 0, geometryChunk.__webGLVertexCount );
+			_gl.drawArrays( _gl.TRIANGLE_STRIP, 0, geometryGroup.__webGLVertexCount );
 
 		}
 
@@ -2074,11 +2074,30 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function addObject( scene, object, camera ) {
 
-		var g, geometry, geometryChunk, objmap;
 
-		geometry = object.geometry;
+	this.initWebGLObjects = function( scene, camera ) {
+
+		if ( !scene.__webGLObjects ) {
+
+			scene.__webGLObjects = [];
+			scene.__webGLObjectsMap = {};
+
+			scene.__webGLObjectsImmediate = [];
+
+		}
+
+		for ( var o = 0, ol = scene.objects.length; o < ol; o ++ ) {
+
+			addObject( scene.objects[ o ], scene, camera );
+
+		}
+
+	};
+
+	function addObject( object, scene, camera ) {
+
+		var g, geometry, geometryGroup, objmap;
 
 		if ( scene.__webGLObjectsMap[ object.id ] == undefined ) {
 
@@ -2099,18 +2118,26 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		if ( object instanceof THREE.Mesh ) {
 
+			geometry = object.geometry;
+
+			if ( geometry.geometryGroups == undefined ) {
+
+				sortFacesByMaterial( geometry );
+
+			}
+
 			// create separate VBOs per geometry chunk
 
-			for ( g in geometry.geometryChunks ) {
+			for ( g in geometry.geometryGroups ) {
 
-				geometryChunk = geometry.geometryChunks[ g ];
+				geometryGroup = geometry.geometryGroups[ g ];
 
 				// initialise VBO on the first access
 
-				if( ! geometryChunk.__webGLVertexBuffer ) {
+				if( ! geometryGroup.__webGLVertexBuffer ) {
 
-					createMeshBuffers( geometryChunk );
-					initMeshBuffers( geometryChunk, object );
+					createMeshBuffers( geometryGroup );
+					initMeshBuffers( geometryGroup, object );
 
 					geometry.__dirtyVertices = true;
 					geometry.__dirtyElements = true;
@@ -2125,13 +2152,13 @@ THREE.WebGLRenderer = function ( parameters ) {
 					geometry.__dirtyUvs || geometry.__dirtyNormals ||
 					geometry.__dirtyColors || geometry.__dirtyTangents ) {
 
-					setMeshBuffers( geometryChunk, object, _gl.DYNAMIC_DRAW );
+					setMeshBuffers( geometryGroup, object, _gl.DYNAMIC_DRAW );
 
 				}
 
 				// create separate wrapper per each use of VBO
 
-				add_buffer( objlist, objmap, g, geometryChunk, object );
+				add_buffer( objlist, objmap, g, geometryGroup, object );
 
 			}
 
@@ -2144,6 +2171,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		} else if ( object instanceof THREE.Ribbon ) {
 
+			geometry = object.geometry;
+
 			if( ! geometry.__webGLVertexBuffer ) {
 
 				createRibbonBuffers( geometry );
@@ -2167,6 +2196,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		} else if ( object instanceof THREE.Line ) {
 
+			geometry = object.geometry;
+
 			if( ! geometry.__webGLVertexBuffer ) {
 
 				createLineBuffers( geometry );
@@ -2190,6 +2221,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		} else if ( object instanceof THREE.ParticleSystem ) {
 
+			geometry = object.geometry;
+
 			if( ! geometry.__webGLVertexBuffer ) {
 
 				createParticleBuffers( geometry );
@@ -2221,6 +2254,82 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
+	function sortFacesByMaterial( geometry ) {
+
+		// TODO
+		// Should optimize by grouping faces with ColorFill / ColorStroke materials
+		// which could then use vertex color attributes instead of each being
+		// in its separate VBO
+
+		var i, l, f, fl, face, material, materials, vertices, mhash, ghash, hash_map = {};
+
+		geometry.geometryGroups = {};
+
+		function materialHash( material ) {
+
+			var hash_array = [];
+
+			for ( i = 0, l = material.length; i < l; i++ ) {
+
+				if ( material[ i ] == undefined ) {
+
+					hash_array.push( "undefined" );
+
+				} else {
+
+					hash_array.push( material[ i ].id );
+
+				}
+
+			}
+
+			return hash_array.join( '_' );
+
+		}
+
+		for ( f = 0, fl = geometry.faces.length; f < fl; f++ ) {
+
+			face = geometry.faces[ f ];
+			materials = face.materials;
+
+			mhash = materialHash( materials );
+
+			if ( hash_map[ mhash ] == undefined ) {
+
+				hash_map[ mhash ] = { 'hash': mhash, 'counter': 0 };
+
+			}
+
+			ghash = hash_map[ mhash ].hash + '_' + hash_map[ mhash ].counter;
+
+			if ( geometry.geometryGroups[ ghash ] == undefined ) {
+
+				geometry.geometryGroups[ ghash ] = { 'faces': [], 'materials': materials, 'vertices': 0 };
+
+			}
+
+			vertices = face instanceof THREE.Face3 ? 3 : 4;
+
+			if ( geometry.geometryGroups[ ghash ].vertices + vertices > 65535 ) {
+
+				hash_map[ mhash ].counter += 1;
+				ghash = hash_map[ mhash ].hash + '_' + hash_map[ mhash ].counter;
+
+				if ( geometry.geometryGroups[ ghash ] == undefined ) {
+
+					geometry.geometryGroups[ ghash ] = { 'faces': [], 'materials': materials, 'vertices': 0 };
+
+				}
+
+			}
+
+			geometry.geometryGroups[ ghash ].faces.push( f );
+			geometry.geometryGroups[ ghash ].vertices += vertices;
+
+		}
+
+	};
+
 	function add_buffer( objlist, objmap, id, buffer, object ) {
 
 		if ( objmap[ id ] == undefined ) {
@@ -2251,29 +2360,6 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	this.initWebGLObjects = function( scene, camera ) {
-
-		var o, ol, object;
-
-		if ( !scene.__webGLObjects ) {
-
-			scene.__webGLObjects = [];
-			scene.__webGLObjectsMap = {};
-
-			scene.__webGLObjectsImmediate = [];
-
-		}
-
-		for ( o = 0, ol = scene.objects.length; o < ol; o++ ) {
-
-			object = scene.objects[ o ];
-
-			addObject( scene, object, camera );
-
-		}
-
-	};
-
 	this.removeObject = function ( scene, object ) {
 
 		var o, ol, zobject;
@@ -2853,7 +2939,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function bufferNeedsSmoothNormals( geometryChunk, object ) {
+	function bufferNeedsSmoothNormals( geometryGroup, object ) {
 
 		var m, ml, i, l, meshMaterial, needsSmoothNormals = false;
 
@@ -2863,9 +2949,9 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			if ( meshMaterial instanceof THREE.MeshFaceMaterial ) {
 
-				for ( i = 0, l = geometryChunk.materials.length; i < l; i++ ) {
+				for ( i = 0, l = geometryGroup.materials.length; i < l; i++ ) {
 
-					if ( materialNeedsSmoothNormals( geometryChunk.materials[ i ] ) ) {
+					if ( materialNeedsSmoothNormals( geometryGroup.materials[ i ] ) ) {
 
 						needsSmoothNormals = true;
 						break;