瀏覽代碼

Merge remote-tracking branch 'remotes/mrdoob/dev' into dev

alteredq 13 年之前
父節點
當前提交
d8c23537f4
共有 8 個文件被更改,包括 674 次插入662 次删除
  1. 345 344
      build/Three.js
  2. 45 45
      build/custom/ThreeCanvas.js
  3. 21 21
      build/custom/ThreeDOM.js
  4. 19 19
      build/custom/ThreeSVG.js
  5. 201 200
      build/custom/ThreeWebGL.js
  6. 2 7
      examples/webgl_loader_ctm_materials.html
  7. 22 12
      src/core/Ray.js
  8. 19 14
      src/renderers/WebGLRenderer.js

+ 345 - 344
build/Three.js

@@ -18,39 +18,39 @@ b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]};
 THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes;c[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);c[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);c[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);c[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);c[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);c[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;6>a;a++)b=c[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))};
 THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),e=0;6>e;e++)if(a=b[e].x*c.n14+b[e].y*c.n24+b[e].z*c.n34+b[e].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3;
-THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);r=o.dot(b);s=q.add(a,m.copy(b).multiplyScalar(r));return t=c.distanceTo(s)}function d(a,b,c,d){o.sub(d,b);q.sub(c,b);m.sub(a,b);u=o.dot(o);x=o.dot(q);v=o.dot(m);A=q.dot(q);D=q.dot(m);E=1/(u*A-x*x);C=(A*v-x*D)*E;F=(u*D-x*v)*E;return 0<=C&&0<=F&&1>C+F}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,c,d=[];for(b=0,
-c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,l=new THREE.Vector3,k=new THREE.Vector3,p=new THREE.Vector3,n=new THREE.Vector3;this.intersectObject=function(a){for(var b,m=[],o=0,q=a.children.length;o<q;o++)Array.prototype.push.apply(m,this.intersectObject(a.children[o]));if(a instanceof THREE.Particle){o=
-c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.scale.x)return[];b={distance:o,point:a.position,face:null,object:a};m.push(b)}else if(a instanceof THREE.Mesh){o=c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return m;var r,j=a.geometry,s=j.vertices,t;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,q=j.faces.length;o<q;o++)if(b=j.faces[o],i.copy(this.origin),l.copy(this.direction),
-t=a.matrixWorld,k=t.multiplyVector3(k.copy(b.centroid)).subSelf(i),r=k.dot(l),!(0>=r)&&(e=t.multiplyVector3(e.copy(s[b.a].position)),f=t.multiplyVector3(f.copy(s[b.b].position)),g=t.multiplyVector3(g.copy(s[b.c].position)),b instanceof THREE.Face4&&(h=t.multiplyVector3(h.copy(s[b.d].position))),p=a.matrixRotationWorld.multiplyVector3(p.copy(b.normal)),r=l.dot(p),a.doubleSided||(a.flipSided?0<r:0>r)))if(r=p.dot(k.sub(e,i))/r,n.add(i,l.multiplyScalar(r)),b instanceof THREE.Face3)d(n,e,f,g)&&(b={distance:i.distanceTo(n),
-point:n.clone(),face:b,object:a},m.push(b));else if(b instanceof THREE.Face4&&(d(n,e,f,h)||d(n,f,g,h)))b={distance:i.distanceTo(n),point:n.clone(),face:b,object:a},m.push(b)}return m};var o=new THREE.Vector3,q=new THREE.Vector3,m=new THREE.Vector3,r,s,t,u,x,v,A,D,E,C,F};
+THREE.Ray=function(a,b){function c(a,b,c){n.sub(c,a);r=n.dot(b);s=q.add(a,m.copy(b).multiplyScalar(r));return t=c.distanceTo(s)}function d(a,b,c,d){n.sub(d,b);q.sub(c,b);m.sub(a,b);u=n.dot(n);x=n.dot(q);w=n.dot(m);A=q.dot(q);D=q.dot(m);B=1/(u*A-x*x);C=(A*w-x*D)*B;G=(u*D-x*w)*B;return 0<=C&&0<=G&&1>C+G}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,c,d=[];for(b=0,
+c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,l=new THREE.Vector3,k=new THREE.Vector3,p=new THREE.Vector3,o=new THREE.Vector3;this.intersectObject=function(a){for(var b,m=[],n=0,q=a.children.length;n<q;n++)Array.prototype.push.apply(m,this.intersectObject(a.children[n]));if(a instanceof THREE.Particle){n=
+c(this.origin,this.direction,a.matrixWorld.getPosition());if(n>a.scale.x)return[];b={distance:n,point:a.position,face:null,object:a};m.push(b)}else if(a instanceof THREE.Mesh){n=c(this.origin,this.direction,a.matrixWorld.getPosition());if(n>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return m;var j,r,s=a.geometry,t=s.vertices,y;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(n=0,q=s.faces.length;n<q;n++)if(b=s.faces[n],i.copy(this.origin),l.copy(this.direction),
+y=a.matrixWorld,k=y.multiplyVector3(k.copy(b.centroid)).subSelf(i),p=a.matrixRotationWorld.multiplyVector3(p.copy(b.normal)),j=l.dot(p),!(1.0E-4>Math.abs(j))&&(r=p.dot(k)/j,!(0>r)&&(a.doubleSided||(a.flipSided?0<j:0>j))))if(o.add(i,l.multiplyScalar(r)),b instanceof THREE.Face3)e=y.multiplyVector3(e.copy(t[b.a].position)),f=y.multiplyVector3(f.copy(t[b.b].position)),g=y.multiplyVector3(g.copy(t[b.c].position)),d(o,e,f,g)&&(b={distance:i.distanceTo(o),point:o.clone(),face:b,object:a},m.push(b));else if(b instanceof
+THREE.Face4&&(e=y.multiplyVector3(e.copy(t[b.a].position)),f=y.multiplyVector3(f.copy(t[b.b].position)),g=y.multiplyVector3(g.copy(t[b.c].position)),h=y.multiplyVector3(h.copy(t[b.d].position)),d(o,e,f,h)||d(o,f,g,h)))b={distance:i.distanceTo(o),point:o.clone(),face:b,object:a},m.push(b)}return m};var n=new THREE.Vector3,q=new THREE.Vector3,m=new THREE.Vector3,r,s,t,u,x,w,A,D,B,C,G};
 THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,k,p){h=!1;b=f;c=g;d=k;e=p;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
-function(f,g,k,p,n,o){h?(h=!1,b=f<k?f<n?f:n:k<n?k:n,c=g<p?g<o?g:o:p<o?p:o,d=f>k?f>n?f:n:k>n?k:n,e=g>p?g>o?g:o:p>o?p:o):(b=f<k?f<n?f<b?f:b:n<b?n:b:k<n?k<b?k:b:n<b?n:b,c=g<p?g<o?g<c?g:c:o<c?o:c:p<o?p<c?p:c:o<c?o:c,d=f>k?f>n?f>d?f:d:n>d?n:d:k>n?k>d?k:d:n>d?n:d,e=g>p?g>o?g>e?g:e:o>e?o:e:p>o?p>e?p:e:o>e?o:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
+function(f,g,k,p,o,n){h?(h=!1,b=f<k?f<o?f:o:k<o?k:o,c=g<p?g<n?g:n:p<n?p:n,d=f>k?f>o?f:o:k>o?k:o,e=g>p?g>n?g:n:p>n?p:n):(b=f<k?f<o?f<b?f:b:o<b?o:b:k<o?k<b?k:b:o<b?o:b,c=g<p?g<n?g<c?g:c:n<c?n:c:p<n?p<c?p:c:n<c?n:c,d=f>k?f>o?f>d?f:d:o>d?o:d:k>o?k>d?k:d:o>d?o:d,e=g>p?g>n?g>e?g:e:n>e?n:e:p>n?p>e?p:e:n>e?n:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
 f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||e<a.getTop()||c>a.getBottom()?!1:!0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
 THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())}};THREE.Matrix3=function(){this.m=[]};
 THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,d,e,f,g,h,i,l,k,p,n,o,q,m){this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==f?f:1,g||0,h||0,i||0,l||0,void 0!==k?k:1,p||0,n||0,o||0,q||0,void 0!==m?m:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,i,l,k,p,n,o,q,m){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=h;this.n31=i;this.n32=l;this.n33=k;this.n34=p;this.n41=n;this.n42=o;this.n43=q;this.n44=m;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
-b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(0===f.length())f.z=1;d.cross(c,f).normalize();0===d.length()&&(f.x+=1.0E-4,d.cross(c,f).normalize());e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,h=a.n22,i=a.n23,l=a.n24,k=a.n31,p=a.n32,n=a.n33,o=a.n34,q=a.n41,m=a.n42,r=a.n43,
-s=a.n44,t=b.n11,u=b.n12,x=b.n13,v=b.n14,A=b.n21,D=b.n22,E=b.n23,C=b.n24,F=b.n31,K=b.n32,L=b.n33,R=b.n34,N=b.n41,P=b.n42,B=b.n43,j=b.n44;this.n11=c*t+d*A+e*F+f*N;this.n12=c*u+d*D+e*K+f*P;this.n13=c*x+d*E+e*L+f*B;this.n14=c*v+d*C+e*R+f*j;this.n21=g*t+h*A+i*F+l*N;this.n22=g*u+h*D+i*K+l*P;this.n23=g*x+h*E+i*L+l*B;this.n24=g*v+h*C+i*R+l*j;this.n31=k*t+p*A+n*F+o*N;this.n32=k*u+p*D+n*K+o*P;this.n33=k*x+p*E+n*L+o*B;this.n34=k*v+p*C+n*R+o*j;this.n41=q*t+m*A+r*F+s*N;this.n42=q*u+m*D+r*K+s*P;this.n43=q*x+m*
-E+r*L+s*B;this.n44=q*v+m*C+r*R+s*j;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
+THREE.Matrix4=function(a,b,c,d,e,f,g,h,i,l,k,p,o,n,q,m){this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==f?f:1,g||0,h||0,i||0,l||0,void 0!==k?k:1,p||0,o||0,n||0,q||0,void 0!==m?m:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,i,l,k,p,o,n,q,m){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=h;this.n31=i;this.n32=l;this.n33=k;this.n34=p;this.n41=o;this.n42=n;this.n43=q;this.n44=m;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
+b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(0===f.length())f.z=1;d.cross(c,f).normalize();0===d.length()&&(f.x+=1.0E-4,d.cross(c,f).normalize());e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,h=a.n22,i=a.n23,l=a.n24,k=a.n31,p=a.n32,o=a.n33,n=a.n34,q=a.n41,m=a.n42,r=a.n43,
+s=a.n44,t=b.n11,u=b.n12,x=b.n13,w=b.n14,A=b.n21,D=b.n22,B=b.n23,C=b.n24,G=b.n31,K=b.n32,L=b.n33,T=b.n34,M=b.n41,E=b.n42,j=b.n43,Q=b.n44;this.n11=c*t+d*A+e*G+f*M;this.n12=c*u+d*D+e*K+f*E;this.n13=c*x+d*B+e*L+f*j;this.n14=c*w+d*C+e*T+f*Q;this.n21=g*t+h*A+i*G+l*M;this.n22=g*u+h*D+i*K+l*E;this.n23=g*x+h*B+i*L+l*j;this.n24=g*w+h*C+i*T+l*Q;this.n31=k*t+p*A+o*G+n*M;this.n32=k*u+p*D+o*K+n*E;this.n33=k*x+p*B+o*L+n*j;this.n34=k*w+p*C+o*T+n*Q;this.n41=q*t+m*A+r*G+s*M;this.n42=q*u+m*D+r*K+s*E;this.n43=q*x+m*
+B+r*L+s*j;this.n44=q*w+m*C+r*T+s*Q;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
 a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*
 c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*
-a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,h=this.n24,i=this.n31,l=this.n32,k=this.n33,p=this.n34,n=this.n41,o=this.n42,q=this.n43,m=this.n44;return d*g*l*n-c*h*l*n-d*f*k*n+b*h*k*n+c*f*p*n-b*g*p*n-d*g*i*o+c*h*i*o+d*e*k*o-a*h*k*o-c*e*p*o+a*g*p*o+d*f*i*q-b*h*i*q-d*e*l*q+a*h*l*q+b*e*p*q-a*f*p*q-c*f*i*m+b*g*i*m+c*e*l*m-a*g*l*m-b*e*k*m+a*f*k*m},transpose:function(){var a;
+a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,h=this.n24,i=this.n31,l=this.n32,k=this.n33,p=this.n34,o=this.n41,n=this.n42,q=this.n43,m=this.n44;return d*g*l*o-c*h*l*o-d*f*k*o+b*h*k*o+c*f*p*o-b*g*p*o-d*g*i*n+c*h*i*n+d*e*k*n-a*h*k*n-c*e*p*n+a*g*p*n+d*f*i*q-b*h*i*q-d*e*l*q+a*h*l*q+b*e*p*q-a*f*p*q-c*f*i*m+b*g*i*m+c*e*l*m-a*g*l*m-b*e*k*m+a*f*k*m},transpose:function(){var a;
 a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n34=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;
 a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.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(a){a[0]=this.n11;a[1]=this.n21;a[2]=this.n31;
 a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=this.n34;a[b+15]=this.n44;return a},
 setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},
 setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,h=a.z,i=e*f,l=e*g;this.set(i*f+c,i*g-d*h,i*h+d*g,0,i*g+d*h,l*g+c,l*h-d*f,0,i*h-d*g,l*h+d*f,e*h*h+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12,
-this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,d=a.n13,e=a.n14,f=a.n21,g=a.n22,h=a.n23,i=a.n24,l=a.n31,k=a.n32,p=a.n33,n=a.n34,o=a.n41,q=a.n42,m=a.n43,r=a.n44;this.n11=h*n*q-i*p*q+i*k*m-g*n*m-h*k*r+g*p*r;this.n12=e*p*q-d*n*q-e*k*m+c*n*m+d*k*r-c*p*r;this.n13=d*i*q-e*h*q+e*g*m-c*i*m-d*g*r+c*h*r;this.n14=e*h*k-d*i*k-e*g*p+c*i*p+d*g*n-c*h*n;this.n21=i*p*o-h*n*o-i*l*m+f*n*m+h*l*r-f*p*r;this.n22=d*n*o-e*p*o+
-e*l*m-b*n*m-d*l*r+b*p*r;this.n23=e*h*o-d*i*o-e*f*m+b*i*m+d*f*r-b*h*r;this.n24=d*i*l-e*h*l+e*f*p-b*i*p-d*f*n+b*h*n;this.n31=g*n*o-i*k*o+i*l*q-f*n*q-g*l*r+f*k*r;this.n32=e*k*o-c*n*o-e*l*q+b*n*q+c*l*r-b*k*r;this.n33=c*i*o-e*g*o+e*f*q-b*i*q-c*f*r+b*g*r;this.n34=e*g*l-c*i*l-e*f*k+b*i*k+c*f*n-b*g*n;this.n41=h*k*o-g*p*o-h*l*q+f*p*q+g*l*m-f*k*m;this.n42=c*p*o-d*k*o+d*l*q-b*p*q-c*l*m+b*k*m;this.n43=d*g*o-c*h*o-d*f*q+b*h*q+c*f*m-b*g*m;this.n44=c*h*l-d*g*l+d*f*k-b*h*k-c*f*p+b*g*p;this.multiplyScalar(1/a.determinant());
+this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,d=a.n13,e=a.n14,f=a.n21,g=a.n22,h=a.n23,i=a.n24,l=a.n31,k=a.n32,p=a.n33,o=a.n34,n=a.n41,q=a.n42,m=a.n43,r=a.n44;this.n11=h*o*q-i*p*q+i*k*m-g*o*m-h*k*r+g*p*r;this.n12=e*p*q-d*o*q-e*k*m+c*o*m+d*k*r-c*p*r;this.n13=d*i*q-e*h*q+e*g*m-c*i*m-d*g*r+c*h*r;this.n14=e*h*k-d*i*k-e*g*p+c*i*p+d*g*o-c*h*o;this.n21=i*p*n-h*o*n-i*l*m+f*o*m+h*l*r-f*p*r;this.n22=d*o*n-e*p*n+
+e*l*m-b*o*m-d*l*r+b*p*r;this.n23=e*h*n-d*i*n-e*f*m+b*i*m+d*f*r-b*h*r;this.n24=d*i*l-e*h*l+e*f*p-b*i*p-d*f*o+b*h*o;this.n31=g*o*n-i*k*n+i*l*q-f*o*q-g*l*r+f*k*r;this.n32=e*k*n-c*o*n-e*l*q+b*o*q+c*l*r-b*k*r;this.n33=c*i*n-e*g*n+e*f*q-b*i*q-c*f*r+b*g*r;this.n34=e*g*l-c*i*l-e*f*k+b*i*k+c*f*o-b*g*o;this.n41=h*k*n-g*p*n-h*l*q+f*p*q+g*l*m-f*k*m;this.n42=c*p*n-d*k*n+d*l*q-b*p*q-c*l*m+b*k*m;this.n43=d*g*n-c*h*n-d*f*q+b*h*q+c*f*m-b*g*m;this.n44=c*h*l-d*g*l+d*f*k-b*h*k-c*f*p+b*g*p;this.multiplyScalar(1/a.determinant());
 return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,e=a.z,f=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var i=g*h,l=g*e,k=d*h,p=d*e;this.n11=i+p*c;this.n12=k*c-l;this.n13=f*d;this.n21=f*e;this.n22=f*h;this.n23=-c;this.n31=l*c-k;this.n32=p+i*c;this.n33=f*g;break;case "ZXY":i=g*h;l=g*e;k=d*h;p=d*e;this.n11=i-p*c;this.n12=-f*e;this.n13=k+l*c;this.n21=l+k*c;this.n22=f*h;this.n23=p-i*c;this.n31=-f*d;this.n32=c;this.n33=f*g;break;case "ZYX":i=
 f*h;l=f*e;k=c*h;p=c*e;this.n11=g*h;this.n12=k*d-l;this.n13=i*d+p;this.n21=g*e;this.n22=p*d+i;this.n23=l*d-k;this.n31=-d;this.n32=c*g;this.n33=f*g;break;case "YZX":i=f*g;l=f*d;k=c*g;p=c*d;this.n11=g*h;this.n12=p-i*e;this.n13=k*e+l;this.n21=e;this.n22=f*h;this.n23=-c*h;this.n31=-d*h;this.n32=l*e+k;this.n33=i-p*e;break;case "XZY":i=f*g;l=f*d;k=c*g;p=c*d;this.n11=g*h;this.n12=-e;this.n13=d*h;this.n21=i*e+p;this.n22=f*h;this.n23=l*e-k;this.n31=k*e-l;this.n32=c*h;this.n33=p*e+i;break;default:i=f*h,l=f*
 e,k=c*h,p=c*e,this.n11=g*h,this.n12=-g*e,this.n13=d,this.n21=l+k*d,this.n22=i-p*d,this.n23=-c*g,this.n31=p-i*d,this.n32=k+l*d,this.n33=f*g}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,f=b+b,g=c+c,h=d+d,a=b*f,i=b*g,b=b*h,l=c*g,c=c*h,d=d*h,f=e*f,g=e*g,e=e*h;this.n11=1-(l+d);this.n12=i-e;this.n13=b+g;this.n21=i+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=
 a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);f.set(this.n13,
 this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();c.y=e.length();c.z=f.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
 return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this},rotateByAxis:function(a,b){if(1===a.x&&0===a.y&&0===a.z)return this.rotateX(b);if(0===a.x&&1===a.y&&0===a.z)return this.rotateY(b);if(0===a.x&&0===a.y&&1===
-a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e),c=c/f,d=d/f,e=e/f,f=c*c,g=d*d,h=e*e,i=Math.cos(b),l=Math.sin(b),k=1-i,p=c*d*k,n=c*e*k,k=d*e*k,c=c*l,o=d*l,l=e*l,e=f+(1-f)*i,f=p+l,d=n-o,p=p-l,g=g+(1-g)*i,l=k+c,n=n+o,k=k-c,h=h+(1-h)*i,i=this.n11,c=this.n21,o=this.n31,q=this.n41,m=this.n12,r=this.n22,s=this.n32,t=this.n42,u=this.n13,x=this.n23,v=this.n33,A=this.n43;this.n11=e*i+f*m+d*u;this.n21=e*c+f*r+d*x;this.n31=e*o+f*s+d*v;this.n41=e*q+f*t+d*A;this.n12=p*i+g*m+l*u;this.n22=
-p*c+g*r+l*x;this.n32=p*o+g*s+l*v;this.n42=p*q+g*t+l*A;this.n13=n*i+k*m+h*u;this.n23=n*c+k*r+h*x;this.n33=n*o+k*s+h*v;this.n43=n*q+k*t+h*A;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,f=this.n13,g=this.n23,h=this.n33,i=this.n43,l=Math.cos(a),a=Math.sin(a);this.n12=l*b+a*f;this.n22=l*c+a*g;this.n32=l*d+a*h;this.n42=l*e+a*i;this.n13=l*f-a*b;this.n23=l*g-a*c;this.n33=l*h-a*d;this.n43=l*i-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,
+a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e),c=c/f,d=d/f,e=e/f,f=c*c,g=d*d,h=e*e,i=Math.cos(b),l=Math.sin(b),k=1-i,p=c*d*k,o=c*e*k,k=d*e*k,c=c*l,n=d*l,l=e*l,e=f+(1-f)*i,f=p+l,d=o-n,p=p-l,g=g+(1-g)*i,l=k+c,o=o+n,k=k-c,h=h+(1-h)*i,i=this.n11,c=this.n21,n=this.n31,q=this.n41,m=this.n12,r=this.n22,s=this.n32,t=this.n42,u=this.n13,x=this.n23,w=this.n33,A=this.n43;this.n11=e*i+f*m+d*u;this.n21=e*c+f*r+d*x;this.n31=e*n+f*s+d*w;this.n41=e*q+f*t+d*A;this.n12=p*i+g*m+l*u;this.n22=
+p*c+g*r+l*x;this.n32=p*n+g*s+l*w;this.n42=p*q+g*t+l*A;this.n13=o*i+k*m+h*u;this.n23=o*c+k*r+h*x;this.n33=o*n+k*s+h*w;this.n43=o*q+k*t+h*A;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,f=this.n13,g=this.n23,h=this.n33,i=this.n43,l=Math.cos(a),a=Math.sin(a);this.n12=l*b+a*f;this.n22=l*c+a*g;this.n32=l*d+a*h;this.n42=l*e+a*i;this.n13=l*f-a*b;this.n23=l*g-a*c;this.n33=l*h-a*d;this.n43=l*i-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,
 f=this.n13,g=this.n23,h=this.n33,i=this.n43,l=Math.cos(a),a=Math.sin(a);this.n11=l*b-a*f;this.n21=l*c-a*g;this.n31=l*d-a*h;this.n41=l*e-a*i;this.n13=l*f+a*b;this.n23=l*g+a*c;this.n33=l*h+a*d;this.n43=l*i+a*e;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,f=this.n12,g=this.n22,h=this.n32,i=this.n42,l=Math.cos(a),a=Math.sin(a);this.n11=l*b+a*f;this.n21=l*c+a*g;this.n31=l*d+a*h;this.n41=l*e+a*i;this.n12=l*f-a*b;this.n22=l*g-a*c;this.n32=l*h-a*d;this.n42=l*i-a*e;return this},
 translate:function(a){var b=a.x,c=a.y,a=a.z;this.n14=this.n11*b+this.n12*c+this.n13*a+this.n14;this.n24=this.n21*b+this.n22*c+this.n23*a+this.n24;this.n34=this.n31*b+this.n32*c+this.n33*a+this.n34;this.n44=this.n41*b+this.n42*c+this.n43*a+this.n44;return this}};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,i=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,k=-a.n23*a.n11+a.n21*a.n13,p=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*g+a.n31*l;if(0===a)return null;a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*h;c[5]=a*i;c[6]=a*l;c[7]=a*k;c[8]=a*p;return b};
@@ -63,16 +63,16 @@ this.children.indexOf(a)){void 0!==a.parent&&a.parent.remove(a);a.parent=this;th
 a||b&&(e=e.getChildByName(a,b),void 0!==e))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(1!==this.scale.x||1!==this.scale.y||1!==this.scale.z)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){this.matrixAutoUpdate&&
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)}};THREE.Object3DCount=0;
 THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=l[i]=l[i]||new THREE.RenderableVertex;i++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d<c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return!0}
-var e,f,g=[],h,i,l=[],k,p,n=[],o,q=[],m,r,s=[],t,u,x=[],v={objects:[],sprites:[],lights:[],elements:[]},A=new THREE.Vector3,D=new THREE.Vector4,E=new THREE.Matrix4,C=new THREE.Matrix4,F=new THREE.Frustum,K=new THREE.Vector4,L=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);E.multiply(b.projectionMatrix,b.matrixWorldInverse);E.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);E.multiply(b.matrixWorld,
-b.projectionMatrixInverse);E.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){f=0;v.objects.length=0;v.sprites.length=0;v.lights.length=0;var g=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||F.contains(b))?(E.multiplyVector3(A.copy(b.position)),e=a(),e.object=
-b,e.z=A.z,v.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(E.multiplyVector3(A.copy(b.position)),e=a(),e.object=b,e.z=A.z,v.sprites.push(e)):b instanceof THREE.Light&&v.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&v.objects.sort(c);return v};this.projectScene=function(a,e,f){var g=e.near,j=e.far,H,A,y,I,O,T,aa,ga,fa,S,ba,$,ca,ia,La,ja;u=r=o=p=0;v.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
-a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);E.multiply(e.projectionMatrix,e.matrixWorldInverse);F.setFromMatrix(E);v=this.projectGraph(a,!1);for(a=0,H=v.objects.length;a<H;a++)if(fa=v.objects[a].object,S=fa.matrixWorld,$=fa.material,i=0,fa instanceof THREE.Mesh){ba=fa.geometry;ca=fa.geometry.materials;I=ba.vertices;ia=ba.faces;La=ba.faceVertexUvs;ba=fa.matrixRotationWorld.extractRotation(S);for(A=0,y=I.length;A<y;A++)h=b(),h.positionWorld.copy(I[A].position),S.multiplyVector3(h.positionWorld),
-h.positionScreen.copy(h.positionWorld),E.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<j;for(I=0,A=ia.length;I<A;I++){y=ia[I];if(y instanceof THREE.Face3)if(O=l[y.a],T=l[y.b],aa=l[y.c],O.visible&&T.visible&&aa.visible&&(fa.doubleSided||fa.flipSided!=0>(aa.positionScreen.x-O.positionScreen.x)*(T.positionScreen.y-O.positionScreen.y)-(aa.positionScreen.y-O.positionScreen.y)*(T.positionScreen.x-
-O.positionScreen.x)))ga=n[p]=n[p]||new THREE.RenderableFace3,p++,k=ga,k.v1.copy(O),k.v2.copy(T),k.v3.copy(aa);else continue;else if(y instanceof THREE.Face4)if(O=l[y.a],T=l[y.b],aa=l[y.c],ga=l[y.d],O.visible&&T.visible&&aa.visible&&ga.visible&&(fa.doubleSided||fa.flipSided!=(0>(ga.positionScreen.x-O.positionScreen.x)*(T.positionScreen.y-O.positionScreen.y)-(ga.positionScreen.y-O.positionScreen.y)*(T.positionScreen.x-O.positionScreen.x)||0>(T.positionScreen.x-aa.positionScreen.x)*(ga.positionScreen.y-
-aa.positionScreen.y)-(T.positionScreen.y-aa.positionScreen.y)*(ga.positionScreen.x-aa.positionScreen.x))))ja=q[o]=q[o]||new THREE.RenderableFace4,o++,k=ja,k.v1.copy(O),k.v2.copy(T),k.v3.copy(aa),k.v4.copy(ga);else continue;k.normalWorld.copy(y.normal);ba.multiplyVector3(k.normalWorld);k.centroidWorld.copy(y.centroid);S.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);E.multiplyVector3(k.centroidScreen);aa=y.vertexNormals;for(O=0,T=aa.length;O<T;O++)ga=k.vertexNormalsWorld[O],
-ga.copy(aa[O]),ba.multiplyVector3(ga);for(O=0,T=La.length;O<T;O++)if(ja=La[O][I])for(aa=0,ga=ja.length;aa<ga;aa++)k.uvs[O][aa]=ja[aa];k.material=$;k.faceMaterial=null!==y.materialIndex?ca[y.materialIndex]:null;k.z=k.centroidScreen.z;v.elements.push(k)}}else if(fa instanceof THREE.Line){C.multiply(E,S);I=fa.geometry.vertices;O=b();O.positionScreen.copy(I[0].position);C.multiplyVector4(O.positionScreen);for(A=1,y=I.length;A<y;A++)if(O=b(),O.positionScreen.copy(I[A].position),C.multiplyVector4(O.positionScreen),
-T=l[i-2],K.copy(O.positionScreen),L.copy(T.positionScreen),d(K,L))K.multiplyScalar(1/K.w),L.multiplyScalar(1/L.w),fa=s[r]=s[r]||new THREE.RenderableLine,r++,m=fa,m.v1.positionScreen.copy(K),m.v2.positionScreen.copy(L),m.z=Math.max(K.z,L.z),m.material=$,v.elements.push(m)}for(a=0,H=v.sprites.length;a<H;a++)if(fa=v.sprites[a].object,S=fa.matrixWorld,fa instanceof THREE.Particle&&(D.set(S.n14,S.n24,S.n34,1),E.multiplyVector4(D),D.z/=D.w,0<D.z&&1>D.z))g=x[u]=x[u]||new THREE.RenderableParticle,u++,t=g,
-t.x=D.x/D.w,t.y=D.y/D.w,t.z=D.z,t.rotation=fa.rotation.z,t.scale.x=fa.scale.x*Math.abs(t.x-(D.x+e.projectionMatrix.n11)/(D.w+e.projectionMatrix.n14)),t.scale.y=fa.scale.y*Math.abs(t.y-(D.y+e.projectionMatrix.n22)/(D.w+e.projectionMatrix.n24)),t.material=fa.material,v.elements.push(t);f&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
+var e,f,g=[],h,i,l=[],k,p,o=[],n,q=[],m,r,s=[],t,u,x=[],w={objects:[],sprites:[],lights:[],elements:[]},A=new THREE.Vector3,D=new THREE.Vector4,B=new THREE.Matrix4,C=new THREE.Matrix4,G=new THREE.Frustum,K=new THREE.Vector4,L=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);B.multiply(b.projectionMatrix,b.matrixWorldInverse);B.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);B.multiply(b.matrixWorld,
+b.projectionMatrixInverse);B.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){f=0;w.objects.length=0;w.sprites.length=0;w.lights.length=0;var g=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||G.contains(b))?(B.multiplyVector3(A.copy(b.position)),e=a(),e.object=
+b,e.z=A.z,w.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(B.multiplyVector3(A.copy(b.position)),e=a(),e.object=b,e.z=A.z,w.sprites.push(e)):b instanceof THREE.Light&&w.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&w.objects.sort(c);return w};this.projectScene=function(a,e,f){var g=e.near,A=e.far,I,R,y,F,P,$,Z,ga,fa,S,aa,ba,ca,ha,Na,ja;u=r=n=p=0;w.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
+a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);B.multiply(e.projectionMatrix,e.matrixWorldInverse);G.setFromMatrix(B);w=this.projectGraph(a,!1);for(a=0,I=w.objects.length;a<I;a++)if(fa=w.objects[a].object,S=fa.matrixWorld,ba=fa.material,i=0,fa instanceof THREE.Mesh){aa=fa.geometry;ca=fa.geometry.materials;F=aa.vertices;ha=aa.faces;Na=aa.faceVertexUvs;aa=fa.matrixRotationWorld.extractRotation(S);for(R=0,y=F.length;R<y;R++)h=b(),h.positionWorld.copy(F[R].position),S.multiplyVector3(h.positionWorld),
+h.positionScreen.copy(h.positionWorld),B.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<A;for(F=0,R=ha.length;F<R;F++){y=ha[F];if(y instanceof THREE.Face3)if(P=l[y.a],$=l[y.b],Z=l[y.c],P.visible&&$.visible&&Z.visible&&(fa.doubleSided||fa.flipSided!=0>(Z.positionScreen.x-P.positionScreen.x)*($.positionScreen.y-P.positionScreen.y)-(Z.positionScreen.y-P.positionScreen.y)*($.positionScreen.x-
+P.positionScreen.x)))ga=o[p]=o[p]||new THREE.RenderableFace3,p++,k=ga,k.v1.copy(P),k.v2.copy($),k.v3.copy(Z);else continue;else if(y instanceof THREE.Face4)if(P=l[y.a],$=l[y.b],Z=l[y.c],ga=l[y.d],P.visible&&$.visible&&Z.visible&&ga.visible&&(fa.doubleSided||fa.flipSided!=(0>(ga.positionScreen.x-P.positionScreen.x)*($.positionScreen.y-P.positionScreen.y)-(ga.positionScreen.y-P.positionScreen.y)*($.positionScreen.x-P.positionScreen.x)||0>($.positionScreen.x-Z.positionScreen.x)*(ga.positionScreen.y-
+Z.positionScreen.y)-($.positionScreen.y-Z.positionScreen.y)*(ga.positionScreen.x-Z.positionScreen.x))))ja=q[n]=q[n]||new THREE.RenderableFace4,n++,k=ja,k.v1.copy(P),k.v2.copy($),k.v3.copy(Z),k.v4.copy(ga);else continue;k.normalWorld.copy(y.normal);aa.multiplyVector3(k.normalWorld);k.centroidWorld.copy(y.centroid);S.multiplyVector3(k.centroidWorld);k.centroidScreen.copy(k.centroidWorld);B.multiplyVector3(k.centroidScreen);Z=y.vertexNormals;for(P=0,$=Z.length;P<$;P++)ga=k.vertexNormalsWorld[P],ga.copy(Z[P]),
+aa.multiplyVector3(ga);for(P=0,$=Na.length;P<$;P++)if(ja=Na[P][F])for(Z=0,ga=ja.length;Z<ga;Z++)k.uvs[P][Z]=ja[Z];k.material=ba;k.faceMaterial=null!==y.materialIndex?ca[y.materialIndex]:null;k.z=k.centroidScreen.z;w.elements.push(k)}}else if(fa instanceof THREE.Line){C.multiply(B,S);F=fa.geometry.vertices;P=b();P.positionScreen.copy(F[0].position);C.multiplyVector4(P.positionScreen);for(R=1,y=F.length;R<y;R++)if(P=b(),P.positionScreen.copy(F[R].position),C.multiplyVector4(P.positionScreen),$=l[i-
+2],K.copy(P.positionScreen),L.copy($.positionScreen),d(K,L))K.multiplyScalar(1/K.w),L.multiplyScalar(1/L.w),fa=s[r]=s[r]||new THREE.RenderableLine,r++,m=fa,m.v1.positionScreen.copy(K),m.v2.positionScreen.copy(L),m.z=Math.max(K.z,L.z),m.material=ba,w.elements.push(m)}for(a=0,I=w.sprites.length;a<I;a++)if(fa=w.sprites[a].object,S=fa.matrixWorld,fa instanceof THREE.Particle&&(D.set(S.n14,S.n24,S.n34,1),B.multiplyVector4(D),D.z/=D.w,0<D.z&&1>D.z))g=x[u]=x[u]||new THREE.RenderableParticle,u++,t=g,t.x=
+D.x/D.w,t.y=D.y/D.w,t.z=D.z,t.rotation=fa.rotation.z,t.scale.x=fa.scale.x*Math.abs(t.x-(D.x+e.projectionMatrix.n11)/(D.w+e.projectionMatrix.n14)),t.scale.y=fa.scale.y*Math.abs(t.y-(D.y+e.projectionMatrix.n22)/(D.w+e.projectionMatrix.n24)),t.material=fa.material,w.elements.push(t);f&&w.elements.sort(c);return w}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
@@ -88,13 +88,13 @@ b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid
 b,c,d,e,f,g=new THREE.Vector3,h=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],d=this.vertices[c.a],e=this.vertices[c.b],f=this.vertices[c.c],g.sub(f.position,e.position),h.sub(d.position,e.position),g.crossSelf(h),g.isZero()||g.normalize(),c.normal.copy(g)},computeVertexNormals:function(){var a,b,c,d;if(void 0===this.__tmpVertices){d=this.__tmpVertices=Array(this.vertices.length);for(a=0,b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)if(c=
 this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=this.__tmpVertices;for(a=0,b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),
 d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));for(a=0,b=this.vertices.length;a<b;a++)d[a].normalize();for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,
-b,c,d,e,f,B){h=a.vertices[b].position;i=a.vertices[c].position;l=a.vertices[d].position;k=g[e];p=g[f];n=g[B];o=i.x-h.x;q=l.x-h.x;m=i.y-h.y;r=l.y-h.y;s=i.z-h.z;t=l.z-h.z;u=p.u-k.u;x=n.u-k.u;v=p.v-k.v;A=n.v-k.v;D=1/(u*A-x*v);K.set((A*o-v*q)*D,(A*m-v*r)*D,(A*s-v*t)*D);L.set((u*q-x*o)*D,(u*r-x*m)*D,(u*t-x*s)*D);C[b].addSelf(K);C[c].addSelf(K);C[d].addSelf(K);F[b].addSelf(L);F[c].addSelf(L);F[d].addSelf(L)}var b,c,d,e,f,g,h,i,l,k,p,n,o,q,m,r,s,t,u,x,v,A,D,E,C=[],F=[],K=new THREE.Vector3,L=new THREE.Vector3,
-R=new THREE.Vector3,N=new THREE.Vector3,P=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)C[b]=new THREE.Vector3,F[b]=new THREE.Vector3;for(b=0,c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var B=["a","b","c","d"];for(b=0,c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)P.copy(f.vertexNormals[d]),e=f[B[d]],
-E=C[e],R.copy(E),R.subSelf(P.multiplyScalar(P.dot(E))).normalize(),N.cross(f.vertexNormals[d],E),e=N.dot(F[e]),e=0>e?-1:1,f.vertexTangents[d]=new THREE.Vector4(R.x,R.y,R.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
+b,c,d,e,f,j){h=a.vertices[b].position;i=a.vertices[c].position;l=a.vertices[d].position;k=g[e];p=g[f];o=g[j];n=i.x-h.x;q=l.x-h.x;m=i.y-h.y;r=l.y-h.y;s=i.z-h.z;t=l.z-h.z;u=p.u-k.u;x=o.u-k.u;w=p.v-k.v;A=o.v-k.v;D=1/(u*A-x*w);K.set((A*n-w*q)*D,(A*m-w*r)*D,(A*s-w*t)*D);L.set((u*q-x*n)*D,(u*r-x*m)*D,(u*t-x*s)*D);C[b].addSelf(K);C[c].addSelf(K);C[d].addSelf(K);G[b].addSelf(L);G[c].addSelf(L);G[d].addSelf(L)}var b,c,d,e,f,g,h,i,l,k,p,o,n,q,m,r,s,t,u,x,w,A,D,B,C=[],G=[],K=new THREE.Vector3,L=new THREE.Vector3,
+T=new THREE.Vector3,M=new THREE.Vector3,E=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)C[b]=new THREE.Vector3,G[b]=new THREE.Vector3;for(b=0,c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var j=["a","b","c","d"];for(b=0,c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)E.copy(f.vertexNormals[d]),e=f[j[d]],
+B=C[e],T.copy(B),T.subSelf(E.multiplyScalar(E.dot(B))).normalize(),M.cross(f.vertexNormals[d],B),e=M.dot(G[e]),e=0>e?-1:1,f.vertexTangents[d]=new THREE.Vector4(T.x,T.y,T.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
 this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a,b=0,c=0,d=this.vertices.length;c<d;c++)a=this.vertices[c].position.length(),a>b&&(b=a);this.boundingSphere={radius:b}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;for(f=0,g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*
 e)].join("_"),void 0===a[d]?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];for(f=0,g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
-THREE.Spline=function(a){function b(a,b,c,d,e,f,g){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,i,l,k,p,n;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;f=Math.floor(e);g=e-f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>this.points.length-2?f:f+1;c[3]=f>this.points.length-3?f:f+2;l=this.points[c[0]];k=this.points[c[1]];
-p=this.points[c[2]];n=this.points[c[3]];h=g*g;i=g*h;d.x=b(l.x,k.x,p.x,n.x,g,h,i);d.y=b(l.y,k.y,p.y,n.y,g,h,i);d.z=b(l.z,k.z,p.z,n.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,f=new THREE.Vector3,g=new THREE.Vector3,h=[],i=0;h[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,d=this.getPoint(b),g.copy(d),i+=g.distanceTo(f),
+THREE.Spline=function(a){function b(a,b,c,d,e,f,g){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,i,l,k,p,o;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;f=Math.floor(e);g=e-f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>this.points.length-2?f:f+1;c[3]=f>this.points.length-3?f:f+2;l=this.points[c[0]];k=this.points[c[1]];
+p=this.points[c[2]];o=this.points[c[3]];h=g*g;i=g*h;d.x=b(l.x,k.x,p.x,o.x,g,h,i);d.y=b(l.y,k.y,p.y,o.y,g,h,i);d.z=b(l.z,k.z,p.z,o.z,g,h,i);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,f=new THREE.Vector3,g=new THREE.Vector3,h=[],i=0;h[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,d=this.getPoint(b),g.copy(d),i+=g.distanceTo(f),
 f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(h[b]=i,e=b);h[h.length]=i;return{chunks:h,total:i}};this.reparametrizeByArcLength=function(a){var b,c,d,e,f,g,h=[],i=new THREE.Vector3,l=this.getLength();h.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=l.chunks[b]-l.chunks[b-1];g=Math.ceil(a*c/l.total);e=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<g-1;c++)d=e+c*(1/g)*(f-e),d=this.getPoint(d),h.push(i.copy(d).clone());h.push(i.copy(this.points[b]).clone())}this.points=
 h}};THREE.Edge=function(a,b,c,d){this.vertices=[a,b];this.vertexIndices=[c,d];this.faces=[];this.faceIndices=[]};THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};
 THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=void 0!==e?e:0.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;
@@ -153,47 +153,47 @@ THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=
 THREE.Scene.prototype.addObject=function(a){if(a instanceof THREE.Light)-1===this.lights.indexOf(a)&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&-1===this.objects.indexOf(a)){this.objects.push(a);this.__objectsAdded.push(a);var b=this.__objectsRemoved.indexOf(a);-1!==b&&this.__objectsRemoved.splice(b,1)}for(b=0;b<a.children.length;b++)this.addObject(a.children[b])};
 THREE.Scene.prototype.removeObject=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);-1!==b&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),-1!==b&&(this.objects.splice(b,1),this.__objectsRemoved.push(a),b=this.__objectsAdded.indexOf(a),-1!==b&&this.__objectsAdded.splice(b,1)));for(b=0;b<a.children.length;b++)this.removeObject(a.children[b])};
 THREE.Fog=function(a,b,c){this.color=new THREE.Color(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3};THREE.FogExp2=function(a,b){this.color=new THREE.Color(a);this.density=void 0!==b?b:2.5E-4};
-THREE.DOMRenderer=function(){var a=null,b=new THREE.Projector,c,d,e,f;this.domElement=document.createElement("div");this.setSize=function(a,b){c=a;d=b;e=c/2;f=d/2};this.render=function(c,d){var i,l,k,p,n,o,q,m;a=b.projectScene(c,d);for(i=0,l=a.length;i<l;i++)if(n=a[i],n instanceof THREE.RenderableParticle){q=n.x*e+e;m=n.y*f+f;for(k=0,p=n.material.length;k<p;k++)if(o=n.material[k],o instanceof THREE.ParticleDOMMaterial)o=o.domElement,o.style.left=q+"px",o.style.top=m+"px"}}};
-THREE.CanvasRenderer=function(a){function b(a){if(t!=a)m.globalAlpha=t=a}function c(a){if(u!=a){switch(a){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}u=a}}function d(a){if(x!=a)m.strokeStyle=x=a}function e(a){if(v!=a)m.fillStyle=v=a}var a=a||{},f=this,g,h,i,l=new THREE.Projector,k=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
-p,n,o,q,m=k.getContext("2d"),r=new THREE.Color(0),s=0,t=1,u=0,x=null,v=null,A=null,D=null,E=null,C,F,K,L,R=new THREE.RenderableVertex,N=new THREE.RenderableVertex,P,B,j,H,V,y,I,O,T,aa,ga,fa,S=new THREE.Color,ba=new THREE.Color,$=new THREE.Color,ca=new THREE.Color,ia=new THREE.Color,La=[],ja=[],za,qa,Ga,Fa,ab,gb,Ra,Sa,bb,Wa,Aa=new THREE.Rectangle,Ma=new THREE.Rectangle,xa=new THREE.Rectangle,Sb=!1,Z=new THREE.Color,Q=new THREE.Color,jb=new THREE.Color,Ia=new THREE.Vector3,gc,hc,Lc,cb,ic,uc,a=16;gc=
-document.createElement("canvas");gc.width=gc.height=2;hc=gc.getContext("2d");hc.fillStyle="rgba(0,0,0,1)";hc.fillRect(0,0,2,2);Lc=hc.getImageData(0,0,2,2);cb=Lc.data;ic=document.createElement("canvas");ic.width=ic.height=a;uc=ic.getContext("2d");uc.translate(-a/2,-a/2);uc.scale(a,a);a--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){p=a;n=b;o=Math.floor(p/2);q=Math.floor(n/2);k.width=p;k.height=n;Aa.set(-o,
--q,o,q);Ma.set(-o,-q,o,q);t=1;u=0;E=D=A=v=x=null};this.setClearColor=function(a,b){r.copy(a);s=b;Ma.set(-o,-q,o,q)};this.setClearColorHex=function(a,b){r.setHex(a);s=b;Ma.set(-o,-q,o,q)};this.clear=function(){m.setTransform(1,0,0,-1,o,q);Ma.isEmpty()||(Ma.minSelf(Aa),Ma.inflate(2),1>s&&m.clearRect(Math.floor(Ma.getX()),Math.floor(Ma.getY()),Math.floor(Ma.getWidth()),Math.floor(Ma.getHeight())),0<s&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(255*r.r)+","+Math.floor(255*r.g)+","+Math.floor(255*
-r.b)+","+s+")"),m.fillRect(Math.floor(Ma.getX()),Math.floor(Ma.getY()),Math.floor(Ma.getWidth()),Math.floor(Ma.getHeight()))),Ma.empty())};this.render=function(a,k){function n(a){var b,c,d,e;Z.setRGB(0,0,0);Q.setRGB(0,0,0);jb.setRGB(0,0,0);for(b=0,c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(Z.r+=e.r,Z.g+=e.g,Z.b+=e.b):d instanceof THREE.DirectionalLight?(Q.r+=e.r,Q.g+=e.g,Q.b+=e.b):d instanceof THREE.PointLight&&(jb.r+=e.r,jb.g+=e.g,jb.b+=e.b)}function p(a,b,c,d){var e,f,
-g,Z,h,j;for(e=0,f=a.length;e<f;e++)g=a[e],Z=g.color,g instanceof THREE.DirectionalLight?(h=g.matrixWorld.getPosition(),j=c.dot(h),0>=j||(j*=g.intensity,d.r+=Z.r*j,d.g+=Z.g*j,d.b+=Z.b*j)):g instanceof THREE.PointLight&&(h=g.matrixWorld.getPosition(),j=c.dot(Ia.sub(h,b).normalize()),0>=j||(j*=0==g.distance?1:1-Math.min(b.distanceTo(h)/g.distance,1),0!=j&&(j*=g.intensity,d.r+=Z.r*j,d.g+=Z.g*j,d.b+=Z.b*j)))}function r(a,f,g){b(g.opacity);c(g.blending);var Z,h,j,i,k,l;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)i=
-g.map.image,k=i.width>>1,l=i.height>>1,g=f.scale.x*o,j=f.scale.y*q,Z=g*k,h=j*l,xa.set(a.x-Z,a.y-h,a.x+Z,a.y+h),Aa.intersects(xa)&&(m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(g,-j),m.translate(-k,-l),m.drawImage(i,0,0),m.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(Z=f.scale.x*o,h=f.scale.y*q,xa.set(a.x-Z,a.y-h,a.x+Z,a.y+h),Aa.intersects(xa)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(Z,h),g.program(m),
-m.restore()))}function s(a,e,f,g){b(g.opacity);c(g.blending);m.beginPath();m.moveTo(a.positionScreen.x,a.positionScreen.y);m.lineTo(e.positionScreen.x,e.positionScreen.y);m.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(A!=a)m.lineWidth=A=a;a=g.linecap;if(D!=a)m.lineCap=D=a;a=g.linejoin;if(E!=a)m.lineJoin=E=a;d(g.color.getContextStyle());m.stroke();xa.inflate(2*g.linewidth)}}function t(a,d,e,g,h,l,Q,m){f.info.render.vertices+=3;f.info.render.faces++;b(m.opacity);c(m.blending);
-P=a.positionScreen.x;B=a.positionScreen.y;j=d.positionScreen.x;H=d.positionScreen.y;V=e.positionScreen.x;y=e.positionScreen.y;x(P,B,j,H,V,y);if(m instanceof THREE.MeshBasicMaterial)if(m.map)m.map.mapping instanceof THREE.UVMapping&&(Fa=Q.uvs[0],Mc(P,B,j,H,V,y,Fa[g].u,Fa[g].v,Fa[h].u,Fa[h].v,Fa[l].u,Fa[l].v,m.map));else if(m.envMap){if(m.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,Ia.copy(Q.vertexNormalsWorld[g]),ab=0.5*(Ia.x*a.n11+Ia.y*a.n12+Ia.z*a.n13)+0.5,gb=
-0.5*-(Ia.x*a.n21+Ia.y*a.n22+Ia.z*a.n23)+0.5,Ia.copy(Q.vertexNormalsWorld[h]),Ra=0.5*(Ia.x*a.n11+Ia.y*a.n12+Ia.z*a.n13)+0.5,Sa=0.5*-(Ia.x*a.n21+Ia.y*a.n22+Ia.z*a.n23)+0.5,Ia.copy(Q.vertexNormalsWorld[l]),bb=0.5*(Ia.x*a.n11+Ia.y*a.n12+Ia.z*a.n13)+0.5,Wa=0.5*-(Ia.x*a.n21+Ia.y*a.n22+Ia.z*a.n23)+0.5,Mc(P,B,j,H,V,y,ab,gb,Ra,Sa,bb,Wa,m.envMap)}else m.wireframe?Eb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):zb(m.color);else if(m instanceof THREE.MeshLambertMaterial)m.map&&!m.wireframe&&
-(m.map.mapping instanceof THREE.UVMapping&&(Fa=Q.uvs[0],Mc(P,B,j,H,V,y,Fa[g].u,Fa[g].v,Fa[h].u,Fa[h].v,Fa[l].u,Fa[l].v,m.map)),c(THREE.SubtractiveBlending)),Sb?!m.wireframe&&m.shading==THREE.SmoothShading&&3==Q.vertexNormalsWorld.length?(ba.r=$.r=ca.r=Z.r,ba.g=$.g=ca.g=Z.g,ba.b=$.b=ca.b=Z.b,p(i,Q.v1.positionWorld,Q.vertexNormalsWorld[0],ba),p(i,Q.v2.positionWorld,Q.vertexNormalsWorld[1],$),p(i,Q.v3.positionWorld,Q.vertexNormalsWorld[2],ca),ba.r=Math.max(0,Math.min(m.color.r*ba.r,1)),ba.g=Math.max(0,
-Math.min(m.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(m.color.b*ba.b,1)),$.r=Math.max(0,Math.min(m.color.r*$.r,1)),$.g=Math.max(0,Math.min(m.color.g*$.g,1)),$.b=Math.max(0,Math.min(m.color.b*$.b,1)),ca.r=Math.max(0,Math.min(m.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(m.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(m.color.b*ca.b,1)),ia.r=0.5*($.r+ca.r),ia.g=0.5*($.g+ca.g),ia.b=0.5*($.b+ca.b),Ga=vc(ba,$,ca,ia),Yb(P,B,j,H,V,y,0,0,1,0,0,1,Ga)):(S.r=Z.r,S.g=Z.g,S.b=Z.b,p(i,Q.centroidWorld,Q.normalWorld,S),
-S.r=Math.max(0,Math.min(m.color.r*S.r,1)),S.g=Math.max(0,Math.min(m.color.g*S.g,1)),S.b=Math.max(0,Math.min(m.color.b*S.b,1)),m.wireframe?Eb(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):zb(S)):m.wireframe?Eb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):zb(m.color);else if(m instanceof THREE.MeshDepthMaterial)za=k.near,qa=k.far,ba.r=ba.g=ba.b=1-Tb(a.positionScreen.z,za,qa),$.r=$.g=$.b=1-Tb(d.positionScreen.z,za,qa),ca.r=ca.g=ca.b=1-Tb(e.positionScreen.z,za,
-qa),ia.r=0.5*($.r+ca.r),ia.g=0.5*($.g+ca.g),ia.b=0.5*($.b+ca.b),Ga=vc(ba,$,ca,ia),Yb(P,B,j,H,V,y,0,0,1,0,0,1,Ga);else if(m instanceof THREE.MeshNormalMaterial)S.r=Zb(Q.normalWorld.x),S.g=Zb(Q.normalWorld.y),S.b=Zb(Q.normalWorld.z),m.wireframe?Eb(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):zb(S)}function u(a,d,e,g,h,l,m,Q,n){f.info.render.vertices+=4;f.info.render.faces++;b(Q.opacity);c(Q.blending);if(Q.map||Q.envMap)t(a,d,g,0,1,3,m,Q,n),t(h,e,l,1,2,3,m,Q,n);else if(P=a.positionScreen.x,
-B=a.positionScreen.y,j=d.positionScreen.x,H=d.positionScreen.y,V=e.positionScreen.x,y=e.positionScreen.y,I=g.positionScreen.x,O=g.positionScreen.y,T=h.positionScreen.x,aa=h.positionScreen.y,ga=l.positionScreen.x,fa=l.positionScreen.y,Q instanceof THREE.MeshBasicMaterial)v(P,B,j,H,V,y,I,O),Q.wireframe?Eb(Q.color,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):zb(Q.color);else if(Q instanceof THREE.MeshLambertMaterial)Sb?!Q.wireframe&&Q.shading==THREE.SmoothShading&&4==m.vertexNormalsWorld.length?
-(ba.r=$.r=ca.r=ia.r=Z.r,ba.g=$.g=ca.g=ia.g=Z.g,ba.b=$.b=ca.b=ia.b=Z.b,p(i,m.v1.positionWorld,m.vertexNormalsWorld[0],ba),p(i,m.v2.positionWorld,m.vertexNormalsWorld[1],$),p(i,m.v4.positionWorld,m.vertexNormalsWorld[3],ca),p(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ia),ba.r=Math.max(0,Math.min(Q.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(Q.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(Q.color.b*ba.b,1)),$.r=Math.max(0,Math.min(Q.color.r*$.r,1)),$.g=Math.max(0,Math.min(Q.color.g*$.g,1)),$.b=Math.max(0,
-Math.min(Q.color.b*$.b,1)),ca.r=Math.max(0,Math.min(Q.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(Q.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(Q.color.b*ca.b,1)),ia.r=Math.max(0,Math.min(Q.color.r*ia.r,1)),ia.g=Math.max(0,Math.min(Q.color.g*ia.g,1)),ia.b=Math.max(0,Math.min(Q.color.b*ia.b,1)),Ga=vc(ba,$,ca,ia),x(P,B,j,H,I,O),Yb(P,B,j,H,I,O,0,0,1,0,0,1,Ga),x(T,aa,V,y,ga,fa),Yb(T,aa,V,y,ga,fa,1,0,1,1,0,1,Ga)):(S.r=Z.r,S.g=Z.g,S.b=Z.b,p(i,m.centroidWorld,m.normalWorld,S),S.r=Math.max(0,Math.min(Q.color.r*
-S.r,1)),S.g=Math.max(0,Math.min(Q.color.g*S.g,1)),S.b=Math.max(0,Math.min(Q.color.b*S.b,1)),v(P,B,j,H,V,y,I,O),Q.wireframe?Eb(S,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):zb(S)):(v(P,B,j,H,V,y,I,O),Q.wireframe?Eb(Q.color,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):zb(Q.color));else if(Q instanceof THREE.MeshNormalMaterial)S.r=Zb(m.normalWorld.x),S.g=Zb(m.normalWorld.y),S.b=Zb(m.normalWorld.z),v(P,B,j,H,V,y,I,O),Q.wireframe?Eb(S,Q.wireframeLinewidth,Q.wireframeLinecap,
-Q.wireframeLinejoin):zb(S);else if(Q instanceof THREE.MeshDepthMaterial)za=k.near,qa=k.far,ba.r=ba.g=ba.b=1-Tb(a.positionScreen.z,za,qa),$.r=$.g=$.b=1-Tb(d.positionScreen.z,za,qa),ca.r=ca.g=ca.b=1-Tb(g.positionScreen.z,za,qa),ia.r=ia.g=ia.b=1-Tb(e.positionScreen.z,za,qa),Ga=vc(ba,$,ca,ia),x(P,B,j,H,I,O),Yb(P,B,j,H,I,O,0,0,1,0,0,1,Ga),x(T,aa,V,y,ga,fa),Yb(T,aa,V,y,ga,fa,1,0,1,1,0,1,Ga)}function x(a,b,c,d,e,f){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(a,b);m.closePath()}function v(a,
-b,c,d,e,f,g,Z){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(g,Z);m.lineTo(a,b);m.closePath()}function Eb(a,b,c,e){if(A!=b)m.lineWidth=A=b;if(D!=c)m.lineCap=D=c;if(E!=e)m.lineJoin=E=e;d(a.getContextStyle());m.stroke();xa.inflate(2*b)}function zb(a){e(a.getContextStyle());m.fill()}function Mc(a,b,c,d,f,g,Z,h,j,i,Q,l,k){if(0!=k.image.width){if(!0==k.needsUpdate||void 0==La[k.id]){var n=k.wrapS==THREE.RepeatWrapping,p=k.wrapT==THREE.RepeatWrapping;La[k.id]=m.createPattern(k.image,
-n&&p?"repeat":n&&!p?"repeat-x":!n&&p?"repeat-y":"no-repeat");k.needsUpdate=!1}e(La[k.id]);var n=k.offset.x/k.repeat.x,p=k.offset.y/k.repeat.y,jb=k.image.width*k.repeat.x,o=k.image.height*k.repeat.y,Z=(Z+n)*jb,h=(h+p)*o,c=c-a,d=d-b,f=f-a,g=g-b,j=(j+n)*jb-Z,i=(i+p)*o-h,Q=(Q+n)*jb-Z,l=(l+p)*o-h,n=j*l-Q*i;if(0==n){if(void 0===ja[k.id])b=document.createElement("canvas"),b.width=k.image.width,b.height=k.image.height,b=b.getContext("2d"),b.drawImage(k.image,0,0),ja[k.id]=b.getImageData(0,0,k.image.width,
-k.image.height).data;b=ja[k.id];Z=4*(Math.floor(Z)+Math.floor(h)*k.image.width);S.setRGB(b[Z]/255,b[Z+1]/255,b[Z+2]/255);zb(S)}else n=1/n,k=(l*c-i*f)*n,i=(l*d-i*g)*n,c=(j*f-Q*c)*n,d=(j*g-Q*d)*n,a=a-k*Z-c*h,Z=b-i*Z-d*h,m.save(),m.transform(k,i,c,d,a,Z),m.fill(),m.restore()}}function Yb(a,b,c,d,e,f,g,Z,h,j,i,k,Q){var l,n;l=Q.width-1;n=Q.height-1;g*=l;Z*=n;c-=a;d-=b;e-=a;f-=b;h=h*l-g;j=j*n-Z;i=i*l-g;k=k*n-Z;n=1/(h*k-i*j);l=(k*c-j*e)*n;j=(k*d-j*f)*n;c=(h*e-i*c)*n;d=(h*f-i*d)*n;a=a-l*g-c*Z;b=b-j*g-d*Z;
-m.save();m.transform(l,j,c,d,a,b);m.clip();m.drawImage(Q,0,0);m.restore()}function vc(a,b,c,d){var e=~~(255*a.r),f=~~(255*a.g),a=~~(255*a.b),g=~~(255*b.r),Z=~~(255*b.g),b=~~(255*b.b),h=~~(255*c.r),j=~~(255*c.g),c=~~(255*c.b),i=~~(255*d.r),k=~~(255*d.g),d=~~(255*d.b);cb[0]=0>e?0:255<e?255:e;cb[1]=0>f?0:255<f?255:f;cb[2]=0>a?0:255<a?255:a;cb[4]=0>g?0:255<g?255:g;cb[5]=0>Z?0:255<Z?255:Z;cb[6]=0>b?0:255<b?255:b;cb[8]=0>h?0:255<h?255:h;cb[9]=0>j?0:255<j?255:j;cb[10]=0>c?0:255<c?255:c;cb[12]=0>i?0:255<
-i?255:i;cb[13]=0>k?0:255<k?255:k;cb[14]=0>d?0:255<d?255:d;hc.putImageData(Lc,0,0);uc.drawImage(gc,0,0);return ic}function Tb(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Zb(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function Fb(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;0!=e&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var xc,Xc,Na,hb;this.autoClear?this.clear():m.setTransform(1,0,0,-1,o,q);f.info.render.vertices=0;f.info.render.faces=0;g=l.projectScene(a,k,this.sortElements);h=g.elements;i=
-g.lights;(Sb=0<i.length)&&n(i);for(xc=0,Xc=h.length;xc<Xc;xc++)if(Na=h[xc],hb=Na.material,hb=hb instanceof THREE.MeshFaceMaterial?Na.faceMaterial:hb,!(null==hb||0==hb.opacity)){xa.empty();if(Na instanceof THREE.RenderableParticle)C=Na,C.x*=o,C.y*=q,r(C,Na,hb,a);else if(Na instanceof THREE.RenderableLine)C=Na.v1,F=Na.v2,C.positionScreen.x*=o,C.positionScreen.y*=q,F.positionScreen.x*=o,F.positionScreen.y*=q,xa.addPoint(C.positionScreen.x,C.positionScreen.y),xa.addPoint(F.positionScreen.x,F.positionScreen.y),
-Aa.intersects(xa)&&s(C,F,Na,hb,a);else if(Na instanceof THREE.RenderableFace3)C=Na.v1,F=Na.v2,K=Na.v3,C.positionScreen.x*=o,C.positionScreen.y*=q,F.positionScreen.x*=o,F.positionScreen.y*=q,K.positionScreen.x*=o,K.positionScreen.y*=q,hb.overdraw&&(Fb(C.positionScreen,F.positionScreen),Fb(F.positionScreen,K.positionScreen),Fb(K.positionScreen,C.positionScreen)),xa.add3Points(C.positionScreen.x,C.positionScreen.y,F.positionScreen.x,F.positionScreen.y,K.positionScreen.x,K.positionScreen.y),Aa.intersects(xa)&&
-t(C,F,K,0,1,2,Na,hb,a);else if(Na instanceof THREE.RenderableFace4)C=Na.v1,F=Na.v2,K=Na.v3,L=Na.v4,C.positionScreen.x*=o,C.positionScreen.y*=q,F.positionScreen.x*=o,F.positionScreen.y*=q,K.positionScreen.x*=o,K.positionScreen.y*=q,L.positionScreen.x*=o,L.positionScreen.y*=q,R.positionScreen.copy(F.positionScreen),N.positionScreen.copy(L.positionScreen),hb.overdraw&&(Fb(C.positionScreen,F.positionScreen),Fb(F.positionScreen,L.positionScreen),Fb(L.positionScreen,C.positionScreen),Fb(K.positionScreen,
-R.positionScreen),Fb(K.positionScreen,N.positionScreen)),xa.addPoint(C.positionScreen.x,C.positionScreen.y),xa.addPoint(F.positionScreen.x,F.positionScreen.y),xa.addPoint(K.positionScreen.x,K.positionScreen.y),xa.addPoint(L.positionScreen.x,L.positionScreen.y),Aa.intersects(xa)&&u(C,F,K,L,R,N,Na,hb,a);Ma.addRectangle(xa)}m.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(a,b,c,d){var e,f,g,h,i,k;for(e=0,f=a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(i=g.matrixWorld.getPosition(),k=c.dot(i),0>=k||(k*=g.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),k=c.dot(C.sub(i,b).normalize()),0>=k||(k*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=k&&(k*=g.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)))}function b(a){null==F[a]&&(F[a]=document.createElementNS("http://www.w3.org/2000/svg",
-"path"),0==P&&F[a].setAttribute("shape-rendering","crispEdges"));return F[a]}function c(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}var d=this,e,f,g,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,k,p,n,o,q,m,r,s=new THREE.Rectangle,t=new THREE.Rectangle,u=!1,x=new THREE.Color,v=new THREE.Color,A=new THREE.Color,D=new THREE.Color,E,C=new THREE.Vector3,F=[],K=[],L,R,N,P=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,
-faces:0}};this.setQuality=function(a){switch(a){case "high":P=1;break;case "low":P=0}};this.setSize=function(a,b){l=a;k=b;p=l/2;n=k/2;i.setAttribute("viewBox",-p+" "+-n+" "+l+" "+k);i.setAttribute("width",l);i.setAttribute("height",k);s.set(-p,-n,p,n)};this.clear=function(){for(;0<i.childNodes.length;)i.removeChild(i.childNodes[0])};this.render=function(k,j){var l,C,y,I;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(k,j,this.sortElements);f=e.elements;
-g=e.lights;N=R=0;if(u=0<g.length){v.setRGB(0,0,0);A.setRGB(0,0,0);D.setRGB(0,0,0);for(l=0,C=g.length;l<C;l++)I=g[l],y=I.color,I instanceof THREE.AmbientLight?(v.r+=y.r,v.g+=y.g,v.b+=y.b):I instanceof THREE.DirectionalLight?(A.r+=y.r,A.g+=y.g,A.b+=y.b):I instanceof THREE.PointLight&&(D.r+=y.r,D.g+=y.g,D.b+=y.b)}for(l=0,C=f.length;l<C;l++)if(y=f[l],I=y.material,I=I instanceof THREE.MeshFaceMaterial?y.faceMaterial:I,!(null==I||0==I.opacity))if(t.empty(),y instanceof THREE.RenderableParticle)o=y,o.x*=
-p,o.y*=-n;else if(y instanceof THREE.RenderableLine){if(o=y.v1,q=y.v2,o.positionScreen.x*=p,o.positionScreen.y*=-n,q.positionScreen.x*=p,q.positionScreen.y*=-n,t.addPoint(o.positionScreen.x,o.positionScreen.y),t.addPoint(q.positionScreen.x,q.positionScreen.y),s.intersects(t)){y=o;var O=q,T=N++;null==K[T]&&(K[T]=document.createElementNS("http://www.w3.org/2000/svg","line"),0==P&&K[T].setAttribute("shape-rendering","crispEdges"));L=K[T];L.setAttribute("x1",y.positionScreen.x);L.setAttribute("y1",y.positionScreen.y);
-L.setAttribute("x2",O.positionScreen.x);L.setAttribute("y2",O.positionScreen.y);I instanceof THREE.LineBasicMaterial&&(L.setAttribute("style","fill: none; stroke: "+I.color.getContextStyle()+"; stroke-width: "+I.linewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.linecap+"; stroke-linejoin: "+I.linejoin),i.appendChild(L))}}else if(y instanceof THREE.RenderableFace3){if(o=y.v1,q=y.v2,m=y.v3,o.positionScreen.x*=p,o.positionScreen.y*=-n,q.positionScreen.x*=p,q.positionScreen.y*=-n,m.positionScreen.x*=
-p,m.positionScreen.y*=-n,t.addPoint(o.positionScreen.x,o.positionScreen.y),t.addPoint(q.positionScreen.x,q.positionScreen.y),t.addPoint(m.positionScreen.x,m.positionScreen.y),s.intersects(t)){var O=o,T=q,aa=m;d.info.render.vertices+=3;d.info.render.faces++;L=b(R++);L.setAttribute("d","M "+O.positionScreen.x+" "+O.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+"z");I instanceof THREE.MeshBasicMaterial?x.copy(I.color):I instanceof THREE.MeshLambertMaterial?
-u?(x.r=v.r,x.g=v.g,x.b=v.b,a(g,y.centroidWorld,y.normalWorld,x),x.r=Math.max(0,Math.min(I.color.r*x.r,1)),x.g=Math.max(0,Math.min(I.color.g*x.g,1)),x.b=Math.max(0,Math.min(I.color.b*x.b,1))):x.copy(I.color):I instanceof THREE.MeshDepthMaterial?(E=1-I.__2near/(I.__farPlusNear-y.z*I.__farMinusNear),x.setRGB(E,E,E)):I instanceof THREE.MeshNormalMaterial&&x.setRGB(c(y.normalWorld.x),c(y.normalWorld.y),c(y.normalWorld.z));I.wireframe?L.setAttribute("style","fill: none; stroke: "+x.getContextStyle()+"; stroke-width: "+
-I.wireframeLinewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.wireframeLinecap+"; stroke-linejoin: "+I.wireframeLinejoin):L.setAttribute("style","fill: "+x.getContextStyle()+"; fill-opacity: "+I.opacity);i.appendChild(L)}}else if(y instanceof THREE.RenderableFace4&&(o=y.v1,q=y.v2,m=y.v3,r=y.v4,o.positionScreen.x*=p,o.positionScreen.y*=-n,q.positionScreen.x*=p,q.positionScreen.y*=-n,m.positionScreen.x*=p,m.positionScreen.y*=-n,r.positionScreen.x*=p,r.positionScreen.y*=-n,t.addPoint(o.positionScreen.x,
-o.positionScreen.y),t.addPoint(q.positionScreen.x,q.positionScreen.y),t.addPoint(m.positionScreen.x,m.positionScreen.y),t.addPoint(r.positionScreen.x,r.positionScreen.y),s.intersects(t))){var O=o,T=q,aa=m,F=r;d.info.render.vertices+=4;d.info.render.faces++;L=b(R++);L.setAttribute("d","M "+O.positionScreen.x+" "+O.positionScreen.y+" L "+T.positionScreen.x+" "+T.positionScreen.y+" L "+aa.positionScreen.x+","+aa.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+"z");I instanceof THREE.MeshBasicMaterial?
-x.copy(I.color):I instanceof THREE.MeshLambertMaterial?u?(x.r=v.r,x.g=v.g,x.b=v.b,a(g,y.centroidWorld,y.normalWorld,x),x.r=Math.max(0,Math.min(I.color.r*x.r,1)),x.g=Math.max(0,Math.min(I.color.g*x.g,1)),x.b=Math.max(0,Math.min(I.color.b*x.b,1))):x.copy(I.color):I instanceof THREE.MeshDepthMaterial?(E=1-I.__2near/(I.__farPlusNear-y.z*I.__farMinusNear),x.setRGB(E,E,E)):I instanceof THREE.MeshNormalMaterial&&x.setRGB(c(y.normalWorld.x),c(y.normalWorld.y),c(y.normalWorld.z));I.wireframe?L.setAttribute("style",
-"fill: none; stroke: "+x.getContextStyle()+"; stroke-width: "+I.wireframeLinewidth+"; stroke-opacity: "+I.opacity+"; stroke-linecap: "+I.wireframeLinecap+"; stroke-linejoin: "+I.wireframeLinejoin):L.setAttribute("style","fill: "+x.getContextStyle()+"; fill-opacity: "+I.opacity);i.appendChild(L)}}};
+THREE.DOMRenderer=function(){var a=null,b=new THREE.Projector,c,d,e,f;this.domElement=document.createElement("div");this.setSize=function(a,b){c=a;d=b;e=c/2;f=d/2};this.render=function(c,d){var i,l,k,p,o,n,q,m;a=b.projectScene(c,d);for(i=0,l=a.length;i<l;i++)if(o=a[i],o instanceof THREE.RenderableParticle){q=o.x*e+e;m=o.y*f+f;for(k=0,p=o.material.length;k<p;k++)if(n=o.material[k],n instanceof THREE.ParticleDOMMaterial)n=n.domElement,n.style.left=q+"px",n.style.top=m+"px"}}};
+THREE.CanvasRenderer=function(a){function b(a){if(t!=a)m.globalAlpha=t=a}function c(a){if(u!=a){switch(a){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}u=a}}function d(a){if(x!=a)m.strokeStyle=x=a}function e(a){if(w!=a)m.fillStyle=w=a}var a=a||{},f=this,g,h,i,l=new THREE.Projector,k=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
+p,o,n,q,m=k.getContext("2d"),r=new THREE.Color(0),s=0,t=1,u=0,x=null,w=null,A=null,D=null,B=null,C,G,K,L,T=new THREE.RenderableVertex,M=new THREE.RenderableVertex,E,j,Q,I,R,y,F,P,$,Z,ga,fa,S=new THREE.Color,aa=new THREE.Color,ba=new THREE.Color,ca=new THREE.Color,ha=new THREE.Color,Na=[],ja=[],za,qa,Ga,Ea,Sa,Ta,Wa,fb,Za,lb,Oa=new THREE.Rectangle,Ka=new THREE.Rectangle,xa=new THREE.Rectangle,Sb=!1,Y=new THREE.Color,O=new THREE.Color,ib=new THREE.Color,Ha=new THREE.Vector3,hc,ic,Mc,bb,jc,vc,a=16;hc=
+document.createElement("canvas");hc.width=hc.height=2;ic=hc.getContext("2d");ic.fillStyle="rgba(0,0,0,1)";ic.fillRect(0,0,2,2);Mc=ic.getImageData(0,0,2,2);bb=Mc.data;jc=document.createElement("canvas");jc.width=jc.height=a;vc=jc.getContext("2d");vc.translate(-a/2,-a/2);vc.scale(a,a);a--;this.domElement=k;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){p=a;o=b;n=Math.floor(p/2);q=Math.floor(o/2);k.width=p;k.height=o;Oa.set(-n,
+-q,n,q);Ka.set(-n,-q,n,q);t=1;u=0;B=D=A=w=x=null};this.setClearColor=function(a,b){r.copy(a);s=b;Ka.set(-n,-q,n,q)};this.setClearColorHex=function(a,b){r.setHex(a);s=b;Ka.set(-n,-q,n,q)};this.clear=function(){m.setTransform(1,0,0,-1,n,q);Ka.isEmpty()||(Ka.minSelf(Oa),Ka.inflate(2),1>s&&m.clearRect(Math.floor(Ka.getX()),Math.floor(Ka.getY()),Math.floor(Ka.getWidth()),Math.floor(Ka.getHeight())),0<s&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(255*r.r)+","+Math.floor(255*r.g)+","+Math.floor(255*
+r.b)+","+s+")"),m.fillRect(Math.floor(Ka.getX()),Math.floor(Ka.getY()),Math.floor(Ka.getWidth()),Math.floor(Ka.getHeight()))),Ka.empty())};this.render=function(a,k){function o(a){var b,c,d,e;Y.setRGB(0,0,0);O.setRGB(0,0,0);ib.setRGB(0,0,0);for(b=0,c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(Y.r+=e.r,Y.g+=e.g,Y.b+=e.b):d instanceof THREE.DirectionalLight?(O.r+=e.r,O.g+=e.g,O.b+=e.b):d instanceof THREE.PointLight&&(ib.r+=e.r,ib.g+=e.g,ib.b+=e.b)}function p(a,b,c,d){var e,f,
+g,j,h,Y;for(e=0,f=a.length;e<f;e++)g=a[e],j=g.color,g instanceof THREE.DirectionalLight?(h=g.matrixWorld.getPosition(),Y=c.dot(h),0>=Y||(Y*=g.intensity,d.r+=j.r*Y,d.g+=j.g*Y,d.b+=j.b*Y)):g instanceof THREE.PointLight&&(h=g.matrixWorld.getPosition(),Y=c.dot(Ha.sub(h,b).normalize()),0>=Y||(Y*=0==g.distance?1:1-Math.min(b.distanceTo(h)/g.distance,1),0!=Y&&(Y*=g.intensity,d.r+=j.r*Y,d.g+=j.g*Y,d.b+=j.b*Y)))}function r(a,f,g){b(g.opacity);c(g.blending);var j,h,Y,i,k,l;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)i=
+g.map.image,k=i.width>>1,l=i.height>>1,g=f.scale.x*n,Y=f.scale.y*q,j=g*k,h=Y*l,xa.set(a.x-j,a.y-h,a.x+j,a.y+h),Oa.intersects(xa)&&(m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(g,-Y),m.translate(-k,-l),m.drawImage(i,0,0),m.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(j=f.scale.x*n,h=f.scale.y*q,xa.set(a.x-j,a.y-h,a.x+j,a.y+h),Oa.intersects(xa)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(j,h),g.program(m),
+m.restore()))}function s(a,e,f,g){b(g.opacity);c(g.blending);m.beginPath();m.moveTo(a.positionScreen.x,a.positionScreen.y);m.lineTo(e.positionScreen.x,e.positionScreen.y);m.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(A!=a)m.lineWidth=A=a;a=g.linecap;if(D!=a)m.lineCap=D=a;a=g.linejoin;if(B!=a)m.lineJoin=B=a;d(g.color.getContextStyle());m.stroke();xa.inflate(2*g.linewidth)}}function t(a,d,e,g,h,l,O,m){f.info.render.vertices+=3;f.info.render.faces++;b(m.opacity);c(m.blending);
+E=a.positionScreen.x;j=a.positionScreen.y;Q=d.positionScreen.x;I=d.positionScreen.y;R=e.positionScreen.x;y=e.positionScreen.y;x(E,j,Q,I,R,y);if(m instanceof THREE.MeshBasicMaterial)if(m.map)m.map.mapping instanceof THREE.UVMapping&&(Ea=O.uvs[0],Nc(E,j,Q,I,R,y,Ea[g].u,Ea[g].v,Ea[h].u,Ea[h].v,Ea[l].u,Ea[l].v,m.map));else if(m.envMap){if(m.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=k.matrixWorldInverse,Ha.copy(O.vertexNormalsWorld[g]),Sa=0.5*(Ha.x*a.n11+Ha.y*a.n12+Ha.z*a.n13)+0.5,Ta=
+0.5*-(Ha.x*a.n21+Ha.y*a.n22+Ha.z*a.n23)+0.5,Ha.copy(O.vertexNormalsWorld[h]),Wa=0.5*(Ha.x*a.n11+Ha.y*a.n12+Ha.z*a.n13)+0.5,fb=0.5*-(Ha.x*a.n21+Ha.y*a.n22+Ha.z*a.n23)+0.5,Ha.copy(O.vertexNormalsWorld[l]),Za=0.5*(Ha.x*a.n11+Ha.y*a.n12+Ha.z*a.n13)+0.5,lb=0.5*-(Ha.x*a.n21+Ha.y*a.n22+Ha.z*a.n23)+0.5,Nc(E,j,Q,I,R,y,Sa,Ta,Wa,fb,Za,lb,m.envMap)}else m.wireframe?Eb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):zb(m.color);else if(m instanceof THREE.MeshLambertMaterial)m.map&&!m.wireframe&&
+(m.map.mapping instanceof THREE.UVMapping&&(Ea=O.uvs[0],Nc(E,j,Q,I,R,y,Ea[g].u,Ea[g].v,Ea[h].u,Ea[h].v,Ea[l].u,Ea[l].v,m.map)),c(THREE.SubtractiveBlending)),Sb?!m.wireframe&&m.shading==THREE.SmoothShading&&3==O.vertexNormalsWorld.length?(aa.r=ba.r=ca.r=Y.r,aa.g=ba.g=ca.g=Y.g,aa.b=ba.b=ca.b=Y.b,p(i,O.v1.positionWorld,O.vertexNormalsWorld[0],aa),p(i,O.v2.positionWorld,O.vertexNormalsWorld[1],ba),p(i,O.v3.positionWorld,O.vertexNormalsWorld[2],ca),aa.r=Math.max(0,Math.min(m.color.r*aa.r,1)),aa.g=Math.max(0,
+Math.min(m.color.g*aa.g,1)),aa.b=Math.max(0,Math.min(m.color.b*aa.b,1)),ba.r=Math.max(0,Math.min(m.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(m.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(m.color.b*ba.b,1)),ca.r=Math.max(0,Math.min(m.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(m.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(m.color.b*ca.b,1)),ha.r=0.5*(ba.r+ca.r),ha.g=0.5*(ba.g+ca.g),ha.b=0.5*(ba.b+ca.b),Ga=wc(aa,ba,ca,ha),Yb(E,j,Q,I,R,y,0,0,1,0,0,1,Ga)):(S.r=Y.r,S.g=Y.g,S.b=Y.b,p(i,O.centroidWorld,O.normalWorld,
+S),S.r=Math.max(0,Math.min(m.color.r*S.r,1)),S.g=Math.max(0,Math.min(m.color.g*S.g,1)),S.b=Math.max(0,Math.min(m.color.b*S.b,1)),m.wireframe?Eb(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):zb(S)):m.wireframe?Eb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):zb(m.color);else if(m instanceof THREE.MeshDepthMaterial)za=k.near,qa=k.far,aa.r=aa.g=aa.b=1-Tb(a.positionScreen.z,za,qa),ba.r=ba.g=ba.b=1-Tb(d.positionScreen.z,za,qa),ca.r=ca.g=ca.b=1-Tb(e.positionScreen.z,
+za,qa),ha.r=0.5*(ba.r+ca.r),ha.g=0.5*(ba.g+ca.g),ha.b=0.5*(ba.b+ca.b),Ga=wc(aa,ba,ca,ha),Yb(E,j,Q,I,R,y,0,0,1,0,0,1,Ga);else if(m instanceof THREE.MeshNormalMaterial)S.r=Zb(O.normalWorld.x),S.g=Zb(O.normalWorld.y),S.b=Zb(O.normalWorld.z),m.wireframe?Eb(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):zb(S)}function u(a,d,e,g,h,l,m,O,o){f.info.render.vertices+=4;f.info.render.faces++;b(O.opacity);c(O.blending);if(O.map||O.envMap)t(a,d,g,0,1,3,m,O,o),t(h,e,l,1,2,3,m,O,o);else if(E=a.positionScreen.x,
+j=a.positionScreen.y,Q=d.positionScreen.x,I=d.positionScreen.y,R=e.positionScreen.x,y=e.positionScreen.y,F=g.positionScreen.x,P=g.positionScreen.y,$=h.positionScreen.x,Z=h.positionScreen.y,ga=l.positionScreen.x,fa=l.positionScreen.y,O instanceof THREE.MeshBasicMaterial)w(E,j,Q,I,R,y,F,P),O.wireframe?Eb(O.color,O.wireframeLinewidth,O.wireframeLinecap,O.wireframeLinejoin):zb(O.color);else if(O instanceof THREE.MeshLambertMaterial)Sb?!O.wireframe&&O.shading==THREE.SmoothShading&&4==m.vertexNormalsWorld.length?
+(aa.r=ba.r=ca.r=ha.r=Y.r,aa.g=ba.g=ca.g=ha.g=Y.g,aa.b=ba.b=ca.b=ha.b=Y.b,p(i,m.v1.positionWorld,m.vertexNormalsWorld[0],aa),p(i,m.v2.positionWorld,m.vertexNormalsWorld[1],ba),p(i,m.v4.positionWorld,m.vertexNormalsWorld[3],ca),p(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ha),aa.r=Math.max(0,Math.min(O.color.r*aa.r,1)),aa.g=Math.max(0,Math.min(O.color.g*aa.g,1)),aa.b=Math.max(0,Math.min(O.color.b*aa.b,1)),ba.r=Math.max(0,Math.min(O.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(O.color.g*ba.g,1)),ba.b=
+Math.max(0,Math.min(O.color.b*ba.b,1)),ca.r=Math.max(0,Math.min(O.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(O.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(O.color.b*ca.b,1)),ha.r=Math.max(0,Math.min(O.color.r*ha.r,1)),ha.g=Math.max(0,Math.min(O.color.g*ha.g,1)),ha.b=Math.max(0,Math.min(O.color.b*ha.b,1)),Ga=wc(aa,ba,ca,ha),x(E,j,Q,I,F,P),Yb(E,j,Q,I,F,P,0,0,1,0,0,1,Ga),x($,Z,R,y,ga,fa),Yb($,Z,R,y,ga,fa,1,0,1,1,0,1,Ga)):(S.r=Y.r,S.g=Y.g,S.b=Y.b,p(i,m.centroidWorld,m.normalWorld,S),S.r=Math.max(0,Math.min(O.color.r*
+S.r,1)),S.g=Math.max(0,Math.min(O.color.g*S.g,1)),S.b=Math.max(0,Math.min(O.color.b*S.b,1)),w(E,j,Q,I,R,y,F,P),O.wireframe?Eb(S,O.wireframeLinewidth,O.wireframeLinecap,O.wireframeLinejoin):zb(S)):(w(E,j,Q,I,R,y,F,P),O.wireframe?Eb(O.color,O.wireframeLinewidth,O.wireframeLinecap,O.wireframeLinejoin):zb(O.color));else if(O instanceof THREE.MeshNormalMaterial)S.r=Zb(m.normalWorld.x),S.g=Zb(m.normalWorld.y),S.b=Zb(m.normalWorld.z),w(E,j,Q,I,R,y,F,P),O.wireframe?Eb(S,O.wireframeLinewidth,O.wireframeLinecap,
+O.wireframeLinejoin):zb(S);else if(O instanceof THREE.MeshDepthMaterial)za=k.near,qa=k.far,aa.r=aa.g=aa.b=1-Tb(a.positionScreen.z,za,qa),ba.r=ba.g=ba.b=1-Tb(d.positionScreen.z,za,qa),ca.r=ca.g=ca.b=1-Tb(g.positionScreen.z,za,qa),ha.r=ha.g=ha.b=1-Tb(e.positionScreen.z,za,qa),Ga=wc(aa,ba,ca,ha),x(E,j,Q,I,F,P),Yb(E,j,Q,I,F,P,0,0,1,0,0,1,Ga),x($,Z,R,y,ga,fa),Yb($,Z,R,y,ga,fa,1,0,1,1,0,1,Ga)}function x(a,b,c,d,e,f){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(a,b);m.closePath()}function w(a,
+b,c,d,e,f,g,j){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(g,j);m.lineTo(a,b);m.closePath()}function Eb(a,b,c,e){if(A!=b)m.lineWidth=A=b;if(D!=c)m.lineCap=D=c;if(B!=e)m.lineJoin=B=e;d(a.getContextStyle());m.stroke();xa.inflate(2*b)}function zb(a){e(a.getContextStyle());m.fill()}function Nc(a,b,c,d,f,g,j,h,Y,i,l,O,k){if(0!=k.image.width){if(!0==k.needsUpdate||void 0==Na[k.id]){var o=k.wrapS==THREE.RepeatWrapping,p=k.wrapT==THREE.RepeatWrapping;Na[k.id]=m.createPattern(k.image,
+o&&p?"repeat":o&&!p?"repeat-x":!o&&p?"repeat-y":"no-repeat");k.needsUpdate=!1}e(Na[k.id]);var o=k.offset.x/k.repeat.x,p=k.offset.y/k.repeat.y,n=k.image.width*k.repeat.x,ib=k.image.height*k.repeat.y,j=(j+o)*n,h=(h+p)*ib,c=c-a,d=d-b,f=f-a,g=g-b,Y=(Y+o)*n-j,i=(i+p)*ib-h,l=(l+o)*n-j,O=(O+p)*ib-h,o=Y*O-l*i;if(0==o){if(void 0===ja[k.id])b=document.createElement("canvas"),b.width=k.image.width,b.height=k.image.height,b=b.getContext("2d"),b.drawImage(k.image,0,0),ja[k.id]=b.getImageData(0,0,k.image.width,
+k.image.height).data;b=ja[k.id];j=4*(Math.floor(j)+Math.floor(h)*k.image.width);S.setRGB(b[j]/255,b[j+1]/255,b[j+2]/255);zb(S)}else o=1/o,k=(O*c-i*f)*o,i=(O*d-i*g)*o,c=(Y*f-l*c)*o,d=(Y*g-l*d)*o,a=a-k*j-c*h,j=b-i*j-d*h,m.save(),m.transform(k,i,c,d,a,j),m.fill(),m.restore()}}function Yb(a,b,c,d,e,f,g,j,h,Y,i,k,l){var O,o;O=l.width-1;o=l.height-1;g*=O;j*=o;c-=a;d-=b;e-=a;f-=b;h=h*O-g;Y=Y*o-j;i=i*O-g;k=k*o-j;o=1/(h*k-i*Y);O=(k*c-Y*e)*o;Y=(k*d-Y*f)*o;c=(h*e-i*c)*o;d=(h*f-i*d)*o;a=a-O*g-c*j;b=b-Y*g-d*j;
+m.save();m.transform(O,Y,c,d,a,b);m.clip();m.drawImage(l,0,0);m.restore()}function wc(a,b,c,d){var e=~~(255*a.r),f=~~(255*a.g),a=~~(255*a.b),g=~~(255*b.r),j=~~(255*b.g),b=~~(255*b.b),h=~~(255*c.r),Y=~~(255*c.g),c=~~(255*c.b),i=~~(255*d.r),k=~~(255*d.g),d=~~(255*d.b);bb[0]=0>e?0:255<e?255:e;bb[1]=0>f?0:255<f?255:f;bb[2]=0>a?0:255<a?255:a;bb[4]=0>g?0:255<g?255:g;bb[5]=0>j?0:255<j?255:j;bb[6]=0>b?0:255<b?255:b;bb[8]=0>h?0:255<h?255:h;bb[9]=0>Y?0:255<Y?255:Y;bb[10]=0>c?0:255<c?255:c;bb[12]=0>i?0:255<
+i?255:i;bb[13]=0>k?0:255<k?255:k;bb[14]=0>d?0:255<d?255:d;ic.putImageData(Mc,0,0);vc.drawImage(hc,0,0);return jc}function Tb(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function Zb(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function Fb(a,b){var c=b.x-a.x,d=b.y-a.y,e=c*c+d*d;0!=e&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var yc,Yc,La,gb;this.autoClear?this.clear():m.setTransform(1,0,0,-1,n,q);f.info.render.vertices=0;f.info.render.faces=0;g=l.projectScene(a,k,this.sortElements);h=g.elements;i=
+g.lights;(Sb=0<i.length)&&o(i);for(yc=0,Yc=h.length;yc<Yc;yc++)if(La=h[yc],gb=La.material,gb=gb instanceof THREE.MeshFaceMaterial?La.faceMaterial:gb,!(null==gb||0==gb.opacity)){xa.empty();if(La instanceof THREE.RenderableParticle)C=La,C.x*=n,C.y*=q,r(C,La,gb,a);else if(La instanceof THREE.RenderableLine)C=La.v1,G=La.v2,C.positionScreen.x*=n,C.positionScreen.y*=q,G.positionScreen.x*=n,G.positionScreen.y*=q,xa.addPoint(C.positionScreen.x,C.positionScreen.y),xa.addPoint(G.positionScreen.x,G.positionScreen.y),
+Oa.intersects(xa)&&s(C,G,La,gb,a);else if(La instanceof THREE.RenderableFace3)C=La.v1,G=La.v2,K=La.v3,C.positionScreen.x*=n,C.positionScreen.y*=q,G.positionScreen.x*=n,G.positionScreen.y*=q,K.positionScreen.x*=n,K.positionScreen.y*=q,gb.overdraw&&(Fb(C.positionScreen,G.positionScreen),Fb(G.positionScreen,K.positionScreen),Fb(K.positionScreen,C.positionScreen)),xa.add3Points(C.positionScreen.x,C.positionScreen.y,G.positionScreen.x,G.positionScreen.y,K.positionScreen.x,K.positionScreen.y),Oa.intersects(xa)&&
+t(C,G,K,0,1,2,La,gb,a);else if(La instanceof THREE.RenderableFace4)C=La.v1,G=La.v2,K=La.v3,L=La.v4,C.positionScreen.x*=n,C.positionScreen.y*=q,G.positionScreen.x*=n,G.positionScreen.y*=q,K.positionScreen.x*=n,K.positionScreen.y*=q,L.positionScreen.x*=n,L.positionScreen.y*=q,T.positionScreen.copy(G.positionScreen),M.positionScreen.copy(L.positionScreen),gb.overdraw&&(Fb(C.positionScreen,G.positionScreen),Fb(G.positionScreen,L.positionScreen),Fb(L.positionScreen,C.positionScreen),Fb(K.positionScreen,
+T.positionScreen),Fb(K.positionScreen,M.positionScreen)),xa.addPoint(C.positionScreen.x,C.positionScreen.y),xa.addPoint(G.positionScreen.x,G.positionScreen.y),xa.addPoint(K.positionScreen.x,K.positionScreen.y),xa.addPoint(L.positionScreen.x,L.positionScreen.y),Oa.intersects(xa)&&u(C,G,K,L,T,M,La,gb,a);Ka.addRectangle(xa)}m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(a,b,c,d){var e,f,g,h,i,k;for(e=0,f=a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(i=g.matrixWorld.getPosition(),k=c.dot(i),0>=k||(k*=g.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),k=c.dot(C.sub(i,b).normalize()),0>=k||(k*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=k&&(k*=g.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)))}function b(a){null==G[a]&&(G[a]=document.createElementNS("http://www.w3.org/2000/svg",
+"path"),0==E&&G[a].setAttribute("shape-rendering","crispEdges"));return G[a]}function c(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}var d=this,e,f,g,h=new THREE.Projector,i=document.createElementNS("http://www.w3.org/2000/svg","svg"),l,k,p,o,n,q,m,r,s=new THREE.Rectangle,t=new THREE.Rectangle,u=!1,x=new THREE.Color,w=new THREE.Color,A=new THREE.Color,D=new THREE.Color,B,C=new THREE.Vector3,G=[],K=[],L,T,M,E=1;this.domElement=i;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,
+faces:0}};this.setQuality=function(a){switch(a){case "high":E=1;break;case "low":E=0}};this.setSize=function(a,b){l=a;k=b;p=l/2;o=k/2;i.setAttribute("viewBox",-p+" "+-o+" "+l+" "+k);i.setAttribute("width",l);i.setAttribute("height",k);s.set(-p,-o,p,o)};this.clear=function(){for(;0<i.childNodes.length;)i.removeChild(i.childNodes[0])};this.render=function(j,k){var l,C,y,F;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(j,k,this.sortElements);f=e.elements;
+g=e.lights;M=T=0;if(u=0<g.length){w.setRGB(0,0,0);A.setRGB(0,0,0);D.setRGB(0,0,0);for(l=0,C=g.length;l<C;l++)F=g[l],y=F.color,F instanceof THREE.AmbientLight?(w.r+=y.r,w.g+=y.g,w.b+=y.b):F instanceof THREE.DirectionalLight?(A.r+=y.r,A.g+=y.g,A.b+=y.b):F instanceof THREE.PointLight&&(D.r+=y.r,D.g+=y.g,D.b+=y.b)}for(l=0,C=f.length;l<C;l++)if(y=f[l],F=y.material,F=F instanceof THREE.MeshFaceMaterial?y.faceMaterial:F,!(null==F||0==F.opacity))if(t.empty(),y instanceof THREE.RenderableParticle)n=y,n.x*=
+p,n.y*=-o;else if(y instanceof THREE.RenderableLine){if(n=y.v1,q=y.v2,n.positionScreen.x*=p,n.positionScreen.y*=-o,q.positionScreen.x*=p,q.positionScreen.y*=-o,t.addPoint(n.positionScreen.x,n.positionScreen.y),t.addPoint(q.positionScreen.x,q.positionScreen.y),s.intersects(t)){y=n;var P=q,$=M++;null==K[$]&&(K[$]=document.createElementNS("http://www.w3.org/2000/svg","line"),0==E&&K[$].setAttribute("shape-rendering","crispEdges"));L=K[$];L.setAttribute("x1",y.positionScreen.x);L.setAttribute("y1",y.positionScreen.y);
+L.setAttribute("x2",P.positionScreen.x);L.setAttribute("y2",P.positionScreen.y);F instanceof THREE.LineBasicMaterial&&(L.setAttribute("style","fill: none; stroke: "+F.color.getContextStyle()+"; stroke-width: "+F.linewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.linecap+"; stroke-linejoin: "+F.linejoin),i.appendChild(L))}}else if(y instanceof THREE.RenderableFace3){if(n=y.v1,q=y.v2,m=y.v3,n.positionScreen.x*=p,n.positionScreen.y*=-o,q.positionScreen.x*=p,q.positionScreen.y*=-o,m.positionScreen.x*=
+p,m.positionScreen.y*=-o,t.addPoint(n.positionScreen.x,n.positionScreen.y),t.addPoint(q.positionScreen.x,q.positionScreen.y),t.addPoint(m.positionScreen.x,m.positionScreen.y),s.intersects(t)){var P=n,$=q,Z=m;d.info.render.vertices+=3;d.info.render.faces++;L=b(T++);L.setAttribute("d","M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+Z.positionScreen.x+","+Z.positionScreen.y+"z");F instanceof THREE.MeshBasicMaterial?x.copy(F.color):F instanceof THREE.MeshLambertMaterial?
+u?(x.r=w.r,x.g=w.g,x.b=w.b,a(g,y.centroidWorld,y.normalWorld,x),x.r=Math.max(0,Math.min(F.color.r*x.r,1)),x.g=Math.max(0,Math.min(F.color.g*x.g,1)),x.b=Math.max(0,Math.min(F.color.b*x.b,1))):x.copy(F.color):F instanceof THREE.MeshDepthMaterial?(B=1-F.__2near/(F.__farPlusNear-y.z*F.__farMinusNear),x.setRGB(B,B,B)):F instanceof THREE.MeshNormalMaterial&&x.setRGB(c(y.normalWorld.x),c(y.normalWorld.y),c(y.normalWorld.z));F.wireframe?L.setAttribute("style","fill: none; stroke: "+x.getContextStyle()+"; stroke-width: "+
+F.wireframeLinewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframeLinecap+"; stroke-linejoin: "+F.wireframeLinejoin):L.setAttribute("style","fill: "+x.getContextStyle()+"; fill-opacity: "+F.opacity);i.appendChild(L)}}else if(y instanceof THREE.RenderableFace4&&(n=y.v1,q=y.v2,m=y.v3,r=y.v4,n.positionScreen.x*=p,n.positionScreen.y*=-o,q.positionScreen.x*=p,q.positionScreen.y*=-o,m.positionScreen.x*=p,m.positionScreen.y*=-o,r.positionScreen.x*=p,r.positionScreen.y*=-o,t.addPoint(n.positionScreen.x,
+n.positionScreen.y),t.addPoint(q.positionScreen.x,q.positionScreen.y),t.addPoint(m.positionScreen.x,m.positionScreen.y),t.addPoint(r.positionScreen.x,r.positionScreen.y),s.intersects(t))){var P=n,$=q,Z=m,G=r;d.info.render.vertices+=4;d.info.render.faces++;L=b(T++);L.setAttribute("d","M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+$.positionScreen.x+" "+$.positionScreen.y+" L "+Z.positionScreen.x+","+Z.positionScreen.y+" L "+G.positionScreen.x+","+G.positionScreen.y+"z");F instanceof THREE.MeshBasicMaterial?
+x.copy(F.color):F instanceof THREE.MeshLambertMaterial?u?(x.r=w.r,x.g=w.g,x.b=w.b,a(g,y.centroidWorld,y.normalWorld,x),x.r=Math.max(0,Math.min(F.color.r*x.r,1)),x.g=Math.max(0,Math.min(F.color.g*x.g,1)),x.b=Math.max(0,Math.min(F.color.b*x.b,1))):x.copy(F.color):F instanceof THREE.MeshDepthMaterial?(B=1-F.__2near/(F.__farPlusNear-y.z*F.__farMinusNear),x.setRGB(B,B,B)):F instanceof THREE.MeshNormalMaterial&&x.setRGB(c(y.normalWorld.x),c(y.normalWorld.y),c(y.normalWorld.z));F.wireframe?L.setAttribute("style",
+"fill: none; stroke: "+x.getContextStyle()+"; stroke-width: "+F.wireframeLinewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframeLinecap+"; stroke-linejoin: "+F.wireframeLinejoin):L.setAttribute("style","fill: "+x.getContextStyle()+"; fill-opacity: "+F.opacity);i.appendChild(L)}}};
 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 float flipEnvMap;\nuniform int combine;\n#endif",
 envmap_fragment:"#ifdef USE_ENVMAP\nvec4 cubeColor = textureCube( envMap, vec3( flipEnvMap * vReflect.x, vReflect.yz ) );\n#ifdef GAMMA_INPUT\ncubeColor.xyz *= cubeColor.xyz;\n#endif\nif ( combine == 1 ) {\ngl_FragColor.xyz = mix( gl_FragColor.xyz, cubeColor.xyz, reflectivity );\n} else {\ngl_FragColor.xyz = gl_FragColor.xyz * cubeColor.xyz;\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\n#ifdef GAMMA_INPUT\nvec4 texelColor = texture2D( map, vUv );\ntexelColor.xyz *= texelColor.xyz;\ngl_FragColor = gl_FragColor * texelColor;\n#else\ngl_FragColor = gl_FragColor * texture2D( map, vUv );\n#endif\n#endif",
@@ -229,121 +229,122 @@ THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragme
 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(a){function b(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(void 0===a.__webglCustomAttributesList)a.__webglCustomAttributesList=[];for(var e in d.attributes){var f=d.attributes[e];if(!f.__webglInitialized||f.createUniqueBuffers){f.__webglInitialized=!0;var g=1;"v2"===f.type?g=2:"v3"===f.type?g=3:"v4"===f.type?g=4:"c"===f.type&&(g=3);f.size=g;f.array=new Float32Array(c*g);f.buffer=j.createBuffer();f.buffer.belongsToAttribute=e;f.needsUpdate=!0}a.__webglCustomAttributesList.push(f)}}}
 function c(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;if(0<=b.materialIndex)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?!1:a&&void 0!==a.shading&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function e(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?!0:!1}function f(a,b,c){var d,e,f,g,h=a.vertices;g=h.length;
-var i=a.colors,k=i.length,l=a.__vertexArray,m=a.__colorArray,n=a.__sortArray,p=a.__dirtyVertices,o=a.__dirtyColors,q=a.__webglCustomAttributesList;if(c.sortParticles){Ra.multiplySelf(c.matrixWorld);for(d=0;d<g;d++)e=h[d].position,Sa.copy(e),Ra.multiplyVector3(Sa),n[d]=[Sa.z,d];n.sort(function(a,b){return b[0]-a[0]});for(d=0;d<g;d++)e=h[n[d][1]].position,f=3*d,l[f]=e.x,l[f+1]=e.y,l[f+2]=e.z;for(d=0;d<k;d++)f=3*d,e=i[n[d][1]],m[f]=e.r,m[f+1]=e.g,m[f+2]=e.b;if(q)for(i=0,k=q.length;i<k;i++)if(h=q[i],
-void 0===h.boundTo||"vertices"===h.boundTo)if(f=0,e=h.value.length,1===h.size)for(d=0;d<e;d++)g=n[d][1],h.array[d]=h.value[g];else if(2===h.size)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(3===h.size)if("c"===h.type)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=n[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(4===h.size)for(d=0;d<e;d++)g=n[d][1],g=h.value[g],
-h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}else{if(p)for(d=0;d<g;d++)e=h[d].position,f=3*d,l[f]=e.x,l[f+1]=e.y,l[f+2]=e.z;if(o)for(d=0;d<k;d++)e=i[d],f=3*d,m[f]=e.r,m[f+1]=e.g,m[f+2]=e.b;if(q)for(i=0,k=q.length;i<k;i++)if(h=q[i],h.needsUpdate&&(void 0===h.boundTo||"vertices"===h.boundTo))if(e=h.value.length,f=0,1===h.size)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(2===h.size)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(3===h.size)if("c"===
-h.type)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(4===h.size)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}if(p||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,l,b);if(o||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,
-m,b);if(q)for(i=0,k=q.length;i<k;i++)if(h=q[i],h.needsUpdate||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,h.buffer),j.bufferData(j.ARRAY_BUFFER,h.array,b)}function g(a,b){return b.z-a.z}function h(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++)V=null,I=O=ba=S=fa=-1,a[d].render(b,c,Fa,ab),V=null,I=O=ba=S=fa=-1}function i(a,b,c,d,e,f,g,h){var j,i,k,l;b?(i=a.length-1,l=b=-1):(i=0,b=a.length,l=1);for(var m=i;m!==b;m+=l)if(j=a[m],j.render){i=j.object;k=j.buffer;if(h)j=h;else{j=j[c];if(!j)continue;g&&
-B.setBlending(j.blending);B.setDepthTest(j.depthTest);s(j.depthWrite);t(j.polygonOffset,j.polygonOffsetFactor,j.polygonOffsetUnits)}B.setObjectFaces(i);k instanceof THREE.BufferGeometry?B.renderBufferDirect(d,e,f,j,k,i):B.renderBuffer(d,e,f,j,k,i)}}function l(a,b,c,d,e,f,g){for(var h,j,i=0,k=a.length;i<k;i++)if(h=a[i],j=h.object,j.visible){if(g)h=g;else{h=h[b];if(!h)continue;f&&B.setBlending(h.blending);B.setDepthTest(h.depthTest);s(h.depthWrite);t(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}B.renderImmediateObject(c,
-d,e,h,j)}}function k(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function p(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function n(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function o(a,b){for(var c=a.length-1;0<=c;c--)a[c].object===b&&a.splice(c,1)}function q(a,b){for(var c=a.length-1;0<=c;c--)a[c]===b&&a.splice(c,1)}function m(a,b,c,d,e){d.program||B.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=
-new Float32Array(B.maxMorphTargets);for(var f=0,g=B.maxMorphTargets;f<g;f++)e.__webglMorphTargetInfluences[f]=0}var h=!1,f=d.program,g=f.uniforms,i=d.uniforms;f!==V&&(j.useProgram(f),V=f,h=!0);if(d.id!==I)I=d.id,h=!0;if(h){j.uniformMatrix4fv(g.projectionMatrix,!1,a._projectionMatrixArray);if(c&&d.fog)if(i.fogColor.value=c.color,c instanceof THREE.Fog)i.fogNear.value=c.near,i.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)i.fogDensity.value=c.density;if(d instanceof THREE.MeshPhongMaterial||
-d instanceof THREE.MeshLambertMaterial||d.lights){var k,l,m=0,n=0,p=0,o,q,r=bb,s=r.directional.colors,t=r.directional.positions,O=r.point.colors,u=r.point.positions,v=r.point.distances,y=0,C=0,T=q=0;for(c=0,h=b.length;c<h;c++)if(k=b[c],l=k.color,o=k.intensity,q=k.distance,k instanceof THREE.AmbientLight)B.gammaInput?(m+=l.r*l.r,n+=l.g*l.g,p+=l.b*l.b):(m+=l.r,n+=l.g,p+=l.b);else if(k instanceof THREE.DirectionalLight)q=3*y,B.gammaInput?(s[q]=l.r*l.r*o*o,s[q+1]=l.g*l.g*o*o,s[q+2]=l.b*l.b*o*o):(s[q]=
-l.r*o,s[q+1]=l.g*o,s[q+2]=l.b*o),k=k.matrixWorld.getPosition(),l=1/k.length(),t[q]=k.x*l,t[q+1]=k.y*l,t[q+2]=k.z*l,y+=1;else if(k instanceof THREE.SpotLight&&!k.onlyShadow)q=3*y,B.gammaInput?(s[q]=l.r*l.r*o*o,s[q+1]=l.g*l.g*o*o,s[q+2]=l.b*l.b*o*o):(s[q]=l.r*o,s[q+1]=l.g*o,s[q+2]=l.b*o),k=k.matrixWorld.getPosition(),l=1/k.length(),t[q]=k.x*l,t[q+1]=k.y*l,t[q+2]=k.z*l,y+=1;else if(k instanceof THREE.PointLight)T=3*C,B.gammaInput?(O[T]=l.r*l.r*o*o,O[T+1]=l.g*l.g*o*o,O[T+2]=l.b*l.b*o*o):(O[T]=l.r*o,O[T+
-1]=l.g*o,O[T+2]=l.b*o),k=k.matrixWorld.getPosition(),u[T]=k.x,u[T+1]=k.y,u[T+2]=k.z,v[C]=q,C+=1;for(c=3*y,h=s.length;c<h;c++)s[c]=0;for(c=3*C,h=O.length;c<h;c++)O[c]=0;r.point.length=C;r.directional.length=y;r.ambient[0]=m;r.ambient[1]=n;r.ambient[2]=p;b=bb;i.ambientLightColor.value=b.ambient;i.directionalLightColor.value=b.directional.colors;i.directionalLightDirection.value=b.directional.positions;i.pointLightColor.value=b.point.colors;i.pointLightPosition.value=b.point.positions;i.pointLightDistance.value=
-b.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)i.opacity.value=d.opacity,B.gammaInput?i.diffuse.value.copyGammaToLinear(d.color):i.diffuse.value=d.color,(i.map.texture=d.map)&&i.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y),i.lightMap.texture=d.lightMap,i.envMap.texture=d.envMap,i.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,i.reflectivity.value=d.reflectivity,
-i.refractionRatio.value=d.refractionRatio,i.combine.value=d.combine,i.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping;if(d instanceof THREE.LineBasicMaterial)i.diffuse.value=d.color,i.opacity.value=d.opacity;else if(d instanceof THREE.ParticleBasicMaterial)i.psColor.value=d.color,i.opacity.value=d.opacity,i.size.value=d.size,i.scale.value=E.height/2,i.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)i.shininess.value=d.shininess,B.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),
-i.specular.value.copyGammaToLinear(d.specular)):(i.ambient.value=d.ambient,i.specular.value=d.specular),d.wrapAround&&i.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshLambertMaterial)B.gammaInput?i.ambient.value.copyGammaToLinear(d.ambient):i.ambient.value=d.ambient,d.wrapAround&&i.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshDepthMaterial)i.mNear.value=a.near,i.mFar.value=a.far,i.opacity.value=d.opacity;else if(d instanceof THREE.MeshNormalMaterial)i.opacity.value=d.opacity;
-if(e.receiveShadow&&!d._shadowPass&&i.shadowMatrix){for(b=0;b<B.shadowMapPlugin.shadowMatrix.length;b++)i.shadowMatrix.value[b]=B.shadowMapPlugin.shadowMatrix[b],i.shadowMap.texture[b]=B.shadowMapPlugin.shadowMap[b];i.shadowDarkness.value=B.shadowMapDarkness;i.shadowBias.value=B.shadowMapBias}b=d.uniformsList;for(i=0,c=b.length;i<c;i++)if(n=f.uniforms[b[i][1]])if(h=b[i][0],p=h.type,m=h.value,"i"===p)j.uniform1i(n,m);else if("f"===p)j.uniform1f(n,m);else if("v2"===p)j.uniform2f(n,m.x,m.y);else if("v3"===
-p)j.uniform3f(n,m.x,m.y,m.z);else if("v4"===p)j.uniform4f(n,m.x,m.y,m.z,m.w);else if("c"===p)j.uniform3f(n,m.r,m.g,m.b);else if("fv1"===p)j.uniform1fv(n,m);else if("fv"===p)j.uniform3fv(n,m);else if("v3v"===p){if(!h._array)h._array=new Float32Array(3*m.length);for(p=0,r=m.length;p<r;p++)s=3*p,h._array[s]=m[p].x,h._array[s+1]=m[p].y,h._array[s+2]=m[p].z;j.uniform3fv(n,h._array)}else if("m4"===p){if(!h._array)h._array=new Float32Array(16);m.flattenToArray(h._array);j.uniformMatrix4fv(n,!1,h._array)}else if("m4v"===
-p){if(!h._array)h._array=new Float32Array(16*m.length);for(p=0,r=m.length;p<r;p++)m[p].flattenToArrayOffset(h._array,16*p);j.uniformMatrix4fv(n,!1,h._array)}else if("t"===p){if(j.uniform1i(n,m),n=h.texture)if(n.image instanceof Array&&6===n.image.length){if(h=n,6===h.image.length)if(h.needsUpdate){if(!h.image.__webglTextureCube)h.image.__webglTextureCube=j.createTexture();j.activeTexture(j.TEXTURE0+m);j.bindTexture(j.TEXTURE_CUBE_MAP,h.image.__webglTextureCube);m=[];for(n=0;6>n;n++){p=m;r=n;if(B.autoScaleCubemaps){if(s=
-h.image[n],O=Aa,!(s.width<=O&&s.height<=O))u=Math.max(s.width,s.height),t=Math.floor(s.width*O/u),O=Math.floor(s.height*O/u),u=document.createElement("canvas"),u.width=t,u.height=O,u.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,O),s=u}else s=h.image[n];p[r]=s}n=m[0];p=0===(n.width&n.width-1)&&0===(n.height&n.height-1);r=D(h.format);s=D(h.type);x(j.TEXTURE_CUBE_MAP,h,p);for(n=0;6>n;n++)j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,r,r,s,m[n]);h.generateMipmaps&&p&&j.generateMipmap(j.TEXTURE_CUBE_MAP);
-h.needsUpdate=!1;if(h.onUpdated)h.onUpdated()}else j.activeTexture(j.TEXTURE0+m),j.bindTexture(j.TEXTURE_CUBE_MAP,h.image.__webglTextureCube)}else n instanceof THREE.WebGLRenderTargetCube?(h=n,j.activeTexture(j.TEXTURE0+m),j.bindTexture(j.TEXTURE_CUBE_MAP,h.__webglTexture)):B.setTexture(n,m)}else if("tv"===p){if(!h._array){h._array=[];for(p=0,r=h.texture.length;p<r;p++)h._array[p]=m+p}j.uniform1iv(n,h._array);for(p=0,r=h.texture.length;p<r;p++)(n=h.texture[p])&&B.setTexture(n,h._array[p])}(d instanceof
-THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&null!==g.cameraPosition&&j.uniform3f(g.cameraPosition,a.position.x,a.position.y,a.position.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==g.viewMatrix&&j.uniformMatrix4fv(g.viewMatrix,!1,a._viewMatrixArray);d.skinning&&(j.uniformMatrix4fv(g.cameraInverseMatrix,!1,a._viewMatrixArray),j.uniformMatrix4fv(g.boneGlobalMatrices,!1,e.boneMatrices))}j.uniformMatrix4fv(g.modelViewMatrix,
-!1,e._modelViewMatrixArray);g.normalMatrix&&j.uniformMatrix3fv(g.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&null!==g.objectMatrix&&j.uniformMatrix4fv(g.objectMatrix,!1,e._objectMatrixArray);return f}function r(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);c&&c.transposeIntoArray(a._normalMatrixArray)}function s(a){ba!==a&&
-(j.depthMask(a),ba=a)}function t(a,b,c){$!==a&&(a?j.enable(j.POLYGON_OFFSET_FILL):j.disable(j.POLYGON_OFFSET_FILL),$=a);if(a&&(ca!==b||ia!==c))j.polygonOffset(b,c),ca=b,ia=c}function u(a,b){var c;"fragment"===a?c=j.createShader(j.FRAGMENT_SHADER):"vertex"===a&&(c=j.createShader(j.VERTEX_SHADER));j.shaderSource(c,b);j.compileShader(c);return!j.getShaderParameter(c,j.COMPILE_STATUS)?(console.error(j.getShaderInfoLog(c)),console.error(b),null):c}function x(a,b,c){c?(j.texParameteri(a,j.TEXTURE_WRAP_S,
-D(b.wrapS)),j.texParameteri(a,j.TEXTURE_WRAP_T,D(b.wrapT)),j.texParameteri(a,j.TEXTURE_MAG_FILTER,D(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,D(b.minFilter))):(j.texParameteri(a,j.TEXTURE_WRAP_S,j.CLAMP_TO_EDGE),j.texParameteri(a,j.TEXTURE_WRAP_T,j.CLAMP_TO_EDGE),j.texParameteri(a,j.TEXTURE_MAG_FILTER,A(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,A(b.minFilter)))}function v(a,b){j.bindRenderbuffer(j.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(j.renderbufferStorage(j.RENDERBUFFER,
-j.DEPTH_COMPONENT16,b.width,b.height),j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_ATTACHMENT,j.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(j.renderbufferStorage(j.RENDERBUFFER,j.DEPTH_STENCIL,b.width,b.height),j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_STENCIL_ATTACHMENT,j.RENDERBUFFER,a)):j.renderbufferStorage(j.RENDERBUFFER,j.RGBA4,b.width,b.height)}function A(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return j.NEAREST;
-default:return j.LINEAR}}function D(a){switch(a){case THREE.RepeatWrapping:return j.REPEAT;case THREE.ClampToEdgeWrapping:return j.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return j.MIRRORED_REPEAT;case THREE.NearestFilter:return j.NEAREST;case THREE.NearestMipMapNearestFilter:return j.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return j.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return j.LINEAR;case THREE.LinearMipMapNearestFilter:return j.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return j.LINEAR_MIPMAP_LINEAR;
+var i=a.colors,k=i.length,l=a.__vertexArray,m=a.__colorArray,o=a.__sortArray,p=a.__dirtyVertices,n=a.__dirtyColors,q=a.__webglCustomAttributesList;if(c.sortParticles){Ta.multiplySelf(c.matrixWorld);for(d=0;d<g;d++)e=h[d].position,Wa.copy(e),Ta.multiplyVector3(Wa),o[d]=[Wa.z,d];o.sort(function(a,b){return b[0]-a[0]});for(d=0;d<g;d++)e=h[o[d][1]].position,f=3*d,l[f]=e.x,l[f+1]=e.y,l[f+2]=e.z;for(d=0;d<k;d++)f=3*d,e=i[o[d][1]],m[f]=e.r,m[f+1]=e.g,m[f+2]=e.b;if(q)for(i=0,k=q.length;i<k;i++)if(h=q[i],
+void 0===h.boundTo||"vertices"===h.boundTo)if(f=0,e=h.value.length,1===h.size)for(d=0;d<e;d++)g=o[d][1],h.array[d]=h.value[g];else if(2===h.size)for(d=0;d<e;d++)g=o[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(3===h.size)if("c"===h.type)for(d=0;d<e;d++)g=o[d][1],g=h.value[g],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=o[d][1],g=h.value[g],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(4===h.size)for(d=0;d<e;d++)g=o[d][1],g=h.value[g],
+h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}else{if(p)for(d=0;d<g;d++)e=h[d].position,f=3*d,l[f]=e.x,l[f+1]=e.y,l[f+2]=e.z;if(n)for(d=0;d<k;d++)e=i[d],f=3*d,m[f]=e.r,m[f+1]=e.g,m[f+2]=e.b;if(q)for(i=0,k=q.length;i<k;i++)if(h=q[i],h.needsUpdate&&(void 0===h.boundTo||"vertices"===h.boundTo))if(e=h.value.length,f=0,1===h.size)for(d=0;d<e;d++)h.array[d]=h.value[d];else if(2===h.size)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,f+=2;else if(3===h.size)if("c"===
+h.type)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.r,h.array[f+1]=g.g,h.array[f+2]=g.b,f+=3;else for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,f+=3;else if(4===h.size)for(d=0;d<e;d++)g=h.value[d],h.array[f]=g.x,h.array[f+1]=g.y,h.array[f+2]=g.z,h.array[f+3]=g.w,f+=4}if(p||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,l,b);if(n||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,
+m,b);if(q)for(i=0,k=q.length;i<k;i++)if(h=q[i],h.needsUpdate||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,h.buffer),j.bufferData(j.ARRAY_BUFFER,h.array,b)}function g(a,b){return b.z-a.z}function h(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++)I=null,y=F=S=fa=ga=-1,a[d].render(b,c,Ga,Ea),I=null,y=F=S=fa=ga=-1}function i(a,b,c,d,e,f,g,h){var j,i,k,l;b?(i=a.length-1,l=b=-1):(i=0,b=a.length,l=1);for(var m=i;m!==b;m+=l)if(j=a[m],j.render){i=j.object;k=j.buffer;if(h)j=h;else{j=j[c];if(!j)continue;g&&
+E.setBlending(j.blending);E.setDepthTest(j.depthTest);E.setDepthWrite(j.depthWrite);s(j.polygonOffset,j.polygonOffsetFactor,j.polygonOffsetUnits)}E.setObjectFaces(i);k instanceof THREE.BufferGeometry?E.renderBufferDirect(d,e,f,j,k,i):E.renderBuffer(d,e,f,j,k,i)}}function l(a,b,c,d,e,f,g){for(var h,j,i=0,k=a.length;i<k;i++)if(h=a[i],j=h.object,j.visible){if(g)h=g;else{h=h[b];if(!h)continue;f&&E.setBlending(h.blending);E.setDepthTest(h.depthTest);E.setDepthWrite(h.depthWrite);s(h.polygonOffset,h.polygonOffsetFactor,
+h.polygonOffsetUnits)}E.renderImmediateObject(c,d,e,h,j)}}function k(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function p(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function o(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function n(a,b){for(var c=a.length-1;0<=c;c--)a[c].object===b&&a.splice(c,1)}function q(a,b){for(var c=a.length-1;0<=c;c--)a[c]===b&&a.splice(c,1)}function m(a,b,c,d,e){d.program||E.initMaterial(d,b,c,e);if(d.morphTargets&&
+!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(E.maxMorphTargets);for(var f=0,g=E.maxMorphTargets;f<g;f++)e.__webglMorphTargetInfluences[f]=0}var h=!1,f=d.program,g=f.uniforms,i=d.uniforms;f!==I&&(j.useProgram(f),I=f,h=!0);if(d.id!==y)y=d.id,h=!0;if(h){j.uniformMatrix4fv(g.projectionMatrix,!1,a._projectionMatrixArray);if(c&&d.fog)if(i.fogColor.value=c.color,c instanceof THREE.Fog)i.fogNear.value=c.near,i.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)i.fogDensity.value=
+c.density;if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){var k,l,m=0,o=0,p=0,n,q,r=fb,s=r.directional.colors,t=r.directional.positions,F=r.point.colors,P=r.point.positions,x=r.point.distances,w=0,C=0,B=q=0;for(c=0,h=b.length;c<h;c++)if(k=b[c],l=k.color,n=k.intensity,q=k.distance,k instanceof THREE.AmbientLight)E.gammaInput?(m+=l.r*l.r,o+=l.g*l.g,p+=l.b*l.b):(m+=l.r,o+=l.g,p+=l.b);else if(k instanceof THREE.DirectionalLight)q=3*w,E.gammaInput?(s[q]=l.r*l.r*
+n*n,s[q+1]=l.g*l.g*n*n,s[q+2]=l.b*l.b*n*n):(s[q]=l.r*n,s[q+1]=l.g*n,s[q+2]=l.b*n),k=k.matrixWorld.getPosition(),l=1/k.length(),t[q]=k.x*l,t[q+1]=k.y*l,t[q+2]=k.z*l,w+=1;else if(k instanceof THREE.SpotLight&&!k.onlyShadow)q=3*w,E.gammaInput?(s[q]=l.r*l.r*n*n,s[q+1]=l.g*l.g*n*n,s[q+2]=l.b*l.b*n*n):(s[q]=l.r*n,s[q+1]=l.g*n,s[q+2]=l.b*n),k=k.matrixWorld.getPosition(),l=1/k.length(),t[q]=k.x*l,t[q+1]=k.y*l,t[q+2]=k.z*l,w+=1;else if(k instanceof THREE.PointLight)B=3*C,E.gammaInput?(F[B]=l.r*l.r*n*n,F[B+
+1]=l.g*l.g*n*n,F[B+2]=l.b*l.b*n*n):(F[B]=l.r*n,F[B+1]=l.g*n,F[B+2]=l.b*n),k=k.matrixWorld.getPosition(),P[B]=k.x,P[B+1]=k.y,P[B+2]=k.z,x[C]=q,C+=1;for(c=3*w,h=s.length;c<h;c++)s[c]=0;for(c=3*C,h=F.length;c<h;c++)F[c]=0;r.point.length=C;r.directional.length=w;r.ambient[0]=m;r.ambient[1]=o;r.ambient[2]=p;b=fb;i.ambientLightColor.value=b.ambient;i.directionalLightColor.value=b.directional.colors;i.directionalLightDirection.value=b.directional.positions;i.pointLightColor.value=b.point.colors;i.pointLightPosition.value=
+b.point.positions;i.pointLightDistance.value=b.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)i.opacity.value=d.opacity,E.gammaInput?i.diffuse.value.copyGammaToLinear(d.color):i.diffuse.value=d.color,(i.map.texture=d.map)&&i.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y),i.lightMap.texture=d.lightMap,i.envMap.texture=d.envMap,i.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?
+1:-1,i.reflectivity.value=d.reflectivity,i.refractionRatio.value=d.refractionRatio,i.combine.value=d.combine,i.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping;if(d instanceof THREE.LineBasicMaterial)i.diffuse.value=d.color,i.opacity.value=d.opacity;else if(d instanceof THREE.ParticleBasicMaterial)i.psColor.value=d.color,i.opacity.value=d.opacity,i.size.value=d.size,i.scale.value=D.height/2,i.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)i.shininess.value=
+d.shininess,E.gammaInput?(i.ambient.value.copyGammaToLinear(d.ambient),i.specular.value.copyGammaToLinear(d.specular)):(i.ambient.value=d.ambient,i.specular.value=d.specular),d.wrapAround&&i.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshLambertMaterial)E.gammaInput?i.ambient.value.copyGammaToLinear(d.ambient):i.ambient.value=d.ambient,d.wrapAround&&i.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshDepthMaterial)i.mNear.value=a.near,i.mFar.value=a.far,i.opacity.value=d.opacity;
+else if(d instanceof THREE.MeshNormalMaterial)i.opacity.value=d.opacity;if(e.receiveShadow&&!d._shadowPass&&i.shadowMatrix){for(b=0;b<E.shadowMapPlugin.shadowMatrix.length;b++)i.shadowMatrix.value[b]=E.shadowMapPlugin.shadowMatrix[b],i.shadowMap.texture[b]=E.shadowMapPlugin.shadowMap[b];i.shadowDarkness.value=E.shadowMapDarkness;i.shadowBias.value=E.shadowMapBias}b=d.uniformsList;for(i=0,c=b.length;i<c;i++)if(o=f.uniforms[b[i][1]])if(h=b[i][0],p=h.type,m=h.value,"i"===p)j.uniform1i(o,m);else if("f"===
+p)j.uniform1f(o,m);else if("v2"===p)j.uniform2f(o,m.x,m.y);else if("v3"===p)j.uniform3f(o,m.x,m.y,m.z);else if("v4"===p)j.uniform4f(o,m.x,m.y,m.z,m.w);else if("c"===p)j.uniform3f(o,m.r,m.g,m.b);else if("fv1"===p)j.uniform1fv(o,m);else if("fv"===p)j.uniform3fv(o,m);else if("v3v"===p){if(!h._array)h._array=new Float32Array(3*m.length);for(p=0,r=m.length;p<r;p++)s=3*p,h._array[s]=m[p].x,h._array[s+1]=m[p].y,h._array[s+2]=m[p].z;j.uniform3fv(o,h._array)}else if("m4"===p){if(!h._array)h._array=new Float32Array(16);
+m.flattenToArray(h._array);j.uniformMatrix4fv(o,!1,h._array)}else if("m4v"===p){if(!h._array)h._array=new Float32Array(16*m.length);for(p=0,r=m.length;p<r;p++)m[p].flattenToArrayOffset(h._array,16*p);j.uniformMatrix4fv(o,!1,h._array)}else if("t"===p){if(j.uniform1i(o,m),o=h.texture)if(o.image instanceof Array&&6===o.image.length){if(h=o,6===h.image.length)if(h.needsUpdate){if(!h.image.__webglTextureCube)h.image.__webglTextureCube=j.createTexture();j.activeTexture(j.TEXTURE0+m);j.bindTexture(j.TEXTURE_CUBE_MAP,
+h.image.__webglTextureCube);m=[];for(o=0;6>o;o++){p=m;r=o;if(E.autoScaleCubemaps){if(s=h.image[o],F=lb,!(s.width<=F&&s.height<=F))P=Math.max(s.width,s.height),t=Math.floor(s.width*F/P),F=Math.floor(s.height*F/P),P=document.createElement("canvas"),P.width=t,P.height=F,P.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,F),s=P}else s=h.image[o];p[r]=s}o=m[0];p=0===(o.width&o.width-1)&&0===(o.height&o.height-1);r=A(h.format);s=A(h.type);u(j.TEXTURE_CUBE_MAP,h,p);for(o=0;6>o;o++)j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+
+o,0,r,r,s,m[o]);h.generateMipmaps&&p&&j.generateMipmap(j.TEXTURE_CUBE_MAP);h.needsUpdate=!1;if(h.onUpdated)h.onUpdated()}else j.activeTexture(j.TEXTURE0+m),j.bindTexture(j.TEXTURE_CUBE_MAP,h.image.__webglTextureCube)}else o instanceof THREE.WebGLRenderTargetCube?(h=o,j.activeTexture(j.TEXTURE0+m),j.bindTexture(j.TEXTURE_CUBE_MAP,h.__webglTexture)):E.setTexture(o,m)}else if("tv"===p){if(!h._array){h._array=[];for(p=0,r=h.texture.length;p<r;p++)h._array[p]=m+p}j.uniform1iv(o,h._array);for(p=0,r=h.texture.length;p<
+r;p++)(o=h.texture[p])&&E.setTexture(o,h._array[p])}(d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&null!==g.cameraPosition&&j.uniform3f(g.cameraPosition,a.position.x,a.position.y,a.position.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==g.viewMatrix&&j.uniformMatrix4fv(g.viewMatrix,!1,a._viewMatrixArray);d.skinning&&(j.uniformMatrix4fv(g.cameraInverseMatrix,!1,a._viewMatrixArray),
+j.uniformMatrix4fv(g.boneGlobalMatrices,!1,e.boneMatrices))}j.uniformMatrix4fv(g.modelViewMatrix,!1,e._modelViewMatrixArray);g.normalMatrix&&j.uniformMatrix3fv(g.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&null!==g.objectMatrix&&j.uniformMatrix4fv(g.objectMatrix,!1,e._objectMatrixArray);return f}function r(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);
+c&&c.transposeIntoArray(a._normalMatrixArray)}function s(a,b,c){aa!==a&&(a?j.enable(j.POLYGON_OFFSET_FILL):j.disable(j.POLYGON_OFFSET_FILL),aa=a);if(a&&(ba!==b||ca!==c))j.polygonOffset(b,c),ba=b,ca=c}function t(a,b){var c;"fragment"===a?c=j.createShader(j.FRAGMENT_SHADER):"vertex"===a&&(c=j.createShader(j.VERTEX_SHADER));j.shaderSource(c,b);j.compileShader(c);return!j.getShaderParameter(c,j.COMPILE_STATUS)?(console.error(j.getShaderInfoLog(c)),console.error(b),null):c}function u(a,b,c){c?(j.texParameteri(a,
+j.TEXTURE_WRAP_S,A(b.wrapS)),j.texParameteri(a,j.TEXTURE_WRAP_T,A(b.wrapT)),j.texParameteri(a,j.TEXTURE_MAG_FILTER,A(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,A(b.minFilter))):(j.texParameteri(a,j.TEXTURE_WRAP_S,j.CLAMP_TO_EDGE),j.texParameteri(a,j.TEXTURE_WRAP_T,j.CLAMP_TO_EDGE),j.texParameteri(a,j.TEXTURE_MAG_FILTER,w(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,w(b.minFilter)))}function x(a,b){j.bindRenderbuffer(j.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(j.renderbufferStorage(j.RENDERBUFFER,
+j.DEPTH_COMPONENT16,b.width,b.height),j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_ATTACHMENT,j.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(j.renderbufferStorage(j.RENDERBUFFER,j.DEPTH_STENCIL,b.width,b.height),j.framebufferRenderbuffer(j.FRAMEBUFFER,j.DEPTH_STENCIL_ATTACHMENT,j.RENDERBUFFER,a)):j.renderbufferStorage(j.RENDERBUFFER,j.RGBA4,b.width,b.height)}function w(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return j.NEAREST;
+default:return j.LINEAR}}function A(a){switch(a){case THREE.RepeatWrapping:return j.REPEAT;case THREE.ClampToEdgeWrapping:return j.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return j.MIRRORED_REPEAT;case THREE.NearestFilter:return j.NEAREST;case THREE.NearestMipMapNearestFilter:return j.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return j.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return j.LINEAR;case THREE.LinearMipMapNearestFilter:return j.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return j.LINEAR_MIPMAP_LINEAR;
 case THREE.ByteType:return j.BYTE;case THREE.UnsignedByteType:return j.UNSIGNED_BYTE;case THREE.ShortType:return j.SHORT;case THREE.UnsignedShortType:return j.UNSIGNED_SHORT;case THREE.IntType:return j.INT;case THREE.UnsignedShortType:return j.UNSIGNED_INT;case THREE.FloatType:return j.FLOAT;case THREE.AlphaFormat:return j.ALPHA;case THREE.RGBFormat:return j.RGB;case THREE.RGBAFormat:return j.RGBA;case THREE.LuminanceFormat:return j.LUMINANCE;case THREE.LuminanceAlphaFormat:return j.LUMINANCE_ALPHA}return 0}
-var a=a||{},E=void 0!==a.canvas?a.canvas:document.createElement("canvas"),C=void 0!==a.precision?a.precision:"mediump",F=void 0!==a.antialias?a.antialias:!1,K=void 0!==a.stencil?a.stencil:!0,L=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,R=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),N=void 0!==a.clearAlpha?a.clearAlpha:0,P=void 0!==a.maxLights?a.maxLights:4;this.domElement=E;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=
+var a=a||{},D=void 0!==a.canvas?a.canvas:document.createElement("canvas"),B=void 0!==a.precision?a.precision:"mediump",C=void 0!==a.antialias?a.antialias:!1,G=void 0!==a.stencil?a.stencil:!0,K=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,L=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),T=void 0!==a.clearAlpha?a.clearAlpha:0,M=void 0!==a.maxLights?a.maxLights:4;this.domElement=D;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=
 this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMapEnabled=!1;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.maxMorphTargets=8;this.autoScaleCubemaps=!0;this.renderPluginsPre=[];this.renderPluginsPost=[];this.info=
-{memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var B=this,j,H=[],V=null,y=null,I=-1,O=null,T=0,aa=null,ga=null,fa=null,S=null,ba=null,$=null,ca=null,ia=null,La=null,ja=0,za=0,qa=0,Ga=0,Fa=0,ab=0,gb=new THREE.Frustum,Ra=new THREE.Matrix4,Sa=new THREE.Vector4,bb={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};j=function(){var a;try{if(!(a=E.getContext("experimental-webgl",{antialias:F,stencil:K,
-preserveDrawingBuffer:L})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();j.clearColor(0,0,0,1);j.clearDepth(1);j.clearStencil(0);j.enable(j.DEPTH_TEST);j.depthFunc(j.LEQUAL);j.frontFace(j.CCW);j.cullFace(j.BACK);j.enable(j.CULL_FACE);j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,
-j.ONE_MINUS_SRC_ALPHA);j.clearColor(R.r,R.g,R.b,N);this.context=j;var Wa=j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS);j.getParameter(j.TEXTURE_SIZE);var Aa=j.getParameter(j.MAX_CUBE_MAP_TEXTURE_SIZE);this.getContext=function(){return j};this.supportsVertexTextures=function(){return 0<Wa};this.setSize=function(a,b){E.width=a;E.height=b;this.setViewport(0,0,E.width,E.height)};this.setViewport=function(a,b,c,d){ja=a;za=b;qa=c;Ga=d;j.viewport(ja,za,qa,Ga)};this.setScissor=function(a,b,c,d){j.scissor(a,
-b,c,d)};this.enableScissorTest=function(a){a?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)};this.setClearColorHex=function(a,b){R.setHex(a);N=b;j.clearColor(R.r,R.g,R.b,N)};this.setClearColor=function(a,b){R.copy(a);N=b;j.clearColor(R.r,R.g,R.b,N)};this.getClearColor=function(){return R};this.getClearAlpha=function(){return N};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=j.COLOR_BUFFER_BIT;if(void 0===b||b)d|=j.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=
+{memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var E=this,j,Q=[],I=null,R=null,y=-1,F=null,P=0,$=null,Z=null,ga=null,fa=null,S=null,aa=null,ba=null,ca=null,ha=null,Na=0,ja=0,za=0,qa=0,Ga=0,Ea=0,Sa=new THREE.Frustum,Ta=new THREE.Matrix4,Wa=new THREE.Vector4,fb={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};j=function(){var a;try{if(!(a=D.getContext("experimental-webgl",{antialias:C,stencil:G,
+preserveDrawingBuffer:K})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();j.clearColor(0,0,0,1);j.clearDepth(1);j.clearStencil(0);j.enable(j.DEPTH_TEST);j.depthFunc(j.LEQUAL);j.frontFace(j.CCW);j.cullFace(j.BACK);j.enable(j.CULL_FACE);j.enable(j.BLEND);j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,
+j.ONE_MINUS_SRC_ALPHA);j.clearColor(L.r,L.g,L.b,T);this.context=j;var Za=j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS);j.getParameter(j.TEXTURE_SIZE);var lb=j.getParameter(j.MAX_CUBE_MAP_TEXTURE_SIZE);this.getContext=function(){return j};this.supportsVertexTextures=function(){return 0<Za};this.setSize=function(a,b){D.width=a;D.height=b;this.setViewport(0,0,D.width,D.height)};this.setViewport=function(a,b,c,d){Na=a;ja=b;za=c;qa=d;j.viewport(Na,ja,za,qa)};this.setScissor=function(a,b,c,d){j.scissor(a,
+b,c,d)};this.enableScissorTest=function(a){a?j.enable(j.SCISSOR_TEST):j.disable(j.SCISSOR_TEST)};this.setClearColorHex=function(a,b){L.setHex(a);T=b;j.clearColor(L.r,L.g,L.b,T)};this.setClearColor=function(a,b){L.copy(a);T=b;j.clearColor(L.r,L.g,L.b,T)};this.getClearColor=function(){return L};this.getClearAlpha=function(){return T};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=j.COLOR_BUFFER_BIT;if(void 0===b||b)d|=j.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=j.STENCIL_BUFFER_BIT;j.clear(d)};this.clearTarget=
 function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=a.geometry.geometryGroups[b];j.deleteBuffer(c.__webglVertexBuffer);
 j.deleteBuffer(c.__webglNormalBuffer);j.deleteBuffer(c.__webglTangentBuffer);j.deleteBuffer(c.__webglColorBuffer);j.deleteBuffer(c.__webglUVBuffer);j.deleteBuffer(c.__webglUV2Buffer);j.deleteBuffer(c.__webglSkinVertexABuffer);j.deleteBuffer(c.__webglSkinVertexBBuffer);j.deleteBuffer(c.__webglSkinIndicesBuffer);j.deleteBuffer(c.__webglSkinWeightsBuffer);j.deleteBuffer(c.__webglFaceBuffer);j.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=0,e=c.numMorphTargets;d<e;d++)j.deleteBuffer(c.__webglMorphTargetsBuffers[d]);
-if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)j.deleteBuffer(c.__webglCustomAttributesList[d].buffer);B.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),B.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),B.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=
-a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),B.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,j.deleteTexture(a.__webglTexture),B.info.memory.textures--};this.updateShadowMap=function(a,b){V=null;I=O=ba=S=fa=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=j.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=j.createBuffer();
-a.hasPos&&(j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,a.positionArray,j.DYNAMIC_DRAW),j.enableVertexAttribArray(b.attributes.position),j.vertexAttribPointer(b.attributes.position,3,j.FLOAT,!1,0,0));if(a.hasNormal){j.bindBuffer(j.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,f,g,h,i,k,l,m,n,p=3*a.count;for(n=0;n<p;n+=9)c=a.normalArray,d=c[n],e=c[n+1],f=c[n+2],g=c[n+3],i=c[n+4],l=c[n+5],h=c[n+6],k=c[n+7],m=c[n+8],d=(d+g+h)/3,e=(e+i+k)/3,f=
-(f+l+m)/3,c[n]=d,c[n+1]=e,c[n+2]=f,c[n+3]=d,c[n+4]=e,c[n+5]=f,c[n+6]=d,c[n+7]=e,c[n+8]=f}j.bufferData(j.ARRAY_BUFFER,a.normalArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(b.attributes.normal);j.vertexAttribPointer(b.attributes.normal,3,j.FLOAT,!1,0,0)}j.drawArrays(j.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,f){if(0!==d.opacity&&(c=m(a,b,c,d,f),a=c.attributes,b=!1,d=16777215*e.id+2*c.id+(d.wireframe?1:0),d!==O&&(O=d,b=!0),f instanceof THREE.Mesh)){f=e.offsets;d=0;
+if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)j.deleteBuffer(c.__webglCustomAttributesList[d].buffer);E.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),E.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),E.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=
+a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),E.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,j.deleteTexture(a.__webglTexture),E.info.memory.textures--};this.updateShadowMap=function(a,b){I=null;y=F=S=fa=ga=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=j.createBuffer();if(!a.__webglNormalBuffer)a.__webglNormalBuffer=j.createBuffer();
+a.hasPos&&(j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,a.positionArray,j.DYNAMIC_DRAW),j.enableVertexAttribArray(b.attributes.position),j.vertexAttribPointer(b.attributes.position,3,j.FLOAT,!1,0,0));if(a.hasNormal){j.bindBuffer(j.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,f,g,h,i,k,l,m,o,p=3*a.count;for(o=0;o<p;o+=9)c=a.normalArray,d=c[o],e=c[o+1],f=c[o+2],g=c[o+3],i=c[o+4],l=c[o+5],h=c[o+6],k=c[o+7],m=c[o+8],d=(d+g+h)/3,e=(e+i+k)/3,f=
+(f+l+m)/3,c[o]=d,c[o+1]=e,c[o+2]=f,c[o+3]=d,c[o+4]=e,c[o+5]=f,c[o+6]=d,c[o+7]=e,c[o+8]=f}j.bufferData(j.ARRAY_BUFFER,a.normalArray,j.DYNAMIC_DRAW);j.enableVertexAttribArray(b.attributes.normal);j.vertexAttribPointer(b.attributes.normal,3,j.FLOAT,!1,0,0)}j.drawArrays(j.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,f){if(0!==d.opacity&&(c=m(a,b,c,d,f),a=c.attributes,b=!1,d=16777215*e.id+2*c.id+(d.wireframe?1:0),d!==F&&(F=d,b=!0),f instanceof THREE.Mesh)){f=e.offsets;d=0;
 for(c=f.length;d<c;++d)b&&(j.bindBuffer(j.ARRAY_BUFFER,e.vertexPositionBuffer),j.vertexAttribPointer(a.position,e.vertexPositionBuffer.itemSize,j.FLOAT,!1,0,12*f[d].index),0<=a.normal&&e.vertexNormalBuffer&&(j.bindBuffer(j.ARRAY_BUFFER,e.vertexNormalBuffer),j.vertexAttribPointer(a.normal,e.vertexNormalBuffer.itemSize,j.FLOAT,!1,0,12*f[d].index)),0<=a.uv&&e.vertexUvBuffer&&(e.vertexUvBuffer?(j.bindBuffer(j.ARRAY_BUFFER,e.vertexUvBuffer),j.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,j.FLOAT,
-!1,0,8*f[d].index),j.enableVertexAttribArray(a.uv)):j.disableVertexAttribArray(a.uv)),0<=a.color&&e.vertexColorBuffer&&(j.bindBuffer(j.ARRAY_BUFFER,e.vertexColorBuffer),j.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,j.FLOAT,!1,0,16*f[d].index)),j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)),j.drawElements(j.TRIANGLES,f[d].count,j.UNSIGNED_SHORT,2*f[d].start),B.info.render.calls++,B.info.render.vertices+=f[d].count,B.info.render.faces+=f[d].count/3}};this.renderBuffer=function(a,
-b,c,d,e,f){if(0!==d.opacity){var g,h,c=m(a,b,c,d,f),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0);c!==O&&(O=c,a=!0);if(!d.morphTargets&&0<=b.position)a&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;-1!==f.morphTargetBase?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0)):0<=c.position&&(j.bindBuffer(j.ARRAY_BUFFER,
-e.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){g=0;var i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;g<d.numSupportedMorphTargets&&g<i.length;)j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[g]]),j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,!1,0,0),f.__webglMorphTargetInfluences[g]=h[i[g]],g++}else{var i=[],k=-1,l=0;h=f.morphTargetInfluences;var n,p=h.length;g=0;for(-1!==f.morphTargetBase&&(i[f.morphTargetBase]=
-!0);g<d.numSupportedMorphTargets;){for(n=0;n<p;n++)!i[n]&&h[n]>k&&(l=n,k=h[l]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l]);j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,!1,0,0);f.__webglMorphTargetInfluences[g]=k;i[l]=1;k=-1;g++}}null!==d.program.uniforms.morphTargetInfluences&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(g=0,h=e.__webglCustomAttributesList.length;g<h;g++)c=e.__webglCustomAttributesList[g],
+!1,0,8*f[d].index),j.enableVertexAttribArray(a.uv)):j.disableVertexAttribArray(a.uv)),0<=a.color&&e.vertexColorBuffer&&(j.bindBuffer(j.ARRAY_BUFFER,e.vertexColorBuffer),j.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,j.FLOAT,!1,0,16*f[d].index)),j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)),j.drawElements(j.TRIANGLES,f[d].count,j.UNSIGNED_SHORT,2*f[d].start),E.info.render.calls++,E.info.render.vertices+=f[d].count,E.info.render.faces+=f[d].count/3}};this.renderBuffer=function(a,
+b,c,d,e,f){if(0!==d.opacity){var g,h,c=m(a,b,c,d,f),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0);c!==F&&(F=c,a=!0);if(!d.morphTargets&&0<=b.position)a&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0));else if(f.morphTargetBase){c=d.program.attributes;-1!==f.morphTargetBase?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[f.morphTargetBase]),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0)):0<=c.position&&(j.bindBuffer(j.ARRAY_BUFFER,
+e.__webglVertexBuffer),j.vertexAttribPointer(c.position,3,j.FLOAT,!1,0,0));if(f.morphTargetForcedOrder.length){g=0;var i=f.morphTargetForcedOrder;for(h=f.morphTargetInfluences;g<d.numSupportedMorphTargets&&g<i.length;)j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[g]]),j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,!1,0,0),f.__webglMorphTargetInfluences[g]=h[i[g]],g++}else{var i=[],k=-1,l=0;h=f.morphTargetInfluences;var o,p=h.length;g=0;for(-1!==f.morphTargetBase&&(i[f.morphTargetBase]=
+!0);g<d.numSupportedMorphTargets;){for(o=0;o<p;o++)!i[o]&&h[o]>k&&(l=o,k=h[l]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[l]);j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,!1,0,0);f.__webglMorphTargetInfluences[g]=k;i[l]=1;k=-1;g++}}null!==d.program.uniforms.morphTargetInfluences&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,f.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(g=0,h=e.__webglCustomAttributesList.length;g<h;g++)c=e.__webglCustomAttributesList[g],
 0<=b[c.buffer.belongsToAttribute]&&(j.bindBuffer(j.ARRAY_BUFFER,c.buffer),j.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,j.FLOAT,!1,0,0));0<=b.color&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglColorBuffer),j.vertexAttribPointer(b.color,3,j.FLOAT,!1,0,0));0<=b.normal&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglNormalBuffer),j.vertexAttribPointer(b.normal,3,j.FLOAT,!1,0,0));0<=b.tangent&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglTangentBuffer),j.vertexAttribPointer(b.tangent,4,j.FLOAT,!1,0,0));0<=b.uv&&
 (e.__webglUVBuffer?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglUVBuffer),j.vertexAttribPointer(b.uv,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv)):j.disableVertexAttribArray(b.uv));0<=b.uv2&&(e.__webglUV2Buffer?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglUV2Buffer),j.vertexAttribPointer(b.uv2,2,j.FLOAT,!1,0,0),j.enableVertexAttribArray(b.uv2)):j.disableVertexAttribArray(b.uv2));d.skinning&&0<=b.skinVertexA&&0<=b.skinVertexB&&0<=b.skinIndex&&0<=b.skinWeight&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexABuffer),
-j.vertexAttribPointer(b.skinVertexA,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),j.vertexAttribPointer(b.skinIndex,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==La&&(j.lineWidth(d),La=d),a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,
-e.__webglLineBuffer),j.drawElements(j.LINES,e.__webglLineCount,j.UNSIGNED_SHORT,0)):(a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),j.drawElements(j.TRIANGLES,e.__webglFaceCount,j.UNSIGNED_SHORT,0)),B.info.render.calls++,B.info.render.vertices+=e.__webglFaceCount,B.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==La&&(j.lineWidth(d),La=d),j.drawArrays(f,0,e.__webglLineCount),B.info.render.calls++):f instanceof
-THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),B.info.render.calls++,B.info.render.points+=e.__webglParticleCount):f instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),B.info.render.calls++)}};this.render=function(a,b,c,d){var e,f,k,m,n=a.lights,p=a.fog;I=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);void 0===b.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();
-h(this.renderPluginsPre,a,b);B.info.render.calls=0;B.info.render.vertices=0;B.info.render.faces=0;B.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Ra.multiply(b.projectionMatrix,b.matrixWorldInverse);gb.setFromMatrix(Ra);this.setRenderTarget(c);
-(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;for(d=0,e=m.length;d<e;d++)if(f=m[d],k=f.object,f.render=!1,k.visible&&(!(k instanceof THREE.Mesh||k instanceof THREE.ParticleSystem)||!k.frustumCulled||gb.contains(k))){k.matrixWorld.flattenToArray(k._objectMatrixArray);r(k,b);var o=f,q=o.object,O=o.buffer,u=void 0,u=u=void 0,u=q.material;if(u instanceof THREE.MeshFaceMaterial){if(u=O.materialIndex,0<=u)u=q.geometry.materials[u],u.transparent?
-(o.transparent=u,o.opaque=null):(o.opaque=u,o.transparent=null)}else if(u)u.transparent?(o.transparent=u,o.opaque=null):(o.opaque=u,o.transparent=null);f.render=!0;if(this.sortObjects)k.renderDepth?f.z=k.renderDepth:(Sa.copy(k.position),Ra.multiplyVector3(Sa),f.z=Sa.z)}this.sortObjects&&m.sort(g);m=a.__webglObjectsImmediate;for(d=0,e=m.length;d<e;d++)if(f=m[d],k=f.object,k.visible)k.matrixAutoUpdate&&k.matrixWorld.flattenToArray(k._objectMatrixArray),r(k,b),k=f.object.material,k.transparent?(f.transparent=
-k,f.opaque=null):(f.opaque=k,f.transparent=null);a.overrideMaterial?(this.setBlending(a.overrideMaterial.blending),this.setDepthTest(a.overrideMaterial.depthTest),s(a.overrideMaterial.depthWrite),t(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),i(a.__webglObjects,!1,"",b,n,p,!0,a.overrideMaterial),l(a.__webglObjectsImmediate,"",b,n,p,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),i(a.__webglObjects,!0,"opaque",b,n,p,
-!1),l(a.__webglObjectsImmediate,"opaque",b,n,p,!1),i(a.__webglObjects,!1,"transparent",b,n,p,!0),l(a.__webglObjectsImmediate,"transparent",b,n,p,!0));h(this.renderPluginsPost,a,b);c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(j.bindTexture(j.TEXTURE_CUBE_MAP,c.__webglTexture),j.generateMipmap(j.TEXTURE_CUBE_MAP),j.bindTexture(j.TEXTURE_CUBE_MAP,null)):(j.bindTexture(j.TEXTURE_2D,c.__webglTexture),j.generateMipmap(j.TEXTURE_2D),
-j.bindTexture(j.TEXTURE_2D,null)))};this.renderImmediateObject=function(a,b,c,d,e){var f=m(a,b,c,d,e);O=-1;B.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(f,j,gb):e.render(function(a){B.renderBufferImmediate(a,f,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var g=a.__objectsAdded[0],h=a,i=void 0,l=void 0,m=void 0;if(!g.__webglInit)if(g.__webglInit=
-!0,g._modelViewMatrix=new THREE.Matrix4,g._normalMatrixArray=new Float32Array(9),g._modelViewMatrixArray=new Float32Array(16),g._objectMatrixArray=new Float32Array(16),g.matrixWorld.flattenToArray(g._objectMatrixArray),g instanceof THREE.Mesh){if(l=g.geometry,l instanceof THREE.Geometry){if(void 0===l.geometryGroups){var r=l,s=void 0,O=void 0,t=void 0,u=void 0,I=void 0,x=void 0,v=void 0,y={},C=r.morphTargets.length;r.geometryGroups={};for(s=0,O=r.faces.length;s<O;s++)t=r.faces[s],u=t.materialIndex,
-x=void 0!==u?u:-1,void 0===y[x]&&(y[x]={hash:x,counter:0}),v=y[x].hash+"_"+y[x].counter,void 0===r.geometryGroups[v]&&(r.geometryGroups[v]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:C}),I=t instanceof THREE.Face3?3:4,65535<r.geometryGroups[v].vertices+I&&(y[x].counter+=1,v=y[x].hash+"_"+y[x].counter,void 0===r.geometryGroups[v]&&(r.geometryGroups[v]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:C})),t instanceof THREE.Face3?r.geometryGroups[v].faces3.push(s):
-r.geometryGroups[v].faces4.push(s),r.geometryGroups[v].vertices+=I;r.geometryGroupsList=[];var E=void 0;for(E in r.geometryGroups)r.geometryGroups[E].id=T++,r.geometryGroupsList.push(r.geometryGroups[E])}for(i in l.geometryGroups)if(m=l.geometryGroups[i],!m.__webglVertexBuffer){var A=m;A.__webglVertexBuffer=j.createBuffer();A.__webglNormalBuffer=j.createBuffer();A.__webglTangentBuffer=j.createBuffer();A.__webglColorBuffer=j.createBuffer();A.__webglUVBuffer=j.createBuffer();A.__webglUV2Buffer=j.createBuffer();
-A.__webglSkinVertexABuffer=j.createBuffer();A.__webglSkinVertexBBuffer=j.createBuffer();A.__webglSkinIndicesBuffer=j.createBuffer();A.__webglSkinWeightsBuffer=j.createBuffer();A.__webglFaceBuffer=j.createBuffer();A.__webglLineBuffer=j.createBuffer();if(A.numMorphTargets){var D=void 0,H=void 0;A.__webglMorphTargetsBuffers=[];for(D=0,H=A.numMorphTargets;D<H;D++)A.__webglMorphTargetsBuffers.push(j.createBuffer())}B.info.memory.geometries++;var F=m,S=g,aa=S.geometry,K=F.faces3,N=F.faces4,L=3*K.length+
-4*N.length,fa=1*K.length+2*N.length,ba=3*K.length+4*N.length,$=c(S,F),P=e($),ca=d($),R=$.vertexColors?$.vertexColors:!1;F.__vertexArray=new Float32Array(3*L);if(ca)F.__normalArray=new Float32Array(3*L);if(aa.hasTangents)F.__tangentArray=new Float32Array(4*L);if(R)F.__colorArray=new Float32Array(3*L);if(P){if(0<aa.faceUvs.length||0<aa.faceVertexUvs.length)F.__uvArray=new Float32Array(2*L);if(1<aa.faceUvs.length||1<aa.faceVertexUvs.length)F.__uv2Array=new Float32Array(2*L)}if(S.geometry.skinWeights.length&&
-S.geometry.skinIndices.length)F.__skinVertexAArray=new Float32Array(4*L),F.__skinVertexBArray=new Float32Array(4*L),F.__skinIndexArray=new Float32Array(4*L),F.__skinWeightArray=new Float32Array(4*L);F.__faceArray=new Uint16Array(3*fa);F.__lineArray=new Uint16Array(2*ba);if(F.numMorphTargets){F.__morphTargetsArrays=[];for(var ga=0,ia=F.numMorphTargets;ga<ia;ga++)F.__morphTargetsArrays.push(new Float32Array(3*L))}F.__webglFaceCount=3*fa;F.__webglLineCount=2*ba;if($.attributes){if(void 0===F.__webglCustomAttributesList)F.__webglCustomAttributesList=
-[];var V=void 0;for(V in $.attributes){var La=$.attributes[V],ja={},za;for(za in La)ja[za]=La[za];if(!ja.__webglInitialized||ja.createUniqueBuffers){ja.__webglInitialized=!0;var qa=1;"v2"===ja.type?qa=2:"v3"===ja.type?qa=3:"v4"===ja.type?qa=4:"c"===ja.type&&(qa=3);ja.size=qa;ja.array=new Float32Array(L*qa);ja.buffer=j.createBuffer();ja.buffer.belongsToAttribute=V;La.needsUpdate=!0;ja.__original=La}F.__webglCustomAttributesList.push(ja)}}F.__inittedArrays=!0;l.__dirtyVertices=!0;l.__dirtyMorphTargets=
-!0;l.__dirtyElements=!0;l.__dirtyUvs=!0;l.__dirtyNormals=!0;l.__dirtyTangents=!0;l.__dirtyColors=!0}}}else if(g instanceof THREE.Ribbon){if(l=g.geometry,!l.__webglVertexBuffer){var Fa=l;Fa.__webglVertexBuffer=j.createBuffer();Fa.__webglColorBuffer=j.createBuffer();B.info.memory.geometries++;var Ga=l,Aa=Ga.vertices.length;Ga.__vertexArray=new Float32Array(3*Aa);Ga.__colorArray=new Float32Array(3*Aa);Ga.__webglVertexCount=Aa;l.__dirtyVertices=!0;l.__dirtyColors=!0}}else if(g instanceof THREE.Line){if(l=
-g.geometry,!l.__webglVertexBuffer){var Sa=l;Sa.__webglVertexBuffer=j.createBuffer();Sa.__webglColorBuffer=j.createBuffer();B.info.memory.geometries++;var Ra=l,gb=g,ab=Ra.vertices.length;Ra.__vertexArray=new Float32Array(3*ab);Ra.__colorArray=new Float32Array(3*ab);Ra.__webglLineCount=ab;b(Ra,gb);l.__dirtyVertices=!0;l.__dirtyColors=!0}}else if(g instanceof THREE.ParticleSystem&&(l=g.geometry,!l.__webglVertexBuffer)){var bb=l;bb.__webglVertexBuffer=j.createBuffer();bb.__webglColorBuffer=j.createBuffer();
-B.info.geometries++;var Wa=l,jd=g,Nc=Wa.vertices.length;Wa.__vertexArray=new Float32Array(3*Nc);Wa.__colorArray=new Float32Array(3*Nc);Wa.__sortArray=[];Wa.__webglParticleCount=Nc;b(Wa,jd);l.__dirtyVertices=!0;l.__dirtyColors=!0}if(!g.__webglActive){if(g instanceof THREE.Mesh)if(l=g.geometry,l instanceof THREE.BufferGeometry)k(h.__webglObjects,l,g);else for(i in l.geometryGroups)m=l.geometryGroups[i],k(h.__webglObjects,m,g);else g instanceof THREE.Ribbon||g instanceof THREE.Line||g instanceof THREE.ParticleSystem?
-(l=g.geometry,k(h.__webglObjects,l,g)):void 0!==THREE.MarchingCubes&&g instanceof THREE.MarchingCubes||g.immediateRenderCallback?h.__webglObjectsImmediate.push({object:g,opaque:null,transparent:null}):g instanceof THREE.Sprite?h.__webglSprites.push(g):g instanceof THREE.LensFlare&&h.__webglFlares.push(g);g.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var db=a.__objectsRemoved[0],wc=a;db instanceof THREE.Mesh||db instanceof THREE.ParticleSystem||db instanceof THREE.Ribbon||
-db instanceof THREE.Line?o(wc.__webglObjects,db):db instanceof THREE.Sprite?q(wc.__webglSprites,db):db instanceof THREE.LensFlare?q(wc.__webglFlares,db):(db instanceof THREE.MarchingCubes||db.immediateRenderCallback)&&o(wc.__webglObjectsImmediate,db);db.__webglActive=!1;a.__objectsRemoved.splice(0,1)}for(var Oc=0,kd=a.__webglObjects.length;Oc<kd;Oc++){var kb=a.__webglObjects[Oc].object,ha=kb.geometry,jc=void 0,$b=void 0,Ua=void 0;if(kb instanceof THREE.Mesh)if(ha instanceof THREE.BufferGeometry)ha.__dirtyVertices=
-!1,ha.__dirtyElements=!1,ha.__dirtyUvs=!1,ha.__dirtyNormals=!1,ha.__dirtyColors=!1;else{for(var Pc=0,ld=ha.geometryGroupsList.length;Pc<ld;Pc++)if(jc=ha.geometryGroupsList[Pc],Ua=c(kb,jc),$b=Ua.attributes&&p(Ua),ha.__dirtyVertices||ha.__dirtyMorphTargets||ha.__dirtyElements||ha.__dirtyUvs||ha.__dirtyNormals||ha.__dirtyColors||ha.__dirtyTangents||$b){var da=jc,md=kb,Za=j.DYNAMIC_DRAW,nd=!ha.dynamic,yc=Ua;if(da.__inittedArrays){var Yc=d(yc),Qc=yc.vertexColors?yc.vertexColors:!1,Zc=e(yc),$c=Yc===THREE.SmoothShading,
-G=void 0,U=void 0,ib=void 0,M=void 0,ac=void 0,Gb=void 0,lb=void 0,zc=void 0,Ab=void 0,bc=void 0,cc=void 0,W=void 0,X=void 0,Y=void 0,na=void 0,mb=void 0,nb=void 0,ob=void 0,kc=void 0,pb=void 0,qb=void 0,rb=void 0,lc=void 0,sb=void 0,tb=void 0,ub=void 0,mc=void 0,vb=void 0,wb=void 0,xb=void 0,nc=void 0,Hb=void 0,Ib=void 0,Jb=void 0,Ac=void 0,Kb=void 0,Lb=void 0,Mb=void 0,Bc=void 0,ka=void 0,ad=void 0,Nb=void 0,dc=void 0,ec=void 0,$a=void 0,bd=void 0,Ha=void 0,ya=0,Ea=0,Bb=0,Cb=0,eb=0,Pa=0,oa=0,Qa=
-0,Ba=0,J=0,Ca=0,z=0,Xa=void 0,Ja=da.__vertexArray,oc=da.__uvArray,pc=da.__uv2Array,fb=da.__normalArray,ra=da.__tangentArray,Ka=da.__colorArray,sa=da.__skinVertexAArray,ta=da.__skinVertexBArray,ua=da.__skinIndexArray,va=da.__skinWeightArray,Rc=da.__morphTargetsArrays,Sc=da.__webglCustomAttributesList,w=void 0,yb=da.__faceArray,Ya=da.__lineArray,Ta=md.geometry,od=Ta.__dirtyElements,cd=Ta.__dirtyUvs,pd=Ta.__dirtyNormals,qd=Ta.__dirtyTangents,rd=Ta.__dirtyColors,sd=Ta.__dirtyMorphTargets,Ub=Ta.vertices,
-la=da.faces3,ma=da.faces4,Da=Ta.faces,Tc=Ta.faceVertexUvs[0],Uc=Ta.faceVertexUvs[1],Vb=Ta.skinVerticesA,Wb=Ta.skinVerticesB,Xb=Ta.skinIndices,Ob=Ta.skinWeights,Pb=Ta.morphTargets;if(Ta.__dirtyVertices){for(G=0,U=la.length;G<U;G++)M=Da[la[G]],W=Ub[M.a].position,X=Ub[M.b].position,Y=Ub[M.c].position,Ja[Ea]=W.x,Ja[Ea+1]=W.y,Ja[Ea+2]=W.z,Ja[Ea+3]=X.x,Ja[Ea+4]=X.y,Ja[Ea+5]=X.z,Ja[Ea+6]=Y.x,Ja[Ea+7]=Y.y,Ja[Ea+8]=Y.z,Ea+=9;for(G=0,U=ma.length;G<U;G++)M=Da[ma[G]],W=Ub[M.a].position,X=Ub[M.b].position,Y=Ub[M.c].position,
-na=Ub[M.d].position,Ja[Ea]=W.x,Ja[Ea+1]=W.y,Ja[Ea+2]=W.z,Ja[Ea+3]=X.x,Ja[Ea+4]=X.y,Ja[Ea+5]=X.z,Ja[Ea+6]=Y.x,Ja[Ea+7]=Y.y,Ja[Ea+8]=Y.z,Ja[Ea+9]=na.x,Ja[Ea+10]=na.y,Ja[Ea+11]=na.z,Ea+=12;j.bindBuffer(j.ARRAY_BUFFER,da.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Ja,Za)}if(sd)for($a=0,bd=Pb.length;$a<bd;$a++){Ca=0;for(G=0,U=la.length;G<U;G++)M=Da[la[G]],W=Pb[$a].vertices[M.a].position,X=Pb[$a].vertices[M.b].position,Y=Pb[$a].vertices[M.c].position,Ha=Rc[$a],Ha[Ca]=W.x,Ha[Ca+1]=W.y,Ha[Ca+2]=W.z,
-Ha[Ca+3]=X.x,Ha[Ca+4]=X.y,Ha[Ca+5]=X.z,Ha[Ca+6]=Y.x,Ha[Ca+7]=Y.y,Ha[Ca+8]=Y.z,Ca+=9;for(G=0,U=ma.length;G<U;G++)M=Da[ma[G]],W=Pb[$a].vertices[M.a].position,X=Pb[$a].vertices[M.b].position,Y=Pb[$a].vertices[M.c].position,na=Pb[$a].vertices[M.d].position,Ha=Rc[$a],Ha[Ca]=W.x,Ha[Ca+1]=W.y,Ha[Ca+2]=W.z,Ha[Ca+3]=X.x,Ha[Ca+4]=X.y,Ha[Ca+5]=X.z,Ha[Ca+6]=Y.x,Ha[Ca+7]=Y.y,Ha[Ca+8]=Y.z,Ha[Ca+9]=na.x,Ha[Ca+10]=na.y,Ha[Ca+11]=na.z,Ca+=12;j.bindBuffer(j.ARRAY_BUFFER,da.__webglMorphTargetsBuffers[$a]);j.bufferData(j.ARRAY_BUFFER,
-Rc[$a],Za)}if(Ob.length){for(G=0,U=la.length;G<U;G++)M=Da[la[G]],sb=Ob[M.a],tb=Ob[M.b],ub=Ob[M.c],va[J]=sb.x,va[J+1]=sb.y,va[J+2]=sb.z,va[J+3]=sb.w,va[J+4]=tb.x,va[J+5]=tb.y,va[J+6]=tb.z,va[J+7]=tb.w,va[J+8]=ub.x,va[J+9]=ub.y,va[J+10]=ub.z,va[J+11]=ub.w,vb=Xb[M.a],wb=Xb[M.b],xb=Xb[M.c],ua[J]=vb.x,ua[J+1]=vb.y,ua[J+2]=vb.z,ua[J+3]=vb.w,ua[J+4]=wb.x,ua[J+5]=wb.y,ua[J+6]=wb.z,ua[J+7]=wb.w,ua[J+8]=xb.x,ua[J+9]=xb.y,ua[J+10]=xb.z,ua[J+11]=xb.w,Hb=Vb[M.a],Ib=Vb[M.b],Jb=Vb[M.c],sa[J]=Hb.x,sa[J+1]=Hb.y,sa[J+
-2]=Hb.z,sa[J+3]=1,sa[J+4]=Ib.x,sa[J+5]=Ib.y,sa[J+6]=Ib.z,sa[J+7]=1,sa[J+8]=Jb.x,sa[J+9]=Jb.y,sa[J+10]=Jb.z,sa[J+11]=1,Kb=Wb[M.a],Lb=Wb[M.b],Mb=Wb[M.c],ta[J]=Kb.x,ta[J+1]=Kb.y,ta[J+2]=Kb.z,ta[J+3]=1,ta[J+4]=Lb.x,ta[J+5]=Lb.y,ta[J+6]=Lb.z,ta[J+7]=1,ta[J+8]=Mb.x,ta[J+9]=Mb.y,ta[J+10]=Mb.z,ta[J+11]=1,J+=12;for(G=0,U=ma.length;G<U;G++)M=Da[ma[G]],sb=Ob[M.a],tb=Ob[M.b],ub=Ob[M.c],mc=Ob[M.d],va[J]=sb.x,va[J+1]=sb.y,va[J+2]=sb.z,va[J+3]=sb.w,va[J+4]=tb.x,va[J+5]=tb.y,va[J+6]=tb.z,va[J+7]=tb.w,va[J+8]=ub.x,
-va[J+9]=ub.y,va[J+10]=ub.z,va[J+11]=ub.w,va[J+12]=mc.x,va[J+13]=mc.y,va[J+14]=mc.z,va[J+15]=mc.w,vb=Xb[M.a],wb=Xb[M.b],xb=Xb[M.c],nc=Xb[M.d],ua[J]=vb.x,ua[J+1]=vb.y,ua[J+2]=vb.z,ua[J+3]=vb.w,ua[J+4]=wb.x,ua[J+5]=wb.y,ua[J+6]=wb.z,ua[J+7]=wb.w,ua[J+8]=xb.x,ua[J+9]=xb.y,ua[J+10]=xb.z,ua[J+11]=xb.w,ua[J+12]=nc.x,ua[J+13]=nc.y,ua[J+14]=nc.z,ua[J+15]=nc.w,Hb=Vb[M.a],Ib=Vb[M.b],Jb=Vb[M.c],Ac=Vb[M.d],sa[J]=Hb.x,sa[J+1]=Hb.y,sa[J+2]=Hb.z,sa[J+3]=1,sa[J+4]=Ib.x,sa[J+5]=Ib.y,sa[J+6]=Ib.z,sa[J+7]=1,sa[J+8]=
-Jb.x,sa[J+9]=Jb.y,sa[J+10]=Jb.z,sa[J+11]=1,sa[J+12]=Ac.x,sa[J+13]=Ac.y,sa[J+14]=Ac.z,sa[J+15]=1,Kb=Wb[M.a],Lb=Wb[M.b],Mb=Wb[M.c],Bc=Wb[M.d],ta[J]=Kb.x,ta[J+1]=Kb.y,ta[J+2]=Kb.z,ta[J+3]=1,ta[J+4]=Lb.x,ta[J+5]=Lb.y,ta[J+6]=Lb.z,ta[J+7]=1,ta[J+8]=Mb.x,ta[J+9]=Mb.y,ta[J+10]=Mb.z,ta[J+11]=1,ta[J+12]=Bc.x,ta[J+13]=Bc.y,ta[J+14]=Bc.z,ta[J+15]=1,J+=16;0<J&&(j.bindBuffer(j.ARRAY_BUFFER,da.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,sa,Za),j.bindBuffer(j.ARRAY_BUFFER,da.__webglSkinVertexBBuffer),
-j.bufferData(j.ARRAY_BUFFER,ta,Za),j.bindBuffer(j.ARRAY_BUFFER,da.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,ua,Za),j.bindBuffer(j.ARRAY_BUFFER,da.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,va,Za))}if(rd&&Qc){for(G=0,U=la.length;G<U;G++)M=Da[la[G]],lb=M.vertexColors,zc=M.color,3===lb.length&&Qc===THREE.VertexColors?(pb=lb[0],qb=lb[1],rb=lb[2]):rb=qb=pb=zc,Ka[Ba]=pb.r,Ka[Ba+1]=pb.g,Ka[Ba+2]=pb.b,Ka[Ba+3]=qb.r,Ka[Ba+4]=qb.g,Ka[Ba+5]=qb.b,Ka[Ba+6]=rb.r,Ka[Ba+7]=rb.g,Ka[Ba+8]=rb.b,
-Ba+=9;for(G=0,U=ma.length;G<U;G++)M=Da[ma[G]],lb=M.vertexColors,zc=M.color,4===lb.length&&Qc===THREE.VertexColors?(pb=lb[0],qb=lb[1],rb=lb[2],lc=lb[3]):lc=rb=qb=pb=zc,Ka[Ba]=pb.r,Ka[Ba+1]=pb.g,Ka[Ba+2]=pb.b,Ka[Ba+3]=qb.r,Ka[Ba+4]=qb.g,Ka[Ba+5]=qb.b,Ka[Ba+6]=rb.r,Ka[Ba+7]=rb.g,Ka[Ba+8]=rb.b,Ka[Ba+9]=lc.r,Ka[Ba+10]=lc.g,Ka[Ba+11]=lc.b,Ba+=12;0<Ba&&(j.bindBuffer(j.ARRAY_BUFFER,da.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,Ka,Za))}if(qd&&Ta.hasTangents){for(G=0,U=la.length;G<U;G++)M=Da[la[G]],Ab=
-M.vertexTangents,mb=Ab[0],nb=Ab[1],ob=Ab[2],ra[oa]=mb.x,ra[oa+1]=mb.y,ra[oa+2]=mb.z,ra[oa+3]=mb.w,ra[oa+4]=nb.x,ra[oa+5]=nb.y,ra[oa+6]=nb.z,ra[oa+7]=nb.w,ra[oa+8]=ob.x,ra[oa+9]=ob.y,ra[oa+10]=ob.z,ra[oa+11]=ob.w,oa+=12;for(G=0,U=ma.length;G<U;G++)M=Da[ma[G]],Ab=M.vertexTangents,mb=Ab[0],nb=Ab[1],ob=Ab[2],kc=Ab[3],ra[oa]=mb.x,ra[oa+1]=mb.y,ra[oa+2]=mb.z,ra[oa+3]=mb.w,ra[oa+4]=nb.x,ra[oa+5]=nb.y,ra[oa+6]=nb.z,ra[oa+7]=nb.w,ra[oa+8]=ob.x,ra[oa+9]=ob.y,ra[oa+10]=ob.z,ra[oa+11]=ob.w,ra[oa+12]=kc.x,ra[oa+
-13]=kc.y,ra[oa+14]=kc.z,ra[oa+15]=kc.w,oa+=16;j.bindBuffer(j.ARRAY_BUFFER,da.__webglTangentBuffer);j.bufferData(j.ARRAY_BUFFER,ra,Za)}if(pd&&Yc){for(G=0,U=la.length;G<U;G++)if(M=Da[la[G]],ac=M.vertexNormals,Gb=M.normal,3===ac.length&&$c)for(ka=0;3>ka;ka++)Nb=ac[ka],fb[Pa]=Nb.x,fb[Pa+1]=Nb.y,fb[Pa+2]=Nb.z,Pa+=3;else for(ka=0;3>ka;ka++)fb[Pa]=Gb.x,fb[Pa+1]=Gb.y,fb[Pa+2]=Gb.z,Pa+=3;for(G=0,U=ma.length;G<U;G++)if(M=Da[ma[G]],ac=M.vertexNormals,Gb=M.normal,4===ac.length&&$c)for(ka=0;4>ka;ka++)Nb=ac[ka],
-fb[Pa]=Nb.x,fb[Pa+1]=Nb.y,fb[Pa+2]=Nb.z,Pa+=3;else for(ka=0;4>ka;ka++)fb[Pa]=Gb.x,fb[Pa+1]=Gb.y,fb[Pa+2]=Gb.z,Pa+=3;j.bindBuffer(j.ARRAY_BUFFER,da.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,fb,Za)}if(cd&&Tc&&Zc){for(G=0,U=la.length;G<U;G++)if(ib=la[G],M=Da[ib],bc=Tc[ib],void 0!==bc)for(ka=0;3>ka;ka++)dc=bc[ka],oc[Bb]=dc.u,oc[Bb+1]=dc.v,Bb+=2;for(G=0,U=ma.length;G<U;G++)if(ib=ma[G],M=Da[ib],bc=Tc[ib],void 0!==bc)for(ka=0;4>ka;ka++)dc=bc[ka],oc[Bb]=dc.u,oc[Bb+1]=dc.v,Bb+=2;0<Bb&&(j.bindBuffer(j.ARRAY_BUFFER,
-da.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,oc,Za))}if(cd&&Uc&&Zc){for(G=0,U=la.length;G<U;G++)if(ib=la[G],M=Da[ib],cc=Uc[ib],void 0!==cc)for(ka=0;3>ka;ka++)ec=cc[ka],pc[Cb]=ec.u,pc[Cb+1]=ec.v,Cb+=2;for(G=0,U=ma.length;G<U;G++)if(ib=ma[G],M=Da[ib],cc=Uc[ib],void 0!==cc)for(ka=0;4>ka;ka++)ec=cc[ka],pc[Cb]=ec.u,pc[Cb+1]=ec.v,Cb+=2;0<Cb&&(j.bindBuffer(j.ARRAY_BUFFER,da.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,pc,Za))}if(od){for(G=0,U=la.length;G<U;G++)M=Da[la[G]],yb[eb]=ya,yb[eb+1]=ya+1,yb[eb+
-2]=ya+2,eb+=3,Ya[Qa]=ya,Ya[Qa+1]=ya+1,Ya[Qa+2]=ya,Ya[Qa+3]=ya+2,Ya[Qa+4]=ya+1,Ya[Qa+5]=ya+2,Qa+=6,ya+=3;for(G=0,U=ma.length;G<U;G++)M=Da[ma[G]],yb[eb]=ya,yb[eb+1]=ya+1,yb[eb+2]=ya+3,yb[eb+3]=ya+1,yb[eb+4]=ya+2,yb[eb+5]=ya+3,eb+=6,Ya[Qa]=ya,Ya[Qa+1]=ya+1,Ya[Qa+2]=ya,Ya[Qa+3]=ya+3,Ya[Qa+4]=ya+1,Ya[Qa+5]=ya+2,Ya[Qa+6]=ya+2,Ya[Qa+7]=ya+3,Qa+=8,ya+=4;j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,da.__webglFaceBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,yb,Za);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,da.__webglLineBuffer);
-j.bufferData(j.ELEMENT_ARRAY_BUFFER,Ya,Za)}if(Sc)for(ka=0,ad=Sc.length;ka<ad;ka++)if(w=Sc[ka],w.__original.needsUpdate){z=0;if(1===w.size)if(void 0===w.boundTo||"vertices"===w.boundTo){for(G=0,U=la.length;G<U;G++)M=Da[la[G]],w.array[z]=w.value[M.a],w.array[z+1]=w.value[M.b],w.array[z+2]=w.value[M.c],z+=3;for(G=0,U=ma.length;G<U;G++)M=Da[ma[G]],w.array[z]=w.value[M.a],w.array[z+1]=w.value[M.b],w.array[z+2]=w.value[M.c],w.array[z+3]=w.value[M.d],z+=4}else{if("faces"===w.boundTo){for(G=0,U=la.length;G<
-U;G++)Xa=w.value[la[G]],w.array[z]=Xa,w.array[z+1]=Xa,w.array[z+2]=Xa,z+=3;for(G=0,U=ma.length;G<U;G++)Xa=w.value[ma[G]],w.array[z]=Xa,w.array[z+1]=Xa,w.array[z+2]=Xa,w.array[z+3]=Xa,z+=4}}else if(2===w.size)if(void 0===w.boundTo||"vertices"===w.boundTo){for(G=0,U=la.length;G<U;G++)M=Da[la[G]],W=w.value[M.a],X=w.value[M.b],Y=w.value[M.c],w.array[z]=W.x,w.array[z+1]=W.y,w.array[z+2]=X.x,w.array[z+3]=X.y,w.array[z+4]=Y.x,w.array[z+5]=Y.y,z+=6;for(G=0,U=ma.length;G<U;G++)M=Da[ma[G]],W=w.value[M.a],X=
-w.value[M.b],Y=w.value[M.c],na=w.value[M.d],w.array[z]=W.x,w.array[z+1]=W.y,w.array[z+2]=X.x,w.array[z+3]=X.y,w.array[z+4]=Y.x,w.array[z+5]=Y.y,w.array[z+6]=na.x,w.array[z+7]=na.y,z+=8}else{if("faces"===w.boundTo){for(G=0,U=la.length;G<U;G++)Y=X=W=Xa=w.value[la[G]],w.array[z]=W.x,w.array[z+1]=W.y,w.array[z+2]=X.x,w.array[z+3]=X.y,w.array[z+4]=Y.x,w.array[z+5]=Y.y,z+=6;for(G=0,U=ma.length;G<U;G++)na=Y=X=W=Xa=w.value[ma[G]],w.array[z]=W.x,w.array[z+1]=W.y,w.array[z+2]=X.x,w.array[z+3]=X.y,w.array[z+
-4]=Y.x,w.array[z+5]=Y.y,w.array[z+6]=na.x,w.array[z+7]=na.y,z+=8}}else if(3===w.size){var ea;ea="c"===w.type?["r","g","b"]:["x","y","z"];if(void 0===w.boundTo||"vertices"===w.boundTo){for(G=0,U=la.length;G<U;G++)M=Da[la[G]],W=w.value[M.a],X=w.value[M.b],Y=w.value[M.c],w.array[z]=W[ea[0]],w.array[z+1]=W[ea[1]],w.array[z+2]=W[ea[2]],w.array[z+3]=X[ea[0]],w.array[z+4]=X[ea[1]],w.array[z+5]=X[ea[2]],w.array[z+6]=Y[ea[0]],w.array[z+7]=Y[ea[1]],w.array[z+8]=Y[ea[2]],z+=9;for(G=0,U=ma.length;G<U;G++)M=Da[ma[G]],
-W=w.value[M.a],X=w.value[M.b],Y=w.value[M.c],na=w.value[M.d],w.array[z]=W[ea[0]],w.array[z+1]=W[ea[1]],w.array[z+2]=W[ea[2]],w.array[z+3]=X[ea[0]],w.array[z+4]=X[ea[1]],w.array[z+5]=X[ea[2]],w.array[z+6]=Y[ea[0]],w.array[z+7]=Y[ea[1]],w.array[z+8]=Y[ea[2]],w.array[z+9]=na[ea[0]],w.array[z+10]=na[ea[1]],w.array[z+11]=na[ea[2]],z+=12}else if("faces"===w.boundTo){for(G=0,U=la.length;G<U;G++)Y=X=W=Xa=w.value[la[G]],w.array[z]=W[ea[0]],w.array[z+1]=W[ea[1]],w.array[z+2]=W[ea[2]],w.array[z+3]=X[ea[0]],
-w.array[z+4]=X[ea[1]],w.array[z+5]=X[ea[2]],w.array[z+6]=Y[ea[0]],w.array[z+7]=Y[ea[1]],w.array[z+8]=Y[ea[2]],z+=9;for(G=0,U=ma.length;G<U;G++)na=Y=X=W=Xa=w.value[ma[G]],w.array[z]=W[ea[0]],w.array[z+1]=W[ea[1]],w.array[z+2]=W[ea[2]],w.array[z+3]=X[ea[0]],w.array[z+4]=X[ea[1]],w.array[z+5]=X[ea[2]],w.array[z+6]=Y[ea[0]],w.array[z+7]=Y[ea[1]],w.array[z+8]=Y[ea[2]],w.array[z+9]=na[ea[0]],w.array[z+10]=na[ea[1]],w.array[z+11]=na[ea[2]],z+=12}}else if(4===w.size)if(void 0===w.boundTo||"vertices"===w.boundTo){for(G=
-0,U=la.length;G<U;G++)M=Da[la[G]],W=w.value[M.a],X=w.value[M.b],Y=w.value[M.c],w.array[z]=W.x,w.array[z+1]=W.y,w.array[z+2]=W.z,w.array[z+3]=W.w,w.array[z+4]=X.x,w.array[z+5]=X.y,w.array[z+6]=X.z,w.array[z+7]=X.w,w.array[z+8]=Y.x,w.array[z+9]=Y.y,w.array[z+10]=Y.z,w.array[z+11]=Y.w,z+=12;for(G=0,U=ma.length;G<U;G++)M=Da[ma[G]],W=w.value[M.a],X=w.value[M.b],Y=w.value[M.c],na=w.value[M.d],w.array[z]=W.x,w.array[z+1]=W.y,w.array[z+2]=W.z,w.array[z+3]=W.w,w.array[z+4]=X.x,w.array[z+5]=X.y,w.array[z+6]=
-X.z,w.array[z+7]=X.w,w.array[z+8]=Y.x,w.array[z+9]=Y.y,w.array[z+10]=Y.z,w.array[z+11]=Y.w,w.array[z+12]=na.x,w.array[z+13]=na.y,w.array[z+14]=na.z,w.array[z+15]=na.w,z+=16}else if("faces"===w.boundTo){for(G=0,U=la.length;G<U;G++)Y=X=W=Xa=w.value[la[G]],w.array[z]=W.x,w.array[z+1]=W.y,w.array[z+2]=W.z,w.array[z+3]=W.w,w.array[z+4]=X.x,w.array[z+5]=X.y,w.array[z+6]=X.z,w.array[z+7]=X.w,w.array[z+8]=Y.x,w.array[z+9]=Y.y,w.array[z+10]=Y.z,w.array[z+11]=Y.w,z+=12;for(G=0,U=ma.length;G<U;G++)na=Y=X=W=
-Xa=w.value[ma[G]],w.array[z]=W.x,w.array[z+1]=W.y,w.array[z+2]=W.z,w.array[z+3]=W.w,w.array[z+4]=X.x,w.array[z+5]=X.y,w.array[z+6]=X.z,w.array[z+7]=X.w,w.array[z+8]=Y.x,w.array[z+9]=Y.y,w.array[z+10]=Y.z,w.array[z+11]=Y.w,w.array[z+12]=na.x,w.array[z+13]=na.y,w.array[z+14]=na.z,w.array[z+15]=na.w,z+=16}j.bindBuffer(j.ARRAY_BUFFER,w.buffer);j.bufferData(j.ARRAY_BUFFER,w.array,Za)}nd&&(delete da.__inittedArrays,delete da.__colorArray,delete da.__normalArray,delete da.__tangentArray,delete da.__uvArray,
-delete da.__uv2Array,delete da.__faceArray,delete da.__vertexArray,delete da.__lineArray,delete da.__skinVertexAArray,delete da.__skinVertexBArray,delete da.__skinIndexArray,delete da.__skinWeightArray)}}ha.__dirtyVertices=!1;ha.__dirtyMorphTargets=!1;ha.__dirtyElements=!1;ha.__dirtyUvs=!1;ha.__dirtyNormals=!1;ha.__dirtyColors=!1;ha.__dirtyTangents=!1;Ua.attributes&&n(Ua)}else if(kb instanceof THREE.Ribbon){if(ha.__dirtyVertices||ha.__dirtyColors){var Qb=ha,dd=j.DYNAMIC_DRAW,qc=void 0,rc=void 0,Cc=
-void 0,Rb=void 0,Dc=void 0,ed=Qb.vertices,fd=Qb.colors,td=ed.length,ud=fd.length,Ec=Qb.__vertexArray,Fc=Qb.__colorArray,vd=Qb.__dirtyColors;if(Qb.__dirtyVertices){for(qc=0;qc<td;qc++)Cc=ed[qc].position,Rb=3*qc,Ec[Rb]=Cc.x,Ec[Rb+1]=Cc.y,Ec[Rb+2]=Cc.z;j.bindBuffer(j.ARRAY_BUFFER,Qb.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Ec,dd)}if(vd){for(rc=0;rc<ud;rc++)Dc=fd[rc],Rb=3*rc,Fc[Rb]=Dc.r,Fc[Rb+1]=Dc.g,Fc[Rb+2]=Dc.b;j.bindBuffer(j.ARRAY_BUFFER,Qb.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,
-Fc,dd)}}ha.__dirtyVertices=!1;ha.__dirtyColors=!1}else if(kb instanceof THREE.Line){Ua=c(kb,jc);$b=Ua.attributes&&p(Ua);if(ha.__dirtyVertices||ha.__dirtyColors||$b){var Db=ha,Vc=j.DYNAMIC_DRAW,sc=void 0,tc=void 0,Gc=void 0,wa=void 0,Hc=void 0,gd=Db.vertices,hd=Db.colors,wd=gd.length,xd=hd.length,Ic=Db.__vertexArray,Jc=Db.__colorArray,yd=Db.__dirtyColors,Wc=Db.__webglCustomAttributesList,Kc=void 0,id=void 0,Oa=void 0,fc=void 0,Va=void 0,pa=void 0;if(Db.__dirtyVertices){for(sc=0;sc<wd;sc++)Gc=gd[sc].position,
-wa=3*sc,Ic[wa]=Gc.x,Ic[wa+1]=Gc.y,Ic[wa+2]=Gc.z;j.bindBuffer(j.ARRAY_BUFFER,Db.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Ic,Vc)}if(yd){for(tc=0;tc<xd;tc++)Hc=hd[tc],wa=3*tc,Jc[wa]=Hc.r,Jc[wa+1]=Hc.g,Jc[wa+2]=Hc.b;j.bindBuffer(j.ARRAY_BUFFER,Db.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,Jc,Vc)}if(Wc)for(Kc=0,id=Wc.length;Kc<id;Kc++)if(pa=Wc[Kc],pa.needsUpdate&&(void 0===pa.boundTo||"vertices"===pa.boundTo)){wa=0;fc=pa.value.length;if(1===pa.size)for(Oa=0;Oa<fc;Oa++)pa.array[Oa]=pa.value[Oa];
-else if(2===pa.size)for(Oa=0;Oa<fc;Oa++)Va=pa.value[Oa],pa.array[wa]=Va.x,pa.array[wa+1]=Va.y,wa+=2;else if(3===pa.size)if("c"===pa.type)for(Oa=0;Oa<fc;Oa++)Va=pa.value[Oa],pa.array[wa]=Va.r,pa.array[wa+1]=Va.g,pa.array[wa+2]=Va.b,wa+=3;else for(Oa=0;Oa<fc;Oa++)Va=pa.value[Oa],pa.array[wa]=Va.x,pa.array[wa+1]=Va.y,pa.array[wa+2]=Va.z,wa+=3;else if(4===pa.size)for(Oa=0;Oa<fc;Oa++)Va=pa.value[Oa],pa.array[wa]=Va.x,pa.array[wa+1]=Va.y,pa.array[wa+2]=Va.z,pa.array[wa+3]=Va.w,wa+=4;j.bindBuffer(j.ARRAY_BUFFER,
-pa.buffer);j.bufferData(j.ARRAY_BUFFER,pa.array,Vc)}}ha.__dirtyVertices=!1;ha.__dirtyColors=!1;Ua.attributes&&n(Ua)}else if(kb instanceof THREE.ParticleSystem)Ua=c(kb,jc),$b=Ua.attributes&&p(Ua),(ha.__dirtyVertices||ha.__dirtyColors||kb.sortParticles||$b)&&f(ha,j.DYNAMIC_DRAW,kb),ha.__dirtyVertices=!1,ha.__dirtyColors=!1,Ua.attributes&&n(Ua)}};this.initMaterial=function(a,b,c,d){var e,f,g,h,i;a instanceof THREE.MeshDepthMaterial?i="depth":a instanceof THREE.MeshNormalMaterial?i="normal":a instanceof
-THREE.MeshBasicMaterial?i="basic":a instanceof THREE.MeshLambertMaterial?i="lambert":a instanceof THREE.MeshPhongMaterial?i="phong":a instanceof THREE.LineBasicMaterial?i="basic":a instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var l=THREE.ShaderLib[i];a.uniforms=THREE.UniformsUtils.clone(l.uniforms);a.vertexShader=l.vertexShader;a.fragmentShader=l.fragmentShader}var k,m;f=l=0;for(k=0,m=b.length;k<m;k++)e=b[k],e instanceof THREE.SpotLight&&!e.onlyShadow&&f++,e instanceof THREE.DirectionalLight&&
-f++,e instanceof THREE.PointLight&&l++;l+f<=P?k=f:(k=Math.ceil(P*f/(l+f)),l=P-k);e=k;f=l;var n=0;for(l=0,k=b.length;l<k;l++)m=b[l],m instanceof THREE.SpotLight&&m.castShadow&&n++;var p=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)p=d.bones.length;var o;a:{k=a.fragmentShader;m=a.vertexShader;var l=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,
-maxMorphTargets:this.maxMorphTargets,maxDirLights:e,maxPointLights:f,maxBones:p,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:n,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround},q,d=[];i?d.push(i):(d.push(k),d.push(m));for(q in c)d.push(q),d.push(c[q]);i=d.join();for(q=0,d=H.length;q<d;q++)if(H[q].code===i){o=H[q].program;break a}q=j.createProgram();
-d=[0<Wa?"#define VERTEX_TEXTURES":"",B.gammaInput?"#define GAMMA_INPUT":"",B.gammaOutput?"#define GAMMA_OUTPUT":"",B.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#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.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",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");
-e=["precision "+C+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",B.gammaInput?"#define GAMMA_INPUT":"",B.gammaOutput?"#define GAMMA_OUTPUT":"",B.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",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.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",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");j.attachShader(q,u("fragment",
-e+k));j.attachShader(q,u("vertex",d+m));j.linkProgram(q);j.getProgramParameter(q,j.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+j.getProgramParameter(q,j.VALIDATE_STATUS)+", gl error ["+j.getError()+"]");q.uniforms={};q.attributes={};var r,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,cameraInverseMatrix,boneGlobalMatrices,morphTargetInfluences".split(",");for(r in l)d.push(r);r=d;for(d=0,l=r.length;d<l;d++)k=r[d],q.uniforms[k]=
-j.getUniformLocation(q,k);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,skinWeight".split(",");for(r=0;r<c.maxMorphTargets;r++)d.push("morphTarget"+r);for(o in b)d.push(o);o=d;for(r=0,b=o.length;r<b;r++)c=o[r],q.attributes[c]=j.getAttribLocation(q,c);q.id=H.length;H.push({program:q,code:i});B.info.memory.programs=H.length;o=q}a.program=o;o=a.program.attributes;0<=o.position&&j.enableVertexAttribArray(o.position);0<=o.color&&j.enableVertexAttribArray(o.color);0<=o.normal&&
-j.enableVertexAttribArray(o.normal);0<=o.tangent&&j.enableVertexAttribArray(o.tangent);a.skinning&&0<=o.skinVertexA&&0<=o.skinVertexB&&0<=o.skinIndex&&0<=o.skinWeight&&(j.enableVertexAttribArray(o.skinVertexA),j.enableVertexAttribArray(o.skinVertexB),j.enableVertexAttribArray(o.skinIndex),j.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(h in a.attributes)void 0!==o[h]&&0<=o[h]&&j.enableVertexAttribArray(o[h]);if(a.morphTargets)for(h=a.numSupportedMorphTargets=0;h<this.maxMorphTargets;h++)r=
-"morphTarget"+h,0<=o[r]&&(j.enableVertexAttribArray(o[r]),a.numSupportedMorphTargets++);a.uniformsList=[];for(g in a.uniforms)a.uniformsList.push([a.uniforms[g],g])};this.setFaceCulling=function(a,b){a?(!b||"ccw"===b?j.frontFace(j.CCW):j.frontFace(j.CW),"back"===a?j.cullFace(j.BACK):"front"===a?j.cullFace(j.FRONT):j.cullFace(j.FRONT_AND_BACK),j.enable(j.CULL_FACE)):j.disable(j.CULL_FACE)};this.setObjectFaces=function(a){if(aa!==a.doubleSided)a.doubleSided?j.disable(j.CULL_FACE):j.enable(j.CULL_FACE),
-aa=a.doubleSided;if(ga!==a.flipSided)a.flipSided?j.frontFace(j.CW):j.frontFace(j.CCW),ga=a.flipSided};this.setDepthTest=function(a){S!==a&&(a?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST),S=a)};this.setBlending=function(a){if(a!==fa){switch(a){case THREE.AdditiveBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE);break;case THREE.SubtractiveBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:j.blendEquation(j.FUNC_ADD);
-j.blendFunc(j.ZERO,j.SRC_COLOR);break;default:j.blendEquationSeparate(j.FUNC_ADD,j.FUNC_ADD),j.blendFuncSeparate(j.SRC_ALPHA,j.ONE_MINUS_SRC_ALPHA,j.ONE,j.ONE_MINUS_SRC_ALPHA)}fa=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=j.createTexture(),B.info.memory.textures++;j.activeTexture(j.TEXTURE0+b);j.bindTexture(j.TEXTURE_2D,a.__webglTexture);var c=a.image,d=0===(c.width&c.width-1)&&0===(c.height&c.height-1),e=D(a.format),f=D(a.type);x(j.TEXTURE_2D,
-a,d);a instanceof THREE.DataTexture?j.texImage2D(j.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):j.texImage2D(j.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&j.generateMipmap(j.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else j.activeTexture(j.TEXTURE0+b),j.bindTexture(j.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(void 0===a.depthBuffer)a.depthBuffer=!0;if(void 0===a.stencilBuffer)a.stencilBuffer=
-!0;a.__webglTexture=j.createTexture();var c=0===(a.width&a.width-1)&&0===(a.height&a.height-1),d=D(a.format),e=D(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];j.bindTexture(j.TEXTURE_CUBE_MAP,a.__webglTexture);x(j.TEXTURE_CUBE_MAP,a,c);for(c=0;6>c;c++){a.__webglFramebuffer[c]=j.createFramebuffer();a.__webglRenderbuffer[c]=j.createRenderbuffer();j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,0,d,e,null);var f=a,g=j.TEXTURE_CUBE_MAP_POSITIVE_X+c;j.bindFramebuffer(j.FRAMEBUFFER,
-a.__webglFramebuffer[c]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,g,f.__webglTexture,0);v(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=j.createFramebuffer(),a.__webglRenderbuffer=j.createRenderbuffer(),j.bindTexture(j.TEXTURE_2D,a.__webglTexture),x(j.TEXTURE_2D,a,c),j.texImage2D(j.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=j.TEXTURE_2D,j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer),j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,d,a.__webglTexture,0),v(a.__webglRenderbuffer,
-a);b?j.bindTexture(j.TEXTURE_CUBE_MAP,null):j.bindTexture(j.TEXTURE_2D,null);j.bindRenderbuffer(j.RENDERBUFFER,null);j.bindFramebuffer(j.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,d=a.width,a=a.height,c=e=0):(b=null,d=qa,a=Ga,e=ja,c=za);b!==y&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(e,c,d,a),y=b);Fa=d;ab=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
+j.vertexAttribPointer(b.skinVertexA,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),j.vertexAttribPointer(b.skinVertexB,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),j.vertexAttribPointer(b.skinIndex,4,j.FLOAT,!1,0,0),j.bindBuffer(j.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),j.vertexAttribPointer(b.skinWeight,4,j.FLOAT,!1,0,0))}f instanceof THREE.Mesh?(d.wireframe?(d=d.wireframeLinewidth,d!==ha&&(j.lineWidth(d),ha=d),a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,
+e.__webglLineBuffer),j.drawElements(j.LINES,e.__webglLineCount,j.UNSIGNED_SHORT,0)):(a&&j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),j.drawElements(j.TRIANGLES,e.__webglFaceCount,j.UNSIGNED_SHORT,0)),E.info.render.calls++,E.info.render.vertices+=e.__webglFaceCount,E.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==ha&&(j.lineWidth(d),ha=d),j.drawArrays(f,0,e.__webglLineCount),E.info.render.calls++):f instanceof
+THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),E.info.render.calls++,E.info.render.points+=e.__webglParticleCount):f instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),E.info.render.calls++)}};this.render=function(a,b,c,d){var e,f,k,m,o=a.lights,p=a.fog;y=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);void 0===b.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();
+h(this.renderPluginsPre,a,b);E.info.render.calls=0;E.info.render.vertices=0;E.info.render.faces=0;E.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);Ta.multiply(b.projectionMatrix,b.matrixWorldInverse);Sa.setFromMatrix(Ta);this.setRenderTarget(c);
+(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);m=a.__webglObjects;for(d=0,e=m.length;d<e;d++)if(f=m[d],k=f.object,f.render=!1,k.visible&&(!(k instanceof THREE.Mesh||k instanceof THREE.ParticleSystem)||!k.frustumCulled||Sa.contains(k))){k.matrixWorld.flattenToArray(k._objectMatrixArray);r(k,b);var n=f,q=n.object,F=n.buffer,t=void 0,t=t=void 0,t=q.material;if(t instanceof THREE.MeshFaceMaterial){if(t=F.materialIndex,0<=t)t=q.geometry.materials[t],t.transparent?
+(n.transparent=t,n.opaque=null):(n.opaque=t,n.transparent=null)}else if(t)t.transparent?(n.transparent=t,n.opaque=null):(n.opaque=t,n.transparent=null);f.render=!0;if(this.sortObjects)k.renderDepth?f.z=k.renderDepth:(Wa.copy(k.position),Ta.multiplyVector3(Wa),f.z=Wa.z)}this.sortObjects&&m.sort(g);m=a.__webglObjectsImmediate;for(d=0,e=m.length;d<e;d++)if(f=m[d],k=f.object,k.visible)k.matrixAutoUpdate&&k.matrixWorld.flattenToArray(k._objectMatrixArray),r(k,b),k=f.object.material,k.transparent?(f.transparent=
+k,f.opaque=null):(f.opaque=k,f.transparent=null);a.overrideMaterial?(this.setBlending(a.overrideMaterial.blending),this.setDepthTest(a.overrideMaterial.depthTest),this.setDepthWrite(a.overrideMaterial.depthWrite),s(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),i(a.__webglObjects,!1,"",b,o,p,!0,a.overrideMaterial),l(a.__webglObjectsImmediate,"",b,o,p,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),i(a.__webglObjects,!0,
+"opaque",b,o,p,!1),l(a.__webglObjectsImmediate,"opaque",b,o,p,!1),i(a.__webglObjects,!1,"transparent",b,o,p,!0),l(a.__webglObjectsImmediate,"transparent",b,o,p,!0));h(this.renderPluginsPost,a,b);c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(j.bindTexture(j.TEXTURE_CUBE_MAP,c.__webglTexture),j.generateMipmap(j.TEXTURE_CUBE_MAP),j.bindTexture(j.TEXTURE_CUBE_MAP,null)):(j.bindTexture(j.TEXTURE_2D,c.__webglTexture),
+j.generateMipmap(j.TEXTURE_2D),j.bindTexture(j.TEXTURE_2D,null)));this.setDepthTest(!0);this.setDepthWrite(!0)};this.renderImmediateObject=function(a,b,c,d,e){var f=m(a,b,c,d,e);F=-1;E.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(f,j,Sa):e.render(function(a){E.renderBufferImmediate(a,f,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var g=
+a.__objectsAdded[0],h=a,i=void 0,l=void 0,m=void 0;if(!g.__webglInit)if(g.__webglInit=!0,g._modelViewMatrix=new THREE.Matrix4,g._normalMatrixArray=new Float32Array(9),g._modelViewMatrixArray=new Float32Array(16),g._objectMatrixArray=new Float32Array(16),g.matrixWorld.flattenToArray(g._objectMatrixArray),g instanceof THREE.Mesh){if(l=g.geometry,l instanceof THREE.Geometry){if(void 0===l.geometryGroups){var r=l,s=void 0,t=void 0,F=void 0,w=void 0,y=void 0,x=void 0,u=void 0,B={},C=r.morphTargets.length;
+r.geometryGroups={};for(s=0,t=r.faces.length;s<t;s++)F=r.faces[s],w=F.materialIndex,x=void 0!==w?w:-1,void 0===B[x]&&(B[x]={hash:x,counter:0}),u=B[x].hash+"_"+B[x].counter,void 0===r.geometryGroups[u]&&(r.geometryGroups[u]={faces3:[],faces4:[],materialIndex:w,vertices:0,numMorphTargets:C}),y=F instanceof THREE.Face3?3:4,65535<r.geometryGroups[u].vertices+y&&(B[x].counter+=1,u=B[x].hash+"_"+B[x].counter,void 0===r.geometryGroups[u]&&(r.geometryGroups[u]={faces3:[],faces4:[],materialIndex:w,vertices:0,
+numMorphTargets:C})),F instanceof THREE.Face3?r.geometryGroups[u].faces3.push(s):r.geometryGroups[u].faces4.push(s),r.geometryGroups[u].vertices+=y;r.geometryGroupsList=[];var $=void 0;for($ in r.geometryGroups)r.geometryGroups[$].id=P++,r.geometryGroupsList.push(r.geometryGroups[$])}for(i in l.geometryGroups)if(m=l.geometryGroups[i],!m.__webglVertexBuffer){var A=m;A.__webglVertexBuffer=j.createBuffer();A.__webglNormalBuffer=j.createBuffer();A.__webglTangentBuffer=j.createBuffer();A.__webglColorBuffer=
+j.createBuffer();A.__webglUVBuffer=j.createBuffer();A.__webglUV2Buffer=j.createBuffer();A.__webglSkinVertexABuffer=j.createBuffer();A.__webglSkinVertexBBuffer=j.createBuffer();A.__webglSkinIndicesBuffer=j.createBuffer();A.__webglSkinWeightsBuffer=j.createBuffer();A.__webglFaceBuffer=j.createBuffer();A.__webglLineBuffer=j.createBuffer();if(A.numMorphTargets){var D=void 0,I=void 0;A.__webglMorphTargetsBuffers=[];for(D=0,I=A.numMorphTargets;D<I;D++)A.__webglMorphTargetsBuffers.push(j.createBuffer())}E.info.memory.geometries++;
+var G=m,S=g,Z=S.geometry,L=G.faces3,K=G.faces4,M=3*L.length+4*K.length,fa=1*L.length+2*K.length,Q=3*L.length+4*K.length,aa=c(S,G),ba=e(aa),ca=d(aa),ga=aa.vertexColors?aa.vertexColors:!1;G.__vertexArray=new Float32Array(3*M);if(ca)G.__normalArray=new Float32Array(3*M);if(Z.hasTangents)G.__tangentArray=new Float32Array(4*M);if(ga)G.__colorArray=new Float32Array(3*M);if(ba){if(0<Z.faceUvs.length||0<Z.faceVertexUvs.length)G.__uvArray=new Float32Array(2*M);if(1<Z.faceUvs.length||1<Z.faceVertexUvs.length)G.__uv2Array=
+new Float32Array(2*M)}if(S.geometry.skinWeights.length&&S.geometry.skinIndices.length)G.__skinVertexAArray=new Float32Array(4*M),G.__skinVertexBArray=new Float32Array(4*M),G.__skinIndexArray=new Float32Array(4*M),G.__skinWeightArray=new Float32Array(4*M);G.__faceArray=new Uint16Array(3*fa);G.__lineArray=new Uint16Array(2*Q);if(G.numMorphTargets){G.__morphTargetsArrays=[];for(var R=0,ha=G.numMorphTargets;R<ha;R++)G.__morphTargetsArrays.push(new Float32Array(3*M))}G.__webglFaceCount=3*fa;G.__webglLineCount=
+2*Q;if(aa.attributes){if(void 0===G.__webglCustomAttributesList)G.__webglCustomAttributesList=[];var T=void 0;for(T in aa.attributes){var Na=aa.attributes[T],ja={},za;for(za in Na)ja[za]=Na[za];if(!ja.__webglInitialized||ja.createUniqueBuffers){ja.__webglInitialized=!0;var qa=1;"v2"===ja.type?qa=2:"v3"===ja.type?qa=3:"v4"===ja.type?qa=4:"c"===ja.type&&(qa=3);ja.size=qa;ja.array=new Float32Array(M*qa);ja.buffer=j.createBuffer();ja.buffer.belongsToAttribute=T;Na.needsUpdate=!0;ja.__original=Na}G.__webglCustomAttributesList.push(ja)}}G.__inittedArrays=
+!0;l.__dirtyVertices=!0;l.__dirtyMorphTargets=!0;l.__dirtyElements=!0;l.__dirtyUvs=!0;l.__dirtyNormals=!0;l.__dirtyTangents=!0;l.__dirtyColors=!0}}}else if(g instanceof THREE.Ribbon){if(l=g.geometry,!l.__webglVertexBuffer){var Ea=l;Ea.__webglVertexBuffer=j.createBuffer();Ea.__webglColorBuffer=j.createBuffer();E.info.memory.geometries++;var Ga=l,Ta=Ga.vertices.length;Ga.__vertexArray=new Float32Array(3*Ta);Ga.__colorArray=new Float32Array(3*Ta);Ga.__webglVertexCount=Ta;l.__dirtyVertices=!0;l.__dirtyColors=
+!0}}else if(g instanceof THREE.Line){if(l=g.geometry,!l.__webglVertexBuffer){var Wa=l;Wa.__webglVertexBuffer=j.createBuffer();Wa.__webglColorBuffer=j.createBuffer();E.info.memory.geometries++;var Sa=l,fb=g,Za=Sa.vertices.length;Sa.__vertexArray=new Float32Array(3*Za);Sa.__colorArray=new Float32Array(3*Za);Sa.__webglLineCount=Za;b(Sa,fb);l.__dirtyVertices=!0;l.__dirtyColors=!0}}else if(g instanceof THREE.ParticleSystem&&(l=g.geometry,!l.__webglVertexBuffer)){var lb=l;lb.__webglVertexBuffer=j.createBuffer();
+lb.__webglColorBuffer=j.createBuffer();E.info.geometries++;var $b=l,kd=g,Oc=$b.vertices.length;$b.__vertexArray=new Float32Array(3*Oc);$b.__colorArray=new Float32Array(3*Oc);$b.__sortArray=[];$b.__webglParticleCount=Oc;b($b,kd);l.__dirtyVertices=!0;l.__dirtyColors=!0}if(!g.__webglActive){if(g instanceof THREE.Mesh)if(l=g.geometry,l instanceof THREE.BufferGeometry)k(h.__webglObjects,l,g);else for(i in l.geometryGroups)m=l.geometryGroups[i],k(h.__webglObjects,m,g);else g instanceof THREE.Ribbon||g instanceof
+THREE.Line||g instanceof THREE.ParticleSystem?(l=g.geometry,k(h.__webglObjects,l,g)):void 0!==THREE.MarchingCubes&&g instanceof THREE.MarchingCubes||g.immediateRenderCallback?h.__webglObjectsImmediate.push({object:g,opaque:null,transparent:null}):g instanceof THREE.Sprite?h.__webglSprites.push(g):g instanceof THREE.LensFlare&&h.__webglFlares.push(g);g.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var cb=a.__objectsRemoved[0],xc=a;cb instanceof THREE.Mesh||cb instanceof
+THREE.ParticleSystem||cb instanceof THREE.Ribbon||cb instanceof THREE.Line?n(xc.__webglObjects,cb):cb instanceof THREE.Sprite?q(xc.__webglSprites,cb):cb instanceof THREE.LensFlare?q(xc.__webglFlares,cb):(cb instanceof THREE.MarchingCubes||cb.immediateRenderCallback)&&n(xc.__webglObjectsImmediate,cb);cb.__webglActive=!1;a.__objectsRemoved.splice(0,1)}for(var Pc=0,ld=a.__webglObjects.length;Pc<ld;Pc++){var jb=a.__webglObjects[Pc].object,ia=jb.geometry,kc=void 0,ac=void 0,Ua=void 0;if(jb instanceof THREE.Mesh)if(ia instanceof
+THREE.BufferGeometry)ia.__dirtyVertices=!1,ia.__dirtyElements=!1,ia.__dirtyUvs=!1,ia.__dirtyNormals=!1,ia.__dirtyColors=!1;else{for(var Qc=0,md=ia.geometryGroupsList.length;Qc<md;Qc++)if(kc=ia.geometryGroupsList[Qc],Ua=c(jb,kc),ac=Ua.attributes&&p(Ua),ia.__dirtyVertices||ia.__dirtyMorphTargets||ia.__dirtyElements||ia.__dirtyUvs||ia.__dirtyNormals||ia.__dirtyColors||ia.__dirtyTangents||ac){var da=kc,nd=jb,$a=j.DYNAMIC_DRAW,od=!ia.dynamic,zc=Ua;if(da.__inittedArrays){var Zc=d(zc),Rc=zc.vertexColors?
+zc.vertexColors:!1,$c=e(zc),ad=Zc===THREE.SmoothShading,H=void 0,U=void 0,hb=void 0,N=void 0,bc=void 0,Gb=void 0,kb=void 0,Ac=void 0,Ab=void 0,cc=void 0,dc=void 0,V=void 0,W=void 0,X=void 0,na=void 0,mb=void 0,nb=void 0,ob=void 0,lc=void 0,pb=void 0,qb=void 0,rb=void 0,mc=void 0,sb=void 0,tb=void 0,ub=void 0,nc=void 0,vb=void 0,wb=void 0,xb=void 0,oc=void 0,Hb=void 0,Ib=void 0,Jb=void 0,Bc=void 0,Kb=void 0,Lb=void 0,Mb=void 0,Cc=void 0,ka=void 0,bd=void 0,Nb=void 0,ec=void 0,fc=void 0,ab=void 0,cd=
+void 0,Fa=void 0,ya=0,Da=0,Bb=0,Cb=0,db=0,Pa=0,oa=0,Qa=0,Aa=0,J=0,Ba=0,z=0,Xa=void 0,Ia=da.__vertexArray,pc=da.__uvArray,qc=da.__uv2Array,eb=da.__normalArray,ra=da.__tangentArray,Ja=da.__colorArray,sa=da.__skinVertexAArray,ta=da.__skinVertexBArray,ua=da.__skinIndexArray,va=da.__skinWeightArray,Sc=da.__morphTargetsArrays,Tc=da.__webglCustomAttributesList,v=void 0,yb=da.__faceArray,Ya=da.__lineArray,Ra=nd.geometry,pd=Ra.__dirtyElements,dd=Ra.__dirtyUvs,qd=Ra.__dirtyNormals,rd=Ra.__dirtyTangents,sd=
+Ra.__dirtyColors,td=Ra.__dirtyMorphTargets,Ub=Ra.vertices,la=da.faces3,ma=da.faces4,Ca=Ra.faces,Uc=Ra.faceVertexUvs[0],Vc=Ra.faceVertexUvs[1],Vb=Ra.skinVerticesA,Wb=Ra.skinVerticesB,Xb=Ra.skinIndices,Ob=Ra.skinWeights,Pb=Ra.morphTargets;if(Ra.__dirtyVertices){for(H=0,U=la.length;H<U;H++)N=Ca[la[H]],V=Ub[N.a].position,W=Ub[N.b].position,X=Ub[N.c].position,Ia[Da]=V.x,Ia[Da+1]=V.y,Ia[Da+2]=V.z,Ia[Da+3]=W.x,Ia[Da+4]=W.y,Ia[Da+5]=W.z,Ia[Da+6]=X.x,Ia[Da+7]=X.y,Ia[Da+8]=X.z,Da+=9;for(H=0,U=ma.length;H<U;H++)N=
+Ca[ma[H]],V=Ub[N.a].position,W=Ub[N.b].position,X=Ub[N.c].position,na=Ub[N.d].position,Ia[Da]=V.x,Ia[Da+1]=V.y,Ia[Da+2]=V.z,Ia[Da+3]=W.x,Ia[Da+4]=W.y,Ia[Da+5]=W.z,Ia[Da+6]=X.x,Ia[Da+7]=X.y,Ia[Da+8]=X.z,Ia[Da+9]=na.x,Ia[Da+10]=na.y,Ia[Da+11]=na.z,Da+=12;j.bindBuffer(j.ARRAY_BUFFER,da.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Ia,$a)}if(td)for(ab=0,cd=Pb.length;ab<cd;ab++){Ba=0;for(H=0,U=la.length;H<U;H++)N=Ca[la[H]],V=Pb[ab].vertices[N.a].position,W=Pb[ab].vertices[N.b].position,X=Pb[ab].vertices[N.c].position,
+Fa=Sc[ab],Fa[Ba]=V.x,Fa[Ba+1]=V.y,Fa[Ba+2]=V.z,Fa[Ba+3]=W.x,Fa[Ba+4]=W.y,Fa[Ba+5]=W.z,Fa[Ba+6]=X.x,Fa[Ba+7]=X.y,Fa[Ba+8]=X.z,Ba+=9;for(H=0,U=ma.length;H<U;H++)N=Ca[ma[H]],V=Pb[ab].vertices[N.a].position,W=Pb[ab].vertices[N.b].position,X=Pb[ab].vertices[N.c].position,na=Pb[ab].vertices[N.d].position,Fa=Sc[ab],Fa[Ba]=V.x,Fa[Ba+1]=V.y,Fa[Ba+2]=V.z,Fa[Ba+3]=W.x,Fa[Ba+4]=W.y,Fa[Ba+5]=W.z,Fa[Ba+6]=X.x,Fa[Ba+7]=X.y,Fa[Ba+8]=X.z,Fa[Ba+9]=na.x,Fa[Ba+10]=na.y,Fa[Ba+11]=na.z,Ba+=12;j.bindBuffer(j.ARRAY_BUFFER,
+da.__webglMorphTargetsBuffers[ab]);j.bufferData(j.ARRAY_BUFFER,Sc[ab],$a)}if(Ob.length){for(H=0,U=la.length;H<U;H++)N=Ca[la[H]],sb=Ob[N.a],tb=Ob[N.b],ub=Ob[N.c],va[J]=sb.x,va[J+1]=sb.y,va[J+2]=sb.z,va[J+3]=sb.w,va[J+4]=tb.x,va[J+5]=tb.y,va[J+6]=tb.z,va[J+7]=tb.w,va[J+8]=ub.x,va[J+9]=ub.y,va[J+10]=ub.z,va[J+11]=ub.w,vb=Xb[N.a],wb=Xb[N.b],xb=Xb[N.c],ua[J]=vb.x,ua[J+1]=vb.y,ua[J+2]=vb.z,ua[J+3]=vb.w,ua[J+4]=wb.x,ua[J+5]=wb.y,ua[J+6]=wb.z,ua[J+7]=wb.w,ua[J+8]=xb.x,ua[J+9]=xb.y,ua[J+10]=xb.z,ua[J+11]=
+xb.w,Hb=Vb[N.a],Ib=Vb[N.b],Jb=Vb[N.c],sa[J]=Hb.x,sa[J+1]=Hb.y,sa[J+2]=Hb.z,sa[J+3]=1,sa[J+4]=Ib.x,sa[J+5]=Ib.y,sa[J+6]=Ib.z,sa[J+7]=1,sa[J+8]=Jb.x,sa[J+9]=Jb.y,sa[J+10]=Jb.z,sa[J+11]=1,Kb=Wb[N.a],Lb=Wb[N.b],Mb=Wb[N.c],ta[J]=Kb.x,ta[J+1]=Kb.y,ta[J+2]=Kb.z,ta[J+3]=1,ta[J+4]=Lb.x,ta[J+5]=Lb.y,ta[J+6]=Lb.z,ta[J+7]=1,ta[J+8]=Mb.x,ta[J+9]=Mb.y,ta[J+10]=Mb.z,ta[J+11]=1,J+=12;for(H=0,U=ma.length;H<U;H++)N=Ca[ma[H]],sb=Ob[N.a],tb=Ob[N.b],ub=Ob[N.c],nc=Ob[N.d],va[J]=sb.x,va[J+1]=sb.y,va[J+2]=sb.z,va[J+3]=sb.w,
+va[J+4]=tb.x,va[J+5]=tb.y,va[J+6]=tb.z,va[J+7]=tb.w,va[J+8]=ub.x,va[J+9]=ub.y,va[J+10]=ub.z,va[J+11]=ub.w,va[J+12]=nc.x,va[J+13]=nc.y,va[J+14]=nc.z,va[J+15]=nc.w,vb=Xb[N.a],wb=Xb[N.b],xb=Xb[N.c],oc=Xb[N.d],ua[J]=vb.x,ua[J+1]=vb.y,ua[J+2]=vb.z,ua[J+3]=vb.w,ua[J+4]=wb.x,ua[J+5]=wb.y,ua[J+6]=wb.z,ua[J+7]=wb.w,ua[J+8]=xb.x,ua[J+9]=xb.y,ua[J+10]=xb.z,ua[J+11]=xb.w,ua[J+12]=oc.x,ua[J+13]=oc.y,ua[J+14]=oc.z,ua[J+15]=oc.w,Hb=Vb[N.a],Ib=Vb[N.b],Jb=Vb[N.c],Bc=Vb[N.d],sa[J]=Hb.x,sa[J+1]=Hb.y,sa[J+2]=Hb.z,sa[J+
+3]=1,sa[J+4]=Ib.x,sa[J+5]=Ib.y,sa[J+6]=Ib.z,sa[J+7]=1,sa[J+8]=Jb.x,sa[J+9]=Jb.y,sa[J+10]=Jb.z,sa[J+11]=1,sa[J+12]=Bc.x,sa[J+13]=Bc.y,sa[J+14]=Bc.z,sa[J+15]=1,Kb=Wb[N.a],Lb=Wb[N.b],Mb=Wb[N.c],Cc=Wb[N.d],ta[J]=Kb.x,ta[J+1]=Kb.y,ta[J+2]=Kb.z,ta[J+3]=1,ta[J+4]=Lb.x,ta[J+5]=Lb.y,ta[J+6]=Lb.z,ta[J+7]=1,ta[J+8]=Mb.x,ta[J+9]=Mb.y,ta[J+10]=Mb.z,ta[J+11]=1,ta[J+12]=Cc.x,ta[J+13]=Cc.y,ta[J+14]=Cc.z,ta[J+15]=1,J+=16;0<J&&(j.bindBuffer(j.ARRAY_BUFFER,da.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,sa,
+$a),j.bindBuffer(j.ARRAY_BUFFER,da.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,ta,$a),j.bindBuffer(j.ARRAY_BUFFER,da.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,ua,$a),j.bindBuffer(j.ARRAY_BUFFER,da.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,va,$a))}if(sd&&Rc){for(H=0,U=la.length;H<U;H++)N=Ca[la[H]],kb=N.vertexColors,Ac=N.color,3===kb.length&&Rc===THREE.VertexColors?(pb=kb[0],qb=kb[1],rb=kb[2]):rb=qb=pb=Ac,Ja[Aa]=pb.r,Ja[Aa+1]=pb.g,Ja[Aa+2]=pb.b,Ja[Aa+3]=qb.r,Ja[Aa+
+4]=qb.g,Ja[Aa+5]=qb.b,Ja[Aa+6]=rb.r,Ja[Aa+7]=rb.g,Ja[Aa+8]=rb.b,Aa+=9;for(H=0,U=ma.length;H<U;H++)N=Ca[ma[H]],kb=N.vertexColors,Ac=N.color,4===kb.length&&Rc===THREE.VertexColors?(pb=kb[0],qb=kb[1],rb=kb[2],mc=kb[3]):mc=rb=qb=pb=Ac,Ja[Aa]=pb.r,Ja[Aa+1]=pb.g,Ja[Aa+2]=pb.b,Ja[Aa+3]=qb.r,Ja[Aa+4]=qb.g,Ja[Aa+5]=qb.b,Ja[Aa+6]=rb.r,Ja[Aa+7]=rb.g,Ja[Aa+8]=rb.b,Ja[Aa+9]=mc.r,Ja[Aa+10]=mc.g,Ja[Aa+11]=mc.b,Aa+=12;0<Aa&&(j.bindBuffer(j.ARRAY_BUFFER,da.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,Ja,$a))}if(rd&&
+Ra.hasTangents){for(H=0,U=la.length;H<U;H++)N=Ca[la[H]],Ab=N.vertexTangents,mb=Ab[0],nb=Ab[1],ob=Ab[2],ra[oa]=mb.x,ra[oa+1]=mb.y,ra[oa+2]=mb.z,ra[oa+3]=mb.w,ra[oa+4]=nb.x,ra[oa+5]=nb.y,ra[oa+6]=nb.z,ra[oa+7]=nb.w,ra[oa+8]=ob.x,ra[oa+9]=ob.y,ra[oa+10]=ob.z,ra[oa+11]=ob.w,oa+=12;for(H=0,U=ma.length;H<U;H++)N=Ca[ma[H]],Ab=N.vertexTangents,mb=Ab[0],nb=Ab[1],ob=Ab[2],lc=Ab[3],ra[oa]=mb.x,ra[oa+1]=mb.y,ra[oa+2]=mb.z,ra[oa+3]=mb.w,ra[oa+4]=nb.x,ra[oa+5]=nb.y,ra[oa+6]=nb.z,ra[oa+7]=nb.w,ra[oa+8]=ob.x,ra[oa+
+9]=ob.y,ra[oa+10]=ob.z,ra[oa+11]=ob.w,ra[oa+12]=lc.x,ra[oa+13]=lc.y,ra[oa+14]=lc.z,ra[oa+15]=lc.w,oa+=16;j.bindBuffer(j.ARRAY_BUFFER,da.__webglTangentBuffer);j.bufferData(j.ARRAY_BUFFER,ra,$a)}if(qd&&Zc){for(H=0,U=la.length;H<U;H++)if(N=Ca[la[H]],bc=N.vertexNormals,Gb=N.normal,3===bc.length&&ad)for(ka=0;3>ka;ka++)Nb=bc[ka],eb[Pa]=Nb.x,eb[Pa+1]=Nb.y,eb[Pa+2]=Nb.z,Pa+=3;else for(ka=0;3>ka;ka++)eb[Pa]=Gb.x,eb[Pa+1]=Gb.y,eb[Pa+2]=Gb.z,Pa+=3;for(H=0,U=ma.length;H<U;H++)if(N=Ca[ma[H]],bc=N.vertexNormals,
+Gb=N.normal,4===bc.length&&ad)for(ka=0;4>ka;ka++)Nb=bc[ka],eb[Pa]=Nb.x,eb[Pa+1]=Nb.y,eb[Pa+2]=Nb.z,Pa+=3;else for(ka=0;4>ka;ka++)eb[Pa]=Gb.x,eb[Pa+1]=Gb.y,eb[Pa+2]=Gb.z,Pa+=3;j.bindBuffer(j.ARRAY_BUFFER,da.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,eb,$a)}if(dd&&Uc&&$c){for(H=0,U=la.length;H<U;H++)if(hb=la[H],N=Ca[hb],cc=Uc[hb],void 0!==cc)for(ka=0;3>ka;ka++)ec=cc[ka],pc[Bb]=ec.u,pc[Bb+1]=ec.v,Bb+=2;for(H=0,U=ma.length;H<U;H++)if(hb=ma[H],N=Ca[hb],cc=Uc[hb],void 0!==cc)for(ka=0;4>ka;ka++)ec=
+cc[ka],pc[Bb]=ec.u,pc[Bb+1]=ec.v,Bb+=2;0<Bb&&(j.bindBuffer(j.ARRAY_BUFFER,da.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,pc,$a))}if(dd&&Vc&&$c){for(H=0,U=la.length;H<U;H++)if(hb=la[H],N=Ca[hb],dc=Vc[hb],void 0!==dc)for(ka=0;3>ka;ka++)fc=dc[ka],qc[Cb]=fc.u,qc[Cb+1]=fc.v,Cb+=2;for(H=0,U=ma.length;H<U;H++)if(hb=ma[H],N=Ca[hb],dc=Vc[hb],void 0!==dc)for(ka=0;4>ka;ka++)fc=dc[ka],qc[Cb]=fc.u,qc[Cb+1]=fc.v,Cb+=2;0<Cb&&(j.bindBuffer(j.ARRAY_BUFFER,da.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,qc,$a))}if(pd){for(H=
+0,U=la.length;H<U;H++)N=Ca[la[H]],yb[db]=ya,yb[db+1]=ya+1,yb[db+2]=ya+2,db+=3,Ya[Qa]=ya,Ya[Qa+1]=ya+1,Ya[Qa+2]=ya,Ya[Qa+3]=ya+2,Ya[Qa+4]=ya+1,Ya[Qa+5]=ya+2,Qa+=6,ya+=3;for(H=0,U=ma.length;H<U;H++)N=Ca[ma[H]],yb[db]=ya,yb[db+1]=ya+1,yb[db+2]=ya+3,yb[db+3]=ya+1,yb[db+4]=ya+2,yb[db+5]=ya+3,db+=6,Ya[Qa]=ya,Ya[Qa+1]=ya+1,Ya[Qa+2]=ya,Ya[Qa+3]=ya+3,Ya[Qa+4]=ya+1,Ya[Qa+5]=ya+2,Ya[Qa+6]=ya+2,Ya[Qa+7]=ya+3,Qa+=8,ya+=4;j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,da.__webglFaceBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,
+yb,$a);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,da.__webglLineBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,Ya,$a)}if(Tc)for(ka=0,bd=Tc.length;ka<bd;ka++)if(v=Tc[ka],v.__original.needsUpdate){z=0;if(1===v.size)if(void 0===v.boundTo||"vertices"===v.boundTo){for(H=0,U=la.length;H<U;H++)N=Ca[la[H]],v.array[z]=v.value[N.a],v.array[z+1]=v.value[N.b],v.array[z+2]=v.value[N.c],z+=3;for(H=0,U=ma.length;H<U;H++)N=Ca[ma[H]],v.array[z]=v.value[N.a],v.array[z+1]=v.value[N.b],v.array[z+2]=v.value[N.c],v.array[z+3]=v.value[N.d],
+z+=4}else{if("faces"===v.boundTo){for(H=0,U=la.length;H<U;H++)Xa=v.value[la[H]],v.array[z]=Xa,v.array[z+1]=Xa,v.array[z+2]=Xa,z+=3;for(H=0,U=ma.length;H<U;H++)Xa=v.value[ma[H]],v.array[z]=Xa,v.array[z+1]=Xa,v.array[z+2]=Xa,v.array[z+3]=Xa,z+=4}}else if(2===v.size)if(void 0===v.boundTo||"vertices"===v.boundTo){for(H=0,U=la.length;H<U;H++)N=Ca[la[H]],V=v.value[N.a],W=v.value[N.b],X=v.value[N.c],v.array[z]=V.x,v.array[z+1]=V.y,v.array[z+2]=W.x,v.array[z+3]=W.y,v.array[z+4]=X.x,v.array[z+5]=X.y,z+=6;
+for(H=0,U=ma.length;H<U;H++)N=Ca[ma[H]],V=v.value[N.a],W=v.value[N.b],X=v.value[N.c],na=v.value[N.d],v.array[z]=V.x,v.array[z+1]=V.y,v.array[z+2]=W.x,v.array[z+3]=W.y,v.array[z+4]=X.x,v.array[z+5]=X.y,v.array[z+6]=na.x,v.array[z+7]=na.y,z+=8}else{if("faces"===v.boundTo){for(H=0,U=la.length;H<U;H++)X=W=V=Xa=v.value[la[H]],v.array[z]=V.x,v.array[z+1]=V.y,v.array[z+2]=W.x,v.array[z+3]=W.y,v.array[z+4]=X.x,v.array[z+5]=X.y,z+=6;for(H=0,U=ma.length;H<U;H++)na=X=W=V=Xa=v.value[ma[H]],v.array[z]=V.x,v.array[z+
+1]=V.y,v.array[z+2]=W.x,v.array[z+3]=W.y,v.array[z+4]=X.x,v.array[z+5]=X.y,v.array[z+6]=na.x,v.array[z+7]=na.y,z+=8}}else if(3===v.size){var ea;ea="c"===v.type?["r","g","b"]:["x","y","z"];if(void 0===v.boundTo||"vertices"===v.boundTo){for(H=0,U=la.length;H<U;H++)N=Ca[la[H]],V=v.value[N.a],W=v.value[N.b],X=v.value[N.c],v.array[z]=V[ea[0]],v.array[z+1]=V[ea[1]],v.array[z+2]=V[ea[2]],v.array[z+3]=W[ea[0]],v.array[z+4]=W[ea[1]],v.array[z+5]=W[ea[2]],v.array[z+6]=X[ea[0]],v.array[z+7]=X[ea[1]],v.array[z+
+8]=X[ea[2]],z+=9;for(H=0,U=ma.length;H<U;H++)N=Ca[ma[H]],V=v.value[N.a],W=v.value[N.b],X=v.value[N.c],na=v.value[N.d],v.array[z]=V[ea[0]],v.array[z+1]=V[ea[1]],v.array[z+2]=V[ea[2]],v.array[z+3]=W[ea[0]],v.array[z+4]=W[ea[1]],v.array[z+5]=W[ea[2]],v.array[z+6]=X[ea[0]],v.array[z+7]=X[ea[1]],v.array[z+8]=X[ea[2]],v.array[z+9]=na[ea[0]],v.array[z+10]=na[ea[1]],v.array[z+11]=na[ea[2]],z+=12}else if("faces"===v.boundTo){for(H=0,U=la.length;H<U;H++)X=W=V=Xa=v.value[la[H]],v.array[z]=V[ea[0]],v.array[z+
+1]=V[ea[1]],v.array[z+2]=V[ea[2]],v.array[z+3]=W[ea[0]],v.array[z+4]=W[ea[1]],v.array[z+5]=W[ea[2]],v.array[z+6]=X[ea[0]],v.array[z+7]=X[ea[1]],v.array[z+8]=X[ea[2]],z+=9;for(H=0,U=ma.length;H<U;H++)na=X=W=V=Xa=v.value[ma[H]],v.array[z]=V[ea[0]],v.array[z+1]=V[ea[1]],v.array[z+2]=V[ea[2]],v.array[z+3]=W[ea[0]],v.array[z+4]=W[ea[1]],v.array[z+5]=W[ea[2]],v.array[z+6]=X[ea[0]],v.array[z+7]=X[ea[1]],v.array[z+8]=X[ea[2]],v.array[z+9]=na[ea[0]],v.array[z+10]=na[ea[1]],v.array[z+11]=na[ea[2]],z+=12}}else if(4===
+v.size)if(void 0===v.boundTo||"vertices"===v.boundTo){for(H=0,U=la.length;H<U;H++)N=Ca[la[H]],V=v.value[N.a],W=v.value[N.b],X=v.value[N.c],v.array[z]=V.x,v.array[z+1]=V.y,v.array[z+2]=V.z,v.array[z+3]=V.w,v.array[z+4]=W.x,v.array[z+5]=W.y,v.array[z+6]=W.z,v.array[z+7]=W.w,v.array[z+8]=X.x,v.array[z+9]=X.y,v.array[z+10]=X.z,v.array[z+11]=X.w,z+=12;for(H=0,U=ma.length;H<U;H++)N=Ca[ma[H]],V=v.value[N.a],W=v.value[N.b],X=v.value[N.c],na=v.value[N.d],v.array[z]=V.x,v.array[z+1]=V.y,v.array[z+2]=V.z,v.array[z+
+3]=V.w,v.array[z+4]=W.x,v.array[z+5]=W.y,v.array[z+6]=W.z,v.array[z+7]=W.w,v.array[z+8]=X.x,v.array[z+9]=X.y,v.array[z+10]=X.z,v.array[z+11]=X.w,v.array[z+12]=na.x,v.array[z+13]=na.y,v.array[z+14]=na.z,v.array[z+15]=na.w,z+=16}else if("faces"===v.boundTo){for(H=0,U=la.length;H<U;H++)X=W=V=Xa=v.value[la[H]],v.array[z]=V.x,v.array[z+1]=V.y,v.array[z+2]=V.z,v.array[z+3]=V.w,v.array[z+4]=W.x,v.array[z+5]=W.y,v.array[z+6]=W.z,v.array[z+7]=W.w,v.array[z+8]=X.x,v.array[z+9]=X.y,v.array[z+10]=X.z,v.array[z+
+11]=X.w,z+=12;for(H=0,U=ma.length;H<U;H++)na=X=W=V=Xa=v.value[ma[H]],v.array[z]=V.x,v.array[z+1]=V.y,v.array[z+2]=V.z,v.array[z+3]=V.w,v.array[z+4]=W.x,v.array[z+5]=W.y,v.array[z+6]=W.z,v.array[z+7]=W.w,v.array[z+8]=X.x,v.array[z+9]=X.y,v.array[z+10]=X.z,v.array[z+11]=X.w,v.array[z+12]=na.x,v.array[z+13]=na.y,v.array[z+14]=na.z,v.array[z+15]=na.w,z+=16}j.bindBuffer(j.ARRAY_BUFFER,v.buffer);j.bufferData(j.ARRAY_BUFFER,v.array,$a)}od&&(delete da.__inittedArrays,delete da.__colorArray,delete da.__normalArray,
+delete da.__tangentArray,delete da.__uvArray,delete da.__uv2Array,delete da.__faceArray,delete da.__vertexArray,delete da.__lineArray,delete da.__skinVertexAArray,delete da.__skinVertexBArray,delete da.__skinIndexArray,delete da.__skinWeightArray)}}ia.__dirtyVertices=!1;ia.__dirtyMorphTargets=!1;ia.__dirtyElements=!1;ia.__dirtyUvs=!1;ia.__dirtyNormals=!1;ia.__dirtyColors=!1;ia.__dirtyTangents=!1;Ua.attributes&&o(Ua)}else if(jb instanceof THREE.Ribbon){if(ia.__dirtyVertices||ia.__dirtyColors){var Qb=
+ia,ed=j.DYNAMIC_DRAW,rc=void 0,sc=void 0,Dc=void 0,Rb=void 0,Ec=void 0,fd=Qb.vertices,gd=Qb.colors,ud=fd.length,vd=gd.length,Fc=Qb.__vertexArray,Gc=Qb.__colorArray,wd=Qb.__dirtyColors;if(Qb.__dirtyVertices){for(rc=0;rc<ud;rc++)Dc=fd[rc].position,Rb=3*rc,Fc[Rb]=Dc.x,Fc[Rb+1]=Dc.y,Fc[Rb+2]=Dc.z;j.bindBuffer(j.ARRAY_BUFFER,Qb.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Fc,ed)}if(wd){for(sc=0;sc<vd;sc++)Ec=gd[sc],Rb=3*sc,Gc[Rb]=Ec.r,Gc[Rb+1]=Ec.g,Gc[Rb+2]=Ec.b;j.bindBuffer(j.ARRAY_BUFFER,Qb.__webglColorBuffer);
+j.bufferData(j.ARRAY_BUFFER,Gc,ed)}}ia.__dirtyVertices=!1;ia.__dirtyColors=!1}else if(jb instanceof THREE.Line){Ua=c(jb,kc);ac=Ua.attributes&&p(Ua);if(ia.__dirtyVertices||ia.__dirtyColors||ac){var Db=ia,Wc=j.DYNAMIC_DRAW,tc=void 0,uc=void 0,Hc=void 0,wa=void 0,Ic=void 0,hd=Db.vertices,id=Db.colors,xd=hd.length,yd=id.length,Jc=Db.__vertexArray,Kc=Db.__colorArray,zd=Db.__dirtyColors,Xc=Db.__webglCustomAttributesList,Lc=void 0,jd=void 0,Ma=void 0,gc=void 0,Va=void 0,pa=void 0;if(Db.__dirtyVertices){for(tc=
+0;tc<xd;tc++)Hc=hd[tc].position,wa=3*tc,Jc[wa]=Hc.x,Jc[wa+1]=Hc.y,Jc[wa+2]=Hc.z;j.bindBuffer(j.ARRAY_BUFFER,Db.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Jc,Wc)}if(zd){for(uc=0;uc<yd;uc++)Ic=id[uc],wa=3*uc,Kc[wa]=Ic.r,Kc[wa+1]=Ic.g,Kc[wa+2]=Ic.b;j.bindBuffer(j.ARRAY_BUFFER,Db.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,Kc,Wc)}if(Xc)for(Lc=0,jd=Xc.length;Lc<jd;Lc++)if(pa=Xc[Lc],pa.needsUpdate&&(void 0===pa.boundTo||"vertices"===pa.boundTo)){wa=0;gc=pa.value.length;if(1===pa.size)for(Ma=0;Ma<
+gc;Ma++)pa.array[Ma]=pa.value[Ma];else if(2===pa.size)for(Ma=0;Ma<gc;Ma++)Va=pa.value[Ma],pa.array[wa]=Va.x,pa.array[wa+1]=Va.y,wa+=2;else if(3===pa.size)if("c"===pa.type)for(Ma=0;Ma<gc;Ma++)Va=pa.value[Ma],pa.array[wa]=Va.r,pa.array[wa+1]=Va.g,pa.array[wa+2]=Va.b,wa+=3;else for(Ma=0;Ma<gc;Ma++)Va=pa.value[Ma],pa.array[wa]=Va.x,pa.array[wa+1]=Va.y,pa.array[wa+2]=Va.z,wa+=3;else if(4===pa.size)for(Ma=0;Ma<gc;Ma++)Va=pa.value[Ma],pa.array[wa]=Va.x,pa.array[wa+1]=Va.y,pa.array[wa+2]=Va.z,pa.array[wa+
+3]=Va.w,wa+=4;j.bindBuffer(j.ARRAY_BUFFER,pa.buffer);j.bufferData(j.ARRAY_BUFFER,pa.array,Wc)}}ia.__dirtyVertices=!1;ia.__dirtyColors=!1;Ua.attributes&&o(Ua)}else if(jb instanceof THREE.ParticleSystem)Ua=c(jb,kc),ac=Ua.attributes&&p(Ua),(ia.__dirtyVertices||ia.__dirtyColors||jb.sortParticles||ac)&&f(ia,j.DYNAMIC_DRAW,jb),ia.__dirtyVertices=!1,ia.__dirtyColors=!1,Ua.attributes&&o(Ua)}};this.initMaterial=function(a,b,c,d){var e,f,g,h,i;a instanceof THREE.MeshDepthMaterial?i="depth":a instanceof THREE.MeshNormalMaterial?
+i="normal":a instanceof THREE.MeshBasicMaterial?i="basic":a instanceof THREE.MeshLambertMaterial?i="lambert":a instanceof THREE.MeshPhongMaterial?i="phong":a instanceof THREE.LineBasicMaterial?i="basic":a instanceof THREE.ParticleBasicMaterial&&(i="particle_basic");if(i){var k=THREE.ShaderLib[i];a.uniforms=THREE.UniformsUtils.clone(k.uniforms);a.vertexShader=k.vertexShader;a.fragmentShader=k.fragmentShader}var l,m;f=k=0;for(l=0,m=b.length;l<m;l++)e=b[l],e instanceof THREE.SpotLight&&!e.onlyShadow&&
+f++,e instanceof THREE.DirectionalLight&&f++,e instanceof THREE.PointLight&&k++;k+f<=M?l=f:(l=Math.ceil(M*f/(k+f)),k=M-l);e=l;f=k;var o=0;for(k=0,l=b.length;k<l;k++)m=b[k],m instanceof THREE.SpotLight&&m.castShadow&&o++;var p=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)p=d.bones.length;var n;a:{l=a.fragmentShader;m=a.vertexShader;var k=a.uniforms,b=a.attributes,c={map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,
+skinning:a.skinning,morphTargets:a.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:e,maxPointLights:f,maxBones:p,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:o,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround},q,d=[];i?d.push(i):(d.push(l),d.push(m));for(q in c)d.push(q),d.push(c[q]);i=d.join();for(q=0,d=Q.length;q<d;q++)if(Q[q].code===
+i){n=Q[q].program;break a}q=j.createProgram();d=[0<Za?"#define VERTEX_TEXTURES":"",E.gammaInput?"#define GAMMA_INPUT":"",E.gammaOutput?"#define GAMMA_OUTPUT":"",E.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#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.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",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");
+e=["precision "+B+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",E.gammaInput?"#define GAMMA_INPUT":"",E.gammaOutput?"#define GAMMA_OUTPUT":"",E.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",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.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",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");j.attachShader(q,t("fragment",
+e+l));j.attachShader(q,t("vertex",d+m));j.linkProgram(q);j.getProgramParameter(q,j.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+j.getProgramParameter(q,j.VALIDATE_STATUS)+", gl error ["+j.getError()+"]");q.uniforms={};q.attributes={};var r,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,cameraInverseMatrix,boneGlobalMatrices,morphTargetInfluences".split(",");for(r in k)d.push(r);r=d;for(d=0,k=r.length;d<k;d++)l=r[d],q.uniforms[l]=
+j.getUniformLocation(q,l);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,skinWeight".split(",");for(r=0;r<c.maxMorphTargets;r++)d.push("morphTarget"+r);for(n in b)d.push(n);n=d;for(r=0,b=n.length;r<b;r++)c=n[r],q.attributes[c]=j.getAttribLocation(q,c);q.id=Q.length;Q.push({program:q,code:i});E.info.memory.programs=Q.length;n=q}a.program=n;n=a.program.attributes;0<=n.position&&j.enableVertexAttribArray(n.position);0<=n.color&&j.enableVertexAttribArray(n.color);0<=n.normal&&
+j.enableVertexAttribArray(n.normal);0<=n.tangent&&j.enableVertexAttribArray(n.tangent);a.skinning&&0<=n.skinVertexA&&0<=n.skinVertexB&&0<=n.skinIndex&&0<=n.skinWeight&&(j.enableVertexAttribArray(n.skinVertexA),j.enableVertexAttribArray(n.skinVertexB),j.enableVertexAttribArray(n.skinIndex),j.enableVertexAttribArray(n.skinWeight));if(a.attributes)for(h in a.attributes)void 0!==n[h]&&0<=n[h]&&j.enableVertexAttribArray(n[h]);if(a.morphTargets)for(h=a.numSupportedMorphTargets=0;h<this.maxMorphTargets;h++)r=
+"morphTarget"+h,0<=n[r]&&(j.enableVertexAttribArray(n[r]),a.numSupportedMorphTargets++);a.uniformsList=[];for(g in a.uniforms)a.uniformsList.push([a.uniforms[g],g])};this.setFaceCulling=function(a,b){a?(!b||"ccw"===b?j.frontFace(j.CCW):j.frontFace(j.CW),"back"===a?j.cullFace(j.BACK):"front"===a?j.cullFace(j.FRONT):j.cullFace(j.FRONT_AND_BACK),j.enable(j.CULL_FACE)):j.disable(j.CULL_FACE)};this.setObjectFaces=function(a){if($!==a.doubleSided)a.doubleSided?j.disable(j.CULL_FACE):j.enable(j.CULL_FACE),
+$=a.doubleSided;if(Z!==a.flipSided)a.flipSided?j.frontFace(j.CW):j.frontFace(j.CCW),Z=a.flipSided};this.setDepthTest=function(a){fa!==a&&(a?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST),fa=a)};this.setDepthWrite=function(a){S!==a&&(j.depthMask(a),S=a)};this.setBlending=function(a){if(a!==ga){switch(a){case THREE.AdditiveBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.SRC_ALPHA,j.ONE);break;case THREE.SubtractiveBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.ONE_MINUS_SRC_COLOR);break;
+case THREE.MultiplyBlending:j.blendEquation(j.FUNC_ADD);j.blendFunc(j.ZERO,j.SRC_COLOR);break;default:j.blendEquationSeparate(j.FUNC_ADD,j.FUNC_ADD),j.blendFuncSeparate(j.SRC_ALPHA,j.ONE_MINUS_SRC_ALPHA,j.ONE,j.ONE_MINUS_SRC_ALPHA)}ga=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=j.createTexture(),E.info.memory.textures++;j.activeTexture(j.TEXTURE0+b);j.bindTexture(j.TEXTURE_2D,a.__webglTexture);var c=a.image,d=0===(c.width&c.width-1)&&0===
+(c.height&c.height-1),e=A(a.format),f=A(a.type);u(j.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?j.texImage2D(j.TEXTURE_2D,0,e,c.width,c.height,0,e,f,c.data):j.texImage2D(j.TEXTURE_2D,0,e,e,f,a.image);a.generateMipmaps&&d&&j.generateMipmap(j.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else j.activeTexture(j.TEXTURE0+b),j.bindTexture(j.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(void 0===
+a.depthBuffer)a.depthBuffer=!0;if(void 0===a.stencilBuffer)a.stencilBuffer=!0;a.__webglTexture=j.createTexture();var c=0===(a.width&a.width-1)&&0===(a.height&a.height-1),d=A(a.format),e=A(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];j.bindTexture(j.TEXTURE_CUBE_MAP,a.__webglTexture);u(j.TEXTURE_CUBE_MAP,a,c);for(c=0;6>c;c++){a.__webglFramebuffer[c]=j.createFramebuffer();a.__webglRenderbuffer[c]=j.createRenderbuffer();j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,
+0,d,e,null);var f=a,g=j.TEXTURE_CUBE_MAP_POSITIVE_X+c;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer[c]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,g,f.__webglTexture,0);x(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=j.createFramebuffer(),a.__webglRenderbuffer=j.createRenderbuffer(),j.bindTexture(j.TEXTURE_2D,a.__webglTexture),u(j.TEXTURE_2D,a,c),j.texImage2D(j.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=j.TEXTURE_2D,j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer),
+j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,d,a.__webglTexture,0),x(a.__webglRenderbuffer,a);b?j.bindTexture(j.TEXTURE_CUBE_MAP,null):j.bindTexture(j.TEXTURE_2D,null);j.bindRenderbuffer(j.RENDERBUFFER,null);j.bindFramebuffer(j.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,d=a.width,a=a.height,c=e=0):(b=null,d=za,a=qa,e=Na,c=ja);b!==R&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(e,c,d,a),R=b);Ga=d;Ea=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;
+this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
 THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=void 0!==c.wrapS?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==c.wrapT?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==c.magFilter?c.magFilter:THREE.LinearFilter;this.minFilter=void 0!==c.minFilter?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=void 0!==c.format?c.format:THREE.RGBAFormat;this.type=void 0!==c.type?c.type:
 THREE.UnsignedByteType;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.generateMipmaps=!0};
 THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0};
@@ -353,19 +354,19 @@ THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};
 THREE.ColorUtils={adjustHSV:function(a,b,c,d){var e=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,e);e.h=THREE.Math.clamp(e.h+b,0,1);e.s=THREE.Math.clamp(e.s+c,0,1);e.v=THREE.Math.clamp(e.v+d,0,1);a.setHSV(e.h,e.s,e.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,e=a.b,f=Math.max(Math.max(c,d),e),g=Math.min(Math.min(c,d),e);if(g===f)g=c=0;else{var h=f-g,g=h/f,c=(c===f?(d-e)/h:d===f?2+(e-c)/h:4+(c-d)/h)/6;0>c&&(c+=1);1<c&&(c-=1)}void 0===b&&(b={h:0,s:0,v:0});b.h=c;b.s=g;b.v=f;return b}};
 THREE.ColorUtils.__hsv={h:0,s:0,v:0};
-THREE.GeometryUtils={merge:function(a,b){for(var c,d,e=a.vertices.length,f=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,h=f.vertices,i=a.faces,l=f.faces,k=a.faceVertexUvs[0],p=f.faceVertexUvs[0],n={},o=0;o<a.materials.length;o++)n[a.materials[o].id]=o;if(b instanceof THREE.Mesh)b.matrixAutoUpdate&&b.updateMatrix(),c=b.matrix,d=new THREE.Matrix4,d.extractRotation(c,b.scale);for(var o=0,q=h.length;o<q;o++){var m=new THREE.Vertex(h[o].position.clone());c&&c.multiplyVector3(m.position);g.push(m)}for(o=
-0,q=l.length;o<q;o++){var g=l[o],r,s,t=g.vertexNormals,u=g.vertexColors;g instanceof THREE.Face3?r=new THREE.Face3(g.a+e,g.b+e,g.c+e):g instanceof THREE.Face4&&(r=new THREE.Face4(g.a+e,g.b+e,g.c+e,g.d+e));r.normal.copy(g.normal);d&&d.multiplyVector3(r.normal);h=0;for(m=t.length;h<m;h++)s=t[h].clone(),d&&d.multiplyVector3(s),r.vertexNormals.push(s);r.color.copy(g.color);h=0;for(m=u.length;h<m;h++)s=u[h],r.vertexColors.push(s.clone());if(void 0!==g.materialIndex){h=f.materials[g.materialIndex];m=h.id;
-u=n[m];if(void 0===u)u=a.materials.length,n[m]=u,a.materials.push(h);r.materialIndex=u}r.centroid.copy(g.centroid);c&&c.multiplyVector3(r.centroid);i.push(r)}for(o=0,q=p.length;o<q;o++){c=p[o];d=[];h=0;for(m=c.length;h<m;h++)d.push(new THREE.UV(c[h].u,c[h].v));k.push(d)}},clone:function(a){var b=new THREE.Geometry,c,d=a.vertices,e=a.faces,f=a.faceVertexUvs[0];if(a.materials)b.materials=a.materials.slice();for(a=0,c=d.length;a<c;a++){var g=new THREE.Vertex(d[a].position.clone());b.vertices.push(g)}for(a=
+THREE.GeometryUtils={merge:function(a,b){for(var c,d,e=a.vertices.length,f=b instanceof THREE.Mesh?b.geometry:b,g=a.vertices,h=f.vertices,i=a.faces,l=f.faces,k=a.faceVertexUvs[0],p=f.faceVertexUvs[0],o={},n=0;n<a.materials.length;n++)o[a.materials[n].id]=n;if(b instanceof THREE.Mesh)b.matrixAutoUpdate&&b.updateMatrix(),c=b.matrix,d=new THREE.Matrix4,d.extractRotation(c,b.scale);for(var n=0,q=h.length;n<q;n++){var m=new THREE.Vertex(h[n].position.clone());c&&c.multiplyVector3(m.position);g.push(m)}for(n=
+0,q=l.length;n<q;n++){var g=l[n],r,s,t=g.vertexNormals,u=g.vertexColors;g instanceof THREE.Face3?r=new THREE.Face3(g.a+e,g.b+e,g.c+e):g instanceof THREE.Face4&&(r=new THREE.Face4(g.a+e,g.b+e,g.c+e,g.d+e));r.normal.copy(g.normal);d&&d.multiplyVector3(r.normal);h=0;for(m=t.length;h<m;h++)s=t[h].clone(),d&&d.multiplyVector3(s),r.vertexNormals.push(s);r.color.copy(g.color);h=0;for(m=u.length;h<m;h++)s=u[h],r.vertexColors.push(s.clone());if(void 0!==g.materialIndex){h=f.materials[g.materialIndex];m=h.id;
+u=o[m];if(void 0===u)u=a.materials.length,o[m]=u,a.materials.push(h);r.materialIndex=u}r.centroid.copy(g.centroid);c&&c.multiplyVector3(r.centroid);i.push(r)}for(n=0,q=p.length;n<q;n++){c=p[n];d=[];h=0;for(m=c.length;h<m;h++)d.push(new THREE.UV(c[h].u,c[h].v));k.push(d)}},clone:function(a){var b=new THREE.Geometry,c,d=a.vertices,e=a.faces,f=a.faceVertexUvs[0];if(a.materials)b.materials=a.materials.slice();for(a=0,c=d.length;a<c;a++){var g=new THREE.Vertex(d[a].position.clone());b.vertices.push(g)}for(a=
 0,c=e.length;a<c;a++){var h=e[a],i,l,k=h.vertexNormals,p=h.vertexColors;h instanceof THREE.Face3?i=new THREE.Face3(h.a,h.b,h.c):h instanceof THREE.Face4&&(i=new THREE.Face4(h.a,h.b,h.c,h.d));i.normal.copy(h.normal);d=0;for(g=k.length;d<g;d++)l=k[d],i.vertexNormals.push(l.clone());i.color.copy(h.color);d=0;for(g=p.length;d<g;d++)l=p[d],i.vertexColors.push(l.clone());i.materialIndex=h.materialIndex;i.centroid.copy(h.centroid);b.faces.push(i)}for(a=0,c=f.length;a<c;a++){e=f[a];i=[];d=0;for(g=e.length;d<
 g;d++)i.push(new THREE.UV(e[d].u,e[d].v));b.faceVertexUvs[0].push(i)}return b},randomPointInTriangle:function(a,b,c){var d,e,f,g=new THREE.Vector3,h=THREE.GeometryUtils.__v1;d=THREE.GeometryUtils.random();e=THREE.GeometryUtils.random();1<d+e&&(d=1-d,e=1-e);f=1-d-e;g.copy(a);g.multiplyScalar(d);h.copy(b);h.multiplyScalar(e);g.addSelf(h);h.copy(c);h.multiplyScalar(f);g.addSelf(h);return g},randomPointInFace:function(a,b,c){var d,e,f;if(a instanceof THREE.Face3)return d=b.vertices[a.a].position,e=b.vertices[a.b].position,
 f=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,e,f);if(a instanceof THREE.Face4){d=b.vertices[a.a].position;e=b.vertices[a.b].position;f=b.vertices[a.c].position;var b=b.vertices[a.d].position,g;c?a._area1&&a._area2?(c=a._area1,g=a._area2):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b),a._area1=c,a._area2=g):(c=THREE.GeometryUtils.triangleArea(d,e,b),g=THREE.GeometryUtils.triangleArea(e,f,b));return THREE.GeometryUtils.random()*(c+g)<c?
-THREE.GeometryUtils.randomPointInTriangle(d,e,b):THREE.GeometryUtils.randomPointInTriangle(e,f,b)}},randomPointsInGeometry:function(a,b){function c(a){function b(c,d){if(d<c)return c;var e=c+Math.floor((d-c)/2);return l[e]>a?b(c,e-1):l[e]<a?b(e+1,d):e}return b(0,l.length-1)}var d,e,f=a.faces,g=a.vertices,h=f.length,i=0,l=[],k,p,n,o;for(e=0;e<h;e++){d=f[e];if(d instanceof THREE.Face3)k=g[d.a].position,p=g[d.b].position,n=g[d.c].position,d._area=THREE.GeometryUtils.triangleArea(k,p,n);else if(d instanceof
-THREE.Face4)k=g[d.a].position,p=g[d.b].position,n=g[d.c].position,o=g[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(k,p,o),d._area2=THREE.GeometryUtils.triangleArea(p,n,o),d._area=d._area1+d._area2;i+=d._area;l[e]=i}d=[];for(e=0;e<b;e++)g=THREE.GeometryUtils.random()*i,g=c(g),d[e]=THREE.GeometryUtils.randomPointInFace(f[g],a,!0);return d},triangleArea:function(a,b,c){var d,e=THREE.GeometryUtils.__v1;e.sub(a,b);d=e.length();e.sub(a,c);a=e.length();e.sub(b,c);c=e.length();b=0.5*(d+a+c);return Math.sqrt(b*
+THREE.GeometryUtils.randomPointInTriangle(d,e,b):THREE.GeometryUtils.randomPointInTriangle(e,f,b)}},randomPointsInGeometry:function(a,b){function c(a){function b(c,d){if(d<c)return c;var e=c+Math.floor((d-c)/2);return l[e]>a?b(c,e-1):l[e]<a?b(e+1,d):e}return b(0,l.length-1)}var d,e,f=a.faces,g=a.vertices,h=f.length,i=0,l=[],k,p,o,n;for(e=0;e<h;e++){d=f[e];if(d instanceof THREE.Face3)k=g[d.a].position,p=g[d.b].position,o=g[d.c].position,d._area=THREE.GeometryUtils.triangleArea(k,p,o);else if(d instanceof
+THREE.Face4)k=g[d.a].position,p=g[d.b].position,o=g[d.c].position,n=g[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(k,p,n),d._area2=THREE.GeometryUtils.triangleArea(p,o,n),d._area=d._area1+d._area2;i+=d._area;l[e]=i}d=[];for(e=0;e<b;e++)g=THREE.GeometryUtils.random()*i,g=c(g),d[e]=THREE.GeometryUtils.randomPointInFace(f[g],a,!0);return d},triangleArea:function(a,b,c){var d,e=THREE.GeometryUtils.__v1;e.sub(a,b);d=e.length();e.sub(a,c);a=e.length();e.sub(b,c);c=e.length();b=0.5*(d+a+c);return Math.sqrt(b*
 (b-d)*(b-a)*(b-c))},center:function(a){a.computeBoundingBox();var b=a.boundingBox,c=new THREE.Vector3;c.add(b.min,b.max);c.multiplyScalar(-0.5);a.applyMatrix((new THREE.Matrix4).setTranslation(c.x,c.y,c.z));a.computeBoundingBox();return c},normalizeUVs:function(a){for(var a=a.faceVertexUvs[0],b=0,c=a.length;b<c;b++)for(var d=a[b],e=0,f=d.length;e<f;e++)1!==d[e].u&&(d[e].u-=Math.floor(d[e].u)),1!==d[e].v&&(d[e].v-=Math.floor(d[e].v))}};THREE.GeometryUtils.random=THREE.Math.random16;
 THREE.GeometryUtils.__v1=new THREE.Vector3;
 THREE.ImageUtils={crossOrigin:"",loadTexture:function(a,b,c){var d=new Image,e=new THREE.Texture(d,b);d.onload=function(){e.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return e},loadTextureCube:function(a,b,c){var d,e=[],f=new THREE.Texture(e,b);e.loadCount=0;for(b=0,d=a.length;b<d;++b)e[b]=new Image,e[b].onload=function(){e.loadCount+=1;if(6===e.loadCount)f.needsUpdate=!0;c&&c(this)},e[b].crossOrigin="",e[b].src=a[b];return f},getNormalMap:function(a,b){var c=function(a){var b=
-Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,i=g.createImageData(d,e),l=i.data,k=0;k<d;k++)for(var p=1;p<e;p++){var n=0>p-1?e-1:p-1,o=(p+1)%e,q=0>k-1?d-1:k-1,m=(k+1)%d,r=[],s=[0,0,h[4*(p*d+k)]/255*b];r.push([-1,0,h[4*(p*d+q)]/255*b]);r.push([-1,-1,h[4*(n*d+q)]/255*b]);r.push([0,-1,h[4*(n*d+k)]/255*b]);r.push([1,
--1,h[4*(n*d+m)]/255*b]);r.push([1,0,h[4*(p*d+m)]/255*b]);r.push([1,1,h[4*(o*d+m)]/255*b]);r.push([0,1,h[4*(o*d+k)]/255*b]);r.push([-1,1,h[4*(o*d+q)]/255*b]);n=[];q=r.length;for(o=0;o<q;o++){var m=r[o],t=r[(o+1)%q],m=[m[0]-s[0],m[1]-s[1],m[2]-s[2]],t=[t[0]-s[0],t[1]-s[1],t[2]-s[2]];n.push(c([m[1]*t[2]-m[2]*t[1],m[2]*t[0]-m[0]*t[2],m[0]*t[1]-m[1]*t[0]]))}r=[0,0,0];for(o=0;o<n.length;o++)r[0]+=n[o][0],r[1]+=n[o][1],r[2]+=n[o][2];r[0]/=n.length;r[1]/=n.length;r[2]/=n.length;s=4*(p*d+k);l[s]=255*((r[0]+
+Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,i=g.createImageData(d,e),l=i.data,k=0;k<d;k++)for(var p=1;p<e;p++){var o=0>p-1?e-1:p-1,n=(p+1)%e,q=0>k-1?d-1:k-1,m=(k+1)%d,r=[],s=[0,0,h[4*(p*d+k)]/255*b];r.push([-1,0,h[4*(p*d+q)]/255*b]);r.push([-1,-1,h[4*(o*d+q)]/255*b]);r.push([0,-1,h[4*(o*d+k)]/255*b]);r.push([1,
+-1,h[4*(o*d+m)]/255*b]);r.push([1,0,h[4*(p*d+m)]/255*b]);r.push([1,1,h[4*(n*d+m)]/255*b]);r.push([0,1,h[4*(n*d+k)]/255*b]);r.push([-1,1,h[4*(n*d+q)]/255*b]);o=[];q=r.length;for(n=0;n<q;n++){var m=r[n],t=r[(n+1)%q],m=[m[0]-s[0],m[1]-s[1],m[2]-s[2]],t=[t[0]-s[0],t[1]-s[1],t[2]-s[2]];o.push(c([m[1]*t[2]-m[2]*t[1],m[2]*t[0]-m[0]*t[2],m[0]*t[1]-m[1]*t[0]]))}r=[0,0,0];for(n=0;n<o.length;n++)r[0]+=o[n][0],r[1]+=o[n][1],r[2]+=o[n][2];r[0]/=o.length;r[1]/=o.length;r[2]/=o.length;s=4*(p*d+k);l[s]=255*((r[0]+
 1)/2)|0;l[s+1]=255*(r[1]+0.5)|0;l[s+2]=255*r[2]|0;l[s+3]=255}g.putImageData(i,0,0);return f}};
 THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=b})},traverseHierarchy:function(a,b){var c,d,e=a.children.length;for(d=0;d<e;d++)c=a.children[d],b(c),THREE.SceneUtils.traverseHierarchy(c,b)},createMultiMaterialObject:function(a,b){var c,d=b.length,e=new THREE.Object3D;for(c=0;c<d;c++){var f=new THREE.Mesh(a,b[c]);e.add(f)}return e},cloneObject:function(a){var b;a instanceof THREE.MorphAnimMesh?(b=new THREE.MorphAnimMesh(a.geometry,a.material),
 b.duration=a.duration,b.mirroredLoop=a.mirroredLoop,b.time=a.time,b.lastKeyframe=a.lastKeyframe,b.currentKeyframe=a.currentKeyframe,b.direction=a.direction,b.directionBackwards=a.directionBackwards):a instanceof THREE.SkinnedMesh?b=new THREE.SkinnedMesh(a.geometry,a.material):a instanceof THREE.Mesh?b=new THREE.Mesh(a.geometry,a.material):a instanceof THREE.Line?b=new THREE.Line(a.geometry,a.material,a.type):a instanceof THREE.Ribbon?b=new THREE.Ribbon(a.geometry,a.material):a instanceof THREE.ParticleSystem?
@@ -412,9 +413,9 @@ THREE.Path.prototype.quadraticCurveTo=function(a,b,c,d){var e=Array.prototype.sl
 THREE.Path.prototype.bezierCurveTo=function(a,b,c,d,e,f){var g=Array.prototype.slice.call(arguments),h=this.actions[this.actions.length-1].args;this.curves.push(new THREE.CubicBezierCurve(new THREE.Vector2(h[h.length-2],h[h.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d),new THREE.Vector2(e,f)));this.actions.push({action:THREE.PathActions.BEZIER_CURVE_TO,args:g})};
 THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])];Array.prototype.push.apply(c,a);this.curves.push(new THREE.SplineCurve(c));this.actions.push({action:THREE.PathActions.CSPLINE_THRU,args:b})};
 THREE.Path.prototype.arc=function(a,b,c,d,e,f){var g=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(a,b,c,d,e,f));this.actions.push({action:THREE.PathActions.ARC,args:g})};THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var b=[],c=0;c<a;c++)b.push(this.getPoint(c/a));return b};
-THREE.Path.prototype.getPoints=function(a,b){var a=a||12,c=[],d,e,f,g,h,i,l,k,p,n,o,q,m;for(d=0,e=this.actions.length;d<e;d++)switch(f=this.actions[d],g=f.action,f=f.args,g){case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(f[0],f[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=f[2];i=f[3];p=f[0];n=f[1];0<c.length?(g=c[c.length-1],o=g.x,q=g.y):(g=this.actions[d-1].args,o=g[g.length-2],q=g[g.length-1]);for(g=1;g<=a;g++)m=g/a,f=THREE.Shape.Utils.b2(m,o,p,h),m=THREE.Shape.Utils.b2(m,q,n,
-i),c.push(new THREE.Vector2(f,m));break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];p=f[0];n=f[1];l=f[2];k=f[3];0<c.length?(g=c[c.length-1],o=g.x,q=g.y):(g=this.actions[d-1].args,o=g[g.length-2],q=g[g.length-1]);for(g=1;g<=a;g++)m=g/a,f=THREE.Shape.Utils.b3(m,o,p,l,h),m=THREE.Shape.Utils.b3(m,q,n,k,i),c.push(new THREE.Vector2(f,m));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];m=a*f[0].length;g=g.concat(f[0]);f=new THREE.SplineCurve(g);
-for(g=1;g<=m;g++)c.push(f.getPointAt(g/m));break;case THREE.PathActions.ARC:g=this.actions[d-1].args;h=f[0];i=f[1];l=f[2];p=f[3];m=f[4];n=!!f[5];k=g[g.length-2];o=g[g.length-1];0==g.length&&(k=o=0);q=m-p;var r=2*a;for(g=1;g<=r;g++)m=g/r,n||(m=1-m),m=p+m*q,f=k+h+l*Math.cos(m),m=o+i+l*Math.sin(m),c.push(new THREE.Vector2(f,m))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)};
+THREE.Path.prototype.getPoints=function(a,b){var a=a||12,c=[],d,e,f,g,h,i,l,k,p,o,n,q,m;for(d=0,e=this.actions.length;d<e;d++)switch(f=this.actions[d],g=f.action,f=f.args,g){case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(f[0],f[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=f[2];i=f[3];p=f[0];o=f[1];0<c.length?(g=c[c.length-1],n=g.x,q=g.y):(g=this.actions[d-1].args,n=g[g.length-2],q=g[g.length-1]);for(g=1;g<=a;g++)m=g/a,f=THREE.Shape.Utils.b2(m,n,p,h),m=THREE.Shape.Utils.b2(m,q,o,
+i),c.push(new THREE.Vector2(f,m));break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];p=f[0];o=f[1];l=f[2];k=f[3];0<c.length?(g=c[c.length-1],n=g.x,q=g.y):(g=this.actions[d-1].args,n=g[g.length-2],q=g[g.length-1]);for(g=1;g<=a;g++)m=g/a,f=THREE.Shape.Utils.b3(m,n,p,l,h),m=THREE.Shape.Utils.b3(m,q,o,k,i),c.push(new THREE.Vector2(f,m));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];m=a*f[0].length;g=g.concat(f[0]);f=new THREE.SplineCurve(g);
+for(g=1;g<=m;g++)c.push(f.getPointAt(g/m));break;case THREE.PathActions.ARC:g=this.actions[d-1].args;h=f[0];i=f[1];l=f[2];p=f[3];m=f[4];o=!!f[5];k=g[g.length-2];n=g[g.length-1];0==g.length&&(k=n=0);q=m-p;var r=2*a;for(g=1;g<=r;g++)m=g/r,o||(m=1-m),m=p+m*q,f=k+h+l*Math.cos(m),m=n+i+l*Math.sin(m),c.push(new THREE.Vector2(f,m))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)};
 THREE.Path.prototype.nltransform=function(a,b,c,d,e,f){var g=this.getPoints(),h,i,l,k,p;for(h=0,i=g.length;h<i;h++)l=g[h],k=l.x,p=l.y,l.x=a*k+b*p+c,l.y=d*p+e*k+f;return g};
 THREE.Path.prototype.debug=function(a){var b=this.getBoundingBox();a||(a=document.createElement("canvas"),a.setAttribute("width",b.maxX+100),a.setAttribute("height",b.maxY+100),document.body.appendChild(a));b=a.getContext("2d");b.fillStyle="white";b.fillRect(0,0,a.width,a.height);b.strokeStyle="black";b.beginPath();var c,d,e;for(a=0,c=this.actions.length;a<c;a++)d=this.actions[a],e=d.args,d=d.action,d!=THREE.PathActions.CSPLINE_THRU&&b[d].apply(b,e);b.stroke();b.closePath();b.strokeStyle="red";d=
 this.getPoints();for(a=0,c=d.length;a<c;a++)e=d[a],b.beginPath(),b.arc(e.x,e.y,1.5,0,2*Math.PI,!1),b.stroke(),b.closePath()};
@@ -422,8 +423,8 @@ THREE.Path.prototype.toShapes=function(){var a,b,c,d,e=[],f=new THREE.Path;for(a
 d.curves):g.holes.push(d);f.push(g)}else{g=new THREE.Shape;for(a=0,b=e.length;a<b;a++)d=e[a],THREE.Shape.Utils.isClockWise(d.getPoints())?(g.actions=d.actions,g.curves=d.curves,f.push(g),g=new THREE.Shape):g.holes.push(d)}return f};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(a){return new THREE.ExtrudeGeometry(this,a)};
 THREE.Shape.prototype.getPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedPoints(a,this.bends);return d};THREE.Shape.prototype.getSpacedPointsHoles=function(a){var b,c=this.holes.length,d=[];for(b=0;b<c;b++)d[b]=this.holes[b].getTransformedSpacedPoints(a,this.bends);return d};THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getTransformedPoints(a),holes:this.getPointsHoles(a)}};
 THREE.Shape.prototype.extractAllSpacedPoints=function(a){return{shape:this.getTransformedSpacedPoints(a),holes:this.getSpacedPointsHoles(a)}};
-THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),e,f,g,h,i,l,k,p,n,o,q=[];for(i=0;i<b.length;i++){l=b[i];Array.prototype.push.apply(d,l);f=Number.POSITIVE_INFINITY;for(e=0;e<l.length;e++){n=l[e];o=[];for(p=0;p<c.length;p++)k=c[p],k=n.distanceToSquared(k),o.push(k),k<f&&(f=k,g=e,h=p)}e=0<=h-1?h-1:c.length-1;f=0<=g-1?g-1:l.length-1;var m=[l[g],c[h],c[e]];p=THREE.FontUtils.Triangulate.area(m);var r=[l[g],l[f],c[h]];n=THREE.FontUtils.Triangulate.area(r);o=h;k=g;h+=1;g+=-1;0>
-h&&(h+=c.length);h%=c.length;0>g&&(g+=l.length);g%=l.length;e=0<=h-1?h-1:c.length-1;f=0<=g-1?g-1:l.length-1;m=[l[g],c[h],c[e]];m=THREE.FontUtils.Triangulate.area(m);r=[l[g],l[f],c[h]];r=THREE.FontUtils.Triangulate.area(r);p+n>m+r&&(h=o,g=k,0>h&&(h+=c.length),h%=c.length,0>g&&(g+=l.length),g%=l.length,e=0<=h-1?h-1:c.length-1,f=0<=g-1?g-1:l.length-1);p=c.slice(0,h);n=c.slice(h);o=l.slice(g);k=l.slice(0,g);f=[l[g],l[f],c[h]];q.push([l[g],c[h],c[e]]);q.push(f);c=p.concat(o).concat(k).concat(n)}return{shape:c,
+THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),e,f,g,h,i,l,k,p,o,n,q=[];for(i=0;i<b.length;i++){l=b[i];Array.prototype.push.apply(d,l);f=Number.POSITIVE_INFINITY;for(e=0;e<l.length;e++){o=l[e];n=[];for(p=0;p<c.length;p++)k=c[p],k=o.distanceToSquared(k),n.push(k),k<f&&(f=k,g=e,h=p)}e=0<=h-1?h-1:c.length-1;f=0<=g-1?g-1:l.length-1;var m=[l[g],c[h],c[e]];p=THREE.FontUtils.Triangulate.area(m);var r=[l[g],l[f],c[h]];o=THREE.FontUtils.Triangulate.area(r);n=h;k=g;h+=1;g+=-1;0>
+h&&(h+=c.length);h%=c.length;0>g&&(g+=l.length);g%=l.length;e=0<=h-1?h-1:c.length-1;f=0<=g-1?g-1:l.length-1;m=[l[g],c[h],c[e]];m=THREE.FontUtils.Triangulate.area(m);r=[l[g],l[f],c[h]];r=THREE.FontUtils.Triangulate.area(r);p+o>m+r&&(h=n,g=k,0>h&&(h+=c.length),h%=c.length,0>g&&(g+=l.length),g%=l.length,e=0<=h-1?h-1:c.length-1,f=0<=g-1?g-1:l.length-1);p=c.slice(0,h);o=c.slice(h);n=l.slice(g);k=l.slice(0,g);f=[l[g],l[f],c[h]];q.push([l[g],c[h],c[e]]);q.push(f);c=p.concat(n).concat(k).concat(o)}return{shape:c,
 isolatedPts:q,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,e=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),f,g,h,i,l={};for(f=0,g=d.length;f<g;f++)i=d[f].x+":"+d[f].y,void 0!==l[i]&&console.log("Duplicate point",i),l[i]=f;for(f=0,g=c.length;f<g;f++){h=c[f];for(d=0;3>d;d++)i=h[d].x+":"+h[d].y,i=l[i],void 0!==i&&(h[d]=i)}for(f=0,g=e.length;f<g;f++){h=e[f];for(d=0;3>d;d++)i=h[d].x+":"+h[d].y,i=l[i],void 0!==i&&(h[d]=i)}return c.concat(e)},
 isClockWise:function(a){return 0>THREE.FontUtils.Triangulate.area(a)},b2p0:function(a,b){var c=1-a;return c*c*b},b2p1:function(a,b){return 2*(1-a)*a*b},b2p2:function(a,b){return a*a*b},b2:function(a,b,c,d){return this.b2p0(a,b)+this.b2p1(a,c)+this.b2p2(a,d)},b3p0:function(a,b){var c=1-a;return c*c*c*b},b3p1:function(a,b){var c=1-a;return 3*c*c*a*b},b3p2:function(a,b){return 3*(1-a)*a*a*b},b3p3:function(a,b){return a*a*a*b},b3:function(a,b,c,d,e){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+
 this.b3p3(a,e)}};THREE.TextPath=function(a,b){THREE.Path.call(this);this.parameters=b||{};this.set(a)};THREE.TextPath.prototype.set=function(a,b){b=b||this.parameters;this.text=a;var c=void 0!==b.curveSegments?b.curveSegments:4,d=void 0!==b.font?b.font:"helvetiker",e=void 0!==b.weight?b.weight:"normal",f=void 0!==b.style?b.style:"normal";THREE.FontUtils.size=void 0!==b.size?b.size:100;THREE.FontUtils.divisions=c;THREE.FontUtils.face=d;THREE.FontUtils.weight=e;THREE.FontUtils.style=f};
@@ -437,11 +438,11 @@ THREE.Animation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=
 THREE.Bone?e.skinMatrix:e.matrix;var f=e.animationCache.prevKey;e=e.animationCache.nextKey;f.pos=this.data.hierarchy[c].keys[0];f.rot=this.data.hierarchy[c].keys[0];f.scl=this.data.hierarchy[c].keys[0];e.pos=this.getNextKeyWith("pos",c,1);e.rot=this.getNextKeyWith("rot",c,1);e.scl=this.getNextKeyWith("scl",c,1)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};
 THREE.Animation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
 THREE.Animation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++)if(void 0!==this.hierarchy[a].animationCache)this.hierarchy[a]instanceof THREE.Bone?this.hierarchy[a].skinMatrix=this.hierarchy[a].animationCache.originalMatrix:this.hierarchy[a].matrix=this.hierarchy[a].animationCache.originalMatrix,delete this.hierarchy[a].animationCache};
-THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,d,e,f,g,h,i,l,k=this.data.JIT.hierarchy,p,n;n=this.currentTime+=a*this.timeScale;p=this.currentTime%=this.data.length;l=parseInt(Math.min(p*this.data.fps,this.data.length*this.data.fps),10);for(var o=0,q=this.hierarchy.length;o<q;o++)if(a=this.hierarchy[o],i=a.animationCache,this.JITCompile&&void 0!==k[o][l])a instanceof THREE.Bone?(a.skinMatrix=k[o][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!1):(a.matrix=
-k[o][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var m=0;3>m;m++){c=b[m];g=i.prevKey[c];h=i.nextKey[c];if(h.time<=n){if(p<n)if(this.loop){g=this.data.hierarchy[o].keys[0];for(h=this.getNextKeyWith(c,o,1);h.time<p;)g=h,h=this.getNextKeyWith(c,o,h.index+1)}else{this.stop();return}else{do g=h,h=this.getNextKeyWith(c,o,h.index+1);while(h.time<p)}i.prevKey[c]=
-g;i.nextKey[c]=h}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(p-g.time)/(h.time-g.time);e=g[c];f=h[c];if(0>d||1<d)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+o),d=0>d?0:1;if("pos"===c)if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
-this.getPrevKeyWith("pos",o,g.index-1).pos,this.points[1]=e,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",o,h.index+1).pos,d=0.33*d+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,1.01*d),this.target.set(d[0],d[1],d[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if("rot"===
-c)THREE.Quaternion.slerp(e,f,a.quaternion,d);else if("scl"===c)c=a.scale,c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d}}if(this.JITCompile&&void 0===k[0][l]){this.hierarchy[0].updateMatrixWorld(!0);for(o=0;o<this.hierarchy.length;o++)k[o][l]=this.hierarchy[o]instanceof THREE.Bone?this.hierarchy[o].skinMatrix.clone():this.hierarchy[o].matrix.clone()}}};
+THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,d,e,f,g,h,i,l,k=this.data.JIT.hierarchy,p,o;o=this.currentTime+=a*this.timeScale;p=this.currentTime%=this.data.length;l=parseInt(Math.min(p*this.data.fps,this.data.length*this.data.fps),10);for(var n=0,q=this.hierarchy.length;n<q;n++)if(a=this.hierarchy[n],i=a.animationCache,this.JITCompile&&void 0!==k[n][l])a instanceof THREE.Bone?(a.skinMatrix=k[n][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!1):(a.matrix=
+k[n][l],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!0);else{if(this.JITCompile)a instanceof THREE.Bone?a.skinMatrix=a.animationCache.originalMatrix:a.matrix=a.animationCache.originalMatrix;for(var m=0;3>m;m++){c=b[m];g=i.prevKey[c];h=i.nextKey[c];if(h.time<=o){if(p<o)if(this.loop){g=this.data.hierarchy[n].keys[0];for(h=this.getNextKeyWith(c,n,1);h.time<p;)g=h,h=this.getNextKeyWith(c,n,h.index+1)}else{this.stop();return}else{do g=h,h=this.getNextKeyWith(c,n,h.index+1);while(h.time<p)}i.prevKey[c]=
+g;i.nextKey[c]=h}a.matrixAutoUpdate=!0;a.matrixWorldNeedsUpdate=!0;d=(p-g.time)/(h.time-g.time);e=g[c];f=h[c];if(0>d||1<d)console.log("THREE.Animation.update: Warning! Scale out of bounds:"+d+" on bone "+n),d=0>d?0:1;if("pos"===c)if(c=a.position,this.interpolationType===THREE.AnimationHandler.LINEAR)c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d;else{if(this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)if(this.points[0]=
+this.getPrevKeyWith("pos",n,g.index-1).pos,this.points[1]=e,this.points[2]=f,this.points[3]=this.getNextKeyWith("pos",n,h.index+1).pos,d=0.33*d+0.33,e=this.interpolateCatmullRom(this.points,d),c.x=e[0],c.y=e[1],c.z=e[2],this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD)d=this.interpolateCatmullRom(this.points,1.01*d),this.target.set(d[0],d[1],d[2]),this.target.subSelf(c),this.target.y=0,this.target.normalize(),d=Math.atan2(this.target.x,this.target.z),a.rotation.set(0,d,0)}else if("rot"===
+c)THREE.Quaternion.slerp(e,f,a.quaternion,d);else if("scl"===c)c=a.scale,c.x=e[0]+(f[0]-e[0])*d,c.y=e[1]+(f[1]-e[1])*d,c.z=e[2]+(f[2]-e[2])*d}}if(this.JITCompile&&void 0===k[0][l]){this.hierarchy[0].updateMatrixWorld(!0);for(n=0;n<this.hierarchy.length;n++)k[n][l]=this.hierarchy[n]instanceof THREE.Bone?this.hierarchy[n].skinMatrix.clone():this.hierarchy[n].matrix.clone()}}};
 THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],e,f,g,h,i,l;e=(a.length-1)*b;f=Math.floor(e);e-=f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>a.length-2?f:f+1;c[3]=f>a.length-3?f:f+2;f=a[c[0]];h=a[c[1]];i=a[c[2]];l=a[c[3]];c=e*e;g=e*c;d[0]=this.interpolate(f[0],h[0],i[0],l[0],e,c,g);d[1]=this.interpolate(f[1],h[1],i[1],l[1],e,c,g);d[2]=this.interpolate(f[2],h[2],i[2],l[2],e,c,g);return d};
 THREE.Animation.prototype.interpolate=function(a,b,c,d,e,f,g){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c<d.length-1?c:d.length-1:c%d.length;c<d.length;c++)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?0<c?c:0:0<=c?c:c+d.length;0<=c;c--)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[d.length-1]};
@@ -452,7 +453,7 @@ e.matrix;e=this.data.hierarchy[c].keys;if(e.length)f.animationCache.prevKey=e[0]
 THREE.KeyFrameAnimation.prototype.stop=function(){this.isPaused=this.isPlaying=!1;THREE.AnimationHandler.removeFromUpdate(this);for(var a=0;a<this.hierarchy.length;a++){var b=this.hierarchy[a];if(void 0!==b.animationCache){var c=b.animationCache.originalMatrix;b instanceof THREE.Bone?(c.copy(b.skinMatrix),b.skinMatrix=c):(c.copy(b.matrix),b.matrix=c);delete b.animationCache}}};
 THREE.KeyFrameAnimation.prototype.update=function(a){if(this.isPlaying){var b,c,d,e,f=this.data.JIT.hierarchy,g,h,i;h=this.currentTime+=a*this.timeScale;g=this.currentTime%=this.data.length;if(g<this.startTimeMs)g=this.currentTime=this.startTimeMs+g;e=parseInt(Math.min(g*this.data.fps,this.data.length*this.data.fps),10);if((i=g<h)&&!this.loop){for(var a=0,l=this.hierarchy.length;a<l;a++){var k=this.data.hierarchy[a].keys,f=this.data.hierarchy[a].sids;d=k.length-1;e=this.hierarchy[a];if(k.length){for(k=
 0;k<f.length;k++)g=f[k],(h=this.getPrevKeyWith(g,a,d))&&h.apply(g);this.data.hierarchy[a].node.updateMatrix();e.matrixWorldNeedsUpdate=!0}}this.stop()}else if(!(g<this.startTime)){a=0;for(l=this.hierarchy.length;a<l;a++){d=this.hierarchy[a];b=this.data.hierarchy[a];var k=b.keys,p=b.animationCache;if(this.JITCompile&&void 0!==f[a][e])d instanceof THREE.Bone?(d.skinMatrix=f[a][e],d.matrixWorldNeedsUpdate=!1):(d.matrix=f[a][e],d.matrixWorldNeedsUpdate=!0);else if(k.length){if(this.JITCompile&&p)d instanceof
-THREE.Bone?d.skinMatrix=p.originalMatrix:d.matrix=p.originalMatrix;b=p.prevKey;c=p.nextKey;if(b&&c){if(c.time<=h){if(i&&this.loop){b=k[0];for(c=k[1];c.time<g;)b=c,c=k[b.index+1]}else if(!i)for(var n=k.length-1;c.time<g&&c.index!==n;)b=c,c=k[b.index+1];p.prevKey=b;p.nextKey=c}b.interpolate(c,g)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=!0}}if(this.JITCompile&&void 0===f[0][e]){this.hierarchy[0].updateMatrixWorld(!0);for(a=0;a<this.hierarchy.length;a++)f[a][e]=this.hierarchy[a]instanceof
+THREE.Bone?d.skinMatrix=p.originalMatrix:d.matrix=p.originalMatrix;b=p.prevKey;c=p.nextKey;if(b&&c){if(c.time<=h){if(i&&this.loop){b=k[0];for(c=k[1];c.time<g;)b=c,c=k[b.index+1]}else if(!i)for(var o=k.length-1;c.time<g&&c.index!==o;)b=c,c=k[b.index+1];p.prevKey=b;p.nextKey=c}b.interpolate(c,g)}this.data.hierarchy[a].node.updateMatrix();d.matrixWorldNeedsUpdate=!0}}if(this.JITCompile&&void 0===f[0][e]){this.hierarchy[0].updateMatrixWorld(!0);for(a=0;a<this.hierarchy.length;a++)f[a][e]=this.hierarchy[a]instanceof
 THREE.Bone?this.hierarchy[a].skinMatrix.clone():this.hierarchy[a].matrix.clone()}}}};THREE.KeyFrameAnimation.prototype.getNextKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c%=b.length;c<b.length;c++)if(b[c].hasTarget(a))return b[c];return b[0]};THREE.KeyFrameAnimation.prototype.getPrevKeyWith=function(a,b,c){b=this.data.hierarchy[b].keys;for(c=0<=c?c:c+b.length;0<=c;c--)if(b[c].hasTarget(a))return b[c];return b[b.length-1]};
 THREE.CubeCamera=function(a,b,c,d){this.heightOffset=c;this.position=new THREE.Vector3(0,c,0);this.cameraPX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNX=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNY=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraNZ=new THREE.PerspectiveCamera(90,1,a,b);this.cameraPX.position=this.position;this.cameraNX.position=this.position;this.cameraPY.position=
 this.position;this.cameraNY.position=this.position;this.cameraPZ.position=this.position;this.cameraNZ.position=this.position;this.cameraPX.up.set(0,-1,0);this.cameraNX.up.set(0,-1,0);this.cameraPY.up.set(0,0,1);this.cameraNY.up.set(0,0,-1);this.cameraPZ.up.set(0,-1,0);this.cameraNZ.up.set(0,-1,0);this.targetPX=new THREE.Vector3(0,0,0);this.targetNX=new THREE.Vector3(0,0,0);this.targetPY=new THREE.Vector3(0,0,0);this.targetNY=new THREE.Vector3(0,0,0);this.targetPZ=new THREE.Vector3(0,0,0);this.targetNZ=
@@ -480,7 +481,7 @@ new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050
 b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=function(a){this.domElement===
 document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}),
 c=new THREE.CubeGeometry(10,10,20),g=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(g,b);a.position.set(0,10,0);this.animation=e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=e(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a=
-this.debugPath,b=this.spline,g=f(b,10),c=f(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),g=new THREE.Line(g,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));g.scale.set(1,1,1);a.add(g);c.scale.set(1,1,1);a.add(c);for(var g=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),o=0;o<b.points.length;o++)c=new THREE.Mesh(g,h),c.position.copy(b.points[o]),a.add(c)}this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),
+this.debugPath,b=this.spline,g=f(b,10),c=f(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),g=new THREE.Line(g,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));g.scale.set(1,1,1);a.add(g);c.scale.set(1,1,1);a.add(c);for(var g=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),n=0;n<b.points.length;n++)c=new THREE.Mesh(g,h),c.position.copy(b.points[n]),a.add(c)}this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),
 !1)}};THREE.PathControlsIdCounter=0;
 THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=void 0!==b?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
 0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if("function"==typeof this[a.type])this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=
@@ -491,12 +492,12 @@ THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,argu
 this.object.matrixWorldNeedsUpdate=!0};this.updateMovementVector=function(){var a=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=-a+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.RollControls=function(a,b){this.object=a;this.domElement=void 0!==b?b:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var c=new THREE.Vector3,d=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Matrix4,g=!1,h=1,i=0,l=0,k=0,p=0,n=0,o=window.innerWidth/2,q=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var b=a*this.lookSpeed;
-this.rotateHorizontally(b*p);this.rotateVertically(b*n)}b=a*this.movementSpeed;this.object.translateZ(-b*(0<i||this.autoForward&&!(0>i)?1:i));this.object.translateX(b*l);this.object.translateY(b*k);g&&(this.roll+=this.rollSpeed*a*h);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();e.copy(this.forward);d.set(0,1,0);c.cross(d,
+THREE.RollControls=function(a,b){this.object=a;this.domElement=void 0!==b?b:document;this.mouseLook=!0;this.autoForward=!1;this.rollSpeed=this.movementSpeed=this.lookSpeed=1;this.constrainVertical=[-0.9,0.9];this.object.matrixAutoUpdate=!1;this.forward=new THREE.Vector3(0,0,1);this.roll=0;var c=new THREE.Vector3,d=new THREE.Vector3,e=new THREE.Vector3,f=new THREE.Matrix4,g=!1,h=1,i=0,l=0,k=0,p=0,o=0,n=window.innerWidth/2,q=window.innerHeight/2;this.update=function(a){if(this.mouseLook){var b=a*this.lookSpeed;
+this.rotateHorizontally(b*p);this.rotateVertically(b*o)}b=a*this.movementSpeed;this.object.translateZ(-b*(0<i||this.autoForward&&!(0>i)?1:i));this.object.translateX(b*l);this.object.translateY(b*k);g&&(this.roll+=this.rollSpeed*a*h);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();e.copy(this.forward);d.set(0,1,0);c.cross(d,
 e).normalize();d.cross(e,c).normalize();this.object.matrix.n11=c.x;this.object.matrix.n12=d.x;this.object.matrix.n13=e.x;this.object.matrix.n21=c.y;this.object.matrix.n22=d.y;this.object.matrix.n23=e.y;this.object.matrix.n31=c.z;this.object.matrix.n32=d.z;this.object.matrix.n33=e.z;f.identity();f.n11=Math.cos(this.roll);f.n12=-Math.sin(this.roll);f.n21=Math.sin(this.roll);f.n22=Math.cos(this.roll);this.object.matrix.multiplySelf(f);this.object.matrixWorldNeedsUpdate=!0;this.object.matrix.n14=this.object.position.x;
 this.object.matrix.n24=this.object.position.y;this.object.matrix.n34=this.object.position.z};this.translateX=function(a){this.object.position.x+=this.object.matrix.n11*a;this.object.position.y+=this.object.matrix.n21*a;this.object.position.z+=this.object.matrix.n31*a};this.translateY=function(a){this.object.position.x+=this.object.matrix.n12*a;this.object.position.y+=this.object.matrix.n22*a;this.object.position.z+=this.object.matrix.n32*a};this.translateZ=function(a){this.object.position.x-=this.object.matrix.n13*
 a;this.object.position.y-=this.object.matrix.n23*a;this.object.position.z-=this.object.matrix.n33*a};this.rotateHorizontally=function(a){c.set(this.object.matrix.n11,this.object.matrix.n21,this.object.matrix.n31);c.multiplyScalar(a);this.forward.subSelf(c);this.forward.normalize()};this.rotateVertically=function(a){d.set(this.object.matrix.n12,this.object.matrix.n22,this.object.matrix.n32);d.multiplyScalar(a);this.forward.addSelf(d);this.forward.normalize()};this.domElement.addEventListener("contextmenu",
-function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){p=(a.clientX-o)/window.innerWidth;n=(a.clientY-q)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=1;break;case 2:i=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=0;break;case 2:i=0}},!1);this.domElement.addEventListener("keydown",
+function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){p=(a.clientX-n)/window.innerWidth;o=(a.clientY-q)/window.innerHeight},!1);this.domElement.addEventListener("mousedown",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=1;break;case 2:i=-1}},!1);this.domElement.addEventListener("mouseup",function(a){a.preventDefault();a.stopPropagation();switch(a.button){case 0:i=0;break;case 2:i=0}},!1);this.domElement.addEventListener("keydown",
 function(a){switch(a.keyCode){case 38:case 87:i=1;break;case 37:case 65:l=-1;break;case 40:case 83:i=-1;break;case 39:case 68:l=1;break;case 81:g=!0;h=1;break;case 69:g=!0;h=-1;break;case 82:k=1;break;case 70:k=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:i=0;break;case 37:case 65:l=0;break;case 40:case 83:i=0;break;case 39:case 68:l=0;break;case 81:g=!1;break;case 69:g=!1;break;case 82:k=0;break;case 70:k=0}},!1)};
 THREE.TrackballControls=function(a,b){var c=this;this.object=a;this.domElement=void 0!==b?b:document;this.enabled=!0;this.screen={width:window.innerWidth,height:window.innerHeight,offsetLeft:0,offsetTop:0};this.radius=(this.screen.width+this.screen.height)/4;this.rotateSpeed=1;this.zoomSpeed=1.2;this.panSpeed=0.3;this.staticMoving=this.noPan=this.noZoom=this.noRotate=!1;this.dynamicDampingFactor=0.2;this.minDistance=0;this.maxDistance=Infinity;this.keys=[65,83,68];this.target=new THREE.Vector3(0,
 0,0);var d=!1,e=-1,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector2,l=new THREE.Vector2,k=new THREE.Vector2,p=new THREE.Vector2;this.handleEvent=function(a){if("function"==typeof this[a.type])this[a.type](a)};this.getMouseOnScreen=function(a,b){return new THREE.Vector2(0.5*((a-c.screen.offsetLeft)/c.radius),0.5*((b-c.screen.offsetTop)/c.radius))};this.getMouseProjectionOnBall=function(a,b){var d=new THREE.Vector3((a-0.5*c.screen.width-c.screen.offsetLeft)/c.radius,(0.5*
@@ -506,23 +507,23 @@ c.target.addSelf(b);c.staticMoving?k=p:k.addSelf(a.sub(p,k).multiplyScalar(c.dyn
 c.object.position.add(c.target,f);c.checkDistances();c.object.lookAt(c.target)};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",function(a){c.enabled&&(d&&(g=h=c.getMouseProjectionOnBall(a.clientX,a.clientY),i=l=c.getMouseOnScreen(a.clientX,a.clientY),k=p=c.getMouseOnScreen(a.clientX,a.clientY),d=!1),-1!==e&&(0===e&&!c.noRotate?h=c.getMouseProjectionOnBall(a.clientX,a.clientY):1===e&&!c.noZoom?l=c.getMouseOnScreen(a.clientX,
 a.clientY):2===e&&!c.noPan&&(p=c.getMouseOnScreen(a.clientX,a.clientY))))},!1);this.domElement.addEventListener("mousedown",function(a){if(c.enabled&&(a.preventDefault(),a.stopPropagation(),-1===e))e=a.button,0===e&&!c.noRotate?g=h=c.getMouseProjectionOnBall(a.clientX,a.clientY):1===e&&!c.noZoom?i=l=c.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(k=p=c.getMouseOnScreen(a.clientX,a.clientY))},!1);this.domElement.addEventListener("mouseup",function(a){c.enabled&&(a.preventDefault(),a.stopPropagation(),
 e=-1)},!1);window.addEventListener("keydown",function(a){c.enabled&&-1===e&&(a.keyCode===c.keys[0]&&!c.noRotate?e=0:a.keyCode===c.keys[1]&&!c.noZoom?e=1:a.keyCode===c.keys[2]&&!c.noPan&&(e=2),-1!==e&&(d=!0))},!1);window.addEventListener("keyup",function(){c.enabled&&-1!==e&&(e=-1)},!1)};
-THREE.CubeGeometry=function(a,b,c,d,e,f,g,h){function i(a,b,c,g,h,i,k,m){var n,p=d||1,o=e||1,q=h/2,r=i/2,j=l.vertices.length;if("x"===a&&"y"===b||"y"===a&&"x"===b)n="z";else if("x"===a&&"z"===b||"z"===a&&"x"===b)n="y",o=f||1;else if("z"===a&&"y"===b||"y"===a&&"z"===b)n="x",p=f||1;var s=p+1,t=o+1,u=h/p,I=i/o,O=new THREE.Vector3;O[n]=0<k?1:-1;for(h=0;h<t;h++)for(i=0;i<s;i++){var T=new THREE.Vector3;T[a]=(i*u-q)*c;T[b]=(h*I-r)*g;T[n]=k;l.vertices.push(new THREE.Vertex(T))}for(h=0;h<o;h++)for(i=0;i<p;i++)a=
-new THREE.Face4(i+s*h+j,i+s*(h+1)+j,i+1+s*(h+1)+j,i+1+s*h+j),a.normal.copy(O),a.vertexNormals.push(O.clone(),O.clone(),O.clone(),O.clone()),a.materialIndex=m,l.faces.push(a),l.faceVertexUvs[0].push([new THREE.UV(i/p,h/o),new THREE.UV(i/p,(h+1)/o),new THREE.UV((i+1)/p,(h+1)/o),new THREE.UV((i+1)/p,h/o)])}THREE.Geometry.call(this);var l=this,k=a/2,p=b/2,n=c/2,o,q,m,r,s,t;if(void 0!==g){if(g instanceof Array)this.materials=g;else{this.materials=[];for(o=0;6>o;o++)this.materials.push(g)}o=0;r=1;q=2;s=
-3;m=4;t=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(void 0!=h)for(var u in h)void 0!==this.sides[u]&&(this.sides[u]=h[u]);this.sides.px&&i("z","y",-1,-1,c,b,k,o);this.sides.nx&&i("z","y",1,-1,c,b,-k,r);this.sides.py&&i("x","z",1,1,a,c,p,q);this.sides.ny&&i("x","z",1,-1,a,c,-p,s);this.sides.pz&&i("x","y",1,-1,a,b,n,m);this.sides.nz&&i("x","y",-1,-1,a,b,-n,t);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=new THREE.Geometry;
+THREE.CubeGeometry=function(a,b,c,d,e,f,g,h){function i(a,b,c,g,h,i,k,m){var o,p=d||1,n=e||1,q=h/2,j=i/2,r=l.vertices.length;if("x"===a&&"y"===b||"y"===a&&"x"===b)o="z";else if("x"===a&&"z"===b||"z"===a&&"x"===b)o="y",n=f||1;else if("z"===a&&"y"===b||"y"===a&&"z"===b)o="x",p=f||1;var s=p+1,t=n+1,y=h/p,F=i/n,P=new THREE.Vector3;P[o]=0<k?1:-1;for(h=0;h<t;h++)for(i=0;i<s;i++){var u=new THREE.Vector3;u[a]=(i*y-q)*c;u[b]=(h*F-j)*g;u[o]=k;l.vertices.push(new THREE.Vertex(u))}for(h=0;h<n;h++)for(i=0;i<p;i++)a=
+new THREE.Face4(i+s*h+r,i+s*(h+1)+r,i+1+s*(h+1)+r,i+1+s*h+r),a.normal.copy(P),a.vertexNormals.push(P.clone(),P.clone(),P.clone(),P.clone()),a.materialIndex=m,l.faces.push(a),l.faceVertexUvs[0].push([new THREE.UV(i/p,h/n),new THREE.UV(i/p,(h+1)/n),new THREE.UV((i+1)/p,(h+1)/n),new THREE.UV((i+1)/p,h/n)])}THREE.Geometry.call(this);var l=this,k=a/2,p=b/2,o=c/2,n,q,m,r,s,t;if(void 0!==g){if(g instanceof Array)this.materials=g;else{this.materials=[];for(n=0;6>n;n++)this.materials.push(g)}n=0;r=1;q=2;s=
+3;m=4;t=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(void 0!=h)for(var u in h)void 0!==this.sides[u]&&(this.sides[u]=h[u]);this.sides.px&&i("z","y",-1,-1,c,b,k,n);this.sides.nx&&i("z","y",1,-1,c,b,-k,r);this.sides.py&&i("x","z",1,1,a,c,p,q);this.sides.ny&&i("x","z",1,-1,a,c,-p,s);this.sides.pz&&i("x","y",1,-1,a,b,o,m);this.sides.nz&&i("x","y",-1,-1,a,b,-o,t);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=new THREE.Geometry;
 THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
-THREE.CylinderGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);var a=void 0!==a?a:20,b=void 0!==b?b:20,c=void 0!==c?c:100,g=c/2,d=d||8,e=e||1,h,i,l=[],k=[];for(i=0;i<=e;i++){var p=[],n=[],o=i/e,q=o*(b-a)+a;for(h=0;h<=d;h++){var m=h/d,r=q*Math.sin(2*m*Math.PI),s=-o*c+g,t=q*Math.cos(2*m*Math.PI);this.vertices.push(new THREE.Vertex(new THREE.Vector3(r,s,t)));p.push(this.vertices.length-1);n.push(new THREE.UV(m,o))}l.push(p);k.push(n)}for(i=0;i<e;i++)for(h=0;h<d;h++){var c=l[i][h],p=l[i+1][h],
-n=l[i+1][h+1],o=l[i][h+1],q=this.vertices[c].position.clone().setY(0).normalize(),m=this.vertices[p].position.clone().setY(0).normalize(),r=this.vertices[n].position.clone().setY(0).normalize(),s=this.vertices[o].position.clone().setY(0).normalize(),t=k[i][h].clone(),u=k[i+1][h].clone(),x=k[i+1][h+1].clone(),v=k[i][h+1].clone();this.faces.push(new THREE.Face4(c,p,n,o,[q,m,r,s]));this.faceVertexUvs[0].push([t,u,x,v])}if(!f&&0<a){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,g,0)));for(h=
-0;h<d;h++)c=l[0][h],p=l[0][h+1],n=this.vertices.length-1,q=new THREE.Vector3(0,1,0),m=new THREE.Vector3(0,1,0),r=new THREE.Vector3(0,1,0),t=k[0][h].clone(),u=k[0][h+1].clone(),x=new THREE.UV(u.u,0),this.faces.push(new THREE.Face3(c,p,n,[q,m,r])),this.faceVertexUvs[0].push([t,u,x])}if(!f&&0<b){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-g,0)));for(h=0;h<d;h++)c=l[i][h+1],p=l[i][h],n=this.vertices.length-1,q=new THREE.Vector3(0,-1,0),m=new THREE.Vector3(0,-1,0),r=new THREE.Vector3(0,-1,
-0),t=k[i][h+1].clone(),u=k[i][h].clone(),x=new THREE.UV(u.u,1),this.faces.push(new THREE.Face3(c,p,n,[q,m,r])),this.faceVertexUvs[0].push([t,u,x])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
+THREE.CylinderGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);var a=void 0!==a?a:20,b=void 0!==b?b:20,c=void 0!==c?c:100,g=c/2,d=d||8,e=e||1,h,i,l=[],k=[];for(i=0;i<=e;i++){var p=[],o=[],n=i/e,q=n*(b-a)+a;for(h=0;h<=d;h++){var m=h/d,r=q*Math.sin(2*m*Math.PI),s=-n*c+g,t=q*Math.cos(2*m*Math.PI);this.vertices.push(new THREE.Vertex(new THREE.Vector3(r,s,t)));p.push(this.vertices.length-1);o.push(new THREE.UV(m,n))}l.push(p);k.push(o)}for(i=0;i<e;i++)for(h=0;h<d;h++){var c=l[i][h],p=l[i+1][h],
+o=l[i+1][h+1],n=l[i][h+1],q=this.vertices[c].position.clone().setY(0).normalize(),m=this.vertices[p].position.clone().setY(0).normalize(),r=this.vertices[o].position.clone().setY(0).normalize(),s=this.vertices[n].position.clone().setY(0).normalize(),t=k[i][h].clone(),u=k[i+1][h].clone(),x=k[i+1][h+1].clone(),w=k[i][h+1].clone();this.faces.push(new THREE.Face4(c,p,o,n,[q,m,r,s]));this.faceVertexUvs[0].push([t,u,x,w])}if(!f&&0<a){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,g,0)));for(h=
+0;h<d;h++)c=l[0][h],p=l[0][h+1],o=this.vertices.length-1,q=new THREE.Vector3(0,1,0),m=new THREE.Vector3(0,1,0),r=new THREE.Vector3(0,1,0),t=k[0][h].clone(),u=k[0][h+1].clone(),x=new THREE.UV(u.u,0),this.faces.push(new THREE.Face3(c,p,o,[q,m,r])),this.faceVertexUvs[0].push([t,u,x])}if(!f&&0<b){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-g,0)));for(h=0;h<d;h++)c=l[i][h+1],p=l[i][h],o=this.vertices.length-1,q=new THREE.Vector3(0,-1,0),m=new THREE.Vector3(0,-1,0),r=new THREE.Vector3(0,-1,
+0),t=k[i][h+1].clone(),u=k[i][h].clone(),x=new THREE.UV(u.u,1),this.faces.push(new THREE.Face3(c,p,o,[q,m,r])),this.faceVertexUvs[0].push([t,u,x])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
 THREE.ExtrudeGeometry=function(a,b){if("undefined"!==typeof a){THREE.Geometry.call(this);var a=a instanceof Array?a:[a],c,d,e=a.length;this.shapebb=a[e-1].getBoundingBox();for(d=0;d<e;d++)c=a[d],this.addShape(c,b);this.computeCentroids();this.computeFaceNormals()}};THREE.ExtrudeGeometry.prototype=new THREE.Geometry;THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;
-THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,g=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,i=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);g.set(e.y,-e.x);h.copy(a).addSelf(f);i.copy(a).addSelf(g);if(h.equals(i))return g.clone();
-h.copy(b).addSelf(f);i.copy(c).addSelf(g);f=d.dot(g);g=i.subSelf(h).dot(g);0===f&&(console.log("Either infinite or no solutions!"),0===g?console.log("Its finite solutions."):console.log("Too bad, no solutions."));g/=f;return 0>g?(b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=2*Math.PI),c=(b+a)/2,a=-Math.cos(c),c=-Math.sin(c),new THREE.Vector2(a,c)):d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(a){for(H=a.length;0<=--H;){y=H;I=H-1;0>I&&(I=a.length-1);for(var b=
-0,c=o+2*k,b=0;b<c;b++){var d=P*b,e=P*(b+1),f=ga+y+d,g=ga+y+e,j=f,d=ga+I+d,e=ga+I+e,l=g,j=j+F,d=d+F,e=e+F,l=l+F;C.faces.push(new THREE.Face4(j,d,e,l,null,null,x));void 0!==x&&(j=b/c,d=(b+1)/c,e=h+2*i,f=(C.vertices[f].position.z+i)/e,g=(C.vertices[g].position.z+i)/e,C.faceVertexUvs[0].push([new THREE.UV(f,j),new THREE.UV(g,j),new THREE.UV(g,d),new THREE.UV(f,d)]))}}}function f(a,b,c){C.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function g(a,b,c){a+=F;b+=F;c+=F;C.faces.push(new THREE.Face3(a,
-b,c,null,null,u));if(void 0!==u){var d=v.minX,e=v.minY,f=v.maxY,g=v.maxX,h=C.vertices[b].position.x-d,b=C.vertices[b].position.y-e,i=C.vertices[c].position.x-d,c=C.vertices[c].position.y-e;C.faceVertexUvs[0].push([new THREE.UV((C.vertices[a].position.x-d)/g,(C.vertices[a].position.y-e)/f),new THREE.UV(h/g,b/f),new THREE.UV(i/g,c/f)])}}var h=void 0!==b.amount?b.amount:100,i=void 0!==b.bevelThickness?b.bevelThickness:6,l=void 0!==b.bevelSize?b.bevelSize:i-2,k=void 0!==b.bevelSegments?b.bevelSegments:
-3,p=void 0!==b.bevelEnabled?b.bevelEnabled:!0,n=void 0!==b.curveSegments?b.curveSegments:12,o=void 0!==b.steps?b.steps:1,q=b.bendPath,m=b.extrudePath,r,s=!1,t=void 0!==b.useSpacedPoints?b.useSpacedPoints:!1,u=b.material,x=b.extrudeMaterial,v=this.shapebb;if(m)r=m.getPoints(n),o=r.length,s=!0,p=!1;p||(l=i=k=0);var A,D,E,C=this,F=this.vertices.length;q&&a.addWrapPath(q);n=t?a.extractAllSpacedPoints(n):a.extractAllPoints(n);q=n.shape;n=n.holes;if(m=!THREE.Shape.Utils.isClockWise(q)){q=q.reverse();for(D=
-0,E=n.length;D<E;D++)A=n[D],THREE.Shape.Utils.isClockWise(A)&&(n[D]=A.reverse());m=!1}m=THREE.Shape.Utils.triangulateShape(q,n);t=q;for(D=0,E=n.length;D<E;D++)A=n[D],q=q.concat(A);for(var K,L,R,N,P=q.length,B=m.length,j=[],H=0,V=t.length,y=V-1,I=H+1;H<V;H++,y++,I++)y===V&&(y=0),I===V&&(I=0),j[H]=d(t[H],t[y],t[I]);var O=[],T,aa=j.concat();for(D=0,E=n.length;D<E;D++){A=n[D];T=[];for(H=0,V=A.length,y=V-1,I=H+1;H<V;H++,y++,I++)y===V&&(y=0),I===V&&(I=0),T[H]=d(A[H],A[y],A[I]);O.push(T);aa=aa.concat(T)}for(K=
-0;K<k;K++){L=K/k;R=i*(1-L);L=l*Math.sin(L*Math.PI/2);for(H=0,V=t.length;H<V;H++)N=c(t[H],j[H],L),f(N.x,N.y,-R);for(D=0,E=n.length;D<E;D++){A=n[D];T=O[D];for(H=0,V=A.length;H<V;H++)N=c(A[H],T[H],L),f(N.x,N.y,-R)}}L=l;for(H=0;H<P;H++)N=p?c(q[H],aa[H],L):q[H],s?f(N.x,N.y+r[0].y,r[0].x):f(N.x,N.y,0);for(K=1;K<=o;K++)for(H=0;H<P;H++)N=p?c(q[H],aa[H],L):q[H],s?f(N.x,N.y+r[K-1].y,r[K-1].x):f(N.x,N.y,h/o*K);for(K=k-1;0<=K;K--){L=K/k;R=i*(1-L);L=l*Math.sin(L*Math.PI/2);for(H=0,V=t.length;H<V;H++)N=c(t[H],
-j[H],L),f(N.x,N.y,h+R);for(D=0,E=n.length;D<E;D++){A=n[D];T=O[D];for(H=0,V=A.length;H<V;H++)N=c(A[H],T[H],L),s?f(N.x,N.y+r[o-1].y,r[o-1].x+R):f(N.x,N.y,h+R)}}if(p){p=0*P;for(H=0;H<B;H++)l=m[H],g(l[2]+p,l[1]+p,l[0]+p);p=P*(o+2*k);for(H=0;H<B;H++)l=m[H],g(l[0]+p,l[1]+p,l[2]+p)}else{for(H=0;H<B;H++)l=m[H],g(l[2],l[1],l[0]);for(H=0;H<B;H++)l=m[H],g(l[0]+P*o,l[1]+P*o,l[2]+P*o)}var ga=0;e(t);ga+=t.length;for(D=0,E=n.length;D<E;D++)A=n[D],e(A),ga+=A.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;
+THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.log("die");return b.clone().multiplyScalar(c).addSelf(a)}function d(a,b,c){var d=THREE.ExtrudeGeometry.__v1,e=THREE.ExtrudeGeometry.__v2,f=THREE.ExtrudeGeometry.__v3,g=THREE.ExtrudeGeometry.__v4,h=THREE.ExtrudeGeometry.__v5,j=THREE.ExtrudeGeometry.__v6;d.set(a.x-b.x,a.y-b.y);e.set(a.x-c.x,a.y-c.y);d=d.normalize();e=e.normalize();f.set(-d.y,d.x);g.set(e.y,-e.x);h.copy(a).addSelf(f);j.copy(a).addSelf(g);if(h.equals(j))return g.clone();
+h.copy(b).addSelf(f);j.copy(c).addSelf(g);f=d.dot(g);g=j.subSelf(h).dot(g);0===f&&(console.log("Either infinite or no solutions!"),0===g?console.log("Its finite solutions."):console.log("Too bad, no solutions."));g/=f;return 0>g?(b=Math.atan2(b.y-a.y,b.x-a.x),a=Math.atan2(c.y-a.y,c.x-a.x),b>a&&(a+=2*Math.PI),c=(b+a)/2,a=-Math.cos(c),c=-Math.sin(c),new THREE.Vector2(a,c)):d.multiplyScalar(g).addSelf(h).subSelf(a).clone()}function e(a){for(I=a.length;0<=--I;){y=I;F=I-1;0>F&&(F=a.length-1);for(var b=
+0,c=n+2*k,b=0;b<c;b++){var d=E*b,e=E*(b+1),f=ga+y+d,g=ga+y+e,j=f,d=ga+F+d,e=ga+F+e,l=g,j=j+G,d=d+G,e=e+G,l=l+G;C.faces.push(new THREE.Face4(j,d,e,l,null,null,x));void 0!==x&&(j=b/c,d=(b+1)/c,e=h+2*i,f=(C.vertices[f].position.z+i)/e,g=(C.vertices[g].position.z+i)/e,C.faceVertexUvs[0].push([new THREE.UV(f,j),new THREE.UV(g,j),new THREE.UV(g,d),new THREE.UV(f,d)]))}}}function f(a,b,c){C.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function g(a,b,c){a+=G;b+=G;c+=G;C.faces.push(new THREE.Face3(a,
+b,c,null,null,u));if(void 0!==u){var d=w.minX,e=w.minY,f=w.maxY,g=w.maxX,h=C.vertices[b].position.x-d,b=C.vertices[b].position.y-e,j=C.vertices[c].position.x-d,c=C.vertices[c].position.y-e;C.faceVertexUvs[0].push([new THREE.UV((C.vertices[a].position.x-d)/g,(C.vertices[a].position.y-e)/f),new THREE.UV(h/g,b/f),new THREE.UV(j/g,c/f)])}}var h=void 0!==b.amount?b.amount:100,i=void 0!==b.bevelThickness?b.bevelThickness:6,l=void 0!==b.bevelSize?b.bevelSize:i-2,k=void 0!==b.bevelSegments?b.bevelSegments:
+3,p=void 0!==b.bevelEnabled?b.bevelEnabled:!0,o=void 0!==b.curveSegments?b.curveSegments:12,n=void 0!==b.steps?b.steps:1,q=b.bendPath,m=b.extrudePath,r,s=!1,t=void 0!==b.useSpacedPoints?b.useSpacedPoints:!1,u=b.material,x=b.extrudeMaterial,w=this.shapebb;if(m)r=m.getPoints(o),n=r.length,s=!0,p=!1;p||(l=i=k=0);var A,D,B,C=this,G=this.vertices.length;q&&a.addWrapPath(q);o=t?a.extractAllSpacedPoints(o):a.extractAllPoints(o);q=o.shape;o=o.holes;if(m=!THREE.Shape.Utils.isClockWise(q)){q=q.reverse();for(D=
+0,B=o.length;D<B;D++)A=o[D],THREE.Shape.Utils.isClockWise(A)&&(o[D]=A.reverse());m=!1}m=THREE.Shape.Utils.triangulateShape(q,o);t=q;for(D=0,B=o.length;D<B;D++)A=o[D],q=q.concat(A);for(var K,L,T,M,E=q.length,j=m.length,Q=[],I=0,R=t.length,y=R-1,F=I+1;I<R;I++,y++,F++)y===R&&(y=0),F===R&&(F=0),Q[I]=d(t[I],t[y],t[F]);var P=[],$,Z=Q.concat();for(D=0,B=o.length;D<B;D++){A=o[D];$=[];for(I=0,R=A.length,y=R-1,F=I+1;I<R;I++,y++,F++)y===R&&(y=0),F===R&&(F=0),$[I]=d(A[I],A[y],A[F]);P.push($);Z=Z.concat($)}for(K=
+0;K<k;K++){L=K/k;T=i*(1-L);L=l*Math.sin(L*Math.PI/2);for(I=0,R=t.length;I<R;I++)M=c(t[I],Q[I],L),f(M.x,M.y,-T);for(D=0,B=o.length;D<B;D++){A=o[D];$=P[D];for(I=0,R=A.length;I<R;I++)M=c(A[I],$[I],L),f(M.x,M.y,-T)}}L=l;for(I=0;I<E;I++)M=p?c(q[I],Z[I],L):q[I],s?f(M.x,M.y+r[0].y,r[0].x):f(M.x,M.y,0);for(K=1;K<=n;K++)for(I=0;I<E;I++)M=p?c(q[I],Z[I],L):q[I],s?f(M.x,M.y+r[K-1].y,r[K-1].x):f(M.x,M.y,h/n*K);for(K=k-1;0<=K;K--){L=K/k;T=i*(1-L);L=l*Math.sin(L*Math.PI/2);for(I=0,R=t.length;I<R;I++)M=c(t[I],Q[I],
+L),f(M.x,M.y,h+T);for(D=0,B=o.length;D<B;D++){A=o[D];$=P[D];for(I=0,R=A.length;I<R;I++)M=c(A[I],$[I],L),s?f(M.x,M.y+r[n-1].y,r[n-1].x+T):f(M.x,M.y,h+T)}}if(p){p=0*E;for(I=0;I<j;I++)l=m[I],g(l[2]+p,l[1]+p,l[0]+p);p=E*(n+2*k);for(I=0;I<j;I++)l=m[I],g(l[0]+p,l[1]+p,l[2]+p)}else{for(I=0;I<j;I++)l=m[I],g(l[2],l[1],l[0]);for(I=0;I<j;I++)l=m[I],g(l[0]+E*n,l[1]+E*n,l[2]+E*n)}var ga=0;e(t);ga+=t.length;for(D=0,B=o.length;D<B;D++)A=o[D],e(A),ga+=A.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(a){function b(a,b,c){var d=Math.sqrt(a*a+b*b+c*c);return e.vertices.push(new THREE.Vertex(new THREE.Vector3(a/d,b/d,c/d)))-1}function c(a,b,c,d){var f=e.vertices[a].position,g=e.vertices[b].position,h=e.vertices[c].position,a=new THREE.Face3(a,b,c);a.vertexNormals.push(f.clone().normalize(),g.clone().normalize(),h.clone().normalize());d.faces.push(a);d.faceVertexUvs[0].push([new THREE.UV(1-0.5*((Math.atan2(f.z,f.x)+Math.PI)%Math.PI/Math.PI),0.5-f.y/2),new THREE.UV(1-
 0.5*((Math.atan2(g.z,g.x)+Math.PI)%Math.PI/Math.PI),0.5-g.y/2),new THREE.UV(1-0.5*((Math.atan2(h.z,h.x)+Math.PI)%Math.PI/Math.PI),0.5-h.y/2)])}function d(a,c){var d=e.vertices[a].position,f=e.vertices[c].position;return b((d.x+f.x)/2,(d.y+f.y)/2,(d.z+f.z)/2)}var e=this,f=new THREE.Geometry;this.subdivisions=a||0;THREE.Geometry.call(this);a=(1+Math.sqrt(5))/2;b(-1,a,0);b(1,a,0);b(-1,-a,0);b(1,-a,0);b(0,-1,a);b(0,1,a);b(0,-1,-a);b(0,1,-a);b(a,0,-1);b(a,0,1);b(-a,0,-1);b(-a,0,1);c(0,11,5,f);c(0,5,1,
@@ -536,17 +537,17 @@ g.faces.push(h),h=Math.atan2(h.centroid.z,-h.centroid.x),g.faceVertexUvs[0].push
 {radius:a}};THREE.OctahedronGeometry.prototype=new THREE.Geometry;THREE.OctahedronGeometry.prototype.constructor=THREE.OctahedronGeometry;
 THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);for(var e=a/2,f=b/2,c=c||1,d=d||1,g=c+1,h=d+1,i=a/c,l=b/d,k=new THREE.Vector3(0,0,1),a=0;a<h;a++)for(b=0;b<g;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*i-e,-(a*l-f),0)));for(a=0;a<d;a++)for(b=0;b<c;b++)e=new THREE.Face4(b+g*a,b+g*(a+1),b+1+g*(a+1),b+1+g*a),e.normal.copy(k),e.vertexNormals.push(k.clone(),k.clone(),k.clone(),k.clone()),this.faces.push(e),this.faceVertexUvs[0].push([new THREE.UV(b/c,a/d),new THREE.UV(b/
 c,(a+1)/d),new THREE.UV((b+1)/c,(a+1)/d),new THREE.UV((b+1)/c,a/d)]);this.computeCentroids()};THREE.PlaneGeometry.prototype=new THREE.Geometry;THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
-THREE.SphereGeometry=function(a,b,c,d,e,f,g){THREE.Geometry.call(this);var a=a||50,d=void 0!==d?d:0,e=void 0!==e?e:2*Math.PI,f=void 0!==f?f:0,g=void 0!==g?g:Math.PI,b=Math.max(3,Math.floor(b)||8),c=Math.max(2,Math.floor(c)||6),h,i,l=[],k=[];for(i=0;i<=c;i++){var p=[],n=[];for(h=0;h<=b;h++){var o=h/b,q=i/c,m=-a*Math.cos(d+o*e)*Math.sin(f+q*g),r=a*Math.cos(f+q*g),s=a*Math.sin(d+o*e)*Math.sin(f+q*g);this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,r,s)));p.push(this.vertices.length-1);n.push(new THREE.UV(o,
-q))}l.push(p);k.push(n)}for(i=0;i<c;i++)for(h=0;h<b;h++){var d=l[i][h+1],e=l[i][h],f=l[i+1][h],g=l[i+1][h+1],p=this.vertices[d].position.clone().normalize(),n=this.vertices[e].position.clone().normalize(),o=this.vertices[f].position.clone().normalize(),q=this.vertices[g].position.clone().normalize(),m=k[i][h+1].clone(),r=k[i][h].clone(),s=k[i+1][h].clone(),t=k[i+1][h+1].clone();Math.abs(this.vertices[d].position.y)==a?(this.faces.push(new THREE.Face3(d,f,g,[p,o,q])),this.faceVertexUvs[0].push([m,
-s,t])):Math.abs(this.vertices[f].position.y)==a?(this.faces.push(new THREE.Face3(d,e,f,[p,n,o])),this.faceVertexUvs[0].push([m,r,s])):(this.faces.push(new THREE.Face4(d,e,f,g,[p,n,o,q])),this.faceVertexUvs[0].push([m,r,s,t]))}this.computeCentroids();this.computeFaceNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
+THREE.SphereGeometry=function(a,b,c,d,e,f,g){THREE.Geometry.call(this);var a=a||50,d=void 0!==d?d:0,e=void 0!==e?e:2*Math.PI,f=void 0!==f?f:0,g=void 0!==g?g:Math.PI,b=Math.max(3,Math.floor(b)||8),c=Math.max(2,Math.floor(c)||6),h,i,l=[],k=[];for(i=0;i<=c;i++){var p=[],o=[];for(h=0;h<=b;h++){var n=h/b,q=i/c,m=-a*Math.cos(d+n*e)*Math.sin(f+q*g),r=a*Math.cos(f+q*g),s=a*Math.sin(d+n*e)*Math.sin(f+q*g);this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,r,s)));p.push(this.vertices.length-1);o.push(new THREE.UV(n,
+q))}l.push(p);k.push(o)}for(i=0;i<c;i++)for(h=0;h<b;h++){var d=l[i][h+1],e=l[i][h],f=l[i+1][h],g=l[i+1][h+1],p=this.vertices[d].position.clone().normalize(),o=this.vertices[e].position.clone().normalize(),n=this.vertices[f].position.clone().normalize(),q=this.vertices[g].position.clone().normalize(),m=k[i][h+1].clone(),r=k[i][h].clone(),s=k[i+1][h].clone(),t=k[i+1][h+1].clone();Math.abs(this.vertices[d].position.y)==a?(this.faces.push(new THREE.Face3(d,f,g,[p,n,q])),this.faceVertexUvs[0].push([m,
+s,t])):Math.abs(this.vertices[f].position.y)==a?(this.faces.push(new THREE.Face3(d,e,f,[p,o,n])),this.faceVertexUvs[0].push([m,r,s])):(this.faces.push(new THREE.Face4(d,e,f,g,[p,o,n,q])),this.faceVertexUvs[0].push([m,r,s,t]))}this.computeCentroids();this.computeFaceNormals();this.boundingSphere={radius:a}};THREE.SphereGeometry.prototype=new THREE.Geometry;THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
 THREE.TextGeometry=function(a,b){var c=(new THREE.TextPath(a,b)).toShapes();b.amount=void 0!==b.height?b.height:50;if(void 0===b.bevelThickness)b.bevelThickness=10;if(void 0===b.bevelSize)b.bevelSize=8;if(void 0===b.bevelEnabled)b.bevelEnabled=!1;if(b.bend){var d=c[c.length-1].getBoundingBox().maxX;b.bendPath=new THREE.QuadraticBezierCurve(new THREE.Vector2(0,0),new THREE.Vector2(d/2,120),new THREE.Vector2(d,0))}THREE.ExtrudeGeometry.call(this,c,b)};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]},loadFace:function(a){var b=a.familyName.toLowerCase();this.faces[b]=this.faces[b]||{};this.faces[b][a.cssFontWeight]=this.faces[b][a.cssFontWeight]||{};this.faces[b][a.cssFontWeight][a.cssFontStyle]=a;return this.faces[b][a.cssFontWeight][a.cssFontStyle]=a},drawText:function(a){for(var b=this.getFace(),c=this.size/b.resolution,d=
-0,e=(""+a).split(""),f=e.length,g=[],a=0;a<f;a++){var h=new THREE.Path,h=this.extractGlyphPoints(e[a],b,c,d,h),d=d+h.offset;g.push(h.path)}return{paths:g,offset:d/2}},extractGlyphPoints:function(a,b,c,d,e){var f=[],g,h,i,l,k,p,n,o,q,m,r,s=b.glyphs[a]||b.glyphs["?"];if(s){if(s.o){b=s._cachedOutline||(s._cachedOutline=s.o.split(" "));l=b.length;for(a=0;a<l;)switch(i=b[a++],i){case "m":i=b[a++]*c+d;k=b[a++]*c;f.push(new THREE.Vector2(i,k));e.moveTo(i,k);break;case "l":i=b[a++]*c+d;k=b[a++]*c;f.push(new THREE.Vector2(i,
-k));e.lineTo(i,k);break;case "q":i=b[a++]*c+d;k=b[a++]*c;o=b[a++]*c+d;q=b[a++]*c;e.quadraticCurveTo(o,q,i,k);if(g=f[f.length-1]){p=g.x;n=g.y;for(g=1,h=this.divisions;g<=h;g++){var t=g/h,u=THREE.Shape.Utils.b2(t,p,o,i),t=THREE.Shape.Utils.b2(t,n,q,k);f.push(new THREE.Vector2(u,t))}}break;case "b":if(i=b[a++]*c+d,k=b[a++]*c,o=b[a++]*c+d,q=b[a++]*-c,m=b[a++]*c+d,r=b[a++]*-c,e.bezierCurveTo(i,k,o,q,m,r),g=f[f.length-1]){p=g.x;n=g.y;for(g=1,h=this.divisions;g<=h;g++)t=g/h,u=THREE.Shape.Utils.b3(t,p,o,
-m,i),t=THREE.Shape.Utils.b3(t,n,q,r,k),f.push(new THREE.Vector2(u,t))}}}return{offset:s.ha*c,points:f,path:e}}}};
-(function(a){var b=function(a){for(var b=a.length,e=0,f=b-1,g=0;g<b;f=g++)e+=a[f].x*a[g].y-a[g].x*a[f].y;return 0.5*e};a.Triangulate=function(a,d){var e=a.length;if(3>e)return null;var f=[],g=[],h=[],i,l,k;if(0<b(a))for(l=0;l<e;l++)g[l]=l;else for(l=0;l<e;l++)g[l]=e-1-l;var p=2*e;for(l=e-1;2<e;){if(0>=p--){console.log("Warning, unable to triangulate polygon!");break}i=l;e<=i&&(i=0);l=i+1;e<=l&&(l=0);k=l+1;e<=k&&(k=0);var n;a:{n=a;var o=i,q=l,m=k,r=e,s=g,t=void 0,u=void 0,x=void 0,v=void 0,A=void 0,
-D=void 0,E=void 0,C=void 0,F=void 0,u=n[s[o]].x,x=n[s[o]].y,v=n[s[q]].x,A=n[s[q]].y,D=n[s[m]].x,E=n[s[m]].y;if(1.0E-10>(v-u)*(E-x)-(A-x)*(D-u))n=!1;else{for(t=0;t<r;t++)if(!(t==o||t==q||t==m)){var C=n[s[t]].x,F=n[s[t]].y,K=void 0,L=void 0,R=void 0,N=void 0,P=void 0,B=void 0,j=void 0,H=void 0,V=void 0,y=void 0,I=void 0,O=void 0,K=R=P=void 0,K=D-v,L=E-A,R=u-D,N=x-E,P=v-u,B=A-x,j=C-u,H=F-x,V=C-v,y=F-A,I=C-D,O=F-E,K=K*y-L*V,P=P*H-B*j,R=R*O-N*I;if(0<=K&&0<=R&&0<=P){n=!1;break a}}n=!0}}if(n){f.push([a[g[i]],
+0,e=(""+a).split(""),f=e.length,g=[],a=0;a<f;a++){var h=new THREE.Path,h=this.extractGlyphPoints(e[a],b,c,d,h),d=d+h.offset;g.push(h.path)}return{paths:g,offset:d/2}},extractGlyphPoints:function(a,b,c,d,e){var f=[],g,h,i,l,k,p,o,n,q,m,r,s=b.glyphs[a]||b.glyphs["?"];if(s){if(s.o){b=s._cachedOutline||(s._cachedOutline=s.o.split(" "));l=b.length;for(a=0;a<l;)switch(i=b[a++],i){case "m":i=b[a++]*c+d;k=b[a++]*c;f.push(new THREE.Vector2(i,k));e.moveTo(i,k);break;case "l":i=b[a++]*c+d;k=b[a++]*c;f.push(new THREE.Vector2(i,
+k));e.lineTo(i,k);break;case "q":i=b[a++]*c+d;k=b[a++]*c;n=b[a++]*c+d;q=b[a++]*c;e.quadraticCurveTo(n,q,i,k);if(g=f[f.length-1]){p=g.x;o=g.y;for(g=1,h=this.divisions;g<=h;g++){var t=g/h,u=THREE.Shape.Utils.b2(t,p,n,i),t=THREE.Shape.Utils.b2(t,o,q,k);f.push(new THREE.Vector2(u,t))}}break;case "b":if(i=b[a++]*c+d,k=b[a++]*c,n=b[a++]*c+d,q=b[a++]*-c,m=b[a++]*c+d,r=b[a++]*-c,e.bezierCurveTo(i,k,n,q,m,r),g=f[f.length-1]){p=g.x;o=g.y;for(g=1,h=this.divisions;g<=h;g++)t=g/h,u=THREE.Shape.Utils.b3(t,p,n,
+m,i),t=THREE.Shape.Utils.b3(t,o,q,r,k),f.push(new THREE.Vector2(u,t))}}}return{offset:s.ha*c,points:f,path:e}}}};
+(function(a){var b=function(a){for(var b=a.length,e=0,f=b-1,g=0;g<b;f=g++)e+=a[f].x*a[g].y-a[g].x*a[f].y;return 0.5*e};a.Triangulate=function(a,d){var e=a.length;if(3>e)return null;var f=[],g=[],h=[],i,l,k;if(0<b(a))for(l=0;l<e;l++)g[l]=l;else for(l=0;l<e;l++)g[l]=e-1-l;var p=2*e;for(l=e-1;2<e;){if(0>=p--){console.log("Warning, unable to triangulate polygon!");break}i=l;e<=i&&(i=0);l=i+1;e<=l&&(l=0);k=l+1;e<=k&&(k=0);var o;a:{o=a;var n=i,q=l,m=k,r=e,s=g,t=void 0,u=void 0,x=void 0,w=void 0,A=void 0,
+D=void 0,B=void 0,C=void 0,G=void 0,u=o[s[n]].x,x=o[s[n]].y,w=o[s[q]].x,A=o[s[q]].y,D=o[s[m]].x,B=o[s[m]].y;if(1.0E-10>(w-u)*(B-x)-(A-x)*(D-u))o=!1;else{for(t=0;t<r;t++)if(!(t==n||t==q||t==m)){var C=o[s[t]].x,G=o[s[t]].y,K=void 0,L=void 0,T=void 0,M=void 0,E=void 0,j=void 0,Q=void 0,I=void 0,R=void 0,y=void 0,F=void 0,P=void 0,K=T=E=void 0,K=D-w,L=B-A,T=u-D,M=x-B,E=w-u,j=A-x,Q=C-u,I=G-x,R=C-w,y=G-A,F=C-D,P=G-B,K=K*y-L*R,E=E*I-j*Q,T=T*P-M*F;if(0<=K&&0<=T&&0<=E){o=!1;break a}}o=!0}}if(o){f.push([a[g[i]],
 a[g[l]],a[g[k]]]);h.push([g[i],g[l],g[k]]);for(i=l,k=l+1;k<e;i++,k++)g[i]=g[k];e--;p=2*e}}return d?h:f};a.Triangulate.area=b;return a})(THREE.FontUtils);self._typeface_js={faces:THREE.FontUtils.faces,loadFace:THREE.FontUtils.loadFace};
 THREE.TorusGeometry=function(a,b,c,d,e){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;this.arc=e||2*Math.PI;e=new THREE.Vector3;a=[];b=[];for(c=0;c<=this.segmentsR;c++)for(d=0;d<=this.segmentsT;d++){var f=d/this.segmentsT*this.arc,g=2*c/this.segmentsR*Math.PI;e.x=this.radius*Math.cos(f);e.y=this.radius*Math.sin(f);var h=new THREE.Vector3;h.x=(this.radius+this.tube*Math.cos(g))*Math.cos(f);h.y=(this.radius+this.tube*Math.cos(g))*Math.sin(f);h.z=
 this.tube*Math.sin(g);this.vertices.push(new THREE.Vertex(h));a.push(new THREE.UV(d/this.segmentsT,1-c/this.segmentsR));b.push(h.clone().subSelf(e).normalize())}for(c=1;c<=this.segmentsR;c++)for(d=1;d<=this.segmentsT;d++){var e=(this.segmentsT+1)*c+d-1,f=(this.segmentsT+1)*(c-1)+d-1,g=(this.segmentsT+1)*(c-1)+d,h=(this.segmentsT+1)*c+d,i=new THREE.Face4(e,f,g,h,[b[e],b[f],b[g],b[h]]);i.normal.addSelf(b[e]);i.normal.addSelf(b[f]);i.normal.addSelf(b[g]);i.normal.addSelf(b[h]);i.normal.normalize();this.faces.push(i);
@@ -555,13 +556,13 @@ THREE.TorusKnotGeometry=function(a,b,c,d,e,f,g){function h(a,b,c,d,e,f){var g=Ma
 Array(this.segmentsT);for(b=0;b<this.segmentsT;++b){var i=2*(a/this.segmentsR)*this.p*Math.PI,g=2*(b/this.segmentsT)*Math.PI,f=h(i,g,this.q,this.p,this.radius,this.heightScale),i=h(i+0.01,g,this.q,this.p,this.radius,this.heightScale);c.sub(i,f);d.add(i,f);e.cross(c,d);d.cross(e,c);e.normalize();d.normalize();i=-this.tube*Math.cos(g);g=this.tube*Math.sin(g);f.x+=i*d.x+g*e.x;f.y+=i*d.y+g*e.y;f.z+=i*d.z+g*e.z;this.grid[a][b]=this.vertices.push(new THREE.Vertex(new THREE.Vector3(f.x,f.y,f.z)))-1}}for(a=
 0;a<this.segmentsR;++a)for(b=0;b<this.segmentsT;++b){var e=(a+1)%this.segmentsR,f=(b+1)%this.segmentsT,c=this.grid[a][b],d=this.grid[e][b],e=this.grid[e][f],f=this.grid[a][f],g=new THREE.UV(a/this.segmentsR,b/this.segmentsT),i=new THREE.UV((a+1)/this.segmentsR,b/this.segmentsT),l=new THREE.UV((a+1)/this.segmentsR,(b+1)/this.segmentsT),k=new THREE.UV(a/this.segmentsR,(b+1)/this.segmentsT);this.faces.push(new THREE.Face4(c,d,e,f));this.faceVertexUvs[0].push([g,i,l,k])}this.computeCentroids();this.computeFaceNormals();
 this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=new THREE.Geometry;THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;THREE.SubdivisionModifier=function(a){this.subdivisions=void 0===a?1:a;this.useOldVertexColors=!1;this.supportUVs=!0};THREE.SubdivisionModifier.prototype.constructor=THREE.SubdivisionModifier;THREE.SubdivisionModifier.prototype.modify=function(a){for(var b=this.subdivisions;0<b--;)this.smooth(a)};
-THREE.SubdivisionModifier.prototype.smooth=function(a){function b(a,b,c,d,h,i){var k=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(g.useOldVertexColors){k.vertexColors=[];for(var l,m,o,p=0;4>p;p++){o=i[p];l=new THREE.Color;l.setRGB(0,0,0);for(var q=0;q<o.length;q++)m=h.vertexColors[o[q]-1],l.r+=m.r,l.g+=m.g,l.b+=m.b;l.r/=o.length;l.g/=o.length;l.b/=o.length;k.vertexColors[p]=l}}e.push(k);(!g.supportUVs||0!=n.length)&&f.push([n[a],n[b],n[c],n[d]])}function c(a,b){return Math.min(a,b)+"_"+Math.max(a,
-b)}var d=[],e=[],f=[],g=this,h=a.vertices,d=a.faces,i=h.concat(),l=[],k={},p={},n=[],o,q,m,r,s,t=a.faceVertexUvs[0];for(o=0,q=t.length;o<q;o++)for(m=0,r=t[o].length;m<r;m++)s=d[o]["abcd".charAt(m)],n[s]||(n[s]=t[o][m]);var u;for(o=0,q=d.length;o<q;o++)if(s=d[o],l.push(s.centroid),i.push(new THREE.Vertex(s.centroid)),g.supportUVs&&0!=n.length){u=new THREE.UV;if(s instanceof THREE.Face3)u.u=n[s.a].u+n[s.b].u+n[s.c].u,u.v=n[s.a].v+n[s.b].v+n[s.c].v,u.u/=3,u.v/=3;else if(s instanceof THREE.Face4)u.u=
-n[s.a].u+n[s.b].u+n[s.c].u+n[s.d].u,u.v=n[s.a].v+n[s.b].v+n[s.c].v+n[s.d].v,u.u/=4,u.v/=4;n.push(u)}q=function(a){function b(a,c,d){void 0===a[c]&&(a[c]=[]);a[c].push(d)}var d,e,f,g,h={};for(d=0,e=a.faces.length;d<e;d++)f=a.faces[d],f instanceof THREE.Face3?(g=c(f.a,f.b),b(h,g,d),g=c(f.b,f.c),b(h,g,d),g=c(f.c,f.a),b(h,g,d)):f instanceof THREE.Face4&&(g=c(f.a,f.b),b(h,g,d),g=c(f.b,f.c),b(h,g,d),g=c(f.c,f.d),b(h,g,d),g=c(f.d,f.a),b(h,g,d));return h}(a);var x=0,t=h.length,v,A,D={},E={},C=function(a,
-b){void 0===D[a]&&(D[a]=[]);D[a].push(b)},F=function(a,b){void 0===E[a]&&(E[a]={});E[a][b]=null};for(o in q){u=q[o];v=o.split("_");A=v[0];v=v[1];C(A,[A,v]);C(v,[A,v]);for(m=0,r=u.length;m<r;m++)s=u[m],F(A,s,o),F(v,s,o);2>u.length&&(p[o]=!0)}for(o in q)if(u=q[o],s=u[0],u=u[1],v=o.split("_"),A=v[0],v=v[1],r=new THREE.Vector3,p[o]?(r.addSelf(h[A].position),r.addSelf(h[v].position),r.multiplyScalar(0.5)):(r.addSelf(l[s]),r.addSelf(l[u]),r.addSelf(h[A].position),r.addSelf(h[v].position),r.multiplyScalar(0.25)),
-k[o]=t+d.length+x,i.push(new THREE.Vertex(r)),x++,g.supportUVs&&0!=n.length)u=new THREE.UV,u.u=n[A].u+n[v].u,u.v=n[A].v+n[v].v,u.u/=2,u.v/=2,n.push(u);var K,L;v=["123","12","2","23"];r=["123","23","3","31"];var C=["123","31","1","12"],F=["1234","12","2","23"],R=["1234","23","3","34"],N=["1234","34","4","41"],P=["1234","41","1","12"];for(o=0,q=l.length;o<q;o++)s=d[o],u=t+o,s instanceof THREE.Face3?(x=c(s.a,s.b),A=c(s.b,s.c),K=c(s.c,s.a),b(u,k[x],s.b,k[A],s,v),b(u,k[A],s.c,k[K],s,r),b(u,k[K],s.a,k[x],
-s,C)):s instanceof THREE.Face4?(x=c(s.a,s.b),A=c(s.b,s.c),K=c(s.c,s.d),L=c(s.d,s.a),b(u,k[x],s.b,k[A],s,F),b(u,k[A],s.c,k[K],s,R),b(u,k[K],s.d,k[L],s,N),b(u,k[L],s.a,k[x],s,P)):console.log("face should be a face!",s);d=i;i=new THREE.Vector3;k=new THREE.Vector3;for(o=0,q=h.length;o<q;o++)if(void 0!==D[o]){i.set(0,0,0);k.set(0,0,0);s=new THREE.Vector3(0,0,0);u=0;for(m in E[o])i.addSelf(l[m]),u++;x=0;t=D[o].length;for(m=0;m<t;m++)p[c(D[o][m][0],D[o][m][1])]&&x++;if(2!=x){i.divideScalar(u);for(m=0;m<
-t;m++)u=D[o][m],u=h[u[0]].position.clone().addSelf(h[u[1]].position).divideScalar(2),k.addSelf(u);k.divideScalar(t);s.addSelf(h[o].position);s.multiplyScalar(t-3);s.addSelf(i);s.addSelf(k.multiplyScalar(2));s.divideScalar(t);d[o].position=s}}a.vertices=d;a.faces=e;a.faceVertexUvs[0]=f;delete a.__tmpVertices;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals()};
+THREE.SubdivisionModifier.prototype.smooth=function(a){function b(a,b,c,d,h,i){var k=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(g.useOldVertexColors){k.vertexColors=[];for(var l,m,n,p=0;4>p;p++){n=i[p];l=new THREE.Color;l.setRGB(0,0,0);for(var q=0;q<n.length;q++)m=h.vertexColors[n[q]-1],l.r+=m.r,l.g+=m.g,l.b+=m.b;l.r/=n.length;l.g/=n.length;l.b/=n.length;k.vertexColors[p]=l}}e.push(k);(!g.supportUVs||0!=o.length)&&f.push([o[a],o[b],o[c],o[d]])}function c(a,b){return Math.min(a,b)+"_"+Math.max(a,
+b)}var d=[],e=[],f=[],g=this,h=a.vertices,d=a.faces,i=h.concat(),l=[],k={},p={},o=[],n,q,m,r,s,t=a.faceVertexUvs[0];for(n=0,q=t.length;n<q;n++)for(m=0,r=t[n].length;m<r;m++)s=d[n]["abcd".charAt(m)],o[s]||(o[s]=t[n][m]);var u;for(n=0,q=d.length;n<q;n++)if(s=d[n],l.push(s.centroid),i.push(new THREE.Vertex(s.centroid)),g.supportUVs&&0!=o.length){u=new THREE.UV;if(s instanceof THREE.Face3)u.u=o[s.a].u+o[s.b].u+o[s.c].u,u.v=o[s.a].v+o[s.b].v+o[s.c].v,u.u/=3,u.v/=3;else if(s instanceof THREE.Face4)u.u=
+o[s.a].u+o[s.b].u+o[s.c].u+o[s.d].u,u.v=o[s.a].v+o[s.b].v+o[s.c].v+o[s.d].v,u.u/=4,u.v/=4;o.push(u)}q=function(a){function b(a,c,d){void 0===a[c]&&(a[c]=[]);a[c].push(d)}var d,e,f,g,h={};for(d=0,e=a.faces.length;d<e;d++)f=a.faces[d],f instanceof THREE.Face3?(g=c(f.a,f.b),b(h,g,d),g=c(f.b,f.c),b(h,g,d),g=c(f.c,f.a),b(h,g,d)):f instanceof THREE.Face4&&(g=c(f.a,f.b),b(h,g,d),g=c(f.b,f.c),b(h,g,d),g=c(f.c,f.d),b(h,g,d),g=c(f.d,f.a),b(h,g,d));return h}(a);var x=0,t=h.length,w,A,D={},B={},C=function(a,
+b){void 0===D[a]&&(D[a]=[]);D[a].push(b)},G=function(a,b){void 0===B[a]&&(B[a]={});B[a][b]=null};for(n in q){u=q[n];w=n.split("_");A=w[0];w=w[1];C(A,[A,w]);C(w,[A,w]);for(m=0,r=u.length;m<r;m++)s=u[m],G(A,s,n),G(w,s,n);2>u.length&&(p[n]=!0)}for(n in q)if(u=q[n],s=u[0],u=u[1],w=n.split("_"),A=w[0],w=w[1],r=new THREE.Vector3,p[n]?(r.addSelf(h[A].position),r.addSelf(h[w].position),r.multiplyScalar(0.5)):(r.addSelf(l[s]),r.addSelf(l[u]),r.addSelf(h[A].position),r.addSelf(h[w].position),r.multiplyScalar(0.25)),
+k[n]=t+d.length+x,i.push(new THREE.Vertex(r)),x++,g.supportUVs&&0!=o.length)u=new THREE.UV,u.u=o[A].u+o[w].u,u.v=o[A].v+o[w].v,u.u/=2,u.v/=2,o.push(u);var K,L;w=["123","12","2","23"];r=["123","23","3","31"];var C=["123","31","1","12"],G=["1234","12","2","23"],T=["1234","23","3","34"],M=["1234","34","4","41"],E=["1234","41","1","12"];for(n=0,q=l.length;n<q;n++)s=d[n],u=t+n,s instanceof THREE.Face3?(x=c(s.a,s.b),A=c(s.b,s.c),K=c(s.c,s.a),b(u,k[x],s.b,k[A],s,w),b(u,k[A],s.c,k[K],s,r),b(u,k[K],s.a,k[x],
+s,C)):s instanceof THREE.Face4?(x=c(s.a,s.b),A=c(s.b,s.c),K=c(s.c,s.d),L=c(s.d,s.a),b(u,k[x],s.b,k[A],s,G),b(u,k[A],s.c,k[K],s,T),b(u,k[K],s.d,k[L],s,M),b(u,k[L],s.a,k[x],s,E)):console.log("face should be a face!",s);d=i;i=new THREE.Vector3;k=new THREE.Vector3;for(n=0,q=h.length;n<q;n++)if(void 0!==D[n]){i.set(0,0,0);k.set(0,0,0);s=new THREE.Vector3(0,0,0);u=0;for(m in B[n])i.addSelf(l[m]),u++;x=0;t=D[n].length;for(m=0;m<t;m++)p[c(D[n][m][0],D[n][m][1])]&&x++;if(2!=x){i.divideScalar(u);for(m=0;m<
+t;m++)u=D[n][m],u=h[u[0]].position.clone().addSelf(h[u[1]].position).divideScalar(2),k.addSelf(u);k.divideScalar(t);s.addSelf(h[n].position);s.multiplyScalar(t-3);s.addSelf(i);s.addSelf(k.multiplyScalar(2));s.divideScalar(t);d[n].position=s}}a.vertices=d;a.faces=e;a.faceVertexUvs[0]=f;delete a.__tmpVertices;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals()};
 THREE.Loader=function(a){this.statusDomElement=(this.showStatus=a)?THREE.Loader.prototype.addStatusElement():null;this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
 THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:"",addStatusElement:function(){var a=document.createElement("div");a.style.position="absolute";a.style.right="0px";a.style.top="0px";a.style.fontSize="0.8em";a.style.textAlign="left";a.style.background="rgba(0,0,0,0.25)";a.style.color="#fff";a.style.width="120px";a.style.padding="0.5em 0.5em 0.5em 0.5em";a.style.zIndex=1E3;a.innerHTML="Loading ...";return a},updateProgress:function(a){var b="Loaded ",b=a.total?b+((100*a.loaded/a.total).toFixed(0)+
 "%"):b+((a.loaded/1E3).toFixed(2)+" KB");this.statusDomElement.innerHTML=b},extractUrlbase:function(a){a=a.split("/");a.pop();return 1>a.length?"":a.join("/")+"/"},initMaterials:function(a,b,c){a.materials=[];for(var d=0;d<b.length;++d)a.materials[d]=THREE.Loader.prototype.createMaterial(b[d],c)},hasNormals:function(a){var b,c,d=a.materials.length;for(c=0;c<d;c++)if(b=a.materials[c],b instanceof THREE.ShaderMaterial)return!0;return!1},createMaterial:function(a,b){function c(a){a=Math.log(a)/Math.LN2;
@@ -577,126 +578,126 @@ THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,e,f){var g=new XMLHtt
 g.status+"]")};g.open("GET",b,!0);g.overrideMimeType&&g.overrideMimeType("text/plain; charset=x-user-defined");g.setRequestHeader("Content-Type","text/plain");g.send(null)};
 THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,e){var f=new XMLHttpRequest,g=c+"/"+a.buffers,h=0;f.onreadystatechange=function(){4==f.readyState?200==f.status||0==f.status?THREE.BinaryLoader.prototype.createBinModel(f.response,b,d,a.materials):console.error("Couldn't load ["+g+"] ["+f.status+"]"):3==f.readyState?e&&(0==h&&(h=f.getResponseHeader("Content-Length")),e({total:h,loaded:f.responseText.length})):2==f.readyState&&(h=f.getResponseHeader("Content-Length"))};f.open("GET",g,!0);
 f.responseType="arraybuffer";f.send(null)};
-THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var e=function(b){var c,e,i,l,k,p,n,o,q,m,r,s,t,u,x,v;function A(a){return a%4?4-a%4:0}function D(a,b){return(new Uint8Array(a,b,1))[0]}function E(a,b){return(new Uint32Array(a,b,1))[0]}function C(b,c){var d,e,f,g,h,i,j,l,k=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=k[3*d];f=k[3*d+1];g=k[3*d+2];h=H[2*e];e=H[2*e+1];i=H[2*f];j=H[2*f+1];f=H[2*g];l=H[2*g+1];g=P.faceVertexUvs[0];var m=[];m.push(new THREE.UV(h,e));m.push(new THREE.UV(i,j));
-m.push(new THREE.UV(f,l));g.push(m)}}function F(b,c){var d,e,f,g,h,i,j,l,k,m,o=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=o[4*d];f=o[4*d+1];g=o[4*d+2];h=o[4*d+3];i=H[2*e];e=H[2*e+1];j=H[2*f];k=H[2*f+1];l=H[2*g];m=H[2*g+1];g=H[2*h];f=H[2*h+1];h=P.faceVertexUvs[0];var n=[];n.push(new THREE.UV(i,e));n.push(new THREE.UV(j,k));n.push(new THREE.UV(l,m));n.push(new THREE.UV(g,f));h.push(n)}}function K(b,c,d){for(var e,f,g,h,c=new Uint32Array(a,c,3*b),i=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[3*d],f=c[3*
-d+1],g=c[3*d+2],h=i[d],P.faces.push(new THREE.Face3(e,f,g,null,null,h))}function L(b,c,d){for(var e,f,g,h,i,c=new Uint32Array(a,c,4*b),j=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[4*d],f=c[4*d+1],g=c[4*d+2],h=c[4*d+3],i=j[d],P.faces.push(new THREE.Face4(e,f,g,h,null,null,i))}function R(b,c,d,e){for(var f,g,h,i,l,k,m,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),o=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[3*e];g=c[3*e+1];h=c[3*e+2];l=d[3*e];k=d[3*e+1];m=d[3*e+2];i=o[e];var n=j[3*k],p=j[3*k+1];k=
-j[3*k+2];var q=j[3*m],r=j[3*m+1];m=j[3*m+2];P.faces.push(new THREE.Face3(f,g,h,[new THREE.Vector3(j[3*l],j[3*l+1],j[3*l+2]),new THREE.Vector3(n,p,k),new THREE.Vector3(q,r,m)],null,i))}}function N(b,c,d,e){for(var f,g,h,i,k,l,m,o,n,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),p=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[4*e];g=c[4*e+1];h=c[4*e+2];i=c[4*e+3];l=d[4*e];m=d[4*e+1];o=d[4*e+2];n=d[4*e+3];k=p[e];var q=j[3*m],r=j[3*m+1];m=j[3*m+2];var s=j[3*o],t=j[3*o+1];o=j[3*o+2];var u=j[3*n],v=j[3*
-n+1];n=j[3*n+2];P.faces.push(new THREE.Face4(f,g,h,i,[new THREE.Vector3(j[3*l],j[3*l+1],j[3*l+2]),new THREE.Vector3(q,r,m),new THREE.Vector3(s,t,o),new THREE.Vector3(u,v,n)],null,k))}}var P=this,B=0,j=[],H=[],V,y;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(P,d,b);c=function(a,b,c){for(var a=new Uint8Array(a,b,c),d="",e=0;e<c;e++)d+=String.fromCharCode(a[b+e]);return d}(a,B,12);e=D(a,B+12);D(a,B+13);D(a,B+14);D(a,B+15);i=D(a,B+16);l=D(a,B+17);k=D(a,B+18);p=D(a,B+19);n=E(a,B+20);
-o=E(a,B+20+4);q=E(a,B+20+8);b=E(a,B+20+12);m=E(a,B+20+16);r=E(a,B+20+20);s=E(a,B+20+24);t=E(a,B+20+28);u=E(a,B+20+32);x=E(a,B+20+36);v=E(a,B+20+40);"Three.js 003"!==c&&console.warn("DEPRECATED: binary model seems to be using old format");B+=e;c=3*i+p;y=4*i+p;e=b*c;V=m*(c+3*l);i=r*(c+3*k);p=s*(c+3*l+3*k);c=t*y;l=u*(y+4*l);k=x*(y+4*k);B+=function(b){var b=new Float32Array(a,b,3*n),c,d,e,f;for(c=0;c<n;c++)d=b[3*c],e=b[3*c+1],f=b[3*c+2],P.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,f)));return 3*
-n*Float32Array.BYTES_PER_ELEMENT}(B);B+=function(b){if(o){var b=new Int8Array(a,b,3*o),c,d,e,f;for(c=0;c<o;c++)d=b[3*c],e=b[3*c+1],f=b[3*c+2],j.push(d/127,e/127,f/127)}return 3*o*Int8Array.BYTES_PER_ELEMENT}(B);B+=A(3*o);B+=function(b){if(q){var b=new Float32Array(a,b,2*q),c,d,e;for(c=0;c<q;c++)d=b[2*c],e=b[2*c+1],H.push(d,e)}return 2*q*Float32Array.BYTES_PER_ELEMENT}(B);e=B+e+A(2*b);V=e+V+A(2*m);i=V+i+A(2*r);p=i+p+A(2*s);c=p+c+A(2*t);l=c+l+A(2*u);k=l+k+A(2*x);(function(a){if(r){var b=a+3*r*Uint32Array.BYTES_PER_ELEMENT;
-K(r,a,b+3*r*Uint32Array.BYTES_PER_ELEMENT);C(r,b)}})(V);(function(a){if(s){var b=a+3*s*Uint32Array.BYTES_PER_ELEMENT,c=b+3*s*Uint32Array.BYTES_PER_ELEMENT;R(s,a,b,c+3*s*Uint32Array.BYTES_PER_ELEMENT);C(s,c)}})(i);(function(a){if(x){var b=a+4*x*Uint32Array.BYTES_PER_ELEMENT;L(x,a,b+4*x*Uint32Array.BYTES_PER_ELEMENT);F(x,b)}})(l);(function(a){if(v){var b=a+4*v*Uint32Array.BYTES_PER_ELEMENT,c=b+4*v*Uint32Array.BYTES_PER_ELEMENT;N(v,a,b,c+4*v*Uint32Array.BYTES_PER_ELEMENT);F(v,c)}})(k);b&&K(b,B,B+3*b*
-Uint32Array.BYTES_PER_ELEMENT);(function(a){if(m){var b=a+3*m*Uint32Array.BYTES_PER_ELEMENT;R(m,a,b,b+3*m*Uint32Array.BYTES_PER_ELEMENT)}})(e);t&&L(t,p,p+4*t*Uint32Array.BYTES_PER_ELEMENT);(function(a){if(u){var b=a+4*u*Uint32Array.BYTES_PER_ELEMENT;N(u,a,b,b+4*u*Uint32Array.BYTES_PER_ELEMENT)}})(c);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))};
-THREE.ColladaLoader=function(){function a(a,d,e){S=a;d=d||ca;void 0!==e&&(a=e.split("/"),a.pop(),Ra=1>a.length?"":a.join("/")+"/");if((a=S.evaluate("//dae:asset",S,V,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(e=0;e<a.childNodes.length;e++){var i=a.childNodes[e];switch(i.nodeName){case "unit":(i=i.getAttribute("meter"))&&parseFloat(i);break;case "up_axis":Ma=i.textContent.charAt(0)}}if(!Aa.convertUpAxis||Ma===Aa.upAxis)xa=null;else switch(Ma){case "X":xa="Y"===Aa.upAxis?
-"XtoY":"XtoZ";break;case "Y":xa="X"===Aa.upAxis?"YtoX":"YtoZ";break;case "Z":xa="X"===Aa.upAxis?"ZtoX":"ZtoY"}La=b("//dae:library_images/dae:image",g,"image");Ga=b("//dae:library_materials/dae:material",E,"material");Fa=b("//dae:library_effects/dae:effect",R,"effect");qa=b("//dae:library_geometries/dae:geometry",r,"geometry");za=b("//dae:library_controllers/dae:controller",h,"controller");ja=b("//dae:library_animations/dae:animation",P,"animation");gb=b(".//dae:library_visual_scenes/dae:visual_scene",
-k,"visual_scene");Sa=[];bb=[];(a=S.evaluate(".//dae:scene/dae:instance_visual_scene",S,V,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),$=gb[a]):$=null;ba=new THREE.Object3D;for(a=0;a<$.nodes.length;a++)ba.add(f($.nodes[a]));ab=[];c(ba);a={scene:ba,morphs:Sa,skins:bb,animations:ab,dae:{images:La,materials:Ga,effects:Fa,geometries:qa,controllers:za,animations:ja,visualScenes:gb,scene:$}};d&&d(a);return a}function b(a,b,c){for(var a=S.evaluate(a,
-S,V,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),d={},e=a.iterateNext(),f=0;e;){e=(new b).parse(e);if(!e.id||0==e.id.length)e.id=c+f++;d[e.id]=e;e=a.iterateNext()}return d}function c(a){var b=$.getChildById(a.name,!0),d=null;if(b&&b.keys){d={fps:60,hierarchy:[{node:b,keys:b.keys,sids:b.sids}],node:a,name:"animation_"+a.name,length:0};ab.push(d);for(var e=0,f=b.keys.length;e<f;e++)d.length=Math.max(d.length,b.keys[e].time)}else d={hierarchy:[{keys:[],sids:[]}]};e=0;for(f=a.children.length;e<f;e++)for(var b=
+THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var e=function(b){var c,e,i,l,k,p,o,n,q,m,r,s,t,u,x,w;function A(a){return a%4?4-a%4:0}function D(a,b){return(new Uint8Array(a,b,1))[0]}function B(a,b){return(new Uint32Array(a,b,1))[0]}function C(b,c){var d,e,f,g,h,i,j,k,l=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=l[3*d];f=l[3*d+1];g=l[3*d+2];h=I[2*e];e=I[2*e+1];i=I[2*f];j=I[2*f+1];f=I[2*g];k=I[2*g+1];g=E.faceVertexUvs[0];var m=[];m.push(new THREE.UV(h,e));m.push(new THREE.UV(i,j));
+m.push(new THREE.UV(f,k));g.push(m)}}function G(b,c){var d,e,f,g,h,i,j,k,l,m,n=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=n[4*d];f=n[4*d+1];g=n[4*d+2];h=n[4*d+3];i=I[2*e];e=I[2*e+1];j=I[2*f];l=I[2*f+1];k=I[2*g];m=I[2*g+1];g=I[2*h];f=I[2*h+1];h=E.faceVertexUvs[0];var o=[];o.push(new THREE.UV(i,e));o.push(new THREE.UV(j,l));o.push(new THREE.UV(k,m));o.push(new THREE.UV(g,f));h.push(o)}}function K(b,c,d){for(var e,f,g,h,c=new Uint32Array(a,c,3*b),i=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[3*d],f=c[3*
+d+1],g=c[3*d+2],h=i[d],E.faces.push(new THREE.Face3(e,f,g,null,null,h))}function L(b,c,d){for(var e,f,g,h,i,c=new Uint32Array(a,c,4*b),j=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[4*d],f=c[4*d+1],g=c[4*d+2],h=c[4*d+3],i=j[d],E.faces.push(new THREE.Face4(e,f,g,h,null,null,i))}function T(b,c,d,e){for(var f,g,h,i,j,k,l,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),m=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[3*e];g=c[3*e+1];h=c[3*e+2];j=d[3*e];k=d[3*e+1];l=d[3*e+2];i=m[e];var n=Q[3*k],o=Q[3*k+1];k=
+Q[3*k+2];var p=Q[3*l],q=Q[3*l+1];l=Q[3*l+2];E.faces.push(new THREE.Face3(f,g,h,[new THREE.Vector3(Q[3*j],Q[3*j+1],Q[3*j+2]),new THREE.Vector3(n,o,k),new THREE.Vector3(p,q,l)],null,i))}}function M(b,c,d,e){for(var f,g,h,i,j,k,l,m,n,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),o=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[4*e];g=c[4*e+1];h=c[4*e+2];i=c[4*e+3];k=d[4*e];l=d[4*e+1];m=d[4*e+2];n=d[4*e+3];j=o[e];var p=Q[3*l],q=Q[3*l+1];l=Q[3*l+2];var r=Q[3*m],s=Q[3*m+1];m=Q[3*m+2];var t=Q[3*n],u=Q[3*
+n+1];n=Q[3*n+2];E.faces.push(new THREE.Face4(f,g,h,i,[new THREE.Vector3(Q[3*k],Q[3*k+1],Q[3*k+2]),new THREE.Vector3(p,q,l),new THREE.Vector3(r,s,m),new THREE.Vector3(t,u,n)],null,j))}}var E=this,j=0,Q=[],I=[],R,y;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(E,d,b);c=function(a,b,c){for(var a=new Uint8Array(a,b,c),d="",e=0;e<c;e++)d+=String.fromCharCode(a[b+e]);return d}(a,j,12);e=D(a,j+12);D(a,j+13);D(a,j+14);D(a,j+15);i=D(a,j+16);l=D(a,j+17);k=D(a,j+18);p=D(a,j+19);o=B(a,j+20);
+n=B(a,j+20+4);q=B(a,j+20+8);b=B(a,j+20+12);m=B(a,j+20+16);r=B(a,j+20+20);s=B(a,j+20+24);t=B(a,j+20+28);u=B(a,j+20+32);x=B(a,j+20+36);w=B(a,j+20+40);"Three.js 003"!==c&&console.warn("DEPRECATED: binary model seems to be using old format");j+=e;c=3*i+p;y=4*i+p;e=b*c;R=m*(c+3*l);i=r*(c+3*k);p=s*(c+3*l+3*k);c=t*y;l=u*(y+4*l);k=x*(y+4*k);j+=function(b){var b=new Float32Array(a,b,3*o),c,d,e,f;for(c=0;c<o;c++)d=b[3*c],e=b[3*c+1],f=b[3*c+2],E.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,f)));return 3*
+o*Float32Array.BYTES_PER_ELEMENT}(j);j+=function(b){if(n){var b=new Int8Array(a,b,3*n),c,d,e,f;for(c=0;c<n;c++)d=b[3*c],e=b[3*c+1],f=b[3*c+2],Q.push(d/127,e/127,f/127)}return 3*n*Int8Array.BYTES_PER_ELEMENT}(j);j+=A(3*n);j+=function(b){if(q){var b=new Float32Array(a,b,2*q),c,d,e;for(c=0;c<q;c++)d=b[2*c],e=b[2*c+1],I.push(d,e)}return 2*q*Float32Array.BYTES_PER_ELEMENT}(j);e=j+e+A(2*b);R=e+R+A(2*m);i=R+i+A(2*r);p=i+p+A(2*s);c=p+c+A(2*t);l=c+l+A(2*u);k=l+k+A(2*x);(function(a){if(r){var b=a+3*r*Uint32Array.BYTES_PER_ELEMENT;
+K(r,a,b+3*r*Uint32Array.BYTES_PER_ELEMENT);C(r,b)}})(R);(function(a){if(s){var b=a+3*s*Uint32Array.BYTES_PER_ELEMENT,c=b+3*s*Uint32Array.BYTES_PER_ELEMENT;T(s,a,b,c+3*s*Uint32Array.BYTES_PER_ELEMENT);C(s,c)}})(i);(function(a){if(x){var b=a+4*x*Uint32Array.BYTES_PER_ELEMENT;L(x,a,b+4*x*Uint32Array.BYTES_PER_ELEMENT);G(x,b)}})(l);(function(a){if(w){var b=a+4*w*Uint32Array.BYTES_PER_ELEMENT,c=b+4*w*Uint32Array.BYTES_PER_ELEMENT;M(w,a,b,c+4*w*Uint32Array.BYTES_PER_ELEMENT);G(w,c)}})(k);b&&K(b,j,j+3*b*
+Uint32Array.BYTES_PER_ELEMENT);(function(a){if(m){var b=a+3*m*Uint32Array.BYTES_PER_ELEMENT;T(m,a,b,b+3*m*Uint32Array.BYTES_PER_ELEMENT)}})(e);t&&L(t,p,p+4*t*Uint32Array.BYTES_PER_ELEMENT);(function(a){if(u){var b=a+4*u*Uint32Array.BYTES_PER_ELEMENT;M(u,a,b,b+4*u*Uint32Array.BYTES_PER_ELEMENT)}})(c);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e(c))};
+THREE.ColladaLoader=function(){function a(a,d,e){S=a;d=d||ca;void 0!==e&&(a=e.split("/"),a.pop(),Wa=1>a.length?"":a.join("/")+"/");if((a=S.evaluate("//dae:asset",S,R,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(e=0;e<a.childNodes.length;e++){var i=a.childNodes[e];switch(i.nodeName){case "unit":(i=i.getAttribute("meter"))&&parseFloat(i);break;case "up_axis":Ka=i.textContent.charAt(0)}}if(!Oa.convertUpAxis||Ka===Oa.upAxis)xa=null;else switch(Ka){case "X":xa="Y"===Oa.upAxis?
+"XtoY":"XtoZ";break;case "Y":xa="X"===Oa.upAxis?"YtoX":"YtoZ";break;case "Z":xa="X"===Oa.upAxis?"ZtoX":"ZtoY"}Na=b("//dae:library_images/dae:image",g,"image");Ga=b("//dae:library_materials/dae:material",B,"material");Ea=b("//dae:library_effects/dae:effect",T,"effect");qa=b("//dae:library_geometries/dae:geometry",r,"geometry");za=b("//dae:library_controllers/dae:controller",h,"controller");ja=b("//dae:library_animations/dae:animation",E,"animation");Ta=b(".//dae:library_visual_scenes/dae:visual_scene",
+k,"visual_scene");fb=[];Za=[];(a=S.evaluate(".//dae:scene/dae:instance_visual_scene",S,R,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),ba=Ta[a]):ba=null;aa=new THREE.Object3D;for(a=0;a<ba.nodes.length;a++)aa.add(f(ba.nodes[a]));Sa=[];c(aa);a={scene:aa,morphs:fb,skins:Za,animations:Sa,dae:{images:Na,materials:Ga,effects:Ea,geometries:qa,controllers:za,animations:ja,visualScenes:Ta,scene:ba}};d&&d(a);return a}function b(a,b,c){for(var a=S.evaluate(a,
+S,R,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),d={},e=a.iterateNext(),f=0;e;){e=(new b).parse(e);if(!e.id||0==e.id.length)e.id=c+f++;d[e.id]=e;e=a.iterateNext()}return d}function c(a){var b=ba.getChildById(a.name,!0),d=null;if(b&&b.keys){d={fps:60,hierarchy:[{node:b,keys:b.keys,sids:b.sids}],node:a,name:"animation_"+a.name,length:0};Sa.push(d);for(var e=0,f=b.keys.length;e<f;e++)d.length=Math.max(d.length,b.keys[e].time)}else d={hierarchy:[{keys:[],sids:[]}]};e=0;for(f=a.children.length;e<f;e++)for(var b=
 0,g=c(a.children[e]).hierarchy.length;b<g;b++)d.hierarchy.push({keys:[],sids:[]});return d}function d(a,b,c,e){a.world=a.world||new THREE.Matrix4;a.world.copy(a.matrix);if(a.channels&&a.channels.length){var f=a.channels[0].sampler.output[c];f instanceof THREE.Matrix4&&a.world.copy(f)}e&&a.world.multiply(e,a.world);b.push(a);for(e=0;e<a.nodes.length;e++)d(a.nodes[e],b,c,a.world)}function e(a,b,c){var e,f=za[b.url];if(!f||!f.skin)console.log("ColladaLoader: Could not find skin controller.");else if(!b.skeleton||
-!b.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");else{var c=1E6,g=-c,h=0;for(e in ja)for(var i=ja[e],j=0;j<i.sampler.length;j++){var l=i.sampler[j];l.create();c=Math.min(c,l.startTime);g=Math.max(g,l.endTime);h=Math.max(h,l.input.length)}e=h;for(var b=$.getChildById(b.skeleton[0],!0)||$.getChildBySid(b.skeleton[0],!0),k,m,g=new THREE.Vector3,o,j=0;j<a.vertices.length;j++)f.skin.bindShapeMatrix.multiplyVector3(a.vertices[j].position);for(c=0;c<e;c++){h=[];
-i=[];for(j=0;j<a.vertices.length;j++)i.push(new THREE.Vertex(new THREE.Vector3));d(b,h,c);j=h;l=f.skin;for(m=0;m<j.length;m++)if(k=j[m],o=-1,"JOINT"==k.type){for(var n=0;n<l.joints.length;n++)if(k.sid==l.joints[n]){o=n;break}if(0<=o){n=l.invBindMatrices[o];k.invBindMatrix=n;k.skinningMatrix=new THREE.Matrix4;k.skinningMatrix.multiply(k.world,n);k.weights=[];for(n=0;n<l.weights.length;n++)for(var p=0;p<l.weights[n].length;p++){var q=l.weights[n][p];q.joint==o&&k.weights.push(q)}}else throw"ColladaLoader: Could not find joint '"+
-k.sid+"'.";}for(j=0;j<h.length;j++)if("JOINT"==h[j].type)for(l=0;l<h[j].weights.length;l++)k=h[j].weights[l],m=k.index,k=k.weight,o=a.vertices[m],m=i[m],g.x=o.position.x,g.y=o.position.y,g.z=o.position.z,h[j].skinningMatrix.multiplyVector3(g),m.position.x+=g.x*k,m.position.y+=g.y*k,m.position.z+=g.z*k;a.morphTargets.push({name:"target_"+c,vertices:i})}}}function f(a){var b=new THREE.Object3D,c,d,g,h;for(g=0;g<a.controllers.length;g++){var i=za[a.controllers[g].url];switch(i.type){case "skin":if(qa[i.skin.source]){var j=
-new m;j.url=i.skin.source;j.instance_material=a.controllers[g].instance_material;a.geometries.push(j);c=a.controllers[g]}else if(za[i.skin.source]&&(d=i=za[i.skin.source],i.morph&&qa[i.morph.source]))j=new m,j.url=i.morph.source,j.instance_material=a.controllers[g].instance_material,a.geometries.push(j);break;case "morph":if(qa[i.morph.source])j=new m,j.url=i.morph.source,j.instance_material=a.controllers[g].instance_material,a.geometries.push(j),d=a.controllers[g];console.log("ColladaLoader: Morph-controller partially supported.")}}for(g=
-0;g<a.geometries.length;g++){var i=a.geometries[g],j=i.instance_material,i=qa[i.url],k={},l=[],n=0,p;if(i&&i.mesh&&i.mesh.primitives){if(0==b.name.length)b.name=i.id;if(j)for(h=0;h<j.length;h++){p=j[h];var q=Fa[Ga[p.target].instance_effect.url].shader;q.material.opacity=!q.material.opacity?1:q.material.opacity;k[p.symbol]=n;l.push(q.material);p=q.material;n++}j=p||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});i=i.mesh.geometry3js;if(1<n){j=new THREE.MeshFaceMaterial;i.materials=
-l;for(h=0;h<i.faces.length;h++)l=i.faces[h],l.materialIndex=k[l.daeMaterial]}if(void 0!==c)e(i,c),j.morphTargets=!0,j=new THREE.SkinnedMesh(i,j),j.skeleton=c.skeleton,j.skinController=za[c.url],j.skinInstanceController=c,j.name="skin_"+bb.length,bb.push(j);else if(void 0!==d){h=i;k=d instanceof o?za[d.url]:d;if(!k||!k.morph)console.log("could not find morph controller!");else{k=k.morph;for(l=0;l<k.targets.length;l++)if(n=qa[k.targets[l]],n.mesh&&n.mesh.primitives&&n.mesh.primitives.length)n=n.mesh.primitives[0].geometry,
-n.vertices.length===h.vertices.length&&h.morphTargets.push({name:"target_1",vertices:n.vertices});h.morphTargets.push({name:"target_Z",vertices:h.vertices})}j.morphTargets=!0;j=new THREE.Mesh(i,j);j.name="morph_"+Sa.length;Sa.push(j)}else j=new THREE.Mesh(i,j);1<a.geometries.length?b.add(j):b=j}}b.name=a.id||"";b.matrix=a.matrix;c=a.matrix.decompose();b.position=c[0];b.quaternion=c[1];b.useQuaternion=!0;b.scale=c[2];Aa.centerGeometry&&b.geometry&&(c=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(c.multiplySelf(b.scale)),
+!b.skeleton.length)console.log("ColladaLoader: Could not find the skeleton for the skin. ");else{var c=1E6,g=-c,h=0;for(e in ja)for(var i=ja[e],j=0;j<i.sampler.length;j++){var k=i.sampler[j];k.create();c=Math.min(c,k.startTime);g=Math.max(g,k.endTime);h=Math.max(h,k.input.length)}e=h;for(var b=ba.getChildById(b.skeleton[0],!0)||ba.getChildBySid(b.skeleton[0],!0),l,m,g=new THREE.Vector3,n,j=0;j<a.vertices.length;j++)f.skin.bindShapeMatrix.multiplyVector3(a.vertices[j].position);for(c=0;c<e;c++){h=
+[];i=[];for(j=0;j<a.vertices.length;j++)i.push(new THREE.Vertex(new THREE.Vector3));d(b,h,c);j=h;k=f.skin;for(m=0;m<j.length;m++)if(l=j[m],n=-1,"JOINT"==l.type){for(var o=0;o<k.joints.length;o++)if(l.sid==k.joints[o]){n=o;break}if(0<=n){o=k.invBindMatrices[n];l.invBindMatrix=o;l.skinningMatrix=new THREE.Matrix4;l.skinningMatrix.multiply(l.world,o);l.weights=[];for(o=0;o<k.weights.length;o++)for(var p=0;p<k.weights[o].length;p++){var q=k.weights[o][p];q.joint==n&&l.weights.push(q)}}else throw"ColladaLoader: Could not find joint '"+
+l.sid+"'.";}for(j=0;j<h.length;j++)if("JOINT"==h[j].type)for(k=0;k<h[j].weights.length;k++)l=h[j].weights[k],m=l.index,l=l.weight,n=a.vertices[m],m=i[m],g.x=n.position.x,g.y=n.position.y,g.z=n.position.z,h[j].skinningMatrix.multiplyVector3(g),m.position.x+=g.x*l,m.position.y+=g.y*l,m.position.z+=g.z*l;a.morphTargets.push({name:"target_"+c,vertices:i})}}}function f(a){var b=new THREE.Object3D,c,d,g,h;for(g=0;g<a.controllers.length;g++){var j=za[a.controllers[g].url];switch(j.type){case "skin":if(qa[j.skin.source]){var i=
+new m;i.url=j.skin.source;i.instance_material=a.controllers[g].instance_material;a.geometries.push(i);c=a.controllers[g]}else if(za[j.skin.source]&&(d=j=za[j.skin.source],j.morph&&qa[j.morph.source]))i=new m,i.url=j.morph.source,i.instance_material=a.controllers[g].instance_material,a.geometries.push(i);break;case "morph":if(qa[j.morph.source])i=new m,i.url=j.morph.source,i.instance_material=a.controllers[g].instance_material,a.geometries.push(i),d=a.controllers[g];console.log("ColladaLoader: Morph-controller partially supported.")}}for(g=
+0;g<a.geometries.length;g++){var j=a.geometries[g],i=j.instance_material,j=qa[j.url],l={},k=[],o=0,p;if(j&&j.mesh&&j.mesh.primitives){if(0==b.name.length)b.name=j.id;if(i)for(h=0;h<i.length;h++){p=i[h];var q=Ea[Ga[p.target].instance_effect.url].shader;q.material.opacity=!q.material.opacity?1:q.material.opacity;l[p.symbol]=o;k.push(q.material);p=q.material;o++}i=p||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});j=j.mesh.geometry3js;if(1<o){i=new THREE.MeshFaceMaterial;j.materials=
+k;for(h=0;h<j.faces.length;h++)k=j.faces[h],k.materialIndex=l[k.daeMaterial]}if(void 0!==c)e(j,c),i.morphTargets=!0,i=new THREE.SkinnedMesh(j,i),i.skeleton=c.skeleton,i.skinController=za[c.url],i.skinInstanceController=c,i.name="skin_"+Za.length,Za.push(i);else if(void 0!==d){h=j;l=d instanceof n?za[d.url]:d;if(!l||!l.morph)console.log("could not find morph controller!");else{l=l.morph;for(k=0;k<l.targets.length;k++)if(o=qa[l.targets[k]],o.mesh&&o.mesh.primitives&&o.mesh.primitives.length)o=o.mesh.primitives[0].geometry,
+o.vertices.length===h.vertices.length&&h.morphTargets.push({name:"target_1",vertices:o.vertices});h.morphTargets.push({name:"target_Z",vertices:h.vertices})}i.morphTargets=!0;i=new THREE.Mesh(j,i);i.name="morph_"+fb.length;fb.push(i)}else i=new THREE.Mesh(j,i);1<a.geometries.length?b.add(i):b=i}}b.name=a.id||"";b.matrix=a.matrix;c=a.matrix.decompose();b.position=c[0];b.quaternion=c[1];b.useQuaternion=!0;b.scale=c[2];Oa.centerGeometry&&b.geometry&&(c=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(c.multiplySelf(b.scale)),
 b.position.subSelf(c));for(g=0;g<a.nodes.length;g++)b.add(f(a.nodes[g],a));return b}function g(){this.init_from=this.id=""}function h(){this.type=this.name=this.id="";this.morph=this.skin=null}function i(){this.weights=this.targets=this.source=this.method=null}function l(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];this.joints=[];this.weights=[]}function k(){this.name=this.id="";this.nodes=[];this.scene=new THREE.Object3D}function p(){this.sid=this.name=this.id="";this.nodes=
-[];this.controllers=[];this.transforms=[];this.geometries=[];this.channels=[];this.matrix=new THREE.Matrix4}function n(){this.type=this.sid="";this.data=[];this.obj=null}function o(){this.url="";this.skeleton=[];this.instance_material=[]}function q(){this.target=this.symbol=""}function m(){this.url="";this.instance_material=[]}function r(){this.id="";this.mesh=null}function s(a){this.geometry=a.id;this.primitives=[];this.geometry3js=this.vertices=null}function t(){}function u(){this.material="";this.count=
-0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function x(){this.source="";this.stride=this.count=0;this.params=[]}function v(){this.input={}}function A(){this.semantic="";this.offset=0;this.source="";this.set=0}function D(a){this.id=a;this.type=null}function E(){this.name=this.id="";this.instance_effect=null}function C(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texOpts=this.texcoord=this.texture=null}
-function F(a,b){this.type=a;this.effect=b;this.material=null}function K(a){this.effect=a;this.format=this.init_from=null}function L(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function R(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function N(){this.url=""}function P(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function B(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=
-this.arrSyntax=this.dotSyntax=this.sid=this.fullSid=null}function j(a){this.id="";this.animation=a;this.inputs=[];this.endTime=this.startTime=this.interpolation=this.strideOut=this.output=this.input=null;this.duration=0}function H(a){this.targets=[];this.time=a}function V(a){return"dae"==a?"http://www.collada.org/2005/11/COLLADASchema":null}function y(a){for(var a=O(a),b=[],c=0;c<a.length;c++)b.push(parseFloat(a[c]));return b}function I(a){for(var a=O(a),b=[],c=0;c<a.length;c++)b.push(parseInt(a[c],
-10));return b}function O(a){return a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/)}function T(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function aa(a,b){if(Aa.convertUpAxis&&Ma!==Aa.upAxis)switch(xa){case "XtoY":var c=a[0];a[0]=b*a[1];a[1]=c;break;case "XtoZ":c=a[2];a[2]=a[1];a[1]=a[0];a[0]=c;break;case "YtoX":c=a[0];a[0]=a[1];a[1]=b*c;break;case "YtoZ":c=a[1];a[1]=b*a[2];a[2]=c;break;case "ZtoX":c=a[0];a[0]=a[1];a[1]=a[2];a[2]=c;break;case "ZtoY":c=a[1],a[1]=a[2],a[2]=
-b*c}}function ga(a,b){var c=[a[b],a[b+1],a[b+2]];aa(c,-1);return new THREE.Vector3(c[0],c[1],c[2])}function fa(a){if(Aa.convertUpAxis){var b=[a[0],a[4],a[8]];aa(b,-1);a[0]=b[0];a[4]=b[1];a[8]=b[2];b=[a[1],a[5],a[9]];aa(b,-1);a[1]=b[0];a[5]=b[1];a[9]=b[2];b=[a[2],a[6],a[10]];aa(b,-1);a[2]=b[0];a[6]=b[1];a[10]=b[2];b=[a[0],a[1],a[2]];aa(b,-1);a[0]=b[0];a[1]=b[1];a[2]=b[2];b=[a[4],a[5],a[6]];aa(b,-1);a[4]=b[0];a[5]=b[1];a[6]=b[2];b=[a[8],a[9],a[10]];aa(b,-1);a[8]=b[0];a[9]=b[1];a[10]=b[2];b=[a[3],a[7],
-a[11]];aa(b,-1);a[3]=b[0];a[7]=b[1];a[11]=b[2]}return new THREE.Matrix4(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15])}var S=null,ba=null,$,ca=null,ia={},La={},ja={},za={},qa={},Ga={},Fa={},ab,gb,Ra,Sa,bb,Wa=THREE.SmoothShading,Aa={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y"},Ma="Y",xa=null,Sb=Math.PI/180;g.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if("init_from"==
-c.nodeName)this.init_from=c.textContent}return this};h.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.type="none";for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "skin":this.skin=(new l).parse(c);this.type=c.nodeName;break;case "morph":this.morph=(new i).parse(c),this.type=c.nodeName}}return this};i.prototype.parse=function(a){var b={},c=[],d;this.method=a.getAttribute("method");this.source=a.getAttribute("source").replace(/^#/,
-"");for(d=0;d<a.childNodes.length;d++){var e=a.childNodes[d];if(1==e.nodeType)switch(e.nodeName){case "source":e=(new D).parse(e);b[e.id]=e;break;case "targets":c=this.parseInputs(e);break;default:console.log(e.nodeName)}}for(d=0;d<c.length;d++)switch(a=c[d],e=b[a.source],a.semantic){case "MORPH_TARGET":this.targets=e.read();break;case "MORPH_WEIGHT":this.weights=e.read()}return this};i.prototype.parseInputs=function(a){for(var b=[],c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "input":b.push((new A).parse(d))}}return b};
+[];this.controllers=[];this.transforms=[];this.geometries=[];this.channels=[];this.matrix=new THREE.Matrix4}function o(){this.type=this.sid="";this.data=[];this.obj=null}function n(){this.url="";this.skeleton=[];this.instance_material=[]}function q(){this.target=this.symbol=""}function m(){this.url="";this.instance_material=[]}function r(){this.id="";this.mesh=null}function s(a){this.geometry=a.id;this.primitives=[];this.geometry3js=this.vertices=null}function t(){}function u(){this.material="";this.count=
+0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function x(){this.source="";this.stride=this.count=0;this.params=[]}function w(){this.input={}}function A(){this.semantic="";this.offset=0;this.source="";this.set=0}function D(a){this.id=a;this.type=null}function B(){this.name=this.id="";this.instance_effect=null}function C(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texOpts=this.texcoord=this.texture=null}
+function G(a,b){this.type=a;this.effect=b;this.material=null}function K(a){this.effect=a;this.format=this.init_from=null}function L(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function T(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function M(){this.url=""}function E(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function j(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=
+this.arrSyntax=this.dotSyntax=this.sid=this.fullSid=null}function Q(a){this.id="";this.animation=a;this.inputs=[];this.endTime=this.startTime=this.interpolation=this.strideOut=this.output=this.input=null;this.duration=0}function I(a){this.targets=[];this.time=a}function R(a){return"dae"==a?"http://www.collada.org/2005/11/COLLADASchema":null}function y(a){for(var a=P(a),b=[],c=0;c<a.length;c++)b.push(parseFloat(a[c]));return b}function F(a){for(var a=P(a),b=[],c=0;c<a.length;c++)b.push(parseInt(a[c],
+10));return b}function P(a){return a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/)}function $(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function Z(a,b){if(Oa.convertUpAxis&&Ka!==Oa.upAxis)switch(xa){case "XtoY":var c=a[0];a[0]=b*a[1];a[1]=c;break;case "XtoZ":c=a[2];a[2]=a[1];a[1]=a[0];a[0]=c;break;case "YtoX":c=a[0];a[0]=a[1];a[1]=b*c;break;case "YtoZ":c=a[1];a[1]=b*a[2];a[2]=c;break;case "ZtoX":c=a[0];a[0]=a[1];a[1]=a[2];a[2]=c;break;case "ZtoY":c=a[1],a[1]=a[2],a[2]=
+b*c}}function ga(a,b){var c=[a[b],a[b+1],a[b+2]];Z(c,-1);return new THREE.Vector3(c[0],c[1],c[2])}function fa(a){if(Oa.convertUpAxis){var b=[a[0],a[4],a[8]];Z(b,-1);a[0]=b[0];a[4]=b[1];a[8]=b[2];b=[a[1],a[5],a[9]];Z(b,-1);a[1]=b[0];a[5]=b[1];a[9]=b[2];b=[a[2],a[6],a[10]];Z(b,-1);a[2]=b[0];a[6]=b[1];a[10]=b[2];b=[a[0],a[1],a[2]];Z(b,-1);a[0]=b[0];a[1]=b[1];a[2]=b[2];b=[a[4],a[5],a[6]];Z(b,-1);a[4]=b[0];a[5]=b[1];a[6]=b[2];b=[a[8],a[9],a[10]];Z(b,-1);a[8]=b[0];a[9]=b[1];a[10]=b[2];b=[a[3],a[7],a[11]];
+Z(b,-1);a[3]=b[0];a[7]=b[1];a[11]=b[2]}return new THREE.Matrix4(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15])}var S=null,aa=null,ba,ca=null,ha={},Na={},ja={},za={},qa={},Ga={},Ea={},Sa,Ta,Wa,fb,Za,lb=THREE.SmoothShading,Oa={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y"},Ka="Y",xa=null,Sb=Math.PI/180;g.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if("init_from"==c.nodeName)this.init_from=
+c.textContent}return this};h.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.type="none";for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "skin":this.skin=(new l).parse(c);this.type=c.nodeName;break;case "morph":this.morph=(new i).parse(c),this.type=c.nodeName}}return this};i.prototype.parse=function(a){var b={},c=[],d;this.method=a.getAttribute("method");this.source=a.getAttribute("source").replace(/^#/,"");for(d=
+0;d<a.childNodes.length;d++){var e=a.childNodes[d];if(1==e.nodeType)switch(e.nodeName){case "source":e=(new D).parse(e);b[e.id]=e;break;case "targets":c=this.parseInputs(e);break;default:console.log(e.nodeName)}}for(d=0;d<c.length;d++)switch(a=c[d],e=b[a.source],a.semantic){case "MORPH_TARGET":this.targets=e.read();break;case "MORPH_WEIGHT":this.weights=e.read()}return this};i.prototype.parseInputs=function(a){for(var b=[],c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "input":b.push((new A).parse(d))}}return b};
 l.prototype.parse=function(a){var b={},c,d;this.source=a.getAttribute("source").replace(/^#/,"");this.invBindMatrices=[];this.joints=[];this.weights=[];for(var e=0;e<a.childNodes.length;e++){var f=a.childNodes[e];if(1==f.nodeType)switch(f.nodeName){case "bind_shape_matrix":f=y(f.textContent);this.bindShapeMatrix=fa(f);break;case "source":f=(new D).parse(f);b[f.id]=f;break;case "joints":c=f;break;case "vertex_weights":d=f;break;default:console.log(f.nodeName)}}this.parseJoints(c,b);this.parseWeights(d,
 b);return this};l.prototype.parseJoints=function(a,b){for(var c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "input":var d=(new A).parse(d),e=b[d.source];if("JOINT"==d.semantic)this.joints=e.read();else if("INV_BIND_MATRIX"==d.semantic)this.invBindMatrices=e.read()}}};l.prototype.parseWeights=function(a,b){for(var c,d,e=[],f=0;f<a.childNodes.length;f++){var g=a.childNodes[f];if(1==g.nodeType)switch(g.nodeName){case "input":e.push((new A).parse(g));break;
-case "v":c=I(g.textContent);break;case "vcount":d=I(g.textContent)}}for(f=g=0;f<d.length;f++){for(var h=d[f],i=[],j=0;j<h;j++){for(var k={},l=0;l<e.length;l++){var m=e[l],n=c[g+m.offset];switch(m.semantic){case "JOINT":k.joint=n;break;case "WEIGHT":k.weight=b[m.source].data[n]}}i.push(k);g+=e.length}for(j=0;j<i.length;j++)i[j].index=f;this.weights.push(i)}};k.prototype.getChildById=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,b);if(d)return d}return null};
+case "v":c=F(g.textContent);break;case "vcount":d=F(g.textContent)}}for(f=g=0;f<d.length;f++){for(var h=d[f],j=[],i=0;i<h;i++){for(var l={},k=0;k<e.length;k++){var m=e[k],o=c[g+m.offset];switch(m.semantic){case "JOINT":l.joint=o;break;case "WEIGHT":l.weight=b[m.source].data[o]}}j.push(l);g+=e.length}for(i=0;i<j.length;i++)j[i].index=f;this.weights.push(j)}};k.prototype.getChildById=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,b);if(d)return d}return null};
 k.prototype.getChildBySid=function(a,b){for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};k.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.nodes=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "node":this.nodes.push((new p).parse(c))}}return this};p.prototype.getChannelForTransform=function(a){for(var b=0;b<this.channels.length;b++){var c=this.channels[b],
 d=c.target.split("/");d.shift();var e=d.shift(),f=0<=e.indexOf("."),g=0<=e.indexOf("("),h;if(f)d=e.split("."),e=d.shift(),d.shift();else if(g){h=e.split("(");e=h.shift();for(d=0;d<h.length;d++)h[d]=parseInt(h[d].replace(/\)/,""))}if(e==a)return c.info={sid:e,dotSyntax:f,arrSyntax:g,arrIndices:h},c}return null};p.prototype.getChildById=function(a,b){if(this.id==a)return this;if(b)for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildById(a,b);if(d)return d}return null};p.prototype.getChildBySid=
 function(a,b){if(this.sid==a)return this;if(b)for(var c=0;c<this.nodes.length;c++){var d=this.nodes[c].getChildBySid(a,b);if(d)return d}return null};p.prototype.getTransformBySid=function(a){for(var b=0;b<this.transforms.length;b++)if(this.transforms[b].sid==a)return this.transforms[b];return null};p.prototype.parse=function(a){var b;this.id=a.getAttribute("id");this.sid=a.getAttribute("sid");this.name=a.getAttribute("name");this.type=a.getAttribute("type");this.type="JOINT"==this.type?this.type:
-"NODE";this.nodes=[];this.transforms=[];this.geometries=[];this.controllers=[];this.matrix=new THREE.Matrix4;for(var c=0;c<a.childNodes.length;c++)if(b=a.childNodes[c],1==b.nodeType)switch(b.nodeName){case "node":this.nodes.push((new p).parse(b));break;case "instance_camera":break;case "instance_controller":this.controllers.push((new o).parse(b));break;case "instance_geometry":this.geometries.push((new m).parse(b));break;case "instance_light":break;case "instance_node":b=b.getAttribute("url").replace(/^#/,
-"");(b=S.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",S,V,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new p).parse(b));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new n).parse(b));break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in ja)for(var e=ja[d],f=0;f<e.channel.length;f++){var g=e.channel[f],h=e.sampler[f];d=g.target.split("/")[0];if(d==this.id)h.create(),
-g.sampler=h,c=Math.min(c,h.startTime),b=Math.max(b,h.endTime),a.push(g)}if(a.length)this.startTime=c,this.endTime=b;if((this.channels=a)&&this.channels.length){d=[];a=[];c=0;for(e=this.channels.length;c<e;c++){b=this.channels[c];f=b.fullSid;g=b.member;if(Aa.convertUpAxis)switch(g){case "X":switch(xa){case "XtoY":case "XtoZ":case "YtoX":g="Y";break;case "ZtoX":g="Z"}break;case "Y":switch(xa){case "XtoY":case "YtoX":case "ZtoX":g="X";break;case "XtoZ":case "YtoZ":case "ZtoY":g="Z"}break;case "Z":switch(xa){case "XtoZ":g=
-"X";break;case "YtoZ":case "ZtoX":case "ZtoY":g="Y"}}var h=b.sampler,i=h.input,j=this.getTransformBySid(b.sid);if(j){-1===a.indexOf(f)&&a.push(f);b=0;for(var k=i.length;b<k;b++){var l=i[b],q=h.getData(j.type,b),r;r=null;for(var s=0,t=d.length;s<t&&null==r;s++){var u=d[s];if(u.time===l)r=u;else if(u.time>l)break}if(!r){r=new H(l);s=-1;t=0;for(u=d.length;t<u&&-1==s;t++)d[t].time>=l&&(s=t);l=s;d.splice(-1==l?d.length:l,0,r)}r.addTarget(f,j,g,q)}}else console.log('Could not find transform "'+b.sid+'" in node '+
-this.id)}for(c=0;c<a.length;c++){e=a[c];for(b=0;b<d.length;b++)if(r=d[b],!r.hasTarget(e)){h=d;f=r;j=b;g=e;i=void 0;a:{i=j?j-1:0;for(i=0<=i?i:i+h.length;0<=i;i--)if(k=h[i],k.hasTarget(g)){i=k;break a}i=null}k=void 0;a:{for(j+=1;j<h.length;j++)if(k=h[j],k.hasTarget(g))break a;k=null}if(i&&k){h=(f.time-i.time)/(k.time-i.time);i=i.getTarget(g);j=k.getTarget(g).data;k=i.data;q=void 0;if(k.length){q=[];for(l=0;l<k.length;++l)q[l]=k[l]+(j[l]-k[l])*h}else q=k+(j-k)*h;f.addTarget(g,i.transform,i.member,q)}}}this.keys=
-d;this.sids=a}this.updateMatrix();return this};p.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a<this.transforms.length;a++)this.transforms[a].apply(this.matrix)};n.prototype.parse=function(a){this.sid=a.getAttribute("sid");this.type=a.nodeName;this.data=y(a.textContent);this.convert();return this};n.prototype.convert=function(){switch(this.type){case "matrix":this.obj=fa(this.data);break;case "rotate":this.angle=this.data[3]*Sb;case "translate":aa(this.data,-1);this.obj=new THREE.Vector3(this.data[0],
-this.data[1],this.data[2]);break;case "scale":aa(this.data,1);this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;default:console.log("Can not convert Transform of type "+this.type)}};n.prototype.apply=function(a){switch(this.type){case "matrix":a.multiplySelf(this.obj);break;case "translate":a.translate(this.obj);break;case "rotate":a.rotateByAxis(this.obj,this.angle);break;case "scale":a.scale(this.obj)}};n.prototype.update=function(a,b){switch(this.type){case "matrix":console.log("Currently not handling matrix transform updates");
-break;case "translate":case "scale":switch(b){case "X":this.obj.x=a;break;case "Y":this.obj.y=a;break;case "Z":this.obj.z=a;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2]}break;case "rotate":switch(b){case "X":this.obj.x=a;break;case "Y":this.obj.y=a;break;case "Z":this.obj.z=a;break;case "ANGLE":this.angle=a*Sb;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2],this.angle=a[3]*Sb}}};o.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.skeleton=
-[];this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "skeleton":this.skeleton.push(c.textContent.replace(/^#/,""));break;case "bind_material":if(c=S.evaluate(".//dae:instance_material",c,V,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(var d=c.iterateNext();d;)this.instance_material.push((new q).parse(d)),d=c.iterateNext()}}return this};q.prototype.parse=function(a){this.symbol=a.getAttribute("symbol");this.target=a.getAttribute("target").replace(/^#/,
-"");return this};m.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType&&"bind_material"==c.nodeName){if(a=S.evaluate(".//dae:instance_material",c,V,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(b=a.iterateNext();b;)this.instance_material.push((new q).parse(b)),b=a.iterateNext();break}}return this};r.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<
-a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "mesh":this.mesh=(new s(this)).parse(c)}}return this};s.prototype.parse=function(a){this.primitives=[];var b;for(b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "source":var d=c.getAttribute("id");void 0==ia[d]&&(ia[d]=(new D(d)).parse(c));break;case "vertices":this.vertices=(new v).parse(c);break;case "triangles":this.primitives.push((new u).parse(c));break;case "polygons":console.warn("polygon holes not yet supported!");
-case "polylist":this.primitives.push((new t).parse(c))}}this.geometry3js=new THREE.Geometry;a=ia[this.vertices.input.POSITION.source].data;for(b=0;b<a.length;b+=3)this.geometry3js.vertices.push(new THREE.Vertex(ga(a,b)));for(b=0;b<this.primitives.length;b++)a=this.primitives[b],a.setVertices(this.vertices),this.handlePrimitive(a,this.geometry3js);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();
-return this};s.prototype.handlePrimitive=function(a,b){var c=0,d,e,f=a.p,g=a.inputs,h,i,j,k,l=0,m=3,n=[];for(d=0;d<g.length;d++)switch(h=g[d],h.semantic){case "TEXCOORD":n.push(h.set)}for(;c<f.length;){var o=[],p=[],q={},r=[];a.vcount&&(m=a.vcount[l++]);for(d=0;d<m;d++)for(e=0;e<g.length;e++)switch(h=g[e],k=ia[h.source],i=f[c+d*g.length+h.offset],j=k.accessor.params.length,j*=i,h.semantic){case "VERTEX":o.push(i);break;case "NORMAL":p.push(ga(k.data,j));break;case "TEXCOORD":void 0===q[h.set]&&(q[h.set]=
-[]);q[h.set].push(new THREE.UV(k.data[j],1-k.data[j+1]));break;case "COLOR":r.push((new THREE.Color).setRGB(k.data[j],k.data[j+1],k.data[j+2]))}e=null;d=[];if(3===m)d.push(new THREE.Face3(o[0],o[1],o[2],[p[0],p[1],p[2]],r.length?r:new THREE.Color));else if(4===m)d.push(new THREE.Face4(o[0],o[1],o[2],o[3],[p[0],p[1],p[2],p[3]],r.length?r:new THREE.Color));else if(4<m&&Aa.subdivideFaces){r=r.length?r:new THREE.Color;for(e=1;e<m-1;)d.push(new THREE.Face3(o[0],o[e],o[e+1],[p[0],p[e++],p[e]],r))}if(d.length){o=
-0;for(p=d.length;o<p;o++){e=d[o];e.daeMaterial=a.material;b.faces.push(e);for(e=0;e<n.length;e++)r=q[n[e]],r=4<m?[r[0],r[o+1],r[o+2]]:4===m?[r[0],r[1],r[2],r[3]]:[r[0],r[1],r[2]],b.faceVertexUvs[e]||(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(r)}}else console.log("dropped face with vcount "+m+" for geometry with id: "+b.id);c+=g.length*m}};t.prototype=new u;t.prototype.constructor=t;u.prototype.setVertices=function(a){for(var b=0;b<this.inputs.length;b++)if(this.inputs[b].source==a.id)this.inputs[b].source=
-a.input.POSITION.source};u.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=T(a,"count",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "input":this.inputs.push((new A).parse(a.childNodes[b]));break;case "vcount":this.vcount=I(c.textContent);break;case "p":this.p=I(c.textContent)}}return this};x.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=T(a,"count",0);this.stride=
-T(a,"stride",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if("param"==c.nodeName){var d={};d.name=c.getAttribute("name");d.type=c.getAttribute("type");this.params.push(d)}}return this};v.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++)if("input"==a.childNodes[b].nodeName){var c=(new A).parse(a.childNodes[b]);this.input[c.semantic]=c}return this};A.prototype.parse=function(a){this.semantic=a.getAttribute("semantic");this.source=a.getAttribute("source").replace(/^#/,
-"");this.set=T(a,"set",-1);this.offset=T(a,"offset",0);if("TEXCOORD"==this.semantic&&0>this.set)this.set=0;return this};D.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "bool_array":for(var d=O(c.textContent),e=[],f=0;f<d.length;f++)e.push("true"==d[f]||"1"==d[f]?!0:!1);this.data=e;this.type=c.nodeName;break;case "float_array":this.data=y(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=
-I(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=O(c.textContent);this.type=c.nodeName;break;case "technique_common":for(d=0;d<c.childNodes.length;d++)if("accessor"==c.childNodes[d].nodeName){this.accessor=(new x).parse(c.childNodes[d]);break}}}return this};D.prototype.read=function(){var a=[],b=this.accessor.params[0];switch(b.type){case "IDREF":case "Name":case "name":case "float":return this.data;case "float4x4":for(b=0;b<this.data.length;b+=16){var c=
-this.data.slice(b,b+16),c=fa(c);a.push(c)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};E.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");for(var b=0;b<a.childNodes.length;b++)if("instance_effect"==a.childNodes[b].nodeName){this.instance_effect=(new N).parse(a.childNodes[b]);break}return this};C.prototype.isColor=function(){return null==this.texture};C.prototype.isTexture=function(){return null!=this.texture};
+"NODE";this.nodes=[];this.transforms=[];this.geometries=[];this.controllers=[];this.matrix=new THREE.Matrix4;for(var c=0;c<a.childNodes.length;c++)if(b=a.childNodes[c],1==b.nodeType)switch(b.nodeName){case "node":this.nodes.push((new p).parse(b));break;case "instance_camera":break;case "instance_controller":this.controllers.push((new n).parse(b));break;case "instance_geometry":this.geometries.push((new m).parse(b));break;case "instance_light":break;case "instance_node":b=b.getAttribute("url").replace(/^#/,
+"");(b=S.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",S,R,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new p).parse(b));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new o).parse(b));break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in ja)for(var e=ja[d],f=0;f<e.channel.length;f++){var g=e.channel[f],h=e.sampler[f];d=g.target.split("/")[0];if(d==this.id)h.create(),
+g.sampler=h,c=Math.min(c,h.startTime),b=Math.max(b,h.endTime),a.push(g)}if(a.length)this.startTime=c,this.endTime=b;if((this.channels=a)&&this.channels.length){d=[];a=[];c=0;for(e=this.channels.length;c<e;c++){b=this.channels[c];f=b.fullSid;g=b.member;if(Oa.convertUpAxis)switch(g){case "X":switch(xa){case "XtoY":case "XtoZ":case "YtoX":g="Y";break;case "ZtoX":g="Z"}break;case "Y":switch(xa){case "XtoY":case "YtoX":case "ZtoX":g="X";break;case "XtoZ":case "YtoZ":case "ZtoY":g="Z"}break;case "Z":switch(xa){case "XtoZ":g=
+"X";break;case "YtoZ":case "ZtoX":case "ZtoY":g="Y"}}var h=b.sampler,i=h.input,j=this.getTransformBySid(b.sid);if(j){-1===a.indexOf(f)&&a.push(f);b=0;for(var l=i.length;b<l;b++){var k=i[b],q=h.getData(j.type,b),r;r=null;for(var s=0,t=d.length;s<t&&null==r;s++){var u=d[s];if(u.time===k)r=u;else if(u.time>k)break}if(!r){r=new I(k);s=-1;t=0;for(u=d.length;t<u&&-1==s;t++)d[t].time>=k&&(s=t);k=s;d.splice(-1==k?d.length:k,0,r)}r.addTarget(f,j,g,q)}}else console.log('Could not find transform "'+b.sid+'" in node '+
+this.id)}for(c=0;c<a.length;c++){e=a[c];for(b=0;b<d.length;b++)if(r=d[b],!r.hasTarget(e)){h=d;f=r;j=b;g=e;i=void 0;a:{i=j?j-1:0;for(i=0<=i?i:i+h.length;0<=i;i--)if(l=h[i],l.hasTarget(g)){i=l;break a}i=null}l=void 0;a:{for(j+=1;j<h.length;j++)if(l=h[j],l.hasTarget(g))break a;l=null}if(i&&l){h=(f.time-i.time)/(l.time-i.time);i=i.getTarget(g);j=l.getTarget(g).data;l=i.data;q=void 0;if(l.length){q=[];for(k=0;k<l.length;++k)q[k]=l[k]+(j[k]-l[k])*h}else q=l+(j-l)*h;f.addTarget(g,i.transform,i.member,q)}}}this.keys=
+d;this.sids=a}this.updateMatrix();return this};p.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a<this.transforms.length;a++)this.transforms[a].apply(this.matrix)};o.prototype.parse=function(a){this.sid=a.getAttribute("sid");this.type=a.nodeName;this.data=y(a.textContent);this.convert();return this};o.prototype.convert=function(){switch(this.type){case "matrix":this.obj=fa(this.data);break;case "rotate":this.angle=this.data[3]*Sb;case "translate":Z(this.data,-1);this.obj=new THREE.Vector3(this.data[0],
+this.data[1],this.data[2]);break;case "scale":Z(this.data,1);this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;default:console.log("Can not convert Transform of type "+this.type)}};o.prototype.apply=function(a){switch(this.type){case "matrix":a.multiplySelf(this.obj);break;case "translate":a.translate(this.obj);break;case "rotate":a.rotateByAxis(this.obj,this.angle);break;case "scale":a.scale(this.obj)}};o.prototype.update=function(a,b){switch(this.type){case "matrix":console.log("Currently not handling matrix transform updates");
+break;case "translate":case "scale":switch(b){case "X":this.obj.x=a;break;case "Y":this.obj.y=a;break;case "Z":this.obj.z=a;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2]}break;case "rotate":switch(b){case "X":this.obj.x=a;break;case "Y":this.obj.y=a;break;case "Z":this.obj.z=a;break;case "ANGLE":this.angle=a*Sb;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2],this.angle=a[3]*Sb}}};n.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.skeleton=
+[];this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "skeleton":this.skeleton.push(c.textContent.replace(/^#/,""));break;case "bind_material":if(c=S.evaluate(".//dae:instance_material",c,R,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(var d=c.iterateNext();d;)this.instance_material.push((new q).parse(d)),d=c.iterateNext()}}return this};q.prototype.parse=function(a){this.symbol=a.getAttribute("symbol");this.target=a.getAttribute("target").replace(/^#/,
+"");return this};m.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");this.instance_material=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType&&"bind_material"==c.nodeName){if(a=S.evaluate(".//dae:instance_material",c,R,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(b=a.iterateNext();b;)this.instance_material.push((new q).parse(b)),b=a.iterateNext();break}}return this};r.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<
+a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "mesh":this.mesh=(new s(this)).parse(c)}}return this};s.prototype.parse=function(a){this.primitives=[];var b;for(b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "source":var d=c.getAttribute("id");void 0==ha[d]&&(ha[d]=(new D(d)).parse(c));break;case "vertices":this.vertices=(new w).parse(c);break;case "triangles":this.primitives.push((new u).parse(c));break;case "polygons":console.warn("polygon holes not yet supported!");
+case "polylist":this.primitives.push((new t).parse(c))}}this.geometry3js=new THREE.Geometry;a=ha[this.vertices.input.POSITION.source].data;for(b=0;b<a.length;b+=3)this.geometry3js.vertices.push(new THREE.Vertex(ga(a,b)));for(b=0;b<this.primitives.length;b++)a=this.primitives[b],a.setVertices(this.vertices),this.handlePrimitive(a,this.geometry3js);this.geometry3js.computeCentroids();this.geometry3js.computeFaceNormals();this.geometry3js.computeVertexNormals();this.geometry3js.computeBoundingBox();
+return this};s.prototype.handlePrimitive=function(a,b){var c=0,d,e,f=a.p,g=a.inputs,h,i,j,l,k=0,m=3,o=[];for(d=0;d<g.length;d++)switch(h=g[d],h.semantic){case "TEXCOORD":o.push(h.set)}for(;c<f.length;){var n=[],p=[],q={},r=[];a.vcount&&(m=a.vcount[k++]);for(d=0;d<m;d++)for(e=0;e<g.length;e++)switch(h=g[e],l=ha[h.source],i=f[c+d*g.length+h.offset],j=l.accessor.params.length,j*=i,h.semantic){case "VERTEX":n.push(i);break;case "NORMAL":p.push(ga(l.data,j));break;case "TEXCOORD":void 0===q[h.set]&&(q[h.set]=
+[]);q[h.set].push(new THREE.UV(l.data[j],1-l.data[j+1]));break;case "COLOR":r.push((new THREE.Color).setRGB(l.data[j],l.data[j+1],l.data[j+2]))}e=null;d=[];if(3===m)d.push(new THREE.Face3(n[0],n[1],n[2],[p[0],p[1],p[2]],r.length?r:new THREE.Color));else if(4===m)d.push(new THREE.Face4(n[0],n[1],n[2],n[3],[p[0],p[1],p[2],p[3]],r.length?r:new THREE.Color));else if(4<m&&Oa.subdivideFaces){r=r.length?r:new THREE.Color;for(e=1;e<m-1;)d.push(new THREE.Face3(n[0],n[e],n[e+1],[p[0],p[e++],p[e]],r))}if(d.length){n=
+0;for(p=d.length;n<p;n++){e=d[n];e.daeMaterial=a.material;b.faces.push(e);for(e=0;e<o.length;e++)r=q[o[e]],r=4<m?[r[0],r[n+1],r[n+2]]:4===m?[r[0],r[1],r[2],r[3]]:[r[0],r[1],r[2]],b.faceVertexUvs[e]||(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(r)}}else console.log("dropped face with vcount "+m+" for geometry with id: "+b.id);c+=g.length*m}};t.prototype=new u;t.prototype.constructor=t;u.prototype.setVertices=function(a){for(var b=0;b<this.inputs.length;b++)if(this.inputs[b].source==a.id)this.inputs[b].source=
+a.input.POSITION.source};u.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=$(a,"count",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "input":this.inputs.push((new A).parse(a.childNodes[b]));break;case "vcount":this.vcount=F(c.textContent);break;case "p":this.p=F(c.textContent)}}return this};x.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=$(a,"count",0);this.stride=
+$(a,"stride",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if("param"==c.nodeName){var d={};d.name=c.getAttribute("name");d.type=c.getAttribute("type");this.params.push(d)}}return this};w.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++)if("input"==a.childNodes[b].nodeName){var c=(new A).parse(a.childNodes[b]);this.input[c.semantic]=c}return this};A.prototype.parse=function(a){this.semantic=a.getAttribute("semantic");this.source=a.getAttribute("source").replace(/^#/,
+"");this.set=$(a,"set",-1);this.offset=$(a,"offset",0);if("TEXCOORD"==this.semantic&&0>this.set)this.set=0;return this};D.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "bool_array":for(var d=P(c.textContent),e=[],f=0;f<d.length;f++)e.push("true"==d[f]||"1"==d[f]?!0:!1);this.data=e;this.type=c.nodeName;break;case "float_array":this.data=y(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=
+F(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=P(c.textContent);this.type=c.nodeName;break;case "technique_common":for(d=0;d<c.childNodes.length;d++)if("accessor"==c.childNodes[d].nodeName){this.accessor=(new x).parse(c.childNodes[d]);break}}}return this};D.prototype.read=function(){var a=[],b=this.accessor.params[0];switch(b.type){case "IDREF":case "Name":case "name":case "float":return this.data;case "float4x4":for(b=0;b<this.data.length;b+=16){var c=
+this.data.slice(b,b+16),c=fa(c);a.push(c)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};B.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");for(var b=0;b<a.childNodes.length;b++)if("instance_effect"==a.childNodes[b].nodeName){this.instance_effect=(new M).parse(a.childNodes[b]);break}return this};C.prototype.isColor=function(){return null==this.texture};C.prototype.isTexture=function(){return null!=this.texture};
 C.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "color":c=y(c.textContent);this.color=new THREE.Color(0);this.color.setRGB(c[0],c[1],c[2]);this.color.a=c[3];break;case "texture":this.texture=c.getAttribute("texture"),this.texcoord=c.getAttribute("texcoord"),this.texOpts={offsetU:0,offsetV:0,repeatU:1,repeatV:1,wrapU:1,wrapV:1},this.parseTexture(c)}}return this};C.prototype.parseTexture=function(a){if(!a.childNodes)return this;
-a.childNodes[1]&&"extra"===a.childNodes[1].nodeName&&(a=a.childNodes[1],a.childNodes[1]&&"technique"===a.childNodes[1].nodeName&&(a=a.childNodes[1]));for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "offsetU":case "offsetV":case "repeatU":case "repeatV":this.texOpts[c.nodeName]=parseFloat(c.textContent);break;case "wrapU":case "wrapV":this.texOpts[c.nodeName]=parseInt(c.textContent);break;default:this.texOpts[c.nodeName]=c.textContent}}return this};F.prototype.parse=
-function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[c.nodeName]=(new C).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=S.evaluate(".//dae:float",c,V,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var e=d.iterateNext(),f=[];e;)f.push(e),e=d.iterateNext();d=f;0<d.length&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();
-return this};F.prototype.create=function(){var a={},b=void 0!==this.transparency&&1>this.transparency,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof C)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=La[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture(Ra+e.init_from),e.wrapS=d.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,
-e.wrapT=d.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.offset.x=d.texOpts.offsetU,e.offset.y=d.texOpts.offsetV,e.repeat.x=d.texOpts.repeatU,e.repeat.y=d.texOpts.repeatV,a.map=e}}else"diffuse"==c?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=Wa;return this.material=new THREE.MeshLambertMaterial(a)};K.prototype.parse=function(a){for(var b=0;b<
+a.childNodes[1]&&"extra"===a.childNodes[1].nodeName&&(a=a.childNodes[1],a.childNodes[1]&&"technique"===a.childNodes[1].nodeName&&(a=a.childNodes[1]));for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "offsetU":case "offsetV":case "repeatU":case "repeatV":this.texOpts[c.nodeName]=parseFloat(c.textContent);break;case "wrapU":case "wrapV":this.texOpts[c.nodeName]=parseInt(c.textContent);break;default:this.texOpts[c.nodeName]=c.textContent}}return this};G.prototype.parse=
+function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[c.nodeName]=(new C).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=S.evaluate(".//dae:float",c,R,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var e=d.iterateNext(),f=[];e;)f.push(e),e=d.iterateNext();d=f;0<d.length&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();
+return this};G.prototype.create=function(){var a={},b=void 0!==this.transparency&&1>this.transparency,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof C)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=Na[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture(Wa+e.init_from),e.wrapS=d.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,
+e.wrapT=d.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,e.offset.x=d.texOpts.offsetU,e.offset.y=d.texOpts.offsetV,e.repeat.x=d.texOpts.repeatU,e.repeat.y=d.texOpts.repeatV,a.map=e}}else"diffuse"==c?a.color=d.color.getHex():b||(a[c]=d.color.getHex());break;case "shininess":case "reflectivity":a[c]=this[c];break;case "transparency":if(b)a.transparent=!0,a.opacity=this[c],b=!0}a.shading=lb;return this.material=new THREE.MeshLambertMaterial(a)};K.prototype.parse=function(a){for(var b=0;b<
 a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "init_from":this.init_from=c.textContent;break;case "format":this.format=c.textContent;break;default:console.log("unhandled Surface prop: "+c.nodeName)}}return this};L.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "source":this.source=c.textContent;break;case "minfilter":this.minfilter=c.textContent;break;case "magfilter":this.magfilter=
-c.textContent;break;case "mipfilter":this.mipfilter=c.textContent;break;case "wrap_s":this.wrap_s=c.textContent;break;case "wrap_t":this.wrap_t=c.textContent;break;default:console.log("unhandled Sampler2D prop: "+c.nodeName)}}return this};R.prototype.create=function(){if(null==this.shader)return null};R.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.shader=null;for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(c))}}return this};
-R.prototype.parseNewparam=function(a){for(var b=a.getAttribute("sid"),c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "surface":this.surface=(new K(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new L(this)).parse(d);this.sampler.sid=b;break;case "extra":break;default:console.log(d.nodeName)}}};R.prototype.parseProfileCOMMON=function(a){for(var b,c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "profile_COMMON":this.parseProfileCOMMON(d);
-break;case "technique":b=d;break;case "newparam":this.parseNewparam(d);break;case "extra":break;default:console.log(d.nodeName)}}return b};R.prototype.parseTechnique=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "constant":case "lambert":case "blinn":case "phong":this.shader=(new F(c.nodeName,this)).parse(c)}}};N.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};P.prototype.parse=function(a){this.id=
-a.getAttribute("id");this.name=a.getAttribute("name");this.source={};for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "source":c=(new D).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new j(this)).parse(c));break;case "channel":this.channel.push((new B(this)).parse(c))}}return this};B.prototype.parse=function(a){this.source=a.getAttribute("source").replace(/^#/,"");this.target=a.getAttribute("target");var b=this.target.split("/");
-b.shift();var a=b.shift(),c=0<=a.indexOf("."),d=0<=a.indexOf("(");if(c)b=a.split("."),this.sid=b.shift(),this.member=b.shift();else if(d){b=a.split("(");this.sid=b.shift();for(var e=0;e<b.length;e++)b[e]=parseInt(b[e].replace(/\)/,""));this.arrIndices=b}else this.sid=a;this.fullSid=a;this.dotSyntax=c;this.arrSyntax=d;return this};j.prototype.parse=function(a){this.id=a.getAttribute("id");this.inputs=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "input":this.inputs.push((new A).parse(c))}}return this};
-j.prototype.create=function(){for(var a=0;a<this.inputs.length;a++){var b=this.inputs[a],c=this.animation.source[b.source];switch(b.semantic){case "INPUT":this.input=c.read();break;case "OUTPUT":this.output=c.read();this.strideOut=c.accessor.stride;break;case "INTERPOLATION":this.interpolation=c.read();break;case "IN_TANGENT":break;case "OUT_TANGENT":break;default:console.log(b.semantic)}}this.duration=this.endTime=this.startTime=0;if(this.input.length){this.startTime=1E8;this.endTime=-1E8;for(a=
-0;a<this.input.length;a++)this.startTime=Math.min(this.startTime,this.input[a]),this.endTime=Math.max(this.endTime,this.input[a]);this.duration=this.endTime-this.startTime}};j.prototype.getData=function(a,b){var c;if(1<this.strideOut){c=[];for(var b=b*this.strideOut,d=0;d<this.strideOut;++d)c[d]=this.output[b+d];if(3===this.strideOut)switch(a){case "rotate":case "translate":aa(c,-1);break;case "scale":aa(c,1)}}else c=this.output[b];return c};H.prototype.addTarget=function(a,b,c,d){this.targets.push({sid:a,
-member:c,transform:b,data:d})};H.prototype.apply=function(a){for(var b=0;b<this.targets.length;++b){var c=this.targets[b];(!a||c.sid===a)&&c.transform.update(c.data,c.member)}};H.prototype.getTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return this.targets[b];return null};H.prototype.hasTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return!0;return!1};H.prototype.interpolate=function(a,b){for(var c=0;c<this.targets.length;++c){var d=
+c.textContent;break;case "mipfilter":this.mipfilter=c.textContent;break;case "wrap_s":this.wrap_s=c.textContent;break;case "wrap_t":this.wrap_t=c.textContent;break;default:console.log("unhandled Sampler2D prop: "+c.nodeName)}}return this};T.prototype.create=function(){if(null==this.shader)return null};T.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.shader=null;for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(c))}}return this};
+T.prototype.parseNewparam=function(a){for(var b=a.getAttribute("sid"),c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "surface":this.surface=(new K(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new L(this)).parse(d);this.sampler.sid=b;break;case "extra":break;default:console.log(d.nodeName)}}};T.prototype.parseProfileCOMMON=function(a){for(var b,c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "profile_COMMON":this.parseProfileCOMMON(d);
+break;case "technique":b=d;break;case "newparam":this.parseNewparam(d);break;case "extra":break;default:console.log(d.nodeName)}}return b};T.prototype.parseTechnique=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "constant":case "lambert":case "blinn":case "phong":this.shader=(new G(c.nodeName,this)).parse(c)}}};M.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};E.prototype.parse=function(a){this.id=
+a.getAttribute("id");this.name=a.getAttribute("name");this.source={};for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "source":c=(new D).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new Q(this)).parse(c));break;case "channel":this.channel.push((new j(this)).parse(c))}}return this};j.prototype.parse=function(a){this.source=a.getAttribute("source").replace(/^#/,"");this.target=a.getAttribute("target");var b=this.target.split("/");
+b.shift();var a=b.shift(),c=0<=a.indexOf("."),d=0<=a.indexOf("(");if(c)b=a.split("."),this.sid=b.shift(),this.member=b.shift();else if(d){b=a.split("(");this.sid=b.shift();for(var e=0;e<b.length;e++)b[e]=parseInt(b[e].replace(/\)/,""));this.arrIndices=b}else this.sid=a;this.fullSid=a;this.dotSyntax=c;this.arrSyntax=d;return this};Q.prototype.parse=function(a){this.id=a.getAttribute("id");this.inputs=[];for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "input":this.inputs.push((new A).parse(c))}}return this};
+Q.prototype.create=function(){for(var a=0;a<this.inputs.length;a++){var b=this.inputs[a],c=this.animation.source[b.source];switch(b.semantic){case "INPUT":this.input=c.read();break;case "OUTPUT":this.output=c.read();this.strideOut=c.accessor.stride;break;case "INTERPOLATION":this.interpolation=c.read();break;case "IN_TANGENT":break;case "OUT_TANGENT":break;default:console.log(b.semantic)}}this.duration=this.endTime=this.startTime=0;if(this.input.length){this.startTime=1E8;this.endTime=-1E8;for(a=
+0;a<this.input.length;a++)this.startTime=Math.min(this.startTime,this.input[a]),this.endTime=Math.max(this.endTime,this.input[a]);this.duration=this.endTime-this.startTime}};Q.prototype.getData=function(a,b){var c;if(1<this.strideOut){c=[];for(var b=b*this.strideOut,d=0;d<this.strideOut;++d)c[d]=this.output[b+d];if(3===this.strideOut)switch(a){case "rotate":case "translate":Z(c,-1);break;case "scale":Z(c,1)}}else c=this.output[b];return c};I.prototype.addTarget=function(a,b,c,d){this.targets.push({sid:a,
+member:c,transform:b,data:d})};I.prototype.apply=function(a){for(var b=0;b<this.targets.length;++b){var c=this.targets[b];(!a||c.sid===a)&&c.transform.update(c.data,c.member)}};I.prototype.getTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return this.targets[b];return null};I.prototype.hasTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return!0;return!1};I.prototype.interpolate=function(a,b){for(var c=0;c<this.targets.length;++c){var d=
 this.targets[c],e=a.getTarget(d.sid);if(e){var f=(b-this.time)/(a.time-this.time),g=e.data,h=d.data;if(0>f||1<f)console.log("Key.interpolate: Warning! Scale out of bounds:"+f),f=0>f?0:1;if(h.length)for(var e=[],i=0;i<h.length;++i)e[i]=h[i]+(g[i]-h[i])*f;else e=h+(g-h)*f}else e=d.data;d.transform.update(e,d.member)}};return{load:function(b,c,d){var e=0;if(document.implementation&&document.implementation.createDocument){var f=new XMLHttpRequest;f.overrideMimeType&&f.overrideMimeType("text/xml");f.onreadystatechange=
-function(){if(4==f.readyState){if(0==f.status||200==f.status)f.responseXML?(ca=c,a(f.responseXML,void 0,b)):console.error("ColladaLoader: Empty or non-existing file ("+b+")")}else 3==f.readyState&&d&&(0==e&&(e=f.getResponseHeader("Content-Length")),d({total:e,loaded:f.responseText.length}))};f.open("GET",b,!0);f.send(null)}else alert("Don't know how to parse XML!")},parse:a,setPreferredShading:function(a){Wa=a},applySkin:e,geometries:qa,options:Aa}};
+function(){if(4==f.readyState){if(0==f.status||200==f.status)f.responseXML?(ca=c,a(f.responseXML,void 0,b)):console.error("ColladaLoader: Empty or non-existing file ("+b+")")}else 3==f.readyState&&d&&(0==e&&(e=f.getResponseHeader("Content-Length")),d({total:e,loaded:f.responseText.length}))};f.open("GET",b,!0);f.send(null)}else alert("Don't know how to parse XML!")},parse:a,setPreferredShading:function(a){lb=a},applySkin:e,geometries:qa,options:Oa}};
 THREE.JSONLoader=function(a){THREE.Loader.call(this,a)};THREE.JSONLoader.prototype=new THREE.Loader;THREE.JSONLoader.prototype.constructor=THREE.JSONLoader;THREE.JSONLoader.prototype.supr=THREE.Loader.prototype;
 THREE.JSONLoader.prototype.load=function(a,b,c){if(a instanceof Object)console.warn("DEPRECATED: JSONLoader( parameters ) is now JSONLoader( url, callback, texturePath )."),c=a,a=c.model,b=c.callback,c=c.texture_path;c=c?c:this.extractUrlbase(a);this.onLoadStart();this.loadAjaxJSON(this,a,b,c)};
 THREE.JSONLoader.prototype.loadAjaxJSON=function(a,b,c,d,e){var f=new XMLHttpRequest,g=0;f.onreadystatechange=function(){if(4==f.readyState)if(200==f.status||0==f.status){try{var h=JSON.parse(f.responseText)}catch(i){console.warn("DEPRECATED: ["+b+"] seems to be using old model format")}a.createModel(h,c,d);a.onLoadComplete()}else console.error("Couldn't load ["+b+"] ["+f.status+"]");else 3==f.readyState?e&&(0==g&&(g=f.getResponseHeader("Content-Length")),e({total:g,loaded:f.responseText.length})):
 2==f.readyState&&(g=f.getResponseHeader("Content-Length"))};f.open("GET",b,!0);f.overrideMimeType&&f.overrideMimeType("text/plain; charset=x-user-defined");f.setRequestHeader("Content-Type","text/plain");f.send(null)};
-THREE.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,e=void 0!==a.scale?1/a.scale:1;this.initMaterials(d,a.materials,c);(function(b){if(void 0===a.metadata||void 0===a.metadata.formatVersion||3!==a.metadata.formatVersion)console.error("Deprecated file format.");else{var c,e,i,l,k,p,n,o,q,m,r,s,t,u,x=a.faces;p=a.vertices;var v=a.normals,A=a.colors,D=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&D++;for(c=0;c<D;c++)d.faceUvs[c]=[],d.faceVertexUvs[c]=[];l=0;for(k=p.length;l<
-k;)n=new THREE.Vertex,n.position.x=p[l++]*b,n.position.y=p[l++]*b,n.position.z=p[l++]*b,d.vertices.push(n);l=0;for(k=x.length;l<k;){b=x[l++];p=b&1;i=b&2;c=b&4;e=b&8;o=b&16;n=b&32;m=b&64;b&=128;p?(r=new THREE.Face4,r.a=x[l++],r.b=x[l++],r.c=x[l++],r.d=x[l++],p=4):(r=new THREE.Face3,r.a=x[l++],r.b=x[l++],r.c=x[l++],p=3);if(i)i=x[l++],r.materialIndex=i;i=d.faces.length;if(c)for(c=0;c<D;c++)s=a.uvs[c],q=x[l++],u=s[2*q],q=s[2*q+1],d.faceUvs[c][i]=new THREE.UV(u,q);if(e)for(c=0;c<D;c++){s=a.uvs[c];t=[];
-for(e=0;e<p;e++)q=x[l++],u=s[2*q],q=s[2*q+1],t[e]=new THREE.UV(u,q);d.faceVertexUvs[c][i]=t}if(o)o=3*x[l++],e=new THREE.Vector3,e.x=v[o++],e.y=v[o++],e.z=v[o],r.normal=e;if(n)for(c=0;c<p;c++)o=3*x[l++],e=new THREE.Vector3,e.x=v[o++],e.y=v[o++],e.z=v[o],r.vertexNormals.push(e);if(m)n=x[l++],n=new THREE.Color(A[n]),r.color=n;if(b)for(c=0;c<p;c++)n=x[l++],n=new THREE.Color(A[n]),r.vertexColors.push(n);d.faces.push(r)}}})(e);(function(){var b,c,e,i;if(a.skinWeights)for(b=0,c=a.skinWeights.length;b<c;b+=
-2)e=a.skinWeights[b],i=a.skinWeights[b+1],d.skinWeights.push(new THREE.Vector4(e,i,0,0));if(a.skinIndices)for(b=0,c=a.skinIndices.length;b<c;b+=2)e=a.skinIndices[b],i=a.skinIndices[b+1],d.skinIndices.push(new THREE.Vector4(e,i,0,0));d.bones=a.bones;d.animation=a.animation})();(function(b){if(void 0!==a.morphTargets){var c,e,i,l,k,p,n,o,q;for(c=0,e=a.morphTargets.length;c<e;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];o=d.morphTargets[c].vertices;
-q=a.morphTargets[c].vertices;for(i=0,l=q.length;i<l;i+=3)k=q[i]*b,p=q[i+1]*b,n=q[i+2]*b,o.push(new THREE.Vertex(new THREE.Vector3(k,p,n)))}}if(void 0!==a.morphColors)for(c=0,e=a.morphColors.length;c<e;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];l=d.morphColors[c].colors;k=a.morphColors[c].colors;for(b=0,i=k.length;b<i;b+=3)p=new THREE.Color(16755200),p.setRGB(k[b],k[b+1],k[b+2]),l.push(p)}})(e);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&
+THREE.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,e=void 0!==a.scale?1/a.scale:1;this.initMaterials(d,a.materials,c);(function(b){if(void 0===a.metadata||void 0===a.metadata.formatVersion||3!==a.metadata.formatVersion)console.error("Deprecated file format.");else{var c,e,i,l,k,p,o,n,q,m,r,s,t,u,x=a.faces;p=a.vertices;var w=a.normals,A=a.colors,D=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&D++;for(c=0;c<D;c++)d.faceUvs[c]=[],d.faceVertexUvs[c]=[];l=0;for(k=p.length;l<
+k;)o=new THREE.Vertex,o.position.x=p[l++]*b,o.position.y=p[l++]*b,o.position.z=p[l++]*b,d.vertices.push(o);l=0;for(k=x.length;l<k;){b=x[l++];p=b&1;i=b&2;c=b&4;e=b&8;n=b&16;o=b&32;m=b&64;b&=128;p?(r=new THREE.Face4,r.a=x[l++],r.b=x[l++],r.c=x[l++],r.d=x[l++],p=4):(r=new THREE.Face3,r.a=x[l++],r.b=x[l++],r.c=x[l++],p=3);if(i)i=x[l++],r.materialIndex=i;i=d.faces.length;if(c)for(c=0;c<D;c++)s=a.uvs[c],q=x[l++],u=s[2*q],q=s[2*q+1],d.faceUvs[c][i]=new THREE.UV(u,q);if(e)for(c=0;c<D;c++){s=a.uvs[c];t=[];
+for(e=0;e<p;e++)q=x[l++],u=s[2*q],q=s[2*q+1],t[e]=new THREE.UV(u,q);d.faceVertexUvs[c][i]=t}if(n)n=3*x[l++],e=new THREE.Vector3,e.x=w[n++],e.y=w[n++],e.z=w[n],r.normal=e;if(o)for(c=0;c<p;c++)n=3*x[l++],e=new THREE.Vector3,e.x=w[n++],e.y=w[n++],e.z=w[n],r.vertexNormals.push(e);if(m)o=x[l++],o=new THREE.Color(A[o]),r.color=o;if(b)for(c=0;c<p;c++)o=x[l++],o=new THREE.Color(A[o]),r.vertexColors.push(o);d.faces.push(r)}}})(e);(function(){var b,c,e,i;if(a.skinWeights)for(b=0,c=a.skinWeights.length;b<c;b+=
+2)e=a.skinWeights[b],i=a.skinWeights[b+1],d.skinWeights.push(new THREE.Vector4(e,i,0,0));if(a.skinIndices)for(b=0,c=a.skinIndices.length;b<c;b+=2)e=a.skinIndices[b],i=a.skinIndices[b+1],d.skinIndices.push(new THREE.Vector4(e,i,0,0));d.bones=a.bones;d.animation=a.animation})();(function(b){if(void 0!==a.morphTargets){var c,e,i,l,k,p,o,n,q;for(c=0,e=a.morphTargets.length;c<e;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];n=d.morphTargets[c].vertices;
+q=a.morphTargets[c].vertices;for(i=0,l=q.length;i<l;i+=3)k=q[i]*b,p=q[i+1]*b,o=q[i+2]*b,n.push(new THREE.Vertex(new THREE.Vector3(k,p,o)))}}if(void 0!==a.morphColors)for(c=0,e=a.morphColors.length;c<e;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];l=d.morphColors[c].colors;k=a.morphColors[c].colors;for(b=0,i=k.length;b<i;b+=3)p=new THREE.Color(16755200),p.setRGB(k[b],k[b+1],k[b+2]),l.push(p)}})(e);d.computeCentroids();d.computeFaceNormals();this.hasNormals(d)&&
 d.computeTangents();b(d)};THREE.SceneLoader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){};this.callbackSync=function(){};this.callbackProgress=function(){}};THREE.SceneLoader.prototype.constructor=THREE.SceneLoader;
 THREE.SceneLoader.prototype.load=function(a,b){var c=this,d=new XMLHttpRequest;d.onreadystatechange=function(){if(4==d.readyState)if(200==d.status||0==d.status)try{var e=JSON.parse(d.responseText);void 0===e.metadata||void 0===e.metadata.formatVersion||3!==e.metadata.formatVersion?console.error("Deprecated file format."):c.createScene(e,b,a)}catch(f){console.error(f),console.warn("DEPRECATED: ["+a+"] seems to be using old model format")}else console.error("Couldn't load ["+a+"] ["+d.status+"]")};
 d.open("GET",a,!0);d.overrideMimeType&&d.overrideMimeType("text/plain; charset=x-user-defined");d.setRequestHeader("Content-Type","text/plain");d.send(null)};
-THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return"relativeToHTML"==b?a:l+"/"+a}function e(){var a;for(n in N.objects)if(!y.objects[n])if(s=N.objects[n],void 0!==s.geometry){if(F=y.geometries[s.geometry]){a=!1;for(I=0;I<s.materials.length;I++)R=y.materials[s.materials[I]],a=R instanceof THREE.ShaderMaterial;a&&F.computeTangents();x=s.position;v=s.rotation;A=s.quaternion;D=s.scale;A=0;0==R.length&&(R=new THREE.MeshFaceMaterial);1<R.length&&(R=new THREE.MeshFaceMaterial);
-a=new THREE.Mesh(F,R);a.name=n;a.position.set(x[0],x[1],x[2]);A?(a.quaternion.set(A[0],A[1],A[2],A[3]),a.useQuaternion=!0):a.rotation.set(v[0],v[1],v[2]);a.scale.set(D[0],D[1],D[2]);a.visible=s.visible;y.scene.add(a);y.objects[n]=a;if(s.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);y.scene.collisions.colliders.push(b)}if(s.castsShadow)b=new THREE.ShadowVolume(F),y.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;s.trigger&&"none"!=s.trigger.toLowerCase()&&(b=
-{type:s.trigger,object:s},y.triggers[a.name]=b)}}else x=s.position,v=s.rotation,A=s.quaternion,D=s.scale,A=0,a=new THREE.Object3D,a.name=n,a.position.set(x[0],x[1],x[2]),A?(a.quaternion.set(A[0],A[1],A[2],A[3]),a.useQuaternion=!0):a.rotation.set(v[0],v[1],v[2]),a.scale.set(D[0],D[1],D[2]),a.visible=void 0!==s.visible?s.visible:!1,y.scene.add(a),y.objects[n]=a,y.empties[n]=a,s.trigger&&"none"!=s.trigger.toLowerCase()&&(b={type:s.trigger,object:s},y.triggers[a.name]=b)}function f(a){return function(b){y.geometries[a]=
-b;e();B-=1;i.onLoadComplete();h()}}function g(a){return function(b){y.geometries[a]=b}}function h(){i.callbackProgress({totalModels:H,totalTextures:V,loadedModels:H-B,loadedTextures:V-j},y);i.onLoadProgress();0==B&&0==j&&b(y)}var i=this,l=THREE.Loader.prototype.extractUrlbase(c),k,p,n,o,q,m,r,s,t,u,x,v,A,D,E,C,F,K,L,R,N,P,B,j,H,V,y;N=a;c=new THREE.BinaryLoader;P=new THREE.JSONLoader;j=B=0;y={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},
-empties:{}};a=!1;for(n in N.objects)if(s=N.objects[n],s.meshCollider){a=!0;break}if(a)y.scene.collisions=new THREE.CollisionSystem;if(N.transform)a=N.transform.position,t=N.transform.rotation,E=N.transform.scale,a&&y.scene.position.set(a[0],a[1],a[2]),t&&y.scene.rotation.set(t[0],t[1],t[2]),E&&y.scene.scale.set(E[0],E[1],E[2]),(a||t||E)&&y.scene.updateMatrix();a=function(){j-=1;h();i.onLoadComplete()};for(q in N.cameras)E=N.cameras[q],"perspective"==E.type?K=new THREE.PerspectiveCamera(E.fov,E.aspect,
-E.near,E.far):"ortho"==E.type&&(K=new THREE.OrthographicCamera(E.left,E.right,E.top,E.bottom,E.near,E.far)),x=E.position,t=E.target,E=E.up,K.position.set(x[0],x[1],x[2]),K.target=new THREE.Vector3(t[0],t[1],t[2]),E&&K.up.set(E[0],E[1],E[2]),y.cameras[q]=K;for(o in N.lights)t=N.lights[o],q=void 0!==t.color?t.color:16777215,K=void 0!==t.intensity?t.intensity:1,"directional"==t.type?(x=t.direction,u=new THREE.DirectionalLight(q,K),u.position.set(x[0],x[1],x[2]),u.position.normalize()):"point"==t.type?
-(x=t.position,u=t.distance,u=new THREE.PointLight(q,K,u),u.position.set(x[0],x[1],x[2])):"ambient"==t.type&&(u=new THREE.AmbientLight(q)),y.scene.add(u),y.lights[o]=u;for(m in N.fogs)o=N.fogs[m],"linear"==o.type?L=new THREE.Fog(0,o.near,o.far):"exp2"==o.type&&(L=new THREE.FogExp2(0,o.density)),E=o.color,L.color.setRGB(E[0],E[1],E[2]),y.fogs[m]=L;if(y.cameras&&N.defaults.camera)y.currentCamera=y.cameras[N.defaults.camera];if(y.fogs&&N.defaults.fog)y.scene.fog=y.fogs[N.defaults.fog];E=N.defaults.bgcolor;
-y.bgColor=new THREE.Color;y.bgColor.setRGB(E[0],E[1],E[2]);y.bgColorAlpha=N.defaults.bgalpha;for(k in N.geometries)if(m=N.geometries[k],"bin_mesh"==m.type||"ascii_mesh"==m.type)B+=1,i.onLoadStart();H=B;for(k in N.geometries)m=N.geometries[k],"cube"==m.type?(F=new THREE.CubeGeometry(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,m.sides),y.geometries[k]=F):"plane"==m.type?(F=new THREE.PlaneGeometry(m.width,m.height,m.segmentsWidth,m.segmentsHeight),y.geometries[k]=
-F):"sphere"==m.type?(F=new THREE.SphereGeometry(m.radius,m.segmentsWidth,m.segmentsHeight),y.geometries[k]=F):"cylinder"==m.type?(F=new THREE.CylinderGeometry(m.topRad,m.botRad,m.height,m.radSegs,m.heightSegs),y.geometries[k]=F):"torus"==m.type?(F=new THREE.TorusGeometry(m.radius,m.tube,m.segmentsR,m.segmentsT),y.geometries[k]=F):"icosahedron"==m.type?(F=new THREE.IcosahedronGeometry(m.subdivisions),y.geometries[k]=F):"bin_mesh"==m.type?c.load(d(m.url,N.urlBaseType),f(k)):"ascii_mesh"==m.type?P.load(d(m.url,
-N.urlBaseType),f(k)):"embedded_mesh"==m.type&&(m=N.embeds[m.id])&&P.createModel(m,g(k),"");for(r in N.textures)if(k=N.textures[r],k.url instanceof Array){j+=k.url.length;for(m=0;m<k.url.length;m++)i.onLoadStart()}else j+=1,i.onLoadStart();V=j;for(r in N.textures){k=N.textures[r];if(void 0!=k.mapping&&void 0!=THREE[k.mapping])k.mapping=new THREE[k.mapping];if(k.url instanceof Array){m=[];for(var I=0;I<k.url.length;I++)m[I]=d(k.url[I],N.urlBaseType);m=THREE.ImageUtils.loadTextureCube(m,k.mapping,a)}else{m=
-THREE.ImageUtils.loadTexture(d(k.url,N.urlBaseType),k.mapping,a);if(void 0!=THREE[k.minFilter])m.minFilter=THREE[k.minFilter];if(void 0!=THREE[k.magFilter])m.magFilter=THREE[k.magFilter];if(k.repeat){m.repeat.set(k.repeat[0],k.repeat[1]);if(1!=k.repeat[0])m.wrapS=THREE.RepeatWrapping;if(1!=k.repeat[1])m.wrapT=THREE.RepeatWrapping}k.offset&&m.offset.set(k.offset[0],k.offset[1]);if(k.wrap){L={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(void 0!==L[k.wrap[0]])m.wrapS=L[k.wrap[0]];
-if(void 0!==L[k.wrap[1]])m.wrapT=L[k.wrap[1]]}}y.textures[r]=m}for(p in N.materials){r=N.materials[p];for(C in r.parameters)if("envMap"==C||"map"==C||"lightMap"==C)r.parameters[C]=y.textures[r.parameters[C]];else if("shading"==C)r.parameters[C]="flat"==r.parameters[C]?THREE.FlatShading:THREE.SmoothShading;else if("blending"==C)r.parameters[C]=THREE[r.parameters[C]]?THREE[r.parameters[C]]:THREE.NormalBlending;else if("combine"==C)r.parameters[C]="MixOperation"==r.parameters[C]?THREE.MixOperation:THREE.MultiplyOperation;
-else if("vertexColors"==C)if("face"==r.parameters[C])r.parameters[C]=THREE.FaceColors;else if(r.parameters[C])r.parameters[C]=THREE.VertexColors;if(void 0!==r.parameters.opacity&&1>r.parameters.opacity)r.parameters.transparent=!0;if(r.parameters.normalMap){k=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(k.uniforms);m=r.parameters.color;L=r.parameters.specular;c=r.parameters.ambient;P=r.parameters.shininess;a.tNormal.texture=y.textures[r.parameters.normalMap];if(r.parameters.normalMapFactor)a.uNormalScale.value=
-r.parameters.normalMapFactor;if(r.parameters.map)a.tDiffuse.texture=r.parameters.map,a.enableDiffuse.value=!0;if(r.parameters.lightMap)a.tAO.texture=r.parameters.lightMap,a.enableAO.value=!0;if(r.parameters.specularMap)a.tSpecular.texture=y.textures[r.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(m);a.uSpecularColor.value.setHex(L);a.uAmbientColor.value.setHex(c);a.uShininess.value=P;if(r.parameters.opacity)a.uOpacity.value=r.parameters.opacity;r=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,
+THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return"relativeToHTML"==b?a:l+"/"+a}function e(){var a;for(o in M.objects)if(!y.objects[o])if(s=M.objects[o],void 0!==s.geometry){if(G=y.geometries[s.geometry]){a=!1;for(F=0;F<s.materials.length;F++)T=y.materials[s.materials[F]],a=T instanceof THREE.ShaderMaterial;a&&G.computeTangents();x=s.position;w=s.rotation;A=s.quaternion;D=s.scale;A=0;0==T.length&&(T=new THREE.MeshFaceMaterial);1<T.length&&(T=new THREE.MeshFaceMaterial);
+a=new THREE.Mesh(G,T);a.name=o;a.position.set(x[0],x[1],x[2]);A?(a.quaternion.set(A[0],A[1],A[2],A[3]),a.useQuaternion=!0):a.rotation.set(w[0],w[1],w[2]);a.scale.set(D[0],D[1],D[2]);a.visible=s.visible;y.scene.add(a);y.objects[o]=a;if(s.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);y.scene.collisions.colliders.push(b)}if(s.castsShadow)b=new THREE.ShadowVolume(G),y.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;s.trigger&&"none"!=s.trigger.toLowerCase()&&(b=
+{type:s.trigger,object:s},y.triggers[a.name]=b)}}else x=s.position,w=s.rotation,A=s.quaternion,D=s.scale,A=0,a=new THREE.Object3D,a.name=o,a.position.set(x[0],x[1],x[2]),A?(a.quaternion.set(A[0],A[1],A[2],A[3]),a.useQuaternion=!0):a.rotation.set(w[0],w[1],w[2]),a.scale.set(D[0],D[1],D[2]),a.visible=void 0!==s.visible?s.visible:!1,y.scene.add(a),y.objects[o]=a,y.empties[o]=a,s.trigger&&"none"!=s.trigger.toLowerCase()&&(b={type:s.trigger,object:s},y.triggers[a.name]=b)}function f(a){return function(b){y.geometries[a]=
+b;e();j-=1;i.onLoadComplete();h()}}function g(a){return function(b){y.geometries[a]=b}}function h(){i.callbackProgress({totalModels:I,totalTextures:R,loadedModels:I-j,loadedTextures:R-Q},y);i.onLoadProgress();0==j&&0==Q&&b(y)}var i=this,l=THREE.Loader.prototype.extractUrlbase(c),k,p,o,n,q,m,r,s,t,u,x,w,A,D,B,C,G,K,L,T,M,E,j,Q,I,R,y;M=a;c=new THREE.BinaryLoader;E=new THREE.JSONLoader;Q=j=0;y={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},
+empties:{}};a=!1;for(o in M.objects)if(s=M.objects[o],s.meshCollider){a=!0;break}if(a)y.scene.collisions=new THREE.CollisionSystem;if(M.transform)a=M.transform.position,t=M.transform.rotation,B=M.transform.scale,a&&y.scene.position.set(a[0],a[1],a[2]),t&&y.scene.rotation.set(t[0],t[1],t[2]),B&&y.scene.scale.set(B[0],B[1],B[2]),(a||t||B)&&y.scene.updateMatrix();a=function(){Q-=1;h();i.onLoadComplete()};for(q in M.cameras)B=M.cameras[q],"perspective"==B.type?K=new THREE.PerspectiveCamera(B.fov,B.aspect,
+B.near,B.far):"ortho"==B.type&&(K=new THREE.OrthographicCamera(B.left,B.right,B.top,B.bottom,B.near,B.far)),x=B.position,t=B.target,B=B.up,K.position.set(x[0],x[1],x[2]),K.target=new THREE.Vector3(t[0],t[1],t[2]),B&&K.up.set(B[0],B[1],B[2]),y.cameras[q]=K;for(n in M.lights)t=M.lights[n],q=void 0!==t.color?t.color:16777215,K=void 0!==t.intensity?t.intensity:1,"directional"==t.type?(x=t.direction,u=new THREE.DirectionalLight(q,K),u.position.set(x[0],x[1],x[2]),u.position.normalize()):"point"==t.type?
+(x=t.position,u=t.distance,u=new THREE.PointLight(q,K,u),u.position.set(x[0],x[1],x[2])):"ambient"==t.type&&(u=new THREE.AmbientLight(q)),y.scene.add(u),y.lights[n]=u;for(m in M.fogs)n=M.fogs[m],"linear"==n.type?L=new THREE.Fog(0,n.near,n.far):"exp2"==n.type&&(L=new THREE.FogExp2(0,n.density)),B=n.color,L.color.setRGB(B[0],B[1],B[2]),y.fogs[m]=L;if(y.cameras&&M.defaults.camera)y.currentCamera=y.cameras[M.defaults.camera];if(y.fogs&&M.defaults.fog)y.scene.fog=y.fogs[M.defaults.fog];B=M.defaults.bgcolor;
+y.bgColor=new THREE.Color;y.bgColor.setRGB(B[0],B[1],B[2]);y.bgColorAlpha=M.defaults.bgalpha;for(k in M.geometries)if(m=M.geometries[k],"bin_mesh"==m.type||"ascii_mesh"==m.type)j+=1,i.onLoadStart();I=j;for(k in M.geometries)m=M.geometries[k],"cube"==m.type?(G=new THREE.CubeGeometry(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,m.sides),y.geometries[k]=G):"plane"==m.type?(G=new THREE.PlaneGeometry(m.width,m.height,m.segmentsWidth,m.segmentsHeight),y.geometries[k]=
+G):"sphere"==m.type?(G=new THREE.SphereGeometry(m.radius,m.segmentsWidth,m.segmentsHeight),y.geometries[k]=G):"cylinder"==m.type?(G=new THREE.CylinderGeometry(m.topRad,m.botRad,m.height,m.radSegs,m.heightSegs),y.geometries[k]=G):"torus"==m.type?(G=new THREE.TorusGeometry(m.radius,m.tube,m.segmentsR,m.segmentsT),y.geometries[k]=G):"icosahedron"==m.type?(G=new THREE.IcosahedronGeometry(m.subdivisions),y.geometries[k]=G):"bin_mesh"==m.type?c.load(d(m.url,M.urlBaseType),f(k)):"ascii_mesh"==m.type?E.load(d(m.url,
+M.urlBaseType),f(k)):"embedded_mesh"==m.type&&(m=M.embeds[m.id])&&E.createModel(m,g(k),"");for(r in M.textures)if(k=M.textures[r],k.url instanceof Array){Q+=k.url.length;for(m=0;m<k.url.length;m++)i.onLoadStart()}else Q+=1,i.onLoadStart();R=Q;for(r in M.textures){k=M.textures[r];if(void 0!=k.mapping&&void 0!=THREE[k.mapping])k.mapping=new THREE[k.mapping];if(k.url instanceof Array){m=[];for(var F=0;F<k.url.length;F++)m[F]=d(k.url[F],M.urlBaseType);m=THREE.ImageUtils.loadTextureCube(m,k.mapping,a)}else{m=
+THREE.ImageUtils.loadTexture(d(k.url,M.urlBaseType),k.mapping,a);if(void 0!=THREE[k.minFilter])m.minFilter=THREE[k.minFilter];if(void 0!=THREE[k.magFilter])m.magFilter=THREE[k.magFilter];if(k.repeat){m.repeat.set(k.repeat[0],k.repeat[1]);if(1!=k.repeat[0])m.wrapS=THREE.RepeatWrapping;if(1!=k.repeat[1])m.wrapT=THREE.RepeatWrapping}k.offset&&m.offset.set(k.offset[0],k.offset[1]);if(k.wrap){L={repeat:THREE.RepeatWrapping,mirror:THREE.MirroredRepeatWrapping};if(void 0!==L[k.wrap[0]])m.wrapS=L[k.wrap[0]];
+if(void 0!==L[k.wrap[1]])m.wrapT=L[k.wrap[1]]}}y.textures[r]=m}for(p in M.materials){r=M.materials[p];for(C in r.parameters)if("envMap"==C||"map"==C||"lightMap"==C)r.parameters[C]=y.textures[r.parameters[C]];else if("shading"==C)r.parameters[C]="flat"==r.parameters[C]?THREE.FlatShading:THREE.SmoothShading;else if("blending"==C)r.parameters[C]=THREE[r.parameters[C]]?THREE[r.parameters[C]]:THREE.NormalBlending;else if("combine"==C)r.parameters[C]="MixOperation"==r.parameters[C]?THREE.MixOperation:THREE.MultiplyOperation;
+else if("vertexColors"==C)if("face"==r.parameters[C])r.parameters[C]=THREE.FaceColors;else if(r.parameters[C])r.parameters[C]=THREE.VertexColors;if(void 0!==r.parameters.opacity&&1>r.parameters.opacity)r.parameters.transparent=!0;if(r.parameters.normalMap){k=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(k.uniforms);m=r.parameters.color;L=r.parameters.specular;c=r.parameters.ambient;E=r.parameters.shininess;a.tNormal.texture=y.textures[r.parameters.normalMap];if(r.parameters.normalMapFactor)a.uNormalScale.value=
+r.parameters.normalMapFactor;if(r.parameters.map)a.tDiffuse.texture=r.parameters.map,a.enableDiffuse.value=!0;if(r.parameters.lightMap)a.tAO.texture=r.parameters.lightMap,a.enableAO.value=!0;if(r.parameters.specularMap)a.tSpecular.texture=y.textures[r.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(m);a.uSpecularColor.value.setHex(L);a.uAmbientColor.value.setHex(c);a.uShininess.value=E;if(r.parameters.opacity)a.uOpacity.value=r.parameters.opacity;r=new THREE.ShaderMaterial({fragmentShader:k.fragmentShader,
 vertexShader:k.vertexShader,uniforms:a,lights:!0,fog:!0})}else r=new THREE[r.type](r.parameters);y.materials[p]=r}e();i.callbackSync(y);h()};THREE.UTF8Loader=function(){};THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
 THREE.UTF8Loader.prototype.load=function(a,b,c){if(a instanceof Object)console.warn("DEPRECATED: UTF8Loader( parameters ) is now UTF8Loader( url, callback, metaData )."),c=a,a=c.model,b=c.callback,c={scale:c.scale,offsetX:c.offsetX,offsetY:c.offsetY,offsetZ:c.offsetZ};var d=new XMLHttpRequest,e=void 0!==c.scale?c.scale:1,f=void 0!==c.offsetX?c.offsetX:0,g=void 0!==c.offsetY?c.offsetY:0,h=void 0!==c.offsetZ?c.offsetZ:0;d.onreadystatechange=function(){4==d.readyState?200==d.status||0==d.status?THREE.UTF8Loader.prototype.createModel(d.responseText,
 b,e,f,g,h):alert("Couldn't load ["+a+"] ["+d.status+"]"):3!=d.readyState&&2==d.readyState&&d.getResponseHeader("Content-Length")};d.open("GET",a,!0);d.send(null)};THREE.UTF8Loader.prototype.decompressMesh=function(a){var b=a.charCodeAt(0);57344<=b&&(b-=2048);b++;for(var c=new Float32Array(8*b),d=1,e=0;8>e;e++){for(var f=0,g=0;g<b;++g){var h=a.charCodeAt(g+d),f=f+(h>>1^-(h&1));c[8*g+e]=f}d+=b}b=a.length-d;f=new Uint16Array(b);for(e=g=0;e<b;e++)h=a.charCodeAt(e+d),f[e]=g-h,0==h&&g++;return[c,f]};
-THREE.UTF8Loader.prototype.createModel=function(a,b,c,d,e,f){var g=function(){var b=this;b.materials=[];THREE.Geometry.call(this);var g=THREE.UTF8Loader.prototype.decompressMesh(a),l=[],k=[];(function(a,g,i){for(var k,l,r,s=a.length;i<s;i+=g)k=a[i],l=a[i+1],r=a[i+2],k=k/16383*c,l=l/16383*c,r=r/16383*c,k+=d,l+=e,r+=f,b.vertices.push(new THREE.Vertex(new THREE.Vector3(k,l,r)))})(g[0],8,0);(function(a,b,c){for(var d,e,f=a.length;c<f;c+=b)d=a[c],e=a[c+1],d/=1023,e/=1023,k.push(d,1-e)})(g[0],8,3);(function(a,
-b,c){for(var d,e,f,g=a.length;c<g;c+=b)d=a[c],e=a[c+1],f=a[c+2],d=(d-512)/511,e=(e-512)/511,f=(f-512)/511,l.push(d,e,f)})(g[0],8,5);(function(a){var c,d,e,f,g,i,t,u,x,v=a.length;for(c=0;c<v;c+=3){d=a[c];e=a[c+1];f=a[c+2];g=b;u=d;x=e;i=f;var A=l[3*e],D=l[3*e+1],E=l[3*e+2],C=l[3*f],F=l[3*f+1],K=l[3*f+2];t=new THREE.Vector3(l[3*d],l[3*d+1],l[3*d+2]);A=new THREE.Vector3(A,D,E);C=new THREE.Vector3(C,F,K);g.faces.push(new THREE.Face3(u,x,i,[t,A,C],null,0));g=k[2*d];d=k[2*d+1];i=k[2*e];t=k[2*e+1];u=k[2*
+THREE.UTF8Loader.prototype.createModel=function(a,b,c,d,e,f){var g=function(){var b=this;b.materials=[];THREE.Geometry.call(this);var g=THREE.UTF8Loader.prototype.decompressMesh(a),l=[],k=[];(function(a,g,i){for(var l,k,r,s=a.length;i<s;i+=g)l=a[i],k=a[i+1],r=a[i+2],l=l/16383*c,k=k/16383*c,r=r/16383*c,l+=d,k+=e,r+=f,b.vertices.push(new THREE.Vertex(new THREE.Vector3(l,k,r)))})(g[0],8,0);(function(a,b,c){for(var d,e,f=a.length;c<f;c+=b)d=a[c],e=a[c+1],d/=1023,e/=1023,k.push(d,1-e)})(g[0],8,3);(function(a,
+b,c){for(var d,e,f,g=a.length;c<g;c+=b)d=a[c],e=a[c+1],f=a[c+2],d=(d-512)/511,e=(e-512)/511,f=(f-512)/511,l.push(d,e,f)})(g[0],8,5);(function(a){var c,d,e,f,g,i,t,u,x,w=a.length;for(c=0;c<w;c+=3){d=a[c];e=a[c+1];f=a[c+2];g=b;u=d;x=e;i=f;var A=l[3*e],D=l[3*e+1],B=l[3*e+2],C=l[3*f],G=l[3*f+1],K=l[3*f+2];t=new THREE.Vector3(l[3*d],l[3*d+1],l[3*d+2]);A=new THREE.Vector3(A,D,B);C=new THREE.Vector3(C,G,K);g.faces.push(new THREE.Face3(u,x,i,[t,A,C],null,0));g=k[2*d];d=k[2*d+1];i=k[2*e];t=k[2*e+1];u=k[2*
 f];x=k[2*f+1];f=b.faceVertexUvs[0];e=i;i=t;t=[];t.push(new THREE.UV(g,d));t.push(new THREE.UV(e,i));t.push(new THREE.UV(u,x));f.push(t)}})(g[1]);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g)};
 THREE.Axes=function(){THREE.Object3D.call(this);var a=new THREE.Geometry;a.vertices.push(new THREE.Vertex);a.vertices.push(new THREE.Vertex(new THREE.Vector3(0,100,0)));var b=new THREE.CylinderGeometry(0,5,25,5,1),c;c=new THREE.Line(a,new THREE.LineBasicMaterial({color:16711680}));c.rotation.z=-Math.PI/2;this.add(c);c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:16711680}));c.position.x=100;c.rotation.z=-Math.PI/2;this.add(c);c=new THREE.Line(a,new THREE.LineBasicMaterial({color:65280}));this.add(c);
 c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:65280}));c.position.y=100;this.add(c);c=new THREE.Line(a,new THREE.LineBasicMaterial({color:255}));c.rotation.x=Math.PI/2;this.add(c);c=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:255}));c.position.z=100;c.rotation.x=Math.PI/2;this.add(c)};THREE.Axes.prototype=new THREE.Object3D;THREE.Axes.prototype.constructor=THREE.Axes;
 THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.material=b;this.init=function(a){this.resolution=a;this.isolation=80;this.size=a;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(3*this.size3);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(3*this.maxCount);this.normalArray=new Float32Array(3*this.maxCount)};this.lerp=function(a,b,e){return a+(b-a)*e};this.VIntX=function(a,b,e,f,g,h,i,l,k,p){g=(g-k)/(p-k);k=this.normal_cache;b[f]=h+g*this.delta;b[f+1]=i;b[f+2]=l;e[f]=this.lerp(k[a],k[a+3],g);e[f+1]=this.lerp(k[a+1],k[a+4],g);e[f+2]=this.lerp(k[a+2],k[a+5],g)};this.VIntY=function(a,b,e,f,g,h,i,l,k,p){g=(g-k)/(p-k);k=this.normal_cache;b[f]=h;b[f+1]=i+g*this.delta;b[f+2]=l;b=a+3*this.yd;
 e[f]=this.lerp(k[a],k[b],g);e[f+1]=this.lerp(k[a+1],k[b+1],g);e[f+2]=this.lerp(k[a+2],k[b+2],g)};this.VIntZ=function(a,b,e,f,g,h,i,l,k,p){g=(g-k)/(p-k);k=this.normal_cache;b[f]=h;b[f+1]=i;b[f+2]=l+g*this.delta;b=a+3*this.zd;e[f]=this.lerp(k[a],k[b],g);e[f+1]=this.lerp(k[a+1],k[b+1],g);e[f+2]=this.lerp(k[a+2],k[b+2],g)};this.compNorm=function(a){var b=3*a;0===this.normal_cache[b]&&(this.normal_cache[b]=this.field[a-1]-this.field[a+1],this.normal_cache[b+1]=this.field[a-this.yd]-this.field[a+this.yd],
-this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,e,f,g,h){var i=f+1,l=f+this.yd,k=f+this.zd,p=i+this.yd,n=i+this.zd,o=f+this.yd+this.zd,q=i+this.yd+this.zd,m=0,r=this.field[f],s=this.field[i],t=this.field[l],u=this.field[p],x=this.field[k],v=this.field[n],A=this.field[o],D=this.field[q];r<g&&(m|=1);s<g&&(m|=2);t<g&&(m|=8);u<g&&(m|=4);x<g&&(m|=16);v<g&&(m|=32);A<g&&(m|=128);D<g&&(m|=64);var E=THREE.edgeTable[m];if(0===E)return 0;var C=this.delta,F=a+
-C,K=b+C,C=e+C;E&1&&(this.compNorm(f),this.compNorm(i),this.VIntX(3*f,this.vlist,this.nlist,0,g,a,b,e,r,s));E&2&&(this.compNorm(i),this.compNorm(p),this.VIntY(3*i,this.vlist,this.nlist,3,g,F,b,e,s,u));E&4&&(this.compNorm(l),this.compNorm(p),this.VIntX(3*l,this.vlist,this.nlist,6,g,a,K,e,t,u));E&8&&(this.compNorm(f),this.compNorm(l),this.VIntY(3*f,this.vlist,this.nlist,9,g,a,b,e,r,t));E&16&&(this.compNorm(k),this.compNorm(n),this.VIntX(3*k,this.vlist,this.nlist,12,g,a,b,C,x,v));E&32&&(this.compNorm(n),
-this.compNorm(q),this.VIntY(3*n,this.vlist,this.nlist,15,g,F,b,C,v,D));E&64&&(this.compNorm(o),this.compNorm(q),this.VIntX(3*o,this.vlist,this.nlist,18,g,a,K,C,A,D));E&128&&(this.compNorm(k),this.compNorm(o),this.VIntY(3*k,this.vlist,this.nlist,21,g,a,b,C,x,A));E&256&&(this.compNorm(f),this.compNorm(k),this.VIntZ(3*f,this.vlist,this.nlist,24,g,a,b,e,r,x));E&512&&(this.compNorm(i),this.compNorm(n),this.VIntZ(3*i,this.vlist,this.nlist,27,g,F,b,e,s,v));E&1024&&(this.compNorm(p),this.compNorm(q),this.VIntZ(3*
-p,this.vlist,this.nlist,30,g,F,K,e,u,D));E&2048&&(this.compNorm(l),this.compNorm(o),this.VIntZ(3*l,this.vlist,this.nlist,33,g,a,K,e,t,A));m<<=4;for(g=f=0;-1!=THREE.triTable[m+g];)a=m+g,b=a+1,e=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[e],h),g+=3,f++;return f};this.posnormtriv=function(a,b,e,f,g,h){var i=3*this.count;this.positionArray[i]=a[e];this.positionArray[i+1]=a[e+1];this.positionArray[i+2]=a[e+2];this.positionArray[i+3]=a[f];this.positionArray[i+
+this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,e,f,g,h){var i=f+1,l=f+this.yd,k=f+this.zd,p=i+this.yd,o=i+this.zd,n=f+this.yd+this.zd,q=i+this.yd+this.zd,m=0,r=this.field[f],s=this.field[i],t=this.field[l],u=this.field[p],x=this.field[k],w=this.field[o],A=this.field[n],D=this.field[q];r<g&&(m|=1);s<g&&(m|=2);t<g&&(m|=8);u<g&&(m|=4);x<g&&(m|=16);w<g&&(m|=32);A<g&&(m|=128);D<g&&(m|=64);var B=THREE.edgeTable[m];if(0===B)return 0;var C=this.delta,G=a+
+C,K=b+C,C=e+C;B&1&&(this.compNorm(f),this.compNorm(i),this.VIntX(3*f,this.vlist,this.nlist,0,g,a,b,e,r,s));B&2&&(this.compNorm(i),this.compNorm(p),this.VIntY(3*i,this.vlist,this.nlist,3,g,G,b,e,s,u));B&4&&(this.compNorm(l),this.compNorm(p),this.VIntX(3*l,this.vlist,this.nlist,6,g,a,K,e,t,u));B&8&&(this.compNorm(f),this.compNorm(l),this.VIntY(3*f,this.vlist,this.nlist,9,g,a,b,e,r,t));B&16&&(this.compNorm(k),this.compNorm(o),this.VIntX(3*k,this.vlist,this.nlist,12,g,a,b,C,x,w));B&32&&(this.compNorm(o),
+this.compNorm(q),this.VIntY(3*o,this.vlist,this.nlist,15,g,G,b,C,w,D));B&64&&(this.compNorm(n),this.compNorm(q),this.VIntX(3*n,this.vlist,this.nlist,18,g,a,K,C,A,D));B&128&&(this.compNorm(k),this.compNorm(n),this.VIntY(3*k,this.vlist,this.nlist,21,g,a,b,C,x,A));B&256&&(this.compNorm(f),this.compNorm(k),this.VIntZ(3*f,this.vlist,this.nlist,24,g,a,b,e,r,x));B&512&&(this.compNorm(i),this.compNorm(o),this.VIntZ(3*i,this.vlist,this.nlist,27,g,G,b,e,s,w));B&1024&&(this.compNorm(p),this.compNorm(q),this.VIntZ(3*
+p,this.vlist,this.nlist,30,g,G,K,e,u,D));B&2048&&(this.compNorm(l),this.compNorm(n),this.VIntZ(3*l,this.vlist,this.nlist,33,g,a,K,e,t,A));m<<=4;for(g=f=0;-1!=THREE.triTable[m+g];)a=m+g,b=a+1,e=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[e],h),g+=3,f++;return f};this.posnormtriv=function(a,b,e,f,g,h){var i=3*this.count;this.positionArray[i]=a[e];this.positionArray[i+1]=a[e+1];this.positionArray[i+2]=a[e+2];this.positionArray[i+3]=a[f];this.positionArray[i+
 4]=a[f+1];this.positionArray[i+5]=a[f+2];this.positionArray[i+6]=a[g];this.positionArray[i+7]=a[g+1];this.positionArray[i+8]=a[g+2];this.normalArray[i]=b[e];this.normalArray[i+1]=b[e+1];this.normalArray[i+2]=b[e+2];this.normalArray[i+3]=b[f];this.normalArray[i+4]=b[f+1];this.normalArray[i+5]=b[f+2];this.normalArray[i+6]=b[g];this.normalArray[i+7]=b[g+1];this.normalArray[i+8]=b[g+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&h(this)};this.begin=function(){this.count=0;
-this.hasNormal=this.hasPos=!1};this.end=function(a){if(0!==this.count){for(var b=3*this.count;b<this.positionArray.length;b++)this.positionArray[b]=0;a(this)}};this.addBall=function(a,b,e,f,g){var h=this.size*Math.sqrt(f/g),i=e*this.size,l=b*this.size,k=a*this.size,p=Math.floor(i-h);1>p&&(p=1);i=Math.floor(i+h);i>this.size-1&&(i=this.size-1);var n=Math.floor(l-h);1>n&&(n=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var o=Math.floor(k-h);1>o&&(o=1);h=Math.floor(k+h);h>this.size-1&&(h=this.size-
-1);for(var q,m,r,s,t,u,x,k=p;k<i;k++){r=this.size2*k;t=k/this.size-e;u=t*t;for(p=n;p<l;p++){m=r+this.size*p;q=p/this.size-b;x=q*q;for(q=o;q<h;q++)s=q/this.size-a,s=f/(1.0E-6+s*s+x+u)-g,0<s&&(this.field[m+q]+=s)}}};this.addPlaneX=function(a,b){var e,f,g,h,i,l=this.size,k=this.yd,p=this.zd,n=this.field,o=l*Math.sqrt(a/b);o>l&&(o=l);for(e=0;e<o;e++)if(f=e/l,f*=f,h=a/(1.0E-4+f)-b,0<h)for(f=0;f<l;f++){i=e+f*k;for(g=0;g<l;g++)n[p*g+i]+=h}};this.addPlaneY=function(a,b){var e,f,g,h,i,l,k=this.size,p=this.yd,
-n=this.zd,o=this.field,q=k*Math.sqrt(a/b);q>k&&(q=k);for(f=0;f<q;f++)if(e=f/k,e*=e,h=a/(1.0E-4+e)-b,0<h){i=f*p;for(e=0;e<k;e++){l=i+e;for(g=0;g<k;g++)o[n*g+l]+=h}}};this.addPlaneZ=function(a,b){var e,f,g,h,i,l,k=this.size,p=this.yd,n=this.zd,o=this.field,q=k*Math.sqrt(a/b);q>k&&(q=k);for(g=0;g<q;g++)if(e=g/k,e*=e,h=a/(1.0E-4+e)-b,0<h){i=n*g;for(f=0;f<k;f++){l=i+f*p;for(e=0;e<k;e++)o[l+e]+=h}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[3*a]=0,this.field[a]=0};this.render=
-function(a){this.begin();var b,e,f,g,h,i,l,k,p,n=this.size-2;for(g=1;g<n;g++){p=this.size2*g;l=(g-this.halfsize)/this.halfsize;for(f=1;f<n;f++){k=p+this.size*f;i=(f-this.halfsize)/this.halfsize;for(e=1;e<n;e++)h=(e-this.halfsize)/this.halfsize,b=k+e,this.polygonize(h,i,l,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,e=[];this.render(function(f){var g,h,i,l,k,p,n,o;for(g=0;g<f.count;g++)n=3*g,k=n+1,o=n+2,h=f.positionArray[n],i=f.positionArray[k],l=
-f.positionArray[o],p=new THREE.Vector3(h,i,l),h=f.normalArray[n],i=f.normalArray[k],l=f.normalArray[o],n=new THREE.Vector3(h,i,l),n.normalize(),k=new THREE.Vertex(p),b.vertices.push(k),e.push(n);p=f.count/3;for(g=0;g<p;g++)n=3*(a+g),k=n+1,o=n+2,h=e[n],i=e[k],l=e[o],n=new THREE.Face3(n,k,o,[h,i,l]),b.faces.push(n);a+=p;f.count=0});return b};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
+this.hasNormal=this.hasPos=!1};this.end=function(a){if(0!==this.count){for(var b=3*this.count;b<this.positionArray.length;b++)this.positionArray[b]=0;a(this)}};this.addBall=function(a,b,e,f,g){var h=this.size*Math.sqrt(f/g),i=e*this.size,l=b*this.size,k=a*this.size,p=Math.floor(i-h);1>p&&(p=1);i=Math.floor(i+h);i>this.size-1&&(i=this.size-1);var o=Math.floor(l-h);1>o&&(o=1);l=Math.floor(l+h);l>this.size-1&&(l=this.size-1);var n=Math.floor(k-h);1>n&&(n=1);h=Math.floor(k+h);h>this.size-1&&(h=this.size-
+1);for(var q,m,r,s,t,u,x,k=p;k<i;k++){r=this.size2*k;t=k/this.size-e;u=t*t;for(p=o;p<l;p++){m=r+this.size*p;q=p/this.size-b;x=q*q;for(q=n;q<h;q++)s=q/this.size-a,s=f/(1.0E-6+s*s+x+u)-g,0<s&&(this.field[m+q]+=s)}}};this.addPlaneX=function(a,b){var e,f,g,h,i,l=this.size,k=this.yd,p=this.zd,o=this.field,n=l*Math.sqrt(a/b);n>l&&(n=l);for(e=0;e<n;e++)if(f=e/l,f*=f,h=a/(1.0E-4+f)-b,0<h)for(f=0;f<l;f++){i=e+f*k;for(g=0;g<l;g++)o[p*g+i]+=h}};this.addPlaneY=function(a,b){var e,f,g,h,i,l,k=this.size,p=this.yd,
+o=this.zd,n=this.field,q=k*Math.sqrt(a/b);q>k&&(q=k);for(f=0;f<q;f++)if(e=f/k,e*=e,h=a/(1.0E-4+e)-b,0<h){i=f*p;for(e=0;e<k;e++){l=i+e;for(g=0;g<k;g++)n[o*g+l]+=h}}};this.addPlaneZ=function(a,b){var e,f,g,h,i,l,k=this.size,p=this.yd,o=this.zd,n=this.field,q=k*Math.sqrt(a/b);q>k&&(q=k);for(g=0;g<q;g++)if(e=g/k,e*=e,h=a/(1.0E-4+e)-b,0<h){i=o*g;for(f=0;f<k;f++){l=i+f*p;for(e=0;e<k;e++)n[l+e]+=h}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[3*a]=0,this.field[a]=0};this.render=
+function(a){this.begin();var b,e,f,g,h,i,l,k,p,o=this.size-2;for(g=1;g<o;g++){p=this.size2*g;l=(g-this.halfsize)/this.halfsize;for(f=1;f<o;f++){k=p+this.size*f;i=(f-this.halfsize)/this.halfsize;for(e=1;e<o;e++)h=(e-this.halfsize)/this.halfsize,b=k+e,this.polygonize(h,i,l,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,e=[];this.render(function(f){var g,h,i,l,k,p,o,n;for(g=0;g<f.count;g++)o=3*g,k=o+1,n=o+2,h=f.positionArray[o],i=f.positionArray[k],l=
+f.positionArray[n],p=new THREE.Vector3(h,i,l),h=f.normalArray[o],i=f.normalArray[k],l=f.normalArray[n],o=new THREE.Vector3(h,i,l),o.normalize(),k=new THREE.Vertex(p),b.vertices.push(k),e.push(o);p=f.count/3;for(g=0;g<p;g++)o=3*(a+g),k=o+1,n=o+2,h=e[o],i=e[k],l=e[n],o=new THREE.Face3(o,k,n,[h,i,l]),b.faces.push(o);a+=p;f.count=0});return b};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
 419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
@@ -728,32 +729,32 @@ THREE.VisibleCamera=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){
 this.update(a);this.add(new THREE.Line(this.lineGeometry,this.lineMaterial,THREE.LinePieces))};THREE.VisibleCamera.prototype=new THREE.Object3D;THREE.VisibleCamera.prototype.constructor=THREE.VisibleCamera;
 THREE.VisibleCamera.prototype.update=function(a){function b(a,b,f,g){THREE.VisibleCamera.__v.set(b,f,g);THREE.VisibleCamera.__projector.unprojectVector(THREE.VisibleCamera.__v,THREE.VisibleCamera.__c);a=c.pointMap[a];if(void 0!==a){b=0;for(f=a.length;b<f;b++)c.lineGeometry.vertices[a[b]].position.copy(THREE.VisibleCamera.__v)}}var c=this;THREE.VisibleCamera.__c.projectionMatrix.copy(a.projectionMatrix);b("c",0,0,0);b("t",0,0,1);b("n1",-1,-1,0);b("n2",1,-1,0);b("n3",-1,1,0);b("n4",1,1,0);b("f1",-1,
 -1,1);b("f2",1,-1,1);b("f3",-1,1,1);b("f4",1,1,1);b("u1",0.7,1.1,0);b("u2",-0.7,1.1,0);b("u3",0,2,0);b("cf1",-1,0,1);b("cf2",1,0,1);b("cf3",0,-1,1);b("cf4",0,1,1);b("cn1",-1,0,0);b("cn2",1,0,0);b("cn3",0,-1,0);b("cn4",0,1,0);this.lineGeometry.__dirtyVertices=!0};THREE.VisibleCamera.__projector=new THREE.Projector;THREE.VisibleCamera.__v=new THREE.Vector3;THREE.VisibleCamera.__c=new THREE.Camera;
-THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),e=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(e,a.vertexShader);b.compileShader(d);b.compileShader(e);b.attachShader(c,d);b.attachShader(c,e);b.linkProgram(c);return c}var b,c,d,e,f,g,h,i,l,k,p,n,o;this.init=function(q){b=q.context;c=q;d=new Float32Array(16);e=new Uint16Array(6);q=0;d[q++]=-1;d[q++]=-1;d[q++]=0;d[q++]=0;d[q++]=1;d[q++]=-1;d[q++]=1;d[q++]=
+THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),e=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(e,a.vertexShader);b.compileShader(d);b.compileShader(e);b.attachShader(c,d);b.attachShader(c,e);b.linkProgram(c);return c}var b,c,d,e,f,g,h,i,l,k,p,o,n;this.init=function(q){b=q.context;c=q;d=new Float32Array(16);e=new Uint16Array(6);q=0;d[q++]=-1;d[q++]=-1;d[q++]=0;d[q++]=0;d[q++]=1;d[q++]=-1;d[q++]=1;d[q++]=
 0;d[q++]=1;d[q++]=1;d[q++]=1;d[q++]=1;d[q++]=-1;d[q++]=1;d[q++]=0;d[q++]=1;q=0;e[q++]=0;e[q++]=1;e[q++]=2;e[q++]=0;e[q++]=2;e[q++]=3;f=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);h=b.createTexture();i=b.createTexture();b.bindTexture(b.TEXTURE_2D,h);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,
 b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.bindTexture(b.TEXTURE_2D,i);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);
-b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);0>=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(l=!1,k=a(THREE.ShaderFlares.lensFlare)):(l=!0,k=a(THREE.ShaderFlares.lensFlareVertexTexture));p={};n={};p.vertex=b.getAttribLocation(k,"position");p.uv=b.getAttribLocation(k,"uv");n.renderType=b.getUniformLocation(k,"renderType");n.map=b.getUniformLocation(k,"map");n.occlusionMap=b.getUniformLocation(k,"occlusionMap");n.opacity=b.getUniformLocation(k,"opacity");n.color=b.getUniformLocation(k,
-"color");n.scale=b.getUniformLocation(k,"scale");n.rotation=b.getUniformLocation(k,"rotation");n.screenPosition=b.getUniformLocation(k,"screenPosition");o=!1};this.render=function(a,d,e,s){var a=a.__webglFlares,t=a.length;if(t){var u=new THREE.Vector3,x=s/e,v=0.5*e,A=0.5*s,D=16/s,E=new THREE.Vector2(D*x,D),C=new THREE.Vector3(1,1,0),F=new THREE.Vector2(1,1),K=n,D=p;b.useProgram(k);o||(b.enableVertexAttribArray(p.vertex),b.enableVertexAttribArray(p.uv),o=!0);b.uniform1i(K.occlusionMap,0);b.uniform1i(K.map,
-1);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(D.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(D.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(!1);var L,R,N,P,B;for(L=0;L<t;L++)if(D=16/s,E.set(D*x,D),P=a[L],u.set(P.matrixWorld.n14,P.matrixWorld.n24,P.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(u),d.projectionMatrix.multiplyVector3(u),C.copy(u),F.x=C.x*v+v,F.y=C.y*A+A,l||0<F.x&&F.x<e&&0<F.y&&F.y<s){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
-h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,F.x-8,F.y-8,16,16,0);b.uniform1i(K.renderType,0);b.uniform2f(K.scale,E.x,E.y);b.uniform3f(K.screenPosition,C.x,C.y,C.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,F.x-8,F.y-8,16,16,0);b.uniform1i(K.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,h);b.drawElements(b.TRIANGLES,
-6,b.UNSIGNED_SHORT,0);P.positionScreen.copy(C);P.customUpdateCallback?P.customUpdateCallback(P):P.updateLensFlares();b.uniform1i(K.renderType,2);b.enable(b.BLEND);for(R=0,N=P.lensFlares.length;R<N;R++)if(B=P.lensFlares[R],0.0010<B.opacity&&0.0010<B.scale)C.x=B.x,C.y=B.y,C.z=B.z,D=B.size*B.scale/s,E.x=D*x,E.y=D,b.uniform3f(K.screenPosition,C.x,C.y,C.z),b.uniform2f(K.scale,E.x,E.y),b.uniform1f(K.rotation,B.rotation),b.uniform1f(K.opacity,B.opacity),b.uniform3f(K.color,B.color.r,B.color.g,B.color.b),
-c.setBlending(B.blending),c.setTexture(B.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
+b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);0>=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(l=!1,k=a(THREE.ShaderFlares.lensFlare)):(l=!0,k=a(THREE.ShaderFlares.lensFlareVertexTexture));p={};o={};p.vertex=b.getAttribLocation(k,"position");p.uv=b.getAttribLocation(k,"uv");o.renderType=b.getUniformLocation(k,"renderType");o.map=b.getUniformLocation(k,"map");o.occlusionMap=b.getUniformLocation(k,"occlusionMap");o.opacity=b.getUniformLocation(k,"opacity");o.color=b.getUniformLocation(k,
+"color");o.scale=b.getUniformLocation(k,"scale");o.rotation=b.getUniformLocation(k,"rotation");o.screenPosition=b.getUniformLocation(k,"screenPosition");n=!1};this.render=function(a,d,e,s){var a=a.__webglFlares,t=a.length;if(t){var u=new THREE.Vector3,x=s/e,w=0.5*e,A=0.5*s,D=16/s,B=new THREE.Vector2(D*x,D),C=new THREE.Vector3(1,1,0),G=new THREE.Vector2(1,1),K=o,D=p;b.useProgram(k);n||(b.enableVertexAttribArray(p.vertex),b.enableVertexAttribArray(p.uv),n=!0);b.uniform1i(K.occlusionMap,0);b.uniform1i(K.map,
+1);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(D.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(D.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(!1);var L,T,M,E,j;for(L=0;L<t;L++)if(D=16/s,B.set(D*x,D),E=a[L],u.set(E.matrixWorld.n14,E.matrixWorld.n24,E.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(u),d.projectionMatrix.multiplyVector3(u),C.copy(u),G.x=C.x*w+w,G.y=C.y*A+A,l||0<G.x&&G.x<e&&0<G.y&&G.y<s){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
+h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,G.x-8,G.y-8,16,16,0);b.uniform1i(K.renderType,0);b.uniform2f(K.scale,B.x,B.y);b.uniform3f(K.screenPosition,C.x,C.y,C.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,G.x-8,G.y-8,16,16,0);b.uniform1i(K.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,h);b.drawElements(b.TRIANGLES,
+6,b.UNSIGNED_SHORT,0);E.positionScreen.copy(C);E.customUpdateCallback?E.customUpdateCallback(E):E.updateLensFlares();b.uniform1i(K.renderType,2);b.enable(b.BLEND);for(T=0,M=E.lensFlares.length;T<M;T++)if(j=E.lensFlares[T],0.0010<j.opacity&&0.0010<j.scale)C.x=j.x,C.y=j.y,C.z=j.z,D=j.size*j.scale/s,B.x=D*x,B.y=D,b.uniform3f(K.screenPosition,C.x,C.y,C.z),b.uniform2f(K.scale,B.x,B.y),b.uniform1f(K.rotation,j.rotation),b.uniform1f(K.opacity,j.opacity),b.uniform3f(K.color,j.color.r,j.color.g,j.color.b),
+c.setBlending(j.blending),c.setTexture(j.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
 THREE.ShadowMapPlugin=function(){var a,b,c,d,e,f=new THREE.Frustum,g=new THREE.Matrix4;this.shadowMatrix=[];this.shadowMap=[];this.init=function(c){a=c.context;b=c;var c=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(c.uniforms);d=new THREE.ShaderMaterial({fragmentShader:c.fragmentShader,vertexShader:c.vertexShader,uniforms:f});e=new THREE.ShaderMaterial({fragmentShader:c.fragmentShader,vertexShader:c.vertexShader,uniforms:f,morphTargets:!0});d._shadowPass=!0;e._shadowPass=!0};this.render=
-function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(h){var i,l,k,p,n,o,q,m,r=0,s=h.lights;c||(c=new THREE.PerspectiveCamera(b.shadowCameraFov,b.shadowMapWidth/b.shadowMapHeight,b.shadowCameraNear,b.shadowCameraFar));a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(i=0,l=s.length;i<l;i++)if(q=s[i],q.castShadow&&q instanceof THREE.SpotLight){this.shadowMap[r]||(this.shadowMap[r]=new THREE.WebGLRenderTarget(b.shadowMapWidth,
+function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(h){var i,l,k,p,o,n,q,m,r=0,s=h.lights;c||(c=new THREE.PerspectiveCamera(b.shadowCameraFov,b.shadowMapWidth/b.shadowMapHeight,b.shadowCameraNear,b.shadowCameraFar));a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(i=0,l=s.length;i<l;i++)if(q=s[i],q.castShadow&&q instanceof THREE.SpotLight){this.shadowMap[r]||(this.shadowMap[r]=new THREE.WebGLRenderTarget(b.shadowMapWidth,
 b.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}),this.shadowMatrix[r]=new THREE.Matrix4);k=this.shadowMap[r];p=this.shadowMatrix[r];c.position.copy(q.position);c.lookAt(q.target.position);null==c.parent&&(h.add(c),b.autoUpdateScene&&h.updateMatrixWorld());c.matrixWorldInverse.getInverse(c.matrixWorld);p.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);p.multiplySelf(c.projectionMatrix);p.multiplySelf(c.matrixWorldInverse);if(!c._viewMatrixArray)c._viewMatrixArray=
-new Float32Array(16);c.matrixWorldInverse.flattenToArray(c._viewMatrixArray);if(!c._projectionMatrixArray)c._projectionMatrixArray=new Float32Array(16);c.projectionMatrix.flattenToArray(c._projectionMatrixArray);g.multiply(c.projectionMatrix,c.matrixWorldInverse);f.setFromMatrix(g);b.setRenderTarget(k);b.clear();m=h.__webglObjects;for(k=0,p=m.length;k<p;k++)if(n=m[k],q=n.object,n.render=!1,q.visible&&q.castShadow&&(!(q instanceof THREE.Mesh)||!q.frustumCulled||f.contains(q)))q.matrixWorld.flattenToArray(q._objectMatrixArray),
-q._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,q.matrixWorld,q._modelViewMatrixArray),n.render=!0;for(k=0,p=m.length;k<p;k++)if(n=m[k],n.render)q=n.object,n=n.buffer,b.setObjectFaces(q),o=q.customDepthMaterial?q.customDepthMaterial:q.geometry.morphTargets.length?e:d,n instanceof THREE.BufferGeometry?b.renderBufferDirect(c,s,null,o,n,q):b.renderBuffer(c,s,null,o,n,q);m=h.__webglObjectsImmediate;for(k=0,p=m.length;k<p;k++)n=m[k],q=n.object,q.visible&&q.castShadow&&(q.matrixAutoUpdate&&q.matrixWorld.flattenToArray(q._objectMatrixArray),
+new Float32Array(16);c.matrixWorldInverse.flattenToArray(c._viewMatrixArray);if(!c._projectionMatrixArray)c._projectionMatrixArray=new Float32Array(16);c.projectionMatrix.flattenToArray(c._projectionMatrixArray);g.multiply(c.projectionMatrix,c.matrixWorldInverse);f.setFromMatrix(g);b.setRenderTarget(k);b.clear();m=h.__webglObjects;for(k=0,p=m.length;k<p;k++)if(o=m[k],q=o.object,o.render=!1,q.visible&&q.castShadow&&(!(q instanceof THREE.Mesh)||!q.frustumCulled||f.contains(q)))q.matrixWorld.flattenToArray(q._objectMatrixArray),
+q._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,q.matrixWorld,q._modelViewMatrixArray),o.render=!0;for(k=0,p=m.length;k<p;k++)if(o=m[k],o.render)q=o.object,o=o.buffer,b.setObjectFaces(q),n=q.customDepthMaterial?q.customDepthMaterial:q.geometry.morphTargets.length?e:d,o instanceof THREE.BufferGeometry?b.renderBufferDirect(c,s,null,n,o,q):b.renderBuffer(c,s,null,n,o,q);m=h.__webglObjectsImmediate;for(k=0,p=m.length;k<p;k++)o=m[k],q=o.object,q.visible&&q.castShadow&&(q.matrixAutoUpdate&&q.matrixWorld.flattenToArray(q._objectMatrixArray),
 q._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,q.matrixWorld,q._modelViewMatrixArray),b.renderImmediateObject(c,s,null,d,q));r++}h=b.getClearColor();i=b.getClearAlpha();a.clearColor(h.r,h.g,h.b,i);a.enable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};
 THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,e,f,g,h,i,l,k;this.init=function(a){b=a.context;c=a;d=new Float32Array(16);e=new Uint16Array(6);a=0;d[a++]=-1;d[a++]=-1;d[a++]=0;d[a++]=1;d[a++]=1;d[a++]=-1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=0;d[a++]=-1;d[a++]=1;d[a++]=0;a=d[a++]=0;e[a++]=0;e[a++]=1;e[a++]=2;e[a++]=0;e[a++]=2;e[a++]=3;f=b.createBuffer();g=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
-g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,n=b.createProgram(),o=b.createShader(b.FRAGMENT_SHADER),q=b.createShader(b.VERTEX_SHADER);b.shaderSource(o,a.fragmentShader);b.shaderSource(q,a.vertexShader);b.compileShader(o);b.compileShader(q);b.attachShader(n,o);b.attachShader(n,q);b.linkProgram(n);h=n;i={};l={};i.position=b.getAttribLocation(h,"position");i.uv=b.getAttribLocation(h,"uv");l.uvOffset=b.getUniformLocation(h,"uvOffset");l.uvScale=b.getUniformLocation(h,
+g);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,o=b.createProgram(),n=b.createShader(b.FRAGMENT_SHADER),q=b.createShader(b.VERTEX_SHADER);b.shaderSource(n,a.fragmentShader);b.shaderSource(q,a.vertexShader);b.compileShader(n);b.compileShader(q);b.attachShader(o,n);b.attachShader(o,q);b.linkProgram(o);h=o;i={};l={};i.position=b.getAttribLocation(h,"position");i.uv=b.getAttribLocation(h,"uv");l.uvOffset=b.getUniformLocation(h,"uvOffset");l.uvScale=b.getUniformLocation(h,
 "uvScale");l.rotation=b.getUniformLocation(h,"rotation");l.scale=b.getUniformLocation(h,"scale");l.alignment=b.getUniformLocation(h,"alignment");l.color=b.getUniformLocation(h,"color");l.map=b.getUniformLocation(h,"map");l.opacity=b.getUniformLocation(h,"opacity");l.useScreenCoordinates=b.getUniformLocation(h,"useScreenCoordinates");l.affectedByDistance=b.getUniformLocation(h,"affectedByDistance");l.screenPosition=b.getUniformLocation(h,"screenPosition");l.modelViewMatrix=b.getUniformLocation(h,"modelViewMatrix");
-l.projectionMatrix=b.getUniformLocation(h,"projectionMatrix");k=!1};this.render=function(d,e,o,q){var d=d.__webglSprites,m=d.length;if(m){var r=i,s=l,t=q/o,o=0.5*o,u=0.5*q,x=!0;b.useProgram(h);k||(b.enableVertexAttribArray(r.position),b.enableVertexAttribArray(r.uv),k=!0);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(r.position,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(r.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.uniformMatrix4fv(s.projectionMatrix,
-!1,e._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(s.map,0);for(var v,A=[],r=0;r<m;r++)if(v=d[r],v.visible&&0!==v.opacity)v.useScreenCoordinates?v.z=-v.position.z:(v._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,v.matrixWorld,v._modelViewMatrixArray),v.z=-v._modelViewMatrix.n34);d.sort(a);for(r=0;r<m;r++)v=d[r],v.visible&&0!==v.opacity&&v.map&&v.map.image&&v.map.image.width&&(v.useScreenCoordinates?(b.uniform1i(s.useScreenCoordinates,1),b.uniform3f(s.screenPosition,(v.position.x-
-o)/o,(u-v.position.y)/u,Math.max(0,Math.min(1,v.position.z)))):(b.uniform1i(s.useScreenCoordinates,0),b.uniform1i(s.affectedByDistance,v.affectedByDistance?1:0),b.uniformMatrix4fv(s.modelViewMatrix,!1,v._modelViewMatrixArray)),e=v.map.image.width/(v.scaleByViewport?q:1),A[0]=e*t*v.scale.x,A[1]=e*v.scale.y,b.uniform2f(s.uvScale,v.uvScale.x,v.uvScale.y),b.uniform2f(s.uvOffset,v.uvOffset.x,v.uvOffset.y),b.uniform2f(s.alignment,v.alignment.x,v.alignment.y),b.uniform1f(s.opacity,v.opacity),b.uniform3f(s.color,
-v.color.r,v.color.g,v.color.b),b.uniform1f(s.rotation,v.rotation),b.uniform2fv(s.scale,A),v.mergeWith3D&&!x?(b.enable(b.DEPTH_TEST),x=!0):!v.mergeWith3D&&x&&(b.disable(b.DEPTH_TEST),x=!1),c.setBlending(v.blending),c.setTexture(v.map,0),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0));b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
-if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var b=this,c=this.setSize,d=this.render,e=new THREE.PerspectiveCamera,f=new THREE.PerspectiveCamera,g=new THREE.Matrix4,h=new THREE.Matrix4,i,l,k,p;e.matrixAutoUpdate=f.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},n=new THREE.WebGLRenderTarget(512,512,a),o=new THREE.WebGLRenderTarget(512,512,a),q=new THREE.PerspectiveCamera(53,
-1,1,1E4);q.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:n},mapRight:{type:"t",value:1,texture:o}},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}"}),
-m=new THREE.Scene;m.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));m.add(q);this.setSize=function(a,d){c.call(b,a,d);n.width=a;n.height=d;o.width=a;o.height=d};this.render=function(a,c){a.updateMatrixWorld();if(i!==c.aspect||l!==c.near||k!==c.far||p!==c.fov){i=c.aspect;l=c.near;k=c.far;p=c.fov;var t=c.projectionMatrix.clone(),u=0.5*(125/30),x=u*l/125,v=l*Math.tan(p*Math.PI/360),A;g.n14=u;h.n14=-u;u=-v*i+x;A=v*i+x;t.n11=2*l/(A-u);t.n13=(A+u)/(A-u);e.projectionMatrix.copy(t);u=-v*i-x;A=v*i-x;t.n11=
-2*l/(A-u);t.n13=(A+u)/(A-u);f.projectionMatrix.copy(t)}e.matrixWorld.copy(c.matrixWorld).multiplySelf(h);e.position.copy(c.position);e.near=c.near;e.far=c.far;d.call(b,a,e,n,!0);f.matrixWorld.copy(c.matrixWorld).multiplySelf(g);f.position.copy(c.position);f.near=c.near;f.far=c.far;d.call(b,a,f,o,!0);m.updateMatrixWorld();d.call(b,m,q)}};
+l.projectionMatrix=b.getUniformLocation(h,"projectionMatrix");k=!1};this.render=function(d,e,n,q){var d=d.__webglSprites,m=d.length;if(m){var r=i,s=l,t=q/n,n=0.5*n,u=0.5*q,x=!0;b.useProgram(h);k||(b.enableVertexAttribArray(r.position),b.enableVertexAttribArray(r.uv),k=!0);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(r.position,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(r.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.uniformMatrix4fv(s.projectionMatrix,
+!1,e._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(s.map,0);for(var w,A=[],r=0;r<m;r++)if(w=d[r],w.visible&&0!==w.opacity)w.useScreenCoordinates?w.z=-w.position.z:(w._modelViewMatrix.multiplyToArray(e.matrixWorldInverse,w.matrixWorld,w._modelViewMatrixArray),w.z=-w._modelViewMatrix.n34);d.sort(a);for(r=0;r<m;r++)w=d[r],w.visible&&0!==w.opacity&&w.map&&w.map.image&&w.map.image.width&&(w.useScreenCoordinates?(b.uniform1i(s.useScreenCoordinates,1),b.uniform3f(s.screenPosition,(w.position.x-
+n)/n,(u-w.position.y)/u,Math.max(0,Math.min(1,w.position.z)))):(b.uniform1i(s.useScreenCoordinates,0),b.uniform1i(s.affectedByDistance,w.affectedByDistance?1:0),b.uniformMatrix4fv(s.modelViewMatrix,!1,w._modelViewMatrixArray)),e=w.map.image.width/(w.scaleByViewport?q:1),A[0]=e*t*w.scale.x,A[1]=e*w.scale.y,b.uniform2f(s.uvScale,w.uvScale.x,w.uvScale.y),b.uniform2f(s.uvOffset,w.uvOffset.x,w.uvOffset.y),b.uniform2f(s.alignment,w.alignment.x,w.alignment.y),b.uniform1f(s.opacity,w.opacity),b.uniform3f(s.color,
+w.color.r,w.color.g,w.color.b),b.uniform1f(s.rotation,w.rotation),b.uniform2fv(s.scale,A),w.mergeWith3D&&!x?(b.enable(b.DEPTH_TEST),x=!0):!w.mergeWith3D&&x&&(b.disable(b.DEPTH_TEST),x=!1),c.setBlending(w.blending),c.setTexture(w.map,0),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0));b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
+if(THREE.WebGLRenderer)THREE.AnaglyphWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoUpdateScene=!1;var b=this,c=this.setSize,d=this.render,e=new THREE.PerspectiveCamera,f=new THREE.PerspectiveCamera,g=new THREE.Matrix4,h=new THREE.Matrix4,i,l,k,p;e.matrixAutoUpdate=f.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},o=new THREE.WebGLRenderTarget(512,512,a),n=new THREE.WebGLRenderTarget(512,512,a),q=new THREE.PerspectiveCamera(53,
+1,1,1E4);q.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:o},mapRight:{type:"t",value:1,texture:n}},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}"}),
+m=new THREE.Scene;m.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));m.add(q);this.setSize=function(a,d){c.call(b,a,d);o.width=a;o.height=d;n.width=a;n.height=d};this.render=function(a,c){a.updateMatrixWorld();if(i!==c.aspect||l!==c.near||k!==c.far||p!==c.fov){i=c.aspect;l=c.near;k=c.far;p=c.fov;var t=c.projectionMatrix.clone(),u=0.5*(125/30),x=u*l/125,w=l*Math.tan(p*Math.PI/360),A;g.n14=u;h.n14=-u;u=-w*i+x;A=w*i+x;t.n11=2*l/(A-u);t.n13=(A+u)/(A-u);e.projectionMatrix.copy(t);u=-w*i-x;A=w*i-x;t.n11=
+2*l/(A-u);t.n13=(A+u)/(A-u);f.projectionMatrix.copy(t)}e.matrixWorld.copy(c.matrixWorld).multiplySelf(h);e.position.copy(c.position);e.near=c.near;e.far=c.far;d.call(b,a,e,o,!0);f.matrixWorld.copy(c.matrixWorld).multiplySelf(g);f.position.copy(c.position);f.near=c.near;f.far=c.far;d.call(b,a,f,n,!0);m.updateMatrixWorld();d.call(b,m,q)}};
 if(THREE.WebGLRenderer)THREE.CrosseyedWebGLRenderer=function(a){THREE.WebGLRenderer.call(this,a);this.autoClear=!1;var b=this,c=this.setSize,d=this.render,e,f,g=new THREE.PerspectiveCamera;g.target=new THREE.Vector3(0,0,0);var h=new THREE.PerspectiveCamera;h.target=new THREE.Vector3(0,0,0);b.separation=10;if(a&&void 0!==a.separation)b.separation=a.separation;this.setSize=function(a,d){c.call(b,a,d);e=a/2;f=d};this.render=function(a,c){this.clear();g.fov=c.fov;g.aspect=0.5*c.aspect;g.near=c.near;g.far=
 c.far;g.updateProjectionMatrix();g.position.copy(c.position);g.target.copy(c.target);g.translateX(b.separation);g.lookAt(g.target);h.projectionMatrix=g.projectionMatrix;h.position.copy(c.position);h.target.copy(c.target);h.translateX(-b.separation);h.lookAt(h.target);this.setViewport(0,0,e,f);d.call(b,a,g);this.setViewport(e,0,e,f);d.call(b,a,h,!1)}};
 THREE.ShaderFlares={lensFlareVertexTexture:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = (       visibility.r / 9.0 ) *\n( 1.0 - visibility.g / 9.0 ) *\n(       visibility.b / 9.0 ) *\n( 1.0 - visibility.a / 9.0 );\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},

+ 45 - 45
build/custom/ThreeCanvas.js

@@ -16,11 +16,11 @@ b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]};
 THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes;c[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);c[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);c[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);c[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);c[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);c[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;6>a;a++)b=c[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))};
 THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),e=0;6>e;e++)if(a=b[e].x*c.n14+b[e].y*c.n24+b[e].z*c.n34+b[e].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3;
-THREE.Ray=function(a,b){function c(a,b,c){j.sub(c,a);q=j.dot(b);w=p.add(a,k.copy(b).multiplyScalar(q));return u=c.distanceTo(w)}function d(a,b,c,d){j.sub(d,b);p.sub(c,b);k.sub(a,b);I=j.dot(j);G=j.dot(p);v=j.dot(k);H=p.dot(p);z=p.dot(k);E=1/(I*H-G*G);r=(H*v-G*z)*E;s=(I*z-G*v)*E;return 0<=r&&0<=s&&1>r+s}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,c,d=[];for(b=0,
+THREE.Ray=function(a,b){function c(a,b,c){j.sub(c,a);q=j.dot(b);x=p.add(a,k.copy(b).multiplyScalar(q));return v=c.distanceTo(x)}function d(a,b,c,d){j.sub(d,b);p.sub(c,b);k.sub(a,b);I=j.dot(j);G=j.dot(p);w=j.dot(k);H=p.dot(p);A=p.dot(k);F=1/(I*H-G*G);r=(H*w-G*A)*F;s=(I*A-G*w)*F;return 0<=r&&0<=s&&1>r+s}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,c,d=[];for(b=0,
 c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,i=new THREE.Vector3,m=new THREE.Vector3,h=new THREE.Vector3,l=new THREE.Vector3,o=new THREE.Vector3,n=new THREE.Vector3;this.intersectObject=function(a){for(var b,k=[],j=0,p=a.children.length;j<p;j++)Array.prototype.push.apply(k,this.intersectObject(a.children[j]));if(a instanceof THREE.Particle){j=
-c(this.origin,this.direction,a.matrixWorld.getPosition());if(j>a.scale.x)return[];b={distance:j,point:a.position,face:null,object:a};k.push(b)}else if(a instanceof THREE.Mesh){j=c(this.origin,this.direction,a.matrixWorld.getPosition());if(j>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return k;var q,r=a.geometry,s=r.vertices,F;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(j=0,p=r.faces.length;j<p;j++)if(b=r.faces[j],m.copy(this.origin),h.copy(this.direction),
-F=a.matrixWorld,l=F.multiplyVector3(l.copy(b.centroid)).subSelf(m),q=l.dot(h),!(0>=q)&&(e=F.multiplyVector3(e.copy(s[b.a].position)),f=F.multiplyVector3(f.copy(s[b.b].position)),g=F.multiplyVector3(g.copy(s[b.c].position)),b instanceof THREE.Face4&&(i=F.multiplyVector3(i.copy(s[b.d].position))),o=a.matrixRotationWorld.multiplyVector3(o.copy(b.normal)),q=h.dot(o),a.doubleSided||(a.flipSided?0<q:0>q)))if(q=o.dot(l.sub(e,m))/q,n.add(m,h.multiplyScalar(q)),b instanceof THREE.Face3)d(n,e,f,g)&&(b={distance:m.distanceTo(n),
-point:n.clone(),face:b,object:a},k.push(b));else if(b instanceof THREE.Face4&&(d(n,e,f,i)||d(n,f,g,i)))b={distance:m.distanceTo(n),point:n.clone(),face:b,object:a},k.push(b)}return k};var j=new THREE.Vector3,p=new THREE.Vector3,k=new THREE.Vector3,q,w,u,I,G,v,H,z,E,r,s};
+c(this.origin,this.direction,a.matrixWorld.getPosition());if(j>a.scale.x)return[];b={distance:j,point:a.position,face:null,object:a};k.push(b)}else if(a instanceof THREE.Mesh){j=c(this.origin,this.direction,a.matrixWorld.getPosition());if(j>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return k;var q,r,s=a.geometry,E=s.vertices,t;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(j=0,p=s.faces.length;j<p;j++)if(b=s.faces[j],m.copy(this.origin),h.copy(this.direction),
+t=a.matrixWorld,l=t.multiplyVector3(l.copy(b.centroid)).subSelf(m),o=a.matrixRotationWorld.multiplyVector3(o.copy(b.normal)),q=h.dot(o),!(1.0E-4>Math.abs(q))&&(r=o.dot(l)/q,!(0>r)&&(a.doubleSided||(a.flipSided?0<q:0>q))))if(n.add(m,h.multiplyScalar(r)),b instanceof THREE.Face3)e=t.multiplyVector3(e.copy(E[b.a].position)),f=t.multiplyVector3(f.copy(E[b.b].position)),g=t.multiplyVector3(g.copy(E[b.c].position)),d(n,e,f,g)&&(b={distance:m.distanceTo(n),point:n.clone(),face:b,object:a},k.push(b));else if(b instanceof
+THREE.Face4&&(e=t.multiplyVector3(e.copy(E[b.a].position)),f=t.multiplyVector3(f.copy(E[b.b].position)),g=t.multiplyVector3(g.copy(E[b.c].position)),i=t.multiplyVector3(i.copy(E[b.d].position)),d(n,e,f,i)||d(n,f,g,i)))b={distance:m.distanceTo(n),point:n.clone(),face:b,object:a},k.push(b)}return k};var j=new THREE.Vector3,p=new THREE.Vector3,k=new THREE.Vector3,q,x,v,I,G,w,H,A,F,r,s};
 THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,l,o){i=!1;b=f;c=g;d=l;e=o;a()};this.addPoint=function(f,g){i?(i=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
 function(f,g,l,o,n,j){i?(i=!1,b=f<l?f<n?f:n:l<n?l:n,c=g<o?g<j?g:j:o<j?o:j,d=f>l?f>n?f:n:l>n?l:n,e=g>o?g>j?g:j:o>j?o:j):(b=f<l?f<n?f<b?f:b:n<b?n:b:l<n?l<b?l:b:n<b?n:b,c=g<o?g<j?g<c?g:c:j<c?j:c:o<j?o<c?o:c:j<c?j:c,d=f>l?f>n?f>d?f:d:n>d?n:d:l>n?l>d?l:d:n>d?n:d,e=g>o?g>j?g>e?g:e:j>e?j:e:o>j?o>e?o:e:j>e?j:e);a()};this.addRectangle=function(f){i?(i=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
 f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||e<a.getTop()||c>a.getBottom()?!1:!0};this.empty=function(){i=!0;e=d=c=b=0;a()};this.isEmpty=function(){return i}};
@@ -29,8 +29,8 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=
 THREE.Matrix4=function(a,b,c,d,e,f,g,i,m,h,l,o,n,j,p,k){this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==f?f:1,g||0,i||0,m||0,h||0,void 0!==l?l:1,o||0,n||0,j||0,p||0,void 0!==k?k:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,i,m,h,l,o,n,j,p,k){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=i;this.n31=m;this.n32=h;this.n33=l;this.n34=o;this.n41=n;this.n42=j;this.n43=p;this.n44=k;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
 b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(0===f.length())f.z=1;d.cross(c,f).normalize();0===d.length()&&(f.x+=1.0E-4,d.cross(c,f).normalize());e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,i=a.n22,m=a.n23,h=a.n24,l=a.n31,o=a.n32,n=a.n33,j=a.n34,p=a.n41,k=a.n42,q=a.n43,
-w=a.n44,u=b.n11,I=b.n12,G=b.n13,v=b.n14,H=b.n21,z=b.n22,E=b.n23,r=b.n24,s=b.n31,C=b.n32,J=b.n33,Z=b.n34,ca=b.n41,N=b.n42,P=b.n43,S=b.n44;this.n11=c*u+d*H+e*s+f*ca;this.n12=c*I+d*z+e*C+f*N;this.n13=c*G+d*E+e*J+f*P;this.n14=c*v+d*r+e*Z+f*S;this.n21=g*u+i*H+m*s+h*ca;this.n22=g*I+i*z+m*C+h*N;this.n23=g*G+i*E+m*J+h*P;this.n24=g*v+i*r+m*Z+h*S;this.n31=l*u+o*H+n*s+j*ca;this.n32=l*I+o*z+n*C+j*N;this.n33=l*G+o*E+n*J+j*P;this.n34=l*v+o*r+n*Z+j*S;this.n41=p*u+k*H+q*s+w*ca;this.n42=p*I+k*z+q*C+w*N;this.n43=p*
-G+k*E+q*J+w*P;this.n44=p*v+k*r+q*Z+w*S;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
+x=a.n44,v=b.n11,I=b.n12,G=b.n13,w=b.n14,H=b.n21,A=b.n22,F=b.n23,r=b.n24,s=b.n31,D=b.n32,J=b.n33,Z=b.n34,ca=b.n41,N=b.n42,P=b.n43,S=b.n44;this.n11=c*v+d*H+e*s+f*ca;this.n12=c*I+d*A+e*D+f*N;this.n13=c*G+d*F+e*J+f*P;this.n14=c*w+d*r+e*Z+f*S;this.n21=g*v+i*H+m*s+h*ca;this.n22=g*I+i*A+m*D+h*N;this.n23=g*G+i*F+m*J+h*P;this.n24=g*w+i*r+m*Z+h*S;this.n31=l*v+o*H+n*s+j*ca;this.n32=l*I+o*A+n*D+j*N;this.n33=l*G+o*F+n*J+j*P;this.n34=l*w+o*r+n*Z+j*S;this.n41=p*v+k*H+q*s+x*ca;this.n42=p*I+k*A+q*D+x*N;this.n43=p*
+G+k*F+q*J+x*P;this.n44=p*w+k*r+q*Z+x*S;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
 a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*
 c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*
 a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,i=this.n24,m=this.n31,h=this.n32,l=this.n33,o=this.n34,n=this.n41,j=this.n42,p=this.n43,k=this.n44;return d*g*h*n-c*i*h*n-d*f*l*n+b*i*l*n+c*f*o*n-b*g*o*n-d*g*m*j+c*i*m*j+d*e*l*j-a*i*l*j-c*e*o*j+a*g*o*j+d*f*m*p-b*i*m*p-d*e*h*p+a*i*h*p+b*e*o*p-a*f*o*p-c*f*m*k+b*g*m*k+c*e*h*k-a*g*h*k-b*e*l*k+a*f*l*k},transpose:function(){var a;
@@ -47,8 +47,8 @@ e,l=c*i,o=c*e,this.n11=g*i,this.n12=-g*e,this.n13=d,this.n21=h+l*d,this.n22=m-o*
 a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);f.set(this.n13,
 this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();c.y=e.length();c.z=f.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
 return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this},rotateByAxis:function(a,b){if(1===a.x&&0===a.y&&0===a.z)return this.rotateX(b);if(0===a.x&&1===a.y&&0===a.z)return this.rotateY(b);if(0===a.x&&0===a.y&&1===
-a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e),c=c/f,d=d/f,e=e/f,f=c*c,g=d*d,i=e*e,m=Math.cos(b),h=Math.sin(b),l=1-m,o=c*d*l,n=c*e*l,l=d*e*l,c=c*h,j=d*h,h=e*h,e=f+(1-f)*m,f=o+h,d=n-j,o=o-h,g=g+(1-g)*m,h=l+c,n=n+j,l=l-c,i=i+(1-i)*m,m=this.n11,c=this.n21,j=this.n31,p=this.n41,k=this.n12,q=this.n22,w=this.n32,u=this.n42,I=this.n13,G=this.n23,v=this.n33,H=this.n43;this.n11=e*m+f*k+d*I;this.n21=e*c+f*q+d*G;this.n31=e*j+f*w+d*v;this.n41=e*p+f*u+d*H;this.n12=o*m+g*k+h*I;this.n22=
-o*c+g*q+h*G;this.n32=o*j+g*w+h*v;this.n42=o*p+g*u+h*H;this.n13=n*m+l*k+i*I;this.n23=n*c+l*q+i*G;this.n33=n*j+l*w+i*v;this.n43=n*p+l*u+i*H;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,f=this.n13,g=this.n23,i=this.n33,m=this.n43,h=Math.cos(a),a=Math.sin(a);this.n12=h*b+a*f;this.n22=h*c+a*g;this.n32=h*d+a*i;this.n42=h*e+a*m;this.n13=h*f-a*b;this.n23=h*g-a*c;this.n33=h*i-a*d;this.n43=h*m-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,
+a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e),c=c/f,d=d/f,e=e/f,f=c*c,g=d*d,i=e*e,m=Math.cos(b),h=Math.sin(b),l=1-m,o=c*d*l,n=c*e*l,l=d*e*l,c=c*h,j=d*h,h=e*h,e=f+(1-f)*m,f=o+h,d=n-j,o=o-h,g=g+(1-g)*m,h=l+c,n=n+j,l=l-c,i=i+(1-i)*m,m=this.n11,c=this.n21,j=this.n31,p=this.n41,k=this.n12,q=this.n22,x=this.n32,v=this.n42,I=this.n13,G=this.n23,w=this.n33,H=this.n43;this.n11=e*m+f*k+d*I;this.n21=e*c+f*q+d*G;this.n31=e*j+f*x+d*w;this.n41=e*p+f*v+d*H;this.n12=o*m+g*k+h*I;this.n22=
+o*c+g*q+h*G;this.n32=o*j+g*x+h*w;this.n42=o*p+g*v+h*H;this.n13=n*m+l*k+i*I;this.n23=n*c+l*q+i*G;this.n33=n*j+l*x+i*w;this.n43=n*p+l*v+i*H;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,f=this.n13,g=this.n23,i=this.n33,m=this.n43,h=Math.cos(a),a=Math.sin(a);this.n12=h*b+a*f;this.n22=h*c+a*g;this.n32=h*d+a*i;this.n42=h*e+a*m;this.n13=h*f-a*b;this.n23=h*g-a*c;this.n33=h*i-a*d;this.n43=h*m-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,
 f=this.n13,g=this.n23,i=this.n33,m=this.n43,h=Math.cos(a),a=Math.sin(a);this.n11=h*b-a*f;this.n21=h*c-a*g;this.n31=h*d-a*i;this.n41=h*e-a*m;this.n13=h*f+a*b;this.n23=h*g+a*c;this.n33=h*i+a*d;this.n43=h*m+a*e;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,f=this.n12,g=this.n22,i=this.n32,m=this.n42,h=Math.cos(a),a=Math.sin(a);this.n11=h*b+a*f;this.n21=h*c+a*g;this.n31=h*d+a*i;this.n41=h*e+a*m;this.n12=h*f-a*b;this.n22=h*g-a*c;this.n32=h*i-a*d;this.n42=h*m-a*e;return this},
 translate:function(a){var b=a.x,c=a.y,a=a.z;this.n14=this.n11*b+this.n12*c+this.n13*a+this.n14;this.n24=this.n21*b+this.n22*c+this.n23*a+this.n24;this.n34=this.n31*b+this.n32*c+this.n33*a+this.n34;this.n44=this.n41*b+this.n42*c+this.n43*a+this.n44;return this}};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,h=a.n23*a.n12-a.n22*a.n13,l=-a.n23*a.n11+a.n21*a.n13,o=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*g+a.n31*h;if(0===a)return null;a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*i;c[5]=a*m;c[6]=a*h;c[7]=a*l;c[8]=a*o;return b};
@@ -61,16 +61,16 @@ this.children.indexOf(a)){void 0!==a.parent&&a.parent.remove(a);a.parent=this;th
 a||b&&(e=e.getChildByName(a,b),void 0!==e))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(1!==this.scale.x||1!==this.scale.y||1!==this.scale.z)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){this.matrixAutoUpdate&&
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)}};THREE.Object3DCount=0;
 THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=h[m]=h[m]||new THREE.RenderableVertex;m++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,i=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=i)return!0;if(0>e&&0>f||0>g&&0>i)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-i)):0>i&&(d=Math.min(d,g/(g-i)));if(d<c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return!0}
-var e,f,g=[],i,m,h=[],l,o,n=[],j,p=[],k,q,w=[],u,I,G=[],v={objects:[],sprites:[],lights:[],elements:[]},H=new THREE.Vector3,z=new THREE.Vector4,E=new THREE.Matrix4,r=new THREE.Matrix4,s=new THREE.Frustum,C=new THREE.Vector4,J=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);E.multiply(b.projectionMatrix,b.matrixWorldInverse);E.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);E.multiply(b.matrixWorld,
-b.projectionMatrixInverse);E.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){f=0;v.objects.length=0;v.sprites.length=0;v.lights.length=0;var g=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||s.contains(b))?(E.multiplyVector3(H.copy(b.position)),e=a(),e.object=
-b,e.z=H.z,v.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(E.multiplyVector3(H.copy(b.position)),e=a(),e.object=b,e.z=H.z,v.sprites.push(e)):b instanceof THREE.Light&&v.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&v.objects.sort(c);return v};this.projectScene=function(a,e,f){var g=e.near,H=e.far,T,F,D,Q,x,O,M,V,K,t,B,y,A,L,ka,ea;I=q=j=o=0;v.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
-a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);E.multiply(e.projectionMatrix,e.matrixWorldInverse);s.setFromMatrix(E);v=this.projectGraph(a,!1);for(a=0,T=v.objects.length;a<T;a++)if(K=v.objects[a].object,t=K.matrixWorld,y=K.material,m=0,K instanceof THREE.Mesh){B=K.geometry;A=K.geometry.materials;Q=B.vertices;L=B.faces;ka=B.faceVertexUvs;B=K.matrixRotationWorld.extractRotation(t);for(F=0,D=Q.length;F<D;F++)i=b(),i.positionWorld.copy(Q[F].position),t.multiplyVector3(i.positionWorld),
-i.positionScreen.copy(i.positionWorld),E.multiplyVector4(i.positionScreen),i.positionScreen.x/=i.positionScreen.w,i.positionScreen.y/=i.positionScreen.w,i.visible=i.positionScreen.z>g&&i.positionScreen.z<H;for(Q=0,F=L.length;Q<F;Q++){D=L[Q];if(D instanceof THREE.Face3)if(x=h[D.a],O=h[D.b],M=h[D.c],x.visible&&O.visible&&M.visible&&(K.doubleSided||K.flipSided!=0>(M.positionScreen.x-x.positionScreen.x)*(O.positionScreen.y-x.positionScreen.y)-(M.positionScreen.y-x.positionScreen.y)*(O.positionScreen.x-
-x.positionScreen.x)))V=n[o]=n[o]||new THREE.RenderableFace3,o++,l=V,l.v1.copy(x),l.v2.copy(O),l.v3.copy(M);else continue;else if(D instanceof THREE.Face4)if(x=h[D.a],O=h[D.b],M=h[D.c],V=h[D.d],x.visible&&O.visible&&M.visible&&V.visible&&(K.doubleSided||K.flipSided!=(0>(V.positionScreen.x-x.positionScreen.x)*(O.positionScreen.y-x.positionScreen.y)-(V.positionScreen.y-x.positionScreen.y)*(O.positionScreen.x-x.positionScreen.x)||0>(O.positionScreen.x-M.positionScreen.x)*(V.positionScreen.y-M.positionScreen.y)-
-(O.positionScreen.y-M.positionScreen.y)*(V.positionScreen.x-M.positionScreen.x))))ea=p[j]=p[j]||new THREE.RenderableFace4,j++,l=ea,l.v1.copy(x),l.v2.copy(O),l.v3.copy(M),l.v4.copy(V);else continue;l.normalWorld.copy(D.normal);B.multiplyVector3(l.normalWorld);l.centroidWorld.copy(D.centroid);t.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);E.multiplyVector3(l.centroidScreen);M=D.vertexNormals;for(x=0,O=M.length;x<O;x++)V=l.vertexNormalsWorld[x],V.copy(M[x]),B.multiplyVector3(V);
-for(x=0,O=ka.length;x<O;x++)if(ea=ka[x][Q])for(M=0,V=ea.length;M<V;M++)l.uvs[x][M]=ea[M];l.material=y;l.faceMaterial=null!==D.materialIndex?A[D.materialIndex]:null;l.z=l.centroidScreen.z;v.elements.push(l)}}else if(K instanceof THREE.Line){r.multiply(E,t);Q=K.geometry.vertices;x=b();x.positionScreen.copy(Q[0].position);r.multiplyVector4(x.positionScreen);for(F=1,D=Q.length;F<D;F++)if(x=b(),x.positionScreen.copy(Q[F].position),r.multiplyVector4(x.positionScreen),O=h[m-2],C.copy(x.positionScreen),J.copy(O.positionScreen),
-d(C,J))C.multiplyScalar(1/C.w),J.multiplyScalar(1/J.w),K=w[q]=w[q]||new THREE.RenderableLine,q++,k=K,k.v1.positionScreen.copy(C),k.v2.positionScreen.copy(J),k.z=Math.max(C.z,J.z),k.material=y,v.elements.push(k)}for(a=0,T=v.sprites.length;a<T;a++)if(K=v.sprites[a].object,t=K.matrixWorld,K instanceof THREE.Particle&&(z.set(t.n14,t.n24,t.n34,1),E.multiplyVector4(z),z.z/=z.w,0<z.z&&1>z.z))g=G[I]=G[I]||new THREE.RenderableParticle,I++,u=g,u.x=z.x/z.w,u.y=z.y/z.w,u.z=z.z,u.rotation=K.rotation.z,u.scale.x=
-K.scale.x*Math.abs(u.x-(z.x+e.projectionMatrix.n11)/(z.w+e.projectionMatrix.n14)),u.scale.y=K.scale.y*Math.abs(u.y-(z.y+e.projectionMatrix.n22)/(z.w+e.projectionMatrix.n24)),u.material=K.material,v.elements.push(u);f&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
+var e,f,g=[],i,m,h=[],l,o,n=[],j,p=[],k,q,x=[],v,I,G=[],w={objects:[],sprites:[],lights:[],elements:[]},H=new THREE.Vector3,A=new THREE.Vector4,F=new THREE.Matrix4,r=new THREE.Matrix4,s=new THREE.Frustum,D=new THREE.Vector4,J=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);F.multiply(b.projectionMatrix,b.matrixWorldInverse);F.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);F.multiply(b.matrixWorld,
+b.projectionMatrixInverse);F.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){f=0;w.objects.length=0;w.sprites.length=0;w.lights.length=0;var g=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||s.contains(b))?(F.multiplyVector3(H.copy(b.position)),e=a(),e.object=
+b,e.z=H.z,w.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(F.multiplyVector3(H.copy(b.position)),e=a(),e.object=b,e.z=H.z,w.sprites.push(e)):b instanceof THREE.Light&&w.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&w.objects.sort(c);return w};this.projectScene=function(a,e,f){var g=e.near,H=e.far,T,E,t,Q,y,O,M,V,K,u,C,z,B,L,ka,ea;I=q=j=o=0;w.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
+a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);F.multiply(e.projectionMatrix,e.matrixWorldInverse);s.setFromMatrix(F);w=this.projectGraph(a,!1);for(a=0,T=w.objects.length;a<T;a++)if(K=w.objects[a].object,u=K.matrixWorld,z=K.material,m=0,K instanceof THREE.Mesh){C=K.geometry;B=K.geometry.materials;Q=C.vertices;L=C.faces;ka=C.faceVertexUvs;C=K.matrixRotationWorld.extractRotation(u);for(E=0,t=Q.length;E<t;E++)i=b(),i.positionWorld.copy(Q[E].position),u.multiplyVector3(i.positionWorld),
+i.positionScreen.copy(i.positionWorld),F.multiplyVector4(i.positionScreen),i.positionScreen.x/=i.positionScreen.w,i.positionScreen.y/=i.positionScreen.w,i.visible=i.positionScreen.z>g&&i.positionScreen.z<H;for(Q=0,E=L.length;Q<E;Q++){t=L[Q];if(t instanceof THREE.Face3)if(y=h[t.a],O=h[t.b],M=h[t.c],y.visible&&O.visible&&M.visible&&(K.doubleSided||K.flipSided!=0>(M.positionScreen.x-y.positionScreen.x)*(O.positionScreen.y-y.positionScreen.y)-(M.positionScreen.y-y.positionScreen.y)*(O.positionScreen.x-
+y.positionScreen.x)))V=n[o]=n[o]||new THREE.RenderableFace3,o++,l=V,l.v1.copy(y),l.v2.copy(O),l.v3.copy(M);else continue;else if(t instanceof THREE.Face4)if(y=h[t.a],O=h[t.b],M=h[t.c],V=h[t.d],y.visible&&O.visible&&M.visible&&V.visible&&(K.doubleSided||K.flipSided!=(0>(V.positionScreen.x-y.positionScreen.x)*(O.positionScreen.y-y.positionScreen.y)-(V.positionScreen.y-y.positionScreen.y)*(O.positionScreen.x-y.positionScreen.x)||0>(O.positionScreen.x-M.positionScreen.x)*(V.positionScreen.y-M.positionScreen.y)-
+(O.positionScreen.y-M.positionScreen.y)*(V.positionScreen.x-M.positionScreen.x))))ea=p[j]=p[j]||new THREE.RenderableFace4,j++,l=ea,l.v1.copy(y),l.v2.copy(O),l.v3.copy(M),l.v4.copy(V);else continue;l.normalWorld.copy(t.normal);C.multiplyVector3(l.normalWorld);l.centroidWorld.copy(t.centroid);u.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);F.multiplyVector3(l.centroidScreen);M=t.vertexNormals;for(y=0,O=M.length;y<O;y++)V=l.vertexNormalsWorld[y],V.copy(M[y]),C.multiplyVector3(V);
+for(y=0,O=ka.length;y<O;y++)if(ea=ka[y][Q])for(M=0,V=ea.length;M<V;M++)l.uvs[y][M]=ea[M];l.material=z;l.faceMaterial=null!==t.materialIndex?B[t.materialIndex]:null;l.z=l.centroidScreen.z;w.elements.push(l)}}else if(K instanceof THREE.Line){r.multiply(F,u);Q=K.geometry.vertices;y=b();y.positionScreen.copy(Q[0].position);r.multiplyVector4(y.positionScreen);for(E=1,t=Q.length;E<t;E++)if(y=b(),y.positionScreen.copy(Q[E].position),r.multiplyVector4(y.positionScreen),O=h[m-2],D.copy(y.positionScreen),J.copy(O.positionScreen),
+d(D,J))D.multiplyScalar(1/D.w),J.multiplyScalar(1/J.w),K=x[q]=x[q]||new THREE.RenderableLine,q++,k=K,k.v1.positionScreen.copy(D),k.v2.positionScreen.copy(J),k.z=Math.max(D.z,J.z),k.material=z,w.elements.push(k)}for(a=0,T=w.sprites.length;a<T;a++)if(K=w.sprites[a].object,u=K.matrixWorld,K instanceof THREE.Particle&&(A.set(u.n14,u.n24,u.n34,1),F.multiplyVector4(A),A.z/=A.w,0<A.z&&1>A.z))g=G[I]=G[I]||new THREE.RenderableParticle,I++,v=g,v.x=A.x/A.w,v.y=A.y/A.w,v.z=A.z,v.rotation=K.rotation.z,v.scale.x=
+K.scale.x*Math.abs(v.x-(A.x+e.projectionMatrix.n11)/(A.w+e.projectionMatrix.n14)),v.scale.y=K.scale.y*Math.abs(v.y-(A.y+e.projectionMatrix.n22)/(A.w+e.projectionMatrix.n24)),v.material=K.material,w.elements.push(v);f&&w.elements.sort(c);return w}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,i=d*e;this.w=g*f-i*c;this.x=g*c+i*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
@@ -86,9 +86,9 @@ b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid
 b,c,d,e,f,g=new THREE.Vector3,i=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],d=this.vertices[c.a],e=this.vertices[c.b],f=this.vertices[c.c],g.sub(f.position,e.position),i.sub(d.position,e.position),g.crossSelf(i),g.isZero()||g.normalize(),c.normal.copy(g)},computeVertexNormals:function(){var a,b,c,d;if(void 0===this.__tmpVertices){d=this.__tmpVertices=Array(this.vertices.length);for(a=0,b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)if(c=
 this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=this.__tmpVertices;for(a=0,b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),
 d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));for(a=0,b=this.vertices.length;a<b;a++)d[a].normalize();for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,
-b,c,d,e,f,E){i=a.vertices[b].position;m=a.vertices[c].position;h=a.vertices[d].position;l=g[e];o=g[f];n=g[E];j=m.x-i.x;p=h.x-i.x;k=m.y-i.y;q=h.y-i.y;w=m.z-i.z;u=h.z-i.z;I=o.u-l.u;G=n.u-l.u;v=o.v-l.v;H=n.v-l.v;z=1/(I*H-G*v);C.set((H*j-v*p)*z,(H*k-v*q)*z,(H*w-v*u)*z);J.set((I*p-G*j)*z,(I*q-G*k)*z,(I*u-G*w)*z);r[b].addSelf(C);r[c].addSelf(C);r[d].addSelf(C);s[b].addSelf(J);s[c].addSelf(J);s[d].addSelf(J)}var b,c,d,e,f,g,i,m,h,l,o,n,j,p,k,q,w,u,I,G,v,H,z,E,r=[],s=[],C=new THREE.Vector3,J=new THREE.Vector3,
+b,c,d,e,f,F){i=a.vertices[b].position;m=a.vertices[c].position;h=a.vertices[d].position;l=g[e];o=g[f];n=g[F];j=m.x-i.x;p=h.x-i.x;k=m.y-i.y;q=h.y-i.y;x=m.z-i.z;v=h.z-i.z;I=o.u-l.u;G=n.u-l.u;w=o.v-l.v;H=n.v-l.v;A=1/(I*H-G*w);D.set((H*j-w*p)*A,(H*k-w*q)*A,(H*x-w*v)*A);J.set((I*p-G*j)*A,(I*q-G*k)*A,(I*v-G*x)*A);r[b].addSelf(D);r[c].addSelf(D);r[d].addSelf(D);s[b].addSelf(J);s[c].addSelf(J);s[d].addSelf(J)}var b,c,d,e,f,g,i,m,h,l,o,n,j,p,k,q,x,v,I,G,w,H,A,F,r=[],s=[],D=new THREE.Vector3,J=new THREE.Vector3,
 Z=new THREE.Vector3,ca=new THREE.Vector3,N=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)r[b]=new THREE.Vector3,s[b]=new THREE.Vector3;for(b=0,c=this.faces.length;b<c;b++)f=this.faces[b],g=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var P=["a","b","c","d"];for(b=0,c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)N.copy(f.vertexNormals[d]),e=f[P[d]],
-E=r[e],Z.copy(E),Z.subSelf(N.multiplyScalar(N.dot(E))).normalize(),ca.cross(f.vertexNormals[d],E),e=ca.dot(s[e]),e=0>e?-1:1,f.vertexTangents[d]=new THREE.Vector4(Z.x,Z.y,Z.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
+F=r[e],Z.copy(F),Z.subSelf(N.multiplyScalar(N.dot(F))).normalize(),ca.cross(f.vertexNormals[d],F),e=ca.dot(s[e]),e=0>e?-1:1,f.vertexTangents[d]=new THREE.Vector4(Z.x,Z.y,Z.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,e=this.vertices.length;d<e;d++){a=
 this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a,b=0,c=0,d=this.vertices.length;c<d;c++)a=this.vertices[c].position.length(),a>b&&(b=a);this.boundingSphere={radius:b}},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;for(f=0,g=this.vertices.length;f<g;f++)d=this.vertices[f].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*
 e)].join("_"),void 0===a[d]?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];for(f=0,g=this.faces.length;f<g;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
 THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;
@@ -131,38 +131,38 @@ THREE.SpriteAlignment.topRight=new THREE.Vector2(-1,-1);THREE.SpriteAlignment.ce
 THREE.Scene=function(){THREE.Object3D.call(this);this.overrideMaterial=this.fog=null;this.matrixAutoUpdate=!1;this.objects=[];this.lights=[];this.__objectsAdded=[];this.__objectsRemoved=[]};THREE.Scene.prototype=new THREE.Object3D;THREE.Scene.prototype.constructor=THREE.Scene;
 THREE.Scene.prototype.addObject=function(a){if(a instanceof THREE.Light)-1===this.lights.indexOf(a)&&this.lights.push(a);else if(!(a instanceof THREE.Camera||a instanceof THREE.Bone)&&-1===this.objects.indexOf(a)){this.objects.push(a);this.__objectsAdded.push(a);var b=this.__objectsRemoved.indexOf(a);-1!==b&&this.__objectsRemoved.splice(b,1)}for(b=0;b<a.children.length;b++)this.addObject(a.children[b])};
 THREE.Scene.prototype.removeObject=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);-1!==b&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),-1!==b&&(this.objects.splice(b,1),this.__objectsRemoved.push(a),b=this.__objectsAdded.indexOf(a),-1!==b&&this.__objectsAdded.splice(b,1)));for(b=0;b<a.children.length;b++)this.removeObject(a.children[b])};
-THREE.CanvasRenderer=function(a){function b(a){if(u!=a)k.globalAlpha=u=a}function c(a){if(I!=a){switch(a){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}I=a}}function d(a){if(G!=a)k.strokeStyle=G=a}function e(a){if(v!=a)k.fillStyle=v=a}var a=a||{},f=this,g,i,m,h=new THREE.Projector,l=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
-o,n,j,p,k=l.getContext("2d"),q=new THREE.Color(0),w=0,u=1,I=0,G=null,v=null,H=null,z=null,E=null,r,s,C,J,Z=new THREE.RenderableVertex,ca=new THREE.RenderableVertex,N,P,S,T,F,D,Q,x,O,M,V,K,t=new THREE.Color,B=new THREE.Color,y=new THREE.Color,A=new THREE.Color,L=new THREE.Color,ka=[],ea=[],fa,ga,da,$,Ba,Ca,Da,Ea,Fa,Ga,la=new THREE.Rectangle,Y=new THREE.Rectangle,X=new THREE.Rectangle,xa=!1,W=new THREE.Color,ma=new THREE.Color,na=new THREE.Color,R=new THREE.Vector3,ra,sa,ya,aa,ta,ua,a=16;ra=document.createElement("canvas");
-ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);ya=sa.getImageData(0,0,2,2);aa=ya.data;ta=document.createElement("canvas");ta.width=ta.height=a;ua=ta.getContext("2d");ua.translate(-a/2,-a/2);ua.scale(a,a);a--;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){o=a;n=b;j=Math.floor(o/2);p=Math.floor(n/2);l.width=o;l.height=n;la.set(-j,-p,j,p);Y.set(-j,-p,j,p);u=1;I=0;
-E=z=H=v=G=null};this.setClearColor=function(a,b){q.copy(a);w=b;Y.set(-j,-p,j,p)};this.setClearColorHex=function(a,b){q.setHex(a);w=b;Y.set(-j,-p,j,p)};this.clear=function(){k.setTransform(1,0,0,-1,j,p);Y.isEmpty()||(Y.minSelf(la),Y.inflate(2),1>w&&k.clearRect(Math.floor(Y.getX()),Math.floor(Y.getY()),Math.floor(Y.getWidth()),Math.floor(Y.getHeight())),0<w&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(255*q.r)+","+Math.floor(255*q.g)+","+Math.floor(255*q.b)+","+w+")"),k.fillRect(Math.floor(Y.getX()),
+THREE.CanvasRenderer=function(a){function b(a){if(v!=a)k.globalAlpha=v=a}function c(a){if(I!=a){switch(a){case THREE.NormalBlending:k.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:k.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:k.globalCompositeOperation="darker"}I=a}}function d(a){if(G!=a)k.strokeStyle=G=a}function e(a){if(w!=a)k.fillStyle=w=a}var a=a||{},f=this,g,i,m,h=new THREE.Projector,l=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
+o,n,j,p,k=l.getContext("2d"),q=new THREE.Color(0),x=0,v=1,I=0,G=null,w=null,H=null,A=null,F=null,r,s,D,J,Z=new THREE.RenderableVertex,ca=new THREE.RenderableVertex,N,P,S,T,E,t,Q,y,O,M,V,K,u=new THREE.Color,C=new THREE.Color,z=new THREE.Color,B=new THREE.Color,L=new THREE.Color,ka=[],ea=[],fa,ga,da,$,Ba,Ca,Da,Ea,Fa,Ga,la=new THREE.Rectangle,Y=new THREE.Rectangle,X=new THREE.Rectangle,xa=!1,W=new THREE.Color,ma=new THREE.Color,na=new THREE.Color,R=new THREE.Vector3,ra,sa,ya,aa,ta,ua,a=16;ra=document.createElement("canvas");
+ra.width=ra.height=2;sa=ra.getContext("2d");sa.fillStyle="rgba(0,0,0,1)";sa.fillRect(0,0,2,2);ya=sa.getImageData(0,0,2,2);aa=ya.data;ta=document.createElement("canvas");ta.width=ta.height=a;ua=ta.getContext("2d");ua.translate(-a/2,-a/2);ua.scale(a,a);a--;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.setSize=function(a,b){o=a;n=b;j=Math.floor(o/2);p=Math.floor(n/2);l.width=o;l.height=n;la.set(-j,-p,j,p);Y.set(-j,-p,j,p);v=1;I=0;
+F=A=H=w=G=null};this.setClearColor=function(a,b){q.copy(a);x=b;Y.set(-j,-p,j,p)};this.setClearColorHex=function(a,b){q.setHex(a);x=b;Y.set(-j,-p,j,p)};this.clear=function(){k.setTransform(1,0,0,-1,j,p);Y.isEmpty()||(Y.minSelf(la),Y.inflate(2),1>x&&k.clearRect(Math.floor(Y.getX()),Math.floor(Y.getY()),Math.floor(Y.getWidth()),Math.floor(Y.getHeight())),0<x&&(c(THREE.NormalBlending),b(1),e("rgba("+Math.floor(255*q.r)+","+Math.floor(255*q.g)+","+Math.floor(255*q.b)+","+x+")"),k.fillRect(Math.floor(Y.getX()),
 Math.floor(Y.getY()),Math.floor(Y.getWidth()),Math.floor(Y.getHeight()))),Y.empty())};this.render=function(a,l){function o(a){var b,c,d,e;W.setRGB(0,0,0);ma.setRGB(0,0,0);na.setRGB(0,0,0);for(b=0,c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(W.r+=e.r,W.g+=e.g,W.b+=e.b):d instanceof THREE.DirectionalLight?(ma.r+=e.r,ma.g+=e.g,ma.b+=e.b):d instanceof THREE.PointLight&&(na.r+=e.r,na.g+=e.g,na.b+=e.b)}function n(a,b,c,d){var e,f,g,i,l,k;for(e=0,f=a.length;e<f;e++)g=a[e],i=g.color,
 g instanceof THREE.DirectionalLight?(l=g.matrixWorld.getPosition(),k=c.dot(l),0>=k||(k*=g.intensity,d.r+=i.r*k,d.g+=i.g*k,d.b+=i.b*k)):g instanceof THREE.PointLight&&(l=g.matrixWorld.getPosition(),k=c.dot(R.sub(l,b).normalize()),0>=k||(k*=0==g.distance?1:1-Math.min(b.distanceTo(l)/g.distance,1),0!=k&&(k*=g.intensity,d.r+=i.r*k,d.g+=i.g*k,d.b+=i.b*k)))}function q(a,f,g){b(g.opacity);c(g.blending);var i,l,h,m,za,o;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)m=g.map.image,za=m.width>>1,o=m.height>>
-1,g=f.scale.x*j,h=f.scale.y*p,i=g*za,l=h*o,X.set(a.x-i,a.y-l,a.x+i,a.y+l),la.intersects(X)&&(k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(g,-h),k.translate(-za,-o),k.drawImage(m,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(i=f.scale.x*j,l=f.scale.y*p,X.set(a.x-i,a.y-l,a.x+i,a.y+l),la.intersects(X)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(i,l),g.program(k),k.restore()))}function v(a,
-e,f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(H!=a)k.lineWidth=H=a;a=g.linecap;if(z!=a)k.lineCap=z=a;a=g.linejoin;if(E!=a)k.lineJoin=E=a;d(g.color.getContextStyle());k.stroke();X.inflate(2*g.linewidth)}}function u(a,d,e,g,i,k,h,j){f.info.render.vertices+=3;f.info.render.faces++;b(j.opacity);c(j.blending);N=a.positionScreen.x;P=a.positionScreen.y;
-S=d.positionScreen.x;T=d.positionScreen.y;F=e.positionScreen.x;D=e.positionScreen.y;w(N,P,S,T,F,D);if(j instanceof THREE.MeshBasicMaterial)if(j.map)j.map.mapping instanceof THREE.UVMapping&&($=h.uvs[0],Aa(N,P,S,T,F,D,$[g].u,$[g].v,$[i].u,$[i].v,$[k].u,$[k].v,j.map));else if(j.envMap){if(j.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,R.copy(h.vertexNormalsWorld[g]),Ba=0.5*(R.x*a.n11+R.y*a.n12+R.z*a.n13)+0.5,Ca=0.5*-(R.x*a.n21+R.y*a.n22+R.z*a.n23)+0.5,R.copy(h.vertexNormalsWorld[i]),
-Da=0.5*(R.x*a.n11+R.y*a.n12+R.z*a.n13)+0.5,Ea=0.5*-(R.x*a.n21+R.y*a.n22+R.z*a.n23)+0.5,R.copy(h.vertexNormalsWorld[k]),Fa=0.5*(R.x*a.n11+R.y*a.n12+R.z*a.n13)+0.5,Ga=0.5*-(R.x*a.n21+R.y*a.n22+R.z*a.n23)+0.5,Aa(N,P,S,T,F,D,Ba,Ca,Da,Ea,Fa,Ga,j.envMap)}else j.wireframe?ia(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(j.color);else if(j instanceof THREE.MeshLambertMaterial)j.map&&!j.wireframe&&(j.map.mapping instanceof THREE.UVMapping&&($=h.uvs[0],Aa(N,P,S,T,F,D,$[g].u,$[g].v,
-$[i].u,$[i].v,$[k].u,$[k].v,j.map)),c(THREE.SubtractiveBlending)),xa?!j.wireframe&&j.shading==THREE.SmoothShading&&3==h.vertexNormalsWorld.length?(B.r=y.r=A.r=W.r,B.g=y.g=A.g=W.g,B.b=y.b=A.b=W.b,n(m,h.v1.positionWorld,h.vertexNormalsWorld[0],B),n(m,h.v2.positionWorld,h.vertexNormalsWorld[1],y),n(m,h.v3.positionWorld,h.vertexNormalsWorld[2],A),B.r=Math.max(0,Math.min(j.color.r*B.r,1)),B.g=Math.max(0,Math.min(j.color.g*B.g,1)),B.b=Math.max(0,Math.min(j.color.b*B.b,1)),y.r=Math.max(0,Math.min(j.color.r*
-y.r,1)),y.g=Math.max(0,Math.min(j.color.g*y.g,1)),y.b=Math.max(0,Math.min(j.color.b*y.b,1)),A.r=Math.max(0,Math.min(j.color.r*A.r,1)),A.g=Math.max(0,Math.min(j.color.g*A.g,1)),A.b=Math.max(0,Math.min(j.color.b*A.b,1)),L.r=0.5*(y.r+A.r),L.g=0.5*(y.g+A.g),L.b=0.5*(y.b+A.b),da=va(B,y,A,L),pa(N,P,S,T,F,D,0,0,1,0,0,1,da)):(t.r=W.r,t.g=W.g,t.b=W.b,n(m,h.centroidWorld,h.normalWorld,t),t.r=Math.max(0,Math.min(j.color.r*t.r,1)),t.g=Math.max(0,Math.min(j.color.g*t.g,1)),t.b=Math.max(0,Math.min(j.color.b*t.b,
-1)),j.wireframe?ia(t,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(t)):j.wireframe?ia(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(j.color);else if(j instanceof THREE.MeshDepthMaterial)fa=l.near,ga=l.far,B.r=B.g=B.b=1-oa(a.positionScreen.z,fa,ga),y.r=y.g=y.b=1-oa(d.positionScreen.z,fa,ga),A.r=A.g=A.b=1-oa(e.positionScreen.z,fa,ga),L.r=0.5*(y.r+A.r),L.g=0.5*(y.g+A.g),L.b=0.5*(y.b+A.b),da=va(B,y,A,L),pa(N,P,S,T,F,D,0,0,1,0,0,1,da);else if(j instanceof THREE.MeshNormalMaterial)t.r=
-qa(h.normalWorld.x),t.g=qa(h.normalWorld.y),t.b=qa(h.normalWorld.z),j.wireframe?ia(t,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(t)}function I(a,d,e,g,i,j,k,h,o){f.info.render.vertices+=4;f.info.render.faces++;b(h.opacity);c(h.blending);if(h.map||h.envMap)u(a,d,g,0,1,3,k,h,o),u(i,e,j,1,2,3,k,h,o);else if(N=a.positionScreen.x,P=a.positionScreen.y,S=d.positionScreen.x,T=d.positionScreen.y,F=e.positionScreen.x,D=e.positionScreen.y,Q=g.positionScreen.x,x=g.positionScreen.y,O=i.positionScreen.x,
-M=i.positionScreen.y,V=j.positionScreen.x,K=j.positionScreen.y,h instanceof THREE.MeshBasicMaterial)G(N,P,S,T,F,D,Q,x),h.wireframe?ia(h.color,h.wireframeLinewidth,h.wireframeLinecap,h.wireframeLinejoin):ha(h.color);else if(h instanceof THREE.MeshLambertMaterial)xa?!h.wireframe&&h.shading==THREE.SmoothShading&&4==k.vertexNormalsWorld.length?(B.r=y.r=A.r=L.r=W.r,B.g=y.g=A.g=L.g=W.g,B.b=y.b=A.b=L.b=W.b,n(m,k.v1.positionWorld,k.vertexNormalsWorld[0],B),n(m,k.v2.positionWorld,k.vertexNormalsWorld[1],y),
-n(m,k.v4.positionWorld,k.vertexNormalsWorld[3],A),n(m,k.v3.positionWorld,k.vertexNormalsWorld[2],L),B.r=Math.max(0,Math.min(h.color.r*B.r,1)),B.g=Math.max(0,Math.min(h.color.g*B.g,1)),B.b=Math.max(0,Math.min(h.color.b*B.b,1)),y.r=Math.max(0,Math.min(h.color.r*y.r,1)),y.g=Math.max(0,Math.min(h.color.g*y.g,1)),y.b=Math.max(0,Math.min(h.color.b*y.b,1)),A.r=Math.max(0,Math.min(h.color.r*A.r,1)),A.g=Math.max(0,Math.min(h.color.g*A.g,1)),A.b=Math.max(0,Math.min(h.color.b*A.b,1)),L.r=Math.max(0,Math.min(h.color.r*
-L.r,1)),L.g=Math.max(0,Math.min(h.color.g*L.g,1)),L.b=Math.max(0,Math.min(h.color.b*L.b,1)),da=va(B,y,A,L),w(N,P,S,T,Q,x),pa(N,P,S,T,Q,x,0,0,1,0,0,1,da),w(O,M,F,D,V,K),pa(O,M,F,D,V,K,1,0,1,1,0,1,da)):(t.r=W.r,t.g=W.g,t.b=W.b,n(m,k.centroidWorld,k.normalWorld,t),t.r=Math.max(0,Math.min(h.color.r*t.r,1)),t.g=Math.max(0,Math.min(h.color.g*t.g,1)),t.b=Math.max(0,Math.min(h.color.b*t.b,1)),G(N,P,S,T,F,D,Q,x),h.wireframe?ia(t,h.wireframeLinewidth,h.wireframeLinecap,h.wireframeLinejoin):ha(t)):(G(N,P,S,
-T,F,D,Q,x),h.wireframe?ia(h.color,h.wireframeLinewidth,h.wireframeLinecap,h.wireframeLinejoin):ha(h.color));else if(h instanceof THREE.MeshNormalMaterial)t.r=qa(k.normalWorld.x),t.g=qa(k.normalWorld.y),t.b=qa(k.normalWorld.z),G(N,P,S,T,F,D,Q,x),h.wireframe?ia(t,h.wireframeLinewidth,h.wireframeLinecap,h.wireframeLinejoin):ha(t);else if(h instanceof THREE.MeshDepthMaterial)fa=l.near,ga=l.far,B.r=B.g=B.b=1-oa(a.positionScreen.z,fa,ga),y.r=y.g=y.b=1-oa(d.positionScreen.z,fa,ga),A.r=A.g=A.b=1-oa(g.positionScreen.z,
-fa,ga),L.r=L.g=L.b=1-oa(e.positionScreen.z,fa,ga),da=va(B,y,A,L),w(N,P,S,T,Q,x),pa(N,P,S,T,Q,x,0,0,1,0,0,1,da),w(O,M,F,D,V,K),pa(O,M,F,D,V,K,1,0,1,1,0,1,da)}function w(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function G(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function ia(a,b,c,e){if(H!=b)k.lineWidth=H=b;if(z!=c)k.lineCap=z=c;if(E!=e)k.lineJoin=E=e;d(a.getContextStyle());
+1,g=f.scale.x*j,h=f.scale.y*p,i=g*za,l=h*o,X.set(a.x-i,a.y-l,a.x+i,a.y+l),la.intersects(X)&&(k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(g,-h),k.translate(-za,-o),k.drawImage(m,0,0),k.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(i=f.scale.x*j,l=f.scale.y*p,X.set(a.x-i,a.y-l,a.x+i,a.y+l),la.intersects(X)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),k.save(),k.translate(a.x,a.y),k.rotate(-f.rotation),k.scale(i,l),g.program(k),k.restore()))}function w(a,
+e,f,g){b(g.opacity);c(g.blending);k.beginPath();k.moveTo(a.positionScreen.x,a.positionScreen.y);k.lineTo(e.positionScreen.x,e.positionScreen.y);k.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(H!=a)k.lineWidth=H=a;a=g.linecap;if(A!=a)k.lineCap=A=a;a=g.linejoin;if(F!=a)k.lineJoin=F=a;d(g.color.getContextStyle());k.stroke();X.inflate(2*g.linewidth)}}function v(a,d,e,g,i,k,h,j){f.info.render.vertices+=3;f.info.render.faces++;b(j.opacity);c(j.blending);N=a.positionScreen.x;P=a.positionScreen.y;
+S=d.positionScreen.x;T=d.positionScreen.y;E=e.positionScreen.x;t=e.positionScreen.y;x(N,P,S,T,E,t);if(j instanceof THREE.MeshBasicMaterial)if(j.map)j.map.mapping instanceof THREE.UVMapping&&($=h.uvs[0],Aa(N,P,S,T,E,t,$[g].u,$[g].v,$[i].u,$[i].v,$[k].u,$[k].v,j.map));else if(j.envMap){if(j.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,R.copy(h.vertexNormalsWorld[g]),Ba=0.5*(R.x*a.n11+R.y*a.n12+R.z*a.n13)+0.5,Ca=0.5*-(R.x*a.n21+R.y*a.n22+R.z*a.n23)+0.5,R.copy(h.vertexNormalsWorld[i]),
+Da=0.5*(R.x*a.n11+R.y*a.n12+R.z*a.n13)+0.5,Ea=0.5*-(R.x*a.n21+R.y*a.n22+R.z*a.n23)+0.5,R.copy(h.vertexNormalsWorld[k]),Fa=0.5*(R.x*a.n11+R.y*a.n12+R.z*a.n13)+0.5,Ga=0.5*-(R.x*a.n21+R.y*a.n22+R.z*a.n23)+0.5,Aa(N,P,S,T,E,t,Ba,Ca,Da,Ea,Fa,Ga,j.envMap)}else j.wireframe?ia(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(j.color);else if(j instanceof THREE.MeshLambertMaterial)j.map&&!j.wireframe&&(j.map.mapping instanceof THREE.UVMapping&&($=h.uvs[0],Aa(N,P,S,T,E,t,$[g].u,$[g].v,
+$[i].u,$[i].v,$[k].u,$[k].v,j.map)),c(THREE.SubtractiveBlending)),xa?!j.wireframe&&j.shading==THREE.SmoothShading&&3==h.vertexNormalsWorld.length?(C.r=z.r=B.r=W.r,C.g=z.g=B.g=W.g,C.b=z.b=B.b=W.b,n(m,h.v1.positionWorld,h.vertexNormalsWorld[0],C),n(m,h.v2.positionWorld,h.vertexNormalsWorld[1],z),n(m,h.v3.positionWorld,h.vertexNormalsWorld[2],B),C.r=Math.max(0,Math.min(j.color.r*C.r,1)),C.g=Math.max(0,Math.min(j.color.g*C.g,1)),C.b=Math.max(0,Math.min(j.color.b*C.b,1)),z.r=Math.max(0,Math.min(j.color.r*
+z.r,1)),z.g=Math.max(0,Math.min(j.color.g*z.g,1)),z.b=Math.max(0,Math.min(j.color.b*z.b,1)),B.r=Math.max(0,Math.min(j.color.r*B.r,1)),B.g=Math.max(0,Math.min(j.color.g*B.g,1)),B.b=Math.max(0,Math.min(j.color.b*B.b,1)),L.r=0.5*(z.r+B.r),L.g=0.5*(z.g+B.g),L.b=0.5*(z.b+B.b),da=va(C,z,B,L),pa(N,P,S,T,E,t,0,0,1,0,0,1,da)):(u.r=W.r,u.g=W.g,u.b=W.b,n(m,h.centroidWorld,h.normalWorld,u),u.r=Math.max(0,Math.min(j.color.r*u.r,1)),u.g=Math.max(0,Math.min(j.color.g*u.g,1)),u.b=Math.max(0,Math.min(j.color.b*u.b,
+1)),j.wireframe?ia(u,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(u)):j.wireframe?ia(j.color,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(j.color);else if(j instanceof THREE.MeshDepthMaterial)fa=l.near,ga=l.far,C.r=C.g=C.b=1-oa(a.positionScreen.z,fa,ga),z.r=z.g=z.b=1-oa(d.positionScreen.z,fa,ga),B.r=B.g=B.b=1-oa(e.positionScreen.z,fa,ga),L.r=0.5*(z.r+B.r),L.g=0.5*(z.g+B.g),L.b=0.5*(z.b+B.b),da=va(C,z,B,L),pa(N,P,S,T,E,t,0,0,1,0,0,1,da);else if(j instanceof THREE.MeshNormalMaterial)u.r=
+qa(h.normalWorld.x),u.g=qa(h.normalWorld.y),u.b=qa(h.normalWorld.z),j.wireframe?ia(u,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(u)}function I(a,d,e,g,i,j,k,h,o){f.info.render.vertices+=4;f.info.render.faces++;b(h.opacity);c(h.blending);if(h.map||h.envMap)v(a,d,g,0,1,3,k,h,o),v(i,e,j,1,2,3,k,h,o);else if(N=a.positionScreen.x,P=a.positionScreen.y,S=d.positionScreen.x,T=d.positionScreen.y,E=e.positionScreen.x,t=e.positionScreen.y,Q=g.positionScreen.x,y=g.positionScreen.y,O=i.positionScreen.x,
+M=i.positionScreen.y,V=j.positionScreen.x,K=j.positionScreen.y,h instanceof THREE.MeshBasicMaterial)G(N,P,S,T,E,t,Q,y),h.wireframe?ia(h.color,h.wireframeLinewidth,h.wireframeLinecap,h.wireframeLinejoin):ha(h.color);else if(h instanceof THREE.MeshLambertMaterial)xa?!h.wireframe&&h.shading==THREE.SmoothShading&&4==k.vertexNormalsWorld.length?(C.r=z.r=B.r=L.r=W.r,C.g=z.g=B.g=L.g=W.g,C.b=z.b=B.b=L.b=W.b,n(m,k.v1.positionWorld,k.vertexNormalsWorld[0],C),n(m,k.v2.positionWorld,k.vertexNormalsWorld[1],z),
+n(m,k.v4.positionWorld,k.vertexNormalsWorld[3],B),n(m,k.v3.positionWorld,k.vertexNormalsWorld[2],L),C.r=Math.max(0,Math.min(h.color.r*C.r,1)),C.g=Math.max(0,Math.min(h.color.g*C.g,1)),C.b=Math.max(0,Math.min(h.color.b*C.b,1)),z.r=Math.max(0,Math.min(h.color.r*z.r,1)),z.g=Math.max(0,Math.min(h.color.g*z.g,1)),z.b=Math.max(0,Math.min(h.color.b*z.b,1)),B.r=Math.max(0,Math.min(h.color.r*B.r,1)),B.g=Math.max(0,Math.min(h.color.g*B.g,1)),B.b=Math.max(0,Math.min(h.color.b*B.b,1)),L.r=Math.max(0,Math.min(h.color.r*
+L.r,1)),L.g=Math.max(0,Math.min(h.color.g*L.g,1)),L.b=Math.max(0,Math.min(h.color.b*L.b,1)),da=va(C,z,B,L),x(N,P,S,T,Q,y),pa(N,P,S,T,Q,y,0,0,1,0,0,1,da),x(O,M,E,t,V,K),pa(O,M,E,t,V,K,1,0,1,1,0,1,da)):(u.r=W.r,u.g=W.g,u.b=W.b,n(m,k.centroidWorld,k.normalWorld,u),u.r=Math.max(0,Math.min(h.color.r*u.r,1)),u.g=Math.max(0,Math.min(h.color.g*u.g,1)),u.b=Math.max(0,Math.min(h.color.b*u.b,1)),G(N,P,S,T,E,t,Q,y),h.wireframe?ia(u,h.wireframeLinewidth,h.wireframeLinecap,h.wireframeLinejoin):ha(u)):(G(N,P,S,
+T,E,t,Q,y),h.wireframe?ia(h.color,h.wireframeLinewidth,h.wireframeLinecap,h.wireframeLinejoin):ha(h.color));else if(h instanceof THREE.MeshNormalMaterial)u.r=qa(k.normalWorld.x),u.g=qa(k.normalWorld.y),u.b=qa(k.normalWorld.z),G(N,P,S,T,E,t,Q,y),h.wireframe?ia(u,h.wireframeLinewidth,h.wireframeLinecap,h.wireframeLinejoin):ha(u);else if(h instanceof THREE.MeshDepthMaterial)fa=l.near,ga=l.far,C.r=C.g=C.b=1-oa(a.positionScreen.z,fa,ga),z.r=z.g=z.b=1-oa(d.positionScreen.z,fa,ga),B.r=B.g=B.b=1-oa(g.positionScreen.z,
+fa,ga),L.r=L.g=L.b=1-oa(e.positionScreen.z,fa,ga),da=va(C,z,B,L),x(N,P,S,T,Q,y),pa(N,P,S,T,Q,y,0,0,1,0,0,1,da),x(O,M,E,t,V,K),pa(O,M,E,t,V,K,1,0,1,1,0,1,da)}function x(a,b,c,d,e,f){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(a,b);k.closePath()}function G(a,b,c,d,e,f,g,h){k.beginPath();k.moveTo(a,b);k.lineTo(c,d);k.lineTo(e,f);k.lineTo(g,h);k.lineTo(a,b);k.closePath()}function ia(a,b,c,e){if(H!=b)k.lineWidth=H=b;if(A!=c)k.lineCap=A=c;if(F!=e)k.lineJoin=F=e;d(a.getContextStyle());
 k.stroke();X.inflate(2*b)}function ha(a){e(a.getContextStyle());k.fill()}function Aa(a,b,c,d,f,g,h,i,j,l,m,o,n){if(0!=n.image.width){if(!0==n.needsUpdate||void 0==ka[n.id]){var p=n.wrapS==THREE.RepeatWrapping,q=n.wrapT==THREE.RepeatWrapping;ka[n.id]=k.createPattern(n.image,p&&q?"repeat":p&&!q?"repeat-x":!p&&q?"repeat-y":"no-repeat");n.needsUpdate=!1}e(ka[n.id]);var p=n.offset.x/n.repeat.x,q=n.offset.y/n.repeat.y,r=n.image.width*n.repeat.x,s=n.image.height*n.repeat.y,h=(h+p)*r,i=(i+q)*s,c=c-a,d=d-
-b,f=f-a,g=g-b,j=(j+p)*r-h,l=(l+q)*s-i,m=(m+p)*r-h,o=(o+q)*s-i,p=j*o-m*l;if(0==p){if(void 0===ea[n.id])b=document.createElement("canvas"),b.width=n.image.width,b.height=n.image.height,b=b.getContext("2d"),b.drawImage(n.image,0,0),ea[n.id]=b.getImageData(0,0,n.image.width,n.image.height).data;b=ea[n.id];h=4*(Math.floor(h)+Math.floor(i)*n.image.width);t.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);ha(t)}else p=1/p,n=(o*c-l*f)*p,l=(o*d-l*g)*p,c=(j*f-m*c)*p,d=(j*g-m*d)*p,a=a-n*h-c*i,h=b-l*h-d*i,k.save(),k.transform(n,
+b,f=f-a,g=g-b,j=(j+p)*r-h,l=(l+q)*s-i,m=(m+p)*r-h,o=(o+q)*s-i,p=j*o-m*l;if(0==p){if(void 0===ea[n.id])b=document.createElement("canvas"),b.width=n.image.width,b.height=n.image.height,b=b.getContext("2d"),b.drawImage(n.image,0,0),ea[n.id]=b.getImageData(0,0,n.image.width,n.image.height).data;b=ea[n.id];h=4*(Math.floor(h)+Math.floor(i)*n.image.width);u.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);ha(u)}else p=1/p,n=(o*c-l*f)*p,l=(o*d-l*g)*p,c=(j*f-m*c)*p,d=(j*g-m*d)*p,a=a-n*h-c*i,h=b-l*h-d*i,k.save(),k.transform(n,
 l,c,d,a,h),k.fill(),k.restore()}}function pa(a,b,c,d,e,f,g,h,i,j,l,m,n){var o,p;o=n.width-1;p=n.height-1;g*=o;h*=p;c-=a;d-=b;e-=a;f-=b;i=i*o-g;j=j*p-h;l=l*o-g;m=m*p-h;p=1/(i*m-l*j);o=(m*c-j*e)*p;j=(m*d-j*f)*p;c=(i*e-l*c)*p;d=(i*f-l*d)*p;a=a-o*g-c*h;b=b-j*g-d*h;k.save();k.transform(o,j,c,d,a,b);k.clip();k.drawImage(n,0,0);k.restore()}function va(a,b,c,d){var e=~~(255*a.r),f=~~(255*a.g),a=~~(255*a.b),g=~~(255*b.r),h=~~(255*b.g),b=~~(255*b.b),i=~~(255*c.r),j=~~(255*c.g),c=~~(255*c.b),k=~~(255*d.r),l=
 ~~(255*d.g),d=~~(255*d.b);aa[0]=0>e?0:255<e?255:e;aa[1]=0>f?0:255<f?255:f;aa[2]=0>a?0:255<a?255:a;aa[4]=0>g?0:255<g?255:g;aa[5]=0>h?0:255<h?255:h;aa[6]=0>b?0:255<b?255:b;aa[8]=0>i?0:255<i?255:i;aa[9]=0>j?0:255<j?255:j;aa[10]=0>c?0:255<c?255:c;aa[12]=0>k?0:255<k?255:k;aa[13]=0>l?0:255<l?255:l;aa[14]=0>d?0:255<d?255:d;sa.putImageData(ya,0,0);ua.drawImage(ra,0,0);return ta}function oa(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function qa(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function ja(a,b){var c=b.x-a.x,
 d=b.y-a.y,e=c*c+d*d;0!=e&&(e=1/Math.sqrt(e),c*=e,d*=e,b.x+=c,b.y+=d,a.x-=c,a.y-=d)}var wa,Ha,U,ba;this.autoClear?this.clear():k.setTransform(1,0,0,-1,j,p);f.info.render.vertices=0;f.info.render.faces=0;g=h.projectScene(a,l,this.sortElements);i=g.elements;m=g.lights;(xa=0<m.length)&&o(m);for(wa=0,Ha=i.length;wa<Ha;wa++)if(U=i[wa],ba=U.material,ba=ba instanceof THREE.MeshFaceMaterial?U.faceMaterial:ba,!(null==ba||0==ba.opacity)){X.empty();if(U instanceof THREE.RenderableParticle)r=U,r.x*=j,r.y*=p,q(r,
-U,ba,a);else if(U instanceof THREE.RenderableLine)r=U.v1,s=U.v2,r.positionScreen.x*=j,r.positionScreen.y*=p,s.positionScreen.x*=j,s.positionScreen.y*=p,X.addPoint(r.positionScreen.x,r.positionScreen.y),X.addPoint(s.positionScreen.x,s.positionScreen.y),la.intersects(X)&&v(r,s,U,ba,a);else if(U instanceof THREE.RenderableFace3)r=U.v1,s=U.v2,C=U.v3,r.positionScreen.x*=j,r.positionScreen.y*=p,s.positionScreen.x*=j,s.positionScreen.y*=p,C.positionScreen.x*=j,C.positionScreen.y*=p,ba.overdraw&&(ja(r.positionScreen,
-s.positionScreen),ja(s.positionScreen,C.positionScreen),ja(C.positionScreen,r.positionScreen)),X.add3Points(r.positionScreen.x,r.positionScreen.y,s.positionScreen.x,s.positionScreen.y,C.positionScreen.x,C.positionScreen.y),la.intersects(X)&&u(r,s,C,0,1,2,U,ba,a);else if(U instanceof THREE.RenderableFace4)r=U.v1,s=U.v2,C=U.v3,J=U.v4,r.positionScreen.x*=j,r.positionScreen.y*=p,s.positionScreen.x*=j,s.positionScreen.y*=p,C.positionScreen.x*=j,C.positionScreen.y*=p,J.positionScreen.x*=j,J.positionScreen.y*=
-p,Z.positionScreen.copy(s.positionScreen),ca.positionScreen.copy(J.positionScreen),ba.overdraw&&(ja(r.positionScreen,s.positionScreen),ja(s.positionScreen,J.positionScreen),ja(J.positionScreen,r.positionScreen),ja(C.positionScreen,Z.positionScreen),ja(C.positionScreen,ca.positionScreen)),X.addPoint(r.positionScreen.x,r.positionScreen.y),X.addPoint(s.positionScreen.x,s.positionScreen.y),X.addPoint(C.positionScreen.x,C.positionScreen.y),X.addPoint(J.positionScreen.x,J.positionScreen.y),la.intersects(X)&&
-I(r,s,C,J,Z,ca,U,ba,a);Y.addRectangle(X)}k.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
+U,ba,a);else if(U instanceof THREE.RenderableLine)r=U.v1,s=U.v2,r.positionScreen.x*=j,r.positionScreen.y*=p,s.positionScreen.x*=j,s.positionScreen.y*=p,X.addPoint(r.positionScreen.x,r.positionScreen.y),X.addPoint(s.positionScreen.x,s.positionScreen.y),la.intersects(X)&&w(r,s,U,ba,a);else if(U instanceof THREE.RenderableFace3)r=U.v1,s=U.v2,D=U.v3,r.positionScreen.x*=j,r.positionScreen.y*=p,s.positionScreen.x*=j,s.positionScreen.y*=p,D.positionScreen.x*=j,D.positionScreen.y*=p,ba.overdraw&&(ja(r.positionScreen,
+s.positionScreen),ja(s.positionScreen,D.positionScreen),ja(D.positionScreen,r.positionScreen)),X.add3Points(r.positionScreen.x,r.positionScreen.y,s.positionScreen.x,s.positionScreen.y,D.positionScreen.x,D.positionScreen.y),la.intersects(X)&&v(r,s,D,0,1,2,U,ba,a);else if(U instanceof THREE.RenderableFace4)r=U.v1,s=U.v2,D=U.v3,J=U.v4,r.positionScreen.x*=j,r.positionScreen.y*=p,s.positionScreen.x*=j,s.positionScreen.y*=p,D.positionScreen.x*=j,D.positionScreen.y*=p,J.positionScreen.x*=j,J.positionScreen.y*=
+p,Z.positionScreen.copy(s.positionScreen),ca.positionScreen.copy(J.positionScreen),ba.overdraw&&(ja(r.positionScreen,s.positionScreen),ja(s.positionScreen,J.positionScreen),ja(J.positionScreen,r.positionScreen),ja(D.positionScreen,Z.positionScreen),ja(D.positionScreen,ca.positionScreen)),X.addPoint(r.positionScreen.x,r.positionScreen.y),X.addPoint(s.positionScreen.x,s.positionScreen.y),X.addPoint(D.positionScreen.x,D.positionScreen.y),X.addPoint(J.positionScreen.x,J.positionScreen.y),la.intersects(X)&&
+I(r,s,D,J,Z,ca,U,ba,a);Y.addRectangle(X)}k.setTransform(1,0,0,1,0,0)}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};
 THREE.ImageUtils={crossOrigin:"",loadTexture:function(a,b,c){var d=new Image,e=new THREE.Texture(d,b);d.onload=function(){e.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return e},loadTextureCube:function(a,b,c){var d,e=[],f=new THREE.Texture(e,b);e.loadCount=0;for(b=0,d=a.length;b<d;++b)e[b]=new Image,e[b].onload=function(){e.loadCount+=1;if(6===e.loadCount)f.needsUpdate=!0;c&&c(this)},e[b].crossOrigin="",e[b].src=a[b];return f},getNormalMap:function(a,b){var c=function(a){var b=
-Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var i=g.getImageData(0,0,d,e).data,m=g.createImageData(d,e),h=m.data,l=0;l<d;l++)for(var o=1;o<e;o++){var n=0>o-1?e-1:o-1,j=(o+1)%e,p=0>l-1?d-1:l-1,k=(l+1)%d,q=[],w=[0,0,i[4*(o*d+l)]/255*b];q.push([-1,0,i[4*(o*d+p)]/255*b]);q.push([-1,-1,i[4*(n*d+p)]/255*b]);q.push([0,-1,i[4*(n*d+l)]/255*b]);q.push([1,
--1,i[4*(n*d+k)]/255*b]);q.push([1,0,i[4*(o*d+k)]/255*b]);q.push([1,1,i[4*(j*d+k)]/255*b]);q.push([0,1,i[4*(j*d+l)]/255*b]);q.push([-1,1,i[4*(j*d+p)]/255*b]);n=[];p=q.length;for(j=0;j<p;j++){var k=q[j],u=q[(j+1)%p],k=[k[0]-w[0],k[1]-w[1],k[2]-w[2]],u=[u[0]-w[0],u[1]-w[1],u[2]-w[2]];n.push(c([k[1]*u[2]-k[2]*u[1],k[2]*u[0]-k[0]*u[2],k[0]*u[1]-k[1]*u[0]]))}q=[0,0,0];for(j=0;j<n.length;j++)q[0]+=n[j][0],q[1]+=n[j][1],q[2]+=n[j][2];q[0]/=n.length;q[1]/=n.length;q[2]/=n.length;w=4*(o*d+l);h[w]=255*((q[0]+
-1)/2)|0;h[w+1]=255*(q[1]+0.5)|0;h[w+2]=255*q[2]|0;h[w+3]=255}g.putImageData(m,0,0);return f}};
+Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var i=g.getImageData(0,0,d,e).data,m=g.createImageData(d,e),h=m.data,l=0;l<d;l++)for(var o=1;o<e;o++){var n=0>o-1?e-1:o-1,j=(o+1)%e,p=0>l-1?d-1:l-1,k=(l+1)%d,q=[],x=[0,0,i[4*(o*d+l)]/255*b];q.push([-1,0,i[4*(o*d+p)]/255*b]);q.push([-1,-1,i[4*(n*d+p)]/255*b]);q.push([0,-1,i[4*(n*d+l)]/255*b]);q.push([1,
+-1,i[4*(n*d+k)]/255*b]);q.push([1,0,i[4*(o*d+k)]/255*b]);q.push([1,1,i[4*(j*d+k)]/255*b]);q.push([0,1,i[4*(j*d+l)]/255*b]);q.push([-1,1,i[4*(j*d+p)]/255*b]);n=[];p=q.length;for(j=0;j<p;j++){var k=q[j],v=q[(j+1)%p],k=[k[0]-x[0],k[1]-x[1],k[2]-x[2]],v=[v[0]-x[0],v[1]-x[1],v[2]-x[2]];n.push(c([k[1]*v[2]-k[2]*v[1],k[2]*v[0]-k[0]*v[2],k[0]*v[1]-k[1]*v[0]]))}q=[0,0,0];for(j=0;j<n.length;j++)q[0]+=n[j][0],q[1]+=n[j][1],q[2]+=n[j][2];q[0]/=n.length;q[1]/=n.length;q[2]/=n.length;x=4*(o*d+l);h[x]=255*((q[0]+
+1)/2)|0;h[x+1]=255*(q[1]+0.5)|0;h[x+2]=255*q[2]|0;h[x+3]=255}g.putImageData(m,0,0);return f}};

+ 21 - 21
build/custom/ThreeDOM.js

@@ -16,11 +16,11 @@ b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]};
 THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes;c[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);c[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);c[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);c[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);c[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);c[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;6>a;a++)b=c[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))};
 THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),e=0;6>e;e++)if(a=b[e].x*c.n14+b[e].y*c.n24+b[e].z*c.n34+b[e].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3;
-THREE.Ray=function(a,b){function c(a,b,c){m.sub(c,a);p=m.dot(b);u=q.add(a,o.copy(b).multiplyScalar(p));return r=c.distanceTo(u)}function d(a,b,c,d){m.sub(d,b);q.sub(c,b);o.sub(a,b);w=m.dot(m);D=m.dot(q);s=m.dot(o);A=q.dot(q);v=q.dot(o);y=1/(w*A-D*D);F=(A*s-D*v)*y;J=(w*v-D*s)*y;return 0<=F&&0<=J&&1>F+J}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,c,d=[];for(b=0,
+THREE.Ray=function(a,b){function c(a,b,c){m.sub(c,a);p=m.dot(b);v=q.add(a,o.copy(b).multiplyScalar(p));return r=c.distanceTo(v)}function d(a,b,c,d){m.sub(d,b);q.sub(c,b);o.sub(a,b);w=m.dot(m);D=m.dot(q);s=m.dot(o);B=q.dot(q);x=q.dot(o);z=1/(w*B-D*D);F=(B*s-D*x)*z;J=(w*x-D*s)*z;return 0<=F&&0<=J&&1>F+J}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,c,d=[];for(b=0,
 c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3,l=new THREE.Vector3,n=new THREE.Vector3;this.intersectObject=function(a){for(var b,m=[],o=0,p=a.children.length;o<p;o++)Array.prototype.push.apply(m,this.intersectObject(a.children[o]));if(a instanceof THREE.Particle){o=
-c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.scale.x)return[];b={distance:o,point:a.position,face:null,object:a};m.push(b)}else if(a instanceof THREE.Mesh){o=c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return m;var q,r=a.geometry,s=r.vertices,w;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,p=r.faces.length;o<p;o++)if(b=r.faces[o],k.copy(this.origin),i.copy(this.direction),
-w=a.matrixWorld,j=w.multiplyVector3(j.copy(b.centroid)).subSelf(k),q=j.dot(i),!(0>=q)&&(e=w.multiplyVector3(e.copy(s[b.a].position)),f=w.multiplyVector3(f.copy(s[b.b].position)),g=w.multiplyVector3(g.copy(s[b.c].position)),b instanceof THREE.Face4&&(h=w.multiplyVector3(h.copy(s[b.d].position))),l=a.matrixRotationWorld.multiplyVector3(l.copy(b.normal)),q=i.dot(l),a.doubleSided||(a.flipSided?0<q:0>q)))if(q=l.dot(j.sub(e,k))/q,n.add(k,i.multiplyScalar(q)),b instanceof THREE.Face3)d(n,e,f,g)&&(b={distance:k.distanceTo(n),
-point:n.clone(),face:b,object:a},m.push(b));else if(b instanceof THREE.Face4&&(d(n,e,f,h)||d(n,f,g,h)))b={distance:k.distanceTo(n),point:n.clone(),face:b,object:a},m.push(b)}return m};var m=new THREE.Vector3,q=new THREE.Vector3,o=new THREE.Vector3,p,u,r,w,D,s,A,v,y,F,J};
+c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.scale.x)return[];b={distance:o,point:a.position,face:null,object:a};m.push(b)}else if(a instanceof THREE.Mesh){o=c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return m;var q,r,s=a.geometry,w=s.vertices,u;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,p=s.faces.length;o<p;o++)if(b=s.faces[o],k.copy(this.origin),i.copy(this.direction),
+u=a.matrixWorld,j=u.multiplyVector3(j.copy(b.centroid)).subSelf(k),l=a.matrixRotationWorld.multiplyVector3(l.copy(b.normal)),q=i.dot(l),!(1.0E-4>Math.abs(q))&&(r=l.dot(j)/q,!(0>r)&&(a.doubleSided||(a.flipSided?0<q:0>q))))if(n.add(k,i.multiplyScalar(r)),b instanceof THREE.Face3)e=u.multiplyVector3(e.copy(w[b.a].position)),f=u.multiplyVector3(f.copy(w[b.b].position)),g=u.multiplyVector3(g.copy(w[b.c].position)),d(n,e,f,g)&&(b={distance:k.distanceTo(n),point:n.clone(),face:b,object:a},m.push(b));else if(b instanceof
+THREE.Face4&&(e=u.multiplyVector3(e.copy(w[b.a].position)),f=u.multiplyVector3(f.copy(w[b.b].position)),g=u.multiplyVector3(g.copy(w[b.c].position)),h=u.multiplyVector3(h.copy(w[b.d].position)),d(n,e,f,h)||d(n,f,g,h)))b={distance:k.distanceTo(n),point:n.clone(),face:b,object:a},m.push(b)}return m};var m=new THREE.Vector3,q=new THREE.Vector3,o=new THREE.Vector3,p,v,r,w,D,s,B,x,z,F,J};
 THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,j,l){h=!1;b=f;c=g;d=j;e=l;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
 function(f,g,j,l,n,m){h?(h=!1,b=f<j?f<n?f:n:j<n?j:n,c=g<l?g<m?g:m:l<m?l:m,d=f>j?f>n?f:n:j>n?j:n,e=g>l?g>m?g:m:l>m?l:m):(b=f<j?f<n?f<b?f:b:n<b?n:b:j<n?j<b?j:b:n<b?n:b,c=g<l?g<m?g<c?g:c:m<c?m:c:l<m?l<c?l:c:m<c?m:c,d=f>j?f>n?f>d?f:d:n>d?n:d:j>n?j>d?j:d:n>d?n:d,e=g>l?g>m?g>e?g:e:m>e?m:e:l>m?l>e?l:e:m>e?m:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
 f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||e<a.getTop()||c>a.getBottom()?!1:!0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
@@ -29,8 +29,8 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=
 THREE.Matrix4=function(a,b,c,d,e,f,g,h,k,i,j,l,n,m,q,o){this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==f?f:1,g||0,h||0,k||0,i||0,void 0!==j?j:1,l||0,n||0,m||0,q||0,void 0!==o?o:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,k,i,j,l,n,m,q,o){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=h;this.n31=k;this.n32=i;this.n33=j;this.n34=l;this.n41=n;this.n42=m;this.n43=q;this.n44=o;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
 b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(0===f.length())f.z=1;d.cross(c,f).normalize();0===d.length()&&(f.x+=1.0E-4,d.cross(c,f).normalize());e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,h=a.n22,k=a.n23,i=a.n24,j=a.n31,l=a.n32,n=a.n33,m=a.n34,q=a.n41,o=a.n42,p=a.n43,
-u=a.n44,r=b.n11,w=b.n12,D=b.n13,s=b.n14,A=b.n21,v=b.n22,y=b.n23,F=b.n24,J=b.n31,H=b.n32,I=b.n33,O=b.n34,P=b.n41,Q=b.n42,R=b.n43,S=b.n44;this.n11=c*r+d*A+e*J+f*P;this.n12=c*w+d*v+e*H+f*Q;this.n13=c*D+d*y+e*I+f*R;this.n14=c*s+d*F+e*O+f*S;this.n21=g*r+h*A+k*J+i*P;this.n22=g*w+h*v+k*H+i*Q;this.n23=g*D+h*y+k*I+i*R;this.n24=g*s+h*F+k*O+i*S;this.n31=j*r+l*A+n*J+m*P;this.n32=j*w+l*v+n*H+m*Q;this.n33=j*D+l*y+n*I+m*R;this.n34=j*s+l*F+n*O+m*S;this.n41=q*r+o*A+p*J+u*P;this.n42=q*w+o*v+p*H+u*Q;this.n43=q*D+o*
-y+p*I+u*R;this.n44=q*s+o*F+p*O+u*S;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
+v=a.n44,r=b.n11,w=b.n12,D=b.n13,s=b.n14,B=b.n21,x=b.n22,z=b.n23,F=b.n24,J=b.n31,H=b.n32,I=b.n33,O=b.n34,P=b.n41,Q=b.n42,R=b.n43,S=b.n44;this.n11=c*r+d*B+e*J+f*P;this.n12=c*w+d*x+e*H+f*Q;this.n13=c*D+d*z+e*I+f*R;this.n14=c*s+d*F+e*O+f*S;this.n21=g*r+h*B+k*J+i*P;this.n22=g*w+h*x+k*H+i*Q;this.n23=g*D+h*z+k*I+i*R;this.n24=g*s+h*F+k*O+i*S;this.n31=j*r+l*B+n*J+m*P;this.n32=j*w+l*x+n*H+m*Q;this.n33=j*D+l*z+n*I+m*R;this.n34=j*s+l*F+n*O+m*S;this.n41=q*r+o*B+p*J+v*P;this.n42=q*w+o*x+p*H+v*Q;this.n43=q*D+o*
+z+p*I+v*R;this.n44=q*s+o*F+p*O+v*S;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
 a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*
 c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*
 a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,h=this.n24,k=this.n31,i=this.n32,j=this.n33,l=this.n34,n=this.n41,m=this.n42,q=this.n43,o=this.n44;return d*g*i*n-c*h*i*n-d*f*j*n+b*h*j*n+c*f*l*n-b*g*l*n-d*g*k*m+c*h*k*m+d*e*j*m-a*h*j*m-c*e*l*m+a*g*l*m+d*f*k*q-b*h*k*q-d*e*i*q+a*h*i*q+b*e*l*q-a*f*l*q-c*f*k*o+b*g*k*o+c*e*i*o-a*g*i*o-b*e*j*o+a*f*j*o},transpose:function(){var a;
@@ -47,8 +47,8 @@ e,j=c*h,l=c*e,this.n11=g*h,this.n12=-g*e,this.n13=d,this.n21=i+j*d,this.n22=k-l*
 a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);f.set(this.n13,
 this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();c.y=e.length();c.z=f.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
 return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this},rotateByAxis:function(a,b){if(1===a.x&&0===a.y&&0===a.z)return this.rotateX(b);if(0===a.x&&1===a.y&&0===a.z)return this.rotateY(b);if(0===a.x&&0===a.y&&1===
-a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e),c=c/f,d=d/f,e=e/f,f=c*c,g=d*d,h=e*e,k=Math.cos(b),i=Math.sin(b),j=1-k,l=c*d*j,n=c*e*j,j=d*e*j,c=c*i,m=d*i,i=e*i,e=f+(1-f)*k,f=l+i,d=n-m,l=l-i,g=g+(1-g)*k,i=j+c,n=n+m,j=j-c,h=h+(1-h)*k,k=this.n11,c=this.n21,m=this.n31,q=this.n41,o=this.n12,p=this.n22,u=this.n32,r=this.n42,w=this.n13,D=this.n23,s=this.n33,A=this.n43;this.n11=e*k+f*o+d*w;this.n21=e*c+f*p+d*D;this.n31=e*m+f*u+d*s;this.n41=e*q+f*r+d*A;this.n12=l*k+g*o+i*w;this.n22=
-l*c+g*p+i*D;this.n32=l*m+g*u+i*s;this.n42=l*q+g*r+i*A;this.n13=n*k+j*o+h*w;this.n23=n*c+j*p+h*D;this.n33=n*m+j*u+h*s;this.n43=n*q+j*r+h*A;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,f=this.n13,g=this.n23,h=this.n33,k=this.n43,i=Math.cos(a),a=Math.sin(a);this.n12=i*b+a*f;this.n22=i*c+a*g;this.n32=i*d+a*h;this.n42=i*e+a*k;this.n13=i*f-a*b;this.n23=i*g-a*c;this.n33=i*h-a*d;this.n43=i*k-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,
+a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e),c=c/f,d=d/f,e=e/f,f=c*c,g=d*d,h=e*e,k=Math.cos(b),i=Math.sin(b),j=1-k,l=c*d*j,n=c*e*j,j=d*e*j,c=c*i,m=d*i,i=e*i,e=f+(1-f)*k,f=l+i,d=n-m,l=l-i,g=g+(1-g)*k,i=j+c,n=n+m,j=j-c,h=h+(1-h)*k,k=this.n11,c=this.n21,m=this.n31,q=this.n41,o=this.n12,p=this.n22,v=this.n32,r=this.n42,w=this.n13,D=this.n23,s=this.n33,B=this.n43;this.n11=e*k+f*o+d*w;this.n21=e*c+f*p+d*D;this.n31=e*m+f*v+d*s;this.n41=e*q+f*r+d*B;this.n12=l*k+g*o+i*w;this.n22=
+l*c+g*p+i*D;this.n32=l*m+g*v+i*s;this.n42=l*q+g*r+i*B;this.n13=n*k+j*o+h*w;this.n23=n*c+j*p+h*D;this.n33=n*m+j*v+h*s;this.n43=n*q+j*r+h*B;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,f=this.n13,g=this.n23,h=this.n33,k=this.n43,i=Math.cos(a),a=Math.sin(a);this.n12=i*b+a*f;this.n22=i*c+a*g;this.n32=i*d+a*h;this.n42=i*e+a*k;this.n13=i*f-a*b;this.n23=i*g-a*c;this.n33=i*h-a*d;this.n43=i*k-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,
 f=this.n13,g=this.n23,h=this.n33,k=this.n43,i=Math.cos(a),a=Math.sin(a);this.n11=i*b-a*f;this.n21=i*c-a*g;this.n31=i*d-a*h;this.n41=i*e-a*k;this.n13=i*f+a*b;this.n23=i*g+a*c;this.n33=i*h+a*d;this.n43=i*k+a*e;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,f=this.n12,g=this.n22,h=this.n32,k=this.n42,i=Math.cos(a),a=Math.sin(a);this.n11=i*b+a*f;this.n21=i*c+a*g;this.n31=i*d+a*h;this.n41=i*e+a*k;this.n12=i*f-a*b;this.n22=i*g-a*c;this.n32=i*h-a*d;this.n42=i*k-a*e;return this},
 translate:function(a){var b=a.x,c=a.y,a=a.z;this.n14=this.n11*b+this.n12*c+this.n13*a+this.n14;this.n24=this.n21*b+this.n22*c+this.n23*a+this.n24;this.n34=this.n31*b+this.n32*c+this.n33*a+this.n34;this.n44=this.n41*b+this.n42*c+this.n43*a+this.n44;return this}};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,j=-a.n23*a.n11+a.n21*a.n13,l=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*g+a.n31*i;if(0===a)return null;a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*h;c[5]=a*k;c[6]=a*i;c[7]=a*j;c[8]=a*l;return b};
@@ -61,16 +61,16 @@ this.children.indexOf(a)){void 0!==a.parent&&a.parent.remove(a);a.parent=this;th
 a||b&&(e=e.getChildByName(a,b),void 0!==e))return e}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(1!==this.scale.x||1!==this.scale.y||1!==this.scale.z)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){this.matrixAutoUpdate&&
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)}};THREE.Object3DCount=0;
 THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=i[k]=i[k]||new THREE.RenderableVertex;k++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d<c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return!0}
-var e,f,g=[],h,k,i=[],j,l,n=[],m,q=[],o,p,u=[],r,w,D=[],s={objects:[],sprites:[],lights:[],elements:[]},A=new THREE.Vector3,v=new THREE.Vector4,y=new THREE.Matrix4,F=new THREE.Matrix4,J=new THREE.Frustum,H=new THREE.Vector4,I=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);y.multiply(b.projectionMatrix,b.matrixWorldInverse);y.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);y.multiply(b.matrixWorld,
-b.projectionMatrixInverse);y.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){f=0;s.objects.length=0;s.sprites.length=0;s.lights.length=0;var g=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||J.contains(b))?(y.multiplyVector3(A.copy(b.position)),e=a(),e.object=
-b,e.z=A.z,s.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(y.multiplyVector3(A.copy(b.position)),e=a(),e.object=b,e.z=A.z,s.sprites.push(e)):b instanceof THREE.Light&&s.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&s.objects.sort(c);return s};this.projectScene=function(a,e,f){var g=e.near,A=e.far,T,K,B,G,t,C,z,E,x,L,M,U,X,V,W,N;w=p=m=l=0;s.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
-a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);y.multiply(e.projectionMatrix,e.matrixWorldInverse);J.setFromMatrix(y);s=this.projectGraph(a,!1);for(a=0,T=s.objects.length;a<T;a++)if(x=s.objects[a].object,L=x.matrixWorld,U=x.material,k=0,x instanceof THREE.Mesh){M=x.geometry;X=x.geometry.materials;G=M.vertices;V=M.faces;W=M.faceVertexUvs;M=x.matrixRotationWorld.extractRotation(L);for(K=0,B=G.length;K<B;K++)h=b(),h.positionWorld.copy(G[K].position),L.multiplyVector3(h.positionWorld),
-h.positionScreen.copy(h.positionWorld),y.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<A;for(G=0,K=V.length;G<K;G++){B=V[G];if(B instanceof THREE.Face3)if(t=i[B.a],C=i[B.b],z=i[B.c],t.visible&&C.visible&&z.visible&&(x.doubleSided||x.flipSided!=0>(z.positionScreen.x-t.positionScreen.x)*(C.positionScreen.y-t.positionScreen.y)-(z.positionScreen.y-t.positionScreen.y)*(C.positionScreen.x-
-t.positionScreen.x)))E=n[l]=n[l]||new THREE.RenderableFace3,l++,j=E,j.v1.copy(t),j.v2.copy(C),j.v3.copy(z);else continue;else if(B instanceof THREE.Face4)if(t=i[B.a],C=i[B.b],z=i[B.c],E=i[B.d],t.visible&&C.visible&&z.visible&&E.visible&&(x.doubleSided||x.flipSided!=(0>(E.positionScreen.x-t.positionScreen.x)*(C.positionScreen.y-t.positionScreen.y)-(E.positionScreen.y-t.positionScreen.y)*(C.positionScreen.x-t.positionScreen.x)||0>(C.positionScreen.x-z.positionScreen.x)*(E.positionScreen.y-z.positionScreen.y)-
-(C.positionScreen.y-z.positionScreen.y)*(E.positionScreen.x-z.positionScreen.x))))N=q[m]=q[m]||new THREE.RenderableFace4,m++,j=N,j.v1.copy(t),j.v2.copy(C),j.v3.copy(z),j.v4.copy(E);else continue;j.normalWorld.copy(B.normal);M.multiplyVector3(j.normalWorld);j.centroidWorld.copy(B.centroid);L.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);y.multiplyVector3(j.centroidScreen);z=B.vertexNormals;for(t=0,C=z.length;t<C;t++)E=j.vertexNormalsWorld[t],E.copy(z[t]),M.multiplyVector3(E);
-for(t=0,C=W.length;t<C;t++)if(N=W[t][G])for(z=0,E=N.length;z<E;z++)j.uvs[t][z]=N[z];j.material=U;j.faceMaterial=null!==B.materialIndex?X[B.materialIndex]:null;j.z=j.centroidScreen.z;s.elements.push(j)}}else if(x instanceof THREE.Line){F.multiply(y,L);G=x.geometry.vertices;t=b();t.positionScreen.copy(G[0].position);F.multiplyVector4(t.positionScreen);for(K=1,B=G.length;K<B;K++)if(t=b(),t.positionScreen.copy(G[K].position),F.multiplyVector4(t.positionScreen),C=i[k-2],H.copy(t.positionScreen),I.copy(C.positionScreen),
-d(H,I))H.multiplyScalar(1/H.w),I.multiplyScalar(1/I.w),x=u[p]=u[p]||new THREE.RenderableLine,p++,o=x,o.v1.positionScreen.copy(H),o.v2.positionScreen.copy(I),o.z=Math.max(H.z,I.z),o.material=U,s.elements.push(o)}for(a=0,T=s.sprites.length;a<T;a++)if(x=s.sprites[a].object,L=x.matrixWorld,x instanceof THREE.Particle&&(v.set(L.n14,L.n24,L.n34,1),y.multiplyVector4(v),v.z/=v.w,0<v.z&&1>v.z))g=D[w]=D[w]||new THREE.RenderableParticle,w++,r=g,r.x=v.x/v.w,r.y=v.y/v.w,r.z=v.z,r.rotation=x.rotation.z,r.scale.x=
-x.scale.x*Math.abs(r.x-(v.x+e.projectionMatrix.n11)/(v.w+e.projectionMatrix.n14)),r.scale.y=x.scale.y*Math.abs(r.y-(v.y+e.projectionMatrix.n22)/(v.w+e.projectionMatrix.n24)),r.material=x.material,s.elements.push(r);f&&s.elements.sort(c);return s}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
+var e,f,g=[],h,k,i=[],j,l,n=[],m,q=[],o,p,v=[],r,w,D=[],s={objects:[],sprites:[],lights:[],elements:[]},B=new THREE.Vector3,x=new THREE.Vector4,z=new THREE.Matrix4,F=new THREE.Matrix4,J=new THREE.Frustum,H=new THREE.Vector4,I=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);z.multiply(b.projectionMatrix,b.matrixWorldInverse);z.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);z.multiply(b.matrixWorld,
+b.projectionMatrixInverse);z.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){f=0;s.objects.length=0;s.sprites.length=0;s.lights.length=0;var g=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||J.contains(b))?(z.multiplyVector3(B.copy(b.position)),e=a(),e.object=
+b,e.z=B.z,s.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(z.multiplyVector3(B.copy(b.position)),e=a(),e.object=b,e.z=B.z,s.sprites.push(e)):b instanceof THREE.Light&&s.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&s.objects.sort(c);return s};this.projectScene=function(a,e,f){var g=e.near,B=e.far,T,K,u,G,t,C,A,E,y,L,M,U,X,V,W,N;w=p=m=l=0;s.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
+a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);z.multiply(e.projectionMatrix,e.matrixWorldInverse);J.setFromMatrix(z);s=this.projectGraph(a,!1);for(a=0,T=s.objects.length;a<T;a++)if(y=s.objects[a].object,L=y.matrixWorld,U=y.material,k=0,y instanceof THREE.Mesh){M=y.geometry;X=y.geometry.materials;G=M.vertices;V=M.faces;W=M.faceVertexUvs;M=y.matrixRotationWorld.extractRotation(L);for(K=0,u=G.length;K<u;K++)h=b(),h.positionWorld.copy(G[K].position),L.multiplyVector3(h.positionWorld),
+h.positionScreen.copy(h.positionWorld),z.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<B;for(G=0,K=V.length;G<K;G++){u=V[G];if(u instanceof THREE.Face3)if(t=i[u.a],C=i[u.b],A=i[u.c],t.visible&&C.visible&&A.visible&&(y.doubleSided||y.flipSided!=0>(A.positionScreen.x-t.positionScreen.x)*(C.positionScreen.y-t.positionScreen.y)-(A.positionScreen.y-t.positionScreen.y)*(C.positionScreen.x-
+t.positionScreen.x)))E=n[l]=n[l]||new THREE.RenderableFace3,l++,j=E,j.v1.copy(t),j.v2.copy(C),j.v3.copy(A);else continue;else if(u instanceof THREE.Face4)if(t=i[u.a],C=i[u.b],A=i[u.c],E=i[u.d],t.visible&&C.visible&&A.visible&&E.visible&&(y.doubleSided||y.flipSided!=(0>(E.positionScreen.x-t.positionScreen.x)*(C.positionScreen.y-t.positionScreen.y)-(E.positionScreen.y-t.positionScreen.y)*(C.positionScreen.x-t.positionScreen.x)||0>(C.positionScreen.x-A.positionScreen.x)*(E.positionScreen.y-A.positionScreen.y)-
+(C.positionScreen.y-A.positionScreen.y)*(E.positionScreen.x-A.positionScreen.x))))N=q[m]=q[m]||new THREE.RenderableFace4,m++,j=N,j.v1.copy(t),j.v2.copy(C),j.v3.copy(A),j.v4.copy(E);else continue;j.normalWorld.copy(u.normal);M.multiplyVector3(j.normalWorld);j.centroidWorld.copy(u.centroid);L.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);z.multiplyVector3(j.centroidScreen);A=u.vertexNormals;for(t=0,C=A.length;t<C;t++)E=j.vertexNormalsWorld[t],E.copy(A[t]),M.multiplyVector3(E);
+for(t=0,C=W.length;t<C;t++)if(N=W[t][G])for(A=0,E=N.length;A<E;A++)j.uvs[t][A]=N[A];j.material=U;j.faceMaterial=null!==u.materialIndex?X[u.materialIndex]:null;j.z=j.centroidScreen.z;s.elements.push(j)}}else if(y instanceof THREE.Line){F.multiply(z,L);G=y.geometry.vertices;t=b();t.positionScreen.copy(G[0].position);F.multiplyVector4(t.positionScreen);for(K=1,u=G.length;K<u;K++)if(t=b(),t.positionScreen.copy(G[K].position),F.multiplyVector4(t.positionScreen),C=i[k-2],H.copy(t.positionScreen),I.copy(C.positionScreen),
+d(H,I))H.multiplyScalar(1/H.w),I.multiplyScalar(1/I.w),y=v[p]=v[p]||new THREE.RenderableLine,p++,o=y,o.v1.positionScreen.copy(H),o.v2.positionScreen.copy(I),o.z=Math.max(H.z,I.z),o.material=U,s.elements.push(o)}for(a=0,T=s.sprites.length;a<T;a++)if(y=s.sprites[a].object,L=y.matrixWorld,y instanceof THREE.Particle&&(x.set(L.n14,L.n24,L.n34,1),z.multiplyVector4(x),x.z/=x.w,0<x.z&&1>x.z))g=D[w]=D[w]||new THREE.RenderableParticle,w++,r=g,r.x=x.x/x.w,r.y=x.y/x.w,r.z=x.z,r.rotation=y.rotation.z,r.scale.x=
+y.scale.x*Math.abs(r.x-(x.x+e.projectionMatrix.n11)/(x.w+e.projectionMatrix.n14)),r.scale.y=y.scale.y*Math.abs(r.y-(x.y+e.projectionMatrix.n22)/(x.w+e.projectionMatrix.n24)),r.material=y.material,s.elements.push(r);f&&s.elements.sort(c);return s}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
@@ -111,6 +111,6 @@ THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};
 THREE.ImageUtils={crossOrigin:"",loadTexture:function(a,b,c){var d=new Image,e=new THREE.Texture(d,b);d.onload=function(){e.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return e},loadTextureCube:function(a,b,c){var d,e=[],f=new THREE.Texture(e,b);e.loadCount=0;for(b=0,d=a.length;b<d;++b)e[b]=new Image,e[b].onload=function(){e.loadCount+=1;if(6===e.loadCount)f.needsUpdate=!0;c&&c(this)},e[b].crossOrigin="",e[b].src=a[b];return f},getNormalMap:function(a,b){var c=function(a){var b=
-Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,k=g.createImageData(d,e),i=k.data,j=0;j<d;j++)for(var l=1;l<e;l++){var n=0>l-1?e-1:l-1,m=(l+1)%e,q=0>j-1?d-1:j-1,o=(j+1)%d,p=[],u=[0,0,h[4*(l*d+j)]/255*b];p.push([-1,0,h[4*(l*d+q)]/255*b]);p.push([-1,-1,h[4*(n*d+q)]/255*b]);p.push([0,-1,h[4*(n*d+j)]/255*b]);p.push([1,
--1,h[4*(n*d+o)]/255*b]);p.push([1,0,h[4*(l*d+o)]/255*b]);p.push([1,1,h[4*(m*d+o)]/255*b]);p.push([0,1,h[4*(m*d+j)]/255*b]);p.push([-1,1,h[4*(m*d+q)]/255*b]);n=[];q=p.length;for(m=0;m<q;m++){var o=p[m],r=p[(m+1)%q],o=[o[0]-u[0],o[1]-u[1],o[2]-u[2]],r=[r[0]-u[0],r[1]-u[1],r[2]-u[2]];n.push(c([o[1]*r[2]-o[2]*r[1],o[2]*r[0]-o[0]*r[2],o[0]*r[1]-o[1]*r[0]]))}p=[0,0,0];for(m=0;m<n.length;m++)p[0]+=n[m][0],p[1]+=n[m][1],p[2]+=n[m][2];p[0]/=n.length;p[1]/=n.length;p[2]/=n.length;u=4*(l*d+j);i[u]=255*((p[0]+
-1)/2)|0;i[u+1]=255*(p[1]+0.5)|0;i[u+2]=255*p[2]|0;i[u+3]=255}g.putImageData(k,0,0);return f}};
+Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,k=g.createImageData(d,e),i=k.data,j=0;j<d;j++)for(var l=1;l<e;l++){var n=0>l-1?e-1:l-1,m=(l+1)%e,q=0>j-1?d-1:j-1,o=(j+1)%d,p=[],v=[0,0,h[4*(l*d+j)]/255*b];p.push([-1,0,h[4*(l*d+q)]/255*b]);p.push([-1,-1,h[4*(n*d+q)]/255*b]);p.push([0,-1,h[4*(n*d+j)]/255*b]);p.push([1,
+-1,h[4*(n*d+o)]/255*b]);p.push([1,0,h[4*(l*d+o)]/255*b]);p.push([1,1,h[4*(m*d+o)]/255*b]);p.push([0,1,h[4*(m*d+j)]/255*b]);p.push([-1,1,h[4*(m*d+q)]/255*b]);n=[];q=p.length;for(m=0;m<q;m++){var o=p[m],r=p[(m+1)%q],o=[o[0]-v[0],o[1]-v[1],o[2]-v[2]],r=[r[0]-v[0],r[1]-v[1],r[2]-v[2]];n.push(c([o[1]*r[2]-o[2]*r[1],o[2]*r[0]-o[0]*r[2],o[0]*r[1]-o[1]*r[0]]))}p=[0,0,0];for(m=0;m<n.length;m++)p[0]+=n[m][0],p[1]+=n[m][1],p[2]+=n[m][2];p[0]/=n.length;p[1]/=n.length;p[2]/=n.length;v=4*(l*d+j);i[v]=255*((p[0]+
+1)/2)|0;i[v+1]=255*(p[1]+0.5)|0;i[v+2]=255*p[2]|0;i[v+3]=255}g.putImageData(k,0,0);return f}};

+ 19 - 19
build/custom/ThreeSVG.js

@@ -18,9 +18,9 @@ THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes;c[0].set(a
 THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),e=0;6>e;e++)if(a=b[e].x*c.n14+b[e].y*c.n24+b[e].z*c.n34+b[e].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3;
 THREE.Ray=function(a,b){function c(a,b,c){k.sub(c,a);q=k.dot(b);y=p.add(a,o.copy(b).multiplyScalar(q));return u=c.distanceTo(y)}function d(a,b,c,d){k.sub(d,b);p.sub(c,b);o.sub(a,b);E=k.dot(k);t=k.dot(p);v=k.dot(o);B=p.dot(p);w=p.dot(o);z=1/(E*B-t*t);G=(B*v-t*w)*z;C=(E*w-t*v)*z;return 0<=G&&0<=C&&1>G+C}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,c,d=[];for(b=0,
 c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,l=new THREE.Vector3,j=new THREE.Vector3,i=new THREE.Vector3,m=new THREE.Vector3,n=new THREE.Vector3;this.intersectObject=function(a){for(var b,k=[],o=0,p=a.children.length;o<p;o++)Array.prototype.push.apply(k,this.intersectObject(a.children[o]));if(a instanceof THREE.Particle){o=
-c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.scale.x)return[];b={distance:o,point:a.position,face:null,object:a};k.push(b)}else if(a instanceof THREE.Mesh){o=c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return k;var q,t=a.geometry,v=t.vertices,u;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,p=t.faces.length;o<p;o++)if(b=t.faces[o],l.copy(this.origin),j.copy(this.direction),
-u=a.matrixWorld,i=u.multiplyVector3(i.copy(b.centroid)).subSelf(l),q=i.dot(j),!(0>=q)&&(e=u.multiplyVector3(e.copy(v[b.a].position)),f=u.multiplyVector3(f.copy(v[b.b].position)),g=u.multiplyVector3(g.copy(v[b.c].position)),b instanceof THREE.Face4&&(h=u.multiplyVector3(h.copy(v[b.d].position))),m=a.matrixRotationWorld.multiplyVector3(m.copy(b.normal)),q=j.dot(m),a.doubleSided||(a.flipSided?0<q:0>q)))if(q=m.dot(i.sub(e,l))/q,n.add(l,j.multiplyScalar(q)),b instanceof THREE.Face3)d(n,e,f,g)&&(b={distance:l.distanceTo(n),
-point:n.clone(),face:b,object:a},k.push(b));else if(b instanceof THREE.Face4&&(d(n,e,f,h)||d(n,f,g,h)))b={distance:l.distanceTo(n),point:n.clone(),face:b,object:a},k.push(b)}return k};var k=new THREE.Vector3,p=new THREE.Vector3,o=new THREE.Vector3,q,y,u,E,t,v,B,w,z,G,C};
+c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.scale.x)return[];b={distance:o,point:a.position,face:null,object:a};k.push(b)}else if(a instanceof THREE.Mesh){o=c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return k;var q,t,v=a.geometry,u=v.vertices,r;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,p=v.faces.length;o<p;o++)if(b=v.faces[o],l.copy(this.origin),j.copy(this.direction),
+r=a.matrixWorld,i=r.multiplyVector3(i.copy(b.centroid)).subSelf(l),m=a.matrixRotationWorld.multiplyVector3(m.copy(b.normal)),q=j.dot(m),!(1.0E-4>Math.abs(q))&&(t=m.dot(i)/q,!(0>t)&&(a.doubleSided||(a.flipSided?0<q:0>q))))if(n.add(l,j.multiplyScalar(t)),b instanceof THREE.Face3)e=r.multiplyVector3(e.copy(u[b.a].position)),f=r.multiplyVector3(f.copy(u[b.b].position)),g=r.multiplyVector3(g.copy(u[b.c].position)),d(n,e,f,g)&&(b={distance:l.distanceTo(n),point:n.clone(),face:b,object:a},k.push(b));else if(b instanceof
+THREE.Face4&&(e=r.multiplyVector3(e.copy(u[b.a].position)),f=r.multiplyVector3(f.copy(u[b.b].position)),g=r.multiplyVector3(g.copy(u[b.c].position)),h=r.multiplyVector3(h.copy(u[b.d].position)),d(n,e,f,h)||d(n,f,g,h)))b={distance:l.distanceTo(n),point:n.clone(),face:b,object:a},k.push(b)}return k};var k=new THREE.Vector3,p=new THREE.Vector3,o=new THREE.Vector3,q,y,u,E,t,v,B,w,z,G,C};
 THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,i,m){h=!1;b=f;c=g;d=i;e=m;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
 function(f,g,i,m,n,k){h?(h=!1,b=f<i?f<n?f:n:i<n?i:n,c=g<m?g<k?g:k:m<k?m:k,d=f>i?f>n?f:n:i>n?i:n,e=g>m?g>k?g:k:m>k?m:k):(b=f<i?f<n?f<b?f:b:n<b?n:b:i<n?i<b?i:b:n<b?n:b,c=g<m?g<k?g<c?g:c:k<c?k:c:m<k?m<c?m:c:k<c?k:c,d=f>i?f>n?f>d?f:d:n>d?n:d:i>n?i>d?i:d:n>d?n:d,e=g>m?g>k?g>e?g:e:k>e?k:e:m>k?m>e?m:e:k>e?k:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
 f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||e<a.getTop()||c>a.getBottom()?!1:!0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
@@ -63,12 +63,12 @@ this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWor
 THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=j[l]=j[l]||new THREE.RenderableVertex;l++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d<c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return!0}
 var e,f,g=[],h,l,j=[],i,m,n=[],k,p=[],o,q,y=[],u,E,t=[],v={objects:[],sprites:[],lights:[],elements:[]},B=new THREE.Vector3,w=new THREE.Vector4,z=new THREE.Matrix4,G=new THREE.Matrix4,C=new THREE.Frustum,I=new THREE.Vector4,A=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);z.multiply(b.projectionMatrix,b.matrixWorldInverse);z.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);z.multiply(b.matrixWorld,
 b.projectionMatrixInverse);z.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){f=0;v.objects.length=0;v.sprites.length=0;v.lights.length=0;var g=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||C.contains(b))?(z.multiplyVector3(B.copy(b.position)),e=a(),e.object=
-b,e.z=B.z,v.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(z.multiplyVector3(B.copy(b.position)),e=a(),e.object=b,e.z=B.z,v.sprites.push(e)):b instanceof THREE.Light&&v.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&v.objects.sort(c);return v};this.projectScene=function(a,e,f){var g=e.near,B=e.far,T,N,s,r,x,D,F,J,H,O,P,U,X,V,W,R;E=q=k=m=0;v.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
-a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);z.multiply(e.projectionMatrix,e.matrixWorldInverse);C.setFromMatrix(z);v=this.projectGraph(a,!1);for(a=0,T=v.objects.length;a<T;a++)if(H=v.objects[a].object,O=H.matrixWorld,U=H.material,l=0,H instanceof THREE.Mesh){P=H.geometry;X=H.geometry.materials;r=P.vertices;V=P.faces;W=P.faceVertexUvs;P=H.matrixRotationWorld.extractRotation(O);for(N=0,s=r.length;N<s;N++)h=b(),h.positionWorld.copy(r[N].position),O.multiplyVector3(h.positionWorld),
-h.positionScreen.copy(h.positionWorld),z.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<B;for(r=0,N=V.length;r<N;r++){s=V[r];if(s instanceof THREE.Face3)if(x=j[s.a],D=j[s.b],F=j[s.c],x.visible&&D.visible&&F.visible&&(H.doubleSided||H.flipSided!=0>(F.positionScreen.x-x.positionScreen.x)*(D.positionScreen.y-x.positionScreen.y)-(F.positionScreen.y-x.positionScreen.y)*(D.positionScreen.x-
-x.positionScreen.x)))J=n[m]=n[m]||new THREE.RenderableFace3,m++,i=J,i.v1.copy(x),i.v2.copy(D),i.v3.copy(F);else continue;else if(s instanceof THREE.Face4)if(x=j[s.a],D=j[s.b],F=j[s.c],J=j[s.d],x.visible&&D.visible&&F.visible&&J.visible&&(H.doubleSided||H.flipSided!=(0>(J.positionScreen.x-x.positionScreen.x)*(D.positionScreen.y-x.positionScreen.y)-(J.positionScreen.y-x.positionScreen.y)*(D.positionScreen.x-x.positionScreen.x)||0>(D.positionScreen.x-F.positionScreen.x)*(J.positionScreen.y-F.positionScreen.y)-
-(D.positionScreen.y-F.positionScreen.y)*(J.positionScreen.x-F.positionScreen.x))))R=p[k]=p[k]||new THREE.RenderableFace4,k++,i=R,i.v1.copy(x),i.v2.copy(D),i.v3.copy(F),i.v4.copy(J);else continue;i.normalWorld.copy(s.normal);P.multiplyVector3(i.normalWorld);i.centroidWorld.copy(s.centroid);O.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);z.multiplyVector3(i.centroidScreen);F=s.vertexNormals;for(x=0,D=F.length;x<D;x++)J=i.vertexNormalsWorld[x],J.copy(F[x]),P.multiplyVector3(J);
-for(x=0,D=W.length;x<D;x++)if(R=W[x][r])for(F=0,J=R.length;F<J;F++)i.uvs[x][F]=R[F];i.material=U;i.faceMaterial=null!==s.materialIndex?X[s.materialIndex]:null;i.z=i.centroidScreen.z;v.elements.push(i)}}else if(H instanceof THREE.Line){G.multiply(z,O);r=H.geometry.vertices;x=b();x.positionScreen.copy(r[0].position);G.multiplyVector4(x.positionScreen);for(N=1,s=r.length;N<s;N++)if(x=b(),x.positionScreen.copy(r[N].position),G.multiplyVector4(x.positionScreen),D=j[l-2],I.copy(x.positionScreen),A.copy(D.positionScreen),
+b,e.z=B.z,v.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(z.multiplyVector3(B.copy(b.position)),e=a(),e.object=b,e.z=B.z,v.sprites.push(e)):b instanceof THREE.Light&&v.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&v.objects.sort(c);return v};this.projectScene=function(a,e,f){var g=e.near,B=e.far,T,N,r,s,x,D,F,J,H,O,P,U,X,V,W,R;E=q=k=m=0;v.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
+a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);z.multiply(e.projectionMatrix,e.matrixWorldInverse);C.setFromMatrix(z);v=this.projectGraph(a,!1);for(a=0,T=v.objects.length;a<T;a++)if(H=v.objects[a].object,O=H.matrixWorld,U=H.material,l=0,H instanceof THREE.Mesh){P=H.geometry;X=H.geometry.materials;s=P.vertices;V=P.faces;W=P.faceVertexUvs;P=H.matrixRotationWorld.extractRotation(O);for(N=0,r=s.length;N<r;N++)h=b(),h.positionWorld.copy(s[N].position),O.multiplyVector3(h.positionWorld),
+h.positionScreen.copy(h.positionWorld),z.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<B;for(s=0,N=V.length;s<N;s++){r=V[s];if(r instanceof THREE.Face3)if(x=j[r.a],D=j[r.b],F=j[r.c],x.visible&&D.visible&&F.visible&&(H.doubleSided||H.flipSided!=0>(F.positionScreen.x-x.positionScreen.x)*(D.positionScreen.y-x.positionScreen.y)-(F.positionScreen.y-x.positionScreen.y)*(D.positionScreen.x-
+x.positionScreen.x)))J=n[m]=n[m]||new THREE.RenderableFace3,m++,i=J,i.v1.copy(x),i.v2.copy(D),i.v3.copy(F);else continue;else if(r instanceof THREE.Face4)if(x=j[r.a],D=j[r.b],F=j[r.c],J=j[r.d],x.visible&&D.visible&&F.visible&&J.visible&&(H.doubleSided||H.flipSided!=(0>(J.positionScreen.x-x.positionScreen.x)*(D.positionScreen.y-x.positionScreen.y)-(J.positionScreen.y-x.positionScreen.y)*(D.positionScreen.x-x.positionScreen.x)||0>(D.positionScreen.x-F.positionScreen.x)*(J.positionScreen.y-F.positionScreen.y)-
+(D.positionScreen.y-F.positionScreen.y)*(J.positionScreen.x-F.positionScreen.x))))R=p[k]=p[k]||new THREE.RenderableFace4,k++,i=R,i.v1.copy(x),i.v2.copy(D),i.v3.copy(F),i.v4.copy(J);else continue;i.normalWorld.copy(r.normal);P.multiplyVector3(i.normalWorld);i.centroidWorld.copy(r.centroid);O.multiplyVector3(i.centroidWorld);i.centroidScreen.copy(i.centroidWorld);z.multiplyVector3(i.centroidScreen);F=r.vertexNormals;for(x=0,D=F.length;x<D;x++)J=i.vertexNormalsWorld[x],J.copy(F[x]),P.multiplyVector3(J);
+for(x=0,D=W.length;x<D;x++)if(R=W[x][s])for(F=0,J=R.length;F<J;F++)i.uvs[x][F]=R[F];i.material=U;i.faceMaterial=null!==r.materialIndex?X[r.materialIndex]:null;i.z=i.centroidScreen.z;v.elements.push(i)}}else if(H instanceof THREE.Line){G.multiply(z,O);s=H.geometry.vertices;x=b();x.positionScreen.copy(s[0].position);G.multiplyVector4(x.positionScreen);for(N=1,r=s.length;N<r;N++)if(x=b(),x.positionScreen.copy(s[N].position),G.multiplyVector4(x.positionScreen),D=j[l-2],I.copy(x.positionScreen),A.copy(D.positionScreen),
 d(I,A))I.multiplyScalar(1/I.w),A.multiplyScalar(1/A.w),H=y[q]=y[q]||new THREE.RenderableLine,q++,o=H,o.v1.positionScreen.copy(I),o.v2.positionScreen.copy(A),o.z=Math.max(I.z,A.z),o.material=U,v.elements.push(o)}for(a=0,T=v.sprites.length;a<T;a++)if(H=v.sprites[a].object,O=H.matrixWorld,H instanceof THREE.Particle&&(w.set(O.n14,O.n24,O.n34,1),z.multiplyVector4(w),w.z/=w.w,0<w.z&&1>w.z))g=t[E]=t[E]||new THREE.RenderableParticle,E++,u=g,u.x=w.x/w.w,u.y=w.y/w.w,u.z=w.z,u.rotation=H.rotation.z,u.scale.x=
 H.scale.x*Math.abs(u.x-(w.x+e.projectionMatrix.n11)/(w.w+e.projectionMatrix.n14)),u.scale.y=H.scale.y*Math.abs(u.y-(w.y+e.projectionMatrix.n22)/(w.w+e.projectionMatrix.n24)),u.material=H.material,v.elements.push(u);f&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
 THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,e=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-e),e=Math.sin(-e),f=Math.cos(c),c=Math.sin(c),g=a*b,h=d*e;this.w=g*f-h*c;this.x=g*c+h*f;this.y=d*b*f+a*e*c;this.z=a*e*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
@@ -132,16 +132,16 @@ THREE.Scene.prototype.addObject=function(a){if(a instanceof THREE.Light)-1===thi
 THREE.Scene.prototype.removeObject=function(a){if(a instanceof THREE.Light){var b=this.lights.indexOf(a);-1!==b&&this.lights.splice(b,1)}else a instanceof THREE.Camera||(b=this.objects.indexOf(a),-1!==b&&(this.objects.splice(b,1),this.__objectsRemoved.push(a),b=this.__objectsAdded.indexOf(a),-1!==b&&this.__objectsAdded.splice(b,1)));for(b=0;b<a.children.length;b++)this.removeObject(a.children[b])};
 THREE.SVGRenderer=function(){function a(a,b,c,d){var e,f,g,h,j,i;for(e=0,f=a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(j=g.matrixWorld.getPosition(),i=c.dot(j),0>=i||(i*=g.intensity,d.r+=h.r*i,d.g+=h.g*i,d.b+=h.b*i)):g instanceof THREE.PointLight&&(j=g.matrixWorld.getPosition(),i=c.dot(G.sub(j,b).normalize()),0>=i||(i*=0==g.distance?1:1-Math.min(b.distanceTo(j)/g.distance,1),0!=i&&(i*=g.intensity,d.r+=h.r*i,d.g+=h.g*i,d.b+=h.b*i)))}function b(a){null==C[a]&&(C[a]=document.createElementNS("http://www.w3.org/2000/svg",
 "path"),0==L&&C[a].setAttribute("shape-rendering","crispEdges"));return C[a]}function c(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}var d=this,e,f,g,h=new THREE.Projector,l=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,i,m,n,k,p,o,q,y=new THREE.Rectangle,u=new THREE.Rectangle,E=!1,t=new THREE.Color,v=new THREE.Color,B=new THREE.Color,w=new THREE.Color,z,G=new THREE.Vector3,C=[],I=[],A,K,M,L=1;this.domElement=l;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,
-faces:0}};this.setQuality=function(a){switch(a){case "high":L=1;break;case "low":L=0}};this.setSize=function(a,b){j=a;i=b;m=j/2;n=i/2;l.setAttribute("viewBox",-m+" "+-n+" "+j+" "+i);l.setAttribute("width",j);l.setAttribute("height",i);y.set(-m,-n,m,n)};this.clear=function(){for(;0<l.childNodes.length;)l.removeChild(l.childNodes[0])};this.render=function(i,j){var C,G,s,r;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(i,j,this.sortElements);f=e.elements;
-g=e.lights;M=K=0;if(E=0<g.length){v.setRGB(0,0,0);B.setRGB(0,0,0);w.setRGB(0,0,0);for(C=0,G=g.length;C<G;C++)r=g[C],s=r.color,r instanceof THREE.AmbientLight?(v.r+=s.r,v.g+=s.g,v.b+=s.b):r instanceof THREE.DirectionalLight?(B.r+=s.r,B.g+=s.g,B.b+=s.b):r instanceof THREE.PointLight&&(w.r+=s.r,w.g+=s.g,w.b+=s.b)}for(C=0,G=f.length;C<G;C++)if(s=f[C],r=s.material,r=r instanceof THREE.MeshFaceMaterial?s.faceMaterial:r,!(null==r||0==r.opacity))if(u.empty(),s instanceof THREE.RenderableParticle)k=s,k.x*=
-m,k.y*=-n;else if(s instanceof THREE.RenderableLine){if(k=s.v1,p=s.v2,k.positionScreen.x*=m,k.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,u.addPoint(k.positionScreen.x,k.positionScreen.y),u.addPoint(p.positionScreen.x,p.positionScreen.y),y.intersects(u)){s=k;var x=p,D=M++;null==I[D]&&(I[D]=document.createElementNS("http://www.w3.org/2000/svg","line"),0==L&&I[D].setAttribute("shape-rendering","crispEdges"));A=I[D];A.setAttribute("x1",s.positionScreen.x);A.setAttribute("y1",s.positionScreen.y);
-A.setAttribute("x2",x.positionScreen.x);A.setAttribute("y2",x.positionScreen.y);r instanceof THREE.LineBasicMaterial&&(A.setAttribute("style","fill: none; stroke: "+r.color.getContextStyle()+"; stroke-width: "+r.linewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.linecap+"; stroke-linejoin: "+r.linejoin),l.appendChild(A))}}else if(s instanceof THREE.RenderableFace3){if(k=s.v1,p=s.v2,o=s.v3,k.positionScreen.x*=m,k.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,o.positionScreen.x*=
-m,o.positionScreen.y*=-n,u.addPoint(k.positionScreen.x,k.positionScreen.y),u.addPoint(p.positionScreen.x,p.positionScreen.y),u.addPoint(o.positionScreen.x,o.positionScreen.y),y.intersects(u)){var x=k,D=p,F=o;d.info.render.vertices+=3;d.info.render.faces++;A=b(K++);A.setAttribute("d","M "+x.positionScreen.x+" "+x.positionScreen.y+" L "+D.positionScreen.x+" "+D.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+"z");r instanceof THREE.MeshBasicMaterial?t.copy(r.color):r instanceof THREE.MeshLambertMaterial?
-E?(t.r=v.r,t.g=v.g,t.b=v.b,a(g,s.centroidWorld,s.normalWorld,t),t.r=Math.max(0,Math.min(r.color.r*t.r,1)),t.g=Math.max(0,Math.min(r.color.g*t.g,1)),t.b=Math.max(0,Math.min(r.color.b*t.b,1))):t.copy(r.color):r instanceof THREE.MeshDepthMaterial?(z=1-r.__2near/(r.__farPlusNear-s.z*r.__farMinusNear),t.setRGB(z,z,z)):r instanceof THREE.MeshNormalMaterial&&t.setRGB(c(s.normalWorld.x),c(s.normalWorld.y),c(s.normalWorld.z));r.wireframe?A.setAttribute("style","fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+
-r.wireframeLinewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.wireframeLinecap+"; stroke-linejoin: "+r.wireframeLinejoin):A.setAttribute("style","fill: "+t.getContextStyle()+"; fill-opacity: "+r.opacity);l.appendChild(A)}}else if(s instanceof THREE.RenderableFace4&&(k=s.v1,p=s.v2,o=s.v3,q=s.v4,k.positionScreen.x*=m,k.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,o.positionScreen.x*=m,o.positionScreen.y*=-n,q.positionScreen.x*=m,q.positionScreen.y*=-n,u.addPoint(k.positionScreen.x,
-k.positionScreen.y),u.addPoint(p.positionScreen.x,p.positionScreen.y),u.addPoint(o.positionScreen.x,o.positionScreen.y),u.addPoint(q.positionScreen.x,q.positionScreen.y),y.intersects(u))){var x=k,D=p,F=o,J=q;d.info.render.vertices+=4;d.info.render.faces++;A=b(K++);A.setAttribute("d","M "+x.positionScreen.x+" "+x.positionScreen.y+" L "+D.positionScreen.x+" "+D.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+" L "+J.positionScreen.x+","+J.positionScreen.y+"z");r instanceof THREE.MeshBasicMaterial?
-t.copy(r.color):r instanceof THREE.MeshLambertMaterial?E?(t.r=v.r,t.g=v.g,t.b=v.b,a(g,s.centroidWorld,s.normalWorld,t),t.r=Math.max(0,Math.min(r.color.r*t.r,1)),t.g=Math.max(0,Math.min(r.color.g*t.g,1)),t.b=Math.max(0,Math.min(r.color.b*t.b,1))):t.copy(r.color):r instanceof THREE.MeshDepthMaterial?(z=1-r.__2near/(r.__farPlusNear-s.z*r.__farMinusNear),t.setRGB(z,z,z)):r instanceof THREE.MeshNormalMaterial&&t.setRGB(c(s.normalWorld.x),c(s.normalWorld.y),c(s.normalWorld.z));r.wireframe?A.setAttribute("style",
-"fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+r.wireframeLinewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.wireframeLinecap+"; stroke-linejoin: "+r.wireframeLinejoin):A.setAttribute("style","fill: "+t.getContextStyle()+"; fill-opacity: "+r.opacity);l.appendChild(A)}}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};
+faces:0}};this.setQuality=function(a){switch(a){case "high":L=1;break;case "low":L=0}};this.setSize=function(a,b){j=a;i=b;m=j/2;n=i/2;l.setAttribute("viewBox",-m+" "+-n+" "+j+" "+i);l.setAttribute("width",j);l.setAttribute("height",i);y.set(-m,-n,m,n)};this.clear=function(){for(;0<l.childNodes.length;)l.removeChild(l.childNodes[0])};this.render=function(i,j){var C,G,r,s;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(i,j,this.sortElements);f=e.elements;
+g=e.lights;M=K=0;if(E=0<g.length){v.setRGB(0,0,0);B.setRGB(0,0,0);w.setRGB(0,0,0);for(C=0,G=g.length;C<G;C++)s=g[C],r=s.color,s instanceof THREE.AmbientLight?(v.r+=r.r,v.g+=r.g,v.b+=r.b):s instanceof THREE.DirectionalLight?(B.r+=r.r,B.g+=r.g,B.b+=r.b):s instanceof THREE.PointLight&&(w.r+=r.r,w.g+=r.g,w.b+=r.b)}for(C=0,G=f.length;C<G;C++)if(r=f[C],s=r.material,s=s instanceof THREE.MeshFaceMaterial?r.faceMaterial:s,!(null==s||0==s.opacity))if(u.empty(),r instanceof THREE.RenderableParticle)k=r,k.x*=
+m,k.y*=-n;else if(r instanceof THREE.RenderableLine){if(k=r.v1,p=r.v2,k.positionScreen.x*=m,k.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,u.addPoint(k.positionScreen.x,k.positionScreen.y),u.addPoint(p.positionScreen.x,p.positionScreen.y),y.intersects(u)){r=k;var x=p,D=M++;null==I[D]&&(I[D]=document.createElementNS("http://www.w3.org/2000/svg","line"),0==L&&I[D].setAttribute("shape-rendering","crispEdges"));A=I[D];A.setAttribute("x1",r.positionScreen.x);A.setAttribute("y1",r.positionScreen.y);
+A.setAttribute("x2",x.positionScreen.x);A.setAttribute("y2",x.positionScreen.y);s instanceof THREE.LineBasicMaterial&&(A.setAttribute("style","fill: none; stroke: "+s.color.getContextStyle()+"; stroke-width: "+s.linewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.linecap+"; stroke-linejoin: "+s.linejoin),l.appendChild(A))}}else if(r instanceof THREE.RenderableFace3){if(k=r.v1,p=r.v2,o=r.v3,k.positionScreen.x*=m,k.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,o.positionScreen.x*=
+m,o.positionScreen.y*=-n,u.addPoint(k.positionScreen.x,k.positionScreen.y),u.addPoint(p.positionScreen.x,p.positionScreen.y),u.addPoint(o.positionScreen.x,o.positionScreen.y),y.intersects(u)){var x=k,D=p,F=o;d.info.render.vertices+=3;d.info.render.faces++;A=b(K++);A.setAttribute("d","M "+x.positionScreen.x+" "+x.positionScreen.y+" L "+D.positionScreen.x+" "+D.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+"z");s instanceof THREE.MeshBasicMaterial?t.copy(s.color):s instanceof THREE.MeshLambertMaterial?
+E?(t.r=v.r,t.g=v.g,t.b=v.b,a(g,r.centroidWorld,r.normalWorld,t),t.r=Math.max(0,Math.min(s.color.r*t.r,1)),t.g=Math.max(0,Math.min(s.color.g*t.g,1)),t.b=Math.max(0,Math.min(s.color.b*t.b,1))):t.copy(s.color):s instanceof THREE.MeshDepthMaterial?(z=1-s.__2near/(s.__farPlusNear-r.z*s.__farMinusNear),t.setRGB(z,z,z)):s instanceof THREE.MeshNormalMaterial&&t.setRGB(c(r.normalWorld.x),c(r.normalWorld.y),c(r.normalWorld.z));s.wireframe?A.setAttribute("style","fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+
+s.wireframeLinewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.wireframeLinecap+"; stroke-linejoin: "+s.wireframeLinejoin):A.setAttribute("style","fill: "+t.getContextStyle()+"; fill-opacity: "+s.opacity);l.appendChild(A)}}else if(r instanceof THREE.RenderableFace4&&(k=r.v1,p=r.v2,o=r.v3,q=r.v4,k.positionScreen.x*=m,k.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,o.positionScreen.x*=m,o.positionScreen.y*=-n,q.positionScreen.x*=m,q.positionScreen.y*=-n,u.addPoint(k.positionScreen.x,
+k.positionScreen.y),u.addPoint(p.positionScreen.x,p.positionScreen.y),u.addPoint(o.positionScreen.x,o.positionScreen.y),u.addPoint(q.positionScreen.x,q.positionScreen.y),y.intersects(u))){var x=k,D=p,F=o,J=q;d.info.render.vertices+=4;d.info.render.faces++;A=b(K++);A.setAttribute("d","M "+x.positionScreen.x+" "+x.positionScreen.y+" L "+D.positionScreen.x+" "+D.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+" L "+J.positionScreen.x+","+J.positionScreen.y+"z");s instanceof THREE.MeshBasicMaterial?
+t.copy(s.color):s instanceof THREE.MeshLambertMaterial?E?(t.r=v.r,t.g=v.g,t.b=v.b,a(g,r.centroidWorld,r.normalWorld,t),t.r=Math.max(0,Math.min(s.color.r*t.r,1)),t.g=Math.max(0,Math.min(s.color.g*t.g,1)),t.b=Math.max(0,Math.min(s.color.b*t.b,1))):t.copy(s.color):s instanceof THREE.MeshDepthMaterial?(z=1-s.__2near/(s.__farPlusNear-r.z*s.__farMinusNear),t.setRGB(z,z,z)):s instanceof THREE.MeshNormalMaterial&&t.setRGB(c(r.normalWorld.x),c(r.normalWorld.y),c(r.normalWorld.z));s.wireframe?A.setAttribute("style",
+"fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+s.wireframeLinewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.wireframeLinecap+"; stroke-linejoin: "+s.wireframeLinejoin):A.setAttribute("style","fill: "+t.getContextStyle()+"; fill-opacity: "+s.opacity);l.appendChild(A)}}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};
 THREE.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};
 THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null};

+ 201 - 200
build/custom/ThreeWebGL.js

@@ -1,7 +1,7 @@
 // ThreeWebGL.js r47dev - http://github.com/mrdoob/three.js
 'use strict';var THREE=THREE||{};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;if(!self.requestAnimationFrame)self.requestAnimationFrame=function(){return self.webkitRequestAnimationFrame||self.mozRequestAnimationFrame||self.oRequestAnimationFrame||self.msRequestAnimationFrame||function(a){self.setTimeout(a,1E3/60)}}();THREE.Color=function(a){void 0!==a&&this.setHex(a);return this};
 THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);
-this.b=Math.sqrt(this.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,g,e;if(0===c)this.r=this.g=this.b=0;else switch(d=Math.floor(6*a),g=6*a-d,a=c*(1-b),e=c*(1-b*g),b=c*(1-b*(1-g)),d){case 1:this.r=e;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=e;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=e;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=
+this.b=Math.sqrt(this.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,g,f;if(0===c)this.r=this.g=this.b=0;else switch(d=Math.floor(6*a),g=6*a-d,a=c*(1-b),f=c*(1-b*g),b=c*(1-b*(1-g)),d){case 1:this.r=f;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=f;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=f;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=
 Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return Math.floor(255*this.r)<<16^Math.floor(255*this.g)<<8^Math.floor(255*this.b)},getContextStyle:function(){return"rgb("+Math.floor(255*this.r)+","+Math.floor(255*this.g)+","+Math.floor(255*this.b)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
 THREE.Vector2.prototype={constructor:THREE.Vector2,set:function(a,b){this.x=a;this.y=b;return this},copy:function(a){this.x=a.x;this.y=a.y;return this},clone:function(){return new THREE.Vector2(this.x,this.y)},add:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addSelf:function(a){this.x+=a.x;this.y+=a.y;return this},sub:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},
 divideScalar:function(a){a?(this.x/=a,this.y/=a):this.set(0,0);return this},negate:function(){return this.multiplyScalar(-1)},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.lengthSq())},normalize:function(){return this.divideScalar(this.length())},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.normalize().multiplyScalar(a)},
@@ -16,77 +16,77 @@ b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;this.y-=a.y;this
 normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.normalize().multiplyScalar(a)},lerpSelf:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this}};THREE.Frustum=function(){this.planes=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4]};
 THREE.Frustum.prototype.setFromMatrix=function(a){var b,c=this.planes;c[0].set(a.n41-a.n11,a.n42-a.n12,a.n43-a.n13,a.n44-a.n14);c[1].set(a.n41+a.n11,a.n42+a.n12,a.n43+a.n13,a.n44+a.n14);c[2].set(a.n41+a.n21,a.n42+a.n22,a.n43+a.n23,a.n44+a.n24);c[3].set(a.n41-a.n21,a.n42-a.n22,a.n43-a.n23,a.n44-a.n24);c[4].set(a.n41-a.n31,a.n42-a.n32,a.n43-a.n33,a.n44-a.n34);c[5].set(a.n41+a.n31,a.n42+a.n32,a.n43+a.n33,a.n44+a.n34);for(a=0;6>a;a++)b=c[a],b.divideScalar(Math.sqrt(b.x*b.x+b.y*b.y+b.z*b.z))};
 THREE.Frustum.prototype.contains=function(a){for(var b=this.planes,c=a.matrixWorld,d=THREE.Frustum.__v1.set(c.getColumnX().length(),c.getColumnY().length(),c.getColumnZ().length()),d=-a.geometry.boundingSphere.radius*Math.max(d.x,Math.max(d.y,d.z)),g=0;6>g;g++)if(a=b[g].x*c.n14+b[g].y*c.n24+b[g].z*c.n34+b[g].w,a<=d)return!1;return!0};THREE.Frustum.__v1=new THREE.Vector3;
-THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);t=o.dot(b);v=p.add(a,r.copy(b).multiplyScalar(t));return F=c.distanceTo(v)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);r.sub(a,b);A=o.dot(o);K=o.dot(p);y=o.dot(r);J=p.dot(p);H=p.dot(r);I=1/(A*J-K*K);M=(J*y-K*H)*I;G=(A*H-K*y)*I;return 0<=M&&0<=G&&1>M+G}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,c,d=[];for(b=0,
-c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var g=new THREE.Vector3,e=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3,j=new THREE.Vector3,n=new THREE.Vector3,m=new THREE.Vector3;this.intersectObject=function(a){for(var b,p=[],o=0,r=a.children.length;o<r;o++)Array.prototype.push.apply(p,this.intersectObject(a.children[o]));if(a instanceof THREE.Particle){o=
-c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.scale.x)return[];b={distance:o,point:a.position,face:null,object:a};p.push(b)}else if(a instanceof THREE.Mesh){o=c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return p;var t,f=a.geometry,v=f.vertices,y;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,r=f.faces.length;o<r;o++)if(b=f.faces[o],k.copy(this.origin),l.copy(this.direction),
-y=a.matrixWorld,j=y.multiplyVector3(j.copy(b.centroid)).subSelf(k),t=j.dot(l),!(0>=t)&&(g=y.multiplyVector3(g.copy(v[b.a].position)),e=y.multiplyVector3(e.copy(v[b.b].position)),h=y.multiplyVector3(h.copy(v[b.c].position)),b instanceof THREE.Face4&&(i=y.multiplyVector3(i.copy(v[b.d].position))),n=a.matrixRotationWorld.multiplyVector3(n.copy(b.normal)),t=l.dot(n),a.doubleSided||(a.flipSided?0<t:0>t)))if(t=n.dot(j.sub(g,k))/t,m.add(k,l.multiplyScalar(t)),b instanceof THREE.Face3)d(m,g,e,h)&&(b={distance:k.distanceTo(m),
-point:m.clone(),face:b,object:a},p.push(b));else if(b instanceof THREE.Face4&&(d(m,g,e,i)||d(m,e,h,i)))b={distance:k.distanceTo(m),point:m.clone(),face:b,object:a},p.push(b)}return p};var o=new THREE.Vector3,p=new THREE.Vector3,r=new THREE.Vector3,t,v,F,A,K,y,J,H,I,M,G};
-THREE.Rectangle=function(){function a(){e=d-b;h=g-c}var b,c,d,g,e,h,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return e};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(e,h,j,n){i=!1;b=e;c=h;d=j;g=n;a()};this.addPoint=function(e,h){i?(i=!1,b=e,c=h,d=e,g=h):(b=b<e?b:e,c=c<h?c:h,d=d>e?d:e,g=g>h?g:h);a()};this.add3Points=
-function(e,h,j,n,m,o){i?(i=!1,b=e<j?e<m?e:m:j<m?j:m,c=h<n?h<o?h:o:n<o?n:o,d=e>j?e>m?e:m:j>m?j:m,g=h>n?h>o?h:o:n>o?n:o):(b=e<j?e<m?e<b?e:b:m<b?m:b:j<m?j<b?j:b:m<b?m:b,c=h<n?h<o?h<c?h:c:o<c?o:c:n<o?n<c?n:c:o<c?o:c,d=e>j?e>m?e>d?e:d:m>d?m:d:j>m?j>d?j:d:m>d?m:d,g=h>n?h>o?h>g?h:g:o>g?o:g:n>o?n>g?n:g:o>g?o:g);a()};this.addRectangle=function(e){i?(i=!1,b=e.getLeft(),c=e.getTop(),d=e.getRight(),g=e.getBottom()):(b=b<e.getLeft()?b:e.getLeft(),c=c<e.getTop()?c:e.getTop(),d=d>e.getRight()?d:e.getRight(),g=g>
-e.getBottom()?g:e.getBottom());a()};this.inflate=function(e){b-=e;c-=e;d+=e;g+=e;a()};this.minSelf=function(e){b=b>e.getLeft()?b:e.getLeft();c=c>e.getTop()?c:e.getTop();d=d<e.getRight()?d:e.getRight();g=g<e.getBottom()?g:e.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||g<a.getTop()||c>a.getBottom()?!1:!0};this.empty=function(){i=!0;g=d=c=b=0;a()};this.isEmpty=function(){return i}};
+THREE.Ray=function(a,b){function c(a,b,c){o.sub(c,a);t=o.dot(b);y=p.add(a,r.copy(b).multiplyScalar(t));return F=c.distanceTo(y)}function d(a,b,c,d){o.sub(d,b);p.sub(c,b);r.sub(a,b);I=o.dot(o);A=o.dot(p);v=o.dot(r);J=p.dot(p);K=p.dot(r);G=1/(I*J-A*A);M=(J*v-A*K)*G;H=(I*K-A*v)*G;return 0<=M&&0<=H&&1>M+H}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectScene=function(a){return this.intersectObjects(a.children)};this.intersectObjects=function(a){var b,c,d=[];for(b=0,
+c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));d.sort(function(a,b){return a.distance-b.distance});return d};var g=new THREE.Vector3,f=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3,j=new THREE.Vector3,n=new THREE.Vector3,m=new THREE.Vector3;this.intersectObject=function(a){for(var b,p=[],o=0,r=a.children.length;o<r;o++)Array.prototype.push.apply(p,this.intersectObject(a.children[o]));if(a instanceof THREE.Particle){o=
+c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.scale.x)return[];b={distance:o,point:a.position,face:null,object:a};p.push(b)}else if(a instanceof THREE.Mesh){o=c(this.origin,this.direction,a.matrixWorld.getPosition());if(o>a.geometry.boundingSphere.radius*Math.max(a.scale.x,Math.max(a.scale.y,a.scale.z)))return p;var e,t,y=a.geometry,v=y.vertices,I;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,r=y.faces.length;o<r;o++)if(b=y.faces[o],k.copy(this.origin),l.copy(this.direction),
+I=a.matrixWorld,j=I.multiplyVector3(j.copy(b.centroid)).subSelf(k),n=a.matrixRotationWorld.multiplyVector3(n.copy(b.normal)),e=l.dot(n),!(1.0E-4>Math.abs(e))&&(t=n.dot(j)/e,!(0>t)&&(a.doubleSided||(a.flipSided?0<e:0>e))))if(m.add(k,l.multiplyScalar(t)),b instanceof THREE.Face3)g=I.multiplyVector3(g.copy(v[b.a].position)),f=I.multiplyVector3(f.copy(v[b.b].position)),h=I.multiplyVector3(h.copy(v[b.c].position)),d(m,g,f,h)&&(b={distance:k.distanceTo(m),point:m.clone(),face:b,object:a},p.push(b));else if(b instanceof
+THREE.Face4&&(g=I.multiplyVector3(g.copy(v[b.a].position)),f=I.multiplyVector3(f.copy(v[b.b].position)),h=I.multiplyVector3(h.copy(v[b.c].position)),i=I.multiplyVector3(i.copy(v[b.d].position)),d(m,g,f,i)||d(m,f,h,i)))b={distance:k.distanceTo(m),point:m.clone(),face:b,object:a},p.push(b)}return p};var o=new THREE.Vector3,p=new THREE.Vector3,r=new THREE.Vector3,t,y,F,I,A,v,J,K,G,M,H};
+THREE.Rectangle=function(){function a(){f=d-b;h=g-c}var b,c,d,g,f,h,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return g};this.set=function(f,h,j,n){i=!1;b=f;c=h;d=j;g=n;a()};this.addPoint=function(f,h){i?(i=!1,b=f,c=h,d=f,g=h):(b=b<f?b:f,c=c<h?c:h,d=d>f?d:f,g=g>h?g:h);a()};this.add3Points=
+function(f,h,j,n,m,o){i?(i=!1,b=f<j?f<m?f:m:j<m?j:m,c=h<n?h<o?h:o:n<o?n:o,d=f>j?f>m?f:m:j>m?j:m,g=h>n?h>o?h:o:n>o?n:o):(b=f<j?f<m?f<b?f:b:m<b?m:b:j<m?j<b?j:b:m<b?m:b,c=h<n?h<o?h<c?h:c:o<c?o:c:n<o?n<c?n:c:o<c?o:c,d=f>j?f>m?f>d?f:d:m>d?m:d:j>m?j>d?j:d:m>d?m:d,g=h>n?h>o?h>g?h:g:o>g?o:g:n>o?n>g?n:g:o>g?o:g);a()};this.addRectangle=function(f){i?(i=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),g=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),g=g>
+f.getBottom()?g:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;g+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();g=g<f.getBottom()?g:f.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||g<a.getTop()||c>a.getBottom()?!1:!0};this.empty=function(){i=!0;g=d=c=b=0;a()};this.isEmpty=function(){return i}};
 THREE.Math={clamp:function(a,b,c){return a<b?b:a>c?c:a},clampBottom:function(a,b){return a<b?b:a},mapLinear:function(a,b,c,d,g){return d+(a-b)*(g-d)/(c-b)},random16:function(){return(65280*Math.random()+255*Math.random())/65535},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(0.5-Math.random())}};THREE.Matrix3=function(){this.m=[]};
 THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=this.m;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},transposeIntoArray:function(a){var b=this.m;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this}};
-THREE.Matrix4=function(a,b,c,d,g,e,h,i,k,l,j,n,m,o,p,r){this.set(void 0!==a?a:1,b||0,c||0,d||0,g||0,void 0!==e?e:1,h||0,i||0,k||0,l||0,void 0!==j?j:1,n||0,m||0,o||0,p||0,void 0!==r?r:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
-THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,g,e,h,i,k,l,j,n,m,o,p,r){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=g;this.n22=e;this.n23=h;this.n24=i;this.n31=k;this.n32=l;this.n33=j;this.n34=n;this.n41=m;this.n42=o;this.n43=p;this.n44=r;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
-b,c){var d=THREE.Matrix4.__v1,g=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;e.sub(a,b).normalize();if(0===e.length())e.z=1;d.cross(c,e).normalize();0===d.length()&&(e.x+=1.0E-4,d.cross(c,e).normalize());g.cross(e,d).normalize();this.n11=d.x;this.n12=g.x;this.n13=e.x;this.n21=d.y;this.n22=g.y;this.n23=e.y;this.n31=d.z;this.n32=g.z;this.n33=e.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,g=a.n13,e=a.n14,h=a.n21,i=a.n22,k=a.n23,l=a.n24,j=a.n31,n=a.n32,m=a.n33,o=a.n34,p=a.n41,r=a.n42,t=a.n43,
-v=a.n44,F=b.n11,A=b.n12,K=b.n13,y=b.n14,J=b.n21,H=b.n22,I=b.n23,M=b.n24,G=b.n31,L=b.n32,ka=b.n33,T=b.n34,la=b.n41,ca=b.n42,z=b.n43,f=b.n44;this.n11=c*F+d*J+g*G+e*la;this.n12=c*A+d*H+g*L+e*ca;this.n13=c*K+d*I+g*ka+e*z;this.n14=c*y+d*M+g*T+e*f;this.n21=h*F+i*J+k*G+l*la;this.n22=h*A+i*H+k*L+l*ca;this.n23=h*K+i*I+k*ka+l*z;this.n24=h*y+i*M+k*T+l*f;this.n31=j*F+n*J+m*G+o*la;this.n32=j*A+n*H+m*L+o*ca;this.n33=j*K+n*I+m*ka+o*z;this.n34=j*y+n*M+m*T+o*f;this.n41=p*F+r*J+t*G+v*la;this.n42=p*A+r*H+t*L+v*ca;this.n43=
-p*K+r*I+t*ka+v*z;this.n44=p*y+r*M+t*T+v*f;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=
+THREE.Matrix4=function(a,b,c,d,g,f,h,i,k,l,j,n,m,o,p,r){this.set(void 0!==a?a:1,b||0,c||0,d||0,g||0,void 0!==f?f:1,h||0,i||0,k||0,l||0,void 0!==j?j:1,n||0,m||0,o||0,p||0,void 0!==r?r:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
+THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,g,f,h,i,k,l,j,n,m,o,p,r){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=g;this.n22=f;this.n23=h;this.n24=i;this.n31=k;this.n32=l;this.n33=j;this.n34=n;this.n41=m;this.n42=o;this.n43=p;this.n44=r;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
+b,c){var d=THREE.Matrix4.__v1,g=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(0===f.length())f.z=1;d.cross(c,f).normalize();0===d.length()&&(f.x+=1.0E-4,d.cross(c,f).normalize());g.cross(f,d).normalize();this.n11=d.x;this.n12=g.x;this.n13=f.x;this.n21=d.y;this.n22=g.y;this.n23=f.y;this.n31=d.z;this.n32=g.z;this.n33=f.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,g=a.n13,f=a.n14,h=a.n21,i=a.n22,k=a.n23,l=a.n24,j=a.n31,n=a.n32,m=a.n33,o=a.n34,p=a.n41,r=a.n42,t=a.n43,
+y=a.n44,F=b.n11,I=b.n12,A=b.n13,v=b.n14,J=b.n21,K=b.n22,G=b.n23,M=b.n24,H=b.n31,L=b.n32,V=b.n33,ga=b.n34,oa=b.n41,z=b.n42,e=b.n43,qa=b.n44;this.n11=c*F+d*J+g*H+f*oa;this.n12=c*I+d*K+g*L+f*z;this.n13=c*A+d*G+g*V+f*e;this.n14=c*v+d*M+g*ga+f*qa;this.n21=h*F+i*J+k*H+l*oa;this.n22=h*I+i*K+k*L+l*z;this.n23=h*A+i*G+k*V+l*e;this.n24=h*v+i*M+k*ga+l*qa;this.n31=j*F+n*J+m*H+o*oa;this.n32=j*I+n*K+m*L+o*z;this.n33=j*A+n*G+m*V+o*e;this.n34=j*v+n*M+m*ga+o*qa;this.n41=p*F+r*J+t*H+y*oa;this.n42=p*I+r*K+t*L+y*z;this.n43=
+p*A+r*G+t*V+y*e;this.n44=p*v+r*M+t*ga+y*qa;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=
 a;this.n23*=a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,g=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*g;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*g;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*g;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,g=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*g;a.y=
 this.n21*b+this.n22*c+this.n23*d+this.n24*g;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*g;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*g;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*
-a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,g=this.n21,e=this.n22,h=this.n23,i=this.n24,k=this.n31,l=this.n32,j=this.n33,n=this.n34,m=this.n41,o=this.n42,p=this.n43,r=this.n44;return d*h*l*m-c*i*l*m-d*e*j*m+b*i*j*m+c*e*n*m-b*h*n*m-d*h*k*o+c*i*k*o+d*g*j*o-a*i*j*o-c*g*n*o+a*h*n*o+d*e*k*p-b*i*k*p-d*g*l*p+a*i*l*p+b*g*n*p-a*e*n*p-c*e*k*r+b*h*k*r+c*g*l*r-a*h*l*r-
-b*g*j*r+a*e*j*r},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n34=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;
+a.x+this.n32*a.y+this.n33*a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,g=this.n21,f=this.n22,h=this.n23,i=this.n24,k=this.n31,l=this.n32,j=this.n33,n=this.n34,m=this.n41,o=this.n42,p=this.n43,r=this.n44;return d*h*l*m-c*i*l*m-d*f*j*m+b*i*j*m+c*f*n*m-b*h*n*m-d*h*k*o+c*i*k*o+d*g*j*o-a*i*j*o-c*g*n*o+a*h*n*o+d*f*k*p-b*i*k*p-d*g*l*p+a*i*l*p+b*g*n*p-a*f*n*p-c*f*k*r+b*h*k*r+c*g*l*r-a*h*l*r-
+b*g*j*r+a*f*j*r},transpose:function(){var a;a=this.n21;this.n21=this.n12;this.n12=a;a=this.n31;this.n31=this.n13;this.n13=a;a=this.n32;this.n32=this.n23;this.n23=a;a=this.n41;this.n41=this.n14;this.n14=a;a=this.n42;this.n42=this.n24;this.n24=a;a=this.n43;this.n43=this.n34;this.n34=a;return this},clone:function(){var a=new THREE.Matrix4;a.n11=this.n11;a.n12=this.n12;a.n13=this.n13;a.n14=this.n14;a.n21=this.n21;a.n22=this.n22;a.n23=this.n23;a.n24=this.n24;a.n31=this.n31;a.n32=this.n32;a.n33=this.n33;
 a.n34=this.n34;a.n41=this.n41;a.n42=this.n42;a.n43=this.n43;a.n44=this.n44;return a},flatten:function(){this.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(a){a[0]=
 this.n11;a[1]=this.n21;a[2]=this.n31;a[3]=this.n41;a[4]=this.n12;a[5]=this.n22;a[6]=this.n32;a[7]=this.n42;a[8]=this.n13;a[9]=this.n23;a[10]=this.n33;a[11]=this.n43;a[12]=this.n14;a[13]=this.n24;a[14]=this.n34;a[15]=this.n44;return a},flattenToArrayOffset:function(a,b){a[b]=this.n11;a[b+1]=this.n21;a[b+2]=this.n31;a[b+3]=this.n41;a[b+4]=this.n12;a[b+5]=this.n22;a[b+6]=this.n32;a[b+7]=this.n42;a[b+8]=this.n13;a[b+9]=this.n23;a[b+10]=this.n33;a[b+11]=this.n43;a[b+12]=this.n14;a[b+13]=this.n24;a[b+14]=
 this.n34;a[b+15]=this.n44;return a},setTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},setScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},setRotationX:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},setRotationY:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},setRotationZ:function(a){var b=Math.cos(a),a=Math.sin(a);this.set(b,-a,0,
-0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),g=1-c,e=a.x,h=a.y,i=a.z,k=g*e,l=g*h;this.set(k*e+c,k*h-d*i,k*i+d*h,0,k*h+d*i,l*h+c,l*i-d*e,0,k*i-d*h,l*i+d*e,g*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12,
-this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,d=a.n13,g=a.n14,e=a.n21,h=a.n22,i=a.n23,k=a.n24,l=a.n31,j=a.n32,n=a.n33,m=a.n34,o=a.n41,p=a.n42,r=a.n43,t=a.n44;this.n11=i*m*p-k*n*p+k*j*r-h*m*r-i*j*t+h*n*t;this.n12=g*n*p-d*m*p-g*j*r+c*m*r+d*j*t-c*n*t;this.n13=d*k*p-g*i*p+g*h*r-c*k*r-d*h*t+c*i*t;this.n14=g*i*j-d*k*j-g*h*n+c*k*n+d*h*m-c*i*m;this.n21=k*n*o-i*m*o-k*l*r+e*m*r+i*l*t-e*n*t;this.n22=d*m*o-g*n*o+
-g*l*r-b*m*r-d*l*t+b*n*t;this.n23=g*i*o-d*k*o-g*e*r+b*k*r+d*e*t-b*i*t;this.n24=d*k*l-g*i*l+g*e*n-b*k*n-d*e*m+b*i*m;this.n31=h*m*o-k*j*o+k*l*p-e*m*p-h*l*t+e*j*t;this.n32=g*j*o-c*m*o-g*l*p+b*m*p+c*l*t-b*j*t;this.n33=c*k*o-g*h*o+g*e*p-b*k*p-c*e*t+b*h*t;this.n34=g*h*l-c*k*l-g*e*j+b*k*j+c*e*m-b*h*m;this.n41=i*j*o-h*n*o-i*l*p+e*n*p+h*l*r-e*j*r;this.n42=c*n*o-d*j*o+d*l*p-b*n*p-c*l*r+b*j*r;this.n43=d*h*o-c*i*o-d*e*p+b*i*p+c*e*r-b*h*r;this.n44=c*i*l-d*h*l+d*e*j-b*i*j-c*e*n+b*h*n;this.multiplyScalar(1/a.determinant());
-return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,g=a.z,e=Math.cos(c),c=Math.sin(c),h=Math.cos(d),d=Math.sin(d),i=Math.cos(g),g=Math.sin(g);switch(b){case "YXZ":var k=h*i,l=h*g,j=d*i,n=d*g;this.n11=k+n*c;this.n12=j*c-l;this.n13=e*d;this.n21=e*g;this.n22=e*i;this.n23=-c;this.n31=l*c-j;this.n32=n+k*c;this.n33=e*h;break;case "ZXY":k=h*i;l=h*g;j=d*i;n=d*g;this.n11=k-n*c;this.n12=-e*g;this.n13=j+l*c;this.n21=l+j*c;this.n22=e*i;this.n23=n-k*c;this.n31=-e*d;this.n32=c;this.n33=e*h;break;case "ZYX":k=
-e*i;l=e*g;j=c*i;n=c*g;this.n11=h*i;this.n12=j*d-l;this.n13=k*d+n;this.n21=h*g;this.n22=n*d+k;this.n23=l*d-j;this.n31=-d;this.n32=c*h;this.n33=e*h;break;case "YZX":k=e*h;l=e*d;j=c*h;n=c*d;this.n11=h*i;this.n12=n-k*g;this.n13=j*g+l;this.n21=g;this.n22=e*i;this.n23=-c*i;this.n31=-d*i;this.n32=l*g+j;this.n33=k-n*g;break;case "XZY":k=e*h;l=e*d;j=c*h;n=c*d;this.n11=h*i;this.n12=-g;this.n13=d*i;this.n21=k*g+n;this.n22=e*i;this.n23=l*g-j;this.n31=j*g-l;this.n32=c*i;this.n33=n*g+k;break;default:k=e*i,l=e*
-g,j=c*i,n=c*g,this.n11=h*i,this.n12=-h*g,this.n13=d,this.n21=l+j*d,this.n22=k-n*d,this.n23=-c*h,this.n31=n-k*d,this.n32=j+l*d,this.n33=e*h}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,g=a.w,e=b+b,h=c+c,i=d+d,a=b*e,k=b*h,b=b*i,l=c*h,c=c*i,d=d*i,e=g*e,h=g*h,g=g*i;this.n11=1-(l+d);this.n12=k-g;this.n13=b+h;this.n21=k+g;this.n22=1-(a+d);this.n23=c-e;this.n31=b-h;this.n32=c+e;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=
-a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,g=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);g.setScale(c.x,c.y,c.z);this.multiply(d,g);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,g=THREE.Matrix4.__v2,e=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);g.set(this.n12,this.n22,this.n32);e.set(this.n13,
-this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();c.y=g.length();c.z=e.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
+0,a,b,0,0,0,0,1,0,0,0,0,1);return this},setRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),g=1-c,f=a.x,h=a.y,i=a.z,k=g*f,l=g*h;this.set(k*f+c,k*h-d*i,k*i+d*h,0,k*h+d*i,l*h+c,l*i-d*f,0,k*i-d*h,l*i+d*f,g*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},getPosition:function(){return THREE.Matrix4.__v1.set(this.n14,this.n24,this.n34)},getColumnX:function(){return THREE.Matrix4.__v1.set(this.n11,this.n21,this.n31)},getColumnY:function(){return THREE.Matrix4.__v1.set(this.n12,
+this.n22,this.n32)},getColumnZ:function(){return THREE.Matrix4.__v1.set(this.n13,this.n23,this.n33)},getInverse:function(a){var b=a.n11,c=a.n12,d=a.n13,g=a.n14,f=a.n21,h=a.n22,i=a.n23,k=a.n24,l=a.n31,j=a.n32,n=a.n33,m=a.n34,o=a.n41,p=a.n42,r=a.n43,t=a.n44;this.n11=i*m*p-k*n*p+k*j*r-h*m*r-i*j*t+h*n*t;this.n12=g*n*p-d*m*p-g*j*r+c*m*r+d*j*t-c*n*t;this.n13=d*k*p-g*i*p+g*h*r-c*k*r-d*h*t+c*i*t;this.n14=g*i*j-d*k*j-g*h*n+c*k*n+d*h*m-c*i*m;this.n21=k*n*o-i*m*o-k*l*r+f*m*r+i*l*t-f*n*t;this.n22=d*m*o-g*n*o+
+g*l*r-b*m*r-d*l*t+b*n*t;this.n23=g*i*o-d*k*o-g*f*r+b*k*r+d*f*t-b*i*t;this.n24=d*k*l-g*i*l+g*f*n-b*k*n-d*f*m+b*i*m;this.n31=h*m*o-k*j*o+k*l*p-f*m*p-h*l*t+f*j*t;this.n32=g*j*o-c*m*o-g*l*p+b*m*p+c*l*t-b*j*t;this.n33=c*k*o-g*h*o+g*f*p-b*k*p-c*f*t+b*h*t;this.n34=g*h*l-c*k*l-g*f*j+b*k*j+c*f*m-b*h*m;this.n41=i*j*o-h*n*o-i*l*p+f*n*p+h*l*r-f*j*r;this.n42=c*n*o-d*j*o+d*l*p-b*n*p-c*l*r+b*j*r;this.n43=d*h*o-c*i*o-d*f*p+b*i*p+c*f*r-b*h*r;this.n44=c*i*l-d*h*l+d*f*j-b*i*j-c*f*n+b*h*n;this.multiplyScalar(1/a.determinant());
+return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,g=a.z,f=Math.cos(c),c=Math.sin(c),h=Math.cos(d),d=Math.sin(d),i=Math.cos(g),g=Math.sin(g);switch(b){case "YXZ":var k=h*i,l=h*g,j=d*i,n=d*g;this.n11=k+n*c;this.n12=j*c-l;this.n13=f*d;this.n21=f*g;this.n22=f*i;this.n23=-c;this.n31=l*c-j;this.n32=n+k*c;this.n33=f*h;break;case "ZXY":k=h*i;l=h*g;j=d*i;n=d*g;this.n11=k-n*c;this.n12=-f*g;this.n13=j+l*c;this.n21=l+j*c;this.n22=f*i;this.n23=n-k*c;this.n31=-f*d;this.n32=c;this.n33=f*h;break;case "ZYX":k=
+f*i;l=f*g;j=c*i;n=c*g;this.n11=h*i;this.n12=j*d-l;this.n13=k*d+n;this.n21=h*g;this.n22=n*d+k;this.n23=l*d-j;this.n31=-d;this.n32=c*h;this.n33=f*h;break;case "YZX":k=f*h;l=f*d;j=c*h;n=c*d;this.n11=h*i;this.n12=n-k*g;this.n13=j*g+l;this.n21=g;this.n22=f*i;this.n23=-c*i;this.n31=-d*i;this.n32=l*g+j;this.n33=k-n*g;break;case "XZY":k=f*h;l=f*d;j=c*h;n=c*d;this.n11=h*i;this.n12=-g;this.n13=d*i;this.n21=k*g+n;this.n22=f*i;this.n23=l*g-j;this.n31=j*g-l;this.n32=c*i;this.n33=n*g+k;break;default:k=f*i,l=f*
+g,j=c*i,n=c*g,this.n11=h*i,this.n12=-h*g,this.n13=d,this.n21=l+j*d,this.n22=k-n*d,this.n23=-c*h,this.n31=n-k*d,this.n32=j+l*d,this.n33=f*h}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,g=a.w,f=b+b,h=c+c,i=d+d,a=b*f,k=b*h,b=b*i,l=c*h,c=c*i,d=d*i,f=g*f,h=g*h,g=g*i;this.n11=1-(l+d);this.n12=k-g;this.n13=b+h;this.n21=k+g;this.n22=1-(a+d);this.n23=c-f;this.n31=b-h;this.n32=c+f;this.n33=1-(a+l);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=
+a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,g=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);g.setScale(c.x,c.y,c.z);this.multiply(d,g);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,g=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);g.set(this.n12,this.n22,this.n32);f.set(this.n13,
+this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();c.y=g.length();c.z=f.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
 return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this},rotateByAxis:function(a,b){if(1===a.x&&0===a.y&&0===a.z)return this.rotateX(b);if(0===a.x&&1===a.y&&0===a.z)return this.rotateY(b);if(0===a.x&&0===a.y&&1===
-a.z)return this.rotateZ(b);var c=a.x,d=a.y,g=a.z,e=Math.sqrt(c*c+d*d+g*g),c=c/e,d=d/e,g=g/e,e=c*c,h=d*d,i=g*g,k=Math.cos(b),l=Math.sin(b),j=1-k,n=c*d*j,m=c*g*j,j=d*g*j,c=c*l,o=d*l,l=g*l,g=e+(1-e)*k,e=n+l,d=m-o,n=n-l,h=h+(1-h)*k,l=j+c,m=m+o,j=j-c,i=i+(1-i)*k,k=this.n11,c=this.n21,o=this.n31,p=this.n41,r=this.n12,t=this.n22,v=this.n32,F=this.n42,A=this.n13,K=this.n23,y=this.n33,J=this.n43;this.n11=g*k+e*r+d*A;this.n21=g*c+e*t+d*K;this.n31=g*o+e*v+d*y;this.n41=g*p+e*F+d*J;this.n12=n*k+h*r+l*A;this.n22=
-n*c+h*t+l*K;this.n32=n*o+h*v+l*y;this.n42=n*p+h*F+l*J;this.n13=m*k+j*r+i*A;this.n23=m*c+j*t+i*K;this.n33=m*o+j*v+i*y;this.n43=m*p+j*F+i*J;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,g=this.n42,e=this.n13,h=this.n23,i=this.n33,k=this.n43,l=Math.cos(a),a=Math.sin(a);this.n12=l*b+a*e;this.n22=l*c+a*h;this.n32=l*d+a*i;this.n42=l*g+a*k;this.n13=l*e-a*b;this.n23=l*h-a*c;this.n33=l*i-a*d;this.n43=l*k-a*g;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,g=this.n41,
-e=this.n13,h=this.n23,i=this.n33,k=this.n43,l=Math.cos(a),a=Math.sin(a);this.n11=l*b-a*e;this.n21=l*c-a*h;this.n31=l*d-a*i;this.n41=l*g-a*k;this.n13=l*e+a*b;this.n23=l*h+a*c;this.n33=l*i+a*d;this.n43=l*k+a*g;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,g=this.n41,e=this.n12,h=this.n22,i=this.n32,k=this.n42,l=Math.cos(a),a=Math.sin(a);this.n11=l*b+a*e;this.n21=l*c+a*h;this.n31=l*d+a*i;this.n41=l*g+a*k;this.n12=l*e-a*b;this.n22=l*h-a*c;this.n32=l*i-a*d;this.n42=l*k-a*g;return this},
+a.z)return this.rotateZ(b);var c=a.x,d=a.y,g=a.z,f=Math.sqrt(c*c+d*d+g*g),c=c/f,d=d/f,g=g/f,f=c*c,h=d*d,i=g*g,k=Math.cos(b),l=Math.sin(b),j=1-k,n=c*d*j,m=c*g*j,j=d*g*j,c=c*l,o=d*l,l=g*l,g=f+(1-f)*k,f=n+l,d=m-o,n=n-l,h=h+(1-h)*k,l=j+c,m=m+o,j=j-c,i=i+(1-i)*k,k=this.n11,c=this.n21,o=this.n31,p=this.n41,r=this.n12,t=this.n22,y=this.n32,F=this.n42,I=this.n13,A=this.n23,v=this.n33,J=this.n43;this.n11=g*k+f*r+d*I;this.n21=g*c+f*t+d*A;this.n31=g*o+f*y+d*v;this.n41=g*p+f*F+d*J;this.n12=n*k+h*r+l*I;this.n22=
+n*c+h*t+l*A;this.n32=n*o+h*y+l*v;this.n42=n*p+h*F+l*J;this.n13=m*k+j*r+i*I;this.n23=m*c+j*t+i*A;this.n33=m*o+j*y+i*v;this.n43=m*p+j*F+i*J;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,g=this.n42,f=this.n13,h=this.n23,i=this.n33,k=this.n43,l=Math.cos(a),a=Math.sin(a);this.n12=l*b+a*f;this.n22=l*c+a*h;this.n32=l*d+a*i;this.n42=l*g+a*k;this.n13=l*f-a*b;this.n23=l*h-a*c;this.n33=l*i-a*d;this.n43=l*k-a*g;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,g=this.n41,
+f=this.n13,h=this.n23,i=this.n33,k=this.n43,l=Math.cos(a),a=Math.sin(a);this.n11=l*b-a*f;this.n21=l*c-a*h;this.n31=l*d-a*i;this.n41=l*g-a*k;this.n13=l*f+a*b;this.n23=l*h+a*c;this.n33=l*i+a*d;this.n43=l*k+a*g;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,g=this.n41,f=this.n12,h=this.n22,i=this.n32,k=this.n42,l=Math.cos(a),a=Math.sin(a);this.n11=l*b+a*f;this.n21=l*c+a*h;this.n31=l*d+a*i;this.n41=l*g+a*k;this.n12=l*f-a*b;this.n22=l*h-a*c;this.n32=l*i-a*d;this.n42=l*k-a*g;return this},
 translate:function(a){var b=a.x,c=a.y,a=a.z;this.n14=this.n11*b+this.n12*c+this.n13*a+this.n14;this.n24=this.n21*b+this.n22*c+this.n23*a+this.n24;this.n34=this.n31*b+this.n32*c+this.n33*a+this.n34;this.n44=this.n41*b+this.n42*c+this.n43*a+this.n44;return this}};
-THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,e=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,j=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*h+a.n31*l;if(0===a)return null;a=1/a;c[0]=a*d;c[1]=a*g;c[2]=a*e;c[3]=a*h;c[4]=a*i;c[5]=a*k;c[6]=a*l;c[7]=a*j;c[8]=a*n;return b};
-THREE.Matrix4.makeFrustum=function(a,b,c,d,g,e){var h;h=new THREE.Matrix4;h.n11=2*g/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*g/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(e+g)/(e-g);h.n34=-2*e*g/(e-g);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var g,a=c*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,g,e){var h,i,k,l;h=new THREE.Matrix4;i=b-a;k=c-d;l=e-g;h.n11=2/i;h.n12=0;h.n13=0;h.n14=-((b+a)/i);h.n21=0;h.n22=2/k;h.n23=0;h.n24=-((c+d)/k);h.n31=0;h.n32=0;h.n33=-2/l;h.n34=-((e+g)/l);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};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;
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,g=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,h=-a.n33*a.n12+a.n32*a.n13,i=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,l=a.n23*a.n12-a.n22*a.n13,j=-a.n23*a.n11+a.n21*a.n13,n=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*h+a.n31*l;if(0===a)return null;a=1/a;c[0]=a*d;c[1]=a*g;c[2]=a*f;c[3]=a*h;c[4]=a*i;c[5]=a*k;c[6]=a*l;c[7]=a*j;c[8]=a*n;return b};
+THREE.Matrix4.makeFrustum=function(a,b,c,d,g,f){var h;h=new THREE.Matrix4;h.n11=2*g/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*g/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(f+g)/(f-g);h.n34=-2*f*g/(f-g);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var g,a=c*Math.tan(a*Math.PI/360);g=-a;return THREE.Matrix4.makeFrustum(g*b,a*b,g,a,c,d)};
+THREE.Matrix4.makeOrtho=function(a,b,c,d,g,f){var h,i,k,l;h=new THREE.Matrix4;i=b-a;k=c-d;l=f-g;h.n11=2/i;h.n12=0;h.n13=0;h.n14=-((b+a)/i);h.n21=0;h.n22=2/k;h.n23=0;h.n24=-((c+d)/k);h.n31=0;h.n32=0;h.n33=-2/l;h.n34=-((f+g)/l);h.n41=0;h.n42=0;h.n43=0;h.n44=1;return h};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;
 THREE.Object3D=function(){this.name="";this.id=THREE.Object3DCount++;this.parent=void 0;this.children=[];this.up=new THREE.Vector3(0,1,0);this.position=new THREE.Vector3;this.rotation=new THREE.Vector3;this.eulerOrder="XYZ";this.scale=new THREE.Vector3(1,1,1);this.flipSided=this.doubleSided=this.dynamic=!1;this.renderDepth=null;this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixRotationWorld=new THREE.Matrix4;this.matrixWorldNeedsUpdate=this.matrixAutoUpdate=
 !0;this.quaternion=new THREE.Quaternion;this.useQuaternion=!1;this.boundRadius=0;this.boundRadiusScale=1;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this._vector=new THREE.Vector3};
 THREE.Object3D.prototype={constructor:THREE.Object3D,translate:function(a,b){this.matrix.rotateAxis(b);this.position.addSelf(b.multiplyScalar(a))},translateX:function(a){this.translate(a,this._vector.set(1,0,0))},translateY:function(a){this.translate(a,this._vector.set(0,1,0))},translateZ:function(a){this.translate(a,this._vector.set(0,0,1))},lookAt:function(a){this.matrix.lookAt(a,this.position,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)},add:function(a){if(-1===
 this.children.indexOf(a)){void 0!==a.parent&&a.parent.remove(a);a.parent=this;this.children.push(a);for(var b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.addObject(a)}},remove:function(a){var b=this.children.indexOf(a);if(-1!==b){a.parent=void 0;this.children.splice(b,1);for(b=this;void 0!==b.parent;)b=b.parent;void 0!==b&&b instanceof THREE.Scene&&b.removeObject(a)}},getChildByName:function(a,b){var c,d,g;for(c=0,d=this.children.length;c<d;c++){g=this.children[c];if(g.name===
 a||b&&(g=g.getChildByName(a,b),void 0!==g))return g}},updateMatrix:function(){this.matrix.setPosition(this.position);this.useQuaternion?this.matrix.setRotationFromQuaternion(this.quaternion):this.matrix.setRotationFromEuler(this.rotation,this.eulerOrder);if(1!==this.scale.x||1!==this.scale.y||1!==this.scale.z)this.matrix.scale(this.scale),this.boundRadiusScale=Math.max(this.scale.x,Math.max(this.scale.y,this.scale.z));this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){this.matrixAutoUpdate&&
 this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)}};THREE.Object3DCount=0;THREE.Quaternion=function(a,b,c,d){this.set(a||0,b||0,c||0,void 0!==d?d:1)};
-THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,g=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-g),g=Math.sin(-g),e=Math.cos(c),c=Math.sin(c),h=a*b,i=d*g;this.w=h*e-i*c;this.x=h*c+i*e;this.y=d*b*e+a*g*c;this.z=a*g*e-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
+THREE.Quaternion.prototype={constructor:THREE.Quaternion,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this},setFromEuler:function(a){var b=Math.PI/360,c=a.x*b,d=a.y*b,g=a.z*b,a=Math.cos(d),d=Math.sin(d),b=Math.cos(-g),g=Math.sin(-g),f=Math.cos(c),c=Math.sin(c),h=a*b,i=d*g;this.w=h*f-i*c;this.x=h*c+i*f;this.y=d*b*f+a*g*c;this.z=a*g*f-d*b*c;return this},setFromAxisAngle:function(a,b){var c=b/2,d=Math.sin(c);
 this.x=a.x*d;this.y=a.y*d;this.z=a.z*d;this.w=Math.cos(c);return this},setFromRotationMatrix:function(a){var b=Math.pow(a.determinant(),1/3);this.w=Math.sqrt(Math.max(0,b+a.n11+a.n22+a.n33))/2;this.x=Math.sqrt(Math.max(0,b+a.n11-a.n22-a.n33))/2;this.y=Math.sqrt(Math.max(0,b-a.n11+a.n22-a.n33))/2;this.z=Math.sqrt(Math.max(0,b-a.n11-a.n22+a.n33))/2;this.x=0>a.n32-a.n23?-Math.abs(this.x):Math.abs(this.x);this.y=0>a.n13-a.n31?-Math.abs(this.y):Math.abs(this.y);this.z=0>a.n21-a.n12?-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 a=Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w);0===a?this.w=this.z=this.y=this.x=0:(a=1/a,this.x*=a,this.y*=a,this.z*=a,this.w*=a);return this},multiplySelf:function(a){var b=
-this.x,c=this.y,d=this.z,g=this.w,e=a.x,h=a.y,i=a.z,a=a.w;this.x=b*a+g*e+c*i-d*h;this.y=c*a+g*h+d*e-b*i;this.z=d*a+g*i+b*h-c*e;this.w=g*a-b*e-c*h-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,g=a.z,e=this.x,h=this.y,i=this.z,k=this.w,l=k*c+h*g-i*d,j=k*d+i*c-e*g,n=k*g+e*d-h*c,c=-e*
-c-h*d-i*g;b.x=l*k+c*-e+j*-i-n*-h;b.y=j*k+c*-h+n*-e-l*-i;b.z=n*k+c*-i+l*-h-j*-e;return b}};
-THREE.Quaternion.slerp=function(a,b,c,d){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>g?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,g=-g):c.copy(b);if(1<=Math.abs(g))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var e=Math.acos(g),g=Math.sqrt(1-g*g);if(0.0010>Math.abs(g))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*e)/g;d=Math.sin(d*e)/g;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
-THREE.Face3=function(a,b,c,d,g,e){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=e;this.centroid=new THREE.Vector3};
-THREE.Face4=function(a,b,c,d,g,e,h){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=h;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
+this.x,c=this.y,d=this.z,g=this.w,f=a.x,h=a.y,i=a.z,a=a.w;this.x=b*a+g*f+c*i-d*h;this.y=c*a+g*h+d*f-b*i;this.z=d*a+g*i+b*h-c*f;this.w=g*a-b*f-c*h-d*i;return this},multiply:function(a,b){this.x=a.x*b.w+a.y*b.z-a.z*b.y+a.w*b.x;this.y=-a.x*b.z+a.y*b.w+a.z*b.x+a.w*b.y;this.z=a.x*b.y-a.y*b.x+a.z*b.w+a.w*b.z;this.w=-a.x*b.x-a.y*b.y-a.z*b.z+a.w*b.w;return this},multiplyVector3:function(a,b){b||(b=a);var c=a.x,d=a.y,g=a.z,f=this.x,h=this.y,i=this.z,k=this.w,l=k*c+h*g-i*d,j=k*d+i*c-f*g,n=k*g+f*d-h*c,c=-f*
+c-h*d-i*g;b.x=l*k+c*-f+j*-i-n*-h;b.y=j*k+c*-h+n*-f-l*-i;b.z=n*k+c*-i+l*-h-j*-f;return b}};
+THREE.Quaternion.slerp=function(a,b,c,d){var g=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>g?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,g=-g):c.copy(b);if(1<=Math.abs(g))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(g),g=Math.sqrt(1-g*g);if(0.0010>Math.abs(g))return c.w=0.5*(a.w+b.w),c.x=0.5*(a.x+b.x),c.y=0.5*(a.y+b.y),c.z=0.5*(a.z+b.z),c;b=Math.sin((1-d)*f)/g;d=Math.sin(d*f)/g;c.w=a.w*b+c.w*d;c.x=a.x*b+c.x*d;c.y=a.y*b+c.y*d;c.z=a.z*b+c.z*d;return c};THREE.Vertex=function(a){this.position=a||new THREE.Vector3};
+THREE.Face3=function(a,b,c,d,g,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=d instanceof Array?d:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
+THREE.Face4=function(a,b,c,d,g,f,h){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=g instanceof THREE.Vector3?g:new THREE.Vector3;this.vertexNormals=g instanceof Array?g:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=h;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
 THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.dynamic=this.hasTangents=!1};
-THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a,new THREE.Vector3(1,1,1));for(var c=0,d=this.vertices.length;c<d;c++)a.multiplyVector3(this.vertices[c].position);c=0;for(d=this.faces.length;c<d;c++){var g=this.faces[c];b.multiplyVector3(g.normal);for(var e=0,h=g.vertexNormals.length;e<h;e++)b.multiplyVector3(g.vertexNormals[e]);a.multiplyVector3(g.centroid)}},computeCentroids:function(){var a,b,c;for(a=0,b=this.faces.length;a<
+THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){var b=new THREE.Matrix4;b.extractRotation(a,new THREE.Vector3(1,1,1));for(var c=0,d=this.vertices.length;c<d;c++)a.multiplyVector3(this.vertices[c].position);c=0;for(d=this.faces.length;c<d;c++){var g=this.faces[c];b.multiplyVector3(g.normal);for(var f=0,h=g.vertexNormals.length;f<h;f++)b.multiplyVector3(g.vertexNormals[f]);a.multiplyVector3(g.centroid)}},computeCentroids:function(){var a,b,c;for(a=0,b=this.faces.length;a<
 b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.divideScalar(3)):c instanceof THREE.Face4&&(c.centroid.addSelf(this.vertices[c.a].position),c.centroid.addSelf(this.vertices[c.b].position),c.centroid.addSelf(this.vertices[c.c].position),c.centroid.addSelf(this.vertices[c.d].position),c.centroid.divideScalar(4))},computeFaceNormals:function(){var a,
-b,c,d,g,e,h=new THREE.Vector3,i=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],d=this.vertices[c.a],g=this.vertices[c.b],e=this.vertices[c.c],h.sub(e.position,g.position),i.sub(d.position,g.position),h.crossSelf(i),h.isZero()||h.normalize(),c.normal.copy(h)},computeVertexNormals:function(){var a,b,c,d;if(void 0===this.__tmpVertices){d=this.__tmpVertices=Array(this.vertices.length);for(a=0,b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)if(c=
+b,c,d,g,f,h=new THREE.Vector3,i=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],d=this.vertices[c.a],g=this.vertices[c.b],f=this.vertices[c.c],h.sub(f.position,g.position),i.sub(d.position,g.position),h.crossSelf(i),h.isZero()||h.normalize(),c.normal.copy(h)},computeVertexNormals:function(){var a,b,c,d;if(void 0===this.__tmpVertices){d=this.__tmpVertices=Array(this.vertices.length);for(a=0,b=this.vertices.length;a<b;a++)d[a]=new THREE.Vector3;for(a=0,b=this.faces.length;a<b;a++)if(c=
 this.faces[a],c instanceof THREE.Face3)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];else if(c instanceof THREE.Face4)c.vertexNormals=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3]}else{d=this.__tmpVertices;for(a=0,b=this.vertices.length;a<b;a++)d[a].set(0,0,0)}for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(d[c.a].addSelf(c.normal),d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal)):c instanceof THREE.Face4&&(d[c.a].addSelf(c.normal),
 d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));for(a=0,b=this.vertices.length;a<b;a++)d[a].normalize();for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],c instanceof THREE.Face3?(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c])):c instanceof THREE.Face4&&(c.vertexNormals[0].copy(d[c.a]),c.vertexNormals[1].copy(d[c.b]),c.vertexNormals[2].copy(d[c.c]),c.vertexNormals[3].copy(d[c.d]))},computeTangents:function(){function a(a,
-b,c,d,g,e,z){i=a.vertices[b].position;k=a.vertices[c].position;l=a.vertices[d].position;j=h[g];n=h[e];m=h[z];o=k.x-i.x;p=l.x-i.x;r=k.y-i.y;t=l.y-i.y;v=k.z-i.z;F=l.z-i.z;A=n.u-j.u;K=m.u-j.u;y=n.v-j.v;J=m.v-j.v;H=1/(A*J-K*y);L.set((J*o-y*p)*H,(J*r-y*t)*H,(J*v-y*F)*H);ka.set((A*p-K*o)*H,(A*t-K*r)*H,(A*F-K*v)*H);M[b].addSelf(L);M[c].addSelf(L);M[d].addSelf(L);G[b].addSelf(ka);G[c].addSelf(ka);G[d].addSelf(ka)}var b,c,d,g,e,h,i,k,l,j,n,m,o,p,r,t,v,F,A,K,y,J,H,I,M=[],G=[],L=new THREE.Vector3,ka=new THREE.Vector3,
-T=new THREE.Vector3,la=new THREE.Vector3,ca=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)M[b]=new THREE.Vector3,G[b]=new THREE.Vector3;for(b=0,c=this.faces.length;b<c;b++)e=this.faces[b],h=this.faceVertexUvs[0][b],e instanceof THREE.Face3?a(this,e.a,e.b,e.c,0,1,2):e instanceof THREE.Face4&&(a(this,e.a,e.b,e.c,0,1,2),a(this,e.a,e.b,e.d,0,1,3));var z=["a","b","c","d"];for(b=0,c=this.faces.length;b<c;b++){e=this.faces[b];for(d=0;d<e.vertexNormals.length;d++)ca.copy(e.vertexNormals[d]),g=
-e[z[d]],I=M[g],T.copy(I),T.subSelf(ca.multiplyScalar(ca.dot(I))).normalize(),la.cross(e.vertexNormals[d],I),g=la.dot(G[g]),g=0>g?-1:1,e.vertexTangents[d]=new THREE.Vector4(T.x,T.y,T.z,g)}this.hasTangents=!0},computeBoundingBox:function(){if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,g=this.vertices.length;d<
-g;d++){a=this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a,b=0,c=0,d=this.vertices.length;c<d;c++)a=this.vertices[c].position.length(),a>b&&(b=a);this.boundingSphere={radius:b}},mergeVertices:function(){var a={},b=[],c=[],d,g=Math.pow(10,4),e,h;for(e=0,h=this.vertices.length;e<h;e++)d=this.vertices[e].position,d=[Math.round(d.x*g),Math.round(d.y*g),
-Math.round(d.z*g)].join("_"),void 0===a[d]?(a[d]=e,b.push(this.vertices[e]),c[e]=b.length-1):c[e]=c[a[d]];for(e=0,h=this.faces.length;e<h;e++)if(a=this.faces[e],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
-THREE.Spline=function(a){function b(a,b,c,d,g,e,h){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*h+(-3*(b-c)-2*a-d)*e+a*g+b}this.points=a;var c=[],d={x:0,y:0,z:0},g,e,h,i,k,l,j,n,m;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){g=(this.points.length-1)*a;e=Math.floor(g);h=g-e;c[0]=0===e?e:e-1;c[1]=e;c[2]=e>this.points.length-2?e:e+1;c[3]=e>this.points.length-3?e:e+2;l=this.points[c[0]];j=this.points[c[1]];
-n=this.points[c[2]];m=this.points[c[3]];i=h*h;k=h*i;d.x=b(l.x,j.x,n.x,m.x,h,i,k);d.y=b(l.y,j.y,n.y,m.y,h,i,k);d.z=b(l.z,j.z,n.z,m.z,h,i,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,g=b=b=0,e=new THREE.Vector3,h=new THREE.Vector3,i=[],j=0;i[0]=0;a||(a=100);c=this.points.length*a;e.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,d=this.getPoint(b),h.copy(d),j+=h.distanceTo(e),
-e.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=g&&(i[b]=j,g=b);i[i.length]=j;return{chunks:i,total:j}};this.reparametrizeByArcLength=function(a){var b,c,d,g,e,h,i=[],j=new THREE.Vector3,n=this.getLength();i.push(j.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=n.chunks[b]-n.chunks[b-1];h=Math.ceil(a*c/n.total);g=(b-1)/(this.points.length-1);e=b/(this.points.length-1);for(c=1;c<h-1;c++)d=g+c*(1/h)*(e-g),d=this.getPoint(d),i.push(j.copy(d).clone());i.push(j.copy(this.points[b]).clone())}this.points=
+b,c,e,d,g,f){i=a.vertices[b].position;k=a.vertices[c].position;l=a.vertices[e].position;j=h[d];n=h[g];m=h[f];o=k.x-i.x;p=l.x-i.x;r=k.y-i.y;t=l.y-i.y;y=k.z-i.z;F=l.z-i.z;I=n.u-j.u;A=m.u-j.u;v=n.v-j.v;J=m.v-j.v;K=1/(I*J-A*v);L.set((J*o-v*p)*K,(J*r-v*t)*K,(J*y-v*F)*K);V.set((I*p-A*o)*K,(I*t-A*r)*K,(I*F-A*y)*K);M[b].addSelf(L);M[c].addSelf(L);M[e].addSelf(L);H[b].addSelf(V);H[c].addSelf(V);H[e].addSelf(V)}var b,c,d,g,f,h,i,k,l,j,n,m,o,p,r,t,y,F,I,A,v,J,K,G,M=[],H=[],L=new THREE.Vector3,V=new THREE.Vector3,
+ga=new THREE.Vector3,oa=new THREE.Vector3,z=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)M[b]=new THREE.Vector3,H[b]=new THREE.Vector3;for(b=0,c=this.faces.length;b<c;b++)f=this.faces[b],h=this.faceVertexUvs[0][b],f instanceof THREE.Face3?a(this,f.a,f.b,f.c,0,1,2):f instanceof THREE.Face4&&(a(this,f.a,f.b,f.c,0,1,2),a(this,f.a,f.b,f.d,0,1,3));var e=["a","b","c","d"];for(b=0,c=this.faces.length;b<c;b++){f=this.faces[b];for(d=0;d<f.vertexNormals.length;d++)z.copy(f.vertexNormals[d]),g=f[e[d]],
+G=M[g],ga.copy(G),ga.subSelf(z.multiplyScalar(z.dot(G))).normalize(),oa.cross(f.vertexNormals[d],G),g=oa.dot(H[g]),g=0>g?-1:1,f.vertexTangents[d]=new THREE.Vector4(ga.x,ga.y,ga.z,g)}this.hasTangents=!0},computeBoundingBox:function(){if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox?(this.boundingBox.min.copy(a),this.boundingBox.max.copy(a)):this.boundingBox={min:a.clone(),max:a.clone()};for(var b=this.boundingBox.min,c=this.boundingBox.max,d=1,g=this.vertices.length;d<
+g;d++){a=this.vertices[d].position;if(a.x<b.x)b.x=a.x;else if(a.x>c.x)c.x=a.x;if(a.y<b.y)b.y=a.y;else if(a.y>c.y)c.y=a.y;if(a.z<b.z)b.z=a.z;else if(a.z>c.z)c.z=a.z}}},computeBoundingSphere:function(){for(var a,b=0,c=0,d=this.vertices.length;c<d;c++)a=this.vertices[c].position.length(),a>b&&(b=a);this.boundingSphere={radius:b}},mergeVertices:function(){var a={},b=[],c=[],d,g=Math.pow(10,4),f,h;for(f=0,h=this.vertices.length;f<h;f++)d=this.vertices[f].position,d=[Math.round(d.x*g),Math.round(d.y*g),
+Math.round(d.z*g)].join("_"),void 0===a[d]?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];for(f=0,h=this.faces.length;f<h;f++)if(a=this.faces[f],a instanceof THREE.Face3)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c];else if(a instanceof THREE.Face4)a.a=c[a.a],a.b=c[a.b],a.c=c[a.c],a.d=c[a.d];this.vertices=b}};THREE.GeometryCount=0;
+THREE.Spline=function(a){function b(a,b,c,d,g,f,h){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*h+(-3*(b-c)-2*a-d)*f+a*g+b}this.points=a;var c=[],d={x:0,y:0,z:0},g,f,h,i,k,l,j,n,m;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){g=(this.points.length-1)*a;f=Math.floor(g);h=g-f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>this.points.length-2?f:f+1;c[3]=f>this.points.length-3?f:f+2;l=this.points[c[0]];j=this.points[c[1]];
+n=this.points[c[2]];m=this.points[c[3]];i=h*h;k=h*i;d.x=b(l.x,j.x,n.x,m.x,h,i,k);d.y=b(l.y,j.y,n.y,m.y,h,i,k);d.z=b(l.z,j.z,n.z,m.z,h,i,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,g=b=b=0,f=new THREE.Vector3,h=new THREE.Vector3,i=[],j=0;i[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,d=this.getPoint(b),h.copy(d),j+=h.distanceTo(f),
+f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=g&&(i[b]=j,g=b);i[i.length]=j;return{chunks:i,total:j}};this.reparametrizeByArcLength=function(a){var b,c,d,g,f,h,i=[],j=new THREE.Vector3,n=this.getLength();i.push(j.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=n.chunks[b]-n.chunks[b-1];h=Math.ceil(a*c/n.total);g=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<h-1;c++)d=g+c*(1/h)*(f-g),d=this.getPoint(d),i.push(j.copy(d).clone());i.push(j.copy(this.points[b]).clone())}this.points=
 i}};THREE.Edge=function(a,b,c,d){this.vertices=[a,b];this.vertexIndices=[c,d];this.faces=[];this.faceIndices=[]};THREE.Camera=function(){if(arguments.length)return console.warn("DEPRECATED: Camera() is now PerspectiveCamera() or OrthographicCamera()."),new THREE.PerspectiveCamera(arguments[0],arguments[1],arguments[2],arguments[3]);THREE.Object3D.call(this);this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4;this.projectionMatrixInverse=new THREE.Matrix4};
-THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,g,e){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=void 0!==g?g:0.1;this.far=void 0!==e?e:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;
+THREE.Camera.prototype=new THREE.Object3D;THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.lookAt=function(a){this.matrix.lookAt(this.position,a,this.up);this.rotationAutoUpdate&&this.rotation.setRotationFromMatrix(this.matrix)};THREE.OrthographicCamera=function(a,b,c,d,g,f){THREE.Camera.call(this);this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=void 0!==g?g:0.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=new THREE.Camera;
 THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){this.projectionMatrix=THREE.Matrix4.makeOrtho(this.left,this.right,this.top,this.bottom,this.near,this.far)};THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.fov=void 0!==a?a:50;this.aspect=void 0!==b?b:1;this.near=void 0!==c?c:0.1;this.far=void 0!==d?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=new THREE.Camera;
-THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:43.25)/(2*a));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,g,e){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=g;this.height=e;this.updateProjectionMatrix()};
+THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:43.25)/(2*a));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,g,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=g;this.height=f;this.updateProjectionMatrix()};
 THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
 this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0};THREE.DirectionalLight.prototype=new THREE.Light;THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;THREE.PointLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,0,0);this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0};THREE.PointLight.prototype=new THREE.Light;
@@ -109,10 +109,10 @@ THREE.MeshShaderMaterial=function(a){console.warn("DEPRECATED: MeshShaderMateria
 THREE.ParticleBasicMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.map=void 0!==a.map?a.map:null;this.size=void 0!==a.size?a.size:1;this.sizeAttenuation=void 0!==a.sizeAttenuation?a.sizeAttenuation:!0;this.vertexColors=void 0!==a.vertexColors?a.vertexColors:!1;this.fog=void 0!==a.fog?a.fog:!0};THREE.ParticleBasicMaterial.prototype=new THREE.Material;THREE.ParticleBasicMaterial.prototype.constructor=THREE.ParticleBasicMaterial;
 THREE.ShaderMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.fragmentShader=void 0!==a.fragmentShader?a.fragmentShader:"void main() {}";this.vertexShader=void 0!==a.vertexShader?a.vertexShader:"void main() {}";this.uniforms=void 0!==a.uniforms?a.uniforms:{};this.attributes=a.attributes;this.shading=void 0!==a.shading?a.shading:THREE.SmoothShading;this.wireframe=void 0!==a.wireframe?a.wireframe:!1;this.wireframeLinewidth=void 0!==a.wireframeLinewidth?a.wireframeLinewidth:1;this.fog=void 0!==
 a.fog?a.fog:!1;this.lights=void 0!==a.lights?a.lights:!1;this.vertexColors=void 0!==a.vertexColors?a.vertexColors:!1;this.skinning=void 0!==a.skinning?a.skinning:!1;this.morphTargets=void 0!==a.morphTargets?a.morphTargets:!1};THREE.ShaderMaterial.prototype=new THREE.Material;THREE.ShaderMaterial.prototype.constructor=THREE.ShaderMaterial;
-THREE.Texture=function(a,b,c,d,g,e,h,i){this.id=THREE.TextureCount++;this.image=a;this.mapping=void 0!==b?b:new THREE.UVMapping;this.wrapS=void 0!==c?c:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==d?d:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==g?g:THREE.LinearFilter;this.minFilter=void 0!==e?e:THREE.LinearMipMapLinearFilter;this.format=void 0!==h?h:THREE.RGBAFormat;this.type=void 0!==i?i:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps=
+THREE.Texture=function(a,b,c,d,g,f,h,i){this.id=THREE.TextureCount++;this.image=a;this.mapping=void 0!==b?b:new THREE.UVMapping;this.wrapS=void 0!==c?c:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==d?d:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==g?g:THREE.LinearFilter;this.minFilter=void 0!==f?f:THREE.LinearMipMapLinearFilter;this.format=void 0!==h?h:THREE.RGBAFormat;this.type=void 0!==i?i:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps=
 !0;this.needsUpdate=!1;this.onUpdate=null};THREE.Texture.prototype={constructor:THREE.Texture,clone:function(){var a=new THREE.Texture(this.image,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter,this.format,this.type);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a}};THREE.TextureCount=0;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.CubeReflectionMapping=function(){};THREE.CubeRefractionMapping=function(){};THREE.LatitudeReflectionMapping=function(){};
 THREE.LatitudeRefractionMapping=function(){};THREE.SphericalReflectionMapping=function(){};THREE.SphericalRefractionMapping=function(){};THREE.UVMapping=function(){};THREE.RepeatWrapping=0;THREE.ClampToEdgeWrapping=1;THREE.MirroredRepeatWrapping=2;THREE.NearestFilter=3;THREE.NearestMipMapNearestFilter=4;THREE.NearestMipMapLinearFilter=5;THREE.LinearFilter=6;THREE.LinearMipMapNearestFilter=7;THREE.LinearMipMapLinearFilter=8;THREE.ByteType=9;THREE.UnsignedByteType=10;THREE.ShortType=11;
-THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(a,b,c,d,g,e,h,i,k,l){THREE.Texture.call(this,null,e,h,i,k,l,d,g);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
+THREE.UnsignedShortType=12;THREE.IntType=13;THREE.UnsignedIntType=14;THREE.FloatType=15;THREE.AlphaFormat=16;THREE.RGBFormat=17;THREE.RGBAFormat=18;THREE.LuminanceFormat=19;THREE.LuminanceAlphaFormat=20;THREE.DataTexture=function(a,b,c,d,g,f,h,i,k,l){THREE.Texture.call(this,null,f,h,i,k,l,d,g);this.image={data:a,width:b,height:c}};THREE.DataTexture.prototype=new THREE.Texture;THREE.DataTexture.prototype.constructor=THREE.DataTexture;
 THREE.DataTexture.prototype.clone=function(){var a=new THREE.DataTexture(this.image.data,this.image.width,this.image.height,this.format,this.type,this.mapping,this.wrapS,this.wrapT,this.magFilter,this.minFilter);a.offset.copy(this.offset);a.repeat.copy(this.repeat);return a};THREE.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;
 THREE.ParticleSystem=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b;this.sortParticles=!1;if(this.geometry)this.geometry.boundingSphere||this.geometry.computeBoundingSphere(),this.boundRadius=a.boundingSphere.radius;this.frustumCulled=!1};THREE.ParticleSystem.prototype=new THREE.Object3D;THREE.ParticleSystem.prototype.constructor=THREE.ParticleSystem;
 THREE.Line=function(a,b,c){THREE.Object3D.call(this);this.geometry=a;this.material=b;this.type=void 0!==c?c:THREE.LineStrip;this.geometry&&(this.geometry.boundingSphere||this.geometry.computeBoundingSphere())};THREE.LineStrip=0;THREE.LinePieces=1;THREE.Line.prototype=new THREE.Object3D;THREE.Line.prototype.constructor=THREE.Line;
@@ -120,12 +120,12 @@ THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material
 for(var c=0;c<this.geometry.morphTargets.length;c++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[c].name]=c}};THREE.Mesh.prototype=new THREE.Object3D;THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.supr=THREE.Object3D.prototype;
 THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(void 0!==this.morphTargetDictionary[a])return this.morphTargetDictionary[a];console.log("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};THREE.Bone=function(a){THREE.Object3D.call(this);this.skin=a;this.skinMatrix=new THREE.Matrix4};THREE.Bone.prototype=new THREE.Object3D;THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.supr=THREE.Object3D.prototype;
 THREE.Bone.prototype.update=function(a,b){this.matrixAutoUpdate&&(b|=this.updateMatrix());if(b||this.matrixWorldNeedsUpdate)a?this.skinMatrix.multiply(a,this.matrix):this.skinMatrix.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,b=!0;var c,d=this.children.length;for(c=0;c<d;c++)this.children[c].update(this.skinMatrix,b)};
-THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,d,g,e,h,i;if(void 0!==this.geometry.bones){for(c=0;c<this.geometry.bones.length;c++)g=this.geometry.bones[c],e=g.pos,h=g.rotq,i=g.scl,d=this.addBone(),d.name=g.name,d.position.set(e[0],e[1],e[2]),d.quaternion.set(h[0],h[1],h[2],h[3]),d.useQuaternion=!0,void 0!==i?d.scale.set(i[0],i[1],i[2]):d.scale.set(1,1,1);for(c=0;c<this.bones.length;c++)g=this.geometry.bones[c],
+THREE.SkinnedMesh=function(a,b){THREE.Mesh.call(this,a,b);this.identityMatrix=new THREE.Matrix4;this.bones=[];this.boneMatrices=[];var c,d,g,f,h,i;if(void 0!==this.geometry.bones){for(c=0;c<this.geometry.bones.length;c++)g=this.geometry.bones[c],f=g.pos,h=g.rotq,i=g.scl,d=this.addBone(),d.name=g.name,d.position.set(f[0],f[1],f[2]),d.quaternion.set(h[0],h[1],h[2],h[3]),d.useQuaternion=!0,void 0!==i?d.scale.set(i[0],i[1],i[2]):d.scale.set(1,1,1);for(c=0;c<this.bones.length;c++)g=this.geometry.bones[c],
 d=this.bones[c],-1===g.parent?this.add(d):this.bones[g.parent].add(d);this.boneMatrices=new Float32Array(16*this.bones.length);this.pose()}};THREE.SkinnedMesh.prototype=new THREE.Mesh;THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;THREE.SkinnedMesh.prototype.addBone=function(a){void 0===a&&(a=new THREE.Bone(this));this.bones.push(a);return a};
 THREE.SkinnedMesh.prototype.updateMatrixWorld=function(a){this.matrixAutoUpdate&&this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)this.parent?this.matrixWorld.multiply(this.parent.matrixWorld,this.matrix):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1;for(var a=0,b=this.children.length;a<b;a++){var c=this.children[a];c instanceof THREE.Bone?c.update(this.identityMatrix,!1):c.updateMatrixWorld(!0)}for(var b=this.bones.length,c=this.bones,d=this.boneMatrices,a=0;a<b;a++)c[a].skinMatrix.flattenToArrayOffset(d,
 16*a)};
-THREE.SkinnedMesh.prototype.pose=function(){this.updateMatrixWorld(!0);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];var d=new THREE.Matrix4;d.getInverse(a.skinMatrix);b.push(d);a.skinMatrix.flattenToArrayOffset(this.boneMatrices,16*c)}if(void 0===this.geometry.skinVerticesA){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];for(a=0;a<this.geometry.skinIndices.length;a++){var c=this.geometry.vertices[a].position,g=this.geometry.skinIndices[a].x,e=this.geometry.skinIndices[a].y,d=
-new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[g].multiplyVector3(d));d=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[e].multiplyVector3(d));1!==this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y&&(c=0.5*(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y)),this.geometry.skinWeights[a].x+=c,this.geometry.skinWeights[a].y+=c)}}};THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b};
+THREE.SkinnedMesh.prototype.pose=function(){this.updateMatrixWorld(!0);for(var a,b=[],c=0;c<this.bones.length;c++){a=this.bones[c];var d=new THREE.Matrix4;d.getInverse(a.skinMatrix);b.push(d);a.skinMatrix.flattenToArrayOffset(this.boneMatrices,16*c)}if(void 0===this.geometry.skinVerticesA){this.geometry.skinVerticesA=[];this.geometry.skinVerticesB=[];for(a=0;a<this.geometry.skinIndices.length;a++){var c=this.geometry.vertices[a].position,g=this.geometry.skinIndices[a].x,f=this.geometry.skinIndices[a].y,d=
+new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesA.push(b[g].multiplyVector3(d));d=new THREE.Vector3(c.x,c.y,c.z);this.geometry.skinVerticesB.push(b[f].multiplyVector3(d));1!==this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y&&(c=0.5*(1-(this.geometry.skinWeights[a].x+this.geometry.skinWeights[a].y)),this.geometry.skinWeights[a].x+=c,this.geometry.skinWeights[a].y+=c)}}};THREE.Ribbon=function(a,b){THREE.Object3D.call(this);this.geometry=a;this.material=b};
 THREE.Ribbon.prototype=new THREE.Object3D;THREE.Ribbon.prototype.constructor=THREE.Ribbon;THREE.LOD=function(){THREE.Object3D.call(this);this.LODs=[]};THREE.LOD.prototype=new THREE.Object3D;THREE.LOD.prototype.constructor=THREE.LOD;THREE.LOD.prototype.supr=THREE.Object3D.prototype;THREE.LOD.prototype.addLevel=function(a,b){void 0===b&&(b=0);for(var b=Math.abs(b),c=0;c<this.LODs.length&&!(b<this.LODs[c].visibleAtDistance);c++);this.LODs.splice(c,0,{visibleAtDistance:b,object3D:a});this.add(a)};
 THREE.LOD.prototype.update=function(a){if(1<this.LODs.length){a.matrixWorldInverse.getInverse(a.matrixWorld);a=a.matrixWorldInverse;a=-(a.n31*this.position.x+a.n32*this.position.y+a.n33*this.position.z+a.n34);this.LODs[0].object3D.visible=!0;for(var b=1;b<this.LODs.length;b++)if(a>=this.LODs[b].visibleAtDistance)this.LODs[b-1].object3D.visible=!1,this.LODs[b].object3D.visible=!0;else break;for(;b<this.LODs.length;b++)this.LODs[b].object3D.visible=!1}};
 THREE.Sprite=function(a){THREE.Object3D.call(this);this.color=void 0!==a.color?new THREE.Color(a.color):new THREE.Color(16777215);this.map=a.map instanceof THREE.Texture?a.map:THREE.ImageUtils.loadTexture(a.map);this.blending=void 0!==a.blending?a.blending:THREE.NormalBlending;this.useScreenCoordinates=void 0!==a.useScreenCoordinates?a.useScreenCoordinates:!0;this.mergeWith3D=void 0!==a.mergeWith3D?a.mergeWith3D:!this.useScreenCoordinates;this.affectedByDistance=void 0!==a.affectedByDistance?a.affectedByDistance:
@@ -169,143 +169,144 @@ THREE.ShaderChunk.lights_phong_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fr
 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(a){function b(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(void 0===a.__webglCustomAttributesList)a.__webglCustomAttributesList=[];for(var g in d.attributes){var e=d.attributes[g];if(!e.__webglInitialized||e.createUniqueBuffers){e.__webglInitialized=!0;var h=1;"v2"===e.type?h=2:"v3"===e.type?h=3:"v4"===e.type?h=4:"c"===e.type&&(h=3);e.size=h;e.array=new Float32Array(c*h);e.buffer=f.createBuffer();e.buffer.belongsToAttribute=g;e.needsUpdate=!0}a.__webglCustomAttributesList.push(e)}}}
-function c(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;if(0<=b.materialIndex)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?!1:a&&void 0!==a.shading&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function g(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?!0:!1}function e(a,b,c){var d,g,e,h,i=a.vertices;h=i.length;
-var j=a.colors,n=j.length,l=a.__vertexArray,k=a.__colorArray,m=a.__sortArray,p=a.__dirtyVertices,o=a.__dirtyColors,r=a.__webglCustomAttributesList;if(c.sortParticles){pb.multiplySelf(c.matrixWorld);for(d=0;d<h;d++)g=i[d].position,Wa.copy(g),pb.multiplyVector3(Wa),m[d]=[Wa.z,d];m.sort(function(a,b){return b[0]-a[0]});for(d=0;d<h;d++)g=i[m[d][1]].position,e=3*d,l[e]=g.x,l[e+1]=g.y,l[e+2]=g.z;for(d=0;d<n;d++)e=3*d,g=j[m[d][1]],k[e]=g.r,k[e+1]=g.g,k[e+2]=g.b;if(r)for(j=0,n=r.length;j<n;j++)if(i=r[j],
-void 0===i.boundTo||"vertices"===i.boundTo)if(e=0,g=i.value.length,1===i.size)for(d=0;d<g;d++)h=m[d][1],i.array[d]=i.value[h];else if(2===i.size)for(d=0;d<g;d++)h=m[d][1],h=i.value[h],i.array[e]=h.x,i.array[e+1]=h.y,e+=2;else if(3===i.size)if("c"===i.type)for(d=0;d<g;d++)h=m[d][1],h=i.value[h],i.array[e]=h.r,i.array[e+1]=h.g,i.array[e+2]=h.b,e+=3;else for(d=0;d<g;d++)h=m[d][1],h=i.value[h],i.array[e]=h.x,i.array[e+1]=h.y,i.array[e+2]=h.z,e+=3;else if(4===i.size)for(d=0;d<g;d++)h=m[d][1],h=i.value[h],
-i.array[e]=h.x,i.array[e+1]=h.y,i.array[e+2]=h.z,i.array[e+3]=h.w,e+=4}else{if(p)for(d=0;d<h;d++)g=i[d].position,e=3*d,l[e]=g.x,l[e+1]=g.y,l[e+2]=g.z;if(o)for(d=0;d<n;d++)g=j[d],e=3*d,k[e]=g.r,k[e+1]=g.g,k[e+2]=g.b;if(r)for(j=0,n=r.length;j<n;j++)if(i=r[j],i.needsUpdate&&(void 0===i.boundTo||"vertices"===i.boundTo))if(g=i.value.length,e=0,1===i.size)for(d=0;d<g;d++)i.array[d]=i.value[d];else if(2===i.size)for(d=0;d<g;d++)h=i.value[d],i.array[e]=h.x,i.array[e+1]=h.y,e+=2;else if(3===i.size)if("c"===
-i.type)for(d=0;d<g;d++)h=i.value[d],i.array[e]=h.r,i.array[e+1]=h.g,i.array[e+2]=h.b,e+=3;else for(d=0;d<g;d++)h=i.value[d],i.array[e]=h.x,i.array[e+1]=h.y,i.array[e+2]=h.z,e+=3;else if(4===i.size)for(d=0;d<g;d++)h=i.value[d],i.array[e]=h.x,i.array[e+1]=h.y,i.array[e+2]=h.z,i.array[e+3]=h.w,e+=4}if(p||c.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,a.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,l,b);if(o||c.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,a.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,
-k,b);if(r)for(j=0,n=r.length;j<n;j++)if(i=r[j],i.needsUpdate||c.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,i.buffer),f.bufferData(f.ARRAY_BUFFER,i.array,b)}function h(a,b){return b.z-a.z}function i(a,b,c){if(a.length)for(var d=0,f=a.length;d<f;d++)ob=null,Va=Ca=qb=ab=rb=-1,a[d].render(b,c,bc,cc),ob=null,Va=Ca=qb=ab=rb=-1}function k(a,b,c,d,f,e,g,h){var i,j,n,l;b?(j=a.length-1,l=b=-1):(j=0,b=a.length,l=1);for(var k=j;k!==b;k+=l)if(i=a[k],i.render){j=i.object;n=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;
-g&&z.setBlending(i.blending);z.setDepthTest(i.depthTest);v(i.depthWrite);F(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}z.setObjectFaces(j);n instanceof THREE.BufferGeometry?z.renderBufferDirect(d,f,e,i,n,j):z.renderBuffer(d,f,e,i,n,j)}}function l(a,b,c,d,f,e,g){for(var h,i,j=0,n=a.length;j<n;j++)if(h=a[j],i=h.object,i.visible){if(g)h=g;else{h=h[b];if(!h)continue;e&&z.setBlending(h.blending);z.setDepthTest(h.depthTest);v(h.depthWrite);F(h.polygonOffset,h.polygonOffsetFactor,h.polygonOffsetUnits)}z.renderImmediateObject(c,
-d,f,h,i)}}function j(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function n(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function m(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function o(a,b){for(var c=a.length-1;0<=c;c--)a[c].object===b&&a.splice(c,1)}function p(a,b){for(var c=a.length-1;0<=c;c--)a[c]===b&&a.splice(c,1)}function r(a,b,c,d,e){d.program||z.initMaterial(d,b,c,e);if(d.morphTargets&&!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=
-new Float32Array(z.maxMorphTargets);for(var g=0,h=z.maxMorphTargets;g<h;g++)e.__webglMorphTargetInfluences[g]=0}var i=!1,g=d.program,h=g.uniforms,j=d.uniforms;g!==ob&&(f.useProgram(g),ob=g,i=!0);if(d.id!==Va)Va=d.id,i=!0;if(i){f.uniformMatrix4fv(h.projectionMatrix,!1,a._projectionMatrixArray);if(c&&d.fog)if(j.fogColor.value=c.color,c instanceof THREE.Fog)j.fogNear.value=c.near,j.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)j.fogDensity.value=c.density;if(d instanceof THREE.MeshPhongMaterial||
-d instanceof THREE.MeshLambertMaterial||d.lights){var n,l,k=0,m=0,p=0,o,r,t=dc,v=t.directional.colors,y=t.directional.positions,A=t.point.colors,F=t.point.positions,M=t.point.distances,J=0,G=0,L=r=0;for(c=0,i=b.length;c<i;c++)if(n=b[c],l=n.color,o=n.intensity,r=n.distance,n instanceof THREE.AmbientLight)z.gammaInput?(k+=l.r*l.r,m+=l.g*l.g,p+=l.b*l.b):(k+=l.r,m+=l.g,p+=l.b);else if(n instanceof THREE.DirectionalLight)r=3*J,z.gammaInput?(v[r]=l.r*l.r*o*o,v[r+1]=l.g*l.g*o*o,v[r+2]=l.b*l.b*o*o):(v[r]=
-l.r*o,v[r+1]=l.g*o,v[r+2]=l.b*o),n=n.matrixWorld.getPosition(),l=1/n.length(),y[r]=n.x*l,y[r+1]=n.y*l,y[r+2]=n.z*l,J+=1;else if(n instanceof THREE.SpotLight&&!n.onlyShadow)r=3*J,z.gammaInput?(v[r]=l.r*l.r*o*o,v[r+1]=l.g*l.g*o*o,v[r+2]=l.b*l.b*o*o):(v[r]=l.r*o,v[r+1]=l.g*o,v[r+2]=l.b*o),n=n.matrixWorld.getPosition(),l=1/n.length(),y[r]=n.x*l,y[r+1]=n.y*l,y[r+2]=n.z*l,J+=1;else if(n instanceof THREE.PointLight)L=3*G,z.gammaInput?(A[L]=l.r*l.r*o*o,A[L+1]=l.g*l.g*o*o,A[L+2]=l.b*l.b*o*o):(A[L]=l.r*o,A[L+
-1]=l.g*o,A[L+2]=l.b*o),n=n.matrixWorld.getPosition(),F[L]=n.x,F[L+1]=n.y,F[L+2]=n.z,M[G]=r,G+=1;for(c=3*J,i=v.length;c<i;c++)v[c]=0;for(c=3*G,i=A.length;c<i;c++)A[c]=0;t.point.length=G;t.directional.length=J;t.ambient[0]=k;t.ambient[1]=m;t.ambient[2]=p;b=dc;j.ambientLightColor.value=b.ambient;j.directionalLightColor.value=b.directional.colors;j.directionalLightDirection.value=b.directional.positions;j.pointLightColor.value=b.point.colors;j.pointLightPosition.value=b.point.positions;j.pointLightDistance.value=
-b.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)j.opacity.value=d.opacity,z.gammaInput?j.diffuse.value.copyGammaToLinear(d.color):j.diffuse.value=d.color,(j.map.texture=d.map)&&j.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y),j.lightMap.texture=d.lightMap,j.envMap.texture=d.envMap,j.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?1:-1,j.reflectivity.value=d.reflectivity,
-j.refractionRatio.value=d.refractionRatio,j.combine.value=d.combine,j.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping;if(d instanceof THREE.LineBasicMaterial)j.diffuse.value=d.color,j.opacity.value=d.opacity;else if(d instanceof THREE.ParticleBasicMaterial)j.psColor.value=d.color,j.opacity.value=d.opacity,j.size.value=d.size,j.scale.value=I.height/2,j.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)j.shininess.value=d.shininess,z.gammaInput?(j.ambient.value.copyGammaToLinear(d.ambient),
-j.specular.value.copyGammaToLinear(d.specular)):(j.ambient.value=d.ambient,j.specular.value=d.specular),d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshLambertMaterial)z.gammaInput?j.ambient.value.copyGammaToLinear(d.ambient):j.ambient.value=d.ambient,d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshDepthMaterial)j.mNear.value=a.near,j.mFar.value=a.far,j.opacity.value=d.opacity;else if(d instanceof THREE.MeshNormalMaterial)j.opacity.value=d.opacity;
-if(e.receiveShadow&&!d._shadowPass&&j.shadowMatrix){for(b=0;b<z.shadowMapPlugin.shadowMatrix.length;b++)j.shadowMatrix.value[b]=z.shadowMapPlugin.shadowMatrix[b],j.shadowMap.texture[b]=z.shadowMapPlugin.shadowMap[b];j.shadowDarkness.value=z.shadowMapDarkness;j.shadowBias.value=z.shadowMapBias}b=d.uniformsList;for(j=0,c=b.length;j<c;j++)if(m=g.uniforms[b[j][1]])if(i=b[j][0],p=i.type,k=i.value,"i"===p)f.uniform1i(m,k);else if("f"===p)f.uniform1f(m,k);else if("v2"===p)f.uniform2f(m,k.x,k.y);else if("v3"===
-p)f.uniform3f(m,k.x,k.y,k.z);else if("v4"===p)f.uniform4f(m,k.x,k.y,k.z,k.w);else if("c"===p)f.uniform3f(m,k.r,k.g,k.b);else if("fv1"===p)f.uniform1fv(m,k);else if("fv"===p)f.uniform3fv(m,k);else if("v3v"===p){if(!i._array)i._array=new Float32Array(3*k.length);for(p=0,t=k.length;p<t;p++)v=3*p,i._array[v]=k[p].x,i._array[v+1]=k[p].y,i._array[v+2]=k[p].z;f.uniform3fv(m,i._array)}else if("m4"===p){if(!i._array)i._array=new Float32Array(16);k.flattenToArray(i._array);f.uniformMatrix4fv(m,!1,i._array)}else if("m4v"===
-p){if(!i._array)i._array=new Float32Array(16*k.length);for(p=0,t=k.length;p<t;p++)k[p].flattenToArrayOffset(i._array,16*p);f.uniformMatrix4fv(m,!1,i._array)}else if("t"===p){if(f.uniform1i(m,k),m=i.texture)if(m.image instanceof Array&&6===m.image.length){if(i=m,6===i.image.length)if(i.needsUpdate){if(!i.image.__webglTextureCube)i.image.__webglTextureCube=f.createTexture();f.activeTexture(f.TEXTURE0+k);f.bindTexture(f.TEXTURE_CUBE_MAP,i.image.__webglTextureCube);k=[];for(m=0;6>m;m++){p=k;t=m;if(z.autoScaleCubemaps){if(v=
-i.image[m],A=wc,!(v.width<=A&&v.height<=A))F=Math.max(v.width,v.height),y=Math.floor(v.width*A/F),A=Math.floor(v.height*A/F),F=document.createElement("canvas"),F.width=y,F.height=A,F.getContext("2d").drawImage(v,0,0,v.width,v.height,0,0,y,A),v=F}else v=i.image[m];p[t]=v}m=k[0];p=0===(m.width&m.width-1)&&0===(m.height&m.height-1);t=H(i.format);v=H(i.type);K(f.TEXTURE_CUBE_MAP,i,p);for(m=0;6>m;m++)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,t,t,v,k[m]);i.generateMipmaps&&p&&f.generateMipmap(f.TEXTURE_CUBE_MAP);
-i.needsUpdate=!1;if(i.onUpdated)i.onUpdated()}else f.activeTexture(f.TEXTURE0+k),f.bindTexture(f.TEXTURE_CUBE_MAP,i.image.__webglTextureCube)}else m instanceof THREE.WebGLRenderTargetCube?(i=m,f.activeTexture(f.TEXTURE0+k),f.bindTexture(f.TEXTURE_CUBE_MAP,i.__webglTexture)):z.setTexture(m,k)}else if("tv"===p){if(!i._array){i._array=[];for(p=0,t=i.texture.length;p<t;p++)i._array[p]=k+p}f.uniform1iv(m,i._array);for(p=0,t=i.texture.length;p<t;p++)(m=i.texture[p])&&z.setTexture(m,i._array[p])}(d instanceof
-THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&null!==h.cameraPosition&&f.uniform3f(h.cameraPosition,a.position.x,a.position.y,a.position.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==h.viewMatrix&&f.uniformMatrix4fv(h.viewMatrix,!1,a._viewMatrixArray);d.skinning&&(f.uniformMatrix4fv(h.cameraInverseMatrix,!1,a._viewMatrixArray),f.uniformMatrix4fv(h.boneGlobalMatrices,!1,e.boneMatrices))}f.uniformMatrix4fv(h.modelViewMatrix,
-!1,e._modelViewMatrixArray);h.normalMatrix&&f.uniformMatrix3fv(h.normalMatrix,!1,e._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&null!==h.objectMatrix&&f.uniformMatrix4fv(h.objectMatrix,!1,e._objectMatrixArray);return g}function t(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);c&&c.transposeIntoArray(a._normalMatrixArray)}function v(a){qb!==a&&
-(f.depthMask(a),qb=a)}function F(a,b,c){ec!==a&&(a?f.enable(f.POLYGON_OFFSET_FILL):f.disable(f.POLYGON_OFFSET_FILL),ec=a);if(a&&(fc!==b||Lb!==c))f.polygonOffset(b,c),fc=b,Lb=c}function A(a,b){var c;"fragment"===a?c=f.createShader(f.FRAGMENT_SHADER):"vertex"===a&&(c=f.createShader(f.VERTEX_SHADER));f.shaderSource(c,b);f.compileShader(c);return!f.getShaderParameter(c,f.COMPILE_STATUS)?(console.error(f.getShaderInfoLog(c)),console.error(b),null):c}function K(a,b,c){c?(f.texParameteri(a,f.TEXTURE_WRAP_S,
-H(b.wrapS)),f.texParameteri(a,f.TEXTURE_WRAP_T,H(b.wrapT)),f.texParameteri(a,f.TEXTURE_MAG_FILTER,H(b.magFilter)),f.texParameteri(a,f.TEXTURE_MIN_FILTER,H(b.minFilter))):(f.texParameteri(a,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(a,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texParameteri(a,f.TEXTURE_MAG_FILTER,J(b.magFilter)),f.texParameteri(a,f.TEXTURE_MIN_FILTER,J(b.minFilter)))}function y(a,b){f.bindRenderbuffer(f.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,
-f.DEPTH_COMPONENT16,b.width,b.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_ATTACHMENT,f.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(f.renderbufferStorage(f.RENDERBUFFER,f.DEPTH_STENCIL,b.width,b.height),f.framebufferRenderbuffer(f.FRAMEBUFFER,f.DEPTH_STENCIL_ATTACHMENT,f.RENDERBUFFER,a)):f.renderbufferStorage(f.RENDERBUFFER,f.RGBA4,b.width,b.height)}function J(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;
-default:return f.LINEAR}}function H(a){switch(a){case THREE.RepeatWrapping:return f.REPEAT;case THREE.ClampToEdgeWrapping:return f.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return f.MIRRORED_REPEAT;case THREE.NearestFilter:return f.NEAREST;case THREE.NearestMipMapNearestFilter:return f.NEAREST_MIPMAP_NEAREST;case THREE.NearestMipMapLinearFilter:return f.NEAREST_MIPMAP_LINEAR;case THREE.LinearFilter:return f.LINEAR;case THREE.LinearMipMapNearestFilter:return f.LINEAR_MIPMAP_NEAREST;case THREE.LinearMipMapLinearFilter:return f.LINEAR_MIPMAP_LINEAR;
-case THREE.ByteType:return f.BYTE;case THREE.UnsignedByteType:return f.UNSIGNED_BYTE;case THREE.ShortType:return f.SHORT;case THREE.UnsignedShortType:return f.UNSIGNED_SHORT;case THREE.IntType:return f.INT;case THREE.UnsignedShortType:return f.UNSIGNED_INT;case THREE.FloatType:return f.FLOAT;case THREE.AlphaFormat:return f.ALPHA;case THREE.RGBFormat:return f.RGB;case THREE.RGBAFormat:return f.RGBA;case THREE.LuminanceFormat:return f.LUMINANCE;case THREE.LuminanceAlphaFormat:return f.LUMINANCE_ALPHA}return 0}
-var a=a||{},I=void 0!==a.canvas?a.canvas:document.createElement("canvas"),M=void 0!==a.precision?a.precision:"mediump",G=void 0!==a.antialias?a.antialias:!1,L=void 0!==a.stencil?a.stencil:!0,ka=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,T=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),la=void 0!==a.clearAlpha?a.clearAlpha:0,ca=void 0!==a.maxLights?a.maxLights:4;this.domElement=I;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=
+THREE.WebGLRenderer=function(a){function b(a,b){var c=a.vertices.length,d=b.material;if(d.attributes){if(void 0===a.__webglCustomAttributesList)a.__webglCustomAttributesList=[];for(var g in d.attributes){var f=d.attributes[g];if(!f.__webglInitialized||f.createUniqueBuffers){f.__webglInitialized=!0;var h=1;"v2"===f.type?h=2:"v3"===f.type?h=3:"v4"===f.type?h=4:"c"===f.type&&(h=3);f.size=h;f.array=new Float32Array(c*h);f.buffer=e.createBuffer();f.buffer.belongsToAttribute=g;f.needsUpdate=!0}a.__webglCustomAttributesList.push(f)}}}
+function c(a,b){if(a.material&&!(a.material instanceof THREE.MeshFaceMaterial))return a.material;if(0<=b.materialIndex)return a.geometry.materials[b.materialIndex]}function d(a){return a instanceof THREE.MeshBasicMaterial&&!a.envMap||a instanceof THREE.MeshDepthMaterial?!1:a&&void 0!==a.shading&&a.shading===THREE.SmoothShading?THREE.SmoothShading:THREE.FlatShading}function g(a){return a.map||a.lightMap||a instanceof THREE.ShaderMaterial?!0:!1}function f(a,b,c){var d,g,f,h,i=a.vertices;h=i.length;
+var j=a.colors,n=j.length,l=a.__vertexArray,k=a.__colorArray,m=a.__sortArray,p=a.__dirtyVertices,o=a.__dirtyColors,r=a.__webglCustomAttributesList;if(c.sortParticles){nb.multiplySelf(c.matrixWorld);for(d=0;d<h;d++)g=i[d].position,Va.copy(g),nb.multiplyVector3(Va),m[d]=[Va.z,d];m.sort(function(a,b){return b[0]-a[0]});for(d=0;d<h;d++)g=i[m[d][1]].position,f=3*d,l[f]=g.x,l[f+1]=g.y,l[f+2]=g.z;for(d=0;d<n;d++)f=3*d,g=j[m[d][1]],k[f]=g.r,k[f+1]=g.g,k[f+2]=g.b;if(r)for(j=0,n=r.length;j<n;j++)if(i=r[j],
+void 0===i.boundTo||"vertices"===i.boundTo)if(f=0,g=i.value.length,1===i.size)for(d=0;d<g;d++)h=m[d][1],i.array[d]=i.value[h];else if(2===i.size)for(d=0;d<g;d++)h=m[d][1],h=i.value[h],i.array[f]=h.x,i.array[f+1]=h.y,f+=2;else if(3===i.size)if("c"===i.type)for(d=0;d<g;d++)h=m[d][1],h=i.value[h],i.array[f]=h.r,i.array[f+1]=h.g,i.array[f+2]=h.b,f+=3;else for(d=0;d<g;d++)h=m[d][1],h=i.value[h],i.array[f]=h.x,i.array[f+1]=h.y,i.array[f+2]=h.z,f+=3;else if(4===i.size)for(d=0;d<g;d++)h=m[d][1],h=i.value[h],
+i.array[f]=h.x,i.array[f+1]=h.y,i.array[f+2]=h.z,i.array[f+3]=h.w,f+=4}else{if(p)for(d=0;d<h;d++)g=i[d].position,f=3*d,l[f]=g.x,l[f+1]=g.y,l[f+2]=g.z;if(o)for(d=0;d<n;d++)g=j[d],f=3*d,k[f]=g.r,k[f+1]=g.g,k[f+2]=g.b;if(r)for(j=0,n=r.length;j<n;j++)if(i=r[j],i.needsUpdate&&(void 0===i.boundTo||"vertices"===i.boundTo))if(g=i.value.length,f=0,1===i.size)for(d=0;d<g;d++)i.array[d]=i.value[d];else if(2===i.size)for(d=0;d<g;d++)h=i.value[d],i.array[f]=h.x,i.array[f+1]=h.y,f+=2;else if(3===i.size)if("c"===
+i.type)for(d=0;d<g;d++)h=i.value[d],i.array[f]=h.r,i.array[f+1]=h.g,i.array[f+2]=h.b,f+=3;else for(d=0;d<g;d++)h=i.value[d],i.array[f]=h.x,i.array[f+1]=h.y,i.array[f+2]=h.z,f+=3;else if(4===i.size)for(d=0;d<g;d++)h=i.value[d],i.array[f]=h.x,i.array[f+1]=h.y,i.array[f+2]=h.z,i.array[f+3]=h.w,f+=4}if(p||c.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,a.__webglVertexBuffer),e.bufferData(e.ARRAY_BUFFER,l,b);if(o||c.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,a.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,
+k,b);if(r)for(j=0,n=r.length;j<n;j++)if(i=r[j],i.needsUpdate||c.sortParticles)e.bindBuffer(e.ARRAY_BUFFER,i.buffer),e.bufferData(e.ARRAY_BUFFER,i.array,b)}function h(a,b){return b.z-a.z}function i(a,b,c){if(a.length)for(var d=0,e=a.length;d<e;d++)$a=null,Ha=Ca=ob=pb=ab=-1,a[d].render(b,c,ac,bc),$a=null,Ha=Ca=ob=pb=ab=-1}function k(a,b,c,d,e,f,g,h){var i,j,n,l;b?(j=a.length-1,l=b=-1):(j=0,b=a.length,l=1);for(var k=j;k!==b;k+=l)if(i=a[k],i.render){j=i.object;n=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;
+g&&z.setBlending(i.blending);z.setDepthTest(i.depthTest);z.setDepthWrite(i.depthWrite);y(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}z.setObjectFaces(j);n instanceof THREE.BufferGeometry?z.renderBufferDirect(d,e,f,i,n,j):z.renderBuffer(d,e,f,i,n,j)}}function l(a,b,c,d,e,f,g){for(var h,i,j=0,n=a.length;j<n;j++)if(h=a[j],i=h.object,i.visible){if(g)h=g;else{h=h[b];if(!h)continue;f&&z.setBlending(h.blending);z.setDepthTest(h.depthTest);z.setDepthWrite(h.depthWrite);y(h.polygonOffset,h.polygonOffsetFactor,
+h.polygonOffsetUnits)}z.renderImmediateObject(c,d,e,h,i)}}function j(a,b,c){a.push({buffer:b,object:c,opaque:null,transparent:null})}function n(a){for(var b in a.attributes)if(a.attributes[b].needsUpdate)return!0;return!1}function m(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function o(a,b){for(var c=a.length-1;0<=c;c--)a[c].object===b&&a.splice(c,1)}function p(a,b){for(var c=a.length-1;0<=c;c--)a[c]===b&&a.splice(c,1)}function r(a,b,c,d,f){d.program||z.initMaterial(d,b,c,f);if(d.morphTargets&&
+!f.__webglMorphTargetInfluences){f.__webglMorphTargetInfluences=new Float32Array(z.maxMorphTargets);for(var g=0,h=z.maxMorphTargets;g<h;g++)f.__webglMorphTargetInfluences[g]=0}var i=!1,g=d.program,h=g.uniforms,j=d.uniforms;g!==$a&&(e.useProgram(g),$a=g,i=!0);if(d.id!==Ha)Ha=d.id,i=!0;if(i){e.uniformMatrix4fv(h.projectionMatrix,!1,a._projectionMatrixArray);if(c&&d.fog)if(j.fogColor.value=c.color,c instanceof THREE.Fog)j.fogNear.value=c.near,j.fogFar.value=c.far;else if(c instanceof THREE.FogExp2)j.fogDensity.value=
+c.density;if(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d.lights){var n,l,k=0,m=0,p=0,o,r,t=cc,v=t.directional.colors,y=t.directional.positions,A=t.point.colors,F=t.point.positions,M=t.point.distances,G=0,H=0,L=r=0;for(c=0,i=b.length;c<i;c++)if(n=b[c],l=n.color,o=n.intensity,r=n.distance,n instanceof THREE.AmbientLight)z.gammaInput?(k+=l.r*l.r,m+=l.g*l.g,p+=l.b*l.b):(k+=l.r,m+=l.g,p+=l.b);else if(n instanceof THREE.DirectionalLight)r=3*G,z.gammaInput?(v[r]=l.r*l.r*
+o*o,v[r+1]=l.g*l.g*o*o,v[r+2]=l.b*l.b*o*o):(v[r]=l.r*o,v[r+1]=l.g*o,v[r+2]=l.b*o),n=n.matrixWorld.getPosition(),l=1/n.length(),y[r]=n.x*l,y[r+1]=n.y*l,y[r+2]=n.z*l,G+=1;else if(n instanceof THREE.SpotLight&&!n.onlyShadow)r=3*G,z.gammaInput?(v[r]=l.r*l.r*o*o,v[r+1]=l.g*l.g*o*o,v[r+2]=l.b*l.b*o*o):(v[r]=l.r*o,v[r+1]=l.g*o,v[r+2]=l.b*o),n=n.matrixWorld.getPosition(),l=1/n.length(),y[r]=n.x*l,y[r+1]=n.y*l,y[r+2]=n.z*l,G+=1;else if(n instanceof THREE.PointLight)L=3*H,z.gammaInput?(A[L]=l.r*l.r*o*o,A[L+
+1]=l.g*l.g*o*o,A[L+2]=l.b*l.b*o*o):(A[L]=l.r*o,A[L+1]=l.g*o,A[L+2]=l.b*o),n=n.matrixWorld.getPosition(),F[L]=n.x,F[L+1]=n.y,F[L+2]=n.z,M[H]=r,H+=1;for(c=3*G,i=v.length;c<i;c++)v[c]=0;for(c=3*H,i=A.length;c<i;c++)A[c]=0;t.point.length=H;t.directional.length=G;t.ambient[0]=k;t.ambient[1]=m;t.ambient[2]=p;b=cc;j.ambientLightColor.value=b.ambient;j.directionalLightColor.value=b.directional.colors;j.directionalLightDirection.value=b.directional.positions;j.pointLightColor.value=b.point.colors;j.pointLightPosition.value=
+b.point.positions;j.pointLightDistance.value=b.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.MeshPhongMaterial)j.opacity.value=d.opacity,z.gammaInput?j.diffuse.value.copyGammaToLinear(d.color):j.diffuse.value=d.color,(j.map.texture=d.map)&&j.offsetRepeat.value.set(d.map.offset.x,d.map.offset.y,d.map.repeat.x,d.map.repeat.y),j.lightMap.texture=d.lightMap,j.envMap.texture=d.envMap,j.flipEnvMap.value=d.envMap instanceof THREE.WebGLRenderTargetCube?
+1:-1,j.reflectivity.value=d.reflectivity,j.refractionRatio.value=d.refractionRatio,j.combine.value=d.combine,j.useRefract.value=d.envMap&&d.envMap.mapping instanceof THREE.CubeRefractionMapping;if(d instanceof THREE.LineBasicMaterial)j.diffuse.value=d.color,j.opacity.value=d.opacity;else if(d instanceof THREE.ParticleBasicMaterial)j.psColor.value=d.color,j.opacity.value=d.opacity,j.size.value=d.size,j.scale.value=K.height/2,j.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)j.shininess.value=
+d.shininess,z.gammaInput?(j.ambient.value.copyGammaToLinear(d.ambient),j.specular.value.copyGammaToLinear(d.specular)):(j.ambient.value=d.ambient,j.specular.value=d.specular),d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshLambertMaterial)z.gammaInput?j.ambient.value.copyGammaToLinear(d.ambient):j.ambient.value=d.ambient,d.wrapAround&&j.wrapRGB.value.copy(d.wrapRGB);else if(d instanceof THREE.MeshDepthMaterial)j.mNear.value=a.near,j.mFar.value=a.far,j.opacity.value=d.opacity;
+else if(d instanceof THREE.MeshNormalMaterial)j.opacity.value=d.opacity;if(f.receiveShadow&&!d._shadowPass&&j.shadowMatrix){for(b=0;b<z.shadowMapPlugin.shadowMatrix.length;b++)j.shadowMatrix.value[b]=z.shadowMapPlugin.shadowMatrix[b],j.shadowMap.texture[b]=z.shadowMapPlugin.shadowMap[b];j.shadowDarkness.value=z.shadowMapDarkness;j.shadowBias.value=z.shadowMapBias}b=d.uniformsList;for(j=0,c=b.length;j<c;j++)if(m=g.uniforms[b[j][1]])if(i=b[j][0],p=i.type,k=i.value,"i"===p)e.uniform1i(m,k);else if("f"===
+p)e.uniform1f(m,k);else if("v2"===p)e.uniform2f(m,k.x,k.y);else if("v3"===p)e.uniform3f(m,k.x,k.y,k.z);else if("v4"===p)e.uniform4f(m,k.x,k.y,k.z,k.w);else if("c"===p)e.uniform3f(m,k.r,k.g,k.b);else if("fv1"===p)e.uniform1fv(m,k);else if("fv"===p)e.uniform3fv(m,k);else if("v3v"===p){if(!i._array)i._array=new Float32Array(3*k.length);for(p=0,t=k.length;p<t;p++)v=3*p,i._array[v]=k[p].x,i._array[v+1]=k[p].y,i._array[v+2]=k[p].z;e.uniform3fv(m,i._array)}else if("m4"===p){if(!i._array)i._array=new Float32Array(16);
+k.flattenToArray(i._array);e.uniformMatrix4fv(m,!1,i._array)}else if("m4v"===p){if(!i._array)i._array=new Float32Array(16*k.length);for(p=0,t=k.length;p<t;p++)k[p].flattenToArrayOffset(i._array,16*p);e.uniformMatrix4fv(m,!1,i._array)}else if("t"===p){if(e.uniform1i(m,k),m=i.texture)if(m.image instanceof Array&&6===m.image.length){if(i=m,6===i.image.length)if(i.needsUpdate){if(!i.image.__webglTextureCube)i.image.__webglTextureCube=e.createTexture();e.activeTexture(e.TEXTURE0+k);e.bindTexture(e.TEXTURE_CUBE_MAP,
+i.image.__webglTextureCube);k=[];for(m=0;6>m;m++){p=k;t=m;if(z.autoScaleCubemaps){if(v=i.image[m],A=vc,!(v.width<=A&&v.height<=A))F=Math.max(v.width,v.height),y=Math.floor(v.width*A/F),A=Math.floor(v.height*A/F),F=document.createElement("canvas"),F.width=y,F.height=A,F.getContext("2d").drawImage(v,0,0,v.width,v.height,0,0,y,A),v=F}else v=i.image[m];p[t]=v}m=k[0];p=0===(m.width&m.width-1)&&0===(m.height&m.height-1);t=J(i.format);v=J(i.type);I(e.TEXTURE_CUBE_MAP,i,p);for(m=0;6>m;m++)e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+
+m,0,t,t,v,k[m]);i.generateMipmaps&&p&&e.generateMipmap(e.TEXTURE_CUBE_MAP);i.needsUpdate=!1;if(i.onUpdated)i.onUpdated()}else e.activeTexture(e.TEXTURE0+k),e.bindTexture(e.TEXTURE_CUBE_MAP,i.image.__webglTextureCube)}else m instanceof THREE.WebGLRenderTargetCube?(i=m,e.activeTexture(e.TEXTURE0+k),e.bindTexture(e.TEXTURE_CUBE_MAP,i.__webglTexture)):z.setTexture(m,k)}else if("tv"===p){if(!i._array){i._array=[];for(p=0,t=i.texture.length;p<t;p++)i._array[p]=k+p}e.uniform1iv(m,i._array);for(p=0,t=i.texture.length;p<
+t;p++)(m=i.texture[p])&&z.setTexture(m,i._array[p])}(d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&null!==h.cameraPosition&&e.uniform3f(h.cameraPosition,a.position.x,a.position.y,a.position.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==h.viewMatrix&&e.uniformMatrix4fv(h.viewMatrix,!1,a._viewMatrixArray);d.skinning&&(e.uniformMatrix4fv(h.cameraInverseMatrix,!1,a._viewMatrixArray),
+e.uniformMatrix4fv(h.boneGlobalMatrices,!1,f.boneMatrices))}e.uniformMatrix4fv(h.modelViewMatrix,!1,f._modelViewMatrixArray);h.normalMatrix&&e.uniformMatrix3fv(h.normalMatrix,!1,f._normalMatrixArray);(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||f.receiveShadow)&&null!==h.objectMatrix&&e.uniformMatrix4fv(h.objectMatrix,!1,f._objectMatrixArray);return g}function t(a,b){a._modelViewMatrix.multiplyToArray(b.matrixWorldInverse,a.matrixWorld,a._modelViewMatrixArray);var c=THREE.Matrix4.makeInvert3x3(a._modelViewMatrix);
+c&&c.transposeIntoArray(a._normalMatrixArray)}function y(a,b,c){dc!==a&&(a?e.enable(e.POLYGON_OFFSET_FILL):e.disable(e.POLYGON_OFFSET_FILL),dc=a);if(a&&(ec!==b||Lb!==c))e.polygonOffset(b,c),ec=b,Lb=c}function F(a,b){var c;"fragment"===a?c=e.createShader(e.FRAGMENT_SHADER):"vertex"===a&&(c=e.createShader(e.VERTEX_SHADER));e.shaderSource(c,b);e.compileShader(c);return!e.getShaderParameter(c,e.COMPILE_STATUS)?(console.error(e.getShaderInfoLog(c)),console.error(b),null):c}function I(a,b,c){c?(e.texParameteri(a,
+e.TEXTURE_WRAP_S,J(b.wrapS)),e.texParameteri(a,e.TEXTURE_WRAP_T,J(b.wrapT)),e.texParameteri(a,e.TEXTURE_MAG_FILTER,J(b.magFilter)),e.texParameteri(a,e.TEXTURE_MIN_FILTER,J(b.minFilter))):(e.texParameteri(a,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(a,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(a,e.TEXTURE_MAG_FILTER,v(b.magFilter)),e.texParameteri(a,e.TEXTURE_MIN_FILTER,v(b.minFilter)))}function A(a,b){e.bindRenderbuffer(e.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(e.renderbufferStorage(e.RENDERBUFFER,
+e.DEPTH_COMPONENT16,b.width,b.height),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.RENDERBUFFER,a)):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,a)):e.renderbufferStorage(e.RENDERBUFFER,e.RGBA4,b.width,b.height)}function v(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return e.NEAREST;
+default:return e.LINEAR}}function J(a){switch(a){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 a=a||{},K=void 0!==a.canvas?a.canvas:document.createElement("canvas"),G=void 0!==a.precision?a.precision:"mediump",M=void 0!==a.antialias?a.antialias:!1,H=void 0!==a.stencil?a.stencil:!0,L=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,V=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),ga=void 0!==a.clearAlpha?a.clearAlpha:0,oa=void 0!==a.maxLights?a.maxLights:4;this.domElement=K;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=
 this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapBias=0.0039;this.shadowMapDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCameraNear=1;this.shadowCameraFar=5E3;this.shadowCameraFov=50;this.shadowMapEnabled=!1;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.maxMorphTargets=8;this.autoScaleCubemaps=!0;this.renderPluginsPre=[];this.renderPluginsPost=
-[];this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var z=this,f,Ha=[],ob=null,Kb=null,Va=-1,Ca=null,Qc=0,Mb=null,Nb=null,rb=null,ab=null,qb=null,ec=null,fc=null,Lb=null,bb=null,sb=0,zb=0,tb=0,Ab=0,bc=0,cc=0,Ob=new THREE.Frustum,pb=new THREE.Matrix4,Wa=new THREE.Vector4,dc={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};f=function(){var a;try{if(!(a=I.getContext("experimental-webgl",
-{antialias:G,stencil:L,preserveDrawingBuffer:ka})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();f.clearColor(0,0,0,1);f.clearDepth(1);f.clearStencil(0);f.enable(f.DEPTH_TEST);f.depthFunc(f.LEQUAL);f.frontFace(f.CCW);f.cullFace(f.BACK);f.enable(f.CULL_FACE);f.enable(f.BLEND);f.blendEquation(f.FUNC_ADD);
-f.blendFunc(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA);f.clearColor(T.r,T.g,T.b,la);this.context=f;var Pb=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS);f.getParameter(f.TEXTURE_SIZE);var wc=f.getParameter(f.MAX_CUBE_MAP_TEXTURE_SIZE);this.getContext=function(){return f};this.supportsVertexTextures=function(){return 0<Pb};this.setSize=function(a,b){I.width=a;I.height=b;this.setViewport(0,0,I.width,I.height)};this.setViewport=function(a,b,c,d){sb=a;zb=b;tb=c;Ab=d;f.viewport(sb,zb,tb,Ab)};this.setScissor=
-function(a,b,c,d){f.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?f.enable(f.SCISSOR_TEST):f.disable(f.SCISSOR_TEST)};this.setClearColorHex=function(a,b){T.setHex(a);la=b;f.clearColor(T.r,T.g,T.b,la)};this.setClearColor=function(a,b){T.copy(a);la=b;f.clearColor(T.r,T.g,T.b,la)};this.getClearColor=function(){return T};this.getClearAlpha=function(){return la};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=f.COLOR_BUFFER_BIT;if(void 0===b||b)d|=f.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=
-f.STENCIL_BUFFER_BIT;f.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=
-a.geometry.geometryGroups[b];f.deleteBuffer(c.__webglVertexBuffer);f.deleteBuffer(c.__webglNormalBuffer);f.deleteBuffer(c.__webglTangentBuffer);f.deleteBuffer(c.__webglColorBuffer);f.deleteBuffer(c.__webglUVBuffer);f.deleteBuffer(c.__webglUV2Buffer);f.deleteBuffer(c.__webglSkinVertexABuffer);f.deleteBuffer(c.__webglSkinVertexBBuffer);f.deleteBuffer(c.__webglSkinIndicesBuffer);f.deleteBuffer(c.__webglSkinWeightsBuffer);f.deleteBuffer(c.__webglFaceBuffer);f.deleteBuffer(c.__webglLineBuffer);if(c.numMorphTargets)for(var d=
-0,e=c.numMorphTargets;d<e;d++)f.deleteBuffer(c.__webglMorphTargetsBuffers[d]);if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)f.deleteBuffer(c.__webglCustomAttributesList[d].buffer);z.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),z.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),
-z.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),z.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,f.deleteTexture(a.__webglTexture),z.info.memory.textures--};this.updateShadowMap=function(a,b){ob=null;Va=Ca=qb=ab=rb=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=f.createBuffer();
-if(!a.__webglNormalBuffer)a.__webglNormalBuffer=f.createBuffer();a.hasPos&&(f.bindBuffer(f.ARRAY_BUFFER,a.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,a.positionArray,f.DYNAMIC_DRAW),f.enableVertexAttribArray(b.attributes.position),f.vertexAttribPointer(b.attributes.position,3,f.FLOAT,!1,0,0));if(a.hasNormal){f.bindBuffer(f.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,e,g,h,i,j,l,k,n,m,p=3*a.count;for(m=0;m<p;m+=9)c=a.normalArray,d=c[m],e=c[m+1],g=c[m+2],h=c[m+3],j=c[m+
-4],k=c[m+5],i=c[m+6],l=c[m+7],n=c[m+8],d=(d+h+i)/3,e=(e+j+l)/3,g=(g+k+n)/3,c[m]=d,c[m+1]=e,c[m+2]=g,c[m+3]=d,c[m+4]=e,c[m+5]=g,c[m+6]=d,c[m+7]=e,c[m+8]=g}f.bufferData(f.ARRAY_BUFFER,a.normalArray,f.DYNAMIC_DRAW);f.enableVertexAttribArray(b.attributes.normal);f.vertexAttribPointer(b.attributes.normal,3,f.FLOAT,!1,0,0)}f.drawArrays(f.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,e,g){if(0!==d.opacity&&(c=r(a,b,c,d,g),a=c.attributes,b=!1,d=16777215*e.id+2*c.id+(d.wireframe?
-1:0),d!==Ca&&(Ca=d,b=!0),g instanceof THREE.Mesh)){g=e.offsets;d=0;for(c=g.length;d<c;++d)b&&(f.bindBuffer(f.ARRAY_BUFFER,e.vertexPositionBuffer),f.vertexAttribPointer(a.position,e.vertexPositionBuffer.itemSize,f.FLOAT,!1,0,12*g[d].index),0<=a.normal&&e.vertexNormalBuffer&&(f.bindBuffer(f.ARRAY_BUFFER,e.vertexNormalBuffer),f.vertexAttribPointer(a.normal,e.vertexNormalBuffer.itemSize,f.FLOAT,!1,0,12*g[d].index)),0<=a.uv&&e.vertexUvBuffer&&(e.vertexUvBuffer?(f.bindBuffer(f.ARRAY_BUFFER,e.vertexUvBuffer),
-f.vertexAttribPointer(a.uv,e.vertexUvBuffer.itemSize,f.FLOAT,!1,0,8*g[d].index),f.enableVertexAttribArray(a.uv)):f.disableVertexAttribArray(a.uv)),0<=a.color&&e.vertexColorBuffer&&(f.bindBuffer(f.ARRAY_BUFFER,e.vertexColorBuffer),f.vertexAttribPointer(a.color,e.vertexColorBuffer.itemSize,f.FLOAT,!1,0,16*g[d].index)),f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)),f.drawElements(f.TRIANGLES,g[d].count,f.UNSIGNED_SHORT,2*g[d].start),z.info.render.calls++,z.info.render.vertices+=g[d].count,
-z.info.render.faces+=g[d].count/3}};this.renderBuffer=function(a,b,c,d,e,g){if(0!==d.opacity){var h,i,c=r(a,b,c,d,g),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0);c!==Ca&&(Ca=c,a=!0);if(!d.morphTargets&&0<=b.position)a&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglVertexBuffer),f.vertexAttribPointer(b.position,3,f.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;-1!==g.morphTargetBase?(f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[g.morphTargetBase]),f.vertexAttribPointer(c.position,
-3,f.FLOAT,!1,0,0)):0<=c.position&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglVertexBuffer),f.vertexAttribPointer(c.position,3,f.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){h=0;var j=g.morphTargetForcedOrder;for(i=g.morphTargetInfluences;h<d.numSupportedMorphTargets&&h<j.length;)f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[j[h]]),f.vertexAttribPointer(c["morphTarget"+h],3,f.FLOAT,!1,0,0),g.__webglMorphTargetInfluences[h]=i[j[h]],h++}else{var j=[],l=-1,k=0;i=g.morphTargetInfluences;var n,
-m=i.length;h=0;for(-1!==g.morphTargetBase&&(j[g.morphTargetBase]=!0);h<d.numSupportedMorphTargets;){for(n=0;n<m;n++)!j[n]&&i[n]>l&&(k=n,l=i[k]);f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[k]);f.vertexAttribPointer(c["morphTarget"+h],3,f.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[h]=l;j[k]=1;l=-1;h++}}null!==d.program.uniforms.morphTargetInfluences&&f.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(h=0,i=
-e.__webglCustomAttributesList.length;h<i;h++)c=e.__webglCustomAttributesList[h],0<=b[c.buffer.belongsToAttribute]&&(f.bindBuffer(f.ARRAY_BUFFER,c.buffer),f.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,f.FLOAT,!1,0,0));0<=b.color&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglColorBuffer),f.vertexAttribPointer(b.color,3,f.FLOAT,!1,0,0));0<=b.normal&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglNormalBuffer),f.vertexAttribPointer(b.normal,3,f.FLOAT,!1,0,0));0<=b.tangent&&(f.bindBuffer(f.ARRAY_BUFFER,
-e.__webglTangentBuffer),f.vertexAttribPointer(b.tangent,4,f.FLOAT,!1,0,0));0<=b.uv&&(e.__webglUVBuffer?(f.bindBuffer(f.ARRAY_BUFFER,e.__webglUVBuffer),f.vertexAttribPointer(b.uv,2,f.FLOAT,!1,0,0),f.enableVertexAttribArray(b.uv)):f.disableVertexAttribArray(b.uv));0<=b.uv2&&(e.__webglUV2Buffer?(f.bindBuffer(f.ARRAY_BUFFER,e.__webglUV2Buffer),f.vertexAttribPointer(b.uv2,2,f.FLOAT,!1,0,0),f.enableVertexAttribArray(b.uv2)):f.disableVertexAttribArray(b.uv2));d.skinning&&0<=b.skinVertexA&&0<=b.skinVertexB&&
-0<=b.skinIndex&&0<=b.skinWeight&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinVertexABuffer),f.vertexAttribPointer(b.skinVertexA,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinVertexBBuffer),f.vertexAttribPointer(b.skinVertexB,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinIndicesBuffer),f.vertexAttribPointer(b.skinIndex,4,f.FLOAT,!1,0,0),f.bindBuffer(f.ARRAY_BUFFER,e.__webglSkinWeightsBuffer),f.vertexAttribPointer(b.skinWeight,4,f.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe?
-(d=d.wireframeLinewidth,d!==bb&&(f.lineWidth(d),bb=d),a&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.__webglLineBuffer),f.drawElements(f.LINES,e.__webglLineCount,f.UNSIGNED_SHORT,0)):(a&&f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,e.__webglFaceBuffer),f.drawElements(f.TRIANGLES,e.__webglFaceCount,f.UNSIGNED_SHORT,0)),z.info.render.calls++,z.info.render.vertices+=e.__webglFaceCount,z.info.render.faces+=e.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?f.LINE_STRIP:f.LINES,d=d.linewidth,d!==
-bb&&(f.lineWidth(d),bb=d),f.drawArrays(g,0,e.__webglLineCount),z.info.render.calls++):g instanceof THREE.ParticleSystem?(f.drawArrays(f.POINTS,0,e.__webglParticleCount),z.info.render.calls++,z.info.render.points+=e.__webglParticleCount):g instanceof THREE.Ribbon&&(f.drawArrays(f.TRIANGLE_STRIP,0,e.__webglVertexCount),z.info.render.calls++)}};this.render=function(a,b,c,d){var e,g,j,n,m=a.lights,p=a.fog;Va=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);void 0===b.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
-a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();i(this.renderPluginsPre,a,b);z.info.render.calls=0;z.info.render.vertices=0;z.info.render.faces=0;z.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);pb.multiply(b.projectionMatrix,
-b.matrixWorldInverse);Ob.setFromMatrix(pb);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);n=a.__webglObjects;for(d=0,e=n.length;d<e;d++)if(g=n[d],j=g.object,g.render=!1,j.visible&&(!(j instanceof THREE.Mesh||j instanceof THREE.ParticleSystem)||!j.frustumCulled||Ob.contains(j))){j.matrixWorld.flattenToArray(j._objectMatrixArray);t(j,b);var o=g,r=o.object,y=o.buffer,A=void 0,A=A=void 0,A=r.material;if(A instanceof THREE.MeshFaceMaterial){if(A=
-y.materialIndex,0<=A)A=r.geometry.materials[A],A.transparent?(o.transparent=A,o.opaque=null):(o.opaque=A,o.transparent=null)}else if(A)A.transparent?(o.transparent=A,o.opaque=null):(o.opaque=A,o.transparent=null);g.render=!0;if(this.sortObjects)j.renderDepth?g.z=j.renderDepth:(Wa.copy(j.position),pb.multiplyVector3(Wa),g.z=Wa.z)}this.sortObjects&&n.sort(h);n=a.__webglObjectsImmediate;for(d=0,e=n.length;d<e;d++)if(g=n[d],j=g.object,j.visible)j.matrixAutoUpdate&&j.matrixWorld.flattenToArray(j._objectMatrixArray),
-t(j,b),j=g.object.material,j.transparent?(g.transparent=j,g.opaque=null):(g.opaque=j,g.transparent=null);a.overrideMaterial?(this.setBlending(a.overrideMaterial.blending),this.setDepthTest(a.overrideMaterial.depthTest),v(a.overrideMaterial.depthWrite),F(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),k(a.__webglObjects,!1,"",b,m,p,!0,a.overrideMaterial),l(a.__webglObjectsImmediate,"",b,m,p,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),
-k(a.__webglObjects,!0,"opaque",b,m,p,!1),l(a.__webglObjectsImmediate,"opaque",b,m,p,!1),k(a.__webglObjects,!1,"transparent",b,m,p,!0),l(a.__webglObjectsImmediate,"transparent",b,m,p,!0));i(this.renderPluginsPost,a,b);c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(f.bindTexture(f.TEXTURE_CUBE_MAP,c.__webglTexture),f.generateMipmap(f.TEXTURE_CUBE_MAP),f.bindTexture(f.TEXTURE_CUBE_MAP,null)):(f.bindTexture(f.TEXTURE_2D,
-c.__webglTexture),f.generateMipmap(f.TEXTURE_2D),f.bindTexture(f.TEXTURE_2D,null)))};this.renderImmediateObject=function(a,b,c,d,e){var g=r(a,b,c,d,e);Ca=-1;z.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(g,f,Ob):e.render(function(a){z.renderBufferImmediate(a,g,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var h=a.__objectsAdded[0],i=
-a,l=void 0,k=void 0,r=void 0;if(!h.__webglInit)if(h.__webglInit=!0,h._modelViewMatrix=new THREE.Matrix4,h._normalMatrixArray=new Float32Array(9),h._modelViewMatrixArray=new Float32Array(16),h._objectMatrixArray=new Float32Array(16),h.matrixWorld.flattenToArray(h._objectMatrixArray),h instanceof THREE.Mesh){if(k=h.geometry,k instanceof THREE.Geometry){if(void 0===k.geometryGroups){var t=k,v=void 0,y=void 0,A=void 0,F=void 0,K=void 0,H=void 0,I=void 0,J={},M=t.morphTargets.length;t.geometryGroups={};
-for(v=0,y=t.faces.length;v<y;v++)A=t.faces[v],F=A.materialIndex,H=void 0!==F?F:-1,void 0===J[H]&&(J[H]={hash:H,counter:0}),I=J[H].hash+"_"+J[H].counter,void 0===t.geometryGroups[I]&&(t.geometryGroups[I]={faces3:[],faces4:[],materialIndex:F,vertices:0,numMorphTargets:M}),K=A instanceof THREE.Face3?3:4,65535<t.geometryGroups[I].vertices+K&&(J[H].counter+=1,I=J[H].hash+"_"+J[H].counter,void 0===t.geometryGroups[I]&&(t.geometryGroups[I]={faces3:[],faces4:[],materialIndex:F,vertices:0,numMorphTargets:M})),
-A instanceof THREE.Face3?t.geometryGroups[I].faces3.push(v):t.geometryGroups[I].faces4.push(v),t.geometryGroups[I].vertices+=K;t.geometryGroupsList=[];var L=void 0;for(L in t.geometryGroups)t.geometryGroups[L].id=Qc++,t.geometryGroupsList.push(t.geometryGroups[L])}for(l in k.geometryGroups)if(r=k.geometryGroups[l],!r.__webglVertexBuffer){var G=r;G.__webglVertexBuffer=f.createBuffer();G.__webglNormalBuffer=f.createBuffer();G.__webglTangentBuffer=f.createBuffer();G.__webglColorBuffer=f.createBuffer();
-G.__webglUVBuffer=f.createBuffer();G.__webglUV2Buffer=f.createBuffer();G.__webglSkinVertexABuffer=f.createBuffer();G.__webglSkinVertexBBuffer=f.createBuffer();G.__webglSkinIndicesBuffer=f.createBuffer();G.__webglSkinWeightsBuffer=f.createBuffer();G.__webglFaceBuffer=f.createBuffer();G.__webglLineBuffer=f.createBuffer();if(G.numMorphTargets){var T=void 0,ca=void 0;G.__webglMorphTargetsBuffers=[];for(T=0,ca=G.numMorphTargets;T<ca;T++)G.__webglMorphTargetsBuffers.push(f.createBuffer())}z.info.memory.geometries++;
-var ha=r,la=h,ka=la.geometry,Ca=ha.faces3,Ha=ha.faces4,Da=3*Ca.length+4*Ha.length,Va=1*Ca.length+2*Ha.length,Wa=3*Ca.length+4*Ha.length,ub=c(la,ha),ob=g(ub),pb=d(ub),qb=ub.vertexColors?ub.vertexColors:!1;ha.__vertexArray=new Float32Array(3*Da);if(pb)ha.__normalArray=new Float32Array(3*Da);if(ka.hasTangents)ha.__tangentArray=new Float32Array(4*Da);if(qb)ha.__colorArray=new Float32Array(3*Da);if(ob){if(0<ka.faceUvs.length||0<ka.faceVertexUvs.length)ha.__uvArray=new Float32Array(2*Da);if(1<ka.faceUvs.length||
-1<ka.faceVertexUvs.length)ha.__uv2Array=new Float32Array(2*Da)}if(la.geometry.skinWeights.length&&la.geometry.skinIndices.length)ha.__skinVertexAArray=new Float32Array(4*Da),ha.__skinVertexBArray=new Float32Array(4*Da),ha.__skinIndexArray=new Float32Array(4*Da),ha.__skinWeightArray=new Float32Array(4*Da);ha.__faceArray=new Uint16Array(3*Va);ha.__lineArray=new Uint16Array(2*Wa);if(ha.numMorphTargets){ha.__morphTargetsArrays=[];for(var ab=0,rb=ha.numMorphTargets;ab<rb;ab++)ha.__morphTargetsArrays.push(new Float32Array(3*
-Da))}ha.__webglFaceCount=3*Va;ha.__webglLineCount=2*Wa;if(ub.attributes){if(void 0===ha.__webglCustomAttributesList)ha.__webglCustomAttributesList=[];var bb=void 0;for(bb in ub.attributes){var gc=ub.attributes[bb],wa={},sb;for(sb in gc)wa[sb]=gc[sb];if(!wa.__webglInitialized||wa.createUniqueBuffers){wa.__webglInitialized=!0;var Bb=1;"v2"===wa.type?Bb=2:"v3"===wa.type?Bb=3:"v4"===wa.type?Bb=4:"c"===wa.type&&(Bb=3);wa.size=Bb;wa.array=new Float32Array(Da*Bb);wa.buffer=f.createBuffer();wa.buffer.belongsToAttribute=
-bb;gc.needsUpdate=!0;wa.__original=gc}ha.__webglCustomAttributesList.push(wa)}}ha.__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(h instanceof THREE.Ribbon){if(k=h.geometry,!k.__webglVertexBuffer){var zb=k;zb.__webglVertexBuffer=f.createBuffer();zb.__webglColorBuffer=f.createBuffer();z.info.memory.geometries++;var hc=k,tb=hc.vertices.length;hc.__vertexArray=new Float32Array(3*
-tb);hc.__colorArray=new Float32Array(3*tb);hc.__webglVertexCount=tb;k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(h instanceof THREE.Line){if(k=h.geometry,!k.__webglVertexBuffer){var Ab=k;Ab.__webglVertexBuffer=f.createBuffer();Ab.__webglColorBuffer=f.createBuffer();z.info.memory.geometries++;var Qb=k,Ob=h,xc=Qb.vertices.length;Qb.__vertexArray=new Float32Array(3*xc);Qb.__colorArray=new Float32Array(3*xc);Qb.__webglLineCount=xc;b(Qb,Ob);k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(h instanceof
-THREE.ParticleSystem&&(k=h.geometry,!k.__webglVertexBuffer)){var Kb=k;Kb.__webglVertexBuffer=f.createBuffer();Kb.__webglColorBuffer=f.createBuffer();z.info.geometries++;var Cb=k,bc=h,yc=Cb.vertices.length;Cb.__vertexArray=new Float32Array(3*yc);Cb.__colorArray=new Float32Array(3*yc);Cb.__sortArray=[];Cb.__webglParticleCount=yc;b(Cb,bc);k.__dirtyVertices=!0;k.__dirtyColors=!0}if(!h.__webglActive){if(h instanceof THREE.Mesh)if(k=h.geometry,k instanceof THREE.BufferGeometry)j(i.__webglObjects,k,h);else for(l in k.geometryGroups)r=
+[];this.info={memory:{programs:0,geometries:0,textures:0},render:{calls:0,vertices:0,faces:0,points:0}};var z=this,e,qa=[],$a=null,$b=null,Ha=-1,Ca=null,Qc=0,Kb=null,Mb=null,ab=null,pb=null,ob=null,dc=null,ec=null,Lb=null,yb=null,qb=0,rb=0,zb=0,sb=0,ac=0,bc=0,Ab=new THREE.Frustum,nb=new THREE.Matrix4,Va=new THREE.Vector4,cc={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};e=function(){var a;try{if(!(a=K.getContext("experimental-webgl",
+{antialias:M,stencil:H,preserveDrawingBuffer:L})))throw"Error creating WebGL context.";console.log(navigator.userAgent+" | "+a.getParameter(a.VERSION)+" | "+a.getParameter(a.VENDOR)+" | "+a.getParameter(a.RENDERER)+" | "+a.getParameter(a.SHADING_LANGUAGE_VERSION))}catch(b){console.error(b)}return a}();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(V.r,V.g,V.b,ga);this.context=e;var Nb=e.getParameter(e.MAX_VERTEX_TEXTURE_IMAGE_UNITS);e.getParameter(e.TEXTURE_SIZE);var vc=e.getParameter(e.MAX_CUBE_MAP_TEXTURE_SIZE);this.getContext=function(){return e};this.supportsVertexTextures=function(){return 0<Nb};this.setSize=function(a,b){K.width=a;K.height=b;this.setViewport(0,0,K.width,K.height)};this.setViewport=function(a,b,c,d){qb=a;rb=b;zb=c;sb=d;e.viewport(qb,rb,zb,sb)};this.setScissor=
+function(a,b,c,d){e.scissor(a,b,c,d)};this.enableScissorTest=function(a){a?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST)};this.setClearColorHex=function(a,b){V.setHex(a);ga=b;e.clearColor(V.r,V.g,V.b,ga)};this.setClearColor=function(a,b){V.copy(a);ga=b;e.clearColor(V.r,V.g,V.b,ga)};this.getClearColor=function(){return V};this.getClearAlpha=function(){return ga};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=e.COLOR_BUFFER_BIT;if(void 0===b||b)d|=e.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=
+e.STENCIL_BUFFER_BIT;e.clear(d)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.addPostPlugin=function(a){a.init(this);this.renderPluginsPost.push(a)};this.addPrePlugin=function(a){a.init(this);this.renderPluginsPre.push(a)};this.deallocateObject=function(a){if(a.__webglInit)if(a.__webglInit=!1,delete a._modelViewMatrix,delete a._normalMatrixArray,delete a._modelViewMatrixArray,delete a._objectMatrixArray,a instanceof THREE.Mesh)for(var b in a.geometry.geometryGroups){var c=
+a.geometry.geometryGroups[b];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]);if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)e.deleteBuffer(c.__webglCustomAttributesList[d].buffer);z.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,e.deleteBuffer(a.__webglVertexBuffer),e.deleteBuffer(a.__webglColorBuffer),z.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,e.deleteBuffer(a.__webglVertexBuffer),e.deleteBuffer(a.__webglColorBuffer),
+z.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,e.deleteBuffer(a.__webglVertexBuffer),e.deleteBuffer(a.__webglColorBuffer),z.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,e.deleteTexture(a.__webglTexture),z.info.memory.textures--};this.updateShadowMap=function(a,b){$a=null;Ha=Ca=ob=pb=ab=-1;this.shadowMapPlugin.update(a,b)};this.renderBufferImmediate=function(a,b,c){if(!a.__webglVertexBuffer)a.__webglVertexBuffer=e.createBuffer();
+if(!a.__webglNormalBuffer)a.__webglNormalBuffer=e.createBuffer();a.hasPos&&(e.bindBuffer(e.ARRAY_BUFFER,a.__webglVertexBuffer),e.bufferData(e.ARRAY_BUFFER,a.positionArray,e.DYNAMIC_DRAW),e.enableVertexAttribArray(b.attributes.position),e.vertexAttribPointer(b.attributes.position,3,e.FLOAT,!1,0,0));if(a.hasNormal){e.bindBuffer(e.ARRAY_BUFFER,a.__webglNormalBuffer);if(c===THREE.FlatShading){var d,f,g,h,i,j,l,k,n,m,p=3*a.count;for(m=0;m<p;m+=9)c=a.normalArray,d=c[m],f=c[m+1],g=c[m+2],h=c[m+3],j=c[m+
+4],k=c[m+5],i=c[m+6],l=c[m+7],n=c[m+8],d=(d+h+i)/3,f=(f+j+l)/3,g=(g+k+n)/3,c[m]=d,c[m+1]=f,c[m+2]=g,c[m+3]=d,c[m+4]=f,c[m+5]=g,c[m+6]=d,c[m+7]=f,c[m+8]=g}e.bufferData(e.ARRAY_BUFFER,a.normalArray,e.DYNAMIC_DRAW);e.enableVertexAttribArray(b.attributes.normal);e.vertexAttribPointer(b.attributes.normal,3,e.FLOAT,!1,0,0)}e.drawArrays(e.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,b,c,d,f,g){if(0!==d.opacity&&(c=r(a,b,c,d,g),a=c.attributes,b=!1,d=16777215*f.id+2*c.id+(d.wireframe?
+1:0),d!==Ca&&(Ca=d,b=!0),g instanceof THREE.Mesh)){g=f.offsets;d=0;for(c=g.length;d<c;++d)b&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexPositionBuffer),e.vertexAttribPointer(a.position,f.vertexPositionBuffer.itemSize,e.FLOAT,!1,0,12*g[d].index),0<=a.normal&&f.vertexNormalBuffer&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexNormalBuffer),e.vertexAttribPointer(a.normal,f.vertexNormalBuffer.itemSize,e.FLOAT,!1,0,12*g[d].index)),0<=a.uv&&f.vertexUvBuffer&&(f.vertexUvBuffer?(e.bindBuffer(e.ARRAY_BUFFER,f.vertexUvBuffer),
+e.vertexAttribPointer(a.uv,f.vertexUvBuffer.itemSize,e.FLOAT,!1,0,8*g[d].index),e.enableVertexAttribArray(a.uv)):e.disableVertexAttribArray(a.uv)),0<=a.color&&f.vertexColorBuffer&&(e.bindBuffer(e.ARRAY_BUFFER,f.vertexColorBuffer),e.vertexAttribPointer(a.color,f.vertexColorBuffer.itemSize,e.FLOAT,!1,0,16*g[d].index)),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.vertexIndexBuffer)),e.drawElements(e.TRIANGLES,g[d].count,e.UNSIGNED_SHORT,2*g[d].start),z.info.render.calls++,z.info.render.vertices+=g[d].count,
+z.info.render.faces+=g[d].count/3}};this.renderBuffer=function(a,b,c,d,f,g){if(0!==d.opacity){var h,i,c=r(a,b,c,d,g),b=c.attributes,a=!1,c=16777215*f.id+2*c.id+(d.wireframe?1:0);c!==Ca&&(Ca=c,a=!0);if(!d.morphTargets&&0<=b.position)a&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(b.position,3,e.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;-1!==g.morphTargetBase?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[g.morphTargetBase]),e.vertexAttribPointer(c.position,
+3,e.FLOAT,!1,0,0)):0<=c.position&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglVertexBuffer),e.vertexAttribPointer(c.position,3,e.FLOAT,!1,0,0));if(g.morphTargetForcedOrder.length){h=0;var j=g.morphTargetForcedOrder;for(i=g.morphTargetInfluences;h<d.numSupportedMorphTargets&&h<j.length;)e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[j[h]]),e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,!1,0,0),g.__webglMorphTargetInfluences[h]=i[j[h]],h++}else{var j=[],l=-1,k=0;i=g.morphTargetInfluences;var n,
+m=i.length;h=0;for(-1!==g.morphTargetBase&&(j[g.morphTargetBase]=!0);h<d.numSupportedMorphTargets;){for(n=0;n<m;n++)!j[n]&&i[n]>l&&(k=n,l=i[k]);e.bindBuffer(e.ARRAY_BUFFER,f.__webglMorphTargetsBuffers[k]);e.vertexAttribPointer(c["morphTarget"+h],3,e.FLOAT,!1,0,0);g.__webglMorphTargetInfluences[h]=l;j[k]=1;l=-1;h++}}null!==d.program.uniforms.morphTargetInfluences&&e.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(f.__webglCustomAttributesList)for(h=0,i=
+f.__webglCustomAttributesList.length;h<i;h++)c=f.__webglCustomAttributesList[h],0<=b[c.buffer.belongsToAttribute]&&(e.bindBuffer(e.ARRAY_BUFFER,c.buffer),e.vertexAttribPointer(b[c.buffer.belongsToAttribute],c.size,e.FLOAT,!1,0,0));0<=b.color&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglColorBuffer),e.vertexAttribPointer(b.color,3,e.FLOAT,!1,0,0));0<=b.normal&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglNormalBuffer),e.vertexAttribPointer(b.normal,3,e.FLOAT,!1,0,0));0<=b.tangent&&(e.bindBuffer(e.ARRAY_BUFFER,
+f.__webglTangentBuffer),e.vertexAttribPointer(b.tangent,4,e.FLOAT,!1,0,0));0<=b.uv&&(f.__webglUVBuffer?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglUVBuffer),e.vertexAttribPointer(b.uv,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv)):e.disableVertexAttribArray(b.uv));0<=b.uv2&&(f.__webglUV2Buffer?(e.bindBuffer(e.ARRAY_BUFFER,f.__webglUV2Buffer),e.vertexAttribPointer(b.uv2,2,e.FLOAT,!1,0,0),e.enableVertexAttribArray(b.uv2)):e.disableVertexAttribArray(b.uv2));d.skinning&&0<=b.skinVertexA&&0<=b.skinVertexB&&
+0<=b.skinIndex&&0<=b.skinWeight&&(e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinVertexABuffer),e.vertexAttribPointer(b.skinVertexA,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinVertexBBuffer),e.vertexAttribPointer(b.skinVertexB,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinIndicesBuffer),e.vertexAttribPointer(b.skinIndex,4,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,f.__webglSkinWeightsBuffer),e.vertexAttribPointer(b.skinWeight,4,e.FLOAT,!1,0,0))}g instanceof THREE.Mesh?(d.wireframe?
+(d=d.wireframeLinewidth,d!==yb&&(e.lineWidth(d),yb=d),a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglLineBuffer),e.drawElements(e.LINES,f.__webglLineCount,e.UNSIGNED_SHORT,0)):(a&&e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,f.__webglFaceBuffer),e.drawElements(e.TRIANGLES,f.__webglFaceCount,e.UNSIGNED_SHORT,0)),z.info.render.calls++,z.info.render.vertices+=f.__webglFaceCount,z.info.render.faces+=f.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?e.LINE_STRIP:e.LINES,d=d.linewidth,d!==
+yb&&(e.lineWidth(d),yb=d),e.drawArrays(g,0,f.__webglLineCount),z.info.render.calls++):g instanceof THREE.ParticleSystem?(e.drawArrays(e.POINTS,0,f.__webglParticleCount),z.info.render.calls++,z.info.render.points+=f.__webglParticleCount):g instanceof THREE.Ribbon&&(e.drawArrays(e.TRIANGLE_STRIP,0,f.__webglVertexCount),z.info.render.calls++)}};this.render=function(a,b,c,d){var f,g,j,n,m=a.lights,p=a.fog;Ha=-1;this.autoUpdateObjects&&this.initWebGLObjects(a);void 0===b.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
+a.add(b));this.autoUpdateScene&&a.updateMatrixWorld();i(this.renderPluginsPre,a,b);z.info.render.calls=0;z.info.render.vertices=0;z.info.render.faces=0;z.info.render.points=0;b.matrixWorldInverse.getInverse(b.matrixWorld);if(!b._viewMatrixArray)b._viewMatrixArray=new Float32Array(16);b.matrixWorldInverse.flattenToArray(b._viewMatrixArray);if(!b._projectionMatrixArray)b._projectionMatrixArray=new Float32Array(16);b.projectionMatrix.flattenToArray(b._projectionMatrixArray);nb.multiply(b.projectionMatrix,
+b.matrixWorldInverse);Ab.setFromMatrix(nb);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);n=a.__webglObjects;for(d=0,f=n.length;d<f;d++)if(g=n[d],j=g.object,g.render=!1,j.visible&&(!(j instanceof THREE.Mesh||j instanceof THREE.ParticleSystem)||!j.frustumCulled||Ab.contains(j))){j.matrixWorld.flattenToArray(j._objectMatrixArray);t(j,b);var o=g,r=o.object,v=o.buffer,A=void 0,A=A=void 0,A=r.material;if(A instanceof THREE.MeshFaceMaterial){if(A=
+v.materialIndex,0<=A)A=r.geometry.materials[A],A.transparent?(o.transparent=A,o.opaque=null):(o.opaque=A,o.transparent=null)}else if(A)A.transparent?(o.transparent=A,o.opaque=null):(o.opaque=A,o.transparent=null);g.render=!0;if(this.sortObjects)j.renderDepth?g.z=j.renderDepth:(Va.copy(j.position),nb.multiplyVector3(Va),g.z=Va.z)}this.sortObjects&&n.sort(h);n=a.__webglObjectsImmediate;for(d=0,f=n.length;d<f;d++)if(g=n[d],j=g.object,j.visible)j.matrixAutoUpdate&&j.matrixWorld.flattenToArray(j._objectMatrixArray),
+t(j,b),j=g.object.material,j.transparent?(g.transparent=j,g.opaque=null):(g.opaque=j,g.transparent=null);a.overrideMaterial?(this.setBlending(a.overrideMaterial.blending),this.setDepthTest(a.overrideMaterial.depthTest),this.setDepthWrite(a.overrideMaterial.depthWrite),y(a.overrideMaterial.polygonOffset,a.overrideMaterial.polygonOffsetFactor,a.overrideMaterial.polygonOffsetUnits),k(a.__webglObjects,!1,"",b,m,p,!0,a.overrideMaterial),l(a.__webglObjectsImmediate,"",b,m,p,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),
+k(a.__webglObjects,!0,"opaque",b,m,p,!1),l(a.__webglObjectsImmediate,"opaque",b,m,p,!1),k(a.__webglObjects,!1,"transparent",b,m,p,!0),l(a.__webglObjectsImmediate,"transparent",b,m,p,!0));i(this.renderPluginsPost,a,b);c&&c.generateMipmaps&&c.minFilter!==THREE.NearestFilter&&c.minFilter!==THREE.LinearFilter&&(c instanceof THREE.WebGLRenderTargetCube?(e.bindTexture(e.TEXTURE_CUBE_MAP,c.__webglTexture),e.generateMipmap(e.TEXTURE_CUBE_MAP),e.bindTexture(e.TEXTURE_CUBE_MAP,null)):(e.bindTexture(e.TEXTURE_2D,
+c.__webglTexture),e.generateMipmap(e.TEXTURE_2D),e.bindTexture(e.TEXTURE_2D,null)));this.setDepthTest(!0);this.setDepthWrite(!0)};this.renderImmediateObject=function(a,b,c,d,f){var g=r(a,b,c,d,f);Ca=-1;z.setObjectFaces(f);f.immediateRenderCallback?f.immediateRenderCallback(g,e,Ab):f.render(function(a){z.renderBufferImmediate(a,g,d.shading)})};this.initWebGLObjects=function(a){if(!a.__webglObjects)a.__webglObjects=[],a.__webglObjectsImmediate=[],a.__webglSprites=[],a.__webglFlares=[];for(;a.__objectsAdded.length;){var h=
+a.__objectsAdded[0],i=a,l=void 0,k=void 0,r=void 0;if(!h.__webglInit)if(h.__webglInit=!0,h._modelViewMatrix=new THREE.Matrix4,h._normalMatrixArray=new Float32Array(9),h._modelViewMatrixArray=new Float32Array(16),h._objectMatrixArray=new Float32Array(16),h.matrixWorld.flattenToArray(h._objectMatrixArray),h instanceof THREE.Mesh){if(k=h.geometry,k instanceof THREE.Geometry){if(void 0===k.geometryGroups){var t=k,v=void 0,y=void 0,A=void 0,I=void 0,F=void 0,G=void 0,J=void 0,K={},M=t.morphTargets.length;
+t.geometryGroups={};for(v=0,y=t.faces.length;v<y;v++)A=t.faces[v],I=A.materialIndex,G=void 0!==I?I:-1,void 0===K[G]&&(K[G]={hash:G,counter:0}),J=K[G].hash+"_"+K[G].counter,void 0===t.geometryGroups[J]&&(t.geometryGroups[J]={faces3:[],faces4:[],materialIndex:I,vertices:0,numMorphTargets:M}),F=A instanceof THREE.Face3?3:4,65535<t.geometryGroups[J].vertices+F&&(K[G].counter+=1,J=K[G].hash+"_"+K[G].counter,void 0===t.geometryGroups[J]&&(t.geometryGroups[J]={faces3:[],faces4:[],materialIndex:I,vertices:0,
+numMorphTargets:M})),A instanceof THREE.Face3?t.geometryGroups[J].faces3.push(v):t.geometryGroups[J].faces4.push(v),t.geometryGroups[J].vertices+=F;t.geometryGroupsList=[];var L=void 0;for(L in t.geometryGroups)t.geometryGroups[L].id=Qc++,t.geometryGroupsList.push(t.geometryGroups[L])}for(l in k.geometryGroups)if(r=k.geometryGroups[l],!r.__webglVertexBuffer){var H=r;H.__webglVertexBuffer=e.createBuffer();H.__webglNormalBuffer=e.createBuffer();H.__webglTangentBuffer=e.createBuffer();H.__webglColorBuffer=
+e.createBuffer();H.__webglUVBuffer=e.createBuffer();H.__webglUV2Buffer=e.createBuffer();H.__webglSkinVertexABuffer=e.createBuffer();H.__webglSkinVertexBBuffer=e.createBuffer();H.__webglSkinIndicesBuffer=e.createBuffer();H.__webglSkinWeightsBuffer=e.createBuffer();H.__webglFaceBuffer=e.createBuffer();H.__webglLineBuffer=e.createBuffer();if(H.numMorphTargets){var V=void 0,ga=void 0;H.__webglMorphTargetsBuffers=[];for(V=0,ga=H.numMorphTargets;V<ga;V++)H.__webglMorphTargetsBuffers.push(e.createBuffer())}z.info.memory.geometries++;
+var ha=r,oa=h,qa=oa.geometry,Ca=ha.faces3,Ha=ha.faces4,Da=3*Ca.length+4*Ha.length,Va=1*Ca.length+2*Ha.length,$a=3*Ca.length+4*Ha.length,tb=c(oa,ha),nb=g(tb),ob=d(tb),pb=tb.vertexColors?tb.vertexColors:!1;ha.__vertexArray=new Float32Array(3*Da);if(ob)ha.__normalArray=new Float32Array(3*Da);if(qa.hasTangents)ha.__tangentArray=new Float32Array(4*Da);if(pb)ha.__colorArray=new Float32Array(3*Da);if(nb){if(0<qa.faceUvs.length||0<qa.faceVertexUvs.length)ha.__uvArray=new Float32Array(2*Da);if(1<qa.faceUvs.length||
+1<qa.faceVertexUvs.length)ha.__uv2Array=new Float32Array(2*Da)}if(oa.geometry.skinWeights.length&&oa.geometry.skinIndices.length)ha.__skinVertexAArray=new Float32Array(4*Da),ha.__skinVertexBArray=new Float32Array(4*Da),ha.__skinIndexArray=new Float32Array(4*Da),ha.__skinWeightArray=new Float32Array(4*Da);ha.__faceArray=new Uint16Array(3*Va);ha.__lineArray=new Uint16Array(2*$a);if(ha.numMorphTargets){ha.__morphTargetsArrays=[];for(var ab=0,yb=ha.numMorphTargets;ab<yb;ab++)ha.__morphTargetsArrays.push(new Float32Array(3*
+Da))}ha.__webglFaceCount=3*Va;ha.__webglLineCount=2*$a;if(tb.attributes){if(void 0===ha.__webglCustomAttributesList)ha.__webglCustomAttributesList=[];var qb=void 0;for(qb in tb.attributes){var fc=tb.attributes[qb],wa={},rb;for(rb in fc)wa[rb]=fc[rb];if(!wa.__webglInitialized||wa.createUniqueBuffers){wa.__webglInitialized=!0;var Bb=1;"v2"===wa.type?Bb=2:"v3"===wa.type?Bb=3:"v4"===wa.type?Bb=4:"c"===wa.type&&(Bb=3);wa.size=Bb;wa.array=new Float32Array(Da*Bb);wa.buffer=e.createBuffer();wa.buffer.belongsToAttribute=
+qb;fc.needsUpdate=!0;wa.__original=fc}ha.__webglCustomAttributesList.push(wa)}}ha.__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(h instanceof THREE.Ribbon){if(k=h.geometry,!k.__webglVertexBuffer){var zb=k;zb.__webglVertexBuffer=e.createBuffer();zb.__webglColorBuffer=e.createBuffer();z.info.memory.geometries++;var gc=k,sb=gc.vertices.length;gc.__vertexArray=new Float32Array(3*
+sb);gc.__colorArray=new Float32Array(3*sb);gc.__webglVertexCount=sb;k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(h instanceof THREE.Line){if(k=h.geometry,!k.__webglVertexBuffer){var Ab=k;Ab.__webglVertexBuffer=e.createBuffer();Ab.__webglColorBuffer=e.createBuffer();z.info.memory.geometries++;var Ob=k,$b=h,wc=Ob.vertices.length;Ob.__vertexArray=new Float32Array(3*wc);Ob.__colorArray=new Float32Array(3*wc);Ob.__webglLineCount=wc;b(Ob,$b);k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(h instanceof
+THREE.ParticleSystem&&(k=h.geometry,!k.__webglVertexBuffer)){var Kb=k;Kb.__webglVertexBuffer=e.createBuffer();Kb.__webglColorBuffer=e.createBuffer();z.info.geometries++;var Cb=k,ac=h,xc=Cb.vertices.length;Cb.__vertexArray=new Float32Array(3*xc);Cb.__colorArray=new Float32Array(3*xc);Cb.__sortArray=[];Cb.__webglParticleCount=xc;b(Cb,ac);k.__dirtyVertices=!0;k.__dirtyColors=!0}if(!h.__webglActive){if(h instanceof THREE.Mesh)if(k=h.geometry,k instanceof THREE.BufferGeometry)j(i.__webglObjects,k,h);else for(l in k.geometryGroups)r=
 k.geometryGroups[l],j(i.__webglObjects,r,h);else h instanceof THREE.Ribbon||h instanceof THREE.Line||h instanceof THREE.ParticleSystem?(k=h.geometry,j(i.__webglObjects,k,h)):void 0!==THREE.MarchingCubes&&h instanceof THREE.MarchingCubes||h.immediateRenderCallback?i.__webglObjectsImmediate.push({object:h,opaque:null,transparent:null}):h instanceof THREE.Sprite?i.__webglSprites.push(h):h instanceof THREE.LensFlare&&i.__webglFlares.push(h);h.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var za=
-a.__objectsRemoved[0],ic=a;za instanceof THREE.Mesh||za instanceof THREE.ParticleSystem||za instanceof THREE.Ribbon||za instanceof THREE.Line?o(ic.__webglObjects,za):za instanceof THREE.Sprite?p(ic.__webglSprites,za):za instanceof THREE.LensFlare?p(ic.__webglFlares,za):(za instanceof THREE.MarchingCubes||za.immediateRenderCallback)&&o(ic.__webglObjectsImmediate,za);za.__webglActive=!1;a.__objectsRemoved.splice(0,1)}for(var zc=0,cc=a.__webglObjects.length;zc<cc;zc++){var Fa=a.__webglObjects[zc].object,
-P=Fa.geometry,Rb=void 0,Db=void 0,sa=void 0;if(Fa instanceof THREE.Mesh)if(P instanceof THREE.BufferGeometry)P.__dirtyVertices=!1,P.__dirtyElements=!1,P.__dirtyUvs=!1,P.__dirtyNormals=!1,P.__dirtyColors=!1;else{for(var Ac=0,dc=P.geometryGroupsList.length;Ac<dc;Ac++)if(Rb=P.geometryGroupsList[Ac],sa=c(Fa,Rb),Db=sa.attributes&&n(sa),P.__dirtyVertices||P.__dirtyMorphTargets||P.__dirtyElements||P.__dirtyUvs||P.__dirtyNormals||P.__dirtyColors||P.__dirtyTangents||Db){var N=Rb,ec=Fa,xa=f.DYNAMIC_DRAW,fc=
-!P.dynamic,jc=sa;if(N.__inittedArrays){var Lb=d(jc),Bc=jc.vertexColors?jc.vertexColors:!1,Mb=g(jc),Nb=Lb===THREE.SmoothShading,u=void 0,B=void 0,Ea=void 0,x=void 0,Eb=void 0,cb=void 0,Ga=void 0,kc=void 0,Xa=void 0,Fb=void 0,Gb=void 0,C=void 0,D=void 0,E=void 0,U=void 0,Ia=void 0,Ja=void 0,Ka=void 0,Sb=void 0,La=void 0,Ma=void 0,Na=void 0,Tb=void 0,Oa=void 0,Pa=void 0,Qa=void 0,Ub=void 0,Ra=void 0,Sa=void 0,Ta=void 0,Vb=void 0,db=void 0,eb=void 0,fb=void 0,lc=void 0,gb=void 0,hb=void 0,ib=void 0,mc=
-void 0,Q=void 0,Pb=void 0,jb=void 0,Hb=void 0,Ib=void 0,ya=void 0,Ic=void 0,ja=void 0,da=0,ia=0,Ya=0,Za=0,Aa=0,pa=0,V=0,qa=0,ea=0,w=0,fa=0,s=0,ua=void 0,ma=N.__vertexArray,Wb=N.__uvArray,Xb=N.__uv2Array,Ba=N.__normalArray,X=N.__tangentArray,na=N.__colorArray,Y=N.__skinVertexAArray,Z=N.__skinVertexBArray,$=N.__skinIndexArray,aa=N.__skinWeightArray,Cc=N.__morphTargetsArrays,Dc=N.__webglCustomAttributesList,q=void 0,Ua=N.__faceArray,va=N.__lineArray,ra=ec.geometry,wc=ra.__dirtyElements,Jc=ra.__dirtyUvs,
-Rc=ra.__dirtyNormals,Sc=ra.__dirtyTangents,Tc=ra.__dirtyColors,Uc=ra.__dirtyMorphTargets,vb=ra.vertices,R=N.faces3,S=N.faces4,ga=ra.faces,Ec=ra.faceVertexUvs[0],Fc=ra.faceVertexUvs[1],wb=ra.skinVerticesA,xb=ra.skinVerticesB,yb=ra.skinIndices,kb=ra.skinWeights,lb=ra.morphTargets;if(ra.__dirtyVertices){for(u=0,B=R.length;u<B;u++)x=ga[R[u]],C=vb[x.a].position,D=vb[x.b].position,E=vb[x.c].position,ma[ia]=C.x,ma[ia+1]=C.y,ma[ia+2]=C.z,ma[ia+3]=D.x,ma[ia+4]=D.y,ma[ia+5]=D.z,ma[ia+6]=E.x,ma[ia+7]=E.y,ma[ia+
-8]=E.z,ia+=9;for(u=0,B=S.length;u<B;u++)x=ga[S[u]],C=vb[x.a].position,D=vb[x.b].position,E=vb[x.c].position,U=vb[x.d].position,ma[ia]=C.x,ma[ia+1]=C.y,ma[ia+2]=C.z,ma[ia+3]=D.x,ma[ia+4]=D.y,ma[ia+5]=D.z,ma[ia+6]=E.x,ma[ia+7]=E.y,ma[ia+8]=E.z,ma[ia+9]=U.x,ma[ia+10]=U.y,ma[ia+11]=U.z,ia+=12;f.bindBuffer(f.ARRAY_BUFFER,N.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,ma,xa)}if(Uc)for(ya=0,Ic=lb.length;ya<Ic;ya++){fa=0;for(u=0,B=R.length;u<B;u++)x=ga[R[u]],C=lb[ya].vertices[x.a].position,D=lb[ya].vertices[x.b].position,
-E=lb[ya].vertices[x.c].position,ja=Cc[ya],ja[fa]=C.x,ja[fa+1]=C.y,ja[fa+2]=C.z,ja[fa+3]=D.x,ja[fa+4]=D.y,ja[fa+5]=D.z,ja[fa+6]=E.x,ja[fa+7]=E.y,ja[fa+8]=E.z,fa+=9;for(u=0,B=S.length;u<B;u++)x=ga[S[u]],C=lb[ya].vertices[x.a].position,D=lb[ya].vertices[x.b].position,E=lb[ya].vertices[x.c].position,U=lb[ya].vertices[x.d].position,ja=Cc[ya],ja[fa]=C.x,ja[fa+1]=C.y,ja[fa+2]=C.z,ja[fa+3]=D.x,ja[fa+4]=D.y,ja[fa+5]=D.z,ja[fa+6]=E.x,ja[fa+7]=E.y,ja[fa+8]=E.z,ja[fa+9]=U.x,ja[fa+10]=U.y,ja[fa+11]=U.z,fa+=12;
-f.bindBuffer(f.ARRAY_BUFFER,N.__webglMorphTargetsBuffers[ya]);f.bufferData(f.ARRAY_BUFFER,Cc[ya],xa)}if(kb.length){for(u=0,B=R.length;u<B;u++)x=ga[R[u]],Oa=kb[x.a],Pa=kb[x.b],Qa=kb[x.c],aa[w]=Oa.x,aa[w+1]=Oa.y,aa[w+2]=Oa.z,aa[w+3]=Oa.w,aa[w+4]=Pa.x,aa[w+5]=Pa.y,aa[w+6]=Pa.z,aa[w+7]=Pa.w,aa[w+8]=Qa.x,aa[w+9]=Qa.y,aa[w+10]=Qa.z,aa[w+11]=Qa.w,Ra=yb[x.a],Sa=yb[x.b],Ta=yb[x.c],$[w]=Ra.x,$[w+1]=Ra.y,$[w+2]=Ra.z,$[w+3]=Ra.w,$[w+4]=Sa.x,$[w+5]=Sa.y,$[w+6]=Sa.z,$[w+7]=Sa.w,$[w+8]=Ta.x,$[w+9]=Ta.y,$[w+10]=
-Ta.z,$[w+11]=Ta.w,db=wb[x.a],eb=wb[x.b],fb=wb[x.c],Y[w]=db.x,Y[w+1]=db.y,Y[w+2]=db.z,Y[w+3]=1,Y[w+4]=eb.x,Y[w+5]=eb.y,Y[w+6]=eb.z,Y[w+7]=1,Y[w+8]=fb.x,Y[w+9]=fb.y,Y[w+10]=fb.z,Y[w+11]=1,gb=xb[x.a],hb=xb[x.b],ib=xb[x.c],Z[w]=gb.x,Z[w+1]=gb.y,Z[w+2]=gb.z,Z[w+3]=1,Z[w+4]=hb.x,Z[w+5]=hb.y,Z[w+6]=hb.z,Z[w+7]=1,Z[w+8]=ib.x,Z[w+9]=ib.y,Z[w+10]=ib.z,Z[w+11]=1,w+=12;for(u=0,B=S.length;u<B;u++)x=ga[S[u]],Oa=kb[x.a],Pa=kb[x.b],Qa=kb[x.c],Ub=kb[x.d],aa[w]=Oa.x,aa[w+1]=Oa.y,aa[w+2]=Oa.z,aa[w+3]=Oa.w,aa[w+4]=Pa.x,
-aa[w+5]=Pa.y,aa[w+6]=Pa.z,aa[w+7]=Pa.w,aa[w+8]=Qa.x,aa[w+9]=Qa.y,aa[w+10]=Qa.z,aa[w+11]=Qa.w,aa[w+12]=Ub.x,aa[w+13]=Ub.y,aa[w+14]=Ub.z,aa[w+15]=Ub.w,Ra=yb[x.a],Sa=yb[x.b],Ta=yb[x.c],Vb=yb[x.d],$[w]=Ra.x,$[w+1]=Ra.y,$[w+2]=Ra.z,$[w+3]=Ra.w,$[w+4]=Sa.x,$[w+5]=Sa.y,$[w+6]=Sa.z,$[w+7]=Sa.w,$[w+8]=Ta.x,$[w+9]=Ta.y,$[w+10]=Ta.z,$[w+11]=Ta.w,$[w+12]=Vb.x,$[w+13]=Vb.y,$[w+14]=Vb.z,$[w+15]=Vb.w,db=wb[x.a],eb=wb[x.b],fb=wb[x.c],lc=wb[x.d],Y[w]=db.x,Y[w+1]=db.y,Y[w+2]=db.z,Y[w+3]=1,Y[w+4]=eb.x,Y[w+5]=eb.y,Y[w+
-6]=eb.z,Y[w+7]=1,Y[w+8]=fb.x,Y[w+9]=fb.y,Y[w+10]=fb.z,Y[w+11]=1,Y[w+12]=lc.x,Y[w+13]=lc.y,Y[w+14]=lc.z,Y[w+15]=1,gb=xb[x.a],hb=xb[x.b],ib=xb[x.c],mc=xb[x.d],Z[w]=gb.x,Z[w+1]=gb.y,Z[w+2]=gb.z,Z[w+3]=1,Z[w+4]=hb.x,Z[w+5]=hb.y,Z[w+6]=hb.z,Z[w+7]=1,Z[w+8]=ib.x,Z[w+9]=ib.y,Z[w+10]=ib.z,Z[w+11]=1,Z[w+12]=mc.x,Z[w+13]=mc.y,Z[w+14]=mc.z,Z[w+15]=1,w+=16;0<w&&(f.bindBuffer(f.ARRAY_BUFFER,N.__webglSkinVertexABuffer),f.bufferData(f.ARRAY_BUFFER,Y,xa),f.bindBuffer(f.ARRAY_BUFFER,N.__webglSkinVertexBBuffer),f.bufferData(f.ARRAY_BUFFER,
-Z,xa),f.bindBuffer(f.ARRAY_BUFFER,N.__webglSkinIndicesBuffer),f.bufferData(f.ARRAY_BUFFER,$,xa),f.bindBuffer(f.ARRAY_BUFFER,N.__webglSkinWeightsBuffer),f.bufferData(f.ARRAY_BUFFER,aa,xa))}if(Tc&&Bc){for(u=0,B=R.length;u<B;u++)x=ga[R[u]],Ga=x.vertexColors,kc=x.color,3===Ga.length&&Bc===THREE.VertexColors?(La=Ga[0],Ma=Ga[1],Na=Ga[2]):Na=Ma=La=kc,na[ea]=La.r,na[ea+1]=La.g,na[ea+2]=La.b,na[ea+3]=Ma.r,na[ea+4]=Ma.g,na[ea+5]=Ma.b,na[ea+6]=Na.r,na[ea+7]=Na.g,na[ea+8]=Na.b,ea+=9;for(u=0,B=S.length;u<B;u++)x=
-ga[S[u]],Ga=x.vertexColors,kc=x.color,4===Ga.length&&Bc===THREE.VertexColors?(La=Ga[0],Ma=Ga[1],Na=Ga[2],Tb=Ga[3]):Tb=Na=Ma=La=kc,na[ea]=La.r,na[ea+1]=La.g,na[ea+2]=La.b,na[ea+3]=Ma.r,na[ea+4]=Ma.g,na[ea+5]=Ma.b,na[ea+6]=Na.r,na[ea+7]=Na.g,na[ea+8]=Na.b,na[ea+9]=Tb.r,na[ea+10]=Tb.g,na[ea+11]=Tb.b,ea+=12;0<ea&&(f.bindBuffer(f.ARRAY_BUFFER,N.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,na,xa))}if(Sc&&ra.hasTangents){for(u=0,B=R.length;u<B;u++)x=ga[R[u]],Xa=x.vertexTangents,Ia=Xa[0],Ja=Xa[1],Ka=Xa[2],
-X[V]=Ia.x,X[V+1]=Ia.y,X[V+2]=Ia.z,X[V+3]=Ia.w,X[V+4]=Ja.x,X[V+5]=Ja.y,X[V+6]=Ja.z,X[V+7]=Ja.w,X[V+8]=Ka.x,X[V+9]=Ka.y,X[V+10]=Ka.z,X[V+11]=Ka.w,V+=12;for(u=0,B=S.length;u<B;u++)x=ga[S[u]],Xa=x.vertexTangents,Ia=Xa[0],Ja=Xa[1],Ka=Xa[2],Sb=Xa[3],X[V]=Ia.x,X[V+1]=Ia.y,X[V+2]=Ia.z,X[V+3]=Ia.w,X[V+4]=Ja.x,X[V+5]=Ja.y,X[V+6]=Ja.z,X[V+7]=Ja.w,X[V+8]=Ka.x,X[V+9]=Ka.y,X[V+10]=Ka.z,X[V+11]=Ka.w,X[V+12]=Sb.x,X[V+13]=Sb.y,X[V+14]=Sb.z,X[V+15]=Sb.w,V+=16;f.bindBuffer(f.ARRAY_BUFFER,N.__webglTangentBuffer);f.bufferData(f.ARRAY_BUFFER,
-X,xa)}if(Rc&&Lb){for(u=0,B=R.length;u<B;u++)if(x=ga[R[u]],Eb=x.vertexNormals,cb=x.normal,3===Eb.length&&Nb)for(Q=0;3>Q;Q++)jb=Eb[Q],Ba[pa]=jb.x,Ba[pa+1]=jb.y,Ba[pa+2]=jb.z,pa+=3;else for(Q=0;3>Q;Q++)Ba[pa]=cb.x,Ba[pa+1]=cb.y,Ba[pa+2]=cb.z,pa+=3;for(u=0,B=S.length;u<B;u++)if(x=ga[S[u]],Eb=x.vertexNormals,cb=x.normal,4===Eb.length&&Nb)for(Q=0;4>Q;Q++)jb=Eb[Q],Ba[pa]=jb.x,Ba[pa+1]=jb.y,Ba[pa+2]=jb.z,pa+=3;else for(Q=0;4>Q;Q++)Ba[pa]=cb.x,Ba[pa+1]=cb.y,Ba[pa+2]=cb.z,pa+=3;f.bindBuffer(f.ARRAY_BUFFER,
-N.__webglNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Ba,xa)}if(Jc&&Ec&&Mb){for(u=0,B=R.length;u<B;u++)if(Ea=R[u],x=ga[Ea],Fb=Ec[Ea],void 0!==Fb)for(Q=0;3>Q;Q++)Hb=Fb[Q],Wb[Ya]=Hb.u,Wb[Ya+1]=Hb.v,Ya+=2;for(u=0,B=S.length;u<B;u++)if(Ea=S[u],x=ga[Ea],Fb=Ec[Ea],void 0!==Fb)for(Q=0;4>Q;Q++)Hb=Fb[Q],Wb[Ya]=Hb.u,Wb[Ya+1]=Hb.v,Ya+=2;0<Ya&&(f.bindBuffer(f.ARRAY_BUFFER,N.__webglUVBuffer),f.bufferData(f.ARRAY_BUFFER,Wb,xa))}if(Jc&&Fc&&Mb){for(u=0,B=R.length;u<B;u++)if(Ea=R[u],x=ga[Ea],Gb=Fc[Ea],void 0!==Gb)for(Q=
-0;3>Q;Q++)Ib=Gb[Q],Xb[Za]=Ib.u,Xb[Za+1]=Ib.v,Za+=2;for(u=0,B=S.length;u<B;u++)if(Ea=S[u],x=ga[Ea],Gb=Fc[Ea],void 0!==Gb)for(Q=0;4>Q;Q++)Ib=Gb[Q],Xb[Za]=Ib.u,Xb[Za+1]=Ib.v,Za+=2;0<Za&&(f.bindBuffer(f.ARRAY_BUFFER,N.__webglUV2Buffer),f.bufferData(f.ARRAY_BUFFER,Xb,xa))}if(wc){for(u=0,B=R.length;u<B;u++)x=ga[R[u]],Ua[Aa]=da,Ua[Aa+1]=da+1,Ua[Aa+2]=da+2,Aa+=3,va[qa]=da,va[qa+1]=da+1,va[qa+2]=da,va[qa+3]=da+2,va[qa+4]=da+1,va[qa+5]=da+2,qa+=6,da+=3;for(u=0,B=S.length;u<B;u++)x=ga[S[u]],Ua[Aa]=da,Ua[Aa+
-1]=da+1,Ua[Aa+2]=da+3,Ua[Aa+3]=da+1,Ua[Aa+4]=da+2,Ua[Aa+5]=da+3,Aa+=6,va[qa]=da,va[qa+1]=da+1,va[qa+2]=da,va[qa+3]=da+3,va[qa+4]=da+1,va[qa+5]=da+2,va[qa+6]=da+2,va[qa+7]=da+3,qa+=8,da+=4;f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,N.__webglFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ua,xa);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,N.__webglLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,va,xa)}if(Dc)for(Q=0,Pb=Dc.length;Q<Pb;Q++)if(q=Dc[Q],q.__original.needsUpdate){s=0;if(1===q.size)if(void 0===q.boundTo||
-"vertices"===q.boundTo){for(u=0,B=R.length;u<B;u++)x=ga[R[u]],q.array[s]=q.value[x.a],q.array[s+1]=q.value[x.b],q.array[s+2]=q.value[x.c],s+=3;for(u=0,B=S.length;u<B;u++)x=ga[S[u]],q.array[s]=q.value[x.a],q.array[s+1]=q.value[x.b],q.array[s+2]=q.value[x.c],q.array[s+3]=q.value[x.d],s+=4}else{if("faces"===q.boundTo){for(u=0,B=R.length;u<B;u++)ua=q.value[R[u]],q.array[s]=ua,q.array[s+1]=ua,q.array[s+2]=ua,s+=3;for(u=0,B=S.length;u<B;u++)ua=q.value[S[u]],q.array[s]=ua,q.array[s+1]=ua,q.array[s+2]=ua,
-q.array[s+3]=ua,s+=4}}else if(2===q.size)if(void 0===q.boundTo||"vertices"===q.boundTo){for(u=0,B=R.length;u<B;u++)x=ga[R[u]],C=q.value[x.a],D=q.value[x.b],E=q.value[x.c],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=D.x,q.array[s+3]=D.y,q.array[s+4]=E.x,q.array[s+5]=E.y,s+=6;for(u=0,B=S.length;u<B;u++)x=ga[S[u]],C=q.value[x.a],D=q.value[x.b],E=q.value[x.c],U=q.value[x.d],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=D.x,q.array[s+3]=D.y,q.array[s+4]=E.x,q.array[s+5]=E.y,q.array[s+6]=U.x,q.array[s+
-7]=U.y,s+=8}else{if("faces"===q.boundTo){for(u=0,B=R.length;u<B;u++)E=D=C=ua=q.value[R[u]],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=D.x,q.array[s+3]=D.y,q.array[s+4]=E.x,q.array[s+5]=E.y,s+=6;for(u=0,B=S.length;u<B;u++)U=E=D=C=ua=q.value[S[u]],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=D.x,q.array[s+3]=D.y,q.array[s+4]=E.x,q.array[s+5]=E.y,q.array[s+6]=U.x,q.array[s+7]=U.y,s+=8}}else if(3===q.size){var O;O="c"===q.type?["r","g","b"]:["x","y","z"];if(void 0===q.boundTo||"vertices"===q.boundTo){for(u=
-0,B=R.length;u<B;u++)x=ga[R[u]],C=q.value[x.a],D=q.value[x.b],E=q.value[x.c],q.array[s]=C[O[0]],q.array[s+1]=C[O[1]],q.array[s+2]=C[O[2]],q.array[s+3]=D[O[0]],q.array[s+4]=D[O[1]],q.array[s+5]=D[O[2]],q.array[s+6]=E[O[0]],q.array[s+7]=E[O[1]],q.array[s+8]=E[O[2]],s+=9;for(u=0,B=S.length;u<B;u++)x=ga[S[u]],C=q.value[x.a],D=q.value[x.b],E=q.value[x.c],U=q.value[x.d],q.array[s]=C[O[0]],q.array[s+1]=C[O[1]],q.array[s+2]=C[O[2]],q.array[s+3]=D[O[0]],q.array[s+4]=D[O[1]],q.array[s+5]=D[O[2]],q.array[s+
-6]=E[O[0]],q.array[s+7]=E[O[1]],q.array[s+8]=E[O[2]],q.array[s+9]=U[O[0]],q.array[s+10]=U[O[1]],q.array[s+11]=U[O[2]],s+=12}else if("faces"===q.boundTo){for(u=0,B=R.length;u<B;u++)E=D=C=ua=q.value[R[u]],q.array[s]=C[O[0]],q.array[s+1]=C[O[1]],q.array[s+2]=C[O[2]],q.array[s+3]=D[O[0]],q.array[s+4]=D[O[1]],q.array[s+5]=D[O[2]],q.array[s+6]=E[O[0]],q.array[s+7]=E[O[1]],q.array[s+8]=E[O[2]],s+=9;for(u=0,B=S.length;u<B;u++)U=E=D=C=ua=q.value[S[u]],q.array[s]=C[O[0]],q.array[s+1]=C[O[1]],q.array[s+2]=C[O[2]],
-q.array[s+3]=D[O[0]],q.array[s+4]=D[O[1]],q.array[s+5]=D[O[2]],q.array[s+6]=E[O[0]],q.array[s+7]=E[O[1]],q.array[s+8]=E[O[2]],q.array[s+9]=U[O[0]],q.array[s+10]=U[O[1]],q.array[s+11]=U[O[2]],s+=12}}else if(4===q.size)if(void 0===q.boundTo||"vertices"===q.boundTo){for(u=0,B=R.length;u<B;u++)x=ga[R[u]],C=q.value[x.a],D=q.value[x.b],E=q.value[x.c],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=C.z,q.array[s+3]=C.w,q.array[s+4]=D.x,q.array[s+5]=D.y,q.array[s+6]=D.z,q.array[s+7]=D.w,q.array[s+8]=E.x,q.array[s+
-9]=E.y,q.array[s+10]=E.z,q.array[s+11]=E.w,s+=12;for(u=0,B=S.length;u<B;u++)x=ga[S[u]],C=q.value[x.a],D=q.value[x.b],E=q.value[x.c],U=q.value[x.d],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=C.z,q.array[s+3]=C.w,q.array[s+4]=D.x,q.array[s+5]=D.y,q.array[s+6]=D.z,q.array[s+7]=D.w,q.array[s+8]=E.x,q.array[s+9]=E.y,q.array[s+10]=E.z,q.array[s+11]=E.w,q.array[s+12]=U.x,q.array[s+13]=U.y,q.array[s+14]=U.z,q.array[s+15]=U.w,s+=16}else if("faces"===q.boundTo){for(u=0,B=R.length;u<B;u++)E=D=C=ua=q.value[R[u]],
-q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=C.z,q.array[s+3]=C.w,q.array[s+4]=D.x,q.array[s+5]=D.y,q.array[s+6]=D.z,q.array[s+7]=D.w,q.array[s+8]=E.x,q.array[s+9]=E.y,q.array[s+10]=E.z,q.array[s+11]=E.w,s+=12;for(u=0,B=S.length;u<B;u++)U=E=D=C=ua=q.value[S[u]],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=C.z,q.array[s+3]=C.w,q.array[s+4]=D.x,q.array[s+5]=D.y,q.array[s+6]=D.z,q.array[s+7]=D.w,q.array[s+8]=E.x,q.array[s+9]=E.y,q.array[s+10]=E.z,q.array[s+11]=E.w,q.array[s+12]=U.x,q.array[s+13]=U.y,
-q.array[s+14]=U.z,q.array[s+15]=U.w,s+=16}f.bindBuffer(f.ARRAY_BUFFER,q.buffer);f.bufferData(f.ARRAY_BUFFER,q.array,xa)}fc&&(delete N.__inittedArrays,delete N.__colorArray,delete N.__normalArray,delete N.__tangentArray,delete N.__uvArray,delete N.__uv2Array,delete N.__faceArray,delete N.__vertexArray,delete N.__lineArray,delete N.__skinVertexAArray,delete N.__skinVertexBArray,delete N.__skinIndexArray,delete N.__skinWeightArray)}}P.__dirtyVertices=!1;P.__dirtyMorphTargets=!1;P.__dirtyElements=!1;
-P.__dirtyUvs=!1;P.__dirtyNormals=!1;P.__dirtyColors=!1;P.__dirtyTangents=!1;sa.attributes&&m(sa)}else if(Fa instanceof THREE.Ribbon){if(P.__dirtyVertices||P.__dirtyColors){var mb=P,Kc=f.DYNAMIC_DRAW,Yb=void 0,Zb=void 0,nc=void 0,nb=void 0,oc=void 0,Lc=mb.vertices,Mc=mb.colors,Vc=Lc.length,Wc=Mc.length,pc=mb.__vertexArray,qc=mb.__colorArray,Xc=mb.__dirtyColors;if(mb.__dirtyVertices){for(Yb=0;Yb<Vc;Yb++)nc=Lc[Yb].position,nb=3*Yb,pc[nb]=nc.x,pc[nb+1]=nc.y,pc[nb+2]=nc.z;f.bindBuffer(f.ARRAY_BUFFER,mb.__webglVertexBuffer);
-f.bufferData(f.ARRAY_BUFFER,pc,Kc)}if(Xc){for(Zb=0;Zb<Wc;Zb++)oc=Mc[Zb],nb=3*Zb,qc[nb]=oc.r,qc[nb+1]=oc.g,qc[nb+2]=oc.b;f.bindBuffer(f.ARRAY_BUFFER,mb.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,qc,Kc)}}P.__dirtyVertices=!1;P.__dirtyColors=!1}else if(Fa instanceof THREE.Line){sa=c(Fa,Rb);Db=sa.attributes&&n(sa);if(P.__dirtyVertices||P.__dirtyColors||Db){var $a=P,Gc=f.DYNAMIC_DRAW,$b=void 0,ac=void 0,rc=void 0,ba=void 0,sc=void 0,Nc=$a.vertices,Oc=$a.colors,Yc=Nc.length,Zc=Oc.length,tc=$a.__vertexArray,
-uc=$a.__colorArray,$c=$a.__dirtyColors,Hc=$a.__webglCustomAttributesList,vc=void 0,Pc=void 0,oa=void 0,Jb=void 0,ta=void 0,W=void 0;if($a.__dirtyVertices){for($b=0;$b<Yc;$b++)rc=Nc[$b].position,ba=3*$b,tc[ba]=rc.x,tc[ba+1]=rc.y,tc[ba+2]=rc.z;f.bindBuffer(f.ARRAY_BUFFER,$a.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,tc,Gc)}if($c){for(ac=0;ac<Zc;ac++)sc=Oc[ac],ba=3*ac,uc[ba]=sc.r,uc[ba+1]=sc.g,uc[ba+2]=sc.b;f.bindBuffer(f.ARRAY_BUFFER,$a.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,uc,Gc)}if(Hc)for(vc=
-0,Pc=Hc.length;vc<Pc;vc++)if(W=Hc[vc],W.needsUpdate&&(void 0===W.boundTo||"vertices"===W.boundTo)){ba=0;Jb=W.value.length;if(1===W.size)for(oa=0;oa<Jb;oa++)W.array[oa]=W.value[oa];else if(2===W.size)for(oa=0;oa<Jb;oa++)ta=W.value[oa],W.array[ba]=ta.x,W.array[ba+1]=ta.y,ba+=2;else if(3===W.size)if("c"===W.type)for(oa=0;oa<Jb;oa++)ta=W.value[oa],W.array[ba]=ta.r,W.array[ba+1]=ta.g,W.array[ba+2]=ta.b,ba+=3;else for(oa=0;oa<Jb;oa++)ta=W.value[oa],W.array[ba]=ta.x,W.array[ba+1]=ta.y,W.array[ba+2]=ta.z,
-ba+=3;else if(4===W.size)for(oa=0;oa<Jb;oa++)ta=W.value[oa],W.array[ba]=ta.x,W.array[ba+1]=ta.y,W.array[ba+2]=ta.z,W.array[ba+3]=ta.w,ba+=4;f.bindBuffer(f.ARRAY_BUFFER,W.buffer);f.bufferData(f.ARRAY_BUFFER,W.array,Gc)}}P.__dirtyVertices=!1;P.__dirtyColors=!1;sa.attributes&&m(sa)}else if(Fa instanceof THREE.ParticleSystem)sa=c(Fa,Rb),Db=sa.attributes&&n(sa),(P.__dirtyVertices||P.__dirtyColors||Fa.sortParticles||Db)&&e(P,f.DYNAMIC_DRAW,Fa),P.__dirtyVertices=!1,P.__dirtyColors=!1,sa.attributes&&m(sa)}};
-this.initMaterial=function(a,b,c,d){var e,g,h,i,j;a instanceof THREE.MeshDepthMaterial?j="depth":a instanceof THREE.MeshNormalMaterial?j="normal":a instanceof THREE.MeshBasicMaterial?j="basic":a instanceof THREE.MeshLambertMaterial?j="lambert":a instanceof THREE.MeshPhongMaterial?j="phong":a instanceof THREE.LineBasicMaterial?j="basic":a instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var k=THREE.ShaderLib[j];a.uniforms=THREE.UniformsUtils.clone(k.uniforms);a.vertexShader=k.vertexShader;
-a.fragmentShader=k.fragmentShader}var l,n;g=k=0;for(l=0,n=b.length;l<n;l++)e=b[l],e instanceof THREE.SpotLight&&!e.onlyShadow&&g++,e instanceof THREE.DirectionalLight&&g++,e instanceof THREE.PointLight&&k++;k+g<=ca?l=g:(l=Math.ceil(ca*g/(k+g)),k=ca-l);e=l;g=k;var m=0;for(k=0,l=b.length;k<l;k++)n=b[k],n instanceof THREE.SpotLight&&n.castShadow&&m++;var p=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)p=d.bones.length;var o;a:{l=a.fragmentShader;n=a.vertexShader;var k=a.uniforms,b=a.attributes,c=
-{map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:e,maxPointLights:g,maxBones:p,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:m,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround},
-r,d=[];j?d.push(j):(d.push(l),d.push(n));for(r in c)d.push(r),d.push(c[r]);j=d.join();for(r=0,d=Ha.length;r<d;r++)if(Ha[r].code===j){o=Ha[r].program;break a}r=f.createProgram();d=[0<Pb?"#define VERTEX_TEXTURES":"",z.gammaInput?"#define GAMMA_INPUT":"",z.gammaOutput?"#define GAMMA_OUTPUT":"",z.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,"#define MAX_BONES "+c.maxBones,
+a.__objectsRemoved[0],hc=a;za instanceof THREE.Mesh||za instanceof THREE.ParticleSystem||za instanceof THREE.Ribbon||za instanceof THREE.Line?o(hc.__webglObjects,za):za instanceof THREE.Sprite?p(hc.__webglSprites,za):za instanceof THREE.LensFlare?p(hc.__webglFlares,za):(za instanceof THREE.MarchingCubes||za.immediateRenderCallback)&&o(hc.__webglObjectsImmediate,za);za.__webglActive=!1;a.__objectsRemoved.splice(0,1)}for(var yc=0,bc=a.__webglObjects.length;yc<bc;yc++){var Fa=a.__webglObjects[yc].object,
+P=Fa.geometry,Pb=void 0,Db=void 0,sa=void 0;if(Fa instanceof THREE.Mesh)if(P instanceof THREE.BufferGeometry)P.__dirtyVertices=!1,P.__dirtyElements=!1,P.__dirtyUvs=!1,P.__dirtyNormals=!1,P.__dirtyColors=!1;else{for(var zc=0,cc=P.geometryGroupsList.length;zc<cc;zc++)if(Pb=P.geometryGroupsList[zc],sa=c(Fa,Pb),Db=sa.attributes&&n(sa),P.__dirtyVertices||P.__dirtyMorphTargets||P.__dirtyElements||P.__dirtyUvs||P.__dirtyNormals||P.__dirtyColors||P.__dirtyTangents||Db){var N=Pb,dc=Fa,xa=e.DYNAMIC_DRAW,ec=
+!P.dynamic,ic=sa;if(N.__inittedArrays){var Lb=d(ic),Ac=ic.vertexColors?ic.vertexColors:!1,Mb=g(ic),Nb=Lb===THREE.SmoothShading,u=void 0,B=void 0,Ea=void 0,x=void 0,Eb=void 0,bb=void 0,Ga=void 0,jc=void 0,Wa=void 0,Fb=void 0,Gb=void 0,C=void 0,D=void 0,E=void 0,T=void 0,Ia=void 0,Ja=void 0,Ka=void 0,Qb=void 0,La=void 0,Ma=void 0,Na=void 0,Rb=void 0,Oa=void 0,Pa=void 0,Qa=void 0,Sb=void 0,Ra=void 0,Sa=void 0,Ta=void 0,Tb=void 0,cb=void 0,db=void 0,eb=void 0,kc=void 0,fb=void 0,gb=void 0,hb=void 0,lc=
+void 0,Q=void 0,Hc=void 0,ib=void 0,Hb=void 0,Ib=void 0,ya=void 0,Ic=void 0,ja=void 0,ca=0,ia=0,Xa=0,Ya=0,Aa=0,na=0,U=0,pa=0,da=0,w=0,ea=0,s=0,ua=void 0,ka=N.__vertexArray,Ub=N.__uvArray,Vb=N.__uv2Array,Ba=N.__normalArray,X=N.__tangentArray,la=N.__colorArray,Y=N.__skinVertexAArray,Z=N.__skinVertexBArray,$=N.__skinIndexArray,aa=N.__skinWeightArray,Bc=N.__morphTargetsArrays,Cc=N.__webglCustomAttributesList,q=void 0,Ua=N.__faceArray,va=N.__lineArray,ra=dc.geometry,vc=ra.__dirtyElements,Jc=ra.__dirtyUvs,
+Rc=ra.__dirtyNormals,Sc=ra.__dirtyTangents,Tc=ra.__dirtyColors,Uc=ra.__dirtyMorphTargets,ub=ra.vertices,R=N.faces3,S=N.faces4,fa=ra.faces,Dc=ra.faceVertexUvs[0],Ec=ra.faceVertexUvs[1],vb=ra.skinVerticesA,wb=ra.skinVerticesB,xb=ra.skinIndices,jb=ra.skinWeights,kb=ra.morphTargets;if(ra.__dirtyVertices){for(u=0,B=R.length;u<B;u++)x=fa[R[u]],C=ub[x.a].position,D=ub[x.b].position,E=ub[x.c].position,ka[ia]=C.x,ka[ia+1]=C.y,ka[ia+2]=C.z,ka[ia+3]=D.x,ka[ia+4]=D.y,ka[ia+5]=D.z,ka[ia+6]=E.x,ka[ia+7]=E.y,ka[ia+
+8]=E.z,ia+=9;for(u=0,B=S.length;u<B;u++)x=fa[S[u]],C=ub[x.a].position,D=ub[x.b].position,E=ub[x.c].position,T=ub[x.d].position,ka[ia]=C.x,ka[ia+1]=C.y,ka[ia+2]=C.z,ka[ia+3]=D.x,ka[ia+4]=D.y,ka[ia+5]=D.z,ka[ia+6]=E.x,ka[ia+7]=E.y,ka[ia+8]=E.z,ka[ia+9]=T.x,ka[ia+10]=T.y,ka[ia+11]=T.z,ia+=12;e.bindBuffer(e.ARRAY_BUFFER,N.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,ka,xa)}if(Uc)for(ya=0,Ic=kb.length;ya<Ic;ya++){ea=0;for(u=0,B=R.length;u<B;u++)x=fa[R[u]],C=kb[ya].vertices[x.a].position,D=kb[ya].vertices[x.b].position,
+E=kb[ya].vertices[x.c].position,ja=Bc[ya],ja[ea]=C.x,ja[ea+1]=C.y,ja[ea+2]=C.z,ja[ea+3]=D.x,ja[ea+4]=D.y,ja[ea+5]=D.z,ja[ea+6]=E.x,ja[ea+7]=E.y,ja[ea+8]=E.z,ea+=9;for(u=0,B=S.length;u<B;u++)x=fa[S[u]],C=kb[ya].vertices[x.a].position,D=kb[ya].vertices[x.b].position,E=kb[ya].vertices[x.c].position,T=kb[ya].vertices[x.d].position,ja=Bc[ya],ja[ea]=C.x,ja[ea+1]=C.y,ja[ea+2]=C.z,ja[ea+3]=D.x,ja[ea+4]=D.y,ja[ea+5]=D.z,ja[ea+6]=E.x,ja[ea+7]=E.y,ja[ea+8]=E.z,ja[ea+9]=T.x,ja[ea+10]=T.y,ja[ea+11]=T.z,ea+=12;
+e.bindBuffer(e.ARRAY_BUFFER,N.__webglMorphTargetsBuffers[ya]);e.bufferData(e.ARRAY_BUFFER,Bc[ya],xa)}if(jb.length){for(u=0,B=R.length;u<B;u++)x=fa[R[u]],Oa=jb[x.a],Pa=jb[x.b],Qa=jb[x.c],aa[w]=Oa.x,aa[w+1]=Oa.y,aa[w+2]=Oa.z,aa[w+3]=Oa.w,aa[w+4]=Pa.x,aa[w+5]=Pa.y,aa[w+6]=Pa.z,aa[w+7]=Pa.w,aa[w+8]=Qa.x,aa[w+9]=Qa.y,aa[w+10]=Qa.z,aa[w+11]=Qa.w,Ra=xb[x.a],Sa=xb[x.b],Ta=xb[x.c],$[w]=Ra.x,$[w+1]=Ra.y,$[w+2]=Ra.z,$[w+3]=Ra.w,$[w+4]=Sa.x,$[w+5]=Sa.y,$[w+6]=Sa.z,$[w+7]=Sa.w,$[w+8]=Ta.x,$[w+9]=Ta.y,$[w+10]=
+Ta.z,$[w+11]=Ta.w,cb=vb[x.a],db=vb[x.b],eb=vb[x.c],Y[w]=cb.x,Y[w+1]=cb.y,Y[w+2]=cb.z,Y[w+3]=1,Y[w+4]=db.x,Y[w+5]=db.y,Y[w+6]=db.z,Y[w+7]=1,Y[w+8]=eb.x,Y[w+9]=eb.y,Y[w+10]=eb.z,Y[w+11]=1,fb=wb[x.a],gb=wb[x.b],hb=wb[x.c],Z[w]=fb.x,Z[w+1]=fb.y,Z[w+2]=fb.z,Z[w+3]=1,Z[w+4]=gb.x,Z[w+5]=gb.y,Z[w+6]=gb.z,Z[w+7]=1,Z[w+8]=hb.x,Z[w+9]=hb.y,Z[w+10]=hb.z,Z[w+11]=1,w+=12;for(u=0,B=S.length;u<B;u++)x=fa[S[u]],Oa=jb[x.a],Pa=jb[x.b],Qa=jb[x.c],Sb=jb[x.d],aa[w]=Oa.x,aa[w+1]=Oa.y,aa[w+2]=Oa.z,aa[w+3]=Oa.w,aa[w+4]=Pa.x,
+aa[w+5]=Pa.y,aa[w+6]=Pa.z,aa[w+7]=Pa.w,aa[w+8]=Qa.x,aa[w+9]=Qa.y,aa[w+10]=Qa.z,aa[w+11]=Qa.w,aa[w+12]=Sb.x,aa[w+13]=Sb.y,aa[w+14]=Sb.z,aa[w+15]=Sb.w,Ra=xb[x.a],Sa=xb[x.b],Ta=xb[x.c],Tb=xb[x.d],$[w]=Ra.x,$[w+1]=Ra.y,$[w+2]=Ra.z,$[w+3]=Ra.w,$[w+4]=Sa.x,$[w+5]=Sa.y,$[w+6]=Sa.z,$[w+7]=Sa.w,$[w+8]=Ta.x,$[w+9]=Ta.y,$[w+10]=Ta.z,$[w+11]=Ta.w,$[w+12]=Tb.x,$[w+13]=Tb.y,$[w+14]=Tb.z,$[w+15]=Tb.w,cb=vb[x.a],db=vb[x.b],eb=vb[x.c],kc=vb[x.d],Y[w]=cb.x,Y[w+1]=cb.y,Y[w+2]=cb.z,Y[w+3]=1,Y[w+4]=db.x,Y[w+5]=db.y,Y[w+
+6]=db.z,Y[w+7]=1,Y[w+8]=eb.x,Y[w+9]=eb.y,Y[w+10]=eb.z,Y[w+11]=1,Y[w+12]=kc.x,Y[w+13]=kc.y,Y[w+14]=kc.z,Y[w+15]=1,fb=wb[x.a],gb=wb[x.b],hb=wb[x.c],lc=wb[x.d],Z[w]=fb.x,Z[w+1]=fb.y,Z[w+2]=fb.z,Z[w+3]=1,Z[w+4]=gb.x,Z[w+5]=gb.y,Z[w+6]=gb.z,Z[w+7]=1,Z[w+8]=hb.x,Z[w+9]=hb.y,Z[w+10]=hb.z,Z[w+11]=1,Z[w+12]=lc.x,Z[w+13]=lc.y,Z[w+14]=lc.z,Z[w+15]=1,w+=16;0<w&&(e.bindBuffer(e.ARRAY_BUFFER,N.__webglSkinVertexABuffer),e.bufferData(e.ARRAY_BUFFER,Y,xa),e.bindBuffer(e.ARRAY_BUFFER,N.__webglSkinVertexBBuffer),e.bufferData(e.ARRAY_BUFFER,
+Z,xa),e.bindBuffer(e.ARRAY_BUFFER,N.__webglSkinIndicesBuffer),e.bufferData(e.ARRAY_BUFFER,$,xa),e.bindBuffer(e.ARRAY_BUFFER,N.__webglSkinWeightsBuffer),e.bufferData(e.ARRAY_BUFFER,aa,xa))}if(Tc&&Ac){for(u=0,B=R.length;u<B;u++)x=fa[R[u]],Ga=x.vertexColors,jc=x.color,3===Ga.length&&Ac===THREE.VertexColors?(La=Ga[0],Ma=Ga[1],Na=Ga[2]):Na=Ma=La=jc,la[da]=La.r,la[da+1]=La.g,la[da+2]=La.b,la[da+3]=Ma.r,la[da+4]=Ma.g,la[da+5]=Ma.b,la[da+6]=Na.r,la[da+7]=Na.g,la[da+8]=Na.b,da+=9;for(u=0,B=S.length;u<B;u++)x=
+fa[S[u]],Ga=x.vertexColors,jc=x.color,4===Ga.length&&Ac===THREE.VertexColors?(La=Ga[0],Ma=Ga[1],Na=Ga[2],Rb=Ga[3]):Rb=Na=Ma=La=jc,la[da]=La.r,la[da+1]=La.g,la[da+2]=La.b,la[da+3]=Ma.r,la[da+4]=Ma.g,la[da+5]=Ma.b,la[da+6]=Na.r,la[da+7]=Na.g,la[da+8]=Na.b,la[da+9]=Rb.r,la[da+10]=Rb.g,la[da+11]=Rb.b,da+=12;0<da&&(e.bindBuffer(e.ARRAY_BUFFER,N.__webglColorBuffer),e.bufferData(e.ARRAY_BUFFER,la,xa))}if(Sc&&ra.hasTangents){for(u=0,B=R.length;u<B;u++)x=fa[R[u]],Wa=x.vertexTangents,Ia=Wa[0],Ja=Wa[1],Ka=Wa[2],
+X[U]=Ia.x,X[U+1]=Ia.y,X[U+2]=Ia.z,X[U+3]=Ia.w,X[U+4]=Ja.x,X[U+5]=Ja.y,X[U+6]=Ja.z,X[U+7]=Ja.w,X[U+8]=Ka.x,X[U+9]=Ka.y,X[U+10]=Ka.z,X[U+11]=Ka.w,U+=12;for(u=0,B=S.length;u<B;u++)x=fa[S[u]],Wa=x.vertexTangents,Ia=Wa[0],Ja=Wa[1],Ka=Wa[2],Qb=Wa[3],X[U]=Ia.x,X[U+1]=Ia.y,X[U+2]=Ia.z,X[U+3]=Ia.w,X[U+4]=Ja.x,X[U+5]=Ja.y,X[U+6]=Ja.z,X[U+7]=Ja.w,X[U+8]=Ka.x,X[U+9]=Ka.y,X[U+10]=Ka.z,X[U+11]=Ka.w,X[U+12]=Qb.x,X[U+13]=Qb.y,X[U+14]=Qb.z,X[U+15]=Qb.w,U+=16;e.bindBuffer(e.ARRAY_BUFFER,N.__webglTangentBuffer);e.bufferData(e.ARRAY_BUFFER,
+X,xa)}if(Rc&&Lb){for(u=0,B=R.length;u<B;u++)if(x=fa[R[u]],Eb=x.vertexNormals,bb=x.normal,3===Eb.length&&Nb)for(Q=0;3>Q;Q++)ib=Eb[Q],Ba[na]=ib.x,Ba[na+1]=ib.y,Ba[na+2]=ib.z,na+=3;else for(Q=0;3>Q;Q++)Ba[na]=bb.x,Ba[na+1]=bb.y,Ba[na+2]=bb.z,na+=3;for(u=0,B=S.length;u<B;u++)if(x=fa[S[u]],Eb=x.vertexNormals,bb=x.normal,4===Eb.length&&Nb)for(Q=0;4>Q;Q++)ib=Eb[Q],Ba[na]=ib.x,Ba[na+1]=ib.y,Ba[na+2]=ib.z,na+=3;else for(Q=0;4>Q;Q++)Ba[na]=bb.x,Ba[na+1]=bb.y,Ba[na+2]=bb.z,na+=3;e.bindBuffer(e.ARRAY_BUFFER,
+N.__webglNormalBuffer);e.bufferData(e.ARRAY_BUFFER,Ba,xa)}if(Jc&&Dc&&Mb){for(u=0,B=R.length;u<B;u++)if(Ea=R[u],x=fa[Ea],Fb=Dc[Ea],void 0!==Fb)for(Q=0;3>Q;Q++)Hb=Fb[Q],Ub[Xa]=Hb.u,Ub[Xa+1]=Hb.v,Xa+=2;for(u=0,B=S.length;u<B;u++)if(Ea=S[u],x=fa[Ea],Fb=Dc[Ea],void 0!==Fb)for(Q=0;4>Q;Q++)Hb=Fb[Q],Ub[Xa]=Hb.u,Ub[Xa+1]=Hb.v,Xa+=2;0<Xa&&(e.bindBuffer(e.ARRAY_BUFFER,N.__webglUVBuffer),e.bufferData(e.ARRAY_BUFFER,Ub,xa))}if(Jc&&Ec&&Mb){for(u=0,B=R.length;u<B;u++)if(Ea=R[u],x=fa[Ea],Gb=Ec[Ea],void 0!==Gb)for(Q=
+0;3>Q;Q++)Ib=Gb[Q],Vb[Ya]=Ib.u,Vb[Ya+1]=Ib.v,Ya+=2;for(u=0,B=S.length;u<B;u++)if(Ea=S[u],x=fa[Ea],Gb=Ec[Ea],void 0!==Gb)for(Q=0;4>Q;Q++)Ib=Gb[Q],Vb[Ya]=Ib.u,Vb[Ya+1]=Ib.v,Ya+=2;0<Ya&&(e.bindBuffer(e.ARRAY_BUFFER,N.__webglUV2Buffer),e.bufferData(e.ARRAY_BUFFER,Vb,xa))}if(vc){for(u=0,B=R.length;u<B;u++)x=fa[R[u]],Ua[Aa]=ca,Ua[Aa+1]=ca+1,Ua[Aa+2]=ca+2,Aa+=3,va[pa]=ca,va[pa+1]=ca+1,va[pa+2]=ca,va[pa+3]=ca+2,va[pa+4]=ca+1,va[pa+5]=ca+2,pa+=6,ca+=3;for(u=0,B=S.length;u<B;u++)x=fa[S[u]],Ua[Aa]=ca,Ua[Aa+
+1]=ca+1,Ua[Aa+2]=ca+3,Ua[Aa+3]=ca+1,Ua[Aa+4]=ca+2,Ua[Aa+5]=ca+3,Aa+=6,va[pa]=ca,va[pa+1]=ca+1,va[pa+2]=ca,va[pa+3]=ca+3,va[pa+4]=ca+1,va[pa+5]=ca+2,va[pa+6]=ca+2,va[pa+7]=ca+3,pa+=8,ca+=4;e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,N.__webglFaceBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,Ua,xa);e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,N.__webglLineBuffer);e.bufferData(e.ELEMENT_ARRAY_BUFFER,va,xa)}if(Cc)for(Q=0,Hc=Cc.length;Q<Hc;Q++)if(q=Cc[Q],q.__original.needsUpdate){s=0;if(1===q.size)if(void 0===q.boundTo||
+"vertices"===q.boundTo){for(u=0,B=R.length;u<B;u++)x=fa[R[u]],q.array[s]=q.value[x.a],q.array[s+1]=q.value[x.b],q.array[s+2]=q.value[x.c],s+=3;for(u=0,B=S.length;u<B;u++)x=fa[S[u]],q.array[s]=q.value[x.a],q.array[s+1]=q.value[x.b],q.array[s+2]=q.value[x.c],q.array[s+3]=q.value[x.d],s+=4}else{if("faces"===q.boundTo){for(u=0,B=R.length;u<B;u++)ua=q.value[R[u]],q.array[s]=ua,q.array[s+1]=ua,q.array[s+2]=ua,s+=3;for(u=0,B=S.length;u<B;u++)ua=q.value[S[u]],q.array[s]=ua,q.array[s+1]=ua,q.array[s+2]=ua,
+q.array[s+3]=ua,s+=4}}else if(2===q.size)if(void 0===q.boundTo||"vertices"===q.boundTo){for(u=0,B=R.length;u<B;u++)x=fa[R[u]],C=q.value[x.a],D=q.value[x.b],E=q.value[x.c],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=D.x,q.array[s+3]=D.y,q.array[s+4]=E.x,q.array[s+5]=E.y,s+=6;for(u=0,B=S.length;u<B;u++)x=fa[S[u]],C=q.value[x.a],D=q.value[x.b],E=q.value[x.c],T=q.value[x.d],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=D.x,q.array[s+3]=D.y,q.array[s+4]=E.x,q.array[s+5]=E.y,q.array[s+6]=T.x,q.array[s+
+7]=T.y,s+=8}else{if("faces"===q.boundTo){for(u=0,B=R.length;u<B;u++)E=D=C=ua=q.value[R[u]],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=D.x,q.array[s+3]=D.y,q.array[s+4]=E.x,q.array[s+5]=E.y,s+=6;for(u=0,B=S.length;u<B;u++)T=E=D=C=ua=q.value[S[u]],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=D.x,q.array[s+3]=D.y,q.array[s+4]=E.x,q.array[s+5]=E.y,q.array[s+6]=T.x,q.array[s+7]=T.y,s+=8}}else if(3===q.size){var O;O="c"===q.type?["r","g","b"]:["x","y","z"];if(void 0===q.boundTo||"vertices"===q.boundTo){for(u=
+0,B=R.length;u<B;u++)x=fa[R[u]],C=q.value[x.a],D=q.value[x.b],E=q.value[x.c],q.array[s]=C[O[0]],q.array[s+1]=C[O[1]],q.array[s+2]=C[O[2]],q.array[s+3]=D[O[0]],q.array[s+4]=D[O[1]],q.array[s+5]=D[O[2]],q.array[s+6]=E[O[0]],q.array[s+7]=E[O[1]],q.array[s+8]=E[O[2]],s+=9;for(u=0,B=S.length;u<B;u++)x=fa[S[u]],C=q.value[x.a],D=q.value[x.b],E=q.value[x.c],T=q.value[x.d],q.array[s]=C[O[0]],q.array[s+1]=C[O[1]],q.array[s+2]=C[O[2]],q.array[s+3]=D[O[0]],q.array[s+4]=D[O[1]],q.array[s+5]=D[O[2]],q.array[s+
+6]=E[O[0]],q.array[s+7]=E[O[1]],q.array[s+8]=E[O[2]],q.array[s+9]=T[O[0]],q.array[s+10]=T[O[1]],q.array[s+11]=T[O[2]],s+=12}else if("faces"===q.boundTo){for(u=0,B=R.length;u<B;u++)E=D=C=ua=q.value[R[u]],q.array[s]=C[O[0]],q.array[s+1]=C[O[1]],q.array[s+2]=C[O[2]],q.array[s+3]=D[O[0]],q.array[s+4]=D[O[1]],q.array[s+5]=D[O[2]],q.array[s+6]=E[O[0]],q.array[s+7]=E[O[1]],q.array[s+8]=E[O[2]],s+=9;for(u=0,B=S.length;u<B;u++)T=E=D=C=ua=q.value[S[u]],q.array[s]=C[O[0]],q.array[s+1]=C[O[1]],q.array[s+2]=C[O[2]],
+q.array[s+3]=D[O[0]],q.array[s+4]=D[O[1]],q.array[s+5]=D[O[2]],q.array[s+6]=E[O[0]],q.array[s+7]=E[O[1]],q.array[s+8]=E[O[2]],q.array[s+9]=T[O[0]],q.array[s+10]=T[O[1]],q.array[s+11]=T[O[2]],s+=12}}else if(4===q.size)if(void 0===q.boundTo||"vertices"===q.boundTo){for(u=0,B=R.length;u<B;u++)x=fa[R[u]],C=q.value[x.a],D=q.value[x.b],E=q.value[x.c],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=C.z,q.array[s+3]=C.w,q.array[s+4]=D.x,q.array[s+5]=D.y,q.array[s+6]=D.z,q.array[s+7]=D.w,q.array[s+8]=E.x,q.array[s+
+9]=E.y,q.array[s+10]=E.z,q.array[s+11]=E.w,s+=12;for(u=0,B=S.length;u<B;u++)x=fa[S[u]],C=q.value[x.a],D=q.value[x.b],E=q.value[x.c],T=q.value[x.d],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=C.z,q.array[s+3]=C.w,q.array[s+4]=D.x,q.array[s+5]=D.y,q.array[s+6]=D.z,q.array[s+7]=D.w,q.array[s+8]=E.x,q.array[s+9]=E.y,q.array[s+10]=E.z,q.array[s+11]=E.w,q.array[s+12]=T.x,q.array[s+13]=T.y,q.array[s+14]=T.z,q.array[s+15]=T.w,s+=16}else if("faces"===q.boundTo){for(u=0,B=R.length;u<B;u++)E=D=C=ua=q.value[R[u]],
+q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=C.z,q.array[s+3]=C.w,q.array[s+4]=D.x,q.array[s+5]=D.y,q.array[s+6]=D.z,q.array[s+7]=D.w,q.array[s+8]=E.x,q.array[s+9]=E.y,q.array[s+10]=E.z,q.array[s+11]=E.w,s+=12;for(u=0,B=S.length;u<B;u++)T=E=D=C=ua=q.value[S[u]],q.array[s]=C.x,q.array[s+1]=C.y,q.array[s+2]=C.z,q.array[s+3]=C.w,q.array[s+4]=D.x,q.array[s+5]=D.y,q.array[s+6]=D.z,q.array[s+7]=D.w,q.array[s+8]=E.x,q.array[s+9]=E.y,q.array[s+10]=E.z,q.array[s+11]=E.w,q.array[s+12]=T.x,q.array[s+13]=T.y,
+q.array[s+14]=T.z,q.array[s+15]=T.w,s+=16}e.bindBuffer(e.ARRAY_BUFFER,q.buffer);e.bufferData(e.ARRAY_BUFFER,q.array,xa)}ec&&(delete N.__inittedArrays,delete N.__colorArray,delete N.__normalArray,delete N.__tangentArray,delete N.__uvArray,delete N.__uv2Array,delete N.__faceArray,delete N.__vertexArray,delete N.__lineArray,delete N.__skinVertexAArray,delete N.__skinVertexBArray,delete N.__skinIndexArray,delete N.__skinWeightArray)}}P.__dirtyVertices=!1;P.__dirtyMorphTargets=!1;P.__dirtyElements=!1;
+P.__dirtyUvs=!1;P.__dirtyNormals=!1;P.__dirtyColors=!1;P.__dirtyTangents=!1;sa.attributes&&m(sa)}else if(Fa instanceof THREE.Ribbon){if(P.__dirtyVertices||P.__dirtyColors){var lb=P,Kc=e.DYNAMIC_DRAW,Wb=void 0,Xb=void 0,mc=void 0,mb=void 0,nc=void 0,Lc=lb.vertices,Mc=lb.colors,Vc=Lc.length,Wc=Mc.length,oc=lb.__vertexArray,pc=lb.__colorArray,Xc=lb.__dirtyColors;if(lb.__dirtyVertices){for(Wb=0;Wb<Vc;Wb++)mc=Lc[Wb].position,mb=3*Wb,oc[mb]=mc.x,oc[mb+1]=mc.y,oc[mb+2]=mc.z;e.bindBuffer(e.ARRAY_BUFFER,lb.__webglVertexBuffer);
+e.bufferData(e.ARRAY_BUFFER,oc,Kc)}if(Xc){for(Xb=0;Xb<Wc;Xb++)nc=Mc[Xb],mb=3*Xb,pc[mb]=nc.r,pc[mb+1]=nc.g,pc[mb+2]=nc.b;e.bindBuffer(e.ARRAY_BUFFER,lb.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,pc,Kc)}}P.__dirtyVertices=!1;P.__dirtyColors=!1}else if(Fa instanceof THREE.Line){sa=c(Fa,Pb);Db=sa.attributes&&n(sa);if(P.__dirtyVertices||P.__dirtyColors||Db){var Za=P,Fc=e.DYNAMIC_DRAW,Yb=void 0,Zb=void 0,qc=void 0,ba=void 0,rc=void 0,Nc=Za.vertices,Oc=Za.colors,Yc=Nc.length,Zc=Oc.length,sc=Za.__vertexArray,
+tc=Za.__colorArray,$c=Za.__dirtyColors,Gc=Za.__webglCustomAttributesList,uc=void 0,Pc=void 0,ma=void 0,Jb=void 0,ta=void 0,W=void 0;if(Za.__dirtyVertices){for(Yb=0;Yb<Yc;Yb++)qc=Nc[Yb].position,ba=3*Yb,sc[ba]=qc.x,sc[ba+1]=qc.y,sc[ba+2]=qc.z;e.bindBuffer(e.ARRAY_BUFFER,Za.__webglVertexBuffer);e.bufferData(e.ARRAY_BUFFER,sc,Fc)}if($c){for(Zb=0;Zb<Zc;Zb++)rc=Oc[Zb],ba=3*Zb,tc[ba]=rc.r,tc[ba+1]=rc.g,tc[ba+2]=rc.b;e.bindBuffer(e.ARRAY_BUFFER,Za.__webglColorBuffer);e.bufferData(e.ARRAY_BUFFER,tc,Fc)}if(Gc)for(uc=
+0,Pc=Gc.length;uc<Pc;uc++)if(W=Gc[uc],W.needsUpdate&&(void 0===W.boundTo||"vertices"===W.boundTo)){ba=0;Jb=W.value.length;if(1===W.size)for(ma=0;ma<Jb;ma++)W.array[ma]=W.value[ma];else if(2===W.size)for(ma=0;ma<Jb;ma++)ta=W.value[ma],W.array[ba]=ta.x,W.array[ba+1]=ta.y,ba+=2;else if(3===W.size)if("c"===W.type)for(ma=0;ma<Jb;ma++)ta=W.value[ma],W.array[ba]=ta.r,W.array[ba+1]=ta.g,W.array[ba+2]=ta.b,ba+=3;else for(ma=0;ma<Jb;ma++)ta=W.value[ma],W.array[ba]=ta.x,W.array[ba+1]=ta.y,W.array[ba+2]=ta.z,
+ba+=3;else if(4===W.size)for(ma=0;ma<Jb;ma++)ta=W.value[ma],W.array[ba]=ta.x,W.array[ba+1]=ta.y,W.array[ba+2]=ta.z,W.array[ba+3]=ta.w,ba+=4;e.bindBuffer(e.ARRAY_BUFFER,W.buffer);e.bufferData(e.ARRAY_BUFFER,W.array,Fc)}}P.__dirtyVertices=!1;P.__dirtyColors=!1;sa.attributes&&m(sa)}else if(Fa instanceof THREE.ParticleSystem)sa=c(Fa,Pb),Db=sa.attributes&&n(sa),(P.__dirtyVertices||P.__dirtyColors||Fa.sortParticles||Db)&&f(P,e.DYNAMIC_DRAW,Fa),P.__dirtyVertices=!1,P.__dirtyColors=!1,sa.attributes&&m(sa)}};
+this.initMaterial=function(a,b,c,d){var f,g,h,i,j;a instanceof THREE.MeshDepthMaterial?j="depth":a instanceof THREE.MeshNormalMaterial?j="normal":a instanceof THREE.MeshBasicMaterial?j="basic":a instanceof THREE.MeshLambertMaterial?j="lambert":a instanceof THREE.MeshPhongMaterial?j="phong":a instanceof THREE.LineBasicMaterial?j="basic":a instanceof THREE.ParticleBasicMaterial&&(j="particle_basic");if(j){var k=THREE.ShaderLib[j];a.uniforms=THREE.UniformsUtils.clone(k.uniforms);a.vertexShader=k.vertexShader;
+a.fragmentShader=k.fragmentShader}var l,n;g=k=0;for(l=0,n=b.length;l<n;l++)f=b[l],f instanceof THREE.SpotLight&&!f.onlyShadow&&g++,f instanceof THREE.DirectionalLight&&g++,f instanceof THREE.PointLight&&k++;k+g<=oa?l=g:(l=Math.ceil(oa*g/(k+g)),k=oa-l);f=l;g=k;var m=0;for(k=0,l=b.length;k<l;k++)n=b[k],n instanceof THREE.SpotLight&&n.castShadow&&m++;var p=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)p=d.bones.length;var o;a:{l=a.fragmentShader;n=a.vertexShader;var k=a.uniforms,b=a.attributes,c=
+{map:!!a.map,envMap:!!a.envMap,lightMap:!!a.lightMap,vertexColors:a.vertexColors,fog:c,useFog:a.fog,sizeAttenuation:a.sizeAttenuation,skinning:a.skinning,morphTargets:a.morphTargets,maxMorphTargets:this.maxMorphTargets,maxDirLights:f,maxPointLights:g,maxBones:p,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapWidth:this.shadowMapWidth,shadowMapHeight:this.shadowMapHeight,maxShadows:m,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround},
+r,d=[];j?d.push(j):(d.push(l),d.push(n));for(r in c)d.push(r),d.push(c[r]);j=d.join();for(r=0,d=qa.length;r<d;r++)if(qa[r].code===j){o=qa[r].program;break a}r=e.createProgram();d=[0<Nb?"#define VERTEX_TEXTURES":"",z.gammaInput?"#define GAMMA_INPUT":"",z.gammaOutput?"#define GAMMA_OUTPUT":"",z.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"","#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.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",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");
-e=["precision "+M+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",z.gammaInput?"#define GAMMA_INPUT":"",z.gammaOutput?"#define GAMMA_OUTPUT":"",z.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",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.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",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");f.attachShader(r,A("fragment",
-e+l));f.attachShader(r,A("vertex",d+n));f.linkProgram(r);f.getProgramParameter(r,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(r,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");r.uniforms={};r.attributes={};var t,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,cameraInverseMatrix,boneGlobalMatrices,morphTargetInfluences".split(",");for(t in k)d.push(t);t=d;for(d=0,k=t.length;d<k;d++)l=t[d],r.uniforms[l]=
-f.getUniformLocation(r,l);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,skinWeight".split(",");for(t=0;t<c.maxMorphTargets;t++)d.push("morphTarget"+t);for(o in b)d.push(o);o=d;for(t=0,b=o.length;t<b;t++)c=o[t],r.attributes[c]=f.getAttribLocation(r,c);r.id=Ha.length;Ha.push({program:r,code:j});z.info.memory.programs=Ha.length;o=r}a.program=o;o=a.program.attributes;0<=o.position&&f.enableVertexAttribArray(o.position);0<=o.color&&f.enableVertexAttribArray(o.color);0<=o.normal&&
-f.enableVertexAttribArray(o.normal);0<=o.tangent&&f.enableVertexAttribArray(o.tangent);a.skinning&&0<=o.skinVertexA&&0<=o.skinVertexB&&0<=o.skinIndex&&0<=o.skinWeight&&(f.enableVertexAttribArray(o.skinVertexA),f.enableVertexAttribArray(o.skinVertexB),f.enableVertexAttribArray(o.skinIndex),f.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(i in a.attributes)void 0!==o[i]&&0<=o[i]&&f.enableVertexAttribArray(o[i]);if(a.morphTargets)for(i=a.numSupportedMorphTargets=0;i<this.maxMorphTargets;i++)t=
-"morphTarget"+i,0<=o[t]&&(f.enableVertexAttribArray(o[t]),a.numSupportedMorphTargets++);a.uniformsList=[];for(h in a.uniforms)a.uniformsList.push([a.uniforms[h],h])};this.setFaceCulling=function(a,b){a?(!b||"ccw"===b?f.frontFace(f.CCW):f.frontFace(f.CW),"back"===a?f.cullFace(f.BACK):"front"===a?f.cullFace(f.FRONT):f.cullFace(f.FRONT_AND_BACK),f.enable(f.CULL_FACE)):f.disable(f.CULL_FACE)};this.setObjectFaces=function(a){if(Mb!==a.doubleSided)a.doubleSided?f.disable(f.CULL_FACE):f.enable(f.CULL_FACE),
-Mb=a.doubleSided;if(Nb!==a.flipSided)a.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW),Nb=a.flipSided};this.setDepthTest=function(a){ab!==a&&(a?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST),ab=a)};this.setBlending=function(a){if(a!==rb){switch(a){case THREE.AdditiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.SRC_ALPHA,f.ONE);break;case THREE.SubtractiveBlending:f.blendEquation(f.FUNC_ADD);f.blendFunc(f.ZERO,f.ONE_MINUS_SRC_COLOR);break;case THREE.MultiplyBlending:f.blendEquation(f.FUNC_ADD);
-f.blendFunc(f.ZERO,f.SRC_COLOR);break;default:f.blendEquationSeparate(f.FUNC_ADD,f.FUNC_ADD),f.blendFuncSeparate(f.SRC_ALPHA,f.ONE_MINUS_SRC_ALPHA,f.ONE,f.ONE_MINUS_SRC_ALPHA)}rb=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=f.createTexture(),z.info.memory.textures++;f.activeTexture(f.TEXTURE0+b);f.bindTexture(f.TEXTURE_2D,a.__webglTexture);var c=a.image,d=0===(c.width&c.width-1)&&0===(c.height&c.height-1),e=H(a.format),g=H(a.type);K(f.TEXTURE_2D,
-a,d);a instanceof THREE.DataTexture?f.texImage2D(f.TEXTURE_2D,0,e,c.width,c.height,0,e,g,c.data):f.texImage2D(f.TEXTURE_2D,0,e,e,g,a.image);a.generateMipmaps&&d&&f.generateMipmap(f.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else f.activeTexture(f.TEXTURE0+b),f.bindTexture(f.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(void 0===a.depthBuffer)a.depthBuffer=!0;if(void 0===a.stencilBuffer)a.stencilBuffer=
-!0;a.__webglTexture=f.createTexture();var c=0===(a.width&a.width-1)&&0===(a.height&a.height-1),d=H(a.format),e=H(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];f.bindTexture(f.TEXTURE_CUBE_MAP,a.__webglTexture);K(f.TEXTURE_CUBE_MAP,a,c);for(c=0;6>c;c++){a.__webglFramebuffer[c]=f.createFramebuffer();a.__webglRenderbuffer[c]=f.createRenderbuffer();f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,0,d,e,null);var g=a,h=f.TEXTURE_CUBE_MAP_POSITIVE_X+c;f.bindFramebuffer(f.FRAMEBUFFER,
-a.__webglFramebuffer[c]);f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,h,g.__webglTexture,0);y(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=f.createFramebuffer(),a.__webglRenderbuffer=f.createRenderbuffer(),f.bindTexture(f.TEXTURE_2D,a.__webglTexture),K(f.TEXTURE_2D,a,c),f.texImage2D(f.TEXTURE_2D,0,d,a.width,a.height,0,d,e,null),d=f.TEXTURE_2D,f.bindFramebuffer(f.FRAMEBUFFER,a.__webglFramebuffer),f.framebufferTexture2D(f.FRAMEBUFFER,f.COLOR_ATTACHMENT0,d,a.__webglTexture,0),y(a.__webglRenderbuffer,
-a);b?f.bindTexture(f.TEXTURE_CUBE_MAP,null):f.bindTexture(f.TEXTURE_2D,null);f.bindRenderbuffer(f.RENDERBUFFER,null);f.bindFramebuffer(f.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,d=a.width,a=a.height,c=e=0):(b=null,d=tb,a=Ab,e=sb,c=zb);b!==Kb&&(f.bindFramebuffer(f.FRAMEBUFFER,b),f.viewport(e,c,d,a),Kb=b);bc=d;cc=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
+f=["precision "+G+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",z.gammaInput?"#define GAMMA_INPUT":"",z.gammaOutput?"#define GAMMA_OUTPUT":"",z.physicallyBasedShading?"#define PHYSICALLY_BASED_SHADING":"",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.metal?"#define METAL":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",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");e.attachShader(r,F("fragment",
+f+l));e.attachShader(r,F("vertex",d+n));e.linkProgram(r);e.getProgramParameter(r,e.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+e.getProgramParameter(r,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]");r.uniforms={};r.attributes={};var t,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,cameraInverseMatrix,boneGlobalMatrices,morphTargetInfluences".split(",");for(t in k)d.push(t);t=d;for(d=0,k=t.length;d<k;d++)l=t[d],r.uniforms[l]=
+e.getUniformLocation(r,l);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,skinWeight".split(",");for(t=0;t<c.maxMorphTargets;t++)d.push("morphTarget"+t);for(o in b)d.push(o);o=d;for(t=0,b=o.length;t<b;t++)c=o[t],r.attributes[c]=e.getAttribLocation(r,c);r.id=qa.length;qa.push({program:r,code:j});z.info.memory.programs=qa.length;o=r}a.program=o;o=a.program.attributes;0<=o.position&&e.enableVertexAttribArray(o.position);0<=o.color&&e.enableVertexAttribArray(o.color);0<=o.normal&&
+e.enableVertexAttribArray(o.normal);0<=o.tangent&&e.enableVertexAttribArray(o.tangent);a.skinning&&0<=o.skinVertexA&&0<=o.skinVertexB&&0<=o.skinIndex&&0<=o.skinWeight&&(e.enableVertexAttribArray(o.skinVertexA),e.enableVertexAttribArray(o.skinVertexB),e.enableVertexAttribArray(o.skinIndex),e.enableVertexAttribArray(o.skinWeight));if(a.attributes)for(i in a.attributes)void 0!==o[i]&&0<=o[i]&&e.enableVertexAttribArray(o[i]);if(a.morphTargets)for(i=a.numSupportedMorphTargets=0;i<this.maxMorphTargets;i++)t=
+"morphTarget"+i,0<=o[t]&&(e.enableVertexAttribArray(o[t]),a.numSupportedMorphTargets++);a.uniformsList=[];for(h in a.uniforms)a.uniformsList.push([a.uniforms[h],h])};this.setFaceCulling=function(a,b){a?(!b||"ccw"===b?e.frontFace(e.CCW):e.frontFace(e.CW),"back"===a?e.cullFace(e.BACK):"front"===a?e.cullFace(e.FRONT):e.cullFace(e.FRONT_AND_BACK),e.enable(e.CULL_FACE)):e.disable(e.CULL_FACE)};this.setObjectFaces=function(a){if(Kb!==a.doubleSided)a.doubleSided?e.disable(e.CULL_FACE):e.enable(e.CULL_FACE),
+Kb=a.doubleSided;if(Mb!==a.flipSided)a.flipSided?e.frontFace(e.CW):e.frontFace(e.CCW),Mb=a.flipSided};this.setDepthTest=function(a){pb!==a&&(a?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),pb=a)};this.setDepthWrite=function(a){ob!==a&&(e.depthMask(a),ob=a)};this.setBlending=function(a){if(a!==ab){switch(a){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)}ab=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=e.createTexture(),z.info.memory.textures++;e.activeTexture(e.TEXTURE0+b);e.bindTexture(e.TEXTURE_2D,a.__webglTexture);var c=a.image,d=0===(c.width&c.width-1)&&
+0===(c.height&c.height-1),f=J(a.format),g=J(a.type);I(e.TEXTURE_2D,a,d);a instanceof THREE.DataTexture?e.texImage2D(e.TEXTURE_2D,0,f,c.width,c.height,0,f,g,c.data):e.texImage2D(e.TEXTURE_2D,0,f,f,g,a.image);a.generateMipmaps&&d&&e.generateMipmap(e.TEXTURE_2D);a.needsUpdate=!1;if(a.onUpdated)a.onUpdated()}else e.activeTexture(e.TEXTURE0+b),e.bindTexture(e.TEXTURE_2D,a.__webglTexture)};this.setRenderTarget=function(a){var b=a instanceof THREE.WebGLRenderTargetCube;if(a&&!a.__webglFramebuffer){if(void 0===
+a.depthBuffer)a.depthBuffer=!0;if(void 0===a.stencilBuffer)a.stencilBuffer=!0;a.__webglTexture=e.createTexture();var c=0===(a.width&a.width-1)&&0===(a.height&a.height-1),d=J(a.format),f=J(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];e.bindTexture(e.TEXTURE_CUBE_MAP,a.__webglTexture);I(e.TEXTURE_CUBE_MAP,a,c);for(c=0;6>c;c++){a.__webglFramebuffer[c]=e.createFramebuffer();a.__webglRenderbuffer[c]=e.createRenderbuffer();e.texImage2D(e.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,d,a.width,a.height,
+0,d,f,null);var g=a,h=e.TEXTURE_CUBE_MAP_POSITIVE_X+c;e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer[c]);e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,h,g.__webglTexture,0);A(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=e.createFramebuffer(),a.__webglRenderbuffer=e.createRenderbuffer(),e.bindTexture(e.TEXTURE_2D,a.__webglTexture),I(e.TEXTURE_2D,a,c),e.texImage2D(e.TEXTURE_2D,0,d,a.width,a.height,0,d,f,null),d=e.TEXTURE_2D,e.bindFramebuffer(e.FRAMEBUFFER,a.__webglFramebuffer),
+e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,d,a.__webglTexture,0),A(a.__webglRenderbuffer,a);b?e.bindTexture(e.TEXTURE_CUBE_MAP,null):e.bindTexture(e.TEXTURE_2D,null);e.bindRenderbuffer(e.RENDERBUFFER,null);e.bindFramebuffer(e.FRAMEBUFFER,null)}a?(b=b?a.__webglFramebuffer[a.activeCubeFace]:a.__webglFramebuffer,d=a.width,a=a.height,c=f=0):(b=null,d=zb,a=sb,f=qb,c=rb);b!==$b&&(e.bindFramebuffer(e.FRAMEBUFFER,b),e.viewport(f,c,d,a),$b=b);ac=d;bc=a};this.shadowMapPlugin=new THREE.ShadowMapPlugin;
+this.addPrePlugin(this.shadowMapPlugin);this.addPostPlugin(new THREE.SpritePlugin);this.addPostPlugin(new THREE.LensFlarePlugin)};
 THREE.WebGLRenderTarget=function(a,b,c){this.width=a;this.height=b;c=c||{};this.wrapS=void 0!==c.wrapS?c.wrapS:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==c.wrapT?c.wrapT:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==c.magFilter?c.magFilter:THREE.LinearFilter;this.minFilter=void 0!==c.minFilter?c.minFilter:THREE.LinearMipMapLinearFilter;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.format=void 0!==c.format?c.format:THREE.RGBAFormat;this.type=void 0!==c.type?c.type:
 THREE.UnsignedByteType;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.generateMipmaps=!0};
 THREE.WebGLRenderTarget.prototype.clone=function(){var a=new THREE.WebGLRenderTarget(this.width,this.height);a.wrapS=this.wrapS;a.wrapT=this.wrapT;a.magFilter=this.magFilter;a.minFilter=this.minFilter;a.offset.copy(this.offset);a.repeat.copy(this.repeat);a.format=this.format;a.type=this.type;a.depthBuffer=this.depthBuffer;a.stencilBuffer=this.stencilBuffer;return a};THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0};
 THREE.WebGLRenderTargetCube.prototype=new THREE.WebGLRenderTarget;THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;
 THREE.BufferGeometry=function(){this.id=THREE.GeometryCount++;this.vertexColorArray=this.vertexUvArray=this.vertexNormalArray=this.vertexPositionArray=this.vertexIndexArray=this.vertexColorBuffer=this.vertexUvBuffer=this.vertexNormalBuffer=this.vertexPositionBuffer=this.vertexIndexBuffer=null;this.dynamic=!1;this.boundingSphere=this.boundingBox=null;this.morphTargets=[]};THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,computeBoundingBox:function(){},computeBoundingSphere:function(){}};
 THREE.LensFlare=function(a,b,c,d,g){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,g)};THREE.LensFlare.prototype=new THREE.Object3D;THREE.LensFlare.prototype.constructor=THREE.LensFlare;THREE.LensFlare.prototype.supr=THREE.Object3D.prototype;
-THREE.LensFlare.prototype.add=function(a,b,c,d,g,e){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===e&&(e=1);void 0===g&&(g=new THREE.Color(16777215));if(void 0===d)d=THREE.NormalBlending;c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:1,opacity:e,color:g,blending:d})};
+THREE.LensFlare.prototype.add=function(a,b,c,d,g,f){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===f&&(f=1);void 0===g&&(g=new THREE.Color(16777215));if(void 0===d)d=THREE.NormalBlending;c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:1,opacity:f,color:g,blending:d})};
 THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,c,d=2*-this.positionScreen.x,g=2*-this.positionScreen.y;for(a=0;a<b;a++)c=this.lensFlares[a],c.x=this.positionScreen.x+d*c.distance,c.y=this.positionScreen.y+g*c.distance,c.wantedRotation=0.25*c.x*Math.PI,c.rotation+=0.25*(c.wantedRotation-c.rotation)};
 THREE.MarchingCubes=function(a,b){THREE.Object3D.call(this);this.material=b;this.init=function(a){this.resolution=a;this.isolation=80;this.size=a;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(3*this.size3);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(3*this.maxCount);this.normalArray=new Float32Array(3*this.maxCount)};this.lerp=function(a,b,g){return a+(b-a)*g};this.VIntX=function(a,b,g,e,h,i,k,l,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[e]=i+h*this.delta;b[e+1]=k;b[e+2]=l;g[e]=this.lerp(j[a],j[a+3],h);g[e+1]=this.lerp(j[a+1],j[a+4],h);g[e+2]=this.lerp(j[a+2],j[a+5],h)};this.VIntY=function(a,b,g,e,h,i,k,l,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[e]=i;b[e+1]=k+h*this.delta;b[e+2]=l;b=a+3*this.yd;
-g[e]=this.lerp(j[a],j[b],h);g[e+1]=this.lerp(j[a+1],j[b+1],h);g[e+2]=this.lerp(j[a+2],j[b+2],h)};this.VIntZ=function(a,b,g,e,h,i,k,l,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[e]=i;b[e+1]=k;b[e+2]=l+h*this.delta;b=a+3*this.zd;g[e]=this.lerp(j[a],j[b],h);g[e+1]=this.lerp(j[a+1],j[b+1],h);g[e+2]=this.lerp(j[a+2],j[b+2],h)};this.compNorm=function(a){var b=3*a;0===this.normal_cache[b]&&(this.normal_cache[b]=this.field[a-1]-this.field[a+1],this.normal_cache[b+1]=this.field[a-this.yd]-this.field[a+this.yd],
-this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,g,e,h,i){var k=e+1,l=e+this.yd,j=e+this.zd,n=k+this.yd,m=k+this.zd,o=e+this.yd+this.zd,p=k+this.yd+this.zd,r=0,t=this.field[e],v=this.field[k],F=this.field[l],A=this.field[n],K=this.field[j],y=this.field[m],J=this.field[o],H=this.field[p];t<h&&(r|=1);v<h&&(r|=2);F<h&&(r|=8);A<h&&(r|=4);K<h&&(r|=16);y<h&&(r|=32);J<h&&(r|=128);H<h&&(r|=64);var I=THREE.edgeTable[r];if(0===I)return 0;var M=this.delta,G=a+
-M,L=b+M,M=g+M;I&1&&(this.compNorm(e),this.compNorm(k),this.VIntX(3*e,this.vlist,this.nlist,0,h,a,b,g,t,v));I&2&&(this.compNorm(k),this.compNorm(n),this.VIntY(3*k,this.vlist,this.nlist,3,h,G,b,g,v,A));I&4&&(this.compNorm(l),this.compNorm(n),this.VIntX(3*l,this.vlist,this.nlist,6,h,a,L,g,F,A));I&8&&(this.compNorm(e),this.compNorm(l),this.VIntY(3*e,this.vlist,this.nlist,9,h,a,b,g,t,F));I&16&&(this.compNorm(j),this.compNorm(m),this.VIntX(3*j,this.vlist,this.nlist,12,h,a,b,M,K,y));I&32&&(this.compNorm(m),
-this.compNorm(p),this.VIntY(3*m,this.vlist,this.nlist,15,h,G,b,M,y,H));I&64&&(this.compNorm(o),this.compNorm(p),this.VIntX(3*o,this.vlist,this.nlist,18,h,a,L,M,J,H));I&128&&(this.compNorm(j),this.compNorm(o),this.VIntY(3*j,this.vlist,this.nlist,21,h,a,b,M,K,J));I&256&&(this.compNorm(e),this.compNorm(j),this.VIntZ(3*e,this.vlist,this.nlist,24,h,a,b,g,t,K));I&512&&(this.compNorm(k),this.compNorm(m),this.VIntZ(3*k,this.vlist,this.nlist,27,h,G,b,g,v,y));I&1024&&(this.compNorm(n),this.compNorm(p),this.VIntZ(3*
-n,this.vlist,this.nlist,30,h,G,L,g,A,H));I&2048&&(this.compNorm(l),this.compNorm(o),this.VIntZ(3*l,this.vlist,this.nlist,33,h,a,L,g,F,J));r<<=4;for(h=e=0;-1!=THREE.triTable[r+h];)a=r+h,b=a+1,g=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[g],i),h+=3,e++;return e};this.posnormtriv=function(a,b,g,e,h,i){var k=3*this.count;this.positionArray[k]=a[g];this.positionArray[k+1]=a[g+1];this.positionArray[k+2]=a[g+2];this.positionArray[k+3]=a[e];this.positionArray[k+
-4]=a[e+1];this.positionArray[k+5]=a[e+2];this.positionArray[k+6]=a[h];this.positionArray[k+7]=a[h+1];this.positionArray[k+8]=a[h+2];this.normalArray[k]=b[g];this.normalArray[k+1]=b[g+1];this.normalArray[k+2]=b[g+2];this.normalArray[k+3]=b[e];this.normalArray[k+4]=b[e+1];this.normalArray[k+5]=b[e+2];this.normalArray[k+6]=b[h];this.normalArray[k+7]=b[h+1];this.normalArray[k+8]=b[h+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&i(this)};this.begin=function(){this.count=0;
-this.hasNormal=this.hasPos=!1};this.end=function(a){if(0!==this.count){for(var b=3*this.count;b<this.positionArray.length;b++)this.positionArray[b]=0;a(this)}};this.addBall=function(a,b,g,e,h){var i=this.size*Math.sqrt(e/h),k=g*this.size,l=b*this.size,j=a*this.size,n=Math.floor(k-i);1>n&&(n=1);k=Math.floor(k+i);k>this.size-1&&(k=this.size-1);var m=Math.floor(l-i);1>m&&(m=1);l=Math.floor(l+i);l>this.size-1&&(l=this.size-1);var o=Math.floor(j-i);1>o&&(o=1);i=Math.floor(j+i);i>this.size-1&&(i=this.size-
-1);for(var p,r,t,v,F,A,K,j=n;j<k;j++){t=this.size2*j;F=j/this.size-g;A=F*F;for(n=m;n<l;n++){r=t+this.size*n;p=n/this.size-b;K=p*p;for(p=o;p<i;p++)v=p/this.size-a,v=e/(1.0E-6+v*v+K+A)-h,0<v&&(this.field[r+p]+=v)}}};this.addPlaneX=function(a,b){var g,e,h,i,k,l=this.size,j=this.yd,n=this.zd,m=this.field,o=l*Math.sqrt(a/b);o>l&&(o=l);for(g=0;g<o;g++)if(e=g/l,e*=e,i=a/(1.0E-4+e)-b,0<i)for(e=0;e<l;e++){k=g+e*j;for(h=0;h<l;h++)m[n*h+k]+=i}};this.addPlaneY=function(a,b){var g,e,h,i,k,l,j=this.size,n=this.yd,
-m=this.zd,o=this.field,p=j*Math.sqrt(a/b);p>j&&(p=j);for(e=0;e<p;e++)if(g=e/j,g*=g,i=a/(1.0E-4+g)-b,0<i){k=e*n;for(g=0;g<j;g++){l=k+g;for(h=0;h<j;h++)o[m*h+l]+=i}}};this.addPlaneZ=function(a,b){var g,e,h,i,k,l,j=this.size,n=this.yd,m=this.zd,o=this.field,p=j*Math.sqrt(a/b);p>j&&(p=j);for(h=0;h<p;h++)if(g=h/j,g*=g,i=a/(1.0E-4+g)-b,0<i){k=m*h;for(e=0;e<j;e++){l=k+e*n;for(g=0;g<j;g++)o[l+g]+=i}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[3*a]=0,this.field[a]=0};this.render=
-function(a){this.begin();var b,g,e,h,i,k,l,j,n,m=this.size-2;for(h=1;h<m;h++){n=this.size2*h;l=(h-this.halfsize)/this.halfsize;for(e=1;e<m;e++){j=n+this.size*e;k=(e-this.halfsize)/this.halfsize;for(g=1;g<m;g++)i=(g-this.halfsize)/this.halfsize,b=j+g,this.polygonize(i,k,l,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,g=[];this.render(function(e){var h,i,k,l,j,n,m,o;for(h=0;h<e.count;h++)m=3*h,j=m+1,o=m+2,i=e.positionArray[m],k=e.positionArray[j],l=
-e.positionArray[o],n=new THREE.Vector3(i,k,l),i=e.normalArray[m],k=e.normalArray[j],l=e.normalArray[o],m=new THREE.Vector3(i,k,l),m.normalize(),j=new THREE.Vertex(n),b.vertices.push(j),g.push(m);n=e.count/3;for(h=0;h<n;h++)m=3*(a+h),j=m+1,o=m+2,i=g[m],k=g[j],l=g[o],m=new THREE.Face3(m,j,o,[i,k,l]),b.faces.push(m);a+=n;e.count=0});return b};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
+this.hasPos=!1;this.positionArray=new Float32Array(3*this.maxCount);this.normalArray=new Float32Array(3*this.maxCount)};this.lerp=function(a,b,g){return a+(b-a)*g};this.VIntX=function(a,b,g,f,h,i,k,l,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[f]=i+h*this.delta;b[f+1]=k;b[f+2]=l;g[f]=this.lerp(j[a],j[a+3],h);g[f+1]=this.lerp(j[a+1],j[a+4],h);g[f+2]=this.lerp(j[a+2],j[a+5],h)};this.VIntY=function(a,b,g,f,h,i,k,l,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[f]=i;b[f+1]=k+h*this.delta;b[f+2]=l;b=a+3*this.yd;
+g[f]=this.lerp(j[a],j[b],h);g[f+1]=this.lerp(j[a+1],j[b+1],h);g[f+2]=this.lerp(j[a+2],j[b+2],h)};this.VIntZ=function(a,b,g,f,h,i,k,l,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[f]=i;b[f+1]=k;b[f+2]=l+h*this.delta;b=a+3*this.zd;g[f]=this.lerp(j[a],j[b],h);g[f+1]=this.lerp(j[a+1],j[b+1],h);g[f+2]=this.lerp(j[a+2],j[b+2],h)};this.compNorm=function(a){var b=3*a;0===this.normal_cache[b]&&(this.normal_cache[b]=this.field[a-1]-this.field[a+1],this.normal_cache[b+1]=this.field[a-this.yd]-this.field[a+this.yd],
+this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,g,f,h,i){var k=f+1,l=f+this.yd,j=f+this.zd,n=k+this.yd,m=k+this.zd,o=f+this.yd+this.zd,p=k+this.yd+this.zd,r=0,t=this.field[f],y=this.field[k],F=this.field[l],I=this.field[n],A=this.field[j],v=this.field[m],J=this.field[o],K=this.field[p];t<h&&(r|=1);y<h&&(r|=2);F<h&&(r|=8);I<h&&(r|=4);A<h&&(r|=16);v<h&&(r|=32);J<h&&(r|=128);K<h&&(r|=64);var G=THREE.edgeTable[r];if(0===G)return 0;var M=this.delta,H=a+
+M,L=b+M,M=g+M;G&1&&(this.compNorm(f),this.compNorm(k),this.VIntX(3*f,this.vlist,this.nlist,0,h,a,b,g,t,y));G&2&&(this.compNorm(k),this.compNorm(n),this.VIntY(3*k,this.vlist,this.nlist,3,h,H,b,g,y,I));G&4&&(this.compNorm(l),this.compNorm(n),this.VIntX(3*l,this.vlist,this.nlist,6,h,a,L,g,F,I));G&8&&(this.compNorm(f),this.compNorm(l),this.VIntY(3*f,this.vlist,this.nlist,9,h,a,b,g,t,F));G&16&&(this.compNorm(j),this.compNorm(m),this.VIntX(3*j,this.vlist,this.nlist,12,h,a,b,M,A,v));G&32&&(this.compNorm(m),
+this.compNorm(p),this.VIntY(3*m,this.vlist,this.nlist,15,h,H,b,M,v,K));G&64&&(this.compNorm(o),this.compNorm(p),this.VIntX(3*o,this.vlist,this.nlist,18,h,a,L,M,J,K));G&128&&(this.compNorm(j),this.compNorm(o),this.VIntY(3*j,this.vlist,this.nlist,21,h,a,b,M,A,J));G&256&&(this.compNorm(f),this.compNorm(j),this.VIntZ(3*f,this.vlist,this.nlist,24,h,a,b,g,t,A));G&512&&(this.compNorm(k),this.compNorm(m),this.VIntZ(3*k,this.vlist,this.nlist,27,h,H,b,g,y,v));G&1024&&(this.compNorm(n),this.compNorm(p),this.VIntZ(3*
+n,this.vlist,this.nlist,30,h,H,L,g,I,K));G&2048&&(this.compNorm(l),this.compNorm(o),this.VIntZ(3*l,this.vlist,this.nlist,33,h,a,L,g,F,J));r<<=4;for(h=f=0;-1!=THREE.triTable[r+h];)a=r+h,b=a+1,g=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[g],i),h+=3,f++;return f};this.posnormtriv=function(a,b,g,f,h,i){var k=3*this.count;this.positionArray[k]=a[g];this.positionArray[k+1]=a[g+1];this.positionArray[k+2]=a[g+2];this.positionArray[k+3]=a[f];this.positionArray[k+
+4]=a[f+1];this.positionArray[k+5]=a[f+2];this.positionArray[k+6]=a[h];this.positionArray[k+7]=a[h+1];this.positionArray[k+8]=a[h+2];this.normalArray[k]=b[g];this.normalArray[k+1]=b[g+1];this.normalArray[k+2]=b[g+2];this.normalArray[k+3]=b[f];this.normalArray[k+4]=b[f+1];this.normalArray[k+5]=b[f+2];this.normalArray[k+6]=b[h];this.normalArray[k+7]=b[h+1];this.normalArray[k+8]=b[h+2];this.hasNormal=this.hasPos=!0;this.count+=3;this.count>=this.maxCount-3&&i(this)};this.begin=function(){this.count=0;
+this.hasNormal=this.hasPos=!1};this.end=function(a){if(0!==this.count){for(var b=3*this.count;b<this.positionArray.length;b++)this.positionArray[b]=0;a(this)}};this.addBall=function(a,b,g,f,h){var i=this.size*Math.sqrt(f/h),k=g*this.size,l=b*this.size,j=a*this.size,n=Math.floor(k-i);1>n&&(n=1);k=Math.floor(k+i);k>this.size-1&&(k=this.size-1);var m=Math.floor(l-i);1>m&&(m=1);l=Math.floor(l+i);l>this.size-1&&(l=this.size-1);var o=Math.floor(j-i);1>o&&(o=1);i=Math.floor(j+i);i>this.size-1&&(i=this.size-
+1);for(var p,r,t,y,F,I,A,j=n;j<k;j++){t=this.size2*j;F=j/this.size-g;I=F*F;for(n=m;n<l;n++){r=t+this.size*n;p=n/this.size-b;A=p*p;for(p=o;p<i;p++)y=p/this.size-a,y=f/(1.0E-6+y*y+A+I)-h,0<y&&(this.field[r+p]+=y)}}};this.addPlaneX=function(a,b){var g,f,h,i,k,l=this.size,j=this.yd,n=this.zd,m=this.field,o=l*Math.sqrt(a/b);o>l&&(o=l);for(g=0;g<o;g++)if(f=g/l,f*=f,i=a/(1.0E-4+f)-b,0<i)for(f=0;f<l;f++){k=g+f*j;for(h=0;h<l;h++)m[n*h+k]+=i}};this.addPlaneY=function(a,b){var g,f,h,i,k,l,j=this.size,n=this.yd,
+m=this.zd,o=this.field,p=j*Math.sqrt(a/b);p>j&&(p=j);for(f=0;f<p;f++)if(g=f/j,g*=g,i=a/(1.0E-4+g)-b,0<i){k=f*n;for(g=0;g<j;g++){l=k+g;for(h=0;h<j;h++)o[m*h+l]+=i}}};this.addPlaneZ=function(a,b){var g,f,h,i,k,l,j=this.size,n=this.yd,m=this.zd,o=this.field,p=j*Math.sqrt(a/b);p>j&&(p=j);for(h=0;h<p;h++)if(g=h/j,g*=g,i=a/(1.0E-4+g)-b,0<i){k=m*h;for(f=0;f<j;f++){l=k+f*n;for(g=0;g<j;g++)o[l+g]+=i}}};this.reset=function(){var a;for(a=0;a<this.size3;a++)this.normal_cache[3*a]=0,this.field[a]=0};this.render=
+function(a){this.begin();var b,g,f,h,i,k,l,j,n,m=this.size-2;for(h=1;h<m;h++){n=this.size2*h;l=(h-this.halfsize)/this.halfsize;for(f=1;f<m;f++){j=n+this.size*f;k=(f-this.halfsize)/this.halfsize;for(g=1;g<m;g++)i=(g-this.halfsize)/this.halfsize,b=j+g,this.polygonize(i,k,l,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,g=[];this.render(function(f){var h,i,k,l,j,n,m,o;for(h=0;h<f.count;h++)m=3*h,j=m+1,o=m+2,i=f.positionArray[m],k=f.positionArray[j],l=
+f.positionArray[o],n=new THREE.Vector3(i,k,l),i=f.normalArray[m],k=f.normalArray[j],l=f.normalArray[o],m=new THREE.Vector3(i,k,l),m.normalize(),j=new THREE.Vertex(n),b.vertices.push(j),g.push(m);n=f.count/3;for(h=0;h<n;h++)m=3*(a+h),j=m+1,o=m+2,i=g[m],k=g[j],l=g[o],m=new THREE.Face3(m,j,o,[i,k,l]),b.faces.push(m);a+=n;f.count=0});return b};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
 THREE.edgeTable=new Int32Array([0,265,515,778,1030,1295,1541,1804,2060,2309,2575,2822,3082,3331,3593,3840,400,153,915,666,1430,1183,1941,1692,2460,2197,2975,2710,3482,3219,3993,3728,560,825,51,314,1590,1855,1077,1340,2620,2869,2111,2358,3642,3891,3129,3376,928,681,419,170,1958,1711,1445,1196,2988,2725,2479,2214,4010,3747,3497,3232,1120,1385,1635,1898,102,367,613,876,3180,3429,3695,3942,2154,2403,2665,2912,1520,1273,2035,1786,502,255,1013,764,3580,3317,4095,3830,2554,2291,3065,2800,1616,1881,1107,
 1370,598,863,85,348,3676,3925,3167,3414,2650,2899,2137,2384,1984,1737,1475,1226,966,719,453,204,4044,3781,3535,3270,3018,2755,2505,2240,2240,2505,2755,3018,3270,3535,3781,4044,204,453,719,966,1226,1475,1737,1984,2384,2137,2899,2650,3414,3167,3925,3676,348,85,863,598,1370,1107,1881,1616,2800,3065,2291,2554,3830,4095,3317,3580,764,1013,255,502,1786,2035,1273,1520,2912,2665,2403,2154,3942,3695,3429,3180,876,613,367,102,1898,1635,1385,1120,3232,3497,3747,4010,2214,2479,2725,2988,1196,1445,1711,1958,170,
 419,681,928,3376,3129,3891,3642,2358,2111,2869,2620,1340,1077,1855,1590,314,51,825,560,3728,3993,3219,3482,2710,2975,2197,2460,1692,1941,1183,1430,666,915,153,400,3840,3593,3331,3082,2822,2575,2309,2060,1804,1541,1295,1030,778,515,265,0]);
@@ -330,33 +331,33 @@ THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0
 4,1,4,0,7,4,11,-1,-1,-1,-1,3,1,4,3,4,8,1,10,4,7,4,11,10,11,4,-1,4,11,7,9,11,4,9,2,11,9,1,2,-1,-1,-1,-1,9,7,4,9,11,7,9,1,11,2,11,1,0,8,3,-1,11,7,4,11,4,2,2,4,0,-1,-1,-1,-1,-1,-1,-1,11,7,4,11,4,2,8,3,4,3,2,4,-1,-1,-1,-1,2,9,10,2,7,9,2,3,7,7,4,9,-1,-1,-1,-1,9,10,7,9,7,4,10,2,7,8,7,0,2,0,7,-1,3,7,10,3,10,2,7,4,10,1,10,0,4,0,10,-1,1,10,2,8,7,4,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,7,1,3,-1,-1,-1,-1,-1,-1,-1,4,9,1,4,1,7,0,8,1,8,7,1,-1,-1,-1,-1,4,0,3,7,4,3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,4,8,7,-1,-1,-1,
 -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,9,10,8,10,11,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,11,9,10,-1,-1,-1,-1,-1,-1,-1,0,1,10,0,10,8,8,10,11,-1,-1,-1,-1,-1,-1,-1,3,1,10,11,3,10,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,2,11,1,11,9,9,11,8,-1,-1,-1,-1,-1,-1,-1,3,0,9,3,9,11,1,2,9,2,11,9,-1,-1,-1,-1,0,2,11,8,0,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,3,2,11,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,10,8,9,-1,-1,-1,-1,-1,-1,-1,9,10,2,0,9,2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,2,3,8,2,8,10,0,1,8,1,10,8,-1,-1,-1,-1,1,10,
 2,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,1,3,8,9,1,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,9,1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,3,8,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]);
-THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),e=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(e,a.vertexShader);b.compileShader(d);b.compileShader(e);b.attachShader(c,d);b.attachShader(c,e);b.linkProgram(c);return c}var b,c,d,g,e,h,i,k,l,j,n,m,o;this.init=function(p){b=p.context;c=p;d=new Float32Array(16);g=new Uint16Array(6);p=0;d[p++]=-1;d[p++]=-1;d[p++]=0;d[p++]=0;d[p++]=1;d[p++]=-1;d[p++]=1;d[p++]=
-0;d[p++]=1;d[p++]=1;d[p++]=1;d[p++]=1;d[p++]=-1;d[p++]=1;d[p++]=0;d[p++]=1;p=0;g[p++]=0;g[p++]=1;g[p++]=2;g[p++]=0;g[p++]=2;g[p++]=3;e=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,e);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,g,b.STATIC_DRAW);i=b.createTexture();k=b.createTexture();b.bindTexture(b.TEXTURE_2D,i);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,
+THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.createShader(b.FRAGMENT_SHADER),f=b.createShader(b.VERTEX_SHADER);b.shaderSource(d,a.fragmentShader);b.shaderSource(f,a.vertexShader);b.compileShader(d);b.compileShader(f);b.attachShader(c,d);b.attachShader(c,f);b.linkProgram(c);return c}var b,c,d,g,f,h,i,k,l,j,n,m,o;this.init=function(p){b=p.context;c=p;d=new Float32Array(16);g=new Uint16Array(6);p=0;d[p++]=-1;d[p++]=-1;d[p++]=0;d[p++]=0;d[p++]=1;d[p++]=-1;d[p++]=1;d[p++]=
+0;d[p++]=1;d[p++]=1;d[p++]=1;d[p++]=1;d[p++]=-1;d[p++]=1;d[p++]=0;d[p++]=1;p=0;g[p++]=0;g[p++]=1;g[p++]=2;g[p++]=0;g[p++]=2;g[p++]=3;f=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,g,b.STATIC_DRAW);i=b.createTexture();k=b.createTexture();b.bindTexture(b.TEXTURE_2D,i);b.texImage2D(b.TEXTURE_2D,0,b.RGB,16,16,0,b.RGB,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,
 b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);b.bindTexture(b.TEXTURE_2D,k);b.texImage2D(b.TEXTURE_2D,0,b.RGBA,16,16,0,b.RGBA,b.UNSIGNED_BYTE,null);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE);b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.NEAREST);
 b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.NEAREST);0>=b.getParameter(b.MAX_VERTEX_TEXTURE_IMAGE_UNITS)?(l=!1,j=a(THREE.ShaderFlares.lensFlare)):(l=!0,j=a(THREE.ShaderFlares.lensFlareVertexTexture));n={};m={};n.vertex=b.getAttribLocation(j,"position");n.uv=b.getAttribLocation(j,"uv");m.renderType=b.getUniformLocation(j,"renderType");m.map=b.getUniformLocation(j,"map");m.occlusionMap=b.getUniformLocation(j,"occlusionMap");m.opacity=b.getUniformLocation(j,"opacity");m.color=b.getUniformLocation(j,
-"color");m.scale=b.getUniformLocation(j,"scale");m.rotation=b.getUniformLocation(j,"rotation");m.screenPosition=b.getUniformLocation(j,"screenPosition");o=!1};this.render=function(a,d,g,v){var a=a.__webglFlares,F=a.length;if(F){var A=new THREE.Vector3,K=v/g,y=0.5*g,J=0.5*v,H=16/v,I=new THREE.Vector2(H*K,H),M=new THREE.Vector3(1,1,0),G=new THREE.Vector2(1,1),L=m,H=n;b.useProgram(j);o||(b.enableVertexAttribArray(n.vertex),b.enableVertexAttribArray(n.uv),o=!0);b.uniform1i(L.occlusionMap,0);b.uniform1i(L.map,
-1);b.bindBuffer(b.ARRAY_BUFFER,e);b.vertexAttribPointer(H.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(H.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(!1);var ka,T,la,ca,z;for(ka=0;ka<F;ka++)if(H=16/v,I.set(H*K,H),ca=a[ka],A.set(ca.matrixWorld.n14,ca.matrixWorld.n24,ca.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(A),d.projectionMatrix.multiplyVector3(A),M.copy(A),G.x=M.x*y+y,G.y=M.y*J+J,l||0<G.x&&G.x<g&&0<G.y&&G.y<v){b.activeTexture(b.TEXTURE1);
-b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,G.x-8,G.y-8,16,16,0);b.uniform1i(L.renderType,0);b.uniform2f(L.scale,I.x,I.y);b.uniform3f(L.screenPosition,M.x,M.y,M.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,k);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,G.x-8,G.y-8,16,16,0);b.uniform1i(L.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
-i);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);ca.positionScreen.copy(M);ca.customUpdateCallback?ca.customUpdateCallback(ca):ca.updateLensFlares();b.uniform1i(L.renderType,2);b.enable(b.BLEND);for(T=0,la=ca.lensFlares.length;T<la;T++)if(z=ca.lensFlares[T],0.0010<z.opacity&&0.0010<z.scale)M.x=z.x,M.y=z.y,M.z=z.z,H=z.size*z.scale/v,I.x=H*K,I.y=H,b.uniform3f(L.screenPosition,M.x,M.y,M.z),b.uniform2f(L.scale,I.x,I.y),b.uniform1f(L.rotation,z.rotation),b.uniform1f(L.opacity,z.opacity),b.uniform3f(L.color,
-z.color.r,z.color.g,z.color.b),c.setBlending(z.blending),c.setTexture(z.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
-THREE.ShadowMapPlugin=function(){var a,b,c,d,g,e=new THREE.Frustum,h=new THREE.Matrix4;this.shadowMatrix=[];this.shadowMap=[];this.init=function(c){a=c.context;b=c;var c=THREE.ShaderLib.depthRGBA,e=THREE.UniformsUtils.clone(c.uniforms);d=new THREE.ShaderMaterial({fragmentShader:c.fragmentShader,vertexShader:c.vertexShader,uniforms:e});g=new THREE.ShaderMaterial({fragmentShader:c.fragmentShader,vertexShader:c.vertexShader,uniforms:e,morphTargets:!0});d._shadowPass=!0;g._shadowPass=!0};this.render=
-function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(i){var k,l,j,n,m,o,p,r,t=0,v=i.lights;c||(c=new THREE.PerspectiveCamera(b.shadowCameraFov,b.shadowMapWidth/b.shadowMapHeight,b.shadowCameraNear,b.shadowCameraFar));a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(k=0,l=v.length;k<l;k++)if(p=v[k],p.castShadow&&p instanceof THREE.SpotLight){this.shadowMap[t]||(this.shadowMap[t]=new THREE.WebGLRenderTarget(b.shadowMapWidth,
+"color");m.scale=b.getUniformLocation(j,"scale");m.rotation=b.getUniformLocation(j,"rotation");m.screenPosition=b.getUniformLocation(j,"screenPosition");o=!1};this.render=function(a,d,g,y){var a=a.__webglFlares,F=a.length;if(F){var I=new THREE.Vector3,A=y/g,v=0.5*g,J=0.5*y,K=16/y,G=new THREE.Vector2(K*A,K),M=new THREE.Vector3(1,1,0),H=new THREE.Vector2(1,1),L=m,K=n;b.useProgram(j);o||(b.enableVertexAttribArray(n.vertex),b.enableVertexAttribArray(n.uv),o=!0);b.uniform1i(L.occlusionMap,0);b.uniform1i(L.map,
+1);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(K.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(K.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(!1);var V,ga,oa,z,e;for(V=0;V<F;V++)if(K=16/y,G.set(K*A,K),z=a[V],I.set(z.matrixWorld.n14,z.matrixWorld.n24,z.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(I),d.projectionMatrix.multiplyVector3(I),M.copy(I),H.x=M.x*v+v,H.y=M.y*J+J,l||0<H.x&&H.x<g&&0<H.y&&H.y<y){b.activeTexture(b.TEXTURE1);
+b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,H.x-8,H.y-8,16,16,0);b.uniform1i(L.renderType,0);b.uniform2f(L.scale,G.x,G.y);b.uniform3f(L.screenPosition,M.x,M.y,M.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,k);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,H.x-8,H.y-8,16,16,0);b.uniform1i(L.renderType,1);b.disable(b.DEPTH_TEST);b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
+i);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);z.positionScreen.copy(M);z.customUpdateCallback?z.customUpdateCallback(z):z.updateLensFlares();b.uniform1i(L.renderType,2);b.enable(b.BLEND);for(ga=0,oa=z.lensFlares.length;ga<oa;ga++)if(e=z.lensFlares[ga],0.0010<e.opacity&&0.0010<e.scale)M.x=e.x,M.y=e.y,M.z=e.z,K=e.size*e.scale/y,G.x=K*A,G.y=K,b.uniform3f(L.screenPosition,M.x,M.y,M.z),b.uniform2f(L.scale,G.x,G.y),b.uniform1f(L.rotation,e.rotation),b.uniform1f(L.opacity,e.opacity),b.uniform3f(L.color,
+e.color.r,e.color.g,e.color.b),c.setBlending(e.blending),c.setTexture(e.texture,1),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0)}b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
+THREE.ShadowMapPlugin=function(){var a,b,c,d,g,f=new THREE.Frustum,h=new THREE.Matrix4;this.shadowMatrix=[];this.shadowMap=[];this.init=function(c){a=c.context;b=c;var c=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(c.uniforms);d=new THREE.ShaderMaterial({fragmentShader:c.fragmentShader,vertexShader:c.vertexShader,uniforms:f});g=new THREE.ShaderMaterial({fragmentShader:c.fragmentShader,vertexShader:c.vertexShader,uniforms:f,morphTargets:!0});d._shadowPass=!0;g._shadowPass=!0};this.render=
+function(a,c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(i){var k,l,j,n,m,o,p,r,t=0,y=i.lights;c||(c=new THREE.PerspectiveCamera(b.shadowCameraFov,b.shadowMapWidth/b.shadowMapHeight,b.shadowCameraNear,b.shadowCameraFar));a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(k=0,l=y.length;k<l;k++)if(p=y[k],p.castShadow&&p instanceof THREE.SpotLight){this.shadowMap[t]||(this.shadowMap[t]=new THREE.WebGLRenderTarget(b.shadowMapWidth,
 b.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,format:THREE.RGBAFormat}),this.shadowMatrix[t]=new THREE.Matrix4);j=this.shadowMap[t];n=this.shadowMatrix[t];c.position.copy(p.position);c.lookAt(p.target.position);null==c.parent&&(i.add(c),b.autoUpdateScene&&i.updateMatrixWorld());c.matrixWorldInverse.getInverse(c.matrixWorld);n.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);n.multiplySelf(c.projectionMatrix);n.multiplySelf(c.matrixWorldInverse);if(!c._viewMatrixArray)c._viewMatrixArray=
-new Float32Array(16);c.matrixWorldInverse.flattenToArray(c._viewMatrixArray);if(!c._projectionMatrixArray)c._projectionMatrixArray=new Float32Array(16);c.projectionMatrix.flattenToArray(c._projectionMatrixArray);h.multiply(c.projectionMatrix,c.matrixWorldInverse);e.setFromMatrix(h);b.setRenderTarget(j);b.clear();r=i.__webglObjects;for(j=0,n=r.length;j<n;j++)if(m=r[j],p=m.object,m.render=!1,p.visible&&p.castShadow&&(!(p instanceof THREE.Mesh)||!p.frustumCulled||e.contains(p)))p.matrixWorld.flattenToArray(p._objectMatrixArray),
-p._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,p.matrixWorld,p._modelViewMatrixArray),m.render=!0;for(j=0,n=r.length;j<n;j++)if(m=r[j],m.render)p=m.object,m=m.buffer,b.setObjectFaces(p),o=p.customDepthMaterial?p.customDepthMaterial:p.geometry.morphTargets.length?g:d,m instanceof THREE.BufferGeometry?b.renderBufferDirect(c,v,null,o,m,p):b.renderBuffer(c,v,null,o,m,p);r=i.__webglObjectsImmediate;for(j=0,n=r.length;j<n;j++)m=r[j],p=m.object,p.visible&&p.castShadow&&(p.matrixAutoUpdate&&p.matrixWorld.flattenToArray(p._objectMatrixArray),
-p._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,p.matrixWorld,p._modelViewMatrixArray),b.renderImmediateObject(c,v,null,d,p));t++}i=b.getClearColor();k=b.getClearAlpha();a.clearColor(i.r,i.g,i.b,k);a.enable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};
-THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,g,e,h,i,k,l,j;this.init=function(a){b=a.context;c=a;d=new Float32Array(16);g=new Uint16Array(6);a=0;d[a++]=-1;d[a++]=-1;d[a++]=0;d[a++]=1;d[a++]=1;d[a++]=-1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=0;d[a++]=-1;d[a++]=1;d[a++]=0;a=d[a++]=0;g[a++]=0;g[a++]=1;g[a++]=2;g[a++]=0;g[a++]=2;g[a++]=3;e=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,e);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
+new Float32Array(16);c.matrixWorldInverse.flattenToArray(c._viewMatrixArray);if(!c._projectionMatrixArray)c._projectionMatrixArray=new Float32Array(16);c.projectionMatrix.flattenToArray(c._projectionMatrixArray);h.multiply(c.projectionMatrix,c.matrixWorldInverse);f.setFromMatrix(h);b.setRenderTarget(j);b.clear();r=i.__webglObjects;for(j=0,n=r.length;j<n;j++)if(m=r[j],p=m.object,m.render=!1,p.visible&&p.castShadow&&(!(p instanceof THREE.Mesh)||!p.frustumCulled||f.contains(p)))p.matrixWorld.flattenToArray(p._objectMatrixArray),
+p._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,p.matrixWorld,p._modelViewMatrixArray),m.render=!0;for(j=0,n=r.length;j<n;j++)if(m=r[j],m.render)p=m.object,m=m.buffer,b.setObjectFaces(p),o=p.customDepthMaterial?p.customDepthMaterial:p.geometry.morphTargets.length?g:d,m instanceof THREE.BufferGeometry?b.renderBufferDirect(c,y,null,o,m,p):b.renderBuffer(c,y,null,o,m,p);r=i.__webglObjectsImmediate;for(j=0,n=r.length;j<n;j++)m=r[j],p=m.object,p.visible&&p.castShadow&&(p.matrixAutoUpdate&&p.matrixWorld.flattenToArray(p._objectMatrixArray),
+p._modelViewMatrix.multiplyToArray(c.matrixWorldInverse,p.matrixWorld,p._modelViewMatrixArray),b.renderImmediateObject(c,y,null,d,p));t++}i=b.getClearColor();k=b.getClearAlpha();a.clearColor(i.r,i.g,i.b,k);a.enable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};
+THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,g,f,h,i,k,l,j;this.init=function(a){b=a.context;c=a;d=new Float32Array(16);g=new Uint16Array(6);a=0;d[a++]=-1;d[a++]=-1;d[a++]=0;d[a++]=1;d[a++]=1;d[a++]=-1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=1;d[a++]=0;d[a++]=-1;d[a++]=1;d[a++]=0;a=d[a++]=0;g[a++]=0;g[a++]=1;g[a++]=2;g[a++]=0;g[a++]=2;g[a++]=3;f=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,f);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
 h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,g,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,m=b.createProgram(),o=b.createShader(b.FRAGMENT_SHADER),p=b.createShader(b.VERTEX_SHADER);b.shaderSource(o,a.fragmentShader);b.shaderSource(p,a.vertexShader);b.compileShader(o);b.compileShader(p);b.attachShader(m,o);b.attachShader(m,p);b.linkProgram(m);i=m;k={};l={};k.position=b.getAttribLocation(i,"position");k.uv=b.getAttribLocation(i,"uv");l.uvOffset=b.getUniformLocation(i,"uvOffset");l.uvScale=b.getUniformLocation(i,
 "uvScale");l.rotation=b.getUniformLocation(i,"rotation");l.scale=b.getUniformLocation(i,"scale");l.alignment=b.getUniformLocation(i,"alignment");l.color=b.getUniformLocation(i,"color");l.map=b.getUniformLocation(i,"map");l.opacity=b.getUniformLocation(i,"opacity");l.useScreenCoordinates=b.getUniformLocation(i,"useScreenCoordinates");l.affectedByDistance=b.getUniformLocation(i,"affectedByDistance");l.screenPosition=b.getUniformLocation(i,"screenPosition");l.modelViewMatrix=b.getUniformLocation(i,"modelViewMatrix");
-l.projectionMatrix=b.getUniformLocation(i,"projectionMatrix");j=!1};this.render=function(d,g,o,p){var d=d.__webglSprites,r=d.length;if(r){var t=k,v=l,F=p/o,o=0.5*o,A=0.5*p,K=!0;b.useProgram(i);j||(b.enableVertexAttribArray(t.position),b.enableVertexAttribArray(t.uv),j=!0);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,e);b.vertexAttribPointer(t.position,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(t.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.uniformMatrix4fv(v.projectionMatrix,
-!1,g._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(v.map,0);for(var y,J=[],t=0;t<r;t++)if(y=d[t],y.visible&&0!==y.opacity)y.useScreenCoordinates?y.z=-y.position.z:(y._modelViewMatrix.multiplyToArray(g.matrixWorldInverse,y.matrixWorld,y._modelViewMatrixArray),y.z=-y._modelViewMatrix.n34);d.sort(a);for(t=0;t<r;t++)y=d[t],y.visible&&0!==y.opacity&&y.map&&y.map.image&&y.map.image.width&&(y.useScreenCoordinates?(b.uniform1i(v.useScreenCoordinates,1),b.uniform3f(v.screenPosition,(y.position.x-
-o)/o,(A-y.position.y)/A,Math.max(0,Math.min(1,y.position.z)))):(b.uniform1i(v.useScreenCoordinates,0),b.uniform1i(v.affectedByDistance,y.affectedByDistance?1:0),b.uniformMatrix4fv(v.modelViewMatrix,!1,y._modelViewMatrixArray)),g=y.map.image.width/(y.scaleByViewport?p:1),J[0]=g*F*y.scale.x,J[1]=g*y.scale.y,b.uniform2f(v.uvScale,y.uvScale.x,y.uvScale.y),b.uniform2f(v.uvOffset,y.uvOffset.x,y.uvOffset.y),b.uniform2f(v.alignment,y.alignment.x,y.alignment.y),b.uniform1f(v.opacity,y.opacity),b.uniform3f(v.color,
-y.color.r,y.color.g,y.color.b),b.uniform1f(v.rotation,y.rotation),b.uniform2fv(v.scale,J),y.mergeWith3D&&!K?(b.enable(b.DEPTH_TEST),K=!0):!y.mergeWith3D&&K&&(b.disable(b.DEPTH_TEST),K=!1),c.setBlending(y.blending),c.setTexture(y.map,0),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0));b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
+l.projectionMatrix=b.getUniformLocation(i,"projectionMatrix");j=!1};this.render=function(d,g,o,p){var d=d.__webglSprites,r=d.length;if(r){var t=k,y=l,F=p/o,o=0.5*o,I=0.5*p,A=!0;b.useProgram(i);j||(b.enableVertexAttribArray(t.position),b.enableVertexAttribArray(t.uv),j=!0);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,f);b.vertexAttribPointer(t.position,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(t.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.uniformMatrix4fv(y.projectionMatrix,
+!1,g._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(y.map,0);for(var v,J=[],t=0;t<r;t++)if(v=d[t],v.visible&&0!==v.opacity)v.useScreenCoordinates?v.z=-v.position.z:(v._modelViewMatrix.multiplyToArray(g.matrixWorldInverse,v.matrixWorld,v._modelViewMatrixArray),v.z=-v._modelViewMatrix.n34);d.sort(a);for(t=0;t<r;t++)v=d[t],v.visible&&0!==v.opacity&&v.map&&v.map.image&&v.map.image.width&&(v.useScreenCoordinates?(b.uniform1i(y.useScreenCoordinates,1),b.uniform3f(y.screenPosition,(v.position.x-
+o)/o,(I-v.position.y)/I,Math.max(0,Math.min(1,v.position.z)))):(b.uniform1i(y.useScreenCoordinates,0),b.uniform1i(y.affectedByDistance,v.affectedByDistance?1:0),b.uniformMatrix4fv(y.modelViewMatrix,!1,v._modelViewMatrixArray)),g=v.map.image.width/(v.scaleByViewport?p:1),J[0]=g*F*v.scale.x,J[1]=g*v.scale.y,b.uniform2f(y.uvScale,v.uvScale.x,v.uvScale.y),b.uniform2f(y.uvOffset,v.uvOffset.x,v.uvOffset.y),b.uniform2f(y.alignment,v.alignment.x,v.alignment.y),b.uniform1f(y.opacity,v.opacity),b.uniform3f(y.color,
+v.color.r,v.color.g,v.color.b),b.uniform1f(y.rotation,v.rotation),b.uniform2fv(y.scale,J),v.mergeWith3D&&!A?(b.enable(b.DEPTH_TEST),A=!0):!v.mergeWith3D&&A&&(b.disable(b.DEPTH_TEST),A=!1),c.setBlending(v.blending),c.setTexture(v.map,0),b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0));b.enable(b.CULL_FACE);b.enable(b.DEPTH_TEST);b.depthMask(!0)}}};
 THREE.ShaderFlares={lensFlareVertexTexture:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.1 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.9, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.9 ) ) +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ) +\ntexture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = (       visibility.r / 9.0 ) *\n( 1.0 - visibility.g / 9.0 ) *\n(       visibility.b / 9.0 ) *\n( 1.0 - visibility.a / 9.0 );\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},
 lensFlare:{vertexShader:"uniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform int renderType;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif( renderType == 2 ) {\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",fragmentShader:"precision mediump float;\nuniform sampler2D map;\nuniform sampler2D occlusionMap;\nuniform float opacity;\nuniform int renderType;\nuniform vec3 color;\nvarying vec2 vUV;\nvoid main() {\nif( renderType == 0 ) {\ngl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );\n} else if( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nfloat visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a +\ntexture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a +\ntexture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a +\ntexture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;\nvisibility = ( 1.0 - visibility / 4.0 );\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * visibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"}};
 THREE.ShaderSprite={sprite:{vertexShader:"uniform int useScreenCoordinates;\nuniform int affectedByDistance;\nuniform vec3 screenPosition;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 alignment;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position + alignment;\nvec2 rotatedPosition;\nrotatedPosition.x = ( cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y ) * scale.x;\nrotatedPosition.y = ( sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y ) * scale.y;\nvec4 finalPosition;\nif( useScreenCoordinates != 0 ) {\nfinalPosition = vec4( screenPosition.xy + rotatedPosition, screenPosition.z, 1.0 );\n} else {\nfinalPosition = projectionMatrix * modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition * ( affectedByDistance == 1 ? 1.0 : finalPosition.z );\n}\ngl_Position = finalPosition;\n}",
 fragmentShader:"precision mediump float;\nuniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\n}"}};
-THREE.ImageUtils={crossOrigin:"",loadTexture:function(a,b,c){var d=new Image,g=new THREE.Texture(d,b);d.onload=function(){g.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return g},loadTextureCube:function(a,b,c){var d,g=[],e=new THREE.Texture(g,b);g.loadCount=0;for(b=0,d=a.length;b<d;++b)g[b]=new Image,g[b].onload=function(){g.loadCount+=1;if(6===g.loadCount)e.needsUpdate=!0;c&&c(this)},g[b].crossOrigin="",g[b].src=a[b];return e},getNormalMap:function(a,b){var c=function(a){var b=
-Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,g=a.height,e=document.createElement("canvas");e.width=d;e.height=g;var h=e.getContext("2d");h.drawImage(a,0,0);for(var i=h.getImageData(0,0,d,g).data,k=h.createImageData(d,g),l=k.data,j=0;j<d;j++)for(var n=1;n<g;n++){var m=0>n-1?g-1:n-1,o=(n+1)%g,p=0>j-1?d-1:j-1,r=(j+1)%d,t=[],v=[0,0,i[4*(n*d+j)]/255*b];t.push([-1,0,i[4*(n*d+p)]/255*b]);t.push([-1,-1,i[4*(m*d+p)]/255*b]);t.push([0,-1,i[4*(m*d+j)]/255*b]);t.push([1,
--1,i[4*(m*d+r)]/255*b]);t.push([1,0,i[4*(n*d+r)]/255*b]);t.push([1,1,i[4*(o*d+r)]/255*b]);t.push([0,1,i[4*(o*d+j)]/255*b]);t.push([-1,1,i[4*(o*d+p)]/255*b]);m=[];p=t.length;for(o=0;o<p;o++){var r=t[o],F=t[(o+1)%p],r=[r[0]-v[0],r[1]-v[1],r[2]-v[2]],F=[F[0]-v[0],F[1]-v[1],F[2]-v[2]];m.push(c([r[1]*F[2]-r[2]*F[1],r[2]*F[0]-r[0]*F[2],r[0]*F[1]-r[1]*F[0]]))}t=[0,0,0];for(o=0;o<m.length;o++)t[0]+=m[o][0],t[1]+=m[o][1],t[2]+=m[o][2];t[0]/=m.length;t[1]/=m.length;t[2]/=m.length;v=4*(n*d+j);l[v]=255*((t[0]+
-1)/2)|0;l[v+1]=255*(t[1]+0.5)|0;l[v+2]=255*t[2]|0;l[v+3]=255}h.putImageData(k,0,0);return e}};
+THREE.ImageUtils={crossOrigin:"",loadTexture:function(a,b,c){var d=new Image,g=new THREE.Texture(d,b);d.onload=function(){g.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return g},loadTextureCube:function(a,b,c){var d,g=[],f=new THREE.Texture(g,b);g.loadCount=0;for(b=0,d=a.length;b<d;++b)g[b]=new Image,g[b].onload=function(){g.loadCount+=1;if(6===g.loadCount)f.needsUpdate=!0;c&&c(this)},g[b].crossOrigin="",g[b].src=a[b];return f},getNormalMap:function(a,b){var c=function(a){var b=
+Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,g=a.height,f=document.createElement("canvas");f.width=d;f.height=g;var h=f.getContext("2d");h.drawImage(a,0,0);for(var i=h.getImageData(0,0,d,g).data,k=h.createImageData(d,g),l=k.data,j=0;j<d;j++)for(var n=1;n<g;n++){var m=0>n-1?g-1:n-1,o=(n+1)%g,p=0>j-1?d-1:j-1,r=(j+1)%d,t=[],y=[0,0,i[4*(n*d+j)]/255*b];t.push([-1,0,i[4*(n*d+p)]/255*b]);t.push([-1,-1,i[4*(m*d+p)]/255*b]);t.push([0,-1,i[4*(m*d+j)]/255*b]);t.push([1,
+-1,i[4*(m*d+r)]/255*b]);t.push([1,0,i[4*(n*d+r)]/255*b]);t.push([1,1,i[4*(o*d+r)]/255*b]);t.push([0,1,i[4*(o*d+j)]/255*b]);t.push([-1,1,i[4*(o*d+p)]/255*b]);m=[];p=t.length;for(o=0;o<p;o++){var r=t[o],F=t[(o+1)%p],r=[r[0]-y[0],r[1]-y[1],r[2]-y[2]],F=[F[0]-y[0],F[1]-y[1],F[2]-y[2]];m.push(c([r[1]*F[2]-r[2]*F[1],r[2]*F[0]-r[0]*F[2],r[0]*F[1]-r[1]*F[0]]))}t=[0,0,0];for(o=0;o<m.length;o++)t[0]+=m[o][0],t[1]+=m[o][1],t[2]+=m[o][2];t[0]/=m.length;t[1]/=m.length;t[2]/=m.length;y=4*(n*d+j);l[y]=255*((t[0]+
+1)/2)|0;l[y+1]=255*(t[1]+0.5)|0;l[y+2]=255*t[2]|0;l[y+3]=255}h.putImageData(k,0,0);return f}};

+ 2 - 7
examples/webgl_loader_ctm_materials.html

@@ -62,7 +62,7 @@
 			var mesh;
 
 			var textureCube;
-			var cameraCube, sceneCube, cubeTarget;
+			var cameraCube, sceneCube;
 
 			var loader;
 
@@ -95,7 +95,6 @@
 
 				// SKYBOX
 
-				cubeTarget = new THREE.Vector3( 0, 0, 0 );
 				sceneCube = new THREE.Scene();
 				cameraCube = new THREE.PerspectiveCamera( 25, SCREEN_WIDTH / SCREEN_HEIGHT, 1, 10000 );
 				sceneCube.add( cameraCube );
@@ -348,11 +347,7 @@
 
 				controls.update();
 
-				cubeTarget.x = - camera.position.x;
-				cubeTarget.y = - camera.position.y;
-				cubeTarget.z = - camera.position.z;
-
-				cameraCube.lookAt( cubeTarget );
+				cameraCube.rotation.copy( camera.rotation );
 
 				renderer.clear();
 				renderer.render( sceneCube, cameraCube );

+ 22 - 12
src/core/Ray.js

@@ -103,30 +103,35 @@ THREE.Ray = function ( origin, direction ) {
 
 				objMatrix = object.matrixWorld;
 
-				// check if face.centroid is behind the origin
+				// determine if ray intersects the plane of the face
+				// note: this works regardless of the direction of the face normal
 
 				vector = objMatrix.multiplyVector3( vector.copy( face.centroid ) ).subSelf( originCopy );
-				dot = vector.dot( directionCopy );
+				normal = object.matrixRotationWorld.multiplyVector3( normal.copy( face.normal ) );
+				dot = directionCopy.dot( normal );
 
-				if ( dot <= 0 ) continue;
+				// bail if ray and plane are parallel
 
-				//
+				if ( Math.abs( dot ) < 0.0001 ) continue;
 
-				a = objMatrix.multiplyVector3( a.copy( vertices[ face.a ].position ) );
-				b = objMatrix.multiplyVector3( b.copy( vertices[ face.b ].position ) );
-				c = objMatrix.multiplyVector3( c.copy( vertices[ face.c ].position ) );
-				if ( face instanceof THREE.Face4 ) d = objMatrix.multiplyVector3( d.copy( vertices[ face.d ].position ) );
+				// calc distance to plane
 
-				normal = object.matrixRotationWorld.multiplyVector3( normal.copy( face.normal ) );
-				dot = directionCopy.dot( normal );
+				scalar = normal.dot( vector ) / dot;
 
-				if ( object.doubleSided || ( object.flipSided ? dot > 0 : dot < 0 ) ) { // Math.abs( dot ) > 0.0001
+				// if negative distance, then plane is behind ray
+
+				if ( scalar < 0 ) continue;
+
+				if ( object.doubleSided || ( object.flipSided ? dot > 0 : dot < 0 ) ) {
 
-					scalar = normal.dot( vector.sub( a, originCopy ) ) / dot;
 					intersectPoint.add( originCopy, directionCopy.multiplyScalar( scalar ) );
 
 					if ( face instanceof THREE.Face3 ) {
 
+						a = objMatrix.multiplyVector3( a.copy( vertices[ face.a ].position ) );
+						b = objMatrix.multiplyVector3( b.copy( vertices[ face.b ].position ) );
+						c = objMatrix.multiplyVector3( c.copy( vertices[ face.c ].position ) );
+
 						if ( pointInFace3( intersectPoint, a, b, c ) ) {
 
 							intersect = {
@@ -144,6 +149,11 @@ THREE.Ray = function ( origin, direction ) {
 
 					} else if ( face instanceof THREE.Face4 ) {
 
+						a = objMatrix.multiplyVector3( a.copy( vertices[ face.a ].position ) );
+						b = objMatrix.multiplyVector3( b.copy( vertices[ face.b ].position ) );
+						c = objMatrix.multiplyVector3( c.copy( vertices[ face.c ].position ) );
+						d = objMatrix.multiplyVector3( d.copy( vertices[ face.d ].position ) );
+
 						if ( pointInFace3( intersectPoint, a, b, d ) || pointInFace3( intersectPoint, b, c, d ) ) {
 
 							intersect = {

+ 19 - 14
src/renderers/WebGLRenderer.js

@@ -3244,7 +3244,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			this.setBlending( scene.overrideMaterial.blending );
 			this.setDepthTest( scene.overrideMaterial.depthTest );
-			setDepthWrite( scene.overrideMaterial.depthWrite );
+			this.setDepthWrite( scene.overrideMaterial.depthWrite );
 			setPolygonOffset( scene.overrideMaterial.polygonOffset, scene.overrideMaterial.polygonOffsetFactor, scene.overrideMaterial.polygonOffsetUnits );
 
 			renderObjects( scene.__webglObjects, false, "", camera, lights, fog, true, scene.overrideMaterial );
@@ -3279,7 +3279,12 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		}
 
-		//_gl.finish();
+		// Ensure depth buffer writing is enabled so it can be cleared on next render
+
+		this.setDepthTest( true );
+		this.setDepthWrite( true );
+
+		// _gl.finish();
 
 	};
 
@@ -3348,7 +3353,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 					if ( useBlending ) _this.setBlending( material.blending );
 
 					_this.setDepthTest( material.depthTest );
-					setDepthWrite( material.depthWrite );
+					_this.setDepthWrite( material.depthWrite );
 					setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );
 
 				}
@@ -3395,7 +3400,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 					if ( useBlending ) _this.setBlending( material.blending );
 
 					_this.setDepthTest( material.depthTest );
-					setDepthWrite( material.depthWrite );
+					_this.setDepthWrite( material.depthWrite );
 					setPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );
 
 				}
@@ -4889,7 +4894,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		if ( _oldDepthTest !== depthTest ) {
 
-			if( depthTest ) {
+			if ( depthTest ) {
 
 				_gl.enable( _gl.DEPTH_TEST );
 
@@ -4905,24 +4910,24 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 	};
 
-	function setLineWidth ( width ) {
-
-		if ( width !== _oldLineWidth ) {
+	this.setDepthWrite = function ( depthWrite ) {
 
-			_gl.lineWidth( width );
+		if ( _oldDepthWrite !== depthWrite ) {
 
-			_oldLineWidth = width;
+			_gl.depthMask( depthWrite );
+			_oldDepthWrite = depthWrite;
 
 		}
 
 	};
 
-	function setDepthWrite ( depthWrite ) {
+	function setLineWidth ( width ) {
 
-		if ( _oldDepthWrite !== depthWrite ) {
+		if ( width !== _oldLineWidth ) {
 
-			_gl.depthMask( depthWrite );
-			_oldDepthWrite = depthWrite;
+			_gl.lineWidth( width );
+
+			_oldLineWidth = width;
 
 		}