Selaa lähdekoodia

Optimized uniforms updates.

Should not refresh anything if material doesn't change for several objects in a row (in a single frame).

Hope this didn't break something, I remember this being tricky. Went through examples and they seem to work ok, gained some fps in performance test.

Also disabled sorting in depth-of-field example for some more fps gain.

Still didn't figure out the original reason for recent fps drop in performance / dof examples :/
alteredq 14 vuotta sitten
vanhempi
commit
ba75a48a2b
4 muutettua tiedostoa jossa 470 lisäystä ja 447 poistoa
  1. 279 279
      build/Three.js
  2. 108 108
      build/custom/ThreeWebGL.js
  3. 2 0
      examples/webgl_postprocessing_dof.html
  4. 81 60
      src/renderers/WebGLRenderer.js

+ 279 - 279
build/Three.js

@@ -16,8 +16,8 @@ c.z;this.w=b.w-c.w;return this},subSelf:function(b){this.x-=b.x;this.y-=b.y;this
 normalize:function(){return this.divideScalar(this.length())},setLength:function(b){return this.normalize().multiplyScalar(b)},lerpSelf:function(b,c){this.x+=(b.x-this.x)*c;this.y+=(b.y-this.y)*c;this.z+=(b.z-this.z)*c;this.w+=(b.w-this.w)*c;return this}};THREE.Ray=function(b,c){this.origin=b||new THREE.Vector3;this.direction=c||new THREE.Vector3};
 THREE.Ray.prototype={constructor:THREE.Ray,intersectScene:function(b){return this.intersectObjects(b.objects)},intersectObjects:function(b){var c,e,f=[];c=0;for(e=b.length;c<e;c++)Array.prototype.push.apply(f,this.intersectObject(b[c]));f.sort(function(b,e){return b.distance-e.distance});return f},intersectObject:function(b){function c(b,e,c){var f;f=c.clone().subSelf(b).dot(e);if(f<=0)return null;b=b.clone().addSelf(e.clone().multiplyScalar(f));return c.distanceTo(b)}function e(b,e,c,f){var f=f.clone().subSelf(e),
 c=c.clone().subSelf(e),h=b.clone().subSelf(e),b=f.dot(f),e=f.dot(c),f=f.dot(h),k=c.dot(c),c=c.dot(h),h=1/(b*k-e*e),k=(k*f-e*c)*h,b=(b*c-e*f)*h;return k>0&&b>0&&k+b<1}if(b instanceof THREE.Particle){var f=c(this.origin,this.direction,b.matrixWorld.getPosition());if(f==null||f>b.scale.x)return[];return[{distance:f,point:b.position,face:null,object:b}]}else if(b instanceof THREE.Mesh){f=c(this.origin,this.direction,b.matrixWorld.getPosition());if(f==null||f>b.geometry.boundingSphere.radius*Math.max(b.scale.x,
-Math.max(b.scale.y,b.scale.z)))return[];var h,m,k,n,u,p,v,t,x,w,y=b.geometry,z=y.vertices,A=[],f=0;for(h=y.faces.length;f<h;f++)if(m=y.faces[f],x=this.origin.clone(),w=this.direction.clone(),p=b.matrixWorld,k=p.multiplyVector3(m.centroid.clone()).subSelf(x),t=k.dot(w),!(t<=0)&&(k=p.multiplyVector3(z[m.a].position.clone()),n=p.multiplyVector3(z[m.b].position.clone()),u=p.multiplyVector3(z[m.c].position.clone()),p=m instanceof THREE.Face4?p.multiplyVector3(z[m.d].position.clone()):null,v=b.matrixRotationWorld.multiplyVector3(m.normal.clone()),
-t=w.dot(v),b.doubleSided||(b.flipSided?t>0:t<0)))if(t=v.dot((new THREE.Vector3).sub(k,x))/t,x=x.addSelf(w.multiplyScalar(t)),m instanceof THREE.Face3)e(x,k,n,u)&&(m={distance:this.origin.distanceTo(x),point:x,face:m,object:b},A.push(m));else if(m instanceof THREE.Face4&&(e(x,k,n,p)||e(x,n,u,p)))m={distance:this.origin.distanceTo(x),point:x,face:m,object:b},A.push(m);A.sort(function(b,e){return b.distance-e.distance});return A}else return[]}};
+Math.max(b.scale.y,b.scale.z)))return[];var h,m,k,n,u,p,v,t,x,w,y=b.geometry,z=y.vertices,B=[],f=0;for(h=y.faces.length;f<h;f++)if(m=y.faces[f],x=this.origin.clone(),w=this.direction.clone(),p=b.matrixWorld,k=p.multiplyVector3(m.centroid.clone()).subSelf(x),t=k.dot(w),!(t<=0)&&(k=p.multiplyVector3(z[m.a].position.clone()),n=p.multiplyVector3(z[m.b].position.clone()),u=p.multiplyVector3(z[m.c].position.clone()),p=m instanceof THREE.Face4?p.multiplyVector3(z[m.d].position.clone()):null,v=b.matrixRotationWorld.multiplyVector3(m.normal.clone()),
+t=w.dot(v),b.doubleSided||(b.flipSided?t>0:t<0)))if(t=v.dot((new THREE.Vector3).sub(k,x))/t,x=x.addSelf(w.multiplyScalar(t)),m instanceof THREE.Face3)e(x,k,n,u)&&(m={distance:this.origin.distanceTo(x),point:x,face:m,object:b},B.push(m));else if(m instanceof THREE.Face4&&(e(x,k,n,p)||e(x,n,u,p)))m={distance:this.origin.distanceTo(x),point:x,face:m,object:b},B.push(m);B.sort(function(b,e){return b.distance-e.distance});return B}else return[]}};
 THREE.Rectangle=function(){function b(){m=f-c;k=h-e}var c,e,f,h,m,k,n=!0;this.getX=function(){return c};this.getY=function(){return e};this.getWidth=function(){return m};this.getHeight=function(){return k};this.getLeft=function(){return c};this.getTop=function(){return e};this.getRight=function(){return f};this.getBottom=function(){return h};this.set=function(k,m,v,t){n=!1;c=k;e=m;f=v;h=t;b()};this.addPoint=function(k,m){n?(n=!1,c=k,e=m,f=k,h=m):(c=c<k?c:k,e=e<m?e:m,f=f>k?f:k,h=h>m?h:m);b()};this.add3Points=
 function(k,m,v,t,x,w){n?(n=!1,c=k<v?k<x?k:x:v<x?v:x,e=m<t?m<w?m:w:t<w?t:w,f=k>v?k>x?k:x:v>x?v:x,h=m>t?m>w?m:w:t>w?t:w):(c=k<v?k<x?k<c?k:c:x<c?x:c:v<x?v<c?v:c:x<c?x:c,e=m<t?m<w?m<e?m:e:w<e?w:e:t<w?t<e?t:e:w<e?w:e,f=k>v?k>x?k>f?k:f:x>f?x:f:v>x?v>f?v:f:x>f?x:f,h=m>t?m>w?m>h?m:h:w>h?w:h:t>w?t>h?t:h:w>h?w:h);b()};this.addRectangle=function(k){n?(n=!1,c=k.getLeft(),e=k.getTop(),f=k.getRight(),h=k.getBottom()):(c=c<k.getLeft()?c:k.getLeft(),e=e<k.getTop()?e:k.getTop(),f=f>k.getRight()?f:k.getRight(),h=h>
 k.getBottom()?h:k.getBottom());b()};this.inflate=function(k){c-=k;e-=k;f+=k;h+=k;b()};this.minSelf=function(k){c=c>k.getLeft()?c:k.getLeft();e=e>k.getTop()?e:k.getTop();f=f<k.getRight()?f:k.getRight();h=h<k.getBottom()?h:k.getBottom();b()};this.intersects=function(b){return Math.min(f,b.getRight())-Math.max(c,b.getLeft())>=0&&Math.min(h,b.getBottom())-Math.max(e,b.getTop())>=0};this.empty=function(){n=!0;h=f=e=c=0;b()};this.isEmpty=function(){return n}};THREE.Matrix3=function(){this.m=[]};
@@ -26,9 +26,9 @@ THREE.Matrix4=function(b,c,e,f,h,m,k,n,u,p,v,t,x,w,y,z){this.set(b!==void 0?b:1,
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,e,f,h,m,k,n,u,p,v,t,x,w,y,z){this.n11=b;this.n12=c;this.n13=e;this.n14=f;this.n21=h;this.n22=m;this.n23=k;this.n24=n;this.n31=u;this.n32=p;this.n33=v;this.n34=t;this.n41=x;this.n42=w;this.n43=y;this.n44=z;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,
 c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,m=THREE.Matrix4.__v3;m.sub(b,c).normalize();if(m.length()===0)m.z=1;f.cross(e,m).normalize();f.length()===0&&(m.x+=1.0E-4,f.cross(e,m).normalize());h.cross(m,f).normalize();this.n11=f.x;this.n12=h.x;this.n13=m.x;this.n21=f.y;this.n22=h.y;this.n23=m.y;this.n31=f.z;this.n32=h.z;this.n33=m.z;return this},multiplyVector3:function(b){var c=b.x,e=b.y,f=b.z,h=1/(this.n41*c+this.n42*e+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*e+this.n13*f+this.n14)*h;
 b.y=(this.n21*c+this.n22*e+this.n23*f+this.n24)*h;b.z=(this.n31*c+this.n32*e+this.n33*f+this.n34)*h;return b},multiplyVector4:function(b){var c=b.x,e=b.y,f=b.z,h=b.w;b.x=this.n11*c+this.n12*e+this.n13*f+this.n14*h;b.y=this.n21*c+this.n22*e+this.n23*f+this.n24*h;b.z=this.n31*c+this.n32*e+this.n33*f+this.n34*h;b.w=this.n41*c+this.n42*e+this.n43*f+this.n44*h;return b},rotateAxis:function(b){var c=b.x,e=b.y,f=b.z;b.x=c*this.n11+e*this.n12+f*this.n13;b.y=c*this.n21+e*this.n22+f*this.n23;b.z=c*this.n31+
-e*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,f=b.n12,h=b.n13,m=b.n14,k=b.n21,n=b.n22,u=b.n23,p=b.n24,v=b.n31,t=b.n32,x=b.n33,w=b.n34,y=b.n41,z=b.n42,A=b.n43,E=b.n44,D=c.n11,F=c.n12,
-G=c.n13,N=c.n14,Q=c.n21,L=c.n22,H=c.n23,M=c.n24,X=c.n31,C=c.n32,O=c.n33,P=c.n34,U=c.n41,V=c.n42,o=c.n43,ea=c.n44;this.n11=e*D+f*Q+h*X+m*U;this.n12=e*F+f*L+h*C+m*V;this.n13=e*G+f*H+h*O+m*o;this.n14=e*N+f*M+h*P+m*ea;this.n21=k*D+n*Q+u*X+p*U;this.n22=k*F+n*L+u*C+p*V;this.n23=k*G+n*H+u*O+p*o;this.n24=k*N+n*M+u*P+p*ea;this.n31=v*D+t*Q+x*X+w*U;this.n32=v*F+t*L+x*C+w*V;this.n33=v*G+t*H+x*O+w*o;this.n34=v*N+t*M+x*P+w*ea;this.n41=y*D+z*Q+A*X+E*U;this.n42=y*F+z*L+A*C+E*V;this.n43=y*G+z*H+A*O+E*o;this.n44=y*
-N+z*M+A*P+E*ea;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);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*=
+e*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var e=b.n11,f=b.n12,h=b.n13,m=b.n14,k=b.n21,n=b.n22,u=b.n23,p=b.n24,v=b.n31,t=b.n32,x=b.n33,w=b.n34,y=b.n41,z=b.n42,B=b.n43,D=b.n44,E=c.n11,F=c.n12,
+G=c.n13,N=c.n14,Q=c.n21,H=c.n22,K=c.n23,I=c.n24,X=c.n31,C=c.n32,O=c.n33,P=c.n34,U=c.n41,W=c.n42,o=c.n43,da=c.n44;this.n11=e*E+f*Q+h*X+m*U;this.n12=e*F+f*H+h*C+m*W;this.n13=e*G+f*K+h*O+m*o;this.n14=e*N+f*I+h*P+m*da;this.n21=k*E+n*Q+u*X+p*U;this.n22=k*F+n*H+u*C+p*W;this.n23=k*G+n*K+u*O+p*o;this.n24=k*N+n*I+u*P+p*da;this.n31=v*E+t*Q+x*X+w*U;this.n32=v*F+t*H+x*C+w*W;this.n33=v*G+t*K+x*O+w*o;this.n34=v*N+t*I+x*P+w*da;this.n41=y*E+z*Q+B*X+D*U;this.n42=y*F+z*H+B*C+D*W;this.n43=y*G+z*K+B*O+D*o;this.n44=y*
+N+z*I+B*P+D*da;return this},multiplyToArray:function(b,c,e){this.multiply(b,c);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,c=this.n12,e=this.n13,f=this.n14,h=this.n21,m=this.n22,k=this.n23,n=this.n24,u=this.n31,p=this.n32,v=this.n33,t=this.n34,x=this.n41,w=this.n42,y=this.n43,z=this.n44;return f*k*p*x-e*n*p*x-f*m*v*x+c*n*v*x+e*m*t*x-c*k*t*x-f*k*u*w+e*n*u*w+f*h*v*w-b*n*v*w-e*h*t*w+b*k*t*w+f*m*u*y-c*n*u*y-f*h*p*y+b*n*p*y+c*h*t*y-b*m*t*y-e*m*u*z+c*k*u*z+e*h*p*z-b*k*p*z-c*h*
 v*z+b*m*v*z},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]=
@@ -42,8 +42,8 @@ b.x,e=b.y,f=b.z,h=b.w,m=c+c,k=e+e,n=f+f,b=c*m,u=c*k;c*=n;var p=e*k;e*=n;f*=n;m*=
 f.identity();f.setRotationFromQuaternion(c);h.setScale(e.x,e.y,e.z);this.multiply(f,h);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,e){var f=THREE.Matrix4.__v1,h=THREE.Matrix4.__v2,m=THREE.Matrix4.__v3;f.set(this.n11,this.n21,this.n31);h.set(this.n12,this.n22,this.n32);m.set(this.n13,this.n23,this.n33);b=b instanceof THREE.Vector3?b:new THREE.Vector3;c=c instanceof THREE.Quaternion?c:new THREE.Quaternion;e=e instanceof THREE.Vector3?e:new THREE.Vector3;e.x=f.length();
 e.y=h.length();e.z=m.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;f=THREE.Matrix4.__m1;f.copy(this);f.n11/=e.x;f.n21/=e.x;f.n31/=e.x;f.n12/=e.y;f.n22/=e.y;f.n32/=e.y;f.n13/=e.z;f.n23/=e.z;f.n33/=e.z;c.setFromRotationMatrix(f);return[b,c,e]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var e=1/c.x,f=1/c.y,h=1/c.z;this.n11=b.n11*e;this.n21=b.n21*e;this.n31=b.n31*e;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*h;this.n23=
 b.n23*h;this.n33=b.n33*h}};
-THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,h=b.n13,m=b.n14,k=b.n21,n=b.n22,u=b.n23,p=b.n24,v=b.n31,t=b.n32,x=b.n33,w=b.n34,y=b.n41,z=b.n42,A=b.n43,E=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=u*w*z-p*x*z+p*t*A-n*w*A-u*t*E+n*x*E;c.n12=m*x*z-h*w*z-m*t*A+f*w*A+h*t*E-f*x*E;c.n13=h*p*z-m*u*z+m*n*A-f*p*A-h*n*E+f*u*E;c.n14=m*u*t-h*p*t-m*n*x+f*p*x+h*n*w-f*u*w;c.n21=p*x*y-u*w*y-p*v*A+k*w*A+u*v*E-k*x*E;c.n22=h*w*y-m*x*y+m*v*A-e*w*A-h*v*E+e*x*E;c.n23=m*u*y-h*p*y-m*k*A+e*p*A+h*k*E-e*u*E;c.n24=
-h*p*v-m*u*v+m*k*x-e*p*x-h*k*w+e*u*w;c.n31=n*w*y-p*t*y+p*v*z-k*w*z-n*v*E+k*t*E;c.n32=m*t*y-f*w*y-m*v*z+e*w*z+f*v*E-e*t*E;c.n33=h*p*y-m*n*y+m*k*z-e*p*z-f*k*E+e*n*E;c.n34=m*n*v-f*p*v-m*k*t+e*p*t+f*k*w-e*n*w;c.n41=u*t*y-n*x*y-u*v*z+k*x*z+n*v*A-k*t*A;c.n42=f*x*y-h*t*y+h*v*z-e*x*z-f*v*A+e*t*A;c.n43=h*n*y-f*u*y-h*k*z+e*u*z+f*k*A-e*n*A;c.n44=f*u*v-h*n*v+h*k*t-e*u*t-f*k*x+e*n*x;c.multiplyScalar(1/b.determinant());return c};
+THREE.Matrix4.makeInvert=function(b,c){var e=b.n11,f=b.n12,h=b.n13,m=b.n14,k=b.n21,n=b.n22,u=b.n23,p=b.n24,v=b.n31,t=b.n32,x=b.n33,w=b.n34,y=b.n41,z=b.n42,B=b.n43,D=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=u*w*z-p*x*z+p*t*B-n*w*B-u*t*D+n*x*D;c.n12=m*x*z-h*w*z-m*t*B+f*w*B+h*t*D-f*x*D;c.n13=h*p*z-m*u*z+m*n*B-f*p*B-h*n*D+f*u*D;c.n14=m*u*t-h*p*t-m*n*x+f*p*x+h*n*w-f*u*w;c.n21=p*x*y-u*w*y-p*v*B+k*w*B+u*v*D-k*x*D;c.n22=h*w*y-m*x*y+m*v*B-e*w*B-h*v*D+e*x*D;c.n23=m*u*y-h*p*y-m*k*B+e*p*B+h*k*D-e*u*D;c.n24=
+h*p*v-m*u*v+m*k*x-e*p*x-h*k*w+e*u*w;c.n31=n*w*y-p*t*y+p*v*z-k*w*z-n*v*D+k*t*D;c.n32=m*t*y-f*w*y-m*v*z+e*w*z+f*v*D-e*t*D;c.n33=h*p*y-m*n*y+m*k*z-e*p*z-f*k*D+e*n*D;c.n34=m*n*v-f*p*v-m*k*t+e*p*t+f*k*w-e*n*w;c.n41=u*t*y-n*x*y-u*v*z+k*x*z+n*v*B-k*t*B;c.n42=f*x*y-h*t*y+h*v*z-e*x*z-f*v*B+e*t*B;c.n43=h*n*y-f*u*y-h*k*z+e*u*z+f*k*B-e*n*B;c.n44=f*u*v-h*n*v+h*k*t-e*u*t-f*k*x+e*n*x;c.multiplyScalar(1/b.determinant());return c};
 THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,e=c.m,f=b.n33*b.n22-b.n32*b.n23,h=-b.n33*b.n21+b.n31*b.n23,m=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,u=-b.n32*b.n11+b.n31*b.n12,p=b.n23*b.n12-b.n22*b.n13,v=-b.n23*b.n11+b.n21*b.n13,t=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*k+b.n31*p;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;e[0]=b*f;e[1]=b*h;e[2]=b*m;e[3]=b*k;e[4]=b*n;e[5]=b*u;e[6]=b*p;e[7]=b*v;e[8]=b*t;return c};
 THREE.Matrix4.makeFrustum=function(b,c,e,f,h,m){var k;k=new THREE.Matrix4;k.n11=2*h/(c-b);k.n12=0;k.n13=(c+b)/(c-b);k.n14=0;k.n21=0;k.n22=2*h/(f-e);k.n23=(f+e)/(f-e);k.n24=0;k.n31=0;k.n32=0;k.n33=-(m+h)/(m-h);k.n34=-2*m*h/(m-h);k.n41=0;k.n42=0;k.n43=-1;k.n44=0;return k};THREE.Matrix4.makePerspective=function(b,c,e,f){var h,b=e*Math.tan(b*Math.PI/360);h=-b;return THREE.Matrix4.makeFrustum(h*c,b*c,h,b,e,f)};
 THREE.Matrix4.makeOrtho=function(b,c,e,f,h,m){var k,n,u,p;k=new THREE.Matrix4;n=c-b;u=e-f;p=m-h;k.n11=2/n;k.n12=0;k.n13=0;k.n14=-((c+b)/n);k.n21=0;k.n22=2/u;k.n23=0;k.n24=-((e+f)/u);k.n31=0;k.n32=0;k.n33=-2/p;k.n34=-((m+h)/p);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.__m1=new THREE.Matrix4;THREE.Matrix4.__m2=new THREE.Matrix4;
@@ -54,17 +54,17 @@ THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(b,c){thi
 b)return h;if(c&&(h=h.getChildByName(b,c),h!==void 0))return h}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);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,c,e){this.matrixAutoUpdate&&
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||c)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,c=!0;for(var b=0,f=this.children.length;b<f;b++)this.children[b].update(this.matrixWorld,c,e)},addChild:function(b){console.warn("DEPRECATED: Object3D.addChild() is now Object3D.add().");this.add(b)},removeChild:function(b){console.warn("DEPRECATED: Object3D.removeChild() is now Object3D.remove().");
 this.remove(b)}};THREE.Object3DCount=0;
-THREE.Projector=function(){function b(){var b=u[n]=u[n]||new THREE.RenderableVertex;n++;return b}function c(b,e){return e.z-b.z}function e(b,e){var c=0,f=1,k=b.z+b.w,h=e.z+e.w,m=-b.z+b.w,n=-e.z+e.w;return k>=0&&h>=0&&m>=0&&n>=0?!0:k<0&&h<0||m<0&&n<0?!1:(k<0?c=Math.max(c,k/(k-h)):h<0&&(f=Math.min(f,k/(k-h))),m<0?c=Math.max(c,m/(m-n)):n<0&&(f=Math.min(f,m/(m-n))),f<c?!1:(b.lerpSelf(e,c),e.lerpSelf(b,1-f),!0))}var f,h,m=[],k,n,u=[],p,v,t=[],x,w=[],y,z,A=[],E,D,F=[],G=[],N=[],Q=new THREE.Vector4,L=new THREE.Vector4,
-H=new THREE.Matrix4,M=new THREE.Matrix4,X=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],C=new THREE.Vector4,O=new THREE.Vector4;this.projectVector=function(b,e){H.multiply(e.projectionMatrix,e.matrixWorldInverse);H.multiplyVector3(b);return b};this.unprojectVector=function(b,e){H.multiply(e.matrixWorld,THREE.Matrix4.makeInvert(e.projectionMatrix));H.multiplyVector3(b);return b};this.projectObjects=function(b,e,k){var o,n;h=G.length=0;
-o=b.objects;b=0;for(e=o.length;b<e;b++){n=o[b];var w;if(!(w=!n.visible))if(w=n instanceof THREE.Mesh)if(w=n.frustumCulled){a:{w=void 0;for(var t=n.matrixWorld,p=-n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)),u=0;u<6;u++)if(w=X[u].x*t.n14+X[u].y*t.n24+X[u].z*t.n34+X[u].w,w<=p){w=!1;break a}w=!0}w=!w}if(!w)w=m[h]=m[h]||new THREE.RenderableObject,h++,f=w,Q.copy(n.position),H.multiplyVector3(Q),f.object=n,f.z=Q.z,G.push(f)}k&&G.sort(c);return G};this.projectScene=
-function(f,h,m){var o=h.near,G=h.far,S,Q,$,la,ja,ma,da,Y,T,Z,fa,na,va,K,ca,qa,ua;D=z=x=v=N.length=0;h.matrixAutoUpdate&&h.update(void 0,!0);f.update(void 0,!1,h);H.multiply(h.projectionMatrix,h.matrixWorldInverse);X[0].set(H.n41-H.n11,H.n42-H.n12,H.n43-H.n13,H.n44-H.n14);X[1].set(H.n41+H.n11,H.n42+H.n12,H.n43+H.n13,H.n44+H.n14);X[2].set(H.n41+H.n21,H.n42+H.n22,H.n43+H.n23,H.n44+H.n24);X[3].set(H.n41-H.n21,H.n42-H.n22,H.n43-H.n23,H.n44-H.n24);X[4].set(H.n41-H.n31,H.n42-H.n32,H.n43-H.n33,H.n44-H.n34);
-X[5].set(H.n41+H.n31,H.n42+H.n32,H.n43+H.n33,H.n44+H.n34);for(S=0;S<6;S++)T=X[S],T.divideScalar(Math.sqrt(T.x*T.x+T.y*T.y+T.z*T.z));T=this.projectObjects(f,h,!0);f=0;for(S=T.length;f<S;f++)if(Z=T[f].object,Z.visible)if(fa=Z.matrixWorld,na=Z.matrixRotationWorld,va=Z.materials,K=Z.overdraw,n=0,Z instanceof THREE.Mesh){ca=Z.geometry;la=ca.vertices;qa=ca.faces;ca=ca.faceVertexUvs;Q=0;for($=la.length;Q<$;Q++)k=b(),k.positionWorld.copy(la[Q].position),fa.multiplyVector3(k.positionWorld),k.positionScreen.copy(k.positionWorld),
-H.multiplyVector4(k.positionScreen),k.positionScreen.x/=k.positionScreen.w,k.positionScreen.y/=k.positionScreen.w,k.visible=k.positionScreen.z>o&&k.positionScreen.z<G;la=0;for(Q=qa.length;la<Q;la++){$=qa[la];if($ instanceof THREE.Face3)if(ja=u[$.a],ma=u[$.b],da=u[$.c],ja.visible&&ma.visible&&da.visible&&(Z.doubleSided||Z.flipSided!=(da.positionScreen.x-ja.positionScreen.x)*(ma.positionScreen.y-ja.positionScreen.y)-(da.positionScreen.y-ja.positionScreen.y)*(ma.positionScreen.x-ja.positionScreen.x)<
-0))Y=t[v]=t[v]||new THREE.RenderableFace3,v++,p=Y,p.v1.copy(ja),p.v2.copy(ma),p.v3.copy(da);else continue;else if($ instanceof THREE.Face4)if(ja=u[$.a],ma=u[$.b],da=u[$.c],Y=u[$.d],ja.visible&&ma.visible&&da.visible&&Y.visible&&(Z.doubleSided||Z.flipSided!=((Y.positionScreen.x-ja.positionScreen.x)*(ma.positionScreen.y-ja.positionScreen.y)-(Y.positionScreen.y-ja.positionScreen.y)*(ma.positionScreen.x-ja.positionScreen.x)<0||(ma.positionScreen.x-da.positionScreen.x)*(Y.positionScreen.y-da.positionScreen.y)-
-(ma.positionScreen.y-da.positionScreen.y)*(Y.positionScreen.x-da.positionScreen.x)<0)))ua=w[x]=w[x]||new THREE.RenderableFace4,x++,p=ua,p.v1.copy(ja),p.v2.copy(ma),p.v3.copy(da),p.v4.copy(Y);else continue;p.normalWorld.copy($.normal);na.multiplyVector3(p.normalWorld);p.centroidWorld.copy($.centroid);fa.multiplyVector3(p.centroidWorld);p.centroidScreen.copy(p.centroidWorld);H.multiplyVector3(p.centroidScreen);da=$.vertexNormals;ja=0;for(ma=da.length;ja<ma;ja++)Y=p.vertexNormalsWorld[ja],Y.copy(da[ja]),
-na.multiplyVector3(Y);ja=0;for(ma=ca.length;ja<ma;ja++)if(ua=ca[ja][la]){da=0;for(Y=ua.length;da<Y;da++)p.uvs[ja][da]=ua[da]}p.meshMaterials=va;p.faceMaterials=$.materials;p.overdraw=K;p.z=p.centroidScreen.z;N.push(p)}}else if(Z instanceof THREE.Line){M.multiply(H,fa);la=Z.geometry.vertices;ja=b();ja.positionScreen.copy(la[0].position);M.multiplyVector4(ja.positionScreen);Q=1;for($=la.length;Q<$;Q++)if(ja=b(),ja.positionScreen.copy(la[Q].position),M.multiplyVector4(ja.positionScreen),ma=u[n-2],C.copy(ja.positionScreen),
-O.copy(ma.positionScreen),e(C,O))C.multiplyScalar(1/C.w),O.multiplyScalar(1/O.w),fa=A[z]=A[z]||new THREE.RenderableLine,z++,y=fa,y.v1.positionScreen.copy(C),y.v2.positionScreen.copy(O),y.z=Math.max(C.z,O.z),y.materials=Z.materials,N.push(y)}else if(Z instanceof THREE.Particle&&(L.set(Z.matrixWorld.n14,Z.matrixWorld.n24,Z.matrixWorld.n34,1),H.multiplyVector4(L),L.z/=L.w,L.z>0&&L.z<1))fa=F[D]=F[D]||new THREE.RenderableParticle,D++,E=fa,E.x=L.x/L.w,E.y=L.y/L.w,E.z=L.z,E.rotation=Z.rotation.z,E.scale.x=
-Z.scale.x*Math.abs(E.x-(L.x+h.projectionMatrix.n11)/(L.w+h.projectionMatrix.n14)),E.scale.y=Z.scale.y*Math.abs(E.y-(L.y+h.projectionMatrix.n22)/(L.w+h.projectionMatrix.n24)),E.materials=Z.materials,N.push(E);m&&N.sort(c);return N}};THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)};
+THREE.Projector=function(){function b(){var b=u[n]=u[n]||new THREE.RenderableVertex;n++;return b}function c(b,e){return e.z-b.z}function e(b,e){var c=0,f=1,k=b.z+b.w,h=e.z+e.w,m=-b.z+b.w,n=-e.z+e.w;return k>=0&&h>=0&&m>=0&&n>=0?!0:k<0&&h<0||m<0&&n<0?!1:(k<0?c=Math.max(c,k/(k-h)):h<0&&(f=Math.min(f,k/(k-h))),m<0?c=Math.max(c,m/(m-n)):n<0&&(f=Math.min(f,m/(m-n))),f<c?!1:(b.lerpSelf(e,c),e.lerpSelf(b,1-f),!0))}var f,h,m=[],k,n,u=[],p,v,t=[],x,w=[],y,z,B=[],D,E,F=[],G=[],N=[],Q=new THREE.Vector4,H=new THREE.Vector4,
+K=new THREE.Matrix4,I=new THREE.Matrix4,X=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],C=new THREE.Vector4,O=new THREE.Vector4;this.projectVector=function(b,e){K.multiply(e.projectionMatrix,e.matrixWorldInverse);K.multiplyVector3(b);return b};this.unprojectVector=function(b,e){K.multiply(e.matrixWorld,THREE.Matrix4.makeInvert(e.projectionMatrix));K.multiplyVector3(b);return b};this.projectObjects=function(b,e,k){var o,n;h=G.length=0;
+o=b.objects;b=0;for(e=o.length;b<e;b++){n=o[b];var w;if(!(w=!n.visible))if(w=n instanceof THREE.Mesh)if(w=n.frustumCulled){a:{w=void 0;for(var t=n.matrixWorld,p=-n.geometry.boundingSphere.radius*Math.max(n.scale.x,Math.max(n.scale.y,n.scale.z)),u=0;u<6;u++)if(w=X[u].x*t.n14+X[u].y*t.n24+X[u].z*t.n34+X[u].w,w<=p){w=!1;break a}w=!0}w=!w}if(!w)w=m[h]=m[h]||new THREE.RenderableObject,h++,f=w,Q.copy(n.position),K.multiplyVector3(Q),f.object=n,f.z=Q.z,G.push(f)}k&&G.sort(c);return G};this.projectScene=
+function(f,h,m){var o=h.near,G=h.far,S,Q,aa,ia,ka,ma,ca,ha,T,Z,ea,oa,xa,M,fa,na,ta;E=z=x=v=N.length=0;h.matrixAutoUpdate&&h.update(void 0,!0);f.update(void 0,!1,h);K.multiply(h.projectionMatrix,h.matrixWorldInverse);X[0].set(K.n41-K.n11,K.n42-K.n12,K.n43-K.n13,K.n44-K.n14);X[1].set(K.n41+K.n11,K.n42+K.n12,K.n43+K.n13,K.n44+K.n14);X[2].set(K.n41+K.n21,K.n42+K.n22,K.n43+K.n23,K.n44+K.n24);X[3].set(K.n41-K.n21,K.n42-K.n22,K.n43-K.n23,K.n44-K.n24);X[4].set(K.n41-K.n31,K.n42-K.n32,K.n43-K.n33,K.n44-K.n34);
+X[5].set(K.n41+K.n31,K.n42+K.n32,K.n43+K.n33,K.n44+K.n34);for(S=0;S<6;S++)T=X[S],T.divideScalar(Math.sqrt(T.x*T.x+T.y*T.y+T.z*T.z));T=this.projectObjects(f,h,!0);f=0;for(S=T.length;f<S;f++)if(Z=T[f].object,Z.visible)if(ea=Z.matrixWorld,oa=Z.matrixRotationWorld,xa=Z.materials,M=Z.overdraw,n=0,Z instanceof THREE.Mesh){fa=Z.geometry;ia=fa.vertices;na=fa.faces;fa=fa.faceVertexUvs;Q=0;for(aa=ia.length;Q<aa;Q++)k=b(),k.positionWorld.copy(ia[Q].position),ea.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>o&&k.positionScreen.z<G;ia=0;for(Q=na.length;ia<Q;ia++){aa=na[ia];if(aa instanceof THREE.Face3)if(ka=u[aa.a],ma=u[aa.b],ca=u[aa.c],ka.visible&&ma.visible&&ca.visible&&(Z.doubleSided||Z.flipSided!=(ca.positionScreen.x-ka.positionScreen.x)*(ma.positionScreen.y-ka.positionScreen.y)-(ca.positionScreen.y-ka.positionScreen.y)*(ma.positionScreen.x-ka.positionScreen.x)<
+0))ha=t[v]=t[v]||new THREE.RenderableFace3,v++,p=ha,p.v1.copy(ka),p.v2.copy(ma),p.v3.copy(ca);else continue;else if(aa instanceof THREE.Face4)if(ka=u[aa.a],ma=u[aa.b],ca=u[aa.c],ha=u[aa.d],ka.visible&&ma.visible&&ca.visible&&ha.visible&&(Z.doubleSided||Z.flipSided!=((ha.positionScreen.x-ka.positionScreen.x)*(ma.positionScreen.y-ka.positionScreen.y)-(ha.positionScreen.y-ka.positionScreen.y)*(ma.positionScreen.x-ka.positionScreen.x)<0||(ma.positionScreen.x-ca.positionScreen.x)*(ha.positionScreen.y-
+ca.positionScreen.y)-(ma.positionScreen.y-ca.positionScreen.y)*(ha.positionScreen.x-ca.positionScreen.x)<0)))ta=w[x]=w[x]||new THREE.RenderableFace4,x++,p=ta,p.v1.copy(ka),p.v2.copy(ma),p.v3.copy(ca),p.v4.copy(ha);else continue;p.normalWorld.copy(aa.normal);oa.multiplyVector3(p.normalWorld);p.centroidWorld.copy(aa.centroid);ea.multiplyVector3(p.centroidWorld);p.centroidScreen.copy(p.centroidWorld);K.multiplyVector3(p.centroidScreen);ca=aa.vertexNormals;ka=0;for(ma=ca.length;ka<ma;ka++)ha=p.vertexNormalsWorld[ka],
+ha.copy(ca[ka]),oa.multiplyVector3(ha);ka=0;for(ma=fa.length;ka<ma;ka++)if(ta=fa[ka][ia]){ca=0;for(ha=ta.length;ca<ha;ca++)p.uvs[ka][ca]=ta[ca]}p.meshMaterials=xa;p.faceMaterials=aa.materials;p.overdraw=M;p.z=p.centroidScreen.z;N.push(p)}}else if(Z instanceof THREE.Line){I.multiply(K,ea);ia=Z.geometry.vertices;ka=b();ka.positionScreen.copy(ia[0].position);I.multiplyVector4(ka.positionScreen);Q=1;for(aa=ia.length;Q<aa;Q++)if(ka=b(),ka.positionScreen.copy(ia[Q].position),I.multiplyVector4(ka.positionScreen),
+ma=u[n-2],C.copy(ka.positionScreen),O.copy(ma.positionScreen),e(C,O))C.multiplyScalar(1/C.w),O.multiplyScalar(1/O.w),ea=B[z]=B[z]||new THREE.RenderableLine,z++,y=ea,y.v1.positionScreen.copy(C),y.v2.positionScreen.copy(O),y.z=Math.max(C.z,O.z),y.materials=Z.materials,N.push(y)}else if(Z instanceof THREE.Particle&&(H.set(Z.matrixWorld.n14,Z.matrixWorld.n24,Z.matrixWorld.n34,1),K.multiplyVector4(H),H.z/=H.w,H.z>0&&H.z<1))ea=F[E]=F[E]||new THREE.RenderableParticle,E++,D=ea,D.x=H.x/H.w,D.y=H.y/H.w,D.z=
+H.z,D.rotation=Z.rotation.z,D.scale.x=Z.scale.x*Math.abs(D.x-(H.x+h.projectionMatrix.n11)/(H.w+h.projectionMatrix.n14)),D.scale.y=Z.scale.y*Math.abs(D.y-(H.y+h.projectionMatrix.n22)/(H.w+h.projectionMatrix.n24)),D.materials=Z.materials,N.push(D);m&&N.sort(c);return N}};THREE.Quaternion=function(b,c,e,f){this.set(b||0,c||0,e||0,f!==void 0?f:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,e,f){this.x=b;this.y=c;this.z=e;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=0.5*Math.PI/360,e=b.x*c,f=b.y*c,h=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-h),h=Math.sin(-h),m=Math.cos(e),e=Math.sin(e),k=b*c,n=f*h;this.w=k*m-n*e;this.x=k*e+n*m;this.y=f*c*m+b*h*e;this.z=b*h*m-f*c*e;return this},setFromAxisAngle:function(b,c){var e=c/2,f=Math.sin(e);
 this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(e);return this},setFromRotationMatrix:function(b){var c=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,c+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,c-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,c-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.n12<0?-Math.abs(this.z):Math.abs(this.z);
 this.normalize();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);b==0?this.w=this.z=this.y=this.x=0:(b=1/b,this.x*=b,this.y*=b,this.z*=b,this.w*=b);return this},multiplySelf:function(b){var c=
@@ -79,9 +79,9 @@ c;b++)e=this.faces[b],e.centroid.set(0,0,0),e instanceof THREE.Face3?(e.centroid
 e,f,h,m,k,n=new THREE.Vector3,u=new THREE.Vector3;f=0;for(h=this.faces.length;f<h;f++){m=this.faces[f];if(b&&m.vertexNormals.length){n.set(0,0,0);c=0;for(e=m.vertexNormals.length;c<e;c++)n.addSelf(m.vertexNormals[c]);n.divideScalar(3)}else c=this.vertices[m.a],e=this.vertices[m.b],k=this.vertices[m.c],n.sub(k.position,e.position),u.sub(c.position,e.position),n.crossSelf(u);n.isZero()||n.normalize();m.normal.copy(n)}},computeVertexNormals:function(){var b,c,e,f;if(this.__tmpVertices==void 0){f=this.__tmpVertices=
 Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)f[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)if(e=this.faces[b],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{f=this.__tmpVertices;b=0;for(c=this.vertices.length;b<c;b++)f[b].set(0,0,0)}b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e instanceof
 THREE.Face3?(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal)):e instanceof THREE.Face4&&(f[e.a].addSelf(e.normal),f[e.b].addSelf(e.normal),f[e.c].addSelf(e.normal),f[e.d].addSelf(e.normal));b=0;for(c=this.vertices.length;b<c;b++)f[b].normalize();b=0;for(c=this.faces.length;b<c;b++)e=this.faces[b],e instanceof THREE.Face3?(e.vertexNormals[0].copy(f[e.a]),e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c])):e instanceof THREE.Face4&&(e.vertexNormals[0].copy(f[e.a]),
-e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c]),e.vertexNormals[3].copy(f[e.d]))},computeTangents:function(){function b(b,e,c,f,h,m,o){n=b.vertices[e].position;u=b.vertices[c].position;p=b.vertices[f].position;v=k[h];t=k[m];x=k[o];w=u.x-n.x;y=p.x-n.x;z=u.y-n.y;A=p.y-n.y;E=u.z-n.z;D=p.z-n.z;F=t.u-v.u;G=x.u-v.u;N=t.v-v.v;Q=x.v-v.v;L=1/(F*Q-G*N);C.set((Q*w-N*y)*L,(Q*z-N*A)*L,(Q*E-N*D)*L);O.set((F*y-G*w)*L,(F*A-G*z)*L,(F*D-G*E)*L);M[e].addSelf(C);M[c].addSelf(C);M[f].addSelf(C);X[e].addSelf(O);
-X[c].addSelf(O);X[f].addSelf(O)}var c,e,f,h,m,k,n,u,p,v,t,x,w,y,z,A,E,D,F,G,N,Q,L,H,M=[],X=[],C=new THREE.Vector3,O=new THREE.Vector3,P=new THREE.Vector3,U=new THREE.Vector3,V=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++)M[c]=new THREE.Vector3,X[c]=new THREE.Vector3;c=0;for(e=this.faces.length;c<e;c++)m=this.faces[c],k=this.faceVertexUvs[0][c],m instanceof THREE.Face3?b(this,m.a,m.b,m.c,0,1,2):m instanceof THREE.Face4&&(b(this,m.a,m.b,m.c,0,1,2),b(this,m.a,m.b,m.d,0,1,3));var o=["a","b",
-"c","d"];c=0;for(e=this.faces.length;c<e;c++){m=this.faces[c];for(f=0;f<m.vertexNormals.length;f++)V.copy(m.vertexNormals[f]),h=m[o[f]],H=M[h],P.copy(H),P.subSelf(V.multiplyScalar(V.dot(H))).normalize(),U.cross(m.vertexNormals[f],H),h=U.dot(X[h]),h=h<0?-1:1,m.vertexTangents[f]=new THREE.Vector4(P.x,P.y,P.z,h)}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,
+e.vertexNormals[1].copy(f[e.b]),e.vertexNormals[2].copy(f[e.c]),e.vertexNormals[3].copy(f[e.d]))},computeTangents:function(){function b(b,e,c,f,h,m,o){n=b.vertices[e].position;u=b.vertices[c].position;p=b.vertices[f].position;v=k[h];t=k[m];x=k[o];w=u.x-n.x;y=p.x-n.x;z=u.y-n.y;B=p.y-n.y;D=u.z-n.z;E=p.z-n.z;F=t.u-v.u;G=x.u-v.u;N=t.v-v.v;Q=x.v-v.v;H=1/(F*Q-G*N);C.set((Q*w-N*y)*H,(Q*z-N*B)*H,(Q*D-N*E)*H);O.set((F*y-G*w)*H,(F*B-G*z)*H,(F*E-G*D)*H);I[e].addSelf(C);I[c].addSelf(C);I[f].addSelf(C);X[e].addSelf(O);
+X[c].addSelf(O);X[f].addSelf(O)}var c,e,f,h,m,k,n,u,p,v,t,x,w,y,z,B,D,E,F,G,N,Q,H,K,I=[],X=[],C=new THREE.Vector3,O=new THREE.Vector3,P=new THREE.Vector3,U=new THREE.Vector3,W=new THREE.Vector3;c=0;for(e=this.vertices.length;c<e;c++)I[c]=new THREE.Vector3,X[c]=new THREE.Vector3;c=0;for(e=this.faces.length;c<e;c++)m=this.faces[c],k=this.faceVertexUvs[0][c],m instanceof THREE.Face3?b(this,m.a,m.b,m.c,0,1,2):m instanceof THREE.Face4&&(b(this,m.a,m.b,m.c,0,1,2),b(this,m.a,m.b,m.d,0,1,3));var o=["a","b",
+"c","d"];c=0;for(e=this.faces.length;c<e;c++){m=this.faces[c];for(f=0;f<m.vertexNormals.length;f++)W.copy(m.vertexNormals[f]),h=m[o[f]],K=I[h],P.copy(K),P.subSelf(W.multiplyScalar(W.dot(K))).normalize(),U.cross(m.vertexNormals[f],K),h=U.dot(X[h]),h=h<0?-1:1,m.vertexTangents[f]=new THREE.Vector4(P.x,P.y,P.z,h)}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 c=1,e=this.vertices.length;c<e;c++){b=this.vertices[c];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=0,c=0,e=this.vertices.length;c<e;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,e){return Math.min(b,e)+"_"+Math.max(b,e)}function c(b,e,c){b[e]===void 0?(b[e]={set:{},array:[]},b[e].set[c]=1,b[e].array.push(c)):b[e].set[c]===void 0&&(b[e].set[c]=1,b[e].array.push(c))}var e,f,h,m,k,n=
 {};e=0;for(f=this.faces.length;e<f;e++)k=this.faces[e],k instanceof THREE.Face3?(h=b(k.a,k.b),c(n,h,e),h=b(k.b,k.c),c(n,h,e),h=b(k.a,k.c),c(n,h,e)):k instanceof THREE.Face4&&(h=b(k.b,k.d),c(n,h,e),h=b(k.a,k.b),c(n,h,e),h=b(k.a,k.d),c(n,h,e),h=b(k.b,k.c),c(n,h,e),h=b(k.c,k.d),c(n,h,e));e=0;for(f=this.edges.length;e<f;e++){k=this.edges[e];h=k.vertexIndices[0];m=k.vertexIndices[1];k.faceIndices=n[b(h,m)].array;for(h=0;h<k.faceIndices.length;h++)m=k.faceIndices[h],k.faces.push(this.faces[m])}}};
@@ -148,48 +148,48 @@ THREE.Scene.prototype.removeChildRecurse=function(b){if(b instanceof THREE.Light
 THREE.Scene.prototype.addObject=function(b){console.warn("DEPRECATED: Scene.addObject() is now Scene.add().");this.add(b)};THREE.Scene.prototype.addLight=function(b){console.warn("DEPRECATED: Scene.addLight() is now Scene.add().");this.add(b)};THREE.Scene.prototype.removeChild=function(b){console.warn("DEPRECATED: Scene.removeChild() is now Scene.remove().");this.remove(b)};THREE.Scene.prototype.removeObject=function(b){console.warn("DEPRECATED: Scene.removeObject() is now Scene.remove().");this.remove(b)};
 THREE.Scene.prototype.removeLight=function(b){console.warn("DEPRECATED: Scene.removeLight() is now Scene.remove().");this.remove(b)};THREE.Fog=function(b,c,e){this.color=new THREE.Color(b);this.near=c!==void 0?c:1;this.far=e!==void 0?e:1E3};THREE.FogExp2=function(b,c){this.color=new THREE.Color(b);this.density=c!==void 0?c:2.5E-4};
 THREE.DOMRenderer=function(){THREE.Renderer.call(this);var b=null,c=new THREE.Projector,e,f,h,m;this.domElement=document.createElement("div");this.setSize=function(b,c){e=b;f=c;h=e/2;m=f/2};this.render=function(e,f){var u,p,v,t,x,w,y,z;b=c.projectScene(e,f);u=0;for(p=b.length;u<p;u++)if(x=b[u],x instanceof THREE.RenderableParticle){y=x.x*h+h;z=x.y*m+m;v=0;for(t=x.material.length;v<t;v++)if(w=x.material[v],w instanceof THREE.ParticleDOMMaterial)w=w.domElement,w.style.left=y+"px",w.style.top=z+"px"}}};
-THREE.CanvasRenderer=function(b){function c(b){if(A!=b)w.globalAlpha=A=b}function e(b){if(E!=b){switch(b){case THREE.NormalBlending:w.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:w.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:w.globalCompositeOperation="darker"}E=b}}function f(b){if(D!=b)w.strokeStyle=D=b}function h(b){if(F!=b)w.fillStyle=F=b}var m=this,k=null,n=new THREE.Projector,b=b||{},u=b.canvas!==void 0?b.canvas:document.createElement("canvas"),
-p,v,t,x,w=u.getContext("2d"),y=new THREE.Color(0),z=0,A=1,E=0,D=null,F=null,G=null,N=null,Q=null,L,H,M,X,C=new THREE.RenderableVertex,O=new THREE.RenderableVertex,P,U,V,o,ea,S,ta,$,la,ja,ma,da,Y=new THREE.Color(0),T=new THREE.Color(0),Z=new THREE.Color(0),fa=new THREE.Color(0),na=new THREE.Color(0),va=[],K,ca,qa,ua,sa,xa,Ea,Da,pa,Ga,J=new THREE.Rectangle,ha=new THREE.Rectangle,W=new THREE.Rectangle,ra=!1,ga=new THREE.Color,ia=new THREE.Color,za=new THREE.Color,ya=new THREE.Color,oa=new THREE.Vector3,
-Ha,Ba,aa,Aa,ka,Wa,b=16;Ha=document.createElement("canvas");Ha.width=Ha.height=2;Ba=Ha.getContext("2d");Ba.fillStyle="rgba(0,0,0,1)";Ba.fillRect(0,0,2,2);aa=Ba.getImageData(0,0,2,2);Aa=aa.data;ka=document.createElement("canvas");ka.width=ka.height=b;Wa=ka.getContext("2d");Wa.translate(-b/2,-b/2);Wa.scale(b,b);b--;this.domElement=u;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(b,e){p=b;v=e;t=Math.floor(p/2);x=Math.floor(v/2);u.width=
-p;u.height=v;J.set(-t,-x,t,x);ha.set(-t,-x,t,x);A=1;E=0;Q=N=G=F=D=null};this.setClearColor=function(b,e){y.copy(b);z=e;ha.set(-t,-x,t,x)};this.setClearColorHex=function(b,e){y.setHex(b);z=e;ha.set(-t,-x,t,x)};this.clear=function(){w.setTransform(1,0,0,-1,t,x);ha.isEmpty()||(ha.minSelf(J),ha.inflate(2),z<1&&w.clearRect(Math.floor(ha.getX()),Math.floor(ha.getY()),Math.floor(ha.getWidth()),Math.floor(ha.getHeight())),z>0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*
-255)+","+Math.floor(y.b*255)+","+z+")"),w.fillRect(Math.floor(ha.getX()),Math.floor(ha.getY()),Math.floor(ha.getWidth()),Math.floor(ha.getHeight()))),ha.empty())};this.render=function(b,u){function p(b){var e,c,f,k=b.lights;ia.setRGB(0,0,0);za.setRGB(0,0,0);ya.setRGB(0,0,0);b=0;for(e=k.length;b<e;b++)c=k[b],f=c.color,c instanceof THREE.AmbientLight?(ia.r+=f.r,ia.g+=f.g,ia.b+=f.b):c instanceof THREE.DirectionalLight?(za.r+=f.r,za.g+=f.g,za.b+=f.b):c instanceof THREE.PointLight&&(ya.r+=f.r,ya.g+=f.g,
-ya.b+=f.b)}function v(b,e,c,f){var k,h,m,o,n=b.lights,b=0;for(k=n.length;b<k;b++)h=n[b],m=h.color,h instanceof THREE.DirectionalLight?(o=c.dot(h.position),o<=0||(o*=h.intensity,f.r+=m.r*o,f.g+=m.g*o,f.b+=m.b*o)):h instanceof THREE.PointLight&&(o=c.dot(oa.sub(h.position,e).normalize()),o<=0||(o*=h.distance==0?1:1-Math.min(e.distanceTo(h.position)/h.distance,1),o!=0&&(o*=h.intensity,f.r+=m.r*o,f.g+=m.g*o,f.b+=m.b*o)))}function y(b,k,m){c(m.opacity);e(m.blending);var o,n,u,ka,p,v;if(m instanceof THREE.ParticleBasicMaterial){if(m.map)ka=
-m.map.image,p=ka.width>>1,v=ka.height>>1,m=k.scale.x*t,u=k.scale.y*x,o=m*p,n=u*v,W.set(b.x-o,b.y-n,b.x+o,b.y+n),J.intersects(W)&&(w.save(),w.translate(b.x,b.y),w.rotate(-k.rotation),w.scale(m,-u),w.translate(-p,-v),w.drawImage(ka,0,0),w.restore())}else m instanceof THREE.ParticleCanvasMaterial&&(o=k.scale.x*t,n=k.scale.y*x,W.set(b.x-o,b.y-n,b.x+o,b.y+n),J.intersects(W)&&(f(m.color.getContextStyle()),h(m.color.getContextStyle()),w.save(),w.translate(b.x,b.y),w.rotate(-k.rotation),w.scale(o,n),m.program(w),
-w.restore()))}function z(b,k,h,m){c(m.opacity);e(m.blending);w.beginPath();w.moveTo(b.positionScreen.x,b.positionScreen.y);w.lineTo(k.positionScreen.x,k.positionScreen.y);w.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(G!=b)w.lineWidth=G=b;b=m.linecap;if(N!=b)w.lineCap=N=b;b=m.linejoin;if(Q!=b)w.lineJoin=Q=b;f(m.color.getContextStyle());w.stroke();W.inflate(m.linewidth*2)}}function A(b,f,k,h,n,t,ka,p,w){m.info.render.vertices+=3;m.info.render.faces++;c(p.opacity);e(p.blending);
-P=b.positionScreen.x;U=b.positionScreen.y;V=f.positionScreen.x;o=f.positionScreen.y;ea=k.positionScreen.x;S=k.positionScreen.y;D(P,U,V,o,ea,S);if(p instanceof THREE.MeshBasicMaterial)if(p.map)p.map.mapping instanceof THREE.UVMapping&&(ua=ka.uvs[0],ab(P,U,V,o,ea,S,ua[h].u,ua[h].v,ua[n].u,ua[n].v,ua[t].u,ua[t].v,p.map));else if(p.envMap){if(p.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=u.matrixWorldInverse,oa.copy(ka.vertexNormalsWorld[0]),sa=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+
-0.5,xa=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,oa.copy(ka.vertexNormalsWorld[1]),Ea=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,Da=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,oa.copy(ka.vertexNormalsWorld[2]),pa=(oa.x*b.n11+oa.y*b.n12+oa.z*b.n13)*0.5+0.5,Ga=-(oa.x*b.n21+oa.y*b.n22+oa.z*b.n23)*0.5+0.5,ab(P,U,V,o,ea,S,sa,xa,Ea,Da,pa,Ga,p.envMap)}else p.wireframe?Ka(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):La(p.color);else if(p instanceof THREE.MeshLambertMaterial)p.map&&
-!p.wireframe&&(p.map.mapping instanceof THREE.UVMapping&&(ua=ka.uvs[0],ab(P,U,V,o,ea,S,ua[h].u,ua[h].v,ua[n].u,ua[n].v,ua[t].u,ua[t].v,p.map)),e(THREE.SubtractiveBlending)),ra?!p.wireframe&&p.shading==THREE.SmoothShading&&ka.vertexNormalsWorld.length==3?(T.r=Z.r=fa.r=ia.r,T.g=Z.g=fa.g=ia.g,T.b=Z.b=fa.b=ia.b,v(w,ka.v1.positionWorld,ka.vertexNormalsWorld[0],T),v(w,ka.v2.positionWorld,ka.vertexNormalsWorld[1],Z),v(w,ka.v3.positionWorld,ka.vertexNormalsWorld[2],fa),T.r=Math.max(0,Math.min(p.color.r*T.r,
-1)),T.g=Math.max(0,Math.min(p.color.g*T.g,1)),T.b=Math.max(0,Math.min(p.color.b*T.b,1)),Z.r=Math.max(0,Math.min(p.color.r*Z.r,1)),Z.g=Math.max(0,Math.min(p.color.g*Z.g,1)),Z.b=Math.max(0,Math.min(p.color.b*Z.b,1)),fa.r=Math.max(0,Math.min(p.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(p.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(p.color.b*fa.b,1)),na.r=(Z.r+fa.r)*0.5,na.g=(Z.g+fa.g)*0.5,na.b=(Z.b+fa.b)*0.5,qa=Xa(T,Z,fa,na),Ta(P,U,V,o,ea,S,0,0,1,0,0,1,qa)):(ga.r=ia.r,ga.g=ia.g,ga.b=ia.b,v(w,ka.centroidWorld,
-ka.normalWorld,ga),Y.r=Math.max(0,Math.min(p.color.r*ga.r,1)),Y.g=Math.max(0,Math.min(p.color.g*ga.g,1)),Y.b=Math.max(0,Math.min(p.color.b*ga.b,1)),p.wireframe?Ka(Y,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):La(Y)):p.wireframe?Ka(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):La(p.color);else if(p instanceof THREE.MeshDepthMaterial)K=u.near,ca=u.far,T.r=T.g=T.b=1-Oa(b.positionScreen.z,K,ca),Z.r=Z.g=Z.b=1-Oa(f.positionScreen.z,K,ca),fa.r=fa.g=fa.b=1-Oa(k.positionScreen.z,
-K,ca),na.r=(Z.r+fa.r)*0.5,na.g=(Z.g+fa.g)*0.5,na.b=(Z.b+fa.b)*0.5,qa=Xa(T,Z,fa,na),Ta(P,U,V,o,ea,S,0,0,1,0,0,1,qa);else if(p instanceof THREE.MeshNormalMaterial)Y.r=Ua(ka.normalWorld.x),Y.g=Ua(ka.normalWorld.y),Y.b=Ua(ka.normalWorld.z),p.wireframe?Ka(Y,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):La(Y)}function E(b,f,k,h,n,p,ka,t,w){m.info.render.vertices+=4;m.info.render.faces++;c(t.opacity);e(t.blending);if(t.map||t.envMap)A(b,f,h,0,1,3,ka,t,w),A(n,k,p,1,2,3,ka,t,w);else if(P=b.positionScreen.x,
-U=b.positionScreen.y,V=f.positionScreen.x,o=f.positionScreen.y,ea=k.positionScreen.x,S=k.positionScreen.y,ta=h.positionScreen.x,$=h.positionScreen.y,la=n.positionScreen.x,ja=n.positionScreen.y,ma=p.positionScreen.x,da=p.positionScreen.y,t instanceof THREE.MeshBasicMaterial)F(P,U,V,o,ea,S,ta,$),t.wireframe?Ka(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(t.color);else if(t instanceof THREE.MeshLambertMaterial)ra?!t.wireframe&&t.shading==THREE.SmoothShading&&ka.vertexNormalsWorld.length==
-4?(T.r=Z.r=fa.r=na.r=ia.r,T.g=Z.g=fa.g=na.g=ia.g,T.b=Z.b=fa.b=na.b=ia.b,v(w,ka.v1.positionWorld,ka.vertexNormalsWorld[0],T),v(w,ka.v2.positionWorld,ka.vertexNormalsWorld[1],Z),v(w,ka.v4.positionWorld,ka.vertexNormalsWorld[3],fa),v(w,ka.v3.positionWorld,ka.vertexNormalsWorld[2],na),T.r=Math.max(0,Math.min(t.color.r*T.r,1)),T.g=Math.max(0,Math.min(t.color.g*T.g,1)),T.b=Math.max(0,Math.min(t.color.b*T.b,1)),Z.r=Math.max(0,Math.min(t.color.r*Z.r,1)),Z.g=Math.max(0,Math.min(t.color.g*Z.g,1)),Z.b=Math.max(0,
-Math.min(t.color.b*Z.b,1)),fa.r=Math.max(0,Math.min(t.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(t.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(t.color.b*fa.b,1)),na.r=Math.max(0,Math.min(t.color.r*na.r,1)),na.g=Math.max(0,Math.min(t.color.g*na.g,1)),na.b=Math.max(0,Math.min(t.color.b*na.b,1)),qa=Xa(T,Z,fa,na),D(P,U,V,o,ta,$),Ta(P,U,V,o,ta,$,0,0,1,0,0,1,qa),D(la,ja,ea,S,ma,da),Ta(la,ja,ea,S,ma,da,1,0,1,1,0,1,qa)):(ga.r=ia.r,ga.g=ia.g,ga.b=ia.b,v(w,ka.centroidWorld,ka.normalWorld,ga),Y.r=Math.max(0,Math.min(t.color.r*
-ga.r,1)),Y.g=Math.max(0,Math.min(t.color.g*ga.g,1)),Y.b=Math.max(0,Math.min(t.color.b*ga.b,1)),F(P,U,V,o,ea,S,ta,$),t.wireframe?Ka(Y,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(Y)):(F(P,U,V,o,ea,S,ta,$),t.wireframe?Ka(t.color,t.wireframeLinewidth,t.wireframeLinecap,t.wireframeLinejoin):La(t.color));else if(t instanceof THREE.MeshNormalMaterial)Y.r=Ua(ka.normalWorld.x),Y.g=Ua(ka.normalWorld.y),Y.b=Ua(ka.normalWorld.z),F(P,U,V,o,ea,S,ta,$),t.wireframe?Ka(Y,t.wireframeLinewidth,t.wireframeLinecap,
-t.wireframeLinejoin):La(Y);else if(t instanceof THREE.MeshDepthMaterial)K=u.near,ca=u.far,T.r=T.g=T.b=1-Oa(b.positionScreen.z,K,ca),Z.r=Z.g=Z.b=1-Oa(f.positionScreen.z,K,ca),fa.r=fa.g=fa.b=1-Oa(h.positionScreen.z,K,ca),na.r=na.g=na.b=1-Oa(k.positionScreen.z,K,ca),qa=Xa(T,Z,fa,na),D(P,U,V,o,ta,$),Ta(P,U,V,o,ta,$,0,0,1,0,0,1,qa),D(la,ja,ea,S,ma,da),Ta(la,ja,ea,S,ma,da,1,0,1,1,0,1,qa)}function D(b,e,c,f,k,h){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(k,h);w.lineTo(b,e);w.closePath()}function F(b,
-e,c,f,k,h,m,o){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(k,h);w.lineTo(m,o);w.lineTo(b,e);w.closePath()}function Ka(b,e,c,k){if(G!=e)w.lineWidth=G=e;if(N!=c)w.lineCap=N=c;if(Q!=k)w.lineJoin=Q=k;f(b.getContextStyle());w.stroke();W.inflate(e*2)}function La(b){h(b.getContextStyle());w.fill()}function ab(b,e,c,f,k,m,o,n,t,p,ka,u,v){if(v.image.width!=0){if(v.needsUpdate==!0||va[v.id]==void 0){var x=v.wrapS==THREE.RepeatWrapping,J=v.wrapT==THREE.RepeatWrapping;va[v.id]=w.createPattern(v.image,
-x&&J?"repeat":x&&!J?"repeat-x":!x&&J?"repeat-y":"no-repeat");v.needsUpdate=!1}h(va[v.id]);var x=v.offset.x/v.repeat.x,J=v.offset.y/v.repeat.y,$a=(v.image.width-1)*v.repeat.x,v=(v.image.height-1)*v.repeat.y,o=(o+x)*$a,n=(n+J)*v,t=(t+x)*$a,p=(p+J)*v,ka=(ka+x)*$a,u=(u+J)*v;c-=b;f-=e;k-=b;m-=e;t-=o;p-=n;ka-=o;u-=n;x=1/(t*u-ka*p);v=(u*c-p*k)*x;p=(u*f-p*m)*x;c=(t*k-ka*c)*x;f=(t*m-ka*f)*x;b=b-v*o-c*n;e=e-p*o-f*n;w.save();w.transform(v,p,c,f,b,e);w.fill();w.restore()}}function Ta(b,e,c,f,k,h,m,o,n,t,p,ka,
-u){var v,x;v=u.width-1;x=u.height-1;m*=v;o*=x;n*=v;t*=x;p*=v;ka*=x;c-=b;f-=e;k-=b;h-=e;n-=m;t-=o;p-=m;ka-=o;x=1/(n*ka-p*t);v=(ka*c-t*k)*x;t=(ka*f-t*h)*x;c=(n*k-p*c)*x;f=(n*h-p*f)*x;b=b-v*m-c*o;e=e-t*m-f*o;w.save();w.transform(v,t,c,f,b,e);w.clip();w.drawImage(u,0,0);w.restore()}function Xa(b,e,c,f){var k=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),m=~~(e.r*255),o=~~(e.g*255),e=~~(e.b*255),n=~~(c.r*255),t=~~(c.g*255),c=~~(c.b*255),p=~~(f.r*255),u=~~(f.g*255),f=~~(f.b*255);Aa[0]=k<0?0:k>255?255:k;Aa[1]=
-h<0?0:h>255?255:h;Aa[2]=b<0?0:b>255?255:b;Aa[4]=m<0?0:m>255?255:m;Aa[5]=o<0?0:o>255?255:o;Aa[6]=e<0?0:e>255?255:e;Aa[8]=n<0?0:n>255?255:n;Aa[9]=t<0?0:t>255?255:t;Aa[10]=c<0?0:c>255?255:c;Aa[12]=p<0?0:p>255?255:p;Aa[13]=u<0?0:u>255?255:u;Aa[14]=f<0?0:f>255?255:f;Ba.putImageData(aa,0,0);Wa.drawImage(Ha,0,0);return ka}function Oa(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Ua(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Ma(b,e){var c=e.x-b.x,f=e.y-b.y,k=c*c+f*f;k!=0&&(k=1/Math.sqrt(k),c*=k,f*=k,
-e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Ya,db,wa,Fa,Na,Va,Za,Ca;this.autoClear?this.clear():w.setTransform(1,0,0,-1,t,x);m.info.render.vertices=0;m.info.render.faces=0;k=n.projectScene(b,u,this.sortElements);(ra=b.lights.length>0)&&p(b);Ya=0;for(db=k.length;Ya<db;Ya++){wa=k[Ya];W.empty();if(wa instanceof THREE.RenderableParticle){L=wa;L.x*=t;L.y*=x;Fa=0;for(Na=wa.materials.length;Fa<Na;)Ca=wa.materials[Fa++],Ca.opacity!=0&&y(L,wa,Ca,b)}else if(wa instanceof THREE.RenderableLine){if(L=wa.v1,H=wa.v2,L.positionScreen.x*=
-t,L.positionScreen.y*=x,H.positionScreen.x*=t,H.positionScreen.y*=x,W.addPoint(L.positionScreen.x,L.positionScreen.y),W.addPoint(H.positionScreen.x,H.positionScreen.y),J.intersects(W)){Fa=0;for(Na=wa.materials.length;Fa<Na;)Ca=wa.materials[Fa++],Ca.opacity!=0&&z(L,H,wa,Ca,b)}}else if(wa instanceof THREE.RenderableFace3){if(L=wa.v1,H=wa.v2,M=wa.v3,L.positionScreen.x*=t,L.positionScreen.y*=x,H.positionScreen.x*=t,H.positionScreen.y*=x,M.positionScreen.x*=t,M.positionScreen.y*=x,wa.overdraw&&(Ma(L.positionScreen,
-H.positionScreen),Ma(H.positionScreen,M.positionScreen),Ma(M.positionScreen,L.positionScreen)),W.add3Points(L.positionScreen.x,L.positionScreen.y,H.positionScreen.x,H.positionScreen.y,M.positionScreen.x,M.positionScreen.y),J.intersects(W)){Fa=0;for(Na=wa.meshMaterials.length;Fa<Na;)if(Ca=wa.meshMaterials[Fa++],Ca instanceof THREE.MeshFaceMaterial){Va=0;for(Za=wa.faceMaterials.length;Va<Za;)(Ca=wa.faceMaterials[Va++])&&Ca.opacity!=0&&A(L,H,M,0,1,2,wa,Ca,b)}else Ca.opacity!=0&&A(L,H,M,0,1,2,wa,Ca,b)}}else if(wa instanceof
-THREE.RenderableFace4&&(L=wa.v1,H=wa.v2,M=wa.v3,X=wa.v4,L.positionScreen.x*=t,L.positionScreen.y*=x,H.positionScreen.x*=t,H.positionScreen.y*=x,M.positionScreen.x*=t,M.positionScreen.y*=x,X.positionScreen.x*=t,X.positionScreen.y*=x,C.positionScreen.copy(H.positionScreen),O.positionScreen.copy(X.positionScreen),wa.overdraw&&(Ma(L.positionScreen,H.positionScreen),Ma(H.positionScreen,X.positionScreen),Ma(X.positionScreen,L.positionScreen),Ma(M.positionScreen,C.positionScreen),Ma(M.positionScreen,O.positionScreen)),
-W.addPoint(L.positionScreen.x,L.positionScreen.y),W.addPoint(H.positionScreen.x,H.positionScreen.y),W.addPoint(M.positionScreen.x,M.positionScreen.y),W.addPoint(X.positionScreen.x,X.positionScreen.y),J.intersects(W))){Fa=0;for(Na=wa.meshMaterials.length;Fa<Na;)if(Ca=wa.meshMaterials[Fa++],Ca instanceof THREE.MeshFaceMaterial){Va=0;for(Za=wa.faceMaterials.length;Va<Za;)(Ca=wa.faceMaterials[Va++])&&Ca.opacity!=0&&E(L,H,M,X,C,O,wa,Ca,b)}else Ca.opacity!=0&&E(L,H,M,X,C,O,wa,Ca,b)}ha.addRectangle(W)}w.setTransform(1,
-0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function b(b,e,c){var f,k,h,m;f=0;for(k=b.lights.length;f<k;f++)h=b.lights[f],h instanceof THREE.DirectionalLight?(m=e.normalWorld.dot(h.position)*h.intensity,m>0&&(c.r+=h.color.r*m,c.g+=h.color.g*m,c.b+=h.color.b*m)):h instanceof THREE.PointLight&&(X.sub(h.position,e.centroidWorld),X.normalize(),m=e.normalWorld.dot(X)*h.intensity,m>0&&(c.r+=h.color.r*m,c.g+=h.color.g*m,c.b+=h.color.b*m))}function c(e,c,k,o,n,t){m.info.render.vertices+=3;m.info.render.faces++;P=f(U++);
-P.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?G.copy(n.color):n instanceof THREE.MeshLambertMaterial?F?(N.r=Q.r,N.g=Q.g,N.b=Q.b,b(t,o,N),G.r=Math.max(0,Math.min(n.color.r*N.r,1)),G.g=Math.max(0,Math.min(n.color.g*N.g,1)),G.b=Math.max(0,Math.min(n.color.b*N.b,1))):G.copy(n.color):n instanceof THREE.MeshDepthMaterial?(M=1-n.__2near/(n.__farPlusNear-
-o.z*n.__farMinusNear),G.setRGB(M,M,M)):n instanceof THREE.MeshNormalMaterial&&G.setRGB(h(o.normalWorld.x),h(o.normalWorld.y),h(o.normalWorld.z));n.wireframe?P.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):P.setAttribute("style","fill: "+G.getContextStyle()+"; fill-opacity: "+n.opacity);u.appendChild(P)}function e(e,c,k,o,n,t,p){m.info.render.vertices+=
-4;m.info.render.faces++;P=f(U++);P.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+" L "+o.positionScreen.x+","+o.positionScreen.y+"z");t instanceof THREE.MeshBasicMaterial?G.copy(t.color):t instanceof THREE.MeshLambertMaterial?F?(N.r=Q.r,N.g=Q.g,N.b=Q.b,b(p,n,N),G.r=Math.max(0,Math.min(t.color.r*N.r,1)),G.g=Math.max(0,Math.min(t.color.g*N.g,1)),G.b=Math.max(0,Math.min(t.color.b*N.b,1))):
-G.copy(t.color):t instanceof THREE.MeshDepthMaterial?(M=1-t.__2near/(t.__farPlusNear-n.z*t.__farMinusNear),G.setRGB(M,M,M)):t instanceof THREE.MeshNormalMaterial&&G.setRGB(h(n.normalWorld.x),h(n.normalWorld.y),h(n.normalWorld.z));t.wireframe?P.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+t.wireframeLinewidth+"; stroke-opacity: "+t.opacity+"; stroke-linecap: "+t.wireframeLinecap+"; stroke-linejoin: "+t.wireframeLinejoin):P.setAttribute("style","fill: "+G.getContextStyle()+
-"; fill-opacity: "+t.opacity);u.appendChild(P)}function f(b){C[b]==null&&(C[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),o==0&&C[b].setAttribute("shape-rendering","crispEdges"));return C[b]}function h(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var m=this,k=null,n=new THREE.Projector,u=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,v,t,x,w,y,z,A,E=new THREE.Rectangle,D=new THREE.Rectangle,F=!1,G=new THREE.Color(16777215),N=new THREE.Color(16777215),Q=new THREE.Color(0),
-L=new THREE.Color(0),H=new THREE.Color(0),M,X=new THREE.Vector3,C=[],O=[],P,U,V,o=1;this.domElement=u;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(b){switch(b){case "high":o=1;break;case "low":o=0}};this.setSize=function(b,e){p=b;v=e;t=p/2;x=v/2;u.setAttribute("viewBox",-t+" "+-x+" "+p+" "+v);u.setAttribute("width",p);u.setAttribute("height",v);E.set(-t,-x,t,x)};this.clear=function(){for(;u.childNodes.length>0;)u.removeChild(u.childNodes[0])};
-this.render=function(b,f){var h,p,v,G,N,C,M,T;this.autoClear&&this.clear();m.info.render.vertices=0;m.info.render.faces=0;k=n.projectScene(b,f,this.sortElements);V=U=0;if(F=b.lights.length>0){M=b.lights;Q.setRGB(0,0,0);L.setRGB(0,0,0);H.setRGB(0,0,0);h=0;for(p=M.length;h<p;h++)v=M[h],G=v.color,v instanceof THREE.AmbientLight?(Q.r+=G.r,Q.g+=G.g,Q.b+=G.b):v instanceof THREE.DirectionalLight?(L.r+=G.r,L.g+=G.g,L.b+=G.b):v instanceof THREE.PointLight&&(H.r+=G.r,H.g+=G.g,H.b+=G.b)}h=0;for(p=k.length;h<
-p;h++)if(M=k[h],D.empty(),M instanceof THREE.RenderableParticle){w=M;w.x*=t;w.y*=-x;v=0;for(G=M.materials.length;v<G;)v++}else if(M instanceof THREE.RenderableLine){if(w=M.v1,y=M.v2,w.positionScreen.x*=t,w.positionScreen.y*=-x,y.positionScreen.x*=t,y.positionScreen.y*=-x,D.addPoint(w.positionScreen.x,w.positionScreen.y),D.addPoint(y.positionScreen.x,y.positionScreen.y),E.intersects(D)){v=0;for(G=M.materials.length;v<G;)if((T=M.materials[v++])&&T.opacity!=0){N=w;C=y;var Z=V++;O[Z]==null&&(O[Z]=document.createElementNS("http://www.w3.org/2000/svg",
-"line"),o==0&&O[Z].setAttribute("shape-rendering","crispEdges"));P=O[Z];P.setAttribute("x1",N.positionScreen.x);P.setAttribute("y1",N.positionScreen.y);P.setAttribute("x2",C.positionScreen.x);P.setAttribute("y2",C.positionScreen.y);T instanceof THREE.LineBasicMaterial&&(P.setAttribute("style","fill: none; stroke: "+T.color.getContextStyle()+"; stroke-width: "+T.linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+T.linecap+"; stroke-linejoin: "+T.linejoin),u.appendChild(P))}}}else if(M instanceof
-THREE.RenderableFace3){if(w=M.v1,y=M.v2,z=M.v3,w.positionScreen.x*=t,w.positionScreen.y*=-x,y.positionScreen.x*=t,y.positionScreen.y*=-x,z.positionScreen.x*=t,z.positionScreen.y*=-x,D.addPoint(w.positionScreen.x,w.positionScreen.y),D.addPoint(y.positionScreen.x,y.positionScreen.y),D.addPoint(z.positionScreen.x,z.positionScreen.y),E.intersects(D)){v=0;for(G=M.meshMaterials.length;v<G;)if(T=M.meshMaterials[v++],T instanceof THREE.MeshFaceMaterial){N=0;for(C=M.faceMaterials.length;N<C;)(T=M.faceMaterials[N++])&&
-T.opacity!=0&&c(w,y,z,M,T,b)}else T&&T.opacity!=0&&c(w,y,z,M,T,b)}}else if(M instanceof THREE.RenderableFace4&&(w=M.v1,y=M.v2,z=M.v3,A=M.v4,w.positionScreen.x*=t,w.positionScreen.y*=-x,y.positionScreen.x*=t,y.positionScreen.y*=-x,z.positionScreen.x*=t,z.positionScreen.y*=-x,A.positionScreen.x*=t,A.positionScreen.y*=-x,D.addPoint(w.positionScreen.x,w.positionScreen.y),D.addPoint(y.positionScreen.x,y.positionScreen.y),D.addPoint(z.positionScreen.x,z.positionScreen.y),D.addPoint(A.positionScreen.x,A.positionScreen.y),
-E.intersects(D))){v=0;for(G=M.meshMaterials.length;v<G;)if(T=M.meshMaterials[v++],T instanceof THREE.MeshFaceMaterial){N=0;for(C=M.faceMaterials.length;N<C;)(T=M.faceMaterials[N++])&&T.opacity!=0&&e(w,y,z,A,M,T,b)}else T&&T.opacity!=0&&e(w,y,z,A,M,T,b)}}};
+THREE.CanvasRenderer=function(b){function c(b){if(B!=b)w.globalAlpha=B=b}function e(b){if(D!=b){switch(b){case THREE.NormalBlending:w.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:w.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:w.globalCompositeOperation="darker"}D=b}}function f(b){if(E!=b)w.strokeStyle=E=b}function h(b){if(F!=b)w.fillStyle=F=b}var m=this,k=null,n=new THREE.Projector,b=b||{},u=b.canvas!==void 0?b.canvas:document.createElement("canvas"),
+p,v,t,x,w=u.getContext("2d"),y=new THREE.Color(0),z=0,B=1,D=0,E=null,F=null,G=null,N=null,Q=null,H,K,I,X,C=new THREE.RenderableVertex,O=new THREE.RenderableVertex,P,U,W,o,da,S,la,aa,ia,ka,ma,ca,ha=new THREE.Color(0),T=new THREE.Color(0),Z=new THREE.Color(0),ea=new THREE.Color(0),oa=new THREE.Color(0),xa=[],M,fa,na,ta,sa,Da,Ca,Fa,Ba,pa,L=new THREE.Rectangle,$=new THREE.Rectangle,V=new THREE.Rectangle,va=!1,ra=new THREE.Color,ja=new THREE.Color,ya=new THREE.Color,ua=new THREE.Color,qa=new THREE.Vector3,
+Ha,za,Ia,Y,Ea,ga,b=16;Ha=document.createElement("canvas");Ha.width=Ha.height=2;za=Ha.getContext("2d");za.fillStyle="rgba(0,0,0,1)";za.fillRect(0,0,2,2);Ia=za.getImageData(0,0,2,2);Y=Ia.data;Ea=document.createElement("canvas");Ea.width=Ea.height=b;ga=Ea.getContext("2d");ga.translate(-b/2,-b/2);ga.scale(b,b);b--;this.domElement=u;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(b,e){p=b;v=e;t=Math.floor(p/2);x=Math.floor(v/2);u.width=
+p;u.height=v;L.set(-t,-x,t,x);$.set(-t,-x,t,x);B=1;D=0;Q=N=G=F=E=null};this.setClearColor=function(b,e){y.copy(b);z=e;$.set(-t,-x,t,x)};this.setClearColorHex=function(b,e){y.setHex(b);z=e;$.set(-t,-x,t,x)};this.clear=function(){w.setTransform(1,0,0,-1,t,x);$.isEmpty()||($.minSelf(L),$.inflate(2),z<1&&w.clearRect(Math.floor($.getX()),Math.floor($.getY()),Math.floor($.getWidth()),Math.floor($.getHeight())),z>0&&(e(THREE.NormalBlending),c(1),h("rgba("+Math.floor(y.r*255)+","+Math.floor(y.g*255)+","+
+Math.floor(y.b*255)+","+z+")"),w.fillRect(Math.floor($.getX()),Math.floor($.getY()),Math.floor($.getWidth()),Math.floor($.getHeight()))),$.empty())};this.render=function(b,u){function p(b){var e,c,f,k=b.lights;ja.setRGB(0,0,0);ya.setRGB(0,0,0);ua.setRGB(0,0,0);b=0;for(e=k.length;b<e;b++)c=k[b],f=c.color,c instanceof THREE.AmbientLight?(ja.r+=f.r,ja.g+=f.g,ja.b+=f.b):c instanceof THREE.DirectionalLight?(ya.r+=f.r,ya.g+=f.g,ya.b+=f.b):c instanceof THREE.PointLight&&(ua.r+=f.r,ua.g+=f.g,ua.b+=f.b)}function v(b,
+e,c,f){var k,h,m,o,n=b.lights,b=0;for(k=n.length;b<k;b++)h=n[b],m=h.color,h instanceof THREE.DirectionalLight?(o=c.dot(h.position),o<=0||(o*=h.intensity,f.r+=m.r*o,f.g+=m.g*o,f.b+=m.b*o)):h instanceof THREE.PointLight&&(o=c.dot(qa.sub(h.position,e).normalize()),o<=0||(o*=h.distance==0?1:1-Math.min(e.distanceTo(h.position)/h.distance,1),o!=0&&(o*=h.intensity,f.r+=m.r*o,f.g+=m.g*o,f.b+=m.b*o)))}function y(b,k,m){c(m.opacity);e(m.blending);var o,n,u,p,ga,v;if(m instanceof THREE.ParticleBasicMaterial){if(m.map)p=
+m.map.image,ga=p.width>>1,v=p.height>>1,m=k.scale.x*t,u=k.scale.y*x,o=m*ga,n=u*v,V.set(b.x-o,b.y-n,b.x+o,b.y+n),L.intersects(V)&&(w.save(),w.translate(b.x,b.y),w.rotate(-k.rotation),w.scale(m,-u),w.translate(-ga,-v),w.drawImage(p,0,0),w.restore())}else m instanceof THREE.ParticleCanvasMaterial&&(o=k.scale.x*t,n=k.scale.y*x,V.set(b.x-o,b.y-n,b.x+o,b.y+n),L.intersects(V)&&(f(m.color.getContextStyle()),h(m.color.getContextStyle()),w.save(),w.translate(b.x,b.y),w.rotate(-k.rotation),w.scale(o,n),m.program(w),
+w.restore()))}function z(b,k,h,m){c(m.opacity);e(m.blending);w.beginPath();w.moveTo(b.positionScreen.x,b.positionScreen.y);w.lineTo(k.positionScreen.x,k.positionScreen.y);w.closePath();if(m instanceof THREE.LineBasicMaterial){b=m.linewidth;if(G!=b)w.lineWidth=G=b;b=m.linecap;if(N!=b)w.lineCap=N=b;b=m.linejoin;if(Q!=b)w.lineJoin=Q=b;f(m.color.getContextStyle());w.stroke();V.inflate(m.linewidth*2)}}function B(b,f,k,h,n,t,p,ga,w){m.info.render.vertices+=3;m.info.render.faces++;c(ga.opacity);e(ga.blending);
+P=b.positionScreen.x;U=b.positionScreen.y;W=f.positionScreen.x;o=f.positionScreen.y;da=k.positionScreen.x;S=k.positionScreen.y;E(P,U,W,o,da,S);if(ga instanceof THREE.MeshBasicMaterial)if(ga.map)ga.map.mapping instanceof THREE.UVMapping&&(ta=p.uvs[0],ab(P,U,W,o,da,S,ta[h].u,ta[h].v,ta[n].u,ta[n].v,ta[t].u,ta[t].v,ga.map));else if(ga.envMap){if(ga.envMap.mapping instanceof THREE.SphericalReflectionMapping)b=u.matrixWorldInverse,qa.copy(p.vertexNormalsWorld[0]),sa=(qa.x*b.n11+qa.y*b.n12+qa.z*b.n13)*
+0.5+0.5,Da=-(qa.x*b.n21+qa.y*b.n22+qa.z*b.n23)*0.5+0.5,qa.copy(p.vertexNormalsWorld[1]),Ca=(qa.x*b.n11+qa.y*b.n12+qa.z*b.n13)*0.5+0.5,Fa=-(qa.x*b.n21+qa.y*b.n22+qa.z*b.n23)*0.5+0.5,qa.copy(p.vertexNormalsWorld[2]),Ba=(qa.x*b.n11+qa.y*b.n12+qa.z*b.n13)*0.5+0.5,pa=-(qa.x*b.n21+qa.y*b.n22+qa.z*b.n23)*0.5+0.5,ab(P,U,W,o,da,S,sa,Da,Ca,Fa,Ba,pa,ga.envMap)}else ga.wireframe?La(ga.color,ga.wireframeLinewidth,ga.wireframeLinecap,ga.wireframeLinejoin):Ma(ga.color);else if(ga instanceof THREE.MeshLambertMaterial)ga.map&&
+!ga.wireframe&&(ga.map.mapping instanceof THREE.UVMapping&&(ta=p.uvs[0],ab(P,U,W,o,da,S,ta[h].u,ta[h].v,ta[n].u,ta[n].v,ta[t].u,ta[t].v,ga.map)),e(THREE.SubtractiveBlending)),va?!ga.wireframe&&ga.shading==THREE.SmoothShading&&p.vertexNormalsWorld.length==3?(T.r=Z.r=ea.r=ja.r,T.g=Z.g=ea.g=ja.g,T.b=Z.b=ea.b=ja.b,v(w,p.v1.positionWorld,p.vertexNormalsWorld[0],T),v(w,p.v2.positionWorld,p.vertexNormalsWorld[1],Z),v(w,p.v3.positionWorld,p.vertexNormalsWorld[2],ea),T.r=Math.max(0,Math.min(ga.color.r*T.r,
+1)),T.g=Math.max(0,Math.min(ga.color.g*T.g,1)),T.b=Math.max(0,Math.min(ga.color.b*T.b,1)),Z.r=Math.max(0,Math.min(ga.color.r*Z.r,1)),Z.g=Math.max(0,Math.min(ga.color.g*Z.g,1)),Z.b=Math.max(0,Math.min(ga.color.b*Z.b,1)),ea.r=Math.max(0,Math.min(ga.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(ga.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(ga.color.b*ea.b,1)),oa.r=(Z.r+ea.r)*0.5,oa.g=(Z.g+ea.g)*0.5,oa.b=(Z.b+ea.b)*0.5,na=Ya(T,Z,ea,oa),Va(P,U,W,o,da,S,0,0,1,0,0,1,na)):(ra.r=ja.r,ra.g=ja.g,ra.b=ja.b,v(w,p.centroidWorld,
+p.normalWorld,ra),ha.r=Math.max(0,Math.min(ga.color.r*ra.r,1)),ha.g=Math.max(0,Math.min(ga.color.g*ra.g,1)),ha.b=Math.max(0,Math.min(ga.color.b*ra.b,1)),ga.wireframe?La(ha,ga.wireframeLinewidth,ga.wireframeLinecap,ga.wireframeLinejoin):Ma(ha)):ga.wireframe?La(ga.color,ga.wireframeLinewidth,ga.wireframeLinecap,ga.wireframeLinejoin):Ma(ga.color);else if(ga instanceof THREE.MeshDepthMaterial)M=u.near,fa=u.far,T.r=T.g=T.b=1-Qa(b.positionScreen.z,M,fa),Z.r=Z.g=Z.b=1-Qa(f.positionScreen.z,M,fa),ea.r=ea.g=
+ea.b=1-Qa(k.positionScreen.z,M,fa),oa.r=(Z.r+ea.r)*0.5,oa.g=(Z.g+ea.g)*0.5,oa.b=(Z.b+ea.b)*0.5,na=Ya(T,Z,ea,oa),Va(P,U,W,o,da,S,0,0,1,0,0,1,na);else if(ga instanceof THREE.MeshNormalMaterial)ha.r=Wa(p.normalWorld.x),ha.g=Wa(p.normalWorld.y),ha.b=Wa(p.normalWorld.z),ga.wireframe?La(ha,ga.wireframeLinewidth,ga.wireframeLinecap,ga.wireframeLinejoin):Ma(ha)}function D(b,f,k,h,n,ga,t,p,w){m.info.render.vertices+=4;m.info.render.faces++;c(p.opacity);e(p.blending);if(p.map||p.envMap)B(b,f,h,0,1,3,t,p,w),
+B(n,k,ga,1,2,3,t,p,w);else if(P=b.positionScreen.x,U=b.positionScreen.y,W=f.positionScreen.x,o=f.positionScreen.y,da=k.positionScreen.x,S=k.positionScreen.y,la=h.positionScreen.x,aa=h.positionScreen.y,ia=n.positionScreen.x,ka=n.positionScreen.y,ma=ga.positionScreen.x,ca=ga.positionScreen.y,p instanceof THREE.MeshBasicMaterial)F(P,U,W,o,da,S,la,aa),p.wireframe?La(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Ma(p.color);else if(p instanceof THREE.MeshLambertMaterial)va?!p.wireframe&&
+p.shading==THREE.SmoothShading&&t.vertexNormalsWorld.length==4?(T.r=Z.r=ea.r=oa.r=ja.r,T.g=Z.g=ea.g=oa.g=ja.g,T.b=Z.b=ea.b=oa.b=ja.b,v(w,t.v1.positionWorld,t.vertexNormalsWorld[0],T),v(w,t.v2.positionWorld,t.vertexNormalsWorld[1],Z),v(w,t.v4.positionWorld,t.vertexNormalsWorld[3],ea),v(w,t.v3.positionWorld,t.vertexNormalsWorld[2],oa),T.r=Math.max(0,Math.min(p.color.r*T.r,1)),T.g=Math.max(0,Math.min(p.color.g*T.g,1)),T.b=Math.max(0,Math.min(p.color.b*T.b,1)),Z.r=Math.max(0,Math.min(p.color.r*Z.r,1)),
+Z.g=Math.max(0,Math.min(p.color.g*Z.g,1)),Z.b=Math.max(0,Math.min(p.color.b*Z.b,1)),ea.r=Math.max(0,Math.min(p.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(p.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(p.color.b*ea.b,1)),oa.r=Math.max(0,Math.min(p.color.r*oa.r,1)),oa.g=Math.max(0,Math.min(p.color.g*oa.g,1)),oa.b=Math.max(0,Math.min(p.color.b*oa.b,1)),na=Ya(T,Z,ea,oa),E(P,U,W,o,la,aa),Va(P,U,W,o,la,aa,0,0,1,0,0,1,na),E(ia,ka,da,S,ma,ca),Va(ia,ka,da,S,ma,ca,1,0,1,1,0,1,na)):(ra.r=ja.r,ra.g=ja.g,ra.b=ja.b,
+v(w,t.centroidWorld,t.normalWorld,ra),ha.r=Math.max(0,Math.min(p.color.r*ra.r,1)),ha.g=Math.max(0,Math.min(p.color.g*ra.g,1)),ha.b=Math.max(0,Math.min(p.color.b*ra.b,1)),F(P,U,W,o,da,S,la,aa),p.wireframe?La(ha,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Ma(ha)):(F(P,U,W,o,da,S,la,aa),p.wireframe?La(p.color,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Ma(p.color));else if(p instanceof THREE.MeshNormalMaterial)ha.r=Wa(t.normalWorld.x),ha.g=Wa(t.normalWorld.y),ha.b=Wa(t.normalWorld.z),
+F(P,U,W,o,da,S,la,aa),p.wireframe?La(ha,p.wireframeLinewidth,p.wireframeLinecap,p.wireframeLinejoin):Ma(ha);else if(p instanceof THREE.MeshDepthMaterial)M=u.near,fa=u.far,T.r=T.g=T.b=1-Qa(b.positionScreen.z,M,fa),Z.r=Z.g=Z.b=1-Qa(f.positionScreen.z,M,fa),ea.r=ea.g=ea.b=1-Qa(h.positionScreen.z,M,fa),oa.r=oa.g=oa.b=1-Qa(k.positionScreen.z,M,fa),na=Ya(T,Z,ea,oa),E(P,U,W,o,la,aa),Va(P,U,W,o,la,aa,0,0,1,0,0,1,na),E(ia,ka,da,S,ma,ca),Va(ia,ka,da,S,ma,ca,1,0,1,1,0,1,na)}function E(b,e,c,f,k,h){w.beginPath();
+w.moveTo(b,e);w.lineTo(c,f);w.lineTo(k,h);w.lineTo(b,e);w.closePath()}function F(b,e,c,f,k,h,m,o){w.beginPath();w.moveTo(b,e);w.lineTo(c,f);w.lineTo(k,h);w.lineTo(m,o);w.lineTo(b,e);w.closePath()}function La(b,e,c,k){if(G!=e)w.lineWidth=G=e;if(N!=c)w.lineCap=N=c;if(Q!=k)w.lineJoin=Q=k;f(b.getContextStyle());w.stroke();V.inflate(e*2)}function Ma(b){h(b.getContextStyle());w.fill()}function ab(b,e,c,f,k,m,o,n,p,ga,t,u,v){if(v.image.width!=0){if(v.needsUpdate==!0||xa[v.id]==void 0){var x=v.wrapS==THREE.RepeatWrapping,
+Pa=v.wrapT==THREE.RepeatWrapping;xa[v.id]=w.createPattern(v.image,x&&Pa?"repeat":x&&!Pa?"repeat-x":!x&&Pa?"repeat-y":"no-repeat");v.needsUpdate=!1}h(xa[v.id]);var x=v.offset.x/v.repeat.x,Pa=v.offset.y/v.repeat.y,L=(v.image.width-1)*v.repeat.x,v=(v.image.height-1)*v.repeat.y,o=(o+x)*L,n=(n+Pa)*v,p=(p+x)*L,ga=(ga+Pa)*v,t=(t+x)*L,u=(u+Pa)*v;c-=b;f-=e;k-=b;m-=e;p-=o;ga-=n;t-=o;u-=n;x=1/(p*u-t*ga);v=(u*c-ga*k)*x;ga=(u*f-ga*m)*x;c=(p*k-t*c)*x;f=(p*m-t*f)*x;b=b-v*o-c*n;e=e-ga*o-f*n;w.save();w.transform(v,
+ga,c,f,b,e);w.fill();w.restore()}}function Va(b,e,c,f,k,h,m,o,n,p,ga,t,u){var v,x;v=u.width-1;x=u.height-1;m*=v;o*=x;n*=v;p*=x;ga*=v;t*=x;c-=b;f-=e;k-=b;h-=e;n-=m;p-=o;ga-=m;t-=o;x=1/(n*t-ga*p);v=(t*c-p*k)*x;p=(t*f-p*h)*x;c=(n*k-ga*c)*x;f=(n*h-ga*f)*x;b=b-v*m-c*o;e=e-p*m-f*o;w.save();w.transform(v,p,c,f,b,e);w.clip();w.drawImage(u,0,0);w.restore()}function Ya(b,e,c,f){var k=~~(b.r*255),h=~~(b.g*255),b=~~(b.b*255),m=~~(e.r*255),o=~~(e.g*255),e=~~(e.b*255),n=~~(c.r*255),p=~~(c.g*255),c=~~(c.b*255),
+t=~~(f.r*255),u=~~(f.g*255),f=~~(f.b*255);Y[0]=k<0?0:k>255?255:k;Y[1]=h<0?0:h>255?255:h;Y[2]=b<0?0:b>255?255:b;Y[4]=m<0?0:m>255?255:m;Y[5]=o<0?0:o>255?255:o;Y[6]=e<0?0:e>255?255:e;Y[8]=n<0?0:n>255?255:n;Y[9]=p<0?0:p>255?255:p;Y[10]=c<0?0:c>255?255:c;Y[12]=t<0?0:t>255?255:t;Y[13]=u<0?0:u>255?255:u;Y[14]=f<0?0:f>255?255:f;za.putImageData(Ia,0,0);ga.drawImage(Ha,0,0);return Ea}function Qa(b,e,c){b=(b-e)/(c-e);return b*b*(3-2*b)}function Wa(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}function Na(b,e){var c=e.x-
+b.x,f=e.y-b.y,k=c*c+f*f;k!=0&&(k=1/Math.sqrt(k),c*=k,f*=k,e.x+=c,e.y+=f,b.x-=c,b.y-=f)}var Za,cb,wa,Ga,Oa,Xa,$a,Aa;this.autoClear?this.clear():w.setTransform(1,0,0,-1,t,x);m.info.render.vertices=0;m.info.render.faces=0;k=n.projectScene(b,u,this.sortElements);(va=b.lights.length>0)&&p(b);Za=0;for(cb=k.length;Za<cb;Za++){wa=k[Za];V.empty();if(wa instanceof THREE.RenderableParticle){H=wa;H.x*=t;H.y*=x;Ga=0;for(Oa=wa.materials.length;Ga<Oa;)Aa=wa.materials[Ga++],Aa.opacity!=0&&y(H,wa,Aa,b)}else if(wa instanceof
+THREE.RenderableLine){if(H=wa.v1,K=wa.v2,H.positionScreen.x*=t,H.positionScreen.y*=x,K.positionScreen.x*=t,K.positionScreen.y*=x,V.addPoint(H.positionScreen.x,H.positionScreen.y),V.addPoint(K.positionScreen.x,K.positionScreen.y),L.intersects(V)){Ga=0;for(Oa=wa.materials.length;Ga<Oa;)Aa=wa.materials[Ga++],Aa.opacity!=0&&z(H,K,wa,Aa,b)}}else if(wa instanceof THREE.RenderableFace3){if(H=wa.v1,K=wa.v2,I=wa.v3,H.positionScreen.x*=t,H.positionScreen.y*=x,K.positionScreen.x*=t,K.positionScreen.y*=x,I.positionScreen.x*=
+t,I.positionScreen.y*=x,wa.overdraw&&(Na(H.positionScreen,K.positionScreen),Na(K.positionScreen,I.positionScreen),Na(I.positionScreen,H.positionScreen)),V.add3Points(H.positionScreen.x,H.positionScreen.y,K.positionScreen.x,K.positionScreen.y,I.positionScreen.x,I.positionScreen.y),L.intersects(V)){Ga=0;for(Oa=wa.meshMaterials.length;Ga<Oa;)if(Aa=wa.meshMaterials[Ga++],Aa instanceof THREE.MeshFaceMaterial){Xa=0;for($a=wa.faceMaterials.length;Xa<$a;)(Aa=wa.faceMaterials[Xa++])&&Aa.opacity!=0&&B(H,K,
+I,0,1,2,wa,Aa,b)}else Aa.opacity!=0&&B(H,K,I,0,1,2,wa,Aa,b)}}else if(wa instanceof THREE.RenderableFace4&&(H=wa.v1,K=wa.v2,I=wa.v3,X=wa.v4,H.positionScreen.x*=t,H.positionScreen.y*=x,K.positionScreen.x*=t,K.positionScreen.y*=x,I.positionScreen.x*=t,I.positionScreen.y*=x,X.positionScreen.x*=t,X.positionScreen.y*=x,C.positionScreen.copy(K.positionScreen),O.positionScreen.copy(X.positionScreen),wa.overdraw&&(Na(H.positionScreen,K.positionScreen),Na(K.positionScreen,X.positionScreen),Na(X.positionScreen,
+H.positionScreen),Na(I.positionScreen,C.positionScreen),Na(I.positionScreen,O.positionScreen)),V.addPoint(H.positionScreen.x,H.positionScreen.y),V.addPoint(K.positionScreen.x,K.positionScreen.y),V.addPoint(I.positionScreen.x,I.positionScreen.y),V.addPoint(X.positionScreen.x,X.positionScreen.y),L.intersects(V))){Ga=0;for(Oa=wa.meshMaterials.length;Ga<Oa;)if(Aa=wa.meshMaterials[Ga++],Aa instanceof THREE.MeshFaceMaterial){Xa=0;for($a=wa.faceMaterials.length;Xa<$a;)(Aa=wa.faceMaterials[Xa++])&&Aa.opacity!=
+0&&D(H,K,I,X,C,O,wa,Aa,b)}else Aa.opacity!=0&&D(H,K,I,X,C,O,wa,Aa,b)}$.addRectangle(V)}w.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function b(b,e,c){var f,k,h,m;f=0;for(k=b.lights.length;f<k;f++)h=b.lights[f],h instanceof THREE.DirectionalLight?(m=e.normalWorld.dot(h.position)*h.intensity,m>0&&(c.r+=h.color.r*m,c.g+=h.color.g*m,c.b+=h.color.b*m)):h instanceof THREE.PointLight&&(X.sub(h.position,e.centroidWorld),X.normalize(),m=e.normalWorld.dot(X)*h.intensity,m>0&&(c.r+=h.color.r*m,c.g+=h.color.g*m,c.b+=h.color.b*m))}function c(e,c,k,o,n,p){m.info.render.vertices+=3;m.info.render.faces++;P=f(U++);
+P.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+"z");n instanceof THREE.MeshBasicMaterial?G.copy(n.color):n instanceof THREE.MeshLambertMaterial?F?(N.r=Q.r,N.g=Q.g,N.b=Q.b,b(p,o,N),G.r=Math.max(0,Math.min(n.color.r*N.r,1)),G.g=Math.max(0,Math.min(n.color.g*N.g,1)),G.b=Math.max(0,Math.min(n.color.b*N.b,1))):G.copy(n.color):n instanceof THREE.MeshDepthMaterial?(I=1-n.__2near/(n.__farPlusNear-
+o.z*n.__farMinusNear),G.setRGB(I,I,I)):n instanceof THREE.MeshNormalMaterial&&G.setRGB(h(o.normalWorld.x),h(o.normalWorld.y),h(o.normalWorld.z));n.wireframe?P.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+n.wireframeLinewidth+"; stroke-opacity: "+n.opacity+"; stroke-linecap: "+n.wireframeLinecap+"; stroke-linejoin: "+n.wireframeLinejoin):P.setAttribute("style","fill: "+G.getContextStyle()+"; fill-opacity: "+n.opacity);u.appendChild(P)}function e(e,c,k,o,n,p,t){m.info.render.vertices+=
+4;m.info.render.faces++;P=f(U++);P.setAttribute("d","M "+e.positionScreen.x+" "+e.positionScreen.y+" L "+c.positionScreen.x+" "+c.positionScreen.y+" L "+k.positionScreen.x+","+k.positionScreen.y+" L "+o.positionScreen.x+","+o.positionScreen.y+"z");p instanceof THREE.MeshBasicMaterial?G.copy(p.color):p instanceof THREE.MeshLambertMaterial?F?(N.r=Q.r,N.g=Q.g,N.b=Q.b,b(t,n,N),G.r=Math.max(0,Math.min(p.color.r*N.r,1)),G.g=Math.max(0,Math.min(p.color.g*N.g,1)),G.b=Math.max(0,Math.min(p.color.b*N.b,1))):
+G.copy(p.color):p instanceof THREE.MeshDepthMaterial?(I=1-p.__2near/(p.__farPlusNear-n.z*p.__farMinusNear),G.setRGB(I,I,I)):p instanceof THREE.MeshNormalMaterial&&G.setRGB(h(n.normalWorld.x),h(n.normalWorld.y),h(n.normalWorld.z));p.wireframe?P.setAttribute("style","fill: none; stroke: "+G.getContextStyle()+"; stroke-width: "+p.wireframeLinewidth+"; stroke-opacity: "+p.opacity+"; stroke-linecap: "+p.wireframeLinecap+"; stroke-linejoin: "+p.wireframeLinejoin):P.setAttribute("style","fill: "+G.getContextStyle()+
+"; fill-opacity: "+p.opacity);u.appendChild(P)}function f(b){C[b]==null&&(C[b]=document.createElementNS("http://www.w3.org/2000/svg","path"),o==0&&C[b].setAttribute("shape-rendering","crispEdges"));return C[b]}function h(b){b=(b+1)*0.5;return b<0?0:b>1?1:b}var m=this,k=null,n=new THREE.Projector,u=document.createElementNS("http://www.w3.org/2000/svg","svg"),p,v,t,x,w,y,z,B,D=new THREE.Rectangle,E=new THREE.Rectangle,F=!1,G=new THREE.Color(16777215),N=new THREE.Color(16777215),Q=new THREE.Color(0),
+H=new THREE.Color(0),K=new THREE.Color(0),I,X=new THREE.Vector3,C=[],O=[],P,U,W,o=1;this.domElement=u;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setQuality=function(b){switch(b){case "high":o=1;break;case "low":o=0}};this.setSize=function(b,e){p=b;v=e;t=p/2;x=v/2;u.setAttribute("viewBox",-t+" "+-x+" "+p+" "+v);u.setAttribute("width",p);u.setAttribute("height",v);D.set(-t,-x,t,x)};this.clear=function(){for(;u.childNodes.length>0;)u.removeChild(u.childNodes[0])};
+this.render=function(b,f){var h,p,v,G,N,C,I,T;this.autoClear&&this.clear();m.info.render.vertices=0;m.info.render.faces=0;k=n.projectScene(b,f,this.sortElements);W=U=0;if(F=b.lights.length>0){I=b.lights;Q.setRGB(0,0,0);H.setRGB(0,0,0);K.setRGB(0,0,0);h=0;for(p=I.length;h<p;h++)v=I[h],G=v.color,v instanceof THREE.AmbientLight?(Q.r+=G.r,Q.g+=G.g,Q.b+=G.b):v instanceof THREE.DirectionalLight?(H.r+=G.r,H.g+=G.g,H.b+=G.b):v instanceof THREE.PointLight&&(K.r+=G.r,K.g+=G.g,K.b+=G.b)}h=0;for(p=k.length;h<
+p;h++)if(I=k[h],E.empty(),I instanceof THREE.RenderableParticle){w=I;w.x*=t;w.y*=-x;v=0;for(G=I.materials.length;v<G;)v++}else if(I instanceof THREE.RenderableLine){if(w=I.v1,y=I.v2,w.positionScreen.x*=t,w.positionScreen.y*=-x,y.positionScreen.x*=t,y.positionScreen.y*=-x,E.addPoint(w.positionScreen.x,w.positionScreen.y),E.addPoint(y.positionScreen.x,y.positionScreen.y),D.intersects(E)){v=0;for(G=I.materials.length;v<G;)if((T=I.materials[v++])&&T.opacity!=0){N=w;C=y;var Z=W++;O[Z]==null&&(O[Z]=document.createElementNS("http://www.w3.org/2000/svg",
+"line"),o==0&&O[Z].setAttribute("shape-rendering","crispEdges"));P=O[Z];P.setAttribute("x1",N.positionScreen.x);P.setAttribute("y1",N.positionScreen.y);P.setAttribute("x2",C.positionScreen.x);P.setAttribute("y2",C.positionScreen.y);T instanceof THREE.LineBasicMaterial&&(P.setAttribute("style","fill: none; stroke: "+T.color.getContextStyle()+"; stroke-width: "+T.linewidth+"; stroke-opacity: "+T.opacity+"; stroke-linecap: "+T.linecap+"; stroke-linejoin: "+T.linejoin),u.appendChild(P))}}}else if(I instanceof
+THREE.RenderableFace3){if(w=I.v1,y=I.v2,z=I.v3,w.positionScreen.x*=t,w.positionScreen.y*=-x,y.positionScreen.x*=t,y.positionScreen.y*=-x,z.positionScreen.x*=t,z.positionScreen.y*=-x,E.addPoint(w.positionScreen.x,w.positionScreen.y),E.addPoint(y.positionScreen.x,y.positionScreen.y),E.addPoint(z.positionScreen.x,z.positionScreen.y),D.intersects(E)){v=0;for(G=I.meshMaterials.length;v<G;)if(T=I.meshMaterials[v++],T instanceof THREE.MeshFaceMaterial){N=0;for(C=I.faceMaterials.length;N<C;)(T=I.faceMaterials[N++])&&
+T.opacity!=0&&c(w,y,z,I,T,b)}else T&&T.opacity!=0&&c(w,y,z,I,T,b)}}else if(I instanceof THREE.RenderableFace4&&(w=I.v1,y=I.v2,z=I.v3,B=I.v4,w.positionScreen.x*=t,w.positionScreen.y*=-x,y.positionScreen.x*=t,y.positionScreen.y*=-x,z.positionScreen.x*=t,z.positionScreen.y*=-x,B.positionScreen.x*=t,B.positionScreen.y*=-x,E.addPoint(w.positionScreen.x,w.positionScreen.y),E.addPoint(y.positionScreen.x,y.positionScreen.y),E.addPoint(z.positionScreen.x,z.positionScreen.y),E.addPoint(B.positionScreen.x,B.positionScreen.y),
+D.intersects(E))){v=0;for(G=I.meshMaterials.length;v<G;)if(T=I.meshMaterials[v++],T instanceof THREE.MeshFaceMaterial){N=0;for(C=I.faceMaterials.length;N<C;)(T=I.faceMaterials[N++])&&T.opacity!=0&&e(w,y,z,B,I,T,b)}else T&&T.opacity!=0&&e(w,y,z,B,I,T,b)}}};
 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_vertex:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform vec4 offsetRepeat;\n#endif",map_pars_fragment:"#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif",map_vertex:"#ifdef USE_MAP\nvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif",map_fragment:"#ifdef USE_MAP\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif",
@@ -221,120 +221,120 @@ THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.
 THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle,THREE.UniformsLib.shadowmap]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_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;",
 THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,
 "}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask  = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}};
-THREE.WebGLRenderer=function(b){function c(b,e,c){var f,k,h,m=b.vertices,n=m.length,t=b.colors,p=t.length,u=b.__vertexArray,w=b.__colorArray,v=b.__sortArray,x=b.__dirtyVertices,J=b.__dirtyColors,y=b.__webglCustomAttributes,W,z;if(y)for(W in y)y[W].offset=0;if(c.sortParticles){qa.multiplySelf(c.matrixWorld);for(f=0;f<n;f++)k=m[f].position,xa.copy(k),qa.multiplyVector3(xa),v[f]=[xa.z,f];v.sort(function(b,e){return e[0]-b[0]});for(f=0;f<n;f++)k=m[v[f][1]].position,h=f*3,u[h]=k.x,u[h+1]=k.y,u[h+2]=k.z;
-for(f=0;f<p;f++)h=f*3,color=t[v[f][1]],w[h]=color.r,w[h+1]=color.g,w[h+2]=color.b;if(y)for(W in y){f=y[W];t=f.value.length;for(h=0;h<t;h++){index=v[h][1];p=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[p]=f.value[index]}else{if(f.boundTo===void 0||f.boundTo==="vertices")z=f.value[index];f.size===2?(f.array[p]=z.x,f.array[p+1]=z.y):f.size===3?f.type==="c"?(f.array[p]=z.r,f.array[p+1]=z.g,f.array[p+2]=z.b):(f.array[p]=z.x,f.array[p+1]=z.y,f.array[p+2]=z.z):(f.array[p]=
-z.x,f.array[p+1]=z.y,f.array[p+2]=z.z,f.array[p+3]=z.w)}f.offset+=f.size}}}else{if(x)for(f=0;f<n;f++)k=m[f].position,h=f*3,u[h]=k.x,u[h+1]=k.y,u[h+2]=k.z;if(J)for(f=0;f<p;f++)color=t[f],h=f*3,w[h]=color.r,w[h+1]=color.g,w[h+2]=color.b;if(y)for(W in y)if(f=y[W],f.__original.needsUpdate){t=f.value.length;for(h=0;h<t;h++){p=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[p]=f.value[h]}else{if(f.boundTo===void 0||f.boundTo==="vertices")z=f.value[h];f.size===2?(f.array[p]=
-z.x,f.array[p+1]=z.y):f.size===3?f.type==="c"?(f.array[p]=z.r,f.array[p+1]=z.g,f.array[p+2]=z.b):(f.array[p]=z.x,f.array[p+1]=z.y,f.array[p+2]=z.z):(f.array[p]=z.x,f.array[p+1]=z.y,f.array[p+2]=z.z,f.array[p+3]=z.w)}f.offset+=f.size}}}if(x||c.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,b.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,u,e);if(J||c.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,b.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,w,e);if(y)for(W in y)if(f=y[W],f.__original.needsUpdate||c.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,
-f.buffer),o.bufferData(o.ARRAY_BUFFER,f.array,e)}function e(b,e,c,f,k){f.program||V.initMaterial(f,e,c,k);if(f.morphTargets&&!k.__webglMorphTargetInfluences){k.__webglMorphTargetInfluences=new Float32Array(V.maxMorphTargets);for(var h=0,m=V.maxMorphTargets;h<m;h++)k.__webglMorphTargetInfluences[h]=0}var h=f.program,m=h.uniforms,n=f.uniforms;h!=S&&(o.useProgram(h),S=h);o.uniformMatrix4fv(m.projectionMatrix,!1,ua);if(c&&f.fog)if(n.fogColor.value=c.color,c instanceof THREE.Fog)n.fogNear.value=c.near,
-n.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)n.fogDensity.value=c.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){var t,p,u,w=0,v=0,x=0,J,y,W,z=Ea,A=z.directional.colors,ha=z.directional.positions,E=z.point.colors,D=z.point.positions,F=z.point.distances,G=0,K=0,c=p=W=0;for(t=e.length;c<t;c++)if(p=e[c],u=p.color,J=p.position,y=p.intensity,W=p.distance,p instanceof THREE.AmbientLight)w+=u.r,v+=u.g,x+=u.b;else if(p instanceof THREE.DirectionalLight)W=
-G*3,A[W]=u.r*y,A[W+1]=u.g*y,A[W+2]=u.b*y,ha[W]=J.x,ha[W+1]=J.y,ha[W+2]=J.z,G+=1;else if(p instanceof THREE.SpotLight)W=G*3,A[W]=u.r*y,A[W+1]=u.g*y,A[W+2]=u.b*y,u=1/J.length(),ha[W]=J.x*u,ha[W+1]=J.y*u,ha[W+2]=J.z*u,G+=1;else if(p instanceof THREE.PointLight)p=K*3,E[p]=u.r*y,E[p+1]=u.g*y,E[p+2]=u.b*y,D[p]=J.x,D[p+1]=J.y,D[p+2]=J.z,F[K]=W,K+=1;c=G*3;for(t=A.length;c<t;c++)A[c]=0;c=K*3;for(t=E.length;c<t;c++)E[c]=0;z.point.length=K;z.directional.length=G;z.ambient[0]=w;z.ambient[1]=v;z.ambient[2]=x;
-e=Ea;n.enableLighting.value=e.directional.length+e.point.length;n.ambientLightColor.value=e.ambient;n.directionalLightColor.value=e.directional.colors;n.directionalLightDirection.value=e.directional.positions;n.pointLightColor.value=e.point.colors;n.pointLightPosition.value=e.point.positions;n.pointLightDistance.value=e.point.distances}if(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial)n.diffuse.value=f.color,n.opacity.value=f.opacity,
-(n.map.texture=f.map)&&n.offsetRepeat.value.set(f.map.offset.x,f.map.offset.y,f.map.repeat.x,f.map.repeat.y),n.lightMap.texture=f.lightMap,n.envMap.texture=f.envMap,n.reflectivity.value=f.reflectivity,n.refractionRatio.value=f.refractionRatio,n.combine.value=f.combine,n.useRefract.value=f.envMap&&f.envMap.mapping instanceof THREE.CubeRefractionMapping;if(f instanceof THREE.LineBasicMaterial)n.diffuse.value=f.color,n.opacity.value=f.opacity;else if(f instanceof THREE.ParticleBasicMaterial)n.psColor.value=
-f.color,n.opacity.value=f.opacity,n.size.value=f.size,n.scale.value=Da.height/2,n.map.texture=f.map;else if(f instanceof THREE.MeshPhongMaterial)n.ambient.value=f.ambient,n.specular.value=f.specular,n.shininess.value=f.shininess;else if(f instanceof THREE.MeshDepthMaterial)n.mNear.value=b.near,n.mFar.value=b.far,n.opacity.value=f.opacity;else if(f instanceof THREE.MeshNormalMaterial)n.opacity.value=f.opacity;if(k.receiveShadow&&!f._shadowPass&&n.shadowMatrix){for(e=0;e<ia.length;e++)n.shadowMatrix.value[e]=
-ia[e],n.shadowMap.texture[e]=V.shadowMap[e];n.shadowDarkness.value=V.shadowMapDarkness;n.shadowBias.value=V.shadowMapBias}e=f.uniformsList;n=0;for(c=e.length;n<c;n++)if(v=h.uniforms[e[n][1]])if(w=e[n][0],x=w.type,t=w.value,x=="i")o.uniform1i(v,t);else if(x=="f")o.uniform1f(v,t);else if(x=="v2")o.uniform2f(v,t.x,t.y);else if(x=="v3")o.uniform3f(v,t.x,t.y,t.z);else if(x=="v4")o.uniform4f(v,t.x,t.y,t.z,t.w);else if(x=="c")o.uniform3f(v,t.r,t.g,t.b);else if(x=="fv1")o.uniform1fv(v,t);else if(x=="fv")o.uniform3fv(v,
-t);else if(x=="v3v"){if(!w._array)w._array=new Float32Array(3*t.length);x=0;for(J=t.length;x<J;x++)z=x*3,w._array[z]=t[x].x,w._array[z+1]=t[x].y,w._array[z+2]=t[x].z;o.uniform3fv(v,w._array)}else if(x=="m4"){if(!w._array)w._array=new Float32Array(16);t.flattenToArray(w._array);o.uniformMatrix4fv(v,!1,w._array)}else if(x=="m4v"){if(!w._array)w._array=new Float32Array(16*t.length);x=0;for(J=t.length;x<J;x++)t[x].flattenToArrayOffset(w._array,x*16);o.uniformMatrix4fv(v,!1,w._array)}else if(x=="t"){if(o.uniform1i(v,
-t),v=w.texture)if(v.image instanceof Array&&v.image.length==6){if(w=v,w.image.length==6)if(w.needsUpdate){if(!w.image.__webglTextureCube)w.image.__webglTextureCube=o.createTexture();o.activeTexture(o.TEXTURE0+t);o.bindTexture(o.TEXTURE_CUBE_MAP,w.image.__webglTextureCube);for(t=0;t<6;t++)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+t,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,w.image[t]);H(o.TEXTURE_CUBE_MAP,w,w.image[0]);w.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+t),o.bindTexture(o.TEXTURE_CUBE_MAP,w.image.__webglTextureCube)}else v instanceof
-THREE.WebGLRenderTargetCube?(w=v,o.activeTexture(o.TEXTURE0+t),o.bindTexture(o.TEXTURE_CUBE_MAP,w.__webglTexture)):M(v,t)}else if(x=="tv"){if(!w._array){w._array=[];x=0;for(J=w.texture.length;x<J;x++)w._array[x]=t+x}o.uniform1iv(v,w._array);x=0;for(J=w.texture.length;x<J;x++)(v=w.texture[x])&&M(v,w._array[x])}o.uniformMatrix4fv(m.modelViewMatrix,!1,k._modelViewMatrixArray);m.normalMatrix&&o.uniformMatrix3fv(m.normalMatrix,!1,k._normalMatrixArray);(f instanceof THREE.ShaderMaterial||f instanceof THREE.MeshPhongMaterial||
-f.envMap)&&m.cameraPosition!==null&&o.uniform3f(m.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.ShaderMaterial||f.envMap||f.skinning||k.receiveShadow)&&m.objectMatrix!==null&&o.uniformMatrix4fv(m.objectMatrix,!1,k._objectMatrixArray);(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.ShaderMaterial||f.skinning)&&m.viewMatrix!==null&&o.uniformMatrix4fv(m.viewMatrix,!1,sa);f.skinning&&(o.uniformMatrix4fv(m.cameraInverseMatrix,
-!1,sa),o.uniformMatrix4fv(m.boneGlobalMatrices,!1,k.boneMatrices));return h}function f(b,c,f,k,h,m){if(k.opacity!=0){var n,b=e(b,c,f,k,m).attributes;if(!k.morphTargets&&b.position>=0)o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(b.position,3,o.FLOAT,!1,0,0);else if(m.morphTargetBase){c=k.program.attributes;m.morphTargetBase!==-1?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[m.morphTargetBase]),o.vertexAttribPointer(c.position,3,o.FLOAT,!1,0,0)):c.position>=0&&
-(o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(c.position,3,o.FLOAT,!1,0,0));if(m.morphTargetForcedOrder.length)for(var f=0,t=m.morphTargetForcedOrder,p=m.morphTargetInfluences;f<k.numSupportedMorphTargets&&f<t.length;)o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[t[f]]),o.vertexAttribPointer(c["morphTarget"+f],3,o.FLOAT,!1,0,0),m.__webglMorphTargetInfluences[f]=p[t[f]],f++;else{var t=[],w=-1,u=0,p=m.morphTargetInfluences,v,x=p.length,f=0;for(m.morphTargetBase!==
--1&&(t[m.morphTargetBase]=!0);f<k.numSupportedMorphTargets;){for(v=0;v<x;v++)!t[v]&&p[v]>w&&(u=v,w=p[u]);o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[u]);o.vertexAttribPointer(c["morphTarget"+f],3,o.FLOAT,!1,0,0);m.__webglMorphTargetInfluences[f]=w;t[u]=1;w=-1;f++}}k.program.uniforms.morphTargetInfluences!==null&&o.uniform1fv(k.program.uniforms.morphTargetInfluences,m.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(n in h.__webglCustomAttributes)b[n]>=0&&(c=h.__webglCustomAttributes[n],
+THREE.WebGLRenderer=function(b){function c(b,e,c){var f,k,h,m=b.vertices,n=m.length,p=b.colors,t=p.length,u=b.__vertexArray,w=b.__colorArray,v=b.__sortArray,x=b.__dirtyVertices,L=b.__dirtyColors,V=b.__webglCustomAttributes,y,z;if(V)for(y in V)V[y].offset=0;if(c.sortParticles){ta.multiplySelf(c.matrixWorld);for(f=0;f<n;f++)k=m[f].position,Ca.copy(k),ta.multiplyVector3(Ca),v[f]=[Ca.z,f];v.sort(function(b,e){return e[0]-b[0]});for(f=0;f<n;f++)k=m[v[f][1]].position,h=f*3,u[h]=k.x,u[h+1]=k.y,u[h+2]=k.z;
+for(f=0;f<t;f++)h=f*3,color=p[v[f][1]],w[h]=color.r,w[h+1]=color.g,w[h+2]=color.b;if(V)for(y in V){f=V[y];p=f.value.length;for(h=0;h<p;h++){index=v[h][1];t=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[t]=f.value[index]}else{if(f.boundTo===void 0||f.boundTo==="vertices")z=f.value[index];f.size===2?(f.array[t]=z.x,f.array[t+1]=z.y):f.size===3?f.type==="c"?(f.array[t]=z.r,f.array[t+1]=z.g,f.array[t+2]=z.b):(f.array[t]=z.x,f.array[t+1]=z.y,f.array[t+2]=z.z):(f.array[t]=
+z.x,f.array[t+1]=z.y,f.array[t+2]=z.z,f.array[t+3]=z.w)}f.offset+=f.size}}}else{if(x)for(f=0;f<n;f++)k=m[f].position,h=f*3,u[h]=k.x,u[h+1]=k.y,u[h+2]=k.z;if(L)for(f=0;f<t;f++)color=p[f],h=f*3,w[h]=color.r,w[h+1]=color.g,w[h+2]=color.b;if(V)for(y in V)if(f=V[y],f.__original.needsUpdate){p=f.value.length;for(h=0;h<p;h++){t=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[t]=f.value[h]}else{if(f.boundTo===void 0||f.boundTo==="vertices")z=f.value[h];f.size===2?(f.array[t]=
+z.x,f.array[t+1]=z.y):f.size===3?f.type==="c"?(f.array[t]=z.r,f.array[t+1]=z.g,f.array[t+2]=z.b):(f.array[t]=z.x,f.array[t+1]=z.y,f.array[t+2]=z.z):(f.array[t]=z.x,f.array[t+1]=z.y,f.array[t+2]=z.z,f.array[t+3]=z.w)}f.offset+=f.size}}}if(x||c.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,b.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,u,e);if(L||c.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,b.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,w,e);if(V)for(y in V)if(f=V[y],f.__original.needsUpdate||c.sortParticles)o.bindBuffer(o.ARRAY_BUFFER,
+f.buffer),o.bufferData(o.ARRAY_BUFFER,f.array,e)}function e(b,e,c,f,k){f.program||W.initMaterial(f,e,c,k);if(f.morphTargets&&!k.__webglMorphTargetInfluences){k.__webglMorphTargetInfluences=new Float32Array(W.maxMorphTargets);for(var h=0,m=W.maxMorphTargets;h<m;h++)k.__webglMorphTargetInfluences[h]=0}var n=!1,h=f.program,m=h.uniforms,p=f.uniforms;h!=S&&(o.useProgram(h),S=h,n=!0);if(f.id!=aa)aa=f.id,n=!0;if(n){o.uniformMatrix4fv(m.projectionMatrix,!1,sa);if(c&&f.fog)if(p.fogColor.value=c.color,c instanceof
+THREE.Fog)p.fogNear.value=c.near,p.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)p.fogDensity.value=c.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){for(var t,u,w=0,v=0,x=0,L,V,y,z=Fa,B=z.directional.colors,D=z.directional.positions,$=z.point.colors,E=z.point.positions,F=z.point.distances,G=0,M=0,c=t=y=0,n=e.length;c<n;c++)if(t=e[c],u=t.color,L=t.position,V=t.intensity,y=t.distance,t instanceof THREE.AmbientLight)w+=u.r,v+=u.g,x+=u.b;else if(t instanceof
+THREE.DirectionalLight)y=G*3,B[y]=u.r*V,B[y+1]=u.g*V,B[y+2]=u.b*V,D[y]=L.x,D[y+1]=L.y,D[y+2]=L.z,G+=1;else if(t instanceof THREE.SpotLight)y=G*3,B[y]=u.r*V,B[y+1]=u.g*V,B[y+2]=u.b*V,u=1/L.length(),D[y]=L.x*u,D[y+1]=L.y*u,D[y+2]=L.z*u,G+=1;else if(t instanceof THREE.PointLight)t=M*3,$[t]=u.r*V,$[t+1]=u.g*V,$[t+2]=u.b*V,E[t]=L.x,E[t+1]=L.y,E[t+2]=L.z,F[M]=y,M+=1;c=G*3;for(n=B.length;c<n;c++)B[c]=0;c=M*3;for(n=$.length;c<n;c++)$[c]=0;z.point.length=M;z.directional.length=G;z.ambient[0]=w;z.ambient[1]=
+v;z.ambient[2]=x;e=Fa;p.enableLighting.value=e.directional.length+e.point.length;p.ambientLightColor.value=e.ambient;p.directionalLightColor.value=e.directional.colors;p.directionalLightDirection.value=e.directional.positions;p.pointLightColor.value=e.point.colors;p.pointLightPosition.value=e.point.positions;p.pointLightDistance.value=e.point.distances}if(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial)p.diffuse.value=f.color,p.opacity.value=
+f.opacity,(p.map.texture=f.map)&&p.offsetRepeat.value.set(f.map.offset.x,f.map.offset.y,f.map.repeat.x,f.map.repeat.y),p.lightMap.texture=f.lightMap,p.envMap.texture=f.envMap,p.reflectivity.value=f.reflectivity,p.refractionRatio.value=f.refractionRatio,p.combine.value=f.combine,p.useRefract.value=f.envMap&&f.envMap.mapping instanceof THREE.CubeRefractionMapping;if(f instanceof THREE.LineBasicMaterial)p.diffuse.value=f.color,p.opacity.value=f.opacity;else if(f instanceof THREE.ParticleBasicMaterial)p.psColor.value=
+f.color,p.opacity.value=f.opacity,p.size.value=f.size,p.scale.value=Ba.height/2,p.map.texture=f.map;else if(f instanceof THREE.MeshPhongMaterial)p.ambient.value=f.ambient,p.specular.value=f.specular,p.shininess.value=f.shininess;else if(f instanceof THREE.MeshDepthMaterial)p.mNear.value=b.near,p.mFar.value=b.far,p.opacity.value=f.opacity;else if(f instanceof THREE.MeshNormalMaterial)p.opacity.value=f.opacity;if(k.receiveShadow&&!f._shadowPass&&p.shadowMatrix){for(e=0;e<ya.length;e++)p.shadowMatrix.value[e]=
+ya[e],p.shadowMap.texture[e]=W.shadowMap[e];p.shadowDarkness.value=W.shadowMapDarkness;p.shadowBias.value=W.shadowMapBias}e=f.uniformsList;p=0;for(c=e.length;p<c;p++)if(v=h.uniforms[e[p][1]])if(w=e[p][0],x=w.type,n=w.value,x=="i")o.uniform1i(v,n);else if(x=="f")o.uniform1f(v,n);else if(x=="v2")o.uniform2f(v,n.x,n.y);else if(x=="v3")o.uniform3f(v,n.x,n.y,n.z);else if(x=="v4")o.uniform4f(v,n.x,n.y,n.z,n.w);else if(x=="c")o.uniform3f(v,n.r,n.g,n.b);else if(x=="fv1")o.uniform1fv(v,n);else if(x=="fv")o.uniform3fv(v,
+n);else if(x=="v3v"){if(!w._array)w._array=new Float32Array(3*n.length);x=0;for(L=n.length;x<L;x++)z=x*3,w._array[z]=n[x].x,w._array[z+1]=n[x].y,w._array[z+2]=n[x].z;o.uniform3fv(v,w._array)}else if(x=="m4"){if(!w._array)w._array=new Float32Array(16);n.flattenToArray(w._array);o.uniformMatrix4fv(v,!1,w._array)}else if(x=="m4v"){if(!w._array)w._array=new Float32Array(16*n.length);x=0;for(L=n.length;x<L;x++)n[x].flattenToArrayOffset(w._array,x*16);o.uniformMatrix4fv(v,!1,w._array)}else if(x=="t"){if(o.uniform1i(v,
+n),v=w.texture)if(v.image instanceof Array&&v.image.length==6){if(w=v,w.image.length==6)if(w.needsUpdate){if(!w.image.__webglTextureCube)w.image.__webglTextureCube=o.createTexture();o.activeTexture(o.TEXTURE0+n);o.bindTexture(o.TEXTURE_CUBE_MAP,w.image.__webglTextureCube);for(n=0;n<6;n++)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,w.image[n]);K(o.TEXTURE_CUBE_MAP,w,w.image[0]);w.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+n),o.bindTexture(o.TEXTURE_CUBE_MAP,w.image.__webglTextureCube)}else v instanceof
+THREE.WebGLRenderTargetCube?(w=v,o.activeTexture(o.TEXTURE0+n),o.bindTexture(o.TEXTURE_CUBE_MAP,w.__webglTexture)):I(v,n)}else if(x=="tv"){if(!w._array){w._array=[];x=0;for(L=w.texture.length;x<L;x++)w._array[x]=n+x}o.uniform1iv(v,w._array);x=0;for(L=w.texture.length;x<L;x++)(v=w.texture[x])&&I(v,w._array[x])}(f instanceof THREE.ShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&m.cameraPosition!==null&&o.uniform3f(m.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof
+THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.ShaderMaterial||f.skinning)&&m.viewMatrix!==null&&o.uniformMatrix4fv(m.viewMatrix,!1,Da);f.skinning&&(o.uniformMatrix4fv(m.cameraInverseMatrix,!1,Da),o.uniformMatrix4fv(m.boneGlobalMatrices,!1,k.boneMatrices))}o.uniformMatrix4fv(m.modelViewMatrix,!1,k._modelViewMatrixArray);m.normalMatrix&&o.uniformMatrix3fv(m.normalMatrix,!1,k._normalMatrixArray);(f instanceof THREE.ShaderMaterial||f.envMap||f.skinning||k.receiveShadow)&&
+m.objectMatrix!==null&&o.uniformMatrix4fv(m.objectMatrix,!1,k._objectMatrixArray);return h}function f(b,c,f,k,h,m){if(k.opacity!=0){var n,b=e(b,c,f,k,m).attributes;if(!k.morphTargets&&b.position>=0)o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(b.position,3,o.FLOAT,!1,0,0);else if(m.morphTargetBase){c=k.program.attributes;m.morphTargetBase!==-1?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[m.morphTargetBase]),o.vertexAttribPointer(c.position,3,o.FLOAT,!1,0,0)):
+c.position>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglVertexBuffer),o.vertexAttribPointer(c.position,3,o.FLOAT,!1,0,0));if(m.morphTargetForcedOrder.length)for(var f=0,p=m.morphTargetForcedOrder,t=m.morphTargetInfluences;f<k.numSupportedMorphTargets&&f<p.length;)o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[p[f]]),o.vertexAttribPointer(c["morphTarget"+f],3,o.FLOAT,!1,0,0),m.__webglMorphTargetInfluences[f]=t[p[f]],f++;else{var p=[],w=-1,u=0,t=m.morphTargetInfluences,v,x=t.length,f=0;for(m.morphTargetBase!==
+-1&&(p[m.morphTargetBase]=!0);f<k.numSupportedMorphTargets;){for(v=0;v<x;v++)!p[v]&&t[v]>w&&(u=v,w=t[u]);o.bindBuffer(o.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[u]);o.vertexAttribPointer(c["morphTarget"+f],3,o.FLOAT,!1,0,0);m.__webglMorphTargetInfluences[f]=w;p[u]=1;w=-1;f++}}k.program.uniforms.morphTargetInfluences!==null&&o.uniform1fv(k.program.uniforms.morphTargetInfluences,m.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(n in h.__webglCustomAttributes)b[n]>=0&&(c=h.__webglCustomAttributes[n],
 o.bindBuffer(o.ARRAY_BUFFER,c.buffer),o.vertexAttribPointer(b[n],c.size,o.FLOAT,!1,0,0));b.color>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglColorBuffer),o.vertexAttribPointer(b.color,3,o.FLOAT,!1,0,0));b.normal>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglNormalBuffer),o.vertexAttribPointer(b.normal,3,o.FLOAT,!1,0,0));b.tangent>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglTangentBuffer),o.vertexAttribPointer(b.tangent,4,o.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglUVBuffer),
 o.vertexAttribPointer(b.uv,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(b.uv)):o.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(o.bindBuffer(o.ARRAY_BUFFER,h.__webglUV2Buffer),o.vertexAttribPointer(b.uv2,2,o.FLOAT,!1,0,0),o.enableVertexAttribArray(b.uv2)):o.disableVertexAttribArray(b.uv2));k.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinVertexABuffer),o.vertexAttribPointer(b.skinVertexA,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,
 h.__webglSkinVertexBBuffer),o.vertexAttribPointer(b.skinVertexB,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),o.vertexAttribPointer(b.skinIndex,4,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),o.vertexAttribPointer(b.skinWeight,4,o.FLOAT,!1,0,0));m instanceof THREE.Mesh?(k.wireframe?(o.lineWidth(k.wireframeLinewidth),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),o.drawElements(o.LINES,h.__webglLineCount,o.UNSIGNED_SHORT,0)):(o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,
-h.__webglFaceBuffer),o.drawElements(o.TRIANGLES,h.__webglFaceCount,o.UNSIGNED_SHORT,0)),V.info.render.calls++,V.info.render.vertices+=h.__webglFaceCount,V.info.render.faces+=h.__webglFaceCount/3):m instanceof THREE.Line?(m=m.type==THREE.LineStrip?o.LINE_STRIP:o.LINES,o.lineWidth(k.linewidth),o.drawArrays(m,0,h.__webglLineCount),V.info.render.calls++):m instanceof THREE.ParticleSystem?(o.drawArrays(o.POINTS,0,h.__webglParticleCount),V.info.render.calls++):m instanceof THREE.Ribbon&&(o.drawArrays(o.TRIANGLE_STRIP,
-0,h.__webglVertexCount),V.info.render.calls++)}}function h(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=o.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=o.createBuffer();b.hasPos&&(o.bindBuffer(o.ARRAY_BUFFER,b.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,b.positionArray,o.DYNAMIC_DRAW),o.enableVertexAttribArray(e.attributes.position),o.vertexAttribPointer(e.attributes.position,3,o.FLOAT,!1,0,0));if(b.hasNormal){o.bindBuffer(o.ARRAY_BUFFER,b.__webglNormalBuffer);if(c==
-THREE.FlatShading){var f,h,k,m,n,t,p,w,u,v,x=b.count*3;for(v=0;v<x;v+=9)c=b.normalArray,f=c[v],h=c[v+1],k=c[v+2],m=c[v+3],t=c[v+4],w=c[v+5],n=c[v+6],p=c[v+7],u=c[v+8],f=(f+m+n)/3,h=(h+t+p)/3,k=(k+w+u)/3,c[v]=f,c[v+1]=h,c[v+2]=k,c[v+3]=f,c[v+4]=h,c[v+5]=k,c[v+6]=f,c[v+7]=h,c[v+8]=k}o.bufferData(o.ARRAY_BUFFER,b.normalArray,o.DYNAMIC_DRAW);o.enableVertexAttribArray(e.attributes.normal);o.vertexAttribPointer(e.attributes.normal,3,o.FLOAT,!1,0,0)}o.drawArrays(o.TRIANGLES,0,b.count);b.count=0}function m(b){if($!=
-b.doubleSided)b.doubleSided?o.disable(o.CULL_FACE):o.enable(o.CULL_FACE),$=b.doubleSided;if(la!=b.flipSided)b.flipSided?o.frontFace(o.CW):o.frontFace(o.CCW),la=b.flipSided}function k(b){ma!=b&&(b?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),ma=b)}function n(b){da!=b&&(o.depthMask(b),da=b)}function u(b,e,c){Y!=b&&(b?o.enable(o.POLYGON_OFFSET_FILL):o.disable(o.POLYGON_OFFSET_FILL),Y=b);if(b&&(T!=e||Z!=c))o.polygonOffset(e,c),T=e,Z=c}function p(b){ca[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-
-b.n14);ca[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);ca[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);ca[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);ca[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);ca[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var e,b=0;b<6;b++)e=ca[b],e.divideScalar(Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z))}function v(b){for(var e=b.matrixWorld,c=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),
-f=0;f<6;f++)if(b=ca[f].x*e.n14+ca[f].y*e.n24+ca[f].z*e.n34+ca[f].w,b<=c)return!1;return!0}function t(b,e){b.list[b.count]=e;b.count+=1}function x(b){var e,c,f=b.object,h=b.opaque,k=b.transparent;k.count=0;b=h.count=0;for(e=f.materials.length;b<e;b++)c=f.materials[b],c.transparent?t(k,c):t(h,c)}function w(b){var e,c,f,h,k=b.object,m=b.buffer,n=b.opaque,o=b.transparent;o.count=0;b=n.count=0;for(f=k.materials.length;b<f;b++)if(e=k.materials[b],e instanceof THREE.MeshFaceMaterial){e=0;for(c=m.materials.length;e<
-c;e++)(h=m.materials[e])&&(h.transparent?t(o,h):t(n,h))}else(h=e)&&(h.transparent?t(o,h):t(n,h))}function y(b,e){return e.z-b.z}function z(b){var c,n,t,w=0,u,x,J,y,z=b.lights;ga||(ga=new THREE.Camera(V.shadowCameraFov,V.shadowMapWidth/V.shadowMapHeight,V.shadowCameraNear,V.shadowCameraFar));c=0;for(n=z.length;c<n;c++)if(t=z[c],t instanceof THREE.SpotLight&&t.castShadow){V.shadowMap[w]||(V.shadowMap[w]=new THREE.WebGLRenderTarget(V.shadowMapWidth,V.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
-format:THREE.RGBAFormat}));ia[w]||(ia[w]=new THREE.Matrix4);u=V.shadowMap[w];x=ia[w];ga.position.copy(t.position);ga.target.position.copy(t.target.position);ga.update(void 0,!0);b.update(void 0,!1,ga);x.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);x.multiplySelf(ga.projectionMatrix);x.multiplySelf(ga.matrixWorldInverse);ga.matrixWorldInverse.flattenToArray(sa);ga.projectionMatrix.flattenToArray(ua);qa.multiply(ga.projectionMatrix,ga.matrixWorldInverse);p(qa);V.initWebGLObjects(b);X(u);o.clearColor(1,
-1,1,1);V.clear();o.clearColor(ha.r,ha.g,ha.b,W);x=b.__webglObjects.length;t=b.__webglObjectsImmediate.length;for(u=0;u<x;u++)J=b.__webglObjects[u],y=J.object,y.visible&&y.castShadow?!(y instanceof THREE.Mesh)||!y.frustumCulled||v(y)?(y.matrixWorld.flattenToArray(y._objectMatrixArray),E(y,ga,!1),J.render=!0):J.render=!1:J.render=!1;k(!0);L(THREE.NormalBlending);for(u=0;u<x;u++)if(J=b.__webglObjects[u],J.render)y=J.object,buffer=J.buffer,m(y),J=y.customDepthMaterial?y.customDepthMaterial:y.geometry.morphTargets.length?
-oa:ya,f(ga,z,null,J,buffer,y);for(u=0;u<t;u++)J=b.__webglObjectsImmediate[u],y=J.object,y.visible&&y.castShadow&&(y.matrixAutoUpdate&&y.matrixWorld.flattenToArray(y._objectMatrixArray),E(y,ga,!1),m(y),program=e(ga,z,null,ya,y),y.render(function(b){h(b,program,ya.shading)}));w++}}function A(b,e){var c,f,h;c=aa.attributes;var k=aa.uniforms,m=K/va,n,t=[],p=va*0.5,w=K*0.5,u=!0;o.useProgram(aa.program);S=aa.program;ma=ja=-1;Aa||(o.enableVertexAttribArray(aa.attributes.position),o.enableVertexAttribArray(aa.attributes.uv),
-Aa=!0);o.disable(o.CULL_FACE);o.enable(o.BLEND);o.depthMask(!0);o.bindBuffer(o.ARRAY_BUFFER,aa.vertexBuffer);o.vertexAttribPointer(c.position,2,o.FLOAT,!1,16,0);o.vertexAttribPointer(c.uv,2,o.FLOAT,!1,16,8);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,aa.elementBuffer);o.uniformMatrix4fv(k.projectionMatrix,!1,ua);o.activeTexture(o.TEXTURE0);o.uniform1i(k.map,0);c=0;for(f=b.__webglSprites.length;c<f;c++)if(h=b.__webglSprites[c],h.visible&&h.opacity!=0)h.useScreenCoordinates?h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,
-h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(y);c=0;for(f=b.__webglSprites.length;c<f;c++)h=b.__webglSprites[c],h.visible&&h.opacity!=0&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(o.uniform1i(k.useScreenCoordinates,1),o.uniform3f(k.screenPosition,(h.position.x-p)/p,(w-h.position.y)/w,Math.max(0,Math.min(1,h.position.z)))):(o.uniform1i(k.useScreenCoordinates,0),o.uniform1i(k.affectedByDistance,h.affectedByDistance?1:0),o.uniformMatrix4fv(k.modelViewMatrix,
-!1,h._modelViewMatrixArray)),n=h.map.image.width/(h.scaleByViewport?K:1),t[0]=n*m*h.scale.x,t[1]=n*h.scale.y,o.uniform2f(k.uvScale,h.uvScale.x,h.uvScale.y),o.uniform2f(k.uvOffset,h.uvOffset.x,h.uvOffset.y),o.uniform2f(k.alignment,h.alignment.x,h.alignment.y),o.uniform1f(k.opacity,h.opacity),o.uniform3f(k.color,h.color.r,h.color.g,h.color.b),o.uniform1f(k.rotation,h.rotation),o.uniform2fv(k.scale,t),h.mergeWith3D&&!u?(o.enable(o.DEPTH_TEST),u=!0):!h.mergeWith3D&&u&&(o.disable(o.DEPTH_TEST),u=!1),L(h.blending),
-M(h.map,0),o.drawElements(o.TRIANGLES,6,o.UNSIGNED_SHORT,0));o.enable(o.CULL_FACE);o.enable(o.DEPTH_TEST);o.depthMask(da)}function E(b,e,c){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function D(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b<c;b++)if(f=h[b],f.attributes)for(e in f.attributes)if(f.attributes[e].needsUpdate)return!0;return!1}function F(b){var e,
-c,f,h;h=b.__materials;b=0;for(c=h.length;b<c;b++)if(f=h[b],f.attributes)for(e in f.attributes)f.attributes[e].needsUpdate=!1}function G(b,e){var c;for(c=b.length-1;c>=0;c--)b[c].object==e&&b.splice(c,1)}function N(b){function e(b){var h=[];c=0;for(f=b.length;c<f;c++)b[c]==void 0?h.push("undefined"):h.push(b[c].id);return h.join("_")}var c,f,h,k,m,n,o,t,p={},u=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};h=0;for(k=b.faces.length;h<k;h++)m=b.faces[h],n=m.materials,o=e(n),p[o]==
-void 0&&(p[o]={hash:o,counter:0}),t=p[o].hash+"_"+p[o].counter,b.geometryGroups[t]==void 0&&(b.geometryGroups[t]={faces:[],materials:n,vertices:0,numMorphTargets:u}),m=m instanceof THREE.Face3?3:4,b.geometryGroups[t].vertices+m>65535&&(p[o].counter+=1,t=p[o].hash+"_"+p[o].counter,b.geometryGroups[t]==void 0&&(b.geometryGroups[t]={faces:[],materials:n,vertices:0,numMorphTargets:u})),b.geometryGroups[t].faces.push(h),b.geometryGroups[t].vertices+=m;b.geometryGroupsList=[];for(var w in b.geometryGroups)b.geometryGroupsList.push(b.geometryGroups[w])}
-function Q(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function L(b){if(b!=ja){switch(b){case THREE.AdditiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE);break;case THREE.SubtractiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.SRC_COLOR);break;default:o.blendEquationSeparate(o.FUNC_ADD,o.FUNC_ADD),o.blendFuncSeparate(o.SRC_ALPHA,
-o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA)}ja=b}}function H(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(o.texParameteri(b,o.TEXTURE_WRAP_S,U(e.wrapS)),o.texParameteri(b,o.TEXTURE_WRAP_T,U(e.wrapT)),o.texParameteri(b,o.TEXTURE_MAG_FILTER,U(e.magFilter)),o.texParameteri(b,o.TEXTURE_MIN_FILTER,U(e.minFilter)),o.generateMipmap(b)):(o.texParameteri(b,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(b,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(b,o.TEXTURE_MAG_FILTER,P(e.magFilter)),
-o.texParameteri(b,o.TEXTURE_MIN_FILTER,P(e.minFilter)))}function M(b,e){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=o.createTexture(),V.info.memory.textures++;o.activeTexture(o.TEXTURE0+e);o.bindTexture(o.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?o.texImage2D(o.TEXTURE_2D,0,U(b.format),b.image.width,b.image.height,0,U(b.format),o.UNSIGNED_BYTE,b.image.data):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,b.image);H(o.TEXTURE_2D,b,b.image);b.needsUpdate=
-!1}else o.activeTexture(o.TEXTURE0+e),o.bindTexture(o.TEXTURE_2D,b.__webglTexture)}function X(b){var e=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglRenderbuffer=o.createRenderbuffer();b.__webglTexture=o.createTexture();if(e){o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture);H(o.TEXTURE_CUBE_MAP,b,b);b.__webglFramebuffer=[];for(var c=0;c<6;c++)b.__webglFramebuffer[c]=o.createFramebuffer(),
-o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,U(b.format),b.width,b.height,0,U(b.format),U(b.type),null)}else b.__webglFramebuffer=o.createFramebuffer(),o.bindTexture(o.TEXTURE_2D,b.__webglTexture),H(o.TEXTURE_2D,b,b),o.texImage2D(o.TEXTURE_2D,0,U(b.format),b.width,b.height,0,U(b.format),U(b.type),null);o.bindRenderbuffer(o.RENDERBUFFER,b.__webglRenderbuffer);if(e)for(c=0;c<6;++c)o.bindFramebuffer(o.FRAMEBUFFER,b.__webglFramebuffer[c]),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+
-c,b.__webglTexture,0);else o.bindFramebuffer(o.FRAMEBUFFER,b.__webglFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_COMPONENT16,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,
-o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,b.__webglRenderbuffer)):o.renderbufferStorage(o.RENDERBUFFER,o.RGBA4,b.width,b.height);e?o.bindTexture(o.TEXTURE_CUBE_MAP,null):o.bindTexture(o.TEXTURE_2D,null);o.bindRenderbuffer(o.RENDERBUFFER,null);o.bindFramebuffer(o.FRAMEBUFFER,null)}var f,h;b?(e=e?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,c=b.width,b=b.height,h=f=0):(e=null,c=va,b=K,f=fa,h=na);e!=ta&&(o.bindFramebuffer(o.FRAMEBUFFER,e),o.viewport(f,h,c,b),ta=e)}function C(b){b instanceof
-THREE.WebGLRenderTargetCube?(o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture),o.generateMipmap(o.TEXTURE_CUBE_MAP),o.bindTexture(o.TEXTURE_CUBE_MAP,null)):(o.bindTexture(o.TEXTURE_2D,b.__webglTexture),o.generateMipmap(o.TEXTURE_2D),o.bindTexture(o.TEXTURE_2D,null))}function O(b,e){var c;b=="fragment"?c=o.createShader(o.FRAGMENT_SHADER):b=="vertex"&&(c=o.createShader(o.VERTEX_SHADER));o.shaderSource(c,e);o.compileShader(c);if(!o.getShaderParameter(c,o.COMPILE_STATUS))return console.error(o.getShaderInfoLog(c)),
-console.error(e),null;return c}function P(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return o.NEAREST;default:return o.LINEAR}}function U(b){switch(b){case THREE.RepeatWrapping:return o.REPEAT;case THREE.ClampToEdgeWrapping:return o.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return o.MIRRORED_REPEAT;case THREE.NearestFilter:return o.NEAREST;case THREE.NearestMipMapNearestFilter:return o.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return o.NEAREST_MIPMAP_LINEAR;
-case THREE.LinearFilter:return o.LINEAR;case THREE.LinearMipMapNearestFilter:return o.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return o.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return o.BYTE;case THREE.UnsignedByteType:return o.UNSIGNED_BYTE;case THREE.ShortType:return o.SHORT;case THREE.UnsignedShortType:return o.UNSIGNED_SHORT;case THREE.IntType:return o.INT;case THREE.UnsignedShortType:return o.UNSIGNED_INT;case THREE.FloatType:return o.FLOAT;case THREE.AlphaFormat:return o.ALPHA;
-case THREE.RGBFormat:return o.RGB;case THREE.RGBAFormat:return o.RGBA;case THREE.LuminanceFormat:return o.LUMINANCE;case THREE.LuminanceAlphaFormat:return o.LUMINANCE_ALPHA}return 0}var V=this,o,ea=[],S=null,ta=null,$=null,la=null,ja=null,ma=null,da=null,Y=null,T=null,Z=null,fa=0,na=0,va=0,K=0,ca=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],qa=new THREE.Matrix4,ua=new Float32Array(16),sa=new Float32Array(16),xa=new THREE.Vector4,Ea=
-{ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Da=b.canvas!==void 0?b.canvas:document.createElement("canvas"),pa=b.stencil!==void 0?b.stencil:!0,Ga=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,J=b.antialias!==void 0?b.antialias:!1,ha=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),W=b.clearAlpha!==void 0?b.clearAlpha:0,ra=b.maxLights!==void 0?b.maxLights:4;this.info={memory:{programs:0,
-geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=Da;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var ga,ia=[],b=THREE.ShaderLib.depthRGBA,za=THREE.UniformsUtils.clone(b.uniforms),ya=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,
-vertexShader:b.vertexShader,uniforms:za}),oa=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:za,morphTargets:!0});ya._shadowPass=!0;oa._shadowPass=!0;try{if(!(o=Da.getContext("experimental-webgl",{antialias:J,stencil:pa,preserveDrawingBuffer:Ga})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+o.getParameter(o.VERSION)+" | "+o.getParameter(o.VENDOR)+" | "+o.getParameter(o.RENDERER)+" | "+o.getParameter(o.SHADING_LANGUAGE_VERSION))}catch(Ha){console.error(Ha)}o.clearColor(0,
-0,0,1);o.clearDepth(1);o.clearStencil(0);o.enable(o.DEPTH_TEST);o.depthFunc(o.LEQUAL);o.frontFace(o.CCW);o.cullFace(o.BACK);o.enable(o.CULL_FACE);o.enable(o.BLEND);o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA);o.clearColor(ha.r,ha.g,ha.b,W);this.context=o;var Ba=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,aa={};aa.vertices=new Float32Array(16);aa.faces=new Uint16Array(6);pa=0;aa.vertices[pa++]=-1;aa.vertices[pa++]=-1;aa.vertices[pa++]=0;aa.vertices[pa++]=1;aa.vertices[pa++]=
-1;aa.vertices[pa++]=-1;aa.vertices[pa++]=1;aa.vertices[pa++]=1;aa.vertices[pa++]=1;aa.vertices[pa++]=1;aa.vertices[pa++]=1;aa.vertices[pa++]=0;aa.vertices[pa++]=-1;aa.vertices[pa++]=1;aa.vertices[pa++]=0;pa=aa.vertices[pa++]=0;aa.faces[pa++]=0;aa.faces[pa++]=1;aa.faces[pa++]=2;aa.faces[pa++]=0;aa.faces[pa++]=2;aa.faces[pa++]=3;aa.vertexBuffer=o.createBuffer();aa.elementBuffer=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,aa.vertexBuffer);o.bufferData(o.ARRAY_BUFFER,aa.vertices,o.STATIC_DRAW);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,
-aa.elementBuffer);o.bufferData(o.ELEMENT_ARRAY_BUFFER,aa.faces,o.STATIC_DRAW);aa.program=o.createProgram();o.attachShader(aa.program,O("fragment",THREE.ShaderLib.sprite.fragmentShader));o.attachShader(aa.program,O("vertex",THREE.ShaderLib.sprite.vertexShader));o.linkProgram(aa.program);aa.attributes={};aa.uniforms={};aa.attributes.position=o.getAttribLocation(aa.program,"position");aa.attributes.uv=o.getAttribLocation(aa.program,"uv");aa.uniforms.uvOffset=o.getUniformLocation(aa.program,"uvOffset");
-aa.uniforms.uvScale=o.getUniformLocation(aa.program,"uvScale");aa.uniforms.rotation=o.getUniformLocation(aa.program,"rotation");aa.uniforms.scale=o.getUniformLocation(aa.program,"scale");aa.uniforms.alignment=o.getUniformLocation(aa.program,"alignment");aa.uniforms.color=o.getUniformLocation(aa.program,"color");aa.uniforms.map=o.getUniformLocation(aa.program,"map");aa.uniforms.opacity=o.getUniformLocation(aa.program,"opacity");aa.uniforms.useScreenCoordinates=o.getUniformLocation(aa.program,"useScreenCoordinates");
-aa.uniforms.affectedByDistance=o.getUniformLocation(aa.program,"affectedByDistance");aa.uniforms.screenPosition=o.getUniformLocation(aa.program,"screenPosition");aa.uniforms.modelViewMatrix=o.getUniformLocation(aa.program,"modelViewMatrix");aa.uniforms.projectionMatrix=o.getUniformLocation(aa.program,"projectionMatrix");var Aa=!1;this.setSize=function(b,e){Da.width=b;Da.height=e;this.setViewport(0,0,Da.width,Da.height)};this.setViewport=function(b,e,c,f){fa=b;na=e;va=c;K=f;o.viewport(fa,na,va,K)};
-this.setScissor=function(b,e,c,f){o.scissor(b,e,c,f)};this.enableScissorTest=function(b){b?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)};this.setClearColorHex=function(b,e){ha.setHex(b);W=e;o.clearColor(ha.r,ha.g,ha.b,W)};this.setClearColor=function(b,e){ha.copy(b);W=e;o.clearColor(ha.r,ha.g,ha.b,W)};this.getClearColor=function(){return ha};this.getClearAlpha=function(){return W};this.clear=function(){o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT|o.STENCIL_BUFFER_BIT)};this.getContext=function(){return o};
-this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var e=b.geometry.geometryGroups[g];o.deleteBuffer(e.__webglVertexBuffer);o.deleteBuffer(e.__webglNormalBuffer);o.deleteBuffer(e.__webglTangentBuffer);o.deleteBuffer(e.__webglColorBuffer);o.deleteBuffer(e.__webglUVBuffer);o.deleteBuffer(e.__webglUV2Buffer);o.deleteBuffer(e.__webglSkinVertexABuffer);
-o.deleteBuffer(e.__webglSkinVertexBBuffer);o.deleteBuffer(e.__webglSkinIndicesBuffer);o.deleteBuffer(e.__webglSkinWeightsBuffer);o.deleteBuffer(e.__webglFaceBuffer);o.deleteBuffer(e.__webglLineBuffer);if(e.numMorphTargets)for(var c=0,f=e.numMorphTargets;c<f;c++)o.deleteBuffer(e.__webglMorphTargetsBuffers[c]);V.info.memory.geometries--}else if(b instanceof THREE.Ribbon)b=b.geometry,o.deleteBuffer(b.__webglVertexBuffer),o.deleteBuffer(b.__webglColorBuffer),V.info.memory.geometries--;else if(b instanceof
-THREE.Line)b=b.geometry,o.deleteBuffer(b.__webglVertexBuffer),o.deleteBuffer(b.__webglColorBuffer),V.info.memory.geometries--;else if(b instanceof THREE.ParticleSystem)b=b.geometry,o.deleteBuffer(b.__webglVertexBuffer),o.deleteBuffer(b.__webglColorBuffer),V.info.memory.geometries--};this.deallocateTexture=function(b){if(b.__webglInit)b.__webglInit=!1,o.deleteTexture(b.__webglTexture),V.info.memory.textures--};this.initMaterial=function(b,e,c,f){var h,k,m,n;b instanceof THREE.MeshDepthMaterial?n="depth":
-b instanceof THREE.MeshNormalMaterial?n="normal":b instanceof THREE.MeshBasicMaterial?n="basic":b instanceof THREE.MeshLambertMaterial?n="lambert":b instanceof THREE.MeshPhongMaterial?n="phong":b instanceof THREE.LineBasicMaterial?n="basic":b instanceof THREE.ParticleBasicMaterial&&(n="particle_basic");if(n){var t=THREE.ShaderLib[n];b.uniforms=THREE.UniformsUtils.clone(t.uniforms);b.vertexShader=t.vertexShader;b.fragmentShader=t.fragmentShader}var p,u,w;p=w=t=0;for(u=e.length;p<u;p++)m=e[p],m instanceof
-THREE.SpotLight&&w++,m instanceof THREE.DirectionalLight&&w++,m instanceof THREE.PointLight&&t++;t+w<=ra?p=w:(p=Math.ceil(ra*w/(t+w)),t=ra-p);m={directional:p,point:t};t=w=0;for(p=e.length;t<p;t++)u=e[t],u instanceof THREE.SpotLight&&u.castShadow&&w++;var v=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)v=f.bones.length;var x;a:{p=b.fragmentShader;u=b.vertexShader;var t=b.uniforms,e=b.attributes,c={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:c,useFog:b.fog,
-sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:m.directional,maxPointLights:m.point,maxBones:v,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:w,alphaTest:b.alphaTest},J,f=[];n?f.push(n):(f.push(p),f.push(u));for(J in c)f.push(J),f.push(c[J]);n=f.join();J=0;for(f=ea.length;J<f;J++)if(ea[J].code==
-n){x=ea[J].program;break a}J=o.createProgram();f=[Ba?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?
-"#define SHADOWMAP_SOFT":"",c.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");
+h.__webglFaceBuffer),o.drawElements(o.TRIANGLES,h.__webglFaceCount,o.UNSIGNED_SHORT,0)),W.info.render.calls++,W.info.render.vertices+=h.__webglFaceCount,W.info.render.faces+=h.__webglFaceCount/3):m instanceof THREE.Line?(m=m.type==THREE.LineStrip?o.LINE_STRIP:o.LINES,o.lineWidth(k.linewidth),o.drawArrays(m,0,h.__webglLineCount),W.info.render.calls++):m instanceof THREE.ParticleSystem?(o.drawArrays(o.POINTS,0,h.__webglParticleCount),W.info.render.calls++):m instanceof THREE.Ribbon&&(o.drawArrays(o.TRIANGLE_STRIP,
+0,h.__webglVertexCount),W.info.render.calls++)}}function h(b,e,c){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=o.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=o.createBuffer();b.hasPos&&(o.bindBuffer(o.ARRAY_BUFFER,b.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,b.positionArray,o.DYNAMIC_DRAW),o.enableVertexAttribArray(e.attributes.position),o.vertexAttribPointer(e.attributes.position,3,o.FLOAT,!1,0,0));if(b.hasNormal){o.bindBuffer(o.ARRAY_BUFFER,b.__webglNormalBuffer);if(c==
+THREE.FlatShading){var f,h,k,m,n,p,t,w,u,v,x=b.count*3;for(v=0;v<x;v+=9)c=b.normalArray,f=c[v],h=c[v+1],k=c[v+2],m=c[v+3],p=c[v+4],w=c[v+5],n=c[v+6],t=c[v+7],u=c[v+8],f=(f+m+n)/3,h=(h+p+t)/3,k=(k+w+u)/3,c[v]=f,c[v+1]=h,c[v+2]=k,c[v+3]=f,c[v+4]=h,c[v+5]=k,c[v+6]=f,c[v+7]=h,c[v+8]=k}o.bufferData(o.ARRAY_BUFFER,b.normalArray,o.DYNAMIC_DRAW);o.enableVertexAttribArray(e.attributes.normal);o.vertexAttribPointer(e.attributes.normal,3,o.FLOAT,!1,0,0)}o.drawArrays(o.TRIANGLES,0,b.count);b.count=0}function m(b){if(ia!=
+b.doubleSided)b.doubleSided?o.disable(o.CULL_FACE):o.enable(o.CULL_FACE),ia=b.doubleSided;if(ka!=b.flipSided)b.flipSided?o.frontFace(o.CW):o.frontFace(o.CCW),ka=b.flipSided}function k(b){ca!=b&&(b?o.enable(o.DEPTH_TEST):o.disable(o.DEPTH_TEST),ca=b)}function n(b){ha!=b&&(o.depthMask(b),ha=b)}function u(b,e,c){T!=b&&(b?o.enable(o.POLYGON_OFFSET_FILL):o.disable(o.POLYGON_OFFSET_FILL),T=b);if(b&&(Z!=e||ea!=c))o.polygonOffset(e,c),Z=e,ea=c}function p(b){na[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-
+b.n14);na[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);na[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);na[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);na[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);na[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var e,b=0;b<6;b++)e=na[b],e.divideScalar(Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z))}function v(b){for(var e=b.matrixWorld,c=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),
+f=0;f<6;f++)if(b=na[f].x*e.n14+na[f].y*e.n24+na[f].z*e.n34+na[f].w,b<=c)return!1;return!0}function t(b,e){b.list[b.count]=e;b.count+=1}function x(b){var e,c,f=b.object,h=b.opaque,k=b.transparent;k.count=0;b=h.count=0;for(e=f.materials.length;b<e;b++)c=f.materials[b],c.transparent?t(k,c):t(h,c)}function w(b){var e,c,f,h,k=b.object,m=b.buffer,n=b.opaque,o=b.transparent;o.count=0;b=n.count=0;for(f=k.materials.length;b<f;b++)if(e=k.materials[b],e instanceof THREE.MeshFaceMaterial){e=0;for(c=m.materials.length;e<
+c;e++)(h=m.materials[e])&&(h.transparent?t(o,h):t(n,h))}else(h=e)&&(h.transparent?t(o,h):t(n,h))}function y(b,e){return e.z-b.z}function z(b){var c,n,t,w=0,u,x,L,y,z=b.lights;ja||(ja=new THREE.Camera(W.shadowCameraFov,W.shadowMapWidth/W.shadowMapHeight,W.shadowCameraNear,W.shadowCameraFar));c=0;for(n=z.length;c<n;c++)if(t=z[c],t instanceof THREE.SpotLight&&t.castShadow){aa=-1;W.shadowMap[w]||(W.shadowMap[w]=new THREE.WebGLRenderTarget(W.shadowMapWidth,W.shadowMapHeight,{minFilter:THREE.LinearFilter,
+magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));ya[w]||(ya[w]=new THREE.Matrix4);u=W.shadowMap[w];x=ya[w];ja.position.copy(t.position);ja.target.position.copy(t.target.position);ja.update(void 0,!0);b.update(void 0,!1,ja);x.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);x.multiplySelf(ja.projectionMatrix);x.multiplySelf(ja.matrixWorldInverse);ja.matrixWorldInverse.flattenToArray(Da);ja.projectionMatrix.flattenToArray(sa);ta.multiply(ja.projectionMatrix,ja.matrixWorldInverse);p(ta);W.initWebGLObjects(b);
+X(u);o.clearColor(1,1,1,1);W.clear();o.clearColor(V.r,V.g,V.b,va);x=b.__webglObjects.length;t=b.__webglObjectsImmediate.length;for(u=0;u<x;u++)L=b.__webglObjects[u],y=L.object,y.visible&&y.castShadow?!(y instanceof THREE.Mesh)||!y.frustumCulled||v(y)?(y.matrixWorld.flattenToArray(y._objectMatrixArray),D(y,ja,!1),L.render=!0):L.render=!1:L.render=!1;k(!0);H(THREE.NormalBlending);for(u=0;u<x;u++)if(L=b.__webglObjects[u],L.render)y=L.object,buffer=L.buffer,m(y),L=y.customDepthMaterial?y.customDepthMaterial:
+y.geometry.morphTargets.length?Ha:qa,f(ja,z,null,L,buffer,y);for(u=0;u<t;u++)L=b.__webglObjectsImmediate[u],y=L.object,y.visible&&y.castShadow&&(y.matrixAutoUpdate&&y.matrixWorld.flattenToArray(y._objectMatrixArray),D(y,ja,!1),m(y),program=e(ja,z,null,qa,y),y.render(function(b){h(b,program,qa.shading)}));w++}}function B(b,e){var c,f,h;c=Y.attributes;var k=Y.uniforms,m=fa/M,n,p=[],t=M*0.5,w=fa*0.5,u=!0;o.useProgram(Y.program);S=Y.program;ca=ma=-1;Ea||(o.enableVertexAttribArray(Y.attributes.position),
+o.enableVertexAttribArray(Y.attributes.uv),Ea=!0);o.disable(o.CULL_FACE);o.enable(o.BLEND);o.depthMask(!0);o.bindBuffer(o.ARRAY_BUFFER,Y.vertexBuffer);o.vertexAttribPointer(c.position,2,o.FLOAT,!1,16,0);o.vertexAttribPointer(c.uv,2,o.FLOAT,!1,16,8);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,Y.elementBuffer);o.uniformMatrix4fv(k.projectionMatrix,!1,sa);o.activeTexture(o.TEXTURE0);o.uniform1i(k.map,0);c=0;for(f=b.__webglSprites.length;c<f;c++)if(h=b.__webglSprites[c],h.visible&&h.opacity!=0)h.useScreenCoordinates?
+h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(y);c=0;for(f=b.__webglSprites.length;c<f;c++)h=b.__webglSprites[c],h.visible&&h.opacity!=0&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(o.uniform1i(k.useScreenCoordinates,1),o.uniform3f(k.screenPosition,(h.position.x-t)/t,(w-h.position.y)/w,Math.max(0,Math.min(1,h.position.z)))):(o.uniform1i(k.useScreenCoordinates,
+0),o.uniform1i(k.affectedByDistance,h.affectedByDistance?1:0),o.uniformMatrix4fv(k.modelViewMatrix,!1,h._modelViewMatrixArray)),n=h.map.image.width/(h.scaleByViewport?fa:1),p[0]=n*m*h.scale.x,p[1]=n*h.scale.y,o.uniform2f(k.uvScale,h.uvScale.x,h.uvScale.y),o.uniform2f(k.uvOffset,h.uvOffset.x,h.uvOffset.y),o.uniform2f(k.alignment,h.alignment.x,h.alignment.y),o.uniform1f(k.opacity,h.opacity),o.uniform3f(k.color,h.color.r,h.color.g,h.color.b),o.uniform1f(k.rotation,h.rotation),o.uniform2fv(k.scale,p),
+h.mergeWith3D&&!u?(o.enable(o.DEPTH_TEST),u=!0):!h.mergeWith3D&&u&&(o.disable(o.DEPTH_TEST),u=!1),H(h.blending),I(h.map,0),o.drawElements(o.TRIANGLES,6,o.UNSIGNED_SHORT,0));o.enable(o.CULL_FACE);o.enable(o.DEPTH_TEST);o.depthMask(ha)}function D(b,e,c){b._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);c&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function E(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b<
+c;b++)if(f=h[b],f.attributes)for(e in f.attributes)if(f.attributes[e].needsUpdate)return!0;return!1}function F(b){var e,c,f,h;h=b.__materials;b=0;for(c=h.length;b<c;b++)if(f=h[b],f.attributes)for(e in f.attributes)f.attributes[e].needsUpdate=!1}function G(b,e){var c;for(c=b.length-1;c>=0;c--)b[c].object==e&&b.splice(c,1)}function N(b){function e(b){var h=[];c=0;for(f=b.length;c<f;c++)b[c]==void 0?h.push("undefined"):h.push(b[c].id);return h.join("_")}var c,f,h,k,m,n,o,p,t={},u=b.morphTargets!==void 0?
+b.morphTargets.length:0;b.geometryGroups={};h=0;for(k=b.faces.length;h<k;h++)m=b.faces[h],n=m.materials,o=e(n),t[o]==void 0&&(t[o]={hash:o,counter:0}),p=t[o].hash+"_"+t[o].counter,b.geometryGroups[p]==void 0&&(b.geometryGroups[p]={faces:[],materials:n,vertices:0,numMorphTargets:u}),m=m instanceof THREE.Face3?3:4,b.geometryGroups[p].vertices+m>65535&&(t[o].counter+=1,p=t[o].hash+"_"+t[o].counter,b.geometryGroups[p]==void 0&&(b.geometryGroups[p]={faces:[],materials:n,vertices:0,numMorphTargets:u})),
+b.geometryGroups[p].faces.push(h),b.geometryGroups[p].vertices+=m;b.geometryGroupsList=[];for(var w in b.geometryGroups)b.geometryGroupsList.push(b.geometryGroups[w])}function Q(b,e,c){b.push({buffer:e,object:c,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function H(b){if(b!=ma){switch(b){case THREE.AdditiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE);break;case THREE.SubtractiveBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.ONE_MINUS_SRC_COLOR);break;
+case THREE.MultiplyBlending:o.blendEquation(o.FUNC_ADD);o.blendFunc(o.ZERO,o.SRC_COLOR);break;default:o.blendEquationSeparate(o.FUNC_ADD,o.FUNC_ADD),o.blendFuncSeparate(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA,o.ONE,o.ONE_MINUS_SRC_ALPHA)}ma=b}}function K(b,e,c){(c.width&c.width-1)==0&&(c.height&c.height-1)==0?(o.texParameteri(b,o.TEXTURE_WRAP_S,U(e.wrapS)),o.texParameteri(b,o.TEXTURE_WRAP_T,U(e.wrapT)),o.texParameteri(b,o.TEXTURE_MAG_FILTER,U(e.magFilter)),o.texParameteri(b,o.TEXTURE_MIN_FILTER,U(e.minFilter)),
+o.generateMipmap(b)):(o.texParameteri(b,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(b,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(b,o.TEXTURE_MAG_FILTER,P(e.magFilter)),o.texParameteri(b,o.TEXTURE_MIN_FILTER,P(e.minFilter)))}function I(b,e){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=o.createTexture(),W.info.memory.textures++;o.activeTexture(o.TEXTURE0+e);o.bindTexture(o.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?o.texImage2D(o.TEXTURE_2D,0,U(b.format),
+b.image.width,b.image.height,0,U(b.format),o.UNSIGNED_BYTE,b.image.data):o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,b.image);K(o.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else o.activeTexture(o.TEXTURE0+e),o.bindTexture(o.TEXTURE_2D,b.__webglTexture)}function X(b){var e=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglRenderbuffer=o.createRenderbuffer();b.__webglTexture=
+o.createTexture();if(e){o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture);K(o.TEXTURE_CUBE_MAP,b,b);b.__webglFramebuffer=[];for(var c=0;c<6;c++)b.__webglFramebuffer[c]=o.createFramebuffer(),o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,U(b.format),b.width,b.height,0,U(b.format),U(b.type),null)}else b.__webglFramebuffer=o.createFramebuffer(),o.bindTexture(o.TEXTURE_2D,b.__webglTexture),K(o.TEXTURE_2D,b,b),o.texImage2D(o.TEXTURE_2D,0,U(b.format),b.width,b.height,0,U(b.format),U(b.type),null);o.bindRenderbuffer(o.RENDERBUFFER,
+b.__webglRenderbuffer);if(e)for(c=0;c<6;++c)o.bindFramebuffer(o.FRAMEBUFFER,b.__webglFramebuffer[c]),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+c,b.__webglTexture,0);else o.bindFramebuffer(o.FRAMEBUFFER,b.__webglFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_COMPONENT16,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,
+o.DEPTH_ATTACHMENT,o.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,b.width,b.height),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,b.__webglRenderbuffer)):o.renderbufferStorage(o.RENDERBUFFER,o.RGBA4,b.width,b.height);e?o.bindTexture(o.TEXTURE_CUBE_MAP,null):o.bindTexture(o.TEXTURE_2D,null);o.bindRenderbuffer(o.RENDERBUFFER,null);o.bindFramebuffer(o.FRAMEBUFFER,null)}var f,h;b?(e=e?b.__webglFramebuffer[b.activeCubeFace]:
+b.__webglFramebuffer,c=b.width,b=b.height,h=f=0):(e=null,c=M,b=fa,f=oa,h=xa);e!=la&&(o.bindFramebuffer(o.FRAMEBUFFER,e),o.viewport(f,h,c,b),la=e)}function C(b){b instanceof THREE.WebGLRenderTargetCube?(o.bindTexture(o.TEXTURE_CUBE_MAP,b.__webglTexture),o.generateMipmap(o.TEXTURE_CUBE_MAP),o.bindTexture(o.TEXTURE_CUBE_MAP,null)):(o.bindTexture(o.TEXTURE_2D,b.__webglTexture),o.generateMipmap(o.TEXTURE_2D),o.bindTexture(o.TEXTURE_2D,null))}function O(b,e){var c;b=="fragment"?c=o.createShader(o.FRAGMENT_SHADER):
+b=="vertex"&&(c=o.createShader(o.VERTEX_SHADER));o.shaderSource(c,e);o.compileShader(c);if(!o.getShaderParameter(c,o.COMPILE_STATUS))return console.error(o.getShaderInfoLog(c)),console.error(e),null;return c}function P(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return o.NEAREST;default:return o.LINEAR}}function U(b){switch(b){case THREE.RepeatWrapping:return o.REPEAT;case THREE.ClampToEdgeWrapping:return o.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return o.MIRRORED_REPEAT;
+case THREE.NearestFilter:return o.NEAREST;case THREE.NearestMipMapNearestFilter:return o.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return o.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return o.LINEAR;case THREE.LinearMipMapNearestFilter:return o.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return o.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return o.BYTE;case THREE.UnsignedByteType:return o.UNSIGNED_BYTE;case THREE.ShortType:return o.SHORT;case THREE.UnsignedShortType:return o.UNSIGNED_SHORT;
+case THREE.IntType:return o.INT;case THREE.UnsignedShortType:return o.UNSIGNED_INT;case THREE.FloatType:return o.FLOAT;case THREE.AlphaFormat:return o.ALPHA;case THREE.RGBFormat:return o.RGB;case THREE.RGBAFormat:return o.RGBA;case THREE.LuminanceFormat:return o.LUMINANCE;case THREE.LuminanceAlphaFormat:return o.LUMINANCE_ALPHA}return 0}var W=this,o,da=[],S=null,la=null,aa=-1,ia=null,ka=null,ma=null,ca=null,ha=null,T=null,Z=null,ea=null,oa=0,xa=0,M=0,fa=0,na=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
+new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ta=new THREE.Matrix4,sa=new Float32Array(16),Da=new Float32Array(16),Ca=new THREE.Vector4,Fa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ba=b.canvas!==void 0?b.canvas:document.createElement("canvas"),pa=b.stencil!==void 0?b.stencil:!0,L=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,$=b.antialias!==void 0?b.antialias:!1,V=b.clearColor!==void 0?new THREE.Color(b.clearColor):
+new THREE.Color(0),va=b.clearAlpha!==void 0?b.clearAlpha:0,ra=b.maxLights!==void 0?b.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=Ba;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;
+var ja,ya=[],b=THREE.ShaderLib.depthRGBA,ua=THREE.UniformsUtils.clone(b.uniforms),qa=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:ua}),Ha=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:ua,morphTargets:!0});qa._shadowPass=!0;Ha._shadowPass=!0;try{if(!(o=Ba.getContext("experimental-webgl",{antialias:$,stencil:pa,preserveDrawingBuffer:L})))throw"Error creating WebGL context.";console.log(navigator.userAgent+
+" | "+o.getParameter(o.VERSION)+" | "+o.getParameter(o.VENDOR)+" | "+o.getParameter(o.RENDERER)+" | "+o.getParameter(o.SHADING_LANGUAGE_VERSION))}catch(za){console.error(za)}o.clearColor(0,0,0,1);o.clearDepth(1);o.clearStencil(0);o.enable(o.DEPTH_TEST);o.depthFunc(o.LEQUAL);o.frontFace(o.CCW);o.cullFace(o.BACK);o.enable(o.CULL_FACE);o.enable(o.BLEND);o.blendEquation(o.FUNC_ADD);o.blendFunc(o.SRC_ALPHA,o.ONE_MINUS_SRC_ALPHA);o.clearColor(V.r,V.g,V.b,va);this.context=o;var Ia=o.getParameter(o.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
+0,Y={};Y.vertices=new Float32Array(16);Y.faces=new Uint16Array(6);pa=0;Y.vertices[pa++]=-1;Y.vertices[pa++]=-1;Y.vertices[pa++]=0;Y.vertices[pa++]=1;Y.vertices[pa++]=1;Y.vertices[pa++]=-1;Y.vertices[pa++]=1;Y.vertices[pa++]=1;Y.vertices[pa++]=1;Y.vertices[pa++]=1;Y.vertices[pa++]=1;Y.vertices[pa++]=0;Y.vertices[pa++]=-1;Y.vertices[pa++]=1;Y.vertices[pa++]=0;pa=Y.vertices[pa++]=0;Y.faces[pa++]=0;Y.faces[pa++]=1;Y.faces[pa++]=2;Y.faces[pa++]=0;Y.faces[pa++]=2;Y.faces[pa++]=3;Y.vertexBuffer=o.createBuffer();
+Y.elementBuffer=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,Y.vertexBuffer);o.bufferData(o.ARRAY_BUFFER,Y.vertices,o.STATIC_DRAW);o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,Y.elementBuffer);o.bufferData(o.ELEMENT_ARRAY_BUFFER,Y.faces,o.STATIC_DRAW);Y.program=o.createProgram();o.attachShader(Y.program,O("fragment",THREE.ShaderLib.sprite.fragmentShader));o.attachShader(Y.program,O("vertex",THREE.ShaderLib.sprite.vertexShader));o.linkProgram(Y.program);Y.attributes={};Y.uniforms={};Y.attributes.position=o.getAttribLocation(Y.program,
+"position");Y.attributes.uv=o.getAttribLocation(Y.program,"uv");Y.uniforms.uvOffset=o.getUniformLocation(Y.program,"uvOffset");Y.uniforms.uvScale=o.getUniformLocation(Y.program,"uvScale");Y.uniforms.rotation=o.getUniformLocation(Y.program,"rotation");Y.uniforms.scale=o.getUniformLocation(Y.program,"scale");Y.uniforms.alignment=o.getUniformLocation(Y.program,"alignment");Y.uniforms.color=o.getUniformLocation(Y.program,"color");Y.uniforms.map=o.getUniformLocation(Y.program,"map");Y.uniforms.opacity=
+o.getUniformLocation(Y.program,"opacity");Y.uniforms.useScreenCoordinates=o.getUniformLocation(Y.program,"useScreenCoordinates");Y.uniforms.affectedByDistance=o.getUniformLocation(Y.program,"affectedByDistance");Y.uniforms.screenPosition=o.getUniformLocation(Y.program,"screenPosition");Y.uniforms.modelViewMatrix=o.getUniformLocation(Y.program,"modelViewMatrix");Y.uniforms.projectionMatrix=o.getUniformLocation(Y.program,"projectionMatrix");var Ea=!1;this.setSize=function(b,e){Ba.width=b;Ba.height=
+e;this.setViewport(0,0,Ba.width,Ba.height)};this.setViewport=function(b,e,c,f){oa=b;xa=e;M=c;fa=f;o.viewport(oa,xa,M,fa)};this.setScissor=function(b,e,c,f){o.scissor(b,e,c,f)};this.enableScissorTest=function(b){b?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)};this.setClearColorHex=function(b,e){V.setHex(b);va=e;o.clearColor(V.r,V.g,V.b,va)};this.setClearColor=function(b,e){V.copy(b);va=e;o.clearColor(V.r,V.g,V.b,va)};this.getClearColor=function(){return V};this.getClearAlpha=function(){return va};
+this.clear=function(){o.clear(o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT|o.STENCIL_BUFFER_BIT)};this.getContext=function(){return o};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var e=b.geometry.geometryGroups[g];o.deleteBuffer(e.__webglVertexBuffer);o.deleteBuffer(e.__webglNormalBuffer);o.deleteBuffer(e.__webglTangentBuffer);
+o.deleteBuffer(e.__webglColorBuffer);o.deleteBuffer(e.__webglUVBuffer);o.deleteBuffer(e.__webglUV2Buffer);o.deleteBuffer(e.__webglSkinVertexABuffer);o.deleteBuffer(e.__webglSkinVertexBBuffer);o.deleteBuffer(e.__webglSkinIndicesBuffer);o.deleteBuffer(e.__webglSkinWeightsBuffer);o.deleteBuffer(e.__webglFaceBuffer);o.deleteBuffer(e.__webglLineBuffer);if(e.numMorphTargets)for(var c=0,f=e.numMorphTargets;c<f;c++)o.deleteBuffer(e.__webglMorphTargetsBuffers[c]);W.info.memory.geometries--}else if(b instanceof
+THREE.Ribbon)b=b.geometry,o.deleteBuffer(b.__webglVertexBuffer),o.deleteBuffer(b.__webglColorBuffer),W.info.memory.geometries--;else if(b instanceof THREE.Line)b=b.geometry,o.deleteBuffer(b.__webglVertexBuffer),o.deleteBuffer(b.__webglColorBuffer),W.info.memory.geometries--;else if(b instanceof THREE.ParticleSystem)b=b.geometry,o.deleteBuffer(b.__webglVertexBuffer),o.deleteBuffer(b.__webglColorBuffer),W.info.memory.geometries--};this.deallocateTexture=function(b){if(b.__webglInit)b.__webglInit=!1,
+o.deleteTexture(b.__webglTexture),W.info.memory.textures--};this.initMaterial=function(b,e,c,f){var h,k,m,n;b instanceof THREE.MeshDepthMaterial?n="depth":b instanceof THREE.MeshNormalMaterial?n="normal":b instanceof THREE.MeshBasicMaterial?n="basic":b instanceof THREE.MeshLambertMaterial?n="lambert":b instanceof THREE.MeshPhongMaterial?n="phong":b instanceof THREE.LineBasicMaterial?n="basic":b instanceof THREE.ParticleBasicMaterial&&(n="particle_basic");if(n){var p=THREE.ShaderLib[n];b.uniforms=
+THREE.UniformsUtils.clone(p.uniforms);b.vertexShader=p.vertexShader;b.fragmentShader=p.fragmentShader}var t,u,w;t=w=p=0;for(u=e.length;t<u;t++)m=e[t],m instanceof THREE.SpotLight&&w++,m instanceof THREE.DirectionalLight&&w++,m instanceof THREE.PointLight&&p++;p+w<=ra?t=w:(t=Math.ceil(ra*w/(p+w)),p=ra-t);m={directional:t,point:p};p=w=0;for(t=e.length;p<t;p++)u=e[p],u instanceof THREE.SpotLight&&u.castShadow&&w++;var v=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)v=f.bones.length;var x;a:{t=b.fragmentShader;
+u=b.vertexShader;var p=b.uniforms,e=b.attributes,c={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:c,useFog:b.fog,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:m.directional,maxPointLights:m.point,maxBones:v,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:w,
+alphaTest:b.alphaTest},L,f=[];n?f.push(n):(f.push(t),f.push(u));for(L in c)f.push(L),f.push(c[L]);n=f.join();L=0;for(f=da.length;L<f;L++)if(da[L].code==n){x=da[L].program;break a}L=o.createProgram();f=[Ia?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":
+"",c.skinning?"#define USE_SKINNING":"",c.morphTargets?"#define USE_MORPHTARGETS":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.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");
 m=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",c.useFog&&c.fog?"#define USE_FOG":"",c.useFog&&c.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",c.map?"#define USE_MAP":"",c.envMap?"#define USE_ENVMAP":"",c.lightMap?"#define USE_LIGHTMAP":"",c.vertexColors?"#define USE_COLOR":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",
-c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");o.attachShader(J,O("fragment",m+p));o.attachShader(J,O("vertex",f+u));o.linkProgram(J);o.getProgramParameter(J,o.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+o.getProgramParameter(J,o.VALIDATE_STATUS)+", gl error ["+
-o.getError()+"]");J.uniforms={};J.attributes={};var y,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(y in t)f.push(y);y=f;f=0;for(t=y.length;f<t;f++)p=y[f],J.uniforms[p]=o.getUniformLocation(J,p);f=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(y=0;y<c.maxMorphTargets;y++)f.push("morphTarget"+y);for(x in e)f.push(x);
-x=f;y=0;for(e=x.length;y<e;y++)c=x[y],J.attributes[c]=o.getAttribLocation(J,c);ea.push({program:J,code:n});V.info.memory.programs=ea.length;x=J}b.program=x;x=b.program.attributes;x.position>=0&&o.enableVertexAttribArray(x.position);x.color>=0&&o.enableVertexAttribArray(x.color);x.normal>=0&&o.enableVertexAttribArray(x.normal);x.tangent>=0&&o.enableVertexAttribArray(x.tangent);b.skinning&&x.skinVertexA>=0&&x.skinVertexB>=0&&x.skinIndex>=0&&x.skinWeight>=0&&(o.enableVertexAttribArray(x.skinVertexA),
+c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapSoft?"#define SHADOWMAP_WIDTH "+c.shadowMapWidth.toFixed(1):"",c.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+c.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");o.attachShader(L,O("fragment",m+t));o.attachShader(L,O("vertex",f+u));o.linkProgram(L);o.getProgramParameter(L,o.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+o.getProgramParameter(L,o.VALIDATE_STATUS)+", gl error ["+
+o.getError()+"]");L.uniforms={};L.attributes={};var y,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(y in p)f.push(y);y=f;f=0;for(p=y.length;f<p;f++)t=y[f],L.uniforms[t]=o.getUniformLocation(L,t);f=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(y=0;y<c.maxMorphTargets;y++)f.push("morphTarget"+y);for(x in e)f.push(x);
+x=f;y=0;for(e=x.length;y<e;y++)c=x[y],L.attributes[c]=o.getAttribLocation(L,c);da.push({program:L,code:n});W.info.memory.programs=da.length;x=L}b.program=x;x=b.program.attributes;x.position>=0&&o.enableVertexAttribArray(x.position);x.color>=0&&o.enableVertexAttribArray(x.color);x.normal>=0&&o.enableVertexAttribArray(x.normal);x.tangent>=0&&o.enableVertexAttribArray(x.tangent);b.skinning&&x.skinVertexA>=0&&x.skinVertexB>=0&&x.skinIndex>=0&&x.skinWeight>=0&&(o.enableVertexAttribArray(x.skinVertexA),
 o.enableVertexAttribArray(x.skinVertexB),o.enableVertexAttribArray(x.skinIndex),o.enableVertexAttribArray(x.skinWeight));if(b.attributes)for(k in b.attributes)x[k]!==void 0&&x[k]>=0&&o.enableVertexAttribArray(x[k]);if(b.morphTargets)for(k=b.numSupportedMorphTargets=0;k<this.maxMorphTargets;k++)y="morphTarget"+k,x[y]>=0&&(o.enableVertexAttribArray(x[y]),b.numSupportedMorphTargets++);b.uniformsList=[];for(h in b.uniforms)b.uniformsList.push([b.uniforms[h],h])};this.clearTarget=function(b,e,c,f){X(b);
-b=0;e&&(b|=o.COLOR_BUFFER_BIT);c&&(b|=o.DEPTH_BUFFER_BIT);f&&(b|=o.STENCIL_BUFFER_BIT);o.clear(b)};this.render=function(b,c,o,t){var J,W,ha,D,F,G,K,H,ra=b.lights,M=b.fog;this.shadowMapEnabled&&z(b,c);V.info.render.calls=0;V.info.render.vertices=0;V.info.render.faces=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(sa);c.projectionMatrix.flattenToArray(ua);qa.multiply(c.projectionMatrix,c.matrixWorldInverse);p(qa);this.initWebGLObjects(b);X(o);(this.autoClear||
-t)&&this.clear();F=b.__webglObjects.length;for(t=0;t<F;t++)if(J=b.__webglObjects[t],K=J.object,K.visible)if(!(K instanceof THREE.Mesh)||!K.frustumCulled||v(K)){if(K.matrixWorld.flattenToArray(K._objectMatrixArray),E(K,c,!0),w(J),J.render=!0,this.sortObjects)J.object.renderDepth?J.z=J.object.renderDepth:(xa.copy(K.position),qa.multiplyVector3(xa),J.z=xa.z)}else J.render=!1;else J.render=!1;this.sortObjects&&b.__webglObjects.sort(y);G=b.__webglObjectsImmediate.length;for(t=0;t<G;t++)J=b.__webglObjectsImmediate[t],
-K=J.object,K.visible&&(K.matrixAutoUpdate&&K.matrixWorld.flattenToArray(K._objectMatrixArray),E(K,c,!0),x(J));if(b.overrideMaterial){k(b.overrideMaterial.depthTest);L(b.overrideMaterial.blending);for(t=0;t<F;t++)if(J=b.__webglObjects[t],J.render)K=J.object,H=J.buffer,m(K),f(c,ra,M,b.overrideMaterial,H,K);for(t=0;t<G;t++)J=b.__webglObjectsImmediate[t],K=J.object,K.visible&&(m(K),W=e(c,ra,M,b.overrideMaterial,K),K.render(function(c){h(c,W,b.overrideMaterial.shading)}))}else{L(THREE.NormalBlending);
-for(t=F-1;t>=0;t--)if(J=b.__webglObjects[t],J.render){K=J.object;H=J.buffer;ha=J.opaque;m(K);for(J=0;J<ha.count;J++)D=ha.list[J],k(D.depthTest),n(D.depthWrite),u(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),f(c,ra,M,D,H,K)}for(t=0;t<G;t++)if(J=b.__webglObjectsImmediate[t],K=J.object,K.visible){ha=J.opaque;m(K);for(J=0;J<ha.count;J++)D=ha.list[J],k(D.depthTest),n(D.depthWrite),u(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),W=e(c,ra,M,D,K),K.render(function(b){h(b,W,D.shading)})}for(t=
-0;t<F;t++)if(J=b.__webglObjects[t],J.render){K=J.object;H=J.buffer;ha=J.transparent;m(K);for(J=0;J<ha.count;J++)D=ha.list[J],L(D.blending),k(D.depthTest),n(D.depthWrite),u(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),f(c,ra,M,D,H,K)}for(t=0;t<G;t++)if(J=b.__webglObjectsImmediate[t],K=J.object,K.visible){ha=J.transparent;m(K);for(J=0;J<ha.count;J++)D=ha.list[J],L(D.blending),k(D.depthTest),n(D.depthWrite),u(D.polygonOffset,D.polygonOffsetFactor,D.polygonOffsetUnits),W=e(c,ra,M,D,K),
-K.render(function(b){h(b,W,D.shading)})}}b.__webglSprites.length&&A(b,c);o&&o.minFilter!==THREE.NearestFilter&&o.minFilter!==THREE.LinearFilter&&C(o)};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var e=b.__objectsAdded[0],f=b,h=void 0,k=void 0,m=void 0;if(!e.__webglInit)if(e.__webglInit=!0,e._modelViewMatrix=new THREE.Matrix4,e._normalMatrixArray=new Float32Array(9),e._modelViewMatrixArray=
-new Float32Array(16),e._objectMatrixArray=new Float32Array(16),e.matrixWorld.flattenToArray(e._objectMatrixArray),e instanceof THREE.Mesh)for(h in k=e.geometry,k.geometryGroups==void 0&&N(k),k.geometryGroups){if(m=k.geometryGroups[h],!m.__webglVertexBuffer){var n=m;n.__webglVertexBuffer=o.createBuffer();n.__webglNormalBuffer=o.createBuffer();n.__webglTangentBuffer=o.createBuffer();n.__webglColorBuffer=o.createBuffer();n.__webglUVBuffer=o.createBuffer();n.__webglUV2Buffer=o.createBuffer();n.__webglSkinVertexABuffer=
-o.createBuffer();n.__webglSkinVertexBBuffer=o.createBuffer();n.__webglSkinIndicesBuffer=o.createBuffer();n.__webglSkinWeightsBuffer=o.createBuffer();n.__webglFaceBuffer=o.createBuffer();n.__webglLineBuffer=o.createBuffer();if(n.numMorphTargets){var t=void 0,p=void 0;n.__webglMorphTargetsBuffers=[];t=0;for(p=n.numMorphTargets;t<p;t++)n.__webglMorphTargetsBuffers.push(o.createBuffer())}V.info.memory.geometries++;for(var n=e,w=void 0,u=void 0,v=void 0,x=v=void 0,J=void 0,y=void 0,W=y=t=0,z=v=u=void 0,
-v=p=z=u=w=void 0,x=n.geometry,J=x.faces,z=m.faces,w=0,u=z.length;w<u;w++)v=z[w],v=J[v],v instanceof THREE.Face3?(t+=3,y+=1,W+=3):v instanceof THREE.Face4&&(t+=4,y+=2,W+=4);for(var w=m,u=n,ha=z=J=void 0,A=void 0,ha=void 0,v=[],J=0,z=u.materials.length;J<z;J++)if(ha=u.materials[J],ha instanceof THREE.MeshFaceMaterial){ha=0;for(l=w.materials.length;ha<l;ha++)(A=w.materials[ha])&&v.push(A)}else(A=ha)&&v.push(A);w=v;m.__materials=w;a:{J=u=void 0;z=w.length;for(u=0;u<z;u++)if(J=w[u],J.map||J.lightMap||
-J instanceof THREE.ShaderMaterial){u=!0;break a}u=!1}a:{z=J=void 0;v=w.length;for(J=0;J<v;J++)if(z=w[J],!(z instanceof THREE.MeshBasicMaterial&&!z.envMap||z instanceof THREE.MeshDepthMaterial)){z=z&&z.shading!=void 0&&z.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}z=!1}a:{v=J=void 0;ha=w.length;for(J=0;J<ha;J++)if(v=w[J],v.vertexColors){v=v.vertexColors;break a}v=!1}m.__vertexArray=new Float32Array(t*3);if(z)m.__normalArray=new Float32Array(t*3);if(x.hasTangents)m.__tangentArray=
-new Float32Array(t*4);if(v)m.__colorArray=new Float32Array(t*3);if(u){if(x.faceUvs.length>0||x.faceVertexUvs.length>0)m.__uvArray=new Float32Array(t*2);if(x.faceUvs.length>1||x.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(t*2)}if(n.geometry.skinWeights.length&&n.geometry.skinIndices.length)m.__skinVertexAArray=new Float32Array(t*4),m.__skinVertexBArray=new Float32Array(t*4),m.__skinIndexArray=new Float32Array(t*4),m.__skinWeightArray=new Float32Array(t*4);m.__faceArray=new Uint16Array(y*3+
-(n.geometry.edgeFaces?n.geometry.edgeFaces.length*6:0));m.__lineArray=new Uint16Array(W*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];x=0;for(J=m.numMorphTargets;x<J;x++)m.__morphTargetsArrays.push(new Float32Array(t*3))}m.__needsSmoothNormals=z==THREE.SmoothShading;m.__uvType=u;m.__vertexColorType=v;m.__normalType=z;m.__webglFaceCount=y*3+(n.geometry.edgeFaces?n.geometry.edgeFaces.length*6:0);m.__webglLineCount=W*2;x=0;for(J=w.length;x<J;x++)if(u=w[x],u.attributes){if(m.__webglCustomAttributes===
-void 0)m.__webglCustomAttributes={};for(a in u.attributes){v=u.attributes[a];z={};for(p in v)z[p]=v[p];if(!z.__webglInitialized||z.createUniqueBuffers)z.__webglInitialized=!0,y=1,z.type==="v2"?y=2:z.type==="v3"?y=3:z.type==="v4"?y=4:z.type==="c"&&(y=3),z.size=y,z.array=new Float32Array(t*y),z.buffer=o.createBuffer(),z.buffer.belongsToAttribute=a,v.needsUpdate=!0,z.__original=v;m.__webglCustomAttributes[a]=z}}m.__inittedArrays=!0;k.__dirtyVertices=!0;k.__dirtyMorphTargets=!0;k.__dirtyElements=!0;k.__dirtyUvs=
-!0;k.__dirtyNormals=!0;k.__dirtyTangents=!0;k.__dirtyColors=!0}}else if(e instanceof THREE.Ribbon){if(k=e.geometry,!k.__webglVertexBuffer)m=k,m.__webglVertexBuffer=o.createBuffer(),m.__webglColorBuffer=o.createBuffer(),V.info.memory.geometries++,m=k,n=m.vertices.length,m.__vertexArray=new Float32Array(n*3),m.__colorArray=new Float32Array(n*3),m.__webglVertexCount=n,k.__dirtyVertices=!0,k.__dirtyColors=!0}else if(e instanceof THREE.Line){if(k=e.geometry,!k.__webglVertexBuffer)m=k,m.__webglVertexBuffer=
-o.createBuffer(),m.__webglColorBuffer=o.createBuffer(),V.info.memory.geometries++,m=k,n=m.vertices.length,m.__vertexArray=new Float32Array(n*3),m.__colorArray=new Float32Array(n*3),m.__webglLineCount=n,k.__dirtyVertices=!0,k.__dirtyColors=!0}else if(e instanceof THREE.ParticleSystem&&(k=e.geometry,!k.__webglVertexBuffer)){m=k;m.__webglVertexBuffer=o.createBuffer();m.__webglColorBuffer=o.createBuffer();V.info.geometries++;m=k;n=e;t=m.vertices.length;m.__vertexArray=new Float32Array(t*3);m.__colorArray=
-new Float32Array(t*3);m.__sortArray=[];m.__webglParticleCount=t;m.__materials=n.materials;W=y=p=void 0;p=0;for(y=n.materials.length;p<y;p++)if(W=n.materials[p],W.attributes){if(m.__webglCustomAttributes===void 0)m.__webglCustomAttributes={};for(a in W.attributes){originalAttribute=W.attributes[a];attribute={};for(property in originalAttribute)attribute[property]=originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type===
-"v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(t*size),attribute.buffer=o.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;m.__webglCustomAttributes[a]=attribute}}k.__dirtyVertices=!0;k.__dirtyColors=!0}if(!e.__webglActive){if(e instanceof THREE.Mesh)for(h in k=e.geometry,k.geometryGroups)m=k.geometryGroups[h],Q(f.__webglObjects,
-m,e);else e instanceof THREE.Ribbon||e instanceof THREE.Line||e instanceof THREE.ParticleSystem?(k=e.geometry,Q(f.__webglObjects,k,e)):THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes?f.__webglObjectsImmediate.push({object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}}):e instanceof THREE.Sprite&&f.__webglSprites.push(e);e.__webglActive=!0}b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){e=b.__objectsRemoved[0];f=b;if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||
-e instanceof THREE.Ribbon||e instanceof THREE.Line)G(f.__webglObjects,e);else if(e instanceof THREE.Sprite){f=f.__webglSprites;h=e;k=void 0;for(k=f.length-1;k>=0;k--)f[k]==h&&f.splice(k,1)}else e instanceof THREE.MarchingCubes&&G(f.__webglObjectsImmediate,e);e.__webglActive=!1;b.__objectsRemoved.splice(0,1)}e=0;for(f=b.__webglObjects.length;e<f;e++)if(k=b.__webglObjects[e].object,p=m=h=void 0,k instanceof THREE.Mesh){h=k.geometry;n=0;for(t=h.geometryGroupsList.length;n<t;n++)if(m=h.geometryGroupsList[n],
-p=D(m),h.__dirtyVertices||h.__dirtyMorphTargets||h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||p)if(p=m,y=o.DYNAMIC_DRAW,W=!h.dynamic,p.__inittedArrays){var E=w=x=void 0,K=void 0,H=E=void 0,ra=void 0,M=void 0,ia=void 0,ga=A=ha=v=z=J=u=void 0,ca=void 0,L=void 0,I=K=ia=K=M=ra=void 0,B=void 0,C=B=I=ra=void 0,qa=void 0,Z=C=B=I=E=E=H=ia=K=C=B=I=qa=C=B=I=qa=C=B=I=void 0,T=0,O=0,ua=0,aa=0,S=0,za=0,P=0,X=0,oa=0,R=0,U=0,C=I=0,C=void 0,fa=p.__vertexArray,na=p.__uvArray,
-ja=p.__uv2Array,la=p.__normalArray,Y=p.__tangentArray,ya=p.__colorArray,$=p.__skinVertexAArray,sa=p.__skinVertexBArray,da=p.__skinIndexArray,ea=p.__skinWeightArray,ma=p.__morphTargetsArrays,Ba=p.__webglCustomAttributes,B=void 0,va=p.__faceArray,pa=p.__lineArray,Ha=p.__needsSmoothNormals,J=p.__vertexColorType,u=p.__uvType,z=p.__normalType,xa=k.geometry,ta=xa.__dirtyVertices,Da=xa.__dirtyElements,Aa=xa.__dirtyUvs,Ea=xa.__dirtyNormals,Ga=xa.__dirtyTangents,bb=xa.__dirtyColors,cb=xa.__dirtyMorphTargets,
-Pa=xa.vertices,eb=p.faces,hb=xa.faces,fb=xa.faceVertexUvs[0],gb=xa.faceVertexUvs[1],Qa=xa.skinVerticesA,Ra=xa.skinVerticesB,Sa=xa.skinIndices,Ja=xa.skinWeights,Ia=xa.morphTargets;if(Ba)for(Z in Ba)Ba[Z].offset=0,Ba[Z].offsetSrc=0;x=0;for(w=eb.length;x<w;x++)if(E=eb[x],K=hb[E],fb&&(v=fb[E]),gb&&(ha=gb[E]),E=K.vertexNormals,H=K.normal,ra=K.vertexColors,M=K.color,ia=K.vertexTangents,K instanceof THREE.Face3){if(ta)A=Pa[K.a].position,ga=Pa[K.b].position,ca=Pa[K.c].position,fa[O]=A.x,fa[O+1]=A.y,fa[O+
-2]=A.z,fa[O+3]=ga.x,fa[O+4]=ga.y,fa[O+5]=ga.z,fa[O+6]=ca.x,fa[O+7]=ca.y,fa[O+8]=ca.z,O+=9;if(Ba)for(Z in Ba)if(B=Ba[Z],B.__original.needsUpdate)I=B.offset,C=B.offsetSrc,B.size===1?(B.boundTo===void 0||B.boundTo==="vertices"?(B.array[I]=B.value[K.a],B.array[I+1]=B.value[K.b],B.array[I+2]=B.value[K.c]):B.boundTo==="faces"?(C=B.value[C],B.array[I]=C,B.array[I+1]=C,B.array[I+2]=C,B.offsetSrc++):B.boundTo==="faceVertices"&&(B.array[I]=B.value[C],B.array[I+1]=B.value[C+1],B.array[I+2]=B.value[C+2],B.offsetSrc+=
-3),B.offset+=3):(B.boundTo===void 0||B.boundTo==="vertices"?(A=B.value[K.a],ga=B.value[K.b],ca=B.value[K.c]):B.boundTo==="faces"?(ca=ga=A=C=B.value[C],B.offsetSrc++):B.boundTo==="faceVertices"&&(A=B.value[C],ga=B.value[C+1],ca=B.value[C+2],B.offsetSrc+=3),B.size===2?(B.array[I]=A.x,B.array[I+1]=A.y,B.array[I+2]=ga.x,B.array[I+3]=ga.y,B.array[I+4]=ca.x,B.array[I+5]=ca.y,B.offset+=6):B.size===3?(B.type==="c"?(B.array[I]=A.r,B.array[I+1]=A.g,B.array[I+2]=A.b,B.array[I+3]=ga.r,B.array[I+4]=ga.g,B.array[I+
-5]=ga.b,B.array[I+6]=ca.r,B.array[I+7]=ca.g,B.array[I+8]=ca.b):(B.array[I]=A.x,B.array[I+1]=A.y,B.array[I+2]=A.z,B.array[I+3]=ga.x,B.array[I+4]=ga.y,B.array[I+5]=ga.z,B.array[I+6]=ca.x,B.array[I+7]=ca.y,B.array[I+8]=ca.z),B.offset+=9):(B.array[I]=A.x,B.array[I+1]=A.y,B.array[I+2]=A.z,B.array[I+3]=A.w,B.array[I+4]=ga.x,B.array[I+5]=ga.y,B.array[I+6]=ga.z,B.array[I+7]=ga.w,B.array[I+8]=ca.x,B.array[I+9]=ca.y,B.array[I+10]=ca.z,B.array[I+11]=ca.w,B.offset+=12));if(cb){I=0;for(B=Ia.length;I<B;I++)A=Ia[I].vertices[K.a].position,
-ga=Ia[I].vertices[K.b].position,ca=Ia[I].vertices[K.c].position,C=ma[I],C[U]=A.x,C[U+1]=A.y,C[U+2]=A.z,C[U+3]=ga.x,C[U+4]=ga.y,C[U+5]=ga.z,C[U+6]=ca.x,C[U+7]=ca.y,C[U+8]=ca.z;U+=9}if(Ja.length)I=Ja[K.a],B=Ja[K.b],C=Ja[K.c],ea[R]=I.x,ea[R+1]=I.y,ea[R+2]=I.z,ea[R+3]=I.w,ea[R+4]=B.x,ea[R+5]=B.y,ea[R+6]=B.z,ea[R+7]=B.w,ea[R+8]=C.x,ea[R+9]=C.y,ea[R+10]=C.z,ea[R+11]=C.w,I=Sa[K.a],B=Sa[K.b],C=Sa[K.c],da[R]=I.x,da[R+1]=I.y,da[R+2]=I.z,da[R+3]=I.w,da[R+4]=B.x,da[R+5]=B.y,da[R+6]=B.z,da[R+7]=B.w,da[R+8]=C.x,
-da[R+9]=C.y,da[R+10]=C.z,da[R+11]=C.w,I=Qa[K.a],B=Qa[K.b],C=Qa[K.c],$[R]=I.x,$[R+1]=I.y,$[R+2]=I.z,$[R+3]=1,$[R+4]=B.x,$[R+5]=B.y,$[R+6]=B.z,$[R+7]=1,$[R+8]=C.x,$[R+9]=C.y,$[R+10]=C.z,$[R+11]=1,I=Ra[K.a],B=Ra[K.b],C=Ra[K.c],sa[R]=I.x,sa[R+1]=I.y,sa[R+2]=I.z,sa[R+3]=1,sa[R+4]=B.x,sa[R+5]=B.y,sa[R+6]=B.z,sa[R+7]=1,sa[R+8]=C.x,sa[R+9]=C.y,sa[R+10]=C.z,sa[R+11]=1,R+=12;if(bb&&J)ra.length==3&&J==THREE.VertexColors?(K=ra[0],I=ra[1],B=ra[2]):B=I=K=M,ya[oa]=K.r,ya[oa+1]=K.g,ya[oa+2]=K.b,ya[oa+3]=I.r,ya[oa+
-4]=I.g,ya[oa+5]=I.b,ya[oa+6]=B.r,ya[oa+7]=B.g,ya[oa+8]=B.b,oa+=9;if(Ga&&xa.hasTangents)ra=ia[0],M=ia[1],K=ia[2],Y[P]=ra.x,Y[P+1]=ra.y,Y[P+2]=ra.z,Y[P+3]=ra.w,Y[P+4]=M.x,Y[P+5]=M.y,Y[P+6]=M.z,Y[P+7]=M.w,Y[P+8]=K.x,Y[P+9]=K.y,Y[P+10]=K.z,Y[P+11]=K.w,P+=12;if(Ea&&z)if(E.length==3&&Ha)for(ia=0;ia<3;ia++)H=E[ia],la[za]=H.x,la[za+1]=H.y,la[za+2]=H.z,za+=3;else for(ia=0;ia<3;ia++)la[za]=H.x,la[za+1]=H.y,la[za+2]=H.z,za+=3;if(Aa&&v!==void 0&&u)for(ia=0;ia<3;ia++)E=v[ia],na[ua]=E.u,na[ua+1]=E.v,ua+=2;if(Aa&&
-ha!==void 0&&u)for(ia=0;ia<3;ia++)E=ha[ia],ja[aa]=E.u,ja[aa+1]=E.v,aa+=2;Da&&(va[S]=T,va[S+1]=T+1,va[S+2]=T+2,S+=3,pa[X]=T,pa[X+1]=T+1,pa[X+2]=T,pa[X+3]=T+2,pa[X+4]=T+1,pa[X+5]=T+2,X+=6,T+=3)}else if(K instanceof THREE.Face4){if(ta)A=Pa[K.a].position,ga=Pa[K.b].position,ca=Pa[K.c].position,L=Pa[K.d].position,fa[O]=A.x,fa[O+1]=A.y,fa[O+2]=A.z,fa[O+3]=ga.x,fa[O+4]=ga.y,fa[O+5]=ga.z,fa[O+6]=ca.x,fa[O+7]=ca.y,fa[O+8]=ca.z,fa[O+9]=L.x,fa[O+10]=L.y,fa[O+11]=L.z,O+=12;if(Ba)for(Z in Ba)if(B=Ba[Z],B.__original.needsUpdate)I=
-B.offset,C=B.offsetSrc,B.size===1?(B.boundTo===void 0||B.boundTo==="vertices"?(B.array[I]=B.value[K.a],B.array[I+1]=B.value[K.b],B.array[I+2]=B.value[K.c],B.array[I+3]=B.value[K.d]):B.boundTo==="faces"?(C=B.value[C],B.array[I]=C,B.array[I+1]=C,B.array[I+2]=C,B.array[I+3]=C,B.offsetSrc++):B.boundTo==="faceVertices"&&(B.array[I]=B.value[C],B.array[I+1]=B.value[C+1],B.array[I+2]=B.value[C+2],B.array[I+3]=B.value[C+3],B.offsetSrc+=4),B.offset+=4):(B.boundTo===void 0||B.boundTo==="vertices"?(A=B.value[K.a],
-ga=B.value[K.b],ca=B.value[K.c],L=B.value[K.d]):B.boundTo==="faces"?(L=ca=ga=A=C=B.value[C],B.offsetSrc++):B.boundTo==="faceVertices"&&(A=B.value[C],ga=B.value[C+1],ca=B.value[C+2],L=B.value[C+3],B.offsetSrc+=4),B.size===2?(B.array[I]=A.x,B.array[I+1]=A.y,B.array[I+2]=ga.x,B.array[I+3]=ga.y,B.array[I+4]=ca.x,B.array[I+5]=ca.y,B.array[I+6]=L.x,B.array[I+7]=L.y,B.offset+=8):B.size===3?(B.type==="c"?(B.array[I]=A.r,B.array[I+1]=A.g,B.array[I+2]=A.b,B.array[I+3]=ga.r,B.array[I+4]=ga.g,B.array[I+5]=ga.b,
-B.array[I+6]=ca.r,B.array[I+7]=ca.g,B.array[I+8]=ca.b,B.array[I+9]=L.r,B.array[I+10]=L.g,B.array[I+11]=L.b):(B.array[I]=A.x,B.array[I+1]=A.y,B.array[I+2]=A.z,B.array[I+3]=ga.x,B.array[I+4]=ga.y,B.array[I+5]=ga.z,B.array[I+6]=ca.x,B.array[I+7]=ca.y,B.array[I+8]=ca.z,B.array[I+9]=L.x,B.array[I+10]=L.y,B.array[I+11]=L.z),B.offset+=12):(B.array[I]=A.x,B.array[I+1]=A.y,B.array[I+2]=A.z,B.array[I+3]=A.w,B.array[I+4]=ga.x,B.array[I+5]=ga.y,B.array[I+6]=ga.z,B.array[I+7]=ga.w,B.array[I+8]=ca.x,B.array[I+
-9]=ca.y,B.array[I+10]=ca.z,B.array[I+11]=ca.w,B.array[I+12]=L.x,B.array[I+13]=L.y,B.array[I+14]=L.z,B.array[I+15]=L.w,B.offset+=16));if(cb){I=0;for(B=Ia.length;I<B;I++)A=Ia[I].vertices[K.a].position,ga=Ia[I].vertices[K.b].position,ca=Ia[I].vertices[K.c].position,L=Ia[I].vertices[K.d].position,C=ma[I],C[U]=A.x,C[U+1]=A.y,C[U+2]=A.z,C[U+3]=ga.x,C[U+4]=ga.y,C[U+5]=ga.z,C[U+6]=ca.x,C[U+7]=ca.y,C[U+8]=ca.z,C[U+9]=L.x,C[U+10]=L.y,C[U+11]=L.z;U+=12}if(Ja.length)I=Ja[K.a],B=Ja[K.b],C=Ja[K.c],qa=Ja[K.d],ea[R]=
-I.x,ea[R+1]=I.y,ea[R+2]=I.z,ea[R+3]=I.w,ea[R+4]=B.x,ea[R+5]=B.y,ea[R+6]=B.z,ea[R+7]=B.w,ea[R+8]=C.x,ea[R+9]=C.y,ea[R+10]=C.z,ea[R+11]=C.w,ea[R+12]=qa.x,ea[R+13]=qa.y,ea[R+14]=qa.z,ea[R+15]=qa.w,I=Sa[K.a],B=Sa[K.b],C=Sa[K.c],qa=Sa[K.d],da[R]=I.x,da[R+1]=I.y,da[R+2]=I.z,da[R+3]=I.w,da[R+4]=B.x,da[R+5]=B.y,da[R+6]=B.z,da[R+7]=B.w,da[R+8]=C.x,da[R+9]=C.y,da[R+10]=C.z,da[R+11]=C.w,da[R+12]=qa.x,da[R+13]=qa.y,da[R+14]=qa.z,da[R+15]=qa.w,I=Qa[K.a],B=Qa[K.b],C=Qa[K.c],qa=Qa[K.d],$[R]=I.x,$[R+1]=I.y,$[R+2]=
-I.z,$[R+3]=1,$[R+4]=B.x,$[R+5]=B.y,$[R+6]=B.z,$[R+7]=1,$[R+8]=C.x,$[R+9]=C.y,$[R+10]=C.z,$[R+11]=1,$[R+12]=qa.x,$[R+13]=qa.y,$[R+14]=qa.z,$[R+15]=1,I=Ra[K.a],B=Ra[K.b],C=Ra[K.c],K=Ra[K.d],sa[R]=I.x,sa[R+1]=I.y,sa[R+2]=I.z,sa[R+3]=1,sa[R+4]=B.x,sa[R+5]=B.y,sa[R+6]=B.z,sa[R+7]=1,sa[R+8]=C.x,sa[R+9]=C.y,sa[R+10]=C.z,sa[R+11]=1,sa[R+12]=K.x,sa[R+13]=K.y,sa[R+14]=K.z,sa[R+15]=1,R+=16;if(bb&&J)ra.length==4&&J==THREE.VertexColors?(K=ra[0],I=ra[1],B=ra[2],ra=ra[3]):ra=B=I=K=M,ya[oa]=K.r,ya[oa+1]=K.g,ya[oa+
-2]=K.b,ya[oa+3]=I.r,ya[oa+4]=I.g,ya[oa+5]=I.b,ya[oa+6]=B.r,ya[oa+7]=B.g,ya[oa+8]=B.b,ya[oa+9]=ra.r,ya[oa+10]=ra.g,ya[oa+11]=ra.b,oa+=12;if(Ga&&xa.hasTangents)ra=ia[0],M=ia[1],K=ia[2],ia=ia[3],Y[P]=ra.x,Y[P+1]=ra.y,Y[P+2]=ra.z,Y[P+3]=ra.w,Y[P+4]=M.x,Y[P+5]=M.y,Y[P+6]=M.z,Y[P+7]=M.w,Y[P+8]=K.x,Y[P+9]=K.y,Y[P+10]=K.z,Y[P+11]=K.w,Y[P+12]=ia.x,Y[P+13]=ia.y,Y[P+14]=ia.z,Y[P+15]=ia.w,P+=16;if(Ea&&z)if(E.length==4&&Ha)for(ia=0;ia<4;ia++)H=E[ia],la[za]=H.x,la[za+1]=H.y,la[za+2]=H.z,za+=3;else for(ia=0;ia<
-4;ia++)la[za]=H.x,la[za+1]=H.y,la[za+2]=H.z,za+=3;if(Aa&&v!==void 0&&u)for(ia=0;ia<4;ia++)E=v[ia],na[ua]=E.u,na[ua+1]=E.v,ua+=2;if(Aa&&ha!==void 0&&u)for(ia=0;ia<4;ia++)E=ha[ia],ja[aa]=E.u,ja[aa+1]=E.v,aa+=2;Da&&(va[S]=T,va[S+1]=T+1,va[S+2]=T+3,va[S+3]=T+1,va[S+4]=T+2,va[S+5]=T+3,S+=6,pa[X]=T,pa[X+1]=T+1,pa[X+2]=T,pa[X+3]=T+3,pa[X+4]=T+1,pa[X+5]=T+2,pa[X+6]=T+2,pa[X+7]=T+3,X+=8,T+=4)}ta&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,fa,y));if(Ba)for(Z in Ba)B=Ba[Z],
-B.__original.needsUpdate&&(o.bindBuffer(o.ARRAY_BUFFER,B.buffer),o.bufferData(o.ARRAY_BUFFER,B.array,y));if(cb){I=0;for(B=Ia.length;I<B;I++)o.bindBuffer(o.ARRAY_BUFFER,p.__webglMorphTargetsBuffers[I]),o.bufferData(o.ARRAY_BUFFER,ma[I],y)}bb&&oa>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,ya,y));Ea&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglNormalBuffer),o.bufferData(o.ARRAY_BUFFER,la,y));Ga&&xa.hasTangents&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglTangentBuffer),o.bufferData(o.ARRAY_BUFFER,
-Y,y));Aa&&ua>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,na,y));Aa&&aa>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,ja,y));Da&&(o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,p.__webglFaceBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,va,y),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,p.__webglLineBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,pa,y));R>0&&(o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,$,y),o.bindBuffer(o.ARRAY_BUFFER,
-p.__webglSkinVertexBBuffer),o.bufferData(o.ARRAY_BUFFER,sa,y),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,da,y),o.bindBuffer(o.ARRAY_BUFFER,p.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER,ea,y));W&&(delete p.__inittedArrays,delete p.__colorArray,delete p.__normalArray,delete p.__tangentArray,delete p.__uvArray,delete p.__uv2Array,delete p.__faceArray,delete p.__vertexArray,delete p.__lineArray,delete p.__skinVertexAArray,delete p.__skinVertexBArray,
-delete p.__skinIndexArray,delete p.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;F(m)}else if(k instanceof THREE.Ribbon){h=k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=o.DYNAMIC_DRAW;n=x=W=W=void 0;w=k.vertices;t=k.colors;u=w.length;p=t.length;J=k.__vertexArray;y=k.__colorArray;z=k.__dirtyColors;if(k.__dirtyVertices){for(W=0;W<u;W++)x=w[W].position,n=W*3,J[n]=x.x,J[n+1]=x.y,
-J[n+2]=x.z;o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer);o.bufferData(o.ARRAY_BUFFER,J,m)}if(z){for(W=0;W<p;W++)color=t[W],n=W*3,y[n]=color.r,y[n+1]=color.g,y[n+2]=color.b;o.bindBuffer(o.ARRAY_BUFFER,k.__webglColorBuffer);o.bufferData(o.ARRAY_BUFFER,y,m)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(k instanceof THREE.Line){h=k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=o.DYNAMIC_DRAW;n=x=W=W=void 0;w=k.vertices;t=k.colors;u=w.length;p=t.length;J=k.__vertexArray;y=k.__colorArray;
-z=k.__dirtyColors;if(k.__dirtyVertices){for(W=0;W<u;W++)x=w[W].position,n=W*3,J[n]=x.x,J[n+1]=x.y,J[n+2]=x.z;o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer);o.bufferData(o.ARRAY_BUFFER,J,m)}if(z){for(W=0;W<p;W++)color=t[W],n=W*3,y[n]=color.r,y[n+1]=color.g,y[n+2]=color.b;o.bindBuffer(o.ARRAY_BUFFER,k.__webglColorBuffer);o.bufferData(o.ARRAY_BUFFER,y,m)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(k instanceof THREE.ParticleSystem)h=k.geometry,p=D(h),(h.__dirtyVertices||h.__dirtyColors||k.sortParticles||
-p)&&c(h,o.DYNAMIC_DRAW,k),h.__dirtyVertices=!1,h.__dirtyColors=!1,F(h)};this.setFaceCulling=function(b,e){b?(!e||e=="ccw"?o.frontFace(o.CCW):o.frontFace(o.CW),b=="back"?o.cullFace(o.BACK):b=="front"?o.cullFace(o.FRONT):o.cullFace(o.FRONT_AND_BACK),o.enable(o.CULL_FACE)):o.disable(o.CULL_FACE)};this.supportsVertexTextures=function(){return Ba}};
+b=0;e&&(b|=o.COLOR_BUFFER_BIT);c&&(b|=o.DEPTH_BUFFER_BIT);f&&(b|=o.STENCIL_BUFFER_BIT);o.clear(b)};this.render=function(b,c,o,t){var L,V,$,E,F,G,M,va,ja=b.lights,K=b.fog;aa=-1;this.shadowMapEnabled&&z(b,c);W.info.render.calls=0;W.info.render.vertices=0;W.info.render.faces=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Da);c.projectionMatrix.flattenToArray(sa);ta.multiply(c.projectionMatrix,c.matrixWorldInverse);p(ta);this.initWebGLObjects(b);X(o);
+(this.autoClear||t)&&this.clear();F=b.__webglObjects.length;for(t=0;t<F;t++)if(L=b.__webglObjects[t],M=L.object,M.visible)if(!(M instanceof THREE.Mesh)||!M.frustumCulled||v(M)){if(M.matrixWorld.flattenToArray(M._objectMatrixArray),D(M,c,!0),w(L),L.render=!0,this.sortObjects)L.object.renderDepth?L.z=L.object.renderDepth:(Ca.copy(M.position),ta.multiplyVector3(Ca),L.z=Ca.z)}else L.render=!1;else L.render=!1;this.sortObjects&&b.__webglObjects.sort(y);G=b.__webglObjectsImmediate.length;for(t=0;t<G;t++)L=
+b.__webglObjectsImmediate[t],M=L.object,M.visible&&(M.matrixAutoUpdate&&M.matrixWorld.flattenToArray(M._objectMatrixArray),D(M,c,!0),x(L));if(b.overrideMaterial){k(b.overrideMaterial.depthTest);H(b.overrideMaterial.blending);for(t=0;t<F;t++)if(L=b.__webglObjects[t],L.render)M=L.object,va=L.buffer,m(M),f(c,ja,K,b.overrideMaterial,va,M);for(t=0;t<G;t++)L=b.__webglObjectsImmediate[t],M=L.object,M.visible&&(m(M),V=e(c,ja,K,b.overrideMaterial,M),M.render(function(c){h(c,V,b.overrideMaterial.shading)}))}else{H(THREE.NormalBlending);
+for(t=F-1;t>=0;t--)if(L=b.__webglObjects[t],L.render){M=L.object;va=L.buffer;$=L.opaque;m(M);for(L=0;L<$.count;L++)E=$.list[L],k(E.depthTest),n(E.depthWrite),u(E.polygonOffset,E.polygonOffsetFactor,E.polygonOffsetUnits),f(c,ja,K,E,va,M)}for(t=0;t<G;t++)if(L=b.__webglObjectsImmediate[t],M=L.object,M.visible){$=L.opaque;m(M);for(L=0;L<$.count;L++)E=$.list[L],k(E.depthTest),n(E.depthWrite),u(E.polygonOffset,E.polygonOffsetFactor,E.polygonOffsetUnits),V=e(c,ja,K,E,M),M.render(function(b){h(b,V,E.shading)})}for(t=
+0;t<F;t++)if(L=b.__webglObjects[t],L.render){M=L.object;va=L.buffer;$=L.transparent;m(M);for(L=0;L<$.count;L++)E=$.list[L],H(E.blending),k(E.depthTest),n(E.depthWrite),u(E.polygonOffset,E.polygonOffsetFactor,E.polygonOffsetUnits),f(c,ja,K,E,va,M)}for(t=0;t<G;t++)if(L=b.__webglObjectsImmediate[t],M=L.object,M.visible){$=L.transparent;m(M);for(L=0;L<$.count;L++)E=$.list[L],H(E.blending),k(E.depthTest),n(E.depthWrite),u(E.polygonOffset,E.polygonOffsetFactor,E.polygonOffsetUnits),V=e(c,ja,K,E,M),M.render(function(b){h(b,
+V,E.shading)})}}b.__webglSprites.length&&B(b,c);o&&o.minFilter!==THREE.NearestFilter&&o.minFilter!==THREE.LinearFilter&&C(o)};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var e=b.__objectsAdded[0],f=b,h=void 0,k=void 0,m=void 0;if(!e.__webglInit)if(e.__webglInit=!0,e._modelViewMatrix=new THREE.Matrix4,e._normalMatrixArray=new Float32Array(9),e._modelViewMatrixArray=new Float32Array(16),e._objectMatrixArray=
+new Float32Array(16),e.matrixWorld.flattenToArray(e._objectMatrixArray),e instanceof THREE.Mesh)for(h in k=e.geometry,k.geometryGroups==void 0&&N(k),k.geometryGroups){if(m=k.geometryGroups[h],!m.__webglVertexBuffer){var n=m;n.__webglVertexBuffer=o.createBuffer();n.__webglNormalBuffer=o.createBuffer();n.__webglTangentBuffer=o.createBuffer();n.__webglColorBuffer=o.createBuffer();n.__webglUVBuffer=o.createBuffer();n.__webglUV2Buffer=o.createBuffer();n.__webglSkinVertexABuffer=o.createBuffer();n.__webglSkinVertexBBuffer=
+o.createBuffer();n.__webglSkinIndicesBuffer=o.createBuffer();n.__webglSkinWeightsBuffer=o.createBuffer();n.__webglFaceBuffer=o.createBuffer();n.__webglLineBuffer=o.createBuffer();if(n.numMorphTargets){var p=void 0,t=void 0;n.__webglMorphTargetsBuffers=[];p=0;for(t=n.numMorphTargets;p<t;p++)n.__webglMorphTargetsBuffers.push(o.createBuffer())}W.info.memory.geometries++;for(var n=e,w=void 0,u=void 0,v=void 0,x=v=void 0,L=void 0,y=void 0,V=y=p=0,z=v=u=void 0,v=t=z=u=w=void 0,x=n.geometry,L=x.faces,z=
+m.faces,w=0,u=z.length;w<u;w++)v=z[w],v=L[v],v instanceof THREE.Face3?(p+=3,y+=1,V+=3):v instanceof THREE.Face4&&(p+=4,y+=2,V+=4);for(var w=m,u=n,B=z=L=void 0,$=void 0,B=void 0,v=[],L=0,z=u.materials.length;L<z;L++)if(B=u.materials[L],B instanceof THREE.MeshFaceMaterial){B=0;for(l=w.materials.length;B<l;B++)($=w.materials[B])&&v.push($)}else($=B)&&v.push($);w=v;m.__materials=w;a:{L=u=void 0;z=w.length;for(u=0;u<z;u++)if(L=w[u],L.map||L.lightMap||L instanceof THREE.ShaderMaterial){u=!0;break a}u=!1}a:{z=
+L=void 0;v=w.length;for(L=0;L<v;L++)if(z=w[L],!(z instanceof THREE.MeshBasicMaterial&&!z.envMap||z instanceof THREE.MeshDepthMaterial)){z=z&&z.shading!=void 0&&z.shading==THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading;break a}z=!1}a:{v=L=void 0;B=w.length;for(L=0;L<B;L++)if(v=w[L],v.vertexColors){v=v.vertexColors;break a}v=!1}m.__vertexArray=new Float32Array(p*3);if(z)m.__normalArray=new Float32Array(p*3);if(x.hasTangents)m.__tangentArray=new Float32Array(p*4);if(v)m.__colorArray=new Float32Array(p*
+3);if(u){if(x.faceUvs.length>0||x.faceVertexUvs.length>0)m.__uvArray=new Float32Array(p*2);if(x.faceUvs.length>1||x.faceVertexUvs.length>1)m.__uv2Array=new Float32Array(p*2)}if(n.geometry.skinWeights.length&&n.geometry.skinIndices.length)m.__skinVertexAArray=new Float32Array(p*4),m.__skinVertexBArray=new Float32Array(p*4),m.__skinIndexArray=new Float32Array(p*4),m.__skinWeightArray=new Float32Array(p*4);m.__faceArray=new Uint16Array(y*3+(n.geometry.edgeFaces?n.geometry.edgeFaces.length*6:0));m.__lineArray=
+new Uint16Array(V*2);if(m.numMorphTargets){m.__morphTargetsArrays=[];x=0;for(L=m.numMorphTargets;x<L;x++)m.__morphTargetsArrays.push(new Float32Array(p*3))}m.__needsSmoothNormals=z==THREE.SmoothShading;m.__uvType=u;m.__vertexColorType=v;m.__normalType=z;m.__webglFaceCount=y*3+(n.geometry.edgeFaces?n.geometry.edgeFaces.length*6:0);m.__webglLineCount=V*2;x=0;for(L=w.length;x<L;x++)if(u=w[x],u.attributes){if(m.__webglCustomAttributes===void 0)m.__webglCustomAttributes={};for(a in u.attributes){v=u.attributes[a];
+z={};for(t in v)z[t]=v[t];if(!z.__webglInitialized||z.createUniqueBuffers)z.__webglInitialized=!0,y=1,z.type==="v2"?y=2:z.type==="v3"?y=3:z.type==="v4"?y=4:z.type==="c"&&(y=3),z.size=y,z.array=new Float32Array(p*y),z.buffer=o.createBuffer(),z.buffer.belongsToAttribute=a,v.needsUpdate=!0,z.__original=v;m.__webglCustomAttributes[a]=z}}m.__inittedArrays=!0;k.__dirtyVertices=!0;k.__dirtyMorphTargets=!0;k.__dirtyElements=!0;k.__dirtyUvs=!0;k.__dirtyNormals=!0;k.__dirtyTangents=!0;k.__dirtyColors=!0}}else if(e instanceof
+THREE.Ribbon){if(k=e.geometry,!k.__webglVertexBuffer)m=k,m.__webglVertexBuffer=o.createBuffer(),m.__webglColorBuffer=o.createBuffer(),W.info.memory.geometries++,m=k,n=m.vertices.length,m.__vertexArray=new Float32Array(n*3),m.__colorArray=new Float32Array(n*3),m.__webglVertexCount=n,k.__dirtyVertices=!0,k.__dirtyColors=!0}else if(e instanceof THREE.Line){if(k=e.geometry,!k.__webglVertexBuffer)m=k,m.__webglVertexBuffer=o.createBuffer(),m.__webglColorBuffer=o.createBuffer(),W.info.memory.geometries++,
+m=k,n=m.vertices.length,m.__vertexArray=new Float32Array(n*3),m.__colorArray=new Float32Array(n*3),m.__webglLineCount=n,k.__dirtyVertices=!0,k.__dirtyColors=!0}else if(e instanceof THREE.ParticleSystem&&(k=e.geometry,!k.__webglVertexBuffer)){m=k;m.__webglVertexBuffer=o.createBuffer();m.__webglColorBuffer=o.createBuffer();W.info.geometries++;m=k;n=e;p=m.vertices.length;m.__vertexArray=new Float32Array(p*3);m.__colorArray=new Float32Array(p*3);m.__sortArray=[];m.__webglParticleCount=p;m.__materials=
+n.materials;V=y=t=void 0;t=0;for(y=n.materials.length;t<y;t++)if(V=n.materials[t],V.attributes){if(m.__webglCustomAttributes===void 0)m.__webglCustomAttributes={};for(a in V.attributes){originalAttribute=V.attributes[a];attribute={};for(property in originalAttribute)attribute[property]=originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type==="v2"?size=2:attribute.type==="v3"?size=3:attribute.type==="v4"?size=
+4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(p*size),attribute.buffer=o.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;m.__webglCustomAttributes[a]=attribute}}k.__dirtyVertices=!0;k.__dirtyColors=!0}if(!e.__webglActive){if(e instanceof THREE.Mesh)for(h in k=e.geometry,k.geometryGroups)m=k.geometryGroups[h],Q(f.__webglObjects,m,e);else e instanceof THREE.Ribbon||e instanceof THREE.Line||
+e instanceof THREE.ParticleSystem?(k=e.geometry,Q(f.__webglObjects,k,e)):THREE.MarchingCubes!==void 0&&e instanceof THREE.MarchingCubes?f.__webglObjectsImmediate.push({object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}}):e instanceof THREE.Sprite&&f.__webglSprites.push(e);e.__webglActive=!0}b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){e=b.__objectsRemoved[0];f=b;if(e instanceof THREE.Mesh||e instanceof THREE.ParticleSystem||e instanceof THREE.Ribbon||e instanceof THREE.Line)G(f.__webglObjects,
+e);else if(e instanceof THREE.Sprite){f=f.__webglSprites;h=e;k=void 0;for(k=f.length-1;k>=0;k--)f[k]==h&&f.splice(k,1)}else e instanceof THREE.MarchingCubes&&G(f.__webglObjectsImmediate,e);e.__webglActive=!1;b.__objectsRemoved.splice(0,1)}e=0;for(f=b.__webglObjects.length;e<f;e++)if(k=b.__webglObjects[e].object,t=m=h=void 0,k instanceof THREE.Mesh){h=k.geometry;n=0;for(p=h.geometryGroupsList.length;n<p;n++)if(m=h.geometryGroupsList[n],t=E(m),h.__dirtyVertices||h.__dirtyMorphTargets||h.__dirtyElements||
+h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||t)if(t=m,y=o.DYNAMIC_DRAW,V=!h.dynamic,t.__inittedArrays){var D=w=x=void 0,M=void 0,va=D=void 0,ja=void 0,K=void 0,I=void 0,fa=$=B=v=z=L=u=void 0,H=void 0,ra=void 0,J=M=I=M=K=ja=void 0,A=void 0,C=A=J=ja=void 0,na=void 0,Z=C=A=J=D=D=va=I=M=C=A=J=na=C=A=J=na=C=A=J=void 0,T=0,O=0,ta=0,Y=0,S=0,ya=0,P=0,qa=0,X=0,R=0,U=0,C=J=0,C=void 0,ea=t.__vertexArray,oa=t.__uvArray,ka=t.__uv2Array,ha=t.__normalArray,ia=t.__tangentArray,aa=t.__colorArray,
+ua=t.__skinVertexAArray,sa=t.__skinVertexBArray,ca=t.__skinIndexArray,da=t.__skinWeightArray,ma=t.__morphTargetsArrays,za=t.__webglCustomAttributes,A=void 0,xa=t.__faceArray,pa=t.__lineArray,Ha=t.__needsSmoothNormals,L=t.__vertexColorType,u=t.__uvType,z=t.__normalType,la=k.geometry,Da=la.__dirtyVertices,Ca=la.__dirtyElements,Ea=la.__dirtyUvs,Ia=la.__dirtyNormals,Fa=la.__dirtyTangents,Ba=la.__dirtyColors,bb=la.__dirtyMorphTargets,Ra=la.vertices,db=t.faces,gb=la.faces,eb=la.faceVertexUvs[0],fb=la.faceVertexUvs[1],
+Sa=la.skinVerticesA,Ta=la.skinVerticesB,Ua=la.skinIndices,Ka=la.skinWeights,Ja=la.morphTargets;if(za)for(Z in za)za[Z].offset=0,za[Z].offsetSrc=0;x=0;for(w=db.length;x<w;x++)if(D=db[x],M=gb[D],eb&&(v=eb[D]),fb&&(B=fb[D]),D=M.vertexNormals,va=M.normal,ja=M.vertexColors,K=M.color,I=M.vertexTangents,M instanceof THREE.Face3){if(Da)$=Ra[M.a].position,fa=Ra[M.b].position,H=Ra[M.c].position,ea[O]=$.x,ea[O+1]=$.y,ea[O+2]=$.z,ea[O+3]=fa.x,ea[O+4]=fa.y,ea[O+5]=fa.z,ea[O+6]=H.x,ea[O+7]=H.y,ea[O+8]=H.z,O+=9;
+if(za)for(Z in za)if(A=za[Z],A.__original.needsUpdate)J=A.offset,C=A.offsetSrc,A.size===1?(A.boundTo===void 0||A.boundTo==="vertices"?(A.array[J]=A.value[M.a],A.array[J+1]=A.value[M.b],A.array[J+2]=A.value[M.c]):A.boundTo==="faces"?(C=A.value[C],A.array[J]=C,A.array[J+1]=C,A.array[J+2]=C,A.offsetSrc++):A.boundTo==="faceVertices"&&(A.array[J]=A.value[C],A.array[J+1]=A.value[C+1],A.array[J+2]=A.value[C+2],A.offsetSrc+=3),A.offset+=3):(A.boundTo===void 0||A.boundTo==="vertices"?($=A.value[M.a],fa=A.value[M.b],
+H=A.value[M.c]):A.boundTo==="faces"?(H=fa=$=C=A.value[C],A.offsetSrc++):A.boundTo==="faceVertices"&&($=A.value[C],fa=A.value[C+1],H=A.value[C+2],A.offsetSrc+=3),A.size===2?(A.array[J]=$.x,A.array[J+1]=$.y,A.array[J+2]=fa.x,A.array[J+3]=fa.y,A.array[J+4]=H.x,A.array[J+5]=H.y,A.offset+=6):A.size===3?(A.type==="c"?(A.array[J]=$.r,A.array[J+1]=$.g,A.array[J+2]=$.b,A.array[J+3]=fa.r,A.array[J+4]=fa.g,A.array[J+5]=fa.b,A.array[J+6]=H.r,A.array[J+7]=H.g,A.array[J+8]=H.b):(A.array[J]=$.x,A.array[J+1]=$.y,
+A.array[J+2]=$.z,A.array[J+3]=fa.x,A.array[J+4]=fa.y,A.array[J+5]=fa.z,A.array[J+6]=H.x,A.array[J+7]=H.y,A.array[J+8]=H.z),A.offset+=9):(A.array[J]=$.x,A.array[J+1]=$.y,A.array[J+2]=$.z,A.array[J+3]=$.w,A.array[J+4]=fa.x,A.array[J+5]=fa.y,A.array[J+6]=fa.z,A.array[J+7]=fa.w,A.array[J+8]=H.x,A.array[J+9]=H.y,A.array[J+10]=H.z,A.array[J+11]=H.w,A.offset+=12));if(bb){J=0;for(A=Ja.length;J<A;J++)$=Ja[J].vertices[M.a].position,fa=Ja[J].vertices[M.b].position,H=Ja[J].vertices[M.c].position,C=ma[J],C[U]=
+$.x,C[U+1]=$.y,C[U+2]=$.z,C[U+3]=fa.x,C[U+4]=fa.y,C[U+5]=fa.z,C[U+6]=H.x,C[U+7]=H.y,C[U+8]=H.z;U+=9}if(Ka.length)J=Ka[M.a],A=Ka[M.b],C=Ka[M.c],da[R]=J.x,da[R+1]=J.y,da[R+2]=J.z,da[R+3]=J.w,da[R+4]=A.x,da[R+5]=A.y,da[R+6]=A.z,da[R+7]=A.w,da[R+8]=C.x,da[R+9]=C.y,da[R+10]=C.z,da[R+11]=C.w,J=Ua[M.a],A=Ua[M.b],C=Ua[M.c],ca[R]=J.x,ca[R+1]=J.y,ca[R+2]=J.z,ca[R+3]=J.w,ca[R+4]=A.x,ca[R+5]=A.y,ca[R+6]=A.z,ca[R+7]=A.w,ca[R+8]=C.x,ca[R+9]=C.y,ca[R+10]=C.z,ca[R+11]=C.w,J=Sa[M.a],A=Sa[M.b],C=Sa[M.c],ua[R]=J.x,
+ua[R+1]=J.y,ua[R+2]=J.z,ua[R+3]=1,ua[R+4]=A.x,ua[R+5]=A.y,ua[R+6]=A.z,ua[R+7]=1,ua[R+8]=C.x,ua[R+9]=C.y,ua[R+10]=C.z,ua[R+11]=1,J=Ta[M.a],A=Ta[M.b],C=Ta[M.c],sa[R]=J.x,sa[R+1]=J.y,sa[R+2]=J.z,sa[R+3]=1,sa[R+4]=A.x,sa[R+5]=A.y,sa[R+6]=A.z,sa[R+7]=1,sa[R+8]=C.x,sa[R+9]=C.y,sa[R+10]=C.z,sa[R+11]=1,R+=12;if(Ba&&L)ja.length==3&&L==THREE.VertexColors?(M=ja[0],J=ja[1],A=ja[2]):A=J=M=K,aa[X]=M.r,aa[X+1]=M.g,aa[X+2]=M.b,aa[X+3]=J.r,aa[X+4]=J.g,aa[X+5]=J.b,aa[X+6]=A.r,aa[X+7]=A.g,aa[X+8]=A.b,X+=9;if(Fa&&la.hasTangents)ja=
+I[0],K=I[1],M=I[2],ia[P]=ja.x,ia[P+1]=ja.y,ia[P+2]=ja.z,ia[P+3]=ja.w,ia[P+4]=K.x,ia[P+5]=K.y,ia[P+6]=K.z,ia[P+7]=K.w,ia[P+8]=M.x,ia[P+9]=M.y,ia[P+10]=M.z,ia[P+11]=M.w,P+=12;if(Ia&&z)if(D.length==3&&Ha)for(I=0;I<3;I++)va=D[I],ha[ya]=va.x,ha[ya+1]=va.y,ha[ya+2]=va.z,ya+=3;else for(I=0;I<3;I++)ha[ya]=va.x,ha[ya+1]=va.y,ha[ya+2]=va.z,ya+=3;if(Ea&&v!==void 0&&u)for(I=0;I<3;I++)D=v[I],oa[ta]=D.u,oa[ta+1]=D.v,ta+=2;if(Ea&&B!==void 0&&u)for(I=0;I<3;I++)D=B[I],ka[Y]=D.u,ka[Y+1]=D.v,Y+=2;Ca&&(xa[S]=T,xa[S+
+1]=T+1,xa[S+2]=T+2,S+=3,pa[qa]=T,pa[qa+1]=T+1,pa[qa+2]=T,pa[qa+3]=T+2,pa[qa+4]=T+1,pa[qa+5]=T+2,qa+=6,T+=3)}else if(M instanceof THREE.Face4){if(Da)$=Ra[M.a].position,fa=Ra[M.b].position,H=Ra[M.c].position,ra=Ra[M.d].position,ea[O]=$.x,ea[O+1]=$.y,ea[O+2]=$.z,ea[O+3]=fa.x,ea[O+4]=fa.y,ea[O+5]=fa.z,ea[O+6]=H.x,ea[O+7]=H.y,ea[O+8]=H.z,ea[O+9]=ra.x,ea[O+10]=ra.y,ea[O+11]=ra.z,O+=12;if(za)for(Z in za)if(A=za[Z],A.__original.needsUpdate)J=A.offset,C=A.offsetSrc,A.size===1?(A.boundTo===void 0||A.boundTo===
+"vertices"?(A.array[J]=A.value[M.a],A.array[J+1]=A.value[M.b],A.array[J+2]=A.value[M.c],A.array[J+3]=A.value[M.d]):A.boundTo==="faces"?(C=A.value[C],A.array[J]=C,A.array[J+1]=C,A.array[J+2]=C,A.array[J+3]=C,A.offsetSrc++):A.boundTo==="faceVertices"&&(A.array[J]=A.value[C],A.array[J+1]=A.value[C+1],A.array[J+2]=A.value[C+2],A.array[J+3]=A.value[C+3],A.offsetSrc+=4),A.offset+=4):(A.boundTo===void 0||A.boundTo==="vertices"?($=A.value[M.a],fa=A.value[M.b],H=A.value[M.c],ra=A.value[M.d]):A.boundTo==="faces"?
+(ra=H=fa=$=C=A.value[C],A.offsetSrc++):A.boundTo==="faceVertices"&&($=A.value[C],fa=A.value[C+1],H=A.value[C+2],ra=A.value[C+3],A.offsetSrc+=4),A.size===2?(A.array[J]=$.x,A.array[J+1]=$.y,A.array[J+2]=fa.x,A.array[J+3]=fa.y,A.array[J+4]=H.x,A.array[J+5]=H.y,A.array[J+6]=ra.x,A.array[J+7]=ra.y,A.offset+=8):A.size===3?(A.type==="c"?(A.array[J]=$.r,A.array[J+1]=$.g,A.array[J+2]=$.b,A.array[J+3]=fa.r,A.array[J+4]=fa.g,A.array[J+5]=fa.b,A.array[J+6]=H.r,A.array[J+7]=H.g,A.array[J+8]=H.b,A.array[J+9]=ra.r,
+A.array[J+10]=ra.g,A.array[J+11]=ra.b):(A.array[J]=$.x,A.array[J+1]=$.y,A.array[J+2]=$.z,A.array[J+3]=fa.x,A.array[J+4]=fa.y,A.array[J+5]=fa.z,A.array[J+6]=H.x,A.array[J+7]=H.y,A.array[J+8]=H.z,A.array[J+9]=ra.x,A.array[J+10]=ra.y,A.array[J+11]=ra.z),A.offset+=12):(A.array[J]=$.x,A.array[J+1]=$.y,A.array[J+2]=$.z,A.array[J+3]=$.w,A.array[J+4]=fa.x,A.array[J+5]=fa.y,A.array[J+6]=fa.z,A.array[J+7]=fa.w,A.array[J+8]=H.x,A.array[J+9]=H.y,A.array[J+10]=H.z,A.array[J+11]=H.w,A.array[J+12]=ra.x,A.array[J+
+13]=ra.y,A.array[J+14]=ra.z,A.array[J+15]=ra.w,A.offset+=16));if(bb){J=0;for(A=Ja.length;J<A;J++)$=Ja[J].vertices[M.a].position,fa=Ja[J].vertices[M.b].position,H=Ja[J].vertices[M.c].position,ra=Ja[J].vertices[M.d].position,C=ma[J],C[U]=$.x,C[U+1]=$.y,C[U+2]=$.z,C[U+3]=fa.x,C[U+4]=fa.y,C[U+5]=fa.z,C[U+6]=H.x,C[U+7]=H.y,C[U+8]=H.z,C[U+9]=ra.x,C[U+10]=ra.y,C[U+11]=ra.z;U+=12}if(Ka.length)J=Ka[M.a],A=Ka[M.b],C=Ka[M.c],na=Ka[M.d],da[R]=J.x,da[R+1]=J.y,da[R+2]=J.z,da[R+3]=J.w,da[R+4]=A.x,da[R+5]=A.y,da[R+
+6]=A.z,da[R+7]=A.w,da[R+8]=C.x,da[R+9]=C.y,da[R+10]=C.z,da[R+11]=C.w,da[R+12]=na.x,da[R+13]=na.y,da[R+14]=na.z,da[R+15]=na.w,J=Ua[M.a],A=Ua[M.b],C=Ua[M.c],na=Ua[M.d],ca[R]=J.x,ca[R+1]=J.y,ca[R+2]=J.z,ca[R+3]=J.w,ca[R+4]=A.x,ca[R+5]=A.y,ca[R+6]=A.z,ca[R+7]=A.w,ca[R+8]=C.x,ca[R+9]=C.y,ca[R+10]=C.z,ca[R+11]=C.w,ca[R+12]=na.x,ca[R+13]=na.y,ca[R+14]=na.z,ca[R+15]=na.w,J=Sa[M.a],A=Sa[M.b],C=Sa[M.c],na=Sa[M.d],ua[R]=J.x,ua[R+1]=J.y,ua[R+2]=J.z,ua[R+3]=1,ua[R+4]=A.x,ua[R+5]=A.y,ua[R+6]=A.z,ua[R+7]=1,ua[R+
+8]=C.x,ua[R+9]=C.y,ua[R+10]=C.z,ua[R+11]=1,ua[R+12]=na.x,ua[R+13]=na.y,ua[R+14]=na.z,ua[R+15]=1,J=Ta[M.a],A=Ta[M.b],C=Ta[M.c],M=Ta[M.d],sa[R]=J.x,sa[R+1]=J.y,sa[R+2]=J.z,sa[R+3]=1,sa[R+4]=A.x,sa[R+5]=A.y,sa[R+6]=A.z,sa[R+7]=1,sa[R+8]=C.x,sa[R+9]=C.y,sa[R+10]=C.z,sa[R+11]=1,sa[R+12]=M.x,sa[R+13]=M.y,sa[R+14]=M.z,sa[R+15]=1,R+=16;if(Ba&&L)ja.length==4&&L==THREE.VertexColors?(M=ja[0],J=ja[1],A=ja[2],ja=ja[3]):ja=A=J=M=K,aa[X]=M.r,aa[X+1]=M.g,aa[X+2]=M.b,aa[X+3]=J.r,aa[X+4]=J.g,aa[X+5]=J.b,aa[X+6]=A.r,
+aa[X+7]=A.g,aa[X+8]=A.b,aa[X+9]=ja.r,aa[X+10]=ja.g,aa[X+11]=ja.b,X+=12;if(Fa&&la.hasTangents)ja=I[0],K=I[1],M=I[2],I=I[3],ia[P]=ja.x,ia[P+1]=ja.y,ia[P+2]=ja.z,ia[P+3]=ja.w,ia[P+4]=K.x,ia[P+5]=K.y,ia[P+6]=K.z,ia[P+7]=K.w,ia[P+8]=M.x,ia[P+9]=M.y,ia[P+10]=M.z,ia[P+11]=M.w,ia[P+12]=I.x,ia[P+13]=I.y,ia[P+14]=I.z,ia[P+15]=I.w,P+=16;if(Ia&&z)if(D.length==4&&Ha)for(I=0;I<4;I++)va=D[I],ha[ya]=va.x,ha[ya+1]=va.y,ha[ya+2]=va.z,ya+=3;else for(I=0;I<4;I++)ha[ya]=va.x,ha[ya+1]=va.y,ha[ya+2]=va.z,ya+=3;if(Ea&&v!==
+void 0&&u)for(I=0;I<4;I++)D=v[I],oa[ta]=D.u,oa[ta+1]=D.v,ta+=2;if(Ea&&B!==void 0&&u)for(I=0;I<4;I++)D=B[I],ka[Y]=D.u,ka[Y+1]=D.v,Y+=2;Ca&&(xa[S]=T,xa[S+1]=T+1,xa[S+2]=T+3,xa[S+3]=T+1,xa[S+4]=T+2,xa[S+5]=T+3,S+=6,pa[qa]=T,pa[qa+1]=T+1,pa[qa+2]=T,pa[qa+3]=T+3,pa[qa+4]=T+1,pa[qa+5]=T+2,pa[qa+6]=T+2,pa[qa+7]=T+3,qa+=8,T+=4)}Da&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglVertexBuffer),o.bufferData(o.ARRAY_BUFFER,ea,y));if(za)for(Z in za)A=za[Z],A.__original.needsUpdate&&(o.bindBuffer(o.ARRAY_BUFFER,A.buffer),
+o.bufferData(o.ARRAY_BUFFER,A.array,y));if(bb){J=0;for(A=Ja.length;J<A;J++)o.bindBuffer(o.ARRAY_BUFFER,t.__webglMorphTargetsBuffers[J]),o.bufferData(o.ARRAY_BUFFER,ma[J],y)}Ba&&X>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglColorBuffer),o.bufferData(o.ARRAY_BUFFER,aa,y));Ia&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglNormalBuffer),o.bufferData(o.ARRAY_BUFFER,ha,y));Fa&&la.hasTangents&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglTangentBuffer),o.bufferData(o.ARRAY_BUFFER,ia,y));Ea&&ta>0&&(o.bindBuffer(o.ARRAY_BUFFER,
+t.__webglUVBuffer),o.bufferData(o.ARRAY_BUFFER,oa,y));Ea&&Y>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglUV2Buffer),o.bufferData(o.ARRAY_BUFFER,ka,y));Ca&&(o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t.__webglFaceBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,xa,y),o.bindBuffer(o.ELEMENT_ARRAY_BUFFER,t.__webglLineBuffer),o.bufferData(o.ELEMENT_ARRAY_BUFFER,pa,y));R>0&&(o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinVertexABuffer),o.bufferData(o.ARRAY_BUFFER,ua,y),o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinVertexBBuffer),
+o.bufferData(o.ARRAY_BUFFER,sa,y),o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinIndicesBuffer),o.bufferData(o.ARRAY_BUFFER,ca,y),o.bindBuffer(o.ARRAY_BUFFER,t.__webglSkinWeightsBuffer),o.bufferData(o.ARRAY_BUFFER,da,y));V&&(delete t.__inittedArrays,delete t.__colorArray,delete t.__normalArray,delete t.__tangentArray,delete t.__uvArray,delete t.__uv2Array,delete t.__faceArray,delete t.__vertexArray,delete t.__lineArray,delete t.__skinVertexAArray,delete t.__skinVertexBArray,delete t.__skinIndexArray,delete t.__skinWeightArray)}h.__dirtyVertices=
+!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;F(m)}else if(k instanceof THREE.Ribbon){h=k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=o.DYNAMIC_DRAW;n=x=V=V=void 0;w=k.vertices;p=k.colors;u=w.length;t=p.length;L=k.__vertexArray;y=k.__colorArray;z=k.__dirtyColors;if(k.__dirtyVertices){for(V=0;V<u;V++)x=w[V].position,n=V*3,L[n]=x.x,L[n+1]=x.y,L[n+2]=x.z;o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer);o.bufferData(o.ARRAY_BUFFER,
+L,m)}if(z){for(V=0;V<t;V++)color=p[V],n=V*3,y[n]=color.r,y[n+1]=color.g,y[n+2]=color.b;o.bindBuffer(o.ARRAY_BUFFER,k.__webglColorBuffer);o.bufferData(o.ARRAY_BUFFER,y,m)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(k instanceof THREE.Line){h=k.geometry;if(h.__dirtyVertices||h.__dirtyColors){k=h;m=o.DYNAMIC_DRAW;n=x=V=V=void 0;w=k.vertices;p=k.colors;u=w.length;t=p.length;L=k.__vertexArray;y=k.__colorArray;z=k.__dirtyColors;if(k.__dirtyVertices){for(V=0;V<u;V++)x=w[V].position,n=V*3,L[n]=x.x,L[n+
+1]=x.y,L[n+2]=x.z;o.bindBuffer(o.ARRAY_BUFFER,k.__webglVertexBuffer);o.bufferData(o.ARRAY_BUFFER,L,m)}if(z){for(V=0;V<t;V++)color=p[V],n=V*3,y[n]=color.r,y[n+1]=color.g,y[n+2]=color.b;o.bindBuffer(o.ARRAY_BUFFER,k.__webglColorBuffer);o.bufferData(o.ARRAY_BUFFER,y,m)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(k instanceof THREE.ParticleSystem)h=k.geometry,t=E(h),(h.__dirtyVertices||h.__dirtyColors||k.sortParticles||t)&&c(h,o.DYNAMIC_DRAW,k),h.__dirtyVertices=!1,h.__dirtyColors=!1,F(h)};this.setFaceCulling=
+function(b,e){b?(!e||e=="ccw"?o.frontFace(o.CCW):o.frontFace(o.CW),b=="back"?o.cullFace(o.BACK):b=="front"?o.cullFace(o.FRONT):o.cullFace(o.FRONT_AND_BACK),o.enable(o.CULL_FACE)):o.disable(o.CULL_FACE)};this.supportsVertexTextures=function(){return Ia}};
 THREE.WebGLRenderTarget=function(b,c,e){this.width=b;this.height=c;e=e||{};this.wrapS=e.wrapS!==void 0?e.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=e.wrapT!==void 0?e.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=e.magFilter!==void 0?e.magFilter:THREE.LinearFilter;this.minFilter=e.minFilter!==void 0?e.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=e.format!==void 0?e.format:THREE.RGBAFormat;this.type=e.type!==void 0?e.type:
 THREE.UnsignedByteType;this.depthBuffer=e.depthBuffer!==void 0?e.depthBuffer:!0;this.stencilBuffer=e.stencilBuffer!==void 0?e.stencilBuffer:!0};
 THREE.WebGLRenderTarget.prototype.clone=function(){var b=new THREE.WebGLRenderTarget(this.width,this.height);b.wrapS=this.wrapS;b.wrapT=this.wrapT;b.magFilter=this.magFilter;b.minFilter=this.minFilter;b.offset.copy(this.offset);b.repeat.copy(this.repeat);b.format=this.format;b.type=this.type;b.depthBuffer=this.depthBuffer;b.stencilBuffer=this.stencilBuffer;return b};THREE.WebGLRenderTargetCube=function(b,c,e){THREE.WebGLRenderTarget.call(this,b,c,e);this.activeCubeFace=0};
@@ -344,8 +344,8 @@ THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new
 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};
 THREE.ColorUtils={adjustHSV:function(b,c,e,f){var h=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(b,h);h.h=THREE.ColorUtils.clamp(h.h+c,0,1);h.s=THREE.ColorUtils.clamp(h.s+e,0,1);h.v=THREE.ColorUtils.clamp(h.v+f,0,1);b.setHSV(h.h,h.s,h.v)},rgbToHsv:function(b,c){var e=b.r,f=b.g,h=b.b,m=Math.max(Math.max(e,f),h),k=Math.min(Math.min(e,f),h);if(k==m)k=e=0;else{var n=m-k,k=n/m,e=e==m?(f-h)/n:f==m?2+(h-e)/n:4+(e-f)/n;e/=6;e<0&&(e+=1);e>1&&(e-=1)}c===void 0&&(c={h:0,s:0,v:0});c.h=e;c.s=k;c.v=m;return c},
 clamp:function(b,c,e){return b<c?c:b>e?e:b}};THREE.ColorUtils.__hsv={h:0,s:0,v:0};
-THREE.GeometryUtils={merge:function(b,c){var e,f,h=b.vertices.length,m=c instanceof THREE.Mesh?c.geometry:c,k=b.vertices,n=m.vertices,u=b.faces,p=m.faces,v=b.faceVertexUvs[0],m=m.faceVertexUvs[0];if(c instanceof THREE.Mesh)c.matrixAutoUpdate&&c.updateMatrix(),e=c.matrix,f=new THREE.Matrix4,f.extractRotation(e,c.scale);for(var t=0,x=n.length;t<x;t++){var w=new THREE.Vertex(n[t].position.clone());e&&e.multiplyVector3(w.position);k.push(w)}t=0;for(x=p.length;t<x;t++){var w=p[t],y,z,A=w.vertexNormals,
-E=w.vertexColors;w instanceof THREE.Face3?y=new THREE.Face3(w.a+h,w.b+h,w.c+h):w instanceof THREE.Face4&&(y=new THREE.Face4(w.a+h,w.b+h,w.c+h,w.d+h));y.normal.copy(w.normal);f&&f.multiplyVector3(y.normal);k=0;for(n=A.length;k<n;k++)z=A[k].clone(),f&&f.multiplyVector3(z),y.vertexNormals.push(z);y.color.copy(w.color);k=0;for(n=E.length;k<n;k++)z=E[k],y.vertexColors.push(z.clone());y.materials=w.materials.slice();y.centroid.copy(w.centroid);e&&e.multiplyVector3(y.centroid);u.push(y)}t=0;for(x=m.length;t<
+THREE.GeometryUtils={merge:function(b,c){var e,f,h=b.vertices.length,m=c instanceof THREE.Mesh?c.geometry:c,k=b.vertices,n=m.vertices,u=b.faces,p=m.faces,v=b.faceVertexUvs[0],m=m.faceVertexUvs[0];if(c instanceof THREE.Mesh)c.matrixAutoUpdate&&c.updateMatrix(),e=c.matrix,f=new THREE.Matrix4,f.extractRotation(e,c.scale);for(var t=0,x=n.length;t<x;t++){var w=new THREE.Vertex(n[t].position.clone());e&&e.multiplyVector3(w.position);k.push(w)}t=0;for(x=p.length;t<x;t++){var w=p[t],y,z,B=w.vertexNormals,
+D=w.vertexColors;w instanceof THREE.Face3?y=new THREE.Face3(w.a+h,w.b+h,w.c+h):w instanceof THREE.Face4&&(y=new THREE.Face4(w.a+h,w.b+h,w.c+h,w.d+h));y.normal.copy(w.normal);f&&f.multiplyVector3(y.normal);k=0;for(n=B.length;k<n;k++)z=B[k].clone(),f&&f.multiplyVector3(z),y.vertexNormals.push(z);y.color.copy(w.color);k=0;for(n=D.length;k<n;k++)z=D[k],y.vertexColors.push(z.clone());y.materials=w.materials.slice();y.centroid.copy(w.centroid);e&&e.multiplyVector3(y.centroid);u.push(y)}t=0;for(x=m.length;t<
 x;t++){e=m[t];f=[];k=0;for(n=e.length;k<n;k++)f.push(new THREE.UV(e[k].u,e[k].v));v.push(f)}},clone:function(b){var c=new THREE.Geometry,e,f=b.vertices,h=b.faces,m=b.faceVertexUvs[0],b=0;for(e=f.length;b<e;b++){var k=new THREE.Vertex(f[b].position.clone());c.vertices.push(k)}b=0;for(e=h.length;b<e;b++){var n=h[b],u,p,v=n.vertexNormals,t=n.vertexColors;n instanceof THREE.Face3?u=new THREE.Face3(n.a,n.b,n.c):n instanceof THREE.Face4&&(u=new THREE.Face4(n.a,n.b,n.c,n.d));u.normal.copy(n.normal);f=0;
 for(k=v.length;f<k;f++)p=v[f],u.vertexNormals.push(p.clone());u.color.copy(n.color);f=0;for(k=t.length;f<k;f++)p=t[f],u.vertexColors.push(p.clone());u.materials=n.materials.slice();u.centroid.copy(n.centroid);c.faces.push(u)}b=0;for(e=m.length;b<e;b++){h=m[b];u=[];f=0;for(k=h.length;f<k;f++)u.push(new THREE.UV(h[f].u,h[f].v));c.faceVertexUvs[0].push(u)}return c},randomPointInTriangle:function(b,c,e){var f,h,m,k=new THREE.Vector3,n=THREE.GeometryUtils.__v1;f=THREE.GeometryUtils.random();h=THREE.GeometryUtils.random();
 f+h>1&&(f=1-f,h=1-h);m=1-f-h;k.copy(b);k.multiplyScalar(f);n.copy(c);n.multiplyScalar(h);k.addSelf(n);n.copy(e);n.multiplyScalar(m);k.addSelf(n);return k},randomPointInFace:function(b,c,e){var f,h,m;if(b instanceof THREE.Face3)return f=c.vertices[b.a].position,h=c.vertices[b.b].position,m=c.vertices[b.c].position,THREE.GeometryUtils.randomPointInTriangle(f,h,m);else if(b instanceof THREE.Face4){f=c.vertices[b.a].position;h=c.vertices[b.b].position;m=c.vertices[b.c].position;var c=c.vertices[b.d].position,
@@ -354,9 +354,9 @@ b?e(c,h-1):p[h]<b?e(h+1,f):h}return e(0,p.length-1)}var f,h,m=b.faces,k=b.vertic
 p[h]=u}f=[];k={};for(h=0;h<c;h++)n=THREE.GeometryUtils.random()*u,n=e(n),f[h]=THREE.GeometryUtils.randomPointInFace(m[n],b,!0),k[n]?k[n]+=1:k[n]=1;return f},triangleArea:function(b,c,e){var f,h=THREE.GeometryUtils.__v1;h.sub(b,c);f=h.length();h.sub(b,e);b=h.length();h.sub(c,e);e=h.length();c=0.5*(f+b+e);return Math.sqrt(c*(c-f)*(c-b)*(c-e))},random16:function(){return(65280*Math.random()+255*Math.random())/65535},center:function(b){b.computeBoundingBox();var c=new THREE.Matrix4;c.setTranslation(-0.5*
 (b.boundingBox.x[1]+b.boundingBox.x[0]),-0.5*(b.boundingBox.y[1]+b.boundingBox.y[0]),-0.5*(b.boundingBox.z[1]+b.boundingBox.z[0]));b.applyMatrix(c);b.computeBoundingBox()}};THREE.GeometryUtils.random=THREE.GeometryUtils.random16;THREE.GeometryUtils.__v1=new THREE.Vector3;
 THREE.ImageUtils={loadTexture:function(b,c,e){var f=new Image,h=new THREE.Texture(f,c);f.onload=function(){h.needsUpdate=!0;e&&e(this)};f.crossOrigin="";f.src=b;return h},loadTextureCube:function(b,c,e){var f,h=[],m=new THREE.Texture(h,c),c=h.loadCount=0;for(f=b.length;c<f;++c)h[c]=new Image,h[c].onload=function(){h.loadCount+=1;if(h.loadCount==6)m.needsUpdate=!0;e&&e(this)},h[c].crossOrigin="",h[c].src=b[c];return m},getNormalMap:function(b,c){var e=function(b){var e=Math.sqrt(b[0]*b[0]+b[1]*b[1]+
-b[2]*b[2]);return[b[0]/e,b[1]/e,b[2]/e]};c|=1;var f=b.width,h=b.height,m=document.createElement("canvas");m.width=f;m.height=h;var k=m.getContext("2d");k.drawImage(b,0,0);for(var n=k.getImageData(0,0,f,h).data,u=k.createImageData(f,h),p=u.data,v=0;v<f;v++)for(var t=1;t<h;t++){var x=t-1<0?h-1:t-1,w=(t+1)%h,y=v-1<0?f-1:v-1,z=(v+1)%f,A=[],E=[0,0,n[(t*f+v)*4]/255*c];A.push([-1,0,n[(t*f+y)*4]/255*c]);A.push([-1,-1,n[(x*f+y)*4]/255*c]);A.push([0,-1,n[(x*f+v)*4]/255*c]);A.push([1,-1,n[(x*f+z)*4]/255*c]);
-A.push([1,0,n[(t*f+z)*4]/255*c]);A.push([1,1,n[(w*f+z)*4]/255*c]);A.push([0,1,n[(w*f+v)*4]/255*c]);A.push([-1,1,n[(w*f+y)*4]/255*c]);x=[];y=A.length;for(w=0;w<y;w++){var z=A[w],D=A[(w+1)%y],z=[z[0]-E[0],z[1]-E[1],z[2]-E[2]],D=[D[0]-E[0],D[1]-E[1],D[2]-E[2]];x.push(e([z[1]*D[2]-z[2]*D[1],z[2]*D[0]-z[0]*D[2],z[0]*D[1]-z[1]*D[0]]))}A=[0,0,0];for(w=0;w<x.length;w++)A[0]+=x[w][0],A[1]+=x[w][1],A[2]+=x[w][2];A[0]/=x.length;A[1]/=x.length;A[2]/=x.length;E=(t*f+v)*4;p[E]=(A[0]+1)/2*255|0;p[E+1]=(A[1]+0.5)*
-255|0;p[E+2]=A[2]*255|0;p[E+3]=255}k.putImageData(u,0,0);return m}};THREE.SceneUtils={showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var e,f,h=b.children.length;for(f=0;f<h;f++)e=b.children[f],c(e),THREE.SceneUtils.traverseHierarchy(e,c)}};
+b[2]*b[2]);return[b[0]/e,b[1]/e,b[2]/e]};c|=1;var f=b.width,h=b.height,m=document.createElement("canvas");m.width=f;m.height=h;var k=m.getContext("2d");k.drawImage(b,0,0);for(var n=k.getImageData(0,0,f,h).data,u=k.createImageData(f,h),p=u.data,v=0;v<f;v++)for(var t=1;t<h;t++){var x=t-1<0?h-1:t-1,w=(t+1)%h,y=v-1<0?f-1:v-1,z=(v+1)%f,B=[],D=[0,0,n[(t*f+v)*4]/255*c];B.push([-1,0,n[(t*f+y)*4]/255*c]);B.push([-1,-1,n[(x*f+y)*4]/255*c]);B.push([0,-1,n[(x*f+v)*4]/255*c]);B.push([1,-1,n[(x*f+z)*4]/255*c]);
+B.push([1,0,n[(t*f+z)*4]/255*c]);B.push([1,1,n[(w*f+z)*4]/255*c]);B.push([0,1,n[(w*f+v)*4]/255*c]);B.push([-1,1,n[(w*f+y)*4]/255*c]);x=[];y=B.length;for(w=0;w<y;w++){var z=B[w],E=B[(w+1)%y],z=[z[0]-D[0],z[1]-D[1],z[2]-D[2]],E=[E[0]-D[0],E[1]-D[1],E[2]-D[2]];x.push(e([z[1]*E[2]-z[2]*E[1],z[2]*E[0]-z[0]*E[2],z[0]*E[1]-z[1]*E[0]]))}B=[0,0,0];for(w=0;w<x.length;w++)B[0]+=x[w][0],B[1]+=x[w][1],B[2]+=x[w][2];B[0]/=x.length;B[1]/=x.length;B[2]/=x.length;D=(t*f+v)*4;p[D]=(B[0]+1)/2*255|0;p[D+1]=(B[1]+0.5)*
+255|0;p[D+2]=B[2]*255|0;p[D+3]=255}k.putImageData(u,0,0);return m}};THREE.SceneUtils={showHierarchy:function(b,c){THREE.SceneUtils.traverseHierarchy(b,function(b){b.visible=c})},traverseHierarchy:function(b,c){var e,f,h=b.children.length;for(f=0;f<h;f++)e=b.children[f],c(e),THREE.SceneUtils.traverseHierarchy(e,c)}};
 if(THREE.WebGLRenderer)THREE.ShaderUtils={lib:{fresnel:{uniforms:{mRefractionRatio:{type:"f",value:1.02},mFresnelBias:{type:"f",value:0.1},mFresnelPower:{type:"f",value:2},mFresnelScale:{type:"f",value:1},tCube:{type:"t",value:1,texture:null}},fragmentShader:"uniform samplerCube tCube;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 reflectedColor = textureCube( tCube, vec3( -vReflect.x, vReflect.yz ) );\nvec4 refractedColor = vec4( 1.0, 1.0, 1.0, 1.0 );\nrefractedColor.r = textureCube( tCube, vec3( -vRefract[0].x, vRefract[0].yz ) ).r;\nrefractedColor.g = textureCube( tCube, vec3( -vRefract[1].x, vRefract[1].yz ) ).g;\nrefractedColor.b = textureCube( tCube, vec3( -vRefract[2].x, vRefract[2].yz ) ).b;\nrefractedColor.a = 1.0;\ngl_FragColor = mix( refractedColor, reflectedColor, clamp( vReflectionFactor, 0.0, 1.0 ) );\n}",
 vertexShader:"uniform float mRefractionRatio;\nuniform float mFresnelBias;\nuniform float mFresnelScale;\nuniform float mFresnelPower;\nvarying vec3 vReflect;\nvarying vec3 vRefract[3];\nvarying float vReflectionFactor;\nvoid main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\nvec4 mPosition = objectMatrix * vec4( position, 1.0 );\nvec3 nWorld = normalize ( mat3( objectMatrix[0].xyz, objectMatrix[1].xyz, objectMatrix[2].xyz ) * normal );\nvec3 I = mPosition.xyz - cameraPosition;\nvReflect = reflect( I, nWorld );\nvRefract[0] = refract( normalize( I ), nWorld, mRefractionRatio );\nvRefract[1] = refract( normalize( I ), nWorld, mRefractionRatio * 0.99 );\nvRefract[2] = refract( normalize( I ), nWorld, mRefractionRatio * 0.98 );\nvReflectionFactor = mFresnelBias + mFresnelScale * pow( 1.0 + dot( normalize( I ), nWorld ), mFresnelPower );\ngl_Position = projectionMatrix * mvPosition;\n}"},
 normal:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.fog,THREE.UniformsLib.lights,{enableAO:{type:"i",value:0},enableDiffuse:{type:"i",value:0},enableSpecular:{type:"i",value:0},tDiffuse:{type:"t",value:0,texture:null},tNormal:{type:"t",value:2,texture:null},tSpecular:{type:"t",value:3,texture:null},tAO:{type:"t",value:4,texture:null},uNormalScale:{type:"f",value:1},tDisplacement:{type:"t",value:5,texture:null},uDisplacementBias:{type:"f",value:0},uDisplacementScale:{type:"f",value:1},uDiffuseColor:{type:"c",
@@ -393,7 +393,7 @@ THREE.Path.prototype.splineThru=function(b){var c=Array.prototype.slice.call(arg
 THREE.Path.prototype.arc=function(b,c,e,f,h,m){var k=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(b,c,e,f,h,m));this.actions.push({action:THREE.PathActions.ARC,args:k})};THREE.Path.prototype.getSpacedPoints=function(b){b||(b=40);for(var c=[],e=0;e<b;e++)c.push(this.getPoint(e/b));return c};
 THREE.Path.prototype.getPoints=function(b,c){var b=b||12,e=[],f,h,m,k,n,u,p,v,t,x,w,y,z;f=0;for(h=this.actions.length;f<h;f++)switch(m=this.actions[f],k=m.action,m=m.args,k){case THREE.PathActions.LINE_TO:e.push(new THREE.Vector2(m[0],m[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:n=m[2];u=m[3];t=m[0];x=m[1];e.length>0?(k=e[e.length-1],w=k.x,y=k.y):(k=this.actions[f-1].args,w=k[k.length-2],y=k[k.length-1]);for(k=1;k<=b;k++)z=k/b,m=THREE.Shape.Utils.b2(z,w,t,n),z=THREE.Shape.Utils.b2(z,y,x,
 u),e.push(new THREE.Vector2(m,z));break;case THREE.PathActions.BEZIER_CURVE_TO:n=m[4];u=m[5];t=m[0];x=m[1];p=m[2];v=m[3];e.length>0?(k=e[e.length-1],w=k.x,y=k.y):(k=this.actions[f-1].args,w=k[k.length-2],y=k[k.length-1]);for(k=1;k<=b;k++)z=k/b,m=THREE.Shape.Utils.b3(z,w,t,p,n),z=THREE.Shape.Utils.b3(z,y,x,v,u),e.push(new THREE.Vector2(m,z));break;case THREE.PathActions.CSPLINE_THRU:k=this.actions[f-1].args;k=[new THREE.Vector2(k[k.length-2],k[k.length-1])];z=b*m[0].length;k=k.concat(m[0]);m=new THREE.SplineCurve(k);
-for(k=1;k<=z;k++)e.push(m.getPointAt(k/z));break;case THREE.PathActions.ARC:k=this.actions[f-1].args;n=m[0];u=m[1];p=m[2];t=m[3];z=m[4];x=!!m[5];v=k[k.length-2];w=k[k.length-1];k.length==0&&(v=w=0);y=z-t;var A=b*2;for(k=1;k<=A;k++)z=k/A,x||(z=1-z),z=t+z*y,m=v+n+p*Math.cos(z),z=w+u+p*Math.sin(z),e.push(new THREE.Vector2(m,z))}c&&e.push(e[0]);return e};THREE.Path.prototype.transform=function(b,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),b)};
+for(k=1;k<=z;k++)e.push(m.getPointAt(k/z));break;case THREE.PathActions.ARC:k=this.actions[f-1].args;n=m[0];u=m[1];p=m[2];t=m[3];z=m[4];x=!!m[5];v=k[k.length-2];w=k[k.length-1];k.length==0&&(v=w=0);y=z-t;var B=b*2;for(k=1;k<=B;k++)z=k/B,x||(z=1-z),z=t+z*y,m=v+n+p*Math.cos(z),z=w+u+p*Math.sin(z),e.push(new THREE.Vector2(m,z))}c&&e.push(e[0]);return e};THREE.Path.prototype.transform=function(b,c){this.getBoundingBox();return this.getWrapPoints(this.getPoints(c),b)};
 THREE.Path.prototype.nltransform=function(b,c,e,f,h,m){var k=this.getPoints(),n,u,p,v,t;n=0;for(u=k.length;n<u;n++)p=k[n],v=p.x,t=p.y,p.x=b*v+c*t+e,p.y=f*t+h*v+m;return k};
 THREE.Path.prototype.debug=function(b){var c=this.getBoundingBox();b||(b=document.createElement("canvas"),b.setAttribute("width",c.maxX+100),b.setAttribute("height",c.maxY+100),document.body.appendChild(b));c=b.getContext("2d");c.fillStyle="white";c.fillRect(0,0,b.width,b.height);c.strokeStyle="black";c.beginPath();var e,f,h,b=0;for(e=this.actions.length;b<e;b++)f=this.actions[b],h=f.args,f=f.action,f!=THREE.PathActions.CSPLINE_THRU&&c[f].apply(c,h);c.stroke();c.closePath();c.strokeStyle="red";f=
 this.getPoints();b=0;for(e=f.length;b<e;b++)h=f[b],c.beginPath(),c.arc(h.x,h.y,1.5,0,Math.PI*2,!1),c.stroke(),c.closePath()};
@@ -401,8 +401,8 @@ THREE.Path.prototype.toShapes=function(){var b,c,e,f,h=[],m=new THREE.Path;b=0;f
 f.curves):k.holes.push(f);m.push(k)}else{k=new THREE.Shape;b=0;for(c=h.length;b<c;b++)f=h[b],THREE.Shape.Utils.isClockWise(f.getPoints())?(k.actions=f.actions,k.curves=f.curves,m.push(k),k=new THREE.Shape):k.holes.push(f)}return m};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=new THREE.Path;THREE.Shape.prototype.constructor=THREE.Path;THREE.Shape.prototype.extrude=function(b){return new THREE.ExtrudeGeometry(this,b)};
 THREE.Shape.prototype.getPointsHoles=function(b){var c,e=this.holes.length,f=[];for(c=0;c<e;c++)f[c]=this.holes[c].getTransformedPoints(b,this.bends);return f};THREE.Shape.prototype.getSpacedPointsHoles=function(b){var c,e=this.holes.length,f=[];for(c=0;c<e;c++)f[c]=this.holes[c].getTransformedSpacedPoints(b,this.bends);return f};THREE.Shape.prototype.extractAllPoints=function(b){return{shape:this.getTransformedPoints(b),holes:this.getPointsHoles(b)}};
 THREE.Shape.prototype.extractAllSpacedPoints=function(b){return{shape:this.getTransformedSpacedPoints(b),holes:this.getSpacedPointsHoles(b)}};
-THREE.Shape.Utils={removeHoles:function(b,c){var e=b.concat(),f=e.concat(),h,m,k,n,u,p,v,t,x,w,y=[];for(u=0;u<c.length;u++){p=c[u];Array.prototype.push.apply(f,p);m=Number.POSITIVE_INFINITY;for(h=0;h<p.length;h++){x=p[h];w=[];for(t=0;t<e.length;t++)v=e[t],v=x.distanceToSquared(v),w.push(v),v<m&&(m=v,k=h,n=t)}h=n-1>=0?n-1:e.length-1;m=k-1>=0?k-1:p.length-1;var z=[p[k],e[n],e[h]];t=THREE.FontUtils.Triangulate.area(z);var A=[p[k],p[m],e[n]];x=THREE.FontUtils.Triangulate.area(A);w=n;v=k;n+=1;k+=-1;n<
-0&&(n+=e.length);n%=e.length;k<0&&(k+=p.length);k%=p.length;h=n-1>=0?n-1:e.length-1;m=k-1>=0?k-1:p.length-1;z=[p[k],e[n],e[h]];z=THREE.FontUtils.Triangulate.area(z);A=[p[k],p[m],e[n]];A=THREE.FontUtils.Triangulate.area(A);t+x>z+A&&(n=w,k=v,n<0&&(n+=e.length),n%=e.length,k<0&&(k+=p.length),k%=p.length,h=n-1>=0?n-1:e.length-1,m=k-1>=0?k-1:p.length-1);t=e.slice(0,n);x=e.slice(n);w=p.slice(k);v=p.slice(0,k);m=[p[k],p[m],e[n]];y.push([p[k],e[n],e[h]]);y.push(m);e=t.concat(w).concat(v).concat(x)}return{shape:e,
+THREE.Shape.Utils={removeHoles:function(b,c){var e=b.concat(),f=e.concat(),h,m,k,n,u,p,v,t,x,w,y=[];for(u=0;u<c.length;u++){p=c[u];Array.prototype.push.apply(f,p);m=Number.POSITIVE_INFINITY;for(h=0;h<p.length;h++){x=p[h];w=[];for(t=0;t<e.length;t++)v=e[t],v=x.distanceToSquared(v),w.push(v),v<m&&(m=v,k=h,n=t)}h=n-1>=0?n-1:e.length-1;m=k-1>=0?k-1:p.length-1;var z=[p[k],e[n],e[h]];t=THREE.FontUtils.Triangulate.area(z);var B=[p[k],p[m],e[n]];x=THREE.FontUtils.Triangulate.area(B);w=n;v=k;n+=1;k+=-1;n<
+0&&(n+=e.length);n%=e.length;k<0&&(k+=p.length);k%=p.length;h=n-1>=0?n-1:e.length-1;m=k-1>=0?k-1:p.length-1;z=[p[k],e[n],e[h]];z=THREE.FontUtils.Triangulate.area(z);B=[p[k],p[m],e[n]];B=THREE.FontUtils.Triangulate.area(B);t+x>z+B&&(n=w,k=v,n<0&&(n+=e.length),n%=e.length,k<0&&(k+=p.length),k%=p.length,h=n-1>=0?n-1:e.length-1,m=k-1>=0?k-1:p.length-1);t=e.slice(0,n);x=e.slice(n);w=p.slice(k);v=p.slice(0,k);m=[p[k],p[m],e[n]];y.push([p[k],e[n],e[h]]);y.push(m);e=t.concat(w).concat(v).concat(x)}return{shape:e,
 isolatedPts:y,allpoints:f}},triangulateShape:function(b,c){var e=THREE.Shape.Utils.removeHoles(b,c),f=e.allpoints,h=e.isolatedPts,e=THREE.FontUtils.Triangulate(e.shape,!1),m,k,n,u,p={};m=0;for(k=f.length;m<k;m++)u=f[m].x+":"+f[m].y,p[u]!==void 0&&console.log("Duplicate point",u),p[u]=m;m=0;for(k=e.length;m<k;m++){n=e[m];for(f=0;f<3;f++)u=n[f].x+":"+n[f].y,u=p[u],u!==void 0&&(n[f]=u)}m=0;for(k=h.length;m<k;m++){n=h[m];for(f=0;f<3;f++)u=n[f].x+":"+n[f].y,u=p[u],u!==void 0&&(n[f]=u)}return e.concat(h)},
 isClockWise:function(b){return THREE.FontUtils.Triangulate.area(b)<0},b2p0:function(b,c){var e=1-b;return e*e*c},b2p1:function(b,c){return 2*(1-b)*b*c},b2p2:function(b,c){return b*b*c},b2:function(b,c,e,f){return this.b2p0(b,c)+this.b2p1(b,e)+this.b2p2(b,f)},b3p0:function(b,c){var e=1-b;return e*e*e*c},b3p1:function(b,c){var e=1-b;return 3*e*e*b*c},b3p2:function(b,c){return 3*(1-b)*b*b*c},b3p3:function(b,c){return b*b*b*c},b3:function(b,c,e,f,h){return this.b3p0(b,c)+this.b3p1(b,e)+this.b3p2(b,f)+
 this.b3p3(b,h)}};THREE.TextPath=function(b,c){THREE.Path.call(this);this.parameters=c||{};this.set(b)};THREE.TextPath.prototype.set=function(b,c){this.text=b;var c=c||this.parameters,e=c.curveSegments!==void 0?c.curveSegments:4,f=c.font!==void 0?c.font:"helvetiker",h=c.weight!==void 0?c.weight:"normal",m=c.style!==void 0?c.style:"normal";THREE.FontUtils.size=c.size!==void 0?c.size:100;THREE.FontUtils.divisions=e;THREE.FontUtils.face=f;THREE.FontUtils.weight=h;THREE.FontUtils.style=m};
@@ -435,7 +435,7 @@ this.domElement.offsetWidth/2,this.viewHalfY=this.domElement.offsetHeight/2,this
 c*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)/(Math.PI-0)+this.verticalMin;b=this.target.position;h=this.position;b.x=h.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=h.y+100*Math.cos(this.phi);b.z=h.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",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};THREE.FirstPersonCamera.prototype=new THREE.Camera;THREE.FirstPersonCamera.prototype.constructor=THREE.FirstPersonCamera;
 THREE.FirstPersonCamera.prototype.supr=THREE.Camera.prototype;THREE.FirstPersonCamera.prototype.translate=function(b,c){this.matrix.rotateAxis(c);if(this.noFly)c.y=0;this.position.addSelf(c.multiplyScalar(b));this.target.position.addSelf(c.multiplyScalar(b))};
-THREE.PathCamera=function(b){function c(b,e,c,f){var h={name:c,fps:0.6,length:f,hierarchy:[]},k,m=e.getControlPointsArray(),n=e.getLength(),u=m.length,D=0;k=u-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:m[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[k]={time:f,pos:m[k],rot:[0,0,0,1],scl:[1,1,1]};for(k=1;k<u-1;k++)D=f*n.chunks[k]/n.total,e.keys[k]={time:D,pos:m[k]};h.hierarchy[0]=e;THREE.AnimationHandler.add(h);return new THREE.Animation(b,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(b,e){var c,
+THREE.PathCamera=function(b){function c(b,e,c,f){var h={name:c,fps:0.6,length:f,hierarchy:[]},k,m=e.getControlPointsArray(),n=e.getLength(),u=m.length,E=0;k=u-1;e={parent:-1,keys:[]};e.keys[0]={time:0,pos:m[0],rot:[0,0,0,1],scl:[1,1,1]};e.keys[k]={time:f,pos:m[k],rot:[0,0,0,1],scl:[1,1,1]};for(k=1;k<u-1;k++)E=f*n.chunks[k]/n.total,e.keys[k]={time:E,pos:m[k]};h.hierarchy[0]=e;THREE.AnimationHandler.add(h);return new THREE.Animation(b,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function e(b,e){var c,
 f,h=new THREE.Geometry;for(c=0;c<b.points.length*e;c++)f=c/(b.points.length*e),f=b.getPoint(f),h.vertices[c]=new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z));return h}function f(b,c){var f=e(c,10),h=e(c,10),k=new THREE.LineBasicMaterial({color:16711680,linewidth:3});lineObj=new THREE.Line(f,k);particleObj=new THREE.ParticleSystem(h,new THREE.ParticleBasicMaterial({color:16755200,size:3}));lineObj.scale.set(1,1,1);b.addChild(lineObj);particleObj.scale.set(1,1,1);b.addChild(particleObj);h=new THREE.SphereGeometry(1,
 16,8);k=new THREE.MeshBasicMaterial({color:65280});for(i=0;i<c.points.length;i++)f=new THREE.Mesh(h,k),f.position.copy(c.points[i]),f.updateMatrix(),b.addChild(f)}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.lookHorizontal=
 this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.domElement=document;if(b){if(b.duration!==void 0)this.duration=b.duration*1E3;if(b.waypoints!==void 0)this.waypoints=b.waypoints;if(b.useConstantSpeed!==void 0)this.useConstantSpeed=b.useConstantSpeed;if(b.resamplingCoef!==void 0)this.resamplingCoef=b.resamplingCoef;if(b.createDebugPath!==void 0)this.createDebugPath=b.createDebugPath;
@@ -455,12 +455,12 @@ b;this.tdiff=(b-this.lastUpdate)/1E3;this.lastUpdate=b;var b=this.tdiff*this.mov
 !0;this.supr.update.call(this)};this.updateMovementVector=function(){var b=this.moveState.forward||this.autoForward&&!this.moveState.back?1:0;this.moveVector.x=-this.moveState.left+this.moveState.right;this.moveVector.y=-this.moveState.down+this.moveState.up;this.moveVector.z=-b+this.moveState.back};this.updateRotationVector=function(){this.rotationVector.x=-this.moveState.pitchDown+this.moveState.pitchUp;this.rotationVector.y=-this.moveState.yawRight+this.moveState.yawLeft;this.rotationVector.z=
 -this.moveState.rollRight+this.moveState.rollLeft};this.getContainerDimensions=function(){return this.domElement!=document?{size:[this.domElement.offsetWidth,this.domElement.offsetHeight],offset:[this.domElement.offsetLeft,this.domElement.offsetTop]}:{size:[window.innerWidth,window.innerHeight],offset:[0,0]}};this.domElement.addEventListener("mousemove",c(this,this.mousemove),!1);this.domElement.addEventListener("mousedown",c(this,this.mousedown),!1);this.domElement.addEventListener("mouseup",c(this,
 this.mouseup),!1);this.domElement.addEventListener("keydown",c(this,this.keydown),!1);this.domElement.addEventListener("keyup",c(this,this.keyup),!1);this.updateMovementVector();this.updateRotationVector()};THREE.FlyCamera.prototype=new THREE.Camera;THREE.FlyCamera.prototype.constructor=THREE.FlyCamera;THREE.FlyCamera.prototype.supr=THREE.Camera.prototype;
-THREE.RollCamera=function(b,c,e,f){THREE.Camera.call(this,b,c,e,f);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var h=new THREE.Vector3,m=new THREE.Vector3,k=new THREE.Vector3,n=new THREE.Matrix4,u=!1,p=1,v=0,t=0,x=0,w=0,y=0,z=window.innerWidth/2,A=window.innerHeight/2;this.update=
+THREE.RollCamera=function(b,c,e,f){THREE.Camera.call(this,b,c,e,f);this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.domElement=document;this.matrixAutoUpdate=this.useTarget=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;this.lastUpdate=-1;this.delta=0;var h=new THREE.Vector3,m=new THREE.Vector3,k=new THREE.Vector3,n=new THREE.Matrix4,u=!1,p=1,v=0,t=0,x=0,w=0,y=0,z=window.innerWidth/2,B=window.innerHeight/2;this.update=
 function(){var b=(new Date).getTime();if(this.lastUpdate==-1)this.lastUpdate=b;this.delta=(b-this.lastUpdate)/1E3;this.lastUpdate=b;this.mouseLook&&(b=this.delta*this.lookSpeed,this.rotateHorizontally(b*w),this.rotateVertically(b*y));b=this.delta*this.movementSpeed;this.translateZ(b*(v>0||this.autoForward&&!(v<0)?1:v));this.translateX(b*t);this.translateY(b*x);u&&(this.roll+=this.rollSpeed*this.delta*p);if(this.forward.y>this.constrainVertical[1])this.forward.y=this.constrainVertical[1],this.forward.normalize();
 else if(this.forward.y<this.constrainVertical[0])this.forward.y=this.constrainVertical[0],this.forward.normalize();k.copy(this.forward);m.set(0,1,0);h.cross(m,k).normalize();m.cross(k,h).normalize();this.matrix.n11=h.x;this.matrix.n12=m.x;this.matrix.n13=k.x;this.matrix.n21=h.y;this.matrix.n22=m.y;this.matrix.n23=k.y;this.matrix.n31=h.z;this.matrix.n32=m.z;this.matrix.n33=k.z;n.identity();n.n11=Math.cos(this.roll);n.n12=-Math.sin(this.roll);n.n21=Math.sin(this.roll);n.n22=Math.cos(this.roll);this.matrix.multiplySelf(n);
 this.matrixWorldNeedsUpdate=!0;this.matrix.n14=this.position.x;this.matrix.n24=this.position.y;this.matrix.n34=this.position.z;this.supr.update.call(this)};this.translateX=function(b){this.position.x+=this.matrix.n11*b;this.position.y+=this.matrix.n21*b;this.position.z+=this.matrix.n31*b};this.translateY=function(b){this.position.x+=this.matrix.n12*b;this.position.y+=this.matrix.n22*b;this.position.z+=this.matrix.n32*b};this.translateZ=function(b){this.position.x-=this.matrix.n13*b;this.position.y-=
 this.matrix.n23*b;this.position.z-=this.matrix.n33*b};this.rotateHorizontally=function(b){h.set(this.matrix.n11,this.matrix.n21,this.matrix.n31);h.multiplyScalar(b);this.forward.subSelf(h);this.forward.normalize()};this.rotateVertically=function(b){m.set(this.matrix.n12,this.matrix.n22,this.matrix.n32);m.multiplyScalar(b);this.forward.addSelf(m);this.forward.normalize()};this.domElement.addEventListener("contextmenu",function(b){b.preventDefault()},!1);this.domElement.addEventListener("mousemove",
-function(b){w=(b.clientX-z)/window.innerWidth;y=(b.clientY-A)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:v=1;break;case 2:v=-1}},!1);this.domElement.addEventListener("mouseup",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:v=0;break;case 2:v=0}},!1);this.domElement.addEventListener("keydown",function(b){switch(b.keyCode){case 38:case 87:v=1;break;case 37:case 65:t=-1;break;
+function(b){w=(b.clientX-z)/window.innerWidth;y=(b.clientY-B)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:v=1;break;case 2:v=-1}},!1);this.domElement.addEventListener("mouseup",function(b){b.preventDefault();b.stopPropagation();switch(b.button){case 0:v=0;break;case 2:v=0}},!1);this.domElement.addEventListener("keydown",function(b){switch(b.keyCode){case 38:case 87:v=1;break;case 37:case 65:t=-1;break;
 case 40:case 83:v=-1;break;case 39:case 68:t=1;break;case 81:u=!0;p=1;break;case 69:u=!0;p=-1;break;case 82:x=1;break;case 70:x=-1}},!1);this.domElement.addEventListener("keyup",function(b){switch(b.keyCode){case 38:case 87:v=0;break;case 37:case 65:t=0;break;case 40:case 83:v=0;break;case 39:case 68:t=0;break;case 81:u=!1;break;case 69:u=!1;break;case 82:x=0;break;case 70:x=0}},!1)};THREE.RollCamera.prototype=new THREE.Camera;THREE.RollCamera.prototype.constructor=THREE.RollCamera;
 THREE.RollCamera.prototype.supr=THREE.Camera.prototype;
 THREE.TrackballCamera=function(b){function c(b,c){return function(){c.apply(b,arguments)}}b=b||{};THREE.Camera.call(this,b.fov,b.aspect,b.near,b.far,b.target);this.domElement=b.domElement||document;this.screen=b.screen||{width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=b.radius||(this.screen.width+this.screen.height)/4;this.rotateSpeed=b.rotateSpeed||1;this.zoomSpeed=b.zoomSpeed||1.2;this.panSpeed=b.panSpeed||0.3;this.noZoom=b.noZoom||!1;this.noPan=b.noPan||
@@ -473,23 +473,23 @@ c(this,function(b){e&&(m=k=this.getMouseProjectionOnBall(b.clientX,b.clientY),n=
 b.stopPropagation();if(f===this.STATE.NONE)f=b.button,f===this.STATE.ROTATE?m=k=this.getMouseProjectionOnBall(b.clientX,b.clientY):f===this.STATE.ZOOM&&!this.noZoom?n=u=this.getMouseOnScreen(b.clientX,b.clientY):this.noPan||(p=v=this.getMouseOnScreen(b.clientX,b.clientY))}),!1);this.domElement.addEventListener("mouseup",c(this,function(b){b.preventDefault();b.stopPropagation();f=this.STATE.NONE}),!1);window.addEventListener("keydown",c(this,function(b){if(f===this.STATE.NONE){if(b.keyCode===this.keys[this.STATE.ROTATE])f=
 this.STATE.ROTATE;else if(b.keyCode===this.keys[this.STATE.ZOOM]&&!this.noZoom)f=this.STATE.ZOOM;else if(b.keyCode===this.keys[this.STATE.PAN]&&!this.noPan)f=this.STATE.PAN;f!==this.STATE.NONE&&(e=!0)}}),!1);window.addEventListener("keyup",c(this,function(){if(f!==this.STATE.NONE)f=this.STATE.NONE}),!1)};THREE.TrackballCamera.prototype=new THREE.Camera;THREE.TrackballCamera.prototype.constructor=THREE.TrackballCamera;THREE.TrackballCamera.prototype.supr=THREE.Camera.prototype;
 THREE.TrackballCamera.prototype.STATE={NONE:-1,ROTATE:0,ZOOM:1,PAN:2};THREE.QuakeCamera=THREE.FirstPersonCamera;
-THREE.CubeGeometry=function(b,c,e,f,h,m,k,n,u){function p(b,c,e,k,n,p,t,u){var w,x,y=f||1,z=h||1,O=n/2,P=p/2,U=v.vertices.length;if(b=="x"&&c=="y"||b=="y"&&c=="x")w="z";else if(b=="x"&&c=="z"||b=="z"&&c=="x")w="y",z=m||1;else if(b=="z"&&c=="y"||b=="y"&&c=="z")w="x",y=m||1;var V=y+1,o=z+1;n/=y;var ea=p/z;for(x=0;x<o;x++)for(p=0;p<V;p++){var S=new THREE.Vector3;S[b]=(p*n-O)*e;S[c]=(x*ea-P)*k;S[w]=t;v.vertices.push(new THREE.Vertex(S))}for(x=0;x<z;x++)for(p=0;p<y;p++)v.faces.push(new THREE.Face4(p+V*
-x+U,p+V*(x+1)+U,p+1+V*(x+1)+U,p+1+V*x+U,null,null,u)),v.faceVertexUvs[0].push([new THREE.UV(p/y,x/z),new THREE.UV(p/y,(x+1)/z),new THREE.UV((p+1)/y,(x+1)/z),new THREE.UV((p+1)/y,x/z)])}THREE.Geometry.call(this);var v=this,t=b/2,x=c/2,w=e/2,n=n?-1:1;if(k!==void 0)if(k instanceof Array)this.materials=k;else{this.materials=[];for(var y=0;y<6;y++)this.materials.push([k])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(u!=void 0)for(var z in u)this.sides[z]!=void 0&&(this.sides[z]=
+THREE.CubeGeometry=function(b,c,e,f,h,m,k,n,u){function p(b,c,e,k,n,p,t,u){var w,x,y=f||1,z=h||1,O=n/2,P=p/2,U=v.vertices.length;if(b=="x"&&c=="y"||b=="y"&&c=="x")w="z";else if(b=="x"&&c=="z"||b=="z"&&c=="x")w="y",z=m||1;else if(b=="z"&&c=="y"||b=="y"&&c=="z")w="x",y=m||1;var W=y+1,o=z+1;n/=y;var da=p/z;for(x=0;x<o;x++)for(p=0;p<W;p++){var S=new THREE.Vector3;S[b]=(p*n-O)*e;S[c]=(x*da-P)*k;S[w]=t;v.vertices.push(new THREE.Vertex(S))}for(x=0;x<z;x++)for(p=0;p<y;p++)v.faces.push(new THREE.Face4(p+W*
+x+U,p+W*(x+1)+U,p+1+W*(x+1)+U,p+1+W*x+U,null,null,u)),v.faceVertexUvs[0].push([new THREE.UV(p/y,x/z),new THREE.UV(p/y,(x+1)/z),new THREE.UV((p+1)/y,(x+1)/z),new THREE.UV((p+1)/y,x/z)])}THREE.Geometry.call(this);var v=this,t=b/2,x=c/2,w=e/2,n=n?-1:1;if(k!==void 0)if(k instanceof Array)this.materials=k;else{this.materials=[];for(var y=0;y<6;y++)this.materials.push([k])}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(u!=void 0)for(var z in u)this.sides[z]!=void 0&&(this.sides[z]=
 u[z]);this.sides.px&&p("z","y",1*n,-1,e,c,-t,this.materials[0]);this.sides.nx&&p("z","y",-1*n,-1,e,c,t,this.materials[1]);this.sides.py&&p("x","z",1*n,1,b,e,x,this.materials[2]);this.sides.ny&&p("x","z",1*n,-1,b,e,-x,this.materials[3]);this.sides.pz&&p("x","y",1*n,-1,b,c,w,this.materials[4]);this.sides.nz&&p("x","y",-1*n,-1,b,c,-w,this.materials[5]);(function(){for(var b=[],c=[],e=0,f=v.vertices.length;e<f;e++){for(var k=v.vertices[e],h=!1,m=0,n=b.length;m<n;m++){var p=b[m];if(k.position.x==p.position.x&&
 k.position.y==p.position.y&&k.position.z==p.position.z){c[e]=m;h=!0;break}}if(!h)c[e]=b.length,b.push(new THREE.Vertex(k.position.clone()))}e=0;for(f=v.faces.length;e<f;e++)k=v.faces[e],k.a=c[k.a],k.b=c[k.b],k.c=c[k.c],k.d=c[k.d];v.vertices=b})();this.computeCentroids();this.computeFaceNormals()};THREE.CubeGeometry.prototype=new THREE.Geometry;THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
 THREE.CylinderGeometry=function(b,c,e,f,h,m){THREE.Geometry.call(this);var b=b!=null?b:20,c=c!=null?c:20,e=e||100,k=e/2,f=f||8,h=h||1,n,u,p=[],v=[];for(u=0;u<=h;u++){var t=[],x=[],w=u/h,y=w*(c-b)+b;for(n=0;n<=f;n++){var z=n/f;this.vertices.push(new THREE.Vertex(new THREE.Vector3(y*Math.sin(z*Math.PI*2),-w*e+k,y*Math.cos(z*Math.PI*2))));t.push(this.vertices.length-1);x.push(new THREE.UV(z,w))}p.push(t);v.push(x)}for(u=0;u<h;u++)for(n=0;n<f;n++){var e=p[u][n],t=p[u+1][n],x=p[u+1][n+1],w=p[u][n+1],y=
-this.vertices[e].position.clone().setY(0).normalize(),z=this.vertices[t].position.clone().setY(0).normalize(),A=this.vertices[x].position.clone().setY(0).normalize(),E=this.vertices[w].position.clone().setY(0).normalize(),D=v[u][n].clone(),F=v[u+1][n].clone(),G=v[u+1][n+1].clone(),N=v[u][n+1].clone();this.faces.push(new THREE.Face4(e,t,x,w,[y,z,A,E]));this.faceVertexUvs[0].push([D,F,G,N])}if(!m&&b>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,k,0)));for(n=0;n<f;n++)e=p[0][n],t=p[0][n+
-1],x=this.vertices.length-1,y=new THREE.Vector3(0,1,0),z=new THREE.Vector3(0,1,0),A=new THREE.Vector3(0,1,0),D=v[0][n].clone(),F=v[0][n+1].clone(),G=new THREE.UV(F.u,0),this.faces.push(new THREE.Face3(e,t,x,[y,z,A])),this.faceVertexUvs[0].push([D,F,G])}if(!m&&c>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-k,0)));for(n=0;n<f;n++)e=p[u][n+1],t=p[u][n],x=this.vertices.length-1,y=new THREE.Vector3(0,-1,0),z=new THREE.Vector3(0,-1,0),A=new THREE.Vector3(0,-1,0),D=v[u][n+1].clone(),F=v[u][n].clone(),
-G=new THREE.UV(F.u,1),this.faces.push(new THREE.Face3(e,t,x,[y,z,A])),this.faceVertexUvs[0].push([D,F,G])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
+this.vertices[e].position.clone().setY(0).normalize(),z=this.vertices[t].position.clone().setY(0).normalize(),B=this.vertices[x].position.clone().setY(0).normalize(),D=this.vertices[w].position.clone().setY(0).normalize(),E=v[u][n].clone(),F=v[u+1][n].clone(),G=v[u+1][n+1].clone(),N=v[u][n+1].clone();this.faces.push(new THREE.Face4(e,t,x,w,[y,z,B,D]));this.faceVertexUvs[0].push([E,F,G,N])}if(!m&&b>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,k,0)));for(n=0;n<f;n++)e=p[0][n],t=p[0][n+
+1],x=this.vertices.length-1,y=new THREE.Vector3(0,1,0),z=new THREE.Vector3(0,1,0),B=new THREE.Vector3(0,1,0),E=v[0][n].clone(),F=v[0][n+1].clone(),G=new THREE.UV(F.u,0),this.faces.push(new THREE.Face3(e,t,x,[y,z,B])),this.faceVertexUvs[0].push([E,F,G])}if(!m&&c>0){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-k,0)));for(n=0;n<f;n++)e=p[u][n+1],t=p[u][n],x=this.vertices.length-1,y=new THREE.Vector3(0,-1,0),z=new THREE.Vector3(0,-1,0),B=new THREE.Vector3(0,-1,0),E=v[u][n+1].clone(),F=v[u][n].clone(),
+G=new THREE.UV(F.u,1),this.faces.push(new THREE.Face3(e,t,x,[y,z,B])),this.faceVertexUvs[0].push([E,F,G])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
 THREE.ExtrudeGeometry=function(b,c){if(typeof b!="undefined"){THREE.Geometry.call(this);var b=b instanceof Array?b:[b],e,f=b.length,h;this.shapebb=b[f-1].getBoundingBox();for(e=0;e<f;e++)h=b[e],this.addShape(h,c);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
 THREE.ExtrudeGeometry.prototype.addShape=function(b,c){function e(b,c,e){c||console.log("die");return c.clone().multiplyScalar(e).addSelf(b)}function f(b,c,e){var f=THREE.ExtrudeGeometry.__v1,k=THREE.ExtrudeGeometry.__v2,h=THREE.ExtrudeGeometry.__v3,m=THREE.ExtrudeGeometry.__v4,n=THREE.ExtrudeGeometry.__v5,o=THREE.ExtrudeGeometry.__v6;f.set(b.x-c.x,b.y-c.y);k.set(b.x-e.x,b.y-e.y);f=f.normalize();k=k.normalize();h.set(-f.y,f.x);m.set(k.y,-k.x);n.copy(b).addSelf(h);o.copy(b).addSelf(m);if(n.equals(o))return m.clone();
-n.copy(c).addSelf(h);o.copy(e).addSelf(m);h=f.dot(m);m=o.subSelf(n).dot(m);h==0&&(console.log("Either infinite or no solutions!"),m==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));m/=h;if(m<0)return c=Math.atan2(c.y-b.y,c.x-b.x),b=Math.atan2(e.y-b.y,e.x-b.x),c>b&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(m).addSelf(n).subSelf(b).clone()}function h(b){for(C=b.length;--C>=0;){ma=C;da=C-1;da<0&&(da=b.length-
-1);for(var c=0,e=w+v*2,c=0;c<e;c++){var f=ea*c,k=ea*(c+1),h=Y+ma+f,m=Y+ma+k,o=h,f=Y+da+f,k=Y+da+k,p=m;o+=X;f+=X;k+=X;p+=X;M.faces.push(new THREE.Face4(o,f,k,p,null,null,G));G&&(o=c/e,f=(c+1)/e,k=n+u*2,h=(M.vertices[h].position.z+u)/k,m=(M.vertices[m].position.z+u)/k,M.faceVertexUvs[0].push([new THREE.UV(h,o),new THREE.UV(m,o),new THREE.UV(m,f),new THREE.UV(h,f)]))}}}function m(b,c,e){M.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}function k(b,c,e){b+=X;c+=X;e+=X;M.faces.push(new THREE.Face3(b,
-c,e,null,null,F));if(F){var f=N.maxY,k=N.maxX,h=M.vertices[c].position.x,c=M.vertices[c].position.y,m=M.vertices[e].position.x,e=M.vertices[e].position.y;M.faceVertexUvs[0].push([new THREE.UV(M.vertices[b].position.x/k,M.vertices[b].position.y/f),new THREE.UV(h/k,c/f),new THREE.UV(m/k,e/f)])}}var n=c.amount!==void 0?c.amount:100,u=c.bevelThickness!==void 0?c.bevelThickness:6,p=c.bevelSize!==void 0?c.bevelSize:u-2,v=c.bevelSegments!==void 0?c.bevelSegments:3,t=c.bevelEnabled!==void 0?c.bevelEnabled:
-!0,x=c.curveSegments!==void 0?c.curveSegments:12,w=c.steps!==void 0?c.steps:1,y=c.bendPath,z=c.extrudePath,A,E=!1,D=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1,F=c.material,G=c.extrudeMaterial,N=this.shapebb;if(z)A=z.getPoints(x),w=A.length,E=!0,t=!1;t||(p=u=v=0);var Q,L,H,M=this,X=this.vertices.length;y&&b.addWrapPath(y);x=D?b.extractAllSpacedPoints(x):b.extractAllPoints(x);y=x.shape;x=x.holes;if(z=!THREE.Shape.Utils.isClockWise(y)){y=y.reverse();L=0;for(H=x.length;L<H;L++)Q=x[L],THREE.Shape.Utils.isClockWise(Q)&&
-(x[L]=Q.reverse());z=!1}z=THREE.Shape.Utils.triangulateShape(y,x);D=y;L=0;for(H=x.length;L<H;L++)Q=x[L],y=y.concat(Q);var C,O,P,U,V,o,ea=y.length,S=z.length,ta=[];C=0;O=D.length;ma=O-1;for(da=C+1;C<O;C++,ma++,da++)ma==O&&(ma=0),da==O&&(da=0),ta[C]=f(D[C],D[ma],D[da]);var $=[],la,ja=ta.concat();L=0;for(H=x.length;L<H;L++){Q=x[L];la=[];C=0;O=Q.length;ma=O-1;for(da=C+1;C<O;C++,ma++,da++)ma==O&&(ma=0),da==O&&(da=0),la[C]=f(Q[C],Q[ma],Q[da]);$.push(la);ja=ja.concat(la)}for(P=0;P<v;P++){U=P/v;V=u*(1-U);
-U=p*Math.sin(U*Math.PI/2);C=0;for(O=D.length;C<O;C++)o=e(D[C],ta[C],U),m(o.x,o.y,-V);L=0;for(H=x.length;L<H;L++){Q=x[L];la=$[L];C=0;for(O=Q.length;C<O;C++)o=e(Q[C],la[C],U),m(o.x,o.y,-V)}}U=p;for(C=0;C<ea;C++)o=t?e(y[C],ja[C],U):y[C],E?m(o.x,o.y+A[0].y,A[0].x):m(o.x,o.y,0);for(P=1;P<=w;P++)for(C=0;C<ea;C++)o=t?e(y[C],ja[C],U):y[C],E?m(o.x,o.y+A[P-1].y,A[P-1].x):m(o.x,o.y,n/w*P);for(P=v-1;P>=0;P--){U=P/v;V=u*(1-U);U=p*Math.sin(U*Math.PI/2);C=0;for(O=D.length;C<O;C++)o=e(D[C],ta[C],U),m(o.x,o.y,n+V);
-L=0;for(H=x.length;L<H;L++){Q=x[L];la=$[L];C=0;for(O=Q.length;C<O;C++)o=e(Q[C],la[C],U),E?m(o.x,o.y+A[w-1].y,A[w-1].x+V):m(o.x,o.y,n+V)}}if(t){t=ea*0;for(C=0;C<S;C++)p=z[C],k(p[2]+t,p[1]+t,p[0]+t);t=ea*(w+v*2);for(C=0;C<S;C++)p=z[C],k(p[0]+t,p[1]+t,p[2]+t)}else{for(C=0;C<S;C++)p=z[C],k(p[2],p[1],p[0]);for(C=0;C<S;C++)p=z[C],k(p[0]+ea*w,p[1]+ea*w,p[2]+ea*w)}var ma,da,Y=0;h(D);Y+=D.length;L=0;for(H=x.length;L<H;L++)Q=x[L],h(Q),Y+=Q.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;
+n.copy(c).addSelf(h);o.copy(e).addSelf(m);h=f.dot(m);m=o.subSelf(n).dot(m);h==0&&(console.log("Either infinite or no solutions!"),m==0?console.log("Its finite solutions."):console.log("Too bad, no solutions."));m/=h;if(m<0)return c=Math.atan2(c.y-b.y,c.x-b.x),b=Math.atan2(e.y-b.y,e.x-b.x),c>b&&(b+=Math.PI*2),anglec=(c+b)/2,new THREE.Vector2(-Math.cos(anglec),-Math.sin(anglec));return f.multiplyScalar(m).addSelf(n).subSelf(b).clone()}function h(b){for(C=b.length;--C>=0;){ma=C;ca=C-1;ca<0&&(ca=b.length-
+1);for(var c=0,e=w+v*2,c=0;c<e;c++){var f=da*c,k=da*(c+1),h=ha+ma+f,m=ha+ma+k,o=h,f=ha+ca+f,k=ha+ca+k,p=m;o+=X;f+=X;k+=X;p+=X;I.faces.push(new THREE.Face4(o,f,k,p,null,null,G));G&&(o=c/e,f=(c+1)/e,k=n+u*2,h=(I.vertices[h].position.z+u)/k,m=(I.vertices[m].position.z+u)/k,I.faceVertexUvs[0].push([new THREE.UV(h,o),new THREE.UV(m,o),new THREE.UV(m,f),new THREE.UV(h,f)]))}}}function m(b,c,e){I.vertices.push(new THREE.Vertex(new THREE.Vector3(b,c,e)))}function k(b,c,e){b+=X;c+=X;e+=X;I.faces.push(new THREE.Face3(b,
+c,e,null,null,F));if(F){var f=N.maxY,k=N.maxX,h=I.vertices[c].position.x,c=I.vertices[c].position.y,m=I.vertices[e].position.x,e=I.vertices[e].position.y;I.faceVertexUvs[0].push([new THREE.UV(I.vertices[b].position.x/k,I.vertices[b].position.y/f),new THREE.UV(h/k,c/f),new THREE.UV(m/k,e/f)])}}var n=c.amount!==void 0?c.amount:100,u=c.bevelThickness!==void 0?c.bevelThickness:6,p=c.bevelSize!==void 0?c.bevelSize:u-2,v=c.bevelSegments!==void 0?c.bevelSegments:3,t=c.bevelEnabled!==void 0?c.bevelEnabled:
+!0,x=c.curveSegments!==void 0?c.curveSegments:12,w=c.steps!==void 0?c.steps:1,y=c.bendPath,z=c.extrudePath,B,D=!1,E=c.useSpacedPoints!==void 0?c.useSpacedPoints:!1,F=c.material,G=c.extrudeMaterial,N=this.shapebb;if(z)B=z.getPoints(x),w=B.length,D=!0,t=!1;t||(p=u=v=0);var Q,H,K,I=this,X=this.vertices.length;y&&b.addWrapPath(y);x=E?b.extractAllSpacedPoints(x):b.extractAllPoints(x);y=x.shape;x=x.holes;if(z=!THREE.Shape.Utils.isClockWise(y)){y=y.reverse();H=0;for(K=x.length;H<K;H++)Q=x[H],THREE.Shape.Utils.isClockWise(Q)&&
+(x[H]=Q.reverse());z=!1}z=THREE.Shape.Utils.triangulateShape(y,x);E=y;H=0;for(K=x.length;H<K;H++)Q=x[H],y=y.concat(Q);var C,O,P,U,W,o,da=y.length,S=z.length,la=[];C=0;O=E.length;ma=O-1;for(ca=C+1;C<O;C++,ma++,ca++)ma==O&&(ma=0),ca==O&&(ca=0),la[C]=f(E[C],E[ma],E[ca]);var aa=[],ia,ka=la.concat();H=0;for(K=x.length;H<K;H++){Q=x[H];ia=[];C=0;O=Q.length;ma=O-1;for(ca=C+1;C<O;C++,ma++,ca++)ma==O&&(ma=0),ca==O&&(ca=0),ia[C]=f(Q[C],Q[ma],Q[ca]);aa.push(ia);ka=ka.concat(ia)}for(P=0;P<v;P++){U=P/v;W=u*(1-
+U);U=p*Math.sin(U*Math.PI/2);C=0;for(O=E.length;C<O;C++)o=e(E[C],la[C],U),m(o.x,o.y,-W);H=0;for(K=x.length;H<K;H++){Q=x[H];ia=aa[H];C=0;for(O=Q.length;C<O;C++)o=e(Q[C],ia[C],U),m(o.x,o.y,-W)}}U=p;for(C=0;C<da;C++)o=t?e(y[C],ka[C],U):y[C],D?m(o.x,o.y+B[0].y,B[0].x):m(o.x,o.y,0);for(P=1;P<=w;P++)for(C=0;C<da;C++)o=t?e(y[C],ka[C],U):y[C],D?m(o.x,o.y+B[P-1].y,B[P-1].x):m(o.x,o.y,n/w*P);for(P=v-1;P>=0;P--){U=P/v;W=u*(1-U);U=p*Math.sin(U*Math.PI/2);C=0;for(O=E.length;C<O;C++)o=e(E[C],la[C],U),m(o.x,o.y,
+n+W);H=0;for(K=x.length;H<K;H++){Q=x[H];ia=aa[H];C=0;for(O=Q.length;C<O;C++)o=e(Q[C],ia[C],U),D?m(o.x,o.y+B[w-1].y,B[w-1].x+W):m(o.x,o.y,n+W)}}if(t){t=da*0;for(C=0;C<S;C++)p=z[C],k(p[2]+t,p[1]+t,p[0]+t);t=da*(w+v*2);for(C=0;C<S;C++)p=z[C],k(p[0]+t,p[1]+t,p[2]+t)}else{for(C=0;C<S;C++)p=z[C],k(p[2],p[1],p[0]);for(C=0;C<S;C++)p=z[C],k(p[0]+da*w,p[1]+da*w,p[2]+da*w)}var ma,ca,ha=0;h(E);ha+=E.length;H=0;for(K=x.length;H<K;H++)Q=x[H],h(Q),ha+=Q.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;
 THREE.ExtrudeGeometry.__v2=new THREE.Vector2;THREE.ExtrudeGeometry.__v3=new THREE.Vector2;THREE.ExtrudeGeometry.__v4=new THREE.Vector2;THREE.ExtrudeGeometry.__v5=new THREE.Vector2;THREE.ExtrudeGeometry.__v6=new THREE.Vector2;
 THREE.IcosahedronGeometry=function(b){function c(b,c,e){var f=Math.sqrt(b*b+c*c+e*e);return h.vertices.push(new THREE.Vertex(new THREE.Vector3(b/f,c/f,e/f)))-1}function e(b,c,e,f){f.faces.push(new THREE.Face3(b,c,e))}function f(b,e){var f=h.vertices[b].position,k=h.vertices[e].position;return c((f.x+k.x)/2,(f.y+k.y)/2,(f.z+k.z)/2)}var h=this,m=new THREE.Geometry;this.subdivisions=b||0;THREE.Geometry.call(this);b=(1+Math.sqrt(5))/2;c(-1,b,0);c(1,b,0);c(-1,-b,0);c(1,-b,0);c(0,-1,b);c(0,1,b);c(0,-1,
 -b);c(0,1,-b);c(b,0,-1);c(b,0,1);c(-b,0,-1);c(-b,0,1);e(0,11,5,m);e(0,5,1,m);e(0,1,7,m);e(0,7,10,m);e(0,10,11,m);e(1,5,9,m);e(5,11,4,m);e(11,10,2,m);e(10,7,6,m);e(7,1,8,m);e(3,9,4,m);e(3,4,2,m);e(3,2,6,m);e(3,6,8,m);e(3,8,9,m);e(4,9,5,m);e(2,4,11,m);e(6,2,10,m);e(8,6,7,m);e(9,8,1,m);for(var k=0;k<this.subdivisions;k++){var b=new THREE.Geometry,n;for(n in m.faces){var u=f(m.faces[n].a,m.faces[n].b),p=f(m.faces[n].b,m.faces[n].c),v=f(m.faces[n].c,m.faces[n].a);e(m.faces[n].a,u,v,b);e(m.faces[n].b,p,
@@ -499,18 +499,18 @@ for(n=0;n<f.length-1;n++)this.faces.push(new THREE.Face4(h[n],h[n+1],f[n+1],f[n]
 THREE.PlaneGeometry=function(b,c,e,f){THREE.Geometry.call(this);var h,m=b/2,k=c/2,e=e||1,f=f||1,n=e+1,u=f+1;b/=e;var p=c/f;for(h=0;h<u;h++)for(c=0;c<n;c++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(c*b-m,-(h*p-k),0)));for(h=0;h<f;h++)for(c=0;c<e;c++)this.faces.push(new THREE.Face4(c+n*h,c+n*(h+1),c+1+n*(h+1),c+1+n*h)),this.faceVertexUvs[0].push([new THREE.UV(c/e,h/f),new THREE.UV(c/e,(h+1)/f),new THREE.UV((c+1)/e,(h+1)/f),new THREE.UV((c+1)/e,h/f)]);this.computeCentroids();this.computeFaceNormals()};
 THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
 THREE.SphereGeometry=function(b,c,e){THREE.Geometry.call(this);for(var b=b||50,f,h=Math.PI,m=Math.max(3,c||8),k=Math.max(2,e||6),c=[],e=0;e<k+1;e++){f=e/k;var n=b*Math.cos(f*h),u=b*Math.sin(f*h),p=[],v=0;for(f=0;f<m;f++){var t=2*f/m,x=u*Math.sin(t*h),t=u*Math.cos(t*h);(e==0||e==k)&&f>0||(v=this.vertices.push(new THREE.Vertex(new THREE.Vector3(t,n,x)))-1);p.push(v)}c.push(p)}for(var w,y,z,h=c.length,e=0;e<h;e++)if(m=c[e].length,e>0)for(f=0;f<m;f++){p=f==m-1;k=c[e][p?0:f+1];n=c[e][p?m-1:f];u=c[e-1][p?
-m-1:f];p=c[e-1][p?0:f+1];x=e/(h-1);w=(e-1)/(h-1);y=(f+1)/m;var t=f/m,v=new THREE.UV(1-y,x),x=new THREE.UV(1-t,x),t=new THREE.UV(1-t,w),A=new THREE.UV(1-y,w);e<c.length-1&&(w=this.vertices[k].position.clone(),y=this.vertices[n].position.clone(),z=this.vertices[u].position.clone(),w.normalize(),y.normalize(),z.normalize(),this.faces.push(new THREE.Face3(k,n,u,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)])),this.faceVertexUvs[0].push([v,x,t]));e>1&&(w=
-this.vertices[k].position.clone(),y=this.vertices[u].position.clone(),z=this.vertices[p].position.clone(),w.normalize(),y.normalize(),z.normalize(),this.faces.push(new THREE.Face3(k,u,p,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)])),this.faceVertexUvs[0].push([v,t,A]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry;
+m-1:f];p=c[e-1][p?0:f+1];x=e/(h-1);w=(e-1)/(h-1);y=(f+1)/m;var t=f/m,v=new THREE.UV(1-y,x),x=new THREE.UV(1-t,x),t=new THREE.UV(1-t,w),B=new THREE.UV(1-y,w);e<c.length-1&&(w=this.vertices[k].position.clone(),y=this.vertices[n].position.clone(),z=this.vertices[u].position.clone(),w.normalize(),y.normalize(),z.normalize(),this.faces.push(new THREE.Face3(k,n,u,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)])),this.faceVertexUvs[0].push([v,x,t]));e>1&&(w=
+this.vertices[k].position.clone(),y=this.vertices[u].position.clone(),z=this.vertices[p].position.clone(),w.normalize(),y.normalize(),z.normalize(),this.faces.push(new THREE.Face3(k,u,p,[new THREE.Vector3(w.x,w.y,w.z),new THREE.Vector3(y.x,y.y,y.z),new THREE.Vector3(z.x,z.y,z.z)])),this.faceVertexUvs[0].push([v,t,B]))}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals();this.boundingSphere={radius:b}};THREE.SphereGeometry.prototype=new THREE.Geometry;
 THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
 THREE.TextGeometry=function(b,c){var e=(new THREE.TextPath(b,c)).toShapes();c.amount=c.height!==void 0?c.height:50;if(c.bevelThickness===void 0)c.bevelThickness=10;if(c.bevelSize===void 0)c.bevelSize=8;if(c.bevelEnabled===void 0)c.bevelEnabled=!1;if(c.bend){var f=e[e.length-1].getBoundingBox().maxX;c.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(f/2,120),new THREE.Vector2(f,0))}THREE.ExtrudeGeometry.call(this,e,c)};THREE.TextGeometry.prototype=new THREE.ExtrudeGeometry;
 THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
 THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:150,divisions:10,getFace:function(){return this.faces[this.face][this.weight][this.style]},getTextShapes:function(b,c){return(new TextPath(b,c)).toShapes()},loadFace:function(b){var c=b.familyName.toLowerCase();this.faces[c]=this.faces[c]||{};this.faces[c][b.cssFontWeight]=this.faces[c][b.cssFontWeight]||{};this.faces[c][b.cssFontWeight][b.cssFontStyle]=b;return this.faces[c][b.cssFontWeight][b.cssFontStyle]=b},drawText:function(b){for(var c=
-this.getFace(),e=this.size/c.resolution,f=0,h=String(b).split(""),m=h.length,k=[],b=0;b<m;b++){var n=new THREE.Path,n=this.extractGlyphPoints(h[b],c,e,f,n);f+=n.offset;k.push(n.path)}return{paths:k,offset:f/2}},extractGlyphPoints:function(b,c,e,f,h){var m=[],k,n,u,p,v,t,x,w,y,z,A=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(A){if(A.o){c=A._cachedOutline||(A._cachedOutline=A.o.split(" "));u=c.length;for(b=0;b<u;)switch(n=c[b++],n){case "m":n=c[b++]*e+f;p=c[b++]*e;m.push(new THREE.Vector2(n,
-p));h.moveTo(n,p);break;case "l":n=c[b++]*e+f;p=c[b++]*e;m.push(new THREE.Vector2(n,p));h.lineTo(n,p);break;case "q":n=c[b++]*e+f;p=c[b++]*e;x=c[b++]*e+f;w=c[b++]*e;h.quadraticCurveTo(x,w,n,p);if(k=m[m.length-1]){v=k.x;t=k.y;k=1;for(divisions=this.divisions;k<=divisions;k++){var E=k/divisions,D=THREE.Shape.Utils.b2(E,v,x,n),E=THREE.Shape.Utils.b2(E,t,w,p);m.push(new THREE.Vector2(D,E))}}break;case "b":if(n=c[b++]*e+f,p=c[b++]*e,x=c[b++]*e+f,w=c[b++]*-e,y=c[b++]*e+f,z=c[b++]*-e,h.bezierCurveTo(n,p,
-x,w,y,z),k=m[m.length-1]){v=k.x;t=k.y;k=1;for(divisions=this.divisions;k<=divisions;k++)E=k/divisions,D=THREE.Shape.Utils.b3(E,v,x,y,n),E=THREE.Shape.Utils.b3(E,t,w,z,p),m.push(new THREE.Vector2(D,E))}}}return{offset:A.ha*e,points:m,path:h}}}};
-(function(b){var c=function(b){for(var c=b.length,h=0,m=c-1,k=0;k<c;m=k++)h+=b[m].x*b[k].y-b[k].x*b[m].y;return h*0.5};b.Triangulate=function(b,f){var h=b.length;if(h<3)return null;var m=[],k=[],n=[],u,p,v;if(c(b)>0)for(p=0;p<h;p++)k[p]=p;else for(p=0;p<h;p++)k[p]=h-1-p;var t=2*h;for(p=h-1;h>2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return n;return m}u=p;h<=u&&(u=0);p=u+1;h<=p&&(p=0);v=p+1;h<=v&&(v=0);var x;a:{x=b;var w=u,y=p,z=v,A=h,E=k,D=void 0,F=void 0,G=void 0,
-N=void 0,Q=void 0,L=void 0,H=void 0,M=void 0,X=void 0,F=x[E[w]].x,G=x[E[w]].y,N=x[E[y]].x,Q=x[E[y]].y,L=x[E[z]].x,H=x[E[z]].y;if(1.0E-10>(N-F)*(H-G)-(Q-G)*(L-F))x=!1;else{for(D=0;D<A;D++)if(!(D==w||D==y||D==z)){var M=x[E[D]].x,X=x[E[D]].y,C=void 0,O=void 0,P=void 0,U=void 0,V=void 0,o=void 0,ea=void 0,S=void 0,ta=void 0,$=void 0,la=void 0,ja=void 0,C=P=V=void 0,C=L-N,O=H-Q,P=F-L,U=G-H,V=N-F,o=Q-G,ea=M-F,S=X-G,ta=M-N,$=X-Q,la=M-L,ja=X-H,C=C*$-O*ta,V=V*S-o*ea,P=P*ja-U*la;if(C>=0&&P>=0&&V>=0){x=!1;break a}}x=
-!0}}if(x){m.push([b[k[u]],b[k[p]],b[k[v]]]);n.push([k[u],k[p],k[v]]);u=p;for(v=p+1;v<h;u++,v++)k[u]=k[v];h--;t=2*h}}if(f)return n;return m};b.Triangulate.area=c;return b})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
+this.getFace(),e=this.size/c.resolution,f=0,h=String(b).split(""),m=h.length,k=[],b=0;b<m;b++){var n=new THREE.Path,n=this.extractGlyphPoints(h[b],c,e,f,n);f+=n.offset;k.push(n.path)}return{paths:k,offset:f/2}},extractGlyphPoints:function(b,c,e,f,h){var m=[],k,n,u,p,v,t,x,w,y,z,B=c.glyphs[b]||c.glyphs[ctxt.options.fallbackCharacter];if(B){if(B.o){c=B._cachedOutline||(B._cachedOutline=B.o.split(" "));u=c.length;for(b=0;b<u;)switch(n=c[b++],n){case "m":n=c[b++]*e+f;p=c[b++]*e;m.push(new THREE.Vector2(n,
+p));h.moveTo(n,p);break;case "l":n=c[b++]*e+f;p=c[b++]*e;m.push(new THREE.Vector2(n,p));h.lineTo(n,p);break;case "q":n=c[b++]*e+f;p=c[b++]*e;x=c[b++]*e+f;w=c[b++]*e;h.quadraticCurveTo(x,w,n,p);if(k=m[m.length-1]){v=k.x;t=k.y;k=1;for(divisions=this.divisions;k<=divisions;k++){var D=k/divisions,E=THREE.Shape.Utils.b2(D,v,x,n),D=THREE.Shape.Utils.b2(D,t,w,p);m.push(new THREE.Vector2(E,D))}}break;case "b":if(n=c[b++]*e+f,p=c[b++]*e,x=c[b++]*e+f,w=c[b++]*-e,y=c[b++]*e+f,z=c[b++]*-e,h.bezierCurveTo(n,p,
+x,w,y,z),k=m[m.length-1]){v=k.x;t=k.y;k=1;for(divisions=this.divisions;k<=divisions;k++)D=k/divisions,E=THREE.Shape.Utils.b3(D,v,x,y,n),D=THREE.Shape.Utils.b3(D,t,w,z,p),m.push(new THREE.Vector2(E,D))}}}return{offset:B.ha*e,points:m,path:h}}}};
+(function(b){var c=function(b){for(var c=b.length,h=0,m=c-1,k=0;k<c;m=k++)h+=b[m].x*b[k].y-b[k].x*b[m].y;return h*0.5};b.Triangulate=function(b,f){var h=b.length;if(h<3)return null;var m=[],k=[],n=[],u,p,v;if(c(b)>0)for(p=0;p<h;p++)k[p]=p;else for(p=0;p<h;p++)k[p]=h-1-p;var t=2*h;for(p=h-1;h>2;){if(t--<=0){console.log("Warning, unable to triangulate polygon!");if(f)return n;return m}u=p;h<=u&&(u=0);p=u+1;h<=p&&(p=0);v=p+1;h<=v&&(v=0);var x;a:{x=b;var w=u,y=p,z=v,B=h,D=k,E=void 0,F=void 0,G=void 0,
+N=void 0,Q=void 0,H=void 0,K=void 0,I=void 0,X=void 0,F=x[D[w]].x,G=x[D[w]].y,N=x[D[y]].x,Q=x[D[y]].y,H=x[D[z]].x,K=x[D[z]].y;if(1.0E-10>(N-F)*(K-G)-(Q-G)*(H-F))x=!1;else{for(E=0;E<B;E++)if(!(E==w||E==y||E==z)){var I=x[D[E]].x,X=x[D[E]].y,C=void 0,O=void 0,P=void 0,U=void 0,W=void 0,o=void 0,da=void 0,S=void 0,la=void 0,aa=void 0,ia=void 0,ka=void 0,C=P=W=void 0,C=H-N,O=K-Q,P=F-H,U=G-K,W=N-F,o=Q-G,da=I-F,S=X-G,la=I-N,aa=X-Q,ia=I-H,ka=X-K,C=C*aa-O*la,W=W*S-o*da,P=P*ka-U*ia;if(C>=0&&P>=0&&W>=0){x=!1;
+break a}}x=!0}}if(x){m.push([b[k[u]],b[k[p]],b[k[v]]]);n.push([k[u],k[p],k[v]]);u=p;for(v=p+1;v<h;u++,v++)k[u]=k[v];h--;t=2*h}}if(f)return n;return m};b.Triangulate.area=c;return b})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
 THREE.TorusGeometry=function(b,c,e,f,h){THREE.Geometry.call(this);this.radius=b||100;this.tube=c||40;this.segmentsR=e||8;this.segmentsT=f||6;this.arc=h||Math.PI*2;h=new THREE.Vector3;b=[];c=[];for(e=0;e<=this.segmentsR;e++)for(f=0;f<=this.segmentsT;f++){var m=f/this.segmentsT*this.arc,k=e/this.segmentsR*Math.PI*2;h.x=this.radius*Math.cos(m);h.y=this.radius*Math.sin(m);var n=new THREE.Vector3;n.x=(this.radius+this.tube*Math.cos(k))*Math.cos(m);n.y=(this.radius+this.tube*Math.cos(k))*Math.sin(m);n.z=
 this.tube*Math.sin(k);this.vertices.push(new THREE.Vertex(n));b.push(new THREE.UV(f/this.segmentsT,1-e/this.segmentsR));c.push(n.clone().subSelf(h).normalize())}for(e=1;e<=this.segmentsR;e++)for(f=1;f<=this.segmentsT;f++){var h=(this.segmentsT+1)*e+f-1,m=(this.segmentsT+1)*(e-1)+f-1,k=(this.segmentsT+1)*(e-1)+f,n=(this.segmentsT+1)*e+f,u=new THREE.Face4(h,m,k,n,[c[h],c[m],c[k],c[n]]);u.normal.addSelf(c[h]);u.normal.addSelf(c[m]);u.normal.addSelf(c[k]);u.normal.addSelf(c[n]);u.normal.normalize();this.faces.push(u);
 this.faceVertexUvs[0].push([b[h].clone(),b[m].clone(),b[k].clone(),b[n].clone()])}this.computeCentroids()};THREE.TorusGeometry.prototype=new THREE.Geometry;THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
@@ -532,109 +532,109 @@ c.postMessage(b)};
 THREE.BinaryLoader.prototype.loadAjaxBuffers=function(b,c,e,f,h,m){var k=new XMLHttpRequest,n=f+"/"+b,u=0;k.onreadystatechange=function(){k.readyState==4?k.status==200||k.status==0?THREE.BinaryLoader.prototype.createBinModel(k.responseText,e,h,c):alert("Couldn't load ["+n+"] ["+k.status+"]"):k.readyState==3?m&&(u==0&&(u=k.getResponseHeader("Content-Length")),m({total:u,loaded:k.responseText.length})):k.readyState==2&&(u=k.getResponseHeader("Content-Length"))};k.open("GET",n,!0);k.overrideMimeType("text/plain; charset=x-user-defined");
 k.setRequestHeader("Content-Type","text/plain");k.send(null)};
 THREE.BinaryLoader.prototype.createBinModel=function(b,c,e,f){var h=function(c){function e(b,c){var f=v(b,c),h=v(b,c+1),k=v(b,c+2),m=v(b,c+3),n=(m<<1&255|k>>7)-127;f|=(k&127)<<16|h<<8;if(f==0&&n==-127)return 0;return(1-2*(m>>7))*(1+f*Math.pow(2,-23))*Math.pow(2,n)}function h(b,c){var e=v(b,c),f=v(b,c+1),k=v(b,c+2);return(v(b,c+3)<<24)+(k<<16)+(f<<8)+e}function u(b,c){var e=v(b,c);return(v(b,c+1)<<8)+e}function p(b,c){var e=v(b,c);return e>127?e-256:e}function v(b,c){return b.charCodeAt(c)&255}function t(c){var e,
-f,k;e=h(b,c);f=h(b,c+Q);k=h(b,c+L);c=u(b,c+H);E.faces.push(new THREE.Face3(e,f,k,null,null,E.materials[c]))}function x(c){var e,f,k,m,o,p;e=h(b,c);f=h(b,c+Q);k=h(b,c+L);m=u(b,c+H);o=h(b,c+M);p=h(b,c+X);c=h(b,c+C);m=E.materials[m];var t=G[p*3],v=G[p*3+1];p=G[p*3+2];var w=G[c*3],J=G[c*3+1],c=G[c*3+2];E.faces.push(new THREE.Face3(e,f,k,[new THREE.Vector3(G[o*3],G[o*3+1],G[o*3+2]),new THREE.Vector3(t,v,p),new THREE.Vector3(w,J,c)],null,m))}function w(c){var e,f,k,m;e=h(b,c);f=h(b,c+O);k=h(b,c+P);m=h(b,
-c+U);c=u(b,c+V);E.faces.push(new THREE.Face4(e,f,k,m,null,null,E.materials[c]))}function y(c){var e,f,k,m,p,t,v,w;e=h(b,c);f=h(b,c+O);k=h(b,c+P);m=h(b,c+U);p=u(b,c+V);t=h(b,c+o);v=h(b,c+ea);w=h(b,c+S);c=h(b,c+ta);p=E.materials[p];var x=G[v*3],J=G[v*3+1];v=G[v*3+2];var y=G[w*3],W=G[w*3+1];w=G[w*3+2];var z=G[c*3],A=G[c*3+1],c=G[c*3+2];E.faces.push(new THREE.Face4(e,f,k,m,[new THREE.Vector3(G[t*3],G[t*3+1],G[t*3+2]),new THREE.Vector3(x,J,v),new THREE.Vector3(y,W,w),new THREE.Vector3(z,A,c)],null,p))}
-function z(c){var e,f,k,m;e=h(b,c);f=h(b,c+$);k=h(b,c+la);c=N[e*2];m=N[e*2+1];e=N[f*2];var o=E.faceVertexUvs[0];f=N[f*2+1];var p=N[k*2];k=N[k*2+1];var t=[];t.push(new THREE.UV(c,m));t.push(new THREE.UV(e,f));t.push(new THREE.UV(p,k));o.push(t)}function A(c){var e,f,k,m,o,p;e=h(b,c);f=h(b,c+ja);k=h(b,c+ma);m=h(b,c+da);c=N[e*2];o=N[e*2+1];e=N[f*2];p=N[f*2+1];f=N[k*2];var t=E.faceVertexUvs[0];k=N[k*2+1];var u=N[m*2];m=N[m*2+1];var v=[];v.push(new THREE.UV(c,o));v.push(new THREE.UV(e,p));v.push(new THREE.UV(f,
-k));v.push(new THREE.UV(u,m));t.push(v)}var E=this,D=0,F,G=[],N=[],Q,L,H,M,X,C,O,P,U,V,o,ea,S,ta,$,la,ja,ma,da,Y,T,Z,fa,na,va;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(E,f,c);F={signature:b.substr(D,8),header_bytes:v(b,D+8),vertex_coordinate_bytes:v(b,D+9),normal_coordinate_bytes:v(b,D+10),uv_coordinate_bytes:v(b,D+11),vertex_index_bytes:v(b,D+12),normal_index_bytes:v(b,D+13),uv_index_bytes:v(b,D+14),material_index_bytes:v(b,D+15),nvertices:h(b,D+16),nnormals:h(b,D+16+4),nuvs:h(b,
-D+16+8),ntri_flat:h(b,D+16+12),ntri_smooth:h(b,D+16+16),ntri_flat_uv:h(b,D+16+20),ntri_smooth_uv:h(b,D+16+24),nquad_flat:h(b,D+16+28),nquad_smooth:h(b,D+16+32),nquad_flat_uv:h(b,D+16+36),nquad_smooth_uv:h(b,D+16+40)};D+=F.header_bytes;Q=F.vertex_index_bytes;L=F.vertex_index_bytes*2;H=F.vertex_index_bytes*3;M=F.vertex_index_bytes*3+F.material_index_bytes;X=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes;C=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*2;O=F.vertex_index_bytes;
-P=F.vertex_index_bytes*2;U=F.vertex_index_bytes*3;V=F.vertex_index_bytes*4;o=F.vertex_index_bytes*4+F.material_index_bytes;ea=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes;S=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*2;ta=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*3;$=F.uv_index_bytes;la=F.uv_index_bytes*2;ja=F.uv_index_bytes;ma=F.uv_index_bytes*2;da=F.uv_index_bytes*3;c=F.vertex_index_bytes*3+F.material_index_bytes;va=F.vertex_index_bytes*
-4+F.material_index_bytes;Y=F.ntri_flat*c;T=F.ntri_smooth*(c+F.normal_index_bytes*3);Z=F.ntri_flat_uv*(c+F.uv_index_bytes*3);fa=F.ntri_smooth_uv*(c+F.normal_index_bytes*3+F.uv_index_bytes*3);na=F.nquad_flat*va;c=F.nquad_smooth*(va+F.normal_index_bytes*4);va=F.nquad_flat_uv*(va+F.uv_index_bytes*4);D+=function(c){for(var f,h,m,n=F.vertex_coordinate_bytes*3,o=c+F.nvertices*n;c<o;c+=n)f=e(b,c),h=e(b,c+F.vertex_coordinate_bytes),m=e(b,c+F.vertex_coordinate_bytes*2),E.vertices.push(new THREE.Vertex(new THREE.Vector3(f,
-h,m)));return F.nvertices*n}(D);D+=function(c){for(var e,f,h,k=F.normal_coordinate_bytes*3,m=c+F.nnormals*k;c<m;c+=k)e=p(b,c),f=p(b,c+F.normal_coordinate_bytes),h=p(b,c+F.normal_coordinate_bytes*2),G.push(e/127,f/127,h/127);return F.nnormals*k}(D);D+=function(c){for(var f,h,m=F.uv_coordinate_bytes*2,n=c+F.nuvs*m;c<n;c+=m)f=e(b,c),h=e(b,c+F.uv_coordinate_bytes),N.push(f,h);return F.nuvs*m}(D);Y=D+Y;T=Y+T;Z=T+Z;fa=Z+fa;na=fa+na;c=na+c;va=c+va;(function(b){var c,e=F.vertex_index_bytes*3+F.material_index_bytes,
-f=e+F.uv_index_bytes*3,h=b+F.ntri_flat_uv*f;for(c=b;c<h;c+=f)t(c),z(c+e);return h-b})(T);(function(b){var c,e=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*3,f=e+F.uv_index_bytes*3,h=b+F.ntri_smooth_uv*f;for(c=b;c<h;c+=f)x(c),z(c+e);return h-b})(Z);(function(b){var c,e=F.vertex_index_bytes*4+F.material_index_bytes,f=e+F.uv_index_bytes*4,h=b+F.nquad_flat_uv*f;for(c=b;c<h;c+=f)w(c),A(c+e);return h-b})(c);(function(b){var c,e=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*
-4,f=e+F.uv_index_bytes*4,h=b+F.nquad_smooth_uv*f;for(c=b;c<h;c+=f)y(c),A(c+e);return h-b})(va);(function(b){var c,e=F.vertex_index_bytes*3+F.material_index_bytes,f=b+F.ntri_flat*e;for(c=b;c<f;c+=e)t(c);return f-b})(D);(function(b){var c,e=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*3,f=b+F.ntri_smooth*e;for(c=b;c<f;c+=e)x(c);return f-b})(Y);(function(b){var c,e=F.vertex_index_bytes*4+F.material_index_bytes,f=b+F.nquad_flat*e;for(c=b;c<f;c+=e)w(c);return f-b})(fa);(function(b){var c,
-e=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*4,f=b+F.nquad_smooth*e;for(c=b;c<f;c+=e)y(c);return f-b})(na);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};h.prototype=new THREE.Geometry;h.prototype.constructor=h;c(new h(e))};
-THREE.ColladaLoader=function(){function b(b,c,e){for(var b=Y.evaluate(b,Y,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),f={},h=b.iterateNext(),k=0;h;){h=(new c).parse(h);if(h.id.length==0)h.id=e+k++;f[h.id]=h;h=b.iterateNext()}return f}function c(){var b=1E6,c=-b,e=0,f;for(f in K)for(var h=K[f],k=0;k<h.sampler.length;k++){var m=h.sampler[k];m.create();b=Math.min(b,m.startTime);c=Math.max(c,m.endTime);e=Math.max(e,m.input.length)}return{start:b,end:c,frames:e}}function e(b,c,f,h){b.world=b.world||
-new THREE.Matrix4;b.world.copy(b.matrix);if(b.channels&&b.channels.length){var k=b.channels[0].sampler.output[f];k instanceof THREE.Matrix4&&b.world.copy(k)}h&&b.world.multiply(h,b.world);c.push(b);for(h=0;h<b.nodes.length;h++)e(b.nodes[h],c,f,b.world)}function f(b,f,h){var k=ca[f.url];if(!k||!k.skin)console.log("could not find skin controller!");else if(!f.skeleton||!f.skeleton.length)console.log("could not find the skeleton for the skin!");else{var m=c(),f=Z.getChildById(f.skeleton[0],!0)||Z.getChildBySid(f.skeleton[0],
+f,k;e=h(b,c);f=h(b,c+Q);k=h(b,c+H);c=u(b,c+K);D.faces.push(new THREE.Face3(e,f,k,null,null,D.materials[c]))}function x(c){var e,f,k,m,o,p;e=h(b,c);f=h(b,c+Q);k=h(b,c+H);m=u(b,c+K);o=h(b,c+I);p=h(b,c+X);c=h(b,c+C);m=D.materials[m];var t=G[p*3],v=G[p*3+1];p=G[p*3+2];var w=G[c*3],L=G[c*3+1],c=G[c*3+2];D.faces.push(new THREE.Face3(e,f,k,[new THREE.Vector3(G[o*3],G[o*3+1],G[o*3+2]),new THREE.Vector3(t,v,p),new THREE.Vector3(w,L,c)],null,m))}function w(c){var e,f,k,m;e=h(b,c);f=h(b,c+O);k=h(b,c+P);m=h(b,
+c+U);c=u(b,c+W);D.faces.push(new THREE.Face4(e,f,k,m,null,null,D.materials[c]))}function y(c){var e,f,k,m,p,t,v,w;e=h(b,c);f=h(b,c+O);k=h(b,c+P);m=h(b,c+U);p=u(b,c+W);t=h(b,c+o);v=h(b,c+da);w=h(b,c+S);c=h(b,c+la);p=D.materials[p];var x=G[v*3],L=G[v*3+1];v=G[v*3+2];var y=G[w*3],V=G[w*3+1];w=G[w*3+2];var z=G[c*3],B=G[c*3+1],c=G[c*3+2];D.faces.push(new THREE.Face4(e,f,k,m,[new THREE.Vector3(G[t*3],G[t*3+1],G[t*3+2]),new THREE.Vector3(x,L,v),new THREE.Vector3(y,V,w),new THREE.Vector3(z,B,c)],null,p))}
+function z(c){var e,f,k,m;e=h(b,c);f=h(b,c+aa);k=h(b,c+ia);c=N[e*2];m=N[e*2+1];e=N[f*2];var o=D.faceVertexUvs[0];f=N[f*2+1];var p=N[k*2];k=N[k*2+1];var t=[];t.push(new THREE.UV(c,m));t.push(new THREE.UV(e,f));t.push(new THREE.UV(p,k));o.push(t)}function B(c){var e,f,k,m,o,p;e=h(b,c);f=h(b,c+ka);k=h(b,c+ma);m=h(b,c+ca);c=N[e*2];o=N[e*2+1];e=N[f*2];p=N[f*2+1];f=N[k*2];var t=D.faceVertexUvs[0];k=N[k*2+1];var u=N[m*2];m=N[m*2+1];var v=[];v.push(new THREE.UV(c,o));v.push(new THREE.UV(e,p));v.push(new THREE.UV(f,
+k));v.push(new THREE.UV(u,m));t.push(v)}var D=this,E=0,F,G=[],N=[],Q,H,K,I,X,C,O,P,U,W,o,da,S,la,aa,ia,ka,ma,ca,ha,T,Z,ea,oa,xa;THREE.Geometry.call(this);THREE.Loader.prototype.init_materials(D,f,c);F={signature:b.substr(E,8),header_bytes:v(b,E+8),vertex_coordinate_bytes:v(b,E+9),normal_coordinate_bytes:v(b,E+10),uv_coordinate_bytes:v(b,E+11),vertex_index_bytes:v(b,E+12),normal_index_bytes:v(b,E+13),uv_index_bytes:v(b,E+14),material_index_bytes:v(b,E+15),nvertices:h(b,E+16),nnormals:h(b,E+16+4),nuvs:h(b,
+E+16+8),ntri_flat:h(b,E+16+12),ntri_smooth:h(b,E+16+16),ntri_flat_uv:h(b,E+16+20),ntri_smooth_uv:h(b,E+16+24),nquad_flat:h(b,E+16+28),nquad_smooth:h(b,E+16+32),nquad_flat_uv:h(b,E+16+36),nquad_smooth_uv:h(b,E+16+40)};E+=F.header_bytes;Q=F.vertex_index_bytes;H=F.vertex_index_bytes*2;K=F.vertex_index_bytes*3;I=F.vertex_index_bytes*3+F.material_index_bytes;X=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes;C=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*2;O=F.vertex_index_bytes;
+P=F.vertex_index_bytes*2;U=F.vertex_index_bytes*3;W=F.vertex_index_bytes*4;o=F.vertex_index_bytes*4+F.material_index_bytes;da=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes;S=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*2;la=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*3;aa=F.uv_index_bytes;ia=F.uv_index_bytes*2;ka=F.uv_index_bytes;ma=F.uv_index_bytes*2;ca=F.uv_index_bytes*3;c=F.vertex_index_bytes*3+F.material_index_bytes;xa=F.vertex_index_bytes*
+4+F.material_index_bytes;ha=F.ntri_flat*c;T=F.ntri_smooth*(c+F.normal_index_bytes*3);Z=F.ntri_flat_uv*(c+F.uv_index_bytes*3);ea=F.ntri_smooth_uv*(c+F.normal_index_bytes*3+F.uv_index_bytes*3);oa=F.nquad_flat*xa;c=F.nquad_smooth*(xa+F.normal_index_bytes*4);xa=F.nquad_flat_uv*(xa+F.uv_index_bytes*4);E+=function(c){for(var f,h,m,n=F.vertex_coordinate_bytes*3,o=c+F.nvertices*n;c<o;c+=n)f=e(b,c),h=e(b,c+F.vertex_coordinate_bytes),m=e(b,c+F.vertex_coordinate_bytes*2),D.vertices.push(new THREE.Vertex(new THREE.Vector3(f,
+h,m)));return F.nvertices*n}(E);E+=function(c){for(var e,f,h,k=F.normal_coordinate_bytes*3,m=c+F.nnormals*k;c<m;c+=k)e=p(b,c),f=p(b,c+F.normal_coordinate_bytes),h=p(b,c+F.normal_coordinate_bytes*2),G.push(e/127,f/127,h/127);return F.nnormals*k}(E);E+=function(c){for(var f,h,m=F.uv_coordinate_bytes*2,n=c+F.nuvs*m;c<n;c+=m)f=e(b,c),h=e(b,c+F.uv_coordinate_bytes),N.push(f,h);return F.nuvs*m}(E);ha=E+ha;T=ha+T;Z=T+Z;ea=Z+ea;oa=ea+oa;c=oa+c;xa=c+xa;(function(b){var c,e=F.vertex_index_bytes*3+F.material_index_bytes,
+f=e+F.uv_index_bytes*3,h=b+F.ntri_flat_uv*f;for(c=b;c<h;c+=f)t(c),z(c+e);return h-b})(T);(function(b){var c,e=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*3,f=e+F.uv_index_bytes*3,h=b+F.ntri_smooth_uv*f;for(c=b;c<h;c+=f)x(c),z(c+e);return h-b})(Z);(function(b){var c,e=F.vertex_index_bytes*4+F.material_index_bytes,f=e+F.uv_index_bytes*4,h=b+F.nquad_flat_uv*f;for(c=b;c<h;c+=f)w(c),B(c+e);return h-b})(c);(function(b){var c,e=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*
+4,f=e+F.uv_index_bytes*4,h=b+F.nquad_smooth_uv*f;for(c=b;c<h;c+=f)y(c),B(c+e);return h-b})(xa);(function(b){var c,e=F.vertex_index_bytes*3+F.material_index_bytes,f=b+F.ntri_flat*e;for(c=b;c<f;c+=e)t(c);return f-b})(E);(function(b){var c,e=F.vertex_index_bytes*3+F.material_index_bytes+F.normal_index_bytes*3,f=b+F.ntri_smooth*e;for(c=b;c<f;c+=e)x(c);return f-b})(ha);(function(b){var c,e=F.vertex_index_bytes*4+F.material_index_bytes,f=b+F.nquad_flat*e;for(c=b;c<f;c+=e)w(c);return f-b})(ea);(function(b){var c,
+e=F.vertex_index_bytes*4+F.material_index_bytes+F.normal_index_bytes*4,f=b+F.nquad_smooth*e;for(c=b;c<f;c+=e)y(c);return f-b})(oa);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};h.prototype=new THREE.Geometry;h.prototype.constructor=h;c(new h(e))};
+THREE.ColladaLoader=function(){function b(b,c,e){for(var b=ha.evaluate(b,ha,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),f={},h=b.iterateNext(),k=0;h;){h=(new c).parse(h);if(h.id.length==0)h.id=e+k++;f[h.id]=h;h=b.iterateNext()}return f}function c(){var b=1E6,c=-b,e=0,f;for(f in M)for(var h=M[f],k=0;k<h.sampler.length;k++){var m=h.sampler[k];m.create();b=Math.min(b,m.startTime);c=Math.max(c,m.endTime);e=Math.max(e,m.input.length)}return{start:b,end:c,frames:e}}function e(b,c,f,h){b.world=b.world||
+new THREE.Matrix4;b.world.copy(b.matrix);if(b.channels&&b.channels.length){var k=b.channels[0].sampler.output[f];k instanceof THREE.Matrix4&&b.world.copy(k)}h&&b.world.multiply(h,b.world);c.push(b);for(h=0;h<b.nodes.length;h++)e(b.nodes[h],c,f,b.world)}function f(b,f,h){var k=fa[f.url];if(!k||!k.skin)console.log("could not find skin controller!");else if(!f.skeleton||!f.skeleton.length)console.log("could not find the skeleton for the skin!");else{var m=c(),f=Z.getChildById(f.skeleton[0],!0)||Z.getChildBySid(f.skeleton[0],
 !0),n,o,p,t,u=new THREE.Vector3,v;for(n=0;n<b.vertices.length;n++)k.skin.bindShapeMatrix.multiplyVector3(b.vertices[n].position);for(h=0;h<m.frames;h++){var w=[],x=[];for(n=0;n<b.vertices.length;n++)x.push(new THREE.Vertex(new THREE.Vector3));e(f,w,h);n=w;o=k.skin;for(t=0;t<n.length;t++){p=n[t];v=-1;for(var y=0;y<o.joints.length;y++)if(p.sid==o.joints[y]){v=y;break}if(v>=0){y=o.invBindMatrices[v];p.invBindMatrix=y;p.skinningMatrix=new THREE.Matrix4;p.skinningMatrix.multiply(p.world,y);p.weights=[];
-for(y=0;y<o.weights.length;y++)for(var z=0;z<o.weights[y].length;z++){var A=o.weights[y][z];A.joint==v&&p.weights.push(A)}}else throw"could not find joint!";}for(n=0;n<w.length;n++)for(o=0;o<w[n].weights.length;o++)p=w[n].weights[o],t=p.index,p=p.weight,v=b.vertices[t],t=x[t],u.x=v.position.x,u.y=v.position.y,u.z=v.position.z,w[n].skinningMatrix.multiplyVector3(u),t.position.x+=u.x*p,t.position.y+=u.y*p,t.position.z+=u.z*p;b.morphTargets.push({name:"target_"+h,vertices:x})}}}function h(b){var c=new THREE.Object3D,
-e,k,m;c.name=b.id||"";c.matrixAutoUpdate=!1;c.matrix=b.matrix;for(m=0;m<b.controllers.length;m++){var n=ca[b.controllers[m].url];switch(n.type){case "skin":if(qa[n.skin.source]){var o=new y;o.url=n.skin.source;o.instance_material=b.controllers[m].instance_material;b.geometries.push(o);e=b.controllers[m]}else if(ca[n.skin.source]&&(k=n=ca[n.skin.source],n.morph&&qa[n.morph.source]))o=new y,o.url=n.morph.source,o.instance_material=b.controllers[m].instance_material,b.geometries.push(o);break;case "morph":if(qa[n.morph.source])o=
-new y,o.url=n.morph.source,o.instance_material=b.controllers[m].instance_material,b.geometries.push(o),k=b.controllers[m];console.log("DAE: morph-controller partially supported.")}}for(m=0;m<b.geometries.length;m++){var n=b.geometries[m],o=n.instance_material,n=qa[n.url],p={},t=0,u;if(n&&n.mesh&&n.mesh.primitives){if(c.name.length==0)c.name=n.id;if(o)for(j=0;j<o.length;j++){u=o[j];var v=sa[ua[u.target].instance_effect.url].shader;v.material.opacity=!v.material.opacity?1:v.material.opacity;u=p[u.symbol]=
-v.material;t++}o=u||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});n=n.mesh.geometry3js;if(t>1){o=new THREE.MeshFaceMaterial;for(j=0;j<n.faces.length;j++)t=n.faces[j],t.materials=[p[t.daeMaterial]]}if(e!==void 0)f(n,e),o.morphTargets=!0,o=new THREE.SkinnedMesh(n,o),o.skeleton=e.skeleton,o.skinController=ca[e.url],o.skinInstanceController=e,o.name="skin_"+pa.length,pa.push(o);else if(k!==void 0){p=n;t=k instanceof x?ca[k.url]:k;if(!t||!t.morph)console.log("could not find morph controller!");
-else{t=t.morph;for(v=0;v<t.targets.length;v++){var w=qa[t.targets[v]];if(w.mesh&&w.mesh.primitives&&w.mesh.primitives.length)w=w.mesh.primitives[0].geometry,w.vertices.length===p.vertices.length&&p.morphTargets.push({name:"target_1",vertices:w.vertices})}p.morphTargets.push({name:"target_Z",vertices:p.vertices})}o.morphTargets=!0;o=new THREE.Mesh(n,o);o.name="morph_"+Da.length;Da.push(o)}else o=new THREE.Mesh(n,o);c.add(o)}}for(m=0;m<b.nodes.length;m++)c.add(h(b.nodes[m],b));return c}function m(){this.init_from=
+for(y=0;y<o.weights.length;y++)for(var z=0;z<o.weights[y].length;z++){var B=o.weights[y][z];B.joint==v&&p.weights.push(B)}}else throw"could not find joint!";}for(n=0;n<w.length;n++)for(o=0;o<w[n].weights.length;o++)p=w[n].weights[o],t=p.index,p=p.weight,v=b.vertices[t],t=x[t],u.x=v.position.x,u.y=v.position.y,u.z=v.position.z,w[n].skinningMatrix.multiplyVector3(u),t.position.x+=u.x*p,t.position.y+=u.y*p,t.position.z+=u.z*p;b.morphTargets.push({name:"target_"+h,vertices:x})}}}function h(b){var c=new THREE.Object3D,
+e,k,m;c.name=b.id||"";c.matrixAutoUpdate=!1;c.matrix=b.matrix;for(m=0;m<b.controllers.length;m++){var n=fa[b.controllers[m].url];switch(n.type){case "skin":if(na[n.skin.source]){var o=new y;o.url=n.skin.source;o.instance_material=b.controllers[m].instance_material;b.geometries.push(o);e=b.controllers[m]}else if(fa[n.skin.source]&&(k=n=fa[n.skin.source],n.morph&&na[n.morph.source]))o=new y,o.url=n.morph.source,o.instance_material=b.controllers[m].instance_material,b.geometries.push(o);break;case "morph":if(na[n.morph.source])o=
+new y,o.url=n.morph.source,o.instance_material=b.controllers[m].instance_material,b.geometries.push(o),k=b.controllers[m];console.log("DAE: morph-controller partially supported.")}}for(m=0;m<b.geometries.length;m++){var n=b.geometries[m],o=n.instance_material,n=na[n.url],p={},t=0,u;if(n&&n.mesh&&n.mesh.primitives){if(c.name.length==0)c.name=n.id;if(o)for(j=0;j<o.length;j++){u=o[j];var v=sa[ta[u.target].instance_effect.url].shader;v.material.opacity=!v.material.opacity?1:v.material.opacity;u=p[u.symbol]=
+v.material;t++}o=u||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});n=n.mesh.geometry3js;if(t>1){o=new THREE.MeshFaceMaterial;for(j=0;j<n.faces.length;j++)t=n.faces[j],t.materials=[p[t.daeMaterial]]}if(e!==void 0)f(n,e),o.morphTargets=!0,o=new THREE.SkinnedMesh(n,o),o.skeleton=e.skeleton,o.skinController=fa[e.url],o.skinInstanceController=e,o.name="skin_"+Ba.length,Ba.push(o);else if(k!==void 0){p=n;t=k instanceof x?fa[k.url]:k;if(!t||!t.morph)console.log("could not find morph controller!");
+else{t=t.morph;for(v=0;v<t.targets.length;v++){var w=na[t.targets[v]];if(w.mesh&&w.mesh.primitives&&w.mesh.primitives.length)w=w.mesh.primitives[0].geometry,w.vertices.length===p.vertices.length&&p.morphTargets.push({name:"target_1",vertices:w.vertices})}p.morphTargets.push({name:"target_Z",vertices:p.vertices})}o.morphTargets=!0;o=new THREE.Mesh(n,o);o.name="morph_"+Fa.length;Fa.push(o)}else o=new THREE.Mesh(n,o);c.add(o)}}for(m=0;m<b.nodes.length;m++)c.add(h(b.nodes[m],b));return c}function m(){this.init_from=
 this.id=""}function k(){this.type=this.name=this.id="";this.morph=this.skin=null}function n(){this.weights=this.targets=this.source=this.method=null}function u(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];this.joints=[];this.weights=[]}function p(){this.name=this.id="";this.nodes=[];this.scene=new THREE.Object3D}function v(){this.sid=this.name=this.id="";this.nodes=[];this.controllers=[];this.transforms=[];this.geometries=[];this.channels=[];this.matrix=new THREE.Matrix4}function t(){this.type=
-this.sid="";this.data=[];this.matrix=new THREE.Matrix4}function x(){this.url="";this.skeleton=[];this.instance_material=[]}function w(){this.target=this.symbol=""}function y(){this.url="";this.instance_material=[]}function z(){this.id="";this.mesh=null}function A(b){this.geometry=b.id;this.primitives=[];this.geometry3js=this.vertices=null}function E(){}function D(){this.material="";this.count=0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function F(){this.source="";
-this.stride=this.count=0;this.params=[]}function G(){this.input={}}function N(){this.semantic="";this.offset=0;this.source="";this.set=0}function Q(b){this.id=b;this.type=null}function L(){this.name=this.id="";this.instance_effect=null}function H(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texcoord=this.texture=null}function M(b,c){this.type=b;this.effect=c;this.material=null}function X(b){this.effect=b;this.format=this.init_from=
-null}function C(b){this.effect=b;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function O(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function P(){this.url=""}function U(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function V(b){this.animation=b;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=this.dotSyntax=this.sid=null}function o(b){this.id="";this.animation=b;this.inputs=[];this.endTime=
-this.startTime=this.interpolation=this.output=this.input=null;this.duration=0}function ea(b){var c=b.getAttribute("id");if(na[c]!=void 0)return na[c];na[c]=(new Q(c)).parse(b);return na[c]}function S(b){if(b=="dae")return"http://www.collada.org/2005/11/COLLADASchema";return null}function ta(b){for(var b=la(b),c=[],e=0;e<b.length;e++)c.push(parseFloat(b[e]));return c}function $(b){for(var b=la(b),c=[],e=0;e<b.length;e++)c.push(parseInt(b[e],10));return c}function la(b){return b.replace(/^\s+/,"").replace(/\s+$/,
-"").split(/\s+/)}function ja(b,c,e){return b.hasAttribute(c)?parseInt(b.getAttribute(c),10):e}function ma(b,c){if(b===void 0){for(var e="0.";e.length<c+2;)e+="0";return e}c=c||2;e=b.toString().split(".");for(e[1]=e.length>1?e[1].substr(0,c):"0";e[1].length<c;)e[1]+="0";return e.join(".")}function da(b,c){var e="";e+=ma(b.x,c)+",";e+=ma(b.y,c)+",";e+=ma(b.z,c);return e}var Y=null,T=null,Z,fa=null,na={},va={},K={},ca={},qa={},ua={},sa={},xa,Ea,Da,pa,Ga=THREE.SmoothShading;m.prototype.parse=function(b){this.id=
+this.sid="";this.data=[];this.matrix=new THREE.Matrix4}function x(){this.url="";this.skeleton=[];this.instance_material=[]}function w(){this.target=this.symbol=""}function y(){this.url="";this.instance_material=[]}function z(){this.id="";this.mesh=null}function B(b){this.geometry=b.id;this.primitives=[];this.geometry3js=this.vertices=null}function D(){}function E(){this.material="";this.count=0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function F(){this.source="";
+this.stride=this.count=0;this.params=[]}function G(){this.input={}}function N(){this.semantic="";this.offset=0;this.source="";this.set=0}function Q(b){this.id=b;this.type=null}function H(){this.name=this.id="";this.instance_effect=null}function K(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texcoord=this.texture=null}function I(b,c){this.type=b;this.effect=c;this.material=null}function X(b){this.effect=b;this.format=this.init_from=
+null}function C(b){this.effect=b;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function O(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function P(){this.url=""}function U(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function W(b){this.animation=b;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=this.dotSyntax=this.sid=null}function o(b){this.id="";this.animation=b;this.inputs=[];this.endTime=
+this.startTime=this.interpolation=this.output=this.input=null;this.duration=0}function da(b){var c=b.getAttribute("id");if(oa[c]!=void 0)return oa[c];oa[c]=(new Q(c)).parse(b);return oa[c]}function S(b){if(b=="dae")return"http://www.collada.org/2005/11/COLLADASchema";return null}function la(b){for(var b=ia(b),c=[],e=0;e<b.length;e++)c.push(parseFloat(b[e]));return c}function aa(b){for(var b=ia(b),c=[],e=0;e<b.length;e++)c.push(parseInt(b[e],10));return c}function ia(b){return b.replace(/^\s+/,"").replace(/\s+$/,
+"").split(/\s+/)}function ka(b,c,e){return b.hasAttribute(c)?parseInt(b.getAttribute(c),10):e}function ma(b,c){if(b===void 0){for(var e="0.";e.length<c+2;)e+="0";return e}c=c||2;e=b.toString().split(".");for(e[1]=e.length>1?e[1].substr(0,c):"0";e[1].length<c;)e[1]+="0";return e.join(".")}function ca(b,c){var e="";e+=ma(b.x,c)+",";e+=ma(b.y,c)+",";e+=ma(b.z,c);return e}var ha=null,T=null,Z,ea=null,oa={},xa={},M={},fa={},na={},ta={},sa={},Da,Ca,Fa,Ba,pa=THREE.SmoothShading;m.prototype.parse=function(b){this.id=
 b.getAttribute("id");for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeName=="init_from")this.init_from=e.textContent}return this};k.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");this.type="none";for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];switch(e.nodeName){case "skin":this.skin=(new u).parse(e);this.type=e.nodeName;break;case "morph":this.morph=(new n).parse(e),this.type=e.nodeName}}return this};n.prototype.parse=function(b){var c=
 {},e=[],f;this.method=b.getAttribute("method");this.source=b.getAttribute("source").replace(/^#/,"");for(f=0;f<b.childNodes.length;f++){var h=b.childNodes[f];if(h.nodeType==1)switch(h.nodeName){case "source":h=(new Q).parse(h);c[h.id]=h;break;case "targets":e=this.parseInputs(h);break;default:console.log(h.nodeName)}}for(f=0;f<e.length;f++)switch(b=e[f],h=c[b.source],b.semantic){case "MORPH_TARGET":this.targets=h.read();break;case "MORPH_WEIGHT":this.weights=h.read()}return this};n.prototype.parseInputs=
-function(b){for(var c=[],e=0;e<b.childNodes.length;e++){var f=b.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "input":c.push((new N).parse(f))}}return c};u.prototype.parse=function(b){var c={},e,f;this.source=b.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var h=0;h<b.childNodes.length;h++){var k=b.childNodes[h];if(k.nodeType==1)switch(k.nodeName){case "bind_shape_matrix":k=ta(k.textContent);this.bindShapeMatrix=new THREE.Matrix4;this.bindShapeMatrix.set(k[0],
+function(b){for(var c=[],e=0;e<b.childNodes.length;e++){var f=b.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "input":c.push((new N).parse(f))}}return c};u.prototype.parse=function(b){var c={},e,f;this.source=b.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var h=0;h<b.childNodes.length;h++){var k=b.childNodes[h];if(k.nodeType==1)switch(k.nodeName){case "bind_shape_matrix":k=la(k.textContent);this.bindShapeMatrix=new THREE.Matrix4;this.bindShapeMatrix.set(k[0],
 k[1],k[2],k[3],k[4],k[5],k[6],k[7],k[8],k[9],k[10],k[11],k[12],k[13],k[14],k[15]);break;case "source":k=(new Q).parse(k);c[k.id]=k;break;case "joints":e=k;break;case "vertex_weights":f=k;break;default:console.log(k.nodeName)}}this.parseJoints(e,c);this.parseWeights(f,c);return this};u.prototype.parseJoints=function(b,c){for(var e=0;e<b.childNodes.length;e++){var f=b.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "input":var f=(new N).parse(f),h=c[f.source];if(f.semantic=="JOINT")this.joints=
-h.read();else if(f.semantic=="INV_BIND_MATRIX")this.invBindMatrices=h.read()}}};u.prototype.parseWeights=function(b,c){for(var e,f,h=[],k=0;k<b.childNodes.length;k++){var m=b.childNodes[k];if(m.nodeType==1)switch(m.nodeName){case "input":h.push((new N).parse(m));break;case "v":e=$(m.textContent);break;case "vcount":f=$(m.textContent)}}for(k=m=0;k<f.length;k++){for(var n=f[k],o=[],p=0;p<n;p++){for(var t={},u=0;u<h.length;u++){var v=h[u],w=e[m+v.offset];switch(v.semantic){case "JOINT":t.joint=w;break;
+h.read();else if(f.semantic=="INV_BIND_MATRIX")this.invBindMatrices=h.read()}}};u.prototype.parseWeights=function(b,c){for(var e,f,h=[],k=0;k<b.childNodes.length;k++){var m=b.childNodes[k];if(m.nodeType==1)switch(m.nodeName){case "input":h.push((new N).parse(m));break;case "v":e=aa(m.textContent);break;case "vcount":f=aa(m.textContent)}}for(k=m=0;k<f.length;k++){for(var n=f[k],o=[],p=0;p<n;p++){for(var t={},u=0;u<h.length;u++){var v=h[u],w=e[m+v.offset];switch(v.semantic){case "JOINT":t.joint=w;break;
 case "WEIGHT":t.weight=c[v.source].data[w]}}o.push(t);m+=h.length}for(p=0;p<o.length;p++)o[p].index=k;this.weights.push(o)}};p.prototype.getChildById=function(b,c){for(var e=0;e<this.nodes.length;e++){var f=this.nodes[e].getChildById(b,c);if(f)return f}return null};p.prototype.getChildBySid=function(b,c){for(var e=0;e<this.nodes.length;e++){var f=this.nodes[e].getChildBySid(b,c);if(f)return f}return null};p.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");
 this.nodes=[];for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "node":this.nodes.push((new v).parse(e))}}return this};v.prototype.getChannelForTransform=function(b){for(var c=0;c<this.channels.length;c++){var e=this.channels[c],f=e.target.split("/");f.shift();var h=f.shift(),k=h.indexOf(".")>=0,m=h.indexOf("(")>=0,n;if(k)f=h.split("."),h=f.shift(),f.shift();else if(m){n=h.split("(");h=n.shift();for(f=0;f<n.length;f++)n[f]=parseInt(n[f].replace(/\)/,
 ""))}if(h==b)return e.info={sid:h,dotSyntax:k,arrSyntax:m,arrIndices:n},e}return null};v.prototype.getChildById=function(b,c){if(this.id==b)return this;if(c)for(var e=0;e<this.nodes.length;e++){var f=this.nodes[e].getChildById(b,c);if(f)return f}return null};v.prototype.getChildBySid=function(b,c){if(this.sid==b)return this;if(c)for(var e=0;e<this.nodes.length;e++){var f=this.nodes[e].getChildBySid(b,c);if(f)return f}return null};v.prototype.getTransformBySid=function(b){for(var c=0;c<this.transforms.length;c++)if(this.transforms[c].sid==
 b)return this.transforms[c];return null};v.prototype.parse=function(b){var c;this.id=b.getAttribute("id");this.sid=b.getAttribute("sid");this.name=b.getAttribute("name");this.type=b.getAttribute("type");this.type=this.type=="JOINT"?this.type:"NODE";this.nodes=[];this.transforms=[];this.geometries=[];this.controllers=[];this.matrix=new THREE.Matrix4;for(var e=0;e<b.childNodes.length;e++)if(c=b.childNodes[e],c.nodeType==1)switch(c.nodeName){case "node":this.nodes.push((new v).parse(c));break;case "instance_camera":break;
-case "instance_controller":this.controllers.push((new x).parse(c));break;case "instance_geometry":this.geometries.push((new y).parse(c));break;case "instance_light":break;case "instance_node":c=c.getAttribute("url").replace(/^#/,"");(c=Y.evaluate(".//dae:library_nodes//dae:node[@id='"+c+"']",Y,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new v).parse(c));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new t).parse(c));
-break;case "extra":break;default:console.log(c.nodeName)}b=[];e=1E6;c=-1E6;for(var f in K)for(var h=K[f],k=0;k<h.channel.length;k++){var m=h.channel[k],n=h.sampler[k];f=m.target.split("/")[0];if(f==this.id)n.create(),m.sampler=n,e=Math.min(e,n.startTime),c=Math.max(c,n.endTime),b.push(m)}if(b.length)this.startTime=e,this.endTime=c;if((this.channels=b)&&this.channels.length){f=1E7;for(i=0;i<this.channels.length;i++){b=this.channels[i].sampler;for(e=0;e<b.input.length-1;e++)f=Math.min(f,b.input[e+1]-
+case "instance_controller":this.controllers.push((new x).parse(c));break;case "instance_geometry":this.geometries.push((new y).parse(c));break;case "instance_light":break;case "instance_node":c=c.getAttribute("url").replace(/^#/,"");(c=ha.evaluate(".//dae:library_nodes//dae:node[@id='"+c+"']",ha,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new v).parse(c));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new t).parse(c));
+break;case "extra":break;default:console.log(c.nodeName)}b=[];e=1E6;c=-1E6;for(var f in M)for(var h=M[f],k=0;k<h.channel.length;k++){var m=h.channel[k],n=h.sampler[k];f=m.target.split("/")[0];if(f==this.id)n.create(),m.sampler=n,e=Math.min(e,n.startTime),c=Math.max(c,n.endTime),b.push(m)}if(b.length)this.startTime=e,this.endTime=c;if((this.channels=b)&&this.channels.length){f=1E7;for(i=0;i<this.channels.length;i++){b=this.channels[i].sampler;for(e=0;e<b.input.length-1;e++)f=Math.min(f,b.input[e+1]-
 b.input[e])}e=[];for(b=this.startTime;b<this.endTime;b+=f){c=b;for(var h={},o=k=void 0,k=0;k<this.channels.length;k++)o=this.channels[k],h[o.sid]=o;m=new THREE.Matrix4;for(k=0;k<this.transforms.length;k++)if(n=this.transforms[k],o=h[n.sid],o!==void 0){for(var p=o.sampler,u,o=0;o<p.input.length-1;o++)if(p.input[o+1]>c){u=p.output[o];break}m=u!==void 0?u instanceof THREE.Matrix4?m.multiply(m,u):m.multiply(m,n.matrix):m.multiply(m,n.matrix)}else m=m.multiply(m,n.matrix);c=m;e.push({time:b,pos:[c.n14,
-c.n24,c.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=e}this.updateMatrix();return this};v.prototype.updateMatrix=function(){this.matrix.identity();for(var b=0;b<this.transforms.length;b++)this.matrix.multiply(this.matrix,this.transforms[b].matrix)};t.prototype.parse=function(b){this.sid=b.getAttribute("sid");this.type=b.nodeName;this.data=ta(b.textContent);this.updateMatrix();return this};t.prototype.updateMatrix=function(){var b=0;this.matrix.identity();switch(this.type){case "matrix":this.matrix.set(this.data[0],
+c.n24,c.n34],rotq:[0,0,0,1],scl:[1,1,1]})}this.keys=e}this.updateMatrix();return this};v.prototype.updateMatrix=function(){this.matrix.identity();for(var b=0;b<this.transforms.length;b++)this.matrix.multiply(this.matrix,this.transforms[b].matrix)};t.prototype.parse=function(b){this.sid=b.getAttribute("sid");this.type=b.nodeName;this.data=la(b.textContent);this.updateMatrix();return this};t.prototype.updateMatrix=function(){var b=0;this.matrix.identity();switch(this.type){case "matrix":this.matrix.set(this.data[0],
 this.data[1],this.data[2],this.data[3],this.data[4],this.data[5],this.data[6],this.data[7],this.data[8],this.data[9],this.data[10],this.data[11],this.data[12],this.data[13],this.data[14],this.data[15]);break;case "translate":this.matrix.setTranslation(this.data[0],this.data[1],this.data[2]);break;case "rotate":b=this.data[3]*(Math.PI/180);this.matrix.setRotationAxis(new THREE.Vector3(this.data[0],this.data[1],this.data[2]),b);break;case "scale":this.matrix.setScale(this.data[0],this.data[1],this.data[2])}return this.matrix};
-x.prototype.parse=function(b){this.url=b.getAttribute("url").replace(/^#/,"");this.skeleton=[];this.instance_material=[];for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "skeleton":this.skeleton.push(e.textContent.replace(/^#/,""));break;case "bind_material":if(e=Y.evaluate(".//dae:instance_material",e,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(var f=e.iterateNext();f;)this.instance_material.push((new w).parse(f)),f=e.iterateNext()}}return this};
-w.prototype.parse=function(b){this.symbol=b.getAttribute("symbol");this.target=b.getAttribute("target").replace(/^#/,"");return this};y.prototype.parse=function(b){this.url=b.getAttribute("url").replace(/^#/,"");this.instance_material=[];for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1&&e.nodeName=="bind_material"){if(b=Y.evaluate(".//dae:instance_material",e,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(c=b.iterateNext();c;)this.instance_material.push((new w).parse(c)),
-c=b.iterateNext();break}}return this};z.prototype.parse=function(b){this.id=b.getAttribute("id");for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];switch(e.nodeName){case "mesh":this.mesh=(new A(this)).parse(e)}}return this};A.prototype.parse=function(b){function c(b,e){var f=da(b.position);h[f]===void 0&&(h[f]={v:b,index:e});return h[f]}this.primitives=[];var e;for(e=0;e<b.childNodes.length;e++){var f=b.childNodes[e];switch(f.nodeName){case "source":ea(f);break;case "vertices":this.vertices=
-(new G).parse(f);break;case "triangles":this.primitives.push((new D).parse(f));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new E).parse(f))}}var h={};this.geometry3js=new THREE.Geometry;f=na[this.vertices.input.POSITION.source].data;for(b=e=0;e<f.length;e+=3,b++){var k=new THREE.Vertex(new THREE.Vector3(f[e],f[e+1],f[e+2]));c(k,b);this.geometry3js.vertices.push(k)}for(e=0;e<this.primitives.length;e++)primitive=this.primitives[e],primitive.setVertices(this.vertices),
-this.handlePrimitive(primitive,this.geometry3js,h);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();return this};A.prototype.handlePrimitive=function(b,c,e){var f=0,h,k,m=b.p,n=b.inputs,o,p,t,u=0,v=3,w=[];for(h=0;h<n.length;h++)switch(o=n[h],o.semantic){case "TEXCOORD":w.push(o.set)}for(;f<m.length;){var x=[],y=[],z={},A=[];b.vcount&&(v=b.vcount[u++]);for(h=0;h<v;h++)for(k=0;k<n.length;k++)switch(o=
-n[k],source=na[o.source],p=m[f+h*n.length+o.offset],numParams=source.accessor.params.length,t=p*numParams,o.semantic){case "VERTEX":o=da(c.vertices[p].position);x.push(e[o].index);break;case "NORMAL":y.push(new THREE.Vector3(source.data[t],source.data[t+1],source.data[t+2]));break;case "TEXCOORD":z[o.set]===void 0&&(z[o.set]=[]);z[o.set].push(new THREE.UV(source.data[t],source.data[t+1]));break;case "COLOR":A.push((new THREE.Color).setRGB(source.data[t],source.data[t+1],source.data[t+2]))}var E;v==
-3?E=new THREE.Face3(x[0],x[1],x[2],[y[0],y[1],y[2]],A.length?A:new THREE.Color):v==4&&(E=new THREE.Face4(x[0],x[1],x[2],x[3],[y[0],y[1],y[2],y[3]],A.length?A:new THREE.Color));E.daeMaterial=b.material;c.faces.push(E);for(k=0;k<w.length;k++)h=z[w[k]],c.faceVertexUvs[k].push([h[0],h[1],h[2]]);f+=n.length*v}};E.prototype=new D;E.prototype.constructor=E;D.prototype.setVertices=function(b){for(var c=0;c<this.inputs.length;c++)if(this.inputs[c].source==b.id)this.inputs[c].source=b.input.POSITION.source};
-D.prototype.parse=function(b){this.inputs=[];this.material=b.getAttribute("material");this.count=ja(b,"count",0);for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];switch(e.nodeName){case "input":this.inputs.push((new N).parse(b.childNodes[c]));break;case "vcount":this.vcount=$(e.textContent);break;case "p":this.p=$(e.textContent)}}return this};F.prototype.parse=function(b){this.params=[];this.source=b.getAttribute("source");this.count=ja(b,"count",0);this.stride=ja(b,"stride",0);for(var c=
+x.prototype.parse=function(b){this.url=b.getAttribute("url").replace(/^#/,"");this.skeleton=[];this.instance_material=[];for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "skeleton":this.skeleton.push(e.textContent.replace(/^#/,""));break;case "bind_material":if(e=ha.evaluate(".//dae:instance_material",e,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(var f=e.iterateNext();f;)this.instance_material.push((new w).parse(f)),f=e.iterateNext()}}return this};
+w.prototype.parse=function(b){this.symbol=b.getAttribute("symbol");this.target=b.getAttribute("target").replace(/^#/,"");return this};y.prototype.parse=function(b){this.url=b.getAttribute("url").replace(/^#/,"");this.instance_material=[];for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1&&e.nodeName=="bind_material"){if(b=ha.evaluate(".//dae:instance_material",e,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(c=b.iterateNext();c;)this.instance_material.push((new w).parse(c)),
+c=b.iterateNext();break}}return this};z.prototype.parse=function(b){this.id=b.getAttribute("id");for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];switch(e.nodeName){case "mesh":this.mesh=(new B(this)).parse(e)}}return this};B.prototype.parse=function(b){function c(b,e){var f=ca(b.position);h[f]===void 0&&(h[f]={v:b,index:e});return h[f]}this.primitives=[];var e;for(e=0;e<b.childNodes.length;e++){var f=b.childNodes[e];switch(f.nodeName){case "source":da(f);break;case "vertices":this.vertices=
+(new G).parse(f);break;case "triangles":this.primitives.push((new E).parse(f));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new D).parse(f))}}var h={};this.geometry3js=new THREE.Geometry;f=oa[this.vertices.input.POSITION.source].data;for(b=e=0;e<f.length;e+=3,b++){var k=new THREE.Vertex(new THREE.Vector3(f[e],f[e+1],f[e+2]));c(k,b);this.geometry3js.vertices.push(k)}for(e=0;e<this.primitives.length;e++)primitive=this.primitives[e],primitive.setVertices(this.vertices),
+this.handlePrimitive(primitive,this.geometry3js,h);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();return this};B.prototype.handlePrimitive=function(b,c,e){var f=0,h,k,m=b.p,n=b.inputs,o,p,t,u=0,v=3,w=[];for(h=0;h<n.length;h++)switch(o=n[h],o.semantic){case "TEXCOORD":w.push(o.set)}for(;f<m.length;){var x=[],y=[],z={},B=[];b.vcount&&(v=b.vcount[u++]);for(h=0;h<v;h++)for(k=0;k<n.length;k++)switch(o=
+n[k],source=oa[o.source],p=m[f+h*n.length+o.offset],numParams=source.accessor.params.length,t=p*numParams,o.semantic){case "VERTEX":o=ca(c.vertices[p].position);x.push(e[o].index);break;case "NORMAL":y.push(new THREE.Vector3(source.data[t],source.data[t+1],source.data[t+2]));break;case "TEXCOORD":z[o.set]===void 0&&(z[o.set]=[]);z[o.set].push(new THREE.UV(source.data[t],source.data[t+1]));break;case "COLOR":B.push((new THREE.Color).setRGB(source.data[t],source.data[t+1],source.data[t+2]))}var D;v==
+3?D=new THREE.Face3(x[0],x[1],x[2],[y[0],y[1],y[2]],B.length?B:new THREE.Color):v==4&&(D=new THREE.Face4(x[0],x[1],x[2],x[3],[y[0],y[1],y[2],y[3]],B.length?B:new THREE.Color));D.daeMaterial=b.material;c.faces.push(D);for(k=0;k<w.length;k++)h=z[w[k]],c.faceVertexUvs[k].push([h[0],h[1],h[2]]);f+=n.length*v}};D.prototype=new E;D.prototype.constructor=D;E.prototype.setVertices=function(b){for(var c=0;c<this.inputs.length;c++)if(this.inputs[c].source==b.id)this.inputs[c].source=b.input.POSITION.source};
+E.prototype.parse=function(b){this.inputs=[];this.material=b.getAttribute("material");this.count=ka(b,"count",0);for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];switch(e.nodeName){case "input":this.inputs.push((new N).parse(b.childNodes[c]));break;case "vcount":this.vcount=aa(e.textContent);break;case "p":this.p=aa(e.textContent)}}return this};F.prototype.parse=function(b){this.params=[];this.source=b.getAttribute("source");this.count=ka(b,"count",0);this.stride=ka(b,"stride",0);for(var c=
 0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeName=="param"){var f={};f.name=e.getAttribute("name");f.type=e.getAttribute("type");this.params.push(f)}}return this};G.prototype.parse=function(b){this.id=b.getAttribute("id");for(var c=0;c<b.childNodes.length;c++)b.childNodes[c].nodeName=="input"&&(input=(new N).parse(b.childNodes[c]),this.input[input.semantic]=input);return this};N.prototype.parse=function(b){this.semantic=b.getAttribute("semantic");this.source=b.getAttribute("source").replace(/^#/,
-"");this.set=ja(b,"set",-1);this.offset=ja(b,"offset",0);if(this.semantic=="TEXCOORD"&&this.set<0)this.set=0;return this};Q.prototype.parse=function(b){this.id=b.getAttribute("id");for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];switch(e.nodeName){case "bool_array":for(var f=la(e.textContent),h=[],k=0;k<f.length;k++)h.push(f[k]=="true"||f[k]=="1"?!0:!1);this.data=h;this.type=e.nodeName;break;case "float_array":this.data=ta(e.textContent);this.type=e.nodeName;break;case "int_array":this.data=
-$(e.textContent);this.type=e.nodeName;break;case "IDREF_array":case "Name_array":this.data=la(e.textContent);this.type=e.nodeName;break;case "technique_common":for(f=0;f<e.childNodes.length;f++)if(e.childNodes[f].nodeName=="accessor"){this.accessor=(new F).parse(e.childNodes[f]);break}}}return this};Q.prototype.read=function(){var b=[],c=this.accessor.params[0];switch(c.type){case "IDREF":case "Name":case "name":case "float":return this.data;case "float4x4":for(c=0;c<this.data.length;c+=16){var e=
-this.data.slice(c,c+16),f=new THREE.Matrix4;f.set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]);b.push(f)}break;default:console.log("Dae::Source:read dont know how to read "+c.type)}return b};L.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");for(var c=0;c<b.childNodes.length;c++)if(b.childNodes[c].nodeName=="instance_effect"){this.instance_effect=(new P).parse(b.childNodes[c]);break}return this};H.prototype.isColor=
-function(){return this.texture==null};H.prototype.isTexture=function(){return this.texture!=null};H.prototype.parse=function(b){for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "color":e=ta(e.textContent);this.color=new THREE.Color(0);this.color.setRGB(e[0],e[1],e[2]);this.color.a=e[3];break;case "texture":this.texture=e.getAttribute("texture"),this.texcoord=e.getAttribute("texcoord")}}return this};M.prototype.parse=function(b){for(var c=0;c<b.childNodes.length;c++){var e=
-b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[e.nodeName]=(new H).parse(e);break;case "shininess":case "reflectivity":case "transparency":var f;f=Y.evaluate(".//dae:float",e,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var h=f.iterateNext(),k=[];h;)k.push(h),h=f.iterateNext();f=k;f.length>0&&(this[e.nodeName]=parseFloat(f[0].textContent))}}this.create();return this};M.prototype.create=function(){var b=
-{},c=this.transparency!==void 0&&this.transparency<1,e;for(e in this)switch(e){case "ambient":case "emission":case "diffuse":case "specular":var f=this[e];if(f instanceof H)if(f.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(f=va[this.effect.surface.init_from]))b.map=THREE.ImageUtils.loadTexture(Ea+f.init_from),b.map.wrapS=THREE.RepeatWrapping,b.map.wrapT=THREE.RepeatWrapping,b.map.repeat.x=1,b.map.repeat.y=-1}else e=="diffuse"?b.color=
-f.color.getHex():c||(b[e]=f.color.getHex());break;case "shininess":case "reflectivity":b[e]=this[e];break;case "transparency":if(c)b.transparent=!0,b.opacity=this[e],c=!0}b.shading=Ga;return this.material=new THREE.MeshLambertMaterial(b)};X.prototype.parse=function(b){for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "init_from":this.init_from=e.textContent;break;case "format":this.format=e.textContent;break;default:console.log("unhandled Surface prop: "+
+"");this.set=ka(b,"set",-1);this.offset=ka(b,"offset",0);if(this.semantic=="TEXCOORD"&&this.set<0)this.set=0;return this};Q.prototype.parse=function(b){this.id=b.getAttribute("id");for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];switch(e.nodeName){case "bool_array":for(var f=ia(e.textContent),h=[],k=0;k<f.length;k++)h.push(f[k]=="true"||f[k]=="1"?!0:!1);this.data=h;this.type=e.nodeName;break;case "float_array":this.data=la(e.textContent);this.type=e.nodeName;break;case "int_array":this.data=
+aa(e.textContent);this.type=e.nodeName;break;case "IDREF_array":case "Name_array":this.data=ia(e.textContent);this.type=e.nodeName;break;case "technique_common":for(f=0;f<e.childNodes.length;f++)if(e.childNodes[f].nodeName=="accessor"){this.accessor=(new F).parse(e.childNodes[f]);break}}}return this};Q.prototype.read=function(){var b=[],c=this.accessor.params[0];switch(c.type){case "IDREF":case "Name":case "name":case "float":return this.data;case "float4x4":for(c=0;c<this.data.length;c+=16){var e=
+this.data.slice(c,c+16),f=new THREE.Matrix4;f.set(e[0],e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],e[10],e[11],e[12],e[13],e[14],e[15]);b.push(f)}break;default:console.log("Dae::Source:read dont know how to read "+c.type)}return b};H.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");for(var c=0;c<b.childNodes.length;c++)if(b.childNodes[c].nodeName=="instance_effect"){this.instance_effect=(new P).parse(b.childNodes[c]);break}return this};K.prototype.isColor=
+function(){return this.texture==null};K.prototype.isTexture=function(){return this.texture!=null};K.prototype.parse=function(b){for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "color":e=la(e.textContent);this.color=new THREE.Color(0);this.color.setRGB(e[0],e[1],e[2]);this.color.a=e[3];break;case "texture":this.texture=e.getAttribute("texture"),this.texcoord=e.getAttribute("texcoord")}}return this};I.prototype.parse=function(b){for(var c=0;c<b.childNodes.length;c++){var e=
+b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[e.nodeName]=(new K).parse(e);break;case "shininess":case "reflectivity":case "transparency":var f;f=ha.evaluate(".//dae:float",e,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var h=f.iterateNext(),k=[];h;)k.push(h),h=f.iterateNext();f=k;f.length>0&&(this[e.nodeName]=parseFloat(f[0].textContent))}}this.create();return this};I.prototype.create=function(){var b=
+{},c=this.transparency!==void 0&&this.transparency<1,e;for(e in this)switch(e){case "ambient":case "emission":case "diffuse":case "specular":var f=this[e];if(f instanceof K)if(f.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid&&(f=xa[this.effect.surface.init_from]))b.map=THREE.ImageUtils.loadTexture(Ca+f.init_from),b.map.wrapS=THREE.RepeatWrapping,b.map.wrapT=THREE.RepeatWrapping,b.map.repeat.x=1,b.map.repeat.y=-1}else e=="diffuse"?b.color=
+f.color.getHex():c||(b[e]=f.color.getHex());break;case "shininess":case "reflectivity":b[e]=this[e];break;case "transparency":if(c)b.transparent=!0,b.opacity=this[e],c=!0}b.shading=pa;return this.material=new THREE.MeshLambertMaterial(b)};X.prototype.parse=function(b){for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "init_from":this.init_from=e.textContent;break;case "format":this.format=e.textContent;break;default:console.log("unhandled Surface prop: "+
 e.nodeName)}}return this};C.prototype.parse=function(b){for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "source":this.source=e.textContent;break;case "minfilter":this.minfilter=e.textContent;break;case "magfilter":this.magfilter=e.textContent;break;case "mipfilter":this.mipfilter=e.textContent;break;case "wrap_s":this.wrap_s=e.textContent;break;case "wrap_t":this.wrap_t=e.textContent;break;default:console.log("unhandled Sampler2D prop: "+e.nodeName)}}return this};
 O.prototype.create=function(){if(this.shader==null)return null};O.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");this.shader=null;for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(e))}}return this};O.prototype.parseNewparam=function(b){for(var c=b.getAttribute("sid"),e=0;e<b.childNodes.length;e++){var f=b.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "surface":this.surface=
 (new X(this)).parse(f);this.surface.sid=c;break;case "sampler2D":this.sampler=(new C(this)).parse(f);this.sampler.sid=c;break;case "extra":break;default:console.log(f.nodeName)}}};O.prototype.parseProfileCOMMON=function(b){for(var c,e=0;e<b.childNodes.length;e++){var f=b.childNodes[e];if(f.nodeType==1)switch(f.nodeName){case "profile_COMMON":this.parseProfileCOMMON(f);break;case "technique":c=f;break;case "newparam":this.parseNewparam(f);break;case "extra":break;default:console.log(f.nodeName)}}return c};
-O.prototype.parseTechnique=function(b){for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "lambert":case "blinn":case "phong":this.shader=(new M(e.nodeName,this)).parse(e)}}};P.prototype.parse=function(b){this.url=b.getAttribute("url").replace(/^#/,"");return this};U.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");this.source={};for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "source":e=
-(new Q).parse(e);this.source[e.id]=e;break;case "sampler":this.sampler.push((new o(this)).parse(e));break;case "channel":this.channel.push((new V(this)).parse(e))}}return this};V.prototype.parse=function(b){this.source=b.getAttribute("source").replace(/^#/,"");this.target=b.getAttribute("target");var c=this.target.split("/");c.shift();var b=c.shift(),e=b.indexOf(".")>=0,f=b.indexOf("(")>=0,h,k;if(e)c=b.split("."),b=c.shift(),k=c.shift();else if(f){h=b.split("(");b=h.shift();for(c=0;c<h.length;c++)h[c]=
+O.prototype.parseTechnique=function(b){for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "lambert":case "blinn":case "phong":this.shader=(new I(e.nodeName,this)).parse(e)}}};P.prototype.parse=function(b){this.url=b.getAttribute("url").replace(/^#/,"");return this};U.prototype.parse=function(b){this.id=b.getAttribute("id");this.name=b.getAttribute("name");this.source={};for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "source":e=
+(new Q).parse(e);this.source[e.id]=e;break;case "sampler":this.sampler.push((new o(this)).parse(e));break;case "channel":this.channel.push((new W(this)).parse(e))}}return this};W.prototype.parse=function(b){this.source=b.getAttribute("source").replace(/^#/,"");this.target=b.getAttribute("target");var c=this.target.split("/");c.shift();var b=c.shift(),e=b.indexOf(".")>=0,f=b.indexOf("(")>=0,h,k;if(e)c=b.split("."),b=c.shift(),k=c.shift();else if(f){h=b.split("(");b=h.shift();for(c=0;c<h.length;c++)h[c]=
 parseInt(h[c].replace(/\)/,""))}this.sid=b;this.dotSyntax=e;this.arrSyntax=f;this.arrIndices=h;this.member=k;return this};o.prototype.parse=function(b){this.id=b.getAttribute("id");this.inputs=[];for(var c=0;c<b.childNodes.length;c++){var e=b.childNodes[c];if(e.nodeType==1)switch(e.nodeName){case "input":this.inputs.push((new N).parse(e))}}return this};o.prototype.create=function(){for(var b=0;b<this.inputs.length;b++){var c=this.inputs[b],e=this.animation.source[c.source];switch(c.semantic){case "INPUT":this.input=
 e.read();break;case "OUTPUT":this.output=e.read();break;case "INTERPOLATION":this.interpolation=e.read();break;case "IN_TANGENT":break;case "OUT_TANGENT":break;default:console.log(c.semantic)}}this.duration=this.endTime=this.startTime=0;if(this.input.length){this.startTime=1E8;this.endTime=-1E8;for(b=0;b<this.input.length;b++)this.startTime=Math.min(this.startTime,this.input[b]),this.endTime=Math.max(this.endTime,this.input[b]);this.duration=this.endTime-this.startTime}};return{load:function(e,f){if(document.implementation&&
-document.implementation.createDocument){document.implementation.createDocument("http://www.collada.org/2005/11/COLLADASchema","COLLADA",null);e+="?rnd="+Math.random();var n=new XMLHttpRequest;n.overrideMimeType&&n.overrideMimeType("text/xml");n.onreadystatechange=function(){if(n.readyState==4&&(n.status==0||n.status==200)){fa=f;var o,t=e;Y=n.responseXML;o=fa;t!==void 0&&(t=t.split("/"),t.pop(),Ea=t.join("/")+"/");va=b("//dae:library_images/dae:image",m,"image");ua=b("//dae:library_materials/dae:material",
-L,"material");sa=b("//dae:library_effects/dae:effect",O,"effect");qa=b("//dae:library_geometries/dae:geometry",z,"geometry");ca=b("//dae:library_controllers/dae:controller",k,"controller");K=b("//dae:library_animations/dae:animation",U,"animation");xa=b(".//dae:library_visual_scenes/dae:visual_scene",p,"visual_scene");Da=[];pa=[];(t=Y.evaluate(".//dae:scene/dae:instance_visual_scene",Y,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(t=t.getAttribute("url").replace(/^#/,""),Z=xa[t]):
-Z=null;T=new THREE.Object3D;for(t=0;t<Z.nodes.length;t++)T.add(h(Z.nodes[t]));c();for(var u in K);u={scene:T,morphs:Da,skins:pa,dae:{images:va,materials:ua,effects:sa,geometries:qa,controllers:ca,animations:K,visualScenes:xa,scene:Z}};o&&o(u)}};n.open("GET",e,!0);n.send(null)}else alert("Don't know how to parse XML!")},setPreferredShading:function(b){Ga=b},applySkin:f,geometries:qa}};THREE.JSONLoader=function(b){THREE.Loader.call(this,b)};THREE.JSONLoader.prototype=new THREE.Loader;
+document.implementation.createDocument){document.implementation.createDocument("http://www.collada.org/2005/11/COLLADASchema","COLLADA",null);e+="?rnd="+Math.random();var n=new XMLHttpRequest;n.overrideMimeType&&n.overrideMimeType("text/xml");n.onreadystatechange=function(){if(n.readyState==4&&(n.status==0||n.status==200)){ea=f;var o,t=e;ha=n.responseXML;o=ea;t!==void 0&&(t=t.split("/"),t.pop(),Ca=t.join("/")+"/");xa=b("//dae:library_images/dae:image",m,"image");ta=b("//dae:library_materials/dae:material",
+H,"material");sa=b("//dae:library_effects/dae:effect",O,"effect");na=b("//dae:library_geometries/dae:geometry",z,"geometry");fa=b("//dae:library_controllers/dae:controller",k,"controller");M=b("//dae:library_animations/dae:animation",U,"animation");Da=b(".//dae:library_visual_scenes/dae:visual_scene",p,"visual_scene");Fa=[];Ba=[];(t=ha.evaluate(".//dae:scene/dae:instance_visual_scene",ha,S,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(t=t.getAttribute("url").replace(/^#/,""),Z=Da[t]):
+Z=null;T=new THREE.Object3D;for(t=0;t<Z.nodes.length;t++)T.add(h(Z.nodes[t]));c();for(var u in M);u={scene:T,morphs:Fa,skins:Ba,dae:{images:xa,materials:ta,effects:sa,geometries:na,controllers:fa,animations:M,visualScenes:Da,scene:Z}};o&&o(u)}};n.open("GET",e,!0);n.send(null)}else alert("Don't know how to parse XML!")},setPreferredShading:function(b){pa=b},applySkin:f,geometries:na}};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 c=this,e=b.model,f=b.callback,h=b.texture_path?b.texture_path:this.extractUrlbase(e),b=new Worker(e);b.onmessage=function(b){c.createModel(b.data,f,h);c.onLoadComplete()};this.onLoadStart();b.postMessage((new Date).getTime())};
-THREE.JSONLoader.prototype.createModel=function(b,c,e){var f=new THREE.Geometry,h=b.scale!==void 0?1/b.scale:1;this.init_materials(f,b.materials,e);(function(c){if(b.version===void 0||b.version!=2)console.error("Deprecated file format.");else{var e,h,u,p,v,t,x,w,y,z,A,E,D,F,G=b.faces;t=b.vertices;var N=b.normals,Q=b.colors,L=0;for(e=0;e<b.uvs.length;e++)b.uvs[e].length&&L++;for(e=0;e<L;e++)f.faceUvs[e]=[],f.faceVertexUvs[e]=[];p=0;for(v=t.length;p<v;)x=new THREE.Vertex,x.position.x=t[p++]*c,x.position.y=
-t[p++]*c,x.position.z=t[p++]*c,f.vertices.push(x);p=0;for(v=G.length;p<v;){c=G[p++];t=c&1;u=c&2;e=c&4;h=c&8;w=c&16;x=c&32;z=c&64;c&=128;t?(A=new THREE.Face4,A.a=G[p++],A.b=G[p++],A.c=G[p++],A.d=G[p++],t=4):(A=new THREE.Face3,A.a=G[p++],A.b=G[p++],A.c=G[p++],t=3);if(u)u=G[p++],A.materials=f.materials[u];u=f.faces.length;if(e)for(e=0;e<L;e++)E=b.uvs[e],y=G[p++],F=E[y*2],y=E[y*2+1],f.faceUvs[e][u]=new THREE.UV(F,y);if(h)for(e=0;e<L;e++){E=b.uvs[e];D=[];for(h=0;h<t;h++)y=G[p++],F=E[y*2],y=E[y*2+1],D[h]=
-new THREE.UV(F,y);f.faceVertexUvs[e][u]=D}if(w)w=G[p++]*3,h=new THREE.Vector3,h.x=N[w++],h.y=N[w++],h.z=N[w],A.normal=h;if(x)for(e=0;e<t;e++)w=G[p++]*3,h=new THREE.Vector3,h.x=N[w++],h.y=N[w++],h.z=N[w],A.vertexNormals.push(h);if(z)x=G[p++],x=new THREE.Color(Q[x]),A.color=x;if(c)for(e=0;e<t;e++)x=G[p++],x=new THREE.Color(Q[x]),A.vertexColors.push(x);f.faces.push(A)}}})(h);(function(){var c,e,h,u;if(b.skinWeights){c=0;for(e=b.skinWeights.length;c<e;c+=2)h=b.skinWeights[c],u=b.skinWeights[c+1],f.skinWeights.push(new THREE.Vector4(h,
+THREE.JSONLoader.prototype.createModel=function(b,c,e){var f=new THREE.Geometry,h=b.scale!==void 0?1/b.scale:1;this.init_materials(f,b.materials,e);(function(c){if(b.version===void 0||b.version!=2)console.error("Deprecated file format.");else{var e,h,u,p,v,t,x,w,y,z,B,D,E,F,G=b.faces;t=b.vertices;var N=b.normals,Q=b.colors,H=0;for(e=0;e<b.uvs.length;e++)b.uvs[e].length&&H++;for(e=0;e<H;e++)f.faceUvs[e]=[],f.faceVertexUvs[e]=[];p=0;for(v=t.length;p<v;)x=new THREE.Vertex,x.position.x=t[p++]*c,x.position.y=
+t[p++]*c,x.position.z=t[p++]*c,f.vertices.push(x);p=0;for(v=G.length;p<v;){c=G[p++];t=c&1;u=c&2;e=c&4;h=c&8;w=c&16;x=c&32;z=c&64;c&=128;t?(B=new THREE.Face4,B.a=G[p++],B.b=G[p++],B.c=G[p++],B.d=G[p++],t=4):(B=new THREE.Face3,B.a=G[p++],B.b=G[p++],B.c=G[p++],t=3);if(u)u=G[p++],B.materials=f.materials[u];u=f.faces.length;if(e)for(e=0;e<H;e++)D=b.uvs[e],y=G[p++],F=D[y*2],y=D[y*2+1],f.faceUvs[e][u]=new THREE.UV(F,y);if(h)for(e=0;e<H;e++){D=b.uvs[e];E=[];for(h=0;h<t;h++)y=G[p++],F=D[y*2],y=D[y*2+1],E[h]=
+new THREE.UV(F,y);f.faceVertexUvs[e][u]=E}if(w)w=G[p++]*3,h=new THREE.Vector3,h.x=N[w++],h.y=N[w++],h.z=N[w],B.normal=h;if(x)for(e=0;e<t;e++)w=G[p++]*3,h=new THREE.Vector3,h.x=N[w++],h.y=N[w++],h.z=N[w],B.vertexNormals.push(h);if(z)x=G[p++],x=new THREE.Color(Q[x]),B.color=x;if(c)for(e=0;e<t;e++)x=G[p++],x=new THREE.Color(Q[x]),B.vertexColors.push(x);f.faces.push(B)}}})(h);(function(){var c,e,h,u;if(b.skinWeights){c=0;for(e=b.skinWeights.length;c<e;c+=2)h=b.skinWeights[c],u=b.skinWeights[c+1],f.skinWeights.push(new THREE.Vector4(h,
 u,0,0))}if(b.skinIndices){c=0;for(e=b.skinIndices.length;c<e;c+=2)h=b.skinIndices[c],u=b.skinIndices[c+1],f.skinIndices.push(new THREE.Vector4(h,u,0,0))}f.bones=b.bones;f.animation=b.animation})();(function(c){if(b.morphTargets!==void 0){var e,h,u,p,v,t,x,w,y;e=0;for(h=b.morphTargets.length;e<h;e++){f.morphTargets[e]={};f.morphTargets[e].name=b.morphTargets[e].name;f.morphTargets[e].vertices=[];w=f.morphTargets[e].vertices;y=b.morphTargets[e].vertices;u=0;for(p=y.length;u<p;u+=3)v=y[u]*c,t=y[u+1]*
 c,x=y[u+2]*c,w.push(new THREE.Vertex(new THREE.Vector3(v,t,x)))}}if(b.morphColors!==void 0){e=0;for(h=b.morphColors.length;e<h;e++){f.morphColors[e]={};f.morphColors[e].name=b.morphColors[e].name;f.morphColors[e].colors=[];p=f.morphColors[e].colors;v=b.morphColors[e].colors;c=0;for(u=v.length;c<u;c+=3)t=new THREE.Color(16755200),t.setRGB(v[c],v[c+1],v[c+2]),p.push(t)}}})(h);(function(){if(b.edges!==void 0){var c,e,h;for(c=0;c<b.edges.length;c+=2)e=b.edges[c],h=b.edges[c+1],f.edges.push(new THREE.Edge(f.vertices[e],
 f.vertices[h],e,h))}})();f.computeCentroids();f.computeFaceNormals();this.hasNormals(f)&&f.computeTangents();c(f)};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};
-THREE.SceneLoader.prototype={load:function(b,c){var e=this,f=new Worker(b);f.postMessage(0);var h=THREE.Loader.prototype.extractUrlbase(b);f.onmessage=function(b){function f(b,c){return c=="relativeToHTML"?b:h+"/"+b}function n(){for(w in O.objects)if(!S.objects[w])if(D=O.objects[w],D.geometry!==void 0){if(Q=S.geometries[D.geometry]){var b=!1;X=[];for($=0;$<D.materials.length;$++)X[$]=S.materials[D.materials[$]],b=X[$]instanceof THREE.ShaderMaterial;b&&Q.computeTangents();F=D.position;r=D.rotation;
-q=D.quaternion;s=D.scale;q=0;X.length==0&&(X[0]=new THREE.MeshFaceMaterial);X.length>1&&(X=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(Q,X);object.name=w;object.position.set(F[0],F[1],F[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=D.visible;S.scene.add(object);S.objects[w]=object;D.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),S.scene.collisions.colliders.push(b));
-if(D.castsShadow)b=new THREE.ShadowVolume(Q),S.scene.add(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;D.trigger&&D.trigger.toLowerCase()!="none"&&(b={type:D.trigger,object:D},S.triggers[object.name]=b)}}else F=D.position,r=D.rotation,q=D.quaternion,s=D.scale,q=0,object=new THREE.Object3D,object.name=w,object.position.set(F[0],F[1],F[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],
-s[1],s[2]),object.visible=D.visible!==void 0?D.visible:!1,S.scene.add(object),S.objects[w]=object,S.empties[w]=object,D.trigger&&D.trigger.toLowerCase()!="none"&&(b={type:D.trigger,object:D},S.triggers[object.name]=b)}function u(b){return function(c){S.geometries[b]=c;n();U-=1;e.onLoadComplete();v()}}function p(b){return function(c){S.geometries[b]=c}}function v(){e.callbackProgress({totalModels:o,totalTextures:ea,loadedModels:o-U,loadedTextures:ea-V},S);e.onLoadProgress();U==0&&V==0&&c(S)}var t,
-x,w,y,z,A,E,D,F,G,N,Q,L,H,M,X,C,O,P,U,V,o,ea,S;O=b.data;M=new THREE.BinaryLoader;P=new THREE.JSONLoader;V=U=0;S={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(w in O.objects)if(D=O.objects[w],D.meshCollider){b=!0;break}if(b)S.scene.collisions=new THREE.CollisionSystem;if(O.transform){b=O.transform.position;G=O.transform.rotation;var ta=O.transform.scale;b&&S.scene.position.set(b[0],b[1],b[2]);G&&S.scene.rotation.set(G[0],
-G[1],G[2]);ta&&S.scene.scale.set(ta[0],ta[1],ta[2]);(b||G||ta)&&S.scene.updateMatrix()}b=function(){V-=1;v();e.onLoadComplete()};for(z in O.cameras){G=O.cameras[z];if(G.type=="perspective")L=new THREE.Camera(G.fov,G.aspect,G.near,G.far);else if(G.type=="ortho")L=new THREE.Camera,L.projectionMatrix=THREE.Matrix4.makeOrtho(G.left,G.right,G.top,G.bottom,G.near,G.far);F=G.position;G=G.target;L.position.set(F[0],F[1],F[2]);L.target.position.set(G[0],G[1],G[2]);S.cameras[z]=L}for(y in O.lights)z=O.lights[y],
-L=z.color!==void 0?z.color:16777215,G=z.intensity!==void 0?z.intensity:1,z.type=="directional"?(F=z.direction,C=new THREE.DirectionalLight(L,G),C.position.set(F[0],F[1],F[2]),C.position.normalize()):z.type=="point"?(F=z.position,d=z.distance,C=new THREE.PointLight(L,G,d),C.position.set(F[0],F[1],F[2])):z.type=="ambient"&&(C=new THREE.AmbientLight(L)),S.scene.add(C),S.lights[y]=C;for(A in O.fogs)y=O.fogs[A],y.type=="linear"?H=new THREE.Fog(0,y.near,y.far):y.type=="exp2"&&(H=new THREE.FogExp2(0,y.density)),
-G=y.color,H.color.setRGB(G[0],G[1],G[2]),S.fogs[A]=H;if(S.cameras&&O.defaults.camera)S.currentCamera=S.cameras[O.defaults.camera];if(S.fogs&&O.defaults.fog)S.scene.fog=S.fogs[O.defaults.fog];G=O.defaults.bgcolor;S.bgColor=new THREE.Color;S.bgColor.setRGB(G[0],G[1],G[2]);S.bgColorAlpha=O.defaults.bgalpha;for(t in O.geometries)if(A=O.geometries[t],A.type=="bin_mesh"||A.type=="ascii_mesh")U+=1,e.onLoadStart();o=U;for(t in O.geometries)A=O.geometries[t],A.type=="cube"?(Q=new THREE.CubeGeometry(A.width,
-A.height,A.depth,A.segmentsWidth,A.segmentsHeight,A.segmentsDepth,null,A.flipped,A.sides),S.geometries[t]=Q):A.type=="plane"?(Q=new THREE.PlaneGeometry(A.width,A.height,A.segmentsWidth,A.segmentsHeight),S.geometries[t]=Q):A.type=="sphere"?(Q=new THREE.SphereGeometry(A.radius,A.segmentsWidth,A.segmentsHeight),S.geometries[t]=Q):A.type=="cylinder"?(Q=new THREE.CylinderGeometry(A.topRad,A.botRad,A.height,A.radSegs,A.heightSegs),S.geometries[t]=Q):A.type=="torus"?(Q=new THREE.TorusGeometry(A.radius,A.tube,
-A.segmentsR,A.segmentsT),S.geometries[t]=Q):A.type=="icosahedron"?(Q=new THREE.IcosahedronGeometry(A.subdivisions),S.geometries[t]=Q):A.type=="bin_mesh"?M.load({model:f(A.url,O.urlBaseType),callback:u(t)}):A.type=="ascii_mesh"?P.load({model:f(A.url,O.urlBaseType),callback:u(t)}):A.type=="embedded_mesh"&&(A=O.embeds[A.id])&&P.createModel(A,p(t),"");for(E in O.textures)if(t=O.textures[E],t.url instanceof Array){V+=t.url.length;for(M=0;M<t.url.length;M++)e.onLoadStart()}else V+=1,e.onLoadStart();ea=
-V;for(E in O.textures){t=O.textures[E];if(t.mapping!=void 0&&THREE[t.mapping]!=void 0)t.mapping=new THREE[t.mapping];if(t.url instanceof Array){M=[];for(var $=0;$<t.url.length;$++)M[$]=f(t.url[$],O.urlBaseType);M=THREE.ImageUtils.loadTextureCube(M,t.mapping,b)}else{M=THREE.ImageUtils.loadTexture(f(t.url,O.urlBaseType),t.mapping,b);if(THREE[t.minFilter]!=void 0)M.minFilter=THREE[t.minFilter];if(THREE[t.magFilter]!=void 0)M.magFilter=THREE[t.magFilter];if(t.repeat){M.repeat.set(t.repeat[0],t.repeat[1]);
-if(t.repeat[0]!=1)M.wrapS=THREE.RepeatWrapping;if(t.repeat[1]!=1)M.wrapT=THREE.RepeatWrapping}t.offset&&M.offset.set(t.offset[0],t.offset[1]);if(t.wrap){P={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(P[t.wrap[0]]!==void 0)M.wrapS=P[t.wrap[0]];if(P[t.wrap[1]]!==void 0)M.wrapT=P[t.wrap[1]]}}S.textures[E]=M}for(x in O.materials){E=O.materials[x];for(N in E.parameters)if(N=="envMap"||N=="map"||N=="lightMap")E.parameters[N]=S.textures[E.parameters[N]];else if(N=="shading")E.parameters[N]=
-E.parameters[N]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(N=="blending")E.parameters[N]=THREE[E.parameters[N]]?THREE[E.parameters[N]]:THREE.NormalBlending;else if(N=="combine")E.parameters[N]=E.parameters[N]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(N=="vertexColors")if(E.parameters[N]=="face")E.parameters[N]=THREE.FaceColors;else if(E.parameters[N])E.parameters[N]=THREE.VertexColors;if(E.parameters.opacity!==void 0&&E.parameters.opacity<1)E.parameters.transparent=
-!0;if(E.parameters.normalMap){t=THREE.ShaderUtils.lib.normal;b=THREE.UniformsUtils.clone(t.uniforms);M=E.parameters.color;P=E.parameters.specular;A=E.parameters.ambient;H=E.parameters.shininess;b.tNormal.texture=S.textures[E.parameters.normalMap];if(E.parameters.normalMapFactor)b.uNormalScale.value=E.parameters.normalMapFactor;if(E.parameters.map)b.tDiffuse.texture=E.parameters.map,b.enableDiffuse.value=!0;if(E.parameters.lightMap)b.tAO.texture=E.parameters.lightMap,b.enableAO.value=!0;if(E.parameters.specularMap)b.tSpecular.texture=
-S.textures[E.parameters.specularMap],b.enableSpecular.value=!0;b.uDiffuseColor.value.setHex(M);b.uSpecularColor.value.setHex(P);b.uAmbientColor.value.setHex(A);b.uShininess.value=H;if(E.parameters.opacity)b.uOpacity.value=E.parameters.opacity;E=new THREE.ShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:b,lights:!0,fog:!0})}else E=new THREE[E.type](E.parameters);S.materials[x]=E}n();e.callbackSync(S)}},constructor:THREE.SceneLoader};THREE.UTF8Loader=function(){};
+THREE.SceneLoader.prototype={load:function(b,c){var e=this,f=new Worker(b);f.postMessage(0);var h=THREE.Loader.prototype.extractUrlbase(b);f.onmessage=function(b){function f(b,c){return c=="relativeToHTML"?b:h+"/"+b}function n(){for(w in O.objects)if(!S.objects[w])if(E=O.objects[w],E.geometry!==void 0){if(Q=S.geometries[E.geometry]){var b=!1;X=[];for(aa=0;aa<E.materials.length;aa++)X[aa]=S.materials[E.materials[aa]],b=X[aa]instanceof THREE.ShaderMaterial;b&&Q.computeTangents();F=E.position;r=E.rotation;
+q=E.quaternion;s=E.scale;q=0;X.length==0&&(X[0]=new THREE.MeshFaceMaterial);X.length>1&&(X=[new THREE.MeshFaceMaterial]);object=new THREE.Mesh(Q,X);object.name=w;object.position.set(F[0],F[1],F[2]);q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]);object.scale.set(s[0],s[1],s[2]);object.visible=E.visible;S.scene.add(object);S.objects[w]=object;E.meshCollider&&(b=THREE.CollisionUtils.MeshColliderWBox(object),S.scene.collisions.colliders.push(b));
+if(E.castsShadow)b=new THREE.ShadowVolume(Q),S.scene.add(b),b.position=object.position,b.rotation=object.rotation,b.scale=object.scale;E.trigger&&E.trigger.toLowerCase()!="none"&&(b={type:E.trigger,object:E},S.triggers[object.name]=b)}}else F=E.position,r=E.rotation,q=E.quaternion,s=E.scale,q=0,object=new THREE.Object3D,object.name=w,object.position.set(F[0],F[1],F[2]),q?(object.quaternion.set(q[0],q[1],q[2],q[3]),object.useQuaternion=!0):object.rotation.set(r[0],r[1],r[2]),object.scale.set(s[0],
+s[1],s[2]),object.visible=E.visible!==void 0?E.visible:!1,S.scene.add(object),S.objects[w]=object,S.empties[w]=object,E.trigger&&E.trigger.toLowerCase()!="none"&&(b={type:E.trigger,object:E},S.triggers[object.name]=b)}function u(b){return function(c){S.geometries[b]=c;n();U-=1;e.onLoadComplete();v()}}function p(b){return function(c){S.geometries[b]=c}}function v(){e.callbackProgress({totalModels:o,totalTextures:da,loadedModels:o-U,loadedTextures:da-W},S);e.onLoadProgress();U==0&&W==0&&c(S)}var t,
+x,w,y,z,B,D,E,F,G,N,Q,H,K,I,X,C,O,P,U,W,o,da,S;O=b.data;I=new THREE.BinaryLoader;P=new THREE.JSONLoader;W=U=0;S={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},empties:{}};b=!1;for(w in O.objects)if(E=O.objects[w],E.meshCollider){b=!0;break}if(b)S.scene.collisions=new THREE.CollisionSystem;if(O.transform){b=O.transform.position;G=O.transform.rotation;var la=O.transform.scale;b&&S.scene.position.set(b[0],b[1],b[2]);G&&S.scene.rotation.set(G[0],
+G[1],G[2]);la&&S.scene.scale.set(la[0],la[1],la[2]);(b||G||la)&&S.scene.updateMatrix()}b=function(){W-=1;v();e.onLoadComplete()};for(z in O.cameras){G=O.cameras[z];if(G.type=="perspective")H=new THREE.Camera(G.fov,G.aspect,G.near,G.far);else if(G.type=="ortho")H=new THREE.Camera,H.projectionMatrix=THREE.Matrix4.makeOrtho(G.left,G.right,G.top,G.bottom,G.near,G.far);F=G.position;G=G.target;H.position.set(F[0],F[1],F[2]);H.target.position.set(G[0],G[1],G[2]);S.cameras[z]=H}for(y in O.lights)z=O.lights[y],
+H=z.color!==void 0?z.color:16777215,G=z.intensity!==void 0?z.intensity:1,z.type=="directional"?(F=z.direction,C=new THREE.DirectionalLight(H,G),C.position.set(F[0],F[1],F[2]),C.position.normalize()):z.type=="point"?(F=z.position,d=z.distance,C=new THREE.PointLight(H,G,d),C.position.set(F[0],F[1],F[2])):z.type=="ambient"&&(C=new THREE.AmbientLight(H)),S.scene.add(C),S.lights[y]=C;for(B in O.fogs)y=O.fogs[B],y.type=="linear"?K=new THREE.Fog(0,y.near,y.far):y.type=="exp2"&&(K=new THREE.FogExp2(0,y.density)),
+G=y.color,K.color.setRGB(G[0],G[1],G[2]),S.fogs[B]=K;if(S.cameras&&O.defaults.camera)S.currentCamera=S.cameras[O.defaults.camera];if(S.fogs&&O.defaults.fog)S.scene.fog=S.fogs[O.defaults.fog];G=O.defaults.bgcolor;S.bgColor=new THREE.Color;S.bgColor.setRGB(G[0],G[1],G[2]);S.bgColorAlpha=O.defaults.bgalpha;for(t in O.geometries)if(B=O.geometries[t],B.type=="bin_mesh"||B.type=="ascii_mesh")U+=1,e.onLoadStart();o=U;for(t in O.geometries)B=O.geometries[t],B.type=="cube"?(Q=new THREE.CubeGeometry(B.width,
+B.height,B.depth,B.segmentsWidth,B.segmentsHeight,B.segmentsDepth,null,B.flipped,B.sides),S.geometries[t]=Q):B.type=="plane"?(Q=new THREE.PlaneGeometry(B.width,B.height,B.segmentsWidth,B.segmentsHeight),S.geometries[t]=Q):B.type=="sphere"?(Q=new THREE.SphereGeometry(B.radius,B.segmentsWidth,B.segmentsHeight),S.geometries[t]=Q):B.type=="cylinder"?(Q=new THREE.CylinderGeometry(B.topRad,B.botRad,B.height,B.radSegs,B.heightSegs),S.geometries[t]=Q):B.type=="torus"?(Q=new THREE.TorusGeometry(B.radius,B.tube,
+B.segmentsR,B.segmentsT),S.geometries[t]=Q):B.type=="icosahedron"?(Q=new THREE.IcosahedronGeometry(B.subdivisions),S.geometries[t]=Q):B.type=="bin_mesh"?I.load({model:f(B.url,O.urlBaseType),callback:u(t)}):B.type=="ascii_mesh"?P.load({model:f(B.url,O.urlBaseType),callback:u(t)}):B.type=="embedded_mesh"&&(B=O.embeds[B.id])&&P.createModel(B,p(t),"");for(D in O.textures)if(t=O.textures[D],t.url instanceof Array){W+=t.url.length;for(I=0;I<t.url.length;I++)e.onLoadStart()}else W+=1,e.onLoadStart();da=
+W;for(D in O.textures){t=O.textures[D];if(t.mapping!=void 0&&THREE[t.mapping]!=void 0)t.mapping=new THREE[t.mapping];if(t.url instanceof Array){I=[];for(var aa=0;aa<t.url.length;aa++)I[aa]=f(t.url[aa],O.urlBaseType);I=THREE.ImageUtils.loadTextureCube(I,t.mapping,b)}else{I=THREE.ImageUtils.loadTexture(f(t.url,O.urlBaseType),t.mapping,b);if(THREE[t.minFilter]!=void 0)I.minFilter=THREE[t.minFilter];if(THREE[t.magFilter]!=void 0)I.magFilter=THREE[t.magFilter];if(t.repeat){I.repeat.set(t.repeat[0],t.repeat[1]);
+if(t.repeat[0]!=1)I.wrapS=THREE.RepeatWrapping;if(t.repeat[1]!=1)I.wrapT=THREE.RepeatWrapping}t.offset&&I.offset.set(t.offset[0],t.offset[1]);if(t.wrap){P={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(P[t.wrap[0]]!==void 0)I.wrapS=P[t.wrap[0]];if(P[t.wrap[1]]!==void 0)I.wrapT=P[t.wrap[1]]}}S.textures[D]=I}for(x in O.materials){D=O.materials[x];for(N in D.parameters)if(N=="envMap"||N=="map"||N=="lightMap")D.parameters[N]=S.textures[D.parameters[N]];else if(N=="shading")D.parameters[N]=
+D.parameters[N]=="flat"?THREE.FlatShading:THREE.SmoothShading;else if(N=="blending")D.parameters[N]=THREE[D.parameters[N]]?THREE[D.parameters[N]]:THREE.NormalBlending;else if(N=="combine")D.parameters[N]=D.parameters[N]=="MixOperation"?THREE.MixOperation:THREE.MultiplyOperation;else if(N=="vertexColors")if(D.parameters[N]=="face")D.parameters[N]=THREE.FaceColors;else if(D.parameters[N])D.parameters[N]=THREE.VertexColors;if(D.parameters.opacity!==void 0&&D.parameters.opacity<1)D.parameters.transparent=
+!0;if(D.parameters.normalMap){t=THREE.ShaderUtils.lib.normal;b=THREE.UniformsUtils.clone(t.uniforms);I=D.parameters.color;P=D.parameters.specular;B=D.parameters.ambient;K=D.parameters.shininess;b.tNormal.texture=S.textures[D.parameters.normalMap];if(D.parameters.normalMapFactor)b.uNormalScale.value=D.parameters.normalMapFactor;if(D.parameters.map)b.tDiffuse.texture=D.parameters.map,b.enableDiffuse.value=!0;if(D.parameters.lightMap)b.tAO.texture=D.parameters.lightMap,b.enableAO.value=!0;if(D.parameters.specularMap)b.tSpecular.texture=
+S.textures[D.parameters.specularMap],b.enableSpecular.value=!0;b.uDiffuseColor.value.setHex(I);b.uSpecularColor.value.setHex(P);b.uAmbientColor.value.setHex(B);b.uShininess.value=K;if(D.parameters.opacity)b.uOpacity.value=D.parameters.opacity;D=new THREE.ShaderMaterial({fragmentShader:t.fragmentShader,vertexShader:t.vertexShader,uniforms:b,lights:!0,fog:!0})}else D=new THREE[D.type](D.parameters);S.materials[x]=D}n();e.callbackSync(S)}},constructor:THREE.SceneLoader};THREE.UTF8Loader=function(){};
 THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
 THREE.UTF8Loader.prototype.load=function(b){var c=new XMLHttpRequest,e=b.model,f=b.callback,h=b.scale!==void 0?b.scale:1,m=b.offsetX!==void 0?b.offsetX:0,k=b.offsetY!==void 0?b.offsetY:0,n=b.offsetZ!==void 0?b.offsetZ:0;c.onreadystatechange=function(){c.readyState==4?c.status==200||c.status==0?THREE.UTF8Loader.prototype.createModel(c.responseText,f,h,m,k,n):alert("Couldn't load ["+e+"] ["+c.status+"]"):c.readyState!=3&&c.readyState==2&&c.getResponseHeader("Content-Length")};c.open("GET",e,!0);c.send(null)};
 THREE.UTF8Loader.prototype.decompressMesh=function(b){var c=b.charCodeAt(0);c>=57344&&(c-=2048);c++;for(var e=new Float32Array(8*c),f=1,h=0;h<8;h++){for(var m=0,k=0;k<c;++k){var n=b.charCodeAt(k+f);m+=n>>1^-(n&1);e[8*k+h]=m}f+=c}c=b.length-f;m=new Uint16Array(c);for(h=k=0;h<c;h++)n=b.charCodeAt(h+f),m[h]=k-n,n==0&&k++;return[e,m]};
-THREE.UTF8Loader.prototype.createModel=function(b,c,e,f,h,m){var k=function(){var c=this;c.materials=[];THREE.Geometry.call(this);var k=THREE.UTF8Loader.prototype.decompressMesh(b),p=[],v=[];(function(b,k,p){for(var u,v,A,E=b.length;p<E;p+=k)u=b[p],v=b[p+1],A=b[p+2],u=u/16383*e,v=v/16383*e,A=A/16383*e,u+=f,v+=h,A+=m,c.vertices.push(new THREE.Vertex(new THREE.Vector3(u,v,A)))})(k[0],8,0);(function(b,c,e){for(var f,h,k=b.length;e<k;e+=c)f=b[e],h=b[e+1],f/=1023,h/=1023,v.push(f,1-h)})(k[0],8,3);(function(b,
-c,e){for(var f,h,k,m=b.length;e<m;e+=c)f=b[e],h=b[e+1],k=b[e+2],f=(f-512)/511,h=(h-512)/511,k=(k-512)/511,p.push(f,h,k)})(k[0],8,5);(function(b){var e,f,h,k,m,u,D,F,G,N=b.length;for(e=0;e<N;e+=3){f=b[e];h=b[e+1];k=b[e+2];m=c;F=f;G=h;u=k;D=f;var Q=h,L=k,H=m.materials[0],M=p[Q*3],X=p[Q*3+1],Q=p[Q*3+2],C=p[L*3],O=p[L*3+1],L=p[L*3+2];D=new THREE.Vector3(p[D*3],p[D*3+1],p[D*3+2]);Q=new THREE.Vector3(M,X,Q);L=new THREE.Vector3(C,O,L);m.faces.push(new THREE.Face3(F,G,u,[D,Q,L],null,H));m=v[f*2];f=v[f*2+
-1];u=v[h*2];D=v[h*2+1];F=v[k*2];G=v[k*2+1];k=c.faceVertexUvs[0];h=u;u=D;D=[];D.push(new THREE.UV(m,f));D.push(new THREE.UV(h,u));D.push(new THREE.UV(F,G));k.push(D)}})(k[1]);this.computeCentroids();this.computeFaceNormals()};k.prototype=new THREE.Geometry;k.prototype.constructor=k;c(new k)};
+THREE.UTF8Loader.prototype.createModel=function(b,c,e,f,h,m){var k=function(){var c=this;c.materials=[];THREE.Geometry.call(this);var k=THREE.UTF8Loader.prototype.decompressMesh(b),p=[],v=[];(function(b,k,p){for(var u,v,B,D=b.length;p<D;p+=k)u=b[p],v=b[p+1],B=b[p+2],u=u/16383*e,v=v/16383*e,B=B/16383*e,u+=f,v+=h,B+=m,c.vertices.push(new THREE.Vertex(new THREE.Vector3(u,v,B)))})(k[0],8,0);(function(b,c,e){for(var f,h,k=b.length;e<k;e+=c)f=b[e],h=b[e+1],f/=1023,h/=1023,v.push(f,1-h)})(k[0],8,3);(function(b,
+c,e){for(var f,h,k,m=b.length;e<m;e+=c)f=b[e],h=b[e+1],k=b[e+2],f=(f-512)/511,h=(h-512)/511,k=(k-512)/511,p.push(f,h,k)})(k[0],8,5);(function(b){var e,f,h,k,m,u,E,F,G,N=b.length;for(e=0;e<N;e+=3){f=b[e];h=b[e+1];k=b[e+2];m=c;F=f;G=h;u=k;E=f;var Q=h,H=k,K=m.materials[0],I=p[Q*3],X=p[Q*3+1],Q=p[Q*3+2],C=p[H*3],O=p[H*3+1],H=p[H*3+2];E=new THREE.Vector3(p[E*3],p[E*3+1],p[E*3+2]);Q=new THREE.Vector3(I,X,Q);H=new THREE.Vector3(C,O,H);m.faces.push(new THREE.Face3(F,G,u,[E,Q,H],null,K));m=v[f*2];f=v[f*2+
+1];u=v[h*2];E=v[h*2+1];F=v[k*2];G=v[k*2+1];k=c.faceVertexUvs[0];h=u;u=E;E=[];E.push(new THREE.UV(m,f));E.push(new THREE.UV(h,u));E.push(new THREE.UV(F,G));k.push(E)}})(k[1]);this.computeCentroids();this.computeFaceNormals()};k.prototype=new THREE.Geometry;k.prototype.constructor=k;c(new k)};
 THREE.MarchingCubes=function(b,c){THREE.Object3D.call(this);this.materials=c instanceof Array?c:[c];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.hasNormal=this.hasPos=!1;this.positionArray=new Float32Array(this.maxCount*3);this.normalArray=new Float32Array(this.maxCount*3)};this.lerp=function(b,c,h){return b+(c-b)*h};this.VIntX=function(b,c,h,m,k,n,u,p,v,t){k=(k-v)/(t-v);v=this.normal_cache;c[m]=n+k*this.delta;c[m+1]=u;c[m+2]=p;h[m]=this.lerp(v[b],v[b+3],k);h[m+1]=this.lerp(v[b+1],v[b+4],k);h[m+2]=this.lerp(v[b+2],v[b+5],k)};this.VIntY=function(b,c,h,m,k,n,u,p,v,t){k=(k-v)/(t-v);v=this.normal_cache;c[m]=n;c[m+1]=u+k*this.delta;c[m+
 2]=p;c=b+this.yd*3;h[m]=this.lerp(v[b],v[c],k);h[m+1]=this.lerp(v[b+1],v[c+1],k);h[m+2]=this.lerp(v[b+2],v[c+2],k)};this.VIntZ=function(b,c,h,m,k,n,u,p,v,t){k=(k-v)/(t-v);v=this.normal_cache;c[m]=n;c[m+1]=u;c[m+2]=p+k*this.delta;c=b+this.zd*3;h[m]=this.lerp(v[b],v[c],k);h[m+1]=this.lerp(v[b+1],v[c+1],k);h[m+2]=this.lerp(v[b+2],v[c+2],k)};this.compNorm=function(b){var c=b*3;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,h,m,k,n){var u=m+1,p=m+this.yd,v=m+this.zd,t=u+this.yd,x=u+this.zd,w=m+this.yd+this.zd,y=u+this.yd+this.zd,z=0,A=this.field[m],E=this.field[u],D=this.field[p],F=this.field[t],G=this.field[v],N=this.field[x],Q=this.field[w],L=this.field[y];A<k&&(z|=1);E<k&&(z|=2);D<k&&(z|=8);F<k&&(z|=4);G<k&&(z|=16);N<k&&(z|=32);Q<k&&(z|=128);L<k&&(z|=64);var H=THREE.edgeTable[z];if(H==0)return 0;var M=this.delta,
-X=b+M,C=c+M,M=h+M;H&1&&(this.compNorm(m),this.compNorm(u),this.VIntX(m*3,this.vlist,this.nlist,0,k,b,c,h,A,E));H&2&&(this.compNorm(u),this.compNorm(t),this.VIntY(u*3,this.vlist,this.nlist,3,k,X,c,h,E,F));H&4&&(this.compNorm(p),this.compNorm(t),this.VIntX(p*3,this.vlist,this.nlist,6,k,b,C,h,D,F));H&8&&(this.compNorm(m),this.compNorm(p),this.VIntY(m*3,this.vlist,this.nlist,9,k,b,c,h,A,D));H&16&&(this.compNorm(v),this.compNorm(x),this.VIntX(v*3,this.vlist,this.nlist,12,k,b,c,M,G,N));H&32&&(this.compNorm(x),
-this.compNorm(y),this.VIntY(x*3,this.vlist,this.nlist,15,k,X,c,M,N,L));H&64&&(this.compNorm(w),this.compNorm(y),this.VIntX(w*3,this.vlist,this.nlist,18,k,b,C,M,Q,L));H&128&&(this.compNorm(v),this.compNorm(w),this.VIntY(v*3,this.vlist,this.nlist,21,k,b,c,M,G,Q));H&256&&(this.compNorm(m),this.compNorm(v),this.VIntZ(m*3,this.vlist,this.nlist,24,k,b,c,h,A,G));H&512&&(this.compNorm(u),this.compNorm(x),this.VIntZ(u*3,this.vlist,this.nlist,27,k,X,c,h,E,N));H&1024&&(this.compNorm(t),this.compNorm(y),this.VIntZ(t*
-3,this.vlist,this.nlist,30,k,X,C,h,F,L));H&2048&&(this.compNorm(p),this.compNorm(w),this.VIntZ(p*3,this.vlist,this.nlist,33,k,b,C,h,D,Q));z<<=4;for(k=m=0;THREE.triTable[z+k]!=-1;)b=z+k,c=b+1,h=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[h],n),k+=3,m++;return m};this.posnormtriv=function(b,c,h,m,k,n){var u=this.count*3;this.positionArray[u]=b[h];this.positionArray[u+1]=b[h+1];this.positionArray[u+2]=b[h+2];this.positionArray[u+3]=b[m];this.positionArray[u+
+this.yd],this.normal_cache[c+2]=this.field[b-this.zd]-this.field[b+this.zd])};this.polygonize=function(b,c,h,m,k,n){var u=m+1,p=m+this.yd,v=m+this.zd,t=u+this.yd,x=u+this.zd,w=m+this.yd+this.zd,y=u+this.yd+this.zd,z=0,B=this.field[m],D=this.field[u],E=this.field[p],F=this.field[t],G=this.field[v],N=this.field[x],Q=this.field[w],H=this.field[y];B<k&&(z|=1);D<k&&(z|=2);E<k&&(z|=8);F<k&&(z|=4);G<k&&(z|=16);N<k&&(z|=32);Q<k&&(z|=128);H<k&&(z|=64);var K=THREE.edgeTable[z];if(K==0)return 0;var I=this.delta,
+X=b+I,C=c+I,I=h+I;K&1&&(this.compNorm(m),this.compNorm(u),this.VIntX(m*3,this.vlist,this.nlist,0,k,b,c,h,B,D));K&2&&(this.compNorm(u),this.compNorm(t),this.VIntY(u*3,this.vlist,this.nlist,3,k,X,c,h,D,F));K&4&&(this.compNorm(p),this.compNorm(t),this.VIntX(p*3,this.vlist,this.nlist,6,k,b,C,h,E,F));K&8&&(this.compNorm(m),this.compNorm(p),this.VIntY(m*3,this.vlist,this.nlist,9,k,b,c,h,B,E));K&16&&(this.compNorm(v),this.compNorm(x),this.VIntX(v*3,this.vlist,this.nlist,12,k,b,c,I,G,N));K&32&&(this.compNorm(x),
+this.compNorm(y),this.VIntY(x*3,this.vlist,this.nlist,15,k,X,c,I,N,H));K&64&&(this.compNorm(w),this.compNorm(y),this.VIntX(w*3,this.vlist,this.nlist,18,k,b,C,I,Q,H));K&128&&(this.compNorm(v),this.compNorm(w),this.VIntY(v*3,this.vlist,this.nlist,21,k,b,c,I,G,Q));K&256&&(this.compNorm(m),this.compNorm(v),this.VIntZ(m*3,this.vlist,this.nlist,24,k,b,c,h,B,G));K&512&&(this.compNorm(u),this.compNorm(x),this.VIntZ(u*3,this.vlist,this.nlist,27,k,X,c,h,D,N));K&1024&&(this.compNorm(t),this.compNorm(y),this.VIntZ(t*
+3,this.vlist,this.nlist,30,k,X,C,h,F,H));K&2048&&(this.compNorm(p),this.compNorm(w),this.VIntZ(p*3,this.vlist,this.nlist,33,k,b,C,h,E,Q));z<<=4;for(k=m=0;THREE.triTable[z+k]!=-1;)b=z+k,c=b+1,h=b+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[b],3*THREE.triTable[c],3*THREE.triTable[h],n),k+=3,m++;return m};this.posnormtriv=function(b,c,h,m,k,n){var u=this.count*3;this.positionArray[u]=b[h];this.positionArray[u+1]=b[h+1];this.positionArray[u+2]=b[h+2];this.positionArray[u+3]=b[m];this.positionArray[u+
 4]=b[m+1];this.positionArray[u+5]=b[m+2];this.positionArray[u+6]=b[k];this.positionArray[u+7]=b[k+1];this.positionArray[u+8]=b[k+2];this.normalArray[u]=c[h];this.normalArray[u+1]=c[h+1];this.normalArray[u+2]=c[h+2];this.normalArray[u+3]=c[m];this.normalArray[u+4]=c[m+1];this.normalArray[u+5]=c[m+2];this.normalArray[u+6]=c[k];this.normalArray[u+7]=c[k+1];this.normalArray[u+8]=c[k+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&n(this)};this.begin=function(){this.count=0;
 this.hasNormal=this.hasPos=!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,h,m,k){var n=this.size*Math.sqrt(m/k),u=h*this.size,p=c*this.size,v=b*this.size,t=Math.floor(u-n);t<1&&(t=1);u=Math.floor(u+n);u>this.size-1&&(u=this.size-1);var x=Math.floor(p-n);x<1&&(x=1);p=Math.floor(p+n);p>this.size-1&&(p=this.size-1);var w=Math.floor(v-n);w<1&&(w=1);n=Math.floor(v+n);n>this.size-1&&(n=this.size-
-1);for(var y,z,A,E,D,F;t<u;t++){v=this.size2*t;z=t/this.size-h;D=z*z;for(z=x;z<p;z++){A=v+this.size*z;y=z/this.size-c;F=y*y;for(y=w;y<n;y++)E=y/this.size-b,E=m/(1.0E-6+E*E+F+D)-k,E>0&&(this.field[A+y]+=E)}}};this.addPlaneX=function(b,c){var h,m,k,n,u,p=this.size,v=this.yd,t=this.zd,x=this.field,w=p*Math.sqrt(b/c);w>p&&(w=p);for(h=0;h<w;h++)if(m=h/p,m*=m,n=b/(1.0E-4+m)-c,n>0)for(m=0;m<p;m++){u=h+m*v;for(k=0;k<p;k++)x[t*k+u]+=n}};this.addPlaneY=function(b,c){var h,m,k,n,u,p,v=this.size,t=this.yd,x=
+1);for(var y,z,B,D,E,F;t<u;t++){v=this.size2*t;z=t/this.size-h;E=z*z;for(z=x;z<p;z++){B=v+this.size*z;y=z/this.size-c;F=y*y;for(y=w;y<n;y++)D=y/this.size-b,D=m/(1.0E-6+D*D+F+E)-k,D>0&&(this.field[B+y]+=D)}}};this.addPlaneX=function(b,c){var h,m,k,n,u,p=this.size,v=this.yd,t=this.zd,x=this.field,w=p*Math.sqrt(b/c);w>p&&(w=p);for(h=0;h<w;h++)if(m=h/p,m*=m,n=b/(1.0E-4+m)-c,n>0)for(m=0;m<p;m++){u=h+m*v;for(k=0;k<p;k++)x[t*k+u]+=n}};this.addPlaneY=function(b,c){var h,m,k,n,u,p,v=this.size,t=this.yd,x=
 this.zd,w=this.field,y=v*Math.sqrt(b/c);y>v&&(y=v);for(m=0;m<y;m++)if(h=m/v,h*=h,n=b/(1.0E-4+h)-c,n>0){u=m*t;for(h=0;h<v;h++){p=u+h;for(k=0;k<v;k++)w[x*k+p]+=n}}};this.addPlaneZ=function(b,c){var h,m,k,n,u,p;size=this.size;yd=this.yd;zd=this.zd;field=this.field;dist=size*Math.sqrt(b/c);dist>size&&(dist=size);for(k=0;k<dist;k++)if(h=k/size,h*=h,n=b/(1.0E-4+h)-c,n>0){u=zd*k;for(m=0;m<size;m++){p=u+m*yd;for(h=0;h<size;h++)field[p+h]+=n}}};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,h,m,k,n,u,p,v,t,x=this.size-2;for(k=1;k<x;k++){t=this.size2*k;p=(k-this.halfsize)/this.halfsize;for(m=1;m<x;m++){v=t+this.size*m;u=(m-this.halfsize)/this.halfsize;for(h=1;h<x;h++)n=(h-this.halfsize)/this.halfsize,c=v+h,this.polygonize(n,u,p,c,this.isolation,b)}}this.end(b)};this.generateGeometry=function(){var b=0,c=new THREE.Geometry,h=[];this.render(function(m){var k,n,u,p,v,t,x,w;for(k=0;k<m.count;k++)x=k*3,v=x+1,w=x+2,n=m.positionArray[x],
 u=m.positionArray[v],p=m.positionArray[w],t=new THREE.Vector3(n,u,p),n=m.normalArray[x],u=m.normalArray[v],p=m.normalArray[w],x=new THREE.Vector3(n,u,p),x.normalize(),v=new THREE.Vertex(t),c.vertices.push(v),h.push(x);nfaces=m.count/3;for(k=0;k<nfaces;k++)x=(b+k)*3,v=x+1,w=x+2,t=h[x],n=h[v],u=h[w],x=new THREE.Face3(x,v,w,[t,n,u]),c.faces.push(x);b+=nfaces;m.count=0});return c};this.init(b)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
@@ -681,7 +681,7 @@ THREE.CollisionSystem.__r=new THREE.Ray;THREE.CollisionUtils={};THREE.CollisionU
 THREE.CollisionUtils.MeshColliderWBox=function(b){return new THREE.MeshCollider(b,THREE.CollisionUtils.MeshOBB(b))};
 if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);var c=this,e=this.setSize,f=this.render,h=new THREE.Camera,m=new THREE.Camera,k=new THREE.Matrix4,n=new THREE.Matrix4,u,p,v;h.useTarget=m.useTarget=!1;h.matrixAutoUpdate=m.matrixAutoUpdate=!1;var b={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},t=new THREE.WebGLRenderTarget(512,512,b),x=new THREE.WebGLRenderTarget(512,512,b),w=new THREE.Camera(53,1,1,1E4);w.position.z=
 2;_material=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:t},mapRight:{type:"t",value:1,texture:x}},vertexShader:"varying vec2 vUv;\nvoid main() {\nvUv = vec2( uv.x, 1.0 - uv.y );\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D mapLeft;\nuniform sampler2D mapRight;\nvarying vec2 vUv;\nvoid main() {\nvec4 colorL, colorR;\nvec2 uv = vUv;\ncolorL = texture2D( mapLeft, uv );\ncolorR = texture2D( mapRight, uv );\ngl_FragColor = vec4( colorL.g * 0.7 + colorL.b * 0.3, colorR.g, colorR.b, colorL.a + colorR.a ) * 1.1;\n}"});
-var y=new THREE.Scene;y.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);t.width=b;t.height=f;x.width=b;x.height=f};this.render=function(b,e){e.update(null,!0);if(u!==e.aspect||p!==e.near||v!==e.fov){u=e.aspect;p=e.near;v=e.fov;var E=e.projectionMatrix.clone(),D=125/30*0.5,F=D*p/125,G=p*Math.tan(v*Math.PI/360),N;k.n14=D;n.n14=-D;D=-G*u+F;N=G*u+F;E.n11=2*p/(N-D);E.n13=(N+D)/(N-D);h.projectionMatrix=E.clone();D=-G*u-F;N=G*u-F;E.n11=2*p/(N-D);E.n13=
-(N+D)/(N-D);m.projectionMatrix=E.clone()}h.matrix=e.matrixWorld.clone().multiplySelf(n);h.update(null,!0);h.position.copy(e.position);h.near=p;h.far=e.far;f.call(c,b,h,t,!0);m.matrix=e.matrixWorld.clone().multiplySelf(k);m.update(null,!0);m.position.copy(e.position);m.near=p;m.far=e.far;f.call(c,b,m,x,!0);f.call(c,y,w)}};
+var y=new THREE.Scene;y.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),_material));this.setSize=function(b,f){e.call(c,b,f);t.width=b;t.height=f;x.width=b;x.height=f};this.render=function(b,e){e.update(null,!0);if(u!==e.aspect||p!==e.near||v!==e.fov){u=e.aspect;p=e.near;v=e.fov;var D=e.projectionMatrix.clone(),E=125/30*0.5,F=E*p/125,G=p*Math.tan(v*Math.PI/360),N;k.n14=E;n.n14=-E;E=-G*u+F;N=G*u+F;D.n11=2*p/(N-E);D.n13=(N+E)/(N-E);h.projectionMatrix=D.clone();E=-G*u-F;N=G*u-F;D.n11=2*p/(N-E);D.n13=
+(N+E)/(N-E);m.projectionMatrix=D.clone()}h.matrix=e.matrixWorld.clone().multiplySelf(n);h.update(null,!0);h.position.copy(e.position);h.near=p;h.far=e.far;f.call(c,b,h,t,!0);m.matrix=e.matrixWorld.clone().multiplySelf(k);m.update(null,!0);m.position.copy(e.position);m.near=p;m.far=e.far;f.call(c,b,m,x,!0);f.call(c,y,w)}};
 if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(b){THREE.WebGLRenderer.call(this,b);this.autoClear=!1;var c=this,e=this.setSize,f=this.render,h,m,k=new THREE.Camera,n=new THREE.Camera;c.separation=10;if(b&&b.separation!==void 0)c.separation=b.separation;(new THREE.Camera(53,window.innerWidth/2/window.innerHeight,1,1E4)).position.z=-10;this.setSize=function(b,f){e.call(c,b,f);h=b/2;m=f};this.render=function(b,e){this.clear();k.fov=e.fov;k.aspect=0.5*e.aspect;k.near=e.near;k.far=e.far;
 k.updateProjectionMatrix();k.position.copy(e.position);k.target.position.copy(e.target.position);k.translateX(c.separation);n.projectionMatrix=k.projectionMatrix;n.position.copy(e.position);n.target.position.copy(e.target.position);n.translateX(-c.separation);this.setViewport(0,0,h,m);f.call(c,b,k);this.setViewport(h,0,h,m);f.call(c,b,n,!1)}};

+ 108 - 108
build/custom/ThreeWebGL.js

@@ -26,22 +26,22 @@ THREE.Matrix4=function(b,c,d,f,i,h,j,k,p,n,r,m,t,u,y,C){this.set(b!==void 0?b:1,
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(b,c,d,f,i,h,j,k,p,n,r,m,t,u,y,C){this.n11=b;this.n12=c;this.n13=d;this.n14=f;this.n21=i;this.n22=h;this.n23=j;this.n24=k;this.n31=p;this.n32=n;this.n33=r;this.n34=m;this.n41=t;this.n42=u;this.n43=y;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,
 c,d){var f=THREE.Matrix4.__v1,i=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;h.sub(b,c).normalize();if(h.length()===0)h.z=1;f.cross(d,h).normalize();f.length()===0&&(h.x+=1.0E-4,f.cross(d,h).normalize());i.cross(h,f).normalize();this.n11=f.x;this.n12=i.x;this.n13=h.x;this.n21=f.y;this.n22=i.y;this.n23=h.y;this.n31=f.z;this.n32=i.z;this.n33=h.z;return this},multiplyVector3:function(b){var c=b.x,d=b.y,f=b.z,i=1/(this.n41*c+this.n42*d+this.n43*f+this.n44);b.x=(this.n11*c+this.n12*d+this.n13*f+this.n14)*i;
 b.y=(this.n21*c+this.n22*d+this.n23*f+this.n24)*i;b.z=(this.n31*c+this.n32*d+this.n33*f+this.n34)*i;return b},multiplyVector4:function(b){var c=b.x,d=b.y,f=b.z,i=b.w;b.x=this.n11*c+this.n12*d+this.n13*f+this.n14*i;b.y=this.n21*c+this.n22*d+this.n23*f+this.n24*i;b.z=this.n31*c+this.n32*d+this.n33*f+this.n34*i;b.w=this.n41*c+this.n42*d+this.n43*f+this.n44*i;return b},rotateAxis:function(b){var c=b.x,d=b.y,f=b.z;b.x=c*this.n11+d*this.n12+f*this.n13;b.y=c*this.n21+d*this.n22+f*this.n23;b.z=c*this.n31+
-d*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var d=b.n11,f=b.n12,i=b.n13,h=b.n14,j=b.n21,k=b.n22,p=b.n23,n=b.n24,r=b.n31,m=b.n32,t=b.n33,u=b.n34,y=b.n41,C=b.n42,G=b.n43,D=b.n44,wa=c.n11,xa=
-c.n12,oa=c.n13,qa=c.n14,ha=c.n21,J=c.n22,w=c.n23,ia=c.n24,K=c.n31,ja=c.n32,Y=c.n33,ta=c.n34,Q=c.n41,M=c.n42,e=c.n43,Ba=c.n44;this.n11=d*wa+f*ha+i*K+h*Q;this.n12=d*xa+f*J+i*ja+h*M;this.n13=d*oa+f*w+i*Y+h*e;this.n14=d*qa+f*ia+i*ta+h*Ba;this.n21=j*wa+k*ha+p*K+n*Q;this.n22=j*xa+k*J+p*ja+n*M;this.n23=j*oa+k*w+p*Y+n*e;this.n24=j*qa+k*ia+p*ta+n*Ba;this.n31=r*wa+m*ha+t*K+u*Q;this.n32=r*xa+m*J+t*ja+u*M;this.n33=r*oa+m*w+t*Y+u*e;this.n34=r*qa+m*ia+t*ta+u*Ba;this.n41=y*wa+C*ha+G*K+D*Q;this.n42=y*xa+C*J+G*ja+
-D*M;this.n43=y*oa+C*w+G*Y+D*e;this.n44=y*qa+C*ia+G*ta+D*Ba;return this},multiplyToArray:function(b,c,d){this.multiply(b,c);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(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,c=this.n12,d=this.n13,f=this.n14,i=this.n21,h=this.n22,j=this.n23,k=this.n24,p=this.n31,n=this.n32,r=this.n33,m=this.n34,t=this.n41,u=this.n42,y=this.n43,C=this.n44;return f*j*n*t-d*k*n*t-f*h*r*t+c*k*r*t+d*h*m*t-c*j*m*t-f*j*p*u+d*k*p*u+f*i*r*u-b*k*r*u-d*i*m*u+b*j*m*u+f*h*p*y-c*k*p*y-f*i*n*y+b*k*n*y+c*i*m*
-y-b*h*m*y-d*h*p*C+c*j*p*C+d*i*n*C-b*j*n*C-c*i*r*C+b*h*r*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,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=
-this.n43;b[c+12]=this.n14;b[c+13]=this.n24;b[c+14]=this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,d){this.set(1,0,0,b,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(b,c,d){this.set(b,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=
-Math.cos(b),b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var d=Math.cos(c),f=Math.sin(c),i=1-d,h=b.x,j=b.y,k=b.z,p=i*h,n=i*j;this.set(p*h+d,p*j-f*k,p*k+f*j,0,p*j+f*k,n*j+d,n*k-f*h,0,p*k-f*j,n*k+f*h,i*k*k+d,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},
-getColumnX:function(){if(!this.columnX)this.columnX=new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,c){var d=b.x,f=b.y,i=b.z,h=Math.cos(d),d=Math.sin(d),j=Math.cos(f),
-f=Math.sin(f),k=Math.cos(i),i=Math.sin(i);switch(c){case "YXZ":var p=j*k,n=j*i,r=f*k,m=f*i;this.n11=p+m*d;this.n12=r*d-n;this.n13=h*f;this.n21=h*i;this.n22=h*k;this.n23=-d;this.n31=n*d-r;this.n32=m+p*d;this.n33=h*j;break;case "ZXY":p=j*k;n=j*i;r=f*k;m=f*i;this.n11=p-m*d;this.n12=-h*i;this.n13=r+n*d;this.n21=n+r*d;this.n22=h*k;this.n23=m-p*d;this.n31=-h*f;this.n32=d;this.n33=h*j;break;case "ZYX":p=h*k;n=h*i;r=d*k;m=d*i;this.n11=j*k;this.n12=r*f-n;this.n13=p*f+m;this.n21=j*i;this.n22=m*f+p;this.n23=
-n*f-r;this.n31=-f;this.n32=d*j;this.n33=h*j;break;case "YZX":p=h*j;n=h*f;r=d*j;m=d*f;this.n11=j*k;this.n12=m-p*i;this.n13=r*i+n;this.n21=i;this.n22=h*k;this.n23=-d*k;this.n31=-f*k;this.n32=n*i+r;this.n33=p-m*i;break;case "XZY":p=h*j;n=h*f;r=d*j;m=d*f;this.n11=j*k;this.n12=-i;this.n13=f*k;this.n21=p*i+m;this.n22=h*k;this.n23=n*i-r;this.n31=r*i-n;this.n32=d*k;this.n33=m*i+p;break;default:p=h*k,n=h*i,r=d*k,m=d*i,this.n11=j*k,this.n12=-j*i,this.n13=f,this.n21=n+r*f,this.n22=p-m*f,this.n23=-d*j,this.n31=
-m-p*f,this.n32=r+n*f,this.n33=h*j}return this},setRotationFromQuaternion:function(b){var c=b.x,d=b.y,f=b.z,i=b.w,h=c+c,j=d+d,k=f+f,b=c*h,p=c*j;c*=k;var n=d*j;d*=k;f*=k;h*=i;j*=i;i*=k;this.n11=1-(n+f);this.n12=p-i;this.n13=c+j;this.n21=p+i;this.n22=1-(b+f);this.n23=d-h;this.n31=c-j;this.n32=d+h;this.n33=1-(b+n);return this},scale:function(b){var c=b.x,d=b.y,b=b.z;this.n11*=c;this.n12*=d;this.n13*=b;this.n21*=c;this.n22*=d;this.n23*=b;this.n31*=c;this.n32*=d;this.n33*=b;this.n41*=c;this.n42*=d;this.n43*=
-b;return this},compose:function(b,c,d){var f=THREE.Matrix4.__m1,i=THREE.Matrix4.__m2;f.identity();f.setRotationFromQuaternion(c);i.setScale(d.x,d.y,d.z);this.multiply(f,i);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,d){var f=THREE.Matrix4.__v1,i=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;f.set(this.n11,this.n21,this.n31);i.set(this.n12,this.n22,this.n32);h.set(this.n13,this.n23,this.n33);b=b instanceof THREE.Vector3?b:new THREE.Vector3;c=c instanceof THREE.Quaternion?c:
-new THREE.Quaternion;d=d instanceof THREE.Vector3?d:new THREE.Vector3;d.x=f.length();d.y=i.length();d.z=h.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;f=THREE.Matrix4.__m1;f.copy(this);f.n11/=d.x;f.n21/=d.x;f.n31/=d.x;f.n12/=d.y;f.n22/=d.y;f.n32/=d.y;f.n13/=d.z;f.n23/=d.z;f.n33/=d.z;c.setFromRotationMatrix(f);return[b,c,d]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var d=1/c.x,f=1/c.y,i=1/c.z;this.n11=b.n11*d;this.n21=b.n21*d;this.n31=
-b.n31*d;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*i;this.n23=b.n23*i;this.n33=b.n33*i}};
+d*this.n32+f*this.n33;b.normalize();return b},crossVector:function(b){var c=new THREE.Vector4;c.x=this.n11*b.x+this.n12*b.y+this.n13*b.z+this.n14*b.w;c.y=this.n21*b.x+this.n22*b.y+this.n23*b.z+this.n24*b.w;c.z=this.n31*b.x+this.n32*b.y+this.n33*b.z+this.n34*b.w;c.w=b.w?this.n41*b.x+this.n42*b.y+this.n43*b.z+this.n44*b.w:1;return c},multiply:function(b,c){var d=b.n11,f=b.n12,i=b.n13,h=b.n14,j=b.n21,k=b.n22,p=b.n23,n=b.n24,r=b.n31,m=b.n32,t=b.n33,u=b.n34,y=b.n41,C=b.n42,G=b.n43,D=b.n44,xa=c.n11,ya=
+c.n12,oa=c.n13,qa=c.n14,ha=c.n21,J=c.n22,w=c.n23,R=c.n24,K=c.n31,ia=c.n32,T=c.n33,ua=c.n34,Q=c.n41,M=c.n42,e=c.n43,Ca=c.n44;this.n11=d*xa+f*ha+i*K+h*Q;this.n12=d*ya+f*J+i*ia+h*M;this.n13=d*oa+f*w+i*T+h*e;this.n14=d*qa+f*R+i*ua+h*Ca;this.n21=j*xa+k*ha+p*K+n*Q;this.n22=j*ya+k*J+p*ia+n*M;this.n23=j*oa+k*w+p*T+n*e;this.n24=j*qa+k*R+p*ua+n*Ca;this.n31=r*xa+m*ha+t*K+u*Q;this.n32=r*ya+m*J+t*ia+u*M;this.n33=r*oa+m*w+t*T+u*e;this.n34=r*qa+m*R+t*ua+u*Ca;this.n41=y*xa+C*ha+G*K+D*Q;this.n42=y*ya+C*J+G*ia+D*M;
+this.n43=y*oa+C*w+G*T+D*e;this.n44=y*qa+C*R+G*ua+D*Ca;return this},multiplyToArray:function(b,c,d){this.multiply(b,c);d[0]=this.n11;d[1]=this.n21;d[2]=this.n31;d[3]=this.n41;d[4]=this.n12;d[5]=this.n22;d[6]=this.n32;d[7]=this.n42;d[8]=this.n13;d[9]=this.n23;d[10]=this.n33;d[11]=this.n43;d[12]=this.n14;d[13]=this.n24;d[14]=this.n34;d[15]=this.n44;return this},multiplySelf:function(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,c=this.n12,d=this.n13,f=this.n14,i=this.n21,h=this.n22,j=this.n23,k=this.n24,p=this.n31,n=this.n32,r=this.n33,m=this.n34,t=this.n41,u=this.n42,y=this.n43,C=this.n44;return f*j*n*t-d*k*n*t-f*h*r*t+c*k*r*t+d*h*m*t-c*j*m*t-f*j*p*u+d*k*p*u+f*i*r*u-b*k*r*u-d*i*m*u+b*j*m*u+f*h*p*y-c*k*p*y-f*i*n*y+b*k*n*y+c*i*m*y-b*h*m*y-
+d*h*p*C+c*j*p*C+d*i*n*C-b*j*n*C-c*i*r*C+b*h*r*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,c){b[c]=this.n11;b[c+1]=this.n21;b[c+2]=this.n31;b[c+3]=this.n41;b[c+4]=this.n12;b[c+5]=this.n22;b[c+6]=this.n32;b[c+7]=this.n42;b[c+8]=this.n13;b[c+9]=this.n23;b[c+10]=this.n33;b[c+11]=this.n43;b[c+12]=
+this.n14;b[c+13]=this.n24;b[c+14]=this.n34;b[c+15]=this.n44;return b},setTranslation:function(b,c,d){this.set(1,0,0,b,0,1,0,c,0,0,1,d,0,0,0,1);return this},setScale:function(b,c,d){this.set(b,0,0,0,0,c,0,0,0,0,d,0,0,0,0,1);return this},setRotationX:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(1,0,0,0,0,c,-b,0,0,b,c,0,0,0,0,1);return this},setRotationY:function(b){var c=Math.cos(b),b=Math.sin(b);this.set(c,0,b,0,0,1,0,0,-b,0,c,0,0,0,0,1);return this},setRotationZ:function(b){var c=Math.cos(b),
+b=Math.sin(b);this.set(c,-b,0,0,b,c,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(b,c){var d=Math.cos(c),f=Math.sin(c),i=1-d,h=b.x,j=b.y,k=b.z,p=i*h,n=i*j;this.set(p*h+d,p*j-f*k,p*k+f*j,0,p*j+f*k,n*j+d,n*k-f*h,0,p*k-f*j,n*k+f*h,i*k*k+d,0,0,0,0,1);return this},setPosition:function(b){this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},getPosition:function(){if(!this.position)this.position=new THREE.Vector3;this.position.set(this.n14,this.n24,this.n34);return this.position},getColumnX:function(){if(!this.columnX)this.columnX=
+new THREE.Vector3;this.columnX.set(this.n11,this.n21,this.n31);return this.columnX},getColumnY:function(){if(!this.columnY)this.columnY=new THREE.Vector3;this.columnY.set(this.n12,this.n22,this.n32);return this.columnY},getColumnZ:function(){if(!this.columnZ)this.columnZ=new THREE.Vector3;this.columnZ.set(this.n13,this.n23,this.n33);return this.columnZ},setRotationFromEuler:function(b,c){var d=b.x,f=b.y,i=b.z,h=Math.cos(d),d=Math.sin(d),j=Math.cos(f),f=Math.sin(f),k=Math.cos(i),i=Math.sin(i);switch(c){case "YXZ":var p=
+j*k,n=j*i,r=f*k,m=f*i;this.n11=p+m*d;this.n12=r*d-n;this.n13=h*f;this.n21=h*i;this.n22=h*k;this.n23=-d;this.n31=n*d-r;this.n32=m+p*d;this.n33=h*j;break;case "ZXY":p=j*k;n=j*i;r=f*k;m=f*i;this.n11=p-m*d;this.n12=-h*i;this.n13=r+n*d;this.n21=n+r*d;this.n22=h*k;this.n23=m-p*d;this.n31=-h*f;this.n32=d;this.n33=h*j;break;case "ZYX":p=h*k;n=h*i;r=d*k;m=d*i;this.n11=j*k;this.n12=r*f-n;this.n13=p*f+m;this.n21=j*i;this.n22=m*f+p;this.n23=n*f-r;this.n31=-f;this.n32=d*j;this.n33=h*j;break;case "YZX":p=h*j;n=
+h*f;r=d*j;m=d*f;this.n11=j*k;this.n12=m-p*i;this.n13=r*i+n;this.n21=i;this.n22=h*k;this.n23=-d*k;this.n31=-f*k;this.n32=n*i+r;this.n33=p-m*i;break;case "XZY":p=h*j;n=h*f;r=d*j;m=d*f;this.n11=j*k;this.n12=-i;this.n13=f*k;this.n21=p*i+m;this.n22=h*k;this.n23=n*i-r;this.n31=r*i-n;this.n32=d*k;this.n33=m*i+p;break;default:p=h*k,n=h*i,r=d*k,m=d*i,this.n11=j*k,this.n12=-j*i,this.n13=f,this.n21=n+r*f,this.n22=p-m*f,this.n23=-d*j,this.n31=m-p*f,this.n32=r+n*f,this.n33=h*j}return this},setRotationFromQuaternion:function(b){var c=
+b.x,d=b.y,f=b.z,i=b.w,h=c+c,j=d+d,k=f+f,b=c*h,p=c*j;c*=k;var n=d*j;d*=k;f*=k;h*=i;j*=i;i*=k;this.n11=1-(n+f);this.n12=p-i;this.n13=c+j;this.n21=p+i;this.n22=1-(b+f);this.n23=d-h;this.n31=c-j;this.n32=d+h;this.n33=1-(b+n);return this},scale:function(b){var c=b.x,d=b.y,b=b.z;this.n11*=c;this.n12*=d;this.n13*=b;this.n21*=c;this.n22*=d;this.n23*=b;this.n31*=c;this.n32*=d;this.n33*=b;this.n41*=c;this.n42*=d;this.n43*=b;return this},compose:function(b,c,d){var f=THREE.Matrix4.__m1,i=THREE.Matrix4.__m2;
+f.identity();f.setRotationFromQuaternion(c);i.setScale(d.x,d.y,d.z);this.multiply(f,i);this.n14=b.x;this.n24=b.y;this.n34=b.z;return this},decompose:function(b,c,d){var f=THREE.Matrix4.__v1,i=THREE.Matrix4.__v2,h=THREE.Matrix4.__v3;f.set(this.n11,this.n21,this.n31);i.set(this.n12,this.n22,this.n32);h.set(this.n13,this.n23,this.n33);b=b instanceof THREE.Vector3?b:new THREE.Vector3;c=c instanceof THREE.Quaternion?c:new THREE.Quaternion;d=d instanceof THREE.Vector3?d:new THREE.Vector3;d.x=f.length();
+d.y=i.length();d.z=h.length();b.x=this.n14;b.y=this.n24;b.z=this.n34;f=THREE.Matrix4.__m1;f.copy(this);f.n11/=d.x;f.n21/=d.x;f.n31/=d.x;f.n12/=d.y;f.n22/=d.y;f.n32/=d.y;f.n13/=d.z;f.n23/=d.z;f.n33/=d.z;c.setFromRotationMatrix(f);return[b,c,d]},extractPosition:function(b){this.n14=b.n14;this.n24=b.n24;this.n34=b.n34},extractRotation:function(b,c){var d=1/c.x,f=1/c.y,i=1/c.z;this.n11=b.n11*d;this.n21=b.n21*d;this.n31=b.n31*d;this.n12=b.n12*f;this.n22=b.n22*f;this.n32=b.n32*f;this.n13=b.n13*i;this.n23=
+b.n23*i;this.n33=b.n33*i}};
 THREE.Matrix4.makeInvert=function(b,c){var d=b.n11,f=b.n12,i=b.n13,h=b.n14,j=b.n21,k=b.n22,p=b.n23,n=b.n24,r=b.n31,m=b.n32,t=b.n33,u=b.n34,y=b.n41,C=b.n42,G=b.n43,D=b.n44;c===void 0&&(c=new THREE.Matrix4);c.n11=p*u*C-n*t*C+n*m*G-k*u*G-p*m*D+k*t*D;c.n12=h*t*C-i*u*C-h*m*G+f*u*G+i*m*D-f*t*D;c.n13=i*n*C-h*p*C+h*k*G-f*n*G-i*k*D+f*p*D;c.n14=h*p*m-i*n*m-h*k*t+f*n*t+i*k*u-f*p*u;c.n21=n*t*y-p*u*y-n*r*G+j*u*G+p*r*D-j*t*D;c.n22=i*u*y-h*t*y+h*r*G-d*u*G-i*r*D+d*t*D;c.n23=h*p*y-i*n*y-h*j*G+d*n*G+i*j*D-d*p*D;c.n24=
 i*n*r-h*p*r+h*j*t-d*n*t-i*j*u+d*p*u;c.n31=k*u*y-n*m*y+n*r*C-j*u*C-k*r*D+j*m*D;c.n32=h*m*y-f*u*y-h*r*C+d*u*C+f*r*D-d*m*D;c.n33=i*n*y-h*k*y+h*j*C-d*n*C-f*j*D+d*k*D;c.n34=h*k*r-f*n*r-h*j*m+d*n*m+f*j*u-d*k*u;c.n41=p*m*y-k*t*y-p*r*C+j*t*C+k*r*G-j*m*G;c.n42=f*t*y-i*m*y+i*r*C-d*t*C-f*r*G+d*m*G;c.n43=i*k*y-f*p*y-i*j*C+d*p*C+f*j*G-d*k*G;c.n44=f*p*r-i*k*r+i*j*m-d*p*m-f*j*t+d*k*t;c.multiplyScalar(1/b.determinant());return c};
 THREE.Matrix4.makeInvert3x3=function(b){var c=b.m33,d=c.m,f=b.n33*b.n22-b.n32*b.n23,i=-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,p=-b.n32*b.n11+b.n31*b.n12,n=b.n23*b.n12-b.n22*b.n13,r=-b.n23*b.n11+b.n21*b.n13,m=b.n22*b.n11-b.n21*b.n12,b=b.n11*f+b.n21*j+b.n31*n;b==0&&console.error("THREE.Matrix4.makeInvert3x3: Matrix not invertible.");b=1/b;d[0]=b*f;d[1]=b*i;d[2]=b*h;d[3]=b*j;d[4]=b*k;d[5]=b*p;d[6]=b*n;d[7]=b*r;d[8]=b*m;return c};
@@ -54,16 +54,16 @@ THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(b,c){thi
 b)return i;if(c&&(i=i.getChildByName(b,c),i!==void 0))return i}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);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,c,d){this.matrixAutoUpdate&&
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||c)b?this.matrixWorld.multiply(b,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixRotationWorld.extractRotation(this.matrixWorld,this.scale),this.matrixWorldNeedsUpdate=!1,c=!0;for(var b=0,f=this.children.length;b<f;b++)this.children[b].update(this.matrixWorld,c,d)},addChild:function(b){console.warn("DEPRECATED: Object3D.addChild() is now Object3D.add().");this.add(b)},removeChild:function(b){console.warn("DEPRECATED: Object3D.removeChild() is now Object3D.remove().");
 this.remove(b)}};THREE.Object3DCount=0;
-THREE.Projector=function(){function b(){var b=p[k]=p[k]||new THREE.RenderableVertex;k++;return b}function c(b,c){return c.z-b.z}function d(b,c){var d=0,e=1,f=b.z+b.w,i=c.z+c.w,h=-b.z+b.w,j=-c.z+c.w;return f>=0&&i>=0&&h>=0&&j>=0?!0:f<0&&i<0||h<0&&j<0?!1:(f<0?d=Math.max(d,f/(f-i)):i<0&&(e=Math.min(e,f/(f-i))),h<0?d=Math.max(d,h/(h-j)):j<0&&(e=Math.min(e,h/(h-j))),e<d?!1:(b.lerpSelf(c,d),c.lerpSelf(b,1-e),!0))}var f,i,h=[],j,k,p=[],n,r,m=[],t,u=[],y,C,G=[],D,wa,xa=[],oa=[],qa=[],ha=new THREE.Vector4,
-J=new THREE.Vector4,w=new THREE.Matrix4,ia=new THREE.Matrix4,K=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ja=new THREE.Vector4,Y=new THREE.Vector4;this.projectVector=function(b,c){w.multiply(c.projectionMatrix,c.matrixWorldInverse);w.multiplyVector3(b);return b};this.unprojectVector=function(b,c){w.multiply(c.matrixWorld,THREE.Matrix4.makeInvert(c.projectionMatrix));w.multiplyVector3(b);return b};this.projectObjects=function(b,d,j){var e,
+THREE.Projector=function(){function b(){var b=p[k]=p[k]||new THREE.RenderableVertex;k++;return b}function c(b,c){return c.z-b.z}function d(b,c){var d=0,e=1,f=b.z+b.w,i=c.z+c.w,h=-b.z+b.w,j=-c.z+c.w;return f>=0&&i>=0&&h>=0&&j>=0?!0:f<0&&i<0||h<0&&j<0?!1:(f<0?d=Math.max(d,f/(f-i)):i<0&&(e=Math.min(e,f/(f-i))),h<0?d=Math.max(d,h/(h-j)):j<0&&(e=Math.min(e,h/(h-j))),e<d?!1:(b.lerpSelf(c,d),c.lerpSelf(b,1-e),!0))}var f,i,h=[],j,k,p=[],n,r,m=[],t,u=[],y,C,G=[],D,xa,ya=[],oa=[],qa=[],ha=new THREE.Vector4,
+J=new THREE.Vector4,w=new THREE.Matrix4,R=new THREE.Matrix4,K=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],ia=new THREE.Vector4,T=new THREE.Vector4;this.projectVector=function(b,c){w.multiply(c.projectionMatrix,c.matrixWorldInverse);w.multiplyVector3(b);return b};this.unprojectVector=function(b,c){w.multiply(c.matrixWorld,THREE.Matrix4.makeInvert(c.projectionMatrix));w.multiplyVector3(b);return b};this.projectObjects=function(b,d,j){var e,
 k;i=oa.length=0;e=b.objects;b=0;for(d=e.length;b<d;b++){k=e[b];var n;if(!(n=!k.visible))if(n=k instanceof THREE.Mesh)if(n=k.frustumCulled){a:{n=void 0;for(var p=k.matrixWorld,r=-k.geometry.boundingSphere.radius*Math.max(k.scale.x,Math.max(k.scale.y,k.scale.z)),m=0;m<6;m++)if(n=K[m].x*p.n14+K[m].y*p.n24+K[m].z*p.n34+K[m].w,n<=r){n=!1;break a}n=!0}n=!n}if(!n)n=h[i]=h[i]||new THREE.RenderableObject,i++,f=n,ha.copy(k.position),w.multiplyVector3(ha),f.object=k,f.z=ha.z,oa.push(f)}j&&oa.sort(c);return oa};
-this.projectScene=function(f,i,h){var e=i.near,oa=i.far,ha,ua,T,Z,E,W,L,V,va,P,ra,Fa,ya,Ea,R,za,Ca;wa=C=t=r=qa.length=0;i.matrixAutoUpdate&&i.update(void 0,!0);f.update(void 0,!1,i);w.multiply(i.projectionMatrix,i.matrixWorldInverse);K[0].set(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);K[1].set(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);K[2].set(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);K[3].set(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);K[4].set(w.n41-w.n31,w.n42-w.n32,w.n43-
-w.n33,w.n44-w.n34);K[5].set(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);for(ha=0;ha<6;ha++)va=K[ha],va.divideScalar(Math.sqrt(va.x*va.x+va.y*va.y+va.z*va.z));va=this.projectObjects(f,i,!0);f=0;for(ha=va.length;f<ha;f++)if(P=va[f].object,P.visible)if(ra=P.matrixWorld,Fa=P.matrixRotationWorld,ya=P.materials,Ea=P.overdraw,k=0,P instanceof THREE.Mesh){R=P.geometry;Z=R.vertices;za=R.faces;R=R.faceVertexUvs;ua=0;for(T=Z.length;ua<T;ua++)j=b(),j.positionWorld.copy(Z[ua].position),ra.multiplyVector3(j.positionWorld),
-j.positionScreen.copy(j.positionWorld),w.multiplyVector4(j.positionScreen),j.positionScreen.x/=j.positionScreen.w,j.positionScreen.y/=j.positionScreen.w,j.visible=j.positionScreen.z>e&&j.positionScreen.z<oa;Z=0;for(ua=za.length;Z<ua;Z++){T=za[Z];if(T instanceof THREE.Face3)if(E=p[T.a],W=p[T.b],L=p[T.c],E.visible&&W.visible&&L.visible&&(P.doubleSided||P.flipSided!=(L.positionScreen.x-E.positionScreen.x)*(W.positionScreen.y-E.positionScreen.y)-(L.positionScreen.y-E.positionScreen.y)*(W.positionScreen.x-
-E.positionScreen.x)<0))V=m[r]=m[r]||new THREE.RenderableFace3,r++,n=V,n.v1.copy(E),n.v2.copy(W),n.v3.copy(L);else continue;else if(T instanceof THREE.Face4)if(E=p[T.a],W=p[T.b],L=p[T.c],V=p[T.d],E.visible&&W.visible&&L.visible&&V.visible&&(P.doubleSided||P.flipSided!=((V.positionScreen.x-E.positionScreen.x)*(W.positionScreen.y-E.positionScreen.y)-(V.positionScreen.y-E.positionScreen.y)*(W.positionScreen.x-E.positionScreen.x)<0||(W.positionScreen.x-L.positionScreen.x)*(V.positionScreen.y-L.positionScreen.y)-
-(W.positionScreen.y-L.positionScreen.y)*(V.positionScreen.x-L.positionScreen.x)<0)))Ca=u[t]=u[t]||new THREE.RenderableFace4,t++,n=Ca,n.v1.copy(E),n.v2.copy(W),n.v3.copy(L),n.v4.copy(V);else continue;n.normalWorld.copy(T.normal);Fa.multiplyVector3(n.normalWorld);n.centroidWorld.copy(T.centroid);ra.multiplyVector3(n.centroidWorld);n.centroidScreen.copy(n.centroidWorld);w.multiplyVector3(n.centroidScreen);L=T.vertexNormals;E=0;for(W=L.length;E<W;E++)V=n.vertexNormalsWorld[E],V.copy(L[E]),Fa.multiplyVector3(V);
-E=0;for(W=R.length;E<W;E++)if(Ca=R[E][Z]){L=0;for(V=Ca.length;L<V;L++)n.uvs[E][L]=Ca[L]}n.meshMaterials=ya;n.faceMaterials=T.materials;n.overdraw=Ea;n.z=n.centroidScreen.z;qa.push(n)}}else if(P instanceof THREE.Line){ia.multiply(w,ra);Z=P.geometry.vertices;E=b();E.positionScreen.copy(Z[0].position);ia.multiplyVector4(E.positionScreen);ua=1;for(T=Z.length;ua<T;ua++)if(E=b(),E.positionScreen.copy(Z[ua].position),ia.multiplyVector4(E.positionScreen),W=p[k-2],ja.copy(E.positionScreen),Y.copy(W.positionScreen),
-d(ja,Y))ja.multiplyScalar(1/ja.w),Y.multiplyScalar(1/Y.w),ra=G[C]=G[C]||new THREE.RenderableLine,C++,y=ra,y.v1.positionScreen.copy(ja),y.v2.positionScreen.copy(Y),y.z=Math.max(ja.z,Y.z),y.materials=P.materials,qa.push(y)}else if(P instanceof THREE.Particle&&(J.set(P.matrixWorld.n14,P.matrixWorld.n24,P.matrixWorld.n34,1),w.multiplyVector4(J),J.z/=J.w,J.z>0&&J.z<1))ra=xa[wa]=xa[wa]||new THREE.RenderableParticle,wa++,D=ra,D.x=J.x/J.w,D.y=J.y/J.w,D.z=J.z,D.rotation=P.rotation.z,D.scale.x=P.scale.x*Math.abs(D.x-
+this.projectScene=function(f,i,h){var e=i.near,oa=i.far,ha,pa,V,ra,E,W,L,ja,va,P,za,Aa,Ha,Ea,ta,Z,wa;xa=C=t=r=qa.length=0;i.matrixAutoUpdate&&i.update(void 0,!0);f.update(void 0,!1,i);w.multiply(i.projectionMatrix,i.matrixWorldInverse);K[0].set(w.n41-w.n11,w.n42-w.n12,w.n43-w.n13,w.n44-w.n14);K[1].set(w.n41+w.n11,w.n42+w.n12,w.n43+w.n13,w.n44+w.n14);K[2].set(w.n41+w.n21,w.n42+w.n22,w.n43+w.n23,w.n44+w.n24);K[3].set(w.n41-w.n21,w.n42-w.n22,w.n43-w.n23,w.n44-w.n24);K[4].set(w.n41-w.n31,w.n42-w.n32,
+w.n43-w.n33,w.n44-w.n34);K[5].set(w.n41+w.n31,w.n42+w.n32,w.n43+w.n33,w.n44+w.n34);for(ha=0;ha<6;ha++)va=K[ha],va.divideScalar(Math.sqrt(va.x*va.x+va.y*va.y+va.z*va.z));va=this.projectObjects(f,i,!0);f=0;for(ha=va.length;f<ha;f++)if(P=va[f].object,P.visible)if(za=P.matrixWorld,Aa=P.matrixRotationWorld,Ha=P.materials,Ea=P.overdraw,k=0,P instanceof THREE.Mesh){ta=P.geometry;ra=ta.vertices;Z=ta.faces;ta=ta.faceVertexUvs;pa=0;for(V=ra.length;pa<V;pa++)j=b(),j.positionWorld.copy(ra[pa].position),za.multiplyVector3(j.positionWorld),
+j.positionScreen.copy(j.positionWorld),w.multiplyVector4(j.positionScreen),j.positionScreen.x/=j.positionScreen.w,j.positionScreen.y/=j.positionScreen.w,j.visible=j.positionScreen.z>e&&j.positionScreen.z<oa;ra=0;for(pa=Z.length;ra<pa;ra++){V=Z[ra];if(V instanceof THREE.Face3)if(E=p[V.a],W=p[V.b],L=p[V.c],E.visible&&W.visible&&L.visible&&(P.doubleSided||P.flipSided!=(L.positionScreen.x-E.positionScreen.x)*(W.positionScreen.y-E.positionScreen.y)-(L.positionScreen.y-E.positionScreen.y)*(W.positionScreen.x-
+E.positionScreen.x)<0))ja=m[r]=m[r]||new THREE.RenderableFace3,r++,n=ja,n.v1.copy(E),n.v2.copy(W),n.v3.copy(L);else continue;else if(V instanceof THREE.Face4)if(E=p[V.a],W=p[V.b],L=p[V.c],ja=p[V.d],E.visible&&W.visible&&L.visible&&ja.visible&&(P.doubleSided||P.flipSided!=((ja.positionScreen.x-E.positionScreen.x)*(W.positionScreen.y-E.positionScreen.y)-(ja.positionScreen.y-E.positionScreen.y)*(W.positionScreen.x-E.positionScreen.x)<0||(W.positionScreen.x-L.positionScreen.x)*(ja.positionScreen.y-L.positionScreen.y)-
+(W.positionScreen.y-L.positionScreen.y)*(ja.positionScreen.x-L.positionScreen.x)<0)))wa=u[t]=u[t]||new THREE.RenderableFace4,t++,n=wa,n.v1.copy(E),n.v2.copy(W),n.v3.copy(L),n.v4.copy(ja);else continue;n.normalWorld.copy(V.normal);Aa.multiplyVector3(n.normalWorld);n.centroidWorld.copy(V.centroid);za.multiplyVector3(n.centroidWorld);n.centroidScreen.copy(n.centroidWorld);w.multiplyVector3(n.centroidScreen);L=V.vertexNormals;E=0;for(W=L.length;E<W;E++)ja=n.vertexNormalsWorld[E],ja.copy(L[E]),Aa.multiplyVector3(ja);
+E=0;for(W=ta.length;E<W;E++)if(wa=ta[E][ra]){L=0;for(ja=wa.length;L<ja;L++)n.uvs[E][L]=wa[L]}n.meshMaterials=Ha;n.faceMaterials=V.materials;n.overdraw=Ea;n.z=n.centroidScreen.z;qa.push(n)}}else if(P instanceof THREE.Line){R.multiply(w,za);ra=P.geometry.vertices;E=b();E.positionScreen.copy(ra[0].position);R.multiplyVector4(E.positionScreen);pa=1;for(V=ra.length;pa<V;pa++)if(E=b(),E.positionScreen.copy(ra[pa].position),R.multiplyVector4(E.positionScreen),W=p[k-2],ia.copy(E.positionScreen),T.copy(W.positionScreen),
+d(ia,T))ia.multiplyScalar(1/ia.w),T.multiplyScalar(1/T.w),za=G[C]=G[C]||new THREE.RenderableLine,C++,y=za,y.v1.positionScreen.copy(ia),y.v2.positionScreen.copy(T),y.z=Math.max(ia.z,T.z),y.materials=P.materials,qa.push(y)}else if(P instanceof THREE.Particle&&(J.set(P.matrixWorld.n14,P.matrixWorld.n24,P.matrixWorld.n34,1),w.multiplyVector4(J),J.z/=J.w,J.z>0&&J.z<1))za=ya[xa]=ya[xa]||new THREE.RenderableParticle,xa++,D=za,D.x=J.x/J.w,D.y=J.y/J.w,D.z=J.z,D.rotation=P.rotation.z,D.scale.x=P.scale.x*Math.abs(D.x-
 (J.x+i.projectionMatrix.n11)/(J.w+i.projectionMatrix.n14)),D.scale.y=P.scale.y*Math.abs(D.y-(J.y+i.projectionMatrix.n22)/(J.w+i.projectionMatrix.n24)),D.materials=P.materials,qa.push(D);h&&qa.sort(c);return qa}};THREE.Quaternion=function(b,c,d,f){this.set(b||0,c||0,d||0,f!==void 0?f:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(b,c,d,f){this.x=b;this.y=c;this.z=d;this.w=f;return this},copy:function(b){this.x=b.x;this.y=b.y;this.z=b.z;this.w=b.w;return this},setFromEuler:function(b){var c=0.5*Math.PI/360,d=b.x*c,f=b.y*c,i=b.z*c,b=Math.cos(f),f=Math.sin(f),c=Math.cos(-i),i=Math.sin(-i),h=Math.cos(d),d=Math.sin(d),j=b*c,k=f*i;this.w=j*h-k*d;this.x=j*d+k*h;this.y=f*c*h+b*i*d;this.z=b*i*h-f*c*d;return this},setFromAxisAngle:function(b,c){var d=c/2,f=Math.sin(d);
 this.x=b.x*f;this.y=b.y*f;this.z=b.z*f;this.w=Math.cos(d);return this},setFromRotationMatrix:function(b){var c=Math.pow(b.determinant(),1/3);this.w=Math.sqrt(Math.max(0,c+b.n11+b.n22+b.n33))/2;this.x=Math.sqrt(Math.max(0,c+b.n11-b.n22-b.n33))/2;this.y=Math.sqrt(Math.max(0,c-b.n11+b.n22-b.n33))/2;this.z=Math.sqrt(Math.max(0,c-b.n11-b.n22+b.n33))/2;this.x=b.n32-b.n23<0?-Math.abs(this.x):Math.abs(this.x);this.y=b.n13-b.n31<0?-Math.abs(this.y):Math.abs(this.y);this.z=b.n21-b.n12<0?-Math.abs(this.z):Math.abs(this.z);
@@ -79,9 +79,9 @@ c;b++)d=this.faces[b],d.centroid.set(0,0,0),d instanceof THREE.Face3?(d.centroid
 d,f,i,h,j,k=new THREE.Vector3,p=new THREE.Vector3;f=0;for(i=this.faces.length;f<i;f++){h=this.faces[f];if(b&&h.vertexNormals.length){k.set(0,0,0);c=0;for(d=h.vertexNormals.length;c<d;c++)k.addSelf(h.vertexNormals[c]);k.divideScalar(3)}else c=this.vertices[h.a],d=this.vertices[h.b],j=this.vertices[h.c],k.sub(j.position,d.position),p.sub(c.position,d.position),k.crossSelf(p);k.isZero()||k.normalize();h.normal.copy(k)}},computeVertexNormals:function(){var b,c,d,f;if(this.__tmpVertices==void 0){f=this.__tmpVertices=
 Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)f[b]=new THREE.Vector3;b=0;for(c=this.faces.length;b<c;b++)if(d=this.faces[b],d instanceof THREE.Face3)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(d instanceof THREE.Face4)d.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{f=this.__tmpVertices;b=0;for(c=this.vertices.length;b<c;b++)f[b].set(0,0,0)}b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d instanceof
 THREE.Face3?(f[d.a].addSelf(d.normal),f[d.b].addSelf(d.normal),f[d.c].addSelf(d.normal)):d instanceof THREE.Face4&&(f[d.a].addSelf(d.normal),f[d.b].addSelf(d.normal),f[d.c].addSelf(d.normal),f[d.d].addSelf(d.normal));b=0;for(c=this.vertices.length;b<c;b++)f[b].normalize();b=0;for(c=this.faces.length;b<c;b++)d=this.faces[b],d instanceof THREE.Face3?(d.vertexNormals[0].copy(f[d.a]),d.vertexNormals[1].copy(f[d.b]),d.vertexNormals[2].copy(f[d.c])):d instanceof THREE.Face4&&(d.vertexNormals[0].copy(f[d.a]),
-d.vertexNormals[1].copy(f[d.b]),d.vertexNormals[2].copy(f[d.c]),d.vertexNormals[3].copy(f[d.d]))},computeTangents:function(){function b(b,e,c,d,f,i,h){k=b.vertices[e].position;p=b.vertices[c].position;n=b.vertices[d].position;r=j[f];m=j[i];t=j[h];u=p.x-k.x;y=n.x-k.x;C=p.y-k.y;G=n.y-k.y;D=p.z-k.z;wa=n.z-k.z;xa=m.u-r.u;oa=t.u-r.u;qa=m.v-r.v;ha=t.v-r.v;J=1/(xa*ha-oa*qa);ja.set((ha*u-qa*y)*J,(ha*C-qa*G)*J,(ha*D-qa*wa)*J);Y.set((xa*y-oa*u)*J,(xa*G-oa*C)*J,(xa*wa-oa*D)*J);ia[e].addSelf(ja);ia[c].addSelf(ja);
-ia[d].addSelf(ja);K[e].addSelf(Y);K[c].addSelf(Y);K[d].addSelf(Y)}var c,d,f,i,h,j,k,p,n,r,m,t,u,y,C,G,D,wa,xa,oa,qa,ha,J,w,ia=[],K=[],ja=new THREE.Vector3,Y=new THREE.Vector3,ta=new THREE.Vector3,Q=new THREE.Vector3,M=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++)ia[c]=new THREE.Vector3,K[c]=new THREE.Vector3;c=0;for(d=this.faces.length;c<d;c++)h=this.faces[c],j=this.faceVertexUvs[0][c],h instanceof THREE.Face3?b(this,h.a,h.b,h.c,0,1,2):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 e=["a","b","c","d"];c=0;for(d=this.faces.length;c<d;c++){h=this.faces[c];for(f=0;f<h.vertexNormals.length;f++)M.copy(h.vertexNormals[f]),i=h[e[f]],w=ia[i],ta.copy(w),ta.subSelf(M.multiplyScalar(M.dot(w))).normalize(),Q.cross(h.vertexNormals[f],w),i=Q.dot(K[i]),i=i<0?-1:1,h.vertexTangents[f]=new THREE.Vector4(ta.x,ta.y,ta.z,i)}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],
+d.vertexNormals[1].copy(f[d.b]),d.vertexNormals[2].copy(f[d.c]),d.vertexNormals[3].copy(f[d.d]))},computeTangents:function(){function b(b,e,c,d,f,i,h){k=b.vertices[e].position;p=b.vertices[c].position;n=b.vertices[d].position;r=j[f];m=j[i];t=j[h];u=p.x-k.x;y=n.x-k.x;C=p.y-k.y;G=n.y-k.y;D=p.z-k.z;xa=n.z-k.z;ya=m.u-r.u;oa=t.u-r.u;qa=m.v-r.v;ha=t.v-r.v;J=1/(ya*ha-oa*qa);ia.set((ha*u-qa*y)*J,(ha*C-qa*G)*J,(ha*D-qa*xa)*J);T.set((ya*y-oa*u)*J,(ya*G-oa*C)*J,(ya*xa-oa*D)*J);R[e].addSelf(ia);R[c].addSelf(ia);
+R[d].addSelf(ia);K[e].addSelf(T);K[c].addSelf(T);K[d].addSelf(T)}var c,d,f,i,h,j,k,p,n,r,m,t,u,y,C,G,D,xa,ya,oa,qa,ha,J,w,R=[],K=[],ia=new THREE.Vector3,T=new THREE.Vector3,ua=new THREE.Vector3,Q=new THREE.Vector3,M=new THREE.Vector3;c=0;for(d=this.vertices.length;c<d;c++)R[c]=new THREE.Vector3,K[c]=new THREE.Vector3;c=0;for(d=this.faces.length;c<d;c++)h=this.faces[c],j=this.faceVertexUvs[0][c],h instanceof THREE.Face3?b(this,h.a,h.b,h.c,0,1,2):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 e=["a","b","c","d"];c=0;for(d=this.faces.length;c<d;c++){h=this.faces[c];for(f=0;f<h.vertexNormals.length;f++)M.copy(h.vertexNormals[f]),i=h[e[f]],w=R[i],ua.copy(w),ua.subSelf(M.multiplyScalar(M.dot(w))).normalize(),Q.cross(h.vertexNormals[f],w),i=Q.dot(K[i]),i=i<0?-1:1,h.vertexTangents[f]=new THREE.Vector4(ua.x,ua.y,ua.z,i)}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 c=1,d=this.vertices.length;c<d;c++){b=this.vertices[c];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=0,c=0,d=this.vertices.length;c<d;c++)b=Math.max(b,this.vertices[c].position.length());this.boundingSphere={radius:b}},computeEdgeFaces:function(){function b(b,c){return Math.min(b,c)+"_"+Math.max(b,c)}function c(b,c,d){b[c]===void 0?(b[c]={set:{},array:[]},b[c].set[d]=1,b[c].array.push(d)):b[c].set[d]===void 0&&(b[c].set[d]=
 1,b[c].array.push(d))}var d,f,i,h,j,k={};d=0;for(f=this.faces.length;d<f;d++)j=this.faces[d],j instanceof THREE.Face3?(i=b(j.a,j.b),c(k,i,d),i=b(j.b,j.c),c(k,i,d),i=b(j.a,j.c),c(k,i,d)):j instanceof THREE.Face4&&(i=b(j.b,j.d),c(k,i,d),i=b(j.a,j.b),c(k,i,d),i=b(j.a,j.d),c(k,i,d),i=b(j.b,j.c),c(k,i,d),i=b(j.c,j.d),c(k,i,d));d=0;for(f=this.edges.length;d<f;d++){j=this.edges[d];i=j.vertexIndices[0];h=j.vertexIndices[1];j.faceIndices=k[b(i,h)].array;for(i=0;i<j.faceIndices.length;i++)h=j.faceIndices[i],
@@ -178,82 +178,82 @@ THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.
 THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,"}"].join("\n")},particle_basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.particle,THREE.UniformsLib.shadowmap]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_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;",
 THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 psColor;\nuniform float opacity;",THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,"void main() {\ngl_FragColor = vec4( psColor, opacity );",THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.shadowmap_fragment,THREE.ShaderChunk.fog_fragment,
 "}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.morphtarget_pars_vertex,"void main() {\nvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.default_vertex,"}"].join("\n"),fragmentShader:"vec4 pack_depth( const in float depth ) {\nconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\nconst vec4 bit_mask  = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\nvec4 res = fract( depth * bit_shift );\nres -= res.xxyz * bit_mask;\nreturn res;\n}\nvoid main() {\ngl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n}"}};
-THREE.WebGLRenderer=function(b){function c(b,c,d){var f,i,h,j=b.vertices,k=j.length,B=b.colors,n=B.length,F=b.__vertexArray,Da=b.__colorArray,p=b.__sortArray,v=b.__dirtyVertices,m=b.__dirtyColors,r=b.__webglCustomAttributes,t,q;if(r)for(t in r)r[t].offset=0;if(d.sortParticles){za.multiplySelf(d.matrixWorld);for(f=0;f<k;f++)i=j[f].position,Ia.copy(i),za.multiplyVector3(Ia),p[f]=[Ia.z,f];p.sort(function(b,c){return c[0]-b[0]});for(f=0;f<k;f++)i=j[p[f][1]].position,h=f*3,F[h]=i.x,F[h+1]=i.y,F[h+2]=i.z;
+THREE.WebGLRenderer=function(b){function c(b,c,d){var f,i,h,j=b.vertices,k=j.length,B=b.colors,n=B.length,F=b.__vertexArray,Da=b.__colorArray,p=b.__sortArray,v=b.__dirtyVertices,m=b.__dirtyColors,r=b.__webglCustomAttributes,t,q;if(r)for(t in r)r[t].offset=0;if(d.sortParticles){wa.multiplySelf(d.matrixWorld);for(f=0;f<k;f++)i=j[f].position,Ia.copy(i),wa.multiplyVector3(Ia),p[f]=[Ia.z,f];p.sort(function(b,c){return c[0]-b[0]});for(f=0;f<k;f++)i=j[p[f][1]].position,h=f*3,F[h]=i.x,F[h+1]=i.y,F[h+2]=i.z;
 for(f=0;f<n;f++)h=f*3,color=B[p[f][1]],Da[h]=color.r,Da[h+1]=color.g,Da[h+2]=color.b;if(r)for(t in r){f=r[t];B=f.value.length;for(h=0;h<B;h++){index=p[h][1];n=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[n]=f.value[index]}else{if(f.boundTo===void 0||f.boundTo==="vertices")q=f.value[index];f.size===2?(f.array[n]=q.x,f.array[n+1]=q.y):f.size===3?f.type==="c"?(f.array[n]=q.r,f.array[n+1]=q.g,f.array[n+2]=q.b):(f.array[n]=q.x,f.array[n+1]=q.y,f.array[n+2]=q.z):(f.array[n]=
 q.x,f.array[n+1]=q.y,f.array[n+2]=q.z,f.array[n+3]=q.w)}f.offset+=f.size}}}else{if(v)for(f=0;f<k;f++)i=j[f].position,h=f*3,F[h]=i.x,F[h+1]=i.y,F[h+2]=i.z;if(m)for(f=0;f<n;f++)color=B[f],h=f*3,Da[h]=color.r,Da[h+1]=color.g,Da[h+2]=color.b;if(r)for(t in r)if(f=r[t],f.__original.needsUpdate){B=f.value.length;for(h=0;h<B;h++){n=f.offset;if(f.size===1){if(f.boundTo===void 0||f.boundTo==="vertices")f.array[n]=f.value[h]}else{if(f.boundTo===void 0||f.boundTo==="vertices")q=f.value[h];f.size===2?(f.array[n]=
 q.x,f.array[n+1]=q.y):f.size===3?f.type==="c"?(f.array[n]=q.r,f.array[n+1]=q.g,f.array[n+2]=q.b):(f.array[n]=q.x,f.array[n+1]=q.y,f.array[n+2]=q.z):(f.array[n]=q.x,f.array[n+1]=q.y,f.array[n+2]=q.z,f.array[n+3]=q.w)}f.offset+=f.size}}}if(v||d.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,b.__webglVertexBuffer),e.bufferData(e.ARRAY_BUFFER,F,c);if(m||d.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,b.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,Da,c);if(r)for(t in r)if(f=r[t],f.__original.needsUpdate||d.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,
-f.buffer),e.bufferData(e.ARRAY_BUFFER,f.array,c)}function d(b,c,d,f,i){f.program||M.initMaterial(f,c,d,i);if(f.morphTargets&&!i.__webglMorphTargetInfluences){i.__webglMorphTargetInfluences=new Float32Array(M.maxMorphTargets);for(var h=0,j=M.maxMorphTargets;h<j;h++)i.__webglMorphTargetInfluences[h]=0}var h=f.program,j=h.uniforms,k=f.uniforms;h!=Ua&&(e.useProgram(h),Ua=h);e.uniformMatrix4fv(j.projectionMatrix,!1,Ca);if(d&&f.fog)if(k.fogColor.value=d.color,d instanceof THREE.Fog)k.fogNear.value=d.near,
-k.fogFar.value=d.far;else if(d instanceof THREE.FogExp2)k.fogDensity.value=d.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){var B,n,F,p=0,r=0,v=0,m,q,t,u=Wa,H=u.directional.colors,y=u.directional.positions,z=u.point.colors,C=u.point.positions,D=u.point.distances,G=0,I=0,d=n=t=0;for(B=c.length;d<B;d++)if(n=c[d],F=n.color,m=n.position,q=n.intensity,t=n.distance,n instanceof THREE.AmbientLight)p+=F.r,r+=F.g,v+=F.b;else if(n instanceof THREE.DirectionalLight)t=
-G*3,H[t]=F.r*q,H[t+1]=F.g*q,H[t+2]=F.b*q,y[t]=m.x,y[t+1]=m.y,y[t+2]=m.z,G+=1;else if(n instanceof THREE.SpotLight)t=G*3,H[t]=F.r*q,H[t+1]=F.g*q,H[t+2]=F.b*q,F=1/m.length(),y[t]=m.x*F,y[t+1]=m.y*F,y[t+2]=m.z*F,G+=1;else if(n instanceof THREE.PointLight)n=I*3,z[n]=F.r*q,z[n+1]=F.g*q,z[n+2]=F.b*q,C[n]=m.x,C[n+1]=m.y,C[n+2]=m.z,D[I]=t,I+=1;d=G*3;for(B=H.length;d<B;d++)H[d]=0;d=I*3;for(B=z.length;d<B;d++)z[d]=0;u.point.length=I;u.directional.length=G;u.ambient[0]=p;u.ambient[1]=r;u.ambient[2]=v;c=Wa;k.enableLighting.value=
-c.directional.length+c.point.length;k.ambientLightColor.value=c.ambient;k.directionalLightColor.value=c.directional.colors;k.directionalLightDirection.value=c.directional.positions;k.pointLightColor.value=c.point.colors;k.pointLightPosition.value=c.point.positions;k.pointLightDistance.value=c.point.distances}if(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial)k.diffuse.value=f.color,k.opacity.value=f.opacity,(k.map.texture=f.map)&&
-k.offsetRepeat.value.set(f.map.offset.x,f.map.offset.y,f.map.repeat.x,f.map.repeat.y),k.lightMap.texture=f.lightMap,k.envMap.texture=f.envMap,k.reflectivity.value=f.reflectivity,k.refractionRatio.value=f.refractionRatio,k.combine.value=f.combine,k.useRefract.value=f.envMap&&f.envMap.mapping instanceof THREE.CubeRefractionMapping;if(f instanceof THREE.LineBasicMaterial)k.diffuse.value=f.color,k.opacity.value=f.opacity;else if(f instanceof THREE.ParticleBasicMaterial)k.psColor.value=f.color,k.opacity.value=
-f.opacity,k.size.value=f.size,k.scale.value=Ja.height/2,k.map.texture=f.map;else if(f instanceof THREE.MeshPhongMaterial)k.ambient.value=f.ambient,k.specular.value=f.specular,k.shininess.value=f.shininess;else if(f instanceof THREE.MeshDepthMaterial)k.mNear.value=b.near,k.mFar.value=b.far,k.opacity.value=f.opacity;else if(f instanceof THREE.MeshNormalMaterial)k.opacity.value=f.opacity;if(i.receiveShadow&&!f._shadowPass&&k.shadowMatrix){for(c=0;c<Ra.length;c++)k.shadowMatrix.value[c]=Ra[c],k.shadowMap.texture[c]=
-M.shadowMap[c];k.shadowDarkness.value=M.shadowMapDarkness;k.shadowBias.value=M.shadowMapBias}c=f.uniformsList;k=0;for(d=c.length;k<d;k++)if(r=h.uniforms[c[k][1]])if(p=c[k][0],v=p.type,B=p.value,v=="i")e.uniform1i(r,B);else if(v=="f")e.uniform1f(r,B);else if(v=="v2")e.uniform2f(r,B.x,B.y);else if(v=="v3")e.uniform3f(r,B.x,B.y,B.z);else if(v=="v4")e.uniform4f(r,B.x,B.y,B.z,B.w);else if(v=="c")e.uniform3f(r,B.r,B.g,B.b);else if(v=="fv1")e.uniform1fv(r,B);else if(v=="fv")e.uniform3fv(r,B);else if(v==
-"v3v"){if(!p._array)p._array=new Float32Array(3*B.length);v=0;for(m=B.length;v<m;v++)u=v*3,p._array[u]=B[v].x,p._array[u+1]=B[v].y,p._array[u+2]=B[v].z;e.uniform3fv(r,p._array)}else if(v=="m4"){if(!p._array)p._array=new Float32Array(16);B.flattenToArray(p._array);e.uniformMatrix4fv(r,!1,p._array)}else if(v=="m4v"){if(!p._array)p._array=new Float32Array(16*B.length);v=0;for(m=B.length;v<m;v++)B[v].flattenToArrayOffset(p._array,v*16);e.uniformMatrix4fv(r,!1,p._array)}else if(v=="t"){if(e.uniform1i(r,
-B),r=p.texture)if(r.image instanceof Array&&r.image.length==6){if(p=r,p.image.length==6)if(p.needsUpdate){if(!p.image.__webglTextureCube)p.image.__webglTextureCube=e.createTexture();e.activeTexture(e.TEXTURE0+B);e.bindTexture(e.TEXTURE_CUBE_MAP,p.image.__webglTextureCube);for(B=0;B<6;B++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+B,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,p.image[B]);w(e.TEXTURE_CUBE_MAP,p,p.image[0]);p.needsUpdate=!1}else e.activeTexture(e.TEXTURE0+B),e.bindTexture(e.TEXTURE_CUBE_MAP,p.image.__webglTextureCube)}else r instanceof
-THREE.WebGLRenderTargetCube?(p=r,e.activeTexture(e.TEXTURE0+B),e.bindTexture(e.TEXTURE_CUBE_MAP,p.__webglTexture)):ia(r,B)}else if(v=="tv"){if(!p._array){p._array=[];v=0;for(m=p.texture.length;v<m;v++)p._array[v]=B+v}e.uniform1iv(r,p._array);v=0;for(m=p.texture.length;v<m;v++)(r=p.texture[v])&&ia(r,p._array[v])}e.uniformMatrix4fv(j.modelViewMatrix,!1,i._modelViewMatrixArray);j.normalMatrix&&e.uniformMatrix3fv(j.normalMatrix,!1,i._normalMatrixArray);(f instanceof THREE.ShaderMaterial||f instanceof
-THREE.MeshPhongMaterial||f.envMap)&&j.cameraPosition!==null&&e.uniform3f(j.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof THREE.ShaderMaterial||f.envMap||f.skinning||i.receiveShadow)&&j.objectMatrix!==null&&e.uniformMatrix4fv(j.objectMatrix,!1,i._objectMatrixArray);(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.ShaderMaterial||f.skinning)&&j.viewMatrix!==null&&e.uniformMatrix4fv(j.viewMatrix,!1,Sa);f.skinning&&(e.uniformMatrix4fv(j.cameraInverseMatrix,
-!1,Sa),e.uniformMatrix4fv(j.boneGlobalMatrices,!1,i.boneMatrices));return h}function f(b,c,f,i,h,j){if(i.opacity!=0){var k,b=d(b,c,f,i,j).attributes;if(!i.morphTargets&&b.position>=0)e.bindBuffer(e.ARRAY_BUFFER,h.__webglVertexBuffer),e.vertexAttribPointer(b.position,3,e.FLOAT,!1,0,0);else if(j.morphTargetBase){c=i.program.attributes;j.morphTargetBase!==-1?(e.bindBuffer(e.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[j.morphTargetBase]),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0)):c.position>=0&&
-(e.bindBuffer(e.ARRAY_BUFFER,h.__webglVertexBuffer),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var f=0,n=j.morphTargetForcedOrder,B=j.morphTargetInfluences;f<i.numSupportedMorphTargets&&f<n.length;)e.bindBuffer(e.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[n[f]]),e.vertexAttribPointer(c["morphTarget"+f],3,e.FLOAT,!1,0,0),j.__webglMorphTargetInfluences[f]=B[n[f]],f++;else{var n=[],p=-1,r=0,B=j.morphTargetInfluences,m,q=B.length,f=0;for(j.morphTargetBase!==
+f.buffer),e.bufferData(e.ARRAY_BUFFER,f.array,c)}function d(b,c,d,f,i){f.program||M.initMaterial(f,c,d,i);if(f.morphTargets&&!i.__webglMorphTargetInfluences){i.__webglMorphTargetInfluences=new Float32Array(M.maxMorphTargets);for(var h=0,j=M.maxMorphTargets;h<j;h++)i.__webglMorphTargetInfluences[h]=0}var k=!1,h=f.program,j=h.uniforms,B=f.uniforms;h!=Va&&(e.useProgram(h),Va=h,k=!0);if(f.id!=V)V=f.id,k=!0;if(k){e.uniformMatrix4fv(j.projectionMatrix,!1,Sa);if(d&&f.fog)if(B.fogColor.value=d.color,d instanceof
+THREE.Fog)B.fogNear.value=d.near,B.fogFar.value=d.far;else if(d instanceof THREE.FogExp2)B.fogDensity.value=d.density;if(f instanceof THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f.lights){for(var n,F,p=0,r=0,v=0,m,q,t,u=Xa,H=u.directional.colors,y=u.directional.positions,z=u.point.colors,C=u.point.positions,D=u.point.distances,G=0,I=0,d=n=t=0,k=c.length;d<k;d++)if(n=c[d],F=n.color,m=n.position,q=n.intensity,t=n.distance,n instanceof THREE.AmbientLight)p+=F.r,r+=F.g,v+=F.b;else if(n instanceof
+THREE.DirectionalLight)t=G*3,H[t]=F.r*q,H[t+1]=F.g*q,H[t+2]=F.b*q,y[t]=m.x,y[t+1]=m.y,y[t+2]=m.z,G+=1;else if(n instanceof THREE.SpotLight)t=G*3,H[t]=F.r*q,H[t+1]=F.g*q,H[t+2]=F.b*q,F=1/m.length(),y[t]=m.x*F,y[t+1]=m.y*F,y[t+2]=m.z*F,G+=1;else if(n instanceof THREE.PointLight)n=I*3,z[n]=F.r*q,z[n+1]=F.g*q,z[n+2]=F.b*q,C[n]=m.x,C[n+1]=m.y,C[n+2]=m.z,D[I]=t,I+=1;d=G*3;for(k=H.length;d<k;d++)H[d]=0;d=I*3;for(k=z.length;d<k;d++)z[d]=0;u.point.length=I;u.directional.length=G;u.ambient[0]=p;u.ambient[1]=
+r;u.ambient[2]=v;c=Xa;B.enableLighting.value=c.directional.length+c.point.length;B.ambientLightColor.value=c.ambient;B.directionalLightColor.value=c.directional.colors;B.directionalLightDirection.value=c.directional.positions;B.pointLightColor.value=c.point.colors;B.pointLightPosition.value=c.point.positions;B.pointLightDistance.value=c.point.distances}if(f instanceof THREE.MeshBasicMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.MeshPhongMaterial)B.diffuse.value=f.color,B.opacity.value=
+f.opacity,(B.map.texture=f.map)&&B.offsetRepeat.value.set(f.map.offset.x,f.map.offset.y,f.map.repeat.x,f.map.repeat.y),B.lightMap.texture=f.lightMap,B.envMap.texture=f.envMap,B.reflectivity.value=f.reflectivity,B.refractionRatio.value=f.refractionRatio,B.combine.value=f.combine,B.useRefract.value=f.envMap&&f.envMap.mapping instanceof THREE.CubeRefractionMapping;if(f instanceof THREE.LineBasicMaterial)B.diffuse.value=f.color,B.opacity.value=f.opacity;else if(f instanceof THREE.ParticleBasicMaterial)B.psColor.value=
+f.color,B.opacity.value=f.opacity,B.size.value=f.size,B.scale.value=Fa.height/2,B.map.texture=f.map;else if(f instanceof THREE.MeshPhongMaterial)B.ambient.value=f.ambient,B.specular.value=f.specular,B.shininess.value=f.shininess;else if(f instanceof THREE.MeshDepthMaterial)B.mNear.value=b.near,B.mFar.value=b.far,B.opacity.value=f.opacity;else if(f instanceof THREE.MeshNormalMaterial)B.opacity.value=f.opacity;if(i.receiveShadow&&!f._shadowPass&&B.shadowMatrix){for(c=0;c<Ra.length;c++)B.shadowMatrix.value[c]=
+Ra[c],B.shadowMap.texture[c]=M.shadowMap[c];B.shadowDarkness.value=M.shadowMapDarkness;B.shadowBias.value=M.shadowMapBias}c=f.uniformsList;B=0;for(d=c.length;B<d;B++)if(r=h.uniforms[c[B][1]])if(p=c[B][0],v=p.type,k=p.value,v=="i")e.uniform1i(r,k);else if(v=="f")e.uniform1f(r,k);else if(v=="v2")e.uniform2f(r,k.x,k.y);else if(v=="v3")e.uniform3f(r,k.x,k.y,k.z);else if(v=="v4")e.uniform4f(r,k.x,k.y,k.z,k.w);else if(v=="c")e.uniform3f(r,k.r,k.g,k.b);else if(v=="fv1")e.uniform1fv(r,k);else if(v=="fv")e.uniform3fv(r,
+k);else if(v=="v3v"){if(!p._array)p._array=new Float32Array(3*k.length);v=0;for(m=k.length;v<m;v++)u=v*3,p._array[u]=k[v].x,p._array[u+1]=k[v].y,p._array[u+2]=k[v].z;e.uniform3fv(r,p._array)}else if(v=="m4"){if(!p._array)p._array=new Float32Array(16);k.flattenToArray(p._array);e.uniformMatrix4fv(r,!1,p._array)}else if(v=="m4v"){if(!p._array)p._array=new Float32Array(16*k.length);v=0;for(m=k.length;v<m;v++)k[v].flattenToArrayOffset(p._array,v*16);e.uniformMatrix4fv(r,!1,p._array)}else if(v=="t"){if(e.uniform1i(r,
+k),r=p.texture)if(r.image instanceof Array&&r.image.length==6){if(p=r,p.image.length==6)if(p.needsUpdate){if(!p.image.__webglTextureCube)p.image.__webglTextureCube=e.createTexture();e.activeTexture(e.TEXTURE0+k);e.bindTexture(e.TEXTURE_CUBE_MAP,p.image.__webglTextureCube);for(k=0;k<6;k++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,p.image[k]);w(e.TEXTURE_CUBE_MAP,p,p.image[0]);p.needsUpdate=!1}else e.activeTexture(e.TEXTURE0+k),e.bindTexture(e.TEXTURE_CUBE_MAP,p.image.__webglTextureCube)}else r instanceof
+THREE.WebGLRenderTargetCube?(p=r,e.activeTexture(e.TEXTURE0+k),e.bindTexture(e.TEXTURE_CUBE_MAP,p.__webglTexture)):R(r,k)}else if(v=="tv"){if(!p._array){p._array=[];v=0;for(m=p.texture.length;v<m;v++)p._array[v]=k+v}e.uniform1iv(r,p._array);v=0;for(m=p.texture.length;v<m;v++)(r=p.texture[v])&&R(r,p._array[v])}(f instanceof THREE.ShaderMaterial||f instanceof THREE.MeshPhongMaterial||f.envMap)&&j.cameraPosition!==null&&e.uniform3f(j.cameraPosition,b.position.x,b.position.y,b.position.z);(f instanceof
+THREE.MeshPhongMaterial||f instanceof THREE.MeshLambertMaterial||f instanceof THREE.ShaderMaterial||f.skinning)&&j.viewMatrix!==null&&e.uniformMatrix4fv(j.viewMatrix,!1,Ta);f.skinning&&(e.uniformMatrix4fv(j.cameraInverseMatrix,!1,Ta),e.uniformMatrix4fv(j.boneGlobalMatrices,!1,i.boneMatrices))}e.uniformMatrix4fv(j.modelViewMatrix,!1,i._modelViewMatrixArray);j.normalMatrix&&e.uniformMatrix3fv(j.normalMatrix,!1,i._normalMatrixArray);(f instanceof THREE.ShaderMaterial||f.envMap||f.skinning||i.receiveShadow)&&
+j.objectMatrix!==null&&e.uniformMatrix4fv(j.objectMatrix,!1,i._objectMatrixArray);return h}function f(b,c,f,i,h,j){if(i.opacity!=0){var k,b=d(b,c,f,i,j).attributes;if(!i.morphTargets&&b.position>=0)e.bindBuffer(e.ARRAY_BUFFER,h.__webglVertexBuffer),e.vertexAttribPointer(b.position,3,e.FLOAT,!1,0,0);else if(j.morphTargetBase){c=i.program.attributes;j.morphTargetBase!==-1?(e.bindBuffer(e.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[j.morphTargetBase]),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0)):
+c.position>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglVertexBuffer),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0));if(j.morphTargetForcedOrder.length)for(var f=0,n=j.morphTargetForcedOrder,B=j.morphTargetInfluences;f<i.numSupportedMorphTargets&&f<n.length;)e.bindBuffer(e.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[n[f]]),e.vertexAttribPointer(c["morphTarget"+f],3,e.FLOAT,!1,0,0),j.__webglMorphTargetInfluences[f]=B[n[f]],f++;else{var n=[],p=-1,r=0,B=j.morphTargetInfluences,m,q=B.length,f=0;for(j.morphTargetBase!==
 -1&&(n[j.morphTargetBase]=!0);f<i.numSupportedMorphTargets;){for(m=0;m<q;m++)!n[m]&&B[m]>p&&(r=m,p=B[r]);e.bindBuffer(e.ARRAY_BUFFER,h.__webglMorphTargetsBuffers[r]);e.vertexAttribPointer(c["morphTarget"+f],3,e.FLOAT,!1,0,0);j.__webglMorphTargetInfluences[f]=p;n[r]=1;p=-1;f++}}i.program.uniforms.morphTargetInfluences!==null&&e.uniform1fv(i.program.uniforms.morphTargetInfluences,j.__webglMorphTargetInfluences)}if(h.__webglCustomAttributes)for(k in h.__webglCustomAttributes)b[k]>=0&&(c=h.__webglCustomAttributes[k],
 e.bindBuffer(e.ARRAY_BUFFER,c.buffer),e.vertexAttribPointer(b[k],c.size,e.FLOAT,!1,0,0));b.color>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglColorBuffer),e.vertexAttribPointer(b.color,3,e.FLOAT,!1,0,0));b.normal>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglNormalBuffer),e.vertexAttribPointer(b.normal,3,e.FLOAT,!1,0,0));b.tangent>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglTangentBuffer),e.vertexAttribPointer(b.tangent,4,e.FLOAT,!1,0,0));b.uv>=0&&(h.__webglUVBuffer?(e.bindBuffer(e.ARRAY_BUFFER,h.__webglUVBuffer),
 e.vertexAttribPointer(b.uv,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv)):e.disableVertexAttribArray(b.uv));b.uv2>=0&&(h.__webglUV2Buffer?(e.bindBuffer(e.ARRAY_BUFFER,h.__webglUV2Buffer),e.vertexAttribPointer(b.uv2,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv2)):e.disableVertexAttribArray(b.uv2));i.skinning&&b.skinVertexA>=0&&b.skinVertexB>=0&&b.skinIndex>=0&&b.skinWeight>=0&&(e.bindBuffer(e.ARRAY_BUFFER,h.__webglSkinVertexABuffer),e.vertexAttribPointer(b.skinVertexA,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,
 h.__webglSkinVertexBBuffer),e.vertexAttribPointer(b.skinVertexB,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,h.__webglSkinIndicesBuffer),e.vertexAttribPointer(b.skinIndex,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,h.__webglSkinWeightsBuffer),e.vertexAttribPointer(b.skinWeight,4,e.FLOAT,!1,0,0));j instanceof THREE.Mesh?(i.wireframe?(e.lineWidth(i.wireframeLinewidth),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,h.__webglLineBuffer),e.drawElements(e.LINES,h.__webglLineCount,e.UNSIGNED_SHORT,0)):(e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,
 h.__webglFaceBuffer),e.drawElements(e.TRIANGLES,h.__webglFaceCount,e.UNSIGNED_SHORT,0)),M.info.render.calls++,M.info.render.vertices+=h.__webglFaceCount,M.info.render.faces+=h.__webglFaceCount/3):j instanceof THREE.Line?(j=j.type==THREE.LineStrip?e.LINE_STRIP:e.LINES,e.lineWidth(i.linewidth),e.drawArrays(j,0,h.__webglLineCount),M.info.render.calls++):j instanceof THREE.ParticleSystem?(e.drawArrays(e.POINTS,0,h.__webglParticleCount),M.info.render.calls++):j instanceof THREE.Ribbon&&(e.drawArrays(e.TRIANGLE_STRIP,
 0,h.__webglVertexCount),M.info.render.calls++)}}function i(b,c,d){if(!b.__webglVertexBuffer)b.__webglVertexBuffer=e.createBuffer();if(!b.__webglNormalBuffer)b.__webglNormalBuffer=e.createBuffer();b.hasPos&&(e.bindBuffer(e.ARRAY_BUFFER,b.__webglVertexBuffer),e.bufferData(e.ARRAY_BUFFER,b.positionArray,e.DYNAMIC_DRAW),e.enableVertexAttribArray(c.attributes.position),e.vertexAttribPointer(c.attributes.position,3,e.FLOAT,!1,0,0));if(b.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,b.__webglNormalBuffer);if(d==
-THREE.FlatShading){var f,h,i,j,k,B,n,p,r,m,v=b.count*3;for(m=0;m<v;m+=9)d=b.normalArray,f=d[m],h=d[m+1],i=d[m+2],j=d[m+3],B=d[m+4],p=d[m+5],k=d[m+6],n=d[m+7],r=d[m+8],f=(f+j+k)/3,h=(h+B+n)/3,i=(i+p+r)/3,d[m]=f,d[m+1]=h,d[m+2]=i,d[m+3]=f,d[m+4]=h,d[m+5]=i,d[m+6]=f,d[m+7]=h,d[m+8]=i}e.bufferData(e.ARRAY_BUFFER,b.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,b.count);b.count=0}function h(b){if(T!=
-b.doubleSided)b.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE),T=b.doubleSided;if(Z!=b.flipSided)b.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW),Z=b.flipSided}function j(b){W!=b&&(b?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),W=b)}function k(b){L!=b&&(e.depthMask(b),L=b)}function p(b,c,d){V!=b&&(b?e.enable(e.POLYGON_OFFSET_FILL):e.disable(e.POLYGON_OFFSET_FILL),V=b);if(b&&(va!=c||P!=d))e.polygonOffset(c,d),va=c,P=d}function n(b){R[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-b.n14);
-R[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);R[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);R[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);R[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);R[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var c,b=0;b<6;b++)c=R[b],c.divideScalar(Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z))}function r(b){for(var c=b.matrixWorld,e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),d=0;d<6;d++)if(b=
-R[d].x*c.n14+R[d].y*c.n24+R[d].z*c.n34+R[d].w,b<=e)return!1;return!0}function m(b,c){b.list[b.count]=c;b.count+=1}function t(b){var c,e,d=b.object,f=b.opaque,h=b.transparent;h.count=0;b=f.count=0;for(c=d.materials.length;b<c;b++)e=d.materials[b],e.transparent?m(h,e):m(f,e)}function u(b){var c,e,d,f,h=b.object,i=b.buffer,j=b.opaque,k=b.transparent;k.count=0;b=j.count=0;for(d=h.materials.length;b<d;b++)if(c=h.materials[b],c instanceof THREE.MeshFaceMaterial){c=0;for(e=i.materials.length;c<e;c++)(f=
-i.materials[c])&&(f.transparent?m(k,f):m(j,f))}else(f=c)&&(f.transparent?m(k,f):m(j,f))}function y(b,c){return c.z-b.z}function C(b){var c,k,p,La=0,m,q,t,B,u=b.lights;pa||(pa=new THREE.Camera(M.shadowCameraFov,M.shadowMapWidth/M.shadowMapHeight,M.shadowCameraNear,M.shadowCameraFar));c=0;for(k=u.length;c<k;c++)if(p=u[c],p instanceof THREE.SpotLight&&p.castShadow){M.shadowMap[La]||(M.shadowMap[La]=new THREE.WebGLRenderTarget(M.shadowMapWidth,M.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
-format:THREE.RGBAFormat}));Ra[La]||(Ra[La]=new THREE.Matrix4);m=M.shadowMap[La];q=Ra[La];pa.position.copy(p.position);pa.target.position.copy(p.target.position);pa.update(void 0,!0);b.update(void 0,!1,pa);q.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);q.multiplySelf(pa.projectionMatrix);q.multiplySelf(pa.matrixWorldInverse);pa.matrixWorldInverse.flattenToArray(Sa);pa.projectionMatrix.flattenToArray(Ca);za.multiply(pa.projectionMatrix,pa.matrixWorldInverse);n(za);M.initWebGLObjects(b);K(m);e.clearColor(1,
-1,1,1);M.clear();e.clearColor(fa.r,fa.g,fa.b,Ga);q=b.__webglObjects.length;p=b.__webglObjectsImmediate.length;for(m=0;m<q;m++)t=b.__webglObjects[m],B=t.object,B.visible&&B.castShadow?!(B instanceof THREE.Mesh)||!B.frustumCulled||r(B)?(B.matrixWorld.flattenToArray(B._objectMatrixArray),D(B,pa,!1),t.render=!0):t.render=!1:t.render=!1;j(!0);J(THREE.NormalBlending);for(m=0;m<q;m++)if(t=b.__webglObjects[m],t.render)B=t.object,buffer=t.buffer,h(B),t=B.customDepthMaterial?B.customDepthMaterial:B.geometry.morphTargets.length?
-Xa:Ta,f(pa,u,null,t,buffer,B);for(m=0;m<p;m++)t=b.__webglObjectsImmediate[m],B=t.object,B.visible&&B.castShadow&&(B.matrixAutoUpdate&&B.matrixWorld.flattenToArray(B._objectMatrixArray),D(B,pa,!1),h(B),program=d(pa,u,null,Ta,B),B.render(function(b){i(b,program,Ta.shading)}));La++}}function G(b,c){var d,f,h;d=q.attributes;var i=q.uniforms,j=Ea/ya,k,n=[],p=ya*0.5,m=Ea*0.5,r=!0;e.useProgram(q.program);Ua=q.program;W=E=-1;Ya||(e.enableVertexAttribArray(q.attributes.position),e.enableVertexAttribArray(q.attributes.uv),
-Ya=!0);e.disable(e.CULL_FACE);e.enable(e.BLEND);e.depthMask(!0);e.bindBuffer(e.ARRAY_BUFFER,q.vertexBuffer);e.vertexAttribPointer(d.position,2,e.FLOAT,!1,16,0);e.vertexAttribPointer(d.uv,2,e.FLOAT,!1,16,8);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,q.elementBuffer);e.uniformMatrix4fv(i.projectionMatrix,!1,Ca);e.activeTexture(e.TEXTURE0);e.uniform1i(i.map,0);d=0;for(f=b.__webglSprites.length;d<f;d++)if(h=b.__webglSprites[d],h.visible&&h.opacity!=0)h.useScreenCoordinates?h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,
-h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(y);d=0;for(f=b.__webglSprites.length;d<f;d++)h=b.__webglSprites[d],h.visible&&h.opacity!=0&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(e.uniform1i(i.useScreenCoordinates,1),e.uniform3f(i.screenPosition,(h.position.x-p)/p,(m-h.position.y)/m,Math.max(0,Math.min(1,h.position.z)))):(e.uniform1i(i.useScreenCoordinates,0),e.uniform1i(i.affectedByDistance,h.affectedByDistance?1:0),e.uniformMatrix4fv(i.modelViewMatrix,
-!1,h._modelViewMatrixArray)),k=h.map.image.width/(h.scaleByViewport?Ea:1),n[0]=k*j*h.scale.x,n[1]=k*h.scale.y,e.uniform2f(i.uvScale,h.uvScale.x,h.uvScale.y),e.uniform2f(i.uvOffset,h.uvOffset.x,h.uvOffset.y),e.uniform2f(i.alignment,h.alignment.x,h.alignment.y),e.uniform1f(i.opacity,h.opacity),e.uniform3f(i.color,h.color.r,h.color.g,h.color.b),e.uniform1f(i.rotation,h.rotation),e.uniform2fv(i.scale,n),h.mergeWith3D&&!r?(e.enable(e.DEPTH_TEST),r=!0):!h.mergeWith3D&&r&&(e.disable(e.DEPTH_TEST),r=!1),
-J(h.blending),ia(h.map,0),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0));e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(L)}function D(b,c,e){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);e&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function wa(b){var c,e,d,f;f=b.__materials;b=0;for(e=f.length;b<e;b++)if(d=f[b],d.attributes)for(c in d.attributes)if(d.attributes[c].needsUpdate)return!0;return!1}
-function xa(b){var c,e,d,f;f=b.__materials;b=0;for(e=f.length;b<e;b++)if(d=f[b],d.attributes)for(c in d.attributes)d.attributes[c].needsUpdate=!1}function oa(b,c){var e;for(e=b.length-1;e>=0;e--)b[e].object==c&&b.splice(e,1)}function qa(b){function c(b){var f=[];e=0;for(d=b.length;e<d;e++)b[e]==void 0?f.push("undefined"):f.push(b[e].id);return f.join("_")}var e,d,f,h,i,j,k,n,p={},m=b.morphTargets!==void 0?b.morphTargets.length:0;b.geometryGroups={};f=0;for(h=b.faces.length;f<h;f++)i=b.faces[f],j=
-i.materials,k=c(j),p[k]==void 0&&(p[k]={hash:k,counter:0}),n=p[k].hash+"_"+p[k].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:j,vertices:0,numMorphTargets:m}),i=i instanceof THREE.Face3?3:4,b.geometryGroups[n].vertices+i>65535&&(p[k].counter+=1,n=p[k].hash+"_"+p[k].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:j,vertices:0,numMorphTargets:m})),b.geometryGroups[n].faces.push(f),b.geometryGroups[n].vertices+=i;b.geometryGroupsList=[];for(var r in b.geometryGroups)b.geometryGroupsList.push(b.geometryGroups[r])}
-function ha(b,c,e){b.push({buffer:c,object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function J(b){if(b!=E){switch(b){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)}E=b}}function w(b,c,d){(d.width&d.width-1)==0&&(d.height&d.height-1)==0?(e.texParameteri(b,e.TEXTURE_WRAP_S,Q(c.wrapS)),e.texParameteri(b,e.TEXTURE_WRAP_T,Q(c.wrapT)),e.texParameteri(b,e.TEXTURE_MAG_FILTER,Q(c.magFilter)),e.texParameteri(b,e.TEXTURE_MIN_FILTER,Q(c.minFilter)),e.generateMipmap(b)):(e.texParameteri(b,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(b,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(b,e.TEXTURE_MAG_FILTER,ta(c.magFilter)),
-e.texParameteri(b,e.TEXTURE_MIN_FILTER,ta(c.minFilter)))}function ia(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=e.createTexture(),M.info.memory.textures++;e.activeTexture(e.TEXTURE0+c);e.bindTexture(e.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D,0,Q(b.format),b.image.width,b.image.height,0,Q(b.format),e.UNSIGNED_BYTE,b.image.data):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,b.image);w(e.TEXTURE_2D,b,b.image);b.needsUpdate=
-!1}else e.activeTexture(e.TEXTURE0+c),e.bindTexture(e.TEXTURE_2D,b.__webglTexture)}function K(b){var c=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglRenderbuffer=e.createRenderbuffer();b.__webglTexture=e.createTexture();if(c){e.bindTexture(e.TEXTURE_CUBE_MAP,b.__webglTexture);w(e.TEXTURE_CUBE_MAP,b,b);b.__webglFramebuffer=[];for(var d=0;d<6;d++)b.__webglFramebuffer[d]=e.createFramebuffer(),
-e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+d,0,Q(b.format),b.width,b.height,0,Q(b.format),Q(b.type),null)}else b.__webglFramebuffer=e.createFramebuffer(),e.bindTexture(e.TEXTURE_2D,b.__webglTexture),w(e.TEXTURE_2D,b,b),e.texImage2D(e.TEXTURE_2D,0,Q(b.format),b.width,b.height,0,Q(b.format),Q(b.type),null);e.bindRenderbuffer(e.RENDERBUFFER,b.__webglRenderbuffer);if(c)for(d=0;d<6;++d)e.bindFramebuffer(e.FRAMEBUFFER,b.__webglFramebuffer[d]),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+
-d,b.__webglTexture,0);else e.bindFramebuffer(e.FRAMEBUFFER,b.__webglFramebuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,
-e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,b.__webglRenderbuffer)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,b.width,b.height);c?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var f,h;b?(c=c?b.__webglFramebuffer[b.activeCubeFace]:b.__webglFramebuffer,d=b.width,b=b.height,h=f=0):(c=null,d=ya,b=Ea,f=ra,h=Fa);c!=ua&&(e.bindFramebuffer(e.FRAMEBUFFER,c),e.viewport(f,h,d,b),ua=c)}function ja(b){b instanceof
-THREE.WebGLRenderTargetCube?(e.bindTexture(e.TEXTURE_CUBE_MAP,b.__webglTexture),e.generateMipmap(e.TEXTURE_CUBE_MAP),e.bindTexture(e.TEXTURE_CUBE_MAP,null)):(e.bindTexture(e.TEXTURE_2D,b.__webglTexture),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null))}function Y(b,c){var d;b=="fragment"?d=e.createShader(e.FRAGMENT_SHADER):b=="vertex"&&(d=e.createShader(e.VERTEX_SHADER));e.shaderSource(d,c);e.compileShader(d);if(!e.getShaderParameter(d,e.COMPILE_STATUS))return console.error(e.getShaderInfoLog(d)),
-console.error(c),null;return d}function ta(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function Q(b){switch(b){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;
-case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;
-case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var M=this,e,Ba=[],Ua=null,ua=null,T=null,Z=null,E=null,W=null,L=null,V=null,va=null,P=null,ra=0,Fa=0,ya=0,Ea=0,R=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],za=new THREE.Matrix4,Ca=new Float32Array(16),Sa=new Float32Array(16),Ia=new THREE.Vector4,Wa={ambient:[0,
-0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Ja=b.canvas!==void 0?b.canvas:document.createElement("canvas"),S=b.stencil!==void 0?b.stencil:!0,ab=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,bb=b.antialias!==void 0?b.antialias:!1,fa=b.clearColor!==void 0?new THREE.Color(b.clearColor):new THREE.Color(0),Ga=b.clearAlpha!==void 0?b.clearAlpha:0,Va=b.maxLights!==void 0?b.maxLights:4;this.info={memory:{programs:0,geometries:0,
-textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=Ja;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;var pa,Ra=[],b=THREE.ShaderLib.depthRGBA,Za=THREE.UniformsUtils.clone(b.uniforms),Ta=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,
-vertexShader:b.vertexShader,uniforms:Za}),Xa=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:Za,morphTargets:!0});Ta._shadowPass=!0;Xa._shadowPass=!0;try{if(!(e=Ja.getContext("experimental-webgl",{antialias:bb,stencil:S,preserveDrawingBuffer:ab})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION))}catch(cb){console.error(cb)}e.clearColor(0,
-0,0,1);e.clearDepth(1);e.clearStencil(0);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(fa.r,fa.g,fa.b,Ga);this.context=e;var $a=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>0,q={};q.vertices=new Float32Array(16);q.faces=new Uint16Array(6);S=0;q.vertices[S++]=-1;q.vertices[S++]=-1;q.vertices[S++]=0;q.vertices[S++]=1;q.vertices[S++]=
-1;q.vertices[S++]=-1;q.vertices[S++]=1;q.vertices[S++]=1;q.vertices[S++]=1;q.vertices[S++]=1;q.vertices[S++]=1;q.vertices[S++]=0;q.vertices[S++]=-1;q.vertices[S++]=1;q.vertices[S++]=0;S=q.vertices[S++]=0;q.faces[S++]=0;q.faces[S++]=1;q.faces[S++]=2;q.faces[S++]=0;q.faces[S++]=2;q.faces[S++]=3;q.vertexBuffer=e.createBuffer();q.elementBuffer=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,q.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,q.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,q.elementBuffer);
-e.bufferData(e.ELEMENT_ARRAY_BUFFER,q.faces,e.STATIC_DRAW);q.program=e.createProgram();e.attachShader(q.program,Y("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(q.program,Y("vertex",THREE.ShaderLib.sprite.vertexShader));e.linkProgram(q.program);q.attributes={};q.uniforms={};q.attributes.position=e.getAttribLocation(q.program,"position");q.attributes.uv=e.getAttribLocation(q.program,"uv");q.uniforms.uvOffset=e.getUniformLocation(q.program,"uvOffset");q.uniforms.uvScale=e.getUniformLocation(q.program,
-"uvScale");q.uniforms.rotation=e.getUniformLocation(q.program,"rotation");q.uniforms.scale=e.getUniformLocation(q.program,"scale");q.uniforms.alignment=e.getUniformLocation(q.program,"alignment");q.uniforms.color=e.getUniformLocation(q.program,"color");q.uniforms.map=e.getUniformLocation(q.program,"map");q.uniforms.opacity=e.getUniformLocation(q.program,"opacity");q.uniforms.useScreenCoordinates=e.getUniformLocation(q.program,"useScreenCoordinates");q.uniforms.affectedByDistance=e.getUniformLocation(q.program,
-"affectedByDistance");q.uniforms.screenPosition=e.getUniformLocation(q.program,"screenPosition");q.uniforms.modelViewMatrix=e.getUniformLocation(q.program,"modelViewMatrix");q.uniforms.projectionMatrix=e.getUniformLocation(q.program,"projectionMatrix");var Ya=!1;this.setSize=function(b,c){Ja.width=b;Ja.height=c;this.setViewport(0,0,Ja.width,Ja.height)};this.setViewport=function(b,c,d,f){ra=b;Fa=c;ya=d;Ea=f;e.viewport(ra,Fa,ya,Ea)};this.setScissor=function(b,c,d,f){e.scissor(b,c,d,f)};this.enableScissorTest=
-function(b){b?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(b,c){fa.setHex(b);Ga=c;e.clearColor(fa.r,fa.g,fa.b,Ga)};this.setClearColor=function(b,c){fa.copy(b);Ga=c;e.clearColor(fa.r,fa.g,fa.b,Ga)};this.getClearColor=function(){return fa};this.getClearAlpha=function(){return Ga};this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.getContext=function(){return e};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=
-!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c=b.geometry.geometryGroups[g];e.deleteBuffer(c.__webglVertexBuffer);e.deleteBuffer(c.__webglNormalBuffer);e.deleteBuffer(c.__webglTangentBuffer);e.deleteBuffer(c.__webglColorBuffer);e.deleteBuffer(c.__webglUVBuffer);e.deleteBuffer(c.__webglUV2Buffer);e.deleteBuffer(c.__webglSkinVertexABuffer);e.deleteBuffer(c.__webglSkinVertexBBuffer);
-e.deleteBuffer(c.__webglSkinIndicesBuffer);e.deleteBuffer(c.__webglSkinWeightsBuffer);e.deleteBuffer(c.__webglFaceBuffer);e.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,f=c.numMorphTargets;d<f;d++)e.deleteBuffer(c.__webglMorphTargetsBuffers[d]);M.info.memory.geometries--}else if(b instanceof THREE.Ribbon)b=b.geometry,e.deleteBuffer(b.__webglVertexBuffer),e.deleteBuffer(b.__webglColorBuffer),M.info.memory.geometries--;else if(b instanceof THREE.Line)b=b.geometry,e.deleteBuffer(b.__webglVertexBuffer),
-e.deleteBuffer(b.__webglColorBuffer),M.info.memory.geometries--;else if(b instanceof THREE.ParticleSystem)b=b.geometry,e.deleteBuffer(b.__webglVertexBuffer),e.deleteBuffer(b.__webglColorBuffer),M.info.memory.geometries--};this.deallocateTexture=function(b){if(b.__webglInit)b.__webglInit=!1,e.deleteTexture(b.__webglTexture),M.info.memory.textures--};this.initMaterial=function(b,c,d,f){var h,i,j,k;b instanceof THREE.MeshDepthMaterial?k="depth":b instanceof THREE.MeshNormalMaterial?k="normal":b instanceof
-THREE.MeshBasicMaterial?k="basic":b instanceof THREE.MeshLambertMaterial?k="lambert":b instanceof THREE.MeshPhongMaterial?k="phong":b instanceof THREE.LineBasicMaterial?k="basic":b instanceof THREE.ParticleBasicMaterial&&(k="particle_basic");if(k){var n=THREE.ShaderLib[k];b.uniforms=THREE.UniformsUtils.clone(n.uniforms);b.vertexShader=n.vertexShader;b.fragmentShader=n.fragmentShader}var p,m,r;p=r=n=0;for(m=c.length;p<m;p++)j=c[p],j instanceof THREE.SpotLight&&r++,j instanceof THREE.DirectionalLight&&
-r++,j instanceof THREE.PointLight&&n++;n+r<=Va?p=r:(p=Math.ceil(Va*r/(n+r)),n=Va-p);j={directional:p,point:n};n=r=0;for(p=c.length;n<p;n++)m=c[n],m instanceof THREE.SpotLight&&m.castShadow&&r++;var t=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)t=f.bones.length;var v;a:{p=b.fragmentShader;m=b.vertexShader;var n=b.uniforms,c=b.attributes,d={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:d,useFog:b.fog,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,
-maxMorphTargets:this.maxMorphTargets,maxDirLights:j.directional,maxPointLights:j.point,maxBones:t,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:r,alphaTest:b.alphaTest},q,f=[];k?f.push(k):(f.push(p),f.push(m));for(q in d)f.push(q),f.push(d[q]);k=f.join();q=0;for(f=Ba.length;q<f;q++)if(Ba[q].code==k){v=Ba[q].program;break a}q=e.createProgram();f=[$a?"#define VERTEX_TEXTURES":
-"","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,"#define MAX_BONES "+d.maxBones,d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.skinning?"#define USE_SKINNING":"",d.morphTargets?"#define USE_MORPHTARGETS":"",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapSoft?"#define SHADOWMAP_SOFT":"",d.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");
+THREE.FlatShading){var f,h,i,j,k,B,n,p,r,m,v=b.count*3;for(m=0;m<v;m+=9)d=b.normalArray,f=d[m],h=d[m+1],i=d[m+2],j=d[m+3],B=d[m+4],p=d[m+5],k=d[m+6],n=d[m+7],r=d[m+8],f=(f+j+k)/3,h=(h+B+n)/3,i=(i+p+r)/3,d[m]=f,d[m+1]=h,d[m+2]=i,d[m+3]=f,d[m+4]=h,d[m+5]=i,d[m+6]=f,d[m+7]=h,d[m+8]=i}e.bufferData(e.ARRAY_BUFFER,b.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,b.count);b.count=0}function h(b){if(ra!=
+b.doubleSided)b.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE),ra=b.doubleSided;if(E!=b.flipSided)b.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW),E=b.flipSided}function j(b){L!=b&&(b?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),L=b)}function k(b){ja!=b&&(e.depthMask(b),ja=b)}function p(b,c,d){va!=b&&(b?e.enable(e.POLYGON_OFFSET_FILL):e.disable(e.POLYGON_OFFSET_FILL),va=b);if(b&&(P!=c||za!=d))e.polygonOffset(c,d),P=c,za=d}function n(b){Z[0].set(b.n41-b.n11,b.n42-b.n12,b.n43-b.n13,b.n44-
+b.n14);Z[1].set(b.n41+b.n11,b.n42+b.n12,b.n43+b.n13,b.n44+b.n14);Z[2].set(b.n41+b.n21,b.n42+b.n22,b.n43+b.n23,b.n44+b.n24);Z[3].set(b.n41-b.n21,b.n42-b.n22,b.n43-b.n23,b.n44-b.n24);Z[4].set(b.n41-b.n31,b.n42-b.n32,b.n43-b.n33,b.n44-b.n34);Z[5].set(b.n41+b.n31,b.n42+b.n32,b.n43+b.n33,b.n44+b.n34);for(var c,b=0;b<6;b++)c=Z[b],c.divideScalar(Math.sqrt(c.x*c.x+c.y*c.y+c.z*c.z))}function r(b){for(var c=b.matrixWorld,e=-b.geometry.boundingSphere.radius*Math.max(b.scale.x,Math.max(b.scale.y,b.scale.z)),
+d=0;d<6;d++)if(b=Z[d].x*c.n14+Z[d].y*c.n24+Z[d].z*c.n34+Z[d].w,b<=e)return!1;return!0}function m(b,c){b.list[b.count]=c;b.count+=1}function t(b){var c,e,d=b.object,f=b.opaque,h=b.transparent;h.count=0;b=f.count=0;for(c=d.materials.length;b<c;b++)e=d.materials[b],e.transparent?m(h,e):m(f,e)}function u(b){var c,e,d,f,h=b.object,i=b.buffer,j=b.opaque,k=b.transparent;k.count=0;b=j.count=0;for(d=h.materials.length;b<d;b++)if(c=h.materials[b],c instanceof THREE.MeshFaceMaterial){c=0;for(e=i.materials.length;c<
+e;c++)(f=i.materials[c])&&(f.transparent?m(k,f):m(j,f))}else(f=c)&&(f.transparent?m(k,f):m(j,f))}function y(b,c){return c.z-b.z}function C(b){var c,k,p,La=0,m,q,t,B,u=b.lights;X||(X=new THREE.Camera(M.shadowCameraFov,M.shadowMapWidth/M.shadowMapHeight,M.shadowCameraNear,M.shadowCameraFar));c=0;for(k=u.length;c<k;c++)if(p=u[c],p instanceof THREE.SpotLight&&p.castShadow){V=-1;M.shadowMap[La]||(M.shadowMap[La]=new THREE.WebGLRenderTarget(M.shadowMapWidth,M.shadowMapHeight,{minFilter:THREE.LinearFilter,
+magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}));Ra[La]||(Ra[La]=new THREE.Matrix4);m=M.shadowMap[La];q=Ra[La];X.position.copy(p.position);X.target.position.copy(p.target.position);X.update(void 0,!0);b.update(void 0,!1,X);q.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);q.multiplySelf(X.projectionMatrix);q.multiplySelf(X.matrixWorldInverse);X.matrixWorldInverse.flattenToArray(Ta);X.projectionMatrix.flattenToArray(Sa);wa.multiply(X.projectionMatrix,X.matrixWorldInverse);n(wa);M.initWebGLObjects(b);
+K(m);e.clearColor(1,1,1,1);M.clear();e.clearColor(fa.r,fa.g,fa.b,Ja);q=b.__webglObjects.length;p=b.__webglObjectsImmediate.length;for(m=0;m<q;m++)t=b.__webglObjects[m],B=t.object,B.visible&&B.castShadow?!(B instanceof THREE.Mesh)||!B.frustumCulled||r(B)?(B.matrixWorld.flattenToArray(B._objectMatrixArray),D(B,X,!1),t.render=!0):t.render=!1:t.render=!1;j(!0);J(THREE.NormalBlending);for(m=0;m<q;m++)if(t=b.__webglObjects[m],t.render)B=t.object,buffer=t.buffer,h(B),t=B.customDepthMaterial?B.customDepthMaterial:
+B.geometry.morphTargets.length?Ya:Ua,f(X,u,null,t,buffer,B);for(m=0;m<p;m++)t=b.__webglObjectsImmediate[m],B=t.object,B.visible&&B.castShadow&&(B.matrixAutoUpdate&&B.matrixWorld.flattenToArray(B._objectMatrixArray),D(B,X,!1),h(B),program=d(X,u,null,Ua,B),B.render(function(b){i(b,program,Ua.shading)}));La++}}function G(b,c){var d,f,h;d=q.attributes;var i=q.uniforms,j=ta/Ea,k,n=[],p=Ea*0.5,m=ta*0.5,r=!0;e.useProgram(q.program);Va=q.program;L=W=-1;Za||(e.enableVertexAttribArray(q.attributes.position),
+e.enableVertexAttribArray(q.attributes.uv),Za=!0);e.disable(e.CULL_FACE);e.enable(e.BLEND);e.depthMask(!0);e.bindBuffer(e.ARRAY_BUFFER,q.vertexBuffer);e.vertexAttribPointer(d.position,2,e.FLOAT,!1,16,0);e.vertexAttribPointer(d.uv,2,e.FLOAT,!1,16,8);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,q.elementBuffer);e.uniformMatrix4fv(i.projectionMatrix,!1,Sa);e.activeTexture(e.TEXTURE0);e.uniform1i(i.map,0);d=0;for(f=b.__webglSprites.length;d<f;d++)if(h=b.__webglSprites[d],h.visible&&h.opacity!=0)h.useScreenCoordinates?
+h.z=-h.position.z:(h._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,h.matrixWorld,h._modelViewMatrixArray),h.z=-h._modelViewMatrix.n34);b.__webglSprites.sort(y);d=0;for(f=b.__webglSprites.length;d<f;d++)h=b.__webglSprites[d],h.visible&&h.opacity!=0&&h.map&&h.map.image&&h.map.image.width&&(h.useScreenCoordinates?(e.uniform1i(i.useScreenCoordinates,1),e.uniform3f(i.screenPosition,(h.position.x-p)/p,(m-h.position.y)/m,Math.max(0,Math.min(1,h.position.z)))):(e.uniform1i(i.useScreenCoordinates,
+0),e.uniform1i(i.affectedByDistance,h.affectedByDistance?1:0),e.uniformMatrix4fv(i.modelViewMatrix,!1,h._modelViewMatrixArray)),k=h.map.image.width/(h.scaleByViewport?ta:1),n[0]=k*j*h.scale.x,n[1]=k*h.scale.y,e.uniform2f(i.uvScale,h.uvScale.x,h.uvScale.y),e.uniform2f(i.uvOffset,h.uvOffset.x,h.uvOffset.y),e.uniform2f(i.alignment,h.alignment.x,h.alignment.y),e.uniform1f(i.opacity,h.opacity),e.uniform3f(i.color,h.color.r,h.color.g,h.color.b),e.uniform1f(i.rotation,h.rotation),e.uniform2fv(i.scale,n),
+h.mergeWith3D&&!r?(e.enable(e.DEPTH_TEST),r=!0):!h.mergeWith3D&&r&&(e.disable(e.DEPTH_TEST),r=!1),J(h.blending),R(h.map,0),e.drawElements(e.TRIANGLES,6,e.UNSIGNED_SHORT,0));e.enable(e.CULL_FACE);e.enable(e.DEPTH_TEST);e.depthMask(ja)}function D(b,c,e){b._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,b.matrixWorld,b._modelViewMatrixArray);e&&THREE.Matrix4.makeInvert3x3(b._modelViewMatrix).transposeIntoArray(b._normalMatrixArray)}function xa(b){var c,e,d,f;f=b.__materials;b=0;for(e=f.length;b<
+e;b++)if(d=f[b],d.attributes)for(c in d.attributes)if(d.attributes[c].needsUpdate)return!0;return!1}function ya(b){var c,e,d,f;f=b.__materials;b=0;for(e=f.length;b<e;b++)if(d=f[b],d.attributes)for(c in d.attributes)d.attributes[c].needsUpdate=!1}function oa(b,c){var e;for(e=b.length-1;e>=0;e--)b[e].object==c&&b.splice(e,1)}function qa(b){function c(b){var f=[];e=0;for(d=b.length;e<d;e++)b[e]==void 0?f.push("undefined"):f.push(b[e].id);return f.join("_")}var e,d,f,h,i,j,k,n,p={},m=b.morphTargets!==
+void 0?b.morphTargets.length:0;b.geometryGroups={};f=0;for(h=b.faces.length;f<h;f++)i=b.faces[f],j=i.materials,k=c(j),p[k]==void 0&&(p[k]={hash:k,counter:0}),n=p[k].hash+"_"+p[k].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:j,vertices:0,numMorphTargets:m}),i=i instanceof THREE.Face3?3:4,b.geometryGroups[n].vertices+i>65535&&(p[k].counter+=1,n=p[k].hash+"_"+p[k].counter,b.geometryGroups[n]==void 0&&(b.geometryGroups[n]={faces:[],materials:j,vertices:0,numMorphTargets:m})),
+b.geometryGroups[n].faces.push(f),b.geometryGroups[n].vertices+=i;b.geometryGroupsList=[];for(var r in b.geometryGroups)b.geometryGroupsList.push(b.geometryGroups[r])}function ha(b,c,e){b.push({buffer:c,object:e,opaque:{list:[],count:0},transparent:{list:[],count:0}})}function J(b){if(b!=W){switch(b){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)}W=b}}function w(b,c,d){(d.width&d.width-1)==0&&(d.height&d.height-1)==0?(e.texParameteri(b,e.TEXTURE_WRAP_S,Q(c.wrapS)),e.texParameteri(b,e.TEXTURE_WRAP_T,Q(c.wrapT)),e.texParameteri(b,e.TEXTURE_MAG_FILTER,Q(c.magFilter)),e.texParameteri(b,e.TEXTURE_MIN_FILTER,Q(c.minFilter)),
+e.generateMipmap(b)):(e.texParameteri(b,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(b,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(b,e.TEXTURE_MAG_FILTER,ua(c.magFilter)),e.texParameteri(b,e.TEXTURE_MIN_FILTER,ua(c.minFilter)))}function R(b,c){if(b.needsUpdate){if(!b.__webglInit)b.__webglInit=!0,b.__webglTexture=e.createTexture(),M.info.memory.textures++;e.activeTexture(e.TEXTURE0+c);e.bindTexture(e.TEXTURE_2D,b.__webglTexture);b instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D,0,
+Q(b.format),b.image.width,b.image.height,0,Q(b.format),e.UNSIGNED_BYTE,b.image.data):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,b.image);w(e.TEXTURE_2D,b,b.image);b.needsUpdate=!1}else e.activeTexture(e.TEXTURE0+c),e.bindTexture(e.TEXTURE_2D,b.__webglTexture)}function K(b){var c=b instanceof THREE.WebGLRenderTargetCube;if(b&&!b.__webglFramebuffer){if(b.depthBuffer===void 0)b.depthBuffer=!0;if(b.stencilBuffer===void 0)b.stencilBuffer=!0;b.__webglRenderbuffer=e.createRenderbuffer();b.__webglTexture=
+e.createTexture();if(c){e.bindTexture(e.TEXTURE_CUBE_MAP,b.__webglTexture);w(e.TEXTURE_CUBE_MAP,b,b);b.__webglFramebuffer=[];for(var d=0;d<6;d++)b.__webglFramebuffer[d]=e.createFramebuffer(),e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+d,0,Q(b.format),b.width,b.height,0,Q(b.format),Q(b.type),null)}else b.__webglFramebuffer=e.createFramebuffer(),e.bindTexture(e.TEXTURE_2D,b.__webglTexture),w(e.TEXTURE_2D,b,b),e.texImage2D(e.TEXTURE_2D,0,Q(b.format),b.width,b.height,0,Q(b.format),Q(b.type),null);e.bindRenderbuffer(e.RENDERBUFFER,
+b.__webglRenderbuffer);if(c)for(d=0;d<6;++d)e.bindFramebuffer(e.FRAMEBUFFER,b.__webglFramebuffer[d]),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_CUBE_MAP_POSITIVE_X+d,b.__webglTexture,0);else e.bindFramebuffer(e.FRAMEBUFFER,b.__webglFramebuffer),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,b.__webglTexture,0);b.depthBuffer&&!b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_COMPONENT16,b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,
+e.DEPTH_ATTACHMENT,e.RENDERBUFFER,b.__webglRenderbuffer)):b.depthBuffer&&b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,e.DEPTH_STENCIL,b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,b.__webglRenderbuffer)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,b.width,b.height);c?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}var f,h;b?(c=c?b.__webglFramebuffer[b.activeCubeFace]:
+b.__webglFramebuffer,d=b.width,b=b.height,h=f=0):(c=null,d=Ea,b=ta,f=Aa,h=Ha);c!=pa&&(e.bindFramebuffer(e.FRAMEBUFFER,c),e.viewport(f,h,d,b),pa=c)}function ia(b){b instanceof THREE.WebGLRenderTargetCube?(e.bindTexture(e.TEXTURE_CUBE_MAP,b.__webglTexture),e.generateMipmap(e.TEXTURE_CUBE_MAP),e.bindTexture(e.TEXTURE_CUBE_MAP,null)):(e.bindTexture(e.TEXTURE_2D,b.__webglTexture),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null))}function T(b,c){var d;b=="fragment"?d=e.createShader(e.FRAGMENT_SHADER):
+b=="vertex"&&(d=e.createShader(e.VERTEX_SHADER));e.shaderSource(d,c);e.compileShader(d);if(!e.getShaderParameter(d,e.COMPILE_STATUS))return console.error(e.getShaderInfoLog(d)),console.error(c),null;return d}function ua(b){switch(b){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;default:return e.LINEAR}}function Q(b){switch(b){case THREE.RepeatWrapping:return e.REPEAT;case THREE.ClampToEdgeWrapping:return e.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return e.MIRRORED_REPEAT;
+case THREE.NearestFilter:return e.NEAREST;case THREE.NearestMipMapNearestFilter:return e.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return e.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return e.LINEAR;case THREE.LinearMipMapNearestFilter:return e.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return e.LINEAR_MIPMAP_LINEAR;case THREE.ByteType:return e.BYTE;case THREE.UnsignedByteType:return e.UNSIGNED_BYTE;case THREE.ShortType:return e.SHORT;case THREE.UnsignedShortType:return e.UNSIGNED_SHORT;
+case THREE.IntType:return e.INT;case THREE.UnsignedShortType:return e.UNSIGNED_INT;case THREE.FloatType:return e.FLOAT;case THREE.AlphaFormat:return e.ALPHA;case THREE.RGBFormat:return e.RGB;case THREE.RGBAFormat:return e.RGBA;case THREE.LuminanceFormat:return e.LUMINANCE;case THREE.LuminanceAlphaFormat:return e.LUMINANCE_ALPHA}return 0}var M=this,e,Ca=[],Va=null,pa=null,V=-1,ra=null,E=null,W=null,L=null,ja=null,va=null,P=null,za=null,Aa=0,Ha=0,Ea=0,ta=0,Z=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,
+new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],wa=new THREE.Matrix4,Sa=new Float32Array(16),Ta=new Float32Array(16),Ia=new THREE.Vector4,Xa={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}},b=b||{},Fa=b.canvas!==void 0?b.canvas:document.createElement("canvas"),S=b.stencil!==void 0?b.stencil:!0,bb=b.preserveDrawingBuffer!==void 0?b.preserveDrawingBuffer:!1,cb=b.antialias!==void 0?b.antialias:!1,fa=b.clearColor!==void 0?new THREE.Color(b.clearColor):
+new THREE.Color(0),Ja=b.clearAlpha!==void 0?b.clearAlpha:0,Wa=b.maxLights!==void 0?b.maxLights:4;this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0}};this.maxMorphTargets=8;this.domElement=Fa;this.sortObjects=this.autoClear=!0;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMap=[];this.shadowMapEnabled=!1;this.shadowMapSoft=!0;
+var X,Ra=[],b=THREE.ShaderLib.depthRGBA,$a=THREE.UniformsUtils.clone(b.uniforms),Ua=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:$a}),Ya=new THREE.ShaderMaterial({fragmentShader:b.fragmentShader,vertexShader:b.vertexShader,uniforms:$a,morphTargets:!0});Ua._shadowPass=!0;Ya._shadowPass=!0;try{if(!(e=Fa.getContext("experimental-webgl",{antialias:cb,stencil:S,preserveDrawingBuffer:bb})))throw"Error creating WebGL context.";console.log(navigator.userAgent+
+" | "+e.getParameter(e.VERSION)+" | "+e.getParameter(e.VENDOR)+" | "+e.getParameter(e.RENDERER)+" | "+e.getParameter(e.SHADING_LANGUAGE_VERSION))}catch(db){console.error(db)}e.clearColor(0,0,0,1);e.clearDepth(1);e.clearStencil(0);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(fa.r,fa.g,fa.b,Ja);this.context=e;var ab=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS)>
+0,q={};q.vertices=new Float32Array(16);q.faces=new Uint16Array(6);S=0;q.vertices[S++]=-1;q.vertices[S++]=-1;q.vertices[S++]=0;q.vertices[S++]=1;q.vertices[S++]=1;q.vertices[S++]=-1;q.vertices[S++]=1;q.vertices[S++]=1;q.vertices[S++]=1;q.vertices[S++]=1;q.vertices[S++]=1;q.vertices[S++]=0;q.vertices[S++]=-1;q.vertices[S++]=1;q.vertices[S++]=0;S=q.vertices[S++]=0;q.faces[S++]=0;q.faces[S++]=1;q.faces[S++]=2;q.faces[S++]=0;q.faces[S++]=2;q.faces[S++]=3;q.vertexBuffer=e.createBuffer();q.elementBuffer=
+e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,q.vertexBuffer);e.bufferData(e.ARRAY_BUFFER,q.vertices,e.STATIC_DRAW);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,q.elementBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,q.faces,e.STATIC_DRAW);q.program=e.createProgram();e.attachShader(q.program,T("fragment",THREE.ShaderLib.sprite.fragmentShader));e.attachShader(q.program,T("vertex",THREE.ShaderLib.sprite.vertexShader));e.linkProgram(q.program);q.attributes={};q.uniforms={};q.attributes.position=e.getAttribLocation(q.program,
+"position");q.attributes.uv=e.getAttribLocation(q.program,"uv");q.uniforms.uvOffset=e.getUniformLocation(q.program,"uvOffset");q.uniforms.uvScale=e.getUniformLocation(q.program,"uvScale");q.uniforms.rotation=e.getUniformLocation(q.program,"rotation");q.uniforms.scale=e.getUniformLocation(q.program,"scale");q.uniforms.alignment=e.getUniformLocation(q.program,"alignment");q.uniforms.color=e.getUniformLocation(q.program,"color");q.uniforms.map=e.getUniformLocation(q.program,"map");q.uniforms.opacity=
+e.getUniformLocation(q.program,"opacity");q.uniforms.useScreenCoordinates=e.getUniformLocation(q.program,"useScreenCoordinates");q.uniforms.affectedByDistance=e.getUniformLocation(q.program,"affectedByDistance");q.uniforms.screenPosition=e.getUniformLocation(q.program,"screenPosition");q.uniforms.modelViewMatrix=e.getUniformLocation(q.program,"modelViewMatrix");q.uniforms.projectionMatrix=e.getUniformLocation(q.program,"projectionMatrix");var Za=!1;this.setSize=function(b,c){Fa.width=b;Fa.height=
+c;this.setViewport(0,0,Fa.width,Fa.height)};this.setViewport=function(b,c,d,f){Aa=b;Ha=c;Ea=d;ta=f;e.viewport(Aa,Ha,Ea,ta)};this.setScissor=function(b,c,d,f){e.scissor(b,c,d,f)};this.enableScissorTest=function(b){b?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(b,c){fa.setHex(b);Ja=c;e.clearColor(fa.r,fa.g,fa.b,Ja)};this.setClearColor=function(b,c){fa.copy(b);Ja=c;e.clearColor(fa.r,fa.g,fa.b,Ja)};this.getClearColor=function(){return fa};this.getClearAlpha=function(){return Ja};
+this.clear=function(){e.clear(e.COLOR_BUFFER_BIT|e.DEPTH_BUFFER_BIT|e.STENCIL_BUFFER_BIT)};this.getContext=function(){return e};this.deallocateObject=function(b){if(b.__webglInit)if(b.__webglInit=!1,delete b._modelViewMatrix,delete b._normalMatrixArray,delete b._modelViewMatrixArray,delete b._objectMatrixArray,b instanceof THREE.Mesh)for(g in b.geometry.geometryGroups){var c=b.geometry.geometryGroups[g];e.deleteBuffer(c.__webglVertexBuffer);e.deleteBuffer(c.__webglNormalBuffer);e.deleteBuffer(c.__webglTangentBuffer);
+e.deleteBuffer(c.__webglColorBuffer);e.deleteBuffer(c.__webglUVBuffer);e.deleteBuffer(c.__webglUV2Buffer);e.deleteBuffer(c.__webglSkinVertexABuffer);e.deleteBuffer(c.__webglSkinVertexBBuffer);e.deleteBuffer(c.__webglSkinIndicesBuffer);e.deleteBuffer(c.__webglSkinWeightsBuffer);e.deleteBuffer(c.__webglFaceBuffer);e.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,f=c.numMorphTargets;d<f;d++)e.deleteBuffer(c.__webglMorphTargetsBuffers[d]);M.info.memory.geometries--}else if(b instanceof
+THREE.Ribbon)b=b.geometry,e.deleteBuffer(b.__webglVertexBuffer),e.deleteBuffer(b.__webglColorBuffer),M.info.memory.geometries--;else if(b instanceof THREE.Line)b=b.geometry,e.deleteBuffer(b.__webglVertexBuffer),e.deleteBuffer(b.__webglColorBuffer),M.info.memory.geometries--;else if(b instanceof THREE.ParticleSystem)b=b.geometry,e.deleteBuffer(b.__webglVertexBuffer),e.deleteBuffer(b.__webglColorBuffer),M.info.memory.geometries--};this.deallocateTexture=function(b){if(b.__webglInit)b.__webglInit=!1,
+e.deleteTexture(b.__webglTexture),M.info.memory.textures--};this.initMaterial=function(b,c,d,f){var h,i,j,k;b instanceof THREE.MeshDepthMaterial?k="depth":b instanceof THREE.MeshNormalMaterial?k="normal":b instanceof THREE.MeshBasicMaterial?k="basic":b instanceof THREE.MeshLambertMaterial?k="lambert":b instanceof THREE.MeshPhongMaterial?k="phong":b instanceof THREE.LineBasicMaterial?k="basic":b instanceof THREE.ParticleBasicMaterial&&(k="particle_basic");if(k){var n=THREE.ShaderLib[k];b.uniforms=
+THREE.UniformsUtils.clone(n.uniforms);b.vertexShader=n.vertexShader;b.fragmentShader=n.fragmentShader}var p,m,r;p=r=n=0;for(m=c.length;p<m;p++)j=c[p],j instanceof THREE.SpotLight&&r++,j instanceof THREE.DirectionalLight&&r++,j instanceof THREE.PointLight&&n++;n+r<=Wa?p=r:(p=Math.ceil(Wa*r/(n+r)),n=Wa-p);j={directional:p,point:n};n=r=0;for(p=c.length;n<p;n++)m=c[n],m instanceof THREE.SpotLight&&m.castShadow&&r++;var t=50;if(f!==void 0&&f instanceof THREE.SkinnedMesh)t=f.bones.length;var v;a:{p=b.fragmentShader;
+m=b.vertexShader;var n=b.uniforms,c=b.attributes,d={map:!!b.map,envMap:!!b.envMap,lightMap:!!b.lightMap,vertexColors:b.vertexColors,fog:d,useFog:b.fog,sizeAttenuation:b.sizeAttenuation,skinning:b.skinning,morphTargets:b.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:j.directional,maxPointLights:j.point,maxBones:t,shadowMapEnabled:this.shadowMapEnabled&&f.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:r,
+alphaTest:b.alphaTest},q,f=[];k?f.push(k):(f.push(p),f.push(m));for(q in d)f.push(q),f.push(d[q]);k=f.join();q=0;for(f=Ca.length;q<f;q++)if(Ca[q].code==k){v=Ca[q].program;break a}q=e.createProgram();f=[ab?"#define VERTEX_TEXTURES":"","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,"#define MAX_BONES "+d.maxBones,d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":
+"",d.skinning?"#define USE_SKINNING":"",d.morphTargets?"#define USE_MORPHTARGETS":"",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",d.shadowMapSoft?"#define SHADOWMAP_SOFT":"",d.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");
 j=["#ifdef GL_ES\nprecision highp float;\n#endif","#define MAX_DIR_LIGHTS "+d.maxDirLights,"#define MAX_POINT_LIGHTS "+d.maxPointLights,"#define MAX_SHADOWS "+d.maxShadows,d.alphaTest?"#define ALPHATEST "+d.alphaTest:"",d.useFog&&d.fog?"#define USE_FOG":"",d.useFog&&d.fog instanceof THREE.FogExp2?"#define FOG_EXP2":"",d.map?"#define USE_MAP":"",d.envMap?"#define USE_ENVMAP":"",d.lightMap?"#define USE_LIGHTMAP":"",d.vertexColors?"#define USE_COLOR":"",d.shadowMapEnabled?"#define USE_SHADOWMAP":"",
-d.shadowMapSoft?"#define SHADOWMAP_SOFT":"",d.shadowMapSoft?"#define SHADOWMAP_WIDTH "+d.shadowMapWidth.toFixed(1):"",d.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+d.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");e.attachShader(q,Y("fragment",j+p));e.attachShader(q,Y("vertex",f+m));e.linkProgram(q);e.getProgramParameter(q,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(q,e.VALIDATE_STATUS)+", gl error ["+
+d.shadowMapSoft?"#define SHADOWMAP_SOFT":"",d.shadowMapSoft?"#define SHADOWMAP_WIDTH "+d.shadowMapWidth.toFixed(1):"",d.shadowMapSoft?"#define SHADOWMAP_HEIGHT "+d.shadowMapHeight.toFixed(1):"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");e.attachShader(q,T("fragment",j+p));e.attachShader(q,T("vertex",f+m));e.linkProgram(q);e.getProgramParameter(q,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(q,e.VALIDATE_STATUS)+", gl error ["+
 e.getError()+"]");q.uniforms={};q.attributes={};var u,f=["viewMatrix","modelViewMatrix","projectionMatrix","normalMatrix","objectMatrix","cameraPosition","cameraInverseMatrix","boneGlobalMatrices","morphTargetInfluences"];for(u in n)f.push(u);u=f;f=0;for(n=u.length;f<n;f++)p=u[f],q.uniforms[p]=e.getUniformLocation(q,p);f=["position","normal","uv","uv2","tangent","color","skinVertexA","skinVertexB","skinIndex","skinWeight"];for(u=0;u<d.maxMorphTargets;u++)f.push("morphTarget"+u);for(v in c)f.push(v);
-v=f;u=0;for(c=v.length;u<c;u++)d=v[u],q.attributes[d]=e.getAttribLocation(q,d);Ba.push({program:q,code:k});M.info.memory.programs=Ba.length;v=q}b.program=v;v=b.program.attributes;v.position>=0&&e.enableVertexAttribArray(v.position);v.color>=0&&e.enableVertexAttribArray(v.color);v.normal>=0&&e.enableVertexAttribArray(v.normal);v.tangent>=0&&e.enableVertexAttribArray(v.tangent);b.skinning&&v.skinVertexA>=0&&v.skinVertexB>=0&&v.skinIndex>=0&&v.skinWeight>=0&&(e.enableVertexAttribArray(v.skinVertexA),
+v=f;u=0;for(c=v.length;u<c;u++)d=v[u],q.attributes[d]=e.getAttribLocation(q,d);Ca.push({program:q,code:k});M.info.memory.programs=Ca.length;v=q}b.program=v;v=b.program.attributes;v.position>=0&&e.enableVertexAttribArray(v.position);v.color>=0&&e.enableVertexAttribArray(v.color);v.normal>=0&&e.enableVertexAttribArray(v.normal);v.tangent>=0&&e.enableVertexAttribArray(v.tangent);b.skinning&&v.skinVertexA>=0&&v.skinVertexB>=0&&v.skinIndex>=0&&v.skinWeight>=0&&(e.enableVertexAttribArray(v.skinVertexA),
 e.enableVertexAttribArray(v.skinVertexB),e.enableVertexAttribArray(v.skinIndex),e.enableVertexAttribArray(v.skinWeight));if(b.attributes)for(i in b.attributes)v[i]!==void 0&&v[i]>=0&&e.enableVertexAttribArray(v[i]);if(b.morphTargets)for(i=b.numSupportedMorphTargets=0;i<this.maxMorphTargets;i++)u="morphTarget"+i,v[u]>=0&&(e.enableVertexAttribArray(v[u]),b.numSupportedMorphTargets++);b.uniformsList=[];for(h in b.uniforms)b.uniformsList.push([b.uniforms[h],h])};this.clearTarget=function(b,c,d,f){K(b);
-b=0;c&&(b|=e.COLOR_BUFFER_BIT);d&&(b|=e.DEPTH_BUFFER_BIT);f&&(b|=e.STENCIL_BUFFER_BIT);e.clear(b)};this.render=function(b,c,e,m){var q,Pa,w,U,B,E,F,Da,Qa=b.lights,v=b.fog;this.shadowMapEnabled&&C(b,c);M.info.render.calls=0;M.info.render.vertices=0;M.info.render.faces=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Sa);c.projectionMatrix.flattenToArray(Ca);za.multiply(c.projectionMatrix,c.matrixWorldInverse);n(za);this.initWebGLObjects(b);K(e);(this.autoClear||
-m)&&this.clear();B=b.__webglObjects.length;for(m=0;m<B;m++)if(q=b.__webglObjects[m],F=q.object,F.visible)if(!(F instanceof THREE.Mesh)||!F.frustumCulled||r(F)){if(F.matrixWorld.flattenToArray(F._objectMatrixArray),D(F,c,!0),u(q),q.render=!0,this.sortObjects)q.object.renderDepth?q.z=q.object.renderDepth:(Ia.copy(F.position),za.multiplyVector3(Ia),q.z=Ia.z)}else q.render=!1;else q.render=!1;this.sortObjects&&b.__webglObjects.sort(y);E=b.__webglObjectsImmediate.length;for(m=0;m<E;m++)q=b.__webglObjectsImmediate[m],
-F=q.object,F.visible&&(F.matrixAutoUpdate&&F.matrixWorld.flattenToArray(F._objectMatrixArray),D(F,c,!0),t(q));if(b.overrideMaterial){j(b.overrideMaterial.depthTest);J(b.overrideMaterial.blending);for(m=0;m<B;m++)if(q=b.__webglObjects[m],q.render)F=q.object,Da=q.buffer,h(F),f(c,Qa,v,b.overrideMaterial,Da,F);for(m=0;m<E;m++)q=b.__webglObjectsImmediate[m],F=q.object,F.visible&&(h(F),Pa=d(c,Qa,v,b.overrideMaterial,F),F.render(function(c){i(c,Pa,b.overrideMaterial.shading)}))}else{J(THREE.NormalBlending);
+b=0;c&&(b|=e.COLOR_BUFFER_BIT);d&&(b|=e.DEPTH_BUFFER_BIT);f&&(b|=e.STENCIL_BUFFER_BIT);e.clear(b)};this.render=function(b,c,e,m){var q,Pa,w,U,B,E,F,Da,Qa=b.lights,v=b.fog;V=-1;this.shadowMapEnabled&&C(b,c);M.info.render.calls=0;M.info.render.vertices=0;M.info.render.faces=0;c.matrixAutoUpdate&&c.update(void 0,!0);b.update(void 0,!1,c);c.matrixWorldInverse.flattenToArray(Ta);c.projectionMatrix.flattenToArray(Sa);wa.multiply(c.projectionMatrix,c.matrixWorldInverse);n(wa);this.initWebGLObjects(b);K(e);
+(this.autoClear||m)&&this.clear();B=b.__webglObjects.length;for(m=0;m<B;m++)if(q=b.__webglObjects[m],F=q.object,F.visible)if(!(F instanceof THREE.Mesh)||!F.frustumCulled||r(F)){if(F.matrixWorld.flattenToArray(F._objectMatrixArray),D(F,c,!0),u(q),q.render=!0,this.sortObjects)q.object.renderDepth?q.z=q.object.renderDepth:(Ia.copy(F.position),wa.multiplyVector3(Ia),q.z=Ia.z)}else q.render=!1;else q.render=!1;this.sortObjects&&b.__webglObjects.sort(y);E=b.__webglObjectsImmediate.length;for(m=0;m<E;m++)q=
+b.__webglObjectsImmediate[m],F=q.object,F.visible&&(F.matrixAutoUpdate&&F.matrixWorld.flattenToArray(F._objectMatrixArray),D(F,c,!0),t(q));if(b.overrideMaterial){j(b.overrideMaterial.depthTest);J(b.overrideMaterial.blending);for(m=0;m<B;m++)if(q=b.__webglObjects[m],q.render)F=q.object,Da=q.buffer,h(F),f(c,Qa,v,b.overrideMaterial,Da,F);for(m=0;m<E;m++)q=b.__webglObjectsImmediate[m],F=q.object,F.visible&&(h(F),Pa=d(c,Qa,v,b.overrideMaterial,F),F.render(function(c){i(c,Pa,b.overrideMaterial.shading)}))}else{J(THREE.NormalBlending);
 for(m=B-1;m>=0;m--)if(q=b.__webglObjects[m],q.render){F=q.object;Da=q.buffer;w=q.opaque;h(F);for(q=0;q<w.count;q++)U=w.list[q],j(U.depthTest),k(U.depthWrite),p(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),f(c,Qa,v,U,Da,F)}for(m=0;m<E;m++)if(q=b.__webglObjectsImmediate[m],F=q.object,F.visible){w=q.opaque;h(F);for(q=0;q<w.count;q++)U=w.list[q],j(U.depthTest),k(U.depthWrite),p(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),Pa=d(c,Qa,v,U,F),F.render(function(b){i(b,Pa,U.shading)})}for(m=
 0;m<B;m++)if(q=b.__webglObjects[m],q.render){F=q.object;Da=q.buffer;w=q.transparent;h(F);for(q=0;q<w.count;q++)U=w.list[q],J(U.blending),j(U.depthTest),k(U.depthWrite),p(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),f(c,Qa,v,U,Da,F)}for(m=0;m<E;m++)if(q=b.__webglObjectsImmediate[m],F=q.object,F.visible){w=q.transparent;h(F);for(q=0;q<w.count;q++)U=w.list[q],J(U.blending),j(U.depthTest),k(U.depthWrite),p(U.polygonOffset,U.polygonOffsetFactor,U.polygonOffsetUnits),Pa=d(c,Qa,v,U,F),F.render(function(b){i(b,
-Pa,U.shading)})}}b.__webglSprites.length&&G(b,c);e&&e.minFilter!==THREE.NearestFilter&&e.minFilter!==THREE.LinearFilter&&ja(e)};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var d=b.__objectsAdded[0],f=b,h=void 0,i=void 0,j=void 0;if(!d.__webglInit)if(d.__webglInit=!0,d._modelViewMatrix=new THREE.Matrix4,d._normalMatrixArray=new Float32Array(9),d._modelViewMatrixArray=new Float32Array(16),
+Pa,U.shading)})}}b.__webglSprites.length&&G(b,c);e&&e.minFilter!==THREE.NearestFilter&&e.minFilter!==THREE.LinearFilter&&ia(e)};this.initWebGLObjects=function(b){if(!b.__webglObjects)b.__webglObjects=[],b.__webglObjectsImmediate=[],b.__webglSprites=[];for(;b.__objectsAdded.length;){var d=b.__objectsAdded[0],f=b,h=void 0,i=void 0,j=void 0;if(!d.__webglInit)if(d.__webglInit=!0,d._modelViewMatrix=new THREE.Matrix4,d._normalMatrixArray=new Float32Array(9),d._modelViewMatrixArray=new Float32Array(16),
 d._objectMatrixArray=new Float32Array(16),d.matrixWorld.flattenToArray(d._objectMatrixArray),d instanceof THREE.Mesh)for(h in i=d.geometry,i.geometryGroups==void 0&&qa(i),i.geometryGroups){if(j=i.geometryGroups[h],!j.__webglVertexBuffer){var k=j;k.__webglVertexBuffer=e.createBuffer();k.__webglNormalBuffer=e.createBuffer();k.__webglTangentBuffer=e.createBuffer();k.__webglColorBuffer=e.createBuffer();k.__webglUVBuffer=e.createBuffer();k.__webglUV2Buffer=e.createBuffer();k.__webglSkinVertexABuffer=e.createBuffer();
 k.__webglSkinVertexBBuffer=e.createBuffer();k.__webglSkinIndicesBuffer=e.createBuffer();k.__webglSkinWeightsBuffer=e.createBuffer();k.__webglFaceBuffer=e.createBuffer();k.__webglLineBuffer=e.createBuffer();if(k.numMorphTargets){var n=void 0,m=void 0;k.__webglMorphTargetsBuffers=[];n=0;for(m=k.numMorphTargets;n<m;n++)k.__webglMorphTargetsBuffers.push(e.createBuffer())}M.info.memory.geometries++;for(var k=d,p=void 0,q=void 0,r=void 0,t=r=void 0,v=void 0,u=void 0,w=u=n=0,y=r=q=void 0,r=m=y=q=p=void 0,
 t=k.geometry,v=t.faces,y=j.faces,p=0,q=y.length;p<q;p++)r=y[p],r=v[r],r instanceof THREE.Face3?(n+=3,u+=1,w+=3):r instanceof THREE.Face4&&(n+=4,u+=2,w+=4);for(var p=j,q=k,C=y=v=void 0,H=void 0,C=void 0,r=[],v=0,y=q.materials.length;v<y;v++)if(C=q.materials[v],C instanceof THREE.MeshFaceMaterial){C=0;for(l=p.materials.length;C<l;C++)(H=p.materials[C])&&r.push(H)}else(H=C)&&r.push(H);p=r;j.__materials=p;a:{v=q=void 0;y=p.length;for(q=0;q<y;q++)if(v=p[q],v.map||v.lightMap||v instanceof THREE.ShaderMaterial){q=
@@ -266,32 +266,32 @@ M.info.memory.geometries++,j=i,k=j.vertices.length,j.__vertexArray=new Float32Ar
 n;j.__materials=k.materials;w=u=m=void 0;m=0;for(u=k.materials.length;m<u;m++)if(w=k.materials[m],w.attributes){if(j.__webglCustomAttributes===void 0)j.__webglCustomAttributes={};for(a in w.attributes){originalAttribute=w.attributes[a];attribute={};for(property in originalAttribute)attribute[property]=originalAttribute[property];if(!attribute.__webglInitialized||attribute.createUniqueBuffers)attribute.__webglInitialized=!0,size=1,attribute.type==="v2"?size=2:attribute.type==="v3"?size=3:attribute.type===
 "v4"?size=4:attribute.type==="c"&&(size=3),attribute.size=size,attribute.array=new Float32Array(n*size),attribute.buffer=e.createBuffer(),attribute.buffer.belongsToAttribute=a,originalAttribute.needsUpdate=!0,attribute.__original=originalAttribute;j.__webglCustomAttributes[a]=attribute}}i.__dirtyVertices=!0;i.__dirtyColors=!0}if(!d.__webglActive){if(d instanceof THREE.Mesh)for(h in i=d.geometry,i.geometryGroups)j=i.geometryGroups[h],ha(f.__webglObjects,j,d);else d instanceof THREE.Ribbon||d instanceof
 THREE.Line||d instanceof THREE.ParticleSystem?(i=d.geometry,ha(f.__webglObjects,i,d)):THREE.MarchingCubes!==void 0&&d instanceof THREE.MarchingCubes?f.__webglObjectsImmediate.push({object:d,opaque:{list:[],count:0},transparent:{list:[],count:0}}):d instanceof THREE.Sprite&&f.__webglSprites.push(d);d.__webglActive=!0}b.__objectsAdded.splice(0,1)}for(;b.__objectsRemoved.length;){d=b.__objectsRemoved[0];f=b;if(d instanceof THREE.Mesh||d instanceof THREE.ParticleSystem||d instanceof THREE.Ribbon||d instanceof
-THREE.Line)oa(f.__webglObjects,d);else if(d instanceof THREE.Sprite){f=f.__webglSprites;h=d;i=void 0;for(i=f.length-1;i>=0;i--)f[i]==h&&f.splice(i,1)}else d instanceof THREE.MarchingCubes&&oa(f.__webglObjectsImmediate,d);d.__webglActive=!1;b.__objectsRemoved.splice(0,1)}d=0;for(f=b.__webglObjects.length;d<f;d++)if(i=b.__webglObjects[d].object,m=j=h=void 0,i instanceof THREE.Mesh){h=i.geometry;k=0;for(n=h.geometryGroupsList.length;k<n;k++)if(j=h.geometryGroupsList[k],m=wa(j),h.__dirtyVertices||h.__dirtyMorphTargets||
-h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||m)if(m=j,u=e.DYNAMIC_DRAW,w=!h.dynamic,m.__inittedArrays){var D=p=t=void 0,z=void 0,G=D=void 0,E=void 0,J=void 0,I=void 0,N=H=C=r=y=v=q=void 0,O=void 0,K=void 0,s=z=I=z=J=E=void 0,o=void 0,A=o=s=E=void 0,P=void 0,S=A=o=s=D=D=G=I=z=A=o=s=P=A=o=s=P=A=o=s=void 0,ga=0,L=0,W=0,Y=0,T=0,Q=0,X=0,R=0,ka=0,x=0,la=0,A=s=0,A=void 0,ma=m.__vertexArray,ia=m.__uvArray,ja=m.__uv2Array,V=m.__normalArray,$=m.__tangentArray,na=m.__colorArray,
-aa=m.__skinVertexAArray,ca=m.__skinVertexBArray,da=m.__skinIndexArray,ea=m.__skinWeightArray,pa=m.__morphTargetsArrays,Z=m.__webglCustomAttributes,o=void 0,fa=m.__faceArray,Aa=m.__lineArray,va=m.__needsSmoothNormals,v=m.__vertexColorType,q=m.__uvType,y=m.__normalType,sa=i.geometry,ta=sa.__dirtyVertices,ua=sa.__dirtyElements,ra=sa.__dirtyUvs,za=sa.__dirtyNormals,Ba=sa.__dirtyTangents,Ca=sa.__dirtyColors,Ea=sa.__dirtyMorphTargets,ya=sa.vertices,Fa=m.faces,Ja=sa.faces,Ga=sa.faceVertexUvs[0],Ia=sa.faceVertexUvs[1],
-Ma=sa.skinVerticesA,Na=sa.skinVerticesB,Oa=sa.skinIndices,Ka=sa.skinWeights,Ha=sa.morphTargets;if(Z)for(S in Z)Z[S].offset=0,Z[S].offsetSrc=0;t=0;for(p=Fa.length;t<p;t++)if(D=Fa[t],z=Ja[D],Ga&&(r=Ga[D]),Ia&&(C=Ia[D]),D=z.vertexNormals,G=z.normal,E=z.vertexColors,J=z.color,I=z.vertexTangents,z instanceof THREE.Face3){if(ta)H=ya[z.a].position,N=ya[z.b].position,O=ya[z.c].position,ma[L]=H.x,ma[L+1]=H.y,ma[L+2]=H.z,ma[L+3]=N.x,ma[L+4]=N.y,ma[L+5]=N.z,ma[L+6]=O.x,ma[L+7]=O.y,ma[L+8]=O.z,L+=9;if(Z)for(S in Z)if(o=
+THREE.Line)oa(f.__webglObjects,d);else if(d instanceof THREE.Sprite){f=f.__webglSprites;h=d;i=void 0;for(i=f.length-1;i>=0;i--)f[i]==h&&f.splice(i,1)}else d instanceof THREE.MarchingCubes&&oa(f.__webglObjectsImmediate,d);d.__webglActive=!1;b.__objectsRemoved.splice(0,1)}d=0;for(f=b.__webglObjects.length;d<f;d++)if(i=b.__webglObjects[d].object,m=j=h=void 0,i instanceof THREE.Mesh){h=i.geometry;k=0;for(n=h.geometryGroupsList.length;k<n;k++)if(j=h.geometryGroupsList[k],m=xa(j),h.__dirtyVertices||h.__dirtyMorphTargets||
+h.__dirtyElements||h.__dirtyUvs||h.__dirtyNormals||h.__dirtyColors||h.__dirtyTangents||m)if(m=j,u=e.DYNAMIC_DRAW,w=!h.dynamic,m.__inittedArrays){var D=p=t=void 0,z=void 0,G=D=void 0,E=void 0,J=void 0,I=void 0,N=H=C=r=y=v=q=void 0,O=void 0,K=void 0,s=z=I=z=J=E=void 0,o=void 0,A=o=s=E=void 0,P=void 0,S=A=o=s=D=D=G=I=z=A=o=s=P=A=o=s=P=A=o=s=void 0,ga=0,L=0,V=0,W=0,T=0,Q=0,Y=0,R=0,ka=0,x=0,la=0,A=s=0,A=void 0,ma=m.__vertexArray,ia=m.__uvArray,ja=m.__uv2Array,X=m.__normalArray,$=m.__tangentArray,na=m.__colorArray,
+aa=m.__skinVertexAArray,ca=m.__skinVertexBArray,da=m.__skinIndexArray,ea=m.__skinWeightArray,ra=m.__morphTargetsArrays,Z=m.__webglCustomAttributes,o=void 0,fa=m.__faceArray,Ba=m.__lineArray,va=m.__needsSmoothNormals,v=m.__vertexColorType,q=m.__uvType,y=m.__normalType,sa=i.geometry,ta=sa.__dirtyVertices,ua=sa.__dirtyElements,pa=sa.__dirtyUvs,wa=sa.__dirtyNormals,za=sa.__dirtyTangents,Ca=sa.__dirtyColors,Ea=sa.__dirtyMorphTargets,Aa=sa.vertices,Fa=m.faces,Ja=sa.faces,Ha=sa.faceVertexUvs[0],Ia=sa.faceVertexUvs[1],
+Ma=sa.skinVerticesA,Na=sa.skinVerticesB,Oa=sa.skinIndices,Ka=sa.skinWeights,Ga=sa.morphTargets;if(Z)for(S in Z)Z[S].offset=0,Z[S].offsetSrc=0;t=0;for(p=Fa.length;t<p;t++)if(D=Fa[t],z=Ja[D],Ha&&(r=Ha[D]),Ia&&(C=Ia[D]),D=z.vertexNormals,G=z.normal,E=z.vertexColors,J=z.color,I=z.vertexTangents,z instanceof THREE.Face3){if(ta)H=Aa[z.a].position,N=Aa[z.b].position,O=Aa[z.c].position,ma[L]=H.x,ma[L+1]=H.y,ma[L+2]=H.z,ma[L+3]=N.x,ma[L+4]=N.y,ma[L+5]=N.z,ma[L+6]=O.x,ma[L+7]=O.y,ma[L+8]=O.z,L+=9;if(Z)for(S in Z)if(o=
 Z[S],o.__original.needsUpdate)s=o.offset,A=o.offsetSrc,o.size===1?(o.boundTo===void 0||o.boundTo==="vertices"?(o.array[s]=o.value[z.a],o.array[s+1]=o.value[z.b],o.array[s+2]=o.value[z.c]):o.boundTo==="faces"?(A=o.value[A],o.array[s]=A,o.array[s+1]=A,o.array[s+2]=A,o.offsetSrc++):o.boundTo==="faceVertices"&&(o.array[s]=o.value[A],o.array[s+1]=o.value[A+1],o.array[s+2]=o.value[A+2],o.offsetSrc+=3),o.offset+=3):(o.boundTo===void 0||o.boundTo==="vertices"?(H=o.value[z.a],N=o.value[z.b],O=o.value[z.c]):
 o.boundTo==="faces"?(O=N=H=A=o.value[A],o.offsetSrc++):o.boundTo==="faceVertices"&&(H=o.value[A],N=o.value[A+1],O=o.value[A+2],o.offsetSrc+=3),o.size===2?(o.array[s]=H.x,o.array[s+1]=H.y,o.array[s+2]=N.x,o.array[s+3]=N.y,o.array[s+4]=O.x,o.array[s+5]=O.y,o.offset+=6):o.size===3?(o.type==="c"?(o.array[s]=H.r,o.array[s+1]=H.g,o.array[s+2]=H.b,o.array[s+3]=N.r,o.array[s+4]=N.g,o.array[s+5]=N.b,o.array[s+6]=O.r,o.array[s+7]=O.g,o.array[s+8]=O.b):(o.array[s]=H.x,o.array[s+1]=H.y,o.array[s+2]=H.z,o.array[s+
-3]=N.x,o.array[s+4]=N.y,o.array[s+5]=N.z,o.array[s+6]=O.x,o.array[s+7]=O.y,o.array[s+8]=O.z),o.offset+=9):(o.array[s]=H.x,o.array[s+1]=H.y,o.array[s+2]=H.z,o.array[s+3]=H.w,o.array[s+4]=N.x,o.array[s+5]=N.y,o.array[s+6]=N.z,o.array[s+7]=N.w,o.array[s+8]=O.x,o.array[s+9]=O.y,o.array[s+10]=O.z,o.array[s+11]=O.w,o.offset+=12));if(Ea){s=0;for(o=Ha.length;s<o;s++)H=Ha[s].vertices[z.a].position,N=Ha[s].vertices[z.b].position,O=Ha[s].vertices[z.c].position,A=pa[s],A[la]=H.x,A[la+1]=H.y,A[la+2]=H.z,A[la+
+3]=N.x,o.array[s+4]=N.y,o.array[s+5]=N.z,o.array[s+6]=O.x,o.array[s+7]=O.y,o.array[s+8]=O.z),o.offset+=9):(o.array[s]=H.x,o.array[s+1]=H.y,o.array[s+2]=H.z,o.array[s+3]=H.w,o.array[s+4]=N.x,o.array[s+5]=N.y,o.array[s+6]=N.z,o.array[s+7]=N.w,o.array[s+8]=O.x,o.array[s+9]=O.y,o.array[s+10]=O.z,o.array[s+11]=O.w,o.offset+=12));if(Ea){s=0;for(o=Ga.length;s<o;s++)H=Ga[s].vertices[z.a].position,N=Ga[s].vertices[z.b].position,O=Ga[s].vertices[z.c].position,A=ra[s],A[la]=H.x,A[la+1]=H.y,A[la+2]=H.z,A[la+
 3]=N.x,A[la+4]=N.y,A[la+5]=N.z,A[la+6]=O.x,A[la+7]=O.y,A[la+8]=O.z;la+=9}if(Ka.length)s=Ka[z.a],o=Ka[z.b],A=Ka[z.c],ea[x]=s.x,ea[x+1]=s.y,ea[x+2]=s.z,ea[x+3]=s.w,ea[x+4]=o.x,ea[x+5]=o.y,ea[x+6]=o.z,ea[x+7]=o.w,ea[x+8]=A.x,ea[x+9]=A.y,ea[x+10]=A.z,ea[x+11]=A.w,s=Oa[z.a],o=Oa[z.b],A=Oa[z.c],da[x]=s.x,da[x+1]=s.y,da[x+2]=s.z,da[x+3]=s.w,da[x+4]=o.x,da[x+5]=o.y,da[x+6]=o.z,da[x+7]=o.w,da[x+8]=A.x,da[x+9]=A.y,da[x+10]=A.z,da[x+11]=A.w,s=Ma[z.a],o=Ma[z.b],A=Ma[z.c],aa[x]=s.x,aa[x+1]=s.y,aa[x+2]=s.z,aa[x+
-3]=1,aa[x+4]=o.x,aa[x+5]=o.y,aa[x+6]=o.z,aa[x+7]=1,aa[x+8]=A.x,aa[x+9]=A.y,aa[x+10]=A.z,aa[x+11]=1,s=Na[z.a],o=Na[z.b],A=Na[z.c],ca[x]=s.x,ca[x+1]=s.y,ca[x+2]=s.z,ca[x+3]=1,ca[x+4]=o.x,ca[x+5]=o.y,ca[x+6]=o.z,ca[x+7]=1,ca[x+8]=A.x,ca[x+9]=A.y,ca[x+10]=A.z,ca[x+11]=1,x+=12;if(Ca&&v)E.length==3&&v==THREE.VertexColors?(z=E[0],s=E[1],o=E[2]):o=s=z=J,na[ka]=z.r,na[ka+1]=z.g,na[ka+2]=z.b,na[ka+3]=s.r,na[ka+4]=s.g,na[ka+5]=s.b,na[ka+6]=o.r,na[ka+7]=o.g,na[ka+8]=o.b,ka+=9;if(Ba&&sa.hasTangents)E=I[0],J=I[1],
-z=I[2],$[X]=E.x,$[X+1]=E.y,$[X+2]=E.z,$[X+3]=E.w,$[X+4]=J.x,$[X+5]=J.y,$[X+6]=J.z,$[X+7]=J.w,$[X+8]=z.x,$[X+9]=z.y,$[X+10]=z.z,$[X+11]=z.w,X+=12;if(za&&y)if(D.length==3&&va)for(I=0;I<3;I++)G=D[I],V[Q]=G.x,V[Q+1]=G.y,V[Q+2]=G.z,Q+=3;else for(I=0;I<3;I++)V[Q]=G.x,V[Q+1]=G.y,V[Q+2]=G.z,Q+=3;if(ra&&r!==void 0&&q)for(I=0;I<3;I++)D=r[I],ia[W]=D.u,ia[W+1]=D.v,W+=2;if(ra&&C!==void 0&&q)for(I=0;I<3;I++)D=C[I],ja[Y]=D.u,ja[Y+1]=D.v,Y+=2;ua&&(fa[T]=ga,fa[T+1]=ga+1,fa[T+2]=ga+2,T+=3,Aa[R]=ga,Aa[R+1]=ga+1,Aa[R+
-2]=ga,Aa[R+3]=ga+2,Aa[R+4]=ga+1,Aa[R+5]=ga+2,R+=6,ga+=3)}else if(z instanceof THREE.Face4){if(ta)H=ya[z.a].position,N=ya[z.b].position,O=ya[z.c].position,K=ya[z.d].position,ma[L]=H.x,ma[L+1]=H.y,ma[L+2]=H.z,ma[L+3]=N.x,ma[L+4]=N.y,ma[L+5]=N.z,ma[L+6]=O.x,ma[L+7]=O.y,ma[L+8]=O.z,ma[L+9]=K.x,ma[L+10]=K.y,ma[L+11]=K.z,L+=12;if(Z)for(S in Z)if(o=Z[S],o.__original.needsUpdate)s=o.offset,A=o.offsetSrc,o.size===1?(o.boundTo===void 0||o.boundTo==="vertices"?(o.array[s]=o.value[z.a],o.array[s+1]=o.value[z.b],
+3]=1,aa[x+4]=o.x,aa[x+5]=o.y,aa[x+6]=o.z,aa[x+7]=1,aa[x+8]=A.x,aa[x+9]=A.y,aa[x+10]=A.z,aa[x+11]=1,s=Na[z.a],o=Na[z.b],A=Na[z.c],ca[x]=s.x,ca[x+1]=s.y,ca[x+2]=s.z,ca[x+3]=1,ca[x+4]=o.x,ca[x+5]=o.y,ca[x+6]=o.z,ca[x+7]=1,ca[x+8]=A.x,ca[x+9]=A.y,ca[x+10]=A.z,ca[x+11]=1,x+=12;if(Ca&&v)E.length==3&&v==THREE.VertexColors?(z=E[0],s=E[1],o=E[2]):o=s=z=J,na[ka]=z.r,na[ka+1]=z.g,na[ka+2]=z.b,na[ka+3]=s.r,na[ka+4]=s.g,na[ka+5]=s.b,na[ka+6]=o.r,na[ka+7]=o.g,na[ka+8]=o.b,ka+=9;if(za&&sa.hasTangents)E=I[0],J=I[1],
+z=I[2],$[Y]=E.x,$[Y+1]=E.y,$[Y+2]=E.z,$[Y+3]=E.w,$[Y+4]=J.x,$[Y+5]=J.y,$[Y+6]=J.z,$[Y+7]=J.w,$[Y+8]=z.x,$[Y+9]=z.y,$[Y+10]=z.z,$[Y+11]=z.w,Y+=12;if(wa&&y)if(D.length==3&&va)for(I=0;I<3;I++)G=D[I],X[Q]=G.x,X[Q+1]=G.y,X[Q+2]=G.z,Q+=3;else for(I=0;I<3;I++)X[Q]=G.x,X[Q+1]=G.y,X[Q+2]=G.z,Q+=3;if(pa&&r!==void 0&&q)for(I=0;I<3;I++)D=r[I],ia[V]=D.u,ia[V+1]=D.v,V+=2;if(pa&&C!==void 0&&q)for(I=0;I<3;I++)D=C[I],ja[W]=D.u,ja[W+1]=D.v,W+=2;ua&&(fa[T]=ga,fa[T+1]=ga+1,fa[T+2]=ga+2,T+=3,Ba[R]=ga,Ba[R+1]=ga+1,Ba[R+
+2]=ga,Ba[R+3]=ga+2,Ba[R+4]=ga+1,Ba[R+5]=ga+2,R+=6,ga+=3)}else if(z instanceof THREE.Face4){if(ta)H=Aa[z.a].position,N=Aa[z.b].position,O=Aa[z.c].position,K=Aa[z.d].position,ma[L]=H.x,ma[L+1]=H.y,ma[L+2]=H.z,ma[L+3]=N.x,ma[L+4]=N.y,ma[L+5]=N.z,ma[L+6]=O.x,ma[L+7]=O.y,ma[L+8]=O.z,ma[L+9]=K.x,ma[L+10]=K.y,ma[L+11]=K.z,L+=12;if(Z)for(S in Z)if(o=Z[S],o.__original.needsUpdate)s=o.offset,A=o.offsetSrc,o.size===1?(o.boundTo===void 0||o.boundTo==="vertices"?(o.array[s]=o.value[z.a],o.array[s+1]=o.value[z.b],
 o.array[s+2]=o.value[z.c],o.array[s+3]=o.value[z.d]):o.boundTo==="faces"?(A=o.value[A],o.array[s]=A,o.array[s+1]=A,o.array[s+2]=A,o.array[s+3]=A,o.offsetSrc++):o.boundTo==="faceVertices"&&(o.array[s]=o.value[A],o.array[s+1]=o.value[A+1],o.array[s+2]=o.value[A+2],o.array[s+3]=o.value[A+3],o.offsetSrc+=4),o.offset+=4):(o.boundTo===void 0||o.boundTo==="vertices"?(H=o.value[z.a],N=o.value[z.b],O=o.value[z.c],K=o.value[z.d]):o.boundTo==="faces"?(K=O=N=H=A=o.value[A],o.offsetSrc++):o.boundTo==="faceVertices"&&
 (H=o.value[A],N=o.value[A+1],O=o.value[A+2],K=o.value[A+3],o.offsetSrc+=4),o.size===2?(o.array[s]=H.x,o.array[s+1]=H.y,o.array[s+2]=N.x,o.array[s+3]=N.y,o.array[s+4]=O.x,o.array[s+5]=O.y,o.array[s+6]=K.x,o.array[s+7]=K.y,o.offset+=8):o.size===3?(o.type==="c"?(o.array[s]=H.r,o.array[s+1]=H.g,o.array[s+2]=H.b,o.array[s+3]=N.r,o.array[s+4]=N.g,o.array[s+5]=N.b,o.array[s+6]=O.r,o.array[s+7]=O.g,o.array[s+8]=O.b,o.array[s+9]=K.r,o.array[s+10]=K.g,o.array[s+11]=K.b):(o.array[s]=H.x,o.array[s+1]=H.y,o.array[s+
-2]=H.z,o.array[s+3]=N.x,o.array[s+4]=N.y,o.array[s+5]=N.z,o.array[s+6]=O.x,o.array[s+7]=O.y,o.array[s+8]=O.z,o.array[s+9]=K.x,o.array[s+10]=K.y,o.array[s+11]=K.z),o.offset+=12):(o.array[s]=H.x,o.array[s+1]=H.y,o.array[s+2]=H.z,o.array[s+3]=H.w,o.array[s+4]=N.x,o.array[s+5]=N.y,o.array[s+6]=N.z,o.array[s+7]=N.w,o.array[s+8]=O.x,o.array[s+9]=O.y,o.array[s+10]=O.z,o.array[s+11]=O.w,o.array[s+12]=K.x,o.array[s+13]=K.y,o.array[s+14]=K.z,o.array[s+15]=K.w,o.offset+=16));if(Ea){s=0;for(o=Ha.length;s<o;s++)H=
-Ha[s].vertices[z.a].position,N=Ha[s].vertices[z.b].position,O=Ha[s].vertices[z.c].position,K=Ha[s].vertices[z.d].position,A=pa[s],A[la]=H.x,A[la+1]=H.y,A[la+2]=H.z,A[la+3]=N.x,A[la+4]=N.y,A[la+5]=N.z,A[la+6]=O.x,A[la+7]=O.y,A[la+8]=O.z,A[la+9]=K.x,A[la+10]=K.y,A[la+11]=K.z;la+=12}if(Ka.length)s=Ka[z.a],o=Ka[z.b],A=Ka[z.c],P=Ka[z.d],ea[x]=s.x,ea[x+1]=s.y,ea[x+2]=s.z,ea[x+3]=s.w,ea[x+4]=o.x,ea[x+5]=o.y,ea[x+6]=o.z,ea[x+7]=o.w,ea[x+8]=A.x,ea[x+9]=A.y,ea[x+10]=A.z,ea[x+11]=A.w,ea[x+12]=P.x,ea[x+13]=P.y,
+2]=H.z,o.array[s+3]=N.x,o.array[s+4]=N.y,o.array[s+5]=N.z,o.array[s+6]=O.x,o.array[s+7]=O.y,o.array[s+8]=O.z,o.array[s+9]=K.x,o.array[s+10]=K.y,o.array[s+11]=K.z),o.offset+=12):(o.array[s]=H.x,o.array[s+1]=H.y,o.array[s+2]=H.z,o.array[s+3]=H.w,o.array[s+4]=N.x,o.array[s+5]=N.y,o.array[s+6]=N.z,o.array[s+7]=N.w,o.array[s+8]=O.x,o.array[s+9]=O.y,o.array[s+10]=O.z,o.array[s+11]=O.w,o.array[s+12]=K.x,o.array[s+13]=K.y,o.array[s+14]=K.z,o.array[s+15]=K.w,o.offset+=16));if(Ea){s=0;for(o=Ga.length;s<o;s++)H=
+Ga[s].vertices[z.a].position,N=Ga[s].vertices[z.b].position,O=Ga[s].vertices[z.c].position,K=Ga[s].vertices[z.d].position,A=ra[s],A[la]=H.x,A[la+1]=H.y,A[la+2]=H.z,A[la+3]=N.x,A[la+4]=N.y,A[la+5]=N.z,A[la+6]=O.x,A[la+7]=O.y,A[la+8]=O.z,A[la+9]=K.x,A[la+10]=K.y,A[la+11]=K.z;la+=12}if(Ka.length)s=Ka[z.a],o=Ka[z.b],A=Ka[z.c],P=Ka[z.d],ea[x]=s.x,ea[x+1]=s.y,ea[x+2]=s.z,ea[x+3]=s.w,ea[x+4]=o.x,ea[x+5]=o.y,ea[x+6]=o.z,ea[x+7]=o.w,ea[x+8]=A.x,ea[x+9]=A.y,ea[x+10]=A.z,ea[x+11]=A.w,ea[x+12]=P.x,ea[x+13]=P.y,
 ea[x+14]=P.z,ea[x+15]=P.w,s=Oa[z.a],o=Oa[z.b],A=Oa[z.c],P=Oa[z.d],da[x]=s.x,da[x+1]=s.y,da[x+2]=s.z,da[x+3]=s.w,da[x+4]=o.x,da[x+5]=o.y,da[x+6]=o.z,da[x+7]=o.w,da[x+8]=A.x,da[x+9]=A.y,da[x+10]=A.z,da[x+11]=A.w,da[x+12]=P.x,da[x+13]=P.y,da[x+14]=P.z,da[x+15]=P.w,s=Ma[z.a],o=Ma[z.b],A=Ma[z.c],P=Ma[z.d],aa[x]=s.x,aa[x+1]=s.y,aa[x+2]=s.z,aa[x+3]=1,aa[x+4]=o.x,aa[x+5]=o.y,aa[x+6]=o.z,aa[x+7]=1,aa[x+8]=A.x,aa[x+9]=A.y,aa[x+10]=A.z,aa[x+11]=1,aa[x+12]=P.x,aa[x+13]=P.y,aa[x+14]=P.z,aa[x+15]=1,s=Na[z.a],o=
-Na[z.b],A=Na[z.c],z=Na[z.d],ca[x]=s.x,ca[x+1]=s.y,ca[x+2]=s.z,ca[x+3]=1,ca[x+4]=o.x,ca[x+5]=o.y,ca[x+6]=o.z,ca[x+7]=1,ca[x+8]=A.x,ca[x+9]=A.y,ca[x+10]=A.z,ca[x+11]=1,ca[x+12]=z.x,ca[x+13]=z.y,ca[x+14]=z.z,ca[x+15]=1,x+=16;if(Ca&&v)E.length==4&&v==THREE.VertexColors?(z=E[0],s=E[1],o=E[2],E=E[3]):E=o=s=z=J,na[ka]=z.r,na[ka+1]=z.g,na[ka+2]=z.b,na[ka+3]=s.r,na[ka+4]=s.g,na[ka+5]=s.b,na[ka+6]=o.r,na[ka+7]=o.g,na[ka+8]=o.b,na[ka+9]=E.r,na[ka+10]=E.g,na[ka+11]=E.b,ka+=12;if(Ba&&sa.hasTangents)E=I[0],J=I[1],
-z=I[2],I=I[3],$[X]=E.x,$[X+1]=E.y,$[X+2]=E.z,$[X+3]=E.w,$[X+4]=J.x,$[X+5]=J.y,$[X+6]=J.z,$[X+7]=J.w,$[X+8]=z.x,$[X+9]=z.y,$[X+10]=z.z,$[X+11]=z.w,$[X+12]=I.x,$[X+13]=I.y,$[X+14]=I.z,$[X+15]=I.w,X+=16;if(za&&y)if(D.length==4&&va)for(I=0;I<4;I++)G=D[I],V[Q]=G.x,V[Q+1]=G.y,V[Q+2]=G.z,Q+=3;else for(I=0;I<4;I++)V[Q]=G.x,V[Q+1]=G.y,V[Q+2]=G.z,Q+=3;if(ra&&r!==void 0&&q)for(I=0;I<4;I++)D=r[I],ia[W]=D.u,ia[W+1]=D.v,W+=2;if(ra&&C!==void 0&&q)for(I=0;I<4;I++)D=C[I],ja[Y]=D.u,ja[Y+1]=D.v,Y+=2;ua&&(fa[T]=ga,fa[T+
-1]=ga+1,fa[T+2]=ga+3,fa[T+3]=ga+1,fa[T+4]=ga+2,fa[T+5]=ga+3,T+=6,Aa[R]=ga,Aa[R+1]=ga+1,Aa[R+2]=ga,Aa[R+3]=ga+3,Aa[R+4]=ga+1,Aa[R+5]=ga+2,Aa[R+6]=ga+2,Aa[R+7]=ga+3,R+=8,ga+=4)}ta&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer),e.bufferData(e.ARRAY_BUFFER,ma,u));if(Z)for(S in Z)o=Z[S],o.__original.needsUpdate&&(e.bindBuffer(e.ARRAY_BUFFER,o.buffer),e.bufferData(e.ARRAY_BUFFER,o.array,u));if(Ea){s=0;for(o=Ha.length;s<o;s++)e.bindBuffer(e.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[s]),e.bufferData(e.ARRAY_BUFFER,
-pa[s],u)}Ca&&ka>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,na,u));za&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglNormalBuffer),e.bufferData(e.ARRAY_BUFFER,V,u));Ba&&sa.hasTangents&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglTangentBuffer),e.bufferData(e.ARRAY_BUFFER,$,u));ra&&W>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,ia,u));ra&&Y>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,ja,u));ua&&(e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,
-m.__webglFaceBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,fa,u),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m.__webglLineBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,Aa,u));x>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,aa,u),e.bindBuffer(e.ARRAY_BUFFER,m.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,ca,u),e.bindBuffer(e.ARRAY_BUFFER,m.__webglSkinIndicesBuffer),e.bufferData(e.ARRAY_BUFFER,da,u),e.bindBuffer(e.ARRAY_BUFFER,m.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,
-ea,u));w&&(delete m.__inittedArrays,delete m.__colorArray,delete m.__normalArray,delete m.__tangentArray,delete m.__uvArray,delete m.__uv2Array,delete m.__faceArray,delete m.__vertexArray,delete m.__lineArray,delete m.__skinVertexAArray,delete m.__skinVertexBArray,delete m.__skinIndexArray,delete m.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;xa(j)}else if(i instanceof THREE.Ribbon){h=
+Na[z.b],A=Na[z.c],z=Na[z.d],ca[x]=s.x,ca[x+1]=s.y,ca[x+2]=s.z,ca[x+3]=1,ca[x+4]=o.x,ca[x+5]=o.y,ca[x+6]=o.z,ca[x+7]=1,ca[x+8]=A.x,ca[x+9]=A.y,ca[x+10]=A.z,ca[x+11]=1,ca[x+12]=z.x,ca[x+13]=z.y,ca[x+14]=z.z,ca[x+15]=1,x+=16;if(Ca&&v)E.length==4&&v==THREE.VertexColors?(z=E[0],s=E[1],o=E[2],E=E[3]):E=o=s=z=J,na[ka]=z.r,na[ka+1]=z.g,na[ka+2]=z.b,na[ka+3]=s.r,na[ka+4]=s.g,na[ka+5]=s.b,na[ka+6]=o.r,na[ka+7]=o.g,na[ka+8]=o.b,na[ka+9]=E.r,na[ka+10]=E.g,na[ka+11]=E.b,ka+=12;if(za&&sa.hasTangents)E=I[0],J=I[1],
+z=I[2],I=I[3],$[Y]=E.x,$[Y+1]=E.y,$[Y+2]=E.z,$[Y+3]=E.w,$[Y+4]=J.x,$[Y+5]=J.y,$[Y+6]=J.z,$[Y+7]=J.w,$[Y+8]=z.x,$[Y+9]=z.y,$[Y+10]=z.z,$[Y+11]=z.w,$[Y+12]=I.x,$[Y+13]=I.y,$[Y+14]=I.z,$[Y+15]=I.w,Y+=16;if(wa&&y)if(D.length==4&&va)for(I=0;I<4;I++)G=D[I],X[Q]=G.x,X[Q+1]=G.y,X[Q+2]=G.z,Q+=3;else for(I=0;I<4;I++)X[Q]=G.x,X[Q+1]=G.y,X[Q+2]=G.z,Q+=3;if(pa&&r!==void 0&&q)for(I=0;I<4;I++)D=r[I],ia[V]=D.u,ia[V+1]=D.v,V+=2;if(pa&&C!==void 0&&q)for(I=0;I<4;I++)D=C[I],ja[W]=D.u,ja[W+1]=D.v,W+=2;ua&&(fa[T]=ga,fa[T+
+1]=ga+1,fa[T+2]=ga+3,fa[T+3]=ga+1,fa[T+4]=ga+2,fa[T+5]=ga+3,T+=6,Ba[R]=ga,Ba[R+1]=ga+1,Ba[R+2]=ga,Ba[R+3]=ga+3,Ba[R+4]=ga+1,Ba[R+5]=ga+2,Ba[R+6]=ga+2,Ba[R+7]=ga+3,R+=8,ga+=4)}ta&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglVertexBuffer),e.bufferData(e.ARRAY_BUFFER,ma,u));if(Z)for(S in Z)o=Z[S],o.__original.needsUpdate&&(e.bindBuffer(e.ARRAY_BUFFER,o.buffer),e.bufferData(e.ARRAY_BUFFER,o.array,u));if(Ea){s=0;for(o=Ga.length;s<o;s++)e.bindBuffer(e.ARRAY_BUFFER,m.__webglMorphTargetsBuffers[s]),e.bufferData(e.ARRAY_BUFFER,
+ra[s],u)}Ca&&ka>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,na,u));wa&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglNormalBuffer),e.bufferData(e.ARRAY_BUFFER,X,u));za&&sa.hasTangents&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglTangentBuffer),e.bufferData(e.ARRAY_BUFFER,$,u));pa&&V>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,ia,u));pa&&W>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,ja,u));ua&&(e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,
+m.__webglFaceBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,fa,u),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m.__webglLineBuffer),e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ba,u));x>0&&(e.bindBuffer(e.ARRAY_BUFFER,m.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,aa,u),e.bindBuffer(e.ARRAY_BUFFER,m.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,ca,u),e.bindBuffer(e.ARRAY_BUFFER,m.__webglSkinIndicesBuffer),e.bufferData(e.ARRAY_BUFFER,da,u),e.bindBuffer(e.ARRAY_BUFFER,m.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,
+ea,u));w&&(delete m.__inittedArrays,delete m.__colorArray,delete m.__normalArray,delete m.__tangentArray,delete m.__uvArray,delete m.__uv2Array,delete m.__faceArray,delete m.__vertexArray,delete m.__lineArray,delete m.__skinVertexAArray,delete m.__skinVertexBArray,delete m.__skinIndexArray,delete m.__skinWeightArray)}h.__dirtyVertices=!1;h.__dirtyMorphTargets=!1;h.__dirtyElements=!1;h.__dirtyUvs=!1;h.__dirtyNormals=!1;h.__dirtyTangents=!1;h.__dirtyColors=!1;ya(j)}else if(i instanceof THREE.Ribbon){h=
 i.geometry;if(h.__dirtyVertices||h.__dirtyColors){i=h;j=e.DYNAMIC_DRAW;k=t=w=w=void 0;p=i.vertices;n=i.colors;q=p.length;m=n.length;v=i.__vertexArray;u=i.__colorArray;y=i.__dirtyColors;if(i.__dirtyVertices){for(w=0;w<q;w++)t=p[w].position,k=w*3,v[k]=t.x,v[k+1]=t.y,v[k+2]=t.z;e.bindBuffer(e.ARRAY_BUFFER,i.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,v,j)}if(y){for(w=0;w<m;w++)color=n[w],k=w*3,u[k]=color.r,u[k+1]=color.g,u[k+2]=color.b;e.bindBuffer(e.ARRAY_BUFFER,i.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,
 u,j)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(i instanceof THREE.Line){h=i.geometry;if(h.__dirtyVertices||h.__dirtyColors){i=h;j=e.DYNAMIC_DRAW;k=t=w=w=void 0;p=i.vertices;n=i.colors;q=p.length;m=n.length;v=i.__vertexArray;u=i.__colorArray;y=i.__dirtyColors;if(i.__dirtyVertices){for(w=0;w<q;w++)t=p[w].position,k=w*3,v[k]=t.x,v[k+1]=t.y,v[k+2]=t.z;e.bindBuffer(e.ARRAY_BUFFER,i.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,v,j)}if(y){for(w=0;w<m;w++)color=n[w],k=w*3,u[k]=color.r,u[k+1]=color.g,
-u[k+2]=color.b;e.bindBuffer(e.ARRAY_BUFFER,i.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,u,j)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(i instanceof THREE.ParticleSystem)h=i.geometry,m=wa(h),(h.__dirtyVertices||h.__dirtyColors||i.sortParticles||m)&&c(h,e.DYNAMIC_DRAW,i),h.__dirtyVertices=!1,h.__dirtyColors=!1,xa(h)};this.setFaceCulling=function(b,c){b?(!c||c=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW),b=="back"?e.cullFace(e.BACK):b=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK),
-e.enable(e.CULL_FACE)):e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return $a}};
+u[k+2]=color.b;e.bindBuffer(e.ARRAY_BUFFER,i.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,u,j)}}h.__dirtyVertices=!1;h.__dirtyColors=!1}else if(i instanceof THREE.ParticleSystem)h=i.geometry,m=xa(h),(h.__dirtyVertices||h.__dirtyColors||i.sortParticles||m)&&c(h,e.DYNAMIC_DRAW,i),h.__dirtyVertices=!1,h.__dirtyColors=!1,ya(h)};this.setFaceCulling=function(b,c){b?(!c||c=="ccw"?e.frontFace(e.CCW):e.frontFace(e.CW),b=="back"?e.cullFace(e.BACK):b=="front"?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK),
+e.enable(e.CULL_FACE)):e.disable(e.CULL_FACE)};this.supportsVertexTextures=function(){return ab}};
 THREE.WebGLRenderTarget=function(b,c,d){this.width=b;this.height=c;d=d||{};this.wrapS=d.wrapS!==void 0?d.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=d.wrapT!==void 0?d.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=d.magFilter!==void 0?d.magFilter:THREE.LinearFilter;this.minFilter=d.minFilter!==void 0?d.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=d.format!==void 0?d.format:THREE.RGBAFormat;this.type=d.type!==void 0?d.type:
 THREE.UnsignedByteType;this.depthBuffer=d.depthBuffer!==void 0?d.depthBuffer:!0;this.stencilBuffer=d.stencilBuffer!==void 0?d.stencilBuffer:!0};
 THREE.WebGLRenderTarget.prototype.clone=function(){var b=new THREE.WebGLRenderTarget(this.width,this.height);b.wrapS=this.wrapS;b.wrapT=this.wrapT;b.magFilter=this.magFilter;b.minFilter=this.minFilter;b.offset.copy(this.offset);b.repeat.copy(this.repeat);b.format=this.format;b.type=this.type;b.depthBuffer=this.depthBuffer;b.stencilBuffer=this.stencilBuffer;return b};THREE.WebGLRenderTargetCube=function(b,c,d){THREE.WebGLRenderTarget.call(this,b,c,d);this.activeCubeFace=0};

+ 2 - 0
examples/webgl_postprocessing_dof.html

@@ -84,6 +84,8 @@
 				renderer.setSize( window.innerWidth, height );
 				container.appendChild( renderer.domElement );
 
+				renderer.sortObjects = false;
+
 				material_depth = new THREE.MeshDepthMaterial();
 
 				var path = "textures/cube/SwedishRoyalCastle/";

+ 81 - 60
src/renderers/WebGLRenderer.js

@@ -15,6 +15,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 	_gl, _programs = [],
 	_currentProgram = null,
 	_currentFramebuffer = null,
+	_currentMaterialId = -1,
 
 	// gl state cache
 
@@ -2729,6 +2730,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
+		var refreshMaterial = false;
+
 		var program = material.program,
 			p_uniforms = program.uniforms,
 			m_uniforms = material.uniforms;
@@ -2738,116 +2741,130 @@ THREE.WebGLRenderer = function ( parameters ) {
 			_gl.useProgram( program );
 			_currentProgram = program;
 
+			refreshMaterial = true;
+
 		}
 
-		_gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, _projectionMatrixArray );
+		if ( material.id != _currentMaterialId ) {
 
-		// refresh uniforms common to several materials
+			_currentMaterialId = material.id;
+			refreshMaterial = true;
 
-		if ( fog && material.fog ) {
+		}
 
-			refreshUniformsFog( m_uniforms, fog );
+		if ( refreshMaterial ) {
 
-		}
+			_gl.uniformMatrix4fv( p_uniforms.projectionMatrix, false, _projectionMatrixArray );
 
-		if ( material instanceof THREE.MeshPhongMaterial ||
-			 material instanceof THREE.MeshLambertMaterial ||
-			 material.lights ) {
+			// refresh uniforms common to several materials
 
-			setupLights( program, lights );
-			refreshUniformsLights( m_uniforms, _lights );
+			if ( fog && material.fog ) {
 
-		}
+				refreshUniformsFog( m_uniforms, fog );
 
-		if ( material instanceof THREE.MeshBasicMaterial ||
-			 material instanceof THREE.MeshLambertMaterial ||
-			 material instanceof THREE.MeshPhongMaterial ) {
+			}
 
-			refreshUniformsCommon( m_uniforms, material );
+			if ( material instanceof THREE.MeshPhongMaterial ||
+				 material instanceof THREE.MeshLambertMaterial ||
+				 material.lights ) {
 
-		}
+				setupLights( program, lights );
+				refreshUniformsLights( m_uniforms, _lights );
 
-		// refresh single material specific uniforms
+			}
 
-		if ( material instanceof THREE.LineBasicMaterial ) {
+			if ( material instanceof THREE.MeshBasicMaterial ||
+				 material instanceof THREE.MeshLambertMaterial ||
+				 material instanceof THREE.MeshPhongMaterial ) {
 
-			refreshUniformsLine( m_uniforms, material );
+				refreshUniformsCommon( m_uniforms, material );
 
-		} else if ( material instanceof THREE.ParticleBasicMaterial ) {
+			}
 
-			refreshUniformsParticle( m_uniforms, material );
+			// refresh single material specific uniforms
 
-		} else if ( material instanceof THREE.MeshPhongMaterial ) {
+			if ( material instanceof THREE.LineBasicMaterial ) {
 
-			refreshUniformsPhong( m_uniforms, material );
+				refreshUniformsLine( m_uniforms, material );
 
-		} else if ( material instanceof THREE.MeshDepthMaterial ) {
+			} else if ( material instanceof THREE.ParticleBasicMaterial ) {
 
-			m_uniforms.mNear.value = camera.near;
-			m_uniforms.mFar.value = camera.far;
-			m_uniforms.opacity.value = material.opacity;
+				refreshUniformsParticle( m_uniforms, material );
 
-		} else if ( material instanceof THREE.MeshNormalMaterial ) {
+			} else if ( material instanceof THREE.MeshPhongMaterial ) {
 
-			m_uniforms.opacity.value = material.opacity;
+				refreshUniformsPhong( m_uniforms, material );
 
-		}
+			} else if ( material instanceof THREE.MeshDepthMaterial ) {
 
-		if ( object.receiveShadow && ! material._shadowPass ) {
+				m_uniforms.mNear.value = camera.near;
+				m_uniforms.mFar.value = camera.far;
+				m_uniforms.opacity.value = material.opacity;
 
-			refreshUniformsShadow( m_uniforms, material );
+			} else if ( material instanceof THREE.MeshNormalMaterial ) {
 
-		}
+				m_uniforms.opacity.value = material.opacity;
 
-		// load common uniforms
+			}
 
-		loadUniformsGeneric( program, material.uniformsList );
-		loadUniformsMatrices( p_uniforms, object );
+			if ( object.receiveShadow && ! material._shadowPass ) {
 
-		// load material specific uniforms
-		// (shader material also gets them for the sake of genericity)
+				refreshUniformsShadow( m_uniforms, material );
 
-		if ( material instanceof THREE.ShaderMaterial ||
-			 material instanceof THREE.MeshPhongMaterial ||
-			 material.envMap ) {
+			}
 
-			if( p_uniforms.cameraPosition !== null ) {
+			// load common uniforms
 
-				_gl.uniform3f( p_uniforms.cameraPosition, camera.position.x, camera.position.y, camera.position.z );
+			loadUniformsGeneric( program, material.uniformsList );
 
-			}
+			// load material specific uniforms
+			// (shader material also gets them for the sake of genericity)
 
-		}
+			if ( material instanceof THREE.ShaderMaterial ||
+				 material instanceof THREE.MeshPhongMaterial ||
+				 material.envMap ) {
 
-		if ( material instanceof THREE.ShaderMaterial ||
-			 material.envMap ||
-			 material.skinning ||
-			 object.receiveShadow ) {
+				if( p_uniforms.cameraPosition !== null ) {
 
-			if ( p_uniforms.objectMatrix !== null ) {
+					_gl.uniform3f( p_uniforms.cameraPosition, camera.position.x, camera.position.y, camera.position.z );
 
-				_gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray );
+				}
 
 			}
 
-		}
+			if ( material instanceof THREE.MeshPhongMaterial ||
+				 material instanceof THREE.MeshLambertMaterial ||
+				 material instanceof THREE.ShaderMaterial ||
+				 material.skinning ) {
+
+				if( p_uniforms.viewMatrix !== null ) {
 
-		if ( material instanceof THREE.MeshPhongMaterial ||
-			 material instanceof THREE.MeshLambertMaterial ||
-			 material instanceof THREE.ShaderMaterial ||
-			 material.skinning ) {
+					_gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, _viewMatrixArray );
 
-			if( p_uniforms.viewMatrix !== null ) {
+				}
+
+			}
 
-				_gl.uniformMatrix4fv( p_uniforms.viewMatrix, false, _viewMatrixArray );
+			if ( material.skinning ) {
+
+				loadUniformsSkinning( p_uniforms, object );
 
 			}
 
 		}
 
-		if ( material.skinning ) {
+		loadUniformsMatrices( p_uniforms, object );
 
-			loadUniformsSkinning( p_uniforms, object );
+		if ( material instanceof THREE.ShaderMaterial ||
+			 material.envMap ||
+			 material.skinning ||
+			 object.receiveShadow ) {
+
+			if ( p_uniforms.objectMatrix !== null ) {
+
+				_gl.uniformMatrix4fv( p_uniforms.objectMatrix, false, object._objectMatrixArray );
+
+			}
 
 		}
 
@@ -3451,6 +3468,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			if ( light instanceof THREE.SpotLight && light.castShadow ) {
 
+				_currentMaterialId = -1;
+
 				if ( ! _this.shadowMap[ j ] ) {
 
 					var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat };
@@ -3633,6 +3652,8 @@ THREE.WebGLRenderer = function ( parameters ) {
 			lights = scene.lights,
 			fog = scene.fog;
 
+		_currentMaterialId = -1;
+
 		if ( this.shadowMapEnabled ) renderShadowMap( scene, camera );
 
 		_this.info.render.calls = 0;