Browse Source

Merged with mrdoob

Mikael Emtinger 14 years ago
parent
commit
e7b6f4ad3c

+ 245 - 241
build/Three.js

@@ -12,30 +12,30 @@ this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPosit
 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(b,d,c,f){this.set(b||0,d||0,c||0,f||1)};
 THREE.Vector4.prototype={set:function(b,d,c,f){this.x=b;this.y=d;this.z=c;this.w=f;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z,b.w+d.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z,b.w-d.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x*
 b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,d){this.set(this.x+(b.x-this.x)*d,this.y+(b.y-this.y)*d,this.z+(b.z-this.z)*d,this.w+(b.w-this.w)*d)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(b){var d,c,f=b.objects,g=[];b=0;for(d=f.length;b<d;b++){c=f[b];c instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(c)))}g.sort(function(h,j){return h.distance-j.distance});return g},intersectObject:function(b){function d(F,H,U,z){z=z.clone().subSelf(H);U=U.clone().subSelf(H);var J=F.clone().subSelf(H);F=z.dot(z);H=z.dot(U);z=z.dot(J);var L=U.dot(U);U=U.dot(J);J=1/(F*L-H*H);L=(L*z-H*U)*J;F=(F*U-H*z)*J;return L>0&&F>0&&L+F<1}var c,f,g,h,j,k,n,p,o,u,
-y,v=b.geometry,B=v.vertices,C=[];c=0;for(f=v.faces.length;c<f;c++){g=v.faces[c];u=this.origin.clone();y=this.direction.clone();n=b.matrixWorld;h=n.multiplyVector3(B[g.a].position.clone());j=n.multiplyVector3(B[g.b].position.clone());k=n.multiplyVector3(B[g.c].position.clone());n=g instanceof THREE.Face4?n.multiplyVector3(B[g.d].position.clone()):null;p=b.matrixRotationWorld.multiplyVector3(g.normal.clone());o=y.dot(p);if(o<0){p=p.dot((new THREE.Vector3).sub(h,u))/o;u=u.addSelf(y.multiplyScalar(p));
-if(g instanceof THREE.Face3){if(d(u,h,j,k)){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};C.push(g)}}else if(g instanceof THREE.Face4&&(d(u,h,j,n)||d(u,j,k,n))){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};C.push(g)}}}return C}};
+THREE.Ray.prototype={intersectScene:function(b){var d,c,f=b.objects,g=[];b=0;for(d=f.length;b<d;b++){c=f[b];c instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(c)))}g.sort(function(h,j){return h.distance-j.distance});return g},intersectObject:function(b){function d(G,L,V,z){z=z.clone().subSelf(L);V=V.clone().subSelf(L);var N=G.clone().subSelf(L);G=z.dot(z);L=z.dot(V);z=z.dot(N);var Q=V.dot(V);V=V.dot(N);N=1/(G*Q-L*L);Q=(Q*z-L*V)*N;G=(G*V-L*z)*N;return Q>0&&G>0&&Q+G<1}var c,f,g,h,j,k,n,p,o,u,
+y,w=b.geometry,A=w.vertices,E=[];c=0;for(f=w.faces.length;c<f;c++){g=w.faces[c];u=this.origin.clone();y=this.direction.clone();n=b.matrixWorld;h=n.multiplyVector3(A[g.a].position.clone());j=n.multiplyVector3(A[g.b].position.clone());k=n.multiplyVector3(A[g.c].position.clone());n=g instanceof THREE.Face4?n.multiplyVector3(A[g.d].position.clone()):null;p=b.matrixRotationWorld.multiplyVector3(g.normal.clone());o=y.dot(p);if(o<0){p=p.dot((new THREE.Vector3).sub(h,u))/o;u=u.addSelf(y.multiplyScalar(p));
+if(g instanceof THREE.Face3){if(d(u,h,j,k)){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};E.push(g)}}else if(g instanceof THREE.Face4&&(d(u,h,j,n)||d(u,j,k,n))){g={distance:this.origin.distanceTo(u),point:u,face:g,object:b};E.push(g)}}}return E}};
 THREE.Rectangle=function(){function b(){h=f-d;j=g-c}var d,c,f,g,h,j,k=!0;this.getX=function(){return d};this.getY=function(){return c};this.getWidth=function(){return h};this.getHeight=function(){return j};this.getLeft=function(){return d};this.getTop=function(){return c};this.getRight=function(){return f};this.getBottom=function(){return g};this.set=function(n,p,o,u){k=!1;d=n;c=p;f=o;g=u;b()};this.addPoint=function(n,p){if(k){k=!1;d=n;c=p;f=n;g=p}else{d=d<n?d:n;c=c<p?c:p;f=f>n?f:n;g=g>p?g:p}b()};
-this.add3Points=function(n,p,o,u,y,v){if(k){k=!1;d=n<o?n<y?n:y:o<y?o:y;c=p<u?p<v?p:v:u<v?u:v;f=n>o?n>y?n:y:o>y?o:y;g=p>u?p>v?p:v:u>v?u:v}else{d=n<o?n<y?n<d?n:d:y<d?y:d:o<y?o<d?o:d:y<d?y:d;c=p<u?p<v?p<c?p:c:v<c?v:c:u<v?u<c?u:c:v<c?v:c;f=n>o?n>y?n>f?n:f:y>f?y:f:o>y?o>f?o:f:y>f?y:f;g=p>u?p>v?p>g?p:g:v>g?v:g:u>v?u>g?u:g:v>g?v:g}b()};this.addRectangle=function(n){if(k){k=!1;d=n.getLeft();c=n.getTop();f=n.getRight();g=n.getBottom()}else{d=d<n.getLeft()?d:n.getLeft();c=c<n.getTop()?c:n.getTop();f=f>n.getRight()?
+this.add3Points=function(n,p,o,u,y,w){if(k){k=!1;d=n<o?n<y?n:y:o<y?o:y;c=p<u?p<w?p:w:u<w?u:w;f=n>o?n>y?n:y:o>y?o:y;g=p>u?p>w?p:w:u>w?u:w}else{d=n<o?n<y?n<d?n:d:y<d?y:d:o<y?o<d?o:d:y<d?y:d;c=p<u?p<w?p<c?p:c:w<c?w:c:u<w?u<c?u:c:w<c?w:c;f=n>o?n>y?n>f?n:f:y>f?y:f:o>y?o>f?o:f:y>f?y:f;g=p>u?p>w?p>g?p:g:w>g?w:g:u>w?u>g?u:g:w>g?w:g}b()};this.addRectangle=function(n){if(k){k=!1;d=n.getLeft();c=n.getTop();f=n.getRight();g=n.getBottom()}else{d=d<n.getLeft()?d:n.getLeft();c=c<n.getTop()?c:n.getTop();f=f>n.getRight()?
 f:n.getRight();g=g>n.getBottom()?g:n.getBottom()}b()};this.inflate=function(n){d-=n;c-=n;f+=n;g+=n;b()};this.minSelf=function(n){d=d>n.getLeft()?d:n.getLeft();c=c>n.getTop()?c:n.getTop();f=f<n.getRight()?f:n.getRight();g=g<n.getBottom()?g:n.getBottom();b()};this.instersects=function(n){return Math.min(f,n.getRight())-Math.max(d,n.getLeft())>=0&&Math.min(g,n.getBottom())-Math.max(c,n.getTop())>=0};this.empty=function(){k=!0;g=f=c=d=0;b()};this.isEmpty=function(){return k}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}};
-THREE.Matrix4=function(b,d,c,f,g,h,j,k,n,p,o,u,y,v,B,C){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,n||0,p||0,o||1,u||0,y||0,v||0,B||0,C||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(b,d,c,f,g,h,j,k,n,p,o,u,y,v,B,C){this.n11=b;this.n12=d;this.n13=c;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=n;this.n32=p;this.n33=o;this.n34=u;this.n41=y;this.n42=v;this.n43=B;this.n44=C;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,c){var f=THREE.Matrix4.__v1,
+THREE.Matrix4=function(b,d,c,f,g,h,j,k,n,p,o,u,y,w,A,E){this.set(b||1,d||0,c||0,f||0,g||0,h||1,j||0,k||0,n||0,p||0,o||1,u||0,y||0,w||0,A||0,E||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(b,d,c,f,g,h,j,k,n,p,o,u,y,w,A,E){this.n11=b;this.n12=d;this.n13=c;this.n14=f;this.n21=g;this.n22=h;this.n23=j;this.n24=k;this.n31=n;this.n32=p;this.n33=o;this.n34=u;this.n41=y;this.n42=w;this.n43=A;this.n44=E;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,c){var f=THREE.Matrix4.__v1,
 g=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,d).normalize();if(h.length()===0)h.z=1;f.cross(c,h).normalize();if(f.length()===0){h.x+=1.0E-4;f.cross(c,h).normalize()}g.cross(h,f).normalize();this.n11=f.x;this.n12=g.x;this.n13=h.x;this.n21=f.y;this.n22=g.y;this.n23=h.y;this.n31=f.z;this.n32=g.z;this.n33=h.z;return this},multiplyVector3:function(b){var d=b.x,c=b.y,f=b.z,g=1/(this.n41*d+this.n42*c+this.n43*f+this.n44);b.x=(this.n11*d+this.n12*c+this.n13*f+this.n14)*g;b.y=(this.n21*d+this.n22*c+this.n23*
 f+this.n24)*g;b.z=(this.n31*d+this.n32*c+this.n33*f+this.n34)*g;return b},multiplyVector4:function(b){var d=b.x,c=b.y,f=b.z,g=b.w;b.x=this.n11*d+this.n12*c+this.n13*f+this.n14*g;b.y=this.n21*d+this.n22*c+this.n23*f+this.n24*g;b.z=this.n31*d+this.n32*c+this.n33*f+this.n34*g;b.w=this.n41*d+this.n42*c+this.n43*f+this.n44*g;return b},rotateAxis:function(b){var d=b.x,c=b.y,f=b.z;b.x=d*this.n11+c*this.n12+f*this.n13;b.y=d*this.n21+c*this.n22+f*this.n23;b.z=d*this.n31+c*this.n32+f*this.n33;b.normalize();
-return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,n=b.n23,p=b.n24,o=b.n31,u=b.n32,y=b.n33,v=b.n34,B=b.n41,C=b.n42,F=b.n43,H=b.n44,U=d.n11,z=d.n12,J=d.n13,L=d.n14,M=d.n21,Fa=d.n22,
-oa=d.n23,xa=d.n24,Z=d.n31,e=d.n32,da=d.n33,Ca=d.n34;this.n11=c*U+f*M+g*Z;this.n12=c*z+f*Fa+g*e;this.n13=c*J+f*oa+g*da;this.n14=c*L+f*xa+g*Ca+h;this.n21=j*U+k*M+n*Z;this.n22=j*z+k*Fa+n*e;this.n23=j*J+k*oa+n*da;this.n24=j*L+k*xa+n*Ca+p;this.n31=o*U+u*M+y*Z;this.n32=o*z+u*Fa+y*e;this.n33=o*J+u*oa+y*da;this.n34=o*L+u*xa+y*Ca+v;this.n41=B*U+C*M+F*Z;this.n42=B*z+C*Fa+F*e;this.n43=B*J+C*oa+F*da;this.n44=B*L+C*xa+F*Ca+H;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);c[0]=this.n11;c[1]=this.n21;
-c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=b;return this},
-determinant:function(){var b=this.n11,d=this.n12,c=this.n13,f=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,n=this.n31,p=this.n32,o=this.n33,u=this.n34,y=this.n41,v=this.n42,B=this.n43,C=this.n44;return f*j*p*y-c*k*p*y-f*h*o*y+d*k*o*y+c*h*u*y-d*j*u*y-f*j*n*v+c*k*n*v+f*g*o*v-b*k*o*v-c*g*u*v+b*j*u*v+f*h*n*B-d*k*n*B-f*g*p*B+b*k*p*B+d*g*u*B-b*h*u*B-c*h*n*C+d*j*n*C+c*g*p*C-b*j*p*C-d*g*o*C+b*h*o*C},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=this.n13;this.n13=
-b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=this.n11;
-this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;b[8]=this.n13;
-b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,c){this.set(1,0,0,b,0,1,0,d,0,0,1,c,0,0,0,1);return this},
-setScale:function(b,d,c){this.set(b,0,0,0,0,d,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(1,0,0,0,0,d,-b,0,0,b,d,0,0,0,0,1);return this},setRotationY:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,0,b,0,0,1,0,0,-b,0,d,0,0,0,0,1);return this},setRotationZ:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,-b,0,0,b,d,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var c=Math.cos(d),f=Math.sin(d),g=1-c,h=b.x,j=b.y,k=
-b.z,n=g*h,p=g*j;this.set(n*h+c,n*j-f*k,n*k+f*j,0,n*j+f*k,p*j+c,p*k-f*h,0,n*k-f*j,p*k+f*h,g*k*k+c,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var d=b.x,c=b.y,f=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(c);c=Math.sin(c);var h=Math.cos(f);f=Math.sin(f);var j=b*c,k=d*c;this.n11=g*h;this.n12=-g*f;this.n13=c;this.n21=k*h+b*f;this.n22=-k*f+b*h;this.n23=-d*g;this.n31=-j*h+d*f;this.n32=j*f+d*h;this.n33=b*g;return this},
-setRotationFromQuaternion:function(b){var d=b.x,c=b.y,f=b.z,g=b.w,h=d+d,j=c+c,k=f+f;b=d*h;var n=d*j;d*=k;var p=c*j;c*=k;f*=k;h*=g;j*=g;g*=k;this.n11=1-(p+f);this.n12=n-g;this.n13=d+j;this.n21=n+g;this.n22=1-(b+f);this.n23=c-h;this.n31=d-j;this.n32=c+h;this.n33=1-(b+p);return this},scale:function(b){var d=b.x,c=b.y;b=b.z;this.n11*=d;this.n12*=c;this.n13*=b;this.n21*=d;this.n22*=c;this.n23*=b;this.n31*=d;this.n32*=c;this.n33*=b;this.n41*=d;this.n42*=c;this.n43*=b;return this},extractPosition:function(b){this.n14=
+return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,n=b.n23,p=b.n24,o=b.n31,u=b.n32,y=b.n33,w=b.n34,A=b.n41,E=b.n42,G=b.n43,L=b.n44,V=d.n11,z=d.n12,N=d.n13,Q=d.n14,S=d.n21,xa=d.n22,
+sa=d.n23,qa=d.n24,e=d.n31,fa=d.n32,da=d.n33,ya=d.n34;this.n11=c*V+f*S+g*e;this.n12=c*z+f*xa+g*fa;this.n13=c*N+f*sa+g*da;this.n14=c*Q+f*qa+g*ya+h;this.n21=j*V+k*S+n*e;this.n22=j*z+k*xa+n*fa;this.n23=j*N+k*sa+n*da;this.n24=j*Q+k*qa+n*ya+p;this.n31=o*V+u*S+y*e;this.n32=o*z+u*xa+y*fa;this.n33=o*N+u*sa+y*da;this.n34=o*Q+u*qa+y*ya+w;this.n41=A*V+E*S+G*e;this.n42=A*z+E*xa+G*fa;this.n43=A*N+E*sa+G*da;this.n44=A*Q+E*qa+G*ya+L;return this},multiplyToArray:function(b,d,c){this.multiply(b,d);c[0]=this.n11;c[1]=
+this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=
+b;return this},determinant:function(){var b=this.n11,d=this.n12,c=this.n13,f=this.n14,g=this.n21,h=this.n22,j=this.n23,k=this.n24,n=this.n31,p=this.n32,o=this.n33,u=this.n34,y=this.n41,w=this.n42,A=this.n43,E=this.n44;return f*j*p*y-c*k*p*y-f*h*o*y+d*k*o*y+c*h*u*y-d*j*u*y-f*j*n*w+c*k*n*w+f*g*o*w-b*k*o*w-c*g*u*w+b*j*u*w+f*h*n*A-d*k*n*A-f*g*p*A+b*k*p*A+d*g*u*A-b*h*u*A-c*h*n*E+d*j*n*E+c*g*p*E-b*j*p*E-d*g*o*E+b*h*o*E},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=
+this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=
+this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;
+b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,c){this.set(1,0,0,b,0,1,0,d,0,0,1,c,0,0,
+0,1);return this},setScale:function(b,d,c){this.set(b,0,0,0,0,d,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(1,0,0,0,0,d,-b,0,0,b,d,0,0,0,0,1);return this},setRotationY:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,0,b,0,0,1,0,0,-b,0,d,0,0,0,0,1);return this},setRotationZ:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,-b,0,0,b,d,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var c=Math.cos(d),f=Math.sin(d),g=
+1-c,h=b.x,j=b.y,k=b.z,n=g*h,p=g*j;this.set(n*h+c,n*j-f*k,n*k+f*j,0,n*j+f*k,p*j+c,p*k-f*h,0,n*k-f*j,p*k+f*h,g*k*k+c,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var d=b.x,c=b.y,f=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(c);c=Math.sin(c);var h=Math.cos(f);f=Math.sin(f);var j=b*c,k=d*c;this.n11=g*h;this.n12=-g*f;this.n13=c;this.n21=k*h+b*f;this.n22=-k*f+b*h;this.n23=-d*g;this.n31=-j*h+d*f;this.n32=j*f+d*h;this.n33=
+b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,c=b.y,f=b.z,g=b.w,h=d+d,j=c+c,k=f+f;b=d*h;var n=d*j;d*=k;var p=c*j;c*=k;f*=k;h*=g;j*=g;g*=k;this.n11=1-(p+f);this.n12=n-g;this.n13=d+j;this.n21=n+g;this.n22=1-(b+f);this.n23=c-h;this.n31=d-j;this.n32=c+h;this.n33=1-(b+p);return this},scale:function(b){var d=b.x,c=b.y;b=b.z;this.n11*=d;this.n12*=c;this.n13*=b;this.n21*=d;this.n22*=c;this.n23*=b;this.n31*=d;this.n32*=c;this.n33*=b;this.n41*=d;this.n42*=c;this.n43*=b;return this},extractPosition:function(b){this.n14=
 b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,d){var c=1/d.x,f=1/d.y,g=1/d.z;this.n11=b.n11*c;this.n21=b.n21*c;this.n31=b.n31*c;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}};
-THREE.Matrix4.makeInvert=function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,n=b.n23,p=b.n24,o=b.n31,u=b.n32,y=b.n33,v=b.n34,B=b.n41,C=b.n42,F=b.n43,H=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=n*v*C-p*y*C+p*u*F-k*v*F-n*u*H+k*y*H;d.n12=h*y*C-g*v*C-h*u*F+f*v*F+g*u*H-f*y*H;d.n13=g*p*C-h*n*C+h*k*F-f*p*F-g*k*H+f*n*H;d.n14=h*n*u-g*p*u-h*k*y+f*p*y+g*k*v-f*n*v;d.n21=p*y*B-n*v*B-p*o*F+j*v*F+n*o*H-j*y*H;d.n22=g*v*B-h*y*B+h*o*F-c*v*F-g*o*H+c*y*H;d.n23=h*n*B-g*p*B-h*j*F+c*p*F+g*j*H-c*n*H;
-d.n24=g*p*o-h*n*o+h*j*y-c*p*y-g*j*v+c*n*v;d.n31=k*v*B-p*u*B+p*o*C-j*v*C-k*o*H+j*u*H;d.n32=h*u*B-f*v*B-h*o*C+c*v*C+f*o*H-c*u*H;d.n33=g*p*B-h*k*B+h*j*C-c*p*C-f*j*H+c*k*H;d.n34=h*k*o-f*p*o-h*j*u+c*p*u+f*j*v-c*k*v;d.n41=n*u*B-k*y*B-n*o*C+j*y*C+k*o*F-j*u*F;d.n42=f*y*B-g*u*B+g*o*C-c*y*C-f*o*F+c*u*F;d.n43=g*k*B-f*n*B-g*j*C+c*n*C+f*j*F-c*k*F;d.n44=f*n*o-g*k*o+g*j*u-c*n*u-f*j*y+c*k*y;d.multiplyScalar(1/b.determinant());return d};
+THREE.Matrix4.makeInvert=function(b,d){var c=b.n11,f=b.n12,g=b.n13,h=b.n14,j=b.n21,k=b.n22,n=b.n23,p=b.n24,o=b.n31,u=b.n32,y=b.n33,w=b.n34,A=b.n41,E=b.n42,G=b.n43,L=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=n*w*E-p*y*E+p*u*G-k*w*G-n*u*L+k*y*L;d.n12=h*y*E-g*w*E-h*u*G+f*w*G+g*u*L-f*y*L;d.n13=g*p*E-h*n*E+h*k*G-f*p*G-g*k*L+f*n*L;d.n14=h*n*u-g*p*u-h*k*y+f*p*y+g*k*w-f*n*w;d.n21=p*y*A-n*w*A-p*o*G+j*w*G+n*o*L-j*y*L;d.n22=g*w*A-h*y*A+h*o*G-c*w*G-g*o*L+c*y*L;d.n23=h*n*A-g*p*A-h*j*G+c*p*G+g*j*L-c*n*L;
+d.n24=g*p*o-h*n*o+h*j*y-c*p*y-g*j*w+c*n*w;d.n31=k*w*A-p*u*A+p*o*E-j*w*E-k*o*L+j*u*L;d.n32=h*u*A-f*w*A-h*o*E+c*w*E+f*o*L-c*u*L;d.n33=g*p*A-h*k*A+h*j*E-c*p*E-f*j*L+c*k*L;d.n34=h*k*o-f*p*o-h*j*u+c*p*u+f*j*w-c*k*w;d.n41=n*u*A-k*y*A-n*o*E+j*y*E+k*o*G-j*u*G;d.n42=f*y*A-g*u*A+g*o*E-c*y*E-f*o*G+c*u*G;d.n43=g*k*A-f*n*A-g*j*E+c*n*E+f*j*G-c*k*G;d.n44=f*n*o-g*k*o+g*j*u-c*n*u-f*j*y+c*k*y;d.multiplyScalar(1/b.determinant());return d};
 THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,c=d.m,f=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,h=b.n32*b.n21-b.n31*b.n22,j=-b.n33*b.n12+b.n32*b.n13,k=b.n33*b.n11-b.n31*b.n13,n=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,o=-b.n23*b.n11+b.n21*b.n13,u=b.n22*b.n11-b.n21*b.n12;b=b.n11*f+b.n21*j+b.n31*p;if(b==0)throw"matrix not invertible";b=1/b;c[0]=b*f;c[1]=b*g;c[2]=b*h;c[3]=b*j;c[4]=b*k;c[5]=b*n;c[6]=b*p;c[7]=b*o;c[8]=b*u;return d};
 THREE.Matrix4.makeFrustum=function(b,d,c,f,g,h){var j;j=new THREE.Matrix4;j.n11=2*g/(d-b);j.n12=0;j.n13=(d+b)/(d-b);j.n14=0;j.n21=0;j.n22=2*g/(f-c);j.n23=(f+c)/(f-c);j.n24=0;j.n31=0;j.n32=0;j.n33=-(h+g)/(h-g);j.n34=-2*h*g/(h-g);j.n41=0;j.n42=0;j.n43=-1;j.n44=0;return j};THREE.Matrix4.makePerspective=function(b,d,c,f){var g;b=c*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,c,f)};
 THREE.Matrix4.makeOrtho=function(b,d,c,f,g,h){var j,k,n,p;j=new THREE.Matrix4;k=d-b;n=c-f;p=h-g;j.n11=2/k;j.n12=0;j.n13=0;j.n14=-((d+b)/k);j.n21=0;j.n22=2/n;j.n23=0;j.n24=-((c+f)/n);j.n31=0;j.n32=0;j.n33=-2/p;j.n34=-((h+g)/p);j.n41=0;j.n42=0;j.n43=0;j.n44=1;return j};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
@@ -56,16 +56,16 @@ THREE.Geometry.prototype={computeCentroids:function(){var b,d,c;b=0;for(d=this.f
 c.centroid.addSelf(this.vertices[c.d].position);c.centroid.divideScalar(4)}}},computeFaceNormals:function(b){var d,c,f,g,h,j,k=new THREE.Vector3,n=new THREE.Vector3;f=0;for(g=this.faces.length;f<g;f++){h=this.faces[f];if(b&&h.vertexNormals.length){k.set(0,0,0);d=0;for(c=h.vertexNormals.length;d<c;d++)k.addSelf(h.vertexNormals[d]);k.divideScalar(3)}else{d=this.vertices[h.a];c=this.vertices[h.b];j=this.vertices[h.c];k.sub(j.position,c.position);n.sub(d.position,c.position);k.crossSelf(n)}k.isZero()||
 k.normalize();h.normal.copy(k)}},computeVertexNormals:function(){var b,d,c,f;if(this.__tmpVertices==undefined){f=this.__tmpVertices=Array(this.vertices.length);b=0;for(d=this.vertices.length;b<d;b++)f[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++){c=this.faces[b];if(c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{f=
 this.__tmpVertices;b=0;for(d=this.vertices.length;b<d;b++)f[b].set(0,0,0)}b=0;for(d=this.faces.length;b<d;b++){c=this.faces[b];if(c instanceof THREE.Face3){f[c.a].addSelf(c.normal);f[c.b].addSelf(c.normal);f[c.c].addSelf(c.normal)}else if(c instanceof THREE.Face4){f[c.a].addSelf(c.normal);f[c.b].addSelf(c.normal);f[c.c].addSelf(c.normal);f[c.d].addSelf(c.normal)}}b=0;for(d=this.vertices.length;b<d;b++)f[b].normalize();b=0;for(d=this.faces.length;b<d;b++){c=this.faces[b];if(c instanceof THREE.Face3){c.vertexNormals[0].copy(f[c.a]);
-c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(f[c.a]);c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c]);c.vertexNormals[3].copy(f[c.d])}}},computeTangents:function(){function b($,pa,Da,ga,Y,la,Ga){k=$.vertices[pa].position;n=$.vertices[Da].position;p=$.vertices[ga].position;o=j[Y];u=j[la];y=j[Ga];v=n.x-k.x;B=p.x-k.x;C=n.y-k.y;F=p.y-k.y;H=n.z-k.z;U=p.z-k.z;z=u.u-o.u;J=y.u-o.u;L=u.v-o.v;M=y.v-o.v;Fa=1/(z*M-J*L);
-e.set((M*v-L*B)*Fa,(M*C-L*F)*Fa,(M*H-L*U)*Fa);da.set((z*B-J*v)*Fa,(z*F-J*C)*Fa,(z*U-J*H)*Fa);xa[pa].addSelf(e);xa[Da].addSelf(e);xa[ga].addSelf(e);Z[pa].addSelf(da);Z[Da].addSelf(da);Z[ga].addSelf(da)}var d,c,f,g,h,j,k,n,p,o,u,y,v,B,C,F,H,U,z,J,L,M,Fa,oa,xa=[],Z=[],e=new THREE.Vector3,da=new THREE.Vector3,Ca=new THREE.Vector3,Aa=new THREE.Vector3,Ha=new THREE.Vector3;d=0;for(c=this.vertices.length;d<c;d++){xa[d]=new THREE.Vector3;Z[d]=new THREE.Vector3}d=0;for(c=this.faces.length;d<c;d++){h=this.faces[d];
-j=this.faceVertexUvs[0][d];if(h instanceof THREE.Face3)b(this,h.a,h.b,h.c,0,1,2);else if(h instanceof THREE.Face4){b(this,h.a,h.b,h.c,0,1,2);b(this,h.a,h.b,h.d,0,1,3)}}var qa=["a","b","c","d"];d=0;for(c=this.faces.length;d<c;d++){h=this.faces[d];for(f=0;f<h.vertexNormals.length;f++){Ha.copy(h.vertexNormals[f]);g=h[qa[f]];oa=xa[g];Ca.copy(oa);Ca.subSelf(Ha.multiplyScalar(Ha.dot(oa))).normalize();Aa.cross(h.vertexNormals[f],oa);g=Aa.dot(Z[g]);g=g<0?-1:1;h.vertexTangents[f]=new THREE.Vector4(Ca.x,Ca.y,
-Ca.z,g)}}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,c=this.vertices.length;d<c;d++){b=this.vertices[d];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;
+c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c])}else if(c instanceof THREE.Face4){c.vertexNormals[0].copy(f[c.a]);c.vertexNormals[1].copy(f[c.b]);c.vertexNormals[2].copy(f[c.c]);c.vertexNormals[3].copy(f[c.d])}}},computeTangents:function(){function b(aa,pa,za,ia,Y,ma,Da){k=aa.vertices[pa].position;n=aa.vertices[za].position;p=aa.vertices[ia].position;o=j[Y];u=j[ma];y=j[Da];w=n.x-k.x;A=p.x-k.x;E=n.y-k.y;G=p.y-k.y;L=n.z-k.z;V=p.z-k.z;z=u.u-o.u;N=y.u-o.u;Q=u.v-o.v;S=y.v-o.v;xa=1/(z*S-
+N*Q);fa.set((S*w-Q*A)*xa,(S*E-Q*G)*xa,(S*L-Q*V)*xa);da.set((z*A-N*w)*xa,(z*G-N*E)*xa,(z*V-N*L)*xa);qa[pa].addSelf(fa);qa[za].addSelf(fa);qa[ia].addSelf(fa);e[pa].addSelf(da);e[za].addSelf(da);e[ia].addSelf(da)}var d,c,f,g,h,j,k,n,p,o,u,y,w,A,E,G,L,V,z,N,Q,S,xa,sa,qa=[],e=[],fa=new THREE.Vector3,da=new THREE.Vector3,ya=new THREE.Vector3,Fa=new THREE.Vector3,Ga=new THREE.Vector3;d=0;for(c=this.vertices.length;d<c;d++){qa[d]=new THREE.Vector3;e[d]=new THREE.Vector3}d=0;for(c=this.faces.length;d<c;d++){h=
+this.faces[d];j=this.faceVertexUvs[0][d];if(h instanceof THREE.Face3)b(this,h.a,h.b,h.c,0,1,2);else if(h instanceof THREE.Face4){b(this,h.a,h.b,h.c,0,1,2);b(this,h.a,h.b,h.d,0,1,3)}}var ra=["a","b","c","d"];d=0;for(c=this.faces.length;d<c;d++){h=this.faces[d];for(f=0;f<h.vertexNormals.length;f++){Ga.copy(h.vertexNormals[f]);g=h[ra[f]];sa=qa[g];ya.copy(sa);ya.subSelf(Ga.multiplyScalar(Ga.dot(sa))).normalize();Fa.cross(h.vertexNormals[f],sa);g=Fa.dot(e[g]);g=g<0?-1:1;h.vertexTangents[f]=new THREE.Vector4(ya.x,
+ya.y,ya.z,g)}}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,c=this.vertices.length;d<c;d++){b=this.vertices[d];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;
 if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,d=0,c=this.vertices.length;d<c;d++)b=Math.max(b,this.vertices[d].position.length());this.boundingSphere=
 {radius:b}}};THREE.GeometryIdCounter=0;
-THREE.Spline=function(b){function d(v,B,C,F,H,U,z){v=(C-v)*0.5;F=(F-B)*0.5;return(2*(B-C)+v+F)*z+(-3*(B-C)-2*v-F)*U+v*H+B}this.points=b;var c=[],f={x:0,y:0,z:0},g,h,j,k,n,p,o,u,y;this.initFromArray=function(v){this.points=[];for(var B=0;B<v.length;B++)this.points[B]={x:v[B][0],y:v[B][1],z:v[B][2]}};this.getPoint=function(v){g=(this.points.length-1)*v;h=Math.floor(g);j=g-h;c[0]=h==0?h:h-1;c[1]=h;c[2]=h>this.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;p=this.points[c[0]];o=this.points[c[1]];
-u=this.points[c[2]];y=this.points[c[3]];k=j*j;n=j*k;f.x=d(p.x,o.x,u.x,y.x,j,k,n);f.y=d(p.y,o.y,u.y,y.y,j,k,n);f.z=d(p.z,o.z,u.z,y.z,j,k,n);return f};this.getControlPointsArray=function(){var v,B,C=this.points.length,F=[];for(v=0;v<C;v++){B=this.points[v];F[v]=[B.x,B.y,B.z]}return F};this.getLength=function(v){var B,C,F=B=B=0,H=new THREE.Vector3,U=new THREE.Vector3,z=[],J=0;z[0]=0;v||(v=100);C=this.points.length*v;H.copy(this.points[0]);for(v=1;v<C;v++){B=v/C;position=this.getPoint(B);U.copy(position);
-J+=U.distanceTo(H);H.copy(position);B*=this.points.length-1;B=Math.floor(B);if(B!=F){z[B]=J;F=B}}z[z.length]=J;return{chunks:z,total:J}};this.reparametrizeByArcLength=function(v){var B,C,F,H,U,z,J=[],L=new THREE.Vector3,M=this.getLength();J.push(L.copy(this.points[0]).clone());for(B=1;B<this.points.length;B++){C=M.chunks[B]-M.chunks[B-1];z=Math.ceil(v*C/M.total);H=(B-1)/(this.points.length-1);U=B/(this.points.length-1);for(C=1;C<z-1;C++){F=H+C*(1/z)*(U-H);position=this.getPoint(F);J.push(L.copy(position).clone())}J.push(L.copy(this.points[B]).clone())}this.points=
-J}};
+THREE.Spline=function(b){function d(w,A,E,G,L,V,z){w=(E-w)*0.5;G=(G-A)*0.5;return(2*(A-E)+w+G)*z+(-3*(A-E)-2*w-G)*V+w*L+A}this.points=b;var c=[],f={x:0,y:0,z:0},g,h,j,k,n,p,o,u,y;this.initFromArray=function(w){this.points=[];for(var A=0;A<w.length;A++)this.points[A]={x:w[A][0],y:w[A][1],z:w[A][2]}};this.getPoint=function(w){g=(this.points.length-1)*w;h=Math.floor(g);j=g-h;c[0]=h==0?h:h-1;c[1]=h;c[2]=h>this.points.length-2?h:h+1;c[3]=h>this.points.length-3?h:h+2;p=this.points[c[0]];o=this.points[c[1]];
+u=this.points[c[2]];y=this.points[c[3]];k=j*j;n=j*k;f.x=d(p.x,o.x,u.x,y.x,j,k,n);f.y=d(p.y,o.y,u.y,y.y,j,k,n);f.z=d(p.z,o.z,u.z,y.z,j,k,n);return f};this.getControlPointsArray=function(){var w,A,E=this.points.length,G=[];for(w=0;w<E;w++){A=this.points[w];G[w]=[A.x,A.y,A.z]}return G};this.getLength=function(w){var A,E,G=A=A=0,L=new THREE.Vector3,V=new THREE.Vector3,z=[],N=0;z[0]=0;w||(w=100);E=this.points.length*w;L.copy(this.points[0]);for(w=1;w<E;w++){A=w/E;position=this.getPoint(A);V.copy(position);
+N+=V.distanceTo(L);L.copy(position);A*=this.points.length-1;A=Math.floor(A);if(A!=G){z[A]=N;G=A}}z[z.length]=N;return{chunks:z,total:N}};this.reparametrizeByArcLength=function(w){var A,E,G,L,V,z,N=[],Q=new THREE.Vector3,S=this.getLength();N.push(Q.copy(this.points[0]).clone());for(A=1;A<this.points.length;A++){E=S.chunks[A]-S.chunks[A-1];z=Math.ceil(w*E/S.total);L=(A-1)/(this.points.length-1);V=A/(this.points.length-1);for(E=1;E<z-1;E++){G=L+E*(1/z)*(V-L);position=this.getPoint(G);N.push(Q.copy(position).clone())}N.push(Q.copy(this.points[A]).clone())}this.points=
+N}};
 THREE.AnimationHandler=function(){var b=[],d={},c={};c.update=function(g){for(var h=0;h<b.length;h++)b[h].update(g)};c.addToUpdate=function(g){b.indexOf(g)===-1&&b.push(g)};c.removeFromUpdate=function(g){g=b.indexOf(g);g!==-1&&b.splice(g,1)};c.add=function(g){d[g.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+g.name+" already exists in library. Overwriting.");d[g.name]=g;if(g.initialized!==!0){for(var h=0;h<g.hierarchy.length;h++){for(var j=0;j<g.hierarchy[h].keys.length;j++){if(g.hierarchy[h].keys[j].time<0)g.hierarchy[h].keys[j].time=
 0;if(g.hierarchy[h].keys[j].rot!==undefined&&!(g.hierarchy[h].keys[j].rot instanceof THREE.Quaternion)){var k=g.hierarchy[h].keys[j].rot;g.hierarchy[h].keys[j].rot=new THREE.Quaternion(k[0],k[1],k[2],k[3])}}if(g.hierarchy[h].keys[0].morphTargets!==undefined){k={};for(j=0;j<g.hierarchy[h].keys.length;j++)for(var n=0;n<g.hierarchy[h].keys[j].morphTargets.length;n++){var p=g.hierarchy[h].keys[j].morphTargets[n];k[p]=-1}g.hierarchy[h].usedMorphTargets=k;for(j=0;j<g.hierarchy[h].keys.length;j++){var o=
 {};for(p in k){for(n=0;n<g.hierarchy[h].keys[j].morphTargets.length;n++)if(g.hierarchy[h].keys[j].morphTargets[n]===p){o[p]=g.hierarchy[h].keys[j].morphTargetsInfluences[n];break}n===g.hierarchy[h].keys[j].morphTargets.length&&(o[p]=0)}g.hierarchy[h].keys[j].morphTargetsInfluences=o}}for(j=1;j<g.hierarchy[h].keys.length;j++)if(g.hierarchy[h].keys[j].time===g.hierarchy[h].keys[j-1].time){g.hierarchy[h].keys.splice(j,1);j--}for(j=1;j<g.hierarchy[h].keys.length;j++)g.hierarchy[h].keys[j].index=j}j=parseInt(g.length*
@@ -75,11 +75,11 @@ THREE.Animation.prototype.play=function(b,d){if(!this.isPlaying){this.isPlaying=
 g instanceof THREE.Bone?g.skinMatrix:g.matrix}var h=g.animationCache.prevKey;g=g.animationCache.nextKey;h.pos=this.data.hierarchy[c].keys[0];h.rot=this.data.hierarchy[c].keys[0];h.scl=this.data.hierarchy[c].keys[0];g.pos=this.getNextKeyWith("pos",c,1);g.rot=this.getNextKeyWith("rot",c,1);g.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var b=0;b<this.hierarchy.length;b++)if(this.hierarchy[b].animationCache!==undefined){if(this.hierarchy[b]instanceof THREE.Bone)this.hierarchy[b].skinMatrix=this.hierarchy[b].animationCache.originalMatrix;else this.hierarchy[b].matrix=this.hierarchy[b].animationCache.originalMatrix;delete this.hierarchy[b].animationCache}};
-THREE.Animation.prototype.update=function(b){if(this.isPlaying){var d=["pos","rot","scl"],c,f,g,h,j,k,n,p,o=this.data.JIT.hierarchy,u,y;this.currentTime+=b*this.timeScale;y=this.currentTime;u=this.currentTime%=this.data.length;p=parseInt(Math.min(u*this.data.fps,this.data.length*this.data.fps),10);for(var v=0,B=this.hierarchy.length;v<B;v++){b=this.hierarchy[v];n=b.animationCache;if(this.JITCompile&&o[v][p]!==undefined)if(b instanceof THREE.Bone){b.skinMatrix=o[v][p];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=
-!1}else{b.matrix=o[v][p];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(b instanceof THREE.Bone)b.skinMatrix=b.animationCache.originalMatrix;else b.matrix=b.animationCache.originalMatrix;for(var C=0;C<3;C++){c=d[C];j=n.prevKey[c];k=n.nextKey[c];if(k.time<=y){if(u<y)if(this.loop){j=this.data.hierarchy[v].keys[0];for(k=this.getNextKeyWith(c,v,1);k.time<u;){j=k;k=this.getNextKeyWith(c,v,k.index+1)}}else{this.stop();return}else{do{j=k;k=this.getNextKeyWith(c,v,k.index+1)}while(k.time<
-u)}n.prevKey[c]=j;n.nextKey[c]=k}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(u-j.time)/(k.time-j.time);g=j[c];h=k[c];if(f<0||f>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+v);f=f<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
-this.getPrevKeyWith("pos",v,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",v,k.index+1).pos;f=f*0.33+0.33;g=this.interpolateCatmullRom(this.points,f);c.x=g[0];c.y=g[1];c.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){f=this.interpolateCatmullRom(this.points,f*1.01);this.target.set(f[0],f[1],f[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();f=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,f,0)}}}else if(c===
-"rot")THREE.Quaternion.slerp(g,h,b.quaternion,f);else if(c==="scl"){c=b.scale;c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}}}}if(this.JITCompile&&o[0][p]===undefined){this.hierarchy[0].update(undefined,!0);for(v=0;v<this.hierarchy.length;v++)o[v][p]=this.hierarchy[v]instanceof THREE.Bone?this.hierarchy[v].skinMatrix.clone():this.hierarchy[v].matrix.clone()}}};
+THREE.Animation.prototype.update=function(b){if(this.isPlaying){var d=["pos","rot","scl"],c,f,g,h,j,k,n,p,o=this.data.JIT.hierarchy,u,y;this.currentTime+=b*this.timeScale;y=this.currentTime;u=this.currentTime%=this.data.length;p=parseInt(Math.min(u*this.data.fps,this.data.length*this.data.fps),10);for(var w=0,A=this.hierarchy.length;w<A;w++){b=this.hierarchy[w];n=b.animationCache;if(this.JITCompile&&o[w][p]!==undefined)if(b instanceof THREE.Bone){b.skinMatrix=o[w][p];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=
+!1}else{b.matrix=o[w][p];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(b instanceof THREE.Bone)b.skinMatrix=b.animationCache.originalMatrix;else b.matrix=b.animationCache.originalMatrix;for(var E=0;E<3;E++){c=d[E];j=n.prevKey[c];k=n.nextKey[c];if(k.time<=y){if(u<y)if(this.loop){j=this.data.hierarchy[w].keys[0];for(k=this.getNextKeyWith(c,w,1);k.time<u;){j=k;k=this.getNextKeyWith(c,w,k.index+1)}}else{this.stop();return}else{do{j=k;k=this.getNextKeyWith(c,w,k.index+1)}while(k.time<
+u)}n.prevKey[c]=j;n.nextKey[c]=k}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;f=(u-j.time)/(k.time-j.time);g=j[c];h=k[c];if(f<0||f>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+f+" on bone "+w);f=f<0?0:1}if(c==="pos"){c=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
+this.getPrevKeyWith("pos",w,j.index-1).pos;this.points[1]=g;this.points[2]=h;this.points[3]=this.getNextKeyWith("pos",w,k.index+1).pos;f=f*0.33+0.33;g=this.interpolateCatmullRom(this.points,f);c.x=g[0];c.y=g[1];c.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){f=this.interpolateCatmullRom(this.points,f*1.01);this.target.set(f[0],f[1],f[2]);this.target.subSelf(c);this.target.y=0;this.target.normalize();f=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,f,0)}}}else if(c===
+"rot")THREE.Quaternion.slerp(g,h,b.quaternion,f);else if(c==="scl"){c=b.scale;c.x=g[0]+(h[0]-g[0])*f;c.y=g[1]+(h[1]-g[1])*f;c.z=g[2]+(h[2]-g[2])*f}}}}if(this.JITCompile&&o[0][p]===undefined){this.hierarchy[0].update(undefined,!0);for(w=0;w<this.hierarchy.length;w++)o[w][p]=this.hierarchy[w]instanceof THREE.Bone?this.hierarchy[w].skinMatrix.clone():this.hierarchy[w].matrix.clone()}}};
 THREE.Animation.prototype.interpolateCatmullRom=function(b,d){var c=[],f=[],g,h,j,k,n,p;g=(b.length-1)*d;h=Math.floor(g);g-=h;c[0]=h==0?h:h-1;c[1]=h;c[2]=h>b.length-2?h:h+1;c[3]=h>b.length-3?h:h+2;h=b[c[0]];k=b[c[1]];n=b[c[2]];p=b[c[3]];c=g*g;j=g*c;f[0]=this.interpolate(h[0],k[0],n[0],p[0],g,c,j);f[1]=this.interpolate(h[1],k[1],n[1],p[1],g,c,j);f[2]=this.interpolate(h[2],k[2],n[2],p[2],g,c,j);return f};
 THREE.Animation.prototype.interpolate=function(b,d,c,f,g,h,j){b=(c-b)*0.5;f=(f-d)*0.5;return(2*(d-c)+b+f)*j+(-3*(d-c)-2*b-f)*h+b*g+d};THREE.Animation.prototype.getNextKeyWith=function(b,d,c){var f=this.data.hierarchy[d].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)c=c<f.length-1?c:f.length-1;else c%=f.length;for(;c<f.length;c++)if(f[c][b]!==undefined)return f[c];return this.data.hierarchy[d].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(b,d,c){var f=this.data.hierarchy[d].keys;for(c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c>0?c:0:c>=0?c:c+f.length;c>=0;c--)if(f[c][b]!==undefined)return f[c];return this.data.hierarchy[d].keys[f.length-1]};
@@ -140,63 +140,63 @@ THREE.LOD.prototype.update=function(b,d,c){this.matrixAutoUpdate&&(d|=this.updat
 THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
 THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var d=this.geometry.vertices,c=this.geometry.faces,f=this.geometry.edgeFaces,g=b.faces;b=b.vertices;var h=g.length,j,k,n,p,o,u=["a","b","c","d"];for(n=0;n<h;n++){k=d.length;j=g[n];if(j instanceof THREE.Face4){p=4;k=new THREE.Face4(k,k+1,k+2,k+3)}else{p=3;k=new THREE.Face3(k,k+1,k+2)}k.normal.copy(j.normal);c.push(k);for(k=
 0;k<p;k++){o=b[j[u[k]]];d.push(new THREE.Vertex(o.position.clone()))}}for(h=0;h<g.length-1;h++){b=c[h];for(j=h+1;j<g.length;j++){k=c[j];k=this.facesShareEdge(d,b,k);if(k!==undefined){k=new THREE.Face4(k.indices[0],k.indices[3],k.indices[2],k.indices[1]);k.normal.set(1,0,0);f.push(k)}}}};
-THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,c){var f,g,h,j,k,n,p,o,u,y,v,B,C,F=0,H=["a","b","c","d"];f=d instanceof THREE.Face4?4:3;g=c instanceof THREE.Face4?4:3;for(B=0;B<f;B++){h=d[H[B]];k=b[h];for(C=0;C<g;C++){j=c[H[C]];n=b[j];if(Math.abs(k.position.x-n.position.x)<1.0E-4&&Math.abs(k.position.y-n.position.y)<1.0E-4&&Math.abs(k.position.z-n.position.z)<1.0E-4){F++;if(F===1){p=k;o=n;u=h;y=j;v=H[B]}if(F===2){v+=H[B];return v==="ad"||v==="ac"?{faces:[d,c],vertices:[p,o,n,k],indices:[u,
+THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,c){var f,g,h,j,k,n,p,o,u,y,w,A,E,G=0,L=["a","b","c","d"];f=d instanceof THREE.Face4?4:3;g=c instanceof THREE.Face4?4:3;for(A=0;A<f;A++){h=d[L[A]];k=b[h];for(E=0;E<g;E++){j=c[L[E]];n=b[j];if(Math.abs(k.position.x-n.position.x)<1.0E-4&&Math.abs(k.position.y-n.position.y)<1.0E-4&&Math.abs(k.position.z-n.position.z)<1.0E-4){G++;if(G===1){p=k;o=n;u=h;y=j;w=L[A]}if(G===2){w+=L[A];return w==="ad"||w==="ac"?{faces:[d,c],vertices:[p,o,n,k],indices:[u,
 y,j,h],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[d,c],vertices:[p,k,n,o],indices:[u,h,j,y],vertexTypes:[1,1,2,2],extrudable:!0}}}}}};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;
 THREE.Scene.prototype.addChild=function(b){this.supr.addChild.call(this,b);this.addChildRecurse(b)};THREE.Scene.prototype.addChildRecurse=function(b){if(b instanceof THREE.Light)this.lights.indexOf(b)===-1&&this.lights.push(b);else if(b instanceof THREE.Sound)this.sounds.indexOf(b)===-1&&this.sounds.push(b);else if(!(b instanceof THREE.Camera||b instanceof THREE.Bone)&&this.objects.indexOf(b)===-1){this.objects.push(b);this.__objectsAdded.push(b)}for(var d=0;d<b.children.length;d++)this.addChildRecurse(b.children[d])};
 THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var d=this.lights.indexOf(b);d!==-1&&this.lights.splice(d,1)}else if(b instanceof THREE.Sound){d=this.sounds.indexOf(b);d!==-1&&this.sounds.splice(d,1)}else if(!(b instanceof THREE.Camera)){d=this.objects.indexOf(b);if(d!==-1){this.objects.splice(d,1);this.__objectsRemoved.push(b)}}for(d=0;d<b.children.length;d++)this.removeChildRecurse(b.children[d])};
 THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(b,d,c){this.color=new THREE.Color(b);this.near=d||1;this.far=c||1E3};THREE.FogExp2=function(b,d){this.color=new THREE.Color(b);this.density=d!==undefined?d:2.5E-4};
-THREE.Projector=function(){function b(){var e=n[k]=n[k]||new THREE.RenderableVertex;k++;return e}function d(e,da){return da.z-e.z}function c(e,da){var Ca=0,Aa=1,Ha=e.z+e.w,qa=da.z+da.w,$=-e.z+e.w,pa=-da.z+da.w;if(Ha>=0&&qa>=0&&$>=0&&pa>=0)return!0;else if(Ha<0&&qa<0||$<0&&pa<0)return!1;else{if(Ha<0)Ca=Math.max(Ca,Ha/(Ha-qa));else qa<0&&(Aa=Math.min(Aa,Ha/(Ha-qa)));if($<0)Ca=Math.max(Ca,$/($-pa));else pa<0&&(Aa=Math.min(Aa,$/($-pa)));if(Aa<Ca)return!1;else{e.lerpSelf(da,Ca);da.lerpSelf(e,1-Aa);return!0}}}
-var f,g,h=[],j,k,n=[],p,o,u=[],y,v=[],B,C,F=[],H,U,z=[],J=new THREE.Vector4,L=new THREE.Vector4,M=new THREE.Matrix4,Fa=new THREE.Matrix4,oa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],xa=new THREE.Vector4,Z=new THREE.Vector4;this.projectVector=function(e,da){M.multiply(da.projectionMatrix,da.matrixWorldInverse);M.multiplyVector3(e);return e};this.unprojectVector=function(e,da){M.multiply(da.matrixWorld,THREE.Matrix4.makeInvert(da.projectionMatrix));
-M.multiplyVector3(e);return e};this.projectObjects=function(e,da,Ca){da=[];var Aa,Ha,qa;g=0;Ha=e.objects;e=0;for(Aa=Ha.length;e<Aa;e++){qa=Ha[e];var $;if(!($=!qa.visible))if($=qa instanceof THREE.Mesh){a:{$=void 0;for(var pa=qa.matrixWorld,Da=-qa.geometry.boundingSphere.radius*Math.max(qa.scale.x,Math.max(qa.scale.y,qa.scale.z)),ga=0;ga<6;ga++){$=oa[ga].x*pa.n14+oa[ga].y*pa.n24+oa[ga].z*pa.n34+oa[ga].w;if($<=Da){$=!1;break a}}$=!0}$=!$}if(!$){$=h[g]=h[g]||new THREE.RenderableObject;g++;f=$;J.copy(qa.position);
-M.multiplyVector3(J);f.object=qa;f.z=J.z;da.push(f)}}Ca&&da.sort(d);return da};this.projectScene=function(e,da,Ca){var Aa=[],Ha=da.near,qa=da.far,$,pa,Da,ga,Y,la,Ga,ka,na,wa,Ua,cb,ab,Pa,N,X,ma;U=C=y=o=0;da.matrixAutoUpdate&&da.updateMatrix();e.update(undefined,!1,da);M.multiply(da.projectionMatrix,da.matrixWorldInverse);oa[0].set(M.n41-M.n11,M.n42-M.n12,M.n43-M.n13,M.n44-M.n14);oa[1].set(M.n41+M.n11,M.n42+M.n12,M.n43+M.n13,M.n44+M.n14);oa[2].set(M.n41+M.n21,M.n42+M.n22,M.n43+M.n23,M.n44+M.n24);oa[3].set(M.n41-
-M.n21,M.n42-M.n22,M.n43-M.n23,M.n44-M.n24);oa[4].set(M.n41-M.n31,M.n42-M.n32,M.n43-M.n33,M.n44-M.n34);oa[5].set(M.n41+M.n31,M.n42+M.n32,M.n43+M.n33,M.n44+M.n34);for($=0;$<6;$++){na=oa[$];na.divideScalar(Math.sqrt(na.x*na.x+na.y*na.y+na.z*na.z))}na=this.projectObjects(e,da,!0);e=0;for($=na.length;e<$;e++){wa=na[e].object;if(wa.visible){Ua=wa.matrixWorld;cb=wa.matrixRotationWorld;ab=wa.materials;Pa=wa.overdraw;k=0;if(wa instanceof THREE.Mesh){N=wa.geometry;ga=N.vertices;X=N.faces;N=N.faceVertexUvs;
-pa=0;for(Da=ga.length;pa<Da;pa++){j=b();j.positionWorld.copy(ga[pa].position);Ua.multiplyVector3(j.positionWorld);j.positionScreen.copy(j.positionWorld);M.multiplyVector4(j.positionScreen);j.positionScreen.x/=j.positionScreen.w;j.positionScreen.y/=j.positionScreen.w;j.visible=j.positionScreen.z>Ha&&j.positionScreen.z<qa}ga=0;for(pa=X.length;ga<pa;ga++){Da=X[ga];if(Da instanceof THREE.Face3){Y=n[Da.a];la=n[Da.b];Ga=n[Da.c];if(Y.visible&&la.visible&&Ga.visible&&(wa.doubleSided||wa.flipSided!=(Ga.positionScreen.x-
-Y.positionScreen.x)*(la.positionScreen.y-Y.positionScreen.y)-(Ga.positionScreen.y-Y.positionScreen.y)*(la.positionScreen.x-Y.positionScreen.x)<0)){ka=u[o]=u[o]||new THREE.RenderableFace3;o++;p=ka;p.v1.copy(Y);p.v2.copy(la);p.v3.copy(Ga)}else continue}else if(Da instanceof THREE.Face4){Y=n[Da.a];la=n[Da.b];Ga=n[Da.c];ka=n[Da.d];if(Y.visible&&la.visible&&Ga.visible&&ka.visible&&(wa.doubleSided||wa.flipSided!=((ka.positionScreen.x-Y.positionScreen.x)*(la.positionScreen.y-Y.positionScreen.y)-(ka.positionScreen.y-
-Y.positionScreen.y)*(la.positionScreen.x-Y.positionScreen.x)<0||(la.positionScreen.x-Ga.positionScreen.x)*(ka.positionScreen.y-Ga.positionScreen.y)-(la.positionScreen.y-Ga.positionScreen.y)*(ka.positionScreen.x-Ga.positionScreen.x)<0))){ma=v[y]=v[y]||new THREE.RenderableFace4;y++;p=ma;p.v1.copy(Y);p.v2.copy(la);p.v3.copy(Ga);p.v4.copy(ka)}else continue}p.normalWorld.copy(Da.normal);cb.multiplyVector3(p.normalWorld);p.centroidWorld.copy(Da.centroid);Ua.multiplyVector3(p.centroidWorld);p.centroidScreen.copy(p.centroidWorld);
-M.multiplyVector3(p.centroidScreen);Ga=Da.vertexNormals;Y=0;for(la=Ga.length;Y<la;Y++){ka=p.vertexNormalsWorld[Y];ka.copy(Ga[Y]);cb.multiplyVector3(ka)}Y=0;for(la=N.length;Y<la;Y++)if(ma=N[Y][ga]){Ga=0;for(ka=ma.length;Ga<ka;Ga++)p.uvs[Y][Ga]=ma[Ga]}p.meshMaterials=ab;p.faceMaterials=Da.materials;p.overdraw=Pa;p.z=p.centroidScreen.z;Aa.push(p)}}else if(wa instanceof THREE.Line){Fa.multiply(M,Ua);ga=wa.geometry.vertices;Y=b();Y.positionScreen.copy(ga[0].position);Fa.multiplyVector4(Y.positionScreen);
-pa=1;for(Da=ga.length;pa<Da;pa++){Y=b();Y.positionScreen.copy(ga[pa].position);Fa.multiplyVector4(Y.positionScreen);la=n[k-2];xa.copy(Y.positionScreen);Z.copy(la.positionScreen);if(c(xa,Z)){xa.multiplyScalar(1/xa.w);Z.multiplyScalar(1/Z.w);Ua=F[C]=F[C]||new THREE.RenderableLine;C++;B=Ua;B.v1.positionScreen.copy(xa);B.v2.positionScreen.copy(Z);B.z=Math.max(xa.z,Z.z);B.materials=wa.materials;Aa.push(B)}}}else if(wa instanceof THREE.Particle){L.set(wa.position.x,wa.position.y,wa.position.z,1);M.multiplyVector4(L);
-L.z/=L.w;if(L.z>0&&L.z<1){Ua=z[U]=z[U]||new THREE.RenderableParticle;U++;H=Ua;H.x=L.x/L.w;H.y=L.y/L.w;H.z=L.z;H.rotation=wa.rotation.z;H.scale.x=wa.scale.x*Math.abs(H.x-(L.x+da.projectionMatrix.n11)/(L.w+da.projectionMatrix.n14));H.scale.y=wa.scale.y*Math.abs(H.y-(L.y+da.projectionMatrix.n22)/(L.w+da.projectionMatrix.n24));H.materials=wa.materials;Aa.push(H)}}}}Ca&&Aa.sort(d);return Aa}};
-THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,d=new THREE.Projector,c,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,k){c=j;f=k;g=c/2;h=f/2};this.render=function(j,k){var n,p,o,u,y,v,B,C;b=d.projectScene(j,k);n=0;for(p=b.length;n<p;n++){y=b[n];if(y instanceof THREE.RenderableParticle){B=y.x*g+g;C=y.y*h+h;o=0;for(u=y.material.length;o<u;o++){v=y.material[o];if(v instanceof THREE.ParticleDOMMaterial){v=v.domElement;v.style.left=B+"px";v.style.top=C+"px"}}}}}};
-THREE.CanvasRenderer=function(){function b(ra){if(v!=ra)o.globalAlpha=v=ra}function d(ra){if(B!=ra){switch(ra){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}B=ra}}function c(ra){if(C!=ra)o.strokeStyle=C=ra}var f=null,g=new THREE.Projector,h=document.createElement("canvas"),j,k,n,p,o=h.getContext("2d"),u=new THREE.Color(0),y=0,v=1,B=0,
-C=null,F=null,H=null,U=null,z=null,J,L,M,Fa,oa=new THREE.RenderableVertex,xa=new THREE.RenderableVertex,Z,e,da,Ca,Aa,Ha,qa,$,pa,Da,ga,Y,la=new THREE.Color,Ga=new THREE.Color,ka=new THREE.Color,na=new THREE.Color,wa=new THREE.Color,Ua,cb,ab,Pa,N,X,ma,Ea,Ka,ya,ia=new THREE.Rectangle,m=new THREE.Rectangle,A=new THREE.Rectangle,x=!1,t=new THREE.Color,w=new THREE.Color,S=new THREE.Color,E=new THREE.Color,G=new THREE.Vector3,O,D,I,Q,sa,W,Ba=16;O=document.createElement("canvas");O.width=O.height=2;D=O.getContext("2d");
-D.fillStyle="rgba(0,0,0,1)";D.fillRect(0,0,2,2);I=D.getImageData(0,0,2,2);Q=I.data;sa=document.createElement("canvas");sa.width=sa.height=Ba;W=sa.getContext("2d");W.translate(-Ba/2,-Ba/2);W.scale(Ba,Ba);Ba--;this.domElement=h;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(ra,za){j=ra;k=za;n=j/2;p=k/2;h.width=j;h.height=k;ia.set(-n,-p,n,p);v=1;B=0;z=U=H=F=C=null};this.setClearColor=function(ra,za){u=ra;y=za};this.setClearColorHex=function(ra,za){u.setHex(ra);y=za};
-this.clear=function(){o.setTransform(1,0,0,-1,n,p);if(!m.isEmpty()){m.inflate(1);m.minSelf(ia);if(u.hex==0&&y==0)o.clearRect(m.getX(),m.getY(),m.getWidth(),m.getHeight());else{d(THREE.NormalBlending);b(1);o.fillStyle="rgba("+Math.floor(u.r*255)+","+Math.floor(u.g*255)+","+Math.floor(u.b*255)+","+y+")";o.fillRect(m.getX(),m.getY(),m.getWidth(),m.getHeight())}m.empty()}};this.render=function(ra,za){function Ia(T){var ta,fa,aa,va=T.lights;w.setRGB(0,0,0);S.setRGB(0,0,0);E.setRGB(0,0,0);T=0;for(ta=va.length;T<
-ta;T++){fa=va[T];aa=fa.color;if(fa instanceof THREE.AmbientLight){w.r+=aa.r;w.g+=aa.g;w.b+=aa.b}else if(fa instanceof THREE.DirectionalLight){S.r+=aa.r;S.g+=aa.g;S.b+=aa.b}else if(fa instanceof THREE.PointLight){E.r+=aa.r;E.g+=aa.g;E.b+=aa.b}}}function Sa(T,ta,fa,aa){var va,ua,ha,K,Qa=T.lights;T=0;for(va=Qa.length;T<va;T++){ua=Qa[T];ha=ua.color;if(ua instanceof THREE.DirectionalLight){K=fa.dot(ua.position);if(!(K<=0)){K*=ua.intensity;aa.r+=ha.r*K;aa.g+=ha.g*K;aa.b+=ha.b*K}}else if(ua instanceof THREE.PointLight){K=
-fa.dot(G.sub(ua.position,ta).normalize());if(!(K<=0)){K*=ua.distance==0?1:1-Math.min(ta.distanceTo(ua.position)/ua.distance,1);if(K!=0){K*=ua.intensity;aa.r+=ha.r*K;aa.g+=ha.g*K;aa.b+=ha.b*K}}}}}function ea(T,ta,fa){b(fa.opacity);d(fa.blending);var aa,va,ua,ha,K,Qa;if(fa instanceof THREE.ParticleBasicMaterial){if(fa.map){ha=fa.map.image;K=ha.width>>1;Qa=ha.height>>1;fa=ta.scale.x*n;ua=ta.scale.y*p;aa=fa*K;va=ua*Qa;A.set(T.x-aa,T.y-va,T.x+aa,T.y+va);if(ia.instersects(A)){o.save();o.translate(T.x,T.y);
-o.rotate(-ta.rotation);o.scale(fa,-ua);o.translate(-K,-Qa);o.drawImage(ha,0,0);o.restore()}}}else if(fa instanceof THREE.ParticleCanvasMaterial){aa=ta.scale.x*n;va=ta.scale.y*p;A.set(T.x-aa,T.y-va,T.x+aa,T.y+va);if(ia.instersects(A)){c(fa.color.__styleString);ua=fa.color.__styleString;if(F!=ua)o.fillStyle=F=ua;o.save();o.translate(T.x,T.y);o.rotate(-ta.rotation);o.scale(aa,va);fa.program(o);o.restore()}}}function ca(T,ta,fa,aa){b(aa.opacity);d(aa.blending);o.beginPath();o.moveTo(T.positionScreen.x,
-T.positionScreen.y);o.lineTo(ta.positionScreen.x,ta.positionScreen.y);o.closePath();if(aa instanceof THREE.LineBasicMaterial){la.__styleString=aa.color.__styleString;T=aa.linewidth;if(H!=T)o.lineWidth=H=T;T=aa.linecap;if(U!=T)o.lineCap=U=T;T=aa.linejoin;if(z!=T)o.lineJoin=z=T;c(la.__styleString);o.stroke();A.inflate(aa.linewidth*2)}}function ja(T,ta,fa,aa,va,ua,ha,K,Qa){b(K.opacity);d(K.blending);Z=T.positionScreen.x;e=T.positionScreen.y;da=ta.positionScreen.x;Ca=ta.positionScreen.y;Aa=fa.positionScreen.x;
-Ha=fa.positionScreen.y;V(Z,e,da,Ca,Aa,Ha);if(K instanceof THREE.MeshBasicMaterial)if(K.map){if(K.map.mapping instanceof THREE.UVMapping){Pa=ha.uvs[0];Na(Z,e,da,Ca,Aa,Ha,K.map.image,Pa[aa].u,Pa[aa].v,Pa[va].u,Pa[va].v,Pa[ua].u,Pa[ua].v)}}else if(K.envMap){if(K.envMap.mapping instanceof THREE.SphericalReflectionMapping){T=za.matrixWorldInverse;G.copy(ha.vertexNormalsWorld[0]);N=(G.x*T.n11+G.y*T.n12+G.z*T.n13)*0.5+0.5;X=-(G.x*T.n21+G.y*T.n22+G.z*T.n23)*0.5+0.5;G.copy(ha.vertexNormalsWorld[1]);ma=(G.x*
-T.n11+G.y*T.n12+G.z*T.n13)*0.5+0.5;Ea=-(G.x*T.n21+G.y*T.n22+G.z*T.n23)*0.5+0.5;G.copy(ha.vertexNormalsWorld[2]);Ka=(G.x*T.n11+G.y*T.n12+G.z*T.n13)*0.5+0.5;ya=-(G.x*T.n21+G.y*T.n22+G.z*T.n23)*0.5+0.5;Na(Z,e,da,Ca,Aa,Ha,K.envMap.image,N,X,ma,Ea,Ka,ya)}}else K.wireframe?Oa(K.color.__styleString,K.wireframeLinewidth,K.wireframeLinecap,K.wireframeLinejoin):fb(K.color.__styleString);else if(K instanceof THREE.MeshLambertMaterial){if(K.map&&!K.wireframe){if(K.map.mapping instanceof THREE.UVMapping){Pa=ha.uvs[0];
-Na(Z,e,da,Ca,Aa,Ha,K.map.image,Pa[aa].u,Pa[aa].v,Pa[va].u,Pa[va].v,Pa[ua].u,Pa[ua].v)}d(THREE.SubtractiveBlending)}if(x)if(!K.wireframe&&K.shading==THREE.SmoothShading&&ha.vertexNormalsWorld.length==3){Ga.r=ka.r=na.r=w.r;Ga.g=ka.g=na.g=w.g;Ga.b=ka.b=na.b=w.b;Sa(Qa,ha.v1.positionWorld,ha.vertexNormalsWorld[0],Ga);Sa(Qa,ha.v2.positionWorld,ha.vertexNormalsWorld[1],ka);Sa(Qa,ha.v3.positionWorld,ha.vertexNormalsWorld[2],na);wa.r=(ka.r+na.r)*0.5;wa.g=(ka.g+na.g)*0.5;wa.b=(ka.b+na.b)*0.5;ab=Xa(Ga,ka,na,
-wa);Na(Z,e,da,Ca,Aa,Ha,ab,0,0,1,0,0,1)}else{t.r=w.r;t.g=w.g;t.b=w.b;Sa(Qa,ha.centroidWorld,ha.normalWorld,t);la.r=K.color.r*t.r;la.g=K.color.g*t.g;la.b=K.color.b*t.b;la.updateStyleString();K.wireframe?Oa(la.__styleString,K.wireframeLinewidth,K.wireframeLinecap,K.wireframeLinejoin):fb(la.__styleString)}else K.wireframe?Oa(K.color.__styleString,K.wireframeLinewidth,K.wireframeLinecap,K.wireframeLinejoin):fb(K.color.__styleString)}else if(K instanceof THREE.MeshDepthMaterial){Ua=za.near;cb=za.far;Ga.r=
-Ga.g=Ga.b=1-gb(T.positionScreen.z,Ua,cb);ka.r=ka.g=ka.b=1-gb(ta.positionScreen.z,Ua,cb);na.r=na.g=na.b=1-gb(fa.positionScreen.z,Ua,cb);wa.r=(ka.r+na.r)*0.5;wa.g=(ka.g+na.g)*0.5;wa.b=(ka.b+na.b)*0.5;ab=Xa(Ga,ka,na,wa);Na(Z,e,da,Ca,Aa,Ha,ab,0,0,1,0,0,1)}else if(K instanceof THREE.MeshNormalMaterial){la.r=hb(ha.normalWorld.x);la.g=hb(ha.normalWorld.y);la.b=hb(ha.normalWorld.z);la.updateStyleString();K.wireframe?Oa(la.__styleString,K.wireframeLinewidth,K.wireframeLinecap,K.wireframeLinejoin):fb(la.__styleString)}}
-function La(T,ta,fa,aa,va,ua,ha,K,Qa){b(K.opacity);d(K.blending);if(K.map||K.envMap){ja(T,ta,aa,0,1,3,ha,K,Qa);ja(va,fa,ua,1,2,3,ha,K,Qa)}else{Z=T.positionScreen.x;e=T.positionScreen.y;da=ta.positionScreen.x;Ca=ta.positionScreen.y;Aa=fa.positionScreen.x;Ha=fa.positionScreen.y;qa=aa.positionScreen.x;$=aa.positionScreen.y;pa=va.positionScreen.x;Da=va.positionScreen.y;ga=ua.positionScreen.x;Y=ua.positionScreen.y;if(K instanceof THREE.MeshBasicMaterial){P(Z,e,da,Ca,Aa,Ha,qa,$);K.wireframe?Oa(K.color.__styleString,
-K.wireframeLinewidth,K.wireframeLinecap,K.wireframeLinejoin):fb(K.color.__styleString)}else if(K instanceof THREE.MeshLambertMaterial)if(x)if(!K.wireframe&&K.shading==THREE.SmoothShading&&ha.vertexNormalsWorld.length==4){Ga.r=ka.r=na.r=wa.r=w.r;Ga.g=ka.g=na.g=wa.g=w.g;Ga.b=ka.b=na.b=wa.b=w.b;Sa(Qa,ha.v1.positionWorld,ha.vertexNormalsWorld[0],Ga);Sa(Qa,ha.v2.positionWorld,ha.vertexNormalsWorld[1],ka);Sa(Qa,ha.v4.positionWorld,ha.vertexNormalsWorld[3],na);Sa(Qa,ha.v3.positionWorld,ha.vertexNormalsWorld[2],
-wa);ab=Xa(Ga,ka,na,wa);V(Z,e,da,Ca,qa,$);Na(Z,e,da,Ca,qa,$,ab,0,0,1,0,0,1);V(pa,Da,Aa,Ha,ga,Y);Na(pa,Da,Aa,Ha,ga,Y,ab,1,0,1,1,0,1)}else{t.r=w.r;t.g=w.g;t.b=w.b;Sa(Qa,ha.centroidWorld,ha.normalWorld,t);la.r=K.color.r*t.r;la.g=K.color.g*t.g;la.b=K.color.b*t.b;la.updateStyleString();P(Z,e,da,Ca,Aa,Ha,qa,$);K.wireframe?Oa(la.__styleString,K.wireframeLinewidth,K.wireframeLinecap,K.wireframeLinejoin):fb(la.__styleString)}else{P(Z,e,da,Ca,Aa,Ha,qa,$);K.wireframe?Oa(K.color.__styleString,K.wireframeLinewidth,
-K.wireframeLinecap,K.wireframeLinejoin):fb(K.color.__styleString)}else if(K instanceof THREE.MeshNormalMaterial){la.r=hb(ha.normalWorld.x);la.g=hb(ha.normalWorld.y);la.b=hb(ha.normalWorld.z);la.updateStyleString();P(Z,e,da,Ca,Aa,Ha,qa,$);K.wireframe?Oa(la.__styleString,K.wireframeLinewidth,K.wireframeLinecap,K.wireframeLinejoin):fb(la.__styleString)}else if(K instanceof THREE.MeshDepthMaterial){Ua=za.near;cb=za.far;Ga.r=Ga.g=Ga.b=1-gb(T.positionScreen.z,Ua,cb);ka.r=ka.g=ka.b=1-gb(ta.positionScreen.z,
-Ua,cb);na.r=na.g=na.b=1-gb(aa.positionScreen.z,Ua,cb);wa.r=wa.g=wa.b=1-gb(fa.positionScreen.z,Ua,cb);ab=Xa(Ga,ka,na,wa);V(Z,e,da,Ca,qa,$);Na(Z,e,da,Ca,qa,$,ab,0,0,1,0,0,1);V(pa,Da,Aa,Ha,ga,Y);Na(pa,Da,Aa,Ha,ga,Y,ab,1,0,1,1,0,1)}}}function V(T,ta,fa,aa,va,ua){o.beginPath();o.moveTo(T,ta);o.lineTo(fa,aa);o.lineTo(va,ua);o.lineTo(T,ta);o.closePath()}function P(T,ta,fa,aa,va,ua,ha,K){o.beginPath();o.moveTo(T,ta);o.lineTo(fa,aa);o.lineTo(va,ua);o.lineTo(ha,K);o.lineTo(T,ta);o.closePath()}function Oa(T,
-ta,fa,aa){if(H!=ta)o.lineWidth=H=ta;if(U!=fa)o.lineCap=U=fa;if(z!=aa)o.lineJoin=z=aa;c(T);o.stroke();A.inflate(ta*2)}function fb(T){if(F!=T)o.fillStyle=F=T;o.fill()}function Na(T,ta,fa,aa,va,ua,ha,K,Qa,db,Wa,bb,lb){var Ta,ib;Ta=ha.width-1;ib=ha.height-1;K*=Ta;Qa*=ib;db*=Ta;Wa*=ib;bb*=Ta;lb*=ib;fa-=T;aa-=ta;va-=T;ua-=ta;db-=K;Wa-=Qa;bb-=K;lb-=Qa;Ta=db*lb-bb*Wa;if(Ta!=0){ib=1/Ta;Ta=(lb*fa-Wa*va)*ib;Wa=(lb*aa-Wa*ua)*ib;fa=(db*va-bb*fa)*ib;aa=(db*ua-bb*aa)*ib;T=T-Ta*K-fa*Qa;ta=ta-Wa*K-aa*Qa;o.save();
-o.transform(Ta,Wa,fa,aa,T,ta);o.clip();o.drawImage(ha,0,0);o.restore()}}function Xa(T,ta,fa,aa){var va=~~(T.r*255),ua=~~(T.g*255);T=~~(T.b*255);var ha=~~(ta.r*255),K=~~(ta.g*255);ta=~~(ta.b*255);var Qa=~~(fa.r*255),db=~~(fa.g*255);fa=~~(fa.b*255);var Wa=~~(aa.r*255),bb=~~(aa.g*255);aa=~~(aa.b*255);Q[0]=va<0?0:va>255?255:va;Q[1]=ua<0?0:ua>255?255:ua;Q[2]=T<0?0:T>255?255:T;Q[4]=ha<0?0:ha>255?255:ha;Q[5]=K<0?0:K>255?255:K;Q[6]=ta<0?0:ta>255?255:ta;Q[8]=Qa<0?0:Qa>255?255:Qa;Q[9]=db<0?0:db>255?255:db;
-Q[10]=fa<0?0:fa>255?255:fa;Q[12]=Wa<0?0:Wa>255?255:Wa;Q[13]=bb<0?0:bb>255?255:bb;Q[14]=aa<0?0:aa>255?255:aa;D.putImageData(I,0,0);W.drawImage(O,0,0);return sa}function gb(T,ta,fa){T=(T-ta)/(fa-ta);return T*T*(3-2*T)}function hb(T){T=(T+1)*0.5;return T<0?0:T>1?1:T}function Ya(T,ta){var fa=ta.x-T.x,aa=ta.y-T.y,va=1/Math.sqrt(fa*fa+aa*aa);fa*=va;aa*=va;ta.x+=fa;ta.y+=aa;T.x-=fa;T.y-=aa}var eb,Ra,Ja,Ma,R,Va,Za,$a;this.autoClear?this.clear():o.setTransform(1,0,0,-1,n,p);f=g.projectScene(ra,za,this.sortElements);
-(x=ra.lights.length>0)&&Ia(ra);eb=0;for(Ra=f.length;eb<Ra;eb++){Ja=f[eb];A.empty();if(Ja instanceof THREE.RenderableParticle){J=Ja;J.x*=n;J.y*=p;Ma=0;for(R=Ja.materials.length;Ma<R;){$a=Ja.materials[Ma++];$a.opacity!=0&&ea(J,Ja,$a,ra)}}else if(Ja instanceof THREE.RenderableLine){J=Ja.v1;L=Ja.v2;J.positionScreen.x*=n;J.positionScreen.y*=p;L.positionScreen.x*=n;L.positionScreen.y*=p;A.addPoint(J.positionScreen.x,J.positionScreen.y);A.addPoint(L.positionScreen.x,L.positionScreen.y);if(ia.instersects(A)){Ma=
-0;for(R=Ja.materials.length;Ma<R;){$a=Ja.materials[Ma++];$a.opacity!=0&&ca(J,L,Ja,$a,ra)}}}else if(Ja instanceof THREE.RenderableFace3){J=Ja.v1;L=Ja.v2;M=Ja.v3;J.positionScreen.x*=n;J.positionScreen.y*=p;L.positionScreen.x*=n;L.positionScreen.y*=p;M.positionScreen.x*=n;M.positionScreen.y*=p;if(Ja.overdraw){Ya(J.positionScreen,L.positionScreen);Ya(L.positionScreen,M.positionScreen);Ya(M.positionScreen,J.positionScreen)}A.add3Points(J.positionScreen.x,J.positionScreen.y,L.positionScreen.x,L.positionScreen.y,
-M.positionScreen.x,M.positionScreen.y);if(ia.instersects(A)){Ma=0;for(R=Ja.meshMaterials.length;Ma<R;){$a=Ja.meshMaterials[Ma++];if($a instanceof THREE.MeshFaceMaterial){Va=0;for(Za=Ja.faceMaterials.length;Va<Za;)($a=Ja.faceMaterials[Va++])&&$a.opacity!=0&&ja(J,L,M,0,1,2,Ja,$a,ra)}else $a.opacity!=0&&ja(J,L,M,0,1,2,Ja,$a,ra)}}}else if(Ja instanceof THREE.RenderableFace4){J=Ja.v1;L=Ja.v2;M=Ja.v3;Fa=Ja.v4;J.positionScreen.x*=n;J.positionScreen.y*=p;L.positionScreen.x*=n;L.positionScreen.y*=p;M.positionScreen.x*=
-n;M.positionScreen.y*=p;Fa.positionScreen.x*=n;Fa.positionScreen.y*=p;oa.positionScreen.copy(L.positionScreen);xa.positionScreen.copy(Fa.positionScreen);if(Ja.overdraw){Ya(J.positionScreen,L.positionScreen);Ya(L.positionScreen,Fa.positionScreen);Ya(Fa.positionScreen,J.positionScreen);Ya(M.positionScreen,oa.positionScreen);Ya(M.positionScreen,xa.positionScreen)}A.addPoint(J.positionScreen.x,J.positionScreen.y);A.addPoint(L.positionScreen.x,L.positionScreen.y);A.addPoint(M.positionScreen.x,M.positionScreen.y);
-A.addPoint(Fa.positionScreen.x,Fa.positionScreen.y);if(ia.instersects(A)){Ma=0;for(R=Ja.meshMaterials.length;Ma<R;){$a=Ja.meshMaterials[Ma++];if($a instanceof THREE.MeshFaceMaterial){Va=0;for(Za=Ja.faceMaterials.length;Va<Za;)($a=Ja.faceMaterials[Va++])&&$a.opacity!=0&&La(J,L,M,Fa,oa,xa,Ja,$a,ra)}else $a.opacity!=0&&La(J,L,M,Fa,oa,xa,Ja,$a,ra)}}}m.addRectangle(A)}o.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function b(qa,$,pa){var Da,ga,Y,la;Da=0;for(ga=qa.lights.length;Da<ga;Da++){Y=qa.lights[Da];if(Y instanceof THREE.DirectionalLight){la=$.normalWorld.dot(Y.position)*Y.intensity;if(la>0){pa.r+=Y.color.r*la;pa.g+=Y.color.g*la;pa.b+=Y.color.b*la}}else if(Y instanceof THREE.PointLight){xa.sub(Y.position,$.centroidWorld);xa.normalize();la=$.normalWorld.dot(xa)*Y.intensity;if(la>0){pa.r+=Y.color.r*la;pa.g+=Y.color.g*la;pa.b+=Y.color.b*la}}}}function d(qa,$,pa,Da,ga,Y){da=f(Ca++);
-da.setAttribute("d","M "+qa.positionScreen.x+" "+qa.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+"z");if(ga instanceof THREE.MeshBasicMaterial)z.__styleString=ga.color.__styleString;else if(ga instanceof THREE.MeshLambertMaterial)if(U){J.r=L.r;J.g=L.g;J.b=L.b;b(Y,Da,J);z.r=ga.color.r*J.r;z.g=ga.color.g*J.g;z.b=ga.color.b*J.b;z.updateStyleString()}else z.__styleString=ga.color.__styleString;else if(ga instanceof THREE.MeshDepthMaterial){oa=
-1-ga.__2near/(ga.__farPlusNear-Da.z*ga.__farMinusNear);z.setRGB(oa,oa,oa)}else ga instanceof THREE.MeshNormalMaterial&&z.setRGB(g(Da.normalWorld.x),g(Da.normalWorld.y),g(Da.normalWorld.z));ga.wireframe?da.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+ga.wireframeLinewidth+"; stroke-opacity: "+ga.opacity+"; stroke-linecap: "+ga.wireframeLinecap+"; stroke-linejoin: "+ga.wireframeLinejoin):da.setAttribute("style","fill: "+z.__styleString+"; fill-opacity: "+ga.opacity);
-k.appendChild(da)}function c(qa,$,pa,Da,ga,Y,la){da=f(Ca++);da.setAttribute("d","M "+qa.positionScreen.x+" "+qa.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+" L "+Da.positionScreen.x+","+Da.positionScreen.y+"z");if(Y instanceof THREE.MeshBasicMaterial)z.__styleString=Y.color.__styleString;else if(Y instanceof THREE.MeshLambertMaterial)if(U){J.r=L.r;J.g=L.g;J.b=L.b;b(la,ga,J);z.r=Y.color.r*J.r;z.g=Y.color.g*J.g;z.b=Y.color.b*J.b;
-z.updateStyleString()}else z.__styleString=Y.color.__styleString;else if(Y instanceof THREE.MeshDepthMaterial){oa=1-Y.__2near/(Y.__farPlusNear-ga.z*Y.__farMinusNear);z.setRGB(oa,oa,oa)}else Y instanceof THREE.MeshNormalMaterial&&z.setRGB(g(ga.normalWorld.x),g(ga.normalWorld.y),g(ga.normalWorld.z));Y.wireframe?da.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+Y.wireframeLinewidth+"; stroke-opacity: "+Y.opacity+"; stroke-linecap: "+Y.wireframeLinecap+"; stroke-linejoin: "+
-Y.wireframeLinejoin):da.setAttribute("style","fill: "+z.__styleString+"; fill-opacity: "+Y.opacity);k.appendChild(da)}function f(qa){if(Z[qa]==null){Z[qa]=document.createElementNS("http://www.w3.org/2000/svg","path");Ha==0&&Z[qa].setAttribute("shape-rendering","crispEdges")}return Z[qa]}function g(qa){return qa<0?Math.min((1+qa)*0.5,0.5):0.5+Math.min(qa*0.5,0.5)}var h=null,j=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,p,o,u,y,v,B,C,F=new THREE.Rectangle,H=
-new THREE.Rectangle,U=!1,z=new THREE.Color(16777215),J=new THREE.Color(16777215),L=new THREE.Color(0),M=new THREE.Color(0),Fa=new THREE.Color(0),oa,xa=new THREE.Vector3,Z=[],e=[],da,Ca,Aa,Ha=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(qa){switch(qa){case "high":Ha=1;break;case "low":Ha=0}};this.setSize=function(qa,$){n=qa;p=$;o=n/2;u=p/2;k.setAttribute("viewBox",-o+" "+-u+" "+n+" "+p);k.setAttribute("width",n);k.setAttribute("height",p);
-F.set(-o,-u,o,u)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(qa,$){var pa,Da,ga,Y,la,Ga,ka,na;this.autoClear&&this.clear();h=j.projectScene(qa,$,this.sortElements);Aa=Ca=0;if(U=qa.lights.length>0){ka=qa.lights;L.setRGB(0,0,0);M.setRGB(0,0,0);Fa.setRGB(0,0,0);pa=0;for(Da=ka.length;pa<Da;pa++){ga=ka[pa];Y=ga.color;if(ga instanceof THREE.AmbientLight){L.r+=Y.r;L.g+=Y.g;L.b+=Y.b}else if(ga instanceof THREE.DirectionalLight){M.r+=Y.r;M.g+=Y.g;
-M.b+=Y.b}else if(ga instanceof THREE.PointLight){Fa.r+=Y.r;Fa.g+=Y.g;Fa.b+=Y.b}}}pa=0;for(Da=h.length;pa<Da;pa++){ka=h[pa];H.empty();if(ka instanceof THREE.RenderableParticle){y=ka;y.x*=o;y.y*=-u;ga=0;for(Y=ka.materials.length;ga<Y;)ga++}else if(ka instanceof THREE.RenderableLine){y=ka.v1;v=ka.v2;y.positionScreen.x*=o;y.positionScreen.y*=-u;v.positionScreen.x*=o;v.positionScreen.y*=-u;H.addPoint(y.positionScreen.x,y.positionScreen.y);H.addPoint(v.positionScreen.x,v.positionScreen.y);if(F.instersects(H)){ga=
-0;for(Y=ka.materials.length;ga<Y;)if((na=ka.materials[ga++])&&na.opacity!=0){la=y;Ga=v;var wa=Aa++;if(e[wa]==null){e[wa]=document.createElementNS("http://www.w3.org/2000/svg","line");Ha==0&&e[wa].setAttribute("shape-rendering","crispEdges")}da=e[wa];da.setAttribute("x1",la.positionScreen.x);da.setAttribute("y1",la.positionScreen.y);da.setAttribute("x2",Ga.positionScreen.x);da.setAttribute("y2",Ga.positionScreen.y);if(na instanceof THREE.LineBasicMaterial){z.__styleString=na.color.__styleString;da.setAttribute("style",
-"fill: none; stroke: "+z.__styleString+"; stroke-width: "+na.linewidth+"; stroke-opacity: "+na.opacity+"; stroke-linecap: "+na.linecap+"; stroke-linejoin: "+na.linejoin);k.appendChild(da)}}}}else if(ka instanceof THREE.RenderableFace3){y=ka.v1;v=ka.v2;B=ka.v3;y.positionScreen.x*=o;y.positionScreen.y*=-u;v.positionScreen.x*=o;v.positionScreen.y*=-u;B.positionScreen.x*=o;B.positionScreen.y*=-u;H.addPoint(y.positionScreen.x,y.positionScreen.y);H.addPoint(v.positionScreen.x,v.positionScreen.y);H.addPoint(B.positionScreen.x,
-B.positionScreen.y);if(F.instersects(H)){ga=0;for(Y=ka.meshMaterials.length;ga<Y;){na=ka.meshMaterials[ga++];if(na instanceof THREE.MeshFaceMaterial){la=0;for(Ga=ka.faceMaterials.length;la<Ga;)(na=ka.faceMaterials[la++])&&na.opacity!=0&&d(y,v,B,ka,na,qa)}else na&&na.opacity!=0&&d(y,v,B,ka,na,qa)}}}else if(ka instanceof THREE.RenderableFace4){y=ka.v1;v=ka.v2;B=ka.v3;C=ka.v4;y.positionScreen.x*=o;y.positionScreen.y*=-u;v.positionScreen.x*=o;v.positionScreen.y*=-u;B.positionScreen.x*=o;B.positionScreen.y*=
--u;C.positionScreen.x*=o;C.positionScreen.y*=-u;H.addPoint(y.positionScreen.x,y.positionScreen.y);H.addPoint(v.positionScreen.x,v.positionScreen.y);H.addPoint(B.positionScreen.x,B.positionScreen.y);H.addPoint(C.positionScreen.x,C.positionScreen.y);if(F.instersects(H)){ga=0;for(Y=ka.meshMaterials.length;ga<Y;){na=ka.meshMaterials[ga++];if(na instanceof THREE.MeshFaceMaterial){la=0;for(Ga=ka.faceMaterials.length;la<Ga;)(na=ka.faceMaterials[la++])&&na.opacity!=0&&c(y,v,B,C,ka,na,qa)}else na&&na.opacity!=
-0&&c(y,v,B,C,ka,na,qa)}}}}}};
+THREE.Projector=function(){function b(){var fa=n[k]=n[k]||new THREE.RenderableVertex;k++;return fa}function d(fa,da){return da.z-fa.z}function c(fa,da){var ya=0,Fa=1,Ga=fa.z+fa.w,ra=da.z+da.w,aa=-fa.z+fa.w,pa=-da.z+da.w;if(Ga>=0&&ra>=0&&aa>=0&&pa>=0)return!0;else if(Ga<0&&ra<0||aa<0&&pa<0)return!1;else{if(Ga<0)ya=Math.max(ya,Ga/(Ga-ra));else ra<0&&(Fa=Math.min(Fa,Ga/(Ga-ra)));if(aa<0)ya=Math.max(ya,aa/(aa-pa));else pa<0&&(Fa=Math.min(Fa,aa/(aa-pa)));if(Fa<ya)return!1;else{fa.lerpSelf(da,ya);da.lerpSelf(fa,
+1-Fa);return!0}}}var f,g,h=[],j,k,n=[],p,o,u=[],y,w=[],A,E,G=[],L,V,z=[],N=new THREE.Vector4,Q=new THREE.Vector4,S=new THREE.Matrix4,xa=new THREE.Matrix4,sa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],qa=new THREE.Vector4,e=new THREE.Vector4;this.projectVector=function(fa,da){S.multiply(da.projectionMatrix,da.matrixWorldInverse);S.multiplyVector3(fa);return fa};this.unprojectVector=function(fa,da){S.multiply(da.matrixWorld,THREE.Matrix4.makeInvert(da.projectionMatrix));
+S.multiplyVector3(fa);return fa};this.projectObjects=function(fa,da,ya){da=[];var Fa,Ga,ra;g=0;Ga=fa.objects;fa=0;for(Fa=Ga.length;fa<Fa;fa++){ra=Ga[fa];var aa;if(!(aa=!ra.visible))if(aa=ra instanceof THREE.Mesh){a:{aa=void 0;for(var pa=ra.matrixWorld,za=-ra.geometry.boundingSphere.radius*Math.max(ra.scale.x,Math.max(ra.scale.y,ra.scale.z)),ia=0;ia<6;ia++){aa=sa[ia].x*pa.n14+sa[ia].y*pa.n24+sa[ia].z*pa.n34+sa[ia].w;if(aa<=za){aa=!1;break a}}aa=!0}aa=!aa}if(!aa){aa=h[g]=h[g]||new THREE.RenderableObject;
+g++;f=aa;N.copy(ra.position);S.multiplyVector3(N);f.object=ra;f.z=N.z;da.push(f)}}ya&&da.sort(d);return da};this.projectScene=function(fa,da,ya){var Fa=[],Ga=da.near,ra=da.far,aa,pa,za,ia,Y,ma,Da,ja,la,Ea,Sa,$a,Ya,Ta,R,$,na;V=E=y=o=0;da.matrixAutoUpdate&&da.updateMatrix();fa.update(undefined,!1,da);S.multiply(da.projectionMatrix,da.matrixWorldInverse);sa[0].set(S.n41-S.n11,S.n42-S.n12,S.n43-S.n13,S.n44-S.n14);sa[1].set(S.n41+S.n11,S.n42+S.n12,S.n43+S.n13,S.n44+S.n14);sa[2].set(S.n41+S.n21,S.n42+S.n22,
+S.n43+S.n23,S.n44+S.n24);sa[3].set(S.n41-S.n21,S.n42-S.n22,S.n43-S.n23,S.n44-S.n24);sa[4].set(S.n41-S.n31,S.n42-S.n32,S.n43-S.n33,S.n44-S.n34);sa[5].set(S.n41+S.n31,S.n42+S.n32,S.n43+S.n33,S.n44+S.n34);for(aa=0;aa<6;aa++){la=sa[aa];la.divideScalar(Math.sqrt(la.x*la.x+la.y*la.y+la.z*la.z))}la=this.projectObjects(fa,da,!0);fa=0;for(aa=la.length;fa<aa;fa++){Ea=la[fa].object;if(Ea.visible){Sa=Ea.matrixWorld;$a=Ea.matrixRotationWorld;Ya=Ea.materials;Ta=Ea.overdraw;k=0;if(Ea instanceof THREE.Mesh){R=Ea.geometry;
+ia=R.vertices;$=R.faces;R=R.faceVertexUvs;pa=0;for(za=ia.length;pa<za;pa++){j=b();j.positionWorld.copy(ia[pa].position);Sa.multiplyVector3(j.positionWorld);j.positionScreen.copy(j.positionWorld);S.multiplyVector4(j.positionScreen);j.positionScreen.x/=j.positionScreen.w;j.positionScreen.y/=j.positionScreen.w;j.visible=j.positionScreen.z>Ga&&j.positionScreen.z<ra}ia=0;for(pa=$.length;ia<pa;ia++){za=$[ia];if(za instanceof THREE.Face3){Y=n[za.a];ma=n[za.b];Da=n[za.c];if(Y.visible&&ma.visible&&Da.visible&&
+(Ea.doubleSided||Ea.flipSided!=(Da.positionScreen.x-Y.positionScreen.x)*(ma.positionScreen.y-Y.positionScreen.y)-(Da.positionScreen.y-Y.positionScreen.y)*(ma.positionScreen.x-Y.positionScreen.x)<0)){ja=u[o]=u[o]||new THREE.RenderableFace3;o++;p=ja;p.v1.copy(Y);p.v2.copy(ma);p.v3.copy(Da)}else continue}else if(za instanceof THREE.Face4){Y=n[za.a];ma=n[za.b];Da=n[za.c];ja=n[za.d];if(Y.visible&&ma.visible&&Da.visible&&ja.visible&&(Ea.doubleSided||Ea.flipSided!=((ja.positionScreen.x-Y.positionScreen.x)*
+(ma.positionScreen.y-Y.positionScreen.y)-(ja.positionScreen.y-Y.positionScreen.y)*(ma.positionScreen.x-Y.positionScreen.x)<0||(ma.positionScreen.x-Da.positionScreen.x)*(ja.positionScreen.y-Da.positionScreen.y)-(ma.positionScreen.y-Da.positionScreen.y)*(ja.positionScreen.x-Da.positionScreen.x)<0))){na=w[y]=w[y]||new THREE.RenderableFace4;y++;p=na;p.v1.copy(Y);p.v2.copy(ma);p.v3.copy(Da);p.v4.copy(ja)}else continue}p.normalWorld.copy(za.normal);$a.multiplyVector3(p.normalWorld);p.centroidWorld.copy(za.centroid);
+Sa.multiplyVector3(p.centroidWorld);p.centroidScreen.copy(p.centroidWorld);S.multiplyVector3(p.centroidScreen);Da=za.vertexNormals;Y=0;for(ma=Da.length;Y<ma;Y++){ja=p.vertexNormalsWorld[Y];ja.copy(Da[Y]);$a.multiplyVector3(ja)}Y=0;for(ma=R.length;Y<ma;Y++)if(na=R[Y][ia]){Da=0;for(ja=na.length;Da<ja;Da++)p.uvs[Y][Da]=na[Da]}p.meshMaterials=Ya;p.faceMaterials=za.materials;p.overdraw=Ta;p.z=p.centroidScreen.z;Fa.push(p)}}else if(Ea instanceof THREE.Line){xa.multiply(S,Sa);ia=Ea.geometry.vertices;Y=b();
+Y.positionScreen.copy(ia[0].position);xa.multiplyVector4(Y.positionScreen);pa=1;for(za=ia.length;pa<za;pa++){Y=b();Y.positionScreen.copy(ia[pa].position);xa.multiplyVector4(Y.positionScreen);ma=n[k-2];qa.copy(Y.positionScreen);e.copy(ma.positionScreen);if(c(qa,e)){qa.multiplyScalar(1/qa.w);e.multiplyScalar(1/e.w);Sa=G[E]=G[E]||new THREE.RenderableLine;E++;A=Sa;A.v1.positionScreen.copy(qa);A.v2.positionScreen.copy(e);A.z=Math.max(qa.z,e.z);A.materials=Ea.materials;Fa.push(A)}}}else if(Ea instanceof
+THREE.Particle){Q.set(Ea.position.x,Ea.position.y,Ea.position.z,1);S.multiplyVector4(Q);Q.z/=Q.w;if(Q.z>0&&Q.z<1){Sa=z[V]=z[V]||new THREE.RenderableParticle;V++;L=Sa;L.x=Q.x/Q.w;L.y=Q.y/Q.w;L.z=Q.z;L.rotation=Ea.rotation.z;L.scale.x=Ea.scale.x*Math.abs(L.x-(Q.x+da.projectionMatrix.n11)/(Q.w+da.projectionMatrix.n14));L.scale.y=Ea.scale.y*Math.abs(L.y-(Q.y+da.projectionMatrix.n22)/(Q.w+da.projectionMatrix.n24));L.materials=Ea.materials;Fa.push(L)}}}}ya&&Fa.sort(d);return Fa}};
+THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,d=new THREE.Projector,c,f,g,h;this.domElement=document.createElement("div");this.setSize=function(j,k){c=j;f=k;g=c/2;h=f/2};this.render=function(j,k){var n,p,o,u,y,w,A,E;b=d.projectScene(j,k);n=0;for(p=b.length;n<p;n++){y=b[n];if(y instanceof THREE.RenderableParticle){A=y.x*g+g;E=y.y*h+h;o=0;for(u=y.material.length;o<u;o++){w=y.material[o];if(w instanceof THREE.ParticleDOMMaterial){w=w.domElement;w.style.left=A+"px";w.style.top=E+"px"}}}}}};
+THREE.CanvasRenderer=function(){function b(oa){if(w!=oa)o.globalAlpha=w=oa}function d(oa){if(A!=oa){switch(oa){case THREE.NormalBlending:o.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:o.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:o.globalCompositeOperation="darker"}A=oa}}function c(oa){if(E!=oa)o.strokeStyle=E=oa}var f=null,g=new THREE.Projector,h=document.createElement("canvas"),j,k,n,p,o=h.getContext("2d"),u=new THREE.Color(0),y=0,w=1,A=0,
+E=null,G=null,L=null,V=null,z=null,N,Q,S,xa,sa=new THREE.RenderableVertex,qa=new THREE.RenderableVertex,e,fa,da,ya,Fa,Ga,ra,aa,pa,za,ia,Y,ma=new THREE.Color,Da=new THREE.Color,ja=new THREE.Color,la=new THREE.Color,Ea=new THREE.Color,Sa,$a,Ya,Ta,R,$,na,Ba,ha,ka,m=new THREE.Rectangle,C=new THREE.Rectangle,x=new THREE.Rectangle,v=!1,B=new THREE.Color,O=new THREE.Color,I=new THREE.Color,K=new THREE.Color,H=new THREE.Vector3,F,J,M,X,U,Ca,Ha=16;F=document.createElement("canvas");F.width=F.height=2;J=F.getContext("2d");
+J.fillStyle="rgba(0,0,0,1)";J.fillRect(0,0,2,2);M=J.getImageData(0,0,2,2);X=M.data;U=document.createElement("canvas");U.width=U.height=Ha;Ca=U.getContext("2d");Ca.translate(-Ha/2,-Ha/2);Ca.scale(Ha,Ha);Ha--;this.domElement=h;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setSize=function(oa,wa){j=oa;k=wa;n=j/2;p=k/2;h.width=j;h.height=k;m.set(-n,-p,n,p);w=1;A=0;z=V=L=G=E=null};this.setClearColor=function(oa,wa){u=oa;y=wa};this.setClearColorHex=function(oa,wa){u.setHex(oa);y=wa};this.clear=
+function(){o.setTransform(1,0,0,-1,n,p);if(!C.isEmpty()){C.inflate(1);C.minSelf(m);if(u.hex==0&&y==0)o.clearRect(C.getX(),C.getY(),C.getWidth(),C.getHeight());else{d(THREE.NormalBlending);b(1);o.fillStyle="rgba("+Math.floor(u.r*255)+","+Math.floor(u.g*255)+","+Math.floor(u.b*255)+","+y+")";o.fillRect(C.getX(),C.getY(),C.getWidth(),C.getHeight())}C.empty()}};this.render=function(oa,wa){function cb(W){var ta,ea,ca,va=W.lights;O.setRGB(0,0,0);I.setRGB(0,0,0);K.setRGB(0,0,0);W=0;for(ta=va.length;W<ta;W++){ea=
+va[W];ca=ea.color;if(ea instanceof THREE.AmbientLight){O.r+=ca.r;O.g+=ca.g;O.b+=ca.b}else if(ea instanceof THREE.DirectionalLight){I.r+=ca.r;I.g+=ca.g;I.b+=ca.b}else if(ea instanceof THREE.PointLight){K.r+=ca.r;K.g+=ca.g;K.b+=ca.b}}}function Aa(W,ta,ea,ca){var va,ua,ga,P,Na=W.lights;W=0;for(va=Na.length;W<va;W++){ua=Na[W];ga=ua.color;if(ua instanceof THREE.DirectionalLight){P=ea.dot(ua.position);if(!(P<=0)){P*=ua.intensity;ca.r+=ga.r*P;ca.g+=ga.g*P;ca.b+=ga.b*P}}else if(ua instanceof THREE.PointLight){P=
+ea.dot(H.sub(ua.position,ta).normalize());if(!(P<=0)){P*=ua.distance==0?1:1-Math.min(ta.distanceTo(ua.position)/ua.distance,1);if(P!=0){P*=ua.intensity;ca.r+=ga.r*P;ca.g+=ga.g*P;ca.b+=ga.b*P}}}}}function Ia(W,ta,ea){b(ea.opacity);d(ea.blending);var ca,va,ua,ga,P,Na;if(ea instanceof THREE.ParticleBasicMaterial){if(ea.map){ga=ea.map.image;P=ga.width>>1;Na=ga.height>>1;ea=ta.scale.x*n;ua=ta.scale.y*p;ca=ea*P;va=ua*Na;x.set(W.x-ca,W.y-va,W.x+ca,W.y+va);if(m.instersects(x)){o.save();o.translate(W.x,W.y);
+o.rotate(-ta.rotation);o.scale(ea,-ua);o.translate(-P,-Na);o.drawImage(ga,0,0);o.restore()}}}else if(ea instanceof THREE.ParticleCanvasMaterial){ca=ta.scale.x*n;va=ta.scale.y*p;x.set(W.x-ca,W.y-va,W.x+ca,W.y+va);if(m.instersects(x)){c(ea.color.__styleString);ua=ea.color.__styleString;if(G!=ua)o.fillStyle=G=ua;o.save();o.translate(W.x,W.y);o.rotate(-ta.rotation);o.scale(ca,va);ea.program(o);o.restore()}}}function Ja(W,ta,ea,ca){b(ca.opacity);d(ca.blending);o.beginPath();o.moveTo(W.positionScreen.x,
+W.positionScreen.y);o.lineTo(ta.positionScreen.x,ta.positionScreen.y);o.closePath();if(ca instanceof THREE.LineBasicMaterial){ma.__styleString=ca.color.__styleString;W=ca.linewidth;if(L!=W)o.lineWidth=L=W;W=ca.linecap;if(V!=W)o.lineCap=V=W;W=ca.linejoin;if(z!=W)o.lineJoin=z=W;c(ma.__styleString);o.stroke();x.inflate(ca.linewidth*2)}}function Qa(W,ta,ea,ca,va,ua,ga,P,Na){b(P.opacity);d(P.blending);e=W.positionScreen.x;fa=W.positionScreen.y;da=ta.positionScreen.x;ya=ta.positionScreen.y;Fa=ea.positionScreen.x;
+Ga=ea.positionScreen.y;Z(e,fa,da,ya,Fa,Ga);if(P instanceof THREE.MeshBasicMaterial)if(P.map){if(P.map.mapping instanceof THREE.UVMapping){Ta=ga.uvs[0];Ma(e,fa,da,ya,Fa,Ga,P.map.image,Ta[ca].u,Ta[ca].v,Ta[va].u,Ta[va].v,Ta[ua].u,Ta[ua].v)}}else if(P.envMap){if(P.envMap.mapping instanceof THREE.SphericalReflectionMapping){W=wa.matrixWorldInverse;H.copy(ga.vertexNormalsWorld[0]);R=(H.x*W.n11+H.y*W.n12+H.z*W.n13)*0.5+0.5;$=-(H.x*W.n21+H.y*W.n22+H.z*W.n23)*0.5+0.5;H.copy(ga.vertexNormalsWorld[1]);na=(H.x*
+W.n11+H.y*W.n12+H.z*W.n13)*0.5+0.5;Ba=-(H.x*W.n21+H.y*W.n22+H.z*W.n23)*0.5+0.5;H.copy(ga.vertexNormalsWorld[2]);ha=(H.x*W.n11+H.y*W.n12+H.z*W.n13)*0.5+0.5;ka=-(H.x*W.n21+H.y*W.n22+H.z*W.n23)*0.5+0.5;Ma(e,fa,da,ya,Fa,Ga,P.envMap.image,R,$,na,Ba,ha,ka)}}else P.wireframe?ab(P.color.__styleString,P.wireframeLinewidth,P.wireframeLinecap,P.wireframeLinejoin):fb(P.color.__styleString);else if(P instanceof THREE.MeshLambertMaterial){if(P.map&&!P.wireframe){if(P.map.mapping instanceof THREE.UVMapping){Ta=
+ga.uvs[0];Ma(e,fa,da,ya,Fa,Ga,P.map.image,Ta[ca].u,Ta[ca].v,Ta[va].u,Ta[va].v,Ta[ua].u,Ta[ua].v)}d(THREE.SubtractiveBlending)}if(v)if(!P.wireframe&&P.shading==THREE.SmoothShading&&ga.vertexNormalsWorld.length==3){Da.r=ja.r=la.r=O.r;Da.g=ja.g=la.g=O.g;Da.b=ja.b=la.b=O.b;Aa(Na,ga.v1.positionWorld,ga.vertexNormalsWorld[0],Da);Aa(Na,ga.v2.positionWorld,ga.vertexNormalsWorld[1],ja);Aa(Na,ga.v3.positionWorld,ga.vertexNormalsWorld[2],la);Ea.r=(ja.r+la.r)*0.5;Ea.g=(ja.g+la.g)*0.5;Ea.b=(ja.b+la.b)*0.5;Ya=
+Va(Da,ja,la,Ea);Ma(e,fa,da,ya,Fa,Ga,Ya,0,0,1,0,0,1)}else{B.r=O.r;B.g=O.g;B.b=O.b;Aa(Na,ga.centroidWorld,ga.normalWorld,B);ma.r=P.color.r*B.r;ma.g=P.color.g*B.g;ma.b=P.color.b*B.b;ma.updateStyleString();P.wireframe?ab(ma.__styleString,P.wireframeLinewidth,P.wireframeLinecap,P.wireframeLinejoin):fb(ma.__styleString)}else P.wireframe?ab(P.color.__styleString,P.wireframeLinewidth,P.wireframeLinecap,P.wireframeLinejoin):fb(P.color.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){Sa=wa.near;
+$a=wa.far;Da.r=Da.g=Da.b=1-gb(W.positionScreen.z,Sa,$a);ja.r=ja.g=ja.b=1-gb(ta.positionScreen.z,Sa,$a);la.r=la.g=la.b=1-gb(ea.positionScreen.z,Sa,$a);Ea.r=(ja.r+la.r)*0.5;Ea.g=(ja.g+la.g)*0.5;Ea.b=(ja.b+la.b)*0.5;Ya=Va(Da,ja,la,Ea);Ma(e,fa,da,ya,Fa,Ga,Ya,0,0,1,0,0,1)}else if(P instanceof THREE.MeshNormalMaterial){ma.r=hb(ga.normalWorld.x);ma.g=hb(ga.normalWorld.y);ma.b=hb(ga.normalWorld.z);ma.updateStyleString();P.wireframe?ab(ma.__styleString,P.wireframeLinewidth,P.wireframeLinecap,P.wireframeLinejoin):
+fb(ma.__styleString)}}function D(W,ta,ea,ca,va,ua,ga,P,Na){b(P.opacity);d(P.blending);if(P.map||P.envMap){Qa(W,ta,ca,0,1,3,ga,P,Na);Qa(va,ea,ua,1,2,3,ga,P,Na)}else{e=W.positionScreen.x;fa=W.positionScreen.y;da=ta.positionScreen.x;ya=ta.positionScreen.y;Fa=ea.positionScreen.x;Ga=ea.positionScreen.y;ra=ca.positionScreen.x;aa=ca.positionScreen.y;pa=va.positionScreen.x;za=va.positionScreen.y;ia=ua.positionScreen.x;Y=ua.positionScreen.y;if(P instanceof THREE.MeshBasicMaterial){t(e,fa,da,ya,Fa,Ga,ra,aa);
+P.wireframe?ab(P.color.__styleString,P.wireframeLinewidth,P.wireframeLinecap,P.wireframeLinejoin):fb(P.color.__styleString)}else if(P instanceof THREE.MeshLambertMaterial)if(v)if(!P.wireframe&&P.shading==THREE.SmoothShading&&ga.vertexNormalsWorld.length==4){Da.r=ja.r=la.r=Ea.r=O.r;Da.g=ja.g=la.g=Ea.g=O.g;Da.b=ja.b=la.b=Ea.b=O.b;Aa(Na,ga.v1.positionWorld,ga.vertexNormalsWorld[0],Da);Aa(Na,ga.v2.positionWorld,ga.vertexNormalsWorld[1],ja);Aa(Na,ga.v4.positionWorld,ga.vertexNormalsWorld[3],la);Aa(Na,
+ga.v3.positionWorld,ga.vertexNormalsWorld[2],Ea);Ya=Va(Da,ja,la,Ea);Z(e,fa,da,ya,ra,aa);Ma(e,fa,da,ya,ra,aa,Ya,0,0,1,0,0,1);Z(pa,za,Fa,Ga,ia,Y);Ma(pa,za,Fa,Ga,ia,Y,Ya,1,0,1,1,0,1)}else{B.r=O.r;B.g=O.g;B.b=O.b;Aa(Na,ga.centroidWorld,ga.normalWorld,B);ma.r=P.color.r*B.r;ma.g=P.color.g*B.g;ma.b=P.color.b*B.b;ma.updateStyleString();t(e,fa,da,ya,Fa,Ga,ra,aa);P.wireframe?ab(ma.__styleString,P.wireframeLinewidth,P.wireframeLinecap,P.wireframeLinejoin):fb(ma.__styleString)}else{t(e,fa,da,ya,Fa,Ga,ra,aa);
+P.wireframe?ab(P.color.__styleString,P.wireframeLinewidth,P.wireframeLinecap,P.wireframeLinejoin):fb(P.color.__styleString)}else if(P instanceof THREE.MeshNormalMaterial){ma.r=hb(ga.normalWorld.x);ma.g=hb(ga.normalWorld.y);ma.b=hb(ga.normalWorld.z);ma.updateStyleString();t(e,fa,da,ya,Fa,Ga,ra,aa);P.wireframe?ab(ma.__styleString,P.wireframeLinewidth,P.wireframeLinecap,P.wireframeLinejoin):fb(ma.__styleString)}else if(P instanceof THREE.MeshDepthMaterial){Sa=wa.near;$a=wa.far;Da.r=Da.g=Da.b=1-gb(W.positionScreen.z,
+Sa,$a);ja.r=ja.g=ja.b=1-gb(ta.positionScreen.z,Sa,$a);la.r=la.g=la.b=1-gb(ca.positionScreen.z,Sa,$a);Ea.r=Ea.g=Ea.b=1-gb(ea.positionScreen.z,Sa,$a);Ya=Va(Da,ja,la,Ea);Z(e,fa,da,ya,ra,aa);Ma(e,fa,da,ya,ra,aa,Ya,0,0,1,0,0,1);Z(pa,za,Fa,Ga,ia,Y);Ma(pa,za,Fa,Ga,ia,Y,Ya,1,0,1,1,0,1)}}}function Z(W,ta,ea,ca,va,ua){o.beginPath();o.moveTo(W,ta);o.lineTo(ea,ca);o.lineTo(va,ua);o.lineTo(W,ta);o.closePath()}function t(W,ta,ea,ca,va,ua,ga,P){o.beginPath();o.moveTo(W,ta);o.lineTo(ea,ca);o.lineTo(va,ua);o.lineTo(ga,
+P);o.lineTo(W,ta);o.closePath()}function ab(W,ta,ea,ca){if(L!=ta)o.lineWidth=L=ta;if(V!=ea)o.lineCap=V=ea;if(z!=ca)o.lineJoin=z=ca;c(W);o.stroke();x.inflate(ta*2)}function fb(W){if(G!=W)o.fillStyle=G=W;o.fill()}function Ma(W,ta,ea,ca,va,ua,ga,P,Na,db,Ua,bb,lb){var Pa,ib;Pa=ga.width-1;ib=ga.height-1;P*=Pa;Na*=ib;db*=Pa;Ua*=ib;bb*=Pa;lb*=ib;ea-=W;ca-=ta;va-=W;ua-=ta;db-=P;Ua-=Na;bb-=P;lb-=Na;Pa=db*lb-bb*Ua;if(Pa!=0){ib=1/Pa;Pa=(lb*ea-Ua*va)*ib;Ua=(lb*ca-Ua*ua)*ib;ea=(db*va-bb*ea)*ib;ca=(db*ua-bb*ca)*
+ib;W=W-Pa*P-ea*Na;ta=ta-Ua*P-ca*Na;o.save();o.transform(Pa,Ua,ea,ca,W,ta);o.clip();o.drawImage(ga,0,0);o.restore()}}function Va(W,ta,ea,ca){var va=~~(W.r*255),ua=~~(W.g*255);W=~~(W.b*255);var ga=~~(ta.r*255),P=~~(ta.g*255);ta=~~(ta.b*255);var Na=~~(ea.r*255),db=~~(ea.g*255);ea=~~(ea.b*255);var Ua=~~(ca.r*255),bb=~~(ca.g*255);ca=~~(ca.b*255);X[0]=va<0?0:va>255?255:va;X[1]=ua<0?0:ua>255?255:ua;X[2]=W<0?0:W>255?255:W;X[4]=ga<0?0:ga>255?255:ga;X[5]=P<0?0:P>255?255:P;X[6]=ta<0?0:ta>255?255:ta;X[8]=Na<
+0?0:Na>255?255:Na;X[9]=db<0?0:db>255?255:db;X[10]=ea<0?0:ea>255?255:ea;X[12]=Ua<0?0:Ua>255?255:Ua;X[13]=bb<0?0:bb>255?255:bb;X[14]=ca<0?0:ca>255?255:ca;J.putImageData(M,0,0);Ca.drawImage(F,0,0);return U}function gb(W,ta,ea){W=(W-ta)/(ea-ta);return W*W*(3-2*W)}function hb(W){W=(W+1)*0.5;return W<0?0:W>1?1:W}function Wa(W,ta){var ea=ta.x-W.x,ca=ta.y-W.y,va=1/Math.sqrt(ea*ea+ca*ca);ea*=va;ca*=va;ta.x+=ea;ta.y+=ca;W.x-=ea;W.y-=ca}var eb,Oa,Ka,La,T,Ra,Xa,Za;this.autoClear?this.clear():o.setTransform(1,
+0,0,-1,n,p);f=g.projectScene(oa,wa,this.sortElements);(v=oa.lights.length>0)&&cb(oa);eb=0;for(Oa=f.length;eb<Oa;eb++){Ka=f[eb];x.empty();if(Ka instanceof THREE.RenderableParticle){N=Ka;N.x*=n;N.y*=p;La=0;for(T=Ka.materials.length;La<T;){Za=Ka.materials[La++];Za.opacity!=0&&Ia(N,Ka,Za,oa)}}else if(Ka instanceof THREE.RenderableLine){N=Ka.v1;Q=Ka.v2;N.positionScreen.x*=n;N.positionScreen.y*=p;Q.positionScreen.x*=n;Q.positionScreen.y*=p;x.addPoint(N.positionScreen.x,N.positionScreen.y);x.addPoint(Q.positionScreen.x,
+Q.positionScreen.y);if(m.instersects(x)){La=0;for(T=Ka.materials.length;La<T;){Za=Ka.materials[La++];Za.opacity!=0&&Ja(N,Q,Ka,Za,oa)}}}else if(Ka instanceof THREE.RenderableFace3){N=Ka.v1;Q=Ka.v2;S=Ka.v3;N.positionScreen.x*=n;N.positionScreen.y*=p;Q.positionScreen.x*=n;Q.positionScreen.y*=p;S.positionScreen.x*=n;S.positionScreen.y*=p;if(Ka.overdraw){Wa(N.positionScreen,Q.positionScreen);Wa(Q.positionScreen,S.positionScreen);Wa(S.positionScreen,N.positionScreen)}x.add3Points(N.positionScreen.x,N.positionScreen.y,
+Q.positionScreen.x,Q.positionScreen.y,S.positionScreen.x,S.positionScreen.y);if(m.instersects(x)){La=0;for(T=Ka.meshMaterials.length;La<T;){Za=Ka.meshMaterials[La++];if(Za instanceof THREE.MeshFaceMaterial){Ra=0;for(Xa=Ka.faceMaterials.length;Ra<Xa;)(Za=Ka.faceMaterials[Ra++])&&Za.opacity!=0&&Qa(N,Q,S,0,1,2,Ka,Za,oa)}else Za.opacity!=0&&Qa(N,Q,S,0,1,2,Ka,Za,oa)}}}else if(Ka instanceof THREE.RenderableFace4){N=Ka.v1;Q=Ka.v2;S=Ka.v3;xa=Ka.v4;N.positionScreen.x*=n;N.positionScreen.y*=p;Q.positionScreen.x*=
+n;Q.positionScreen.y*=p;S.positionScreen.x*=n;S.positionScreen.y*=p;xa.positionScreen.x*=n;xa.positionScreen.y*=p;sa.positionScreen.copy(Q.positionScreen);qa.positionScreen.copy(xa.positionScreen);if(Ka.overdraw){Wa(N.positionScreen,Q.positionScreen);Wa(Q.positionScreen,xa.positionScreen);Wa(xa.positionScreen,N.positionScreen);Wa(S.positionScreen,sa.positionScreen);Wa(S.positionScreen,qa.positionScreen)}x.addPoint(N.positionScreen.x,N.positionScreen.y);x.addPoint(Q.positionScreen.x,Q.positionScreen.y);
+x.addPoint(S.positionScreen.x,S.positionScreen.y);x.addPoint(xa.positionScreen.x,xa.positionScreen.y);if(m.instersects(x)){La=0;for(T=Ka.meshMaterials.length;La<T;){Za=Ka.meshMaterials[La++];if(Za instanceof THREE.MeshFaceMaterial){Ra=0;for(Xa=Ka.faceMaterials.length;Ra<Xa;)(Za=Ka.faceMaterials[Ra++])&&Za.opacity!=0&&D(N,Q,S,xa,sa,qa,Ka,Za,oa)}else Za.opacity!=0&&D(N,Q,S,xa,sa,qa,Ka,Za,oa)}}}C.addRectangle(x)}o.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function b(ra,aa,pa){var za,ia,Y,ma;za=0;for(ia=ra.lights.length;za<ia;za++){Y=ra.lights[za];if(Y instanceof THREE.DirectionalLight){ma=aa.normalWorld.dot(Y.position)*Y.intensity;if(ma>0){pa.r+=Y.color.r*ma;pa.g+=Y.color.g*ma;pa.b+=Y.color.b*ma}}else if(Y instanceof THREE.PointLight){qa.sub(Y.position,aa.centroidWorld);qa.normalize();ma=aa.normalWorld.dot(qa)*Y.intensity;if(ma>0){pa.r+=Y.color.r*ma;pa.g+=Y.color.g*ma;pa.b+=Y.color.b*ma}}}}function d(ra,aa,pa,za,ia,Y){da=
+f(ya++);da.setAttribute("d","M "+ra.positionScreen.x+" "+ra.positionScreen.y+" L "+aa.positionScreen.x+" "+aa.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+"z");if(ia instanceof THREE.MeshBasicMaterial)z.__styleString=ia.color.__styleString;else if(ia instanceof THREE.MeshLambertMaterial)if(V){N.r=Q.r;N.g=Q.g;N.b=Q.b;b(Y,za,N);z.r=ia.color.r*N.r;z.g=ia.color.g*N.g;z.b=ia.color.b*N.b;z.updateStyleString()}else z.__styleString=ia.color.__styleString;else if(ia instanceof THREE.MeshDepthMaterial){sa=
+1-ia.__2near/(ia.__farPlusNear-za.z*ia.__farMinusNear);z.setRGB(sa,sa,sa)}else ia instanceof THREE.MeshNormalMaterial&&z.setRGB(g(za.normalWorld.x),g(za.normalWorld.y),g(za.normalWorld.z));ia.wireframe?da.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+ia.wireframeLinewidth+"; stroke-opacity: "+ia.opacity+"; stroke-linecap: "+ia.wireframeLinecap+"; stroke-linejoin: "+ia.wireframeLinejoin):da.setAttribute("style","fill: "+z.__styleString+"; fill-opacity: "+ia.opacity);
+k.appendChild(da)}function c(ra,aa,pa,za,ia,Y,ma){da=f(ya++);da.setAttribute("d","M "+ra.positionScreen.x+" "+ra.positionScreen.y+" L "+aa.positionScreen.x+" "+aa.positionScreen.y+" L "+pa.positionScreen.x+","+pa.positionScreen.y+" L "+za.positionScreen.x+","+za.positionScreen.y+"z");if(Y instanceof THREE.MeshBasicMaterial)z.__styleString=Y.color.__styleString;else if(Y instanceof THREE.MeshLambertMaterial)if(V){N.r=Q.r;N.g=Q.g;N.b=Q.b;b(ma,ia,N);z.r=Y.color.r*N.r;z.g=Y.color.g*N.g;z.b=Y.color.b*
+N.b;z.updateStyleString()}else z.__styleString=Y.color.__styleString;else if(Y instanceof THREE.MeshDepthMaterial){sa=1-Y.__2near/(Y.__farPlusNear-ia.z*Y.__farMinusNear);z.setRGB(sa,sa,sa)}else Y instanceof THREE.MeshNormalMaterial&&z.setRGB(g(ia.normalWorld.x),g(ia.normalWorld.y),g(ia.normalWorld.z));Y.wireframe?da.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+Y.wireframeLinewidth+"; stroke-opacity: "+Y.opacity+"; stroke-linecap: "+Y.wireframeLinecap+"; stroke-linejoin: "+
+Y.wireframeLinejoin):da.setAttribute("style","fill: "+z.__styleString+"; fill-opacity: "+Y.opacity);k.appendChild(da)}function f(ra){if(e[ra]==null){e[ra]=document.createElementNS("http://www.w3.org/2000/svg","path");Ga==0&&e[ra].setAttribute("shape-rendering","crispEdges")}return e[ra]}function g(ra){return ra<0?Math.min((1+ra)*0.5,0.5):0.5+Math.min(ra*0.5,0.5)}var h=null,j=new THREE.Projector,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),n,p,o,u,y,w,A,E,G=new THREE.Rectangle,L=
+new THREE.Rectangle,V=!1,z=new THREE.Color(16777215),N=new THREE.Color(16777215),Q=new THREE.Color(0),S=new THREE.Color(0),xa=new THREE.Color(0),sa,qa=new THREE.Vector3,e=[],fa=[],da,ya,Fa,Ga=1;this.domElement=k;this.autoClear=!0;this.sortObjects=!0;this.sortElements=!0;this.setQuality=function(ra){switch(ra){case "high":Ga=1;break;case "low":Ga=0}};this.setSize=function(ra,aa){n=ra;p=aa;o=n/2;u=p/2;k.setAttribute("viewBox",-o+" "+-u+" "+n+" "+p);k.setAttribute("width",n);k.setAttribute("height",
+p);G.set(-o,-u,o,u)};this.clear=function(){for(;k.childNodes.length>0;)k.removeChild(k.childNodes[0])};this.render=function(ra,aa){var pa,za,ia,Y,ma,Da,ja,la;this.autoClear&&this.clear();h=j.projectScene(ra,aa,this.sortElements);Fa=ya=0;if(V=ra.lights.length>0){ja=ra.lights;Q.setRGB(0,0,0);S.setRGB(0,0,0);xa.setRGB(0,0,0);pa=0;for(za=ja.length;pa<za;pa++){ia=ja[pa];Y=ia.color;if(ia instanceof THREE.AmbientLight){Q.r+=Y.r;Q.g+=Y.g;Q.b+=Y.b}else if(ia instanceof THREE.DirectionalLight){S.r+=Y.r;S.g+=
+Y.g;S.b+=Y.b}else if(ia instanceof THREE.PointLight){xa.r+=Y.r;xa.g+=Y.g;xa.b+=Y.b}}}pa=0;for(za=h.length;pa<za;pa++){ja=h[pa];L.empty();if(ja instanceof THREE.RenderableParticle){y=ja;y.x*=o;y.y*=-u;ia=0;for(Y=ja.materials.length;ia<Y;)ia++}else if(ja instanceof THREE.RenderableLine){y=ja.v1;w=ja.v2;y.positionScreen.x*=o;y.positionScreen.y*=-u;w.positionScreen.x*=o;w.positionScreen.y*=-u;L.addPoint(y.positionScreen.x,y.positionScreen.y);L.addPoint(w.positionScreen.x,w.positionScreen.y);if(G.instersects(L)){ia=
+0;for(Y=ja.materials.length;ia<Y;)if((la=ja.materials[ia++])&&la.opacity!=0){ma=y;Da=w;var Ea=Fa++;if(fa[Ea]==null){fa[Ea]=document.createElementNS("http://www.w3.org/2000/svg","line");Ga==0&&fa[Ea].setAttribute("shape-rendering","crispEdges")}da=fa[Ea];da.setAttribute("x1",ma.positionScreen.x);da.setAttribute("y1",ma.positionScreen.y);da.setAttribute("x2",Da.positionScreen.x);da.setAttribute("y2",Da.positionScreen.y);if(la instanceof THREE.LineBasicMaterial){z.__styleString=la.color.__styleString;
+da.setAttribute("style","fill: none; stroke: "+z.__styleString+"; stroke-width: "+la.linewidth+"; stroke-opacity: "+la.opacity+"; stroke-linecap: "+la.linecap+"; stroke-linejoin: "+la.linejoin);k.appendChild(da)}}}}else if(ja instanceof THREE.RenderableFace3){y=ja.v1;w=ja.v2;A=ja.v3;y.positionScreen.x*=o;y.positionScreen.y*=-u;w.positionScreen.x*=o;w.positionScreen.y*=-u;A.positionScreen.x*=o;A.positionScreen.y*=-u;L.addPoint(y.positionScreen.x,y.positionScreen.y);L.addPoint(w.positionScreen.x,w.positionScreen.y);
+L.addPoint(A.positionScreen.x,A.positionScreen.y);if(G.instersects(L)){ia=0;for(Y=ja.meshMaterials.length;ia<Y;){la=ja.meshMaterials[ia++];if(la instanceof THREE.MeshFaceMaterial){ma=0;for(Da=ja.faceMaterials.length;ma<Da;)(la=ja.faceMaterials[ma++])&&la.opacity!=0&&d(y,w,A,ja,la,ra)}else la&&la.opacity!=0&&d(y,w,A,ja,la,ra)}}}else if(ja instanceof THREE.RenderableFace4){y=ja.v1;w=ja.v2;A=ja.v3;E=ja.v4;y.positionScreen.x*=o;y.positionScreen.y*=-u;w.positionScreen.x*=o;w.positionScreen.y*=-u;A.positionScreen.x*=
+o;A.positionScreen.y*=-u;E.positionScreen.x*=o;E.positionScreen.y*=-u;L.addPoint(y.positionScreen.x,y.positionScreen.y);L.addPoint(w.positionScreen.x,w.positionScreen.y);L.addPoint(A.positionScreen.x,A.positionScreen.y);L.addPoint(E.positionScreen.x,E.positionScreen.y);if(G.instersects(L)){ia=0;for(Y=ja.meshMaterials.length;ia<Y;){la=ja.meshMaterials[ia++];if(la instanceof THREE.MeshFaceMaterial){ma=0;for(Da=ja.faceMaterials.length;ma<Da;)(la=ja.faceMaterials[ma++])&&la.opacity!=0&&c(y,w,A,E,ja,la,
+ra)}else la&&la.opacity!=0&&c(y,w,A,E,ja,la,ra)}}}}}};
 THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",envmap_vertex:"#ifdef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal;\nif ( useRefract ) {\nvReflect = refract( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ), refractionRatio );\n} else {\nvReflect = reflect( normalize( mPosition.xyz - cameraPosition ), normalize( nWorld.xyz ) );\n}\n#endif",
 map_particle_pars_fragment:"#ifdef USE_MAP\nuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, gl_PointCoord );\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_pars_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv;\n#endif",lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\nvarying vec2 vUv2;\nuniform sampler2D lightMap;\n#endif",
@@ -222,106 +222,109 @@ THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.
 vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
 THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",
 THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
-THREE.WebGLRenderer=function(b){function d(m,A,x){var t,w,S,E=m.vertices,G=E.length,O=m.colors,D=O.length,I=m.__vertexArray,Q=m.__colorArray,sa=m.__sortArray,W=m.__dirtyVertices,Ba=m.__dirtyColors;if(x.sortParticles){Ua.multiplySelf(x.matrixWorld);for(t=0;t<G;t++){w=E[t].position;Pa.copy(w);Ua.multiplyVector3(Pa);sa[t]=[Pa.z,t]}sa.sort(function(ra,za){return za[0]-ra[0]});for(t=0;t<G;t++){w=E[sa[t][1]].position;S=t*3;I[S]=w.x;I[S+1]=w.y;I[S+2]=w.z}for(t=0;t<D;t++){S=t*3;color=O[sa[t][1]];Q[S]=color.r;
-Q[S+1]=color.g;Q[S+2]=color.b}}else{if(W)for(t=0;t<G;t++){w=E[t].position;S=t*3;I[S]=w.x;I[S+1]=w.y;I[S+2]=w.z}if(Ba)for(t=0;t<D;t++){color=O[t];S=t*3;Q[S]=color.r;Q[S+1]=color.g;Q[S+2]=color.b}}if(W||x.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,I,A)}if(Ba||x.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,Q,A)}}function c(m,A){m.uniforms=Uniforms.clone(A.uniforms);m.vertexShader=A.vertexShader;m.fragmentShader=
-A.fragmentShader}function f(m,A,x,t,w){t.program||$.initMaterial(t,A,x,w);var S=t.program,E=S.uniforms,G=t.uniforms;if(S!=Aa){e.useProgram(S);Aa=S}e.uniformMatrix4fv(E.projectionMatrix,!1,cb);if(x&&(t instanceof THREE.MeshBasicMaterial||t instanceof THREE.MeshLambertMaterial||t instanceof THREE.MeshPhongMaterial||t instanceof THREE.LineBasicMaterial||t instanceof THREE.ParticleBasicMaterial||t.fog)){G.fogColor.value.setHex(x.color.hex);if(x instanceof THREE.Fog){G.fogNear.value=x.near;G.fogFar.value=
-x.far}else if(x instanceof THREE.FogExp2)G.fogDensity.value=x.density}if(t instanceof THREE.MeshPhongMaterial||t instanceof THREE.MeshLambertMaterial||t.lights){var O,D,I=0,Q=0,sa=0,W,Ba,ra,za,Ia=N,Sa=Ia.directional.colors,ea=Ia.directional.positions,ca=Ia.point.colors,ja=Ia.point.positions,La=Ia.point.distances,V=0,P=0;x=D=za=0;for(O=A.length;x<O;x++){D=A[x];W=D.color;Ba=D.position;ra=D.intensity;za=D.distance;if(D instanceof THREE.AmbientLight){I+=W.r;Q+=W.g;sa+=W.b}else if(D instanceof THREE.DirectionalLight){za=
-V*3;Sa[za]=W.r*ra;Sa[za+1]=W.g*ra;Sa[za+2]=W.b*ra;ea[za]=Ba.x;ea[za+1]=Ba.y;ea[za+2]=Ba.z;V+=1}else if(D instanceof THREE.PointLight){D=P*3;ca[D]=W.r*ra;ca[D+1]=W.g*ra;ca[D+2]=W.b*ra;ja[D]=Ba.x;ja[D+1]=Ba.y;ja[D+2]=Ba.z;La[P]=za;P+=1}}for(x=V*3;x<Sa.length;x++)Sa[x]=0;for(x=P*3;x<ca.length;x++)ca[x]=0;Ia.point.length=P;Ia.directional.length=V;Ia.ambient[0]=I;Ia.ambient[1]=Q;Ia.ambient[2]=sa;x=N;G.enableLighting.value=x.directional.length+x.point.length;G.ambientLightColor.value=x.ambient;G.directionalLightColor.value=
-x.directional.colors;G.directionalLightDirection.value=x.directional.positions;G.pointLightColor.value=x.point.colors;G.pointLightPosition.value=x.point.positions;G.pointLightDistance.value=x.point.distances}if(t instanceof THREE.MeshBasicMaterial||t instanceof THREE.MeshLambertMaterial||t instanceof THREE.MeshPhongMaterial){G.diffuse.value.setRGB(t.color.r,t.color.g,t.color.b);G.opacity.value=t.opacity;G.map.texture=t.map;G.lightMap.texture=t.lightMap;G.envMap.texture=t.envMap;G.reflectivity.value=
-t.reflectivity;G.refractionRatio.value=t.refractionRatio;G.combine.value=t.combine;G.useRefract.value=t.envMap&&t.envMap.mapping instanceof THREE.CubeRefractionMapping}if(t instanceof THREE.LineBasicMaterial){G.diffuse.value.setRGB(t.color.r,t.color.g,t.color.b);G.opacity.value=t.opacity}else if(t instanceof THREE.ParticleBasicMaterial){G.psColor.value.setRGB(t.color.r,t.color.g,t.color.b);G.opacity.value=t.opacity;G.size.value=t.size;G.scale.value=da.height/2;G.map.texture=t.map}else if(t instanceof
-THREE.MeshPhongMaterial){G.ambient.value.setRGB(t.ambient.r,t.ambient.g,t.ambient.b);G.specular.value.setRGB(t.specular.r,t.specular.g,t.specular.b);G.shininess.value=t.shininess}else if(t instanceof THREE.MeshDepthMaterial){G.mNear.value=m.near;G.mFar.value=m.far;G.opacity.value=t.opacity}else if(t instanceof THREE.MeshNormalMaterial)G.opacity.value=t.opacity;for(var Oa in G)if(Q=S.uniforms[Oa]){O=G[Oa];I=O.type;x=O.value;if(I=="i")e.uniform1i(Q,x);else if(I=="f")e.uniform1f(Q,x);else if(I=="fv1")e.uniform1fv(Q,
-x);else if(I=="fv")e.uniform3fv(Q,x);else if(I=="v2")e.uniform2f(Q,x.x,x.y);else if(I=="v3")e.uniform3f(Q,x.x,x.y,x.z);else if(I=="v4")e.uniform4f(Q,x.x,x.y,x.z,x.w);else if(I=="c")e.uniform3f(Q,x.r,x.g,x.b);else if(I=="t"){e.uniform1i(Q,x);if(O=O.texture)if(O.image instanceof Array&&O.image.length==6){if(O.image.length==6){if(O.needsUpdate){if(O.__webglInit){e.bindTexture(e.TEXTURE_CUBE_MAP,O.image.__webglTextureCube);for(I=0;I<6;++I)e.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+I,0,0,0,e.RGBA,e.UNSIGNED_BYTE,
-O.image[I])}else{O.image.__webglTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,O.image.__webglTextureCube);for(I=0;I<6;++I)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+I,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,O.image[I]);O.__webglInit=!0}L(e.TEXTURE_CUBE_MAP,O,O.image[0]);e.bindTexture(e.TEXTURE_CUBE_MAP,null);O.needsUpdate=!1}e.activeTexture(e.TEXTURE0+x);e.bindTexture(e.TEXTURE_CUBE_MAP,O.image.__webglTextureCube)}}else M(O,x)}}e.uniformMatrix4fv(E.modelViewMatrix,!1,w._modelViewMatrixArray);
-e.uniformMatrix3fv(E.normalMatrix,!1,w._normalMatrixArray);(t instanceof THREE.MeshShaderMaterial||t instanceof THREE.MeshPhongMaterial||t.envMap)&&e.uniform3f(E.cameraPosition,m.position.x,m.position.y,m.position.z);(t instanceof THREE.MeshShaderMaterial||t.envMap||t.skinning)&&e.uniformMatrix4fv(E.objectMatrix,!1,w._objectMatrixArray);(t instanceof THREE.MeshPhongMaterial||t instanceof THREE.MeshLambertMaterial||t instanceof THREE.MeshShaderMaterial||t.skinning)&&e.uniformMatrix4fv(E.viewMatrix,
-!1,ab);if(t instanceof THREE.ShadowVolumeDynamicMaterial){m=G.directionalLightDirection.value;m[0]=-A.position.x;m[1]=-A.position.y;m[2]=-A.position.z;e.uniform3fv(E.directionalLightDirection,m);e.uniformMatrix4fv(E.objectMatrix,!1,w._objectMatrixArray);e.uniformMatrix4fv(E.viewMatrix,!1,ab)}if(t.skinning){e.uniformMatrix4fv(E.cameraInverseMatrix,!1,ab);e.uniformMatrix4fv(E.boneGlobalMatrices,!1,w.boneMatrices)}return S}function g(m,A,x,t,w,S){if(t.opacity!=0){var E;m=f(m,A,x,t,S).attributes;if(t.morphTargets){A=
-t.program.attributes;S.morphTargetBase!==-1?e.bindBuffer(e.ARRAY_BUFFER,w.__webglMorphTargetsBuffers[S.morphTargetBase]):e.bindBuffer(e.ARRAY_BUFFER,w.__webglVertexBuffer);e.vertexAttribPointer(A.position,3,e.FLOAT,!1,0,0);if(S.morphTargetForcedOrder.length){x=0;for(var G=S.morphTargetForcedOrder,O=S.morphTargetInfluences;x<t.numSupportedMorphTargets&&x<G.length;){e.bindBuffer(e.ARRAY_BUFFER,w.__webglMorphTargetsBuffers[G[x]]);e.vertexAttribPointer(A["morphTarget"+x],3,e.FLOAT,!1,0,0);S.__webglMorphTargetInfluences[x]=
-O[G[x]];x++}}else{G=[];var D=-1,I=0;O=S.morphTargetInfluences;var Q,sa=O.length;x=0;for(S.morphTargetBase!==-1&&(G[S.morphTargetBase]=!0);x<t.numSupportedMorphTargets;){for(Q=0;Q<sa;Q++)if(!G[Q]&&O[Q]>D){I=Q;D=O[I]}e.bindBuffer(e.ARRAY_BUFFER,w.__webglMorphTargetsBuffers[I]);e.vertexAttribPointer(A["morphTarget"+x],3,e.FLOAT,!1,0,0);S.__webglMorphTargetInfluences[x]=D;G[I]=1;D=-1;x++}}e.uniform1fv(t.program.uniforms.morphTargetInfluences,S.__webglMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,
-w.__webglVertexBuffer);e.vertexAttribPointer(m.position,3,e.FLOAT,!1,0,0)}if(w.__webglCustomAttributes)for(E in w.__webglCustomAttributes)if(m[E]>=0){A=w.__webglCustomAttributes[E];e.bindBuffer(e.ARRAY_BUFFER,A.buffer);e.vertexAttribPointer(m[E],A.size,e.FLOAT,!1,0,0)}if(m.color>=0){e.bindBuffer(e.ARRAY_BUFFER,w.__webglColorBuffer);e.vertexAttribPointer(m.color,3,e.FLOAT,!1,0,0)}if(m.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,w.__webglNormalBuffer);e.vertexAttribPointer(m.normal,3,e.FLOAT,!1,0,0)}if(m.tangent>=
-0){e.bindBuffer(e.ARRAY_BUFFER,w.__webglTangentBuffer);e.vertexAttribPointer(m.tangent,4,e.FLOAT,!1,0,0)}if(m.uv>=0)if(w.__webglUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,w.__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(w.__webglUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,w.__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,w.__webglSkinVertexABuffer);e.vertexAttribPointer(m.skinVertexA,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,w.__webglSkinVertexBBuffer);e.vertexAttribPointer(m.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,w.__webglSkinIndicesBuffer);e.vertexAttribPointer(m.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,w.__webglSkinWeightsBuffer);e.vertexAttribPointer(m.skinWeight,
-4,e.FLOAT,!1,0,0)}if(S instanceof THREE.Mesh)if(t.wireframe){e.lineWidth(t.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,w.__webglLineBuffer);e.drawElements(e.LINES,w.__webglLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,w.__webglFaceBuffer);e.drawElements(e.TRIANGLES,w.__webglFaceCount,e.UNSIGNED_SHORT,0)}else if(S instanceof THREE.Line){S=S.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(t.linewidth);e.drawArrays(S,0,w.__webglLineCount)}else if(S instanceof
-THREE.ParticleSystem)e.drawArrays(e.POINTS,0,w.__webglParticleCount);else S instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,w.__webglVertexCount)}}function h(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 j(m){if(pa!=m.doubleSided){m.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);pa=m.doubleSided}if(Da!=m.flipSided){m.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);Da=m.flipSided}}function k(m){if(Y!=
-m){m?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);Y=m}}function n(m){wa[0].set(m.n41-m.n11,m.n42-m.n12,m.n43-m.n13,m.n44-m.n14);wa[1].set(m.n41+m.n11,m.n42+m.n12,m.n43+m.n13,m.n44+m.n14);wa[2].set(m.n41+m.n21,m.n42+m.n22,m.n43+m.n23,m.n44+m.n24);wa[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);wa[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);wa[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=wa[m];A.divideScalar(Math.sqrt(A.x*A.x+A.y*A.y+A.z*
-A.z))}}function p(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=wa[t].x*A.n14+wa[t].y*A.n24+wa[t].z*A.n34+wa[t].w;if(m<=x)return!1}return!0}function o(m,A){m.list[m.count]=A;m.count+=1}function u(m){var A,x,t=m.object,w=m.opaque,S=m.transparent;S.count=0;m=w.count=0;for(A=t.materials.length;m<A;m++){x=t.materials[m];x.transparent?o(S,x):o(w,x)}}function y(m){var A,x,t,w,S=m.object,E=m.buffer,G=m.opaque,O=m.transparent;
-O.count=0;m=G.count=0;for(t=S.materials.length;m<t;m++){A=S.materials[m];if(A instanceof THREE.MeshFaceMaterial){A=0;for(x=E.materials.length;A<x;A++)(w=E.materials[A])&&(w.transparent?o(O,w):o(G,w))}else(w=A)&&(w.transparent?o(O,w):o(G,w))}}function v(m,A){return A.z-m.z}function B(m){e.enable(e.POLYGON_OFFSET_FILL);e.polygonOffset(0.1,1);e.enable(e.STENCIL_TEST);e.enable(e.DEPTH_TEST);e.depthMask(!1);e.colorMask(!1,!1,!1,!1);e.stencilFunc(e.ALWAYS,1,255);e.stencilOpSeparate(e.BACK,e.KEEP,e.INCR,
-e.KEEP);e.stencilOpSeparate(e.FRONT,e.KEEP,e.DECR,e.KEEP);var A,x=m.lights.length,t,w=m.lights,S=[],E,G,O,D,I,Q=m.__webglShadowVolumes.length;for(A=0;A<x;A++){t=m.lights[A];if(t instanceof THREE.DirectionalLight){S[0]=-t.position.x;S[1]=-t.position.y;S[2]=-t.position.z;for(I=0;I<Q;I++){t=m.__webglShadowVolumes[I].object;E=m.__webglShadowVolumes[I].buffer;G=t.materials[0];G.program||$.initMaterial(G,w,undefined,t);G=G.program;O=G.uniforms;D=G.attributes;if(Aa!==G){e.useProgram(G);Aa=G;e.uniformMatrix4fv(O.projectionMatrix,
-!1,cb);e.uniformMatrix4fv(O.viewMatrix,!1,ab);e.uniform3fv(O.directionalLightDirection,S)}t.matrixWorld.flattenToArray(t._objectMatrixArray);e.uniformMatrix4fv(O.objectMatrix,!1,t._objectMatrixArray);e.bindBuffer(e.ARRAY_BUFFER,E.__webglVertexBuffer);e.vertexAttribPointer(D.position,3,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,E.__webglNormalBuffer);e.vertexAttribPointer(D.normal,3,e.FLOAT,!1,0,0);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,E.__webglFaceBuffer);e.cullFace(e.FRONT);e.drawElements(e.TRIANGLES,
-E.__webglFaceCount,e.UNSIGNED_SHORT,0);e.cullFace(e.BACK);e.drawElements(e.TRIANGLES,E.__webglFaceCount,e.UNSIGNED_SHORT,0)}}}e.disable(e.POLYGON_OFFSET_FILL);e.colorMask(!0,!0,!0,!0);e.stencilFunc(e.NOTEQUAL,0,255);e.stencilOp(e.KEEP,e.KEEP,e.KEEP);e.disable(e.DEPTH_TEST);ga="";Aa=ya.program;e.useProgram(ya.program);e.uniformMatrix4fv(ya.projectionLocation,!1,cb);e.uniform1f(ya.darknessLocation,ya.darkness);e.bindBuffer(e.ARRAY_BUFFER,ya.vertexBuffer);e.vertexAttribPointer(ya.vertexLocation,3,e.FLOAT,
-!1,0,0);e.enableVertexAttribArray(ya.vertexLocation);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.blendEquation(e.FUNC_ADD);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ya.elementBuffer);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);e.disable(e.STENCIL_TEST);e.enable(e.DEPTH_TEST);e.depthMask(qa)}function C(m,A){var x,t,w,S=m.__webglLensFlares.length,E,G,O;E=new THREE.Vector3;var D=na/ka;G=ka*0.5;O=na*0.5;var I=16/na,Q=[I*D,I],sa=[1,1,0];I=[1,1];var W,Ba=ia.readBackPixels,ra,za,Ia=ia.uniforms;x=ia.attributes;
-e.useProgram(ia.program);Aa=ia.program;ga="";e.uniform1i(Ia.map,0);e.activeTexture(e.TEXTURE0);e.uniform1f(Ia.opacity,1);e.uniform1f(Ia.rotation,0);e.uniform2fv(Ia.scale,Q);e.bindBuffer(e.ARRAY_BUFFER,ia.vertexBuffer);e.vertexAttribPointer(x.vertex,2,e.FLOAT,!1,16,0);e.vertexAttribPointer(x.uv,2,e.FLOAT,!1,16,8);e.bindTexture(e.TEXTURE_2D,ia.tempTexture);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ia.elementBuffer);e.disable(e.CULL_FACE);e.depthMask(!1);for(w=0;w<S;w++){x=m.__webglLensFlares[w].object;E.set(x.matrixWorld.n14,
-x.matrixWorld.n24,x.matrixWorld.n34);A.matrixWorldInverse.multiplyVector3(E);t=E.z;A.projectionMatrix.multiplyVector3(E);sa[0]=E.x;sa[1]=E.y;sa[2]=E.z;I[0]=sa[0]*G+G;I[1]=sa[1]*O+O;e.copyTexSubImage2D(e.TEXTURE_2D,0,0,0,I[0]-8,I[1]-8,16,16);e.uniform3fv(Ia.screenPosition,sa);e.uniform1i(Ia.renderPink,1);e.enable(e.DEPTH_TEST);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);try{e.readPixels(I[0]-8,I[1]-8,16,16,e.RGBA,e.UNSIGNED_BYTE,ia.readBackPixels)}catch(Sa){console.log("WebGLRenderer.renderLensFlare: readPixels failed!")}e.getError()&&
-console.log("WebGLRenderer.renderLensFlare: readPixels failed!");sampleDistance=parseInt(5*(1-Math.max(0,Math.min(-t,A.far))/A.far),10)+2;t=sampleDistance*4;W=sampleDistance*64;za=0;ra=28-t+(448-W);ia.readBackPixels[ra+0]===255&&ia.readBackPixels[ra+1]===0&&ia.readBackPixels[ra+2]===255&&(za+=0.2);ra=28+t+(448-W);Ba[ra+0]===255&&Ba[ra+1]===0&&Ba[ra+2]===255&&(za+=0.2);ra=28+t+(448+W);Ba[ra+0]===255&&Ba[ra+1]===0&&Ba[ra+2]===255&&(za+=0.2);ra=28-t+(448+W);Ba[ra+0]===255&&Ba[ra+1]===0&&Ba[ra+2]===255&&
-(za+=0.2);ra=476;Ba[ra+0]===255&&Ba[ra+1]===0&&Ba[ra+2]===255&&(za+=0.2);x.positionScreen.x=sa[0];x.positionScreen.y=sa[1];x.positionScreen.z=sa[2];x.customUpdateCallback?x.customUpdateCallback(za,x):x.updateLensFlares(za);e.uniform1i(Ia.renderPink,0);e.disable(e.DEPTH_TEST);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}for(w=0;w<S;w++){x=m.__webglLensFlares[w].object;E=0;for(G=x.lensFlares.length;E<G;E++){O=x.lensFlares[E];if(O.opacity>0.0010&&O.scale>0.0010){sa[0]=O.x;sa[1]=O.y;sa[2]=O.z;I=O.size*
-O.scale/na;Q[0]=I*D;Q[1]=I;e.uniform3fv(Ia.screenPosition,sa);e.uniform1f(Ia.rotation,O.rotation);e.uniform2fv(Ia.scale,Q);e.uniform1f(Ia.opacity,O.opacity);J(O.blending);M(O.texture,0);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(qa)}function F(m,A){m._modelViewMatrix.multiplyToArray(A.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(m._modelViewMatrix).transposeIntoArray(m._normalMatrixArray)}function H(m){var A,
-x,t,w,S;if(m instanceof THREE.Mesh){x=m.geometry;for(A in x.geometryGroups){t=x.geometryGroups[A];S=!1;for(w in t.__webglCustomAttributes)if(t.__webglCustomAttributes[w].needsUpdate){S=!0;break}if(x.__dirtyVertices||x.__dirtyMorphTargets||x.__dirtyElements||x.__dirtyUvs||x.__dirtyNormals||x.__dirtyColors||x.__dirtyTangents||S){S=e.DYNAMIC_DRAW;var E=void 0,G=void 0,O=void 0,D=void 0;O=void 0;var I=void 0,Q=void 0,sa=void 0,W=void 0,Ba=void 0,ra=void 0,za=void 0,Ia=void 0,Sa=void 0,ea=void 0,ca=void 0,
-ja=void 0,La=void 0;Q=void 0;sa=void 0;D=void 0;W=void 0;D=void 0;ea=void 0;ca=void 0;Q=void 0;ea=void 0;ca=void 0;ja=void 0;La=void 0;ea=void 0;ca=void 0;ja=void 0;La=void 0;ea=void 0;ca=void 0;ja=void 0;La=void 0;ea=void 0;ca=void 0;ja=void 0;D=void 0;W=void 0;I=void 0;O=void 0;O=void 0;var V=void 0,P=void 0,Oa=void 0,fb=void 0,Na=0,Xa=0,gb=0,hb=0,Ya=0,eb=0,Ra=0,Ja=0,Ma=0,R=0,Va=0;V=0;var Za=t.__vertexArray,$a=t.__uvArray,T=t.__uv2Array,ta=t.__normalArray,fa=t.__tangentArray,aa=t.__colorArray,va=
-t.__skinVertexAArray,ua=t.__skinVertexBArray,ha=t.__skinIndexArray,K=t.__skinWeightArray,Qa=t.__morphTargetsArrays,db=t.__webglCustomAttributes;P=void 0;var Wa=t.__faceArray,bb=t.__lineArray,lb=t.__needsSmoothNormals;ra=t.__vertexColorType;Ba=t.__uvType;za=t.__normalType;var Ta=m.geometry,ib=Ta.__dirtyVertices,sb=Ta.__dirtyElements,rb=Ta.__dirtyUvs,tb=Ta.__dirtyNormals,ub=Ta.__dirtyTangents,vb=Ta.__dirtyColors,wb=Ta.__dirtyMorphTargets,nb=Ta.vertices,xb=t.faces,Ab=Ta.faces,yb=Ta.faceVertexUvs[0],
-zb=Ta.faceVertexUvs[1],ob=Ta.skinVerticesA,pb=Ta.skinVerticesB,qb=Ta.skinIndices,kb=Ta.skinWeights,mb=Ta.edgeFaces,jb=Ta.morphTargets;if(db)for(fb in db)db[fb].offset=0;E=0;for(G=xb.length;E<G;E++){O=xb[E];D=Ab[O];yb&&(Ia=yb[O]);zb&&(Sa=zb[O]);O=D.vertexNormals;I=D.normal;Q=D.vertexColors;sa=D.color;W=D.vertexTangents;if(D instanceof THREE.Face3){if(ib){ea=nb[D.a].position;ca=nb[D.b].position;ja=nb[D.c].position;Za[Xa]=ea.x;Za[Xa+1]=ea.y;Za[Xa+2]=ea.z;Za[Xa+3]=ca.x;Za[Xa+4]=ca.y;Za[Xa+5]=ca.z;Za[Xa+
-6]=ja.x;Za[Xa+7]=ja.y;Za[Xa+8]=ja.z;Xa+=9}if(db)for(fb in db){P=db[fb];if(P.needsUpdate){V=P.offset;if(P.size===1){P.array[V+0]=P.value[D.a];P.array[V+1]=P.value[D.b];P.array[V+2]=P.value[D.c];P.offset+=3}else{ea=P.value[D.a];ca=P.value[D.b];ja=P.value[D.c];if(P.size===2){P.array[V+0]=ea.x;P.array[V+1]=ea.y;P.array[V+2]=ca.x;P.array[V+3]=ca.y;P.array[V+4]=ja.x;P.array[V+5]=ja.y;P.offset+=6}else if(P.size===3){P.array[V+0]=ea.x;P.array[V+1]=ea.y;P.array[V+2]=ea.z;P.array[V+3]=ca.x;P.array[V+4]=ca.y;
-P.array[V+5]=ca.z;P.array[V+6]=ja.x;P.array[V+7]=ja.y;P.array[V+8]=ja.z;P.offset+=9}else{P.array[V+0]=ea.x;P.array[V+1]=ea.y;P.array[V+2]=ea.z;P.array[V+3]=ea.w;P.array[V+4]=ca.x;P.array[V+5]=ca.y;P.array[V+6]=ca.z;P.array[V+7]=ca.w;P.array[V+8]=ja.x;P.array[V+9]=ja.y;P.array[V+10]=ja.z;P.array[V+11]=ja.w;P.offset+=12}}}}if(wb){V=0;for(P=jb.length;V<P;V++){ea=jb[V].vertices[D.a].position;ca=jb[V].vertices[D.b].position;ja=jb[V].vertices[D.c].position;Oa=Qa[V];Oa[Va+0]=ea.x;Oa[Va+1]=ea.y;Oa[Va+2]=
-ea.z;Oa[Va+3]=ca.x;Oa[Va+4]=ca.y;Oa[Va+5]=ca.z;Oa[Va+6]=ja.x;Oa[Va+7]=ja.y;Oa[Va+8]=ja.z}Va+=9}if(kb.length){ea=kb[D.a];ca=kb[D.b];ja=kb[D.c];K[R]=ea.x;K[R+1]=ea.y;K[R+2]=ea.z;K[R+3]=ea.w;K[R+4]=ca.x;K[R+5]=ca.y;K[R+6]=ca.z;K[R+7]=ca.w;K[R+8]=ja.x;K[R+9]=ja.y;K[R+10]=ja.z;K[R+11]=ja.w;ea=qb[D.a];ca=qb[D.b];ja=qb[D.c];ha[R]=ea.x;ha[R+1]=ea.y;ha[R+2]=ea.z;ha[R+3]=ea.w;ha[R+4]=ca.x;ha[R+5]=ca.y;ha[R+6]=ca.z;ha[R+7]=ca.w;ha[R+8]=ja.x;ha[R+9]=ja.y;ha[R+10]=ja.z;ha[R+11]=ja.w;ea=ob[D.a];ca=ob[D.b];ja=ob[D.c];
-va[R]=ea.x;va[R+1]=ea.y;va[R+2]=ea.z;va[R+3]=1;va[R+4]=ca.x;va[R+5]=ca.y;va[R+6]=ca.z;va[R+7]=1;va[R+8]=ja.x;va[R+9]=ja.y;va[R+10]=ja.z;va[R+11]=1;ea=pb[D.a];ca=pb[D.b];ja=pb[D.c];ua[R]=ea.x;ua[R+1]=ea.y;ua[R+2]=ea.z;ua[R+3]=1;ua[R+4]=ca.x;ua[R+5]=ca.y;ua[R+6]=ca.z;ua[R+7]=1;ua[R+8]=ja.x;ua[R+9]=ja.y;ua[R+10]=ja.z;ua[R+11]=1;R+=12}if(vb&&ra){if(Q.length==3&&ra==THREE.VertexColors){D=Q[0];ea=Q[1];ca=Q[2]}else ca=ea=D=sa;aa[Ma]=D.r;aa[Ma+1]=D.g;aa[Ma+2]=D.b;aa[Ma+3]=ea.r;aa[Ma+4]=ea.g;aa[Ma+5]=ea.b;
-aa[Ma+6]=ca.r;aa[Ma+7]=ca.g;aa[Ma+8]=ca.b;Ma+=9}if(ub&&Ta.hasTangents){Q=W[0];sa=W[1];D=W[2];fa[Ra]=Q.x;fa[Ra+1]=Q.y;fa[Ra+2]=Q.z;fa[Ra+3]=Q.w;fa[Ra+4]=sa.x;fa[Ra+5]=sa.y;fa[Ra+6]=sa.z;fa[Ra+7]=sa.w;fa[Ra+8]=D.x;fa[Ra+9]=D.y;fa[Ra+10]=D.z;fa[Ra+11]=D.w;Ra+=12}if(tb&&za)if(O.length==3&&lb)for(W=0;W<3;W++){I=O[W];ta[eb]=I.x;ta[eb+1]=I.y;ta[eb+2]=I.z;eb+=3}else for(W=0;W<3;W++){ta[eb]=I.x;ta[eb+1]=I.y;ta[eb+2]=I.z;eb+=3}if(rb&&Ia!==undefined&&Ba)for(W=0;W<3;W++){O=Ia[W];$a[gb]=O.u;$a[gb+1]=O.v;gb+=2}if(rb&&
-Sa!==undefined&&Ba)for(W=0;W<3;W++){O=Sa[W];T[hb]=O.u;T[hb+1]=O.v;hb+=2}if(sb){Wa[Ya]=Na;Wa[Ya+1]=Na+1;Wa[Ya+2]=Na+2;Ya+=3;bb[Ja]=Na;bb[Ja+1]=Na+1;bb[Ja+2]=Na;bb[Ja+3]=Na+2;bb[Ja+4]=Na+1;bb[Ja+5]=Na+2;Ja+=6;Na+=3}}else if(D instanceof THREE.Face4){if(ib){ea=nb[D.a].position;ca=nb[D.b].position;ja=nb[D.c].position;La=nb[D.d].position;Za[Xa]=ea.x;Za[Xa+1]=ea.y;Za[Xa+2]=ea.z;Za[Xa+3]=ca.x;Za[Xa+4]=ca.y;Za[Xa+5]=ca.z;Za[Xa+6]=ja.x;Za[Xa+7]=ja.y;Za[Xa+8]=ja.z;Za[Xa+9]=La.x;Za[Xa+10]=La.y;Za[Xa+11]=La.z;
-Xa+=12}if(db)for(fb in db){P=db[fb];if(P.needsUpdate){V=P.offset;if(P.size===1){P.array[V+0]=P.value[D.a];P.array[V+1]=P.value[D.b];P.array[V+2]=P.value[D.c];P.array[V+2]=P.value[D.d];P.offset+=4}else{ea=P.value[D.a];ca=P.value[D.b];ja=P.value[D.c];La=P.value[D.d];if(P.size===2){P.array[V+0]=ea.x;P.array[V+1]=ea.y;P.array[V+2]=ca.x;P.array[V+3]=ca.y;P.array[V+4]=ja.x;P.array[V+5]=ja.y;P.array[V+6]=La.x;P.array[V+7]=La.y;P.offset+=8}else if(P.size===3){P.array[V+0]=ea.x;P.array[V+1]=ea.y;P.array[V+
-2]=ea.z;P.array[V+3]=ca.x;P.array[V+4]=ca.y;P.array[V+5]=ca.z;P.array[V+6]=ja.x;P.array[V+7]=ja.y;P.array[V+8]=ja.z;P.array[V+9]=La.x;P.array[V+10]=La.y;P.array[V+11]=La.z;P.offset+=12}else{P.array[V+0]=ea.x;P.array[V+1]=ea.y;P.array[V+2]=ea.z;P.array[V+3]=ea.w;P.array[V+4]=ca.x;P.array[V+5]=ca.y;P.array[V+6]=ca.z;P.array[V+7]=ca.w;P.array[V+8]=ja.x;P.array[V+9]=ja.y;P.array[V+10]=ja.z;P.array[V+11]=ja.w;P.array[V+12]=La.x;P.array[V+13]=La.y;P.array[V+14]=La.z;P.array[V+15]=La.w;P.offset+=16}}}}if(wb){V=
-0;for(P=jb.length;V<P;V++){ea=jb[V].vertices[D.a].position;ca=jb[V].vertices[D.b].position;ja=jb[V].vertices[D.c].position;La=jb[V].vertices[D.d].position;Oa=Qa[V];Oa[Va+0]=ea.x;Oa[Va+1]=ea.y;Oa[Va+2]=ea.z;Oa[Va+3]=ca.x;Oa[Va+4]=ca.y;Oa[Va+5]=ca.z;Oa[Va+6]=ja.x;Oa[Va+7]=ja.y;Oa[Va+8]=ja.z;Oa[Va+9]=La.x;Oa[Va+10]=La.y;Oa[Va+11]=La.z}Va+=12}if(kb.length){ea=kb[D.a];ca=kb[D.b];ja=kb[D.c];La=kb[D.d];K[R]=ea.x;K[R+1]=ea.y;K[R+2]=ea.z;K[R+3]=ea.w;K[R+4]=ca.x;K[R+5]=ca.y;K[R+6]=ca.z;K[R+7]=ca.w;K[R+8]=ja.x;
-K[R+9]=ja.y;K[R+10]=ja.z;K[R+11]=ja.w;K[R+12]=La.x;K[R+13]=La.y;K[R+14]=La.z;K[R+15]=La.w;ea=qb[D.a];ca=qb[D.b];ja=qb[D.c];La=qb[D.d];ha[R]=ea.x;ha[R+1]=ea.y;ha[R+2]=ea.z;ha[R+3]=ea.w;ha[R+4]=ca.x;ha[R+5]=ca.y;ha[R+6]=ca.z;ha[R+7]=ca.w;ha[R+8]=ja.x;ha[R+9]=ja.y;ha[R+10]=ja.z;ha[R+11]=ja.w;ha[R+12]=La.x;ha[R+13]=La.y;ha[R+14]=La.z;ha[R+15]=La.w;ea=ob[D.a];ca=ob[D.b];ja=ob[D.c];La=ob[D.d];va[R]=ea.x;va[R+1]=ea.y;va[R+2]=ea.z;va[R+3]=1;va[R+4]=ca.x;va[R+5]=ca.y;va[R+6]=ca.z;va[R+7]=1;va[R+8]=ja.x;va[R+
-9]=ja.y;va[R+10]=ja.z;va[R+11]=1;va[R+12]=La.x;va[R+13]=La.y;va[R+14]=La.z;va[R+15]=1;ea=pb[D.a];ca=pb[D.b];ja=pb[D.c];D=pb[D.d];ua[R]=ea.x;ua[R+1]=ea.y;ua[R+2]=ea.z;ua[R+3]=1;ua[R+4]=ca.x;ua[R+5]=ca.y;ua[R+6]=ca.z;ua[R+7]=1;ua[R+8]=ja.x;ua[R+9]=ja.y;ua[R+10]=ja.z;ua[R+11]=1;ua[R+12]=D.x;ua[R+13]=D.y;ua[R+14]=D.z;ua[R+15]=1;R+=16}if(vb&&ra){if(Q.length==4&&ra==THREE.VertexColors){D=Q[0];ea=Q[1];ca=Q[2];Q=Q[3]}else Q=ca=ea=D=sa;aa[Ma]=D.r;aa[Ma+1]=D.g;aa[Ma+2]=D.b;aa[Ma+3]=ea.r;aa[Ma+4]=ea.g;aa[Ma+
-5]=ea.b;aa[Ma+6]=ca.r;aa[Ma+7]=ca.g;aa[Ma+8]=ca.b;aa[Ma+9]=Q.r;aa[Ma+10]=Q.g;aa[Ma+11]=Q.b;Ma+=12}if(ub&&Ta.hasTangents){Q=W[0];sa=W[1];D=W[2];W=W[3];fa[Ra]=Q.x;fa[Ra+1]=Q.y;fa[Ra+2]=Q.z;fa[Ra+3]=Q.w;fa[Ra+4]=sa.x;fa[Ra+5]=sa.y;fa[Ra+6]=sa.z;fa[Ra+7]=sa.w;fa[Ra+8]=D.x;fa[Ra+9]=D.y;fa[Ra+10]=D.z;fa[Ra+11]=D.w;fa[Ra+12]=W.x;fa[Ra+13]=W.y;fa[Ra+14]=W.z;fa[Ra+15]=W.w;Ra+=16}if(tb&&za)if(O.length==4&&lb)for(W=0;W<4;W++){I=O[W];ta[eb]=I.x;ta[eb+1]=I.y;ta[eb+2]=I.z;eb+=3}else for(W=0;W<4;W++){ta[eb]=I.x;
-ta[eb+1]=I.y;ta[eb+2]=I.z;eb+=3}if(rb&&Ia!==undefined&&Ba)for(W=0;W<4;W++){O=Ia[W];$a[gb]=O.u;$a[gb+1]=O.v;gb+=2}if(rb&&Sa!==undefined&&Ba)for(W=0;W<4;W++){O=Sa[W];T[hb]=O.u;T[hb+1]=O.v;hb+=2}if(sb){Wa[Ya]=Na;Wa[Ya+1]=Na+1;Wa[Ya+2]=Na+3;Wa[Ya+3]=Na+1;Wa[Ya+4]=Na+2;Wa[Ya+5]=Na+3;Ya+=6;bb[Ja]=Na;bb[Ja+1]=Na+1;bb[Ja+2]=Na;bb[Ja+3]=Na+3;bb[Ja+4]=Na+1;bb[Ja+5]=Na+2;bb[Ja+6]=Na+2;bb[Ja+7]=Na+3;Ja+=8;Na+=4}}}if(mb){E=0;for(G=mb.length;E<G;E++){Wa[Ya]=mb[E].a;Wa[Ya+1]=mb[E].b;Wa[Ya+2]=mb[E].c;Wa[Ya+3]=mb[E].a;
-Wa[Ya+4]=mb[E].c;Wa[Ya+5]=mb[E].d;Ya+=6}}if(ib){e.bindBuffer(e.ARRAY_BUFFER,t.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Za,S)}if(db)for(fb in db){P=db[fb];if(P.needsUpdate){e.bindBuffer(e.ARRAY_BUFFER,P.buffer);e.bufferData(e.ARRAY_BUFFER,P.array,S);P.needsUpdate=!1}}if(wb){V=0;for(P=jb.length;V<P;V++){e.bindBuffer(e.ARRAY_BUFFER,t.__webglMorphTargetsBuffers[V]);e.bufferData(e.ARRAY_BUFFER,Qa[V],S)}}if(vb&&Ma>0){e.bindBuffer(e.ARRAY_BUFFER,t.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,
-aa,S)}if(tb){e.bindBuffer(e.ARRAY_BUFFER,t.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,ta,S)}if(ub&&Ta.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,t.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,fa,S)}if(rb&&gb>0){e.bindBuffer(e.ARRAY_BUFFER,t.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,$a,S)}if(rb&&hb>0){e.bindBuffer(e.ARRAY_BUFFER,t.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,T,S)}if(sb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Wa,S);
-e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,t.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,bb,S)}if(R>0){e.bindBuffer(e.ARRAY_BUFFER,t.__webglSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,va,S);e.bindBuffer(e.ARRAY_BUFFER,t.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ua,S);e.bindBuffer(e.ARRAY_BUFFER,t.__webglSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,ha,S);e.bindBuffer(e.ARRAY_BUFFER,t.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,K,S)}}}x.__dirtyVertices=!1;x.__dirtyMorphTargets=
-!1;x.__dirtyElements=!1;x.__dirtyUvs=!1;x.__dirtyNormals=!1;x.__dirtyTangents=!1;x.__dirtyColors=!1}else if(m instanceof THREE.Ribbon){x=m.geometry;if(x.__dirtyVertices||x.__dirtyColors){m=x;A=e.DYNAMIC_DRAW;ra=m.vertices;t=m.colors;za=ra.length;S=t.length;Ia=m.__vertexArray;E=m.__colorArray;Sa=m.__dirtyColors;if(m.__dirtyVertices){for(G=0;G<za;G++){Ba=ra[G].position;w=G*3;Ia[w]=Ba.x;Ia[w+1]=Ba.y;Ia[w+2]=Ba.z}e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ia,A)}if(Sa){for(G=
-0;G<S;G++){color=t[G];w=G*3;E[w]=color.r;E[w+1]=color.g;E[w+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,E,A)}}x.__dirtyVertices=!1;x.__dirtyColors=!1}else if(m instanceof THREE.Line){x=m.geometry;if(x.__dirtyVertices||x.__dirtyColors){m=x;A=e.DYNAMIC_DRAW;ra=m.vertices;t=m.colors;za=ra.length;S=t.length;Ia=m.__vertexArray;E=m.__colorArray;Sa=m.__dirtyColors;if(m.__dirtyVertices){for(G=0;G<za;G++){Ba=ra[G].position;w=G*3;Ia[w]=Ba.x;Ia[w+1]=Ba.y;Ia[w+2]=
-Ba.z}e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Ia,A)}if(Sa){for(G=0;G<S;G++){color=t[G];w=G*3;E[w]=color.r;E[w+1]=color.g;E[w+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,E,A)}}x.__dirtyVertices=!1;x.__dirtyColors=!1}else if(m instanceof THREE.ParticleSystem){x=m.geometry;(x.__dirtyVertices||x.__dirtyColors||m.sortParticles)&&d(x,e.DYNAMIC_DRAW,m);x.__dirtyVertices=!1;x.__dirtyColors=!1}}function U(m){function A(sa){var W=
-[];x=0;for(t=sa.length;x<t;x++)sa[x]==undefined?W.push("undefined"):W.push(sa[x].id);return W.join("_")}var x,t,w,S,E,G,O,D,I={},Q=m.morphTargets!==undefined?m.morphTargets.length:0;m.geometryGroups={};w=0;for(S=m.faces.length;w<S;w++){E=m.faces[w];G=E.materials;O=A(G);I[O]==undefined&&(I[O]={hash:O,counter:0});D=I[O].hash+"_"+I[O].counter;m.geometryGroups[D]==undefined&&(m.geometryGroups[D]={faces:[],materials:G,vertices:0,numMorphTargets:Q});E=E instanceof THREE.Face3?3:4;if(m.geometryGroups[D].vertices+
-E>65535){I[O].counter+=1;D=I[O].hash+"_"+I[O].counter;m.geometryGroups[D]==undefined&&(m.geometryGroups[D]={faces:[],materials:G,vertices:0,numMorphTargets:Q})}m.geometryGroups[D].faces.push(w);m.geometryGroups[D].vertices+=E}}function z(m,A,x){m.push({buffer:A,object:x,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function J(m){if(m!=ga){switch(m){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);
-e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD);e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}ga=m}}function L(m,A,x){if((x.width&x.width-1)==0&&(x.height&x.height-1)==0){e.texParameteri(m,e.TEXTURE_WRAP_S,Z(A.wrapS));e.texParameteri(m,e.TEXTURE_WRAP_T,Z(A.wrapT));e.texParameteri(m,e.TEXTURE_MAG_FILTER,Z(A.magFilter));
-e.texParameteri(m,e.TEXTURE_MIN_FILTER,Z(A.minFilter));e.generateMipmap(m)}else{e.texParameteri(m,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(m,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(m,e.TEXTURE_MAG_FILTER,xa(A.magFilter));e.texParameteri(m,e.TEXTURE_MIN_FILTER,xa(A.minFilter))}}function M(m,A){if(m.needsUpdate){if(m.__webglInit){e.bindTexture(e.TEXTURE_2D,m.__webglTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,m.image)}else{m.__webglTexture=e.createTexture();
-e.bindTexture(e.TEXTURE_2D,m.__webglTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,m.image);m.__webglInit=!0}L(e.TEXTURE_2D,m,m.image);e.bindTexture(e.TEXTURE_2D,null);m.needsUpdate=!1}e.activeTexture(e.TEXTURE0+A);e.bindTexture(e.TEXTURE_2D,m.__webglTexture)}function Fa(m){if(m&&!m.__webglFramebuffer){if(m.depthBuffer===undefined)m.depthBuffer=!0;if(m.stencilBuffer===undefined)m.stencilBuffer=!0;m.__webglFramebuffer=e.createFramebuffer();m.__webglRenderbuffer=e.createRenderbuffer();
-m.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,m.__webglTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,Z(m.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,Z(m.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,Z(m.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,Z(m.minFilter));e.texImage2D(e.TEXTURE_2D,0,Z(m.format),m.width,m.height,0,Z(m.format),Z(m.type),null);e.bindRenderbuffer(e.RENDERBUFFER,m.__webglRenderbuffer);e.bindFramebuffer(e.FRAMEBUFFER,
-m.__webglFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,m.__webglTexture,0);if(m.depthBuffer&&!m.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,m.width,m.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,m.__webglRenderbuffer)}else if(m.depthBuffer&&m.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,m.width,m.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,
-m.__webglRenderbuffer)}else e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,m.width,m.height);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var A,x;if(m){A=m.__webglFramebuffer;x=m.width;m=m.height}else{A=null;x=ka;m=na}if(A!=Ha){e.bindFramebuffer(e.FRAMEBUFFER,A);e.viewport(la,Ga,x,m);Ha=A}}function oa(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)){console.error(e.getShaderInfoLog(x));console.error(A);return null}return x}function xa(m){switch(m){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function Z(m){switch(m){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;
-case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;
-case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var e,da=document.createElement("canvas"),Ca=[],Aa=null,Ha=null,qa=!0,$=this,pa=null,Da=null,ga=null,Y=null,la=0,Ga=0,ka=0,na=0,wa=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
-new THREE.Vector4,new THREE.Vector4],Ua=new THREE.Matrix4,cb=new Float32Array(16),ab=new Float32Array(16),Pa=new THREE.Vector4,N={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},X=!0,ma=!0,Ea=new THREE.Color(0),Ka=0;if(b){if(b.stencil!=undefined)X=b.stencil;if(b.antialias!==undefined)ma=b.antialias;b.clearColor!==undefined&&Ea.setHex(b.clearColor);if(b.clearAlpha!==undefined)Ka=b.clearAlpha}this.maxMorphTargets=8;this.domElement=
-da;this.autoClear=!0;this.sortObjects=!0;(function(m,A,x,t){try{if(!(e=da.getContext("experimental-webgl",{antialias:m,stencil:t})))throw"Error creating WebGL context.";}catch(w){console.error(w)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);e.clearColor(A.r,A.g,A.b,x)})(ma,Ea,Ka,X);this.context=e;if(X){var ya=
-{};ya.vertices=new Float32Array(12);ya.faces=new Uint16Array(6);ya.darkness=0.5;ya.vertices[0]=-20;ya.vertices[1]=-20;ya.vertices[2]=-1;ya.vertices[3]=20;ya.vertices[4]=-20;ya.vertices[5]=-1;ya.vertices[6]=20;ya.vertices[7]=20;ya.vertices[8]=-1;ya.vertices[9]=-20;ya.vertices[10]=20;ya.vertices[11]=-1;ya.faces[0]=0;ya.faces[1]=1;ya.faces[2]=2;ya.faces[3]=0;ya.faces[4]=2;ya.faces[5]=3;ya.vertexBuffer=e.createBuffer();ya.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,ya.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,
-ya.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ya.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ya.faces,e.STATIC_DRAW);ya.program=e.createProgram();e.attachShader(ya.program,oa("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(ya.program,oa("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(ya.program);ya.vertexLocation=e.getAttribLocation(ya.program,"position");ya.projectionLocation=e.getUniformLocation(ya.program,"projectionMatrix");ya.darknessLocation=
-e.getUniformLocation(ya.program,"darkness")}var ia={};ia.vertices=new Float32Array(16);ia.faces=new Uint16Array(6);ia.transparency=0.5;b=0;ia.vertices[b++]=-1;ia.vertices[b++]=-1;ia.vertices[b++]=0;ia.vertices[b++]=0;ia.vertices[b++]=1;ia.vertices[b++]=-1;ia.vertices[b++]=1;ia.vertices[b++]=0;ia.vertices[b++]=1;ia.vertices[b++]=1;ia.vertices[b++]=1;ia.vertices[b++]=1;ia.vertices[b++]=-1;ia.vertices[b++]=1;ia.vertices[b++]=0;ia.vertices[b++]=1;b=0;ia.faces[b++]=0;ia.faces[b++]=1;ia.faces[b++]=2;ia.faces[b++]=
-0;ia.faces[b++]=2;ia.faces[b++]=3;ia.vertexBuffer=e.createBuffer();ia.elementBuffer=e.createBuffer();ia.tempTexture=e.createTexture();ia.readBackPixels=new Uint8Array(1024);e.bindBuffer(e.ARRAY_BUFFER,ia.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,ia.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ia.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ia.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,ia.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,
-e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);ia.program=e.createProgram();e.attachShader(ia.program,oa("fragment",THREE.ShaderLib.lensFlare.fragmentShader));e.attachShader(ia.program,oa("vertex",THREE.ShaderLib.lensFlare.vertexShader));e.linkProgram(ia.program);ia.attributes={};ia.uniforms={};ia.attributes.vertex=e.getAttribLocation(ia.program,
-"position");ia.attributes.uv=e.getAttribLocation(ia.program,"UV");ia.uniforms.map=e.getUniformLocation(ia.program,"map");ia.uniforms.opacity=e.getUniformLocation(ia.program,"opacity");ia.uniforms.scale=e.getUniformLocation(ia.program,"scale");ia.uniforms.rotation=e.getUniformLocation(ia.program,"rotation");ia.uniforms.screenPosition=e.getUniformLocation(ia.program,"screenPosition");ia.uniforms.renderPink=e.getUniformLocation(ia.program,"renderPink");this.setSize=function(m,A){da.width=m;da.height=
-A;this.setViewport(0,0,da.width,da.height)};this.setViewport=function(m,A,x,t){la=m;Ga=A;ka=x;na=t;e.viewport(la,Ga,ka,na)};this.setScissor=function(m,A,x,t){e.scissor(m,A,x,t)};this.enableScissorTest=function(m){m?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(m){qa=m;e.depthMask(m)};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|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(m){ya.darkness=m};this.initMaterial=function(m,A,x,t){var w,S,E,G;if(m instanceof THREE.MeshDepthMaterial)c(m,THREE.ShaderLib.depth);else if(m instanceof THREE.ShadowVolumeDynamicMaterial)c(m,THREE.ShaderLib.shadowVolumeDynamic);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 O,D,I,Q;G=I=Q=0;for(O=A.length;G<O;G++){D=A[G];D instanceof THREE.DirectionalLight&&I++;D instanceof THREE.PointLight&&Q++}if(Q+I<=4)A=I;else{A=Math.ceil(4*I/(Q+I));Q=4-A}G={directional:A,point:Q};O=50;if(t!==undefined&&t instanceof THREE.SkinnedMesh)O=
-t.bones.length;a:{Q=m.fragmentShader;A=m.vertexShader;x={map:m.map,envMap:m.envMap,lightMap:m.lightMap,vertexColors:m.vertexColors,fog:x,sizeAttenuation:m.sizeAttenuation,skinning:m.skinning,morphTargets:m.morphTargets,maxDirLights:G.directional,maxPointLights:G.point,maxBones:O};G=Q+"\n\n"+A+"\n\n";for(E in x)G+=E+": "+x[E]+",\n";E=0;for(O=Ca.length;E<O;E++)if(Ca[E].code==G){E=Ca[E].program;break a}E=e.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+
-x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,x.fog?"#define USE_FOG":"",x.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",x.map?"#define USE_MAP":"",x.envMap?"#define USE_ENVMAP":"",x.lightMap?"#define USE_LIGHTMAP":"",x.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+
-x.maxPointLights,"#define MAX_BONES "+x.maxBones,x.map?"#define USE_MAP":"",x.envMap?"#define USE_ENVMAP":"",x.lightMap?"#define USE_LIGHTMAP":"",x.vertexColors?"#define USE_COLOR":"",x.skinning?"#define USE_SKINNING":"",x.morphTargets?"#define USE_MORPHTARGETS":"",x.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
-e.attachShader(E,oa("fragment",prefix_fragment+Q));e.attachShader(E,oa("vertex",prefix_vertex+A));e.linkProgram(E);e.getProgramParameter(E,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(E,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");E.uniforms={};E.attributes={};Ca.push({program:E,code:G})}m.program=E;E=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices",
-"morphTargetInfluences"];for(w in m.uniforms)E.push(w);w=m.program;x=0;for(Q=E.length;x<Q;x++){A=E[x];w.uniforms[A]=e.getUniformLocation(w,A)}E=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(w=0;w<this.maxMorphTargets;w++)E.push("morphTarget"+w);for(S in m.attributes)E.push(S);w=m.program;x=0;for(Q=E.length;x<Q;x++){A=E[x];w.attributes[A]=e.getAttribLocation(w,A)}w=m.program.attributes;e.enableVertexAttribArray(w.position);w.color>=0&&e.enableVertexAttribArray(w.color);
-w.normal>=0&&e.enableVertexAttribArray(w.normal);w.tangent>=0&&e.enableVertexAttribArray(w.tangent);if(m.skinning&&w.skinVertexA>=0&&w.skinVertexB>=0&&w.skinIndex>=0&&w.skinWeight>=0){e.enableVertexAttribArray(w.skinVertexA);e.enableVertexAttribArray(w.skinVertexB);e.enableVertexAttribArray(w.skinIndex);e.enableVertexAttribArray(w.skinWeight)}for(S in m.attributes)w[S]>=0&&e.enableVertexAttribArray(w[S]);if(m.morphTargets){m.numSupportedMorphTargets=0;if(w.morphTarget0>=0){e.enableVertexAttribArray(w.morphTarget0);
-m.numSupportedMorphTargets++}if(w.morphTarget1>=0){e.enableVertexAttribArray(w.morphTarget1);m.numSupportedMorphTargets++}if(w.morphTarget2>=0){e.enableVertexAttribArray(w.morphTarget2);m.numSupportedMorphTargets++}if(w.morphTarget3>=0){e.enableVertexAttribArray(w.morphTarget3);m.numSupportedMorphTargets++}if(w.morphTarget4>=0){e.enableVertexAttribArray(w.morphTarget4);m.numSupportedMorphTargets++}if(w.morphTarget5>=0){e.enableVertexAttribArray(w.morphTarget5);m.numSupportedMorphTargets++}if(w.morphTarget6>=
-0){e.enableVertexAttribArray(w.morphTarget6);m.numSupportedMorphTargets++}if(w.morphTarget7>=0){e.enableVertexAttribArray(w.morphTarget7);m.numSupportedMorphTargets++}t.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);w=0;for(m=this.maxMorphTargets;w<m;w++)t.__webglMorphTargetInfluences[w]=0}};this.render=function(m,A,x,t){var w,S,E,G,O,D,I,Q,sa=m.lights,W=m.fog;A.matrixAutoUpdate&&A.updateMatrix();m.update(undefined,!1,A);A.matrixWorldInverse.flattenToArray(ab);A.projectionMatrix.flattenToArray(cb);
-Ua.multiply(A.projectionMatrix,A.matrixWorldInverse);n(Ua);this.initWebGLObjects(m);Fa(x);(this.autoClear||t)&&this.clear();O=m.__webglObjects.length;for(t=0;t<O;t++){w=m.__webglObjects[t];I=w.object;if(I.visible)if(!(I instanceof THREE.Mesh)||p(I)){I.matrixWorld.flattenToArray(I._objectMatrixArray);F(I,A);y(w);w.render=!0;if(this.sortObjects){Pa.copy(I.position);Ua.multiplyVector3(Pa);w.z=Pa.z}}else w.render=!1;else w.render=!1}this.sortObjects&&m.__webglObjects.sort(v);D=m.__webglObjectsImmediate.length;
-for(t=0;t<D;t++){w=m.__webglObjectsImmediate[t];I=w.object;if(I.visible){I.matrixAutoUpdate&&I.matrixWorld.flattenToArray(I._objectMatrixArray);F(I,A);u(w)}}J(THREE.NormalBlending);for(t=0;t<O;t++){w=m.__webglObjects[t];if(w.render){I=w.object;Q=w.buffer;E=w.opaque;j(I);for(w=0;w<E.count;w++){G=E.list[w];k(G.depthTest);g(A,sa,W,G,Q,I)}}}for(t=0;t<D;t++){w=m.__webglObjectsImmediate[t];I=w.object;if(I.visible){E=w.opaque;j(I);for(w=0;w<E.count;w++){G=E.list[w];k(G.depthTest);S=f(A,sa,W,G,I);I.render(function(Ba){h(Ba,
-S)})}}}for(t=0;t<O;t++){w=m.__webglObjects[t];if(w.render){I=w.object;Q=w.buffer;E=w.transparent;j(I);for(w=0;w<E.count;w++){G=E.list[w];J(G.blending);k(G.depthTest);g(A,sa,W,G,Q,I)}}}for(t=0;t<D;t++){w=m.__webglObjectsImmediate[t];I=w.object;if(I.visible){E=w.transparent;j(I);for(w=0;w<E.count;w++){G=E.list[w];J(G.blending);k(G.depthTest);S=f(A,sa,W,G,I);I.render(function(Ba){h(Ba,S)})}}}X&&m.__webglShadowVolumes.length&&m.lights.length&&B(m);m.__webglLensFlares.length&&C(m,A);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){if(!m.__webglObjects){m.__webglObjects=[];m.__webglObjectsImmediate=[];m.__webglShadowVolumes=[];m.__webglLensFlares=[]}for(;m.__objectsAdded.length;){var A=m.__objectsAdded[0],x=m,t=void 0,w=void 0,S=void 0;if(A._modelViewMatrix==undefined){A._modelViewMatrix=new THREE.Matrix4;A._normalMatrixArray=new Float32Array(9);
-A._modelViewMatrixArray=new Float32Array(16);A._objectMatrixArray=new Float32Array(16);A.matrixWorld.flattenToArray(A._objectMatrixArray)}if(A instanceof THREE.Mesh){w=A.geometry;w.geometryGroups==undefined&&U(w);for(t in w.geometryGroups){S=w.geometryGroups[t];if(!S.__webglVertexBuffer){var E=S;E.__webglVertexBuffer=e.createBuffer();E.__webglNormalBuffer=e.createBuffer();E.__webglTangentBuffer=e.createBuffer();E.__webglColorBuffer=e.createBuffer();E.__webglUVBuffer=e.createBuffer();E.__webglUV2Buffer=
-e.createBuffer();E.__webglSkinVertexABuffer=e.createBuffer();E.__webglSkinVertexBBuffer=e.createBuffer();E.__webglSkinIndicesBuffer=e.createBuffer();E.__webglSkinWeightsBuffer=e.createBuffer();E.__webglFaceBuffer=e.createBuffer();E.__webglLineBuffer=e.createBuffer();if(E.numMorphTargets){var G=void 0,O=void 0;E.__webglMorphTargetsBuffers=[];G=0;for(O=E.numMorphTargets;G<O;G++)E.__webglMorphTargetsBuffers.push(e.createBuffer())}E=S;G=A;var D=void 0,I=void 0,Q=void 0;Q=void 0;var sa=void 0,W=void 0,
-Ba=void 0,ra=Ba=O=0;I=void 0;Q=void 0;var za=void 0;D=void 0;I=void 0;sa=G.geometry;za=sa.faces;W=E.faces;D=0;for(I=W.length;D<I;D++){Q=W[D];Q=za[Q];if(Q instanceof THREE.Face3){O+=3;Ba+=1;ra+=3}else if(Q instanceof THREE.Face4){O+=4;Ba+=2;ra+=4}}D=E;I=G;za=void 0;W=void 0;var Ia=void 0,Sa=void 0;Ia=void 0;Q=[];za=0;for(W=I.materials.length;za<W;za++){Ia=I.materials[za];if(Ia instanceof THREE.MeshFaceMaterial){Ia=0;for(l=D.materials.length;Ia<l;Ia++)(Sa=D.materials[Ia])&&Q.push(Sa)}else(Sa=Ia)&&Q.push(Sa)}D=
-Q;a:{I=void 0;za=void 0;W=D.length;for(I=0;I<W;I++){za=D[I];if(za.map||za.lightMap||za instanceof THREE.MeshShaderMaterial){I=!0;break a}}I=!1}a:{za=D;W=void 0;Q=void 0;Ia=za.length;for(W=0;W<Ia;W++){Q=za[W];if(!(Q instanceof THREE.MeshBasicMaterial&&!Q.envMap||Q instanceof THREE.MeshDepthMaterial)){za=Q&&Q.shading!=undefined&&Q.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}za=!1}a:{W=void 0;Q=void 0;Ia=D.length;for(W=0;W<Ia;W++){Q=D[W];if(Q.vertexColors){Q=Q.vertexColors;
-break a}}Q=!1}E.__vertexArray=new Float32Array(O*3);if(za)E.__normalArray=new Float32Array(O*3);if(sa.hasTangents)E.__tangentArray=new Float32Array(O*4);if(Q)E.__colorArray=new Float32Array(O*3);if(I){if(sa.faceUvs.length>0||sa.faceVertexUvs.length>0)E.__uvArray=new Float32Array(O*2);if(sa.faceUvs.length>1||sa.faceVertexUvs.length>1)E.__uv2Array=new Float32Array(O*2)}if(G.geometry.skinWeights.length&&G.geometry.skinIndices.length){E.__skinVertexAArray=new Float32Array(O*4);E.__skinVertexBArray=new Float32Array(O*
-4);E.__skinIndexArray=new Float32Array(O*4);E.__skinWeightArray=new Float32Array(O*4)}E.__faceArray=new Uint16Array(Ba*3+(G.geometry.edgeFaces?G.geometry.edgeFaces.length*6:0));E.__lineArray=new Uint16Array(ra*2);if(E.numMorphTargets){E.__morphTargetsArrays=[];sa=0;for(W=E.numMorphTargets;sa<W;sa++)E.__morphTargetsArrays.push(new Float32Array(O*3))}E.__needsSmoothNormals=za==THREE.SmoothShading;E.__uvType=I;E.__vertexColorType=Q;E.__normalType=za;E.__webglFaceCount=Ba*3+(G.geometry.edgeFaces?G.geometry.edgeFaces.length*
-6:0);E.__webglLineCount=ra*2;sa=0;for(W=D.length;sa<W;sa++)if(D[sa].attributes){E.__webglCustomAttributes={};for(a in D[sa].attributes){I=D[sa].attributes[a];Ba=1;if(I.type==="v2")Ba=2;else if(I.type==="v3")Ba=3;else if(I.type==="v4")Ba=4;else I.type==="c"&&(Ba=3);I.size=Ba;I.needsUpdate=!0;I.array=new Float32Array(O*Ba);I.buffer=e.createBuffer();E.__webglCustomAttributes[a]=I}}w.__dirtyVertices=!0;w.__dirtyMorphTargets=!0;w.__dirtyElements=!0;w.__dirtyUvs=!0;w.__dirtyNormals=!0;w.__dirtyTangents=
-!0;w.__dirtyColors=!0}A instanceof THREE.ShadowVolume?z(x.__webglShadowVolumes,S,A):z(x.__webglObjects,S,A)}}else if(A instanceof THREE.LensFlare)z(x.__webglLensFlares,undefined,A);else if(A instanceof THREE.Ribbon){w=A.geometry;if(!w.__webglVertexBuffer){t=w;t.__webglVertexBuffer=e.createBuffer();t.__webglColorBuffer=e.createBuffer();t=w;S=t.vertices.length;t.__vertexArray=new Float32Array(S*3);t.__colorArray=new Float32Array(S*3);t.__webglVertexCount=S;w.__dirtyVertices=!0;w.__dirtyColors=!0}z(x.__webglObjects,
-w,A)}else if(A instanceof THREE.Line){w=A.geometry;if(!w.__webglVertexBuffer){t=w;t.__webglVertexBuffer=e.createBuffer();t.__webglColorBuffer=e.createBuffer();t=w;S=t.vertices.length;t.__vertexArray=new Float32Array(S*3);t.__colorArray=new Float32Array(S*3);t.__webglLineCount=S;w.__dirtyVertices=!0;w.__dirtyColors=!0}z(x.__webglObjects,w,A)}else if(A instanceof THREE.ParticleSystem){w=A.geometry;if(!w.__webglVertexBuffer){t=w;t.__webglVertexBuffer=e.createBuffer();t.__webglColorBuffer=e.createBuffer();
-t=w;S=t.vertices.length;t.__vertexArray=new Float32Array(S*3);t.__colorArray=new Float32Array(S*3);t.__sortArray=[];t.__webglParticleCount=S;w.__dirtyVertices=!0;w.__dirtyColors=!0}z(x.__webglObjects,w,A)}else THREE.MarchingCubes!==undefined&&A instanceof THREE.MarchingCubes&&x.__webglObjectsImmediate.push({object:A,opaque:{list:[],count:0},transparent:{list:[],count:0}});m.__objectsAdded.splice(0,1)}for(;m.__objectsRemoved.length;){A=m.__objectsRemoved[0];x=m;w=void 0;t=void 0;for(w=x.__webglObjects.length-
-1;w>=0;w--){t=x.__webglObjects[w].object;A==t&&x.__webglObjects.splice(w,1)}m.__objectsRemoved.splice(0,1)}A=0;for(x=m.__webglObjects.length;A<x;A++)H(m.__webglObjects[A].object,m);A=0;for(x=m.__webglShadowVolumes.length;A<x;A++)H(m.__webglShadowVolumes[A].object,m);A=0;for(x=m.__webglLensFlares.length;A<x;A++)H(m.__webglLensFlares[A].object,m)};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):
+THREE.WebGLRenderer=function(b){function d(m,C,x){var v,B,O,I=m.vertices,K=I.length,H=m.colors,F=H.length,J=m.__vertexArray,M=m.__colorArray,X=m.__sortArray,U=m.__dirtyVertices,Ca=m.__dirtyColors;if(x.sortParticles){Ea.multiplySelf(x.matrixWorld);for(v=0;v<K;v++){B=I[v].position;Ya.copy(B);Ea.multiplyVector3(Ya);X[v]=[Ya.z,v]}X.sort(function(Ha,oa){return oa[0]-Ha[0]});for(v=0;v<K;v++){B=I[X[v][1]].position;O=v*3;J[O]=B.x;J[O+1]=B.y;J[O+2]=B.z}for(v=0;v<F;v++){O=v*3;color=H[X[v][1]];M[O]=color.r;
+M[O+1]=color.g;M[O+2]=color.b}}else{if(U)for(v=0;v<K;v++){B=I[v].position;O=v*3;J[O]=B.x;J[O+1]=B.y;J[O+2]=B.z}if(Ca)for(v=0;v<F;v++){color=H[v];O=v*3;M[O]=color.r;M[O+1]=color.g;M[O+2]=color.b}}if(U||x.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,J,C)}if(Ca||x.sortParticles){e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,M,C)}}function c(m,C,x,v,B){v.program||ra.initMaterial(v,C,x,B);var O=v.program,I=O.uniforms,K=v.uniforms;
+if(O!=ya){e.useProgram(O);ya=O}e.uniformMatrix4fv(I.projectionMatrix,!1,Sa);if(x&&(v instanceof THREE.MeshBasicMaterial||v instanceof THREE.MeshLambertMaterial||v instanceof THREE.MeshPhongMaterial||v instanceof THREE.LineBasicMaterial||v instanceof THREE.ParticleBasicMaterial||v.fog)){K.fogColor.value.setHex(x.color.hex);if(x instanceof THREE.Fog){K.fogNear.value=x.near;K.fogFar.value=x.far}else if(x instanceof THREE.FogExp2)K.fogDensity.value=x.density}if(v instanceof THREE.MeshPhongMaterial||v instanceof
+THREE.MeshLambertMaterial||v.lights){var H,F,J=0,M=0,X=0,U,Ca,Ha,oa,wa=Ta,cb=wa.directional.colors,Aa=wa.directional.positions,Ia=wa.point.colors,Ja=wa.point.positions,Qa=wa.point.distances,D=0,Z=0;x=F=oa=0;for(H=C.length;x<H;x++){F=C[x];U=F.color;Ca=F.position;Ha=F.intensity;oa=F.distance;if(F instanceof THREE.AmbientLight){J+=U.r;M+=U.g;X+=U.b}else if(F instanceof THREE.DirectionalLight){oa=D*3;cb[oa]=U.r*Ha;cb[oa+1]=U.g*Ha;cb[oa+2]=U.b*Ha;Aa[oa]=Ca.x;Aa[oa+1]=Ca.y;Aa[oa+2]=Ca.z;D+=1}else if(F instanceof
+THREE.PointLight){F=Z*3;Ia[F]=U.r*Ha;Ia[F+1]=U.g*Ha;Ia[F+2]=U.b*Ha;Ja[F]=Ca.x;Ja[F+1]=Ca.y;Ja[F+2]=Ca.z;Qa[Z]=oa;Z+=1}}for(x=D*3;x<cb.length;x++)cb[x]=0;for(x=Z*3;x<Ia.length;x++)Ia[x]=0;wa.point.length=Z;wa.directional.length=D;wa.ambient[0]=J;wa.ambient[1]=M;wa.ambient[2]=X;x=Ta;K.enableLighting.value=x.directional.length+x.point.length;K.ambientLightColor.value=x.ambient;K.directionalLightColor.value=x.directional.colors;K.directionalLightDirection.value=x.directional.positions;K.pointLightColor.value=
+x.point.colors;K.pointLightPosition.value=x.point.positions;K.pointLightDistance.value=x.point.distances}if(v instanceof THREE.MeshBasicMaterial||v instanceof THREE.MeshLambertMaterial||v instanceof THREE.MeshPhongMaterial){K.diffuse.value.setRGB(v.color.r,v.color.g,v.color.b);K.opacity.value=v.opacity;K.map.texture=v.map;K.lightMap.texture=v.lightMap;K.envMap.texture=v.envMap;K.reflectivity.value=v.reflectivity;K.refractionRatio.value=v.refractionRatio;K.combine.value=v.combine;K.useRefract.value=
+v.envMap&&v.envMap.mapping instanceof THREE.CubeRefractionMapping}if(v instanceof THREE.LineBasicMaterial){K.diffuse.value.setRGB(v.color.r,v.color.g,v.color.b);K.opacity.value=v.opacity}else if(v instanceof THREE.ParticleBasicMaterial){K.psColor.value.setRGB(v.color.r,v.color.g,v.color.b);K.opacity.value=v.opacity;K.size.value=v.size;K.scale.value=fa.height/2;K.map.texture=v.map}else if(v instanceof THREE.MeshPhongMaterial){K.ambient.value.setRGB(v.ambient.r,v.ambient.g,v.ambient.b);K.specular.value.setRGB(v.specular.r,
+v.specular.g,v.specular.b);K.shininess.value=v.shininess}else if(v instanceof THREE.MeshDepthMaterial){K.mNear.value=m.near;K.mFar.value=m.far;K.opacity.value=v.opacity}else if(v instanceof THREE.MeshNormalMaterial)K.opacity.value=v.opacity;for(var t in K)if(M=O.uniforms[t]){H=K[t];J=H.type;x=H.value;if(J=="i")e.uniform1i(M,x);else if(J=="f")e.uniform1f(M,x);else if(J=="fv1")e.uniform1fv(M,x);else if(J=="fv")e.uniform3fv(M,x);else if(J=="v2")e.uniform2f(M,x.x,x.y);else if(J=="v3")e.uniform3f(M,x.x,
+x.y,x.z);else if(J=="v4")e.uniform4f(M,x.x,x.y,x.z,x.w);else if(J=="c")e.uniform3f(M,x.r,x.g,x.b);else if(J=="t"){e.uniform1i(M,x);if(H=H.texture)if(H.image instanceof Array&&H.image.length==6){if(H.image.length==6){if(H.needsUpdate){if(H.__webglInit){e.bindTexture(e.TEXTURE_CUBE_MAP,H.image.__webglTextureCube);for(J=0;J<6;++J)e.texSubImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,0,0,e.RGBA,e.UNSIGNED_BYTE,H.image[J])}else{H.image.__webglTextureCube=e.createTexture();e.bindTexture(e.TEXTURE_CUBE_MAP,
+H.image.__webglTextureCube);for(J=0;J<6;++J)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+J,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,H.image[J]);H.__webglInit=!0}N(e.TEXTURE_CUBE_MAP,H,H.image[0]);e.bindTexture(e.TEXTURE_CUBE_MAP,null);H.needsUpdate=!1}e.activeTexture(e.TEXTURE0+x);e.bindTexture(e.TEXTURE_CUBE_MAP,H.image.__webglTextureCube)}}else Q(H,x)}}e.uniformMatrix4fv(I.modelViewMatrix,!1,B._modelViewMatrixArray);e.uniformMatrix3fv(I.normalMatrix,!1,B._normalMatrixArray);(v instanceof THREE.MeshShaderMaterial||
+v instanceof THREE.MeshPhongMaterial||v.envMap)&&e.uniform3f(I.cameraPosition,m.position.x,m.position.y,m.position.z);(v instanceof THREE.MeshShaderMaterial||v.envMap||v.skinning)&&e.uniformMatrix4fv(I.objectMatrix,!1,B._objectMatrixArray);(v instanceof THREE.MeshPhongMaterial||v instanceof THREE.MeshLambertMaterial||v instanceof THREE.MeshShaderMaterial||v.skinning)&&e.uniformMatrix4fv(I.viewMatrix,!1,$a);if(v instanceof THREE.ShadowVolumeDynamicMaterial){m=K.directionalLightDirection.value;m[0]=
+-C.position.x;m[1]=-C.position.y;m[2]=-C.position.z;e.uniform3fv(I.directionalLightDirection,m);e.uniformMatrix4fv(I.objectMatrix,!1,B._objectMatrixArray);e.uniformMatrix4fv(I.viewMatrix,!1,$a)}if(v.skinning){e.uniformMatrix4fv(I.cameraInverseMatrix,!1,$a);e.uniformMatrix4fv(I.boneGlobalMatrices,!1,B.boneMatrices)}return O}function f(m,C,x,v,B,O){if(v.opacity!=0){var I;m=c(m,C,x,v,O).attributes;if(v.morphTargets){C=v.program.attributes;O.morphTargetBase!==-1?e.bindBuffer(e.ARRAY_BUFFER,B.__webglMorphTargetsBuffers[O.morphTargetBase]):
+e.bindBuffer(e.ARRAY_BUFFER,B.__webglVertexBuffer);e.vertexAttribPointer(C.position,3,e.FLOAT,!1,0,0);if(O.morphTargetForcedOrder.length){x=0;for(var K=O.morphTargetForcedOrder,H=O.morphTargetInfluences;x<v.numSupportedMorphTargets&&x<K.length;){e.bindBuffer(e.ARRAY_BUFFER,B.__webglMorphTargetsBuffers[K[x]]);e.vertexAttribPointer(C["morphTarget"+x],3,e.FLOAT,!1,0,0);O.__webglMorphTargetInfluences[x]=H[K[x]];x++}}else{K=[];var F=-1,J=0;H=O.morphTargetInfluences;var M,X=H.length;x=0;for(O.morphTargetBase!==
+-1&&(K[O.morphTargetBase]=!0);x<v.numSupportedMorphTargets;){for(M=0;M<X;M++)if(!K[M]&&H[M]>F){J=M;F=H[J]}e.bindBuffer(e.ARRAY_BUFFER,B.__webglMorphTargetsBuffers[J]);e.vertexAttribPointer(C["morphTarget"+x],3,e.FLOAT,!1,0,0);O.__webglMorphTargetInfluences[x]=F;K[J]=1;F=-1;x++}}e.uniform1fv(v.program.uniforms.morphTargetInfluences,O.__webglMorphTargetInfluences)}else{e.bindBuffer(e.ARRAY_BUFFER,B.__webglVertexBuffer);e.vertexAttribPointer(m.position,3,e.FLOAT,!1,0,0)}if(B.__webglCustomAttributes)for(I in B.__webglCustomAttributes)if(m[I]>=
+0){C=B.__webglCustomAttributes[I];e.bindBuffer(e.ARRAY_BUFFER,C.buffer);e.vertexAttribPointer(m[I],C.size,e.FLOAT,!1,0,0)}if(m.color>=0){e.bindBuffer(e.ARRAY_BUFFER,B.__webglColorBuffer);e.vertexAttribPointer(m.color,3,e.FLOAT,!1,0,0)}if(m.normal>=0){e.bindBuffer(e.ARRAY_BUFFER,B.__webglNormalBuffer);e.vertexAttribPointer(m.normal,3,e.FLOAT,!1,0,0)}if(m.tangent>=0){e.bindBuffer(e.ARRAY_BUFFER,B.__webglTangentBuffer);e.vertexAttribPointer(m.tangent,4,e.FLOAT,!1,0,0)}if(m.uv>=0)if(B.__webglUVBuffer){e.bindBuffer(e.ARRAY_BUFFER,
+B.__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(B.__webglUV2Buffer){e.bindBuffer(e.ARRAY_BUFFER,B.__webglUV2Buffer);e.vertexAttribPointer(m.uv2,2,e.FLOAT,!1,0,0);e.enableVertexAttribArray(m.uv2)}else e.disableVertexAttribArray(m.uv2);if(v.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0){e.bindBuffer(e.ARRAY_BUFFER,B.__webglSkinVertexABuffer);e.vertexAttribPointer(m.skinVertexA,
+4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,B.__webglSkinVertexBBuffer);e.vertexAttribPointer(m.skinVertexB,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,B.__webglSkinIndicesBuffer);e.vertexAttribPointer(m.skinIndex,4,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,B.__webglSkinWeightsBuffer);e.vertexAttribPointer(m.skinWeight,4,e.FLOAT,!1,0,0)}if(O instanceof THREE.Mesh)if(v.wireframe){e.lineWidth(v.wireframeLinewidth);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,B.__webglLineBuffer);e.drawElements(e.LINES,
+B.__webglLineCount,e.UNSIGNED_SHORT,0)}else{e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,B.__webglFaceBuffer);e.drawElements(e.TRIANGLES,B.__webglFaceCount,e.UNSIGNED_SHORT,0)}else if(O instanceof THREE.Line){O=O.type==THREE.LineStrip?e.LINE_STRIP:e.LINES;e.lineWidth(v.linewidth);e.drawArrays(O,0,B.__webglLineCount)}else if(O instanceof THREE.ParticleSystem)e.drawArrays(e.POINTS,0,B.__webglParticleCount);else O instanceof THREE.Ribbon&&e.drawArrays(e.TRIANGLE_STRIP,0,B.__webglVertexCount)}}function g(m,C){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(C.attributes.position);e.vertexAttribPointer(C.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(C.attributes.normal);e.vertexAttribPointer(C.attributes.normal,
+3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,m.count);m.count=0}function h(m){if(aa!=m.doubleSided){m.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE);aa=m.doubleSided}if(pa!=m.flipSided){m.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW);pa=m.flipSided}}function j(m){if(ia!=m){m?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST);ia=m}}function k(m){la[0].set(m.n41-m.n11,m.n42-m.n12,m.n43-m.n13,m.n44-m.n14);la[1].set(m.n41+m.n11,m.n42+m.n12,m.n43+m.n13,m.n44+m.n14);la[2].set(m.n41+m.n21,m.n42+m.n22,
+m.n43+m.n23,m.n44+m.n24);la[3].set(m.n41-m.n21,m.n42-m.n22,m.n43-m.n23,m.n44-m.n24);la[4].set(m.n41-m.n31,m.n42-m.n32,m.n43-m.n33,m.n44-m.n34);la[5].set(m.n41+m.n31,m.n42+m.n32,m.n43+m.n33,m.n44+m.n34);var C;for(m=0;m<6;m++){C=la[m];C.divideScalar(Math.sqrt(C.x*C.x+C.y*C.y+C.z*C.z))}}function n(m){for(var C=m.matrixWorld,x=-m.geometry.boundingSphere.radius*Math.max(m.scale.x,Math.max(m.scale.y,m.scale.z)),v=0;v<6;v++){m=la[v].x*C.n14+la[v].y*C.n24+la[v].z*C.n34+la[v].w;if(m<=x)return!1}return!0}function p(m,
+C){m.list[m.count]=C;m.count+=1}function o(m){var C,x,v=m.object,B=m.opaque,O=m.transparent;O.count=0;m=B.count=0;for(C=v.materials.length;m<C;m++){x=v.materials[m];x.transparent?p(O,x):p(B,x)}}function u(m){var C,x,v,B,O=m.object,I=m.buffer,K=m.opaque,H=m.transparent;H.count=0;m=K.count=0;for(v=O.materials.length;m<v;m++){C=O.materials[m];if(C instanceof THREE.MeshFaceMaterial){C=0;for(x=I.materials.length;C<x;C++)(B=I.materials[C])&&(B.transparent?p(H,B):p(K,B))}else(B=C)&&(B.transparent?p(H,B):
+p(K,B))}}function y(m,C){return C.z-m.z}function w(m){e.enable(e.POLYGON_OFFSET_FILL);e.polygonOffset(0.1,1);e.enable(e.STENCIL_TEST);e.enable(e.DEPTH_TEST);e.depthMask(!1);e.colorMask(!1,!1,!1,!1);e.stencilFunc(e.ALWAYS,1,255);e.stencilOpSeparate(e.BACK,e.KEEP,e.INCR,e.KEEP);e.stencilOpSeparate(e.FRONT,e.KEEP,e.DECR,e.KEEP);var C,x=m.lights.length,v,B=m.lights,O=[],I,K,H,F,J,M=m.__webglShadowVolumes.length;for(C=0;C<x;C++){v=m.lights[C];if(v instanceof THREE.DirectionalLight){O[0]=-v.position.x;
+O[1]=-v.position.y;O[2]=-v.position.z;for(J=0;J<M;J++){v=m.__webglShadowVolumes[J].object;I=m.__webglShadowVolumes[J].buffer;K=v.materials[0];K.program||ra.initMaterial(K,B,undefined,v);K=K.program;H=K.uniforms;F=K.attributes;if(ya!==K){e.useProgram(K);ya=K;e.uniformMatrix4fv(H.projectionMatrix,!1,Sa);e.uniformMatrix4fv(H.viewMatrix,!1,$a);e.uniform3fv(H.directionalLightDirection,O)}v.matrixWorld.flattenToArray(v._objectMatrixArray);e.uniformMatrix4fv(H.objectMatrix,!1,v._objectMatrixArray);e.bindBuffer(e.ARRAY_BUFFER,
+I.__webglVertexBuffer);e.vertexAttribPointer(F.position,3,e.FLOAT,!1,0,0);e.bindBuffer(e.ARRAY_BUFFER,I.__webglNormalBuffer);e.vertexAttribPointer(F.normal,3,e.FLOAT,!1,0,0);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,I.__webglFaceBuffer);e.cullFace(e.FRONT);e.drawElements(e.TRIANGLES,I.__webglFaceCount,e.UNSIGNED_SHORT,0);e.cullFace(e.BACK);e.drawElements(e.TRIANGLES,I.__webglFaceCount,e.UNSIGNED_SHORT,0)}}}e.disable(e.POLYGON_OFFSET_FILL);e.colorMask(!0,!0,!0,!0);e.stencilFunc(e.NOTEQUAL,0,255);e.stencilOp(e.KEEP,
+e.KEEP,e.KEEP);e.disable(e.DEPTH_TEST);za="";ya=ha.program;e.useProgram(ha.program);e.uniformMatrix4fv(ha.projectionLocation,!1,Sa);e.uniform1f(ha.darknessLocation,ha.darkness);e.bindBuffer(e.ARRAY_BUFFER,ha.vertexBuffer);e.vertexAttribPointer(ha.vertexLocation,3,e.FLOAT,!1,0,0);e.enableVertexAttribArray(ha.vertexLocation);e.blendFunc(e.ONE,e.ONE_MINUS_SRC_ALPHA);e.blendEquation(e.FUNC_ADD);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ha.elementBuffer);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);e.disable(e.STENCIL_TEST);
+e.enable(e.DEPTH_TEST);e.depthMask(Ga)}function A(m,C){var x,v,B,O=m.__webglLensFlares.length,I,K,H;I=new THREE.Vector3;var F=ja/Da;K=Da*0.5;H=ja*0.5;var J=16/ja,M=[J*F,J],X=[1,1,0];J=[1,1];var U,Ca=ka.readBackPixels,Ha,oa,wa=ka.uniforms;x=ka.attributes;e.useProgram(ka.program);ya=ka.program;za="";e.uniform1i(wa.map,0);e.activeTexture(e.TEXTURE0);e.uniform1f(wa.opacity,1);e.uniform1f(wa.rotation,0);e.uniform2fv(wa.scale,M);e.bindBuffer(e.ARRAY_BUFFER,ka.vertexBuffer);e.vertexAttribPointer(x.vertex,
+2,e.FLOAT,!1,16,0);e.vertexAttribPointer(x.uv,2,e.FLOAT,!1,16,8);e.bindTexture(e.TEXTURE_2D,ka.tempTexture);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ka.elementBuffer);e.disable(e.CULL_FACE);e.depthMask(!1);for(B=0;B<O;B++){x=m.__webglLensFlares[B].object;I.set(x.matrixWorld.n14,x.matrixWorld.n24,x.matrixWorld.n34);C.matrixWorldInverse.multiplyVector3(I);v=I.z;C.projectionMatrix.multiplyVector3(I);X[0]=I.x;X[1]=I.y;X[2]=I.z;J[0]=X[0]*K+K;J[1]=X[1]*H+H;e.copyTexSubImage2D(e.TEXTURE_2D,0,0,0,J[0]-8,J[1]-
+8,16,16);e.uniform3fv(wa.screenPosition,X);e.uniform1i(wa.renderPink,1);e.enable(e.DEPTH_TEST);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0);try{e.readPixels(J[0]-8,J[1]-8,16,16,e.RGBA,e.UNSIGNED_BYTE,ka.readBackPixels)}catch(cb){console.log("WebGLRenderer.renderLensFlare: readPixels failed!")}e.getError()&&console.log("WebGLRenderer.renderLensFlare: readPixels failed!");sampleDistance=parseInt(5*(1-Math.max(0,Math.min(-v,C.far))/C.far),10)+2;v=sampleDistance*4;U=sampleDistance*64;oa=0;Ha=28-v+
+(448-U);ka.readBackPixels[Ha+0]===255&&ka.readBackPixels[Ha+1]===0&&ka.readBackPixels[Ha+2]===255&&(oa+=0.2);Ha=28+v+(448-U);Ca[Ha+0]===255&&Ca[Ha+1]===0&&Ca[Ha+2]===255&&(oa+=0.2);Ha=28+v+(448+U);Ca[Ha+0]===255&&Ca[Ha+1]===0&&Ca[Ha+2]===255&&(oa+=0.2);Ha=28-v+(448+U);Ca[Ha+0]===255&&Ca[Ha+1]===0&&Ca[Ha+2]===255&&(oa+=0.2);Ha=476;Ca[Ha+0]===255&&Ca[Ha+1]===0&&Ca[Ha+2]===255&&(oa+=0.2);x.positionScreen.x=X[0];x.positionScreen.y=X[1];x.positionScreen.z=X[2];x.customUpdateCallback?x.customUpdateCallback(oa,
+x):x.updateLensFlares(oa);e.uniform1i(wa.renderPink,0);e.disable(e.DEPTH_TEST);e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0)}for(B=0;B<O;B++){x=m.__webglLensFlares[B].object;I=0;for(K=x.lensFlares.length;I<K;I++){H=x.lensFlares[I];if(H.opacity>0.0010&&H.scale>0.0010){X[0]=H.x;X[1]=H.y;X[2]=H.z;J=H.size*H.scale/ja;M[0]=J*F;M[1]=J;e.uniform3fv(wa.screenPosition,X);e.uniform1f(wa.rotation,H.rotation);e.uniform2fv(wa.scale,M);e.uniform1f(wa.opacity,H.opacity);z(H.blending);Q(H.texture,0);e.drawElements(e.TRIANGLES,
+6,e.UNSIGNED_SHORT,0)}}}e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(Ga)}function E(m,C){m._modelViewMatrix.multiplyToArray(C.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(m._modelViewMatrix).transposeIntoArray(m._normalMatrixArray)}function G(m){var C,x,v,B,O;if(m instanceof THREE.Mesh){x=m.geometry;for(C in x.geometryGroups){v=x.geometryGroups[C];O=!1;for(B in v.__webglCustomAttributes)if(v.__webglCustomAttributes[B].needsUpdate){O=!0;break}if(x.__dirtyVertices||
+x.__dirtyMorphTargets||x.__dirtyElements||x.__dirtyUvs||x.__dirtyNormals||x.__dirtyColors||x.__dirtyTangents||O){O=e.DYNAMIC_DRAW;var I=void 0,K=void 0,H=void 0,F=void 0;H=void 0;var J=void 0,M=void 0,X=void 0,U=void 0,Ca=void 0,Ha=void 0,oa=void 0,wa=void 0,cb=void 0,Aa=void 0,Ia=void 0,Ja=void 0,Qa=void 0;M=void 0;X=void 0;F=void 0;U=void 0;F=void 0;var D=void 0,Z=void 0;M=void 0;D=void 0;Z=void 0;var t=void 0,ab=void 0;D=void 0;Z=void 0;t=void 0;ab=void 0;D=void 0;Z=void 0;t=void 0;ab=void 0;D=
+void 0;Z=void 0;t=void 0;F=void 0;U=void 0;J=void 0;H=void 0;H=void 0;D=void 0;Z=void 0;t=void 0;var fb=void 0,Ma=0,Va=0,gb=0,hb=0,Wa=0,eb=0,Oa=0,Ka=0,La=0,T=0,Ra=0;Z=D=0;var Xa=v.__vertexArray,Za=v.__uvArray,W=v.__uv2Array,ta=v.__normalArray,ea=v.__tangentArray,ca=v.__colorArray,va=v.__skinVertexAArray,ua=v.__skinVertexBArray,ga=v.__skinIndexArray,P=v.__skinWeightArray,Na=v.__morphTargetsArrays,db=v.__webglCustomAttributes;t=void 0;var Ua=v.__faceArray,bb=v.__lineArray,lb=v.__needsSmoothNormals;
+Ha=v.__vertexColorType;Ca=v.__uvType;oa=v.__normalType;var Pa=m.geometry,ib=Pa.__dirtyVertices,sb=Pa.__dirtyElements,rb=Pa.__dirtyUvs,tb=Pa.__dirtyNormals,ub=Pa.__dirtyTangents,vb=Pa.__dirtyColors,wb=Pa.__dirtyMorphTargets,nb=Pa.vertices,xb=v.faces,Ab=Pa.faces,yb=Pa.faceVertexUvs[0],zb=Pa.faceVertexUvs[1],ob=Pa.skinVerticesA,pb=Pa.skinVerticesB,qb=Pa.skinIndices,kb=Pa.skinWeights,mb=Pa.edgeFaces,jb=Pa.morphTargets;if(db)for(fb in db){db[fb].offset=0;db[fb].offsetSrc=0}I=0;for(K=xb.length;I<K;I++){H=
+xb[I];F=Ab[H];yb&&(wa=yb[H]);zb&&(cb=zb[H]);H=F.vertexNormals;J=F.normal;M=F.vertexColors;X=F.color;U=F.vertexTangents;if(F instanceof THREE.Face3){if(ib){Aa=nb[F.a].position;Ia=nb[F.b].position;Ja=nb[F.c].position;Xa[Va]=Aa.x;Xa[Va+1]=Aa.y;Xa[Va+2]=Aa.z;Xa[Va+3]=Ia.x;Xa[Va+4]=Ia.y;Xa[Va+5]=Ia.z;Xa[Va+6]=Ja.x;Xa[Va+7]=Ja.y;Xa[Va+8]=Ja.z;Va+=9}if(db)for(fb in db){t=db[fb];if(t.needsUpdate){D=t.offset;Z=t.offsetSrc;if(t.size===1){if(t.boundTo===undefined||t.boundTo==="vertices"){t.array[D+0]=t.value[F.a];
+t.array[D+1]=t.value[F.b];t.array[D+2]=t.value[F.c]}else if(t.boundTo==="faces"){t.array[D+0]=t.value[Z];t.array[D+1]=t.value[Z];t.array[D+2]=t.value[Z];t.offsetSrc++}else if(t.boundTo==="faceVertices"){t.array[D+0]=t.value[Z+0];t.array[D+1]=t.value[Z+1];t.array[D+2]=t.value[Z+2];t.offsetSrc+=3}t.offset+=3}else{if(t.boundTo===undefined||t.boundTo==="vertices"){Aa=t.value[F.a];Ia=t.value[F.b];Ja=t.value[F.c]}else if(t.boundTo==="faces"){Aa=t.value[Z];Ia=t.value[Z];Ja=t.value[Z];t.offsetSrc++}else if(t.boundTo===
+"faceVertices"){Aa=t.value[Z+0];Ia=t.value[Z+1];Ja=t.value[Z+2];t.offsetSrc+=3}if(t.size===2){t.array[D+0]=Aa.x;t.array[D+1]=Aa.y;t.array[D+2]=Ia.x;t.array[D+3]=Ia.y;t.array[D+4]=Ja.x;t.array[D+5]=Ja.y;t.offset+=6}else if(t.size===3){if(t.type==="c"){t.array[D+0]=Aa.r;t.array[D+1]=Aa.g;t.array[D+2]=Aa.b;t.array[D+3]=Ia.r;t.array[D+4]=Ia.g;t.array[D+5]=Ia.b;t.array[D+6]=Ja.r;t.array[D+7]=Ja.g;t.array[D+8]=Ja.b}else{t.array[D+0]=Aa.x;t.array[D+1]=Aa.y;t.array[D+2]=Aa.z;t.array[D+3]=Ia.x;t.array[D+4]=
+Ia.y;t.array[D+5]=Ia.z;t.array[D+6]=Ja.x;t.array[D+7]=Ja.y;t.array[D+8]=Ja.z}t.offset+=9}else{t.array[D+0]=Aa.x;t.array[D+1]=Aa.y;t.array[D+2]=Aa.z;t.array[D+3]=Aa.w;t.array[D+4]=Ia.x;t.array[D+5]=Ia.y;t.array[D+6]=Ia.z;t.array[D+7]=Ia.w;t.array[D+8]=Ja.x;t.array[D+9]=Ja.y;t.array[D+10]=Ja.z;t.array[D+11]=Ja.w;t.offset+=12}}}}if(wb){D=0;for(Z=jb.length;D<Z;D++){Aa=jb[D].vertices[F.a].position;Ia=jb[D].vertices[F.b].position;Ja=jb[D].vertices[F.c].position;t=Na[D];t[Ra+0]=Aa.x;t[Ra+1]=Aa.y;t[Ra+2]=
+Aa.z;t[Ra+3]=Ia.x;t[Ra+4]=Ia.y;t[Ra+5]=Ia.z;t[Ra+6]=Ja.x;t[Ra+7]=Ja.y;t[Ra+8]=Ja.z}Ra+=9}if(kb.length){D=kb[F.a];Z=kb[F.b];t=kb[F.c];P[T]=D.x;P[T+1]=D.y;P[T+2]=D.z;P[T+3]=D.w;P[T+4]=Z.x;P[T+5]=Z.y;P[T+6]=Z.z;P[T+7]=Z.w;P[T+8]=t.x;P[T+9]=t.y;P[T+10]=t.z;P[T+11]=t.w;D=qb[F.a];Z=qb[F.b];t=qb[F.c];ga[T]=D.x;ga[T+1]=D.y;ga[T+2]=D.z;ga[T+3]=D.w;ga[T+4]=Z.x;ga[T+5]=Z.y;ga[T+6]=Z.z;ga[T+7]=Z.w;ga[T+8]=t.x;ga[T+9]=t.y;ga[T+10]=t.z;ga[T+11]=t.w;D=ob[F.a];Z=ob[F.b];t=ob[F.c];va[T]=D.x;va[T+1]=D.y;va[T+2]=D.z;
+va[T+3]=1;va[T+4]=Z.x;va[T+5]=Z.y;va[T+6]=Z.z;va[T+7]=1;va[T+8]=t.x;va[T+9]=t.y;va[T+10]=t.z;va[T+11]=1;D=pb[F.a];Z=pb[F.b];t=pb[F.c];ua[T]=D.x;ua[T+1]=D.y;ua[T+2]=D.z;ua[T+3]=1;ua[T+4]=Z.x;ua[T+5]=Z.y;ua[T+6]=Z.z;ua[T+7]=1;ua[T+8]=t.x;ua[T+9]=t.y;ua[T+10]=t.z;ua[T+11]=1;T+=12}if(vb&&Ha){if(M.length==3&&Ha==THREE.VertexColors){F=M[0];D=M[1];Z=M[2]}else Z=D=F=X;ca[La]=F.r;ca[La+1]=F.g;ca[La+2]=F.b;ca[La+3]=D.r;ca[La+4]=D.g;ca[La+5]=D.b;ca[La+6]=Z.r;ca[La+7]=Z.g;ca[La+8]=Z.b;La+=9}if(ub&&Pa.hasTangents){M=
+U[0];X=U[1];F=U[2];ea[Oa]=M.x;ea[Oa+1]=M.y;ea[Oa+2]=M.z;ea[Oa+3]=M.w;ea[Oa+4]=X.x;ea[Oa+5]=X.y;ea[Oa+6]=X.z;ea[Oa+7]=X.w;ea[Oa+8]=F.x;ea[Oa+9]=F.y;ea[Oa+10]=F.z;ea[Oa+11]=F.w;Oa+=12}if(tb&&oa)if(H.length==3&&lb)for(U=0;U<3;U++){J=H[U];ta[eb]=J.x;ta[eb+1]=J.y;ta[eb+2]=J.z;eb+=3}else for(U=0;U<3;U++){ta[eb]=J.x;ta[eb+1]=J.y;ta[eb+2]=J.z;eb+=3}if(rb&&wa!==undefined&&Ca)for(U=0;U<3;U++){H=wa[U];Za[gb]=H.u;Za[gb+1]=H.v;gb+=2}if(rb&&cb!==undefined&&Ca)for(U=0;U<3;U++){H=cb[U];W[hb]=H.u;W[hb+1]=H.v;hb+=
+2}if(sb){Ua[Wa]=Ma;Ua[Wa+1]=Ma+1;Ua[Wa+2]=Ma+2;Wa+=3;bb[Ka]=Ma;bb[Ka+1]=Ma+1;bb[Ka+2]=Ma;bb[Ka+3]=Ma+2;bb[Ka+4]=Ma+1;bb[Ka+5]=Ma+2;Ka+=6;Ma+=3}}else if(F instanceof THREE.Face4){if(ib){Aa=nb[F.a].position;Ia=nb[F.b].position;Ja=nb[F.c].position;Qa=nb[F.d].position;Xa[Va]=Aa.x;Xa[Va+1]=Aa.y;Xa[Va+2]=Aa.z;Xa[Va+3]=Ia.x;Xa[Va+4]=Ia.y;Xa[Va+5]=Ia.z;Xa[Va+6]=Ja.x;Xa[Va+7]=Ja.y;Xa[Va+8]=Ja.z;Xa[Va+9]=Qa.x;Xa[Va+10]=Qa.y;Xa[Va+11]=Qa.z;Va+=12}if(db)for(fb in db){t=db[fb];if(t.needsUpdate){D=t.offset;Z=t.offsetSrc;
+if(t.size===1){if(t.boundTo===undefined||t.boundTo==="vertices"){t.array[D+0]=t.value[F.a];t.array[D+1]=t.value[F.b];t.array[D+2]=t.value[F.c];t.array[D+2]=t.value[F.d]}else if(t.boundTo==="faces"){t.array[D+0]=t.value[Z];t.array[D+1]=t.value[Z];t.array[D+2]=t.value[Z];t.array[D+2]=t.value[Z];t.offsetSrc++}else if(t.boundTo==="faceVertices"){t.array[D+0]=t.value[Z+0];t.array[D+1]=t.value[Z+1];t.array[D+2]=t.value[Z+2];t.array[D+2]=t.value[Z+3];t.offsetSrc+=4}t.offset+=4}else{if(t.boundTo===undefined||
+t.boundTo==="vertices"){Aa=t.value[F.a];Ia=t.value[F.b];Ja=t.value[F.c];Qa=t.value[F.d]}else if(t.boundTo==="faces"){Aa=t.value[Z];Ia=t.value[Z];Ja=t.value[Z];Qa=t.value[Z];t.offsetSrc++}else if(t.boundTo==="faceVertices"){Aa=t.value[Z+0];Ia=t.value[Z+1];Ja=t.value[Z+2];Qa=t.value[Z+3];t.offsetSrc+=4}if(t.size===2){t.array[D+0]=Aa.x;t.array[D+1]=Aa.y;t.array[D+2]=Ia.x;t.array[D+3]=Ia.y;t.array[D+4]=Ja.x;t.array[D+5]=Ja.y;t.array[D+6]=Qa.x;t.array[D+7]=Qa.y;t.offset+=8}else if(t.size===3){if(t.type===
+"c"){t.array[D+0]=Aa.r;t.array[D+1]=Aa.g;t.array[D+2]=Aa.b;t.array[D+3]=Ia.r;t.array[D+4]=Ia.g;t.array[D+5]=Ia.b;t.array[D+6]=Ja.r;t.array[D+7]=Ja.g;t.array[D+8]=Ja.b;t.array[D+9]=Qa.r;t.array[D+10]=Qa.g;t.array[D+11]=Qa.b}else{t.array[D+0]=Aa.x;t.array[D+1]=Aa.y;t.array[D+2]=Aa.z;t.array[D+3]=Ia.x;t.array[D+4]=Ia.y;t.array[D+5]=Ia.z;t.array[D+6]=Ja.x;t.array[D+7]=Ja.y;t.array[D+8]=Ja.z;t.array[D+9]=Qa.x;t.array[D+10]=Qa.y;t.array[D+11]=Qa.z}t.offset+=12}else{t.array[D+0]=Aa.x;t.array[D+1]=Aa.y;t.array[D+
+2]=Aa.z;t.array[D+3]=Aa.w;t.array[D+4]=Ia.x;t.array[D+5]=Ia.y;t.array[D+6]=Ia.z;t.array[D+7]=Ia.w;t.array[D+8]=Ja.x;t.array[D+9]=Ja.y;t.array[D+10]=Ja.z;t.array[D+11]=Ja.w;t.array[D+12]=Qa.x;t.array[D+13]=Qa.y;t.array[D+14]=Qa.z;t.array[D+15]=Qa.w;t.offset+=16}}}}if(wb){D=0;for(Z=jb.length;D<Z;D++){Aa=jb[D].vertices[F.a].position;Ia=jb[D].vertices[F.b].position;Ja=jb[D].vertices[F.c].position;Qa=jb[D].vertices[F.d].position;t=Na[D];t[Ra+0]=Aa.x;t[Ra+1]=Aa.y;t[Ra+2]=Aa.z;t[Ra+3]=Ia.x;t[Ra+4]=Ia.y;
+t[Ra+5]=Ia.z;t[Ra+6]=Ja.x;t[Ra+7]=Ja.y;t[Ra+8]=Ja.z;t[Ra+9]=Qa.x;t[Ra+10]=Qa.y;t[Ra+11]=Qa.z}Ra+=12}if(kb.length){D=kb[F.a];Z=kb[F.b];t=kb[F.c];ab=kb[F.d];P[T]=D.x;P[T+1]=D.y;P[T+2]=D.z;P[T+3]=D.w;P[T+4]=Z.x;P[T+5]=Z.y;P[T+6]=Z.z;P[T+7]=Z.w;P[T+8]=t.x;P[T+9]=t.y;P[T+10]=t.z;P[T+11]=t.w;P[T+12]=ab.x;P[T+13]=ab.y;P[T+14]=ab.z;P[T+15]=ab.w;D=qb[F.a];Z=qb[F.b];t=qb[F.c];ab=qb[F.d];ga[T]=D.x;ga[T+1]=D.y;ga[T+2]=D.z;ga[T+3]=D.w;ga[T+4]=Z.x;ga[T+5]=Z.y;ga[T+6]=Z.z;ga[T+7]=Z.w;ga[T+8]=t.x;ga[T+9]=t.y;ga[T+
+10]=t.z;ga[T+11]=t.w;ga[T+12]=ab.x;ga[T+13]=ab.y;ga[T+14]=ab.z;ga[T+15]=ab.w;D=ob[F.a];Z=ob[F.b];t=ob[F.c];ab=ob[F.d];va[T]=D.x;va[T+1]=D.y;va[T+2]=D.z;va[T+3]=1;va[T+4]=Z.x;va[T+5]=Z.y;va[T+6]=Z.z;va[T+7]=1;va[T+8]=t.x;va[T+9]=t.y;va[T+10]=t.z;va[T+11]=1;va[T+12]=ab.x;va[T+13]=ab.y;va[T+14]=ab.z;va[T+15]=1;D=pb[F.a];Z=pb[F.b];t=pb[F.c];F=pb[F.d];ua[T]=D.x;ua[T+1]=D.y;ua[T+2]=D.z;ua[T+3]=1;ua[T+4]=Z.x;ua[T+5]=Z.y;ua[T+6]=Z.z;ua[T+7]=1;ua[T+8]=t.x;ua[T+9]=t.y;ua[T+10]=t.z;ua[T+11]=1;ua[T+12]=F.x;ua[T+
+13]=F.y;ua[T+14]=F.z;ua[T+15]=1;T+=16}if(vb&&Ha){if(M.length==4&&Ha==THREE.VertexColors){F=M[0];D=M[1];Z=M[2];M=M[3]}else M=Z=D=F=X;ca[La]=F.r;ca[La+1]=F.g;ca[La+2]=F.b;ca[La+3]=D.r;ca[La+4]=D.g;ca[La+5]=D.b;ca[La+6]=Z.r;ca[La+7]=Z.g;ca[La+8]=Z.b;ca[La+9]=M.r;ca[La+10]=M.g;ca[La+11]=M.b;La+=12}if(ub&&Pa.hasTangents){M=U[0];X=U[1];F=U[2];U=U[3];ea[Oa]=M.x;ea[Oa+1]=M.y;ea[Oa+2]=M.z;ea[Oa+3]=M.w;ea[Oa+4]=X.x;ea[Oa+5]=X.y;ea[Oa+6]=X.z;ea[Oa+7]=X.w;ea[Oa+8]=F.x;ea[Oa+9]=F.y;ea[Oa+10]=F.z;ea[Oa+11]=F.w;
+ea[Oa+12]=U.x;ea[Oa+13]=U.y;ea[Oa+14]=U.z;ea[Oa+15]=U.w;Oa+=16}if(tb&&oa)if(H.length==4&&lb)for(U=0;U<4;U++){J=H[U];ta[eb]=J.x;ta[eb+1]=J.y;ta[eb+2]=J.z;eb+=3}else for(U=0;U<4;U++){ta[eb]=J.x;ta[eb+1]=J.y;ta[eb+2]=J.z;eb+=3}if(rb&&wa!==undefined&&Ca)for(U=0;U<4;U++){H=wa[U];Za[gb]=H.u;Za[gb+1]=H.v;gb+=2}if(rb&&cb!==undefined&&Ca)for(U=0;U<4;U++){H=cb[U];W[hb]=H.u;W[hb+1]=H.v;hb+=2}if(sb){Ua[Wa]=Ma;Ua[Wa+1]=Ma+1;Ua[Wa+2]=Ma+3;Ua[Wa+3]=Ma+1;Ua[Wa+4]=Ma+2;Ua[Wa+5]=Ma+3;Wa+=6;bb[Ka]=Ma;bb[Ka+1]=Ma+1;
+bb[Ka+2]=Ma;bb[Ka+3]=Ma+3;bb[Ka+4]=Ma+1;bb[Ka+5]=Ma+2;bb[Ka+6]=Ma+2;bb[Ka+7]=Ma+3;Ka+=8;Ma+=4}}}if(mb){I=0;for(K=mb.length;I<K;I++){Ua[Wa]=mb[I].a;Ua[Wa+1]=mb[I].b;Ua[Wa+2]=mb[I].c;Ua[Wa+3]=mb[I].a;Ua[Wa+4]=mb[I].c;Ua[Wa+5]=mb[I].d;Wa+=6}}if(ib){e.bindBuffer(e.ARRAY_BUFFER,v.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,Xa,O)}if(db)for(fb in db){t=db[fb];if(t.needsUpdate){e.bindBuffer(e.ARRAY_BUFFER,t.buffer);e.bufferData(e.ARRAY_BUFFER,t.array,O);t.needsUpdate=!1}}if(wb){D=0;for(Z=jb.length;D<
+Z;D++){e.bindBuffer(e.ARRAY_BUFFER,v.__webglMorphTargetsBuffers[D]);e.bufferData(e.ARRAY_BUFFER,Na[D],O)}}if(vb&&La>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,ca,O)}if(tb){e.bindBuffer(e.ARRAY_BUFFER,v.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,ta,O)}if(ub&&Pa.hasTangents){e.bindBuffer(e.ARRAY_BUFFER,v.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,ea,O)}if(rb&&gb>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglUVBuffer);e.bufferData(e.ARRAY_BUFFER,Za,O)}if(rb&&
+hb>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglUV2Buffer);e.bufferData(e.ARRAY_BUFFER,W,O)}if(sb){e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ua,O);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,v.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,bb,O)}if(T>0){e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexABuffer);e.bufferData(e.ARRAY_BUFFER,va,O);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinVertexBBuffer);e.bufferData(e.ARRAY_BUFFER,ua,O);e.bindBuffer(e.ARRAY_BUFFER,
+v.__webglSkinIndicesBuffer);e.bufferData(e.ARRAY_BUFFER,ga,O);e.bindBuffer(e.ARRAY_BUFFER,v.__webglSkinWeightsBuffer);e.bufferData(e.ARRAY_BUFFER,P,O)}}}x.__dirtyVertices=!1;x.__dirtyMorphTargets=!1;x.__dirtyElements=!1;x.__dirtyUvs=!1;x.__dirtyNormals=!1;x.__dirtyTangents=!1;x.__dirtyColors=!1}else if(m instanceof THREE.Ribbon){x=m.geometry;if(x.__dirtyVertices||x.__dirtyColors){m=x;C=e.DYNAMIC_DRAW;Ha=m.vertices;v=m.colors;oa=Ha.length;O=v.length;wa=m.__vertexArray;I=m.__colorArray;cb=m.__dirtyColors;
+if(m.__dirtyVertices){for(K=0;K<oa;K++){Ca=Ha[K].position;B=K*3;wa[B]=Ca.x;wa[B+1]=Ca.y;wa[B+2]=Ca.z}e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,wa,C)}if(cb){for(K=0;K<O;K++){color=v[K];B=K*3;I[B]=color.r;I[B+1]=color.g;I[B+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,I,C)}}x.__dirtyVertices=!1;x.__dirtyColors=!1}else if(m instanceof THREE.Line){x=m.geometry;if(x.__dirtyVertices||x.__dirtyColors){m=x;C=e.DYNAMIC_DRAW;Ha=
+m.vertices;v=m.colors;oa=Ha.length;O=v.length;wa=m.__vertexArray;I=m.__colorArray;cb=m.__dirtyColors;if(m.__dirtyVertices){for(K=0;K<oa;K++){Ca=Ha[K].position;B=K*3;wa[B]=Ca.x;wa[B+1]=Ca.y;wa[B+2]=Ca.z}e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,wa,C)}if(cb){for(K=0;K<O;K++){color=v[K];B=K*3;I[B]=color.r;I[B+1]=color.g;I[B+2]=color.b}e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,I,C)}}x.__dirtyVertices=!1;x.__dirtyColors=!1}else if(m instanceof
+THREE.ParticleSystem){x=m.geometry;(x.__dirtyVertices||x.__dirtyColors||m.sortParticles)&&d(x,e.DYNAMIC_DRAW,m);x.__dirtyVertices=!1;x.__dirtyColors=!1}}function L(m){function C(X){var U=[];x=0;for(v=X.length;x<v;x++)X[x]==undefined?U.push("undefined"):U.push(X[x].id);return U.join("_")}var x,v,B,O,I,K,H,F,J={},M=m.morphTargets!==undefined?m.morphTargets.length:0;m.geometryGroups={};B=0;for(O=m.faces.length;B<O;B++){I=m.faces[B];K=I.materials;H=C(K);J[H]==undefined&&(J[H]={hash:H,counter:0});F=J[H].hash+
+"_"+J[H].counter;m.geometryGroups[F]==undefined&&(m.geometryGroups[F]={faces:[],materials:K,vertices:0,numMorphTargets:M});I=I instanceof THREE.Face3?3:4;if(m.geometryGroups[F].vertices+I>65535){J[H].counter+=1;F=J[H].hash+"_"+J[H].counter;m.geometryGroups[F]==undefined&&(m.geometryGroups[F]={faces:[],materials:K,vertices:0,numMorphTargets:M})}m.geometryGroups[F].faces.push(B);m.geometryGroups[F].vertices+=I}}function V(m,C,x){m.push({buffer:C,object:x,opaque:{list:[],count:0},transparent:{list:[],
+count:0}})}function z(m){if(m!=za){switch(m){case THREE.AdditiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE);break;case THREE.SubtractiveBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:e.blendEquation(e.FUNC_ADD);e.blendFunc(e.ZERO,e.SRC_COLOR);break;default:e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD);e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}za=m}}function N(m,C,x){if((x.width&
+x.width-1)==0&&(x.height&x.height-1)==0){e.texParameteri(m,e.TEXTURE_WRAP_S,qa(C.wrapS));e.texParameteri(m,e.TEXTURE_WRAP_T,qa(C.wrapT));e.texParameteri(m,e.TEXTURE_MAG_FILTER,qa(C.magFilter));e.texParameteri(m,e.TEXTURE_MIN_FILTER,qa(C.minFilter));e.generateMipmap(m)}else{e.texParameteri(m,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(m,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(m,e.TEXTURE_MAG_FILTER,sa(C.magFilter));e.texParameteri(m,e.TEXTURE_MIN_FILTER,sa(C.minFilter))}}function Q(m,
+C){if(m.needsUpdate){if(m.__webglInit){e.bindTexture(e.TEXTURE_2D,m.__webglTexture);e.texSubImage2D(e.TEXTURE_2D,0,0,0,e.RGBA,e.UNSIGNED_BYTE,m.image)}else{m.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,m.__webglTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,m.image);m.__webglInit=!0}N(e.TEXTURE_2D,m,m.image);e.bindTexture(e.TEXTURE_2D,null);m.needsUpdate=!1}e.activeTexture(e.TEXTURE0+C);e.bindTexture(e.TEXTURE_2D,m.__webglTexture)}function S(m){if(m&&!m.__webglFramebuffer){if(m.depthBuffer===
+undefined)m.depthBuffer=!0;if(m.stencilBuffer===undefined)m.stencilBuffer=!0;m.__webglFramebuffer=e.createFramebuffer();m.__webglRenderbuffer=e.createRenderbuffer();m.__webglTexture=e.createTexture();e.bindTexture(e.TEXTURE_2D,m.__webglTexture);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,qa(m.wrapS));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,qa(m.wrapT));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,qa(m.magFilter));e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,qa(m.minFilter));e.texImage2D(e.TEXTURE_2D,
+0,qa(m.format),m.width,m.height,0,qa(m.format),qa(m.type),null);e.bindRenderbuffer(e.RENDERBUFFER,m.__webglRenderbuffer);e.bindFramebuffer(e.FRAMEBUFFER,m.__webglFramebuffer);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,m.__webglTexture,0);if(m.depthBuffer&&!m.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,m.width,m.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,m.__webglRenderbuffer)}else if(m.depthBuffer&&m.stencilBuffer){e.renderbufferStorage(e.RENDERBUFFER,
+e.DEPTH_STENCIL,m.width,m.height);e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,m.__webglRenderbuffer)}else e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,m.width,m.height);e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var C,x;if(m){C=m.__webglFramebuffer;x=m.width;m=m.height}else{C=null;x=Da;m=ja}if(C!=Fa){e.bindFramebuffer(e.FRAMEBUFFER,C);e.viewport(Y,ma,x,m);Fa=C}}function xa(m,C){var x;if(m=="fragment")x=
+e.createShader(e.FRAGMENT_SHADER);else m=="vertex"&&(x=e.createShader(e.VERTEX_SHADER));e.shaderSource(x,C);e.compileShader(x);if(!e.getShaderParameter(x,e.COMPILE_STATUS)){console.error(e.getShaderInfoLog(x));console.error(C);return null}return x}function sa(m){switch(m){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function qa(m){switch(m){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;
+case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;
+case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var e,fa=document.createElement("canvas"),da=[],ya=null,Fa=null,Ga=!0,ra=this,aa=null,pa=null,za=null,ia=null,
+Y=0,ma=0,Da=0,ja=0,la=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Ea=new THREE.Matrix4,Sa=new Float32Array(16),$a=new Float32Array(16),Ya=new THREE.Vector4,Ta={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},R=!0,$=!0,na=new THREE.Color(0),Ba=0;if(b){if(b.stencil!=undefined)R=b.stencil;if(b.antialias!==undefined)$=b.antialias;b.clearColor!==undefined&&na.setHex(b.clearColor);
+if(b.clearAlpha!==undefined)Ba=b.clearAlpha}this.maxMorphTargets=8;this.domElement=fa;this.autoClear=!0;this.sortObjects=!0;(function(m,C,x,v){try{if(!(e=fa.getContext("experimental-webgl",{antialias:m,stencil:v})))throw"Error creating WebGL context.";}catch(B){console.error(B)}e.clearColor(0,0,0,1);e.clearDepth(1);e.enable(e.DEPTH_TEST);e.depthFunc(e.LEQUAL);e.frontFace(e.CCW);e.cullFace(e.BACK);e.enable(e.CULL_FACE);e.enable(e.BLEND);e.blendEquation(e.FUNC_ADD);e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA);
+e.clearColor(C.r,C.g,C.b,x)})($,na,Ba,R);this.context=e;if(R){var ha={};ha.vertices=new Float32Array(12);ha.faces=new Uint16Array(6);ha.darkness=0.5;ha.vertices[0]=-20;ha.vertices[1]=-20;ha.vertices[2]=-1;ha.vertices[3]=20;ha.vertices[4]=-20;ha.vertices[5]=-1;ha.vertices[6]=20;ha.vertices[7]=20;ha.vertices[8]=-1;ha.vertices[9]=-20;ha.vertices[10]=20;ha.vertices[11]=-1;ha.faces[0]=0;ha.faces[1]=1;ha.faces[2]=2;ha.faces[3]=0;ha.faces[4]=2;ha.faces[5]=3;ha.vertexBuffer=e.createBuffer();ha.elementBuffer=
+e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,ha.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,ha.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ha.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ha.faces,e.STATIC_DRAW);ha.program=e.createProgram();e.attachShader(ha.program,xa("fragment",THREE.ShaderLib.shadowPost.fragmentShader));e.attachShader(ha.program,xa("vertex",THREE.ShaderLib.shadowPost.vertexShader));e.linkProgram(ha.program);ha.vertexLocation=e.getAttribLocation(ha.program,"position");
+ha.projectionLocation=e.getUniformLocation(ha.program,"projectionMatrix");ha.darknessLocation=e.getUniformLocation(ha.program,"darkness")}var ka={};ka.vertices=new Float32Array(16);ka.faces=new Uint16Array(6);ka.transparency=0.5;b=0;ka.vertices[b++]=-1;ka.vertices[b++]=-1;ka.vertices[b++]=0;ka.vertices[b++]=0;ka.vertices[b++]=1;ka.vertices[b++]=-1;ka.vertices[b++]=1;ka.vertices[b++]=0;ka.vertices[b++]=1;ka.vertices[b++]=1;ka.vertices[b++]=1;ka.vertices[b++]=1;ka.vertices[b++]=-1;ka.vertices[b++]=
+1;ka.vertices[b++]=0;ka.vertices[b++]=1;b=0;ka.faces[b++]=0;ka.faces[b++]=1;ka.faces[b++]=2;ka.faces[b++]=0;ka.faces[b++]=2;ka.faces[b++]=3;ka.vertexBuffer=e.createBuffer();ka.elementBuffer=e.createBuffer();ka.tempTexture=e.createTexture();ka.readBackPixels=new Uint8Array(1024);e.bindBuffer(e.ARRAY_BUFFER,ka.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,ka.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,ka.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,ka.faces,e.STATIC_DRAW);e.bindTexture(e.TEXTURE_2D,
+ka.tempTexture);e.texImage2D(e.TEXTURE_2D,0,e.RGB,16,16,0,e.RGB,e.UNSIGNED_BYTE,null);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST);e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST);ka.program=e.createProgram();e.attachShader(ka.program,xa("fragment",THREE.ShaderLib.lensFlare.fragmentShader));e.attachShader(ka.program,xa("vertex",THREE.ShaderLib.lensFlare.vertexShader));
+e.linkProgram(ka.program);ka.attributes={};ka.uniforms={};ka.attributes.vertex=e.getAttribLocation(ka.program,"position");ka.attributes.uv=e.getAttribLocation(ka.program,"UV");ka.uniforms.map=e.getUniformLocation(ka.program,"map");ka.uniforms.opacity=e.getUniformLocation(ka.program,"opacity");ka.uniforms.scale=e.getUniformLocation(ka.program,"scale");ka.uniforms.rotation=e.getUniformLocation(ka.program,"rotation");ka.uniforms.screenPosition=e.getUniformLocation(ka.program,"screenPosition");ka.uniforms.renderPink=
+e.getUniformLocation(ka.program,"renderPink");this.setSize=function(m,C){fa.width=m;fa.height=C;this.setViewport(0,0,fa.width,fa.height)};this.setViewport=function(m,C,x,v){Y=m;ma=C;Da=x;ja=v;e.viewport(Y,ma,Da,ja)};this.setScissor=function(m,C,x,v){e.scissor(m,C,x,v)};this.enableScissorTest=function(m){m?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.enableDepthBufferWrite=function(m){Ga=m;e.depthMask(m)};this.setClearColorHex=function(m,C){var x=new THREE.Color(m);e.clearColor(x.r,x.g,
+x.b,C)};this.setClearColor=function(m,C){e.clearColor(m.r,m.g,m.b,C)};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(m){ha.darkness=m};this.initMaterial=function(m,C,x,v){var B,O,I;if(m instanceof THREE.MeshDepthMaterial)I="depth";else if(m instanceof THREE.ShadowVolumeDynamicMaterial)I="shadowVolumeDynamic";else if(m instanceof THREE.MeshNormalMaterial)I="normal";else if(m instanceof THREE.MeshBasicMaterial)I="basic";
+else if(m instanceof THREE.MeshLambertMaterial)I="lambert";else if(m instanceof THREE.MeshPhongMaterial)I="phong";else if(m instanceof THREE.LineBasicMaterial)I="basic";else m instanceof THREE.ParticleBasicMaterial&&(I="particle_basic");if(I){var K=THREE.ShaderLib[I];m.uniforms=Uniforms.clone(K.uniforms);m.vertexShader=K.vertexShader;m.fragmentShader=K.fragmentShader}var H,F,J;H=J=K=0;for(F=C.length;H<F;H++){O=C[H];O instanceof THREE.DirectionalLight&&J++;O instanceof THREE.PointLight&&K++}if(K+J<=
+4)C=J;else{C=Math.ceil(4*J/(K+J));K=4-C}O={directional:C,point:K};J=50;if(v!==undefined&&v instanceof THREE.SkinnedMesh)J=v.bones.length;var M;a:{H=m.fragmentShader;F=m.vertexShader;K=m.uniforms;C=m.attributes;x={map:!!m.map,envMap:!!m.envMap,lightMap:!!m.lightMap,vertexColors:m.vertexColors,fog:x,sizeAttenuation:m.sizeAttenuation,skinning:m.skinning,morphTargets:m.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:O.directional,maxPointLights:O.point,maxBones:J};var X;O=[];if(I)O.push(I);
+else{O.push(H);O.push(F)}for(X in x){O.push(X);O.push(x[X])}I=O.join();X=0;for(O=da.length;X<O;X++)if(da[X].code==I){M=da[X].program;break a}X=e.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,x.fog?"#define USE_FOG":"",x.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",x.map?"#define USE_MAP":"",x.envMap?"#define USE_ENVMAP":"",x.lightMap?"#define USE_LIGHTMAP":"",x.vertexColors?
+"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+x.maxDirLights,"#define MAX_POINT_LIGHTS "+x.maxPointLights,"#define MAX_BONES "+x.maxBones,x.map?"#define USE_MAP":"",x.envMap?"#define USE_ENVMAP":"",x.lightMap?"#define USE_LIGHTMAP":"",x.vertexColors?"#define USE_COLOR":"",x.skinning?"#define USE_SKINNING":"",x.morphTargets?"#define USE_MORPHTARGETS":
+"",x.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+e.attachShader(X,xa("fragment",prefix_fragment+H));e.attachShader(X,xa("vertex",prefix_vertex+F));e.linkProgram(X);e.getProgramParameter(X,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(X,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");X.uniforms={};X.attributes={};var U;H=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(U in K)H.push(U);
+U=H;K=0;for(H=U.length;K<H;K++){F=U[K];X.uniforms[F]=e.getUniformLocation(X,F)}H=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(U=0;U<x.maxMorphTargets;U++)H.push("morphTarget"+U);for(M in C)H.push(M);M=H;U=0;for(C=M.length;U<C;U++){x=M[U];X.attributes[x]=e.getAttribLocation(X,x)}da.push({program:X,code:I});M=X}m.program=M;M=m.program.attributes;e.enableVertexAttribArray(M.position);M.color>=0&&e.enableVertexAttribArray(M.color);M.normal>=
+0&&e.enableVertexAttribArray(M.normal);M.tangent>=0&&e.enableVertexAttribArray(M.tangent);if(m.skinning&&M.skinVertexA>=0&&M.skinVertexB>=0&&M.skinIndex>=0&&M.skinWeight>=0){e.enableVertexAttribArray(M.skinVertexA);e.enableVertexAttribArray(M.skinVertexB);e.enableVertexAttribArray(M.skinIndex);e.enableVertexAttribArray(M.skinWeight)}for(B in m.attributes)M[B]>=0&&e.enableVertexAttribArray(M[B]);if(m.morphTargets){m.numSupportedMorphTargets=0;if(M.morphTarget0>=0){e.enableVertexAttribArray(M.morphTarget0);
+m.numSupportedMorphTargets++}if(M.morphTarget1>=0){e.enableVertexAttribArray(M.morphTarget1);m.numSupportedMorphTargets++}if(M.morphTarget2>=0){e.enableVertexAttribArray(M.morphTarget2);m.numSupportedMorphTargets++}if(M.morphTarget3>=0){e.enableVertexAttribArray(M.morphTarget3);m.numSupportedMorphTargets++}if(M.morphTarget4>=0){e.enableVertexAttribArray(M.morphTarget4);m.numSupportedMorphTargets++}if(M.morphTarget5>=0){e.enableVertexAttribArray(M.morphTarget5);m.numSupportedMorphTargets++}if(M.morphTarget6>=
+0){e.enableVertexAttribArray(M.morphTarget6);m.numSupportedMorphTargets++}if(M.morphTarget7>=0){e.enableVertexAttribArray(M.morphTarget7);m.numSupportedMorphTargets++}v.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);m=0;for(B=this.maxMorphTargets;m<B;m++)v.__webglMorphTargetInfluences[m]=0}};this.render=function(m,C,x,v){var B,O,I,K,H,F,J,M,X=m.lights,U=m.fog;C.matrixAutoUpdate&&C.updateMatrix();m.update(undefined,!1,C);C.matrixWorldInverse.flattenToArray($a);C.projectionMatrix.flattenToArray(Sa);
+Ea.multiply(C.projectionMatrix,C.matrixWorldInverse);k(Ea);this.initWebGLObjects(m);S(x);(this.autoClear||v)&&this.clear();H=m.__webglObjects.length;for(v=0;v<H;v++){B=m.__webglObjects[v];J=B.object;if(J.visible)if(!(J instanceof THREE.Mesh)||n(J)){J.matrixWorld.flattenToArray(J._objectMatrixArray);E(J,C);u(B);B.render=!0;if(this.sortObjects){Ya.copy(J.position);Ea.multiplyVector3(Ya);B.z=Ya.z}}else B.render=!1;else B.render=!1}this.sortObjects&&m.__webglObjects.sort(y);F=m.__webglObjectsImmediate.length;
+for(v=0;v<F;v++){B=m.__webglObjectsImmediate[v];J=B.object;if(J.visible){J.matrixAutoUpdate&&J.matrixWorld.flattenToArray(J._objectMatrixArray);E(J,C);o(B)}}z(THREE.NormalBlending);for(v=0;v<H;v++){B=m.__webglObjects[v];if(B.render){J=B.object;M=B.buffer;I=B.opaque;h(J);for(B=0;B<I.count;B++){K=I.list[B];j(K.depthTest);f(C,X,U,K,M,J)}}}for(v=0;v<F;v++){B=m.__webglObjectsImmediate[v];J=B.object;if(J.visible){I=B.opaque;h(J);for(B=0;B<I.count;B++){K=I.list[B];j(K.depthTest);O=c(C,X,U,K,J);J.render(function(Ca){g(Ca,
+O)})}}}for(v=0;v<H;v++){B=m.__webglObjects[v];if(B.render){J=B.object;M=B.buffer;I=B.transparent;h(J);for(B=0;B<I.count;B++){K=I.list[B];z(K.blending);j(K.depthTest);f(C,X,U,K,M,J)}}}for(v=0;v<F;v++){B=m.__webglObjectsImmediate[v];J=B.object;if(J.visible){I=B.transparent;h(J);for(B=0;B<I.count;B++){K=I.list[B];z(K.blending);j(K.depthTest);O=c(C,X,U,K,J);J.render(function(Ca){g(Ca,O)})}}}R&&m.__webglShadowVolumes.length&&m.lights.length&&w(m);m.__webglLensFlares.length&&A(m,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){if(!m.__webglObjects){m.__webglObjects=[];m.__webglObjectsImmediate=[];m.__webglShadowVolumes=[];m.__webglLensFlares=[]}for(;m.__objectsAdded.length;){var C=m.__objectsAdded[0],x=m,v=void 0,B=void 0,O=void 0;if(C._modelViewMatrix==undefined){C._modelViewMatrix=new THREE.Matrix4;C._normalMatrixArray=new Float32Array(9);
+C._modelViewMatrixArray=new Float32Array(16);C._objectMatrixArray=new Float32Array(16);C.matrixWorld.flattenToArray(C._objectMatrixArray)}if(C instanceof THREE.Mesh){B=C.geometry;B.geometryGroups==undefined&&L(B);for(v in B.geometryGroups){O=B.geometryGroups[v];if(!O.__webglVertexBuffer){var I=O;I.__webglVertexBuffer=e.createBuffer();I.__webglNormalBuffer=e.createBuffer();I.__webglTangentBuffer=e.createBuffer();I.__webglColorBuffer=e.createBuffer();I.__webglUVBuffer=e.createBuffer();I.__webglUV2Buffer=
+e.createBuffer();I.__webglSkinVertexABuffer=e.createBuffer();I.__webglSkinVertexBBuffer=e.createBuffer();I.__webglSkinIndicesBuffer=e.createBuffer();I.__webglSkinWeightsBuffer=e.createBuffer();I.__webglFaceBuffer=e.createBuffer();I.__webglLineBuffer=e.createBuffer();if(I.numMorphTargets){var K=void 0,H=void 0;I.__webglMorphTargetsBuffers=[];K=0;for(H=I.numMorphTargets;K<H;K++)I.__webglMorphTargetsBuffers.push(e.createBuffer())}I=O;K=C;var F=void 0,J=void 0,M=void 0;M=void 0;var X=void 0,U=void 0,
+Ca=void 0,Ha=Ca=H=0;J=void 0;M=void 0;var oa=void 0;F=void 0;J=void 0;X=K.geometry;oa=X.faces;U=I.faces;F=0;for(J=U.length;F<J;F++){M=U[F];M=oa[M];if(M instanceof THREE.Face3){H+=3;Ca+=1;Ha+=3}else if(M instanceof THREE.Face4){H+=4;Ca+=2;Ha+=4}}F=I;J=K;oa=void 0;U=void 0;var wa=void 0,cb=void 0;wa=void 0;M=[];oa=0;for(U=J.materials.length;oa<U;oa++){wa=J.materials[oa];if(wa instanceof THREE.MeshFaceMaterial){wa=0;for(l=F.materials.length;wa<l;wa++)(cb=F.materials[wa])&&M.push(cb)}else(cb=wa)&&M.push(cb)}F=
+M;a:{J=void 0;oa=void 0;U=F.length;for(J=0;J<U;J++){oa=F[J];if(oa.map||oa.lightMap||oa instanceof THREE.MeshShaderMaterial){J=!0;break a}}J=!1}a:{oa=F;U=void 0;M=void 0;wa=oa.length;for(U=0;U<wa;U++){M=oa[U];if(!(M instanceof THREE.MeshBasicMaterial&&!M.envMap||M instanceof THREE.MeshDepthMaterial)){oa=M&&M.shading!=undefined&&M.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}oa=!1}a:{U=void 0;M=void 0;wa=F.length;for(U=0;U<wa;U++){M=F[U];if(M.vertexColors){M=M.vertexColors;
+break a}}M=!1}I.__vertexArray=new Float32Array(H*3);if(oa)I.__normalArray=new Float32Array(H*3);if(X.hasTangents)I.__tangentArray=new Float32Array(H*4);if(M)I.__colorArray=new Float32Array(H*3);if(J){if(X.faceUvs.length>0||X.faceVertexUvs.length>0)I.__uvArray=new Float32Array(H*2);if(X.faceUvs.length>1||X.faceVertexUvs.length>1)I.__uv2Array=new Float32Array(H*2)}if(K.geometry.skinWeights.length&&K.geometry.skinIndices.length){I.__skinVertexAArray=new Float32Array(H*4);I.__skinVertexBArray=new Float32Array(H*
+4);I.__skinIndexArray=new Float32Array(H*4);I.__skinWeightArray=new Float32Array(H*4)}I.__faceArray=new Uint16Array(Ca*3+(K.geometry.edgeFaces?K.geometry.edgeFaces.length*6:0));I.__lineArray=new Uint16Array(Ha*2);if(I.numMorphTargets){I.__morphTargetsArrays=[];X=0;for(U=I.numMorphTargets;X<U;X++)I.__morphTargetsArrays.push(new Float32Array(H*3))}I.__needsSmoothNormals=oa==THREE.SmoothShading;I.__uvType=J;I.__vertexColorType=M;I.__normalType=oa;I.__webglFaceCount=Ca*3+(K.geometry.edgeFaces?K.geometry.edgeFaces.length*
+6:0);I.__webglLineCount=Ha*2;X=0;for(U=F.length;X<U;X++)if(F[X].attributes){I.__webglCustomAttributes={};for(a in F[X].attributes){J=F[X].attributes[a];Ca=1;if(J.type==="v2")Ca=2;else if(J.type==="v3")Ca=3;else if(J.type==="v4")Ca=4;else J.type==="c"&&(Ca=3);J.size=Ca;J.needsUpdate=!0;J.array=new Float32Array(H*Ca);J.buffer=e.createBuffer();I.__webglCustomAttributes[a]=J}}B.__dirtyVertices=!0;B.__dirtyMorphTargets=!0;B.__dirtyElements=!0;B.__dirtyUvs=!0;B.__dirtyNormals=!0;B.__dirtyTangents=!0;B.__dirtyColors=
+!0}C instanceof THREE.ShadowVolume?V(x.__webglShadowVolumes,O,C):V(x.__webglObjects,O,C)}}else if(C instanceof THREE.LensFlare)V(x.__webglLensFlares,undefined,C);else if(C instanceof THREE.Ribbon){B=C.geometry;if(!B.__webglVertexBuffer){v=B;v.__webglVertexBuffer=e.createBuffer();v.__webglColorBuffer=e.createBuffer();v=B;O=v.vertices.length;v.__vertexArray=new Float32Array(O*3);v.__colorArray=new Float32Array(O*3);v.__webglVertexCount=O;B.__dirtyVertices=!0;B.__dirtyColors=!0}V(x.__webglObjects,B,
+C)}else if(C instanceof THREE.Line){B=C.geometry;if(!B.__webglVertexBuffer){v=B;v.__webglVertexBuffer=e.createBuffer();v.__webglColorBuffer=e.createBuffer();v=B;O=v.vertices.length;v.__vertexArray=new Float32Array(O*3);v.__colorArray=new Float32Array(O*3);v.__webglLineCount=O;B.__dirtyVertices=!0;B.__dirtyColors=!0}V(x.__webglObjects,B,C)}else if(C instanceof THREE.ParticleSystem){B=C.geometry;if(!B.__webglVertexBuffer){v=B;v.__webglVertexBuffer=e.createBuffer();v.__webglColorBuffer=e.createBuffer();
+v=B;O=v.vertices.length;v.__vertexArray=new Float32Array(O*3);v.__colorArray=new Float32Array(O*3);v.__sortArray=[];v.__webglParticleCount=O;B.__dirtyVertices=!0;B.__dirtyColors=!0}V(x.__webglObjects,B,C)}else THREE.MarchingCubes!==undefined&&C instanceof THREE.MarchingCubes&&x.__webglObjectsImmediate.push({object:C,opaque:{list:[],count:0},transparent:{list:[],count:0}});m.__objectsAdded.splice(0,1)}for(;m.__objectsRemoved.length;){C=m.__objectsRemoved[0];x=m;B=void 0;v=void 0;for(B=x.__webglObjects.length-
+1;B>=0;B--){v=x.__webglObjects[B].object;C==v&&x.__webglObjects.splice(B,1)}m.__objectsRemoved.splice(0,1)}C=0;for(x=m.__webglObjects.length;C<x;C++)G(m.__webglObjects[C].object,m);C=0;for(x=m.__webglShadowVolumes.length;C<x;C++)G(m.__webglShadowVolumes[C].object,m);C=0;for(x=m.__webglLensFlares.length;C<x;C++)G(m.__webglLensFlares[C].object,m)};this.setFaceCulling=function(m,C){if(m){!C||C=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW);if(m=="back")e.cullFace(e.BACK);else m=="front"?e.cullFace(e.FRONT):
 e.cullFace(e.FRONT_AND_BACK);e.enable(e.CULL_FACE)}else e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0}};
 THREE.WebGLRenderTarget=function(b,d,c){this.width=b;this.height=d;c=c||{};this.wrapS=c.wrapS!==undefined?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=c.wrapT!==undefined?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=c.magFilter!==undefined?c.magFilter:THREE.LinearFilter;this.minFilter=c.minFilter!==undefined?c.minFilter:THREE.LinearMipMapLinearFilter;this.format=c.format!==undefined?c.format:THREE.RGBFormat;this.type=c.type!==undefined?c.type:THREE.UnsignedByteType;this.depthBuffer=c.depthBuffer!==
 undefined?c.depthBuffer:!0;this.stencilBuffer=c.stencilBuffer!==undefined?c.stencilBuffer:!0};
@@ -330,18 +333,18 @@ THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.posi
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterials=this.meshMaterials=null;this.overdraw=!1;this.uvs=[[]];this.z=null};
 THREE.RenderableObject=function(){this.z=this.object=null};THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.materials=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.materials=null};
-var GeometryUtils={merge:function(b,d){var c=d instanceof THREE.Mesh,f=b.vertices.length,g=c?d.geometry:d,h=b.vertices,j=g.vertices,k=b.faces,n=g.faces,p=b.faceVertexUvs[0];g=g.faceVertexUvs[0];c&&d.matrixAutoUpdate&&d.updateMatrix();for(var o=0,u=j.length;o<u;o++){var y=new THREE.Vertex(j[o].position.clone());c&&d.matrix.multiplyVector3(y.position);h.push(y)}o=0;for(u=n.length;o<u;o++){j=n[o];var v,B,C=j.vertexNormals;y=j.vertexColors;if(j instanceof THREE.Face3)v=new THREE.Face3(j.a+f,j.b+f,j.c+
-f);else j instanceof THREE.Face4&&(v=new THREE.Face4(j.a+f,j.b+f,j.c+f,j.d+f));v.normal.copy(j.normal);c=0;for(h=C.length;c<h;c++){B=C[c];v.vertexNormals.push(B.clone())}v.color.copy(j.color);c=0;for(h=y.length;c<h;c++){B=y[c];v.vertexColors.push(B.clone())}v.materials=j.materials.slice();v.centroid.copy(j.centroid);k.push(v)}o=0;for(u=g.length;o<u;o++){f=g[o];k=[];c=0;for(h=f.length;c<h;c++)k.push(new THREE.UV(f[c].u,f[c].v));p.push(k)}}},ImageUtils={loadTexture:function(b,d,c){var f=new Image,g=
-new THREE.Texture(f,d);f.onload=function(){g.needsUpdate=!0;c&&c(this)};f.src=b;return g},loadTextureCube:function(b,d,c){var f,g=[],h=new THREE.Texture(g,d);d=g.loadCount=0;for(f=b.length;d<f;++d){g[d]=new Image;g[d].onload=function(){g.loadCount+=1;if(g.loadCount==6)h.needsUpdate=!0;c&&c(this)};g[d].src=b[d]}return h}},SceneUtils={loadScene:function(b,d,c,f){var g=new Worker(b);g.postMessage(0);var h=THREE.Loader.prototype.extractUrlbase(b);g.onmessage=function(j){function k(Da,ga){return ga=="relativeToHTML"?
-Da:h+"/"+Da}function n(){for(v in Z.objects)if(!$.objects[v]){U=Z.objects[v];if(M=$.geometries[U.geometry]){xa=[];for(pa=0;pa<U.materials.length;pa++)xa[pa]=$.materials[U.materials[pa]];z=U.position;r=U.rotation;q=U.quaternion;s=U.scale;q=0;xa.length==0&&(xa[0]=new THREE.MeshFaceMaterial);object=new THREE.Mesh(M,xa);object.position.set(z[0],z[1],z[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);
-object.visible=U.visible;$.scene.addObject(object);$.objects[v]=object}}}function p(Da){return function(ga){$.geometries[Da]=ga;n();Ca-=1;o()}}function o(){f({total_models:Ha,total_textures:qa,loaded_models:Ha-Ca,loaded_textures:qa-Aa},$);Ca==0&&Aa==0&&c($)}var u,y,v,B,C,F,H,U,z,J,L,M,Fa,oa,xa,Z,e,da,Ca,Aa,Ha,qa,$;Z=j.data;e=new THREE.BinaryLoader;da=new THREE.JSONLoader;Aa=Ca=0;$={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};j=function(){Aa-=
-1;o()};for(C in Z.cameras){J=Z.cameras[C];if(J.type=="perspective")Fa=new THREE.Camera(J.fov,J.aspect,J.near,J.far);else if(J.type=="ortho"){Fa=new THREE.Camera;Fa.projectionMatrix=THREE.Matrix4.makeOrtho(J.left,J.right,J.top,J.bottom,J.near,J.far)}z=J.position;J=J.target;Fa.position.set(z[0],z[1],z[2]);Fa.target.position.set(J[0],J[1],J[2]);$.cameras[C]=Fa}for(B in Z.lights){C=Z.lights[B];Fa=C.color!==undefined?C.color:16777215;J=C.intensity!==undefined?C.intensity:1;if(C.type=="directional"){z=
-C.direction;light=new THREE.DirectionalLight(Fa,J);light.position.set(z[0],z[1],z[2]);light.position.normalize()}else if(C.type=="point"){z=C.position;light=new THREE.PointLight(Fa,J);light.position.set(z[0],z[1],z[2])}$.scene.addLight(light);$.lights[B]=light}for(F in Z.fogs){B=Z.fogs[F];if(B.type=="linear")oa=new THREE.Fog(0,B.near,B.far);else B.type=="exp2"&&(oa=new THREE.FogExp2(0,B.density));J=B.color;oa.color.setRGB(J[0],J[1],J[2]);$.fogs[F]=oa}if($.cameras&&Z.defaults.camera)$.currentCamera=
-$.cameras[Z.defaults.camera];if($.fogs&&Z.defaults.fog)$.scene.fog=$.fogs[Z.defaults.fog];J=Z.defaults.bgcolor;$.bgColor=new THREE.Color;$.bgColor.setRGB(J[0],J[1],J[2]);$.bgColorAlpha=Z.defaults.bgalpha;for(u in Z.geometries){F=Z.geometries[u];if(F.type=="bin_mesh"||F.type=="ascii_mesh")Ca+=1}Ha=Ca;for(u in Z.geometries){F=Z.geometries[u];if(F.type=="cube"){M=new Cube(F.width,F.height,F.depth,F.segmentsWidth,F.segmentsHeight,F.segmentsDepth,null,F.flipped,F.sides);$.geometries[u]=M}else if(F.type==
-"plane"){M=new Plane(F.width,F.height,F.segmentsWidth,F.segmentsHeight);$.geometries[u]=M}else if(F.type=="sphere"){M=new Sphere(F.radius,F.segmentsWidth,F.segmentsHeight);$.geometries[u]=M}else if(F.type=="cylinder"){M=new Cylinder(F.numSegs,F.topRad,F.botRad,F.height,F.topOffset,F.botOffset);$.geometries[u]=M}else if(F.type=="torus"){M=new Torus(F.radius,F.tube,F.segmentsR,F.segmentsT);$.geometries[u]=M}else if(F.type=="icosahedron"){M=new Icosahedron(F.subdivisions);$.geometries[u]=M}else if(F.type==
-"bin_mesh")e.load({model:k(F.url,Z.urlBaseType),callback:p(u)});else F.type=="ascii_mesh"&&da.load({model:k(F.url,Z.urlBaseType),callback:p(u)})}for(H in Z.textures){u=Z.textures[H];Aa+=u.url instanceof Array?u.url.length:1}qa=Aa;for(H in Z.textures){u=Z.textures[H];if(u.mapping!=undefined&&THREE[u.mapping]!=undefined)u.mapping=new THREE[u.mapping];if(u.url instanceof Array){F=[];for(var pa=0;pa<u.url.length;pa++)F[pa]=k(u.url[pa],Z.urlBaseType);F=ImageUtils.loadTextureCube(F,u.mapping,j)}else{F=
-ImageUtils.loadTexture(k(u.url,Z.urlBaseType),u.mapping,j);if(THREE[u.minFilter]!=undefined)F.minFilter=THREE[u.minFilter];if(THREE[u.magFilter]!=undefined)F.magFilter=THREE[u.magFilter]}$.textures[H]=F}for(y in Z.materials){H=Z.materials[y];for(L in H.parameters)if(L=="envMap"||L=="map"||L=="lightMap")H.parameters[L]=$.textures[H.parameters[L]];else if(L=="shading")H.parameters[L]=H.parameters[L]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(L=="blending")H.parameters[L]=THREE[H.parameters[L]]?
-THREE[H.parameters[L]]:THREE.NormalBlending;else L=="combine"&&(H.parameters[L]=H.parameters[L]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);H=new THREE[H.type](H.parameters);$.materials[y]=H}n();d($)}},addMesh:function(b,d,c,f,g,h,j,k,n,p){d=new THREE.Mesh(d,p);d.scale.x=d.scale.y=d.scale.z=c;d.position.x=f;d.position.y=g;d.position.z=h;d.rotation.x=j;d.rotation.y=k;d.rotation.z=n;b.addObject(d);return d},addPanoramaCubeWebGL:function(b,d,c){var f=ShaderUtils.lib.cube;f.uniforms.tCube.texture=
+var GeometryUtils={merge:function(b,d){var c=d instanceof THREE.Mesh,f=b.vertices.length,g=c?d.geometry:d,h=b.vertices,j=g.vertices,k=b.faces,n=g.faces,p=b.faceVertexUvs[0];g=g.faceVertexUvs[0];c&&d.matrixAutoUpdate&&d.updateMatrix();for(var o=0,u=j.length;o<u;o++){var y=new THREE.Vertex(j[o].position.clone());c&&d.matrix.multiplyVector3(y.position);h.push(y)}o=0;for(u=n.length;o<u;o++){j=n[o];var w,A,E=j.vertexNormals;y=j.vertexColors;if(j instanceof THREE.Face3)w=new THREE.Face3(j.a+f,j.b+f,j.c+
+f);else j instanceof THREE.Face4&&(w=new THREE.Face4(j.a+f,j.b+f,j.c+f,j.d+f));w.normal.copy(j.normal);c=0;for(h=E.length;c<h;c++){A=E[c];w.vertexNormals.push(A.clone())}w.color.copy(j.color);c=0;for(h=y.length;c<h;c++){A=y[c];w.vertexColors.push(A.clone())}w.materials=j.materials.slice();w.centroid.copy(j.centroid);k.push(w)}o=0;for(u=g.length;o<u;o++){f=g[o];k=[];c=0;for(h=f.length;c<h;c++)k.push(new THREE.UV(f[c].u,f[c].v));p.push(k)}}},ImageUtils={loadTexture:function(b,d,c){var f=new Image,g=
+new THREE.Texture(f,d);f.onload=function(){g.needsUpdate=!0;c&&c(this)};f.src=b;return g},loadTextureCube:function(b,d,c){var f,g=[],h=new THREE.Texture(g,d);d=g.loadCount=0;for(f=b.length;d<f;++d){g[d]=new Image;g[d].onload=function(){g.loadCount+=1;if(g.loadCount==6)h.needsUpdate=!0;c&&c(this)};g[d].src=b[d]}return h}},SceneUtils={loadScene:function(b,d,c,f){var g=new Worker(b);g.postMessage(0);var h=THREE.Loader.prototype.extractUrlbase(b);g.onmessage=function(j){function k(za,ia){return ia=="relativeToHTML"?
+za:h+"/"+za}function n(){for(w in e.objects)if(!aa.objects[w]){V=e.objects[w];if(S=aa.geometries[V.geometry]){qa=[];for(pa=0;pa<V.materials.length;pa++)qa[pa]=aa.materials[V.materials[pa]];z=V.position;r=V.rotation;q=V.quaternion;s=V.scale;q=0;qa.length==0&&(qa[0]=new THREE.MeshFaceMaterial);object=new THREE.Mesh(S,qa);object.position.set(z[0],z[1],z[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);
+object.visible=V.visible;aa.scene.addObject(object);aa.objects[w]=object}}}function p(za){return function(ia){aa.geometries[za]=ia;n();ya-=1;o()}}function o(){f({total_models:Ga,total_textures:ra,loaded_models:Ga-ya,loaded_textures:ra-Fa},aa);ya==0&&Fa==0&&c(aa)}var u,y,w,A,E,G,L,V,z,N,Q,S,xa,sa,qa,e,fa,da,ya,Fa,Ga,ra,aa;e=j.data;fa=new THREE.BinaryLoader;da=new THREE.JSONLoader;Fa=ya=0;aa={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};j=function(){Fa-=
+1;o()};for(E in e.cameras){N=e.cameras[E];if(N.type=="perspective")xa=new THREE.Camera(N.fov,N.aspect,N.near,N.far);else if(N.type=="ortho"){xa=new THREE.Camera;xa.projectionMatrix=THREE.Matrix4.makeOrtho(N.left,N.right,N.top,N.bottom,N.near,N.far)}z=N.position;N=N.target;xa.position.set(z[0],z[1],z[2]);xa.target.position.set(N[0],N[1],N[2]);aa.cameras[E]=xa}for(A in e.lights){E=e.lights[A];xa=E.color!==undefined?E.color:16777215;N=E.intensity!==undefined?E.intensity:1;if(E.type=="directional"){z=
+E.direction;light=new THREE.DirectionalLight(xa,N);light.position.set(z[0],z[1],z[2]);light.position.normalize()}else if(E.type=="point"){z=E.position;light=new THREE.PointLight(xa,N);light.position.set(z[0],z[1],z[2])}aa.scene.addLight(light);aa.lights[A]=light}for(G in e.fogs){A=e.fogs[G];if(A.type=="linear")sa=new THREE.Fog(0,A.near,A.far);else A.type=="exp2"&&(sa=new THREE.FogExp2(0,A.density));N=A.color;sa.color.setRGB(N[0],N[1],N[2]);aa.fogs[G]=sa}if(aa.cameras&&e.defaults.camera)aa.currentCamera=
+aa.cameras[e.defaults.camera];if(aa.fogs&&e.defaults.fog)aa.scene.fog=aa.fogs[e.defaults.fog];N=e.defaults.bgcolor;aa.bgColor=new THREE.Color;aa.bgColor.setRGB(N[0],N[1],N[2]);aa.bgColorAlpha=e.defaults.bgalpha;for(u in e.geometries){G=e.geometries[u];if(G.type=="bin_mesh"||G.type=="ascii_mesh")ya+=1}Ga=ya;for(u in e.geometries){G=e.geometries[u];if(G.type=="cube"){S=new Cube(G.width,G.height,G.depth,G.segmentsWidth,G.segmentsHeight,G.segmentsDepth,null,G.flipped,G.sides);aa.geometries[u]=S}else if(G.type==
+"plane"){S=new Plane(G.width,G.height,G.segmentsWidth,G.segmentsHeight);aa.geometries[u]=S}else if(G.type=="sphere"){S=new Sphere(G.radius,G.segmentsWidth,G.segmentsHeight);aa.geometries[u]=S}else if(G.type=="cylinder"){S=new Cylinder(G.numSegs,G.topRad,G.botRad,G.height,G.topOffset,G.botOffset);aa.geometries[u]=S}else if(G.type=="torus"){S=new Torus(G.radius,G.tube,G.segmentsR,G.segmentsT);aa.geometries[u]=S}else if(G.type=="icosahedron"){S=new Icosahedron(G.subdivisions);aa.geometries[u]=S}else if(G.type==
+"bin_mesh")fa.load({model:k(G.url,e.urlBaseType),callback:p(u)});else G.type=="ascii_mesh"&&da.load({model:k(G.url,e.urlBaseType),callback:p(u)})}for(L in e.textures){u=e.textures[L];Fa+=u.url instanceof Array?u.url.length:1}ra=Fa;for(L in e.textures){u=e.textures[L];if(u.mapping!=undefined&&THREE[u.mapping]!=undefined)u.mapping=new THREE[u.mapping];if(u.url instanceof Array){G=[];for(var pa=0;pa<u.url.length;pa++)G[pa]=k(u.url[pa],e.urlBaseType);G=ImageUtils.loadTextureCube(G,u.mapping,j)}else{G=
+ImageUtils.loadTexture(k(u.url,e.urlBaseType),u.mapping,j);if(THREE[u.minFilter]!=undefined)G.minFilter=THREE[u.minFilter];if(THREE[u.magFilter]!=undefined)G.magFilter=THREE[u.magFilter]}aa.textures[L]=G}for(y in e.materials){L=e.materials[y];for(Q in L.parameters)if(Q=="envMap"||Q=="map"||Q=="lightMap")L.parameters[Q]=aa.textures[L.parameters[Q]];else if(Q=="shading")L.parameters[Q]=L.parameters[Q]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(Q=="blending")L.parameters[Q]=THREE[L.parameters[Q]]?
+THREE[L.parameters[Q]]:THREE.NormalBlending;else Q=="combine"&&(L.parameters[Q]=L.parameters[Q]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation);L=new THREE[L.type](L.parameters);aa.materials[y]=L}n();d(aa)}},addMesh:function(b,d,c,f,g,h,j,k,n,p){d=new THREE.Mesh(d,p);d.scale.x=d.scale.y=d.scale.z=c;d.position.x=f;d.position.y=g;d.position.z=h;d.rotation.x=j;d.rotation.y=k;d.rotation.z=n;b.addObject(d);return d},addPanoramaCubeWebGL:function(b,d,c){var f=ShaderUtils.lib.cube;f.uniforms.tCube.texture=
 c;c=new THREE.MeshShaderMaterial({fragmentShader:f.fragmentShader,vertexShader:f.vertexShader,uniforms:f.uniforms});d=new THREE.Mesh(new Cube(d,d,d,1,1,1,null,!0),c);b.addObject(d);return d},addPanoramaCube:function(b,d,c){var f=[];f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}));f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[4])}));
 f.push(new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));d=new THREE.Mesh(new Cube(d,d,d,1,1,f,!0),new THREE.MeshFaceMaterial);b.addObject(d);return d},addPanoramaCubePlanes:function(b,d,c){var f=d/2;d=new Plane(d,d);var g=Math.PI,h=Math.PI/2;SceneUtils.addMesh(b,d,1,0,0,-f,0,0,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[5])}));SceneUtils.addMesh(b,d,1,-f,0,0,0,h,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[0])}));SceneUtils.addMesh(b,d,1,f,0,0,0,-h,0,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[1])}));
 SceneUtils.addMesh(b,d,1,0,f,0,h,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[2])}));SceneUtils.addMesh(b,d,1,0,-f,0,-h,0,g,new THREE.MeshBasicMaterial({map:new THREE.Texture(c[3])}))},showHierarchy:function(b,d){SceneUtils.traverseHierarchy(b,function(c){c.visible=d})},traverseHierarchy:function(b,d){var c,f,g=b.children.length;for(f=0;f<g;f++){c=b.children[f];d(c);SceneUtils.traverseHierarchy(c,d)}}},ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",
@@ -355,42 +358,43 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195
 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(b){var d,c,f,g,h=2*Math.ceil(b*3)+1;h>25&&(h=25);g=(h-1)*0.5;c=Array(h);for(d=f=0;d<h;++d){c[d]=Math.exp(-((d-g)*(d-g))/(2*b*b));f+=c[d]}for(d=0;d<h;++d)c[d]/=f;return c}};
-THREE.QuakeCamera=function(b){function d(c,f){return function(){f.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.lookSpeed!==undefined)this.lookSpeed=b.lookSpeed;if(b.noFly!==undefined)this.noFly=
-b.noFly;if(b.lookVertical!==undefined)this.lookVertical=b.lookVertical;if(b.autoForward!==undefined)this.autoForward=b.autoForward;if(b.activeLook!==undefined)this.activeLook=b.activeLook;if(b.heightSpeed!==undefined)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==undefined)this.heightCoef=b.heightCoef;if(b.heightMin!==undefined)this.heightMin=b.heightMin;if(b.heightMax!==undefined)this.heightMax=b.heightMax;if(b.domElement!==undefined)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=
-this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.freeze=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(c){c.preventDefault();c.stopPropagation();if(this.activeLook)switch(c.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(c){c.preventDefault();c.stopPropagation();if(this.activeLook)switch(c.button){case 0:this.moveForward=
-!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(c){this.mouseX=c.clientX-this.windowHalfX;this.mouseY=c.clientY-this.windowHalfY};this.onKeyDown=function(c){switch(c.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(c){switch(c.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=
-!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);
-this.moveRight&&this.translateX(this.movementSpeed);var c=this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;c=this.target.position;var f=this.position;c.x=f.x+100*Math.sin(this.phi)*Math.cos(this.theta);c.y=f.y+100*Math.cos(this.phi);c.z=f.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",
-function(c){c.preventDefault()},!1);this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",d(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",d(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",d(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",d(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;
-THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;THREE.QuakeCamera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);if(this.noFly)d.y=0;this.position.addSelf(d.multiplyScalar(b));this.target.position.addSelf(d.multiplyScalar(b))};
-THREE.PathCamera=function(b){function d(p,o,u,y){var v={name:u,fps:0.6,length:y,hierarchy:[]},B,C=o.getControlPointsArray(),F=o.getLength(),H=C.length,U=0;B=H-1;o={parent:-1,keys:[]};o.keys[0]={time:0,pos:C[0],rot:[0,0,0,1],scl:[1,1,1]};o.keys[B]={time:y,pos:C[B],rot:[0,0,0,1],scl:[1,1,1]};for(B=1;B<H-1;B++){U=y*F.chunks[B]/F.total;o.keys[B]={time:U,pos:C[B]}}v.hierarchy[0]=o;THREE.AnimationHandler.add(v);return new THREE.Animation(p,u,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function c(p,o){var u,
-y,v=new THREE.Geometry;for(u=0;u<p.points.length*o;u++){y=u/(p.points.length*o);y=p.getPoint(y);v.vertices[u]=new THREE.Vertex(new THREE.Vector3(y.x,y.y,y.z))}return v}function f(p,o){var u=c(o,10),y=c(o,10),v=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(u,v);particleObj=new THREE.ParticleSystem(y,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);p.addChild(lineObj);particleObj.scale.set(1,1,1);p.addChild(particleObj);y=new Sphere(1,
-16,8);v=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<o.points.length;i++){u=new THREE.Mesh(y,v);u.position.copy(o.points[i]);u.updateMatrix();p.addChild(u)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
+THREE.QuakeCamera=function(b){function d(c,f){return function(){f.apply(c,arguments)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;if(b){if(b.movementSpeed!==undefined)this.movementSpeed=b.movementSpeed;if(b.lookSpeed!==undefined)this.lookSpeed=
+b.lookSpeed;if(b.noFly!==undefined)this.noFly=b.noFly;if(b.lookVertical!==undefined)this.lookVertical=b.lookVertical;if(b.autoForward!==undefined)this.autoForward=b.autoForward;if(b.activeLook!==undefined)this.activeLook=b.activeLook;if(b.heightSpeed!==undefined)this.heightSpeed=b.heightSpeed;if(b.heightCoef!==undefined)this.heightCoef=b.heightCoef;if(b.heightMin!==undefined)this.heightMin=b.heightMin;if(b.heightMax!==undefined)this.heightMax=b.heightMax;if(b.constrainVertical!==undefined)this.constrainVertical=
+b.constrainVertical;if(b.verticalMin!==undefined)this.verticalMin=b.verticalMin;if(b.verticalMax!==undefined)this.verticalMax=b.verticalMax;if(b.domElement!==undefined)this.domElement=b.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.freeze=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(c){c.preventDefault();
+c.stopPropagation();if(this.activeLook)switch(c.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(c){c.preventDefault();c.stopPropagation();if(this.activeLook)switch(c.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(c){this.mouseX=c.clientX-this.windowHalfX;this.mouseY=c.clientY-this.windowHalfY};this.onKeyDown=function(c){switch(c.keyCode){case 38:case 87:this.moveForward=
+!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(c){switch(c.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){if(!this.freeze){this.autoSpeedFactor=this.heightSpeed?((this.position.y<this.heightMin?this.heightMin:this.position.y>
+this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed);var c=this.lookSpeed;this.activeLook||(c=0);this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=
+(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var f=this.target.position,g=this.position;f.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);f.y=g.y+100*Math.cos(this.phi);f.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta)}this.lon+=this.mouseX*c;this.lookVertical&&(this.lat-=this.mouseY*c);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/
+3.14+this.verticalMin;f=this.target.position;g=this.position;f.x=g.x+100*Math.sin(this.phi)*Math.cos(this.theta);f.y=g.y+100*Math.cos(this.phi);f.z=g.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(c){c.preventDefault()},!1);this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",d(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",d(this,
+this.onMouseUp),!1);this.domElement.addEventListener("keydown",d(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",d(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;THREE.QuakeCamera.prototype.translate=function(b,d){this.matrix.rotateAxis(d);if(this.noFly)d.y=0;this.position.addSelf(d.multiplyScalar(b));this.target.position.addSelf(d.multiplyScalar(b))};
+THREE.PathCamera=function(b){function d(p,o,u,y){var w={name:u,fps:0.6,length:y,hierarchy:[]},A,E=o.getControlPointsArray(),G=o.getLength(),L=E.length,V=0;A=L-1;o={parent:-1,keys:[]};o.keys[0]={time:0,pos:E[0],rot:[0,0,0,1],scl:[1,1,1]};o.keys[A]={time:y,pos:E[A],rot:[0,0,0,1],scl:[1,1,1]};for(A=1;A<L-1;A++){V=y*G.chunks[A]/G.total;o.keys[A]={time:V,pos:E[A]}}w.hierarchy[0]=o;THREE.AnimationHandler.add(w);return new THREE.Animation(p,u,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function c(p,o){var u,
+y,w=new THREE.Geometry;for(u=0;u<p.points.length*o;u++){y=u/(p.points.length*o);y=p.getPoint(y);w.vertices[u]=new THREE.Vertex(new THREE.Vector3(y.x,y.y,y.z))}return w}function f(p,o){var u=c(o,10),y=c(o,10),w=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(u,w);particleObj=new THREE.ParticleSystem(y,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);p.addChild(lineObj);particleObj.scale.set(1,1,1);p.addChild(particleObj);y=new Sphere(1,
+16,8);w=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<o.points.length;i++){u=new THREE.Mesh(y,w);u.position.copy(o.points[i]);u.updateMatrix();p.addChild(u)}}THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
 !0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(b){if(b.duration!==undefined)this.duration=b.duration*1E3;if(b.waypoints!==undefined)this.waypoints=b.waypoints;if(b.useConstantSpeed!==undefined)this.useConstantSpeed=b.useConstantSpeed;if(b.resamplingCoef!==undefined)this.resamplingCoef=b.resamplingCoef;if(b.createDebugPath!==undefined)this.createDebugPath=b.createDebugPath;
 if(b.createDebugDummy!==undefined)this.createDebugDummy=b.createDebugDummy;if(b.lookSpeed!==undefined)this.lookSpeed=b.lookSpeed;if(b.lookVertical!==undefined)this.lookVertical=b.lookVertical;if(b.lookHorizontal!==undefined)this.lookHorizontal=b.lookHorizontal;if(b.verticalAngleMap!==undefined)this.verticalAngleMap=b.verticalAngleMap;if(b.horizontalAngleMap!==undefined)this.horizontalAngleMap=b.horizontalAngleMap;if(b.domElement!==undefined)this.domElement=b.domElement}this.theta=this.phi=this.lon=
-this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,h=Math.PI/180;this.update=function(p,o,u){var y,v;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;y=this.phi%g;this.phi=y>=0?y:y+g;y=this.verticalAngleMap.srcRange;v=this.verticalAngleMap.dstRange;
-this.phi=(this.phi-y[0])*(v[1]-v[0])/(y[1]-y[0])+v[0];y=this.horizontalAngleMap.srcRange;v=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(v[1]-v[0])/(y[1]-y[0])+v[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,p,o,u)};this.onMouseMove=function(p){this.mouseX=p.clientX-this.windowHalfX;this.mouseY=p.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
+this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var g=Math.PI*2,h=Math.PI/180;this.update=function(p,o,u){var y,w;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;y=this.phi%g;this.phi=y>=0?y:y+g;y=this.verticalAngleMap.srcRange;w=this.verticalAngleMap.dstRange;
+this.phi=(this.phi-y[0])*(w[1]-w[0])/(y[1]-y[0])+w[0];y=this.horizontalAngleMap.srcRange;w=this.horizontalAngleMap.dstRange;this.theta=(this.theta-y[0])*(w[1]-w[0])/(y[1]-y[0])+w[0];y=this.target.position;y.x=100*Math.sin(this.phi)*Math.cos(this.theta);y.y=100*Math.cos(this.phi);y.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this,p,o,u)};this.onMouseMove=function(p){this.mouseX=p.clientX-this.windowHalfX;this.mouseY=p.clientY-this.windowHalfY};this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);
 this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){b=new THREE.MeshLambertMaterial({color:30719});var j=new THREE.MeshLambertMaterial({color:65280}),k=new Cube(10,10,20),n=new Cube(2,2,10);this.animationParent=new THREE.Mesh(k,b);b=new THREE.Mesh(n,j);b.position.set(0,10,0);this.animation=d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(b)}else{this.animation=
 d(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&f(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(p,o){return function(){o.apply(p,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
-var Cube=function(b,d,c,f,g,h,j,k,n){function p(F,H,U,z,J,L,M,Fa){var oa,xa,Z=f||1,e=g||1,da=J/2,Ca=L/2,Aa=o.vertices.length;if(F=="x"&&H=="y"||F=="y"&&H=="x")oa="z";else if(F=="x"&&H=="z"||F=="z"&&H=="x"){oa="y";e=h||1}else if(F=="z"&&H=="y"||F=="y"&&H=="z"){oa="x";Z=h||1}var Ha=Z+1,qa=e+1;J/=Z;var $=L/e;for(xa=0;xa<qa;xa++)for(L=0;L<Ha;L++){var pa=new THREE.Vector3;pa[F]=(L*J-da)*U;pa[H]=(xa*$-Ca)*z;pa[oa]=M;o.vertices.push(new THREE.Vertex(pa))}for(xa=0;xa<e;xa++)for(L=0;L<Z;L++){o.faces.push(new THREE.Face4(L+
-Ha*xa+Aa,L+Ha*(xa+1)+Aa,L+1+Ha*(xa+1)+Aa,L+1+Ha*xa+Aa,null,null,Fa));o.faceVertexUvs[0].push([new THREE.UV(L/Z,xa/e),new THREE.UV(L/Z,(xa+1)/e),new THREE.UV((L+1)/Z,(xa+1)/e),new THREE.UV((L+1)/Z,xa/e)])}}THREE.Geometry.call(this);var o=this,u=b/2,y=d/2,v=c/2;k=k?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var B=0;B<6;B++)this.materials.push([j])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(n!=undefined)for(var C in n)this.sides[C]!=
-undefined&&(this.sides[C]=n[C]);this.sides.px&&p("z","y",1*k,-1,c,d,-u,this.materials[0]);this.sides.nx&&p("z","y",-1*k,-1,c,d,u,this.materials[1]);this.sides.py&&p("x","z",1*k,1,b,c,y,this.materials[2]);this.sides.ny&&p("x","z",1*k,-1,b,c,-y,this.materials[3]);this.sides.pz&&p("x","y",1*k,-1,b,d,v,this.materials[4]);this.sides.nz&&p("x","y",-1*k,-1,b,d,-v,this.materials[5]);(function(){for(var F=[],H=[],U=0,z=o.vertices.length;U<z;U++){for(var J=o.vertices[U],L=!1,M=0,Fa=F.length;M<Fa;M++){var oa=
-F[M];if(J.position.x==oa.position.x&&J.position.y==oa.position.y&&J.position.z==oa.position.z){H[U]=M;L=!0;break}}if(!L){H[U]=F.length;F.push(new THREE.Vertex(J.position.clone()))}}U=0;for(z=o.faces.length;U<z;U++){J=o.faces[U];J.a=H[J.a];J.b=H[J.b];J.c=H[J.c];J.d=H[J.d]}o.vertices=F})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
+var Cube=function(b,d,c,f,g,h,j,k,n){function p(G,L,V,z,N,Q,S,xa){var sa,qa,e=f||1,fa=g||1,da=N/2,ya=Q/2,Fa=o.vertices.length;if(G=="x"&&L=="y"||G=="y"&&L=="x")sa="z";else if(G=="x"&&L=="z"||G=="z"&&L=="x"){sa="y";fa=h||1}else if(G=="z"&&L=="y"||G=="y"&&L=="z"){sa="x";e=h||1}var Ga=e+1,ra=fa+1;N/=e;var aa=Q/fa;for(qa=0;qa<ra;qa++)for(Q=0;Q<Ga;Q++){var pa=new THREE.Vector3;pa[G]=(Q*N-da)*V;pa[L]=(qa*aa-ya)*z;pa[sa]=S;o.vertices.push(new THREE.Vertex(pa))}for(qa=0;qa<fa;qa++)for(Q=0;Q<e;Q++){o.faces.push(new THREE.Face4(Q+
+Ga*qa+Fa,Q+Ga*(qa+1)+Fa,Q+1+Ga*(qa+1)+Fa,Q+1+Ga*qa+Fa,null,null,xa));o.faceVertexUvs[0].push([new THREE.UV(Q/e,qa/fa),new THREE.UV(Q/e,(qa+1)/fa),new THREE.UV((Q+1)/e,(qa+1)/fa),new THREE.UV((Q+1)/e,qa/fa)])}}THREE.Geometry.call(this);var o=this,u=b/2,y=d/2,w=c/2;k=k?-1:1;if(j!==undefined)if(j instanceof Array)this.materials=j;else{this.materials=[];for(var A=0;A<6;A++)this.materials.push([j])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(n!=undefined)for(var E in n)this.sides[E]!=
+undefined&&(this.sides[E]=n[E]);this.sides.px&&p("z","y",1*k,-1,c,d,-u,this.materials[0]);this.sides.nx&&p("z","y",-1*k,-1,c,d,u,this.materials[1]);this.sides.py&&p("x","z",1*k,1,b,c,y,this.materials[2]);this.sides.ny&&p("x","z",1*k,-1,b,c,-y,this.materials[3]);this.sides.pz&&p("x","y",1*k,-1,b,d,w,this.materials[4]);this.sides.nz&&p("x","y",-1*k,-1,b,d,-w,this.materials[5]);(function(){for(var G=[],L=[],V=0,z=o.vertices.length;V<z;V++){for(var N=o.vertices[V],Q=!1,S=0,xa=G.length;S<xa;S++){var sa=
+G[S];if(N.position.x==sa.position.x&&N.position.y==sa.position.y&&N.position.z==sa.position.z){L[V]=S;Q=!0;break}}if(!Q){L[V]=G.length;G.push(new THREE.Vertex(N.position.clone()))}}V=0;for(z=o.faces.length;V<z;V++){N=o.faces[V];N.a=L[N.a];N.b=L[N.b];N.c=L[N.c];N.d=L[N.d]}o.vertices=G})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
 var Cylinder=function(b,d,c,f,g,h){function j(o,u,y){k.vertices.push(new THREE.Vertex(new THREE.Vector3(o,u,y)))}THREE.Geometry.call(this);var k=this,n=Math.PI,p=f/2;for(f=0;f<b;f++)j(Math.sin(2*n*f/b)*d,Math.cos(2*n*f/b)*d,-p);for(f=0;f<b;f++)j(Math.sin(2*n*f/b)*c,Math.cos(2*n*f/b)*c,p);for(f=0;f<b;f++)k.faces.push(new THREE.Face4(f,f+b,b+(f+1)%b,(f+1)%b));if(c>0){j(0,0,-p-(h||0));for(f=b;f<b+b/2;f++)k.faces.push(new THREE.Face4(2*b,(2*f-2*b)%b,(2*f-2*b+1)%b,(2*f-2*b+2)%b))}if(d>0){j(0,0,p+(g||0));
 for(f=b+b/2;f<2*b;f++)k.faces.push(new THREE.Face4(2*b+1,(2*f-2*b+2)%b+b,(2*f-2*b+1)%b+b,(2*f-2*b)%b+b))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
-var Icosahedron=function(b){function d(u,y,v){var B=Math.sqrt(u*u+y*y+v*v);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(u/B,y/B,v/B)))-1}function c(u,y,v,B){B.faces.push(new THREE.Face3(u,y,v))}function f(u,y){var v=g.vertices[u].position,B=g.vertices[y].position;return d((v.x+B.x)/2,(v.y+B.y)/2,(v.z+B.z)/2)}var g=this,h=new THREE.Geometry,j;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;d(-1,b,0);d(1,b,0);d(-1,-b,0);d(1,-b,0);d(0,-1,b);d(0,1,b);d(0,-1,-b);d(0,
+var Icosahedron=function(b){function d(u,y,w){var A=Math.sqrt(u*u+y*y+w*w);return g.vertices.push(new THREE.Vertex(new THREE.Vector3(u/A,y/A,w/A)))-1}function c(u,y,w,A){A.faces.push(new THREE.Face3(u,y,w))}function f(u,y){var w=g.vertices[u].position,A=g.vertices[y].position;return d((w.x+A.x)/2,(w.y+A.y)/2,(w.z+A.z)/2)}var g=this,h=new THREE.Geometry,j;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;d(-1,b,0);d(1,b,0);d(-1,-b,0);d(1,-b,0);d(0,-1,b);d(0,1,b);d(0,-1,-b);d(0,
 1,-b);d(b,0,-1);d(b,0,1);d(-b,0,-1);d(-b,0,1);c(0,11,5,h);c(0,5,1,h);c(0,1,7,h);c(0,7,10,h);c(0,10,11,h);c(1,5,9,h);c(5,11,4,h);c(11,10,2,h);c(10,7,6,h);c(7,1,8,h);c(3,9,4,h);c(3,4,2,h);c(3,2,6,h);c(3,6,8,h);c(3,8,9,h);c(4,9,5,h);c(2,4,11,h);c(6,2,10,h);c(8,6,7,h);c(9,8,1,h);for(b=0;b<this.subdivisions;b++){j=new THREE.Geometry;for(var k in h.faces){var n=f(h.faces[k].a,h.faces[k].b),p=f(h.faces[k].b,h.faces[k].c),o=f(h.faces[k].c,h.faces[k].a);c(h.faces[k].a,n,o,j);c(h.faces[k].b,p,n,j);c(h.faces[k].c,
 o,p,j);c(n,p,o,j)}h.faces=j.faces}g.faces=h.faces;delete h;delete j;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
 function Lathe(b,d,c){THREE.Geometry.call(this);this.steps=d||12;this.angle=c||2*Math.PI;d=this.angle/this.steps;for(var f=[],g=[],h=[],j=[],k=0;k<b.length;k++){this.vertices.push(new THREE.Vertex(b[k]));f[k]=b[k].clone();g[k]=this.vertices.length-1}for(var n=(new THREE.Matrix4).setRotationZ(d),p=0;p<=this.angle+0.0010;p+=d){for(k=0;k<f.length;k++)if(p<this.angle){f[k]=n.multiplyVector3(f[k].clone());this.vertices.push(new THREE.Vertex(f[k]));h[k]=this.vertices.length-1}else h=j;p==0&&(j=g);for(k=
 0;k<g.length-1;k++){this.faces.push(new THREE.Face4(h[k],h[k+1],g[k+1],g[k]));this.faceVertexUvs[0].push([new THREE.UV(p/c,k/b.length),new THREE.UV(p/c,(k+1)/b.length),new THREE.UV((p-d)/c,(k+1)/b.length),new THREE.UV((p-d)/c,k/b.length)])}g=h;h=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
 var Plane=function(b,d,c,f){THREE.Geometry.call(this);var g,h=b/2,j=d/2;c=c||1;f=f||1;var k=c+1,n=f+1;b/=c;var p=d/f;for(g=0;g<n;g++)for(d=0;d<k;d++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(d*b-h,-(g*p-j),0)));for(g=0;g<f;g++)for(d=0;d<c;d++){this.faces.push(new THREE.Face4(d+k*g,d+k*(g+1),d+1+k*(g+1),d+1+k*g));this.faceVertexUvs[0].push([new THREE.UV(d/c,g/f),new THREE.UV(d/c,(g+1)/f),new THREE.UV((d+1)/c,(g+1)/f),new THREE.UV((d+1)/c,g/f)])}this.computeCentroids();this.computeFaceNormals()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(b,d,c){THREE.Geometry.call(this);var f,g=Math.PI,h=Math.max(3,d||8),j=Math.max(2,c||6);d=[];for(c=0;c<j+1;c++){f=c/j;var k=b*Math.cos(f*g),n=b*Math.sin(f*g),p=[],o=0;for(f=0;f<h;f++){var u=2*f/h,y=n*Math.sin(u*g);u=n*Math.cos(u*g);(c==0||c==j)&&f>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(u,k,y)))-1);p.push(o)}d.push(p)}var v,B,C;g=d.length;for(c=0;c<g;c++){h=d[c].length;if(c>0)for(f=0;f<h;f++){p=f==h-1;j=d[c][p?0:f+1];k=d[c][p?h-1:f];n=d[c-1][p?h-1:f];p=d[c-1][p?
-0:f+1];y=c/(g-1);v=(c-1)/(g-1);B=(f+1)/h;u=f/h;o=new THREE.UV(1-B,y);y=new THREE.UV(1-u,y);u=new THREE.UV(1-u,v);var F=new THREE.UV(1-B,v);if(c<d.length-1){v=this.vertices[j].position.clone();B=this.vertices[k].position.clone();C=this.vertices[n].position.clone();v.normalize();B.normalize();C.normalize();this.faces.push(new THREE.Face3(j,k,n,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(C.x,C.y,C.z)]));this.faceVertexUvs[0].push([o,y,u])}if(c>1){v=this.vertices[j].position.clone();
-B=this.vertices[n].position.clone();C=this.vertices[p].position.clone();v.normalize();B.normalize();C.normalize();this.faces.push(new THREE.Face3(j,n,p,[new THREE.Vector3(v.x,v.y,v.z),new THREE.Vector3(B.x,B.y,B.z),new THREE.Vector3(C.x,C.y,C.z)]));this.faceVertexUvs[0].push([o,u,F])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
+var Sphere=function(b,d,c){THREE.Geometry.call(this);var f,g=Math.PI,h=Math.max(3,d||8),j=Math.max(2,c||6);d=[];for(c=0;c<j+1;c++){f=c/j;var k=b*Math.cos(f*g),n=b*Math.sin(f*g),p=[],o=0;for(f=0;f<h;f++){var u=2*f/h,y=n*Math.sin(u*g);u=n*Math.cos(u*g);(c==0||c==j)&&f>0||(o=this.vertices.push(new THREE.Vertex(new THREE.Vector3(u,k,y)))-1);p.push(o)}d.push(p)}var w,A,E;g=d.length;for(c=0;c<g;c++){h=d[c].length;if(c>0)for(f=0;f<h;f++){p=f==h-1;j=d[c][p?0:f+1];k=d[c][p?h-1:f];n=d[c-1][p?h-1:f];p=d[c-1][p?
+0:f+1];y=c/(g-1);w=(c-1)/(g-1);A=(f+1)/h;u=f/h;o=new THREE.UV(1-A,y);y=new THREE.UV(1-u,y);u=new THREE.UV(1-u,w);var G=new THREE.UV(1-A,w);if(c<d.length-1){w=this.vertices[j].position.clone();A=this.vertices[k].position.clone();E=this.vertices[n].position.clone();w.normalize();A.normalize();E.normalize();this.faces.push(new THREE.Face3(j,k,n,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(E.x,E.y,E.z)]));this.faceVertexUvs[0].push([o,y,u])}if(c>1){w=this.vertices[j].position.clone();
+A=this.vertices[n].position.clone();E=this.vertices[p].position.clone();w.normalize();A.normalize();E.normalize();this.faces.push(new THREE.Face3(j,n,p,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(A.x,A.y,A.z),new THREE.Vector3(E.x,E.y,E.z)]));this.faceVertexUvs[0].push([o,u,G])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 var Torus=function(b,d,c,f){this.radius=b||100;this.tube=d||40;this.segmentsR=c||8;this.segmentsT=f||6;b=[];THREE.Geometry.call(this);for(d=0;d<=this.segmentsR;++d)for(c=0;c<=this.segmentsT;++c){f=c/this.segmentsT*2*Math.PI;var g=d/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(g))*Math.cos(f),(this.radius+this.tube*Math.cos(g))*Math.sin(f),this.tube*Math.sin(g))));b.push([c/this.segmentsT,1-d/this.segmentsR])}for(d=1;d<=this.segmentsR;++d)for(c=
 1;c<=this.segmentsT;++c){f=(this.segmentsT+1)*d+c;g=(this.segmentsT+1)*d+c-1;var h=(this.segmentsT+1)*(d-1)+c-1,j=(this.segmentsT+1)*(d-1)+c;this.faces.push(new THREE.Face4(f,g,h,j));this.faceVertexUvs[0].push([new THREE.UV(b[f][0],b[f][1]),new THREE.UV(b[g][0],b[g][1]),new THREE.UV(b[h][0],b[h][1]),new THREE.UV(b[j][0],b[j][1])])}delete b;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
-var TorusKnot=function(b,d,c,f,g,h,j){function k(u,y,v,B,C,F){y=v/B*u;v=Math.cos(y);return new THREE.Vector3(C*(2+v)*0.5*Math.cos(u),C*(2+v)*Math.sin(u)*0.5,F*C*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=d||40;this.segmentsR=c||64;this.segmentsT=f||8;this.p=g||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;f=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(d=0;d<this.segmentsT;++d){var n=
+var TorusKnot=function(b,d,c,f,g,h,j){function k(u,y,w,A,E,G){y=w/A*u;w=Math.cos(y);return new THREE.Vector3(E*(2+w)*0.5*Math.cos(u),E*(2+w)*Math.sin(u)*0.5,G*E*Math.sin(y)*0.5)}THREE.Geometry.call(this);this.radius=b||200;this.tube=d||40;this.segmentsR=c||64;this.segmentsT=f||8;this.p=g||2;this.q=h||3;this.heightScale=j||1;this.grid=Array(this.segmentsR);c=new THREE.Vector3;f=new THREE.Vector3;h=new THREE.Vector3;for(b=0;b<this.segmentsR;++b){this.grid[b]=Array(this.segmentsT);for(d=0;d<this.segmentsT;++d){var n=
 b/this.segmentsR*2*this.p*Math.PI;j=d/this.segmentsT*2*Math.PI;g=k(n,j,this.q,this.p,this.radius,this.heightScale);n=k(n+0.01,j,this.q,this.p,this.radius,this.heightScale);c.x=n.x-g.x;c.y=n.y-g.y;c.z=n.z-g.z;f.x=n.x+g.x;f.y=n.y+g.y;f.z=n.z+g.z;h.cross(c,f);f.cross(h,c);h.normalize();f.normalize();n=this.tube*Math.cos(j);j=this.tube*Math.sin(j);g.x+=n*f.x+j*h.x;g.y+=n*f.y+j*h.y;g.z+=n*f.z+j*h.z;this.grid[b][d]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(g.x,g.y,g.z)))-1}}for(b=0;b<this.segmentsR;++b)for(d=
 0;d<this.segmentsT;++d){h=(b+1)%this.segmentsR;j=(d+1)%this.segmentsT;g=this.grid[b][d];c=this.grid[h][d];f=this.grid[b][j];h=this.grid[h][j];j=new THREE.UV(b/this.segmentsR,d/this.segmentsT);n=new THREE.UV((b+1)/this.segmentsR,d/this.segmentsT);var p=new THREE.UV(b/this.segmentsR,(d+1)/this.segmentsT),o=new THREE.UV((b+1)/this.segmentsR,(d+1)/this.segmentsT);this.faces.push(new THREE.Face3(g,c,f));this.faceVertexUvs[0].push([j,n,p]);this.faces.push(new THREE.Face3(h,f,c));this.faceVertexUvs[0].push([o,
 p,n])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;THREE.Loader=function(b){this.statusDomElement=(this.showStatus=b)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
@@ -400,38 +404,38 @@ Math.LN2));k.image.width=o;k.image.height=u;k.image.getContext("2d").drawImage(t
 THREE.SubtractiveBlending;else if(b.blending=="Multiply")h.blending=THREE.MultiplyBlending;if(b.transparent!==undefined)h.transparent=b.transparent;if(b.depthTest!==undefined)h.depthTest=b.depthTest;if(b.mapDiffuse&&d){j=document.createElement("canvas");h.map=new THREE.Texture(j);h.map.sourceFile=b.mapDiffuse;f(h.map,d+"/"+b.mapDiffuse)}else if(b.colorDiffuse){j=(b.colorDiffuse[0]*255<<16)+(b.colorDiffuse[1]*255<<8)+b.colorDiffuse[2]*255;h.color=j;h.opacity=b.transparency}else if(b.DbgColor)h.color=
 b.DbgColor;if(b.mapLightmap&&d){j=document.createElement("canvas");h.lightMap=new THREE.Texture(j);h.lightMap.sourceFile=b.mapLightmap;f(h.lightMap,d+"/"+b.mapLightmap)}return new THREE[g](h)}};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
 THREE.JSONLoader.prototype.load=function(b){var d=this,c=b.model,f=b.callback,g=b.texture_path?b.texture_path:this.extractUrlbase(c);b=new Worker(c);b.onmessage=function(h){d.createModel(h.data,f,g);d.onLoadComplete()};this.onLoadStart();b.postMessage((new Date).getTime())};
-THREE.JSONLoader.prototype.createModel=function(b,d,c){var f=new THREE.Geometry;this.init_materials(f,b.materials,c);(function(){if(b.version===undefined||b.version!=2)console.error("Deprecated file format.");else{var g,h,j,k,n,p,o,u,y,v,B,C,F,H,U,z=b.faces;p=b.vertices;var J=b.normals,L=b.colors,M=0;for(g=0;g<b.uvs.length;g++)b.uvs[g].length&&M++;for(g=0;g<M;g++){f.faceUvs[g]=[];f.faceVertexUvs[g]=[]}k=0;for(n=p.length;k<n;){o=new THREE.Vertex;o.position.x=p[k++];o.position.y=p[k++];o.position.z=
-p[k++];f.vertices.push(o)}k=0;for(n=z.length;k<n;){v=z[k++];p=v&1;j=v&2;g=v&4;h=v&8;u=v&16;o=v&32;B=v&64;v&=128;if(p){C=new THREE.Face4;C.a=z[k++];C.b=z[k++];C.c=z[k++];C.d=z[k++];p=4}else{C=new THREE.Face3;C.a=z[k++];C.b=z[k++];C.c=z[k++];p=3}if(j){j=z[k++];C.materials=f.materials[j]}j=f.faces.length;if(g)for(g=0;g<M;g++){F=b.uvs[g];y=z[k++];U=F[y*2];y=F[y*2+1];f.faceUvs[g][j]=new THREE.UV(U,y)}if(h)for(g=0;g<M;g++){F=b.uvs[g];H=[];for(h=0;h<p;h++){y=z[k++];U=F[y*2];y=F[y*2+1];H[h]=new THREE.UV(U,
-y)}f.faceVertexUvs[g][j]=H}if(u){u=z[k++]*3;h=new THREE.Vector3;h.x=J[u++];h.y=J[u++];h.z=J[u];C.normal=h}if(o)for(g=0;g<p;g++){u=z[k++]*3;h=new THREE.Vector3;h.x=J[u++];h.y=J[u++];h.z=J[u];C.vertexNormals.push(h)}if(B){o=new THREE.Color(z[k++]);C.color=o}if(v)for(g=0;g<p;g++){o=z[k++];o=new THREE.Color(L[o]);C.vertexColors.push(o)}f.faces.push(C)}}})();(function(){var g,h,j,k;if(b.skinWeights){g=0;for(h=b.skinWeights.length;g<h;g+=2){j=b.skinWeights[g];k=b.skinWeights[g+1];f.skinWeights.push(new THREE.Vector4(j,
-k,0,0))}}if(b.skinIndices){g=0;for(h=b.skinIndices.length;g<h;g+=2){j=b.skinIndices[g];k=b.skinIndices[g+1];f.skinIndices.push(new THREE.Vector4(j,k,0,0))}}f.bones=b.bones;f.animation=b.animation})();(function(){if(b.morphTargets!==undefined){var g,h,j,k;g=0;for(h=b.morphTargets.length;g<h;g++){f.morphTargets[g]={};f.morphTargets[g].name=b.morphTargets[g].name;f.morphTargets[g].vertices=[];dstVertices=f.morphTargets[g].vertices;srcVertices=b.morphTargets[g].vertices;j=0;for(k=srcVertices.length;j<
-k;j+=3)dstVertices.push(new THREE.Vertex(new THREE.Vector3(srcVertices[j],srcVertices[j+1],srcVertices[j+2])))}}})();f.computeCentroids();f.computeFaceNormals();d(f)};THREE.BinaryLoader=function(b){THREE.Loader.call(this,b)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
+THREE.JSONLoader.prototype.createModel=function(b,d,c){var f=new THREE.Geometry;this.init_materials(f,b.materials,c);(function(){if(b.version===undefined||b.version!=2)console.error("Deprecated file format.");else{var g,h,j,k,n,p,o,u,y,w,A,E,G,L,V,z=b.faces;p=b.vertices;var N=b.normals,Q=b.colors;o=b.scale!==undefined?b.scale:1;var S=0;for(g=0;g<b.uvs.length;g++)b.uvs[g].length&&S++;for(g=0;g<S;g++){f.faceUvs[g]=[];f.faceVertexUvs[g]=[]}k=0;for(n=p.length;k<n;){A=new THREE.Vertex;A.position.x=p[k++]/
+o;A.position.y=p[k++]/o;A.position.z=p[k++]/o;f.vertices.push(A)}k=0;for(n=z.length;k<n;){w=z[k++];p=w&1;j=w&2;g=w&4;h=w&8;u=w&16;o=w&32;A=w&64;w&=128;if(p){E=new THREE.Face4;E.a=z[k++];E.b=z[k++];E.c=z[k++];E.d=z[k++];p=4}else{E=new THREE.Face3;E.a=z[k++];E.b=z[k++];E.c=z[k++];p=3}if(j){j=z[k++];E.materials=f.materials[j]}j=f.faces.length;if(g)for(g=0;g<S;g++){G=b.uvs[g];y=z[k++];V=G[y*2];y=G[y*2+1];f.faceUvs[g][j]=new THREE.UV(V,y)}if(h)for(g=0;g<S;g++){G=b.uvs[g];L=[];for(h=0;h<p;h++){y=z[k++];
+V=G[y*2];y=G[y*2+1];L[h]=new THREE.UV(V,y)}f.faceVertexUvs[g][j]=L}if(u){u=z[k++]*3;h=new THREE.Vector3;h.x=N[u++];h.y=N[u++];h.z=N[u];E.normal=h}if(o)for(g=0;g<p;g++){u=z[k++]*3;h=new THREE.Vector3;h.x=N[u++];h.y=N[u++];h.z=N[u];E.vertexNormals.push(h)}if(A){o=new THREE.Color(z[k++]);E.color=o}if(w)for(g=0;g<p;g++){o=z[k++];o=new THREE.Color(Q[o]);E.vertexColors.push(o)}f.faces.push(E)}}})();(function(){var g,h,j,k;if(b.skinWeights){g=0;for(h=b.skinWeights.length;g<h;g+=2){j=b.skinWeights[g];k=b.skinWeights[g+
+1];f.skinWeights.push(new THREE.Vector4(j,k,0,0))}}if(b.skinIndices){g=0;for(h=b.skinIndices.length;g<h;g+=2){j=b.skinIndices[g];k=b.skinIndices[g+1];f.skinIndices.push(new THREE.Vector4(j,k,0,0))}}f.bones=b.bones;f.animation=b.animation})();(function(){if(b.morphTargets!==undefined){var g,h,j,k;g=0;for(h=b.morphTargets.length;g<h;g++){f.morphTargets[g]={};f.morphTargets[g].name=b.morphTargets[g].name;f.morphTargets[g].vertices=[];dstVertices=f.morphTargets[g].vertices;srcVertices=b.morphTargets[g].vertices;
+j=0;for(k=srcVertices.length;j<k;j+=3)dstVertices.push(new THREE.Vertex(new THREE.Vector3(srcVertices[j],srcVertices[j+1],srcVertices[j+2])))}}})();f.computeCentroids();f.computeFaceNormals();d(f)};THREE.BinaryLoader=function(b){THREE.Loader.call(this,b)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
 THREE.BinaryLoader.prototype={load:function(b){var d=b.model,c=b.callback,f=b.texture_path?b.texture_path:THREE.Loader.prototype.extractUrlbase(d),g=b.bin_path?b.bin_path:THREE.Loader.prototype.extractUrlbase(d);b=(new Date).getTime();d=new Worker(d);var h=this.showProgress?THREE.Loader.prototype.updateProgress:null;d.onmessage=function(j){THREE.BinaryLoader.prototype.loadAjaxBuffers(j.data.buffers,j.data.materials,c,g,f,h)};d.onerror=function(j){alert("worker.onerror: "+j.message+"\n"+j.data);j.preventDefault()};
 d.postMessage(b)},loadAjaxBuffers:function(b,d,c,f,g,h){var j=new XMLHttpRequest,k=f+"/"+b,n=0;j.onreadystatechange=function(){if(j.readyState==4)j.status==200||j.status==0?THREE.BinaryLoader.prototype.createBinModel(j.responseText,c,g,d):alert("Couldn't load ["+k+"] ["+j.status+"]");else if(j.readyState==3){if(h){n==0&&(n=j.getResponseHeader("Content-Length"));h({total:n,loaded:j.responseText.length})}}else j.readyState==2&&(n=j.getResponseHeader("Content-Length"))};j.open("GET",k,!0);j.overrideMimeType("text/plain; charset=x-user-defined");
-j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(b,d,c,f){var g=function(h){function j(N,X){var ma=o(N,X),Ea=o(N,X+1),Ka=o(N,X+2),ya=o(N,X+3),ia=(ya<<1&255|Ka>>7)-127;ma|=(Ka&127)<<16|Ea<<8;if(ma==0&&ia==-127)return 0;return(1-2*(ya>>7))*(1+ma*Math.pow(2,-23))*Math.pow(2,ia)}function k(N,X){var ma=o(N,X),Ea=o(N,X+1),Ka=o(N,X+2);return(o(N,X+3)<<24)+(Ka<<16)+(Ea<<8)+ma}function n(N,X){var ma=o(N,X);return(o(N,X+1)<<8)+ma}function p(N,X){var ma=o(N,X);return ma>
-127?ma-256:ma}function o(N,X){return N.charCodeAt(X)&255}function u(N){var X,ma,Ea;X=k(b,N);ma=k(b,N+M);Ea=k(b,N+Fa);N=n(b,N+oa);THREE.BinaryLoader.prototype.f3(H,X,ma,Ea,N)}function y(N){var X,ma,Ea,Ka,ya,ia;X=k(b,N);ma=k(b,N+M);Ea=k(b,N+Fa);Ka=n(b,N+oa);ya=k(b,N+xa);ia=k(b,N+Z);N=k(b,N+e);THREE.BinaryLoader.prototype.f3n(H,J,X,ma,Ea,Ka,ya,ia,N)}function v(N){var X,ma,Ea,Ka;X=k(b,N);ma=k(b,N+da);Ea=k(b,N+Ca);Ka=k(b,N+Aa);N=n(b,N+Ha);THREE.BinaryLoader.prototype.f4(H,X,ma,Ea,Ka,N)}function B(N){var X,
-ma,Ea,Ka,ya,ia,m,A;X=k(b,N);ma=k(b,N+da);Ea=k(b,N+Ca);Ka=k(b,N+Aa);ya=n(b,N+Ha);ia=k(b,N+qa);m=k(b,N+$);A=k(b,N+pa);N=k(b,N+Da);THREE.BinaryLoader.prototype.f4n(H,J,X,ma,Ea,Ka,ya,ia,m,A,N)}function C(N){var X,ma;X=k(b,N);ma=k(b,N+ga);N=k(b,N+Y);THREE.BinaryLoader.prototype.uv3(H.faceVertexUvs[0],L[X*2],L[X*2+1],L[ma*2],L[ma*2+1],L[N*2],L[N*2+1])}function F(N){var X,ma,Ea;X=k(b,N);ma=k(b,N+la);Ea=k(b,N+Ga);N=k(b,N+ka);THREE.BinaryLoader.prototype.uv4(H.faceVertexUvs[0],L[X*2],L[X*2+1],L[ma*2],L[ma*
-2+1],L[Ea*2],L[Ea*2+1],L[N*2],L[N*2+1])}var H=this,U=0,z,J=[],L=[],M,Fa,oa,xa,Z,e,da,Ca,Aa,Ha,qa,$,pa,Da,ga,Y,la,Ga,ka,na,wa,Ua,cb,ab,Pa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(H,f,h);z={signature:b.substr(U,8),header_bytes:o(b,U+8),vertex_coordinate_bytes:o(b,U+9),normal_coordinate_bytes:o(b,U+10),uv_coordinate_bytes:o(b,U+11),vertex_index_bytes:o(b,U+12),normal_index_bytes:o(b,U+13),uv_index_bytes:o(b,U+14),material_index_bytes:o(b,U+15),nvertices:k(b,U+16),nnormals:k(b,
-U+16+4),nuvs:k(b,U+16+8),ntri_flat:k(b,U+16+12),ntri_smooth:k(b,U+16+16),ntri_flat_uv:k(b,U+16+20),ntri_smooth_uv:k(b,U+16+24),nquad_flat:k(b,U+16+28),nquad_smooth:k(b,U+16+32),nquad_flat_uv:k(b,U+16+36),nquad_smooth_uv:k(b,U+16+40)};U+=z.header_bytes;M=z.vertex_index_bytes;Fa=z.vertex_index_bytes*2;oa=z.vertex_index_bytes*3;xa=z.vertex_index_bytes*3+z.material_index_bytes;Z=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes;e=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*
-2;da=z.vertex_index_bytes;Ca=z.vertex_index_bytes*2;Aa=z.vertex_index_bytes*3;Ha=z.vertex_index_bytes*4;qa=z.vertex_index_bytes*4+z.material_index_bytes;$=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes;pa=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*2;Da=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*3;ga=z.uv_index_bytes;Y=z.uv_index_bytes*2;la=z.uv_index_bytes;Ga=z.uv_index_bytes*2;ka=z.uv_index_bytes*3;h=z.vertex_index_bytes*3+z.material_index_bytes;
-Pa=z.vertex_index_bytes*4+z.material_index_bytes;na=z.ntri_flat*h;wa=z.ntri_smooth*(h+z.normal_index_bytes*3);Ua=z.ntri_flat_uv*(h+z.uv_index_bytes*3);cb=z.ntri_smooth_uv*(h+z.normal_index_bytes*3+z.uv_index_bytes*3);ab=z.nquad_flat*Pa;h=z.nquad_smooth*(Pa+z.normal_index_bytes*4);Pa=z.nquad_flat_uv*(Pa+z.uv_index_bytes*4);U+=function(N){for(var X,ma,Ea,Ka=z.vertex_coordinate_bytes*3,ya=N+z.nvertices*Ka;N<ya;N+=Ka){X=j(b,N);ma=j(b,N+z.vertex_coordinate_bytes);Ea=j(b,N+z.vertex_coordinate_bytes*2);
-THREE.BinaryLoader.prototype.v(H,X,ma,Ea)}return z.nvertices*Ka}(U);U+=function(N){for(var X,ma,Ea,Ka=z.normal_coordinate_bytes*3,ya=N+z.nnormals*Ka;N<ya;N+=Ka){X=p(b,N);ma=p(b,N+z.normal_coordinate_bytes);Ea=p(b,N+z.normal_coordinate_bytes*2);J.push(X/127,ma/127,Ea/127)}return z.nnormals*Ka}(U);U+=function(N){for(var X,ma,Ea=z.uv_coordinate_bytes*2,Ka=N+z.nuvs*Ea;N<Ka;N+=Ea){X=j(b,N);ma=j(b,N+z.uv_coordinate_bytes);L.push(X,ma)}return z.nuvs*Ea}(U);na=U+na;wa=na+wa;Ua=wa+Ua;cb=Ua+cb;ab=cb+ab;h=ab+
-h;Pa=h+Pa;(function(N){var X,ma=z.vertex_index_bytes*3+z.material_index_bytes,Ea=ma+z.uv_index_bytes*3,Ka=N+z.ntri_flat_uv*Ea;for(X=N;X<Ka;X+=Ea){u(X);C(X+ma)}return Ka-N})(wa);(function(N){var X,ma=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*3,Ea=ma+z.uv_index_bytes*3,Ka=N+z.ntri_smooth_uv*Ea;for(X=N;X<Ka;X+=Ea){y(X);C(X+ma)}return Ka-N})(Ua);(function(N){var X,ma=z.vertex_index_bytes*4+z.material_index_bytes,Ea=ma+z.uv_index_bytes*4,Ka=N+z.nquad_flat_uv*Ea;for(X=N;X<Ka;X+=
-Ea){v(X);F(X+ma)}return Ka-N})(h);(function(N){var X,ma=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*4,Ea=ma+z.uv_index_bytes*4,Ka=N+z.nquad_smooth_uv*Ea;for(X=N;X<Ka;X+=Ea){B(X);F(X+ma)}return Ka-N})(Pa);(function(N){var X,ma=z.vertex_index_bytes*3+z.material_index_bytes,Ea=N+z.ntri_flat*ma;for(X=N;X<Ea;X+=ma)u(X);return Ea-N})(U);(function(N){var X,ma=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*3,Ea=N+z.ntri_smooth*ma;for(X=N;X<Ea;X+=ma)y(X);return Ea-
-N})(na);(function(N){var X,ma=z.vertex_index_bytes*4+z.material_index_bytes,Ea=N+z.nquad_flat*ma;for(X=N;X<Ea;X+=ma)v(X);return Ea-N})(cb);(function(N){var X,ma=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*4,Ea=N+z.nquad_smooth*ma;for(X=N;X<Ea;X+=ma)B(X);return Ea-N})(ab);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;d(new g(c))},v:function(b,d,c,f){b.vertices.push(new THREE.Vertex(new THREE.Vector3(d,c,f)))},f3:function(b,
+j.setRequestHeader("Content-Type","text/plain");j.send(null)},createBinModel:function(b,d,c,f){var g=function(h){function j(R,$){var na=o(R,$),Ba=o(R,$+1),ha=o(R,$+2),ka=o(R,$+3),m=(ka<<1&255|ha>>7)-127;na|=(ha&127)<<16|Ba<<8;if(na==0&&m==-127)return 0;return(1-2*(ka>>7))*(1+na*Math.pow(2,-23))*Math.pow(2,m)}function k(R,$){var na=o(R,$),Ba=o(R,$+1),ha=o(R,$+2);return(o(R,$+3)<<24)+(ha<<16)+(Ba<<8)+na}function n(R,$){var na=o(R,$);return(o(R,$+1)<<8)+na}function p(R,$){var na=o(R,$);return na>127?
+na-256:na}function o(R,$){return R.charCodeAt($)&255}function u(R){var $,na,Ba;$=k(b,R);na=k(b,R+S);Ba=k(b,R+xa);R=n(b,R+sa);THREE.BinaryLoader.prototype.f3(L,$,na,Ba,R)}function y(R){var $,na,Ba,ha,ka,m;$=k(b,R);na=k(b,R+S);Ba=k(b,R+xa);ha=n(b,R+sa);ka=k(b,R+qa);m=k(b,R+e);R=k(b,R+fa);THREE.BinaryLoader.prototype.f3n(L,N,$,na,Ba,ha,ka,m,R)}function w(R){var $,na,Ba,ha;$=k(b,R);na=k(b,R+da);Ba=k(b,R+ya);ha=k(b,R+Fa);R=n(b,R+Ga);THREE.BinaryLoader.prototype.f4(L,$,na,Ba,ha,R)}function A(R){var $,na,
+Ba,ha,ka,m,C,x;$=k(b,R);na=k(b,R+da);Ba=k(b,R+ya);ha=k(b,R+Fa);ka=n(b,R+Ga);m=k(b,R+ra);C=k(b,R+aa);x=k(b,R+pa);R=k(b,R+za);THREE.BinaryLoader.prototype.f4n(L,N,$,na,Ba,ha,ka,m,C,x,R)}function E(R){var $,na;$=k(b,R);na=k(b,R+ia);R=k(b,R+Y);THREE.BinaryLoader.prototype.uv3(L.faceVertexUvs[0],Q[$*2],Q[$*2+1],Q[na*2],Q[na*2+1],Q[R*2],Q[R*2+1])}function G(R){var $,na,Ba;$=k(b,R);na=k(b,R+ma);Ba=k(b,R+Da);R=k(b,R+ja);THREE.BinaryLoader.prototype.uv4(L.faceVertexUvs[0],Q[$*2],Q[$*2+1],Q[na*2],Q[na*2+1],
+Q[Ba*2],Q[Ba*2+1],Q[R*2],Q[R*2+1])}var L=this,V=0,z,N=[],Q=[],S,xa,sa,qa,e,fa,da,ya,Fa,Ga,ra,aa,pa,za,ia,Y,ma,Da,ja,la,Ea,Sa,$a,Ya,Ta;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(L,f,h);z={signature:b.substr(V,8),header_bytes:o(b,V+8),vertex_coordinate_bytes:o(b,V+9),normal_coordinate_bytes:o(b,V+10),uv_coordinate_bytes:o(b,V+11),vertex_index_bytes:o(b,V+12),normal_index_bytes:o(b,V+13),uv_index_bytes:o(b,V+14),material_index_bytes:o(b,V+15),nvertices:k(b,V+16),nnormals:k(b,V+16+
+4),nuvs:k(b,V+16+8),ntri_flat:k(b,V+16+12),ntri_smooth:k(b,V+16+16),ntri_flat_uv:k(b,V+16+20),ntri_smooth_uv:k(b,V+16+24),nquad_flat:k(b,V+16+28),nquad_smooth:k(b,V+16+32),nquad_flat_uv:k(b,V+16+36),nquad_smooth_uv:k(b,V+16+40)};V+=z.header_bytes;S=z.vertex_index_bytes;xa=z.vertex_index_bytes*2;sa=z.vertex_index_bytes*3;qa=z.vertex_index_bytes*3+z.material_index_bytes;e=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes;fa=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*
+2;da=z.vertex_index_bytes;ya=z.vertex_index_bytes*2;Fa=z.vertex_index_bytes*3;Ga=z.vertex_index_bytes*4;ra=z.vertex_index_bytes*4+z.material_index_bytes;aa=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes;pa=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*2;za=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*3;ia=z.uv_index_bytes;Y=z.uv_index_bytes*2;ma=z.uv_index_bytes;Da=z.uv_index_bytes*2;ja=z.uv_index_bytes*3;h=z.vertex_index_bytes*3+z.material_index_bytes;
+Ta=z.vertex_index_bytes*4+z.material_index_bytes;la=z.ntri_flat*h;Ea=z.ntri_smooth*(h+z.normal_index_bytes*3);Sa=z.ntri_flat_uv*(h+z.uv_index_bytes*3);$a=z.ntri_smooth_uv*(h+z.normal_index_bytes*3+z.uv_index_bytes*3);Ya=z.nquad_flat*Ta;h=z.nquad_smooth*(Ta+z.normal_index_bytes*4);Ta=z.nquad_flat_uv*(Ta+z.uv_index_bytes*4);V+=function(R){for(var $,na,Ba,ha=z.vertex_coordinate_bytes*3,ka=R+z.nvertices*ha;R<ka;R+=ha){$=j(b,R);na=j(b,R+z.vertex_coordinate_bytes);Ba=j(b,R+z.vertex_coordinate_bytes*2);
+THREE.BinaryLoader.prototype.v(L,$,na,Ba)}return z.nvertices*ha}(V);V+=function(R){for(var $,na,Ba,ha=z.normal_coordinate_bytes*3,ka=R+z.nnormals*ha;R<ka;R+=ha){$=p(b,R);na=p(b,R+z.normal_coordinate_bytes);Ba=p(b,R+z.normal_coordinate_bytes*2);N.push($/127,na/127,Ba/127)}return z.nnormals*ha}(V);V+=function(R){for(var $,na,Ba=z.uv_coordinate_bytes*2,ha=R+z.nuvs*Ba;R<ha;R+=Ba){$=j(b,R);na=j(b,R+z.uv_coordinate_bytes);Q.push($,na)}return z.nuvs*Ba}(V);la=V+la;Ea=la+Ea;Sa=Ea+Sa;$a=Sa+$a;Ya=$a+Ya;h=Ya+
+h;Ta=h+Ta;(function(R){var $,na=z.vertex_index_bytes*3+z.material_index_bytes,Ba=na+z.uv_index_bytes*3,ha=R+z.ntri_flat_uv*Ba;for($=R;$<ha;$+=Ba){u($);E($+na)}return ha-R})(Ea);(function(R){var $,na=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*3,Ba=na+z.uv_index_bytes*3,ha=R+z.ntri_smooth_uv*Ba;for($=R;$<ha;$+=Ba){y($);E($+na)}return ha-R})(Sa);(function(R){var $,na=z.vertex_index_bytes*4+z.material_index_bytes,Ba=na+z.uv_index_bytes*4,ha=R+z.nquad_flat_uv*Ba;for($=R;$<ha;$+=
+Ba){w($);G($+na)}return ha-R})(h);(function(R){var $,na=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*4,Ba=na+z.uv_index_bytes*4,ha=R+z.nquad_smooth_uv*Ba;for($=R;$<ha;$+=Ba){A($);G($+na)}return ha-R})(Ta);(function(R){var $,na=z.vertex_index_bytes*3+z.material_index_bytes,Ba=R+z.ntri_flat*na;for($=R;$<Ba;$+=na)u($);return Ba-R})(V);(function(R){var $,na=z.vertex_index_bytes*3+z.material_index_bytes+z.normal_index_bytes*3,Ba=R+z.ntri_smooth*na;for($=R;$<Ba;$+=na)y($);return Ba-
+R})(la);(function(R){var $,na=z.vertex_index_bytes*4+z.material_index_bytes,Ba=R+z.nquad_flat*na;for($=R;$<Ba;$+=na)w($);return Ba-R})($a);(function(R){var $,na=z.vertex_index_bytes*4+z.material_index_bytes+z.normal_index_bytes*4,Ba=R+z.nquad_smooth*na;for($=R;$<Ba;$+=na)A($);return Ba-R})(Ya);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;d(new g(c))},v:function(b,d,c,f){b.vertices.push(new THREE.Vertex(new THREE.Vector3(d,c,f)))},f3:function(b,
 d,c,f,g){b.faces.push(new THREE.Face3(d,c,f,null,null,b.materials[g]))},f4:function(b,d,c,f,g,h){b.faces.push(new THREE.Face4(d,c,f,g,null,null,b.materials[h]))},f3n:function(b,d,c,f,g,h,j,k,n){h=b.materials[h];var p=d[k*3],o=d[k*3+1];k=d[k*3+2];var u=d[n*3],y=d[n*3+1];n=d[n*3+2];b.faces.push(new THREE.Face3(c,f,g,[new THREE.Vector3(d[j*3],d[j*3+1],d[j*3+2]),new THREE.Vector3(p,o,k),new THREE.Vector3(u,y,n)],null,h))},f4n:function(b,d,c,f,g,h,j,k,n,p,o){j=b.materials[j];var u=d[n*3],y=d[n*3+1];n=
-d[n*3+2];var v=d[p*3],B=d[p*3+1];p=d[p*3+2];var C=d[o*3],F=d[o*3+1];o=d[o*3+2];b.faces.push(new THREE.Face4(c,f,g,h,[new THREE.Vector3(d[k*3],d[k*3+1],d[k*3+2]),new THREE.Vector3(u,y,n),new THREE.Vector3(v,B,p),new THREE.Vector3(C,F,o)],null,j))},uv3:function(b,d,c,f,g,h,j){var k=[];k.push(new THREE.UV(d,c));k.push(new THREE.UV(f,g));k.push(new THREE.UV(h,j));b.push(k)},uv4:function(b,d,c,f,g,h,j,k,n){var p=[];p.push(new THREE.UV(d,c));p.push(new THREE.UV(f,g));p.push(new THREE.UV(h,j));p.push(new THREE.UV(k,
+d[n*3+2];var w=d[p*3],A=d[p*3+1];p=d[p*3+2];var E=d[o*3],G=d[o*3+1];o=d[o*3+2];b.faces.push(new THREE.Face4(c,f,g,h,[new THREE.Vector3(d[k*3],d[k*3+1],d[k*3+2]),new THREE.Vector3(u,y,n),new THREE.Vector3(w,A,p),new THREE.Vector3(E,G,o)],null,j))},uv3:function(b,d,c,f,g,h,j){var k=[];k.push(new THREE.UV(d,c));k.push(new THREE.UV(f,g));k.push(new THREE.UV(h,j));b.push(k)},uv4:function(b,d,c,f,g,h,j,k,n){var p=[];p.push(new THREE.UV(d,c));p.push(new THREE.UV(f,g));p.push(new THREE.UV(h,j));p.push(new THREE.UV(k,
 n));b.push(p)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 THREE.MarchingCubes=function(b,d){THREE.Object3D.call(this);this.materials=d instanceof Array?d:[d];this.init=function(c){this.isolation=80;this.size=c;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
 0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(c,f,g){return c+(f-c)*g};this.VIntX=function(c,f,g,h,j,k,n,p,o,u){j=(j-o)/(u-o);o=this.normal_cache;f[h]=k+j*this.delta;f[h+1]=n;f[h+2]=p;g[h]=this.lerp(o[c],o[c+3],j);g[h+1]=this.lerp(o[c+1],o[c+4],j);g[h+2]=this.lerp(o[c+2],o[c+5],j)};this.VIntY=function(c,f,g,h,j,k,n,p,o,u){j=(j-o)/(u-o);o=this.normal_cache;f[h]=k;f[h+1]=n+j*this.delta;f[h+
 2]=p;f=c+this.yd*3;g[h]=this.lerp(o[c],o[f],j);g[h+1]=this.lerp(o[c+1],o[f+1],j);g[h+2]=this.lerp(o[c+2],o[f+2],j)};this.VIntZ=function(c,f,g,h,j,k,n,p,o,u){j=(j-o)/(u-o);o=this.normal_cache;f[h]=k;f[h+1]=n;f[h+2]=p+j*this.delta;f=c+this.zd*3;g[h]=this.lerp(o[c],o[f],j);g[h+1]=this.lerp(o[c+1],o[f+1],j);g[h+2]=this.lerp(o[c+2],o[f+2],j)};this.compNorm=function(c){var f=c*3;if(this.normal_cache[f]==0){this.normal_cache[f]=this.field[c-1]-this.field[c+1];this.normal_cache[f+1]=this.field[c-this.yd]-
-this.field[c+this.yd];this.normal_cache[f+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,f,g,h,j,k){var n=h+1,p=h+this.yd,o=h+this.zd,u=n+this.yd,y=n+this.zd,v=h+this.yd+this.zd,B=n+this.yd+this.zd,C=0,F=this.field[h],H=this.field[n],U=this.field[p],z=this.field[u],J=this.field[o],L=this.field[y],M=this.field[v],Fa=this.field[B];F<j&&(C|=1);H<j&&(C|=2);U<j&&(C|=8);z<j&&(C|=4);J<j&&(C|=16);L<j&&(C|=32);M<j&&(C|=128);Fa<j&&(C|=64);var oa=THREE.edgeTable[C];if(oa==0)return 0;
-var xa=this.delta,Z=c+xa,e=f+xa;xa=g+xa;if(oa&1){this.compNorm(h);this.compNorm(n);this.VIntX(h*3,this.vlist,this.nlist,0,j,c,f,g,F,H)}if(oa&2){this.compNorm(n);this.compNorm(u);this.VIntY(n*3,this.vlist,this.nlist,3,j,Z,f,g,H,z)}if(oa&4){this.compNorm(p);this.compNorm(u);this.VIntX(p*3,this.vlist,this.nlist,6,j,c,e,g,U,z)}if(oa&8){this.compNorm(h);this.compNorm(p);this.VIntY(h*3,this.vlist,this.nlist,9,j,c,f,g,F,U)}if(oa&16){this.compNorm(o);this.compNorm(y);this.VIntX(o*3,this.vlist,this.nlist,
-12,j,c,f,xa,J,L)}if(oa&32){this.compNorm(y);this.compNorm(B);this.VIntY(y*3,this.vlist,this.nlist,15,j,Z,f,xa,L,Fa)}if(oa&64){this.compNorm(v);this.compNorm(B);this.VIntX(v*3,this.vlist,this.nlist,18,j,c,e,xa,M,Fa)}if(oa&128){this.compNorm(o);this.compNorm(v);this.VIntY(o*3,this.vlist,this.nlist,21,j,c,f,xa,J,M)}if(oa&256){this.compNorm(h);this.compNorm(o);this.VIntZ(h*3,this.vlist,this.nlist,24,j,c,f,g,F,J)}if(oa&512){this.compNorm(n);this.compNorm(y);this.VIntZ(n*3,this.vlist,this.nlist,27,j,Z,
-f,g,H,L)}if(oa&1024){this.compNorm(u);this.compNorm(B);this.VIntZ(u*3,this.vlist,this.nlist,30,j,Z,e,g,z,Fa)}if(oa&2048){this.compNorm(p);this.compNorm(v);this.VIntZ(p*3,this.vlist,this.nlist,33,j,c,e,g,U,M)}C<<=4;for(j=h=0;THREE.triTable[C+j]!=-1;){c=C+j;f=c+1;g=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[f],3*THREE.triTable[g],k);j+=3;h++}return h};this.posnormtriv=function(c,f,g,h,j,k){var n=this.count*3;this.positionArray[n]=c[g];this.positionArray[n+1]=c[g+
+this.field[c+this.yd];this.normal_cache[f+2]=this.field[c-this.zd]-this.field[c+this.zd]}};this.polygonize=function(c,f,g,h,j,k){var n=h+1,p=h+this.yd,o=h+this.zd,u=n+this.yd,y=n+this.zd,w=h+this.yd+this.zd,A=n+this.yd+this.zd,E=0,G=this.field[h],L=this.field[n],V=this.field[p],z=this.field[u],N=this.field[o],Q=this.field[y],S=this.field[w],xa=this.field[A];G<j&&(E|=1);L<j&&(E|=2);V<j&&(E|=8);z<j&&(E|=4);N<j&&(E|=16);Q<j&&(E|=32);S<j&&(E|=128);xa<j&&(E|=64);var sa=THREE.edgeTable[E];if(sa==0)return 0;
+var qa=this.delta,e=c+qa,fa=f+qa;qa=g+qa;if(sa&1){this.compNorm(h);this.compNorm(n);this.VIntX(h*3,this.vlist,this.nlist,0,j,c,f,g,G,L)}if(sa&2){this.compNorm(n);this.compNorm(u);this.VIntY(n*3,this.vlist,this.nlist,3,j,e,f,g,L,z)}if(sa&4){this.compNorm(p);this.compNorm(u);this.VIntX(p*3,this.vlist,this.nlist,6,j,c,fa,g,V,z)}if(sa&8){this.compNorm(h);this.compNorm(p);this.VIntY(h*3,this.vlist,this.nlist,9,j,c,f,g,G,V)}if(sa&16){this.compNorm(o);this.compNorm(y);this.VIntX(o*3,this.vlist,this.nlist,
+12,j,c,f,qa,N,Q)}if(sa&32){this.compNorm(y);this.compNorm(A);this.VIntY(y*3,this.vlist,this.nlist,15,j,e,f,qa,Q,xa)}if(sa&64){this.compNorm(w);this.compNorm(A);this.VIntX(w*3,this.vlist,this.nlist,18,j,c,fa,qa,S,xa)}if(sa&128){this.compNorm(o);this.compNorm(w);this.VIntY(o*3,this.vlist,this.nlist,21,j,c,f,qa,N,S)}if(sa&256){this.compNorm(h);this.compNorm(o);this.VIntZ(h*3,this.vlist,this.nlist,24,j,c,f,g,G,N)}if(sa&512){this.compNorm(n);this.compNorm(y);this.VIntZ(n*3,this.vlist,this.nlist,27,j,e,
+f,g,L,Q)}if(sa&1024){this.compNorm(u);this.compNorm(A);this.VIntZ(u*3,this.vlist,this.nlist,30,j,e,fa,g,z,xa)}if(sa&2048){this.compNorm(p);this.compNorm(w);this.VIntZ(p*3,this.vlist,this.nlist,33,j,c,fa,g,V,S)}E<<=4;for(j=h=0;THREE.triTable[E+j]!=-1;){c=E+j;f=c+1;g=c+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[c],3*THREE.triTable[f],3*THREE.triTable[g],k);j+=3;h++}return h};this.posnormtriv=function(c,f,g,h,j,k){var n=this.count*3;this.positionArray[n]=c[g];this.positionArray[n+1]=c[g+
 1];this.positionArray[n+2]=c[g+2];this.positionArray[n+3]=c[h];this.positionArray[n+4]=c[h+1];this.positionArray[n+5]=c[h+2];this.positionArray[n+6]=c[j];this.positionArray[n+7]=c[j+1];this.positionArray[n+8]=c[j+2];this.normalArray[n]=f[g];this.normalArray[n+1]=f[g+1];this.normalArray[n+2]=f[g+2];this.normalArray[n+3]=f[h];this.normalArray[n+4]=f[h+1];this.normalArray[n+5]=f[h+2];this.normalArray[n+6]=f[j];this.normalArray[n+7]=f[j+1];this.normalArray[n+8]=f[j+2];this.hasPos=!0;this.hasNormal=!0;
 this.count+=3;this.count>=this.maxCount-3&&k(this)};this.begin=function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(c){if(this.count!=0){for(var f=this.count*3;f<this.positionArray.length;f++)this.positionArray[f]=0;c(this)}};this.addBall=function(c,f,g,h,j){var k=this.size*Math.sqrt(h/j),n=g*this.size,p=f*this.size,o=c*this.size,u=Math.floor(n-k);u<1&&(u=1);n=Math.floor(n+k);n>this.size-1&&(n=this.size-1);var y=Math.floor(p-k);y<1&&(y=1);p=Math.floor(p+k);p>this.size-1&&(p=
-this.size-1);var v=Math.floor(o-k);v<1&&(v=1);k=Math.floor(o+k);k>this.size-1&&(k=this.size-1);for(var B,C,F,H,U,z;u<n;u++){o=this.size2*u;C=u/this.size-g;U=C*C;for(C=y;C<p;C++){F=o+this.size*C;B=C/this.size-f;z=B*B;for(B=v;B<k;B++){H=B/this.size-c;H=h/(1.0E-6+H*H+z+U)-j;H>0&&(this.field[F+B]+=H)}}}};this.addPlaneX=function(c,f){var g,h,j,k,n,p=this.size,o=this.yd,u=this.zd,y=this.field,v=p*Math.sqrt(c/f);v>p&&(v=p);for(g=0;g<v;g++){h=g/p;h*=h;k=c/(1.0E-4+h)-f;if(k>0)for(h=0;h<p;h++){n=g+h*o;for(j=
-0;j<p;j++)y[u*j+n]+=k}}};this.addPlaneY=function(c,f){var g,h,j,k,n,p,o=this.size,u=this.yd,y=this.zd,v=this.field,B=o*Math.sqrt(c/f);B>o&&(B=o);for(h=0;h<B;h++){g=h/o;g*=g;k=c/(1.0E-4+g)-f;if(k>0){n=h*u;for(g=0;g<o;g++){p=n+g;for(j=0;j<o;j++)v[y*j+p]+=k}}}};this.addPlaneZ=function(c,f){var g,h,j,k,n,p;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/f);dist>size&&(dist=size);for(j=0;j<dist;j++){g=j/size;g*=g;k=c/(1.0E-4+g)-f;if(k>0){n=zd*j;for(h=0;h<size;h++){p=n+h*yd;
+this.size-1);var w=Math.floor(o-k);w<1&&(w=1);k=Math.floor(o+k);k>this.size-1&&(k=this.size-1);for(var A,E,G,L,V,z;u<n;u++){o=this.size2*u;E=u/this.size-g;V=E*E;for(E=y;E<p;E++){G=o+this.size*E;A=E/this.size-f;z=A*A;for(A=w;A<k;A++){L=A/this.size-c;L=h/(1.0E-6+L*L+z+V)-j;L>0&&(this.field[G+A]+=L)}}}};this.addPlaneX=function(c,f){var g,h,j,k,n,p=this.size,o=this.yd,u=this.zd,y=this.field,w=p*Math.sqrt(c/f);w>p&&(w=p);for(g=0;g<w;g++){h=g/p;h*=h;k=c/(1.0E-4+h)-f;if(k>0)for(h=0;h<p;h++){n=g+h*o;for(j=
+0;j<p;j++)y[u*j+n]+=k}}};this.addPlaneY=function(c,f){var g,h,j,k,n,p,o=this.size,u=this.yd,y=this.zd,w=this.field,A=o*Math.sqrt(c/f);A>o&&(A=o);for(h=0;h<A;h++){g=h/o;g*=g;k=c/(1.0E-4+g)-f;if(k>0){n=h*u;for(g=0;g<o;g++){p=n+g;for(j=0;j<o;j++)w[y*j+p]+=k}}}};this.addPlaneZ=function(c,f){var g,h,j,k,n,p;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(c/f);dist>size&&(dist=size);for(j=0;j<dist;j++){g=j/size;g*=g;k=c/(1.0E-4+g)-f;if(k>0){n=zd*j;for(h=0;h<size;h++){p=n+h*yd;
 for(g=0;g<size;g++)field[p+g]+=k}}}};this.reset=function(){var c;for(c=0;c<this.size3;c++){this.normal_cache[c*3]=0;this.field[c]=0}};this.render=function(c){this.begin();var f,g,h,j,k,n,p,o,u,y=this.size-2;for(j=1;j<y;j++){u=this.size2*j;p=(j-this.halfsize)/this.halfsize;for(h=1;h<y;h++){o=u+this.size*h;n=(h-this.halfsize)/this.halfsize;for(g=1;g<y;g++){k=(g-this.halfsize)/this.halfsize;f=o+g;this.polygonize(k,n,p,f,this.isolation,c)}}}this.end(c)};this.generateGeometry=function(){var c=0,f=new THREE.Geometry;
 this.render(function(g){var h,j,k,n,p,o,u,y;for(h=0;h<g.count;h++){p=h*3;u=p+1;y=p+2;j=g.positionArray[p];k=g.positionArray[u];n=g.positionArray[y];o=new THREE.Vector3(j,k,n);j=g.normalArray[p];k=g.normalArray[u];n=g.normalArray[y];p=new THREE.Vector3(j,k,n);p.normalize();p=new THREE.Vertex(o,p);f.vertices.push(p)}nfaces=g.count/3;for(h=0;h<nfaces;h++){p=(c+h)*3;u=p+1;y=p+2;o=f.vertices[p].normal;j=f.vertices[u].normal;k=f.vertices[y].normal;p=new THREE.Face3(p,u,y,[o,j,k]);f.faces.push(p)}c+=nfaces;
 g.count=0});return f};this.init(b)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;

+ 1 - 1
build/custom/ThreeCanvas.js

@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
 THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var f=Math.cos(c);c=Math.sin(c);var g=a*b,i=e*d;this.w=g*f-i*c;this.x=g*c+i*f;this.y=e*b*f+a*d*c;this.z=a*d*f-e*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,e=this.z,d=this.w,f=a.x,g=a.y,i=a.z;a=a.w;this.x=b*a+d*f+c*i-e*g;this.y=c*a+d*g+e*f-b*i;this.z=e*a+d*i+b*g-c*f;this.w=d*a-b*f-c*g-e*i;return this},
 multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,f=this.x,g=this.y,i=this.z,h=this.w,j=h*c+g*d-i*e,k=h*e+i*c-f*d,n=h*d+f*e-g*c;c=-f*c-g*e-i*d;b.x=j*h+c*-f+k*-i-n*-g;b.y=k*h+c*-g+n*-f-j*-i;b.z=n*h+c*-i+j*-g-k*-f;return b}};
-THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);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}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);if(Math.abs(g)<0.0010){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}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,e,d,f){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,e,d,f,g){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};

+ 1 - 1
build/custom/ThreeDOM.js

@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
 THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var g=Math.cos(c);c=Math.sin(c);var f=a*b,i=e*d;this.w=f*g-i*c;this.x=f*c+i*g;this.y=e*b*g+a*d*c;this.z=a*d*g-e*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,e=this.z,d=this.w,g=a.x,f=a.y,i=a.z;a=a.w;this.x=b*a+d*g+c*i-e*f;this.y=c*a+d*f+e*g-b*i;this.z=e*a+d*i+b*f-c*g;this.w=d*a-b*g-c*f-e*i;return this},
 multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,g=this.x,f=this.y,i=this.z,h=this.w,j=h*c+f*d-i*e,m=h*e+i*c-g*d,l=h*d+g*e-f*c;c=-g*c-f*e-i*d;b.x=j*h+c*-g+m*-i-l*-f;b.y=m*h+c*-f+l*-g-j*-i;b.z=l*h+c*-i+j*-f-m*-g;return b}};
-THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<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}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var g=Math.acos(d),f=Math.sqrt(1-d*d);if(Math.abs(f)<0.0010){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}d=Math.sin((1-e)*g)/f;e=Math.sin(e*g)/f;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,e,d,g){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,e,d,g,f){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};

+ 39 - 38
build/custom/ThreeExtras.js

@@ -1,11 +1,11 @@
 // ThreeExtras.js r38 - http://github.com/mrdoob/three.js
-var GeometryUtils={merge:function(a,f){var b=f instanceof THREE.Mesh,c=a.vertices.length,e=b?f.geometry:f,d=a.vertices,g=e.vertices,h=a.faces,m=e.faces,k=a.faceVertexUvs[0];e=e.faceVertexUvs[0];b&&f.matrixAutoUpdate&&f.updateMatrix();for(var j=0,n=g.length;j<n;j++){var p=new THREE.Vertex(g[j].position.clone());b&&f.matrix.multiplyVector3(p.position);d.push(p)}j=0;for(n=m.length;j<n;j++){g=m[j];var t,x,w=g.vertexNormals;p=g.vertexColors;if(g instanceof THREE.Face3)t=new THREE.Face3(g.a+c,g.b+c,g.c+
-c);else g instanceof THREE.Face4&&(t=new THREE.Face4(g.a+c,g.b+c,g.c+c,g.d+c));t.normal.copy(g.normal);b=0;for(d=w.length;b<d;b++){x=w[b];t.vertexNormals.push(x.clone())}t.color.copy(g.color);b=0;for(d=p.length;b<d;b++){x=p[b];t.vertexColors.push(x.clone())}t.materials=g.materials.slice();t.centroid.copy(g.centroid);h.push(t)}j=0;for(n=e.length;j<n;j++){c=e[j];h=[];b=0;for(d=c.length;b<d;b++)h.push(new THREE.UV(c[b].u,c[b].v));k.push(h)}}},ImageUtils={loadTexture:function(a,f,b){var c=new Image,e=
+var GeometryUtils={merge:function(a,f){var b=f instanceof THREE.Mesh,c=a.vertices.length,e=b?f.geometry:f,d=a.vertices,g=e.vertices,h=a.faces,m=e.faces,k=a.faceVertexUvs[0];e=e.faceVertexUvs[0];b&&f.matrixAutoUpdate&&f.updateMatrix();for(var j=0,n=g.length;j<n;j++){var p=new THREE.Vertex(g[j].position.clone());b&&f.matrix.multiplyVector3(p.position);d.push(p)}j=0;for(n=m.length;j<n;j++){g=m[j];var t,w,x=g.vertexNormals;p=g.vertexColors;if(g instanceof THREE.Face3)t=new THREE.Face3(g.a+c,g.b+c,g.c+
+c);else g instanceof THREE.Face4&&(t=new THREE.Face4(g.a+c,g.b+c,g.c+c,g.d+c));t.normal.copy(g.normal);b=0;for(d=x.length;b<d;b++){w=x[b];t.vertexNormals.push(w.clone())}t.color.copy(g.color);b=0;for(d=p.length;b<d;b++){w=p[b];t.vertexColors.push(w.clone())}t.materials=g.materials.slice();t.centroid.copy(g.centroid);h.push(t)}j=0;for(n=e.length;j<n;j++){c=e[j];h=[];b=0;for(d=c.length;b<d;b++)h.push(new THREE.UV(c[b].u,c[b].v));k.push(h)}}},ImageUtils={loadTexture:function(a,f,b){var c=new Image,e=
 new THREE.Texture(c,f);c.onload=function(){e.needsUpdate=!0;b&&b(this)};c.src=a;return e},loadTextureCube:function(a,f,b){var c,e=[],d=new THREE.Texture(e,f);f=e.loadCount=0;for(c=a.length;f<c;++f){e[f]=new Image;e[f].onload=function(){e.loadCount+=1;if(e.loadCount==6)d.needsUpdate=!0;b&&b(this)};e[f].src=a[f]}return d}},SceneUtils={loadScene:function(a,f,b,c){var e=new Worker(a);e.postMessage(0);var d=THREE.Loader.prototype.extractUrlbase(a);e.onmessage=function(g){function h(V,W){return W=="relativeToHTML"?
 V:d+"/"+V}function m(){for(t in E.objects)if(!F.objects[t]){y=E.objects[t];if(G=F.geometries[y.geometry]){I=[];for(M=0;M<y.materials.length;M++)I[M]=F.materials[y.materials[M]];l=y.position;r=y.rotation;q=y.quaternion;s=y.scale;q=0;I.length==0&&(I[0]=new THREE.MeshFaceMaterial);object=new THREE.Mesh(G,I);object.position.set(l[0],l[1],l[2]);if(q){object.quaternion.set(q[0],q[1],q[2],q[3]);object.useQuaternion=!0}else object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=
-y.visible;F.scene.addObject(object);F.objects[t]=object}}}function k(V){return function(W){F.geometries[V]=W;m();P-=1;j()}}function j(){c({total_models:O,total_textures:R,loaded_models:O-P,loaded_textures:R-N},F);P==0&&N==0&&b(F)}var n,p,t,x,w,u,B,y,l,z,C,G,K,J,I,E,L,S,P,N,O,R,F;E=g.data;L=new THREE.BinaryLoader;S=new THREE.JSONLoader;N=P=0;F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};g=function(){N-=1;j()};for(w in E.cameras){z=E.cameras[w];
-if(z.type=="perspective")K=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho"){K=new THREE.Camera;K.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far)}l=z.position;z=z.target;K.position.set(l[0],l[1],l[2]);K.target.position.set(z[0],z[1],z[2]);F.cameras[w]=K}for(x in E.lights){w=E.lights[x];K=w.color!==undefined?w.color:16777215;z=w.intensity!==undefined?w.intensity:1;if(w.type=="directional"){l=w.direction;light=new THREE.DirectionalLight(K,z);
-light.position.set(l[0],l[1],l[2]);light.position.normalize()}else if(w.type=="point"){l=w.position;light=new THREE.PointLight(K,z);light.position.set(l[0],l[1],l[2])}F.scene.addLight(light);F.lights[x]=light}for(u in E.fogs){x=E.fogs[u];if(x.type=="linear")J=new THREE.Fog(0,x.near,x.far);else x.type=="exp2"&&(J=new THREE.FogExp2(0,x.density));z=x.color;J.color.setRGB(z[0],z[1],z[2]);F.fogs[u]=J}if(F.cameras&&E.defaults.camera)F.currentCamera=F.cameras[E.defaults.camera];if(F.fogs&&E.defaults.fog)F.scene.fog=
+y.visible;F.scene.addObject(object);F.objects[t]=object}}}function k(V){return function(W){F.geometries[V]=W;m();P-=1;j()}}function j(){c({total_models:O,total_textures:R,loaded_models:O-P,loaded_textures:R-N},F);P==0&&N==0&&b(F)}var n,p,t,w,x,u,B,y,l,z,C,G,K,J,I,E,L,S,P,N,O,R,F;E=g.data;L=new THREE.BinaryLoader;S=new THREE.JSONLoader;N=P=0;F={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{}};g=function(){N-=1;j()};for(x in E.cameras){z=E.cameras[x];
+if(z.type=="perspective")K=new THREE.Camera(z.fov,z.aspect,z.near,z.far);else if(z.type=="ortho"){K=new THREE.Camera;K.projectionMatrix=THREE.Matrix4.makeOrtho(z.left,z.right,z.top,z.bottom,z.near,z.far)}l=z.position;z=z.target;K.position.set(l[0],l[1],l[2]);K.target.position.set(z[0],z[1],z[2]);F.cameras[x]=K}for(w in E.lights){x=E.lights[w];K=x.color!==undefined?x.color:16777215;z=x.intensity!==undefined?x.intensity:1;if(x.type=="directional"){l=x.direction;light=new THREE.DirectionalLight(K,z);
+light.position.set(l[0],l[1],l[2]);light.position.normalize()}else if(x.type=="point"){l=x.position;light=new THREE.PointLight(K,z);light.position.set(l[0],l[1],l[2])}F.scene.addLight(light);F.lights[w]=light}for(u in E.fogs){w=E.fogs[u];if(w.type=="linear")J=new THREE.Fog(0,w.near,w.far);else w.type=="exp2"&&(J=new THREE.FogExp2(0,w.density));z=w.color;J.color.setRGB(z[0],z[1],z[2]);F.fogs[u]=J}if(F.cameras&&E.defaults.camera)F.currentCamera=F.cameras[E.defaults.camera];if(F.fogs&&E.defaults.fog)F.scene.fog=
 F.fogs[E.defaults.fog];z=E.defaults.bgcolor;F.bgColor=new THREE.Color;F.bgColor.setRGB(z[0],z[1],z[2]);F.bgColorAlpha=E.defaults.bgalpha;for(n in E.geometries){u=E.geometries[n];if(u.type=="bin_mesh"||u.type=="ascii_mesh")P+=1}O=P;for(n in E.geometries){u=E.geometries[n];if(u.type=="cube"){G=new Cube(u.width,u.height,u.depth,u.segmentsWidth,u.segmentsHeight,u.segmentsDepth,null,u.flipped,u.sides);F.geometries[n]=G}else if(u.type=="plane"){G=new Plane(u.width,u.height,u.segmentsWidth,u.segmentsHeight);
 F.geometries[n]=G}else if(u.type=="sphere"){G=new Sphere(u.radius,u.segmentsWidth,u.segmentsHeight);F.geometries[n]=G}else if(u.type=="cylinder"){G=new Cylinder(u.numSegs,u.topRad,u.botRad,u.height,u.topOffset,u.botOffset);F.geometries[n]=G}else if(u.type=="torus"){G=new Torus(u.radius,u.tube,u.segmentsR,u.segmentsT);F.geometries[n]=G}else if(u.type=="icosahedron"){G=new Icosahedron(u.subdivisions);F.geometries[n]=G}else if(u.type=="bin_mesh")L.load({model:h(u.url,E.urlBaseType),callback:k(n)});else u.type==
 "ascii_mesh"&&S.load({model:h(u.url,E.urlBaseType),callback:k(n)})}for(B in E.textures){n=E.textures[B];N+=n.url instanceof Array?n.url.length:1}R=N;for(B in E.textures){n=E.textures[B];if(n.mapping!=undefined&&THREE[n.mapping]!=undefined)n.mapping=new THREE[n.mapping];if(n.url instanceof Array){u=[];for(var M=0;M<n.url.length;M++)u[M]=h(n.url[M],E.urlBaseType);u=ImageUtils.loadTextureCube(u,n.mapping,g)}else{u=ImageUtils.loadTexture(h(n.url,E.urlBaseType),n.mapping,g);if(THREE[n.minFilter]!=undefined)u.minFilter=
@@ -24,17 +24,18 @@ value:0,texture:null},uImageIncrement:{type:"v2",value:new THREE.Vector2(0.00195
 film:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},time:{type:"f",value:0},nIntensity:{type:"f",value:0.5},sIntensity:{type:"f",value:0.05},sCount:{type:"f",value:4096},grayscale:{type:"i",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float time;\nuniform bool grayscale;\nuniform float nIntensity;\nuniform float sIntensity;\nuniform float sCount;\nvoid main() {\nvec4 cTextureScreen = texture2D( tDiffuse, vUv );\nfloat x = vUv.x * vUv.y * time *  1000.0;\nx = mod( x, 13.0 ) * mod( x, 123.0 );\nfloat dx = mod( x, 0.01 );\nvec3 cResult = cTextureScreen.rgb + cTextureScreen.rgb * clamp( 0.1 + dx * 100.0, 0.0, 1.0 );\nvec2 sc = vec2( sin( vUv.y * sCount ), cos( vUv.y * sCount ) );\ncResult += cTextureScreen.rgb * vec3( sc.x, sc.y, sc.x ) * sIntensity;\ncResult = cTextureScreen.rgb + clamp( nIntensity, 0.0,1.0 ) * ( cResult - cTextureScreen.rgb );\nif( grayscale ) {\ncResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );\n}\ngl_FragColor =  vec4( cResult, cTextureScreen.a );\n}"},
 screen:{uniforms:{tDiffuse:{type:"t",value:0,texture:null},opacity:{type:"f",value:1}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"varying vec2 vUv;\nuniform sampler2D tDiffuse;\nuniform float opacity;\nvoid main() {\nvec4 texel = texture2D( tDiffuse, vUv );\ngl_FragColor = opacity * texel;\n}"},basic:{uniforms:{},vertexShader:"void main() {\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",
 fragmentShader:"void main() {\ngl_FragColor = vec4( 1.0, 0.0, 0.0, 0.5 );\n}"}},buildKernel:function(a){var f,b,c,e,d=2*Math.ceil(a*3)+1;d>25&&(d=25);e=(d-1)*0.5;b=Array(d);for(f=c=0;f<d;++f){b[f]=Math.exp(-((f-e)*(f-e))/(2*a*a));c+=b[f]}for(f=0;f<d;++f)b[f]/=c;return b}};
-THREE.QuakeCamera=function(a){function f(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.noFly!==undefined)this.noFly=
-a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.activeLook!==undefined)this.activeLook=a.activeLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=
-this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=
-!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=
-!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){this.autoSpeedFactor=this.heightSpeed?((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed);
-var b=this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;b=this.target.position;var c=this.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},
-!1);this.domElement.addEventListener("mousemove",f(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",f(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",f(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",f(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",f(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
+THREE.QuakeCamera=function(a){function f(b,c){return function(){c.apply(b,arguments)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=3.14;this.domElement=document;if(a){if(a.movementSpeed!==undefined)this.movementSpeed=a.movementSpeed;if(a.lookSpeed!==undefined)this.lookSpeed=
+a.lookSpeed;if(a.noFly!==undefined)this.noFly=a.noFly;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.autoForward!==undefined)this.autoForward=a.autoForward;if(a.activeLook!==undefined)this.activeLook=a.activeLook;if(a.heightSpeed!==undefined)this.heightSpeed=a.heightSpeed;if(a.heightCoef!==undefined)this.heightCoef=a.heightCoef;if(a.heightMin!==undefined)this.heightMin=a.heightMin;if(a.heightMax!==undefined)this.heightMax=a.heightMax;if(a.constrainVertical!==undefined)this.constrainVertical=
+a.constrainVertical;if(a.verticalMin!==undefined)this.verticalMin=a.verticalMin;if(a.verticalMax!==undefined)this.verticalMax=a.verticalMax;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=0;this.moveForward=!1;this.moveBackward=!1;this.moveLeft=!1;this.moveRight=!1;this.mouseDragOn=!1;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;this.onMouseDown=function(b){b.preventDefault();
+b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(b){b.preventDefault();b.stopPropagation();if(this.activeLook)switch(b.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(b){this.mouseX=b.clientX-this.windowHalfX;this.mouseY=b.clientY-this.windowHalfY};this.onKeyDown=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=
+!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0}};this.onKeyUp=function(b){switch(b.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1}};this.update=function(){this.autoSpeedFactor=this.heightSpeed?((this.position.y<this.heightMin?this.heightMin:this.position.y>this.heightMax?this.heightMax:this.position.y)-
+this.heightMin)*this.heightCoef:0;(this.moveForward||this.autoForward)&&this.translateZ(-(this.movementSpeed+this.autoSpeedFactor));this.moveBackward&&this.translateZ(this.movementSpeed);this.moveLeft&&this.translateX(-this.movementSpeed);this.moveRight&&this.translateX(this.movementSpeed);var b=this.lookSpeed;this.activeLook||(b=0);this.lon+=this.mouseX*b;this.lookVertical&&(this.lat-=this.mouseY*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*
+Math.PI/180;if(this.constrainVertical)this.phi=(this.phi-0)*(this.verticalMax-this.verticalMin)/3.14+this.verticalMin;b=this.target.position;var c=this.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);this.supr.update.call(this)};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",f(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",
+f(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",f(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",f(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",f(this,this.onKeyUp),!1)};THREE.QuakeCamera.prototype=new THREE.Camera;THREE.QuakeCamera.prototype.constructor=THREE.QuakeCamera;THREE.QuakeCamera.prototype.supr=THREE.Camera.prototype;
 THREE.QuakeCamera.prototype.translate=function(a,f){this.matrix.rotateAxis(f);if(this.noFly)f.y=0;this.position.addSelf(f.multiplyScalar(a));this.target.position.addSelf(f.multiplyScalar(a))};
-THREE.PathCamera=function(a){function f(k,j,n,p){var t={name:n,fps:0.6,length:p,hierarchy:[]},x,w=j.getControlPointsArray(),u=j.getLength(),B=w.length,y=0;x=B-1;j={parent:-1,keys:[]};j.keys[0]={time:0,pos:w[0],rot:[0,0,0,1],scl:[1,1,1]};j.keys[x]={time:p,pos:w[x],rot:[0,0,0,1],scl:[1,1,1]};for(x=1;x<B-1;x++){y=p*u.chunks[x]/u.total;j.keys[x]={time:y,pos:w[x]}}t.hierarchy[0]=j;THREE.AnimationHandler.add(t);return new THREE.Animation(k,n,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(k,j){var n,
+THREE.PathCamera=function(a){function f(k,j,n,p){var t={name:n,fps:0.6,length:p,hierarchy:[]},w,x=j.getControlPointsArray(),u=j.getLength(),B=x.length,y=0;w=B-1;j={parent:-1,keys:[]};j.keys[0]={time:0,pos:x[0],rot:[0,0,0,1],scl:[1,1,1]};j.keys[w]={time:p,pos:x[w],rot:[0,0,0,1],scl:[1,1,1]};for(w=1;w<B-1;w++){y=p*u.chunks[w]/u.total;j.keys[w]={time:y,pos:x[w]}}t.hierarchy[0]=j;THREE.AnimationHandler.add(t);return new THREE.Animation(k,n,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function b(k,j){var n,
 p,t=new THREE.Geometry;for(n=0;n<k.points.length*j;n++){p=n/(k.points.length*j);p=k.getPoint(p);t.vertices[n]=new THREE.Vertex(new THREE.Vector3(p.x,p.y,p.z))}return t}function c(k,j){var n=b(j,10),p=b(j,10),t=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(n,t);particleObj=new THREE.ParticleSystem(p,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);k.addChild(lineObj);particleObj.scale.set(1,1,1);k.addChild(particleObj);p=new Sphere(1,
-16,8);t=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<j.points.length;i++){n=new THREE.Mesh(p,t);n.position.copy(j.points[i]);n.updateMatrix();k.addChild(n)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;this.lookVertical=
+16,8);t=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<j.points.length;i++){n=new THREE.Mesh(p,t);n.position.copy(j.points[i]);n.updateMatrix();k.addChild(n)}}THREE.Camera.call(this,a.fov,a.aspect,a.near,a.far,a.target);this.id="PathCamera"+THREE.PathCameraIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookVertical=
 !0;this.lookHorizontal=!0;this.verticalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.horizontalAngleMap={srcRange:[0,6.28],dstRange:[0,6.28]};this.domElement=document;if(a){if(a.duration!==undefined)this.duration=a.duration*1E3;if(a.waypoints!==undefined)this.waypoints=a.waypoints;if(a.useConstantSpeed!==undefined)this.useConstantSpeed=a.useConstantSpeed;if(a.resamplingCoef!==undefined)this.resamplingCoef=a.resamplingCoef;if(a.createDebugPath!==undefined)this.createDebugPath=a.createDebugPath;
 if(a.createDebugDummy!==undefined)this.createDebugDummy=a.createDebugDummy;if(a.lookSpeed!==undefined)this.lookSpeed=a.lookSpeed;if(a.lookVertical!==undefined)this.lookVertical=a.lookVertical;if(a.lookHorizontal!==undefined)this.lookHorizontal=a.lookHorizontal;if(a.verticalAngleMap!==undefined)this.verticalAngleMap=a.verticalAngleMap;if(a.horizontalAngleMap!==undefined)this.horizontalAngleMap=a.horizontalAngleMap;if(a.domElement!==undefined)this.domElement=a.domElement}this.theta=this.phi=this.lon=
 this.lat=this.mouseY=this.mouseX=0;this.windowHalfX=window.innerWidth/2;this.windowHalfY=window.innerHeight/2;var e=Math.PI*2,d=Math.PI/180;this.update=function(k,j,n){var p,t;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*d;this.theta=this.lon*d;p=this.phi%e;this.phi=p>=0?p:p+e;p=this.verticalAngleMap.srcRange;t=this.verticalAngleMap.dstRange;
@@ -42,24 +43,24 @@ this.phi=(this.phi-p[0])*(t[1]-t[0])/(p[1]-p[0])+t[0];p=this.horizontalAngleMap.
 this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){a=new THREE.MeshLambertMaterial({color:30719});var g=new THREE.MeshLambertMaterial({color:65280}),h=new Cube(10,10,20),m=new Cube(2,2,10);this.animationParent=new THREE.Mesh(h,a);a=new THREE.Mesh(m,g);a.position.set(0,10,0);this.animation=f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this);this.animationParent.addChild(this.target);this.animationParent.addChild(a)}else{this.animation=
 f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.addChild(this.target);this.animationParent.addChild(this)}this.createDebugPath&&c(this.debugPath,this.spline);this.domElement.addEventListener("mousemove",function(k,j){return function(){j.apply(k,arguments)}}(this,this.onMouseMove),!1)};THREE.PathCamera.prototype=new THREE.Camera;THREE.PathCamera.prototype.constructor=THREE.PathCamera;THREE.PathCamera.prototype.supr=THREE.Camera.prototype;THREE.PathCameraIdCounter=0;
 var Cube=function(a,f,b,c,e,d,g,h,m){function k(u,B,y,l,z,C,G,K){var J,I,E=c||1,L=e||1,S=z/2,P=C/2,N=j.vertices.length;if(u=="x"&&B=="y"||u=="y"&&B=="x")J="z";else if(u=="x"&&B=="z"||u=="z"&&B=="x"){J="y";L=d||1}else if(u=="z"&&B=="y"||u=="y"&&B=="z"){J="x";E=d||1}var O=E+1,R=L+1;z/=E;var F=C/L;for(I=0;I<R;I++)for(C=0;C<O;C++){var M=new THREE.Vector3;M[u]=(C*z-S)*y;M[B]=(I*F-P)*l;M[J]=G;j.vertices.push(new THREE.Vertex(M))}for(I=0;I<L;I++)for(C=0;C<E;C++){j.faces.push(new THREE.Face4(C+O*I+N,C+O*
-(I+1)+N,C+1+O*(I+1)+N,C+1+O*I+N,null,null,K));j.faceVertexUvs[0].push([new THREE.UV(C/E,I/L),new THREE.UV(C/E,(I+1)/L),new THREE.UV((C+1)/E,(I+1)/L),new THREE.UV((C+1)/E,I/L)])}}THREE.Geometry.call(this);var j=this,n=a/2,p=f/2,t=b/2;h=h?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var x=0;x<6;x++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(m!=undefined)for(var w in m)this.sides[w]!=undefined&&(this.sides[w]=
-m[w]);this.sides.px&&k("z","y",1*h,-1,b,f,-n,this.materials[0]);this.sides.nx&&k("z","y",-1*h,-1,b,f,n,this.materials[1]);this.sides.py&&k("x","z",1*h,1,a,b,p,this.materials[2]);this.sides.ny&&k("x","z",1*h,-1,a,b,-p,this.materials[3]);this.sides.pz&&k("x","y",1*h,-1,a,f,t,this.materials[4]);this.sides.nz&&k("x","y",-1*h,-1,a,f,-t,this.materials[5]);(function(){for(var u=[],B=[],y=0,l=j.vertices.length;y<l;y++){for(var z=j.vertices[y],C=!1,G=0,K=u.length;G<K;G++){var J=u[G];if(z.position.x==J.position.x&&
+(I+1)+N,C+1+O*(I+1)+N,C+1+O*I+N,null,null,K));j.faceVertexUvs[0].push([new THREE.UV(C/E,I/L),new THREE.UV(C/E,(I+1)/L),new THREE.UV((C+1)/E,(I+1)/L),new THREE.UV((C+1)/E,I/L)])}}THREE.Geometry.call(this);var j=this,n=a/2,p=f/2,t=b/2;h=h?-1:1;if(g!==undefined)if(g instanceof Array)this.materials=g;else{this.materials=[];for(var w=0;w<6;w++)this.materials.push([g])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(m!=undefined)for(var x in m)this.sides[x]!=undefined&&(this.sides[x]=
+m[x]);this.sides.px&&k("z","y",1*h,-1,b,f,-n,this.materials[0]);this.sides.nx&&k("z","y",-1*h,-1,b,f,n,this.materials[1]);this.sides.py&&k("x","z",1*h,1,a,b,p,this.materials[2]);this.sides.ny&&k("x","z",1*h,-1,a,b,-p,this.materials[3]);this.sides.pz&&k("x","y",1*h,-1,a,f,t,this.materials[4]);this.sides.nz&&k("x","y",-1*h,-1,a,f,-t,this.materials[5]);(function(){for(var u=[],B=[],y=0,l=j.vertices.length;y<l;y++){for(var z=j.vertices[y],C=!1,G=0,K=u.length;G<K;G++){var J=u[G];if(z.position.x==J.position.x&&
 z.position.y==J.position.y&&z.position.z==J.position.z){B[y]=G;C=!0;break}}if(!C){B[y]=u.length;u.push(new THREE.Vertex(z.position.clone()))}}y=0;for(l=j.faces.length;y<l;y++){z=j.faces[y];z.a=B[z.a];z.b=B[z.b];z.c=B[z.c];z.d=B[z.d]}j.vertices=u})();this.computeCentroids();this.computeFaceNormals()};Cube.prototype=new THREE.Geometry;Cube.prototype.constructor=Cube;
 var Cylinder=function(a,f,b,c,e,d){function g(j,n,p){h.vertices.push(new THREE.Vertex(new THREE.Vector3(j,n,p)))}THREE.Geometry.call(this);var h=this,m=Math.PI,k=c/2;for(c=0;c<a;c++)g(Math.sin(2*m*c/a)*f,Math.cos(2*m*c/a)*f,-k);for(c=0;c<a;c++)g(Math.sin(2*m*c/a)*b,Math.cos(2*m*c/a)*b,k);for(c=0;c<a;c++)h.faces.push(new THREE.Face4(c,c+a,a+(c+1)%a,(c+1)%a));if(b>0){g(0,0,-k-(d||0));for(c=a;c<a+a/2;c++)h.faces.push(new THREE.Face4(2*a,(2*c-2*a)%a,(2*c-2*a+1)%a,(2*c-2*a+2)%a))}if(f>0){g(0,0,k+(e||0));
 for(c=a+a/2;c<2*a;c++)h.faces.push(new THREE.Face4(2*a+1,(2*c-2*a+2)%a+a,(2*c-2*a+1)%a+a,(2*c-2*a)%a+a))}this.computeCentroids();this.computeFaceNormals()};Cylinder.prototype=new THREE.Geometry;Cylinder.prototype.constructor=Cylinder;
-var Icosahedron=function(a){function f(n,p,t){var x=Math.sqrt(n*n+p*p+t*t);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(n/x,p/x,t/x)))-1}function b(n,p,t,x){x.faces.push(new THREE.Face3(n,p,t))}function c(n,p){var t=e.vertices[n].position,x=e.vertices[p].position;return f((t.x+x.x)/2,(t.y+x.y)/2,(t.z+x.z)/2)}var e=this,d=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;f(-1,a,0);f(1,a,0);f(-1,-a,0);f(1,-a,0);f(0,-1,a);f(0,1,a);f(0,-1,-a);f(0,
+var Icosahedron=function(a){function f(n,p,t){var w=Math.sqrt(n*n+p*p+t*t);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(n/w,p/w,t/w)))-1}function b(n,p,t,w){w.faces.push(new THREE.Face3(n,p,t))}function c(n,p){var t=e.vertices[n].position,w=e.vertices[p].position;return f((t.x+w.x)/2,(t.y+w.y)/2,(t.z+w.z)/2)}var e=this,d=new THREE.Geometry,g;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;f(-1,a,0);f(1,a,0);f(-1,-a,0);f(1,-a,0);f(0,-1,a);f(0,1,a);f(0,-1,-a);f(0,
 1,-a);f(a,0,-1);f(a,0,1);f(-a,0,-1);f(-a,0,1);b(0,11,5,d);b(0,5,1,d);b(0,1,7,d);b(0,7,10,d);b(0,10,11,d);b(1,5,9,d);b(5,11,4,d);b(11,10,2,d);b(10,7,6,d);b(7,1,8,d);b(3,9,4,d);b(3,4,2,d);b(3,2,6,d);b(3,6,8,d);b(3,8,9,d);b(4,9,5,d);b(2,4,11,d);b(6,2,10,d);b(8,6,7,d);b(9,8,1,d);for(a=0;a<this.subdivisions;a++){g=new THREE.Geometry;for(var h in d.faces){var m=c(d.faces[h].a,d.faces[h].b),k=c(d.faces[h].b,d.faces[h].c),j=c(d.faces[h].c,d.faces[h].a);b(d.faces[h].a,m,j,g);b(d.faces[h].b,k,m,g);b(d.faces[h].c,
 j,k,g);b(m,k,j,g)}d.faces=g.faces}e.faces=d.faces;delete d;delete g;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Icosahedron.prototype=new THREE.Geometry;Icosahedron.prototype.constructor=Icosahedron;
-function Lathe(a,f,b){THREE.Geometry.call(this);this.steps=f||12;this.angle=b||2*Math.PI;f=this.angle/this.steps;for(var c=[],e=[],d=[],g=[],h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));c[h]=a[h].clone();e[h]=this.vertices.length-1}for(var m=(new THREE.Matrix4).setRotationZ(f),k=0;k<=this.angle+0.001;k+=f){for(h=0;h<c.length;h++)if(k<this.angle){c[h]=m.multiplyVector3(c[h].clone());this.vertices.push(new THREE.Vertex(c[h]));d[h]=this.vertices.length-1}else d=g;k==0&&(g=e);for(h=
+function Lathe(a,f,b){THREE.Geometry.call(this);this.steps=f||12;this.angle=b||2*Math.PI;f=this.angle/this.steps;for(var c=[],e=[],d=[],g=[],h=0;h<a.length;h++){this.vertices.push(new THREE.Vertex(a[h]));c[h]=a[h].clone();e[h]=this.vertices.length-1}for(var m=(new THREE.Matrix4).setRotationZ(f),k=0;k<=this.angle+0.0010;k+=f){for(h=0;h<c.length;h++)if(k<this.angle){c[h]=m.multiplyVector3(c[h].clone());this.vertices.push(new THREE.Vertex(c[h]));d[h]=this.vertices.length-1}else d=g;k==0&&(g=e);for(h=
 0;h<e.length-1;h++){this.faces.push(new THREE.Face4(d[h],d[h+1],e[h+1],e[h]));this.faceVertexUvs[0].push([new THREE.UV(k/b,h/a.length),new THREE.UV(k/b,(h+1)/a.length),new THREE.UV((k-f)/b,(h+1)/a.length),new THREE.UV((k-f)/b,h/a.length)])}e=d;d=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()}Lathe.prototype=new THREE.Geometry;Lathe.prototype.constructor=Lathe;
 var Plane=function(a,f,b,c){THREE.Geometry.call(this);var e,d=a/2,g=f/2;b=b||1;c=c||1;var h=b+1,m=c+1;a/=b;var k=f/c;for(e=0;e<m;e++)for(f=0;f<h;f++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(f*a-d,-(e*k-g),0)));for(e=0;e<c;e++)for(f=0;f<b;f++){this.faces.push(new THREE.Face4(f+h*e,f+h*(e+1),f+1+h*(e+1),f+1+h*e));this.faceVertexUvs[0].push([new THREE.UV(f/b,e/c),new THREE.UV(f/b,(e+1)/c),new THREE.UV((f+1)/b,(e+1)/c),new THREE.UV((f+1)/b,e/c)])}this.computeCentroids();this.computeFaceNormals()};
 Plane.prototype=new THREE.Geometry;Plane.prototype.constructor=Plane;
-var Sphere=function(a,f,b){THREE.Geometry.call(this);var c,e=Math.PI,d=Math.max(3,f||8),g=Math.max(2,b||6);f=[];for(b=0;b<g+1;b++){c=b/g;var h=a*Math.cos(c*e),m=a*Math.sin(c*e),k=[],j=0;for(c=0;c<d;c++){var n=2*c/d,p=m*Math.sin(n*e);n=m*Math.cos(n*e);(b==0||b==g)&&c>0||(j=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,h,p)))-1);k.push(j)}f.push(k)}var t,x,w;e=f.length;for(b=0;b<e;b++){d=f[b].length;if(b>0)for(c=0;c<d;c++){k=c==d-1;g=f[b][k?0:c+1];h=f[b][k?d-1:c];m=f[b-1][k?d-1:c];k=f[b-1][k?
-0:c+1];p=b/(e-1);t=(b-1)/(e-1);x=(c+1)/d;n=c/d;j=new THREE.UV(1-x,p);p=new THREE.UV(1-n,p);n=new THREE.UV(1-n,t);var u=new THREE.UV(1-x,t);if(b<f.length-1){t=this.vertices[g].position.clone();x=this.vertices[h].position.clone();w=this.vertices[m].position.clone();t.normalize();x.normalize();w.normalize();this.faces.push(new THREE.Face3(g,h,m,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(w.x,w.y,w.z)]));this.faceVertexUvs[0].push([j,p,n])}if(b>1){t=this.vertices[g].position.clone();
-x=this.vertices[m].position.clone();w=this.vertices[k].position.clone();t.normalize();x.normalize();w.normalize();this.faces.push(new THREE.Face3(g,m,k,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(x.x,x.y,x.z),new THREE.Vector3(w.x,w.y,w.z)]));this.faceVertexUvs[0].push([j,n,u])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
+var Sphere=function(a,f,b){THREE.Geometry.call(this);var c,e=Math.PI,d=Math.max(3,f||8),g=Math.max(2,b||6);f=[];for(b=0;b<g+1;b++){c=b/g;var h=a*Math.cos(c*e),m=a*Math.sin(c*e),k=[],j=0;for(c=0;c<d;c++){var n=2*c/d,p=m*Math.sin(n*e);n=m*Math.cos(n*e);(b==0||b==g)&&c>0||(j=this.vertices.push(new THREE.Vertex(new THREE.Vector3(n,h,p)))-1);k.push(j)}f.push(k)}var t,w,x;e=f.length;for(b=0;b<e;b++){d=f[b].length;if(b>0)for(c=0;c<d;c++){k=c==d-1;g=f[b][k?0:c+1];h=f[b][k?d-1:c];m=f[b-1][k?d-1:c];k=f[b-1][k?
+0:c+1];p=b/(e-1);t=(b-1)/(e-1);w=(c+1)/d;n=c/d;j=new THREE.UV(1-w,p);p=new THREE.UV(1-n,p);n=new THREE.UV(1-n,t);var u=new THREE.UV(1-w,t);if(b<f.length-1){t=this.vertices[g].position.clone();w=this.vertices[h].position.clone();x=this.vertices[m].position.clone();t.normalize();w.normalize();x.normalize();this.faces.push(new THREE.Face3(g,h,m,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(x.x,x.y,x.z)]));this.faceVertexUvs[0].push([j,p,n])}if(b>1){t=this.vertices[g].position.clone();
+w=this.vertices[m].position.clone();x=this.vertices[k].position.clone();t.normalize();w.normalize();x.normalize();this.faces.push(new THREE.Face3(g,m,k,[new THREE.Vector3(t.x,t.y,t.z),new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(x.x,x.y,x.z)]));this.faceVertexUvs[0].push([j,n,u])}}}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:a}};Sphere.prototype=new THREE.Geometry;Sphere.prototype.constructor=Sphere;
 var Torus=function(a,f,b,c){this.radius=a||100;this.tube=f||40;this.segmentsR=b||8;this.segmentsT=c||6;a=[];THREE.Geometry.call(this);for(f=0;f<=this.segmentsR;++f)for(b=0;b<=this.segmentsT;++b){c=b/this.segmentsT*2*Math.PI;var e=f/this.segmentsR*2*Math.PI;this.vertices.push(new THREE.Vertex(new THREE.Vector3((this.radius+this.tube*Math.cos(e))*Math.cos(c),(this.radius+this.tube*Math.cos(e))*Math.sin(c),this.tube*Math.sin(e))));a.push([b/this.segmentsT,1-f/this.segmentsR])}for(f=1;f<=this.segmentsR;++f)for(b=
 1;b<=this.segmentsT;++b){c=(this.segmentsT+1)*f+b;e=(this.segmentsT+1)*f+b-1;var d=(this.segmentsT+1)*(f-1)+b-1,g=(this.segmentsT+1)*(f-1)+b;this.faces.push(new THREE.Face4(c,e,d,g));this.faceVertexUvs[0].push([new THREE.UV(a[c][0],a[c][1]),new THREE.UV(a[e][0],a[e][1]),new THREE.UV(a[d][0],a[d][1]),new THREE.UV(a[g][0],a[g][1])])}delete a;this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};Torus.prototype=new THREE.Geometry;Torus.prototype.constructor=Torus;
-var TorusKnot=function(a,f,b,c,e,d,g){function h(n,p,t,x,w,u){p=t/x*n;t=Math.cos(p);return new THREE.Vector3(w*(2+t)*0.5*Math.cos(n),w*(2+t)*Math.sin(n)*0.5,u*w*Math.sin(p)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=f||40;this.segmentsR=b||64;this.segmentsT=c||8;this.p=e||2;this.q=d||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;c=new THREE.Vector3;d=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(f=0;f<this.segmentsT;++f){var m=
+var TorusKnot=function(a,f,b,c,e,d,g){function h(n,p,t,w,x,u){p=t/w*n;t=Math.cos(p);return new THREE.Vector3(x*(2+t)*0.5*Math.cos(n),x*(2+t)*Math.sin(n)*0.5,u*x*Math.sin(p)*0.5)}THREE.Geometry.call(this);this.radius=a||200;this.tube=f||40;this.segmentsR=b||64;this.segmentsT=c||8;this.p=e||2;this.q=d||3;this.heightScale=g||1;this.grid=Array(this.segmentsR);b=new THREE.Vector3;c=new THREE.Vector3;d=new THREE.Vector3;for(a=0;a<this.segmentsR;++a){this.grid[a]=Array(this.segmentsT);for(f=0;f<this.segmentsT;++f){var m=
 a/this.segmentsR*2*this.p*Math.PI;g=f/this.segmentsT*2*Math.PI;e=h(m,g,this.q,this.p,this.radius,this.heightScale);m=h(m+0.01,g,this.q,this.p,this.radius,this.heightScale);b.x=m.x-e.x;b.y=m.y-e.y;b.z=m.z-e.z;c.x=m.x+e.x;c.y=m.y+e.y;c.z=m.z+e.z;d.cross(b,c);c.cross(d,b);d.normalize();c.normalize();m=this.tube*Math.cos(g);g=this.tube*Math.sin(g);e.x+=m*c.x+g*d.x;e.y+=m*c.y+g*d.y;e.z+=m*c.z+g*d.z;this.grid[a][f]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(e.x,e.y,e.z)))-1}}for(a=0;a<this.segmentsR;++a)for(f=
 0;f<this.segmentsT;++f){d=(a+1)%this.segmentsR;g=(f+1)%this.segmentsT;e=this.grid[a][f];b=this.grid[d][f];c=this.grid[a][g];d=this.grid[d][g];g=new THREE.UV(a/this.segmentsR,f/this.segmentsT);m=new THREE.UV((a+1)/this.segmentsR,f/this.segmentsT);var k=new THREE.UV(a/this.segmentsR,(f+1)/this.segmentsT),j=new THREE.UV((a+1)/this.segmentsR,(f+1)/this.segmentsT);this.faces.push(new THREE.Face3(e,b,c));this.faceVertexUvs[0].push([g,m,k]);this.faces.push(new THREE.Face3(d,c,b));this.faceVertexUvs[0].push([j,
 k,m])}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};TorusKnot.prototype=new THREE.Geometry;TorusKnot.prototype.constructor=TorusKnot;THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
@@ -69,37 +70,37 @@ Math.LN2));h.image.width=j;h.image.height=n;h.image.getContext("2d").drawImage(t
 THREE.SubtractiveBlending;else if(a.blending=="Multiply")d.blending=THREE.MultiplyBlending;if(a.transparent!==undefined)d.transparent=a.transparent;if(a.depthTest!==undefined)d.depthTest=a.depthTest;if(a.mapDiffuse&&f){g=document.createElement("canvas");d.map=new THREE.Texture(g);d.map.sourceFile=a.mapDiffuse;c(d.map,f+"/"+a.mapDiffuse)}else if(a.colorDiffuse){g=(a.colorDiffuse[0]*255<<16)+(a.colorDiffuse[1]*255<<8)+a.colorDiffuse[2]*255;d.color=g;d.opacity=a.transparency}else if(a.DbgColor)d.color=
 a.DbgColor;if(a.mapLightmap&&f){g=document.createElement("canvas");d.lightMap=new THREE.Texture(g);d.lightMap.sourceFile=a.mapLightmap;c(d.lightMap,f+"/"+a.mapLightmap)}return new THREE[e](d)}};THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
 THREE.JSONLoader.prototype.load=function(a){var f=this,b=a.model,c=a.callback,e=a.texture_path?a.texture_path:this.extractUrlbase(b);a=new Worker(b);a.onmessage=function(d){f.createModel(d.data,c,e);f.onLoadComplete()};this.onLoadStart();a.postMessage((new Date).getTime())};
-THREE.JSONLoader.prototype.createModel=function(a,f,b){var c=new THREE.Geometry;this.init_materials(c,a.materials,b);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var e,d,g,h,m,k,j,n,p,t,x,w,u,B,y,l=a.faces;k=a.vertices;var z=a.normals,C=a.colors,G=0;for(e=0;e<a.uvs.length;e++)a.uvs[e].length&&G++;for(e=0;e<G;e++){c.faceUvs[e]=[];c.faceVertexUvs[e]=[]}h=0;for(m=k.length;h<m;){j=new THREE.Vertex;j.position.x=k[h++];j.position.y=k[h++];j.position.z=
-k[h++];c.vertices.push(j)}h=0;for(m=l.length;h<m;){t=l[h++];k=t&1;g=t&2;e=t&4;d=t&8;n=t&16;j=t&32;x=t&64;t&=128;if(k){w=new THREE.Face4;w.a=l[h++];w.b=l[h++];w.c=l[h++];w.d=l[h++];k=4}else{w=new THREE.Face3;w.a=l[h++];w.b=l[h++];w.c=l[h++];k=3}if(g){g=l[h++];w.materials=c.materials[g]}g=c.faces.length;if(e)for(e=0;e<G;e++){u=a.uvs[e];p=l[h++];y=u[p*2];p=u[p*2+1];c.faceUvs[e][g]=new THREE.UV(y,p)}if(d)for(e=0;e<G;e++){u=a.uvs[e];B=[];for(d=0;d<k;d++){p=l[h++];y=u[p*2];p=u[p*2+1];B[d]=new THREE.UV(y,
-p)}c.faceVertexUvs[e][g]=B}if(n){n=l[h++]*3;d=new THREE.Vector3;d.x=z[n++];d.y=z[n++];d.z=z[n];w.normal=d}if(j)for(e=0;e<k;e++){n=l[h++]*3;d=new THREE.Vector3;d.x=z[n++];d.y=z[n++];d.z=z[n];w.vertexNormals.push(d)}if(x){j=new THREE.Color(l[h++]);w.color=j}if(t)for(e=0;e<k;e++){j=l[h++];j=new THREE.Color(C[j]);w.vertexColors.push(j)}c.faces.push(w)}}})();(function(){var e,d,g,h;if(a.skinWeights){e=0;for(d=a.skinWeights.length;e<d;e+=2){g=a.skinWeights[e];h=a.skinWeights[e+1];c.skinWeights.push(new THREE.Vector4(g,
-h,0,0))}}if(a.skinIndices){e=0;for(d=a.skinIndices.length;e<d;e+=2){g=a.skinIndices[e];h=a.skinIndices[e+1];c.skinIndices.push(new THREE.Vector4(g,h,0,0))}}c.bones=a.bones;c.animation=a.animation})();(function(){if(a.morphTargets!==undefined){var e,d,g,h;e=0;for(d=a.morphTargets.length;e<d;e++){c.morphTargets[e]={};c.morphTargets[e].name=a.morphTargets[e].name;c.morphTargets[e].vertices=[];dstVertices=c.morphTargets[e].vertices;srcVertices=a.morphTargets[e].vertices;g=0;for(h=srcVertices.length;g<
-h;g+=3)dstVertices.push(new THREE.Vertex(new THREE.Vector3(srcVertices[g],srcVertices[g+1],srcVertices[g+2])))}}})();c.computeCentroids();c.computeFaceNormals();f(c)};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
+THREE.JSONLoader.prototype.createModel=function(a,f,b){var c=new THREE.Geometry;this.init_materials(c,a.materials,b);(function(){if(a.version===undefined||a.version!=2)console.error("Deprecated file format.");else{var e,d,g,h,m,k,j,n,p,t,w,x,u,B,y,l=a.faces;k=a.vertices;var z=a.normals,C=a.colors;j=a.scale!==undefined?a.scale:1;var G=0;for(e=0;e<a.uvs.length;e++)a.uvs[e].length&&G++;for(e=0;e<G;e++){c.faceUvs[e]=[];c.faceVertexUvs[e]=[]}h=0;for(m=k.length;h<m;){w=new THREE.Vertex;w.position.x=k[h++]/
+j;w.position.y=k[h++]/j;w.position.z=k[h++]/j;c.vertices.push(w)}h=0;for(m=l.length;h<m;){t=l[h++];k=t&1;g=t&2;e=t&4;d=t&8;n=t&16;j=t&32;w=t&64;t&=128;if(k){x=new THREE.Face4;x.a=l[h++];x.b=l[h++];x.c=l[h++];x.d=l[h++];k=4}else{x=new THREE.Face3;x.a=l[h++];x.b=l[h++];x.c=l[h++];k=3}if(g){g=l[h++];x.materials=c.materials[g]}g=c.faces.length;if(e)for(e=0;e<G;e++){u=a.uvs[e];p=l[h++];y=u[p*2];p=u[p*2+1];c.faceUvs[e][g]=new THREE.UV(y,p)}if(d)for(e=0;e<G;e++){u=a.uvs[e];B=[];for(d=0;d<k;d++){p=l[h++];
+y=u[p*2];p=u[p*2+1];B[d]=new THREE.UV(y,p)}c.faceVertexUvs[e][g]=B}if(n){n=l[h++]*3;d=new THREE.Vector3;d.x=z[n++];d.y=z[n++];d.z=z[n];x.normal=d}if(j)for(e=0;e<k;e++){n=l[h++]*3;d=new THREE.Vector3;d.x=z[n++];d.y=z[n++];d.z=z[n];x.vertexNormals.push(d)}if(w){j=new THREE.Color(l[h++]);x.color=j}if(t)for(e=0;e<k;e++){j=l[h++];j=new THREE.Color(C[j]);x.vertexColors.push(j)}c.faces.push(x)}}})();(function(){var e,d,g,h;if(a.skinWeights){e=0;for(d=a.skinWeights.length;e<d;e+=2){g=a.skinWeights[e];h=a.skinWeights[e+
+1];c.skinWeights.push(new THREE.Vector4(g,h,0,0))}}if(a.skinIndices){e=0;for(d=a.skinIndices.length;e<d;e+=2){g=a.skinIndices[e];h=a.skinIndices[e+1];c.skinIndices.push(new THREE.Vector4(g,h,0,0))}}c.bones=a.bones;c.animation=a.animation})();(function(){if(a.morphTargets!==undefined){var e,d,g,h;e=0;for(d=a.morphTargets.length;e<d;e++){c.morphTargets[e]={};c.morphTargets[e].name=a.morphTargets[e].name;c.morphTargets[e].vertices=[];dstVertices=c.morphTargets[e].vertices;srcVertices=a.morphTargets[e].vertices;
+g=0;for(h=srcVertices.length;g<h;g+=3)dstVertices.push(new THREE.Vertex(new THREE.Vector3(srcVertices[g],srcVertices[g+1],srcVertices[g+2])))}}})();c.computeCentroids();c.computeFaceNormals();f(c)};THREE.BinaryLoader=function(a){THREE.Loader.call(this,a)};THREE.BinaryLoader.prototype=new THREE.Loader;THREE.BinaryLoader.prototype.constructor=THREE.BinaryLoader;THREE.BinaryLoader.prototype.supr=THREE.Loader.prototype;
 THREE.BinaryLoader.prototype={load:function(a){var f=a.model,b=a.callback,c=a.texture_path?a.texture_path:THREE.Loader.prototype.extractUrlbase(f),e=a.bin_path?a.bin_path:THREE.Loader.prototype.extractUrlbase(f);a=(new Date).getTime();f=new Worker(f);var d=this.showProgress?THREE.Loader.prototype.updateProgress:null;f.onmessage=function(g){THREE.BinaryLoader.prototype.loadAjaxBuffers(g.data.buffers,g.data.materials,b,e,c,d)};f.onerror=function(g){alert("worker.onerror: "+g.message+"\n"+g.data);g.preventDefault()};
 f.postMessage(a)},loadAjaxBuffers:function(a,f,b,c,e,d){var g=new XMLHttpRequest,h=c+"/"+a,m=0;g.onreadystatechange=function(){if(g.readyState==4)g.status==200||g.status==0?THREE.BinaryLoader.prototype.createBinModel(g.responseText,b,e,f):alert("Couldn't load ["+h+"] ["+g.status+"]");else if(g.readyState==3){if(d){m==0&&(m=g.getResponseHeader("Content-Length"));d({total:m,loaded:g.responseText.length})}}else g.readyState==2&&(m=g.getResponseHeader("Content-Length"))};g.open("GET",h,!0);g.overrideMimeType("text/plain; charset=x-user-defined");
 g.setRequestHeader("Content-Type","text/plain");g.send(null)},createBinModel:function(a,f,b,c){var e=function(d){function g(o,v){var A=j(o,v),D=j(o,v+1),H=j(o,v+2),Q=j(o,v+3),T=(Q<<1&255|H>>7)-127;A|=(H&127)<<16|D<<8;if(A==0&&T==-127)return 0;return(1-2*(Q>>7))*(1+A*Math.pow(2,-23))*Math.pow(2,T)}function h(o,v){var A=j(o,v),D=j(o,v+1),H=j(o,v+2);return(j(o,v+3)<<24)+(H<<16)+(D<<8)+A}function m(o,v){var A=j(o,v);return(j(o,v+1)<<8)+A}function k(o,v){var A=j(o,v);return A>127?A-256:A}function j(o,
-v){return o.charCodeAt(v)&255}function n(o){var v,A,D;v=h(a,o);A=h(a,o+G);D=h(a,o+K);o=m(a,o+J);THREE.BinaryLoader.prototype.f3(B,v,A,D,o)}function p(o){var v,A,D,H,Q,T;v=h(a,o);A=h(a,o+G);D=h(a,o+K);H=m(a,o+J);Q=h(a,o+I);T=h(a,o+E);o=h(a,o+L);THREE.BinaryLoader.prototype.f3n(B,z,v,A,D,H,Q,T,o)}function t(o){var v,A,D,H;v=h(a,o);A=h(a,o+S);D=h(a,o+P);H=h(a,o+N);o=m(a,o+O);THREE.BinaryLoader.prototype.f4(B,v,A,D,H,o)}function x(o){var v,A,D,H,Q,T,ba,ca;v=h(a,o);A=h(a,o+S);D=h(a,o+P);H=h(a,o+N);Q=m(a,
-o+O);T=h(a,o+R);ba=h(a,o+F);ca=h(a,o+M);o=h(a,o+V);THREE.BinaryLoader.prototype.f4n(B,z,v,A,D,H,Q,T,ba,ca,o)}function w(o){var v,A;v=h(a,o);A=h(a,o+W);o=h(a,o+da);THREE.BinaryLoader.prototype.uv3(B.faceVertexUvs[0],C[v*2],C[v*2+1],C[A*2],C[A*2+1],C[o*2],C[o*2+1])}function u(o){var v,A,D;v=h(a,o);A=h(a,o+ea);D=h(a,o+fa);o=h(a,o+ga);THREE.BinaryLoader.prototype.uv4(B.faceVertexUvs[0],C[v*2],C[v*2+1],C[A*2],C[A*2+1],C[D*2],C[D*2+1],C[o*2],C[o*2+1])}var B=this,y=0,l,z=[],C=[],G,K,J,I,E,L,S,P,N,O,R,F,
+v){return o.charCodeAt(v)&255}function n(o){var v,A,D;v=h(a,o);A=h(a,o+G);D=h(a,o+K);o=m(a,o+J);THREE.BinaryLoader.prototype.f3(B,v,A,D,o)}function p(o){var v,A,D,H,Q,T;v=h(a,o);A=h(a,o+G);D=h(a,o+K);H=m(a,o+J);Q=h(a,o+I);T=h(a,o+E);o=h(a,o+L);THREE.BinaryLoader.prototype.f3n(B,z,v,A,D,H,Q,T,o)}function t(o){var v,A,D,H;v=h(a,o);A=h(a,o+S);D=h(a,o+P);H=h(a,o+N);o=m(a,o+O);THREE.BinaryLoader.prototype.f4(B,v,A,D,H,o)}function w(o){var v,A,D,H,Q,T,ba,ca;v=h(a,o);A=h(a,o+S);D=h(a,o+P);H=h(a,o+N);Q=m(a,
+o+O);T=h(a,o+R);ba=h(a,o+F);ca=h(a,o+M);o=h(a,o+V);THREE.BinaryLoader.prototype.f4n(B,z,v,A,D,H,Q,T,ba,ca,o)}function x(o){var v,A;v=h(a,o);A=h(a,o+W);o=h(a,o+da);THREE.BinaryLoader.prototype.uv3(B.faceVertexUvs[0],C[v*2],C[v*2+1],C[A*2],C[A*2+1],C[o*2],C[o*2+1])}function u(o){var v,A,D;v=h(a,o);A=h(a,o+ea);D=h(a,o+fa);o=h(a,o+ga);THREE.BinaryLoader.prototype.uv4(B.faceVertexUvs[0],C[v*2],C[v*2+1],C[A*2],C[A*2+1],C[D*2],C[D*2+1],C[o*2],C[o*2+1])}var B=this,y=0,l,z=[],C=[],G,K,J,I,E,L,S,P,N,O,R,F,
 M,V,W,da,ea,fa,ga,X,Y,Z,$,aa,U;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(B,c,d);l={signature:a.substr(y,8),header_bytes:j(a,y+8),vertex_coordinate_bytes:j(a,y+9),normal_coordinate_bytes:j(a,y+10),uv_coordinate_bytes:j(a,y+11),vertex_index_bytes:j(a,y+12),normal_index_bytes:j(a,y+13),uv_index_bytes:j(a,y+14),material_index_bytes:j(a,y+15),nvertices:h(a,y+16),nnormals:h(a,y+16+4),nuvs:h(a,y+16+8),ntri_flat:h(a,y+16+12),ntri_smooth:h(a,y+16+16),ntri_flat_uv:h(a,y+16+20),ntri_smooth_uv:h(a,
 y+16+24),nquad_flat:h(a,y+16+28),nquad_smooth:h(a,y+16+32),nquad_flat_uv:h(a,y+16+36),nquad_smooth_uv:h(a,y+16+40)};y+=l.header_bytes;G=l.vertex_index_bytes;K=l.vertex_index_bytes*2;J=l.vertex_index_bytes*3;I=l.vertex_index_bytes*3+l.material_index_bytes;E=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes;L=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*2;S=l.vertex_index_bytes;P=l.vertex_index_bytes*2;N=l.vertex_index_bytes*3;O=l.vertex_index_bytes*4;R=l.vertex_index_bytes*
 4+l.material_index_bytes;F=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes;M=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*2;V=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*3;W=l.uv_index_bytes;da=l.uv_index_bytes*2;ea=l.uv_index_bytes;fa=l.uv_index_bytes*2;ga=l.uv_index_bytes*3;d=l.vertex_index_bytes*3+l.material_index_bytes;U=l.vertex_index_bytes*4+l.material_index_bytes;X=l.ntri_flat*d;Y=l.ntri_smooth*(d+l.normal_index_bytes*3);Z=l.ntri_flat_uv*
 (d+l.uv_index_bytes*3);$=l.ntri_smooth_uv*(d+l.normal_index_bytes*3+l.uv_index_bytes*3);aa=l.nquad_flat*U;d=l.nquad_smooth*(U+l.normal_index_bytes*4);U=l.nquad_flat_uv*(U+l.uv_index_bytes*4);y+=function(o){for(var v,A,D,H=l.vertex_coordinate_bytes*3,Q=o+l.nvertices*H;o<Q;o+=H){v=g(a,o);A=g(a,o+l.vertex_coordinate_bytes);D=g(a,o+l.vertex_coordinate_bytes*2);THREE.BinaryLoader.prototype.v(B,v,A,D)}return l.nvertices*H}(y);y+=function(o){for(var v,A,D,H=l.normal_coordinate_bytes*3,Q=o+l.nnormals*H;o<
-Q;o+=H){v=k(a,o);A=k(a,o+l.normal_coordinate_bytes);D=k(a,o+l.normal_coordinate_bytes*2);z.push(v/127,A/127,D/127)}return l.nnormals*H}(y);y+=function(o){for(var v,A,D=l.uv_coordinate_bytes*2,H=o+l.nuvs*D;o<H;o+=D){v=g(a,o);A=g(a,o+l.uv_coordinate_bytes);C.push(v,A)}return l.nuvs*D}(y);X=y+X;Y=X+Y;Z=Y+Z;$=Z+$;aa=$+aa;d=aa+d;U=d+U;(function(o){var v,A=l.vertex_index_bytes*3+l.material_index_bytes,D=A+l.uv_index_bytes*3,H=o+l.ntri_flat_uv*D;for(v=o;v<H;v+=D){n(v);w(v+A)}return H-o})(Y);(function(o){var v,
-A=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,D=A+l.uv_index_bytes*3,H=o+l.ntri_smooth_uv*D;for(v=o;v<H;v+=D){p(v);w(v+A)}return H-o})(Z);(function(o){var v,A=l.vertex_index_bytes*4+l.material_index_bytes,D=A+l.uv_index_bytes*4,H=o+l.nquad_flat_uv*D;for(v=o;v<H;v+=D){t(v);u(v+A)}return H-o})(d);(function(o){var v,A=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,D=A+l.uv_index_bytes*4,H=o+l.nquad_smooth_uv*D;for(v=o;v<H;v+=D){x(v);u(v+A)}return H-o})(U);
+Q;o+=H){v=k(a,o);A=k(a,o+l.normal_coordinate_bytes);D=k(a,o+l.normal_coordinate_bytes*2);z.push(v/127,A/127,D/127)}return l.nnormals*H}(y);y+=function(o){for(var v,A,D=l.uv_coordinate_bytes*2,H=o+l.nuvs*D;o<H;o+=D){v=g(a,o);A=g(a,o+l.uv_coordinate_bytes);C.push(v,A)}return l.nuvs*D}(y);X=y+X;Y=X+Y;Z=Y+Z;$=Z+$;aa=$+aa;d=aa+d;U=d+U;(function(o){var v,A=l.vertex_index_bytes*3+l.material_index_bytes,D=A+l.uv_index_bytes*3,H=o+l.ntri_flat_uv*D;for(v=o;v<H;v+=D){n(v);x(v+A)}return H-o})(Y);(function(o){var v,
+A=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,D=A+l.uv_index_bytes*3,H=o+l.ntri_smooth_uv*D;for(v=o;v<H;v+=D){p(v);x(v+A)}return H-o})(Z);(function(o){var v,A=l.vertex_index_bytes*4+l.material_index_bytes,D=A+l.uv_index_bytes*4,H=o+l.nquad_flat_uv*D;for(v=o;v<H;v+=D){t(v);u(v+A)}return H-o})(d);(function(o){var v,A=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,D=A+l.uv_index_bytes*4,H=o+l.nquad_smooth_uv*D;for(v=o;v<H;v+=D){w(v);u(v+A)}return H-o})(U);
 (function(o){var v,A=l.vertex_index_bytes*3+l.material_index_bytes,D=o+l.ntri_flat*A;for(v=o;v<D;v+=A)n(v);return D-o})(y);(function(o){var v,A=l.vertex_index_bytes*3+l.material_index_bytes+l.normal_index_bytes*3,D=o+l.ntri_smooth*A;for(v=o;v<D;v+=A)p(v);return D-o})(X);(function(o){var v,A=l.vertex_index_bytes*4+l.material_index_bytes,D=o+l.nquad_flat*A;for(v=o;v<D;v+=A)t(v);return D-o})($);(function(o){var v,A=l.vertex_index_bytes*4+l.material_index_bytes+l.normal_index_bytes*4,D=o+l.nquad_smooth*
-A;for(v=o;v<D;v+=A)x(v);return D-o})(aa);this.computeCentroids();this.computeFaceNormals()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;f(new e(b))},v:function(a,f,b,c){a.vertices.push(new THREE.Vertex(new THREE.Vector3(f,b,c)))},f3:function(a,f,b,c,e){a.faces.push(new THREE.Face3(f,b,c,null,null,a.materials[e]))},f4:function(a,f,b,c,e,d){a.faces.push(new THREE.Face4(f,b,c,e,null,null,a.materials[d]))},f3n:function(a,f,b,c,e,d,g,h,m){d=a.materials[d];var k=f[h*3],j=f[h*3+1];h=f[h*3+2];
-var n=f[m*3],p=f[m*3+1];m=f[m*3+2];a.faces.push(new THREE.Face3(b,c,e,[new THREE.Vector3(f[g*3],f[g*3+1],f[g*3+2]),new THREE.Vector3(k,j,h),new THREE.Vector3(n,p,m)],null,d))},f4n:function(a,f,b,c,e,d,g,h,m,k,j){g=a.materials[g];var n=f[m*3],p=f[m*3+1];m=f[m*3+2];var t=f[k*3],x=f[k*3+1];k=f[k*3+2];var w=f[j*3],u=f[j*3+1];j=f[j*3+2];a.faces.push(new THREE.Face4(b,c,e,d,[new THREE.Vector3(f[h*3],f[h*3+1],f[h*3+2]),new THREE.Vector3(n,p,m),new THREE.Vector3(t,x,k),new THREE.Vector3(w,u,j)],null,g))},
+A;for(v=o;v<D;v+=A)w(v);return D-o})(aa);this.computeCentroids();this.computeFaceNormals()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;f(new e(b))},v:function(a,f,b,c){a.vertices.push(new THREE.Vertex(new THREE.Vector3(f,b,c)))},f3:function(a,f,b,c,e){a.faces.push(new THREE.Face3(f,b,c,null,null,a.materials[e]))},f4:function(a,f,b,c,e,d){a.faces.push(new THREE.Face4(f,b,c,e,null,null,a.materials[d]))},f3n:function(a,f,b,c,e,d,g,h,m){d=a.materials[d];var k=f[h*3],j=f[h*3+1];h=f[h*3+2];
+var n=f[m*3],p=f[m*3+1];m=f[m*3+2];a.faces.push(new THREE.Face3(b,c,e,[new THREE.Vector3(f[g*3],f[g*3+1],f[g*3+2]),new THREE.Vector3(k,j,h),new THREE.Vector3(n,p,m)],null,d))},f4n:function(a,f,b,c,e,d,g,h,m,k,j){g=a.materials[g];var n=f[m*3],p=f[m*3+1];m=f[m*3+2];var t=f[k*3],w=f[k*3+1];k=f[k*3+2];var x=f[j*3],u=f[j*3+1];j=f[j*3+2];a.faces.push(new THREE.Face4(b,c,e,d,[new THREE.Vector3(f[h*3],f[h*3+1],f[h*3+2]),new THREE.Vector3(n,p,m),new THREE.Vector3(t,w,k),new THREE.Vector3(x,u,j)],null,g))},
 uv3:function(a,f,b,c,e,d,g){var h=[];h.push(new THREE.UV(f,b));h.push(new THREE.UV(c,e));h.push(new THREE.UV(d,g));a.push(h)},uv4:function(a,f,b,c,e,d,g,h,m){var k=[];k.push(new THREE.UV(f,b));k.push(new THREE.UV(c,e));k.push(new THREE.UV(d,g));k.push(new THREE.UV(h,m));a.push(k)}};if(!window.Int32Array){window.Int32Array=Array;window.Float32Array=Array}
 THREE.MarchingCubes=function(a,f){THREE.Object3D.call(this);this.materials=f instanceof Array?f:[f];this.init=function(b){this.isolation=80;this.size=b;this.size2=this.size*this.size;this.size3=this.size2*this.size;this.halfsize=this.size/2;this.delta=2/this.size;this.yd=this.size;this.zd=this.size2;this.field=new Float32Array(this.size3);this.normal_cache=new Float32Array(this.size3*3);this.vlist=new Float32Array(36);this.nlist=new Float32Array(36);this.firstDraw=!0;this.maxCount=4096;this.count=
 0;this.hasPos=!1;this.hasNormal=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,c,e){return b+(c-b)*e};this.VIntX=function(b,c,e,d,g,h,m,k,j,n){g=(g-j)/(n-j);j=this.normal_cache;c[d]=h+g*this.delta;c[d+1]=m;c[d+2]=k;e[d]=this.lerp(j[b],j[b+3],g);e[d+1]=this.lerp(j[b+1],j[b+4],g);e[d+2]=this.lerp(j[b+2],j[b+5],g)};this.VIntY=function(b,c,e,d,g,h,m,k,j,n){g=(g-j)/(n-j);j=this.normal_cache;c[d]=h;c[d+1]=m+g*this.delta;c[d+
 2]=k;c=b+this.yd*3;e[d]=this.lerp(j[b],j[c],g);e[d+1]=this.lerp(j[b+1],j[c+1],g);e[d+2]=this.lerp(j[b+2],j[c+2],g)};this.VIntZ=function(b,c,e,d,g,h,m,k,j,n){g=(g-j)/(n-j);j=this.normal_cache;c[d]=h;c[d+1]=m;c[d+2]=k+g*this.delta;c=b+this.zd*3;e[d]=this.lerp(j[b],j[c],g);e[d+1]=this.lerp(j[b+1],j[c+1],g);e[d+2]=this.lerp(j[b+2],j[c+2],g)};this.compNorm=function(b){var c=b*3;if(this.normal_cache[c]==0){this.normal_cache[c]=this.field[b-1]-this.field[b+1];this.normal_cache[c+1]=this.field[b-this.yd]-
-this.field[b+this.yd];this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,c,e,d,g,h){var m=d+1,k=d+this.yd,j=d+this.zd,n=m+this.yd,p=m+this.zd,t=d+this.yd+this.zd,x=m+this.yd+this.zd,w=0,u=this.field[d],B=this.field[m],y=this.field[k],l=this.field[n],z=this.field[j],C=this.field[p],G=this.field[t],K=this.field[x];u<g&&(w|=1);B<g&&(w|=2);y<g&&(w|=8);l<g&&(w|=4);z<g&&(w|=16);C<g&&(w|=32);G<g&&(w|=128);K<g&&(w|=64);var J=THREE.edgeTable[w];if(J==0)return 0;
+this.field[b+this.yd];this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd]}};this.polygonize=function(b,c,e,d,g,h){var m=d+1,k=d+this.yd,j=d+this.zd,n=m+this.yd,p=m+this.zd,t=d+this.yd+this.zd,w=m+this.yd+this.zd,x=0,u=this.field[d],B=this.field[m],y=this.field[k],l=this.field[n],z=this.field[j],C=this.field[p],G=this.field[t],K=this.field[w];u<g&&(x|=1);B<g&&(x|=2);y<g&&(x|=8);l<g&&(x|=4);z<g&&(x|=16);C<g&&(x|=32);G<g&&(x|=128);K<g&&(x|=64);var J=THREE.edgeTable[x];if(J==0)return 0;
 var I=this.delta,E=b+I,L=c+I;I=e+I;if(J&1){this.compNorm(d);this.compNorm(m);this.VIntX(d*3,this.vlist,this.nlist,0,g,b,c,e,u,B)}if(J&2){this.compNorm(m);this.compNorm(n);this.VIntY(m*3,this.vlist,this.nlist,3,g,E,c,e,B,l)}if(J&4){this.compNorm(k);this.compNorm(n);this.VIntX(k*3,this.vlist,this.nlist,6,g,b,L,e,y,l)}if(J&8){this.compNorm(d);this.compNorm(k);this.VIntY(d*3,this.vlist,this.nlist,9,g,b,c,e,u,y)}if(J&16){this.compNorm(j);this.compNorm(p);this.VIntX(j*3,this.vlist,this.nlist,12,g,b,c,I,
-z,C)}if(J&32){this.compNorm(p);this.compNorm(x);this.VIntY(p*3,this.vlist,this.nlist,15,g,E,c,I,C,K)}if(J&64){this.compNorm(t);this.compNorm(x);this.VIntX(t*3,this.vlist,this.nlist,18,g,b,L,I,G,K)}if(J&128){this.compNorm(j);this.compNorm(t);this.VIntY(j*3,this.vlist,this.nlist,21,g,b,c,I,z,G)}if(J&256){this.compNorm(d);this.compNorm(j);this.VIntZ(d*3,this.vlist,this.nlist,24,g,b,c,e,u,z)}if(J&512){this.compNorm(m);this.compNorm(p);this.VIntZ(m*3,this.vlist,this.nlist,27,g,E,c,e,B,C)}if(J&1024){this.compNorm(n);
-this.compNorm(x);this.VIntZ(n*3,this.vlist,this.nlist,30,g,E,L,e,l,K)}if(J&2048){this.compNorm(k);this.compNorm(t);this.VIntZ(k*3,this.vlist,this.nlist,33,g,b,L,e,y,G)}w<<=4;for(g=d=0;THREE.triTable[w+g]!=-1;){b=w+g;c=b+1;e=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[e],h);g+=3;d++}return d};this.posnormtriv=function(b,c,e,d,g,h){var m=this.count*3;this.positionArray[m]=b[e];this.positionArray[m+1]=b[e+1];this.positionArray[m+2]=b[e+2];this.positionArray[m+
+z,C)}if(J&32){this.compNorm(p);this.compNorm(w);this.VIntY(p*3,this.vlist,this.nlist,15,g,E,c,I,C,K)}if(J&64){this.compNorm(t);this.compNorm(w);this.VIntX(t*3,this.vlist,this.nlist,18,g,b,L,I,G,K)}if(J&128){this.compNorm(j);this.compNorm(t);this.VIntY(j*3,this.vlist,this.nlist,21,g,b,c,I,z,G)}if(J&256){this.compNorm(d);this.compNorm(j);this.VIntZ(d*3,this.vlist,this.nlist,24,g,b,c,e,u,z)}if(J&512){this.compNorm(m);this.compNorm(p);this.VIntZ(m*3,this.vlist,this.nlist,27,g,E,c,e,B,C)}if(J&1024){this.compNorm(n);
+this.compNorm(w);this.VIntZ(n*3,this.vlist,this.nlist,30,g,E,L,e,l,K)}if(J&2048){this.compNorm(k);this.compNorm(t);this.VIntZ(k*3,this.vlist,this.nlist,33,g,b,L,e,y,G)}x<<=4;for(g=d=0;THREE.triTable[x+g]!=-1;){b=x+g;c=b+1;e=b+2;this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[e],h);g+=3;d++}return d};this.posnormtriv=function(b,c,e,d,g,h){var m=this.count*3;this.positionArray[m]=b[e];this.positionArray[m+1]=b[e+1];this.positionArray[m+2]=b[e+2];this.positionArray[m+
 3]=b[d];this.positionArray[m+4]=b[d+1];this.positionArray[m+5]=b[d+2];this.positionArray[m+6]=b[g];this.positionArray[m+7]=b[g+1];this.positionArray[m+8]=b[g+2];this.normalArray[m]=c[e];this.normalArray[m+1]=c[e+1];this.normalArray[m+2]=c[e+2];this.normalArray[m+3]=c[d];this.normalArray[m+4]=c[d+1];this.normalArray[m+5]=c[d+2];this.normalArray[m+6]=c[g];this.normalArray[m+7]=c[g+1];this.normalArray[m+8]=c[g+2];this.hasPos=!0;this.hasNormal=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=
 function(){this.count=0;this.hasPos=!1;this.hasNormal=!1};this.end=function(b){if(this.count!=0){for(var c=this.count*3;c<this.positionArray.length;c++)this.positionArray[c]=0;b(this)}};this.addBall=function(b,c,e,d,g){var h=this.size*Math.sqrt(d/g),m=e*this.size,k=c*this.size,j=b*this.size,n=Math.floor(m-h);n<1&&(n=1);m=Math.floor(m+h);m>this.size-1&&(m=this.size-1);var p=Math.floor(k-h);p<1&&(p=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var t=Math.floor(j-h);t<1&&(t=1);h=Math.floor(j+h);
-h>this.size-1&&(h=this.size-1);for(var x,w,u,B,y,l;n<m;n++){j=this.size2*n;w=n/this.size-e;y=w*w;for(w=p;w<k;w++){u=j+this.size*w;x=w/this.size-c;l=x*x;for(x=t;x<h;x++){B=x/this.size-b;B=d/(1.0E-6+B*B+l+y)-g;B>0&&(this.field[u+x]+=B)}}}};this.addPlaneX=function(b,c){var e,d,g,h,m,k=this.size,j=this.yd,n=this.zd,p=this.field,t=k*Math.sqrt(b/c);t>k&&(t=k);for(e=0;e<t;e++){d=e/k;d*=d;h=b/(1.0E-4+d)-c;if(h>0)for(d=0;d<k;d++){m=e+d*j;for(g=0;g<k;g++)p[n*g+m]+=h}}};this.addPlaneY=function(b,c){var e,d,
-g,h,m,k,j=this.size,n=this.yd,p=this.zd,t=this.field,x=j*Math.sqrt(b/c);x>j&&(x=j);for(d=0;d<x;d++){e=d/j;e*=e;h=b/(1.0E-4+e)-c;if(h>0){m=d*n;for(e=0;e<j;e++){k=m+e;for(g=0;g<j;g++)t[p*g+k]+=h}}}};this.addPlaneZ=function(b,c){var e,d,g,h,m,k;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(g=0;g<dist;g++){e=g/size;e*=e;h=b/(1.0E-4+e)-c;if(h>0){m=zd*g;for(d=0;d<size;d++){k=m+d*yd;for(e=0;e<size;e++)field[k+e]+=h}}}};this.reset=function(){var b;
+h>this.size-1&&(h=this.size-1);for(var w,x,u,B,y,l;n<m;n++){j=this.size2*n;x=n/this.size-e;y=x*x;for(x=p;x<k;x++){u=j+this.size*x;w=x/this.size-c;l=w*w;for(w=t;w<h;w++){B=w/this.size-b;B=d/(1.0E-6+B*B+l+y)-g;B>0&&(this.field[u+w]+=B)}}}};this.addPlaneX=function(b,c){var e,d,g,h,m,k=this.size,j=this.yd,n=this.zd,p=this.field,t=k*Math.sqrt(b/c);t>k&&(t=k);for(e=0;e<t;e++){d=e/k;d*=d;h=b/(1.0E-4+d)-c;if(h>0)for(d=0;d<k;d++){m=e+d*j;for(g=0;g<k;g++)p[n*g+m]+=h}}};this.addPlaneY=function(b,c){var e,d,
+g,h,m,k,j=this.size,n=this.yd,p=this.zd,t=this.field,w=j*Math.sqrt(b/c);w>j&&(w=j);for(d=0;d<w;d++){e=d/j;e*=e;h=b/(1.0E-4+e)-c;if(h>0){m=d*n;for(e=0;e<j;e++){k=m+e;for(g=0;g<j;g++)t[p*g+k]+=h}}}};this.addPlaneZ=function(b,c){var e,d,g,h,m,k;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(g=0;g<dist;g++){e=g/size;e*=e;h=b/(1.0E-4+e)-c;if(h>0){m=zd*g;for(d=0;d<size;d++){k=m+d*yd;for(e=0;e<size;e++)field[k+e]+=h}}}};this.reset=function(){var b;
 for(b=0;b<this.size3;b++){this.normal_cache[b*3]=0;this.field[b]=0}};this.render=function(b){this.begin();var c,e,d,g,h,m,k,j,n,p=this.size-2;for(g=1;g<p;g++){n=this.size2*g;k=(g-this.halfsize)/this.halfsize;for(d=1;d<p;d++){j=n+this.size*d;m=(d-this.halfsize)/this.halfsize;for(e=1;e<p;e++){h=(e-this.halfsize)/this.halfsize;c=j+e;this.polygonize(h,m,k,c,this.isolation,b)}}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry;this.render(function(e){var d,g,h,m,k,j,n,p;for(d=
 0;d<e.count;d++){k=d*3;n=k+1;p=k+2;g=e.positionArray[k];h=e.positionArray[n];m=e.positionArray[p];j=new THREE.Vector3(g,h,m);g=e.normalArray[k];h=e.normalArray[n];m=e.normalArray[p];k=new THREE.Vector3(g,h,m);k.normalize();k=new THREE.Vertex(j,k);c.vertices.push(k)}nfaces=e.count/3;for(d=0;d<nfaces;d++){k=(b+d)*3;n=k+1;p=k+2;j=c.vertices[k].normal;g=c.vertices[n].normal;h=c.vertices[p].normal;k=new THREE.Face3(k,n,p,[j,g,h]);c.faces.push(k)}b+=nfaces;e.count=0});return c};this.init(a)};
 THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;

+ 1 - 1
build/custom/ThreeSVG.js

@@ -48,7 +48,7 @@ b,c)}};THREE.Quaternion=function(a,b,c,e){this.set(a||0,b||0,c||0,e!==undefined?
 THREE.Quaternion.prototype={set:function(a,b,c,e){this.x=a;this.y=b;this.z=c;this.w=e;return this},setFromEuler:function(a){var b=0.5*Math.PI/360,c=a.x*b,e=a.y*b,d=a.z*b;a=Math.cos(e);e=Math.sin(e);b=Math.cos(-d);d=Math.sin(-d);var f=Math.cos(c);c=Math.sin(c);var g=a*b,i=e*d;this.w=g*f-i*c;this.x=g*c+i*f;this.y=e*b*f+a*d*c;this.z=a*d*f-e*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,e=this.z,d=this.w,f=a.x,g=a.y,i=a.z;a=a.w;this.x=b*a+d*f+c*i-e*g;this.y=c*a+d*g+e*f-b*i;this.z=e*a+d*i+b*g-c*f;this.w=d*a-b*f-c*g-e*i;return this},
 multiplyVector3:function(a,b){b||(b=a);var c=a.x,e=a.y,d=a.z,f=this.x,g=this.y,i=this.z,h=this.w,j=h*c+g*d-i*e,m=h*e+i*c-f*d,l=h*d+f*e-g*c;c=-f*c-g*e-i*d;b.x=j*h+c*-f+m*-i-l*-g;b.y=m*h+c*-g+l*-f-j*-i;b.z=l*h+c*-i+j*-g-m*-f;return b}};
-THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);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}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Quaternion.slerp=function(a,b,c,e){var d=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;if(Math.abs(d)>=1){c.w=a.w;c.x=a.x;c.y=a.y;c.z=a.z;return c}var f=Math.acos(d),g=Math.sqrt(1-d*d);if(Math.abs(g)<0.0010){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}d=Math.sin((1-e)*f)/g;e=Math.sin(e*f)/g;c.w=a.w*d+b.w*e;c.x=a.x*d+b.x*e;c.y=a.y*d+b.y*e;c.z=a.z*d+b.z*e;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
 THREE.Face3=function(a,b,c,e,d,f){this.a=a;this.b=b;this.c=c;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=d instanceof THREE.Color?d:new THREE.Color;this.vertexColors=d instanceof Array?d:[];this.vertexTangents=[];this.materials=f instanceof Array?f:[f];this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,e,d,f,g){this.a=a;this.b=b;this.c=c;this.d=e;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materials=g instanceof Array?g:[g];this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.set(a||0,b||0)};
 THREE.UV.prototype={set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.set(a.u,a.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};

+ 151 - 151
build/custom/ThreeWebGL.js

@@ -1,7 +1,7 @@
 // ThreeWebGL.js r38 - http://github.com/mrdoob/three.js
 var THREE=THREE||{};THREE.Color=function(b){this.setHex(b)};
-THREE.Color.prototype={autoUpdate:!0,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex;this.__styleString=b.__styleString},setRGB:function(b,d,e){this.r=b;this.g=d;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(b,d,e){var h,g,j,k,o,q;if(e==0)h=g=j=0;else{k=Math.floor(b*6);o=b*6-k;b=e*(1-d);q=e*(1-d*o);d=e*(1-d*(1-o));switch(k){case 1:h=q;g=e;j=b;break;case 2:h=b;g=e;j=d;break;case 3:h=b;g=q;j=e;break;case 4:h=d;g=b;j=e;break;case 5:h=e;g=b;
-j=q;break;case 6:case 0:h=e;g=d;j=b}}this.r=h;this.g=g;this.b=j;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(b){this.hex=~~b&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*
+THREE.Color.prototype={autoUpdate:!0,copy:function(b){this.r=b.r;this.g=b.g;this.b=b.b;this.hex=b.hex;this.__styleString=b.__styleString},setRGB:function(b,d,e){this.r=b;this.g=d;this.b=e;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHSV:function(b,d,e){var h,g,j,k,n,p;if(e==0)h=g=j=0;else{k=Math.floor(b*6);n=b*6-k;b=e*(1-d);p=e*(1-d*n);d=e*(1-d*(1-n));switch(k){case 1:h=p;g=e;j=b;break;case 2:h=b;g=e;j=d;break;case 3:h=b;g=p;j=e;break;case 4:h=d;g=b;j=e;break;case 5:h=e;g=b;
+j=p;break;case 6:case 0:h=e;g=d;j=b}}this.r=h;this.g=g;this.b=j;if(this.autoUpdate){this.updateHex();this.updateStyleString()}},setHex:function(b){this.hex=~~b&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(b,d){this.set(b||0,d||0)};
 THREE.Vector2.prototype={set:function(b,d){this.x=b;this.y=d;return this},copy:function(b){this.set(b.x,b.y);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y);return this},multiplyScalar:function(b){this.set(this.x*b,this.y*b);return this},negate:function(){this.set(-this.x,-this.y);return this},unit:function(){this.multiplyScalar(1/
 this.length());return this},length:function(){return Math.sqrt(this.lengthSq())},lengthSq:function(){return this.x*this.x+this.y*this.y},clone:function(){return new THREE.Vector2(this.x,this.y)}};THREE.Vector3=function(b,d,e){this.set(b||0,d||0,e||0)};
@@ -12,71 +12,71 @@ this.length();b>0?this.multiplyScalar(1/b):this.set(0,0,0);return this},setPosit
 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(b,d,e,h){this.set(b||0,d||0,e||0,h||1)};
 THREE.Vector4.prototype={set:function(b,d,e,h){this.x=b;this.y=d;this.z=e;this.w=h;return this},copy:function(b){this.set(b.x,b.y,b.z,b.w||1);return this},add:function(b,d){this.set(b.x+d.x,b.y+d.y,b.z+d.z,b.w+d.w);return this},addSelf:function(b){this.set(this.x+b.x,this.y+b.y,this.z+b.z,this.w+b.w);return this},sub:function(b,d){this.set(b.x-d.x,b.y-d.y,b.z-d.z,b.w-d.w);return this},subSelf:function(b){this.set(this.x-b.x,this.y-b.y,this.z-b.z,this.w-b.w);return this},multiplyScalar:function(b){this.set(this.x*
 b,this.y*b,this.z*b,this.w*b);return this},divideScalar:function(b){this.set(this.x/b,this.y/b,this.z/b,this.w/b);return this},lerpSelf:function(b,d){this.set(this.x+(b.x-this.x)*d,this.y+(b.y-this.y)*d,this.z+(b.z-this.z)*d,this.w+(b.w-this.w)*d)},clone:function(){return new THREE.Vector4(this.x,this.y,this.z,this.w)}};THREE.Ray=function(b,d){this.origin=b||new THREE.Vector3;this.direction=d||new THREE.Vector3};
-THREE.Ray.prototype={intersectScene:function(b){var d,e,h=b.objects,g=[];b=0;for(d=h.length;b<d;b++){e=h[b];e instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(e)))}g.sort(function(j,k){return j.distance-k.distance});return g},intersectObject:function(b){function d(W,P,ra,ca){ca=ca.clone().subSelf(P);ra=ra.clone().subSelf(P);var sa=W.clone().subSelf(P);W=ca.dot(ca);P=ca.dot(ra);ca=ca.dot(sa);var Z=ra.dot(ra);ra=ra.dot(sa);sa=1/(W*Z-P*P);Z=(Z*ca-P*ra)*sa;W=(W*ra-P*ca)*sa;return Z>0&&W>0&&Z+W<
-1}var e,h,g,j,k,o,q,v,D,F,J,G=b.geometry,N=G.vertices,O=[];e=0;for(h=G.faces.length;e<h;e++){g=G.faces[e];F=this.origin.clone();J=this.direction.clone();q=b.matrixWorld;j=q.multiplyVector3(N[g.a].position.clone());k=q.multiplyVector3(N[g.b].position.clone());o=q.multiplyVector3(N[g.c].position.clone());q=g instanceof THREE.Face4?q.multiplyVector3(N[g.d].position.clone()):null;v=b.matrixRotationWorld.multiplyVector3(g.normal.clone());D=J.dot(v);if(D<0){v=v.dot((new THREE.Vector3).sub(j,F))/D;F=F.addSelf(J.multiplyScalar(v));
-if(g instanceof THREE.Face3){if(d(F,j,k,o)){g={distance:this.origin.distanceTo(F),point:F,face:g,object:b};O.push(g)}}else if(g instanceof THREE.Face4&&(d(F,j,k,q)||d(F,k,o,q))){g={distance:this.origin.distanceTo(F),point:F,face:g,object:b};O.push(g)}}}return O}};
-THREE.Rectangle=function(){function b(){j=h-d;k=g-e}var d,e,h,g,j,k,o=!0;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return h};this.getBottom=function(){return g};this.set=function(q,v,D,F){o=!1;d=q;e=v;h=D;g=F;b()};this.addPoint=function(q,v){if(o){o=!1;d=q;e=v;h=q;g=v}else{d=d<q?d:q;e=e<v?e:v;h=h>q?h:q;g=g>v?g:v}b()};
-this.add3Points=function(q,v,D,F,J,G){if(o){o=!1;d=q<D?q<J?q:J:D<J?D:J;e=v<F?v<G?v:G:F<G?F:G;h=q>D?q>J?q:J:D>J?D:J;g=v>F?v>G?v:G:F>G?F:G}else{d=q<D?q<J?q<d?q:d:J<d?J:d:D<J?D<d?D:d:J<d?J:d;e=v<F?v<G?v<e?v:e:G<e?G:e:F<G?F<e?F:e:G<e?G:e;h=q>D?q>J?q>h?q:h:J>h?J:h:D>J?D>h?D:h:J>h?J:h;g=v>F?v>G?v>g?v:g:G>g?G:g:F>G?F>g?F:g:G>g?G:g}b()};this.addRectangle=function(q){if(o){o=!1;d=q.getLeft();e=q.getTop();h=q.getRight();g=q.getBottom()}else{d=d<q.getLeft()?d:q.getLeft();e=e<q.getTop()?e:q.getTop();h=h>q.getRight()?
-h:q.getRight();g=g>q.getBottom()?g:q.getBottom()}b()};this.inflate=function(q){d-=q;e-=q;h+=q;g+=q;b()};this.minSelf=function(q){d=d>q.getLeft()?d:q.getLeft();e=e>q.getTop()?e:q.getTop();h=h<q.getRight()?h:q.getRight();g=g<q.getBottom()?g:q.getBottom();b()};this.instersects=function(q){return Math.min(h,q.getRight())-Math.max(d,q.getLeft())>=0&&Math.min(g,q.getBottom())-Math.max(e,q.getTop())>=0};this.empty=function(){o=!0;g=h=e=d=0;b()};this.isEmpty=function(){return o}};
+THREE.Ray.prototype={intersectScene:function(b){var d,e,h=b.objects,g=[];b=0;for(d=h.length;b<d;b++){e=h[b];e instanceof THREE.Mesh&&(g=g.concat(this.intersectObject(e)))}g.sort(function(j,k){return j.distance-k.distance});return g},intersectObject:function(b){function d(X,Q,ca,ma){ma=ma.clone().subSelf(Q);ca=ca.clone().subSelf(Q);var wa=X.clone().subSelf(Q);X=ma.dot(ma);Q=ma.dot(ca);ma=ma.dot(wa);var $=ca.dot(ca);ca=ca.dot(wa);wa=1/(X*$-Q*Q);$=($*ma-Q*ca)*wa;X=(X*ca-Q*ma)*wa;return $>0&&X>0&&$+X<
+1}var e,h,g,j,k,n,p,v,E,F,K,G=b.geometry,N=G.vertices,O=[];e=0;for(h=G.faces.length;e<h;e++){g=G.faces[e];F=this.origin.clone();K=this.direction.clone();p=b.matrixWorld;j=p.multiplyVector3(N[g.a].position.clone());k=p.multiplyVector3(N[g.b].position.clone());n=p.multiplyVector3(N[g.c].position.clone());p=g instanceof THREE.Face4?p.multiplyVector3(N[g.d].position.clone()):null;v=b.matrixRotationWorld.multiplyVector3(g.normal.clone());E=K.dot(v);if(E<0){v=v.dot((new THREE.Vector3).sub(j,F))/E;F=F.addSelf(K.multiplyScalar(v));
+if(g instanceof THREE.Face3){if(d(F,j,k,n)){g={distance:this.origin.distanceTo(F),point:F,face:g,object:b};O.push(g)}}else if(g instanceof THREE.Face4&&(d(F,j,k,p)||d(F,k,n,p))){g={distance:this.origin.distanceTo(F),point:F,face:g,object:b};O.push(g)}}}return O}};
+THREE.Rectangle=function(){function b(){j=h-d;k=g-e}var d,e,h,g,j,k,n=!0;this.getX=function(){return d};this.getY=function(){return e};this.getWidth=function(){return j};this.getHeight=function(){return k};this.getLeft=function(){return d};this.getTop=function(){return e};this.getRight=function(){return h};this.getBottom=function(){return g};this.set=function(p,v,E,F){n=!1;d=p;e=v;h=E;g=F;b()};this.addPoint=function(p,v){if(n){n=!1;d=p;e=v;h=p;g=v}else{d=d<p?d:p;e=e<v?e:v;h=h>p?h:p;g=g>v?g:v}b()};
+this.add3Points=function(p,v,E,F,K,G){if(n){n=!1;d=p<E?p<K?p:K:E<K?E:K;e=v<F?v<G?v:G:F<G?F:G;h=p>E?p>K?p:K:E>K?E:K;g=v>F?v>G?v:G:F>G?F:G}else{d=p<E?p<K?p<d?p:d:K<d?K:d:E<K?E<d?E:d:K<d?K:d;e=v<F?v<G?v<e?v:e:G<e?G:e:F<G?F<e?F:e:G<e?G:e;h=p>E?p>K?p>h?p:h:K>h?K:h:E>K?E>h?E:h:K>h?K:h;g=v>F?v>G?v>g?v:g:G>g?G:g:F>G?F>g?F:g:G>g?G:g}b()};this.addRectangle=function(p){if(n){n=!1;d=p.getLeft();e=p.getTop();h=p.getRight();g=p.getBottom()}else{d=d<p.getLeft()?d:p.getLeft();e=e<p.getTop()?e:p.getTop();h=h>p.getRight()?
+h:p.getRight();g=g>p.getBottom()?g:p.getBottom()}b()};this.inflate=function(p){d-=p;e-=p;h+=p;g+=p;b()};this.minSelf=function(p){d=d>p.getLeft()?d:p.getLeft();e=e>p.getTop()?e:p.getTop();h=h<p.getRight()?h:p.getRight();g=g<p.getBottom()?g:p.getBottom();b()};this.instersects=function(p){return Math.min(h,p.getRight())-Math.max(d,p.getLeft())>=0&&Math.min(g,p.getBottom())-Math.max(e,p.getTop())>=0};this.empty=function(){n=!0;g=h=e=d=0;b()};this.isEmpty=function(){return n}};
 THREE.Matrix3=function(){this.m=[]};THREE.Matrix3.prototype={transpose:function(){var b,d=this.m;b=d[1];d[1]=d[3];d[3]=b;b=d[2];d[2]=d[6];d[6]=b;b=d[5];d[5]=d[7];d[7]=b;return this},transposeIntoArray:function(b){var d=this.m;b[0]=d[0];b[1]=d[3];b[2]=d[6];b[3]=d[1];b[4]=d[4];b[5]=d[7];b[6]=d[2];b[7]=d[5];b[8]=d[8];return this}};
-THREE.Matrix4=function(b,d,e,h,g,j,k,o,q,v,D,F,J,G,N,O){this.set(b||1,d||0,e||0,h||0,g||0,j||1,k||0,o||0,q||0,v||0,D||1,F||0,J||0,G||0,N||0,O||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={set:function(b,d,e,h,g,j,k,o,q,v,D,F,J,G,N,O){this.n11=b;this.n12=d;this.n13=e;this.n14=h;this.n21=g;this.n22=j;this.n23=k;this.n24=o;this.n31=q;this.n32=v;this.n33=D;this.n34=F;this.n41=J;this.n42=G;this.n43=N;this.n44=O;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,e){var h=THREE.Matrix4.__v1,
+THREE.Matrix4=function(b,d,e,h,g,j,k,n,p,v,E,F,K,G,N,O){this.set(b||1,d||0,e||0,h||0,g||0,j||1,k||0,n||0,p||0,v||0,E||1,F||0,K||0,G||0,N||0,O||1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={set:function(b,d,e,h,g,j,k,n,p,v,E,F,K,G,N,O){this.n11=b;this.n12=d;this.n13=e;this.n14=h;this.n21=g;this.n22=j;this.n23=k;this.n24=n;this.n31=p;this.n32=v;this.n33=E;this.n34=F;this.n41=K;this.n42=G;this.n43=N;this.n44=O;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(b){this.set(b.n11,b.n12,b.n13,b.n14,b.n21,b.n22,b.n23,b.n24,b.n31,b.n32,b.n33,b.n34,b.n41,b.n42,b.n43,b.n44);return this},lookAt:function(b,d,e){var h=THREE.Matrix4.__v1,
 g=THREE.Matrix4.__v2,j=THREE.Matrix4.__v3;j.sub(b,d).normalize();if(j.length()===0)j.z=1;h.cross(e,j).normalize();if(h.length()===0){j.x+=1.0E-4;h.cross(e,j).normalize()}g.cross(j,h).normalize();this.n11=h.x;this.n12=g.x;this.n13=j.x;this.n21=h.y;this.n22=g.y;this.n23=j.y;this.n31=h.z;this.n32=g.z;this.n33=j.z;return this},multiplyVector3:function(b){var d=b.x,e=b.y,h=b.z,g=1/(this.n41*d+this.n42*e+this.n43*h+this.n44);b.x=(this.n11*d+this.n12*e+this.n13*h+this.n14)*g;b.y=(this.n21*d+this.n22*e+this.n23*
 h+this.n24)*g;b.z=(this.n31*d+this.n32*e+this.n33*h+this.n34)*g;return b},multiplyVector4:function(b){var d=b.x,e=b.y,h=b.z,g=b.w;b.x=this.n11*d+this.n12*e+this.n13*h+this.n14*g;b.y=this.n21*d+this.n22*e+this.n23*h+this.n24*g;b.z=this.n31*d+this.n32*e+this.n33*h+this.n34*g;b.w=this.n41*d+this.n42*e+this.n43*h+this.n44*g;return b},rotateAxis:function(b){var d=b.x,e=b.y,h=b.z;b.x=d*this.n11+e*this.n12+h*this.n13;b.y=d*this.n21+e*this.n22+h*this.n23;b.z=d*this.n31+e*this.n32+h*this.n33;b.normalize();
-return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var e=b.n11,h=b.n12,g=b.n13,j=b.n14,k=b.n21,o=b.n22,q=b.n23,v=b.n24,D=b.n31,F=b.n32,J=b.n33,G=b.n34,N=b.n41,O=b.n42,W=b.n43,P=b.n44,ra=d.n11,ca=d.n12,sa=d.n13,Z=d.n14,K=d.n21,Ia=d.n22,
-ka=d.n23,Da=d.n24,ea=d.n31,c=d.n32,S=d.n33,oa=d.n34;this.n11=e*ra+h*K+g*ea;this.n12=e*ca+h*Ia+g*c;this.n13=e*sa+h*ka+g*S;this.n14=e*Z+h*Da+g*oa+j;this.n21=k*ra+o*K+q*ea;this.n22=k*ca+o*Ia+q*c;this.n23=k*sa+o*ka+q*S;this.n24=k*Z+o*Da+q*oa+v;this.n31=D*ra+F*K+J*ea;this.n32=D*ca+F*Ia+J*c;this.n33=D*sa+F*ka+J*S;this.n34=D*Z+F*Da+J*oa+G;this.n41=N*ra+O*K+W*ea;this.n42=N*ca+O*Ia+W*c;this.n43=N*sa+O*ka+W*S;this.n44=N*Z+O*Da+W*oa+P;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);e[0]=this.n11;
+return b},crossVector:function(b){var d=new THREE.Vector4;d.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;d.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;d.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;d.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return d},multiply:function(b,d){var e=b.n11,h=b.n12,g=b.n13,j=b.n14,k=b.n21,n=b.n22,p=b.n23,v=b.n24,E=b.n31,F=b.n32,K=b.n33,G=b.n34,N=b.n41,O=b.n42,X=b.n43,Q=b.n44,ca=d.n11,ma=d.n12,wa=d.n13,$=d.n14,L=d.n21,xa=d.n22,
+ta=d.n23,ea=d.n24,c=d.n31,T=d.n32,U=d.n33,na=d.n34;this.n11=e*ca+h*L+g*c;this.n12=e*ma+h*xa+g*T;this.n13=e*wa+h*ta+g*U;this.n14=e*$+h*ea+g*na+j;this.n21=k*ca+n*L+p*c;this.n22=k*ma+n*xa+p*T;this.n23=k*wa+n*ta+p*U;this.n24=k*$+n*ea+p*na+v;this.n31=E*ca+F*L+K*c;this.n32=E*ma+F*xa+K*T;this.n33=E*wa+F*ta+K*U;this.n34=E*$+F*ea+K*na+G;this.n41=N*ca+O*L+X*c;this.n42=N*ma+O*xa+X*T;this.n43=N*wa+O*ta+X*U;this.n44=N*$+O*ea+X*na+Q;return this},multiplyToArray:function(b,d,e){this.multiply(b,d);e[0]=this.n11;
 e[1]=this.n21;e[2]=this.n31;e[3]=this.n41;e[4]=this.n12;e[5]=this.n22;e[6]=this.n32;e[7]=this.n42;e[8]=this.n13;e[9]=this.n23;e[10]=this.n33;e[11]=this.n43;e[12]=this.n14;e[13]=this.n24;e[14]=this.n34;e[15]=this.n44;return this},multiplySelf:function(b){this.multiply(this,b);return this},multiplyScalar:function(b){this.n11*=b;this.n12*=b;this.n13*=b;this.n14*=b;this.n21*=b;this.n22*=b;this.n23*=b;this.n24*=b;this.n31*=b;this.n32*=b;this.n33*=b;this.n34*=b;this.n41*=b;this.n42*=b;this.n43*=b;this.n44*=
-b;return this},determinant:function(){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,g=this.n21,j=this.n22,k=this.n23,o=this.n24,q=this.n31,v=this.n32,D=this.n33,F=this.n34,J=this.n41,G=this.n42,N=this.n43,O=this.n44;return h*k*v*J-e*o*v*J-h*j*D*J+d*o*D*J+e*j*F*J-d*k*F*J-h*k*q*G+e*o*q*G+h*g*D*G-b*o*D*G-e*g*F*G+b*k*F*G+h*j*q*N-d*o*q*N-h*g*v*N+b*o*v*N+d*g*F*N-b*j*F*N-e*j*q*O+d*k*q*O+e*g*v*O-b*k*v*O-d*g*D*O+b*j*D*O},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=
+b;return this},determinant:function(){var b=this.n11,d=this.n12,e=this.n13,h=this.n14,g=this.n21,j=this.n22,k=this.n23,n=this.n24,p=this.n31,v=this.n32,E=this.n33,F=this.n34,K=this.n41,G=this.n42,N=this.n43,O=this.n44;return h*k*v*K-e*n*v*K-h*j*E*K+d*n*E*K+e*j*F*K-d*k*F*K-h*k*p*G+e*n*p*G+h*g*E*G-b*n*E*G-e*g*F*G+b*k*F*G+h*j*p*N-d*n*p*N-h*g*v*N+b*n*v*N+d*g*F*N-b*j*F*N-e*j*p*O+d*k*p*O+e*g*v*O-b*k*v*O-d*g*E*O+b*j*E*O},transpose:function(){var b;b=this.n21;this.n21=this.n12;this.n12=b;b=this.n31;this.n31=
 this.n13;this.n13=b;b=this.n32;this.n32=this.n23;this.n23=b;b=this.n41;this.n41=this.n14;this.n14=b;b=this.n42;this.n42=this.n24;this.n24=b;b=this.n43;this.n43=this.n34;this.n43=b;return this},clone:function(){var b=new THREE.Matrix4;b.n11=this.n11;b.n12=this.n12;b.n13=this.n13;b.n14=this.n14;b.n21=this.n21;b.n22=this.n22;b.n23=this.n23;b.n24=this.n24;b.n31=this.n31;b.n32=this.n32;b.n33=this.n33;b.n34=this.n34;b.n41=this.n41;b.n42=this.n42;b.n43=this.n43;b.n44=this.n44;return b},flatten:function(){this.flat[0]=
 this.n11;this.flat[1]=this.n21;this.flat[2]=this.n31;this.flat[3]=this.n41;this.flat[4]=this.n12;this.flat[5]=this.n22;this.flat[6]=this.n32;this.flat[7]=this.n42;this.flat[8]=this.n13;this.flat[9]=this.n23;this.flat[10]=this.n33;this.flat[11]=this.n43;this.flat[12]=this.n14;this.flat[13]=this.n24;this.flat[14]=this.n34;this.flat[15]=this.n44;return this.flat},flattenToArray:function(b){b[0]=this.n11;b[1]=this.n21;b[2]=this.n31;b[3]=this.n41;b[4]=this.n12;b[5]=this.n22;b[6]=this.n32;b[7]=this.n42;
 b[8]=this.n13;b[9]=this.n23;b[10]=this.n33;b[11]=this.n43;b[12]=this.n14;b[13]=this.n24;b[14]=this.n34;b[15]=this.n44;return b},flattenToArrayOffset:function(b,d){b[d]=this.n11;b[d+1]=this.n21;b[d+2]=this.n31;b[d+3]=this.n41;b[d+4]=this.n12;b[d+5]=this.n22;b[d+6]=this.n32;b[d+7]=this.n42;b[d+8]=this.n13;b[d+9]=this.n23;b[d+10]=this.n33;b[d+11]=this.n43;b[d+12]=this.n14;b[d+13]=this.n24;b[d+14]=this.n34;b[d+15]=this.n44;return b},setTranslation:function(b,d,e){this.set(1,0,0,b,0,1,0,d,0,0,1,e,0,0,
 0,1);return this},setScale:function(b,d,e){this.set(b,0,0,0,0,d,0,0,0,0,e,0,0,0,0,1);return this},setRotationX:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(1,0,0,0,0,d,-b,0,0,b,d,0,0,0,0,1);return this},setRotationY:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,0,b,0,0,1,0,0,-b,0,d,0,0,0,0,1);return this},setRotationZ:function(b){var d=Math.cos(b);b=Math.sin(b);this.set(d,-b,0,0,b,d,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,d){var e=Math.cos(d),h=Math.sin(d),g=
-1-e,j=b.x,k=b.y,o=b.z,q=g*j,v=g*k;this.set(q*j+e,q*k-h*o,q*o+h*k,0,q*k+h*o,v*k+e,v*o-h*j,0,q*o-h*k,v*o+h*j,g*o*o+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var d=b.x,e=b.y,h=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(e);e=Math.sin(e);var j=Math.cos(h);h=Math.sin(h);var k=b*e,o=d*e;this.n11=g*j;this.n12=-g*h;this.n13=e;this.n21=o*j+b*h;this.n22=-o*h+b*j;this.n23=-d*g;this.n31=-k*j+d*h;this.n32=k*h+d*j;this.n33=
-b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,e=b.y,h=b.z,g=b.w,j=d+d,k=e+e,o=h+h;b=d*j;var q=d*k;d*=o;var v=e*k;e*=o;h*=o;j*=g;k*=g;g*=o;this.n11=1-(v+h);this.n12=q-g;this.n13=d+k;this.n21=q+g;this.n22=1-(b+h);this.n23=e-j;this.n31=d-k;this.n32=e+j;this.n33=1-(b+v);return this},scale:function(b){var d=b.x,e=b.y;b=b.z;this.n11*=d;this.n12*=e;this.n13*=b;this.n21*=d;this.n22*=e;this.n23*=b;this.n31*=d;this.n32*=e;this.n33*=b;this.n41*=d;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14=
+1-e,j=b.x,k=b.y,n=b.z,p=g*j,v=g*k;this.set(p*j+e,p*k-h*n,p*n+h*k,0,p*k+h*n,v*k+e,v*n-h*j,0,p*n-h*k,v*n+h*j,g*n*n+e,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},setRotationFromEuler:function(b){var d=b.x,e=b.y,h=b.z;b=Math.cos(d);d=Math.sin(d);var g=Math.cos(e);e=Math.sin(e);var j=Math.cos(h);h=Math.sin(h);var k=b*e,n=d*e;this.n11=g*j;this.n12=-g*h;this.n13=e;this.n21=n*j+b*h;this.n22=-n*h+b*j;this.n23=-d*g;this.n31=-k*j+d*h;this.n32=k*h+d*j;this.n33=
+b*g;return this},setRotationFromQuaternion:function(b){var d=b.x,e=b.y,h=b.z,g=b.w,j=d+d,k=e+e,n=h+h;b=d*j;var p=d*k;d*=n;var v=e*k;e*=n;h*=n;j*=g;k*=g;g*=n;this.n11=1-(v+h);this.n12=p-g;this.n13=d+k;this.n21=p+g;this.n22=1-(b+h);this.n23=e-j;this.n31=d-k;this.n32=e+j;this.n33=1-(b+v);return this},scale:function(b){var d=b.x,e=b.y;b=b.z;this.n11*=d;this.n12*=e;this.n13*=b;this.n21*=d;this.n22*=e;this.n23*=b;this.n31*=d;this.n32*=e;this.n33*=b;this.n41*=d;this.n42*=e;this.n43*=b;return this},extractPosition:function(b){this.n14=
 b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,d){var e=1/d.x,h=1/d.y,g=1/d.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*h;this.n22=b.n22*h;this.n32=b.n32*h;this.n13=b.n13*g;this.n23=b.n23*g;this.n33=b.n33*g}};
-THREE.Matrix4.makeInvert=function(b,d){var e=b.n11,h=b.n12,g=b.n13,j=b.n14,k=b.n21,o=b.n22,q=b.n23,v=b.n24,D=b.n31,F=b.n32,J=b.n33,G=b.n34,N=b.n41,O=b.n42,W=b.n43,P=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=q*G*O-v*J*O+v*F*W-o*G*W-q*F*P+o*J*P;d.n12=j*J*O-g*G*O-j*F*W+h*G*W+g*F*P-h*J*P;d.n13=g*v*O-j*q*O+j*o*W-h*v*W-g*o*P+h*q*P;d.n14=j*q*F-g*v*F-j*o*J+h*v*J+g*o*G-h*q*G;d.n21=v*J*N-q*G*N-v*D*W+k*G*W+q*D*P-k*J*P;d.n22=g*G*N-j*J*N+j*D*W-e*G*W-g*D*P+e*J*P;d.n23=j*q*N-g*v*N-j*k*W+e*v*W+g*k*P-e*q*P;
-d.n24=g*v*D-j*q*D+j*k*J-e*v*J-g*k*G+e*q*G;d.n31=o*G*N-v*F*N+v*D*O-k*G*O-o*D*P+k*F*P;d.n32=j*F*N-h*G*N-j*D*O+e*G*O+h*D*P-e*F*P;d.n33=g*v*N-j*o*N+j*k*O-e*v*O-h*k*P+e*o*P;d.n34=j*o*D-h*v*D-j*k*F+e*v*F+h*k*G-e*o*G;d.n41=q*F*N-o*J*N-q*D*O+k*J*O+o*D*W-k*F*W;d.n42=h*J*N-g*F*N+g*D*O-e*J*O-h*D*W+e*F*W;d.n43=g*o*N-h*q*N-g*k*O+e*q*O+h*k*W-e*o*W;d.n44=h*q*D-g*o*D+g*k*F-e*q*F-h*k*J+e*o*J;d.multiplyScalar(1/b.determinant());return d};
-THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,e=d.m,h=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,j=b.n32*b.n21-b.n31*b.n22,k=-b.n33*b.n12+b.n32*b.n13,o=b.n33*b.n11-b.n31*b.n13,q=-b.n32*b.n11+b.n31*b.n12,v=b.n23*b.n12-b.n22*b.n13,D=-b.n23*b.n11+b.n21*b.n13,F=b.n22*b.n11-b.n21*b.n12;b=b.n11*h+b.n21*k+b.n31*v;if(b==0)throw"matrix not invertible";b=1/b;e[0]=b*h;e[1]=b*g;e[2]=b*j;e[3]=b*k;e[4]=b*o;e[5]=b*q;e[6]=b*v;e[7]=b*D;e[8]=b*F;return d};
+THREE.Matrix4.makeInvert=function(b,d){var e=b.n11,h=b.n12,g=b.n13,j=b.n14,k=b.n21,n=b.n22,p=b.n23,v=b.n24,E=b.n31,F=b.n32,K=b.n33,G=b.n34,N=b.n41,O=b.n42,X=b.n43,Q=b.n44;d===undefined&&(d=new THREE.Matrix4);d.n11=p*G*O-v*K*O+v*F*X-n*G*X-p*F*Q+n*K*Q;d.n12=j*K*O-g*G*O-j*F*X+h*G*X+g*F*Q-h*K*Q;d.n13=g*v*O-j*p*O+j*n*X-h*v*X-g*n*Q+h*p*Q;d.n14=j*p*F-g*v*F-j*n*K+h*v*K+g*n*G-h*p*G;d.n21=v*K*N-p*G*N-v*E*X+k*G*X+p*E*Q-k*K*Q;d.n22=g*G*N-j*K*N+j*E*X-e*G*X-g*E*Q+e*K*Q;d.n23=j*p*N-g*v*N-j*k*X+e*v*X+g*k*Q-e*p*Q;
+d.n24=g*v*E-j*p*E+j*k*K-e*v*K-g*k*G+e*p*G;d.n31=n*G*N-v*F*N+v*E*O-k*G*O-n*E*Q+k*F*Q;d.n32=j*F*N-h*G*N-j*E*O+e*G*O+h*E*Q-e*F*Q;d.n33=g*v*N-j*n*N+j*k*O-e*v*O-h*k*Q+e*n*Q;d.n34=j*n*E-h*v*E-j*k*F+e*v*F+h*k*G-e*n*G;d.n41=p*F*N-n*K*N-p*E*O+k*K*O+n*E*X-k*F*X;d.n42=h*K*N-g*F*N+g*E*O-e*K*O-h*E*X+e*F*X;d.n43=g*n*N-h*p*N-g*k*O+e*p*O+h*k*X-e*n*X;d.n44=h*p*E-g*n*E+g*k*F-e*p*F-h*k*K+e*n*K;d.multiplyScalar(1/b.determinant());return d};
+THREE.Matrix4.makeInvert3x3=function(b){var d=b.m33,e=d.m,h=b.n33*b.n22-b.n32*b.n23,g=-b.n33*b.n21+b.n31*b.n23,j=b.n32*b.n21-b.n31*b.n22,k=-b.n33*b.n12+b.n32*b.n13,n=b.n33*b.n11-b.n31*b.n13,p=-b.n32*b.n11+b.n31*b.n12,v=b.n23*b.n12-b.n22*b.n13,E=-b.n23*b.n11+b.n21*b.n13,F=b.n22*b.n11-b.n21*b.n12;b=b.n11*h+b.n21*k+b.n31*v;if(b==0)throw"matrix not invertible";b=1/b;e[0]=b*h;e[1]=b*g;e[2]=b*j;e[3]=b*k;e[4]=b*n;e[5]=b*p;e[6]=b*v;e[7]=b*E;e[8]=b*F;return d};
 THREE.Matrix4.makeFrustum=function(b,d,e,h,g,j){var k;k=new THREE.Matrix4;k.n11=2*g/(d-b);k.n12=0;k.n13=(d+b)/(d-b);k.n14=0;k.n21=0;k.n22=2*g/(h-e);k.n23=(h+e)/(h-e);k.n24=0;k.n31=0;k.n32=0;k.n33=-(j+g)/(j-g);k.n34=-2*j*g/(j-g);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(b,d,e,h){var g;b=e*Math.tan(b*Math.PI/360);g=-b;return THREE.Matrix4.makeFrustum(g*d,b*d,g,b,e,h)};
-THREE.Matrix4.makeOrtho=function(b,d,e,h,g,j){var k,o,q,v;k=new THREE.Matrix4;o=d-b;q=e-h;v=j-g;k.n11=2/o;k.n12=0;k.n13=0;k.n14=-((d+b)/o);k.n21=0;k.n22=2/q;k.n23=0;k.n24=-((e+h)/q);k.n31=0;k.n32=0;k.n33=-2/v;k.n34=-((j+g)/v);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
+THREE.Matrix4.makeOrtho=function(b,d,e,h,g,j){var k,n,p,v;k=new THREE.Matrix4;n=d-b;p=e-h;v=j-g;k.n11=2/n;k.n12=0;k.n13=0;k.n14=-((d+b)/n);k.n21=0;k.n22=2/p;k.n23=0;k.n24=-((e+h)/p);k.n31=0;k.n32=0;k.n33=-2/v;k.n34=-((j+g)/v);k.n41=0;k.n42=0;k.n43=0;k.n44=1;return k};THREE.Matrix4.__v1=new THREE.Vector3;THREE.Matrix4.__v2=new THREE.Vector3;THREE.Matrix4.__v3=new THREE.Vector3;
 THREE.Object3D=function(){this.parent=undefined;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.scale=new THREE.Vector3(1,1,1);this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixAutoUpdate=!0;this.matrixWorldNeedsUpdate=!0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=
 !0;this._vector=new THREE.Vector3};
 THREE.Object3D.prototype={translate:function(b,d){this.matrix.rotateAxis(d);this.position.addSelf(d.multiplyScalar(b))},translateX:function(b){this.translate(b,this._vector.set(1,0,0))},translateY:function(b){this.translate(b,this._vector.set(0,1,0))},translateZ:function(b){this.translate(b,this._vector.set(0,0,1))},lookAt:function(b){this.matrix.lookAt(this.position,b,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},addChild:function(b){if(this.children.indexOf(b)===-1){b.parent!==
 undefined&&b.parent.removeChild(b);b.parent=this;this.children.push(b);for(var d=this;d instanceof THREE.Scene===!1&&d!==undefined;)d=d.parent;d!==undefined&&d.addChildRecurse(b)}},removeChild:function(b){var d=this.children.indexOf(b);if(d!==-1){b.parent=undefined;this.children.splice(d,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))}this.matrixWorldNeedsUpdate=!0},update:function(b,d,e){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||d){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale);this.matrixWorldNeedsUpdate=!1;d=!0}b=0;for(var h=this.children.length;b<h;b++)this.children[b].update(this.matrixWorld,
 d,e)}};THREE.Quaternion=function(b,d,e,h){this.set(b||0,d||0,e||0,h!==undefined?h:1)};
-THREE.Quaternion.prototype={set:function(b,d,e,h){this.x=b;this.y=d;this.z=e;this.w=h;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,e=b.x*d,h=b.y*d,g=b.z*d;b=Math.cos(h);h=Math.sin(h);d=Math.cos(-g);g=Math.sin(-g);var j=Math.cos(e);e=Math.sin(e);var k=b*d,o=h*g;this.w=k*j-o*e;this.x=k*e+o*j;this.y=h*d*j+b*g*e;this.z=b*g*j-h*d*e;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 b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},multiplySelf:function(b){var d=this.x,e=this.y,h=this.z,g=this.w,j=b.x,k=b.y,o=b.z;b=b.w;this.x=d*b+g*j+e*o-h*k;this.y=e*b+g*k+h*j-d*o;this.z=h*b+g*o+d*k-e*j;this.w=g*b-d*j-e*k-h*o;return this},
-multiplyVector3:function(b,d){d||(d=b);var e=b.x,h=b.y,g=b.z,j=this.x,k=this.y,o=this.z,q=this.w,v=q*e+k*g-o*h,D=q*h+o*e-j*g,F=q*g+j*h-k*e;e=-j*e-k*h-o*g;d.x=v*q+e*-j+D*-o-F*-k;d.y=D*q+e*-k+F*-j-v*-o;d.z=F*q+e*-o+v*-k-D*-j;return d}};
-THREE.Quaternion.slerp=function(b,d,e,h){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var j=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<0.001){e.w=0.5*(b.w+d.w);e.x=0.5*(b.x+d.x);e.y=0.5*(b.y+d.y);e.z=0.5*(b.z+d.z);return e}g=Math.sin((1-h)*j)/k;h=Math.sin(h*j)/k;e.w=b.w*g+d.w*h;e.x=b.x*g+d.x*h;e.y=b.y*g+d.y*h;e.z=b.z*g+d.z*h;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
+THREE.Quaternion.prototype={set:function(b,d,e,h){this.x=b;this.y=d;this.z=e;this.w=h;return this},setFromEuler:function(b){var d=0.5*Math.PI/360,e=b.x*d,h=b.y*d,g=b.z*d;b=Math.cos(h);h=Math.sin(h);d=Math.cos(-g);g=Math.sin(-g);var j=Math.cos(e);e=Math.sin(e);var k=b*d,n=h*g;this.w=k*j-n*e;this.x=k*e+n*j;this.y=h*d*j+b*g*e;this.z=b*g*j-h*d*e;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 b=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);if(b==0)this.w=this.z=this.y=this.x=0;else{b=1/b;this.x*=b;this.y*=b;this.z*=b;this.w*=b}return this},multiplySelf:function(b){var d=this.x,e=this.y,h=this.z,g=this.w,j=b.x,k=b.y,n=b.z;b=b.w;this.x=d*b+g*j+e*n-h*k;this.y=e*b+g*k+h*j-d*n;this.z=h*b+g*n+d*k-e*j;this.w=g*b-d*j-e*k-h*n;return this},
+multiplyVector3:function(b,d){d||(d=b);var e=b.x,h=b.y,g=b.z,j=this.x,k=this.y,n=this.z,p=this.w,v=p*e+k*g-n*h,E=p*h+n*e-j*g,F=p*g+j*h-k*e;e=-j*e-k*h-n*g;d.x=v*p+e*-j+E*-n-F*-k;d.y=E*p+e*-k+F*-j-v*-n;d.z=F*p+e*-n+v*-k-E*-j;return d}};
+THREE.Quaternion.slerp=function(b,d,e,h){var g=b.w*d.w+b.x*d.x+b.y*d.y+b.z*d.z;if(Math.abs(g)>=1){e.w=b.w;e.x=b.x;e.y=b.y;e.z=b.z;return e}var j=Math.acos(g),k=Math.sqrt(1-g*g);if(Math.abs(k)<0.0010){e.w=0.5*(b.w+d.w);e.x=0.5*(b.x+d.x);e.y=0.5*(b.y+d.y);e.z=0.5*(b.z+d.z);return e}g=Math.sin((1-h)*j)/k;h=Math.sin(h*j)/k;e.w=b.w*g+d.w*h;e.x=b.x*g+d.x*h;e.y=b.y*g+d.y*h;e.z=b.z*g+d.z*h;return e};THREE.Vertex=function(b){this.position=b||new THREE.Vector3};
 THREE.Face3=function(b,d,e,h,g,j){this.a=b;this.b=d;this.c=e;this.normal=h instanceof THREE.Vector3?h:new THREE.Vector3;this.vertexNormals=h instanceof Array?h:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materials=j instanceof Array?j:[j];this.centroid=new THREE.Vector3};
 THREE.Face4=function(b,d,e,h,g,j,k){this.a=b;this.b=d;this.c=e;this.d=h;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=j instanceof THREE.Color?j:new THREE.Color;this.vertexColors=j instanceof Array?j:[];this.vertexTangents=[];this.materials=k instanceof Array?k:[k];this.centroid=new THREE.Vector3};THREE.UV=function(b,d){this.set(b||0,d||0)};
 THREE.UV.prototype={set:function(b,d){this.u=b;this.v=d;return this},copy:function(b){this.set(b.u,b.v);return this}};THREE.Geometry=function(){this.id="Geometry"+THREE.GeometryIdCounter++;this.vertices=[];this.colors=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.hasTangents=!1};
 THREE.Geometry.prototype={computeCentroids:function(){var b,d,e;b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];e.centroid.set(0,0,0);if(e instanceof THREE.Face3){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);e.centroid.divideScalar(3)}else if(e instanceof THREE.Face4){e.centroid.addSelf(this.vertices[e.a].position);e.centroid.addSelf(this.vertices[e.b].position);e.centroid.addSelf(this.vertices[e.c].position);
-e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(b){var d,e,h,g,j,k,o=new THREE.Vector3,q=new THREE.Vector3;h=0;for(g=this.faces.length;h<g;h++){j=this.faces[h];if(b&&j.vertexNormals.length){o.set(0,0,0);d=0;for(e=j.vertexNormals.length;d<e;d++)o.addSelf(j.vertexNormals[d]);o.divideScalar(3)}else{d=this.vertices[j.a];e=this.vertices[j.b];k=this.vertices[j.c];o.sub(k.position,e.position);q.sub(d.position,e.position);o.crossSelf(q)}o.isZero()||
-o.normalize();j.normal.copy(o)}},computeVertexNormals:function(){var b,d,e,h;if(this.__tmpVertices==undefined){h=this.__tmpVertices=Array(this.vertices.length);b=0;for(d=this.vertices.length;b<d;b++)h[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{h=
+e.centroid.addSelf(this.vertices[e.d].position);e.centroid.divideScalar(4)}}},computeFaceNormals:function(b){var d,e,h,g,j,k,n=new THREE.Vector3,p=new THREE.Vector3;h=0;for(g=this.faces.length;h<g;h++){j=this.faces[h];if(b&&j.vertexNormals.length){n.set(0,0,0);d=0;for(e=j.vertexNormals.length;d<e;d++)n.addSelf(j.vertexNormals[d]);n.divideScalar(3)}else{d=this.vertices[j.a];e=this.vertices[j.b];k=this.vertices[j.c];n.sub(k.position,e.position);p.sub(d.position,e.position);n.crossSelf(p)}n.isZero()||
+n.normalize();j.normal.copy(n)}},computeVertexNormals:function(){var b,d,e,h;if(this.__tmpVertices==undefined){h=this.__tmpVertices=Array(this.vertices.length);b=0;for(d=this.vertices.length;b<d;b++)h[b]=new THREE.Vector3;b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];if(e instanceof THREE.Face3)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(e instanceof THREE.Face4)e.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}}else{h=
 this.__tmpVertices;b=0;for(d=this.vertices.length;b<d;b++)h[b].set(0,0,0)}b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];if(e instanceof THREE.Face3){h[e.a].addSelf(e.normal);h[e.b].addSelf(e.normal);h[e.c].addSelf(e.normal)}else if(e instanceof THREE.Face4){h[e.a].addSelf(e.normal);h[e.b].addSelf(e.normal);h[e.c].addSelf(e.normal);h[e.d].addSelf(e.normal)}}b=0;for(d=this.vertices.length;b<d;b++)h[b].normalize();b=0;for(d=this.faces.length;b<d;b++){e=this.faces[b];if(e instanceof THREE.Face3){e.vertexNormals[0].copy(h[e.a]);
-e.vertexNormals[1].copy(h[e.b]);e.vertexNormals[2].copy(h[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(h[e.a]);e.vertexNormals[1].copy(h[e.b]);e.vertexNormals[2].copy(h[e.c]);e.vertexNormals[3].copy(h[e.d])}}},computeTangents:function(){function b(aa,ma,na,la,Y,va,pa){o=aa.vertices[ma].position;q=aa.vertices[na].position;v=aa.vertices[la].position;D=k[Y];F=k[va];J=k[pa];G=q.x-o.x;N=v.x-o.x;O=q.y-o.y;W=v.y-o.y;P=q.z-o.z;ra=v.z-o.z;ca=F.u-D.u;sa=J.u-D.u;Z=F.v-D.v;K=J.v-D.v;Ia=1/(ca*
-K-sa*Z);c.set((K*G-Z*N)*Ia,(K*O-Z*W)*Ia,(K*P-Z*ra)*Ia);S.set((ca*N-sa*G)*Ia,(ca*W-sa*O)*Ia,(ca*ra-sa*P)*Ia);Da[ma].addSelf(c);Da[na].addSelf(c);Da[la].addSelf(c);ea[ma].addSelf(S);ea[na].addSelf(S);ea[la].addSelf(S)}var d,e,h,g,j,k,o,q,v,D,F,J,G,N,O,W,P,ra,ca,sa,Z,K,Ia,ka,Da=[],ea=[],c=new THREE.Vector3,S=new THREE.Vector3,oa=new THREE.Vector3,ta=new THREE.Vector3,Ea=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){Da[d]=new THREE.Vector3;ea[d]=new THREE.Vector3}d=0;for(e=this.faces.length;d<
-e;d++){j=this.faces[d];k=this.faceVertexUvs[0][d];if(j instanceof THREE.Face3)b(this,j.a,j.b,j.c,0,1,2);else if(j instanceof THREE.Face4){b(this,j.a,j.b,j.c,0,1,2);b(this,j.a,j.b,j.d,0,1,3)}}var wa=["a","b","c","d"];d=0;for(e=this.faces.length;d<e;d++){j=this.faces[d];for(h=0;h<j.vertexNormals.length;h++){Ea.copy(j.vertexNormals[h]);g=j[wa[h]];ka=Da[g];oa.copy(ka);oa.subSelf(Ea.multiplyScalar(Ea.dot(ka))).normalize();ta.cross(j.vertexNormals[h],ka);g=ta.dot(ea[g]);g=g<0?-1:1;j.vertexTangents[h]=new THREE.Vector4(oa.x,
-oa.y,oa.z,g)}}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,e=this.vertices.length;d<e;d++){b=this.vertices[d];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;
+e.vertexNormals[1].copy(h[e.b]);e.vertexNormals[2].copy(h[e.c])}else if(e instanceof THREE.Face4){e.vertexNormals[0].copy(h[e.a]);e.vertexNormals[1].copy(h[e.b]);e.vertexNormals[2].copy(h[e.c]);e.vertexNormals[3].copy(h[e.d])}}},computeTangents:function(){function b(aa,pa,fa,qa,Y,ua,oa){n=aa.vertices[pa].position;p=aa.vertices[fa].position;v=aa.vertices[qa].position;E=k[Y];F=k[ua];K=k[oa];G=p.x-n.x;N=v.x-n.x;O=p.y-n.y;X=v.y-n.y;Q=p.z-n.z;ca=v.z-n.z;ma=F.u-E.u;wa=K.u-E.u;$=F.v-E.v;L=K.v-E.v;xa=1/(ma*
+L-wa*$);T.set((L*G-$*N)*xa,(L*O-$*X)*xa,(L*Q-$*ca)*xa);U.set((ma*N-wa*G)*xa,(ma*X-wa*O)*xa,(ma*ca-wa*Q)*xa);ea[pa].addSelf(T);ea[fa].addSelf(T);ea[qa].addSelf(T);c[pa].addSelf(U);c[fa].addSelf(U);c[qa].addSelf(U)}var d,e,h,g,j,k,n,p,v,E,F,K,G,N,O,X,Q,ca,ma,wa,$,L,xa,ta,ea=[],c=[],T=new THREE.Vector3,U=new THREE.Vector3,na=new THREE.Vector3,Fa=new THREE.Vector3,Ga=new THREE.Vector3;d=0;for(e=this.vertices.length;d<e;d++){ea[d]=new THREE.Vector3;c[d]=new THREE.Vector3}d=0;for(e=this.faces.length;d<
+e;d++){j=this.faces[d];k=this.faceVertexUvs[0][d];if(j instanceof THREE.Face3)b(this,j.a,j.b,j.c,0,1,2);else if(j instanceof THREE.Face4){b(this,j.a,j.b,j.c,0,1,2);b(this,j.a,j.b,j.d,0,1,3)}}var ya=["a","b","c","d"];d=0;for(e=this.faces.length;d<e;d++){j=this.faces[d];for(h=0;h<j.vertexNormals.length;h++){Ga.copy(j.vertexNormals[h]);g=j[ya[h]];ta=ea[g];na.copy(ta);na.subSelf(Ga.multiplyScalar(Ga.dot(ta))).normalize();Fa.cross(j.vertexNormals[h],ta);g=Fa.dot(c[g]);g=g<0?-1:1;j.vertexTangents[h]=new THREE.Vector4(na.x,
+na.y,na.z,g)}}this.hasTangents=!0},computeBoundingBox:function(){var b;if(this.vertices.length>0){this.boundingBox={x:[this.vertices[0].position.x,this.vertices[0].position.x],y:[this.vertices[0].position.y,this.vertices[0].position.y],z:[this.vertices[0].position.z,this.vertices[0].position.z]};for(var d=1,e=this.vertices.length;d<e;d++){b=this.vertices[d];if(b.position.x<this.boundingBox.x[0])this.boundingBox.x[0]=b.position.x;else if(b.position.x>this.boundingBox.x[1])this.boundingBox.x[1]=b.position.x;
 if(b.position.y<this.boundingBox.y[0])this.boundingBox.y[0]=b.position.y;else if(b.position.y>this.boundingBox.y[1])this.boundingBox.y[1]=b.position.y;if(b.position.z<this.boundingBox.z[0])this.boundingBox.z[0]=b.position.z;else if(b.position.z>this.boundingBox.z[1])this.boundingBox.z[1]=b.position.z}}},computeBoundingSphere:function(){for(var b=this.boundingSphere===null?0:this.boundingSphere.radius,d=0,e=this.vertices.length;d<e;d++)b=Math.max(b,this.vertices[d].position.length());this.boundingSphere=
 {radius:b}}};THREE.GeometryIdCounter=0;
 THREE.AnimationHandler=function(){var b=[],d={},e={};e.update=function(g){for(var j=0;j<b.length;j++)b[j].update(g)};e.addToUpdate=function(g){b.indexOf(g)===-1&&b.push(g)};e.removeFromUpdate=function(g){g=b.indexOf(g);g!==-1&&b.splice(g,1)};e.add=function(g){d[g.name]!==undefined&&console.log("THREE.AnimationHandler.add: Warning! "+g.name+" already exists in library. Overwriting.");d[g.name]=g;if(g.initialized!==!0){for(var j=0;j<g.hierarchy.length;j++){for(var k=0;k<g.hierarchy[j].keys.length;k++){if(g.hierarchy[j].keys[k].time<
-0)g.hierarchy[j].keys[k].time=0;if(g.hierarchy[j].keys[k].rot!==undefined&&!(g.hierarchy[j].keys[k].rot instanceof THREE.Quaternion)){var o=g.hierarchy[j].keys[k].rot;g.hierarchy[j].keys[k].rot=new THREE.Quaternion(o[0],o[1],o[2],o[3])}}if(g.hierarchy[j].keys[0].morphTargets!==undefined){o={};for(k=0;k<g.hierarchy[j].keys.length;k++)for(var q=0;q<g.hierarchy[j].keys[k].morphTargets.length;q++){var v=g.hierarchy[j].keys[k].morphTargets[q];o[v]=-1}g.hierarchy[j].usedMorphTargets=o;for(k=0;k<g.hierarchy[j].keys.length;k++){var D=
-{};for(v in o){for(q=0;q<g.hierarchy[j].keys[k].morphTargets.length;q++)if(g.hierarchy[j].keys[k].morphTargets[q]===v){D[v]=g.hierarchy[j].keys[k].morphTargetsInfluences[q];break}q===g.hierarchy[j].keys[k].morphTargets.length&&(D[v]=0)}g.hierarchy[j].keys[k].morphTargetsInfluences=D}}for(k=1;k<g.hierarchy[j].keys.length;k++)if(g.hierarchy[j].keys[k].time===g.hierarchy[j].keys[k-1].time){g.hierarchy[j].keys.splice(k,1);k--}for(k=1;k<g.hierarchy[j].keys.length;k++)g.hierarchy[j].keys[k].index=k}k=parseInt(g.length*
+0)g.hierarchy[j].keys[k].time=0;if(g.hierarchy[j].keys[k].rot!==undefined&&!(g.hierarchy[j].keys[k].rot instanceof THREE.Quaternion)){var n=g.hierarchy[j].keys[k].rot;g.hierarchy[j].keys[k].rot=new THREE.Quaternion(n[0],n[1],n[2],n[3])}}if(g.hierarchy[j].keys[0].morphTargets!==undefined){n={};for(k=0;k<g.hierarchy[j].keys.length;k++)for(var p=0;p<g.hierarchy[j].keys[k].morphTargets.length;p++){var v=g.hierarchy[j].keys[k].morphTargets[p];n[v]=-1}g.hierarchy[j].usedMorphTargets=n;for(k=0;k<g.hierarchy[j].keys.length;k++){var E=
+{};for(v in n){for(p=0;p<g.hierarchy[j].keys[k].morphTargets.length;p++)if(g.hierarchy[j].keys[k].morphTargets[p]===v){E[v]=g.hierarchy[j].keys[k].morphTargetsInfluences[p];break}p===g.hierarchy[j].keys[k].morphTargets.length&&(E[v]=0)}g.hierarchy[j].keys[k].morphTargetsInfluences=E}}for(k=1;k<g.hierarchy[j].keys.length;k++)if(g.hierarchy[j].keys[k].time===g.hierarchy[j].keys[k-1].time){g.hierarchy[j].keys.splice(k,1);k--}for(k=1;k<g.hierarchy[j].keys.length;k++)g.hierarchy[j].keys[k].index=k}k=parseInt(g.length*
 g.fps,10);g.JIT={};g.JIT.hierarchy=[];for(j=0;j<g.hierarchy.length;j++)g.JIT.hierarchy.push(Array(k));g.initialized=!0}};e.get=function(g){if(typeof g==="string")if(d[g])return d[g];else{console.log("THREE.AnimationHandler.get: Couldn't find animation "+g);return null}};e.parse=function(g){var j=[];if(g instanceof THREE.SkinnedMesh)for(var k=0;k<g.bones.length;k++)j.push(g.bones[k]);else h(g,j);return j};var h=function(g,j){j.push(g);for(var k=0;k<g.children.length;k++)h(g.children[k],j)};e.LINEAR=
 0;e.CATMULLROM=1;e.CATMULLROM_FORWARD=2;return e}();THREE.Animation=function(b,d,e,h){this.root=b;this.data=THREE.AnimationHandler.get(d);this.hierarchy=THREE.AnimationHandler.parse(b);this.currentTime=0;this.timeScale=1;this.isPlaying=!1;this.isPaused=!0;this.loop=!0;this.interpolationType=e!==undefined?e:THREE.AnimationHandler.LINEAR;this.JITCompile=h!==undefined?h:!0;this.points=[];this.target=new THREE.Vector3};
 THREE.Animation.prototype.play=function(b,d){if(!this.isPlaying){this.isPlaying=!0;this.loop=b!==undefined?b:!0;this.currentTime=d!==undefined?d:0;var e,h=this.hierarchy.length,g;for(e=0;e<h;e++){g=this.hierarchy[e];if(this.interpolationType!==THREE.AnimationHandler.CATMULLROM_FORWARD)g.useQuaternion=!0;g.matrixAutoUpdate=!0;if(g.animationCache===undefined){g.animationCache={};g.animationCache.prevKey={pos:0,rot:0,scl:0};g.animationCache.nextKey={pos:0,rot:0,scl:0};g.animationCache.originalMatrix=
 g instanceof THREE.Bone?g.skinMatrix:g.matrix}var j=g.animationCache.prevKey;g=g.animationCache.nextKey;j.pos=this.data.hierarchy[e].keys[0];j.rot=this.data.hierarchy[e].keys[0];j.scl=this.data.hierarchy[e].keys[0];g.pos=this.getNextKeyWith("pos",e,1);g.rot=this.getNextKeyWith("rot",e,1);g.scl=this.getNextKeyWith("scl",e,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPlaying=!1;this.isPaused=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var b=0;b<this.hierarchy.length;b++)if(this.hierarchy[b].animationCache!==undefined){if(this.hierarchy[b]instanceof THREE.Bone)this.hierarchy[b].skinMatrix=this.hierarchy[b].animationCache.originalMatrix;else this.hierarchy[b].matrix=this.hierarchy[b].animationCache.originalMatrix;delete this.hierarchy[b].animationCache}};
-THREE.Animation.prototype.update=function(b){if(this.isPlaying){var d=["pos","rot","scl"],e,h,g,j,k,o,q,v,D=this.data.JIT.hierarchy,F,J;this.currentTime+=b*this.timeScale;J=this.currentTime;F=this.currentTime%=this.data.length;v=parseInt(Math.min(F*this.data.fps,this.data.length*this.data.fps),10);for(var G=0,N=this.hierarchy.length;G<N;G++){b=this.hierarchy[G];q=b.animationCache;if(this.JITCompile&&D[G][v]!==undefined)if(b instanceof THREE.Bone){b.skinMatrix=D[G][v];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=
-!1}else{b.matrix=D[G][v];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(b instanceof THREE.Bone)b.skinMatrix=b.animationCache.originalMatrix;else b.matrix=b.animationCache.originalMatrix;for(var O=0;O<3;O++){e=d[O];k=q.prevKey[e];o=q.nextKey[e];if(o.time<=J){if(F<J)if(this.loop){k=this.data.hierarchy[G].keys[0];for(o=this.getNextKeyWith(e,G,1);o.time<F;){k=o;o=this.getNextKeyWith(e,G,o.index+1)}}else{this.stop();return}else{do{k=o;o=this.getNextKeyWith(e,G,o.index+1)}while(o.time<
-F)}q.prevKey[e]=k;q.nextKey[e]=o}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;h=(F-k.time)/(o.time-k.time);g=k[e];j=o[e];if(h<0||h>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+h+" on bone "+G);h=h<0?0:1}if(e==="pos"){e=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){e.x=g[0]+(j[0]-g[0])*h;e.y=g[1]+(j[1]-g[1])*h;e.z=g[2]+(j[2]-g[2])*h}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
-this.getPrevKeyWith("pos",G,k.index-1).pos;this.points[1]=g;this.points[2]=j;this.points[3]=this.getNextKeyWith("pos",G,o.index+1).pos;h=h*0.33+0.33;g=this.interpolateCatmullRom(this.points,h);e.x=g[0];e.y=g[1];e.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){h=this.interpolateCatmullRom(this.points,h*1.01);this.target.set(h[0],h[1],h[2]);this.target.subSelf(e);this.target.y=0;this.target.normalize();h=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,h,0)}}}else if(e===
-"rot")THREE.Quaternion.slerp(g,j,b.quaternion,h);else if(e==="scl"){e=b.scale;e.x=g[0]+(j[0]-g[0])*h;e.y=g[1]+(j[1]-g[1])*h;e.z=g[2]+(j[2]-g[2])*h}}}}if(this.JITCompile&&D[0][v]===undefined){this.hierarchy[0].update(undefined,!0);for(G=0;G<this.hierarchy.length;G++)D[G][v]=this.hierarchy[G]instanceof THREE.Bone?this.hierarchy[G].skinMatrix.clone():this.hierarchy[G].matrix.clone()}}};
-THREE.Animation.prototype.interpolateCatmullRom=function(b,d){var e=[],h=[],g,j,k,o,q,v;g=(b.length-1)*d;j=Math.floor(g);g-=j;e[0]=j==0?j:j-1;e[1]=j;e[2]=j>b.length-2?j:j+1;e[3]=j>b.length-3?j:j+2;j=b[e[0]];o=b[e[1]];q=b[e[2]];v=b[e[3]];e=g*g;k=g*e;h[0]=this.interpolate(j[0],o[0],q[0],v[0],g,e,k);h[1]=this.interpolate(j[1],o[1],q[1],v[1],g,e,k);h[2]=this.interpolate(j[2],o[2],q[2],v[2],g,e,k);return h};
+THREE.Animation.prototype.update=function(b){if(this.isPlaying){var d=["pos","rot","scl"],e,h,g,j,k,n,p,v,E=this.data.JIT.hierarchy,F,K;this.currentTime+=b*this.timeScale;K=this.currentTime;F=this.currentTime%=this.data.length;v=parseInt(Math.min(F*this.data.fps,this.data.length*this.data.fps),10);for(var G=0,N=this.hierarchy.length;G<N;G++){b=this.hierarchy[G];p=b.animationCache;if(this.JITCompile&&E[G][v]!==undefined)if(b instanceof THREE.Bone){b.skinMatrix=E[G][v];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=
+!1}else{b.matrix=E[G][v];b.matrixAutoUpdate=!1;b.matrixWorldNeedsUpdate=!0}else{if(this.JITCompile)if(b instanceof THREE.Bone)b.skinMatrix=b.animationCache.originalMatrix;else b.matrix=b.animationCache.originalMatrix;for(var O=0;O<3;O++){e=d[O];k=p.prevKey[e];n=p.nextKey[e];if(n.time<=K){if(F<K)if(this.loop){k=this.data.hierarchy[G].keys[0];for(n=this.getNextKeyWith(e,G,1);n.time<F;){k=n;n=this.getNextKeyWith(e,G,n.index+1)}}else{this.stop();return}else{do{k=n;n=this.getNextKeyWith(e,G,n.index+1)}while(n.time<
+F)}p.prevKey[e]=k;p.nextKey[e]=n}b.matrixAutoUpdate=!0;b.matrixWorldNeedsUpdate=!0;h=(F-k.time)/(n.time-k.time);g=k[e];j=n[e];if(h<0||h>1){console.log("THREE.Animation.update: Warning! Scale out of bounds:"+h+" on bone "+G);h=h<0?0:1}if(e==="pos"){e=b.position;if(this.interpolationType===THREE.AnimationHandler.LINEAR){e.x=g[0]+(j[0]-g[0])*h;e.y=g[1]+(j[1]-g[1])*h;e.z=g[2]+(j[2]-g[2])*h}else if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){this.points[0]=
+this.getPrevKeyWith("pos",G,k.index-1).pos;this.points[1]=g;this.points[2]=j;this.points[3]=this.getNextKeyWith("pos",G,n.index+1).pos;h=h*0.33+0.33;g=this.interpolateCatmullRom(this.points,h);e.x=g[0];e.y=g[1];e.z=g[2];if(this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD){h=this.interpolateCatmullRom(this.points,h*1.01);this.target.set(h[0],h[1],h[2]);this.target.subSelf(e);this.target.y=0;this.target.normalize();h=Math.atan2(this.target.x,this.target.z);b.rotation.set(0,h,0)}}}else if(e===
+"rot")THREE.Quaternion.slerp(g,j,b.quaternion,h);else if(e==="scl"){e=b.scale;e.x=g[0]+(j[0]-g[0])*h;e.y=g[1]+(j[1]-g[1])*h;e.z=g[2]+(j[2]-g[2])*h}}}}if(this.JITCompile&&E[0][v]===undefined){this.hierarchy[0].update(undefined,!0);for(G=0;G<this.hierarchy.length;G++)E[G][v]=this.hierarchy[G]instanceof THREE.Bone?this.hierarchy[G].skinMatrix.clone():this.hierarchy[G].matrix.clone()}}};
+THREE.Animation.prototype.interpolateCatmullRom=function(b,d){var e=[],h=[],g,j,k,n,p,v;g=(b.length-1)*d;j=Math.floor(g);g-=j;e[0]=j==0?j:j-1;e[1]=j;e[2]=j>b.length-2?j:j+1;e[3]=j>b.length-3?j:j+2;j=b[e[0]];n=b[e[1]];p=b[e[2]];v=b[e[3]];e=g*g;k=g*e;h[0]=this.interpolate(j[0],n[0],p[0],v[0],g,e,k);h[1]=this.interpolate(j[1],n[1],p[1],v[1],g,e,k);h[2]=this.interpolate(j[2],n[2],p[2],v[2],g,e,k);return h};
 THREE.Animation.prototype.interpolate=function(b,d,e,h,g,j,k){b=(e-b)*0.5;h=(h-d)*0.5;return(2*(d-e)+b+h)*k+(-3*(d-e)-2*b-h)*j+b*g+d};THREE.Animation.prototype.getNextKeyWith=function(b,d,e){var h=this.data.hierarchy[d].keys;if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)e=e<h.length-1?e:h.length-1;else e%=h.length;for(;e<h.length;e++)if(h[e][b]!==undefined)return h[e];return this.data.hierarchy[d].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(b,d,e){var h=this.data.hierarchy[d].keys;for(e=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?e>0?e:0:e>=0?e:e+h.length;e>=0;e--)if(h[e][b]!==undefined)return h[e];return this.data.hierarchy[d].keys[h.length-1]};
 THREE.Camera=function(b,d,e,h,g){THREE.Object3D.call(this);this.fov=b||50;this.aspect=d||1;this.near=e||0.1;this.far=h||2E3;this.target=g||new THREE.Object3D;this.useTarget=!0;this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=null;this.updateProjectionMatrix()};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.supr=THREE.Object3D.prototype;
@@ -114,7 +114,7 @@ this.morphTargetDictionary[this.geometry.morphTargets[e].name]=e}}}};THREE.Mesh.
 THREE.Bone=function(b){THREE.Object3D.call(this);this.skin=b;this.skinMatrix=new THREE.Matrix4;this.hasNoneBoneChildren=!1};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.update=function(b,d,e){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate){b?this.skinMatrix.multiply(b,this.matrix):this.skinMatrix.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;d=!0}var h,g=this.children.length;if(this.hasNoneBoneChildren){this.matrixWorld.multiply(this.skin.matrixWorld,this.skinMatrix);for(h=0;h<g;h++){b=this.children[h];b instanceof THREE.Bone?b.update(this.skinMatrix,d,e):b.update(this.matrixWorld,!0,e)}}else for(h=0;h<g;h++)this.children[h].update(this.skinMatrix,
 d,e)};THREE.Bone.prototype.addChild=function(b){if(this.children.indexOf(b)===-1){b.parent!==undefined&&b.parent.removeChild(b);b.parent=this;this.children.push(b);if(!(b instanceof THREE.Bone))this.hasNoneBoneChildren=!0}};if(!window.Float32Array)window.Float32Array=Array;
-THREE.SkinnedMesh=function(b,d){THREE.Mesh.call(this,b,d);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var e,h,g,j,k,o;if(this.geometry.bones!==undefined){for(e=0;e<this.geometry.bones.length;e++){g=this.geometry.bones[e];j=g.pos;k=g.rotq;o=g.scl;h=this.addBone();h.name=g.name;h.position.set(j[0],j[1],j[2]);h.quaternion.set(k[0],k[1],k[2],k[3]);h.useQuaternion=!0;o!==undefined?h.scale.set(o[0],o[1],o[2]):h.scale.set(1,1,1)}for(e=0;e<this.bones.length;e++){g=this.geometry.bones[e];
+THREE.SkinnedMesh=function(b,d){THREE.Mesh.call(this,b,d);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var e,h,g,j,k,n;if(this.geometry.bones!==undefined){for(e=0;e<this.geometry.bones.length;e++){g=this.geometry.bones[e];j=g.pos;k=g.rotq;n=g.scl;h=this.addBone();h.name=g.name;h.position.set(j[0],j[1],j[2]);h.quaternion.set(k[0],k[1],k[2],k[3]);h.useQuaternion=!0;n!==undefined?h.scale.set(n[0],n[1],n[2]):h.scale.set(1,1,1)}for(e=0;e<this.bones.length;e++){g=this.geometry.bones[e];
 h=this.bones[e];g.parent===-1?this.addChild(h):this.bones[g.parent].addChild(h)}this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
 THREE.SkinnedMesh.prototype.update=function(b,d,e){if(this.visible){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;d=!0}var h,g=this.children.length;for(h=0;h<g;h++){b=this.children[h];b instanceof THREE.Bone?b.update(this.identityMatrix,!1,e):b.update(this.matrixWorld,d,e)}e=this.bones.length;ba=this.bones;bm=this.boneMatrices;for(d=0;d<e;d++)ba[d].skinMatrix.flattenToArrayOffset(bm,
 d*16)}};THREE.SkinnedMesh.prototype.addBone=function(b){b===undefined&&(b=new THREE.Bone(this));this.bones.push(b);return b};
@@ -130,24 +130,24 @@ THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.add=functi
 THREE.LOD.prototype.update=function(b,d,e){this.matrixAutoUpdate&&(d|=this.updateMatrix());if(d||this.matrixWorldNeedsUpdate){b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix);this.matrixWorldNeedsUpdate=!1;d=!0}if(this.LODs.length>1){b=e.matrixWorldInverse;b=-(b.n31*this.position.x+b.n32*this.position.y+b.n33*this.position.z+b.n34);this.LODs[0].object3D.visible=!0;for(var h=1;h<this.LODs.length;h++)if(b>=this.LODs[h].visibleAtDistance){this.LODs[h-1].object3D.visible=
 !1;this.LODs[h].object3D.visible=!0}else break;for(;h<this.LODs.length;h++)this.LODs[h].object3D.visible=!1}for(b=0;b<this.children.length;b++)this.children[b].update(this.matrixWorld,d,e)};THREE.ShadowVolume=function(b,d){THREE.Mesh.call(this,b.geometry,d?[new THREE.ShadowVolumeDynamicMaterial]:[new THREE.ShadowVolumeDynamicMaterial]);b.addChild(this);this.calculateShadowVolumeGeometry(b.geometry)};THREE.ShadowVolume.prototype=new THREE.Mesh;THREE.ShadowVolume.prototype.constructor=THREE.ShadowVolume;
 THREE.ShadowVolume.prototype.supr=THREE.Mesh.prototype;
-THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var d=this.geometry.vertices,e=this.geometry.faces,h=this.geometry.edgeFaces,g=b.faces;b=b.vertices;var j=g.length,k,o,q,v,D,F=["a","b","c","d"];for(q=0;q<j;q++){o=d.length;k=g[q];if(k instanceof THREE.Face4){v=4;o=new THREE.Face4(o,o+1,o+2,o+3)}else{v=3;o=new THREE.Face3(o,o+1,o+2)}o.normal.copy(k.normal);e.push(o);for(o=
-0;o<v;o++){D=b[k[F[o]]];d.push(new THREE.Vertex(D.position.clone()))}}for(j=0;j<g.length-1;j++){b=e[j];for(k=j+1;k<g.length;k++){o=e[k];o=this.facesShareEdge(d,b,o);if(o!==undefined){o=new THREE.Face4(o.indices[0],o.indices[3],o.indices[2],o.indices[1]);o.normal.set(1,0,0);h.push(o)}}}};
-THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,e){var h,g,j,k,o,q,v,D,F,J,G,N,O,W=0,P=["a","b","c","d"];h=d instanceof THREE.Face4?4:3;g=e instanceof THREE.Face4?4:3;for(N=0;N<h;N++){j=d[P[N]];o=b[j];for(O=0;O<g;O++){k=e[P[O]];q=b[k];if(Math.abs(o.position.x-q.position.x)<1.0E-4&&Math.abs(o.position.y-q.position.y)<1.0E-4&&Math.abs(o.position.z-q.position.z)<1.0E-4){W++;if(W===1){v=o;D=q;F=j;J=k;G=P[N]}if(W===2){G+=P[N];return G==="ad"||G==="ac"?{faces:[d,e],vertices:[v,D,q,o],indices:[F,
-J,k,j],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[d,e],vertices:[v,o,q,D],indices:[F,j,k,J],vertexTypes:[1,1,2,2],extrudable:!0}}}}}};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;
+THREE.ShadowVolume.prototype.calculateShadowVolumeGeometry=function(b){this.geometry=new THREE.Geometry;this.geometry.boundingSphere=b.boundingSphere;this.geometry.edgeFaces=[];var d=this.geometry.vertices,e=this.geometry.faces,h=this.geometry.edgeFaces,g=b.faces;b=b.vertices;var j=g.length,k,n,p,v,E,F=["a","b","c","d"];for(p=0;p<j;p++){n=d.length;k=g[p];if(k instanceof THREE.Face4){v=4;n=new THREE.Face4(n,n+1,n+2,n+3)}else{v=3;n=new THREE.Face3(n,n+1,n+2)}n.normal.copy(k.normal);e.push(n);for(n=
+0;n<v;n++){E=b[k[F[n]]];d.push(new THREE.Vertex(E.position.clone()))}}for(j=0;j<g.length-1;j++){b=e[j];for(k=j+1;k<g.length;k++){n=e[k];n=this.facesShareEdge(d,b,n);if(n!==undefined){n=new THREE.Face4(n.indices[0],n.indices[3],n.indices[2],n.indices[1]);n.normal.set(1,0,0);h.push(n)}}}};
+THREE.ShadowVolume.prototype.facesShareEdge=function(b,d,e){var h,g,j,k,n,p,v,E,F,K,G,N,O,X=0,Q=["a","b","c","d"];h=d instanceof THREE.Face4?4:3;g=e instanceof THREE.Face4?4:3;for(N=0;N<h;N++){j=d[Q[N]];n=b[j];for(O=0;O<g;O++){k=e[Q[O]];p=b[k];if(Math.abs(n.position.x-p.position.x)<1.0E-4&&Math.abs(n.position.y-p.position.y)<1.0E-4&&Math.abs(n.position.z-p.position.z)<1.0E-4){X++;if(X===1){v=n;E=p;F=j;K=k;G=Q[N]}if(X===2){G+=Q[N];return G==="ad"||G==="ac"?{faces:[d,e],vertices:[v,E,p,n],indices:[F,
+K,k,j],vertexTypes:[1,2,2,1],extrudable:!0}:{faces:[d,e],vertices:[v,n,p,E],indices:[F,j,k,K],vertexTypes:[1,1,2,2],extrudable:!0}}}}}};THREE.Scene=function(){THREE.Object3D.call(this);this.matrixAutoUpdate=!1;this.fog=null;this.objects=[];this.lights=[];this.sounds=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;THREE.Scene.prototype.supr=THREE.Object3D.prototype;
 THREE.Scene.prototype.addChild=function(b){this.supr.addChild.call(this,b);this.addChildRecurse(b)};THREE.Scene.prototype.addChildRecurse=function(b){if(b instanceof THREE.Light)this.lights.indexOf(b)===-1&&this.lights.push(b);else if(b instanceof THREE.Sound)this.sounds.indexOf(b)===-1&&this.sounds.push(b);else if(!(b instanceof THREE.Camera||b instanceof THREE.Bone)&&this.objects.indexOf(b)===-1){this.objects.push(b);this.__objectsAdded.push(b)}for(var d=0;d<b.children.length;d++)this.addChildRecurse(b.children[d])};
 THREE.Scene.prototype.removeChild=function(b){this.supr.removeChild.call(this,b);this.removeChildRecurse(b)};THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light){var d=this.lights.indexOf(b);d!==-1&&this.lights.splice(d,1)}else if(b instanceof THREE.Sound){d=this.sounds.indexOf(b);d!==-1&&this.sounds.splice(d,1)}else if(!(b instanceof THREE.Camera)){d=this.objects.indexOf(b);if(d!==-1){this.objects.splice(d,1);this.__objectsRemoved.push(b)}}for(d=0;d<b.children.length;d++)this.removeChildRecurse(b.children[d])};
 THREE.Scene.prototype.addObject=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeObject=THREE.Scene.prototype.removeChild;THREE.Scene.prototype.addLight=THREE.Scene.prototype.addChild;THREE.Scene.prototype.removeLight=THREE.Scene.prototype.removeChild;THREE.Fog=function(b,d,e){this.color=new THREE.Color(b);this.near=d||1;this.far=e||1E3};THREE.FogExp2=function(b,d){this.color=new THREE.Color(b);this.density=d!==undefined?d:2.5E-4};
-THREE.Projector=function(){function b(){var c=q[o]=q[o]||new THREE.RenderableVertex;o++;return c}function d(c,S){return S.z-c.z}function e(c,S){var oa=0,ta=1,Ea=c.z+c.w,wa=S.z+S.w,aa=-c.z+c.w,ma=-S.z+S.w;if(Ea>=0&&wa>=0&&aa>=0&&ma>=0)return!0;else if(Ea<0&&wa<0||aa<0&&ma<0)return!1;else{if(Ea<0)oa=Math.max(oa,Ea/(Ea-wa));else wa<0&&(ta=Math.min(ta,Ea/(Ea-wa)));if(aa<0)oa=Math.max(oa,aa/(aa-ma));else ma<0&&(ta=Math.min(ta,aa/(aa-ma)));if(ta<oa)return!1;else{c.lerpSelf(S,oa);S.lerpSelf(c,1-ta);return!0}}}
-var h,g,j=[],k,o,q=[],v,D,F=[],J,G=[],N,O,W=[],P,ra,ca=[],sa=new THREE.Vector4,Z=new THREE.Vector4,K=new THREE.Matrix4,Ia=new THREE.Matrix4,ka=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Da=new THREE.Vector4,ea=new THREE.Vector4;this.projectVector=function(c,S){K.multiply(S.projectionMatrix,S.matrixWorldInverse);K.multiplyVector3(c);return c};this.unprojectVector=function(c,S){K.multiply(S.matrixWorld,THREE.Matrix4.makeInvert(S.projectionMatrix));
-K.multiplyVector3(c);return c};this.projectObjects=function(c,S,oa){S=[];var ta,Ea,wa;g=0;Ea=c.objects;c=0;for(ta=Ea.length;c<ta;c++){wa=Ea[c];var aa;if(!(aa=!wa.visible))if(aa=wa instanceof THREE.Mesh){a:{aa=void 0;for(var ma=wa.matrixWorld,na=-wa.geometry.boundingSphere.radius*Math.max(wa.scale.x,Math.max(wa.scale.y,wa.scale.z)),la=0;la<6;la++){aa=ka[la].x*ma.n14+ka[la].y*ma.n24+ka[la].z*ma.n34+ka[la].w;if(aa<=na){aa=!1;break a}}aa=!0}aa=!aa}if(!aa){aa=j[g]=j[g]||new THREE.RenderableObject;g++;
-h=aa;sa.copy(wa.position);K.multiplyVector3(sa);h.object=wa;h.z=sa.z;S.push(h)}}oa&&S.sort(d);return S};this.projectScene=function(c,S,oa){var ta=[],Ea=S.near,wa=S.far,aa,ma,na,la,Y,va,pa,Fa,Ha,$,Oa,Va,Wa,Ta,Ra,Xa,Ya;ra=O=J=D=0;S.matrixAutoUpdate&&S.updateMatrix();c.update(undefined,!1,S);K.multiply(S.projectionMatrix,S.matrixWorldInverse);ka[0].set(K.n41-K.n11,K.n42-K.n12,K.n43-K.n13,K.n44-K.n14);ka[1].set(K.n41+K.n11,K.n42+K.n12,K.n43+K.n13,K.n44+K.n14);ka[2].set(K.n41+K.n21,K.n42+K.n22,K.n43+K.n23,
-K.n44+K.n24);ka[3].set(K.n41-K.n21,K.n42-K.n22,K.n43-K.n23,K.n44-K.n24);ka[4].set(K.n41-K.n31,K.n42-K.n32,K.n43-K.n33,K.n44-K.n34);ka[5].set(K.n41+K.n31,K.n42+K.n32,K.n43+K.n33,K.n44+K.n34);for(aa=0;aa<6;aa++){Ha=ka[aa];Ha.divideScalar(Math.sqrt(Ha.x*Ha.x+Ha.y*Ha.y+Ha.z*Ha.z))}Ha=this.projectObjects(c,S,!0);c=0;for(aa=Ha.length;c<aa;c++){$=Ha[c].object;if($.visible){Oa=$.matrixWorld;Va=$.matrixRotationWorld;Wa=$.materials;Ta=$.overdraw;o=0;if($ instanceof THREE.Mesh){Ra=$.geometry;la=Ra.vertices;
-Xa=Ra.faces;Ra=Ra.faceVertexUvs;ma=0;for(na=la.length;ma<na;ma++){k=b();k.positionWorld.copy(la[ma].position);Oa.multiplyVector3(k.positionWorld);k.positionScreen.copy(k.positionWorld);K.multiplyVector4(k.positionScreen);k.positionScreen.x/=k.positionScreen.w;k.positionScreen.y/=k.positionScreen.w;k.visible=k.positionScreen.z>Ea&&k.positionScreen.z<wa}la=0;for(ma=Xa.length;la<ma;la++){na=Xa[la];if(na instanceof THREE.Face3){Y=q[na.a];va=q[na.b];pa=q[na.c];if(Y.visible&&va.visible&&pa.visible&&($.doubleSided||
-$.flipSided!=(pa.positionScreen.x-Y.positionScreen.x)*(va.positionScreen.y-Y.positionScreen.y)-(pa.positionScreen.y-Y.positionScreen.y)*(va.positionScreen.x-Y.positionScreen.x)<0)){Fa=F[D]=F[D]||new THREE.RenderableFace3;D++;v=Fa;v.v1.copy(Y);v.v2.copy(va);v.v3.copy(pa)}else continue}else if(na instanceof THREE.Face4){Y=q[na.a];va=q[na.b];pa=q[na.c];Fa=q[na.d];if(Y.visible&&va.visible&&pa.visible&&Fa.visible&&($.doubleSided||$.flipSided!=((Fa.positionScreen.x-Y.positionScreen.x)*(va.positionScreen.y-
-Y.positionScreen.y)-(Fa.positionScreen.y-Y.positionScreen.y)*(va.positionScreen.x-Y.positionScreen.x)<0||(va.positionScreen.x-pa.positionScreen.x)*(Fa.positionScreen.y-pa.positionScreen.y)-(va.positionScreen.y-pa.positionScreen.y)*(Fa.positionScreen.x-pa.positionScreen.x)<0))){Ya=G[J]=G[J]||new THREE.RenderableFace4;J++;v=Ya;v.v1.copy(Y);v.v2.copy(va);v.v3.copy(pa);v.v4.copy(Fa)}else continue}v.normalWorld.copy(na.normal);Va.multiplyVector3(v.normalWorld);v.centroidWorld.copy(na.centroid);Oa.multiplyVector3(v.centroidWorld);
-v.centroidScreen.copy(v.centroidWorld);K.multiplyVector3(v.centroidScreen);pa=na.vertexNormals;Y=0;for(va=pa.length;Y<va;Y++){Fa=v.vertexNormalsWorld[Y];Fa.copy(pa[Y]);Va.multiplyVector3(Fa)}Y=0;for(va=Ra.length;Y<va;Y++)if(Ya=Ra[Y][la]){pa=0;for(Fa=Ya.length;pa<Fa;pa++)v.uvs[Y][pa]=Ya[pa]}v.meshMaterials=Wa;v.faceMaterials=na.materials;v.overdraw=Ta;v.z=v.centroidScreen.z;ta.push(v)}}else if($ instanceof THREE.Line){Ia.multiply(K,Oa);la=$.geometry.vertices;Y=b();Y.positionScreen.copy(la[0].position);
-Ia.multiplyVector4(Y.positionScreen);ma=1;for(na=la.length;ma<na;ma++){Y=b();Y.positionScreen.copy(la[ma].position);Ia.multiplyVector4(Y.positionScreen);va=q[o-2];Da.copy(Y.positionScreen);ea.copy(va.positionScreen);if(e(Da,ea)){Da.multiplyScalar(1/Da.w);ea.multiplyScalar(1/ea.w);Oa=W[O]=W[O]||new THREE.RenderableLine;O++;N=Oa;N.v1.positionScreen.copy(Da);N.v2.positionScreen.copy(ea);N.z=Math.max(Da.z,ea.z);N.materials=$.materials;ta.push(N)}}}else if($ instanceof THREE.Particle){Z.set($.position.x,
-$.position.y,$.position.z,1);K.multiplyVector4(Z);Z.z/=Z.w;if(Z.z>0&&Z.z<1){Oa=ca[ra]=ca[ra]||new THREE.RenderableParticle;ra++;P=Oa;P.x=Z.x/Z.w;P.y=Z.y/Z.w;P.z=Z.z;P.rotation=$.rotation.z;P.scale.x=$.scale.x*Math.abs(P.x-(Z.x+S.projectionMatrix.n11)/(Z.w+S.projectionMatrix.n14));P.scale.y=$.scale.y*Math.abs(P.y-(Z.y+S.projectionMatrix.n22)/(Z.w+S.projectionMatrix.n24));P.materials=$.materials;ta.push(P)}}}}oa&&ta.sort(d);return ta}};
+THREE.Projector=function(){function b(){var T=p[n]=p[n]||new THREE.RenderableVertex;n++;return T}function d(T,U){return U.z-T.z}function e(T,U){var na=0,Fa=1,Ga=T.z+T.w,ya=U.z+U.w,aa=-T.z+T.w,pa=-U.z+U.w;if(Ga>=0&&ya>=0&&aa>=0&&pa>=0)return!0;else if(Ga<0&&ya<0||aa<0&&pa<0)return!1;else{if(Ga<0)na=Math.max(na,Ga/(Ga-ya));else ya<0&&(Fa=Math.min(Fa,Ga/(Ga-ya)));if(aa<0)na=Math.max(na,aa/(aa-pa));else pa<0&&(Fa=Math.min(Fa,aa/(aa-pa)));if(Fa<na)return!1;else{T.lerpSelf(U,na);U.lerpSelf(T,1-Fa);return!0}}}
+var h,g,j=[],k,n,p=[],v,E,F=[],K,G=[],N,O,X=[],Q,ca,ma=[],wa=new THREE.Vector4,$=new THREE.Vector4,L=new THREE.Matrix4,xa=new THREE.Matrix4,ta=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ea=new THREE.Vector4,c=new THREE.Vector4;this.projectVector=function(T,U){L.multiply(U.projectionMatrix,U.matrixWorldInverse);L.multiplyVector3(T);return T};this.unprojectVector=function(T,U){L.multiply(U.matrixWorld,THREE.Matrix4.makeInvert(U.projectionMatrix));
+L.multiplyVector3(T);return T};this.projectObjects=function(T,U,na){U=[];var Fa,Ga,ya;g=0;Ga=T.objects;T=0;for(Fa=Ga.length;T<Fa;T++){ya=Ga[T];var aa;if(!(aa=!ya.visible))if(aa=ya instanceof THREE.Mesh){a:{aa=void 0;for(var pa=ya.matrixWorld,fa=-ya.geometry.boundingSphere.radius*Math.max(ya.scale.x,Math.max(ya.scale.y,ya.scale.z)),qa=0;qa<6;qa++){aa=ta[qa].x*pa.n14+ta[qa].y*pa.n24+ta[qa].z*pa.n34+ta[qa].w;if(aa<=fa){aa=!1;break a}}aa=!0}aa=!aa}if(!aa){aa=j[g]=j[g]||new THREE.RenderableObject;g++;
+h=aa;wa.copy(ya.position);L.multiplyVector3(wa);h.object=ya;h.z=wa.z;U.push(h)}}na&&U.sort(d);return U};this.projectScene=function(T,U,na){var Fa=[],Ga=U.near,ya=U.far,aa,pa,fa,qa,Y,ua,oa,Ca,za,ga,Oa,Ta,Ua,gb,Qa,eb,Wa;ca=O=K=E=0;U.matrixAutoUpdate&&U.updateMatrix();T.update(undefined,!1,U);L.multiply(U.projectionMatrix,U.matrixWorldInverse);ta[0].set(L.n41-L.n11,L.n42-L.n12,L.n43-L.n13,L.n44-L.n14);ta[1].set(L.n41+L.n11,L.n42+L.n12,L.n43+L.n13,L.n44+L.n14);ta[2].set(L.n41+L.n21,L.n42+L.n22,L.n43+
+L.n23,L.n44+L.n24);ta[3].set(L.n41-L.n21,L.n42-L.n22,L.n43-L.n23,L.n44-L.n24);ta[4].set(L.n41-L.n31,L.n42-L.n32,L.n43-L.n33,L.n44-L.n34);ta[5].set(L.n41+L.n31,L.n42+L.n32,L.n43+L.n33,L.n44+L.n34);for(aa=0;aa<6;aa++){za=ta[aa];za.divideScalar(Math.sqrt(za.x*za.x+za.y*za.y+za.z*za.z))}za=this.projectObjects(T,U,!0);T=0;for(aa=za.length;T<aa;T++){ga=za[T].object;if(ga.visible){Oa=ga.matrixWorld;Ta=ga.matrixRotationWorld;Ua=ga.materials;gb=ga.overdraw;n=0;if(ga instanceof THREE.Mesh){Qa=ga.geometry;qa=
+Qa.vertices;eb=Qa.faces;Qa=Qa.faceVertexUvs;pa=0;for(fa=qa.length;pa<fa;pa++){k=b();k.positionWorld.copy(qa[pa].position);Oa.multiplyVector3(k.positionWorld);k.positionScreen.copy(k.positionWorld);L.multiplyVector4(k.positionScreen);k.positionScreen.x/=k.positionScreen.w;k.positionScreen.y/=k.positionScreen.w;k.visible=k.positionScreen.z>Ga&&k.positionScreen.z<ya}qa=0;for(pa=eb.length;qa<pa;qa++){fa=eb[qa];if(fa instanceof THREE.Face3){Y=p[fa.a];ua=p[fa.b];oa=p[fa.c];if(Y.visible&&ua.visible&&oa.visible&&
+(ga.doubleSided||ga.flipSided!=(oa.positionScreen.x-Y.positionScreen.x)*(ua.positionScreen.y-Y.positionScreen.y)-(oa.positionScreen.y-Y.positionScreen.y)*(ua.positionScreen.x-Y.positionScreen.x)<0)){Ca=F[E]=F[E]||new THREE.RenderableFace3;E++;v=Ca;v.v1.copy(Y);v.v2.copy(ua);v.v3.copy(oa)}else continue}else if(fa instanceof THREE.Face4){Y=p[fa.a];ua=p[fa.b];oa=p[fa.c];Ca=p[fa.d];if(Y.visible&&ua.visible&&oa.visible&&Ca.visible&&(ga.doubleSided||ga.flipSided!=((Ca.positionScreen.x-Y.positionScreen.x)*
+(ua.positionScreen.y-Y.positionScreen.y)-(Ca.positionScreen.y-Y.positionScreen.y)*(ua.positionScreen.x-Y.positionScreen.x)<0||(ua.positionScreen.x-oa.positionScreen.x)*(Ca.positionScreen.y-oa.positionScreen.y)-(ua.positionScreen.y-oa.positionScreen.y)*(Ca.positionScreen.x-oa.positionScreen.x)<0))){Wa=G[K]=G[K]||new THREE.RenderableFace4;K++;v=Wa;v.v1.copy(Y);v.v2.copy(ua);v.v3.copy(oa);v.v4.copy(Ca)}else continue}v.normalWorld.copy(fa.normal);Ta.multiplyVector3(v.normalWorld);v.centroidWorld.copy(fa.centroid);
+Oa.multiplyVector3(v.centroidWorld);v.centroidScreen.copy(v.centroidWorld);L.multiplyVector3(v.centroidScreen);oa=fa.vertexNormals;Y=0;for(ua=oa.length;Y<ua;Y++){Ca=v.vertexNormalsWorld[Y];Ca.copy(oa[Y]);Ta.multiplyVector3(Ca)}Y=0;for(ua=Qa.length;Y<ua;Y++)if(Wa=Qa[Y][qa]){oa=0;for(Ca=Wa.length;oa<Ca;oa++)v.uvs[Y][oa]=Wa[oa]}v.meshMaterials=Ua;v.faceMaterials=fa.materials;v.overdraw=gb;v.z=v.centroidScreen.z;Fa.push(v)}}else if(ga instanceof THREE.Line){xa.multiply(L,Oa);qa=ga.geometry.vertices;Y=
+b();Y.positionScreen.copy(qa[0].position);xa.multiplyVector4(Y.positionScreen);pa=1;for(fa=qa.length;pa<fa;pa++){Y=b();Y.positionScreen.copy(qa[pa].position);xa.multiplyVector4(Y.positionScreen);ua=p[n-2];ea.copy(Y.positionScreen);c.copy(ua.positionScreen);if(e(ea,c)){ea.multiplyScalar(1/ea.w);c.multiplyScalar(1/c.w);Oa=X[O]=X[O]||new THREE.RenderableLine;O++;N=Oa;N.v1.positionScreen.copy(ea);N.v2.positionScreen.copy(c);N.z=Math.max(ea.z,c.z);N.materials=ga.materials;Fa.push(N)}}}else if(ga instanceof
+THREE.Particle){$.set(ga.position.x,ga.position.y,ga.position.z,1);L.multiplyVector4($);$.z/=$.w;if($.z>0&&$.z<1){Oa=ma[ca]=ma[ca]||new THREE.RenderableParticle;ca++;Q=Oa;Q.x=$.x/$.w;Q.y=$.y/$.w;Q.z=$.z;Q.rotation=ga.rotation.z;Q.scale.x=ga.scale.x*Math.abs(Q.x-($.x+U.projectionMatrix.n11)/($.w+U.projectionMatrix.n14));Q.scale.y=ga.scale.y*Math.abs(Q.y-($.y+U.projectionMatrix.n22)/($.w+U.projectionMatrix.n24));Q.materials=ga.materials;Fa.push(Q)}}}}na&&Fa.sort(d);return Fa}};
 THREE.SoundRenderer=function(){this.volume=1;this.domElement=document.createElement("div");this.domElement.id="THREESound";this.cameraPosition=new THREE.Vector3;this.soundPosition=new THREE.Vector3;this.render=function(b,d,e){e&&b.update(undefined,!1,d);e=b.sounds;var h,g=e.length;for(h=0;h<g;h++){b=e[h];this.soundPosition.set(b.matrixWorld.n14,b.matrixWorld.n24,b.matrixWorld.n34);this.soundPosition.subSelf(d.position);if(b.isPlaying&&b.isLoaded){b.isAddedToDOM||b.addToDOM(this.domElement);b.calculateVolumeAndPan(this.soundPosition)}}}};
 THREE.ShaderChunk={fog_pars_fragment:"#ifdef USE_FOG\nuniform vec3 fogColor;\n#ifdef FOG_EXP2\nuniform float fogDensity;\n#else\nuniform float fogNear;\nuniform float fogFar;\n#endif\n#endif",fog_fragment:"#ifdef USE_FOG\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n#ifdef FOG_EXP2\nconst float LOG2 = 1.442695;\nfloat fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n#else\nfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n#endif\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n#endif",
 envmap_pars_fragment:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float reflectivity;\nuniform samplerCube envMap;\nuniform int combine;\n#endif",envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( -vReflect.x, vReflect.yz ) );\nif ( combine == 1 ) {\ngl_FragColor = vec4( mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity ), opacity );\n} else {\ngl_FragColor = gl_FragColor * cubeColor;\n}\n#endif",envmap_pars_vertex:"#ifdef USE_ENVMAP\nvarying vec3 vReflect;\nuniform float refractionRatio;\nuniform bool useRefract;\n#endif",
@@ -175,103 +175,103 @@ THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.
 vertexShader:["#define PHONG\nvarying vec3 vLightWeighting;\nvarying vec3 vViewPosition;\nvarying vec3 vNormal;",THREE.ShaderChunk.map_pars_vertex,THREE.ShaderChunk.lightmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.lights_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.map_vertex,THREE.ShaderChunk.lightmap_vertex,
 THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.color_vertex,"#ifndef USE_ENVMAP\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\n#endif\nvViewPosition = cameraPosition - mPosition.xyz;\nvec3 transformedNormal = normalize( normalMatrix * normal );\nvNormal = transformedNormal;",THREE.ShaderChunk.lights_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsLib.particle,fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",
 THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n"),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n#ifdef USE_SIZEATTENUATION\ngl_PointSize = size * ( scale / length( mvPosition.xyz ) );\n#else\ngl_PointSize = size;\n#endif\ngl_Position = projectionMatrix * mvPosition;\n}"].join("\n")}};
-THREE.WebGLRenderer=function(b){function d(f,p,n){var i,m,z,s=f.vertices,u=s.length,w=f.colors,r=w.length,t=f.__vertexArray,A=f.__colorArray,M=f.__sortArray,B=f.__dirtyVertices,Q=f.__dirtyColors;if(n.sortParticles){Oa.multiplySelf(n.matrixWorld);for(i=0;i<u;i++){m=s[i].position;Ta.copy(m);Oa.multiplyVector3(Ta);M[i]=[Ta.z,i]}M.sort(function(U,R){return R[0]-U[0]});for(i=0;i<u;i++){m=s[M[i][1]].position;z=i*3;t[z]=m.x;t[z+1]=m.y;t[z+2]=m.z}for(i=0;i<r;i++){z=i*3;color=w[M[i][1]];A[z]=color.r;A[z+1]=
-color.g;A[z+2]=color.b}}else{if(B)for(i=0;i<u;i++){m=s[i].position;z=i*3;t[z]=m.x;t[z+1]=m.y;t[z+2]=m.z}if(Q)for(i=0;i<r;i++){color=w[i];z=i*3;A[z]=color.r;A[z+1]=color.g;A[z+2]=color.b}}if(B||n.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,t,p)}if(Q||n.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,A,p)}}function e(f,p){f.uniforms=Uniforms.clone(p.uniforms);f.vertexShader=p.vertexShader;f.fragmentShader=
-p.fragmentShader}function h(f,p,n,i,m){i.program||aa.initMaterial(i,p,n,m);var z=i.program,s=z.uniforms,u=i.uniforms;if(z!=ta){c.useProgram(z);ta=z}c.uniformMatrix4fv(s.projectionMatrix,!1,Va);if(n&&(i instanceof THREE.MeshBasicMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshPhongMaterial||i instanceof THREE.LineBasicMaterial||i instanceof THREE.ParticleBasicMaterial||i.fog)){u.fogColor.value.setHex(n.color.hex);if(n instanceof THREE.Fog){u.fogNear.value=n.near;u.fogFar.value=
-n.far}else if(n instanceof THREE.FogExp2)u.fogDensity.value=n.density}if(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i.lights){var w,r,t=0,A=0,M=0,B,Q,U,R,T=Ra,Ca=T.directional.colors,H=T.directional.positions,E=T.point.colors,I=T.point.positions,X=T.point.distances,C=0,x=0;n=r=R=0;for(w=p.length;n<w;n++){r=p[n];B=r.color;Q=r.position;U=r.intensity;R=r.distance;if(r instanceof THREE.AmbientLight){t+=B.r;A+=B.g;M+=B.b}else if(r instanceof THREE.DirectionalLight){R=
-C*3;Ca[R]=B.r*U;Ca[R+1]=B.g*U;Ca[R+2]=B.b*U;H[R]=Q.x;H[R+1]=Q.y;H[R+2]=Q.z;C+=1}else if(r instanceof THREE.PointLight){r=x*3;E[r]=B.r*U;E[r+1]=B.g*U;E[r+2]=B.b*U;I[r]=Q.x;I[r+1]=Q.y;I[r+2]=Q.z;X[x]=R;x+=1}}for(n=C*3;n<Ca.length;n++)Ca[n]=0;for(n=x*3;n<E.length;n++)E[n]=0;T.point.length=x;T.directional.length=C;T.ambient[0]=t;T.ambient[1]=A;T.ambient[2]=M;n=Ra;u.enableLighting.value=n.directional.length+n.point.length;u.ambientLightColor.value=n.ambient;u.directionalLightColor.value=n.directional.colors;
-u.directionalLightDirection.value=n.directional.positions;u.pointLightColor.value=n.point.colors;u.pointLightPosition.value=n.point.positions;u.pointLightDistance.value=n.point.distances}if(i instanceof THREE.MeshBasicMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshPhongMaterial){u.diffuse.value.setRGB(i.color.r,i.color.g,i.color.b);u.opacity.value=i.opacity;u.map.texture=i.map;u.lightMap.texture=i.lightMap;u.envMap.texture=i.envMap;u.reflectivity.value=i.reflectivity;u.refractionRatio.value=
-i.refractionRatio;u.combine.value=i.combine;u.useRefract.value=i.envMap&&i.envMap.mapping instanceof THREE.CubeRefractionMapping}if(i instanceof THREE.LineBasicMaterial){u.diffuse.value.setRGB(i.color.r,i.color.g,i.color.b);u.opacity.value=i.opacity}else if(i instanceof THREE.ParticleBasicMaterial){u.psColor.value.setRGB(i.color.r,i.color.g,i.color.b);u.opacity.value=i.opacity;u.size.value=i.size;u.scale.value=S.height/2;u.map.texture=i.map}else if(i instanceof THREE.MeshPhongMaterial){u.ambient.value.setRGB(i.ambient.r,
-i.ambient.g,i.ambient.b);u.specular.value.setRGB(i.specular.r,i.specular.g,i.specular.b);u.shininess.value=i.shininess}else if(i instanceof THREE.MeshDepthMaterial){u.mNear.value=f.near;u.mFar.value=f.far;u.opacity.value=i.opacity}else if(i instanceof THREE.MeshNormalMaterial)u.opacity.value=i.opacity;for(var qa in u)if(A=z.uniforms[qa]){w=u[qa];t=w.type;n=w.value;if(t=="i")c.uniform1i(A,n);else if(t=="f")c.uniform1f(A,n);else if(t=="fv1")c.uniform1fv(A,n);else if(t=="fv")c.uniform3fv(A,n);else if(t==
-"v2")c.uniform2f(A,n.x,n.y);else if(t=="v3")c.uniform3f(A,n.x,n.y,n.z);else if(t=="v4")c.uniform4f(A,n.x,n.y,n.z,n.w);else if(t=="c")c.uniform3f(A,n.r,n.g,n.b);else if(t=="t"){c.uniform1i(A,n);if(w=w.texture)if(w.image instanceof Array&&w.image.length==6){if(w.image.length==6){if(w.needsUpdate){if(w.__webglInit){c.bindTexture(c.TEXTURE_CUBE_MAP,w.image.__webglTextureCube);for(t=0;t<6;++t)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,c.RGBA,c.UNSIGNED_BYTE,w.image[t])}else{w.image.__webglTextureCube=
-c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,w.image.__webglTextureCube);for(t=0;t<6;++t)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,w.image[t]);w.__webglInit=!0}Z(c.TEXTURE_CUBE_MAP,w,w.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);w.needsUpdate=!1}c.activeTexture(c.TEXTURE0+n);c.bindTexture(c.TEXTURE_CUBE_MAP,w.image.__webglTextureCube)}}else K(w,n)}}c.uniformMatrix4fv(s.modelViewMatrix,!1,m._modelViewMatrixArray);c.uniformMatrix3fv(s.normalMatrix,!1,m._normalMatrixArray);
-(i instanceof THREE.MeshShaderMaterial||i instanceof THREE.MeshPhongMaterial||i.envMap)&&c.uniform3f(s.cameraPosition,f.position.x,f.position.y,f.position.z);(i instanceof THREE.MeshShaderMaterial||i.envMap||i.skinning)&&c.uniformMatrix4fv(s.objectMatrix,!1,m._objectMatrixArray);(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshShaderMaterial||i.skinning)&&c.uniformMatrix4fv(s.viewMatrix,!1,Wa);if(i instanceof THREE.ShadowVolumeDynamicMaterial){f=
-u.directionalLightDirection.value;f[0]=-p.position.x;f[1]=-p.position.y;f[2]=-p.position.z;c.uniform3fv(s.directionalLightDirection,f);c.uniformMatrix4fv(s.objectMatrix,!1,m._objectMatrixArray);c.uniformMatrix4fv(s.viewMatrix,!1,Wa)}if(i.skinning){c.uniformMatrix4fv(s.cameraInverseMatrix,!1,Wa);c.uniformMatrix4fv(s.boneGlobalMatrices,!1,m.boneMatrices)}return z}function g(f,p,n,i,m,z){if(i.opacity!=0){var s;f=h(f,p,n,i,z).attributes;if(i.morphTargets){p=i.program.attributes;z.morphTargetBase!==-1?
-c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[z.morphTargetBase]):c.bindBuffer(c.ARRAY_BUFFER,m.__webglVertexBuffer);c.vertexAttribPointer(p.position,3,c.FLOAT,!1,0,0);if(z.morphTargetForcedOrder.length){n=0;for(var u=z.morphTargetForcedOrder,w=z.morphTargetInfluences;n<i.numSupportedMorphTargets&&n<u.length;){c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[u[n]]);c.vertexAttribPointer(p["morphTarget"+n],3,c.FLOAT,!1,0,0);z.__webglMorphTargetInfluences[n]=w[u[n]];n++}}else{u=[];
-var r=-1,t=0;w=z.morphTargetInfluences;var A,M=w.length;n=0;for(z.morphTargetBase!==-1&&(u[z.morphTargetBase]=!0);n<i.numSupportedMorphTargets;){for(A=0;A<M;A++)if(!u[A]&&w[A]>r){t=A;r=w[t]}c.bindBuffer(c.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[t]);c.vertexAttribPointer(p["morphTarget"+n],3,c.FLOAT,!1,0,0);z.__webglMorphTargetInfluences[n]=r;u[t]=1;r=-1;n++}}c.uniform1fv(i.program.uniforms.morphTargetInfluences,z.__webglMorphTargetInfluences)}else{c.bindBuffer(c.ARRAY_BUFFER,m.__webglVertexBuffer);
-c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0)}if(m.__webglCustomAttributes)for(s in m.__webglCustomAttributes)if(f[s]>=0){p=m.__webglCustomAttributes[s];c.bindBuffer(c.ARRAY_BUFFER,p.buffer);c.vertexAttribPointer(f[s],p.size,c.FLOAT,!1,0,0)}if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglNormalBuffer);c.vertexAttribPointer(f.normal,3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,
-m.__webglTangentBuffer);c.vertexAttribPointer(f.tangent,4,c.FLOAT,!1,0,0)}if(f.uv>=0)if(m.__webglUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,m.__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(m.__webglUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,m.__webglUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2);if(i.skinning&&f.skinVertexA>=0&&
-f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,m.__webglSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight,4,c.FLOAT,!1,0,0)}if(z instanceof
-THREE.Mesh)if(i.wireframe){c.lineWidth(i.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webglLineBuffer);c.drawElements(c.LINES,m.__webglLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,m.__webglFaceBuffer);c.drawElements(c.TRIANGLES,m.__webglFaceCount,c.UNSIGNED_SHORT,0)}else if(z instanceof THREE.Line){z=z.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(i.linewidth);c.drawArrays(z,0,m.__webglLineCount)}else if(z instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,
-0,m.__webglParticleCount);else z instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,m.__webglVertexCount)}}function j(f,p){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(p.attributes.position);c.vertexAttribPointer(p.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(p.attributes.normal);c.vertexAttribPointer(p.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,0,f.count);f.count=0}function k(f){if(ma!=f.doubleSided){f.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);ma=f.doubleSided}if(na!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);na=f.flipSided}}function o(f){if(Y!=f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);
-Y=f}}function q(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 p;for(f=0;f<6;f++){p=$[f];p.divideScalar(Math.sqrt(p.x*p.x+p.y*p.y+p.z*p.z))}}function v(f){for(var p=f.matrixWorld,n=-f.geometry.boundingSphere.radius*
-Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),i=0;i<6;i++){f=$[i].x*p.n14+$[i].y*p.n24+$[i].z*p.n34+$[i].w;if(f<=n)return!1}return!0}function D(f,p){f.list[f.count]=p;f.count+=1}function F(f){var p,n,i=f.object,m=f.opaque,z=f.transparent;z.count=0;f=m.count=0;for(p=i.materials.length;f<p;f++){n=i.materials[f];n.transparent?D(z,n):D(m,n)}}function J(f){var p,n,i,m,z=f.object,s=f.buffer,u=f.opaque,w=f.transparent;w.count=0;f=u.count=0;for(i=z.materials.length;f<i;f++){p=z.materials[f];if(p instanceof
-THREE.MeshFaceMaterial){p=0;for(n=s.materials.length;p<n;p++)(m=s.materials[p])&&(m.transparent?D(w,m):D(u,m))}else(m=p)&&(m.transparent?D(w,m):D(u,m))}}function G(f,p){return p.z-f.z}function N(f){c.enable(c.POLYGON_OFFSET_FILL);c.polygonOffset(0.1,1);c.enable(c.STENCIL_TEST);c.depthMask(!1);c.colorMask(!1,!1,!1,!1);c.stencilFunc(c.ALWAYS,1,255);c.stencilOpSeparate(c.BACK,c.KEEP,c.INCR,c.KEEP);c.stencilOpSeparate(c.FRONT,c.KEEP,c.DECR,c.KEEP);var p,n=f.lights.length,i,m=f.lights,z=[],s,u,w,r,t,A=
-f.__webglShadowVolumes.length;for(p=0;p<n;p++){i=f.lights[p];if(i instanceof THREE.DirectionalLight){z[0]=-i.position.x;z[1]=-i.position.y;z[2]=-i.position.z;for(t=0;t<A;t++){i=f.__webglShadowVolumes[t].object;s=f.__webglShadowVolumes[t].buffer;u=i.materials[0];u.program||aa.initMaterial(u,m,undefined,i);u=u.program;w=u.uniforms;r=u.attributes;if(ta!==u){c.useProgram(u);ta=u;c.uniformMatrix4fv(w.projectionMatrix,!1,Va);c.uniformMatrix4fv(w.viewMatrix,!1,Wa);c.uniform3fv(w.directionalLightDirection,
-z)}i.matrixWorld.flattenToArray(i._objectMatrixArray);c.uniformMatrix4fv(w.objectMatrix,!1,i._objectMatrixArray);c.bindBuffer(c.ARRAY_BUFFER,s.__webglVertexBuffer);c.vertexAttribPointer(r.position,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,s.__webglNormalBuffer);c.vertexAttribPointer(r.normal,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,s.__webglFaceBuffer);c.cullFace(c.FRONT);c.drawElements(c.TRIANGLES,s.__webglFaceCount,c.UNSIGNED_SHORT,0);c.cullFace(c.BACK);c.drawElements(c.TRIANGLES,
-s.__webglFaceCount,c.UNSIGNED_SHORT,0)}}}c.disable(c.POLYGON_OFFSET_FILL);c.colorMask(!0,!0,!0,!0);c.stencilFunc(c.NOTEQUAL,0,255);c.stencilOp(c.KEEP,c.KEEP,c.KEEP);c.disable(c.DEPTH_TEST);la="";ta=V.program;c.useProgram(V.program);c.uniformMatrix4fv(V.projectionLocation,!1,Va);c.uniform1f(V.darknessLocation,V.darkness);c.bindBuffer(c.ARRAY_BUFFER,V.vertexBuffer);c.vertexAttribPointer(V.vertexLocation,3,c.FLOAT,!1,0,0);c.enableVertexAttribArray(V.vertexLocation);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);
-c.blendEquation(c.FUNC_ADD);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,V.elementBuffer);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.disable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);c.depthMask(wa)}function O(f,p){var n,i,m,z=f.__webglLensFlares.length,s,u,w;s=new THREE.Vector3;var r=Ha/Fa;u=Fa*0.5;w=Ha*0.5;var t=16/Ha,A=[t*r,t],M=[1,1,0];t=[1,1];var B,Q=L.readBackPixels,U,R,T=L.uniforms;n=L.attributes;c.useProgram(L.program);ta=L.program;la="";c.uniform1i(T.map,0);c.activeTexture(c.TEXTURE0);c.uniform1f(T.opacity,
-1);c.uniform1f(T.rotation,0);c.uniform2fv(T.scale,A);c.bindBuffer(c.ARRAY_BUFFER,L.vertexBuffer);c.vertexAttribPointer(n.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(n.uv,2,c.FLOAT,!1,16,8);c.bindTexture(c.TEXTURE_2D,L.tempTexture);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,L.elementBuffer);c.disable(c.CULL_FACE);c.depthMask(!1);for(m=0;m<z;m++){n=f.__webglLensFlares[m].object;s.set(n.matrixWorld.n14,n.matrixWorld.n24,n.matrixWorld.n34);p.matrixWorldInverse.multiplyVector3(s);i=s.z;p.projectionMatrix.multiplyVector3(s);
-M[0]=s.x;M[1]=s.y;M[2]=s.z;t[0]=M[0]*u+u;t[1]=M[1]*w+w;c.copyTexSubImage2D(c.TEXTURE_2D,0,0,0,t[0]-8,t[1]-8,16,16);c.uniform3fv(T.screenPosition,M);c.uniform1i(T.renderPink,1);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);try{c.readPixels(t[0]-8,t[1]-8,16,16,c.RGBA,c.UNSIGNED_BYTE,L.readBackPixels)}catch(Ca){console.log("WebGLRenderer.renderLensFlare: readPixels failed!")}c.getError()&&console.log("WebGLRenderer.renderLensFlare: readPixels failed!");sampleDistance=parseInt(5*
-(1-Math.max(0,Math.min(-i,p.far))/p.far),10)+2;i=sampleDistance*4;B=sampleDistance*64;R=0;U=28-i+(448-B);L.readBackPixels[U+0]===255&&L.readBackPixels[U+1]===0&&L.readBackPixels[U+2]===255&&(R+=0.2);U=28+i+(448-B);Q[U+0]===255&&Q[U+1]===0&&Q[U+2]===255&&(R+=0.2);U=28+i+(448+B);Q[U+0]===255&&Q[U+1]===0&&Q[U+2]===255&&(R+=0.2);U=28-i+(448+B);Q[U+0]===255&&Q[U+1]===0&&Q[U+2]===255&&(R+=0.2);U=476;Q[U+0]===255&&Q[U+1]===0&&Q[U+2]===255&&(R+=0.2);n.positionScreen.x=M[0];n.positionScreen.y=M[1];n.positionScreen.z=
-M[2];n.customUpdateCallback?n.customUpdateCallback(R,n):n.updateLensFlares(R);c.uniform1i(T.renderPink,0);c.disable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}for(m=0;m<z;m++){n=f.__webglLensFlares[m].object;s=0;for(u=n.lensFlares.length;s<u;s++){w=n.lensFlares[s];if(w.opacity>0.001&&w.scale>0.001){M[0]=w.x;M[1]=w.y;M[2]=w.z;t=w.size*w.scale/Ha;A[0]=t*r;A[1]=t;c.uniform3fv(T.screenPosition,M);c.uniform1f(T.rotation,w.rotation);c.uniform2fv(T.scale,A);c.uniform1f(T.opacity,w.opacity);
-sa(w.blending);K(w.texture,0);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(wa)}function W(f,p){f._modelViewMatrix.multiplyToArray(p.matrixWorldInverse,f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function P(f){var p,n,i,m,z;if(f instanceof THREE.Mesh){n=f.geometry;for(p in n.geometryGroups){i=n.geometryGroups[p];z=!1;for(m in i.__webglCustomAttributes)if(i.__webglCustomAttributes[m].needsUpdate){z=
-!0;break}if(n.__dirtyVertices||n.__dirtyMorphTargets||n.__dirtyElements||n.__dirtyUvs||n.__dirtyNormals||n.__dirtyColors||n.__dirtyTangents||z){z=c.DYNAMIC_DRAW;var s=void 0,u=void 0,w=void 0,r=void 0;w=void 0;var t=void 0,A=void 0,M=void 0,B=void 0,Q=void 0,U=void 0,R=void 0,T=void 0,Ca=void 0,H=void 0,E=void 0,I=void 0,X=void 0;A=void 0;M=void 0;r=void 0;B=void 0;r=void 0;H=void 0;E=void 0;A=void 0;H=void 0;E=void 0;I=void 0;X=void 0;H=void 0;E=void 0;I=void 0;X=void 0;H=void 0;E=void 0;I=void 0;
-X=void 0;H=void 0;E=void 0;I=void 0;r=void 0;B=void 0;t=void 0;w=void 0;w=void 0;var C=void 0,x=void 0,qa=void 0,Za=void 0,ua=0,ya=0,ab=0,bb=0,Ja=0,Ka=0,da=0,La=0,xa=0,y=0,za=0;C=0;var Aa=i.__vertexArray,hb=i.__uvArray,ib=i.__uv2Array,Pa=i.__normalArray,fa=i.__tangentArray,Ba=i.__colorArray,ga=i.__skinVertexAArray,ha=i.__skinVertexBArray,ia=i.__skinIndexArray,ja=i.__skinWeightArray,jb=i.__morphTargetsArrays,Qa=i.__webglCustomAttributes;x=void 0;var Ma=i.__faceArray,Na=i.__lineArray,qb=i.__needsSmoothNormals;
-U=i.__vertexColorType;Q=i.__uvType;R=i.__normalType;var Ga=f.geometry,kb=Ga.__dirtyVertices,lb=Ga.__dirtyElements,gb=Ga.__dirtyUvs,mb=Ga.__dirtyNormals,nb=Ga.__dirtyTangents,ob=Ga.__dirtyColors,pb=Ga.__dirtyMorphTargets,cb=Ga.vertices,rb=i.faces,wb=Ga.faces,sb=Ga.faceVertexUvs[0],tb=Ga.faceVertexUvs[1],db=Ga.skinVerticesA,eb=Ga.skinVerticesB,fb=Ga.skinIndices,Ua=Ga.skinWeights,$a=Ga.edgeFaces,Sa=Ga.morphTargets;if(Qa)for(Za in Qa)Qa[Za].offset=0;s=0;for(u=rb.length;s<u;s++){w=rb[s];r=wb[w];sb&&(T=
-sb[w]);tb&&(Ca=tb[w]);w=r.vertexNormals;t=r.normal;A=r.vertexColors;M=r.color;B=r.vertexTangents;if(r instanceof THREE.Face3){if(kb){H=cb[r.a].position;E=cb[r.b].position;I=cb[r.c].position;Aa[ya]=H.x;Aa[ya+1]=H.y;Aa[ya+2]=H.z;Aa[ya+3]=E.x;Aa[ya+4]=E.y;Aa[ya+5]=E.z;Aa[ya+6]=I.x;Aa[ya+7]=I.y;Aa[ya+8]=I.z;ya+=9}if(Qa)for(Za in Qa){x=Qa[Za];if(x.needsUpdate){C=x.offset;if(x.size===1){x.array[C+0]=x.value[r.a];x.array[C+1]=x.value[r.b];x.array[C+2]=x.value[r.c];x.offset+=3}else{H=x.value[r.a];E=x.value[r.b];
-I=x.value[r.c];if(x.size===2){x.array[C+0]=H.x;x.array[C+1]=H.y;x.array[C+2]=E.x;x.array[C+3]=E.y;x.array[C+4]=I.x;x.array[C+5]=I.y;x.offset+=6}else if(x.size===3){x.array[C+0]=H.x;x.array[C+1]=H.y;x.array[C+2]=H.z;x.array[C+3]=E.x;x.array[C+4]=E.y;x.array[C+5]=E.z;x.array[C+6]=I.x;x.array[C+7]=I.y;x.array[C+8]=I.z;x.offset+=9}else{x.array[C+0]=H.x;x.array[C+1]=H.y;x.array[C+2]=H.z;x.array[C+3]=H.w;x.array[C+4]=E.x;x.array[C+5]=E.y;x.array[C+6]=E.z;x.array[C+7]=E.w;x.array[C+8]=I.x;x.array[C+9]=I.y;
-x.array[C+10]=I.z;x.array[C+11]=I.w;x.offset+=12}}}}if(pb){C=0;for(x=Sa.length;C<x;C++){H=Sa[C].vertices[r.a].position;E=Sa[C].vertices[r.b].position;I=Sa[C].vertices[r.c].position;qa=jb[C];qa[za+0]=H.x;qa[za+1]=H.y;qa[za+2]=H.z;qa[za+3]=E.x;qa[za+4]=E.y;qa[za+5]=E.z;qa[za+6]=I.x;qa[za+7]=I.y;qa[za+8]=I.z}za+=9}if(Ua.length){H=Ua[r.a];E=Ua[r.b];I=Ua[r.c];ja[y]=H.x;ja[y+1]=H.y;ja[y+2]=H.z;ja[y+3]=H.w;ja[y+4]=E.x;ja[y+5]=E.y;ja[y+6]=E.z;ja[y+7]=E.w;ja[y+8]=I.x;ja[y+9]=I.y;ja[y+10]=I.z;ja[y+11]=I.w;
-H=fb[r.a];E=fb[r.b];I=fb[r.c];ia[y]=H.x;ia[y+1]=H.y;ia[y+2]=H.z;ia[y+3]=H.w;ia[y+4]=E.x;ia[y+5]=E.y;ia[y+6]=E.z;ia[y+7]=E.w;ia[y+8]=I.x;ia[y+9]=I.y;ia[y+10]=I.z;ia[y+11]=I.w;H=db[r.a];E=db[r.b];I=db[r.c];ga[y]=H.x;ga[y+1]=H.y;ga[y+2]=H.z;ga[y+3]=1;ga[y+4]=E.x;ga[y+5]=E.y;ga[y+6]=E.z;ga[y+7]=1;ga[y+8]=I.x;ga[y+9]=I.y;ga[y+10]=I.z;ga[y+11]=1;H=eb[r.a];E=eb[r.b];I=eb[r.c];ha[y]=H.x;ha[y+1]=H.y;ha[y+2]=H.z;ha[y+3]=1;ha[y+4]=E.x;ha[y+5]=E.y;ha[y+6]=E.z;ha[y+7]=1;ha[y+8]=I.x;ha[y+9]=I.y;ha[y+10]=I.z;ha[y+
-11]=1;y+=12}if(ob&&U){if(A.length==3&&U==THREE.VertexColors){r=A[0];H=A[1];E=A[2]}else E=H=r=M;Ba[xa]=r.r;Ba[xa+1]=r.g;Ba[xa+2]=r.b;Ba[xa+3]=H.r;Ba[xa+4]=H.g;Ba[xa+5]=H.b;Ba[xa+6]=E.r;Ba[xa+7]=E.g;Ba[xa+8]=E.b;xa+=9}if(nb&&Ga.hasTangents){A=B[0];M=B[1];r=B[2];fa[da]=A.x;fa[da+1]=A.y;fa[da+2]=A.z;fa[da+3]=A.w;fa[da+4]=M.x;fa[da+5]=M.y;fa[da+6]=M.z;fa[da+7]=M.w;fa[da+8]=r.x;fa[da+9]=r.y;fa[da+10]=r.z;fa[da+11]=r.w;da+=12}if(mb&&R)if(w.length==3&&qb)for(B=0;B<3;B++){t=w[B];Pa[Ka]=t.x;Pa[Ka+1]=t.y;Pa[Ka+
-2]=t.z;Ka+=3}else for(B=0;B<3;B++){Pa[Ka]=t.x;Pa[Ka+1]=t.y;Pa[Ka+2]=t.z;Ka+=3}if(gb&&T!==undefined&&Q)for(B=0;B<3;B++){w=T[B];hb[ab]=w.u;hb[ab+1]=w.v;ab+=2}if(gb&&Ca!==undefined&&Q)for(B=0;B<3;B++){w=Ca[B];ib[bb]=w.u;ib[bb+1]=w.v;bb+=2}if(lb){Ma[Ja]=ua;Ma[Ja+1]=ua+1;Ma[Ja+2]=ua+2;Ja+=3;Na[La]=ua;Na[La+1]=ua+1;Na[La+2]=ua;Na[La+3]=ua+2;Na[La+4]=ua+1;Na[La+5]=ua+2;La+=6;ua+=3}}else if(r instanceof THREE.Face4){if(kb){H=cb[r.a].position;E=cb[r.b].position;I=cb[r.c].position;X=cb[r.d].position;Aa[ya]=
-H.x;Aa[ya+1]=H.y;Aa[ya+2]=H.z;Aa[ya+3]=E.x;Aa[ya+4]=E.y;Aa[ya+5]=E.z;Aa[ya+6]=I.x;Aa[ya+7]=I.y;Aa[ya+8]=I.z;Aa[ya+9]=X.x;Aa[ya+10]=X.y;Aa[ya+11]=X.z;ya+=12}if(Qa)for(Za in Qa){x=Qa[Za];if(x.needsUpdate){C=x.offset;if(x.size===1){x.array[C+0]=x.value[r.a];x.array[C+1]=x.value[r.b];x.array[C+2]=x.value[r.c];x.array[C+2]=x.value[r.d];x.offset+=4}else{H=x.value[r.a];E=x.value[r.b];I=x.value[r.c];X=x.value[r.d];if(x.size===2){x.array[C+0]=H.x;x.array[C+1]=H.y;x.array[C+2]=E.x;x.array[C+3]=E.y;x.array[C+
-4]=I.x;x.array[C+5]=I.y;x.array[C+6]=X.x;x.array[C+7]=X.y;x.offset+=8}else if(x.size===3){x.array[C+0]=H.x;x.array[C+1]=H.y;x.array[C+2]=H.z;x.array[C+3]=E.x;x.array[C+4]=E.y;x.array[C+5]=E.z;x.array[C+6]=I.x;x.array[C+7]=I.y;x.array[C+8]=I.z;x.array[C+9]=X.x;x.array[C+10]=X.y;x.array[C+11]=X.z;x.offset+=12}else{x.array[C+0]=H.x;x.array[C+1]=H.y;x.array[C+2]=H.z;x.array[C+3]=H.w;x.array[C+4]=E.x;x.array[C+5]=E.y;x.array[C+6]=E.z;x.array[C+7]=E.w;x.array[C+8]=I.x;x.array[C+9]=I.y;x.array[C+10]=I.z;
-x.array[C+11]=I.w;x.array[C+12]=X.x;x.array[C+13]=X.y;x.array[C+14]=X.z;x.array[C+15]=X.w;x.offset+=16}}}}if(pb){C=0;for(x=Sa.length;C<x;C++){H=Sa[C].vertices[r.a].position;E=Sa[C].vertices[r.b].position;I=Sa[C].vertices[r.c].position;X=Sa[C].vertices[r.d].position;qa=jb[C];qa[za+0]=H.x;qa[za+1]=H.y;qa[za+2]=H.z;qa[za+3]=E.x;qa[za+4]=E.y;qa[za+5]=E.z;qa[za+6]=I.x;qa[za+7]=I.y;qa[za+8]=I.z;qa[za+9]=X.x;qa[za+10]=X.y;qa[za+11]=X.z}za+=12}if(Ua.length){H=Ua[r.a];E=Ua[r.b];I=Ua[r.c];X=Ua[r.d];ja[y]=H.x;
-ja[y+1]=H.y;ja[y+2]=H.z;ja[y+3]=H.w;ja[y+4]=E.x;ja[y+5]=E.y;ja[y+6]=E.z;ja[y+7]=E.w;ja[y+8]=I.x;ja[y+9]=I.y;ja[y+10]=I.z;ja[y+11]=I.w;ja[y+12]=X.x;ja[y+13]=X.y;ja[y+14]=X.z;ja[y+15]=X.w;H=fb[r.a];E=fb[r.b];I=fb[r.c];X=fb[r.d];ia[y]=H.x;ia[y+1]=H.y;ia[y+2]=H.z;ia[y+3]=H.w;ia[y+4]=E.x;ia[y+5]=E.y;ia[y+6]=E.z;ia[y+7]=E.w;ia[y+8]=I.x;ia[y+9]=I.y;ia[y+10]=I.z;ia[y+11]=I.w;ia[y+12]=X.x;ia[y+13]=X.y;ia[y+14]=X.z;ia[y+15]=X.w;H=db[r.a];E=db[r.b];I=db[r.c];X=db[r.d];ga[y]=H.x;ga[y+1]=H.y;ga[y+2]=H.z;ga[y+
-3]=1;ga[y+4]=E.x;ga[y+5]=E.y;ga[y+6]=E.z;ga[y+7]=1;ga[y+8]=I.x;ga[y+9]=I.y;ga[y+10]=I.z;ga[y+11]=1;ga[y+12]=X.x;ga[y+13]=X.y;ga[y+14]=X.z;ga[y+15]=1;H=eb[r.a];E=eb[r.b];I=eb[r.c];r=eb[r.d];ha[y]=H.x;ha[y+1]=H.y;ha[y+2]=H.z;ha[y+3]=1;ha[y+4]=E.x;ha[y+5]=E.y;ha[y+6]=E.z;ha[y+7]=1;ha[y+8]=I.x;ha[y+9]=I.y;ha[y+10]=I.z;ha[y+11]=1;ha[y+12]=r.x;ha[y+13]=r.y;ha[y+14]=r.z;ha[y+15]=1;y+=16}if(ob&&U){if(A.length==4&&U==THREE.VertexColors){r=A[0];H=A[1];E=A[2];A=A[3]}else A=E=H=r=M;Ba[xa]=r.r;Ba[xa+1]=r.g;Ba[xa+
-2]=r.b;Ba[xa+3]=H.r;Ba[xa+4]=H.g;Ba[xa+5]=H.b;Ba[xa+6]=E.r;Ba[xa+7]=E.g;Ba[xa+8]=E.b;Ba[xa+9]=A.r;Ba[xa+10]=A.g;Ba[xa+11]=A.b;xa+=12}if(nb&&Ga.hasTangents){A=B[0];M=B[1];r=B[2];B=B[3];fa[da]=A.x;fa[da+1]=A.y;fa[da+2]=A.z;fa[da+3]=A.w;fa[da+4]=M.x;fa[da+5]=M.y;fa[da+6]=M.z;fa[da+7]=M.w;fa[da+8]=r.x;fa[da+9]=r.y;fa[da+10]=r.z;fa[da+11]=r.w;fa[da+12]=B.x;fa[da+13]=B.y;fa[da+14]=B.z;fa[da+15]=B.w;da+=16}if(mb&&R)if(w.length==4&&qb)for(B=0;B<4;B++){t=w[B];Pa[Ka]=t.x;Pa[Ka+1]=t.y;Pa[Ka+2]=t.z;Ka+=3}else for(B=
-0;B<4;B++){Pa[Ka]=t.x;Pa[Ka+1]=t.y;Pa[Ka+2]=t.z;Ka+=3}if(gb&&T!==undefined&&Q)for(B=0;B<4;B++){w=T[B];hb[ab]=w.u;hb[ab+1]=w.v;ab+=2}if(gb&&Ca!==undefined&&Q)for(B=0;B<4;B++){w=Ca[B];ib[bb]=w.u;ib[bb+1]=w.v;bb+=2}if(lb){Ma[Ja]=ua;Ma[Ja+1]=ua+1;Ma[Ja+2]=ua+3;Ma[Ja+3]=ua+1;Ma[Ja+4]=ua+2;Ma[Ja+5]=ua+3;Ja+=6;Na[La]=ua;Na[La+1]=ua+1;Na[La+2]=ua;Na[La+3]=ua+3;Na[La+4]=ua+1;Na[La+5]=ua+2;Na[La+6]=ua+2;Na[La+7]=ua+3;La+=8;ua+=4}}}if($a){s=0;for(u=$a.length;s<u;s++){Ma[Ja]=$a[s].a;Ma[Ja+1]=$a[s].b;Ma[Ja+2]=
-$a[s].c;Ma[Ja+3]=$a[s].a;Ma[Ja+4]=$a[s].c;Ma[Ja+5]=$a[s].d;Ja+=6}}if(kb){c.bindBuffer(c.ARRAY_BUFFER,i.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,Aa,z)}if(Qa)for(Za in Qa){x=Qa[Za];if(x.needsUpdate){c.bindBuffer(c.ARRAY_BUFFER,x.buffer);c.bufferData(c.ARRAY_BUFFER,x.array,z);x.needsUpdate=!1}}if(pb){C=0;for(x=Sa.length;C<x;C++){c.bindBuffer(c.ARRAY_BUFFER,i.__webglMorphTargetsBuffers[C]);c.bufferData(c.ARRAY_BUFFER,jb[C],z)}}if(ob&&xa>0){c.bindBuffer(c.ARRAY_BUFFER,i.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,
-Ba,z)}if(mb){c.bindBuffer(c.ARRAY_BUFFER,i.__webglNormalBuffer);c.bufferData(c.ARRAY_BUFFER,Pa,z)}if(nb&&Ga.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,i.__webglTangentBuffer);c.bufferData(c.ARRAY_BUFFER,fa,z)}if(gb&&ab>0){c.bindBuffer(c.ARRAY_BUFFER,i.__webglUVBuffer);c.bufferData(c.ARRAY_BUFFER,hb,z)}if(gb&&bb>0){c.bindBuffer(c.ARRAY_BUFFER,i.__webglUV2Buffer);c.bufferData(c.ARRAY_BUFFER,ib,z)}if(lb){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webglFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Ma,z);
-c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webglLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Na,z)}if(y>0){c.bindBuffer(c.ARRAY_BUFFER,i.__webglSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,ga,z);c.bindBuffer(c.ARRAY_BUFFER,i.__webglSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,ha,z);c.bindBuffer(c.ARRAY_BUFFER,i.__webglSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,ia,z);c.bindBuffer(c.ARRAY_BUFFER,i.__webglSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,ja,z)}}}n.__dirtyVertices=!1;n.__dirtyMorphTargets=
-!1;n.__dirtyElements=!1;n.__dirtyUvs=!1;n.__dirtyNormals=!1;n.__dirtyTangents=!1;n.__dirtyColors=!1}else if(f instanceof THREE.Ribbon){n=f.geometry;if(n.__dirtyVertices||n.__dirtyColors){f=n;p=c.DYNAMIC_DRAW;U=f.vertices;i=f.colors;R=U.length;z=i.length;T=f.__vertexArray;s=f.__colorArray;Ca=f.__dirtyColors;if(f.__dirtyVertices){for(u=0;u<R;u++){Q=U[u].position;m=u*3;T[m]=Q.x;T[m+1]=Q.y;T[m+2]=Q.z}c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,T,p)}if(Ca){for(u=0;u<
-z;u++){color=i[u];m=u*3;s[m]=color.r;s[m+1]=color.g;s[m+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,s,p)}}n.__dirtyVertices=!1;n.__dirtyColors=!1}else if(f instanceof THREE.Line){n=f.geometry;if(n.__dirtyVertices||n.__dirtyColors){f=n;p=c.DYNAMIC_DRAW;U=f.vertices;i=f.colors;R=U.length;z=i.length;T=f.__vertexArray;s=f.__colorArray;Ca=f.__dirtyColors;if(f.__dirtyVertices){for(u=0;u<R;u++){Q=U[u].position;m=u*3;T[m]=Q.x;T[m+1]=Q.y;T[m+2]=Q.z}c.bindBuffer(c.ARRAY_BUFFER,
-f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,T,p)}if(Ca){for(u=0;u<z;u++){color=i[u];m=u*3;s[m]=color.r;s[m+1]=color.g;s[m+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,s,p)}}n.__dirtyVertices=!1;n.__dirtyColors=!1}else if(f instanceof THREE.ParticleSystem){n=f.geometry;(n.__dirtyVertices||n.__dirtyColors||f.sortParticles)&&d(n,c.DYNAMIC_DRAW,f);n.__dirtyVertices=!1;n.__dirtyColors=!1}}function ra(f){function p(M){var B=[];n=0;for(i=M.length;n<i;n++)M[n]==
-undefined?B.push("undefined"):B.push(M[n].id);return B.join("_")}var n,i,m,z,s,u,w,r,t={},A=f.morphTargets!==undefined?f.morphTargets.length:0;f.geometryGroups={};m=0;for(z=f.faces.length;m<z;m++){s=f.faces[m];u=s.materials;w=p(u);t[w]==undefined&&(t[w]={hash:w,counter:0});r=t[w].hash+"_"+t[w].counter;f.geometryGroups[r]==undefined&&(f.geometryGroups[r]={faces:[],materials:u,vertices:0,numMorphTargets:A});s=s instanceof THREE.Face3?3:4;if(f.geometryGroups[r].vertices+s>65535){t[w].counter+=1;r=t[w].hash+
-"_"+t[w].counter;f.geometryGroups[r]==undefined&&(f.geometryGroups[r]={faces:[],materials:u,vertices:0,numMorphTargets:A})}f.geometryGroups[r].faces.push(m);f.geometryGroups[r].vertices+=s}}function ca(f,p,n){f.push({buffer:p,object:n,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function sa(f){if(f!=la){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);
-break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD);c.blendFuncSeparate(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}la=f}}function Z(f,p,n){if((n.width&n.width-1)==0&&(n.height&n.height-1)==0){c.texParameteri(f,c.TEXTURE_WRAP_S,ea(p.wrapS));c.texParameteri(f,c.TEXTURE_WRAP_T,ea(p.wrapT));c.texParameteri(f,c.TEXTURE_MAG_FILTER,ea(p.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,
-ea(p.minFilter));c.generateMipmap(f)}else{c.texParameteri(f,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_MAG_FILTER,Da(p.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,Da(p.minFilter))}}function K(f,p){if(f.needsUpdate){if(f.__webglInit){c.bindTexture(c.TEXTURE_2D,f.__webglTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,f.image)}else{f.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,f.__webglTexture);
-c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,f.image);f.__webglInit=!0}Z(c.TEXTURE_2D,f,f.image);c.bindTexture(c.TEXTURE_2D,null);f.needsUpdate=!1}c.activeTexture(c.TEXTURE0+p);c.bindTexture(c.TEXTURE_2D,f.__webglTexture)}function Ia(f){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,ea(f.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,ea(f.wrapT));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,ea(f.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,ea(f.minFilter));c.texImage2D(c.TEXTURE_2D,0,ea(f.format),f.width,f.height,0,ea(f.format),ea(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 p,n;if(f){p=f.__webglFramebuffer;n=f.width;f=f.height}else{p=null;n=Fa;f=Ha}if(p!=Ea){c.bindFramebuffer(c.FRAMEBUFFER,p);c.viewport(va,pa,n,f);Ea=p}}function ka(f,p){var n;if(f=="fragment")n=c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(n=c.createShader(c.VERTEX_SHADER));
-c.shaderSource(n,p);c.compileShader(n);if(!c.getShaderParameter(n,c.COMPILE_STATUS)){console.error(c.getShaderInfoLog(n));console.error(p);return null}return n}function Da(f){switch(f){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;default:return c.LINEAR}}function ea(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 c,S=document.createElement("canvas"),oa=[],ta=null,Ea=null,wa=!0,aa=this,ma=null,na=null,la=null,Y=null,va=0,pa=0,Fa=0,Ha=0,$=[new THREE.Vector4,new THREE.Vector4,
-new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],Oa=new THREE.Matrix4,Va=new Float32Array(16),Wa=new Float32Array(16),Ta=new THREE.Vector4,Ra={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},Xa=!0,Ya=!0,ub=new THREE.Color(0),vb=0;if(b){if(b.stencil!=undefined)Xa=b.stencil;if(b.antialias!==undefined)Ya=b.antialias;b.clearColor!==undefined&&ub.setHex(b.clearColor);if(b.clearAlpha!==undefined)vb=b.clearAlpha}this.maxMorphTargets=
-8;this.domElement=S;this.autoClear=!0;this.sortObjects=!0;(function(f,p,n,i){try{if(!(c=S.getContext("experimental-webgl",{antialias:f,stencil:i})))throw"Error creating WebGL context.";}catch(m){console.error(m)}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.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(p.r,p.g,p.b,n)})(Ya,ub,vb,Xa);this.context=
-c;if(Xa){var V={};V.vertices=new Float32Array(12);V.faces=new Uint16Array(6);V.darkness=0.5;V.vertices[0]=-2;V.vertices[1]=-1;V.vertices[2]=-1;V.vertices[3]=2;V.vertices[4]=-1;V.vertices[5]=-1;V.vertices[6]=2;V.vertices[7]=1;V.vertices[8]=-1;V.vertices[9]=-2;V.vertices[10]=1;V.vertices[11]=-1;V.faces[0]=0;V.faces[1]=1;V.faces[2]=2;V.faces[3]=0;V.faces[4]=2;V.faces[5]=3;V.vertexBuffer=c.createBuffer();V.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,V.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,
-V.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,V.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,V.faces,c.STATIC_DRAW);V.program=c.createProgram();c.attachShader(V.program,ka("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(V.program,ka("vertex",THREE.ShaderLib.shadowPost.vertexShader));c.linkProgram(V.program);V.vertexLocation=c.getAttribLocation(V.program,"position");V.projectionLocation=c.getUniformLocation(V.program,"projectionMatrix");V.darknessLocation=
-c.getUniformLocation(V.program,"darkness")}var L={};L.vertices=new Float32Array(16);L.faces=new Uint16Array(6);L.transparency=0.5;b=0;L.vertices[b++]=-1;L.vertices[b++]=-1;L.vertices[b++]=0;L.vertices[b++]=0;L.vertices[b++]=1;L.vertices[b++]=-1;L.vertices[b++]=1;L.vertices[b++]=0;L.vertices[b++]=1;L.vertices[b++]=1;L.vertices[b++]=1;L.vertices[b++]=1;L.vertices[b++]=-1;L.vertices[b++]=1;L.vertices[b++]=0;L.vertices[b++]=1;b=0;L.faces[b++]=0;L.faces[b++]=1;L.faces[b++]=2;L.faces[b++]=0;L.faces[b++]=
-2;L.faces[b++]=3;L.vertexBuffer=c.createBuffer();L.elementBuffer=c.createBuffer();L.tempTexture=c.createTexture();L.readBackPixels=new Uint8Array(1024);c.bindBuffer(c.ARRAY_BUFFER,L.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,L.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,L.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,L.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,L.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,
-c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);L.program=c.createProgram();c.attachShader(L.program,ka("fragment",THREE.ShaderLib.lensFlare.fragmentShader));c.attachShader(L.program,ka("vertex",THREE.ShaderLib.lensFlare.vertexShader));c.linkProgram(L.program);L.attributes={};L.uniforms={};L.attributes.vertex=c.getAttribLocation(L.program,
-"position");L.attributes.uv=c.getAttribLocation(L.program,"UV");L.uniforms.map=c.getUniformLocation(L.program,"map");L.uniforms.opacity=c.getUniformLocation(L.program,"opacity");L.uniforms.scale=c.getUniformLocation(L.program,"scale");L.uniforms.rotation=c.getUniformLocation(L.program,"rotation");L.uniforms.screenPosition=c.getUniformLocation(L.program,"screenPosition");L.uniforms.renderPink=c.getUniformLocation(L.program,"renderPink");this.setSize=function(f,p){S.width=f;S.height=p;this.setViewport(0,
-0,S.width,S.height)};this.setViewport=function(f,p,n,i){va=f;pa=p;Fa=n;Ha=i;c.viewport(va,pa,Fa,Ha)};this.setScissor=function(f,p,n,i){c.scissor(f,p,n,i)};this.enableScissorTest=function(f){f?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(f){wa=f;c.depthMask(f)};this.setClearColorHex=function(f,p){var n=new THREE.Color(f);c.clearColor(n.r,n.g,n.b,p)};this.setClearColor=function(f,p){c.clearColor(f.r,f.g,f.b,p)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|
-c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(f){V.darkness=f};this.initMaterial=function(f,p,n,i){var m,z,s,u;if(f instanceof THREE.MeshDepthMaterial)e(f,THREE.ShaderLib.depth);else if(f instanceof THREE.ShadowVolumeDynamicMaterial)e(f,THREE.ShaderLib.shadowVolumeDynamic);else if(f instanceof THREE.MeshNormalMaterial)e(f,THREE.ShaderLib.normal);else if(f instanceof THREE.MeshBasicMaterial)e(f,THREE.ShaderLib.basic);else if(f instanceof THREE.MeshLambertMaterial)e(f,
-THREE.ShaderLib.lambert);else if(f instanceof THREE.MeshPhongMaterial)e(f,THREE.ShaderLib.phong);else if(f instanceof THREE.LineBasicMaterial)e(f,THREE.ShaderLib.basic);else f instanceof THREE.ParticleBasicMaterial&&e(f,THREE.ShaderLib.particle_basic);var w,r,t,A;u=t=A=0;for(w=p.length;u<w;u++){r=p[u];r instanceof THREE.DirectionalLight&&t++;r instanceof THREE.PointLight&&A++}if(A+t<=4)p=t;else{p=Math.ceil(4*t/(A+t));A=4-p}u={directional:p,point:A};w=50;if(i!==undefined&&i instanceof THREE.SkinnedMesh)w=
-i.bones.length;a:{A=f.fragmentShader;p=f.vertexShader;n={map:f.map,envMap:f.envMap,lightMap:f.lightMap,vertexColors:f.vertexColors,fog:n,sizeAttenuation:f.sizeAttenuation,skinning:f.skinning,morphTargets:f.morphTargets,maxDirLights:u.directional,maxPointLights:u.point,maxBones:w};u=A+"\n\n"+p+"\n\n";for(s in n)u+=s+": "+n[s]+",\n";s=0;for(w=oa.length;s<w;s++)if(oa[s].code==u){s=oa[s].program;break a}s=c.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+
-n.maxDirLights,"#define MAX_POINT_LIGHTS "+n.maxPointLights,n.fog?"#define USE_FOG":"",n.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.lightMap?"#define USE_LIGHTMAP":"",n.vertexColors?"#define USE_COLOR":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+n.maxDirLights,"#define MAX_POINT_LIGHTS "+
-n.maxPointLights,"#define MAX_BONES "+n.maxBones,n.map?"#define USE_MAP":"",n.envMap?"#define USE_ENVMAP":"",n.lightMap?"#define USE_LIGHTMAP":"",n.vertexColors?"#define USE_COLOR":"",n.skinning?"#define USE_SKINNING":"",n.morphTargets?"#define USE_MORPHTARGETS":"",n.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
-c.attachShader(s,ka("fragment",prefix_fragment+A));c.attachShader(s,ka("vertex",prefix_vertex+p));c.linkProgram(s);c.getProgramParameter(s,c.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+c.getProgramParameter(s,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");s.uniforms={};s.attributes={};oa.push({program:s,code:u})}f.program=s;s=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices",
-"morphTargetInfluences"];for(m in f.uniforms)s.push(m);m=f.program;n=0;for(A=s.length;n<A;n++){p=s[n];m.uniforms[p]=c.getUniformLocation(m,p)}s=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(m=0;m<this.maxMorphTargets;m++)s.push("morphTarget"+m);for(z in f.attributes)s.push(z);m=f.program;n=0;for(A=s.length;n<A;n++){p=s[n];m.attributes[p]=c.getAttribLocation(m,p)}m=f.program.attributes;c.enableVertexAttribArray(m.position);m.color>=0&&c.enableVertexAttribArray(m.color);
-m.normal>=0&&c.enableVertexAttribArray(m.normal);m.tangent>=0&&c.enableVertexAttribArray(m.tangent);if(f.skinning&&m.skinVertexA>=0&&m.skinVertexB>=0&&m.skinIndex>=0&&m.skinWeight>=0){c.enableVertexAttribArray(m.skinVertexA);c.enableVertexAttribArray(m.skinVertexB);c.enableVertexAttribArray(m.skinIndex);c.enableVertexAttribArray(m.skinWeight)}for(z in f.attributes)m[z]>=0&&c.enableVertexAttribArray(m[z]);if(f.morphTargets){f.numSupportedMorphTargets=0;if(m.morphTarget0>=0){c.enableVertexAttribArray(m.morphTarget0);
-f.numSupportedMorphTargets++}if(m.morphTarget1>=0){c.enableVertexAttribArray(m.morphTarget1);f.numSupportedMorphTargets++}if(m.morphTarget2>=0){c.enableVertexAttribArray(m.morphTarget2);f.numSupportedMorphTargets++}if(m.morphTarget3>=0){c.enableVertexAttribArray(m.morphTarget3);f.numSupportedMorphTargets++}if(m.morphTarget4>=0){c.enableVertexAttribArray(m.morphTarget4);f.numSupportedMorphTargets++}if(m.morphTarget5>=0){c.enableVertexAttribArray(m.morphTarget5);f.numSupportedMorphTargets++}if(m.morphTarget6>=
-0){c.enableVertexAttribArray(m.morphTarget6);f.numSupportedMorphTargets++}if(m.morphTarget7>=0){c.enableVertexAttribArray(m.morphTarget7);f.numSupportedMorphTargets++}i.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);m=0;for(f=this.maxMorphTargets;m<f;m++)i.__webglMorphTargetInfluences[m]=0}};this.render=function(f,p,n,i){var m,z,s,u,w,r,t,A,M=f.lights,B=f.fog;p.matrixAutoUpdate&&p.updateMatrix();f.update(undefined,!1,p);p.matrixWorldInverse.flattenToArray(Wa);p.projectionMatrix.flattenToArray(Va);
-Oa.multiply(p.projectionMatrix,p.matrixWorldInverse);q(Oa);this.initWebGLObjects(f);Ia(n);(this.autoClear||i)&&this.clear();w=f.__webglObjects.length;for(i=0;i<w;i++){m=f.__webglObjects[i];t=m.object;if(t.visible)if(!(t instanceof THREE.Mesh)||v(t)){t.matrixWorld.flattenToArray(t._objectMatrixArray);W(t,p);J(m);m.render=!0;if(this.sortObjects){Ta.copy(t.position);Oa.multiplyVector3(Ta);m.z=Ta.z}}else m.render=!1;else m.render=!1}this.sortObjects&&f.__webglObjects.sort(G);r=f.__webglObjectsImmediate.length;
-for(i=0;i<r;i++){m=f.__webglObjectsImmediate[i];t=m.object;if(t.visible){t.matrixAutoUpdate&&t.matrixWorld.flattenToArray(t._objectMatrixArray);W(t,p);F(m)}}sa(THREE.NormalBlending);for(i=0;i<w;i++){m=f.__webglObjects[i];if(m.render){t=m.object;A=m.buffer;s=m.opaque;k(t);for(m=0;m<s.count;m++){u=s.list[m];o(u.depthTest);g(p,M,B,u,A,t)}}}for(i=0;i<r;i++){m=f.__webglObjectsImmediate[i];t=m.object;if(t.visible){s=m.opaque;k(t);for(m=0;m<s.count;m++){u=s.list[m];o(u.depthTest);z=h(p,M,B,u,t);t.render(function(Q){j(Q,
-z)})}}}for(i=0;i<w;i++){m=f.__webglObjects[i];if(m.render){t=m.object;A=m.buffer;s=m.transparent;k(t);for(m=0;m<s.count;m++){u=s.list[m];sa(u.blending);o(u.depthTest);g(p,M,B,u,A,t)}}}for(i=0;i<r;i++){m=f.__webglObjectsImmediate[i];t=m.object;if(t.visible){s=m.transparent;k(t);for(m=0;m<s.count;m++){u=s.list[m];sa(u.blending);o(u.depthTest);z=h(p,M,B,u,t);t.render(function(Q){j(Q,z)})}}}Xa&&f.__webglShadowVolumes.length&&f.lights.length&&N(f);f.__webglLensFlares.length&&O(f,p);if(n&&n.minFilter!==
-THREE.NearestFilter&&n.minFilter!==THREE.LinearFilter){c.bindTexture(c.TEXTURE_2D,n.__webglTexture);c.generateMipmap(c.TEXTURE_2D);c.bindTexture(c.TEXTURE_2D,null)}};this.initWebGLObjects=function(f){if(!f.__webglObjects){f.__webglObjects=[];f.__webglObjectsImmediate=[];f.__webglShadowVolumes=[];f.__webglLensFlares=[]}for(;f.__objectsAdded.length;){var p=f.__objectsAdded[0],n=f,i=void 0,m=void 0,z=void 0;if(p._modelViewMatrix==undefined){p._modelViewMatrix=new THREE.Matrix4;p._normalMatrixArray=new Float32Array(9);
-p._modelViewMatrixArray=new Float32Array(16);p._objectMatrixArray=new Float32Array(16);p.matrixWorld.flattenToArray(p._objectMatrixArray)}if(p instanceof THREE.Mesh){m=p.geometry;m.geometryGroups==undefined&&ra(m);for(i in m.geometryGroups){z=m.geometryGroups[i];if(!z.__webglVertexBuffer){var s=z;s.__webglVertexBuffer=c.createBuffer();s.__webglNormalBuffer=c.createBuffer();s.__webglTangentBuffer=c.createBuffer();s.__webglColorBuffer=c.createBuffer();s.__webglUVBuffer=c.createBuffer();s.__webglUV2Buffer=
-c.createBuffer();s.__webglSkinVertexABuffer=c.createBuffer();s.__webglSkinVertexBBuffer=c.createBuffer();s.__webglSkinIndicesBuffer=c.createBuffer();s.__webglSkinWeightsBuffer=c.createBuffer();s.__webglFaceBuffer=c.createBuffer();s.__webglLineBuffer=c.createBuffer();if(s.numMorphTargets){var u=void 0,w=void 0;s.__webglMorphTargetsBuffers=[];u=0;for(w=s.numMorphTargets;u<w;u++)s.__webglMorphTargetsBuffers.push(c.createBuffer())}s=z;u=p;var r=void 0,t=void 0,A=void 0;A=void 0;var M=void 0,B=void 0,
-Q=void 0,U=Q=w=0;t=void 0;A=void 0;var R=void 0;r=void 0;t=void 0;M=u.geometry;R=M.faces;B=s.faces;r=0;for(t=B.length;r<t;r++){A=B[r];A=R[A];if(A instanceof THREE.Face3){w+=3;Q+=1;U+=3}else if(A instanceof THREE.Face4){w+=4;Q+=2;U+=4}}r=s;t=u;R=void 0;B=void 0;var T=void 0,Ca=void 0;T=void 0;A=[];R=0;for(B=t.materials.length;R<B;R++){T=t.materials[R];if(T instanceof THREE.MeshFaceMaterial){T=0;for(l=r.materials.length;T<l;T++)(Ca=r.materials[T])&&A.push(Ca)}else(Ca=T)&&A.push(Ca)}r=A;a:{t=void 0;
-R=void 0;B=r.length;for(t=0;t<B;t++){R=r[t];if(R.map||R.lightMap||R instanceof THREE.MeshShaderMaterial){t=!0;break a}}t=!1}a:{R=void 0;B=void 0;A=r.length;for(R=0;R<A;R++){B=r[R];if(!(B instanceof THREE.MeshBasicMaterial&&!B.envMap||B instanceof THREE.MeshDepthMaterial)){R=B&&B.shading!=undefined&&B.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}R=!1}a:{B=void 0;A=void 0;T=r.length;for(B=0;B<T;B++){A=r[B];if(A.vertexColors){A=A.vertexColors;break a}}A=!1}s.__vertexArray=
-new Float32Array(w*3);if(R)s.__normalArray=new Float32Array(w*3);if(M.hasTangents)s.__tangentArray=new Float32Array(w*4);if(A)s.__colorArray=new Float32Array(w*3);if(t){if(M.faceUvs.length>0||M.faceVertexUvs.length>0)s.__uvArray=new Float32Array(w*2);if(M.faceUvs.length>1||M.faceVertexUvs.length>1)s.__uv2Array=new Float32Array(w*2)}if(u.geometry.skinWeights.length&&u.geometry.skinIndices.length){s.__skinVertexAArray=new Float32Array(w*4);s.__skinVertexBArray=new Float32Array(w*4);s.__skinIndexArray=
-new Float32Array(w*4);s.__skinWeightArray=new Float32Array(w*4)}s.__faceArray=new Uint16Array(Q*3+(u.geometry.edgeFaces?u.geometry.edgeFaces.length*6:0));s.__lineArray=new Uint16Array(U*2);if(s.numMorphTargets){s.__morphTargetsArrays=[];M=0;for(B=s.numMorphTargets;M<B;M++)s.__morphTargetsArrays.push(new Float32Array(w*3))}s.__needsSmoothNormals=R==THREE.SmoothShading;s.__uvType=t;s.__vertexColorType=A;s.__normalType=R;s.__webglFaceCount=Q*3+(u.geometry.edgeFaces?u.geometry.edgeFaces.length*6:0);s.__webglLineCount=
-U*2;M=0;for(B=r.length;M<B;M++)if(r[M].attributes){s.__webglCustomAttributes={};for(a in r[M].attributes){t=r[M].attributes[a];Q=1;if(t.type==="v2")Q=2;else if(t.type==="v3")Q=3;else if(t.type==="v4")Q=4;else t.type==="c"&&(Q=3);t.size=Q;t.needsUpdate=!0;t.array=new Float32Array(w*Q);t.buffer=c.createBuffer();s.__webglCustomAttributes[a]=t}}m.__dirtyVertices=!0;m.__dirtyMorphTargets=!0;m.__dirtyElements=!0;m.__dirtyUvs=!0;m.__dirtyNormals=!0;m.__dirtyTangents=!0;m.__dirtyColors=!0}p instanceof THREE.ShadowVolume?
-ca(n.__webglShadowVolumes,z,p):ca(n.__webglObjects,z,p)}}else if(p instanceof THREE.LensFlare)ca(n.__webglLensFlares,undefined,p);else if(p instanceof THREE.Ribbon){m=p.geometry;if(!m.__webglVertexBuffer){i=m;i.__webglVertexBuffer=c.createBuffer();i.__webglColorBuffer=c.createBuffer();i=m;z=i.vertices.length;i.__vertexArray=new Float32Array(z*3);i.__colorArray=new Float32Array(z*3);i.__webglVertexCount=z;m.__dirtyVertices=!0;m.__dirtyColors=!0}ca(n.__webglObjects,m,p)}else if(p instanceof THREE.Line){m=
-p.geometry;if(!m.__webglVertexBuffer){i=m;i.__webglVertexBuffer=c.createBuffer();i.__webglColorBuffer=c.createBuffer();i=m;z=i.vertices.length;i.__vertexArray=new Float32Array(z*3);i.__colorArray=new Float32Array(z*3);i.__webglLineCount=z;m.__dirtyVertices=!0;m.__dirtyColors=!0}ca(n.__webglObjects,m,p)}else if(p instanceof THREE.ParticleSystem){m=p.geometry;if(!m.__webglVertexBuffer){i=m;i.__webglVertexBuffer=c.createBuffer();i.__webglColorBuffer=c.createBuffer();i=m;z=i.vertices.length;i.__vertexArray=
-new Float32Array(z*3);i.__colorArray=new Float32Array(z*3);i.__sortArray=[];i.__webglParticleCount=z;m.__dirtyVertices=!0;m.__dirtyColors=!0}ca(n.__webglObjects,m,p)}else THREE.MarchingCubes!==undefined&&p instanceof THREE.MarchingCubes&&n.__webglObjectsImmediate.push({object:p,opaque:{list:[],count:0},transparent:{list:[],count:0}});f.__objectsAdded.splice(0,1)}for(;f.__objectsRemoved.length;){p=f.__objectsRemoved[0];n=f;m=void 0;i=void 0;for(m=n.__webglObjects.length-1;m>=0;m--){i=n.__webglObjects[m].object;
-p==i&&n.__webglObjects.splice(m,1)}f.__objectsRemoved.splice(0,1)}p=0;for(n=f.__webglObjects.length;p<n;p++)P(f.__webglObjects[p].object,f);p=0;for(n=f.__webglShadowVolumes.length;p<n;p++)P(f.__webglShadowVolumes[p].object,f);p=0;for(n=f.__webglLensFlares.length;p<n;p++)P(f.__webglLensFlares[p].object,f)};this.setFaceCulling=function(f,p){if(f){!p||p=="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)};
+THREE.WebGLRenderer=function(b){function d(f,q,m){var i,o,y,s=f.vertices,u=s.length,x=f.colors,r=x.length,t=f.__vertexArray,w=f.__colorArray,I=f.__sortArray,B=f.__dirtyVertices,P=f.__dirtyColors;if(m.sortParticles){ga.multiplySelf(m.matrixWorld);for(i=0;i<u;i++){o=s[i].position;Ua.copy(o);ga.multiplyVector3(Ua);I[i]=[Ua.z,i]}I.sort(function(V,R){return R[0]-V[0]});for(i=0;i<u;i++){o=s[I[i][1]].position;y=i*3;t[y]=o.x;t[y+1]=o.y;t[y+2]=o.z}for(i=0;i<r;i++){y=i*3;color=x[I[i][1]];w[y]=color.r;w[y+1]=
+color.g;w[y+2]=color.b}}else{if(B)for(i=0;i<u;i++){o=s[i].position;y=i*3;t[y]=o.x;t[y+1]=o.y;t[y+2]=o.z}if(P)for(i=0;i<r;i++){color=x[i];y=i*3;w[y]=color.r;w[y+1]=color.g;w[y+2]=color.b}}if(B||m.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,t,q)}if(P||m.sortParticles){c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,w,q)}}function e(f,q,m,i,o){i.program||ya.initMaterial(i,q,m,o);var y=i.program,s=y.uniforms,u=i.uniforms;
+if(y!=na){c.useProgram(y);na=y}c.uniformMatrix4fv(s.projectionMatrix,!1,Oa);if(m&&(i instanceof THREE.MeshBasicMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshPhongMaterial||i instanceof THREE.LineBasicMaterial||i instanceof THREE.ParticleBasicMaterial||i.fog)){u.fogColor.value.setHex(m.color.hex);if(m instanceof THREE.Fog){u.fogNear.value=m.near;u.fogFar.value=m.far}else if(m instanceof THREE.FogExp2)u.fogDensity.value=m.density}if(i instanceof THREE.MeshPhongMaterial||i instanceof
+THREE.MeshLambertMaterial||i.lights){var x,r,t=0,w=0,I=0,B,P,V,R,S=gb,Ha=S.directional.colors,H=S.directional.positions,D=S.point.colors,J=S.point.positions,Z=S.point.distances,C=0,z=0;m=r=R=0;for(x=q.length;m<x;m++){r=q[m];B=r.color;P=r.position;V=r.intensity;R=r.distance;if(r instanceof THREE.AmbientLight){t+=B.r;w+=B.g;I+=B.b}else if(r instanceof THREE.DirectionalLight){R=C*3;Ha[R]=B.r*V;Ha[R+1]=B.g*V;Ha[R+2]=B.b*V;H[R]=P.x;H[R+1]=P.y;H[R+2]=P.z;C+=1}else if(r instanceof THREE.PointLight){r=z*
+3;D[r]=B.r*V;D[r+1]=B.g*V;D[r+2]=B.b*V;J[r]=P.x;J[r+1]=P.y;J[r+2]=P.z;Z[z]=R;z+=1}}for(m=C*3;m<Ha.length;m++)Ha[m]=0;for(m=z*3;m<D.length;m++)D[m]=0;S.point.length=z;S.directional.length=C;S.ambient[0]=t;S.ambient[1]=w;S.ambient[2]=I;m=gb;u.enableLighting.value=m.directional.length+m.point.length;u.ambientLightColor.value=m.ambient;u.directionalLightColor.value=m.directional.colors;u.directionalLightDirection.value=m.directional.positions;u.pointLightColor.value=m.point.colors;u.pointLightPosition.value=
+m.point.positions;u.pointLightDistance.value=m.point.distances}if(i instanceof THREE.MeshBasicMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshPhongMaterial){u.diffuse.value.setRGB(i.color.r,i.color.g,i.color.b);u.opacity.value=i.opacity;u.map.texture=i.map;u.lightMap.texture=i.lightMap;u.envMap.texture=i.envMap;u.reflectivity.value=i.reflectivity;u.refractionRatio.value=i.refractionRatio;u.combine.value=i.combine;u.useRefract.value=i.envMap&&i.envMap.mapping instanceof THREE.CubeRefractionMapping}if(i instanceof
+THREE.LineBasicMaterial){u.diffuse.value.setRGB(i.color.r,i.color.g,i.color.b);u.opacity.value=i.opacity}else if(i instanceof THREE.ParticleBasicMaterial){u.psColor.value.setRGB(i.color.r,i.color.g,i.color.b);u.opacity.value=i.opacity;u.size.value=i.size;u.scale.value=T.height/2;u.map.texture=i.map}else if(i instanceof THREE.MeshPhongMaterial){u.ambient.value.setRGB(i.ambient.r,i.ambient.g,i.ambient.b);u.specular.value.setRGB(i.specular.r,i.specular.g,i.specular.b);u.shininess.value=i.shininess}else if(i instanceof
+THREE.MeshDepthMaterial){u.mNear.value=f.near;u.mFar.value=f.far;u.opacity.value=i.opacity}else if(i instanceof THREE.MeshNormalMaterial)u.opacity.value=i.opacity;for(var ra in u)if(w=y.uniforms[ra]){x=u[ra];t=x.type;m=x.value;if(t=="i")c.uniform1i(w,m);else if(t=="f")c.uniform1f(w,m);else if(t=="fv1")c.uniform1fv(w,m);else if(t=="fv")c.uniform3fv(w,m);else if(t=="v2")c.uniform2f(w,m.x,m.y);else if(t=="v3")c.uniform3f(w,m.x,m.y,m.z);else if(t=="v4")c.uniform4f(w,m.x,m.y,m.z,m.w);else if(t=="c")c.uniform3f(w,
+m.r,m.g,m.b);else if(t=="t"){c.uniform1i(w,m);if(x=x.texture)if(x.image instanceof Array&&x.image.length==6){if(x.image.length==6){if(x.needsUpdate){if(x.__webglInit){c.bindTexture(c.TEXTURE_CUBE_MAP,x.image.__webglTextureCube);for(t=0;t<6;++t)c.texSubImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,0,0,c.RGBA,c.UNSIGNED_BYTE,x.image[t])}else{x.image.__webglTextureCube=c.createTexture();c.bindTexture(c.TEXTURE_CUBE_MAP,x.image.__webglTextureCube);for(t=0;t<6;++t)c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+
+t,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,x.image[t]);x.__webglInit=!0}wa(c.TEXTURE_CUBE_MAP,x,x.image[0]);c.bindTexture(c.TEXTURE_CUBE_MAP,null);x.needsUpdate=!1}c.activeTexture(c.TEXTURE0+m);c.bindTexture(c.TEXTURE_CUBE_MAP,x.image.__webglTextureCube)}}else $(x,m)}}c.uniformMatrix4fv(s.modelViewMatrix,!1,o._modelViewMatrixArray);c.uniformMatrix3fv(s.normalMatrix,!1,o._normalMatrixArray);(i instanceof THREE.MeshShaderMaterial||i instanceof THREE.MeshPhongMaterial||i.envMap)&&c.uniform3f(s.cameraPosition,
+f.position.x,f.position.y,f.position.z);(i instanceof THREE.MeshShaderMaterial||i.envMap||i.skinning)&&c.uniformMatrix4fv(s.objectMatrix,!1,o._objectMatrixArray);(i instanceof THREE.MeshPhongMaterial||i instanceof THREE.MeshLambertMaterial||i instanceof THREE.MeshShaderMaterial||i.skinning)&&c.uniformMatrix4fv(s.viewMatrix,!1,Ta);if(i instanceof THREE.ShadowVolumeDynamicMaterial){f=u.directionalLightDirection.value;f[0]=-q.position.x;f[1]=-q.position.y;f[2]=-q.position.z;c.uniform3fv(s.directionalLightDirection,
+f);c.uniformMatrix4fv(s.objectMatrix,!1,o._objectMatrixArray);c.uniformMatrix4fv(s.viewMatrix,!1,Ta)}if(i.skinning){c.uniformMatrix4fv(s.cameraInverseMatrix,!1,Ta);c.uniformMatrix4fv(s.boneGlobalMatrices,!1,o.boneMatrices)}return y}function h(f,q,m,i,o,y){if(i.opacity!=0){var s;f=e(f,q,m,i,y).attributes;if(i.morphTargets){q=i.program.attributes;y.morphTargetBase!==-1?c.bindBuffer(c.ARRAY_BUFFER,o.__webglMorphTargetsBuffers[y.morphTargetBase]):c.bindBuffer(c.ARRAY_BUFFER,o.__webglVertexBuffer);c.vertexAttribPointer(q.position,
+3,c.FLOAT,!1,0,0);if(y.morphTargetForcedOrder.length){m=0;for(var u=y.morphTargetForcedOrder,x=y.morphTargetInfluences;m<i.numSupportedMorphTargets&&m<u.length;){c.bindBuffer(c.ARRAY_BUFFER,o.__webglMorphTargetsBuffers[u[m]]);c.vertexAttribPointer(q["morphTarget"+m],3,c.FLOAT,!1,0,0);y.__webglMorphTargetInfluences[m]=x[u[m]];m++}}else{u=[];var r=-1,t=0;x=y.morphTargetInfluences;var w,I=x.length;m=0;for(y.morphTargetBase!==-1&&(u[y.morphTargetBase]=!0);m<i.numSupportedMorphTargets;){for(w=0;w<I;w++)if(!u[w]&&
+x[w]>r){t=w;r=x[t]}c.bindBuffer(c.ARRAY_BUFFER,o.__webglMorphTargetsBuffers[t]);c.vertexAttribPointer(q["morphTarget"+m],3,c.FLOAT,!1,0,0);y.__webglMorphTargetInfluences[m]=r;u[t]=1;r=-1;m++}}c.uniform1fv(i.program.uniforms.morphTargetInfluences,y.__webglMorphTargetInfluences)}else{c.bindBuffer(c.ARRAY_BUFFER,o.__webglVertexBuffer);c.vertexAttribPointer(f.position,3,c.FLOAT,!1,0,0)}if(o.__webglCustomAttributes)for(s in o.__webglCustomAttributes)if(f[s]>=0){q=o.__webglCustomAttributes[s];c.bindBuffer(c.ARRAY_BUFFER,
+q.buffer);c.vertexAttribPointer(f[s],q.size,c.FLOAT,!1,0,0)}if(f.color>=0){c.bindBuffer(c.ARRAY_BUFFER,o.__webglColorBuffer);c.vertexAttribPointer(f.color,3,c.FLOAT,!1,0,0)}if(f.normal>=0){c.bindBuffer(c.ARRAY_BUFFER,o.__webglNormalBuffer);c.vertexAttribPointer(f.normal,3,c.FLOAT,!1,0,0)}if(f.tangent>=0){c.bindBuffer(c.ARRAY_BUFFER,o.__webglTangentBuffer);c.vertexAttribPointer(f.tangent,4,c.FLOAT,!1,0,0)}if(f.uv>=0)if(o.__webglUVBuffer){c.bindBuffer(c.ARRAY_BUFFER,o.__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(o.__webglUV2Buffer){c.bindBuffer(c.ARRAY_BUFFER,o.__webglUV2Buffer);c.vertexAttribPointer(f.uv2,2,c.FLOAT,!1,0,0);c.enableVertexAttribArray(f.uv2)}else c.disableVertexAttribArray(f.uv2);if(i.skinning&&f.skinVertexA>=0&&f.skinVertexB>=0&&f.skinIndex>=0&&f.skinWeight>=0){c.bindBuffer(c.ARRAY_BUFFER,o.__webglSkinVertexABuffer);c.vertexAttribPointer(f.skinVertexA,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,
+o.__webglSkinVertexBBuffer);c.vertexAttribPointer(f.skinVertexB,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,o.__webglSkinIndicesBuffer);c.vertexAttribPointer(f.skinIndex,4,c.FLOAT,!1,0,0);c.bindBuffer(c.ARRAY_BUFFER,o.__webglSkinWeightsBuffer);c.vertexAttribPointer(f.skinWeight,4,c.FLOAT,!1,0,0)}if(y instanceof THREE.Mesh)if(i.wireframe){c.lineWidth(i.wireframeLinewidth);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,o.__webglLineBuffer);c.drawElements(c.LINES,o.__webglLineCount,c.UNSIGNED_SHORT,0)}else{c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,
+o.__webglFaceBuffer);c.drawElements(c.TRIANGLES,o.__webglFaceCount,c.UNSIGNED_SHORT,0)}else if(y instanceof THREE.Line){y=y.type==THREE.LineStrip?c.LINE_STRIP:c.LINES;c.lineWidth(i.linewidth);c.drawArrays(y,0,o.__webglLineCount)}else if(y instanceof THREE.ParticleSystem)c.drawArrays(c.POINTS,0,o.__webglParticleCount);else y instanceof THREE.Ribbon&&c.drawArrays(c.TRIANGLE_STRIP,0,o.__webglVertexCount)}}function g(f,q){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(q.attributes.position);c.vertexAttribPointer(q.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(q.attributes.normal);c.vertexAttribPointer(q.attributes.normal,3,c.FLOAT,!1,0,0)}c.drawArrays(c.TRIANGLES,
+0,f.count);f.count=0}function j(f){if(aa!=f.doubleSided){f.doubleSided?c.disable(c.CULL_FACE):c.enable(c.CULL_FACE);aa=f.doubleSided}if(pa!=f.flipSided){f.flipSided?c.frontFace(c.CW):c.frontFace(c.CCW);pa=f.flipSided}}function k(f){if(qa!=f){f?c.enable(c.DEPTH_TEST):c.disable(c.DEPTH_TEST);qa=f}}function n(f){za[0].set(f.n41-f.n11,f.n42-f.n12,f.n43-f.n13,f.n44-f.n14);za[1].set(f.n41+f.n11,f.n42+f.n12,f.n43+f.n13,f.n44+f.n14);za[2].set(f.n41+f.n21,f.n42+f.n22,f.n43+f.n23,f.n44+f.n24);za[3].set(f.n41-
+f.n21,f.n42-f.n22,f.n43-f.n23,f.n44-f.n24);za[4].set(f.n41-f.n31,f.n42-f.n32,f.n43-f.n33,f.n44-f.n34);za[5].set(f.n41+f.n31,f.n42+f.n32,f.n43+f.n33,f.n44+f.n34);var q;for(f=0;f<6;f++){q=za[f];q.divideScalar(Math.sqrt(q.x*q.x+q.y*q.y+q.z*q.z))}}function p(f){for(var q=f.matrixWorld,m=-f.geometry.boundingSphere.radius*Math.max(f.scale.x,Math.max(f.scale.y,f.scale.z)),i=0;i<6;i++){f=za[i].x*q.n14+za[i].y*q.n24+za[i].z*q.n34+za[i].w;if(f<=m)return!1}return!0}function v(f,q){f.list[f.count]=q;f.count+=
+1}function E(f){var q,m,i=f.object,o=f.opaque,y=f.transparent;y.count=0;f=o.count=0;for(q=i.materials.length;f<q;f++){m=i.materials[f];m.transparent?v(y,m):v(o,m)}}function F(f){var q,m,i,o,y=f.object,s=f.buffer,u=f.opaque,x=f.transparent;x.count=0;f=u.count=0;for(i=y.materials.length;f<i;f++){q=y.materials[f];if(q instanceof THREE.MeshFaceMaterial){q=0;for(m=s.materials.length;q<m;q++)(o=s.materials[q])&&(o.transparent?v(x,o):v(u,o))}else(o=q)&&(o.transparent?v(x,o):v(u,o))}}function K(f,q){return q.z-
+f.z}function G(f){c.enable(c.POLYGON_OFFSET_FILL);c.polygonOffset(0.1,1);c.enable(c.STENCIL_TEST);c.depthMask(!1);c.colorMask(!1,!1,!1,!1);c.stencilFunc(c.ALWAYS,1,255);c.stencilOpSeparate(c.BACK,c.KEEP,c.INCR,c.KEEP);c.stencilOpSeparate(c.FRONT,c.KEEP,c.DECR,c.KEEP);var q,m=f.lights.length,i,o=f.lights,y=[],s,u,x,r,t,w=f.__webglShadowVolumes.length;for(q=0;q<m;q++){i=f.lights[q];if(i instanceof THREE.DirectionalLight){y[0]=-i.position.x;y[1]=-i.position.y;y[2]=-i.position.z;for(t=0;t<w;t++){i=f.__webglShadowVolumes[t].object;
+s=f.__webglShadowVolumes[t].buffer;u=i.materials[0];u.program||ya.initMaterial(u,o,undefined,i);u=u.program;x=u.uniforms;r=u.attributes;if(na!==u){c.useProgram(u);na=u;c.uniformMatrix4fv(x.projectionMatrix,!1,Oa);c.uniformMatrix4fv(x.viewMatrix,!1,Ta);c.uniform3fv(x.directionalLightDirection,y)}i.matrixWorld.flattenToArray(i._objectMatrixArray);c.uniformMatrix4fv(x.objectMatrix,!1,i._objectMatrixArray);c.bindBuffer(c.ARRAY_BUFFER,s.__webglVertexBuffer);c.vertexAttribPointer(r.position,3,c.FLOAT,!1,
+0,0);c.bindBuffer(c.ARRAY_BUFFER,s.__webglNormalBuffer);c.vertexAttribPointer(r.normal,3,c.FLOAT,!1,0,0);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,s.__webglFaceBuffer);c.cullFace(c.FRONT);c.drawElements(c.TRIANGLES,s.__webglFaceCount,c.UNSIGNED_SHORT,0);c.cullFace(c.BACK);c.drawElements(c.TRIANGLES,s.__webglFaceCount,c.UNSIGNED_SHORT,0)}}}c.disable(c.POLYGON_OFFSET_FILL);c.colorMask(!0,!0,!0,!0);c.stencilFunc(c.NOTEQUAL,0,255);c.stencilOp(c.KEEP,c.KEEP,c.KEEP);c.disable(c.DEPTH_TEST);fa="";na=W.program;
+c.useProgram(W.program);c.uniformMatrix4fv(W.projectionLocation,!1,Oa);c.uniform1f(W.darknessLocation,W.darkness);c.bindBuffer(c.ARRAY_BUFFER,W.vertexBuffer);c.vertexAttribPointer(W.vertexLocation,3,c.FLOAT,!1,0,0);c.enableVertexAttribArray(W.vertexLocation);c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA);c.blendEquation(c.FUNC_ADD);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,W.elementBuffer);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);c.disable(c.STENCIL_TEST);c.enable(c.DEPTH_TEST);c.depthMask(Ga)}function N(f,
+q){var m,i,o,y=f.__webglLensFlares.length,s,u,x;s=new THREE.Vector3;var r=Ca/oa;u=oa*0.5;x=Ca*0.5;var t=16/Ca,w=[t*r,t],I=[1,1,0];t=[1,1];var B,P=M.readBackPixels,V,R,S=M.uniforms;m=M.attributes;c.useProgram(M.program);na=M.program;fa="";c.uniform1i(S.map,0);c.activeTexture(c.TEXTURE0);c.uniform1f(S.opacity,1);c.uniform1f(S.rotation,0);c.uniform2fv(S.scale,w);c.bindBuffer(c.ARRAY_BUFFER,M.vertexBuffer);c.vertexAttribPointer(m.vertex,2,c.FLOAT,!1,16,0);c.vertexAttribPointer(m.uv,2,c.FLOAT,!1,16,8);
+c.bindTexture(c.TEXTURE_2D,M.tempTexture);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,M.elementBuffer);c.disable(c.CULL_FACE);c.depthMask(!1);for(o=0;o<y;o++){m=f.__webglLensFlares[o].object;s.set(m.matrixWorld.n14,m.matrixWorld.n24,m.matrixWorld.n34);q.matrixWorldInverse.multiplyVector3(s);i=s.z;q.projectionMatrix.multiplyVector3(s);I[0]=s.x;I[1]=s.y;I[2]=s.z;t[0]=I[0]*u+u;t[1]=I[1]*x+x;c.copyTexSubImage2D(c.TEXTURE_2D,0,0,0,t[0]-8,t[1]-8,16,16);c.uniform3fv(S.screenPosition,I);c.uniform1i(S.renderPink,
+1);c.enable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0);try{c.readPixels(t[0]-8,t[1]-8,16,16,c.RGBA,c.UNSIGNED_BYTE,M.readBackPixels)}catch(Ha){console.log("WebGLRenderer.renderLensFlare: readPixels failed!")}c.getError()&&console.log("WebGLRenderer.renderLensFlare: readPixels failed!");sampleDistance=parseInt(5*(1-Math.max(0,Math.min(-i,q.far))/q.far),10)+2;i=sampleDistance*4;B=sampleDistance*64;R=0;V=28-i+(448-B);M.readBackPixels[V+0]===255&&M.readBackPixels[V+1]===0&&M.readBackPixels[V+
+2]===255&&(R+=0.2);V=28+i+(448-B);P[V+0]===255&&P[V+1]===0&&P[V+2]===255&&(R+=0.2);V=28+i+(448+B);P[V+0]===255&&P[V+1]===0&&P[V+2]===255&&(R+=0.2);V=28-i+(448+B);P[V+0]===255&&P[V+1]===0&&P[V+2]===255&&(R+=0.2);V=476;P[V+0]===255&&P[V+1]===0&&P[V+2]===255&&(R+=0.2);m.positionScreen.x=I[0];m.positionScreen.y=I[1];m.positionScreen.z=I[2];m.customUpdateCallback?m.customUpdateCallback(R,m):m.updateLensFlares(R);c.uniform1i(S.renderPink,0);c.disable(c.DEPTH_TEST);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,
+0)}for(o=0;o<y;o++){m=f.__webglLensFlares[o].object;s=0;for(u=m.lensFlares.length;s<u;s++){x=m.lensFlares[s];if(x.opacity>0.0010&&x.scale>0.0010){I[0]=x.x;I[1]=x.y;I[2]=x.z;t=x.size*x.scale/Ca;w[0]=t*r;w[1]=t;c.uniform3fv(S.screenPosition,I);c.uniform1f(S.rotation,x.rotation);c.uniform2fv(S.scale,w);c.uniform1f(S.opacity,x.opacity);ma(x.blending);$(x.texture,0);c.drawElements(c.TRIANGLES,6,c.UNSIGNED_SHORT,0)}}}c.enable(c.CULL_FACE);c.enable(c.DEPTH_TEST);c.depthMask(Ga)}function O(f,q){f._modelViewMatrix.multiplyToArray(q.matrixWorldInverse,
+f.matrixWorld,f._modelViewMatrixArray);THREE.Matrix4.makeInvert3x3(f._modelViewMatrix).transposeIntoArray(f._normalMatrixArray)}function X(f){var q,m,i,o,y;if(f instanceof THREE.Mesh){m=f.geometry;for(q in m.geometryGroups){i=m.geometryGroups[q];y=!1;for(o in i.__webglCustomAttributes)if(i.__webglCustomAttributes[o].needsUpdate){y=!0;break}if(m.__dirtyVertices||m.__dirtyMorphTargets||m.__dirtyElements||m.__dirtyUvs||m.__dirtyNormals||m.__dirtyColors||m.__dirtyTangents||y){y=c.DYNAMIC_DRAW;var s=void 0,
+u=void 0,x=void 0,r=void 0;x=void 0;var t=void 0,w=void 0,I=void 0,B=void 0,P=void 0,V=void 0,R=void 0,S=void 0,Ha=void 0,H=void 0,D=void 0,J=void 0,Z=void 0;w=void 0;I=void 0;r=void 0;B=void 0;r=void 0;H=void 0;D=void 0;w=void 0;H=void 0;D=void 0;J=void 0;Z=void 0;H=void 0;D=void 0;J=void 0;Z=void 0;H=void 0;D=void 0;J=void 0;Z=void 0;H=void 0;D=void 0;J=void 0;r=void 0;B=void 0;t=void 0;x=void 0;x=void 0;var C=void 0,z=void 0,ra=void 0,Xa=void 0,sa=0,Aa=0,Za=0,$a=0,Ja=0,Ka=0,da=0,La=0,va=0,A=0,
+Ba=0;C=0;var Da=i.__vertexArray,hb=i.__uvArray,ib=i.__uv2Array,Pa=i.__normalArray,ha=i.__tangentArray,Ea=i.__colorArray,ia=i.__skinVertexAArray,ja=i.__skinVertexBArray,ka=i.__skinIndexArray,la=i.__skinWeightArray,jb=i.__morphTargetsArrays,Ra=i.__webglCustomAttributes;z=void 0;var Ma=i.__faceArray,Na=i.__lineArray,qb=i.__needsSmoothNormals;V=i.__vertexColorType;P=i.__uvType;R=i.__normalType;var Ia=f.geometry,kb=Ia.__dirtyVertices,lb=Ia.__dirtyElements,fb=Ia.__dirtyUvs,mb=Ia.__dirtyNormals,nb=Ia.__dirtyTangents,
+ob=Ia.__dirtyColors,pb=Ia.__dirtyMorphTargets,ab=Ia.vertices,rb=i.faces,vb=Ia.faces,sb=Ia.faceVertexUvs[0],tb=Ia.faceVertexUvs[1],bb=Ia.skinVerticesA,cb=Ia.skinVerticesB,db=Ia.skinIndices,Va=Ia.skinWeights,Ya=Ia.edgeFaces,Sa=Ia.morphTargets;if(Ra)for(Xa in Ra)Ra[Xa].offset=0;s=0;for(u=rb.length;s<u;s++){x=rb[s];r=vb[x];sb&&(S=sb[x]);tb&&(Ha=tb[x]);x=r.vertexNormals;t=r.normal;w=r.vertexColors;I=r.color;B=r.vertexTangents;if(r instanceof THREE.Face3){if(kb){H=ab[r.a].position;D=ab[r.b].position;J=
+ab[r.c].position;Da[Aa]=H.x;Da[Aa+1]=H.y;Da[Aa+2]=H.z;Da[Aa+3]=D.x;Da[Aa+4]=D.y;Da[Aa+5]=D.z;Da[Aa+6]=J.x;Da[Aa+7]=J.y;Da[Aa+8]=J.z;Aa+=9}if(Ra)for(Xa in Ra){z=Ra[Xa];if(z.needsUpdate){C=z.offset;if(z.size===1){z.array[C+0]=z.value[r.a];z.array[C+1]=z.value[r.b];z.array[C+2]=z.value[r.c];z.offset+=3}else{H=z.value[r.a];D=z.value[r.b];J=z.value[r.c];if(z.size===2){z.array[C+0]=H.x;z.array[C+1]=H.y;z.array[C+2]=D.x;z.array[C+3]=D.y;z.array[C+4]=J.x;z.array[C+5]=J.y;z.offset+=6}else if(z.size===3){z.array[C+
+0]=H.x;z.array[C+1]=H.y;z.array[C+2]=H.z;z.array[C+3]=D.x;z.array[C+4]=D.y;z.array[C+5]=D.z;z.array[C+6]=J.x;z.array[C+7]=J.y;z.array[C+8]=J.z;z.offset+=9}else{z.array[C+0]=H.x;z.array[C+1]=H.y;z.array[C+2]=H.z;z.array[C+3]=H.w;z.array[C+4]=D.x;z.array[C+5]=D.y;z.array[C+6]=D.z;z.array[C+7]=D.w;z.array[C+8]=J.x;z.array[C+9]=J.y;z.array[C+10]=J.z;z.array[C+11]=J.w;z.offset+=12}}}}if(pb){C=0;for(z=Sa.length;C<z;C++){H=Sa[C].vertices[r.a].position;D=Sa[C].vertices[r.b].position;J=Sa[C].vertices[r.c].position;
+ra=jb[C];ra[Ba+0]=H.x;ra[Ba+1]=H.y;ra[Ba+2]=H.z;ra[Ba+3]=D.x;ra[Ba+4]=D.y;ra[Ba+5]=D.z;ra[Ba+6]=J.x;ra[Ba+7]=J.y;ra[Ba+8]=J.z}Ba+=9}if(Va.length){H=Va[r.a];D=Va[r.b];J=Va[r.c];la[A]=H.x;la[A+1]=H.y;la[A+2]=H.z;la[A+3]=H.w;la[A+4]=D.x;la[A+5]=D.y;la[A+6]=D.z;la[A+7]=D.w;la[A+8]=J.x;la[A+9]=J.y;la[A+10]=J.z;la[A+11]=J.w;H=db[r.a];D=db[r.b];J=db[r.c];ka[A]=H.x;ka[A+1]=H.y;ka[A+2]=H.z;ka[A+3]=H.w;ka[A+4]=D.x;ka[A+5]=D.y;ka[A+6]=D.z;ka[A+7]=D.w;ka[A+8]=J.x;ka[A+9]=J.y;ka[A+10]=J.z;ka[A+11]=J.w;H=bb[r.a];
+D=bb[r.b];J=bb[r.c];ia[A]=H.x;ia[A+1]=H.y;ia[A+2]=H.z;ia[A+3]=1;ia[A+4]=D.x;ia[A+5]=D.y;ia[A+6]=D.z;ia[A+7]=1;ia[A+8]=J.x;ia[A+9]=J.y;ia[A+10]=J.z;ia[A+11]=1;H=cb[r.a];D=cb[r.b];J=cb[r.c];ja[A]=H.x;ja[A+1]=H.y;ja[A+2]=H.z;ja[A+3]=1;ja[A+4]=D.x;ja[A+5]=D.y;ja[A+6]=D.z;ja[A+7]=1;ja[A+8]=J.x;ja[A+9]=J.y;ja[A+10]=J.z;ja[A+11]=1;A+=12}if(ob&&V){if(w.length==3&&V==THREE.VertexColors){r=w[0];H=w[1];D=w[2]}else D=H=r=I;Ea[va]=r.r;Ea[va+1]=r.g;Ea[va+2]=r.b;Ea[va+3]=H.r;Ea[va+4]=H.g;Ea[va+5]=H.b;Ea[va+6]=D.r;
+Ea[va+7]=D.g;Ea[va+8]=D.b;va+=9}if(nb&&Ia.hasTangents){w=B[0];I=B[1];r=B[2];ha[da]=w.x;ha[da+1]=w.y;ha[da+2]=w.z;ha[da+3]=w.w;ha[da+4]=I.x;ha[da+5]=I.y;ha[da+6]=I.z;ha[da+7]=I.w;ha[da+8]=r.x;ha[da+9]=r.y;ha[da+10]=r.z;ha[da+11]=r.w;da+=12}if(mb&&R)if(x.length==3&&qb)for(B=0;B<3;B++){t=x[B];Pa[Ka]=t.x;Pa[Ka+1]=t.y;Pa[Ka+2]=t.z;Ka+=3}else for(B=0;B<3;B++){Pa[Ka]=t.x;Pa[Ka+1]=t.y;Pa[Ka+2]=t.z;Ka+=3}if(fb&&S!==undefined&&P)for(B=0;B<3;B++){x=S[B];hb[Za]=x.u;hb[Za+1]=x.v;Za+=2}if(fb&&Ha!==undefined&&P)for(B=
+0;B<3;B++){x=Ha[B];ib[$a]=x.u;ib[$a+1]=x.v;$a+=2}if(lb){Ma[Ja]=sa;Ma[Ja+1]=sa+1;Ma[Ja+2]=sa+2;Ja+=3;Na[La]=sa;Na[La+1]=sa+1;Na[La+2]=sa;Na[La+3]=sa+2;Na[La+4]=sa+1;Na[La+5]=sa+2;La+=6;sa+=3}}else if(r instanceof THREE.Face4){if(kb){H=ab[r.a].position;D=ab[r.b].position;J=ab[r.c].position;Z=ab[r.d].position;Da[Aa]=H.x;Da[Aa+1]=H.y;Da[Aa+2]=H.z;Da[Aa+3]=D.x;Da[Aa+4]=D.y;Da[Aa+5]=D.z;Da[Aa+6]=J.x;Da[Aa+7]=J.y;Da[Aa+8]=J.z;Da[Aa+9]=Z.x;Da[Aa+10]=Z.y;Da[Aa+11]=Z.z;Aa+=12}if(Ra)for(Xa in Ra){z=Ra[Xa];if(z.needsUpdate){C=
+z.offset;if(z.size===1){z.array[C+0]=z.value[r.a];z.array[C+1]=z.value[r.b];z.array[C+2]=z.value[r.c];z.array[C+2]=z.value[r.d];z.offset+=4}else{H=z.value[r.a];D=z.value[r.b];J=z.value[r.c];Z=z.value[r.d];if(z.size===2){z.array[C+0]=H.x;z.array[C+1]=H.y;z.array[C+2]=D.x;z.array[C+3]=D.y;z.array[C+4]=J.x;z.array[C+5]=J.y;z.array[C+6]=Z.x;z.array[C+7]=Z.y;z.offset+=8}else if(z.size===3){z.array[C+0]=H.x;z.array[C+1]=H.y;z.array[C+2]=H.z;z.array[C+3]=D.x;z.array[C+4]=D.y;z.array[C+5]=D.z;z.array[C+6]=
+J.x;z.array[C+7]=J.y;z.array[C+8]=J.z;z.array[C+9]=Z.x;z.array[C+10]=Z.y;z.array[C+11]=Z.z;z.offset+=12}else{z.array[C+0]=H.x;z.array[C+1]=H.y;z.array[C+2]=H.z;z.array[C+3]=H.w;z.array[C+4]=D.x;z.array[C+5]=D.y;z.array[C+6]=D.z;z.array[C+7]=D.w;z.array[C+8]=J.x;z.array[C+9]=J.y;z.array[C+10]=J.z;z.array[C+11]=J.w;z.array[C+12]=Z.x;z.array[C+13]=Z.y;z.array[C+14]=Z.z;z.array[C+15]=Z.w;z.offset+=16}}}}if(pb){C=0;for(z=Sa.length;C<z;C++){H=Sa[C].vertices[r.a].position;D=Sa[C].vertices[r.b].position;
+J=Sa[C].vertices[r.c].position;Z=Sa[C].vertices[r.d].position;ra=jb[C];ra[Ba+0]=H.x;ra[Ba+1]=H.y;ra[Ba+2]=H.z;ra[Ba+3]=D.x;ra[Ba+4]=D.y;ra[Ba+5]=D.z;ra[Ba+6]=J.x;ra[Ba+7]=J.y;ra[Ba+8]=J.z;ra[Ba+9]=Z.x;ra[Ba+10]=Z.y;ra[Ba+11]=Z.z}Ba+=12}if(Va.length){H=Va[r.a];D=Va[r.b];J=Va[r.c];Z=Va[r.d];la[A]=H.x;la[A+1]=H.y;la[A+2]=H.z;la[A+3]=H.w;la[A+4]=D.x;la[A+5]=D.y;la[A+6]=D.z;la[A+7]=D.w;la[A+8]=J.x;la[A+9]=J.y;la[A+10]=J.z;la[A+11]=J.w;la[A+12]=Z.x;la[A+13]=Z.y;la[A+14]=Z.z;la[A+15]=Z.w;H=db[r.a];D=db[r.b];
+J=db[r.c];Z=db[r.d];ka[A]=H.x;ka[A+1]=H.y;ka[A+2]=H.z;ka[A+3]=H.w;ka[A+4]=D.x;ka[A+5]=D.y;ka[A+6]=D.z;ka[A+7]=D.w;ka[A+8]=J.x;ka[A+9]=J.y;ka[A+10]=J.z;ka[A+11]=J.w;ka[A+12]=Z.x;ka[A+13]=Z.y;ka[A+14]=Z.z;ka[A+15]=Z.w;H=bb[r.a];D=bb[r.b];J=bb[r.c];Z=bb[r.d];ia[A]=H.x;ia[A+1]=H.y;ia[A+2]=H.z;ia[A+3]=1;ia[A+4]=D.x;ia[A+5]=D.y;ia[A+6]=D.z;ia[A+7]=1;ia[A+8]=J.x;ia[A+9]=J.y;ia[A+10]=J.z;ia[A+11]=1;ia[A+12]=Z.x;ia[A+13]=Z.y;ia[A+14]=Z.z;ia[A+15]=1;H=cb[r.a];D=cb[r.b];J=cb[r.c];r=cb[r.d];ja[A]=H.x;ja[A+1]=
+H.y;ja[A+2]=H.z;ja[A+3]=1;ja[A+4]=D.x;ja[A+5]=D.y;ja[A+6]=D.z;ja[A+7]=1;ja[A+8]=J.x;ja[A+9]=J.y;ja[A+10]=J.z;ja[A+11]=1;ja[A+12]=r.x;ja[A+13]=r.y;ja[A+14]=r.z;ja[A+15]=1;A+=16}if(ob&&V){if(w.length==4&&V==THREE.VertexColors){r=w[0];H=w[1];D=w[2];w=w[3]}else w=D=H=r=I;Ea[va]=r.r;Ea[va+1]=r.g;Ea[va+2]=r.b;Ea[va+3]=H.r;Ea[va+4]=H.g;Ea[va+5]=H.b;Ea[va+6]=D.r;Ea[va+7]=D.g;Ea[va+8]=D.b;Ea[va+9]=w.r;Ea[va+10]=w.g;Ea[va+11]=w.b;va+=12}if(nb&&Ia.hasTangents){w=B[0];I=B[1];r=B[2];B=B[3];ha[da]=w.x;ha[da+1]=
+w.y;ha[da+2]=w.z;ha[da+3]=w.w;ha[da+4]=I.x;ha[da+5]=I.y;ha[da+6]=I.z;ha[da+7]=I.w;ha[da+8]=r.x;ha[da+9]=r.y;ha[da+10]=r.z;ha[da+11]=r.w;ha[da+12]=B.x;ha[da+13]=B.y;ha[da+14]=B.z;ha[da+15]=B.w;da+=16}if(mb&&R)if(x.length==4&&qb)for(B=0;B<4;B++){t=x[B];Pa[Ka]=t.x;Pa[Ka+1]=t.y;Pa[Ka+2]=t.z;Ka+=3}else for(B=0;B<4;B++){Pa[Ka]=t.x;Pa[Ka+1]=t.y;Pa[Ka+2]=t.z;Ka+=3}if(fb&&S!==undefined&&P)for(B=0;B<4;B++){x=S[B];hb[Za]=x.u;hb[Za+1]=x.v;Za+=2}if(fb&&Ha!==undefined&&P)for(B=0;B<4;B++){x=Ha[B];ib[$a]=x.u;ib[$a+
+1]=x.v;$a+=2}if(lb){Ma[Ja]=sa;Ma[Ja+1]=sa+1;Ma[Ja+2]=sa+3;Ma[Ja+3]=sa+1;Ma[Ja+4]=sa+2;Ma[Ja+5]=sa+3;Ja+=6;Na[La]=sa;Na[La+1]=sa+1;Na[La+2]=sa;Na[La+3]=sa+3;Na[La+4]=sa+1;Na[La+5]=sa+2;Na[La+6]=sa+2;Na[La+7]=sa+3;La+=8;sa+=4}}}if(Ya){s=0;for(u=Ya.length;s<u;s++){Ma[Ja]=Ya[s].a;Ma[Ja+1]=Ya[s].b;Ma[Ja+2]=Ya[s].c;Ma[Ja+3]=Ya[s].a;Ma[Ja+4]=Ya[s].c;Ma[Ja+5]=Ya[s].d;Ja+=6}}if(kb){c.bindBuffer(c.ARRAY_BUFFER,i.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,Da,y)}if(Ra)for(Xa in Ra){z=Ra[Xa];if(z.needsUpdate){c.bindBuffer(c.ARRAY_BUFFER,
+z.buffer);c.bufferData(c.ARRAY_BUFFER,z.array,y);z.needsUpdate=!1}}if(pb){C=0;for(z=Sa.length;C<z;C++){c.bindBuffer(c.ARRAY_BUFFER,i.__webglMorphTargetsBuffers[C]);c.bufferData(c.ARRAY_BUFFER,jb[C],y)}}if(ob&&va>0){c.bindBuffer(c.ARRAY_BUFFER,i.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,Ea,y)}if(mb){c.bindBuffer(c.ARRAY_BUFFER,i.__webglNormalBuffer);c.bufferData(c.ARRAY_BUFFER,Pa,y)}if(nb&&Ia.hasTangents){c.bindBuffer(c.ARRAY_BUFFER,i.__webglTangentBuffer);c.bufferData(c.ARRAY_BUFFER,ha,y)}if(fb&&
+Za>0){c.bindBuffer(c.ARRAY_BUFFER,i.__webglUVBuffer);c.bufferData(c.ARRAY_BUFFER,hb,y)}if(fb&&$a>0){c.bindBuffer(c.ARRAY_BUFFER,i.__webglUV2Buffer);c.bufferData(c.ARRAY_BUFFER,ib,y)}if(lb){c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webglFaceBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Ma,y);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,i.__webglLineBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,Na,y)}if(A>0){c.bindBuffer(c.ARRAY_BUFFER,i.__webglSkinVertexABuffer);c.bufferData(c.ARRAY_BUFFER,ia,y);c.bindBuffer(c.ARRAY_BUFFER,
+i.__webglSkinVertexBBuffer);c.bufferData(c.ARRAY_BUFFER,ja,y);c.bindBuffer(c.ARRAY_BUFFER,i.__webglSkinIndicesBuffer);c.bufferData(c.ARRAY_BUFFER,ka,y);c.bindBuffer(c.ARRAY_BUFFER,i.__webglSkinWeightsBuffer);c.bufferData(c.ARRAY_BUFFER,la,y)}}}m.__dirtyVertices=!1;m.__dirtyMorphTargets=!1;m.__dirtyElements=!1;m.__dirtyUvs=!1;m.__dirtyNormals=!1;m.__dirtyTangents=!1;m.__dirtyColors=!1}else if(f instanceof THREE.Ribbon){m=f.geometry;if(m.__dirtyVertices||m.__dirtyColors){f=m;q=c.DYNAMIC_DRAW;V=f.vertices;
+i=f.colors;R=V.length;y=i.length;S=f.__vertexArray;s=f.__colorArray;Ha=f.__dirtyColors;if(f.__dirtyVertices){for(u=0;u<R;u++){P=V[u].position;o=u*3;S[o]=P.x;S[o+1]=P.y;S[o+2]=P.z}c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,S,q)}if(Ha){for(u=0;u<y;u++){color=i[u];o=u*3;s[o]=color.r;s[o+1]=color.g;s[o+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,s,q)}}m.__dirtyVertices=!1;m.__dirtyColors=!1}else if(f instanceof THREE.Line){m=
+f.geometry;if(m.__dirtyVertices||m.__dirtyColors){f=m;q=c.DYNAMIC_DRAW;V=f.vertices;i=f.colors;R=V.length;y=i.length;S=f.__vertexArray;s=f.__colorArray;Ha=f.__dirtyColors;if(f.__dirtyVertices){for(u=0;u<R;u++){P=V[u].position;o=u*3;S[o]=P.x;S[o+1]=P.y;S[o+2]=P.z}c.bindBuffer(c.ARRAY_BUFFER,f.__webglVertexBuffer);c.bufferData(c.ARRAY_BUFFER,S,q)}if(Ha){for(u=0;u<y;u++){color=i[u];o=u*3;s[o]=color.r;s[o+1]=color.g;s[o+2]=color.b}c.bindBuffer(c.ARRAY_BUFFER,f.__webglColorBuffer);c.bufferData(c.ARRAY_BUFFER,
+s,q)}}m.__dirtyVertices=!1;m.__dirtyColors=!1}else if(f instanceof THREE.ParticleSystem){m=f.geometry;(m.__dirtyVertices||m.__dirtyColors||f.sortParticles)&&d(m,c.DYNAMIC_DRAW,f);m.__dirtyVertices=!1;m.__dirtyColors=!1}}function Q(f){function q(I){var B=[];m=0;for(i=I.length;m<i;m++)I[m]==undefined?B.push("undefined"):B.push(I[m].id);return B.join("_")}var m,i,o,y,s,u,x,r,t={},w=f.morphTargets!==undefined?f.morphTargets.length:0;f.geometryGroups={};o=0;for(y=f.faces.length;o<y;o++){s=f.faces[o];u=
+s.materials;x=q(u);t[x]==undefined&&(t[x]={hash:x,counter:0});r=t[x].hash+"_"+t[x].counter;f.geometryGroups[r]==undefined&&(f.geometryGroups[r]={faces:[],materials:u,vertices:0,numMorphTargets:w});s=s instanceof THREE.Face3?3:4;if(f.geometryGroups[r].vertices+s>65535){t[x].counter+=1;r=t[x].hash+"_"+t[x].counter;f.geometryGroups[r]==undefined&&(f.geometryGroups[r]={faces:[],materials:u,vertices:0,numMorphTargets:w})}f.geometryGroups[r].faces.push(o);f.geometryGroups[r].vertices+=s}}function ca(f,
+q,m){f.push({buffer:q,object:m,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function ma(f){if(f!=fa){switch(f){case THREE.AdditiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE);break;case THREE.SubtractiveBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:c.blendEquation(c.FUNC_ADD);c.blendFunc(c.ZERO,c.SRC_COLOR);break;default:c.blendEquationSeparate(c.FUNC_ADD,c.FUNC_ADD);c.blendFuncSeparate(c.SRC_ALPHA,
+c.ONE_MINUS_SRC_ALPHA,c.ONE,c.ONE_MINUS_SRC_ALPHA)}fa=f}}function wa(f,q,m){if((m.width&m.width-1)==0&&(m.height&m.height-1)==0){c.texParameteri(f,c.TEXTURE_WRAP_S,ea(q.wrapS));c.texParameteri(f,c.TEXTURE_WRAP_T,ea(q.wrapT));c.texParameteri(f,c.TEXTURE_MAG_FILTER,ea(q.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,ea(q.minFilter));c.generateMipmap(f)}else{c.texParameteri(f,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(f,c.TEXTURE_MAG_FILTER,
+ta(q.magFilter));c.texParameteri(f,c.TEXTURE_MIN_FILTER,ta(q.minFilter))}}function $(f,q){if(f.needsUpdate){if(f.__webglInit){c.bindTexture(c.TEXTURE_2D,f.__webglTexture);c.texSubImage2D(c.TEXTURE_2D,0,0,0,c.RGBA,c.UNSIGNED_BYTE,f.image)}else{f.__webglTexture=c.createTexture();c.bindTexture(c.TEXTURE_2D,f.__webglTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGBA,c.RGBA,c.UNSIGNED_BYTE,f.image);f.__webglInit=!0}wa(c.TEXTURE_2D,f,f.image);c.bindTexture(c.TEXTURE_2D,null);f.needsUpdate=!1}c.activeTexture(c.TEXTURE0+
+q);c.bindTexture(c.TEXTURE_2D,f.__webglTexture)}function L(f){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,ea(f.wrapS));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,ea(f.wrapT));
+c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,ea(f.magFilter));c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,ea(f.minFilter));c.texImage2D(c.TEXTURE_2D,0,ea(f.format),f.width,f.height,0,ea(f.format),ea(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 q,m;if(f){q=f.__webglFramebuffer;m=f.width;f=f.height}else{q=null;m=oa;f=Ca}if(q!=Fa){c.bindFramebuffer(c.FRAMEBUFFER,q);c.viewport(Y,ua,m,f);Fa=q}}function xa(f,q){var m;if(f=="fragment")m=c.createShader(c.FRAGMENT_SHADER);else f=="vertex"&&(m=c.createShader(c.VERTEX_SHADER));c.shaderSource(m,q);c.compileShader(m);if(!c.getShaderParameter(m,c.COMPILE_STATUS)){console.error(c.getShaderInfoLog(m));console.error(q);return null}return m}function ta(f){switch(f){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return c.NEAREST;
+default:return c.LINEAR}}function ea(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 c,T=document.createElement("canvas"),U=[],na=null,Fa=null,Ga=!0,ya=this,aa=null,pa=null,fa=null,qa=null,Y=0,ua=0,oa=0,Ca=0,za=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ga=new THREE.Matrix4,Oa=new Float32Array(16),Ta=new Float32Array(16),Ua=new THREE.Vector4,gb={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},Qa=!0,eb=!0,Wa=new THREE.Color(0),ub=0;if(b){if(b.stencil!=
+undefined)Qa=b.stencil;if(b.antialias!==undefined)eb=b.antialias;b.clearColor!==undefined&&Wa.setHex(b.clearColor);if(b.clearAlpha!==undefined)ub=b.clearAlpha}this.maxMorphTargets=8;this.domElement=T;this.autoClear=!0;this.sortObjects=!0;(function(f,q,m,i){try{if(!(c=T.getContext("experimental-webgl",{antialias:f,stencil:i})))throw"Error creating WebGL context.";}catch(o){console.error(o)}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.blendEquation(c.FUNC_ADD);c.blendFunc(c.SRC_ALPHA,c.ONE_MINUS_SRC_ALPHA);c.clearColor(q.r,q.g,q.b,m)})(eb,Wa,ub,Qa);this.context=c;if(Qa){var W={};W.vertices=new Float32Array(12);W.faces=new Uint16Array(6);W.darkness=0.5;W.vertices[0]=-2;W.vertices[1]=-1;W.vertices[2]=-1;W.vertices[3]=2;W.vertices[4]=-1;W.vertices[5]=-1;W.vertices[6]=2;W.vertices[7]=1;W.vertices[8]=-1;W.vertices[9]=-2;W.vertices[10]=1;W.vertices[11]=-1;W.faces[0]=0;W.faces[1]=1;W.faces[2]=
+2;W.faces[3]=0;W.faces[4]=2;W.faces[5]=3;W.vertexBuffer=c.createBuffer();W.elementBuffer=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,W.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,W.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,W.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,W.faces,c.STATIC_DRAW);W.program=c.createProgram();c.attachShader(W.program,xa("fragment",THREE.ShaderLib.shadowPost.fragmentShader));c.attachShader(W.program,xa("vertex",THREE.ShaderLib.shadowPost.vertexShader));
+c.linkProgram(W.program);W.vertexLocation=c.getAttribLocation(W.program,"position");W.projectionLocation=c.getUniformLocation(W.program,"projectionMatrix");W.darknessLocation=c.getUniformLocation(W.program,"darkness")}var M={};M.vertices=new Float32Array(16);M.faces=new Uint16Array(6);M.transparency=0.5;b=0;M.vertices[b++]=-1;M.vertices[b++]=-1;M.vertices[b++]=0;M.vertices[b++]=0;M.vertices[b++]=1;M.vertices[b++]=-1;M.vertices[b++]=1;M.vertices[b++]=0;M.vertices[b++]=1;M.vertices[b++]=1;M.vertices[b++]=
+1;M.vertices[b++]=1;M.vertices[b++]=-1;M.vertices[b++]=1;M.vertices[b++]=0;M.vertices[b++]=1;b=0;M.faces[b++]=0;M.faces[b++]=1;M.faces[b++]=2;M.faces[b++]=0;M.faces[b++]=2;M.faces[b++]=3;M.vertexBuffer=c.createBuffer();M.elementBuffer=c.createBuffer();M.tempTexture=c.createTexture();M.readBackPixels=new Uint8Array(1024);c.bindBuffer(c.ARRAY_BUFFER,M.vertexBuffer);c.bufferData(c.ARRAY_BUFFER,M.vertices,c.STATIC_DRAW);c.bindBuffer(c.ELEMENT_ARRAY_BUFFER,M.elementBuffer);c.bufferData(c.ELEMENT_ARRAY_BUFFER,
+M.faces,c.STATIC_DRAW);c.bindTexture(c.TEXTURE_2D,M.tempTexture);c.texImage2D(c.TEXTURE_2D,0,c.RGB,16,16,0,c.RGB,c.UNSIGNED_BYTE,null);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST);c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST);M.program=c.createProgram();c.attachShader(M.program,xa("fragment",THREE.ShaderLib.lensFlare.fragmentShader));c.attachShader(M.program,
+xa("vertex",THREE.ShaderLib.lensFlare.vertexShader));c.linkProgram(M.program);M.attributes={};M.uniforms={};M.attributes.vertex=c.getAttribLocation(M.program,"position");M.attributes.uv=c.getAttribLocation(M.program,"UV");M.uniforms.map=c.getUniformLocation(M.program,"map");M.uniforms.opacity=c.getUniformLocation(M.program,"opacity");M.uniforms.scale=c.getUniformLocation(M.program,"scale");M.uniforms.rotation=c.getUniformLocation(M.program,"rotation");M.uniforms.screenPosition=c.getUniformLocation(M.program,
+"screenPosition");M.uniforms.renderPink=c.getUniformLocation(M.program,"renderPink");this.setSize=function(f,q){T.width=f;T.height=q;this.setViewport(0,0,T.width,T.height)};this.setViewport=function(f,q,m,i){Y=f;ua=q;oa=m;Ca=i;c.viewport(Y,ua,oa,Ca)};this.setScissor=function(f,q,m,i){c.scissor(f,q,m,i)};this.enableScissorTest=function(f){f?c.enable(c.SCISSOR_TEST):c.disable(c.SCISSOR_TEST)};this.enableDepthBufferWrite=function(f){Ga=f;c.depthMask(f)};this.setClearColorHex=function(f,q){var m=new THREE.Color(f);
+c.clearColor(m.r,m.g,m.b,q)};this.setClearColor=function(f,q){c.clearColor(f.r,f.g,f.b,q)};this.clear=function(){c.clear(c.COLOR_BUFFER_BIT|c.DEPTH_BUFFER_BIT|c.STENCIL_BUFFER_BIT)};this.setStencilShadowDarkness=function(f){W.darkness=f};this.initMaterial=function(f,q,m,i){var o,y,s;if(f instanceof THREE.MeshDepthMaterial)s="depth";else if(f instanceof THREE.ShadowVolumeDynamicMaterial)s="shadowVolumeDynamic";else if(f instanceof THREE.MeshNormalMaterial)s="normal";else if(f instanceof THREE.MeshBasicMaterial)s=
+"basic";else if(f instanceof THREE.MeshLambertMaterial)s="lambert";else if(f instanceof THREE.MeshPhongMaterial)s="phong";else if(f instanceof THREE.LineBasicMaterial)s="basic";else f instanceof THREE.ParticleBasicMaterial&&(s="particle_basic");if(s){var u=THREE.ShaderLib[s];f.uniforms=Uniforms.clone(u.uniforms);f.vertexShader=u.vertexShader;f.fragmentShader=u.fragmentShader}var x,r,t;x=t=u=0;for(r=q.length;x<r;x++){y=q[x];y instanceof THREE.DirectionalLight&&t++;y instanceof THREE.PointLight&&u++}if(u+
+t<=4)q=t;else{q=Math.ceil(4*t/(u+t));u=4-q}y={directional:q,point:u};t=50;if(i!==undefined&&i instanceof THREE.SkinnedMesh)t=i.bones.length;var w;a:{x=f.fragmentShader;r=f.vertexShader;u=f.uniforms;q=f.attributes;m={map:!!f.map,envMap:!!f.envMap,lightMap:!!f.lightMap,vertexColors:f.vertexColors,fog:m,sizeAttenuation:f.sizeAttenuation,skinning:f.skinning,morphTargets:f.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:y.directional,maxPointLights:y.point,maxBones:t};var I;y=[];if(s)y.push(s);
+else{y.push(x);y.push(r)}for(I in m){y.push(I);y.push(m[I])}s=y.join();I=0;for(y=U.length;I<y;I++)if(U[I].code==s){w=U[I].program;break a}I=c.createProgram();prefix_fragment=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+m.maxDirLights,"#define MAX_POINT_LIGHTS "+m.maxPointLights,m.fog?"#define USE_FOG":"",m.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",m.map?"#define USE_MAP":"",m.envMap?"#define USE_ENVMAP":"",m.lightMap?"#define USE_LIGHTMAP":"",m.vertexColors?"#define USE_COLOR":
+"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");prefix_vertex=[c.getParameter(c.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+m.maxDirLights,"#define MAX_POINT_LIGHTS "+m.maxPointLights,"#define MAX_BONES "+m.maxBones,m.map?"#define USE_MAP":"",m.envMap?"#define USE_ENVMAP":"",m.lightMap?"#define USE_LIGHTMAP":"",m.vertexColors?"#define USE_COLOR":"",m.skinning?"#define USE_SKINNING":"",m.morphTargets?"#define USE_MORPHTARGETS":
+"",m.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nuniform mat4 cameraInverseMatrix;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\nattribute vec2 uv2;\n#ifdef USE_COLOR\nattribute vec3 color;\n#endif\n#ifdef USE_MORPHTARGETS\nattribute vec3 morphTarget0;\nattribute vec3 morphTarget1;\nattribute vec3 morphTarget2;\nattribute vec3 morphTarget3;\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+c.attachShader(I,xa("fragment",prefix_fragment+x));c.attachShader(I,xa("vertex",prefix_vertex+r));c.linkProgram(I);c.getProgramParameter(I,c.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+c.getProgramParameter(I,c.VALIDATE_STATUS)+", gl error ["+c.getError()+"]");I.uniforms={};I.attributes={};var B;x=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(B in u)x.push(B);
+B=x;u=0;for(x=B.length;u<x;u++){r=B[u];I.uniforms[r]=c.getUniformLocation(I,r)}x=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(B=0;B<m.maxMorphTargets;B++)x.push("morphTarget"+B);for(w in q)x.push(w);w=x;B=0;for(q=w.length;B<q;B++){m=w[B];I.attributes[m]=c.getAttribLocation(I,m)}U.push({program:I,code:s});w=I}f.program=w;w=f.program.attributes;c.enableVertexAttribArray(w.position);w.color>=0&&c.enableVertexAttribArray(w.color);w.normal>=
+0&&c.enableVertexAttribArray(w.normal);w.tangent>=0&&c.enableVertexAttribArray(w.tangent);if(f.skinning&&w.skinVertexA>=0&&w.skinVertexB>=0&&w.skinIndex>=0&&w.skinWeight>=0){c.enableVertexAttribArray(w.skinVertexA);c.enableVertexAttribArray(w.skinVertexB);c.enableVertexAttribArray(w.skinIndex);c.enableVertexAttribArray(w.skinWeight)}for(o in f.attributes)w[o]>=0&&c.enableVertexAttribArray(w[o]);if(f.morphTargets){f.numSupportedMorphTargets=0;if(w.morphTarget0>=0){c.enableVertexAttribArray(w.morphTarget0);
+f.numSupportedMorphTargets++}if(w.morphTarget1>=0){c.enableVertexAttribArray(w.morphTarget1);f.numSupportedMorphTargets++}if(w.morphTarget2>=0){c.enableVertexAttribArray(w.morphTarget2);f.numSupportedMorphTargets++}if(w.morphTarget3>=0){c.enableVertexAttribArray(w.morphTarget3);f.numSupportedMorphTargets++}if(w.morphTarget4>=0){c.enableVertexAttribArray(w.morphTarget4);f.numSupportedMorphTargets++}if(w.morphTarget5>=0){c.enableVertexAttribArray(w.morphTarget5);f.numSupportedMorphTargets++}if(w.morphTarget6>=
+0){c.enableVertexAttribArray(w.morphTarget6);f.numSupportedMorphTargets++}if(w.morphTarget7>=0){c.enableVertexAttribArray(w.morphTarget7);f.numSupportedMorphTargets++}i.__webglMorphTargetInfluences=new Float32Array(this.maxMorphTargets);f=0;for(o=this.maxMorphTargets;f<o;f++)i.__webglMorphTargetInfluences[f]=0}};this.render=function(f,q,m,i){var o,y,s,u,x,r,t,w,I=f.lights,B=f.fog;q.matrixAutoUpdate&&q.updateMatrix();f.update(undefined,!1,q);q.matrixWorldInverse.flattenToArray(Ta);q.projectionMatrix.flattenToArray(Oa);
+ga.multiply(q.projectionMatrix,q.matrixWorldInverse);n(ga);this.initWebGLObjects(f);L(m);(this.autoClear||i)&&this.clear();x=f.__webglObjects.length;for(i=0;i<x;i++){o=f.__webglObjects[i];t=o.object;if(t.visible)if(!(t instanceof THREE.Mesh)||p(t)){t.matrixWorld.flattenToArray(t._objectMatrixArray);O(t,q);F(o);o.render=!0;if(this.sortObjects){Ua.copy(t.position);ga.multiplyVector3(Ua);o.z=Ua.z}}else o.render=!1;else o.render=!1}this.sortObjects&&f.__webglObjects.sort(K);r=f.__webglObjectsImmediate.length;
+for(i=0;i<r;i++){o=f.__webglObjectsImmediate[i];t=o.object;if(t.visible){t.matrixAutoUpdate&&t.matrixWorld.flattenToArray(t._objectMatrixArray);O(t,q);E(o)}}ma(THREE.NormalBlending);for(i=0;i<x;i++){o=f.__webglObjects[i];if(o.render){t=o.object;w=o.buffer;s=o.opaque;j(t);for(o=0;o<s.count;o++){u=s.list[o];k(u.depthTest);h(q,I,B,u,w,t)}}}for(i=0;i<r;i++){o=f.__webglObjectsImmediate[i];t=o.object;if(t.visible){s=o.opaque;j(t);for(o=0;o<s.count;o++){u=s.list[o];k(u.depthTest);y=e(q,I,B,u,t);t.render(function(P){g(P,
+y)})}}}for(i=0;i<x;i++){o=f.__webglObjects[i];if(o.render){t=o.object;w=o.buffer;s=o.transparent;j(t);for(o=0;o<s.count;o++){u=s.list[o];ma(u.blending);k(u.depthTest);h(q,I,B,u,w,t)}}}for(i=0;i<r;i++){o=f.__webglObjectsImmediate[i];t=o.object;if(t.visible){s=o.transparent;j(t);for(o=0;o<s.count;o++){u=s.list[o];ma(u.blending);k(u.depthTest);y=e(q,I,B,u,t);t.render(function(P){g(P,y)})}}}Qa&&f.__webglShadowVolumes.length&&f.lights.length&&G(f);f.__webglLensFlares.length&&N(f,q);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){if(!f.__webglObjects){f.__webglObjects=[];f.__webglObjectsImmediate=[];f.__webglShadowVolumes=[];f.__webglLensFlares=[]}for(;f.__objectsAdded.length;){var q=f.__objectsAdded[0],m=f,i=void 0,o=void 0,y=void 0;if(q._modelViewMatrix==undefined){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)}if(q instanceof THREE.Mesh){o=q.geometry;o.geometryGroups==undefined&&Q(o);for(i in o.geometryGroups){y=o.geometryGroups[i];if(!y.__webglVertexBuffer){var s=y;s.__webglVertexBuffer=c.createBuffer();s.__webglNormalBuffer=c.createBuffer();s.__webglTangentBuffer=c.createBuffer();s.__webglColorBuffer=c.createBuffer();s.__webglUVBuffer=c.createBuffer();s.__webglUV2Buffer=
+c.createBuffer();s.__webglSkinVertexABuffer=c.createBuffer();s.__webglSkinVertexBBuffer=c.createBuffer();s.__webglSkinIndicesBuffer=c.createBuffer();s.__webglSkinWeightsBuffer=c.createBuffer();s.__webglFaceBuffer=c.createBuffer();s.__webglLineBuffer=c.createBuffer();if(s.numMorphTargets){var u=void 0,x=void 0;s.__webglMorphTargetsBuffers=[];u=0;for(x=s.numMorphTargets;u<x;u++)s.__webglMorphTargetsBuffers.push(c.createBuffer())}s=y;u=q;var r=void 0,t=void 0,w=void 0;w=void 0;var I=void 0,B=void 0,
+P=void 0,V=P=x=0;t=void 0;w=void 0;var R=void 0;r=void 0;t=void 0;I=u.geometry;R=I.faces;B=s.faces;r=0;for(t=B.length;r<t;r++){w=B[r];w=R[w];if(w instanceof THREE.Face3){x+=3;P+=1;V+=3}else if(w instanceof THREE.Face4){x+=4;P+=2;V+=4}}r=s;t=u;R=void 0;B=void 0;var S=void 0,Ha=void 0;S=void 0;w=[];R=0;for(B=t.materials.length;R<B;R++){S=t.materials[R];if(S instanceof THREE.MeshFaceMaterial){S=0;for(l=r.materials.length;S<l;S++)(Ha=r.materials[S])&&w.push(Ha)}else(Ha=S)&&w.push(Ha)}r=w;a:{t=void 0;
+R=void 0;B=r.length;for(t=0;t<B;t++){R=r[t];if(R.map||R.lightMap||R instanceof THREE.MeshShaderMaterial){t=!0;break a}}t=!1}a:{R=void 0;B=void 0;w=r.length;for(R=0;R<w;R++){B=r[R];if(!(B instanceof THREE.MeshBasicMaterial&&!B.envMap||B instanceof THREE.MeshDepthMaterial)){R=B&&B.shading!=undefined&&B.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}}R=!1}a:{B=void 0;w=void 0;S=r.length;for(B=0;B<S;B++){w=r[B];if(w.vertexColors){w=w.vertexColors;break a}}w=!1}s.__vertexArray=
+new Float32Array(x*3);if(R)s.__normalArray=new Float32Array(x*3);if(I.hasTangents)s.__tangentArray=new Float32Array(x*4);if(w)s.__colorArray=new Float32Array(x*3);if(t){if(I.faceUvs.length>0||I.faceVertexUvs.length>0)s.__uvArray=new Float32Array(x*2);if(I.faceUvs.length>1||I.faceVertexUvs.length>1)s.__uv2Array=new Float32Array(x*2)}if(u.geometry.skinWeights.length&&u.geometry.skinIndices.length){s.__skinVertexAArray=new Float32Array(x*4);s.__skinVertexBArray=new Float32Array(x*4);s.__skinIndexArray=
+new Float32Array(x*4);s.__skinWeightArray=new Float32Array(x*4)}s.__faceArray=new Uint16Array(P*3+(u.geometry.edgeFaces?u.geometry.edgeFaces.length*6:0));s.__lineArray=new Uint16Array(V*2);if(s.numMorphTargets){s.__morphTargetsArrays=[];I=0;for(B=s.numMorphTargets;I<B;I++)s.__morphTargetsArrays.push(new Float32Array(x*3))}s.__needsSmoothNormals=R==THREE.SmoothShading;s.__uvType=t;s.__vertexColorType=w;s.__normalType=R;s.__webglFaceCount=P*3+(u.geometry.edgeFaces?u.geometry.edgeFaces.length*6:0);s.__webglLineCount=
+V*2;I=0;for(B=r.length;I<B;I++)if(r[I].attributes){s.__webglCustomAttributes={};for(a in r[I].attributes){t=r[I].attributes[a];P=1;if(t.type==="v2")P=2;else if(t.type==="v3")P=3;else if(t.type==="v4")P=4;else t.type==="c"&&(P=3);t.size=P;t.needsUpdate=!0;t.array=new Float32Array(x*P);t.buffer=c.createBuffer();s.__webglCustomAttributes[a]=t}}o.__dirtyVertices=!0;o.__dirtyMorphTargets=!0;o.__dirtyElements=!0;o.__dirtyUvs=!0;o.__dirtyNormals=!0;o.__dirtyTangents=!0;o.__dirtyColors=!0}q instanceof THREE.ShadowVolume?
+ca(m.__webglShadowVolumes,y,q):ca(m.__webglObjects,y,q)}}else if(q instanceof THREE.LensFlare)ca(m.__webglLensFlares,undefined,q);else if(q instanceof THREE.Ribbon){o=q.geometry;if(!o.__webglVertexBuffer){i=o;i.__webglVertexBuffer=c.createBuffer();i.__webglColorBuffer=c.createBuffer();i=o;y=i.vertices.length;i.__vertexArray=new Float32Array(y*3);i.__colorArray=new Float32Array(y*3);i.__webglVertexCount=y;o.__dirtyVertices=!0;o.__dirtyColors=!0}ca(m.__webglObjects,o,q)}else if(q instanceof THREE.Line){o=
+q.geometry;if(!o.__webglVertexBuffer){i=o;i.__webglVertexBuffer=c.createBuffer();i.__webglColorBuffer=c.createBuffer();i=o;y=i.vertices.length;i.__vertexArray=new Float32Array(y*3);i.__colorArray=new Float32Array(y*3);i.__webglLineCount=y;o.__dirtyVertices=!0;o.__dirtyColors=!0}ca(m.__webglObjects,o,q)}else if(q instanceof THREE.ParticleSystem){o=q.geometry;if(!o.__webglVertexBuffer){i=o;i.__webglVertexBuffer=c.createBuffer();i.__webglColorBuffer=c.createBuffer();i=o;y=i.vertices.length;i.__vertexArray=
+new Float32Array(y*3);i.__colorArray=new Float32Array(y*3);i.__sortArray=[];i.__webglParticleCount=y;o.__dirtyVertices=!0;o.__dirtyColors=!0}ca(m.__webglObjects,o,q)}else THREE.MarchingCubes!==undefined&&q instanceof THREE.MarchingCubes&&m.__webglObjectsImmediate.push({object:q,opaque:{list:[],count:0},transparent:{list:[],count:0}});f.__objectsAdded.splice(0,1)}for(;f.__objectsRemoved.length;){q=f.__objectsRemoved[0];m=f;o=void 0;i=void 0;for(o=m.__webglObjects.length-1;o>=0;o--){i=m.__webglObjects[o].object;
+q==i&&m.__webglObjects.splice(o,1)}f.__objectsRemoved.splice(0,1)}q=0;for(m=f.__webglObjects.length;q<m;q++)X(f.__webglObjects[q].object,f);q=0;for(m=f.__webglShadowVolumes.length;q<m;q++)X(f.__webglShadowVolumes[q].object,f);q=0;for(m=f.__webglLensFlares.length;q<m;q++)X(f.__webglLensFlares[q].object,f)};this.setFaceCulling=function(f,q){if(f){!q||q=="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.WebGLRenderTarget=function(b,d,e){this.width=b;this.height=d;e=e||{};this.wrapS=e.wrapS!==undefined?e.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=e.wrapT!==undefined?e.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=e.magFilter!==undefined?e.magFilter:THREE.LinearFilter;this.minFilter=e.minFilter!==undefined?e.minFilter:THREE.LinearMipMapLinearFilter;this.format=e.format!==undefined?e.format:THREE.RGBFormat;this.type=e.type!==undefined?e.type:THREE.UnsignedByteType};

+ 2 - 2
examples/js/Stats.js

@@ -3,8 +3,8 @@ var Stats=function(){function w(d,K,n){var u,f,c;for(f=0;f<30;f++)for(u=0;u<73;u
 g:16,b:26},fg:{r:255,g:0,b:128}}};e=document.createElement("div");e.style.cursor="pointer";e.style.width="80px";e.style.opacity="0.9";e.style.zIndex="10001";e.addEventListener("click",function(){v++;v==x&&(v=0);m.style.display="none";h.style.display="none";j.style.display="none";switch(v){case 0:m.style.display="block";break;case 1:h.style.display="block";break;case 2:j.style.display="block"}},false);m=document.createElement("div");m.style.backgroundColor="rgb("+Math.floor(b.fps.bg.r/2)+","+Math.floor(b.fps.bg.g/
 2)+","+Math.floor(b.fps.bg.b/2)+")";m.style.padding="2px 0px 3px 0px";e.appendChild(m);g=document.createElement("div");g.style.fontFamily="Helvetica, Arial, sans-serif";g.style.textAlign="left";g.style.fontSize="9px";g.style.color="rgb("+b.fps.fg.r+","+b.fps.fg.g+","+b.fps.fg.b+")";g.style.margin="0px 0px 1px 3px";g.innerHTML='<span style="font-weight:bold">FPS</span>';m.appendChild(g);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";m.appendChild(a);
 p=a.getContext("2d");p.fillStyle="rgb("+b.fps.bg.r+","+b.fps.bg.g+","+b.fps.bg.b+")";p.fillRect(0,0,a.width,a.height);C=p.getImageData(0,0,a.width,a.height);h=document.createElement("div");h.style.backgroundColor="rgb("+Math.floor(b.ms.bg.r/2)+","+Math.floor(b.ms.bg.g/2)+","+Math.floor(b.ms.bg.b/2)+")";h.style.padding="2px 0px 3px 0px";h.style.display="none";e.appendChild(h);i=document.createElement("div");i.style.fontFamily="Helvetica, Arial, sans-serif";i.style.textAlign="left";i.style.fontSize=
-"9px";i.style.color="rgb("+b.ms.fg.r+","+b.ms.fg.g+","+b.ms.fg.b+")";i.style.margin="0px 0px 1px 3px";i.innerHTML='<span style="font-weight:bold">MS</span>';h.appendChild(i);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";h.appendChild(a);r=a.getContext("2d");r.fillStyle="rgb("+b.ms.bg.r+","+b.ms.bg.g+","+b.ms.bg.b+")";r.fillRect(0,0,a.width,a.height);F=r.getImageData(0,0,a.width,a.height);try{if(webkitPerformance&&webkitPerformance.memory.totalJSHeapSize)x=
+"9px";i.style.color="rgb("+b.ms.fg.r+","+b.ms.fg.g+","+b.ms.fg.b+")";i.style.margin="0px 0px 1px 3px";i.innerHTML='<span style="font-weight:bold">MS</span>';h.appendChild(i);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";h.appendChild(a);r=a.getContext("2d");r.fillStyle="rgb("+b.ms.bg.r+","+b.ms.bg.g+","+b.ms.bg.b+")";r.fillRect(0,0,a.width,a.height);F=r.getImageData(0,0,a.width,a.height);try{if(performance&&performance.memory&&performance.memory.totalJSHeapSize)x=
 3}catch(L){}j=document.createElement("div");j.style.backgroundColor="rgb("+Math.floor(b.mem.bg.r/2)+","+Math.floor(b.mem.bg.g/2)+","+Math.floor(b.mem.bg.b/2)+")";j.style.padding="2px 0px 3px 0px";j.style.display="none";e.appendChild(j);k=document.createElement("div");k.style.fontFamily="Helvetica, Arial, sans-serif";k.style.textAlign="left";k.style.fontSize="9px";k.style.color="rgb("+b.mem.fg.r+","+b.mem.fg.g+","+b.mem.fg.b+")";k.style.margin="0px 0px 1px 3px";k.innerHTML='<span style="font-weight:bold">MEM</span>';
 j.appendChild(k);a=document.createElement("canvas");a.width=74;a.height=30;a.style.display="block";a.style.marginLeft="3px";j.appendChild(a);t=a.getContext("2d");t.fillStyle="#301010";t.fillRect(0,0,a.width,a.height);I=t.getImageData(0,0,a.width,a.height);return{domElement:e,update:function(){y++;l=(new Date).getTime();q=l-J;D=Math.min(D,q);E=Math.max(E,q);w(F.data,Math.min(30,30-q/200*30),"ms");i.innerHTML='<span style="font-weight:bold">'+q+" MS</span> ("+D+"-"+E+")";r.putImageData(F,0,0);J=l;if(l>
-z+1E3){o=Math.round(y*1E3/(l-z));A=Math.min(A,o);B=Math.max(B,o);w(C.data,Math.min(30,30-o/100*30),"fps");g.innerHTML='<span style="font-weight:bold">'+o+" FPS</span> ("+A+"-"+B+")";p.putImageData(C,0,0);if(x==3){s=webkitPerformance.memory.usedJSHeapSize*9.54E-7;G=Math.min(G,s);H=Math.max(H,s);w(I.data,Math.min(30,30-s/2),"mem");k.innerHTML='<span style="font-weight:bold">'+Math.round(s)+" MEM</span> ("+Math.round(G)+"-"+Math.round(H)+")";t.putImageData(I,0,0)}z=l;y=0}}}};
+z+1E3){o=Math.round(y*1E3/(l-z));A=Math.min(A,o);B=Math.max(B,o);w(C.data,Math.min(30,30-o/100*30),"fps");g.innerHTML='<span style="font-weight:bold">'+o+" FPS</span> ("+A+"-"+B+")";p.putImageData(C,0,0);if(x==3){s=performance.memory.usedJSHeapSize*9.54E-7;G=Math.min(G,s);H=Math.max(H,s);w(I.data,Math.min(30,30-s/2),"mem");k.innerHTML='<span style="font-weight:bold">'+Math.round(s)+" MEM</span> ("+Math.round(G)+"-"+Math.round(H)+")";t.putImageData(I,0,0)}z=l;y=0}}}};
 

BIN
examples/textures/lava/cloud.png


BIN
examples/textures/lava/lavatile.jpg


+ 1 - 0
examples/webgl_geometry_minecraft_ao.html

@@ -86,6 +86,7 @@
 				container = document.getElementById( 'container' );
 
 				camera = new THREE.QuakeCamera( { fov: 60, aspect: window.innerWidth / window.innerHeight, near: 1, far: 20000,
+												  constrainVertical: true, verticalMin: 1.1, verticalMax: 2.2,
 												  movementSpeed: 15, lookSpeed: 0.005, noFly: false, lookVertical: true } );
 
 				camera.target.position.z = - 100;

+ 1 - 1
examples/webgl_materials_video.html

@@ -137,7 +137,7 @@
 
 					material = materials[ cube_count ];
 
-					material.program = material_base.program;
+					//material.program = material_base.program;
 
 					material.hue = i/xgrid;
 					material.saturation = j/ygrid;

+ 29 - 28
examples/webgl_postprocessing_dof.html

@@ -55,7 +55,7 @@
 				materials = [], objects = [],
 				singleMaterial, zmaterial = [],
 				parameters, i, j, k, h, color, x, y, z, s, n, nobjects,
-				material_depth, material_base, cubeMaterial;
+				material_depth, cubeMaterial;
 
 			var mouseX = 0, mouseY = 0;
 
@@ -79,13 +79,6 @@
 
 				scene = new THREE.Scene();
 
-				/*
-				var light = new THREE.DirectionalLight( 0xffffff );
-				light.position.set( 0, 0.5, 1 );
-				light.position.normalize();
-				scene.addLight( light );
-				*/
-
 				renderer = new THREE.WebGLRenderer( { antialias: false } );
 				renderer.setSize( window.innerWidth, height );
 				container.appendChild( renderer.domElement );
@@ -103,7 +96,6 @@
 				var textureCube = ImageUtils.loadTextureCube( urls );
 
 				parameters = { color: 0xff1100, envMap: textureCube, shading: THREE.FlatShading };
-				//parameters = { color: 0xff1100, shading: THREE.FlatShading };
 				cubeMaterial = new THREE.MeshBasicMaterial( parameters );
 
 				singleMaterial = false;
@@ -111,12 +103,12 @@
 				if( singleMaterial ) zmaterial = [ cubeMaterial ];
 
 				//var geo = new Cube( 1, 1, 1 );
-				var geo = new Sphere( 1, 20, 10 );
 				//var geo = new Icosahedron( 2 );
+				var geo = new Sphere( 1, 20, 10 );
 
-				material_base = cubeMaterial;
-
-				renderer.initMaterial( material_base, scene.lights, scene.fog );
+				var start = new Date().getTime();
+				
+				renderer.initMaterial( cubeMaterial, scene.lights, scene.fog );
 
 				var xgrid = 14,
 					ygrid = 9,
@@ -133,13 +125,17 @@
 				for ( j = 0; j < ygrid; j++ )
 				for ( k = 0; k < zgrid; k++ ) {
 
-					materials[c] = new THREE.MeshBasicMaterial( parameters );
-					materials[c].program = material_base.program;
+					if ( singleMaterial ) {
 
-					if ( singleMaterial )
 						mesh = new THREE.Mesh( geo, zmaterial );
-					else
-						mesh = new THREE.Mesh( geo, materials[c] );
+
+					} else {
+
+						materials[ c ] = new THREE.MeshBasicMaterial( parameters );
+						mesh = new THREE.Mesh( geo, materials[ c ] );
+						renderer.initMaterial( materials[ c ], scene.lights, scene.fog, mesh );
+
+					}
 
 					x = 200 * ( i - xgrid/2 );
 					y = 200 * ( j - ygrid/2 );
@@ -158,6 +154,8 @@
 
 				}
 
+				//console.log("init time: ", new Date().getTime() - start );
+				
 				scene.matrixAutoUpdate = false;
 
 				initPostprocessing();
@@ -171,7 +169,7 @@
 				stats = new Stats();
 				stats.domElement.style.position = 'absolute';
 				stats.domElement.style.top = '0px';
-				//container.appendChild( stats.domElement );
+				container.appendChild( stats.domElement );
 
 				document.addEventListener( 'mousemove', onDocumentMouseMove, false );
 				document.addEventListener( 'touchstart', onDocumentTouchStart, false );
@@ -283,14 +281,17 @@
 				camera.position.x += ( mouseX - camera.position.x ) * 0.036;
 				camera.position.y += ( - (mouseY) - camera.position.y ) * 0.036;
 
-				for( i = 0; i < nobjects; i++ ) {
+				if ( !singleMaterial ) {
 
-					h = ( 360 * ( i/nobjects + time ) % 360 ) / 360;
-					//materials[i].color.setHSV( h, 0.5 + 0.5 * ( i % 20 / 20 ), 1 );
-					materials[i].color.setHSV( h, 1, 1 );
+					for( i = 0; i < nobjects; i++ ) {
 
-				}
+						h = ( 360 * ( i/nobjects + time ) % 360 ) / 360;
+						//materials[ i ].color.setHSV( h, 0.5 + 0.5 * ( i % 20 / 20 ), 1 );
+						materials[ i ].color.setHSV( h, 1, 1 );
+
+					}
 
+				}
 
 				if ( postprocessing.enabled ) {
 
@@ -299,9 +300,9 @@
 					// Render scene into texture
 
 					if ( singleMaterial )
-						zmaterial[0] = cubeMaterial;
+						zmaterial[ 0 ] = cubeMaterial;
 					else
-						for( i = 0; i < nobjects; i++ ) objects[i].materials = [ materials[i] ];
+						for( i = 0; i < nobjects; i++ ) objects[ i ].materials[ 0 ] = materials[ i ];
 
 
 					renderer.render( scene, camera, postprocessing.rtTextureColor, true );
@@ -309,9 +310,9 @@
 					// Render depth into texture
 
 					if ( singleMaterial )
-						zmaterial[0] = material_depth;
+						zmaterial[ 0 ] = material_depth;
 					else
-						for( i = 0; i < nobjects; i++ ) objects[i].materials = [ material_depth ];
+						for( i = 0; i < nobjects; i++ ) objects[i].materials[ 0 ] = material_depth;
 
 					renderer.render( scene, camera, postprocessing.rtTextureDepth, true );
 

+ 1 - 1
examples/webgl_ribbons.html

@@ -129,7 +129,7 @@
 				for ( j = 0; j < ygrid; j++ ) {
 
 					materials[c] = new THREE.MeshBasicMaterial( { color:0xffffff, vertexColors:true } );
-					materials[c].program = material_base.program;
+					//materials[c].program = material_base.program;
 
 					ribbon = new THREE.Ribbon( i % 2 ? geometry : geometry2, materials[c] );
 					ribbon.rotation.x = 0;

+ 335 - 0
examples/webgl_shader_lava.html

@@ -0,0 +1,335 @@
+<!DOCTYPE HTML>
+<html lang="en">
+	<head>
+		<title>three.js webgl - materials - shaders [lava]</title>
+		<meta charset="utf-8">
+		<style type="text/css">
+			body {
+				color: #ffffff;
+				font-family:Monospace;
+				font-size:13px;
+				text-align:center;
+				font-weight: bold;
+
+				background-color: #000000;
+				margin: 0px;
+				overflow: hidden;
+			}
+
+			#info {
+				position: absolute;
+				top: 0px; width: 100%;
+				padding: 5px;
+			}
+
+			a {
+
+				color: #ffffff;
+			}
+
+			#oldie a { color:#da0 }
+		</style>
+	</head>
+	<body>
+
+		<div id="container"></div>
+		<div id="info"><a href="http://github.com/mrdoob/three.js" target="_blank">three.js</a> - shader material demo. featuring lava shader by <a href="http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=21057" target="_blank">TheGameMaker</a></div>
+
+		<script type="text/javascript" src="../build/Three.js"></script>
+
+		<script type="text/javascript" src="js/Detector.js"></script>
+		<script type="text/javascript" src="js/RequestAnimationFrame.js"></script>
+		<script type="text/javascript" src="js/Stats.js"></script>
+
+		<script id="fragmentShader" type="x-shader/x-fragment">
+
+			uniform float time;
+			uniform vec2 resolution;
+			
+			uniform float fogDensity;
+			uniform vec3 fogColor;
+
+			uniform sampler2D texture1;
+			uniform sampler2D texture2;
+
+			varying vec2 vUv;
+
+			void main( void ) {
+
+				vec2 position = -1.0 + 2.0 * vUv;
+
+				vec4 noise = texture2D( texture1, vUv );
+				vec2 T1 = vUv + vec2( 1.5, -1.5 ) * time  *0.02;
+				vec2 T2 = vUv + vec2( -0.5, 2.0 ) * time * 0.01;
+				
+				T1.x += noise.x * 2.0;
+				T1.y += noise.y * 2.0;
+				T2.x -= noise.y * 0.2;
+				T2.y += noise.z * 0.2;
+				
+				float p = texture2D( texture1, T1 * 2.0 ).a;
+				
+				vec4 color = texture2D( texture2, T2 * 2.0 );
+				vec4 temp = color * ( vec4( p, p, p, p ) * 2.0 ) + ( color * color - 0.1 );
+				
+				if( temp.r > 1.0 ){ temp.bg += clamp( temp.r - 2.0, 0.0, 100.0 ); }
+				if( temp.g > 1.0 ){ temp.rb += temp.g - 1.0; }
+				if( temp.b > 1.0 ){ temp.rg += temp.b - 1.0; }
+				
+				gl_FragColor = temp;
+
+				float depth = gl_FragCoord.z / gl_FragCoord.w;
+				const float LOG2 = 1.442695;
+				float fogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );
+				fogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );
+				
+				gl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );
+
+			}
+		</script>
+
+		<script id="vertexShader" type="x-shader/x-vertex">
+
+			varying vec2 vUv;
+
+			void main()
+			{
+
+				vUv = vec2( 3.0, 1.0 ) * uv;
+				vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
+				gl_Position = projectionMatrix * mvPosition;
+
+			}
+
+		</script>
+
+		<script type="text/javascript">
+
+			if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
+
+			var container, stats;
+
+			var start_time;
+
+			var camera, scene, renderer;
+
+			var uniforms, material, mesh;
+
+			var mouseX = 0, mouseY = 0,
+			lat = 0, lon = 0, phy = 0, theta = 0;
+
+			var windowHalfX = window.innerWidth / 2;
+			var windowHalfY = window.innerHeight / 2;
+
+			var postprocessing = { enabled : true };
+			
+			init();
+			animate();
+
+			function init() {
+
+				container = document.getElementById( 'container' );
+
+				camera = new THREE.Camera( 35, windowHalfX / windowHalfY, 1, 3000 );
+				camera.position.z = 4;
+
+				scene = new THREE.Scene();
+
+				start_time = new Date().getTime();
+
+				uniforms = {
+				
+					fogDensity: { type: "f", value: 0.45 },
+					fogColor: 	{ type: "v3", value: new THREE.Vector3( 0, 0, 0 ) },
+					time: 		{ type: "f", value: 1.0 },
+					resolution: { type: "v2", value: new THREE.Vector2() },
+					texture1: 	{ type: "t", value: 0, texture: ImageUtils.loadTexture( "textures/lava/cloud.png" ) },
+					texture2: 	{ type: "t", value: 1, texture: ImageUtils.loadTexture( "textures/lava/lavatile.jpg" ) }
+
+				};
+
+				uniforms.texture1.texture.wrapS = uniforms.texture1.texture.wrapT = THREE.Repeat;
+				uniforms.texture2.texture.wrapS = uniforms.texture2.texture.wrapT = THREE.Repeat;
+
+				var size = 0.65;
+
+				material = new THREE.MeshShaderMaterial( {
+
+					uniforms: uniforms,
+					vertexShader: document.getElementById( 'vertexShader' ).textContent,
+					fragmentShader: document.getElementById( 'fragmentShader' ).textContent
+
+				} );
+
+				mesh = new THREE.Mesh( new Torus( size, 0.3, 30, 30 ), [ material /*, new THREE.MeshBasicMaterial( { color: 0x000000, wireframe: true, wireframeLinewidth: 2 } ) */ ] );
+				mesh.position.x = 0;
+				mesh.position.y = 0;
+				mesh.rotation.x = 0.3;
+				scene.addObject( mesh );
+
+
+				renderer = new THREE.WebGLRenderer( { antialias: true } );
+				container.appendChild( renderer.domElement );
+
+				initPostprocessing();
+				renderer.autoClear = false;
+
+				stats = new Stats();
+				stats.domElement.style.position = 'absolute';
+				stats.domElement.style.top = '0px';
+				//container.appendChild( stats.domElement );
+
+				onWindowResize();
+
+				window.addEventListener( 'resize', onWindowResize, false );
+
+			}
+
+			function onWindowResize( event ) {
+
+				uniforms.resolution.value.x = window.innerWidth;
+				uniforms.resolution.value.y = window.innerHeight;
+
+				renderer.setSize( window.innerWidth, window.innerHeight );
+
+				camera.aspect = window.innerWidth / window.innerHeight;
+				camera.updateProjectionMatrix();
+
+			}
+
+			function initPostprocessing() {
+
+				postprocessing.scene = new THREE.Scene();
+
+				postprocessing.camera = new THREE.Camera();
+				postprocessing.camera.projectionMatrix = THREE.Matrix4.makeOrtho( window.innerWidth / - 2, window.innerWidth / 2,  window.innerHeight / 2, window.innerHeight / - 2, -10000, 10000 );
+				postprocessing.camera.position.z = 100;
+
+				var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter };
+				postprocessing.rtTexture1 = new THREE.WebGLRenderTarget( window.innerWidth, window.innerHeight, pars );
+				postprocessing.rtTexture2 = new THREE.WebGLRenderTarget( 512, 512, pars );
+				postprocessing.rtTexture3 = new THREE.WebGLRenderTarget( 512, 512, pars );
+
+				var screen_shader = ShaderUtils.lib["screen"];
+				var screen_uniforms = Uniforms.clone( screen_shader.uniforms );
+
+				screen_uniforms["tDiffuse"].texture = postprocessing.rtTexture1;
+				screen_uniforms["opacity"].value = 1.0;
+
+				postprocessing.materialScreen = new THREE.MeshShaderMaterial( {
+
+					uniforms: screen_uniforms,
+					vertexShader: screen_shader.vertexShader,
+					fragmentShader: screen_shader.fragmentShader,
+					blending: THREE.AdditiveBlending,
+					transparent: true
+
+				} );
+
+				var convolution_shader = ShaderUtils.lib["convolution"];
+				var convolution_uniforms = Uniforms.clone( convolution_shader.uniforms );
+
+				postprocessing.blurx = new THREE.Vector2( 0.001953125, 0.0 ),
+				postprocessing.blury = new THREE.Vector2( 0.0, 0.001953125 );
+
+				convolution_uniforms["tDiffuse"].texture = postprocessing.rtTexture1;
+				convolution_uniforms["uImageIncrement"].value = postprocessing.blurx;
+				convolution_uniforms["cKernel"].value = ShaderUtils.buildKernel( 4.0 );
+
+				postprocessing.materialConvolution = new THREE.MeshShaderMaterial( {
+
+					uniforms: convolution_uniforms,
+					vertexShader:   "#define KERNEL_SIZE 25.0\n" + convolution_shader.vertexShader,
+					fragmentShader: "#define KERNEL_SIZE 25\n"   + convolution_shader.fragmentShader
+
+				} );
+
+				var film_shader = ShaderUtils.lib["film"];
+				var film_uniforms = Uniforms.clone( film_shader.uniforms );
+				
+				film_uniforms["tDiffuse"].texture = postprocessing.rtTexture1;
+				
+				postprocessing.materialFilm = new THREE.MeshShaderMaterial( { uniforms: film_uniforms, vertexShader: film_shader.vertexShader, fragmentShader: film_shader.fragmentShader } );
+				postprocessing.materialFilm.uniforms.grayscale.value = 0;
+				postprocessing.materialFilm.uniforms.nIntensity.value = 0.35;
+				postprocessing.materialFilm.uniforms.sIntensity.value = 0.95;
+				postprocessing.materialFilm.uniforms.sCount.value = 2048;
+
+				postprocessing.quad = new THREE.Mesh( new Plane( window.innerWidth, window.innerHeight ), postprocessing.materialConvolution );
+				postprocessing.quad.position.z = -500;
+				postprocessing.scene.addObject( postprocessing.quad );
+
+			}
+			
+			//
+
+			function animate() {
+
+				requestAnimationFrame( animate );
+
+				render();
+				stats.update();
+
+			}
+
+			function render() {
+
+				uniforms.time.value += 0.02;
+
+				mesh.rotation.y += 0.00125;
+				mesh.rotation.x += 0.005;
+
+				if ( postprocessing.enabled ) {
+
+					renderer.clear();
+
+					// Render scene into texture
+
+					renderer.render( scene, camera, postprocessing.rtTexture1, true );
+
+					// Render quad with blured scene into texture (convolution pass 1)
+
+					postprocessing.quad.materials = [ postprocessing.materialConvolution ];
+
+					postprocessing.materialConvolution.uniforms.tDiffuse.texture = postprocessing.rtTexture1;
+					postprocessing.materialConvolution.uniforms.uImageIncrement.value = postprocessing.blurx;
+
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture2, true );
+
+					// Render quad with blured scene into texture (convolution pass 2)
+
+					postprocessing.materialConvolution.uniforms.tDiffuse.texture = postprocessing.rtTexture2;
+					postprocessing.materialConvolution.uniforms.uImageIncrement.value = postprocessing.blury;
+
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture3, true );
+
+					// Render original scene with superimposed blur to texture
+
+					postprocessing.quad.materials = [ postprocessing.materialScreen ];
+
+					postprocessing.materialScreen.uniforms.tDiffuse.texture = postprocessing.rtTexture3;
+					postprocessing.materialScreen.uniforms.opacity.value = 1.25;
+
+					renderer.render( postprocessing.scene, postprocessing.camera, postprocessing.rtTexture1, false );
+
+					// Render to screen
+
+					postprocessing.materialFilm.uniforms.time.value += 0.01;
+					postprocessing.quad.materials = [ postprocessing.materialFilm ];
+
+					postprocessing.materialScreen.uniforms.tDiffuse.texture = postprocessing.rtTexture1;
+					renderer.render( postprocessing.scene, postprocessing.camera );
+
+				} else {
+
+					renderer.clear();
+					renderer.render( scene, camera );
+
+				}
+
+			}
+
+		</script>
+
+	</body>
+</html>

+ 38 - 0
src/extras/cameras/QuakeCamera.js

@@ -17,6 +17,10 @@
  *  lookVertical: <bool>,
  *  autoForward: <bool>,
 
+ *  constrainVertical: <bool>,
+ *  verticalMin: <float>,
+ *  verticalMax: <float>,
+ 
  *  heightSpeed: <bool>,
  *  heightCoef: <float>,
  *  heightMin: <float>,
@@ -43,6 +47,10 @@ THREE.QuakeCamera = function ( parameters ) {
 	this.heightCoef = 1.0;
 	this.heightMin = 0.0;
 
+	this.constrainVertical = false;
+	this.verticalMin = 0;
+	this.verticalMax = 3.14;
+	
 	this.domElement = document;
 
 	if ( parameters ) {
@@ -60,6 +68,10 @@ THREE.QuakeCamera = function ( parameters ) {
 		if ( parameters.heightCoef !== undefined ) this.heightCoef = parameters.heightCoef;
 		if ( parameters.heightMin !== undefined ) this.heightMin = parameters.heightMin;
 		if ( parameters.heightMax !== undefined ) this.heightMax = parameters.heightMax;
+		
+		if ( parameters.constrainVertical !== undefined ) this.constrainVertical = parameters.constrainVertical;
+		if ( parameters.verticalMin !== undefined ) this.verticalMin = parameters.verticalMin;
+		if ( parameters.verticalMax !== undefined ) this.verticalMax = parameters.verticalMax;
 
 		if ( parameters.domElement !== undefined ) this.domElement = parameters.domElement;
 
@@ -221,6 +233,26 @@ THREE.QuakeCamera = function ( parameters ) {
 			targetPosition.z = position.z + 100 * Math.sin( this.phi ) * Math.sin( this.theta );
 		}
 
+		this.lon += this.mouseX * actualLookSpeed;
+		if( this.lookVertical ) this.lat -= this.mouseY * actualLookSpeed;
+
+		this.lat = Math.max( - 85, Math.min( 85, this.lat ) );
+		this.phi = ( 90 - this.lat ) * Math.PI / 180;
+		this.theta = this.lon * Math.PI / 180;
+
+		if ( this.constrainVertical ) {
+
+			this.phi = map_linear( this.phi, 0, 3.14, this.verticalMin, this.verticalMax );
+			
+		}
+		
+		var targetPosition = this.target.position,
+			position = this.position;
+
+		targetPosition.x = position.x + 100 * Math.sin( this.phi ) * Math.cos( this.theta );
+		targetPosition.y = position.y + 100 * Math.cos( this.phi );
+		targetPosition.z = position.z + 100 * Math.sin( this.phi ) * Math.sin( this.theta );
+
 		this.supr.update.call( this );
 
 	};
@@ -244,6 +276,12 @@ THREE.QuakeCamera = function ( parameters ) {
 
 	};
 
+	function map_linear( x, sa, sb, ea, eb ) {
+		
+		return ( x  - sa ) * ( eb - ea ) / ( sb - sa ) + ea;
+		
+	};
+	
 	function clamp_bottom( x, a ) {
 
 		return x < a ? a : x;

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

@@ -94,6 +94,8 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 		normals = json.normals,
 		colors = json.colors,
 
+		scale = ( json.scale !== undefined ) ? json.scale : 1.0,
+		
 		nUvLayers = 0;
 
 		// disregard empty arrays
@@ -118,9 +120,9 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 			vertex = new THREE.Vertex();
 
-			vertex.position.x = vertices[ offset ++ ];
-			vertex.position.y = vertices[ offset ++ ];
-			vertex.position.z = vertices[ offset ++ ];
+			vertex.position.x = vertices[ offset ++ ] / scale;
+			vertex.position.y = vertices[ offset ++ ] / scale;
+			vertex.position.z = vertices[ offset ++ ] / scale;
 
 			geometry.vertices.push( vertex );
 

+ 83 - 52
src/renderers/WebGLRenderer.js

@@ -2036,39 +2036,45 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	this.initMaterial = function ( material, lights, fog, object ) {
 
-		var u, a, identifiers, i, parameters, maxLightCount, maxBones;
+		var u, a, identifiers, i, parameters, maxLightCount, maxBones, shaderID;
 
 		if ( material instanceof THREE.MeshDepthMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'depth' ] );
+			shaderID = 'depth';
 
 		} else if ( material instanceof THREE.ShadowVolumeDynamicMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'shadowVolumeDynamic' ] );
+			shaderID = 'shadowVolumeDynamic';
 
 		} else if ( material instanceof THREE.MeshNormalMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'normal' ] );
+			shaderID = 'normal';
 
 		} else if ( material instanceof THREE.MeshBasicMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'basic' ] );
+			shaderID = 'basic';
 
 		} else if ( material instanceof THREE.MeshLambertMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'lambert' ] );
+			shaderID = 'lambert';
 
 		} else if ( material instanceof THREE.MeshPhongMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'phong' ] );
+			shaderID = 'phong';
 
 		} else if ( material instanceof THREE.LineBasicMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'basic' ] );
+			shaderID = 'basic';
 
 		} else if ( material instanceof THREE.ParticleBasicMaterial ) {
 
-			setMaterialShaders( material, THREE.ShaderLib[ 'particle_basic' ] );
+			shaderID = 'particle_basic';
+
+		}
+
+		if ( shaderID ) {
+
+			setMaterialShaders( material, THREE.ShaderLib[ shaderID ] );
 
 		}
 
@@ -2080,53 +2086,17 @@ THREE.WebGLRenderer = function ( parameters ) {
 		maxBones = allocateBones( object );
 
 		parameters = {
-			map: material.map, envMap: material.envMap, lightMap: material.lightMap, vertexColors: material.vertexColors,
+			map: !!material.map, envMap: !!material.envMap, lightMap: !!material.lightMap, 
+			vertexColors: material.vertexColors,
 			fog: fog, sizeAttenuation: material.sizeAttenuation,
 			skinning: material.skinning,
 			morphTargets: material.morphTargets,
+			maxMorphTargets: this.maxMorphTargets,
 			maxDirLights: maxLightCount.directional, maxPointLights: maxLightCount.point,
 			maxBones: maxBones
 		};
 
-		material.program = buildProgram( material.fragmentShader, material.vertexShader, parameters );
-
-		// load uniforms
-
-		identifiers = [
-			'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition',
-			'cameraInverseMatrix', 'boneGlobalMatrices', 'morphTargetInfluences'
-		];
-
-
-		for ( u in material.uniforms ) {
-
-			identifiers.push(u);
-
-		}
-
-		cacheUniformLocations( material.program, identifiers );
-
-
-		// load attributes
-
-		identifiers = [
-			"position", "normal", "uv", "uv2", "tangent", "color",
-			"skinVertexA", "skinVertexB", "skinIndex", "skinWeight"
-		];
-
-		for ( i = 0; i < this.maxMorphTargets; i++ ) {
-
-			identifiers.push( "morphTarget" + i );
-
-		}
-
-		for ( a in material.attributes ) {
-
-			identifiers.push( a );
-
-		}
-
-		cacheAttributeLocations( material.program, identifiers );
+		material.program = buildProgram( shaderID, material.fragmentShader, material.vertexShader, material.uniforms, material.attributes, parameters );
 
 		var attributes = material.program.attributes;
 
@@ -2177,12 +2147,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				_gl.enableVertexAttribArray( attributes.morphTarget2 );
 				material.numSupportedMorphTargets ++;
+
 			}
 
 			if ( attributes.morphTarget3 >= 0 ) {
 
 				_gl.enableVertexAttribArray( attributes.morphTarget3 );
 				material.numSupportedMorphTargets ++;
+
 			}
 
 			if ( attributes.morphTarget4 >= 0 ) {
@@ -2196,6 +2168,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				_gl.enableVertexAttribArray( attributes.morphTarget5 );
 				material.numSupportedMorphTargets ++;
+
 			}
 
 			if ( attributes.morphTarget6 >= 0 ) {
@@ -3878,20 +3851,33 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function buildProgram( fragmentShader, vertexShader, parameters ) {
+	function buildProgram( shaderID, fragmentShader, vertexShader, uniforms, attributes, parameters ) {
 
 		var p, pl, program, code;
+		var chunks = [];
 
 		// Generate code
 
-		code = fragmentShader + "\n\n" + vertexShader + "\n\n";
+		if ( shaderID ) {
+
+			chunks.push( shaderID );
+
+		} else {
+
+			chunks.push( fragmentShader );
+			chunks.push( vertexShader );
+
+		}
 
 		for ( p in parameters ) {
 
-			code += p + ": " + parameters[ p ] + ",\n";
+			chunks.push( p );
+			chunks.push( parameters[ p ] );
 
 		}
 
+		code = chunks.join();
+
 		// Check if code has been already compiled
 
 		for ( p = 0, pl = _programs.length; p < pl; p ++ ) {
@@ -3899,11 +3885,14 @@ THREE.WebGLRenderer = function ( parameters ) {
 			if ( _programs[ p ].code == code ) {
 
 				// console.log( "Code already compiled." /*: \n\n" + code*/ );
+
 				return _programs[ p ].program;
 
 			}
 
 		}
+		
+		//console.log( "building new program " );
 
 		//
 
@@ -4010,6 +3999,48 @@ THREE.WebGLRenderer = function ( parameters ) {
 		program.uniforms = {};
 		program.attributes = {};
 
+		var identifiers, u, a, i;
+
+		// cache uniform locations
+
+		identifiers = [
+
+			'viewMatrix', 'modelViewMatrix', 'projectionMatrix', 'normalMatrix', 'objectMatrix', 'cameraPosition',
+			'cameraInverseMatrix', 'boneGlobalMatrices', 'morphTargetInfluences'
+
+		];
+
+		for ( u in uniforms ) {
+
+			identifiers.push( u );
+
+		}
+
+		cacheUniformLocations( program, identifiers );
+		
+		// cache attributes locations
+
+		identifiers = [
+
+			"position", "normal", "uv", "uv2", "tangent", "color",
+			"skinVertexA", "skinVertexB", "skinIndex", "skinWeight"
+
+		];
+
+		for ( i = 0; i < parameters.maxMorphTargets; i++ ) {
+
+			identifiers.push( "morphTarget" + i );
+
+		}
+
+		for ( a in attributes ) {
+
+			identifiers.push( a );
+
+		}
+
+		cacheAttributeLocations( program, identifiers );
+
 		_programs.push( { program: program, code: code } );
 
 		return program;

+ 10 - 2
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/__init__.py

@@ -124,10 +124,13 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
     filename_ext = ".js"
 
     option_flip_yz = BoolProperty(name="Flip YZ", description="Flip YZ", default=True)
+    use_materials = BoolProperty(name="Materials", description="Export materials", default=True)
     use_normals = BoolProperty(name="Normals", description="Export normals", default=True)
     use_colors = BoolProperty(name="Colors", description="Export vertex colors", default=True)
     use_uv_coords = BoolProperty(name="UVs", description="Export texture coordinates", default=True)
-    option_export_scene = BoolProperty(name="Scene", description="Export scene", default=True)
+    option_export_scene = BoolProperty(name="Scene", description="Export scene", default=False)
+    option_truncate = BoolProperty(name="Truncate", description="Truncate decimals", default=False)
+    option_scale = FloatProperty(name="Scale", description="Scale data", min=0.01, max=1000.0, soft_min=0.01, soft_max=1000.0, default=1.0)
 
     align_types = [("None","None","None"), ("Center","Center","Center"), ("Bottom","Bottom","Bottom"), ("Top","Top","Top")]
     align_model = EnumProperty(name="Align model", description="Align model", items=align_types, default="None")
@@ -163,10 +166,15 @@ class ExportTHREEJS(bpy.types.Operator, ExportHelper):
 
         row = layout.row()
         row.prop(self.properties, "use_normals")
-        row = layout.row()
         row.prop(self.properties, "use_colors")
         row = layout.row()
         row.prop(self.properties, "use_uv_coords")
+        row.prop(self.properties, "use_materials")
+        layout.separator()
+
+        row = layout.row()
+        row.prop(self.properties, "option_truncate")
+        row.prop(self.properties, "option_scale")
 
 
 # ################################################################

+ 31 - 16
utils/exporters/blender/2.56/scripts/op/io_mesh_threejs/export_threejs.py

@@ -208,6 +208,8 @@ var model = {
 
     "version" : 2,
     
+    "scale" : %(scale)f,
+    
     "materials": [%(materials)s],
 
     "vertices": [%(vertices)s],
@@ -228,6 +230,7 @@ postMessage( model );
 """
 
 TEMPLATE_VERTEX = "%f,%f,%f"
+TEMPLATE_VERTEX_TRUNCATE = "%d,%d,%d"
 
 TEMPLATE_N = "%f,%f,%f"
 TEMPLATE_UV = "%f,%f"
@@ -391,8 +394,11 @@ def bottom(vertices):
 def hexcolor(c):
     return ( int(c[0] * 255) << 16  ) + ( int(c[1] * 255) << 8 ) + int(c[2] * 255)
     
-def generate_vertex(v):
-    return TEMPLATE_VERTEX % (v.co.x, v.co.y, v.co.z)
+def generate_vertex(v, truncate):
+    if truncate:
+        return TEMPLATE_VERTEX_TRUNCATE % (v.co.x, v.co.y, v.co.z)
+    else:
+        return TEMPLATE_VERTEX % (v.co.x, v.co.y, v.co.z)
 
 def generate_normal(n):
     return TEMPLATE_N % (n[0], n[1], n[2])
@@ -415,7 +421,7 @@ def setBit(value, position, on):
         mask = ~(1 << position)
         return (value & mask)    
     
-def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords, flipyz):
+def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords, use_materials, flipyz):
     isTriangle = ( len(f.vertices) == 3 )
     
     if isTriangle:
@@ -423,7 +429,7 @@ def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_col
     else:
         nVertices = 4
         
-    hasMaterial = True # for the moment objects without materials get default material
+    hasMaterial = use_materials
     
     hasFaceUvs = False # not supported in Blender
     hasFaceVertexUvs = use_uv_coords
@@ -459,6 +465,7 @@ def generate_face(f, faceIndex, normals, uvs, colors, mesh, use_normals, use_col
     faceData.append(faceType)    
     
     # must clamp in case on polygons bigger than quads
+
     for i in range(nVertices):
         index = f.vertices[i]
         faceData.append(index)
@@ -689,7 +696,7 @@ def extract_materials(mesh, scene):
             # http://www.blender.org/documentation/blender_python_api_2_54_0/bpy.types.Material.html#bpy.types.Material.specular_hardness
             material["specularCoef"] = m.specular_hardness
 
-            if m.active_texture and m.active_texture.type == 'IMAGE':
+            if m.active_texture and m.active_texture.type == 'IMAGE' and m.active_texture.image:
                 fn = bpy.path.abspath(m.active_texture.image.filepath)
                 fn = os.path.normpath(fn)
                 fn_strip = os.path.basename(fn)
@@ -736,7 +743,7 @@ def generate_materials_string(mesh, scene, use_colors, draw_type):
 # ASCII model generator
 # #####################################################
 
-def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model, flipyz, draw_type):
+def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, use_materials, align_model, flipyz, option_truncate, option_scale, draw_type):
 
     vertices = mesh.vertices[:]    
 
@@ -751,7 +758,11 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, al
     colors, ncolor = extract_vertex_colors(mesh, use_colors)
     uvs, nuv = extract_uvs(mesh, use_uv_coords)
 
-    mstring, nmaterial = generate_materials_string(mesh, scene, use_colors, draw_type)
+    mstring = ""
+    nmaterial = 0
+    
+    if use_materials:
+        mstring, nmaterial = generate_materials_string(mesh, scene, use_colors, draw_type)
     
     text = TEMPLATE_FILE_ASCII % {
     "nvertex"   : len(mesh.vertices),
@@ -760,6 +771,8 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, al
     "nnormal"   : nnormal,
     "ncolor"    : ncolor,
     "nmaterial" : nmaterial,
+    
+    "scale" : option_scale,
 
     "uvs"           : generate_uvs(uvs, use_uv_coords),
     "normals"       : generate_normals(normals, use_normals),
@@ -767,9 +780,9 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, al
 
     "materials" : mstring,
 
-    "vertices"      : ",".join(generate_vertex(v) for v in vertices),
+    "vertices"      : ",".join(generate_vertex(v, option_truncate) for v in vertices),
 
-    "faces"     : ",".join(generate_face(f, i, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords, flipyz) for i, f in enumerate(mesh.faces))
+    "faces"     : ",".join(generate_face(f, i, normals, uvs, colors, mesh, use_normals, use_colors, use_uv_coords, use_materials, flipyz) for i, f in enumerate(mesh.faces))
 
     }
 
@@ -780,13 +793,13 @@ def generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, al
 # Model exporter - export single mesh
 # #####################################################
 
-def export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, align_model, flipyz, export_single_model):
+def export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, use_materials, align_model, flipyz, option_truncate, option_scale, export_single_model):
     """Export single mesh"""
 
 
     # collapse modifiers into mesh
     
-    mesh = obj.create_mesh(scene, True, 'RENDER')        
+    mesh = obj.create_mesh(scene, True, 'RENDER')
 
     if not mesh:
         raise Exception("Error, could not get mesh data from object [%s]" % obj.name)
@@ -801,6 +814,8 @@ def export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, al
     else:
         mesh.transform(X_ROT)
 
+    mesh.transform(mathutils.Matrix.Scale(option_scale, 4))
+
     mesh.calc_normals()
 
     faceUV = (len(mesh.uv_textures) > 0)
@@ -823,7 +838,7 @@ def export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, al
         if not active_col_layer:
             use_colors = False
 
-    text = generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, align_model, flipyz, obj.draw_type)    
+    text = generate_ascii_model(mesh, scene, use_normals, use_colors, use_uv_coords, use_materials, align_model, flipyz, option_truncate, option_scale, obj.draw_type)
     write_file(filepath, text)
 
     # remove temp mesh
@@ -924,7 +939,7 @@ def generate_objects(data):
                 group_string = generate_string_list(group_ids)
 
             castsShadow = generate_bool_property(obj.THREE_castsShadow)
-            meshCollider = generate_bool_property(obj.THREE_meshCollider)            
+            meshCollider = generate_bool_property(obj.THREE_meshCollider)
                 
             object_string = TEMPLATE_OBJECT % {
             "object_id"   : generate_string(object_id),
@@ -1250,7 +1265,7 @@ def export_scene(scene, filepath, flipyz):
 # Main
 # #####################################################
 
-def save(operator, context, filepath = "", option_flip_yz = True, use_normals = True, use_colors = True, use_uv_coords = True, align_model = 0, option_export_scene = True):
+def save(operator, context, filepath = "", option_flip_yz = True, use_normals = True, use_colors = True, use_uv_coords = True, use_materials = True, align_model = 0, option_export_scene = False, option_truncate = False, option_scale = 1.0):
 
     filepath = ensure_extension(filepath, '.js')
 
@@ -1281,7 +1296,7 @@ def save(operator, context, filepath = "", option_flip_yz = True, use_normals =
 
                 if name not in geo_set:
                     fname = generate_mesh_filename(name, filepath)
-                    export_mesh(obj, scene, fname, use_normals, use_colors, use_uv_coords, 0, option_flip_yz, False)
+                    export_mesh(obj, scene, fname, use_normals, use_colors, use_uv_coords, use_materials, 0, option_flip_yz, option_truncate, option_scale, False)
                     
                     geo_set.add(name)
 
@@ -1291,7 +1306,7 @@ def save(operator, context, filepath = "", option_flip_yz = True, use_normals =
         if not obj:
             raise Exception("Error, Select 1 active object or select 'export scene'")
 
-        export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, align_model, option_flip_yz, True)
+        export_mesh(obj, scene, filepath, use_normals, use_colors, use_uv_coords, use_materials, align_model, option_flip_yz, option_truncate, option_scale, True)
 
     
     return {'FINISHED'}