2
0
Эх сурвалжийг харах

Refactored morph normals to be optional.

Default computation of morph normals for all models with morphs was taking unnecessary time and memory.

Also made it less resource intensive to recompute morph normals.
alteredq 13 жил өмнө
parent
commit
cb41542aad

+ 365 - 364
build/Three.js

@@ -19,39 +19,39 @@ this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;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,n.copy(b).multiplyScalar(r));return t=c.distanceTo(s)}function d(a,b,c,d){o.sub(d,b);q.sub(c,b);n.sub(a,b);w=o.dot(o);u=o.dot(q);v=o.dot(n);y=q.dot(q);D=q.dot(n);C=1/(w*y-u*u);B=(y*v-u*D)*C;E=(w*D-u*v)*C;return 0<=B&&0<=E&&1>B+E}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,k=new THREE.Vector3,l=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector3;this.intersectObject=function(a){for(var b,n=[],o=0,q=a.children.length;o<q;o++)Array.prototype.push.apply(n,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};n.push(b)}else if(a instanceof THREE.Mesh){o=c(this.origin,this.direction,a.matrixWorld.getPosition());q=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(o>a.geometry.boundingSphere.radius*Math.max(q.x,Math.max(q.y,q.z)))return n;var r,s,j=a.geometry,t=j.vertices,u;a.matrixRotationWorld.extractRotation(a.matrixWorld);
-for(o=0,q=j.faces.length;o<q;o++)if(b=j.faces[o],i.copy(this.origin),k.copy(this.direction),u=a.matrixWorld,l=u.multiplyVector3(l.copy(b.centroid)).subSelf(i),p=a.matrixRotationWorld.multiplyVector3(p.copy(b.normal)),r=k.dot(p),!(1.0E-4>Math.abs(r))&&(s=p.dot(l)/r,!(0>s)&&(a.doubleSided||(a.flipSided?0<r:0>r))))if(m.add(i,k.multiplyScalar(s)),b instanceof THREE.Face3)e=u.multiplyVector3(e.copy(t[b.a].position)),f=u.multiplyVector3(f.copy(t[b.b].position)),g=u.multiplyVector3(g.copy(t[b.c].position)),
-d(m,e,f,g)&&(b={distance:i.distanceTo(m),point:m.clone(),face:b,object:a},n.push(b));else if(b instanceof THREE.Face4&&(e=u.multiplyVector3(e.copy(t[b.a].position)),f=u.multiplyVector3(f.copy(t[b.b].position)),g=u.multiplyVector3(g.copy(t[b.c].position)),h=u.multiplyVector3(h.copy(t[b.d].position)),d(m,e,f,h)||d(m,f,g,h)))b={distance:i.distanceTo(m),point:m.clone(),face:b,object:a},n.push(b)}return n};var o=new THREE.Vector3,q=new THREE.Vector3,n=new THREE.Vector3,r,s,t,w,u,v,y,D,C,B,E};
+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);w=o.dot(o);u=o.dot(q);v=o.dot(m);A=q.dot(q);B=q.dot(m);C=1/(w*A-u*u);D=(A*v-u*B)*C;I=(w*B-u*v)*C;return 0<=D&&0<=I&&1>D+I}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,k=new THREE.Vector3,l=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());q=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(o>a.geometry.boundingSphere.radius*Math.max(q.x,Math.max(q.y,q.z)))return m;var r,s,j=a.geometry,t=j.vertices,u;a.matrixRotationWorld.extractRotation(a.matrixWorld);
+for(o=0,q=j.faces.length;o<q;o++)if(b=j.faces[o],i.copy(this.origin),k.copy(this.direction),u=a.matrixWorld,l=u.multiplyVector3(l.copy(b.centroid)).subSelf(i),p=a.matrixRotationWorld.multiplyVector3(p.copy(b.normal)),r=k.dot(p),!(1.0E-4>Math.abs(r))&&(s=p.dot(l)/r,!(0>s)&&(a.doubleSided||(a.flipSided?0<r:0>r))))if(n.add(i,k.multiplyScalar(s)),b instanceof THREE.Face3)e=u.multiplyVector3(e.copy(t[b.a].position)),f=u.multiplyVector3(f.copy(t[b.b].position)),g=u.multiplyVector3(g.copy(t[b.c].position)),
+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&&(e=u.multiplyVector3(e.copy(t[b.a].position)),f=u.multiplyVector3(f.copy(t[b.b].position)),g=u.multiplyVector3(g.copy(t[b.c].position)),h=u.multiplyVector3(h.copy(t[b.d].position)),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,w,u,v,A,B,C,D,I};
 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,l,p){h=!1;b=f;c=g;d=l;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,l,p,m,o){h?(h=!1,b=f<l?f<m?f:m:l<m?l:m,c=g<p?g<o?g:o:p<o?p:o,d=f>l?f>m?f:m:l>m?l:m,e=g>p?g>o?g:o:p>o?p:o):(b=f<l?f<m?f<b?f:b:m<b?m:b:l<m?l<b?l:b:m<b?m: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>l?f>m?f>d?f:d:m>d?m:d:l>m?l>d?l:d:m>d?m: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,l,p,n,o){h?(h=!1,b=f<l?f<n?f:n:l<n?l:n,c=g<p?g<o?g:o:p<o?p:o,d=f>l?f>n?f:n:l>n?l:n,e=g>p?g>o?g:o:p>o?p:o):(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<p?g<o?g<c?g:c:o<c?o:c:p<o?p<c?p:c:o<c?o: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>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>
 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,k,l,p,m,o,q,n){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,k||0,void 0!==l?l:1,p||0,m||0,o||0,q||0,void 0!==n?n: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,k,l,p,m,o,q,n){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=k;this.n33=l;this.n34=p;this.n41=m;this.n42=o;this.n43=q;this.n44=n;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,k=a.n24,l=a.n31,p=a.n32,m=a.n33,o=a.n34,q=a.n41,n=a.n42,r=a.n43,
-s=a.n44,t=b.n11,w=b.n12,u=b.n13,v=b.n14,y=b.n21,D=b.n22,C=b.n23,B=b.n24,E=b.n31,J=b.n32,N=b.n33,S=b.n34,K=b.n41,O=b.n42,M=b.n43,H=b.n44;this.n11=c*t+d*y+e*E+f*K;this.n12=c*w+d*D+e*J+f*O;this.n13=c*u+d*C+e*N+f*M;this.n14=c*v+d*B+e*S+f*H;this.n21=g*t+h*y+i*E+k*K;this.n22=g*w+h*D+i*J+k*O;this.n23=g*u+h*C+i*N+k*M;this.n24=g*v+h*B+i*S+k*H;this.n31=l*t+p*y+m*E+o*K;this.n32=l*w+p*D+m*J+o*O;this.n33=l*u+p*C+m*N+o*M;this.n34=l*v+p*B+m*S+o*H;this.n41=q*t+n*y+r*E+s*K;this.n42=q*w+n*D+r*J+s*O;this.n43=q*u+n*
-C+r*N+s*M;this.n44=q*v+n*B+r*S+s*H;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,k,l,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,k||0,void 0!==l?l: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,k,l,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=k;this.n33=l;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,k=a.n24,l=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,w=b.n12,u=b.n13,v=b.n14,A=b.n21,B=b.n22,C=b.n23,D=b.n24,I=b.n31,K=b.n32,O=b.n33,S=b.n34,L=b.n41,P=b.n42,H=b.n43,G=b.n44;this.n11=c*t+d*A+e*I+f*L;this.n12=c*w+d*B+e*K+f*P;this.n13=c*u+d*C+e*O+f*H;this.n14=c*v+d*D+e*S+f*G;this.n21=g*t+h*A+i*I+k*L;this.n22=g*w+h*B+i*K+k*P;this.n23=g*u+h*C+i*O+k*H;this.n24=g*v+h*D+i*S+k*G;this.n31=l*t+p*A+n*I+o*L;this.n32=l*w+p*B+n*K+o*P;this.n33=l*u+p*C+n*O+o*H;this.n34=l*v+p*D+n*S+o*G;this.n41=q*t+m*A+r*I+s*L;this.n42=q*w+m*B+r*K+s*P;this.n43=q*u+m*
+C+r*O+s*H;this.n44=q*v+m*D+r*S+s*G;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,k=this.n32,l=this.n33,p=this.n34,m=this.n41,o=this.n42,q=this.n43,n=this.n44;return d*g*k*m-c*h*k*m-d*f*l*m+b*h*l*m+c*f*p*m-b*g*p*m-d*g*i*o+c*h*i*o+d*e*l*o-a*h*l*o-c*e*p*o+a*g*p*o+d*f*i*q-b*h*i*q-d*e*k*q+a*h*k*q+b*e*p*q-a*f*p*q-c*f*i*n+b*g*i*n+c*e*k*n-a*g*k*n-b*e*l*n+a*f*l*n},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,k=this.n32,l=this.n33,p=this.n34,n=this.n41,o=this.n42,q=this.n43,m=this.n44;return d*g*k*n-c*h*k*n-d*f*l*n+b*h*l*n+c*f*p*n-b*g*p*n-d*g*i*o+c*h*i*o+d*e*l*o-a*h*l*o-c*e*p*o+a*g*p*o+d*f*i*q-b*h*i*q-d*e*k*q+a*h*k*q+b*e*p*q-a*f*p*q-c*f*i*m+b*g*i*m+c*e*k*m-a*g*k*m-b*e*l*m+a*f*l*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,k=e*g;this.set(i*f+c,i*g-d*h,i*h+d*g,0,i*g+d*h,k*g+c,k*h-d*f,0,i*h-d*g,k*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,k=a.n31,l=a.n32,p=a.n33,m=a.n34,o=a.n41,q=a.n42,n=a.n43,r=a.n44;this.n11=h*m*q-i*p*q+i*l*n-g*m*n-h*l*r+g*p*r;this.n12=e*p*q-d*m*q-e*l*n+c*m*n+d*l*r-c*p*r;this.n13=d*i*q-e*h*q+e*g*n-c*i*n-d*g*r+c*h*r;this.n14=e*h*l-d*i*l-e*g*p+c*i*p+d*g*m-c*h*m;this.n21=i*p*o-h*m*o-i*k*n+f*m*n+h*k*r-f*p*r;this.n22=d*m*o-e*p*o+
-e*k*n-b*m*n-d*k*r+b*p*r;this.n23=e*h*o-d*i*o-e*f*n+b*i*n+d*f*r-b*h*r;this.n24=d*i*k-e*h*k+e*f*p-b*i*p-d*f*m+b*h*m;this.n31=g*m*o-i*l*o+i*k*q-f*m*q-g*k*r+f*l*r;this.n32=e*l*o-c*m*o-e*k*q+b*m*q+c*k*r-b*l*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*k-c*i*k-e*f*l+b*i*l+c*f*m-b*g*m;this.n41=h*l*o-g*p*o-h*k*q+f*p*q+g*k*n-f*l*n;this.n42=c*p*o-d*l*o+d*k*q-b*p*q-c*k*n+b*l*n;this.n43=d*g*o-c*h*o-d*f*q+b*h*q+c*f*n-b*g*n;this.n44=c*h*k-d*g*k+d*f*l-b*h*l-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,k=a.n31,l=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*l*m-g*n*m-h*l*r+g*p*r;this.n12=e*p*q-d*n*q-e*l*m+c*n*m+d*l*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*l-d*i*l-e*g*p+c*i*p+d*g*n-c*h*n;this.n21=i*p*o-h*n*o-i*k*m+f*n*m+h*k*r-f*p*r;this.n22=d*n*o-e*p*o+
+e*k*m-b*n*m-d*k*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*k-e*h*k+e*f*p-b*i*p-d*f*n+b*h*n;this.n31=g*n*o-i*l*o+i*k*q-f*n*q-g*k*r+f*l*r;this.n32=e*l*o-c*n*o-e*k*q+b*n*q+c*k*r-b*l*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*k-c*i*k-e*f*l+b*i*l+c*f*n-b*g*n;this.n41=h*l*o-g*p*o-h*k*q+f*p*q+g*k*m-f*l*m;this.n42=c*p*o-d*l*o+d*k*q-b*p*q-c*k*m+b*l*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*k-d*g*k+d*f*l-b*h*l-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,k=g*e,l=d*h,p=d*e;this.n11=i+p*c;this.n12=l*c-k;this.n13=f*d;this.n21=f*e;this.n22=f*h;this.n23=-c;this.n31=k*c-l;this.n32=p+i*c;this.n33=f*g;break;case "ZXY":i=g*h;k=g*e;l=d*h;p=d*e;this.n11=i-p*c;this.n12=-f*e;this.n13=l+k*c;this.n21=k+l*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;k=f*e;l=c*h;p=c*e;this.n11=g*h;this.n12=l*d-k;this.n13=i*d+p;this.n21=g*e;this.n22=p*d+i;this.n23=k*d-l;this.n31=-d;this.n32=c*g;this.n33=f*g;break;case "YZX":i=f*g;k=f*d;l=c*g;p=c*d;this.n11=g*h;this.n12=p-i*e;this.n13=l*e+k;this.n21=e;this.n22=f*h;this.n23=-c*h;this.n31=-d*h;this.n32=k*e+l;this.n33=i-p*e;break;case "XZY":i=f*g;k=f*d;l=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=k*e-l;this.n31=l*e-k;this.n32=c*h;this.n33=p*e+i;break;default:i=f*h,k=f*
 e,l=c*h,p=c*e,this.n11=g*h,this.n12=-g*e,this.n13=d,this.n21=k+l*d,this.n22=i-p*d,this.n23=-c*g,this.n31=p-i*d,this.n32=l+k*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,k=c*g,c=c*h,d=d*h,f=e*f,g=e*g,e=e*h;this.n11=1-(k+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+k);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),k=Math.sin(b),l=1-i,p=c*d*l,m=c*e*l,l=d*e*l,c=c*k,o=d*k,k=e*k,e=f+(1-f)*i,f=p+k,d=m-o,p=p-k,g=g+(1-g)*i,k=l+c,m=m+o,l=l-c,h=h+(1-h)*i,i=this.n11,c=this.n21,o=this.n31,q=this.n41,n=this.n12,r=this.n22,s=this.n32,t=this.n42,w=this.n13,u=this.n23,v=this.n33,y=this.n43;this.n11=e*i+f*n+d*w;this.n21=e*c+f*r+d*u;this.n31=e*o+f*s+d*v;this.n41=e*q+f*t+d*y;this.n12=p*i+g*n+k*w;this.n22=
-p*c+g*r+k*u;this.n32=p*o+g*s+k*v;this.n42=p*q+g*t+k*y;this.n13=m*i+l*n+h*w;this.n23=m*c+l*r+h*u;this.n33=m*o+l*s+h*v;this.n43=m*q+l*t+h*y;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,k=Math.cos(a),a=Math.sin(a);this.n12=k*b+a*f;this.n22=k*c+a*g;this.n32=k*d+a*h;this.n42=k*e+a*i;this.n13=k*f-a*b;this.n23=k*g-a*c;this.n33=k*h-a*d;this.n43=k*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),k=Math.sin(b),l=1-i,p=c*d*l,n=c*e*l,l=d*e*l,c=c*k,o=d*k,k=e*k,e=f+(1-f)*i,f=p+k,d=n-o,p=p-k,g=g+(1-g)*i,k=l+c,n=n+o,l=l-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,w=this.n13,u=this.n23,v=this.n33,A=this.n43;this.n11=e*i+f*m+d*w;this.n21=e*c+f*r+d*u;this.n31=e*o+f*s+d*v;this.n41=e*q+f*t+d*A;this.n12=p*i+g*m+k*w;this.n22=
+p*c+g*r+k*u;this.n32=p*o+g*s+k*v;this.n42=p*q+g*t+k*A;this.n13=n*i+l*m+h*w;this.n23=n*c+l*r+h*u;this.n33=n*o+l*s+h*v;this.n43=n*q+l*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,k=Math.cos(a),a=Math.sin(a);this.n12=k*b+a*f;this.n22=k*c+a*g;this.n32=k*d+a*h;this.n42=k*e+a*i;this.n13=k*f-a*b;this.n23=k*g-a*c;this.n33=k*h-a*d;this.n43=k*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,k=Math.cos(a),a=Math.sin(a);this.n11=k*b-a*f;this.n21=k*c-a*g;this.n31=k*d-a*h;this.n41=k*e-a*i;this.n13=k*f+a*b;this.n23=k*g+a*c;this.n33=k*h+a*d;this.n43=k*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,k=Math.cos(a),a=Math.sin(a);this.n11=k*b+a*f;this.n21=k*c+a*g;this.n31=k*d+a*h;this.n41=k*e+a*i;this.n12=k*f-a*b;this.n22=k*g-a*c;this.n32=k*h-a*d;this.n42=k*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,k=a.n23*a.n12-a.n22*a.n13,l=-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*k;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*k;c[7]=a*l;c[8]=a*p;return b};
@@ -64,16 +64,16 @@ this)console.warn("THREE: Object3D.add(): An object can't be added as a child of
 getChildByName:function(a,b){var c,d,e;for(c=0,d=this.children.length;c<d;c++){e=this.children[c];if(e.name===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=k[i]=k[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,k=[],l,p,m=[],o,q=[],n,r,s=[],t,w,u=[],v={objects:[],sprites:[],lights:[],elements:[]},y=new THREE.Vector3,D=new THREE.Vector4,C=new THREE.Matrix4,B=new THREE.Matrix4,E=new THREE.Frustum,J=new THREE.Vector4,N=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);C.multiply(b.projectionMatrix,b.matrixWorldInverse);C.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);C.multiply(b.matrixWorld,
-b.projectionMatrixInverse);C.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||E.contains(b))?(C.multiplyVector3(y.copy(b.position)),e=a(),e.object=
-b,e.z=y.z,v.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(C.multiplyVector3(y.copy(b.position)),e=a(),e.object=b,e.z=y.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,j,y,A,F,P,R,ea,ia,ca,V,ba,U,aa,ha,Ta,oa;w=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);C.multiply(e.projectionMatrix,e.matrixWorldInverse);E.setFromMatrix(C);v=this.projectGraph(a,!1);for(a=0,j=v.objects.length;a<j;a++)if(ca=v.objects[a].object,V=ca.matrixWorld,U=ca.material,i=0,ca instanceof THREE.Mesh){ba=ca.geometry;aa=ca.geometry.materials;F=ba.vertices;ha=ba.faces;Ta=ba.faceVertexUvs;ba=ca.matrixRotationWorld.extractRotation(V);for(y=0,A=F.length;y<A;y++)h=b(),h.positionWorld.copy(F[y].position),V.multiplyVector3(h.positionWorld),
-h.positionScreen.copy(h.positionWorld),C.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<H;for(F=0,y=ha.length;F<y;F++){A=ha[F];if(A instanceof THREE.Face3)if(P=k[A.a],R=k[A.b],ea=k[A.c],P.visible&&R.visible&&ea.visible&&(ca.doubleSided||ca.flipSided!=0>(ea.positionScreen.x-P.positionScreen.x)*(R.positionScreen.y-P.positionScreen.y)-(ea.positionScreen.y-P.positionScreen.y)*(R.positionScreen.x-
-P.positionScreen.x)))ia=m[p]=m[p]||new THREE.RenderableFace3,p++,l=ia,l.v1.copy(P),l.v2.copy(R),l.v3.copy(ea);else continue;else if(A instanceof THREE.Face4)if(P=k[A.a],R=k[A.b],ea=k[A.c],ia=k[A.d],P.visible&&R.visible&&ea.visible&&ia.visible&&(ca.doubleSided||ca.flipSided!=(0>(ia.positionScreen.x-P.positionScreen.x)*(R.positionScreen.y-P.positionScreen.y)-(ia.positionScreen.y-P.positionScreen.y)*(R.positionScreen.x-P.positionScreen.x)||0>(R.positionScreen.x-ea.positionScreen.x)*(ia.positionScreen.y-
-ea.positionScreen.y)-(R.positionScreen.y-ea.positionScreen.y)*(ia.positionScreen.x-ea.positionScreen.x))))oa=q[o]=q[o]||new THREE.RenderableFace4,o++,l=oa,l.v1.copy(P),l.v2.copy(R),l.v3.copy(ea),l.v4.copy(ia);else continue;l.normalWorld.copy(A.normal);ba.multiplyVector3(l.normalWorld);l.centroidWorld.copy(A.centroid);V.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);C.multiplyVector3(l.centroidScreen);ea=A.vertexNormals;for(P=0,R=ea.length;P<R;P++)ia=l.vertexNormalsWorld[P],
-ia.copy(ea[P]),ba.multiplyVector3(ia);for(P=0,R=Ta.length;P<R;P++)if(oa=Ta[P][F])for(ea=0,ia=oa.length;ea<ia;ea++)l.uvs[P][ea]=oa[ea];l.material=U;l.faceMaterial=null!==A.materialIndex?aa[A.materialIndex]:null;l.z=l.centroidScreen.z;v.elements.push(l)}}else if(ca instanceof THREE.Line){B.multiply(C,V);F=ca.geometry.vertices;P=b();P.positionScreen.copy(F[0].position);B.multiplyVector4(P.positionScreen);for(y=1,A=F.length;y<A;y++)if(P=b(),P.positionScreen.copy(F[y].position),B.multiplyVector4(P.positionScreen),
-R=k[i-2],J.copy(P.positionScreen),N.copy(R.positionScreen),d(J,N))J.multiplyScalar(1/J.w),N.multiplyScalar(1/N.w),ca=s[r]=s[r]||new THREE.RenderableLine,r++,n=ca,n.v1.positionScreen.copy(J),n.v2.positionScreen.copy(N),n.z=Math.max(J.z,N.z),n.material=U,v.elements.push(n)}for(a=0,j=v.sprites.length;a<j;a++)if(ca=v.sprites[a].object,V=ca.matrixWorld,ca instanceof THREE.Particle&&(D.set(V.n14,V.n24,V.n34,1),C.multiplyVector4(D),D.z/=D.w,0<D.z&&1>D.z))g=u[w]=u[w]||new THREE.RenderableParticle,w++,t=g,
-t.x=D.x/D.w,t.y=D.y/D.w,t.z=D.z,t.rotation=ca.rotation.z,t.scale.x=ca.scale.x*Math.abs(t.x-(D.x+e.projectionMatrix.n11)/(D.w+e.projectionMatrix.n14)),t.scale.y=ca.scale.y*Math.abs(t.y-(D.y+e.projectionMatrix.n22)/(D.w+e.projectionMatrix.n24)),t.material=ca.material,v.elements.push(t);f&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
+var e,f,g=[],h,i,k=[],l,p,n=[],o,q=[],m,r,s=[],t,w,u=[],v={objects:[],sprites:[],lights:[],elements:[]},A=new THREE.Vector3,B=new THREE.Vector4,C=new THREE.Matrix4,D=new THREE.Matrix4,I=new THREE.Frustum,K=new THREE.Vector4,O=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);C.multiply(b.projectionMatrix,b.matrixWorldInverse);C.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);C.multiply(b.matrixWorld,
+b.projectionMatrixInverse);C.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||I.contains(b))?(C.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?(C.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,G=e.far,j,A,z,E,Q,N,ea,ia,$,aa,ba,Y,ca,fa,Ua,Ka;w=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);C.multiply(e.projectionMatrix,e.matrixWorldInverse);I.setFromMatrix(C);v=this.projectGraph(a,!1);for(a=0,j=v.objects.length;a<j;a++)if($=v.objects[a].object,aa=$.matrixWorld,Y=$.material,i=0,$ instanceof THREE.Mesh){ba=$.geometry;ca=$.geometry.materials;E=ba.vertices;fa=ba.faces;Ua=ba.faceVertexUvs;ba=$.matrixRotationWorld.extractRotation(aa);for(A=0,z=E.length;A<z;A++)h=b(),h.positionWorld.copy(E[A].position),aa.multiplyVector3(h.positionWorld),
+h.positionScreen.copy(h.positionWorld),C.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<G;for(E=0,A=fa.length;E<A;E++){z=fa[E];if(z instanceof THREE.Face3)if(Q=k[z.a],N=k[z.b],ea=k[z.c],Q.visible&&N.visible&&ea.visible&&($.doubleSided||$.flipSided!=0>(ea.positionScreen.x-Q.positionScreen.x)*(N.positionScreen.y-Q.positionScreen.y)-(ea.positionScreen.y-Q.positionScreen.y)*(N.positionScreen.x-
+Q.positionScreen.x)))ia=n[p]=n[p]||new THREE.RenderableFace3,p++,l=ia,l.v1.copy(Q),l.v2.copy(N),l.v3.copy(ea);else continue;else if(z instanceof THREE.Face4)if(Q=k[z.a],N=k[z.b],ea=k[z.c],ia=k[z.d],Q.visible&&N.visible&&ea.visible&&ia.visible&&($.doubleSided||$.flipSided!=(0>(ia.positionScreen.x-Q.positionScreen.x)*(N.positionScreen.y-Q.positionScreen.y)-(ia.positionScreen.y-Q.positionScreen.y)*(N.positionScreen.x-Q.positionScreen.x)||0>(N.positionScreen.x-ea.positionScreen.x)*(ia.positionScreen.y-
+ea.positionScreen.y)-(N.positionScreen.y-ea.positionScreen.y)*(ia.positionScreen.x-ea.positionScreen.x))))Ka=q[o]=q[o]||new THREE.RenderableFace4,o++,l=Ka,l.v1.copy(Q),l.v2.copy(N),l.v3.copy(ea),l.v4.copy(ia);else continue;l.normalWorld.copy(z.normal);ba.multiplyVector3(l.normalWorld);l.centroidWorld.copy(z.centroid);aa.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);C.multiplyVector3(l.centroidScreen);ea=z.vertexNormals;for(Q=0,N=ea.length;Q<N;Q++)ia=l.vertexNormalsWorld[Q],
+ia.copy(ea[Q]),ba.multiplyVector3(ia);for(Q=0,N=Ua.length;Q<N;Q++)if(Ka=Ua[Q][E])for(ea=0,ia=Ka.length;ea<ia;ea++)l.uvs[Q][ea]=Ka[ea];l.material=Y;l.faceMaterial=null!==z.materialIndex?ca[z.materialIndex]:null;l.z=l.centroidScreen.z;v.elements.push(l)}}else if($ instanceof THREE.Line){D.multiply(C,aa);E=$.geometry.vertices;Q=b();Q.positionScreen.copy(E[0].position);D.multiplyVector4(Q.positionScreen);for(A=1,z=E.length;A<z;A++)if(Q=b(),Q.positionScreen.copy(E[A].position),D.multiplyVector4(Q.positionScreen),
+N=k[i-2],K.copy(Q.positionScreen),O.copy(N.positionScreen),d(K,O))K.multiplyScalar(1/K.w),O.multiplyScalar(1/O.w),$=s[r]=s[r]||new THREE.RenderableLine,r++,m=$,m.v1.positionScreen.copy(K),m.v2.positionScreen.copy(O),m.z=Math.max(K.z,O.z),m.material=Y,v.elements.push(m)}for(a=0,j=v.sprites.length;a<j;a++)if($=v.sprites[a].object,aa=$.matrixWorld,$ instanceof THREE.Particle&&(B.set(aa.n14,aa.n24,aa.n34,1),C.multiplyVector4(B),B.z/=B.w,0<B.z&&1>B.z))g=u[w]=u[w]||new THREE.RenderableParticle,w++,t=g,
+t.x=B.x/B.w,t.y=B.y/B.w,t.z=B.z,t.rotation=$.rotation.z,t.scale.x=$.scale.x*Math.abs(t.x-(B.x+e.projectionMatrix.n11)/(B.w+e.projectionMatrix.n14)),t.scale.y=$.scale.y*Math.abs(t.y-(B.y+e.projectionMatrix.n22)/(B.w+e.projectionMatrix.n24)),t.material=$.material,v.elements.push(t);f&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},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=
@@ -89,16 +89,17 @@ 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]))},computeMorphNormals:function(){var a,
-b,c,d,e;for(c=0,d=this.faces.length;c<d;c++){e=this.faces[c];e.__originalVertexNormals=[];for(a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]=e.vertexNormals[a].clone()}var f=new THREE.Geometry;f.faces=this.faces;for(a=0,b=this.morphTargets.length;a<b;a++){var g=this.morphNormals[a];f.vertices=this.morphTargets[a].vertices;f.computeFaceNormals();f.computeVertexNormals();var h,i;for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],h=g.faceNormals[c],i=g.vertexNormals[c],h.copy(e.normal),
-e instanceof THREE.Face3?(i.a.copy(e.vertexNormals[0]),i.b.copy(e.vertexNormals[1]),i.c.copy(e.vertexNormals[2])):(i.a.copy(e.vertexNormals[0]),i.b.copy(e.vertexNormals[1]),i.c.copy(e.vertexNormals[2]),i.d.copy(e.vertexNormals[3]))}for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){function a(a,b,c,d,e,f,C){h=a.vertices[b].position;i=a.vertices[c].position;k=a.vertices[d].position;l=g[e];p=g[f];m=g[C];o=i.x-h.x;q=k.x-h.x;n=i.y-
-h.y;r=k.y-h.y;s=i.z-h.z;t=k.z-h.z;w=p.u-l.u;u=m.u-l.u;v=p.v-l.v;y=m.v-l.v;D=1/(w*y-u*v);J.set((y*o-v*q)*D,(y*n-v*r)*D,(y*s-v*t)*D);N.set((w*q-u*o)*D,(w*r-u*n)*D,(w*t-u*s)*D);B[b].addSelf(J);B[c].addSelf(J);B[d].addSelf(J);E[b].addSelf(N);E[c].addSelf(N);E[d].addSelf(N)}var b,c,d,e,f,g,h,i,k,l,p,m,o,q,n,r,s,t,w,u,v,y,D,C,B=[],E=[],J=new THREE.Vector3,N=new THREE.Vector3,S=new THREE.Vector3,K=new THREE.Vector3,O=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)B[b]=new THREE.Vector3,E[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 M=["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++)O.copy(f.vertexNormals[d]),e=f[M[d]],C=B[e],S.copy(C),S.subSelf(O.multiplyScalar(O.dot(C))).normalize(),K.cross(f.vertexNormals[d],C),e=K.dot(E[e]),e=0>e?-1:1,f.vertexTangents[d]=
-new THREE.Vector4(S.x,S.y,S.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);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}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};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,k,l,p,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){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;k=this.points[c[0]];l=this.points[c[1]];
-p=this.points[c[2]];m=this.points[c[3]];h=g*g;i=g*h;d.x=b(k.x,l.x,p.x,m.x,g,h,i);d.y=b(k.y,l.y,p.y,m.y,g,h,i);d.z=b(k.z,l.z,p.z,m.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,m=this.getLength();h.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=m.chunks[b]-m.chunks[b-1];g=Math.ceil(a*c/m.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=
+b,c,d,e;for(c=0,d=this.faces.length;c<d;c++){e=this.faces[c];e.__originalFaceNormal?e.__originalFaceNormal.copy(e.normal):e.__originalFaceNormal=e.normal.clone();if(!e.__originalVertexNormals)e.__originalVertexNormals=[];for(a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]?e.__originalVertexNormals[a].copy(e.vertexNormals[a]):e.__originalVertexNormals[a]=e.vertexNormals[a].clone()}var f=new THREE.Geometry;f.faces=this.faces;for(a=0,b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]=
+{};this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=[];var g=this.morphNormals[a].faceNormals,h=this.morphNormals[a].vertexNormals,i,k;for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],i=new THREE.Vector3,k=e instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,d:new THREE.Vector3},g.push(i),h.push(k)}g=this.morphNormals[a];f.vertices=this.morphTargets[a].vertices;f.computeFaceNormals();
+f.computeVertexNormals();for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],i=g.faceNormals[c],k=g.vertexNormals[c],i.copy(e.normal),e instanceof THREE.Face3?(k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2])):(k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2]),k.d.copy(e.vertexNormals[3]))}for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],e.normal=e.__originalFaceNormal,e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){function a(a,
+b,c,d,e,f,C){h=a.vertices[b].position;i=a.vertices[c].position;k=a.vertices[d].position;l=g[e];p=g[f];n=g[C];o=i.x-h.x;q=k.x-h.x;m=i.y-h.y;r=k.y-h.y;s=i.z-h.z;t=k.z-h.z;w=p.u-l.u;u=n.u-l.u;v=p.v-l.v;A=n.v-l.v;B=1/(w*A-u*v);K.set((A*o-v*q)*B,(A*m-v*r)*B,(A*s-v*t)*B);O.set((w*q-u*o)*B,(w*r-u*m)*B,(w*t-u*s)*B);D[b].addSelf(K);D[c].addSelf(K);D[d].addSelf(K);I[b].addSelf(O);I[c].addSelf(O);I[d].addSelf(O)}var b,c,d,e,f,g,h,i,k,l,p,n,o,q,m,r,s,t,w,u,v,A,B,C,D=[],I=[],K=new THREE.Vector3,O=new THREE.Vector3,
+S=new THREE.Vector3,L=new THREE.Vector3,P=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)D[b]=new THREE.Vector3,I[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 H=["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[H[d]],
+C=D[e],S.copy(C),S.subSelf(P.multiplyScalar(P.dot(C))).normalize(),L.cross(f.vertexNormals[d],C),e=L.dot(I[e]),e=0>e?-1:1,f.vertexTangents[d]=new THREE.Vector4(S.x,S.y,S.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);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}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};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,k,l,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;k=this.points[c[0]];l=this.points[c[1]];
+p=this.points[c[2]];n=this.points[c[3]];h=g*g;i=g*h;d.x=b(k.x,l.x,p.x,n.x,g,h,i);d.y=b(k.y,l.y,p.y,n.y,g,h,i);d.z=b(k.z,l.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),
+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,n=this.getLength();h.push(i.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=n.chunks[b]-n.chunks[b-1];g=Math.ceil(a*c/n.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;
 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;
@@ -159,47 +160,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,k,l,p,m,o,q,n;a=b.projectScene(c,d);for(i=0,k=a.length;i<k;i++)if(m=a[i],m instanceof THREE.RenderableParticle){q=m.x*e+e;n=m.y*f+f;for(l=0,p=m.material.length;l<p;l++)if(o=m.material[l],o instanceof THREE.ParticleDOMMaterial)o=o.domElement,o.style.left=q+"px",o.style.top=n+"px"}}};
-THREE.CanvasRenderer=function(a){function b(a){if(t!=a)n.globalAlpha=t=a}function c(a){if(w!=a){switch(a){case THREE.NormalBlending:n.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:n.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:n.globalCompositeOperation="darker"}w=a}}function d(a){if(u!=a)n.strokeStyle=u=a}function e(a){if(v!=a)n.fillStyle=v=a}var a=a||{},f=this,g,h,i,k=new THREE.Projector,l=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
-p,m,o,q,n=l.getContext("2d"),r=new THREE.Color(0),s=0,t=1,w=0,u=null,v=null,y=null,D=null,C=null,B,E,J,N,S=new THREE.RenderableVertex,K=new THREE.RenderableVertex,O,M,H,j,Z,A,F,P,R,ea,ia,ca,V=new THREE.Color,ba=new THREE.Color,U=new THREE.Color,aa=new THREE.Color,ha=new THREE.Color,Ta=[],oa=[],Ka,Ea,Ba,ka,db,lb,eb,Za,$a,Sa,Fa=new THREE.Rectangle,ya=new THREE.Rectangle,za=new THREE.Rectangle,Qa=!1,Ha=new THREE.Color,Wa=new THREE.Color,mb=new THREE.Color,$=new THREE.Vector3,Q,Fb,Tc,fb,pc,Cc,a=16;Q=
-document.createElement("canvas");Q.width=Q.height=2;Fb=Q.getContext("2d");Fb.fillStyle="rgba(0,0,0,1)";Fb.fillRect(0,0,2,2);Tc=Fb.getImageData(0,0,2,2);fb=Tc.data;pc=document.createElement("canvas");pc.width=pc.height=a;Cc=pc.getContext("2d");Cc.translate(-a/2,-a/2);Cc.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){p=a;m=b;o=Math.floor(p/2);q=Math.floor(m/2);l.width=p;l.height=m;Fa.set(-o,-q,
-o,q);ya.set(-o,-q,o,q);t=1;w=0;C=D=y=v=u=null};this.setClearColor=function(a,b){r.copy(a);s=b;ya.set(-o,-q,o,q)};this.setClearColorHex=function(a,b){r.setHex(a);s=b;ya.set(-o,-q,o,q)};this.clear=function(){n.setTransform(1,0,0,-1,o,q);ya.isEmpty()||(ya.minSelf(Fa),ya.inflate(2),1>s&&n.clearRect(Math.floor(ya.getX()),Math.floor(ya.getY()),Math.floor(ya.getWidth()),Math.floor(ya.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+")"),n.fillRect(Math.floor(ya.getX()),Math.floor(ya.getY()),Math.floor(ya.getWidth()),Math.floor(ya.getHeight()))),ya.empty())};this.render=function(a,m){function l(a){var b,c,d,e;Ha.setRGB(0,0,0);Wa.setRGB(0,0,0);mb.setRGB(0,0,0);for(b=0,c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(Ha.r+=e.r,Ha.g+=e.g,Ha.b+=e.b):d instanceof THREE.DirectionalLight?(Wa.r+=e.r,Wa.g+=e.g,Wa.b+=e.b):d instanceof THREE.PointLight&&(mb.r+=e.r,mb.g+=e.g,mb.b+=e.b)}function p(a,b,c,d){var e,
-f,g,j,h,i;for(e=0,f=a.length;e<f;e++)g=a[e],j=g.color,g instanceof THREE.DirectionalLight?(h=g.matrixWorld.getPosition(),i=c.dot(h),0>=i||(i*=g.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)):g instanceof THREE.PointLight&&(h=g.matrixWorld.getPosition(),i=c.dot($.sub(h,b).normalize()),0>=i||(i*=0==g.distance?1:1-Math.min(b.distanceTo(h)/g.distance,1),0!=i&&(i*=g.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)))}function r(a,f,g){b(g.opacity);c(g.blending);var $,j,h,i,m,k;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)i=
-g.map.image,m=i.width>>1,k=i.height>>1,g=f.scale.x*o,h=f.scale.y*q,$=g*m,j=h*k,za.set(a.x-$,a.y-j,a.x+$,a.y+j),Fa.intersects(za)&&(n.save(),n.translate(a.x,a.y),n.rotate(-f.rotation),n.scale(g,-h),n.translate(-m,-k),n.drawImage(i,0,0),n.restore())}else g instanceof THREE.ParticleCanvasMaterial&&($=f.scale.x*o,j=f.scale.y*q,za.set(a.x-$,a.y-j,a.x+$,a.y+j),Fa.intersects(za)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),n.save(),n.translate(a.x,a.y),n.rotate(-f.rotation),n.scale($,j),g.program(n),
-n.restore()))}function s(a,e,f,g){b(g.opacity);c(g.blending);n.beginPath();n.moveTo(a.positionScreen.x,a.positionScreen.y);n.lineTo(e.positionScreen.x,e.positionScreen.y);n.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(y!=a)n.lineWidth=y=a;a=g.linecap;if(D!=a)n.lineCap=D=a;a=g.linejoin;if(C!=a)n.lineJoin=C=a;d(g.color.getContextStyle());n.stroke();za.inflate(2*g.linewidth)}}function t(a,d,e,g,h,n,k,Q){f.info.render.vertices+=3;f.info.render.faces++;b(Q.opacity);c(Q.blending);
-O=a.positionScreen.x;M=a.positionScreen.y;H=d.positionScreen.x;j=d.positionScreen.y;Z=e.positionScreen.x;A=e.positionScreen.y;w(O,M,H,j,Z,A);if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.mapping instanceof THREE.UVMapping&&(ka=k.uvs[0],Uc(O,M,H,j,Z,A,ka[g].u,ka[g].v,ka[h].u,ka[h].v,ka[n].u,ka[n].v,Q.map));else if(Q.envMap){if(Q.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=m.matrixWorldInverse,$.copy(k.vertexNormalsWorld[g]),db=0.5*($.x*a.n11+$.y*a.n12+$.z*a.n13)+0.5,lb=0.5*
--($.x*a.n21+$.y*a.n22+$.z*a.n23)+0.5,$.copy(k.vertexNormalsWorld[h]),eb=0.5*($.x*a.n11+$.y*a.n12+$.z*a.n13)+0.5,Za=0.5*-($.x*a.n21+$.y*a.n22+$.z*a.n23)+0.5,$.copy(k.vertexNormalsWorld[n]),$a=0.5*($.x*a.n11+$.y*a.n12+$.z*a.n13)+0.5,Sa=0.5*-($.x*a.n21+$.y*a.n22+$.z*a.n23)+0.5,Uc(O,M,H,j,Z,A,db,lb,eb,Za,$a,Sa,Q.envMap)}else Q.wireframe?Mb(Q.color,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):Gb(Q.color);else if(Q instanceof THREE.MeshLambertMaterial)Q.map&&!Q.wireframe&&(Q.map.mapping instanceof
-THREE.UVMapping&&(ka=k.uvs[0],Uc(O,M,H,j,Z,A,ka[g].u,ka[g].v,ka[h].u,ka[h].v,ka[n].u,ka[n].v,Q.map)),c(THREE.SubtractiveBlending)),Qa?!Q.wireframe&&Q.shading==THREE.SmoothShading&&3==k.vertexNormalsWorld.length?(ba.r=U.r=aa.r=Ha.r,ba.g=U.g=aa.g=Ha.g,ba.b=U.b=aa.b=Ha.b,p(i,k.v1.positionWorld,k.vertexNormalsWorld[0],ba),p(i,k.v2.positionWorld,k.vertexNormalsWorld[1],U),p(i,k.v3.positionWorld,k.vertexNormalsWorld[2],aa),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)),U.r=Math.max(0,Math.min(Q.color.r*U.r,1)),U.g=Math.max(0,Math.min(Q.color.g*U.g,1)),U.b=Math.max(0,Math.min(Q.color.b*U.b,1)),aa.r=Math.max(0,Math.min(Q.color.r*aa.r,1)),aa.g=Math.max(0,Math.min(Q.color.g*aa.g,1)),aa.b=Math.max(0,Math.min(Q.color.b*aa.b,1)),ha.r=0.5*(U.r+aa.r),ha.g=0.5*(U.g+aa.g),ha.b=0.5*(U.b+aa.b),Ba=Dc(ba,U,aa,ha),gc(O,M,H,j,Z,A,0,0,1,0,0,1,Ba)):(V.r=Ha.r,V.g=Ha.g,V.b=Ha.b,p(i,k.centroidWorld,k.normalWorld,V),V.r=Math.max(0,Math.min(Q.color.r*
-V.r,1)),V.g=Math.max(0,Math.min(Q.color.g*V.g,1)),V.b=Math.max(0,Math.min(Q.color.b*V.b,1)),Q.wireframe?Mb(V,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):Gb(V)):Q.wireframe?Mb(Q.color,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):Gb(Q.color);else if(Q instanceof THREE.MeshDepthMaterial)Ka=m.near,Ea=m.far,ba.r=ba.g=ba.b=1-ac(a.positionScreen.z,Ka,Ea),U.r=U.g=U.b=1-ac(d.positionScreen.z,Ka,Ea),aa.r=aa.g=aa.b=1-ac(e.positionScreen.z,Ka,Ea),ha.r=0.5*(U.r+aa.r),ha.g=0.5*
-(U.g+aa.g),ha.b=0.5*(U.b+aa.b),Ba=Dc(ba,U,aa,ha),gc(O,M,H,j,Z,A,0,0,1,0,0,1,Ba);else if(Q instanceof THREE.MeshNormalMaterial)V.r=hc(k.normalWorld.x),V.g=hc(k.normalWorld.y),V.b=hc(k.normalWorld.z),Q.wireframe?Mb(V,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):Gb(V)}function u(a,d,e,g,$,h,Q,k,n){f.info.render.vertices+=4;f.info.render.faces++;b(k.opacity);c(k.blending);if(k.map||k.envMap)t(a,d,g,0,1,3,Q,k,n),t($,e,h,1,2,3,Q,k,n);else if(O=a.positionScreen.x,M=a.positionScreen.y,H=d.positionScreen.x,
-j=d.positionScreen.y,Z=e.positionScreen.x,A=e.positionScreen.y,F=g.positionScreen.x,P=g.positionScreen.y,R=$.positionScreen.x,ea=$.positionScreen.y,ia=h.positionScreen.x,ca=h.positionScreen.y,k instanceof THREE.MeshBasicMaterial)v(O,M,H,j,Z,A,F,P),k.wireframe?Mb(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):Gb(k.color);else if(k instanceof THREE.MeshLambertMaterial)Qa?!k.wireframe&&k.shading==THREE.SmoothShading&&4==Q.vertexNormalsWorld.length?(ba.r=U.r=aa.r=ha.r=Ha.r,ba.g=
-U.g=aa.g=ha.g=Ha.g,ba.b=U.b=aa.b=ha.b=Ha.b,p(i,Q.v1.positionWorld,Q.vertexNormalsWorld[0],ba),p(i,Q.v2.positionWorld,Q.vertexNormalsWorld[1],U),p(i,Q.v4.positionWorld,Q.vertexNormalsWorld[3],aa),p(i,Q.v3.positionWorld,Q.vertexNormalsWorld[2],ha),ba.r=Math.max(0,Math.min(k.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(k.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(k.color.b*ba.b,1)),U.r=Math.max(0,Math.min(k.color.r*U.r,1)),U.g=Math.max(0,Math.min(k.color.g*U.g,1)),U.b=Math.max(0,Math.min(k.color.b*U.b,1)),
-aa.r=Math.max(0,Math.min(k.color.r*aa.r,1)),aa.g=Math.max(0,Math.min(k.color.g*aa.g,1)),aa.b=Math.max(0,Math.min(k.color.b*aa.b,1)),ha.r=Math.max(0,Math.min(k.color.r*ha.r,1)),ha.g=Math.max(0,Math.min(k.color.g*ha.g,1)),ha.b=Math.max(0,Math.min(k.color.b*ha.b,1)),Ba=Dc(ba,U,aa,ha),w(O,M,H,j,F,P),gc(O,M,H,j,F,P,0,0,1,0,0,1,Ba),w(R,ea,Z,A,ia,ca),gc(R,ea,Z,A,ia,ca,1,0,1,1,0,1,Ba)):(V.r=Ha.r,V.g=Ha.g,V.b=Ha.b,p(i,Q.centroidWorld,Q.normalWorld,V),V.r=Math.max(0,Math.min(k.color.r*V.r,1)),V.g=Math.max(0,
-Math.min(k.color.g*V.g,1)),V.b=Math.max(0,Math.min(k.color.b*V.b,1)),v(O,M,H,j,Z,A,F,P),k.wireframe?Mb(V,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):Gb(V)):(v(O,M,H,j,Z,A,F,P),k.wireframe?Mb(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):Gb(k.color));else if(k instanceof THREE.MeshNormalMaterial)V.r=hc(Q.normalWorld.x),V.g=hc(Q.normalWorld.y),V.b=hc(Q.normalWorld.z),v(O,M,H,j,Z,A,F,P),k.wireframe?Mb(V,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):
-Gb(V);else if(k instanceof THREE.MeshDepthMaterial)Ka=m.near,Ea=m.far,ba.r=ba.g=ba.b=1-ac(a.positionScreen.z,Ka,Ea),U.r=U.g=U.b=1-ac(d.positionScreen.z,Ka,Ea),aa.r=aa.g=aa.b=1-ac(g.positionScreen.z,Ka,Ea),ha.r=ha.g=ha.b=1-ac(e.positionScreen.z,Ka,Ea),Ba=Dc(ba,U,aa,ha),w(O,M,H,j,F,P),gc(O,M,H,j,F,P,0,0,1,0,0,1,Ba),w(R,ea,Z,A,ia,ca),gc(R,ea,Z,A,ia,ca,1,0,1,1,0,1,Ba)}function w(a,b,c,d,e,g){n.beginPath();n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,g);n.lineTo(a,b);n.closePath()}function v(a,b,c,d,e,g,f,$){n.beginPath();
-n.moveTo(a,b);n.lineTo(c,d);n.lineTo(e,g);n.lineTo(f,$);n.lineTo(a,b);n.closePath()}function Mb(a,b,c,e){if(y!=b)n.lineWidth=y=b;if(D!=c)n.lineCap=D=c;if(C!=e)n.lineJoin=C=e;d(a.getContextStyle());n.stroke();za.inflate(2*b)}function Gb(a){e(a.getContextStyle());n.fill()}function Uc(a,b,c,d,g,f,$,j,h,i,k,Q,m){if(0!=m.image.width){if(!0==m.needsUpdate||void 0==Ta[m.id]){var l=m.wrapS==THREE.RepeatWrapping,o=m.wrapT==THREE.RepeatWrapping;Ta[m.id]=n.createPattern(m.image,l&&o?"repeat":l&&!o?"repeat-x":
-!l&&o?"repeat-y":"no-repeat");m.needsUpdate=!1}e(Ta[m.id]);var l=m.offset.x/m.repeat.x,o=m.offset.y/m.repeat.y,Fb=m.image.width*m.repeat.x,p=m.image.height*m.repeat.y,$=($+l)*Fb,j=(j+o)*p,c=c-a,d=d-b,g=g-a,f=f-b,h=(h+l)*Fb-$,i=(i+o)*p-j,k=(k+l)*Fb-$,Q=(Q+o)*p-j,l=h*Q-k*i;if(0==l){if(void 0===oa[m.id])b=document.createElement("canvas"),b.width=m.image.width,b.height=m.image.height,b=b.getContext("2d"),b.drawImage(m.image,0,0),oa[m.id]=b.getImageData(0,0,m.image.width,m.image.height).data;b=oa[m.id];
-$=4*(Math.floor($)+Math.floor(j)*m.image.width);V.setRGB(b[$]/255,b[$+1]/255,b[$+2]/255);Gb(V)}else l=1/l,m=(Q*c-i*g)*l,i=(Q*d-i*f)*l,c=(h*g-k*c)*l,d=(h*f-k*d)*l,a=a-m*$-c*j,$=b-i*$-d*j,n.save(),n.transform(m,i,c,d,a,$),n.fill(),n.restore()}}function gc(a,b,c,d,e,g,f,$,j,h,i,k,Q){var m,l;m=Q.width-1;l=Q.height-1;f*=m;$*=l;c-=a;d-=b;e-=a;g-=b;j=j*m-f;h=h*l-$;i=i*m-f;k=k*l-$;l=1/(j*k-i*h);m=(k*c-h*e)*l;h=(k*d-h*g)*l;c=(j*e-i*c)*l;d=(j*g-i*d)*l;a=a-m*f-c*$;b=b-h*f-d*$;n.save();n.transform(m,h,c,d,a,
-b);n.clip();n.drawImage(Q,0,0);n.restore()}function Dc(a,b,c,d){var e=~~(255*a.r),g=~~(255*a.g),a=~~(255*a.b),f=~~(255*b.r),$=~~(255*b.g),b=~~(255*b.b),j=~~(255*c.r),h=~~(255*c.g),c=~~(255*c.b),i=~~(255*d.r),k=~~(255*d.g),d=~~(255*d.b);fb[0]=0>e?0:255<e?255:e;fb[1]=0>g?0:255<g?255:g;fb[2]=0>a?0:255<a?255:a;fb[4]=0>f?0:255<f?255:f;fb[5]=0>$?0:255<$?255:$;fb[6]=0>b?0:255<b?255:b;fb[8]=0>j?0:255<j?255:j;fb[9]=0>h?0:255<h?255:h;fb[10]=0>c?0:255<c?255:c;fb[12]=0>i?0:255<i?255:i;fb[13]=0>k?0:255<k?255:
-k;fb[14]=0>d?0:255<d?255:d;Fb.putImageData(Tc,0,0);Cc.drawImage(Q,0,0);return pc}function ac(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function hc(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function Nb(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 Ec,ed,Oa,jb;this.autoClear?this.clear():n.setTransform(1,0,0,-1,o,q);f.info.render.vertices=0;f.info.render.faces=0;g=k.projectScene(a,m,this.sortElements);h=g.elements;i=g.lights;(Qa=0<i.length)&&l(i);
-for(Ec=0,ed=h.length;Ec<ed;Ec++)if(Oa=h[Ec],jb=Oa.material,jb=jb instanceof THREE.MeshFaceMaterial?Oa.faceMaterial:jb,!(null==jb||0==jb.opacity)){za.empty();if(Oa instanceof THREE.RenderableParticle)B=Oa,B.x*=o,B.y*=q,r(B,Oa,jb,a);else if(Oa instanceof THREE.RenderableLine)B=Oa.v1,E=Oa.v2,B.positionScreen.x*=o,B.positionScreen.y*=q,E.positionScreen.x*=o,E.positionScreen.y*=q,za.addPoint(B.positionScreen.x,B.positionScreen.y),za.addPoint(E.positionScreen.x,E.positionScreen.y),Fa.intersects(za)&&s(B,
-E,Oa,jb,a);else if(Oa instanceof THREE.RenderableFace3)B=Oa.v1,E=Oa.v2,J=Oa.v3,B.positionScreen.x*=o,B.positionScreen.y*=q,E.positionScreen.x*=o,E.positionScreen.y*=q,J.positionScreen.x*=o,J.positionScreen.y*=q,jb.overdraw&&(Nb(B.positionScreen,E.positionScreen),Nb(E.positionScreen,J.positionScreen),Nb(J.positionScreen,B.positionScreen)),za.add3Points(B.positionScreen.x,B.positionScreen.y,E.positionScreen.x,E.positionScreen.y,J.positionScreen.x,J.positionScreen.y),Fa.intersects(za)&&t(B,E,J,0,1,2,
-Oa,jb,a);else if(Oa instanceof THREE.RenderableFace4)B=Oa.v1,E=Oa.v2,J=Oa.v3,N=Oa.v4,B.positionScreen.x*=o,B.positionScreen.y*=q,E.positionScreen.x*=o,E.positionScreen.y*=q,J.positionScreen.x*=o,J.positionScreen.y*=q,N.positionScreen.x*=o,N.positionScreen.y*=q,S.positionScreen.copy(E.positionScreen),K.positionScreen.copy(N.positionScreen),jb.overdraw&&(Nb(B.positionScreen,E.positionScreen),Nb(E.positionScreen,N.positionScreen),Nb(N.positionScreen,B.positionScreen),Nb(J.positionScreen,S.positionScreen),
-Nb(J.positionScreen,K.positionScreen)),za.addPoint(B.positionScreen.x,B.positionScreen.y),za.addPoint(E.positionScreen.x,E.positionScreen.y),za.addPoint(J.positionScreen.x,J.positionScreen.y),za.addPoint(N.positionScreen.x,N.positionScreen.y),Fa.intersects(za)&&u(B,E,J,N,S,K,Oa,jb,a);ya.addRectangle(za)}n.setTransform(1,0,0,1,0,0)}};
-THREE.SVGRenderer=function(){function a(a,b,c,d){var e,g,f,h,i,k;for(e=0,g=a.length;e<g;e++)f=a[e],h=f.color,f instanceof THREE.DirectionalLight?(i=f.matrixWorld.getPosition(),k=c.dot(i),0>=k||(k*=f.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)):f instanceof THREE.PointLight&&(i=f.matrixWorld.getPosition(),k=c.dot(B.sub(i,b).normalize()),0>=k||(k*=0==f.distance?1:1-Math.min(b.distanceTo(i)/f.distance,1),0!=k&&(k*=f.intensity,d.r+=h.r*k,d.g+=h.g*k,d.b+=h.b*k)))}function b(a){null==E[a]&&(E[a]=document.createElementNS("http://www.w3.org/2000/svg",
-"path"),0==O&&E[a].setAttribute("shape-rendering","crispEdges"));return E[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"),k,l,p,m,o,q,n,r,s=new THREE.Rectangle,t=new THREE.Rectangle,w=!1,u=new THREE.Color,v=new THREE.Color,y=new THREE.Color,D=new THREE.Color,C,B=new THREE.Vector3,E=[],J=[],N,S,K,O=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":O=1;break;case "low":O=0}};this.setSize=function(a,b){k=a;l=b;p=k/2;m=l/2;i.setAttribute("viewBox",-p+" "+-m+" "+k+" "+l);i.setAttribute("width",k);i.setAttribute("height",l);s.set(-p,-m,p,m)};this.clear=function(){for(;0<i.childNodes.length;)i.removeChild(i.childNodes[0])};this.render=function(k,l){var j,B,A,F;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(k,l,this.sortElements);f=e.elements;
-g=e.lights;K=S=0;if(w=0<g.length){v.setRGB(0,0,0);y.setRGB(0,0,0);D.setRGB(0,0,0);for(j=0,B=g.length;j<B;j++)F=g[j],A=F.color,F instanceof THREE.AmbientLight?(v.r+=A.r,v.g+=A.g,v.b+=A.b):F instanceof THREE.DirectionalLight?(y.r+=A.r,y.g+=A.g,y.b+=A.b):F instanceof THREE.PointLight&&(D.r+=A.r,D.g+=A.g,D.b+=A.b)}for(j=0,B=f.length;j<B;j++)if(A=f[j],F=A.material,F=F instanceof THREE.MeshFaceMaterial?A.faceMaterial:F,!(null==F||0==F.opacity))if(t.empty(),A instanceof THREE.RenderableParticle)o=A,o.x*=
-p,o.y*=-m;else if(A instanceof THREE.RenderableLine){if(o=A.v1,q=A.v2,o.positionScreen.x*=p,o.positionScreen.y*=-m,q.positionScreen.x*=p,q.positionScreen.y*=-m,t.addPoint(o.positionScreen.x,o.positionScreen.y),t.addPoint(q.positionScreen.x,q.positionScreen.y),s.intersects(t)){A=o;var P=q,R=K++;null==J[R]&&(J[R]=document.createElementNS("http://www.w3.org/2000/svg","line"),0==O&&J[R].setAttribute("shape-rendering","crispEdges"));N=J[R];N.setAttribute("x1",A.positionScreen.x);N.setAttribute("y1",A.positionScreen.y);
-N.setAttribute("x2",P.positionScreen.x);N.setAttribute("y2",P.positionScreen.y);F instanceof THREE.LineBasicMaterial&&(N.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(N))}}else if(A instanceof THREE.RenderableFace3){if(o=A.v1,q=A.v2,n=A.v3,o.positionScreen.x*=p,o.positionScreen.y*=-m,q.positionScreen.x*=p,q.positionScreen.y*=-m,n.positionScreen.x*=
-p,n.positionScreen.y*=-m,t.addPoint(o.positionScreen.x,o.positionScreen.y),t.addPoint(q.positionScreen.x,q.positionScreen.y),t.addPoint(n.positionScreen.x,n.positionScreen.y),s.intersects(t)){var P=o,R=q,E=n;d.info.render.vertices+=3;d.info.render.faces++;N=b(S++);N.setAttribute("d","M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+"z");F instanceof THREE.MeshBasicMaterial?u.copy(F.color):F instanceof THREE.MeshLambertMaterial?
-w?(u.r=v.r,u.g=v.g,u.b=v.b,a(g,A.centroidWorld,A.normalWorld,u),u.r=Math.max(0,Math.min(F.color.r*u.r,1)),u.g=Math.max(0,Math.min(F.color.g*u.g,1)),u.b=Math.max(0,Math.min(F.color.b*u.b,1))):u.copy(F.color):F instanceof THREE.MeshDepthMaterial?(C=1-F.__2near/(F.__farPlusNear-A.z*F.__farMinusNear),u.setRGB(C,C,C)):F instanceof THREE.MeshNormalMaterial&&u.setRGB(c(A.normalWorld.x),c(A.normalWorld.y),c(A.normalWorld.z));F.wireframe?N.setAttribute("style","fill: none; stroke: "+u.getContextStyle()+"; stroke-width: "+
-F.wireframeLinewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframeLinecap+"; stroke-linejoin: "+F.wireframeLinejoin):N.setAttribute("style","fill: "+u.getContextStyle()+"; fill-opacity: "+F.opacity);i.appendChild(N)}}else if(A instanceof THREE.RenderableFace4&&(o=A.v1,q=A.v2,n=A.v3,r=A.v4,o.positionScreen.x*=p,o.positionScreen.y*=-m,q.positionScreen.x*=p,q.positionScreen.y*=-m,n.positionScreen.x*=p,n.positionScreen.y*=-m,r.positionScreen.x*=p,r.positionScreen.y*=-m,t.addPoint(o.positionScreen.x,
-o.positionScreen.y),t.addPoint(q.positionScreen.x,q.positionScreen.y),t.addPoint(n.positionScreen.x,n.positionScreen.y),t.addPoint(r.positionScreen.x,r.positionScreen.y),s.intersects(t))){var P=o,R=q,E=n,ia=r;d.info.render.vertices+=4;d.info.render.faces++;N=b(S++);N.setAttribute("d","M "+P.positionScreen.x+" "+P.positionScreen.y+" L "+R.positionScreen.x+" "+R.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+" L "+ia.positionScreen.x+","+ia.positionScreen.y+"z");F instanceof THREE.MeshBasicMaterial?
-u.copy(F.color):F instanceof THREE.MeshLambertMaterial?w?(u.r=v.r,u.g=v.g,u.b=v.b,a(g,A.centroidWorld,A.normalWorld,u),u.r=Math.max(0,Math.min(F.color.r*u.r,1)),u.g=Math.max(0,Math.min(F.color.g*u.g,1)),u.b=Math.max(0,Math.min(F.color.b*u.b,1))):u.copy(F.color):F instanceof THREE.MeshDepthMaterial?(C=1-F.__2near/(F.__farPlusNear-A.z*F.__farMinusNear),u.setRGB(C,C,C)):F instanceof THREE.MeshNormalMaterial&&u.setRGB(c(A.normalWorld.x),c(A.normalWorld.y),c(A.normalWorld.z));F.wireframe?N.setAttribute("style",
-"fill: none; stroke: "+u.getContextStyle()+"; stroke-width: "+F.wireframeLinewidth+"; stroke-opacity: "+F.opacity+"; stroke-linecap: "+F.wireframeLinecap+"; stroke-linejoin: "+F.wireframeLinejoin):N.setAttribute("style","fill: "+u.getContextStyle()+"; fill-opacity: "+F.opacity);i.appendChild(N)}}};
+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,k,l,p,n,o,q,m;a=b.projectScene(c,d);for(i=0,k=a.length;i<k;i++)if(n=a[i],n instanceof THREE.RenderableParticle){q=n.x*e+e;m=n.y*f+f;for(l=0,p=n.material.length;l<p;l++)if(o=n.material[l],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(w!=a){switch(a){case THREE.NormalBlending:m.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:m.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:m.globalCompositeOperation="darker"}w=a}}function d(a){if(u!=a)m.strokeStyle=u=a}function e(a){if(v!=a)m.fillStyle=v=a}var a=a||{},f=this,g,h,i,k=new THREE.Projector,l=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
+p,n,o,q,m=l.getContext("2d"),r=new THREE.Color(0),s=0,t=1,w=0,u=null,v=null,A=null,B=null,C=null,D,I,K,O,S=new THREE.RenderableVertex,L=new THREE.RenderableVertex,P,H,G,j,X,z,E,Q,N,ea,ia,$,aa=new THREE.Color,ba=new THREE.Color,Y=new THREE.Color,ca=new THREE.Color,fa=new THREE.Color,Ua=[],Ka=[],na,Ha,ra,qa,ib,Va,lb,db,Wa,$a,La=new THREE.Rectangle,ta=new THREE.Rectangle,Aa=new THREE.Rectangle,Fa=!1,Ga=new THREE.Color,Xa=new THREE.Color,mb=new THREE.Color,Z=new THREE.Vector3,R,Fb,Uc,eb,pc,Cc,a=16;R=
+document.createElement("canvas");R.width=R.height=2;Fb=R.getContext("2d");Fb.fillStyle="rgba(0,0,0,1)";Fb.fillRect(0,0,2,2);Uc=Fb.getImageData(0,0,2,2);eb=Uc.data;pc=document.createElement("canvas");pc.width=pc.height=a;Cc=pc.getContext("2d");Cc.translate(-a/2,-a/2);Cc.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){p=a;n=b;o=Math.floor(p/2);q=Math.floor(n/2);l.width=p;l.height=n;La.set(-o,-q,
+o,q);ta.set(-o,-q,o,q);t=1;w=0;C=B=A=v=u=null};this.setClearColor=function(a,b){r.copy(a);s=b;ta.set(-o,-q,o,q)};this.setClearColorHex=function(a,b){r.setHex(a);s=b;ta.set(-o,-q,o,q)};this.clear=function(){m.setTransform(1,0,0,-1,o,q);ta.isEmpty()||(ta.minSelf(La),ta.inflate(2),1>s&&m.clearRect(Math.floor(ta.getX()),Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.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(ta.getX()),Math.floor(ta.getY()),Math.floor(ta.getWidth()),Math.floor(ta.getHeight()))),ta.empty())};this.render=function(a,n){function l(a){var b,c,d,e;Ga.setRGB(0,0,0);Xa.setRGB(0,0,0);mb.setRGB(0,0,0);for(b=0,c=a.length;b<c;b++)d=a[b],e=d.color,d instanceof THREE.AmbientLight?(Ga.r+=e.r,Ga.g+=e.g,Ga.b+=e.b):d instanceof THREE.DirectionalLight?(Xa.r+=e.r,Xa.g+=e.g,Xa.b+=e.b):d instanceof THREE.PointLight&&(mb.r+=e.r,mb.g+=e.g,mb.b+=e.b)}function p(a,b,c,d){var e,
+f,g,j,h,i;for(e=0,f=a.length;e<f;e++)g=a[e],j=g.color,g instanceof THREE.DirectionalLight?(h=g.matrixWorld.getPosition(),i=c.dot(h),0>=i||(i*=g.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)):g instanceof THREE.PointLight&&(h=g.matrixWorld.getPosition(),i=c.dot(Z.sub(h,b).normalize()),0>=i||(i*=0==g.distance?1:1-Math.min(b.distanceTo(h)/g.distance,1),0!=i&&(i*=g.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)))}function r(a,f,g){b(g.opacity);c(g.blending);var Z,j,h,i,n,k;if(g instanceof THREE.ParticleBasicMaterial){if(g.map)i=
+g.map.image,n=i.width>>1,k=i.height>>1,g=f.scale.x*o,h=f.scale.y*q,Z=g*n,j=h*k,Aa.set(a.x-Z,a.y-j,a.x+Z,a.y+j),La.intersects(Aa)&&(m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(g,-h),m.translate(-n,-k),m.drawImage(i,0,0),m.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(Z=f.scale.x*o,j=f.scale.y*q,Aa.set(a.x-Z,a.y-j,a.x+Z,a.y+j),La.intersects(Aa)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),m.save(),m.translate(a.x,a.y),m.rotate(-f.rotation),m.scale(Z,j),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(B!=a)m.lineCap=B=a;a=g.linejoin;if(C!=a)m.lineJoin=C=a;d(g.color.getContextStyle());m.stroke();Aa.inflate(2*g.linewidth)}}function t(a,d,e,g,h,k,m,R){f.info.render.vertices+=3;f.info.render.faces++;b(R.opacity);c(R.blending);
+P=a.positionScreen.x;H=a.positionScreen.y;G=d.positionScreen.x;j=d.positionScreen.y;X=e.positionScreen.x;z=e.positionScreen.y;w(P,H,G,j,X,z);if(R instanceof THREE.MeshBasicMaterial)if(R.map)R.map.mapping instanceof THREE.UVMapping&&(qa=m.uvs[0],Vc(P,H,G,j,X,z,qa[g].u,qa[g].v,qa[h].u,qa[h].v,qa[k].u,qa[k].v,R.map));else if(R.envMap){if(R.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=n.matrixWorldInverse,Z.copy(m.vertexNormalsWorld[g]),ib=0.5*(Z.x*a.n11+Z.y*a.n12+Z.z*a.n13)+0.5,Va=0.5*
+-(Z.x*a.n21+Z.y*a.n22+Z.z*a.n23)+0.5,Z.copy(m.vertexNormalsWorld[h]),lb=0.5*(Z.x*a.n11+Z.y*a.n12+Z.z*a.n13)+0.5,db=0.5*-(Z.x*a.n21+Z.y*a.n22+Z.z*a.n23)+0.5,Z.copy(m.vertexNormalsWorld[k]),Wa=0.5*(Z.x*a.n11+Z.y*a.n12+Z.z*a.n13)+0.5,$a=0.5*-(Z.x*a.n21+Z.y*a.n22+Z.z*a.n23)+0.5,Vc(P,H,G,j,X,z,ib,Va,lb,db,Wa,$a,R.envMap)}else R.wireframe?Mb(R.color,R.wireframeLinewidth,R.wireframeLinecap,R.wireframeLinejoin):Gb(R.color);else if(R instanceof THREE.MeshLambertMaterial)R.map&&!R.wireframe&&(R.map.mapping instanceof
+THREE.UVMapping&&(qa=m.uvs[0],Vc(P,H,G,j,X,z,qa[g].u,qa[g].v,qa[h].u,qa[h].v,qa[k].u,qa[k].v,R.map)),c(THREE.SubtractiveBlending)),Fa?!R.wireframe&&R.shading==THREE.SmoothShading&&3==m.vertexNormalsWorld.length?(ba.r=Y.r=ca.r=Ga.r,ba.g=Y.g=ca.g=Ga.g,ba.b=Y.b=ca.b=Ga.b,p(i,m.v1.positionWorld,m.vertexNormalsWorld[0],ba),p(i,m.v2.positionWorld,m.vertexNormalsWorld[1],Y),p(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ca),ba.r=Math.max(0,Math.min(R.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(R.color.g*ba.g,
+1)),ba.b=Math.max(0,Math.min(R.color.b*ba.b,1)),Y.r=Math.max(0,Math.min(R.color.r*Y.r,1)),Y.g=Math.max(0,Math.min(R.color.g*Y.g,1)),Y.b=Math.max(0,Math.min(R.color.b*Y.b,1)),ca.r=Math.max(0,Math.min(R.color.r*ca.r,1)),ca.g=Math.max(0,Math.min(R.color.g*ca.g,1)),ca.b=Math.max(0,Math.min(R.color.b*ca.b,1)),fa.r=0.5*(Y.r+ca.r),fa.g=0.5*(Y.g+ca.g),fa.b=0.5*(Y.b+ca.b),ra=Dc(ba,Y,ca,fa),gc(P,H,G,j,X,z,0,0,1,0,0,1,ra)):(aa.r=Ga.r,aa.g=Ga.g,aa.b=Ga.b,p(i,m.centroidWorld,m.normalWorld,aa),aa.r=Math.max(0,
+Math.min(R.color.r*aa.r,1)),aa.g=Math.max(0,Math.min(R.color.g*aa.g,1)),aa.b=Math.max(0,Math.min(R.color.b*aa.b,1)),R.wireframe?Mb(aa,R.wireframeLinewidth,R.wireframeLinecap,R.wireframeLinejoin):Gb(aa)):R.wireframe?Mb(R.color,R.wireframeLinewidth,R.wireframeLinecap,R.wireframeLinejoin):Gb(R.color);else if(R instanceof THREE.MeshDepthMaterial)na=n.near,Ha=n.far,ba.r=ba.g=ba.b=1-ac(a.positionScreen.z,na,Ha),Y.r=Y.g=Y.b=1-ac(d.positionScreen.z,na,Ha),ca.r=ca.g=ca.b=1-ac(e.positionScreen.z,na,Ha),fa.r=
+0.5*(Y.r+ca.r),fa.g=0.5*(Y.g+ca.g),fa.b=0.5*(Y.b+ca.b),ra=Dc(ba,Y,ca,fa),gc(P,H,G,j,X,z,0,0,1,0,0,1,ra);else if(R instanceof THREE.MeshNormalMaterial)aa.r=hc(m.normalWorld.x),aa.g=hc(m.normalWorld.y),aa.b=hc(m.normalWorld.z),R.wireframe?Mb(aa,R.wireframeLinewidth,R.wireframeLinecap,R.wireframeLinejoin):Gb(aa)}function u(a,d,e,g,Z,h,R,m,k){f.info.render.vertices+=4;f.info.render.faces++;b(m.opacity);c(m.blending);if(m.map||m.envMap)t(a,d,g,0,1,3,R,m,k),t(Z,e,h,1,2,3,R,m,k);else if(P=a.positionScreen.x,
+H=a.positionScreen.y,G=d.positionScreen.x,j=d.positionScreen.y,X=e.positionScreen.x,z=e.positionScreen.y,E=g.positionScreen.x,Q=g.positionScreen.y,N=Z.positionScreen.x,ea=Z.positionScreen.y,ia=h.positionScreen.x,$=h.positionScreen.y,m instanceof THREE.MeshBasicMaterial)v(P,H,G,j,X,z,E,Q),m.wireframe?Mb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(m.color);else if(m instanceof THREE.MeshLambertMaterial)Fa?!m.wireframe&&m.shading==THREE.SmoothShading&&4==R.vertexNormalsWorld.length?
+(ba.r=Y.r=ca.r=fa.r=Ga.r,ba.g=Y.g=ca.g=fa.g=Ga.g,ba.b=Y.b=ca.b=fa.b=Ga.b,p(i,R.v1.positionWorld,R.vertexNormalsWorld[0],ba),p(i,R.v2.positionWorld,R.vertexNormalsWorld[1],Y),p(i,R.v4.positionWorld,R.vertexNormalsWorld[3],ca),p(i,R.v3.positionWorld,R.vertexNormalsWorld[2],fa),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)),Y.r=Math.max(0,Math.min(m.color.r*Y.r,1)),Y.g=Math.max(0,Math.min(m.color.g*Y.g,1)),Y.b=Math.max(0,
+Math.min(m.color.b*Y.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)),fa.r=Math.max(0,Math.min(m.color.r*fa.r,1)),fa.g=Math.max(0,Math.min(m.color.g*fa.g,1)),fa.b=Math.max(0,Math.min(m.color.b*fa.b,1)),ra=Dc(ba,Y,ca,fa),w(P,H,G,j,E,Q),gc(P,H,G,j,E,Q,0,0,1,0,0,1,ra),w(N,ea,X,z,ia,$),gc(N,ea,X,z,ia,$,1,0,1,1,0,1,ra)):(aa.r=Ga.r,aa.g=Ga.g,aa.b=Ga.b,p(i,R.centroidWorld,R.normalWorld,aa),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)),v(P,H,G,j,X,z,E,Q),m.wireframe?Mb(aa,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(aa)):(v(P,H,G,j,X,z,E,Q),m.wireframe?Mb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(m.color));else if(m instanceof THREE.MeshNormalMaterial)aa.r=hc(R.normalWorld.x),aa.g=hc(R.normalWorld.y),aa.b=hc(R.normalWorld.z),v(P,H,G,j,X,z,E,Q),m.wireframe?Mb(aa,m.wireframeLinewidth,m.wireframeLinecap,
+m.wireframeLinejoin):Gb(aa);else if(m instanceof THREE.MeshDepthMaterial)na=n.near,Ha=n.far,ba.r=ba.g=ba.b=1-ac(a.positionScreen.z,na,Ha),Y.r=Y.g=Y.b=1-ac(d.positionScreen.z,na,Ha),ca.r=ca.g=ca.b=1-ac(g.positionScreen.z,na,Ha),fa.r=fa.g=fa.b=1-ac(e.positionScreen.z,na,Ha),ra=Dc(ba,Y,ca,fa),w(P,H,G,j,E,Q),gc(P,H,G,j,E,Q,0,0,1,0,0,1,ra),w(N,ea,X,z,ia,$),gc(N,ea,X,z,ia,$,1,0,1,1,0,1,ra)}function w(a,b,c,d,e,g){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,g);m.lineTo(a,b);m.closePath()}function v(a,
+b,c,d,e,g,f,Z){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,g);m.lineTo(f,Z);m.lineTo(a,b);m.closePath()}function Mb(a,b,c,e){if(A!=b)m.lineWidth=A=b;if(B!=c)m.lineCap=B=c;if(C!=e)m.lineJoin=C=e;d(a.getContextStyle());m.stroke();Aa.inflate(2*b)}function Gb(a){e(a.getContextStyle());m.fill()}function Vc(a,b,c,d,g,f,Z,j,h,i,R,n,k){if(0!=k.image.width){if(!0==k.needsUpdate||void 0==Ua[k.id]){var l=k.wrapS==THREE.RepeatWrapping,o=k.wrapT==THREE.RepeatWrapping;Ua[k.id]=m.createPattern(k.image,
+l&&o?"repeat":l&&!o?"repeat-x":!l&&o?"repeat-y":"no-repeat");k.needsUpdate=!1}e(Ua[k.id]);var l=k.offset.x/k.repeat.x,o=k.offset.y/k.repeat.y,Fb=k.image.width*k.repeat.x,p=k.image.height*k.repeat.y,Z=(Z+l)*Fb,j=(j+o)*p,c=c-a,d=d-b,g=g-a,f=f-b,h=(h+l)*Fb-Z,i=(i+o)*p-j,R=(R+l)*Fb-Z,n=(n+o)*p-j,l=h*n-R*i;if(0==l){if(void 0===Ka[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),Ka[k.id]=b.getImageData(0,0,k.image.width,
+k.image.height).data;b=Ka[k.id];Z=4*(Math.floor(Z)+Math.floor(j)*k.image.width);aa.setRGB(b[Z]/255,b[Z+1]/255,b[Z+2]/255);Gb(aa)}else l=1/l,k=(n*c-i*g)*l,i=(n*d-i*f)*l,c=(h*g-R*c)*l,d=(h*f-R*d)*l,a=a-k*Z-c*j,Z=b-i*Z-d*j,m.save(),m.transform(k,i,c,d,a,Z),m.fill(),m.restore()}}function gc(a,b,c,d,e,g,f,Z,j,h,i,R,k){var n,l;n=k.width-1;l=k.height-1;f*=n;Z*=l;c-=a;d-=b;e-=a;g-=b;j=j*n-f;h=h*l-Z;i=i*n-f;R=R*l-Z;l=1/(j*R-i*h);n=(R*c-h*e)*l;h=(R*d-h*g)*l;c=(j*e-i*c)*l;d=(j*g-i*d)*l;a=a-n*f-c*Z;b=b-h*f-d*
+Z;m.save();m.transform(n,h,c,d,a,b);m.clip();m.drawImage(k,0,0);m.restore()}function Dc(a,b,c,d){var e=~~(255*a.r),g=~~(255*a.g),a=~~(255*a.b),f=~~(255*b.r),Z=~~(255*b.g),b=~~(255*b.b),j=~~(255*c.r),h=~~(255*c.g),c=~~(255*c.b),i=~~(255*d.r),m=~~(255*d.g),d=~~(255*d.b);eb[0]=0>e?0:255<e?255:e;eb[1]=0>g?0:255<g?255:g;eb[2]=0>a?0:255<a?255:a;eb[4]=0>f?0:255<f?255:f;eb[5]=0>Z?0:255<Z?255:Z;eb[6]=0>b?0:255<b?255:b;eb[8]=0>j?0:255<j?255:j;eb[9]=0>h?0:255<h?255:h;eb[10]=0>c?0:255<c?255:c;eb[12]=0>i?0:255<
+i?255:i;eb[13]=0>m?0:255<m?255:m;eb[14]=0>d?0:255<d?255:d;Fb.putImageData(Uc,0,0);Cc.drawImage(R,0,0);return pc}function ac(a,b,c){a=(a-b)/(c-b);return a*a*(3-2*a)}function hc(a){a=0.5*(a+1);return 0>a?0:1<a?1:a}function Nb(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 Ec,fd,Pa,jb;this.autoClear?this.clear():m.setTransform(1,0,0,-1,o,q);f.info.render.vertices=0;f.info.render.faces=0;g=k.projectScene(a,n,this.sortElements);h=g.elements;i=
+g.lights;(Fa=0<i.length)&&l(i);for(Ec=0,fd=h.length;Ec<fd;Ec++)if(Pa=h[Ec],jb=Pa.material,jb=jb instanceof THREE.MeshFaceMaterial?Pa.faceMaterial:jb,!(null==jb||0==jb.opacity)){Aa.empty();if(Pa instanceof THREE.RenderableParticle)D=Pa,D.x*=o,D.y*=q,r(D,Pa,jb,a);else if(Pa instanceof THREE.RenderableLine)D=Pa.v1,I=Pa.v2,D.positionScreen.x*=o,D.positionScreen.y*=q,I.positionScreen.x*=o,I.positionScreen.y*=q,Aa.addPoint(D.positionScreen.x,D.positionScreen.y),Aa.addPoint(I.positionScreen.x,I.positionScreen.y),
+La.intersects(Aa)&&s(D,I,Pa,jb,a);else if(Pa instanceof THREE.RenderableFace3)D=Pa.v1,I=Pa.v2,K=Pa.v3,D.positionScreen.x*=o,D.positionScreen.y*=q,I.positionScreen.x*=o,I.positionScreen.y*=q,K.positionScreen.x*=o,K.positionScreen.y*=q,jb.overdraw&&(Nb(D.positionScreen,I.positionScreen),Nb(I.positionScreen,K.positionScreen),Nb(K.positionScreen,D.positionScreen)),Aa.add3Points(D.positionScreen.x,D.positionScreen.y,I.positionScreen.x,I.positionScreen.y,K.positionScreen.x,K.positionScreen.y),La.intersects(Aa)&&
+t(D,I,K,0,1,2,Pa,jb,a);else if(Pa instanceof THREE.RenderableFace4)D=Pa.v1,I=Pa.v2,K=Pa.v3,O=Pa.v4,D.positionScreen.x*=o,D.positionScreen.y*=q,I.positionScreen.x*=o,I.positionScreen.y*=q,K.positionScreen.x*=o,K.positionScreen.y*=q,O.positionScreen.x*=o,O.positionScreen.y*=q,S.positionScreen.copy(I.positionScreen),L.positionScreen.copy(O.positionScreen),jb.overdraw&&(Nb(D.positionScreen,I.positionScreen),Nb(I.positionScreen,O.positionScreen),Nb(O.positionScreen,D.positionScreen),Nb(K.positionScreen,
+S.positionScreen),Nb(K.positionScreen,L.positionScreen)),Aa.addPoint(D.positionScreen.x,D.positionScreen.y),Aa.addPoint(I.positionScreen.x,I.positionScreen.y),Aa.addPoint(K.positionScreen.x,K.positionScreen.y),Aa.addPoint(O.positionScreen.x,O.positionScreen.y),La.intersects(Aa)&&u(D,I,K,O,S,L,Pa,jb,a);ta.addRectangle(Aa)}m.setTransform(1,0,0,1,0,0)}};
+THREE.SVGRenderer=function(){function a(a,b,c,d){var e,g,f,h,i,m;for(e=0,g=a.length;e<g;e++)f=a[e],h=f.color,f instanceof THREE.DirectionalLight?(i=f.matrixWorld.getPosition(),m=c.dot(i),0>=m||(m*=f.intensity,d.r+=h.r*m,d.g+=h.g*m,d.b+=h.b*m)):f instanceof THREE.PointLight&&(i=f.matrixWorld.getPosition(),m=c.dot(D.sub(i,b).normalize()),0>=m||(m*=0==f.distance?1:1-Math.min(b.distanceTo(i)/f.distance,1),0!=m&&(m*=f.intensity,d.r+=h.r*m,d.g+=h.g*m,d.b+=h.b*m)))}function b(a){null==I[a]&&(I[a]=document.createElementNS("http://www.w3.org/2000/svg",
+"path"),0==P&&I[a].setAttribute("shape-rendering","crispEdges"));return I[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"),k,l,p,n,o,q,m,r,s=new THREE.Rectangle,t=new THREE.Rectangle,w=!1,u=new THREE.Color,v=new THREE.Color,A=new THREE.Color,B=new THREE.Color,C,D=new THREE.Vector3,I=[],K=[],O,S,L,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){k=a;l=b;p=k/2;n=l/2;i.setAttribute("viewBox",-p+" "+-n+" "+k+" "+l);i.setAttribute("width",k);i.setAttribute("height",l);s.set(-p,-n,p,n)};this.clear=function(){for(;0<i.childNodes.length;)i.removeChild(i.childNodes[0])};this.render=function(k,l){var j,D,z,E;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(k,l,this.sortElements);f=e.elements;
+g=e.lights;L=S=0;if(w=0<g.length){v.setRGB(0,0,0);A.setRGB(0,0,0);B.setRGB(0,0,0);for(j=0,D=g.length;j<D;j++)E=g[j],z=E.color,E instanceof THREE.AmbientLight?(v.r+=z.r,v.g+=z.g,v.b+=z.b):E instanceof THREE.DirectionalLight?(A.r+=z.r,A.g+=z.g,A.b+=z.b):E instanceof THREE.PointLight&&(B.r+=z.r,B.g+=z.g,B.b+=z.b)}for(j=0,D=f.length;j<D;j++)if(z=f[j],E=z.material,E=E instanceof THREE.MeshFaceMaterial?z.faceMaterial:E,!(null==E||0==E.opacity))if(t.empty(),z instanceof THREE.RenderableParticle)o=z,o.x*=
+p,o.y*=-n;else if(z instanceof THREE.RenderableLine){if(o=z.v1,q=z.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)){z=o;var Q=q,N=L++;null==K[N]&&(K[N]=document.createElementNS("http://www.w3.org/2000/svg","line"),0==P&&K[N].setAttribute("shape-rendering","crispEdges"));O=K[N];O.setAttribute("x1",z.positionScreen.x);O.setAttribute("y1",z.positionScreen.y);
+O.setAttribute("x2",Q.positionScreen.x);O.setAttribute("y2",Q.positionScreen.y);E instanceof THREE.LineBasicMaterial&&(O.setAttribute("style","fill: none; stroke: "+E.color.getContextStyle()+"; stroke-width: "+E.linewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.linecap+"; stroke-linejoin: "+E.linejoin),i.appendChild(O))}}else if(z instanceof THREE.RenderableFace3){if(o=z.v1,q=z.v2,m=z.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 Q=o,N=q,I=m;d.info.render.vertices+=3;d.info.render.faces++;O=b(S++);O.setAttribute("d","M "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+"z");E instanceof THREE.MeshBasicMaterial?u.copy(E.color):E instanceof THREE.MeshLambertMaterial?
+w?(u.r=v.r,u.g=v.g,u.b=v.b,a(g,z.centroidWorld,z.normalWorld,u),u.r=Math.max(0,Math.min(E.color.r*u.r,1)),u.g=Math.max(0,Math.min(E.color.g*u.g,1)),u.b=Math.max(0,Math.min(E.color.b*u.b,1))):u.copy(E.color):E instanceof THREE.MeshDepthMaterial?(C=1-E.__2near/(E.__farPlusNear-z.z*E.__farMinusNear),u.setRGB(C,C,C)):E instanceof THREE.MeshNormalMaterial&&u.setRGB(c(z.normalWorld.x),c(z.normalWorld.y),c(z.normalWorld.z));E.wireframe?O.setAttribute("style","fill: none; stroke: "+u.getContextStyle()+"; stroke-width: "+
+E.wireframeLinewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframeLinecap+"; stroke-linejoin: "+E.wireframeLinejoin):O.setAttribute("style","fill: "+u.getContextStyle()+"; fill-opacity: "+E.opacity);i.appendChild(O)}}else if(z instanceof THREE.RenderableFace4&&(o=z.v1,q=z.v2,m=z.v3,r=z.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 Q=o,N=q,I=m,ia=r;d.info.render.vertices+=4;d.info.render.faces++;O=b(S++);O.setAttribute("d","M "+Q.positionScreen.x+" "+Q.positionScreen.y+" L "+N.positionScreen.x+" "+N.positionScreen.y+" L "+I.positionScreen.x+","+I.positionScreen.y+" L "+ia.positionScreen.x+","+ia.positionScreen.y+"z");E instanceof THREE.MeshBasicMaterial?
+u.copy(E.color):E instanceof THREE.MeshLambertMaterial?w?(u.r=v.r,u.g=v.g,u.b=v.b,a(g,z.centroidWorld,z.normalWorld,u),u.r=Math.max(0,Math.min(E.color.r*u.r,1)),u.g=Math.max(0,Math.min(E.color.g*u.g,1)),u.b=Math.max(0,Math.min(E.color.b*u.b,1))):u.copy(E.color):E instanceof THREE.MeshDepthMaterial?(C=1-E.__2near/(E.__farPlusNear-z.z*E.__farMinusNear),u.setRGB(C,C,C)):E instanceof THREE.MeshNormalMaterial&&u.setRGB(c(z.normalWorld.x),c(z.normalWorld.y),c(z.normalWorld.z));E.wireframe?O.setAttribute("style",
+"fill: none; stroke: "+u.getContextStyle()+"; stroke-width: "+E.wireframeLinewidth+"; stroke-opacity: "+E.opacity+"; stroke-linecap: "+E.wireframeLinecap+"; stroke-linejoin: "+E.wireframeLinejoin):O.setAttribute("style","fill: "+u.getContextStyle()+"; fill-opacity: "+E.opacity);i.appendChild(O)}}};
 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",
@@ -235,125 +236,126 @@ 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,m=a.__vertexArray,n=a.__colorArray,l=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,q=a.__webglCustomAttributesList;if(c.sortParticles){$a.multiplySelf(c.matrixWorld);for(d=0;d<g;d++)e=h[d].position,Sa.copy(e),$a.multiplyVector3(Sa),l[d]=[Sa.z,d];l.sort(function(a,b){return b[0]-a[0]});for(d=0;d<g;d++)e=h[l[d][1]].position,f=3*d,m[f]=e.x,m[f+1]=e.y,m[f+2]=e.z;for(d=0;d<k;d++)f=3*d,e=i[l[d][1]],n[f]=e.r,n[f+1]=e.g,n[f+2]=e.b;if(q)for(i=0,k=q.length;i<k;i++)if(h=q[i],
+var i=a.colors,m=i.length,k=a.__vertexArray,n=a.__colorArray,l=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,q=a.__webglCustomAttributesList;if(c.sortParticles){Wa.multiplySelf(c.matrixWorld);for(d=0;d<g;d++)e=h[d].position,$a.copy(e),Wa.multiplyVector3($a),l[d]=[$a.z,d];l.sort(function(a,b){return b[0]-a[0]});for(d=0;d<g;d++)e=h[l[d][1]].position,f=3*d,k[f]=e.x,k[f+1]=e.y,k[f+2]=e.z;for(d=0;d<m;d++)f=3*d,e=i[l[d][1]],n[f]=e.r,n[f+1]=e.g,n[f+2]=e.b;if(q)for(i=0,m=q.length;i<m;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=l[d][1],h.array[d]=h.value[g];else if(2===h.size)for(d=0;d<e;d++)g=l[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=l[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=l[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=l[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(o)for(d=0;d<g;d++)e=h[d].position,f=3*d,m[f]=e.x,m[f+1]=e.y,m[f+2]=e.z;if(p)for(d=0;d<k;d++)e=i[d],f=3*d,n[f]=e.r,n[f+1]=e.g,n[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(o||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,m,b);if(p||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,
-n,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++)ea=A=null,P=R=aa=U=ba=-1,a[d].render(b,c,lb,eb),ea=A=null,P=R=aa=U=ba=-1}function i(a,b,c,d,e,f,g,h){var j,i,k,m;b?(i=a.length-1,m=b=-1):(i=0,b=a.length,m=1);for(var n=i;n!==b;n+=m)if(j=a[n],j.render){i=j.object;k=j.buffer;if(h)j=h;else{j=j[c];if(!j)continue;
-g&&H.setBlending(j.blending);H.setDepthTest(j.depthTest);H.setDepthWrite(j.depthWrite);s(j.polygonOffset,j.polygonOffsetFactor,j.polygonOffsetUnits)}H.setObjectFaces(i);k instanceof THREE.BufferGeometry?H.renderBufferDirect(d,e,f,j,k,i):H.renderBuffer(d,e,f,j,k,i)}}function k(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&&H.setBlending(h.blending);H.setDepthTest(h.depthTest);H.setDepthWrite(h.depthWrite);s(h.polygonOffset,h.polygonOffsetFactor,
-h.polygonOffsetUnits)}H.renderImmediateObject(c,d,e,h,j)}}function l(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 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 q(a,b){for(var c=a.length-1;0<=c;c--)a[c]===b&&a.splice(c,1)}function n(a,b,c,d,e){d.program||H.initMaterial(d,b,c,e);if(d.morphTargets&&
-!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(H.maxMorphTargets);for(var f=0,g=H.maxMorphTargets;f<g;f++)e.__webglMorphTargetInfluences[f]=0}var h=!1,f=d.program,g=f.uniforms,i=d.uniforms;f!==A&&(j.useProgram(f),A=f,h=!0);if(d.id!==P)P=d.id,h=!0;if(h||a!==ea)j.uniformMatrix4fv(g.projectionMatrix,!1,a._projectionMatrixArray),a!==ea&&(ea=a);if(h){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,m=0,n=0,l=0,o,p,q,r=ya,s=r.directional.colors,t=r.directional.positions,F=r.point.colors,u=r.point.positions,v=r.point.distances,B=0,C=0,R=q=0;for(c=0,h=b.length;c<h;c++)if(k=b[c],!k.onlyShadow)if(o=k.color,p=k.intensity,q=k.distance,k instanceof THREE.AmbientLight)H.gammaInput?(m+=o.r*o.r,n+=o.g*o.g,l+=o.b*o.b):(m+=o.r,n+=o.g,l+=o.b);else if(k instanceof THREE.DirectionalLight)q=
-3*B,H.gammaInput?(s[q]=o.r*o.r*p*p,s[q+1]=o.g*o.g*p*p,s[q+2]=o.b*o.b*p*p):(s[q]=o.r*p,s[q+1]=o.g*p,s[q+2]=o.b*p),Fa.copy(k.matrixWorld.getPosition()),Fa.subSelf(k.target.matrixWorld.getPosition()),Fa.normalize(),t[q]=Fa.x,t[q+1]=Fa.y,t[q+2]=Fa.z,B+=1;else if(k instanceof THREE.PointLight||k instanceof THREE.SpotLight)R=3*C,H.gammaInput?(F[R]=o.r*o.r*p*p,F[R+1]=o.g*o.g*p*p,F[R+2]=o.b*o.b*p*p):(F[R]=o.r*p,F[R+1]=o.g*p,F[R+2]=o.b*p),k=k.matrixWorld.getPosition(),u[R]=k.x,u[R+1]=k.y,u[R+2]=k.z,v[C]=q,
-C+=1;for(c=3*B,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=B;r.ambient[0]=m;r.ambient[1]=n;r.ambient[2]=l;c=ya;i.ambientLightColor.value=c.ambient;i.directionalLightColor.value=c.directional.colors;i.directionalLightDirection.value=c.directional.positions;i.pointLightColor.value=c.point.colors;i.pointLightPosition.value=c.point.positions;i.pointLightDistance.value=c.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||
-d instanceof THREE.MeshPhongMaterial)i.opacity.value=d.opacity,H.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,H.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)H.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){h=
-c=0;for(m=b.length;h<m;h++)if(n=b[h],n.castShadow&&(n instanceof THREE.SpotLight||n instanceof THREE.DirectionalLight&&!n.shadowCascade))i.shadowMap.texture[c]=n.shadowMap,i.shadowMapSize.value[c]=n.shadowMapSize,i.shadowMatrix.value[c]=n.shadowMatrix,i.shadowDarkness.value[c]=n.shadowDarkness,i.shadowBias.value[c]=n.shadowBias,c++}b=d.uniformsList;for(i=0,c=b.length;i<c;i++)if(n=f.uniforms[b[i][1]])if(h=b[i][0],l=h.type,m=h.value,"i"===l)j.uniform1i(n,m);else if("f"===l)j.uniform1f(n,m);else if("v2"===
-l)j.uniform2f(n,m.x,m.y);else if("v3"===l)j.uniform3f(n,m.x,m.y,m.z);else if("v4"===l)j.uniform4f(n,m.x,m.y,m.z,m.w);else if("c"===l)j.uniform3f(n,m.r,m.g,m.b);else if("fv1"===l)j.uniform1fv(n,m);else if("fv"===l)j.uniform3fv(n,m);else if("v2v"===l){if(!h._array)h._array=new Float32Array(2*m.length);for(l=0,r=m.length;l<r;l++)s=2*l,h._array[s]=m[l].x,h._array[s+1]=m[l].y;j.uniform2fv(n,h._array)}else if("v3v"===l){if(!h._array)h._array=new Float32Array(3*m.length);for(l=0,r=m.length;l<r;l++)s=3*l,
-h._array[s]=m[l].x,h._array[s+1]=m[l].y,h._array[s+2]=m[l].z;j.uniform3fv(n,h._array)}else if("v4v"==l){if(!h._array)h._array=new Float32Array(4*m.length);for(l=0,r=m.length;l<r;l++)s=4*l,h._array[s]=m[l].x,h._array[s+1]=m[l].y,h._array[s+2]=m[l].z,h._array[s+3]=m[l].w;j.uniform4fv(n,h._array)}else if("m4"===l){if(!h._array)h._array=new Float32Array(16);m.flattenToArray(h._array);j.uniformMatrix4fv(n,!1,h._array)}else if("m4v"===l){if(!h._array)h._array=new Float32Array(16*m.length);for(l=0,r=m.length;l<
-r;l++)m[l].flattenToArrayOffset(h._array,16*l);j.uniformMatrix4fv(n,!1,h._array)}else if("t"===l){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++){l=m;r=n;if(H.autoScaleCubemaps){if(s=h.image[n],F=Qa,!(s.width<=F&&s.height<=F))u=Math.max(s.width,
-s.height),t=Math.floor(s.width*F/u),F=Math.floor(s.height*F/u),u=document.createElement("canvas"),u.width=t,u.height=F,u.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,F),s=u}else s=h.image[n];l[r]=s}n=m[0];l=0===(n.width&n.width-1)&&0===(n.height&n.height-1);r=y(h.format);s=y(h.type);w(j.TEXTURE_CUBE_MAP,h,l);for(n=0;6>n;n++)j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,r,r,s,m[n]);h.generateMipmaps&&l&&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)):H.setTexture(n,m)}else if("tv"===l){if(!h._array){h._array=[];for(l=0,r=h.texture.length;l<r;l++)h._array[l]=m+l}j.uniform1iv(n,h._array);for(l=0,r=h.texture.length;l<r;l++)(n=h.texture[l])&&H.setTexture(n,h._array[l])}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&
+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(o)for(d=0;d<g;d++)e=h[d].position,f=3*d,k[f]=e.x,k[f+1]=e.y,k[f+2]=e.z;if(p)for(d=0;d<m;d++)e=i[d],f=3*d,n[f]=e.r,n[f+1]=e.g,n[f+2]=e.b;if(q)for(i=0,m=q.length;i<m;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(o||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglVertexBuffer),j.bufferData(j.ARRAY_BUFFER,k,b);if(p||c.sortParticles)j.bindBuffer(j.ARRAY_BUFFER,a.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,
+n,b);if(q)for(i=0,m=q.length;i<m;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++)ea=z=null,Q=N=ca=Y=ba=-1,a[d].render(b,c,Va,lb),ea=z=null,Q=N=ca=Y=ba=-1}function i(a,b,c,d,e,f,g,h){var j,i,m,k;b?(i=a.length-1,k=b=-1):(i=0,b=a.length,k=1);for(var n=i;n!==b;n+=k)if(j=a[n],j.render){i=j.object;m=j.buffer;if(h)j=h;else{j=j[c];if(!j)continue;
+g&&G.setBlending(j.blending);G.setDepthTest(j.depthTest);G.setDepthWrite(j.depthWrite);s(j.polygonOffset,j.polygonOffsetFactor,j.polygonOffsetUnits)}G.setObjectFaces(i);m instanceof THREE.BufferGeometry?G.renderBufferDirect(d,e,f,j,m,i):G.renderBuffer(d,e,f,j,m,i)}}function k(a,b,c,d,e,f,g){for(var h,j,i=0,m=a.length;i<m;i++)if(h=a[i],j=h.object,j.visible){if(g)h=g;else{h=h[b];if(!h)continue;f&&G.setBlending(h.blending);G.setDepthTest(h.depthTest);G.setDepthWrite(h.depthWrite);s(h.polygonOffset,h.polygonOffsetFactor,
+h.polygonOffsetUnits)}G.renderImmediateObject(c,d,e,h,j)}}function l(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||G.initMaterial(d,b,c,e);if(d.morphTargets&&
+!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(G.maxMorphTargets);for(var f=0,g=G.maxMorphTargets;f<g;f++)e.__webglMorphTargetInfluences[f]=0}var h=!1,f=d.program,g=f.uniforms,i=d.uniforms;f!==z&&(j.useProgram(f),z=f,h=!0);if(d.id!==Q)Q=d.id,h=!0;if(h||a!==ea)j.uniformMatrix4fv(g.projectionMatrix,!1,a._projectionMatrixArray),a!==ea&&(ea=a);if(h){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 m,k=0,n=0,l=0,o,p,q,r=ta,s=r.directional.colors,t=r.directional.positions,E=r.point.colors,u=r.point.positions,v=r.point.distances,D=0,C=0,N=q=0;for(c=0,h=b.length;c<h;c++)if(m=b[c],!m.onlyShadow)if(o=m.color,p=m.intensity,q=m.distance,m instanceof THREE.AmbientLight)G.gammaInput?(k+=o.r*o.r,n+=o.g*o.g,l+=o.b*o.b):(k+=o.r,n+=o.g,l+=o.b);else if(m instanceof THREE.DirectionalLight)q=
+3*D,G.gammaInput?(s[q]=o.r*o.r*p*p,s[q+1]=o.g*o.g*p*p,s[q+2]=o.b*o.b*p*p):(s[q]=o.r*p,s[q+1]=o.g*p,s[q+2]=o.b*p),La.copy(m.matrixWorld.getPosition()),La.subSelf(m.target.matrixWorld.getPosition()),La.normalize(),t[q]=La.x,t[q+1]=La.y,t[q+2]=La.z,D+=1;else if(m instanceof THREE.PointLight||m instanceof THREE.SpotLight)N=3*C,G.gammaInput?(E[N]=o.r*o.r*p*p,E[N+1]=o.g*o.g*p*p,E[N+2]=o.b*o.b*p*p):(E[N]=o.r*p,E[N+1]=o.g*p,E[N+2]=o.b*p),m=m.matrixWorld.getPosition(),u[N]=m.x,u[N+1]=m.y,u[N+2]=m.z,v[C]=q,
+C+=1;for(c=3*D,h=s.length;c<h;c++)s[c]=0;for(c=3*C,h=E.length;c<h;c++)E[c]=0;r.point.length=C;r.directional.length=D;r.ambient[0]=k;r.ambient[1]=n;r.ambient[2]=l;c=ta;i.ambientLightColor.value=c.ambient;i.directionalLightColor.value=c.directional.colors;i.directionalLightDirection.value=c.directional.positions;i.pointLightColor.value=c.point.colors;i.pointLightPosition.value=c.point.positions;i.pointLightDistance.value=c.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||
+d instanceof THREE.MeshPhongMaterial)i.opacity.value=d.opacity,G.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=B.height/2,i.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)i.shininess.value=d.shininess,G.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)G.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){h=
+c=0;for(k=b.length;h<k;h++)if(n=b[h],n.castShadow&&(n instanceof THREE.SpotLight||n instanceof THREE.DirectionalLight&&!n.shadowCascade))i.shadowMap.texture[c]=n.shadowMap,i.shadowMapSize.value[c]=n.shadowMapSize,i.shadowMatrix.value[c]=n.shadowMatrix,i.shadowDarkness.value[c]=n.shadowDarkness,i.shadowBias.value[c]=n.shadowBias,c++}b=d.uniformsList;for(i=0,c=b.length;i<c;i++)if(n=f.uniforms[b[i][1]])if(h=b[i][0],l=h.type,k=h.value,"i"===l)j.uniform1i(n,k);else if("f"===l)j.uniform1f(n,k);else if("v2"===
+l)j.uniform2f(n,k.x,k.y);else if("v3"===l)j.uniform3f(n,k.x,k.y,k.z);else if("v4"===l)j.uniform4f(n,k.x,k.y,k.z,k.w);else if("c"===l)j.uniform3f(n,k.r,k.g,k.b);else if("fv1"===l)j.uniform1fv(n,k);else if("fv"===l)j.uniform3fv(n,k);else if("v2v"===l){if(!h._array)h._array=new Float32Array(2*k.length);for(l=0,r=k.length;l<r;l++)s=2*l,h._array[s]=k[l].x,h._array[s+1]=k[l].y;j.uniform2fv(n,h._array)}else if("v3v"===l){if(!h._array)h._array=new Float32Array(3*k.length);for(l=0,r=k.length;l<r;l++)s=3*l,
+h._array[s]=k[l].x,h._array[s+1]=k[l].y,h._array[s+2]=k[l].z;j.uniform3fv(n,h._array)}else if("v4v"==l){if(!h._array)h._array=new Float32Array(4*k.length);for(l=0,r=k.length;l<r;l++)s=4*l,h._array[s]=k[l].x,h._array[s+1]=k[l].y,h._array[s+2]=k[l].z,h._array[s+3]=k[l].w;j.uniform4fv(n,h._array)}else if("m4"===l){if(!h._array)h._array=new Float32Array(16);k.flattenToArray(h._array);j.uniformMatrix4fv(n,!1,h._array)}else if("m4v"===l){if(!h._array)h._array=new Float32Array(16*k.length);for(l=0,r=k.length;l<
+r;l++)k[l].flattenToArrayOffset(h._array,16*l);j.uniformMatrix4fv(n,!1,h._array)}else if("t"===l){if(j.uniform1i(n,k),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+k);j.bindTexture(j.TEXTURE_CUBE_MAP,h.image.__webglTextureCube);k=[];for(n=0;6>n;n++){l=k;r=n;if(G.autoScaleCubemaps){if(s=h.image[n],E=Fa,!(s.width<=E&&s.height<=E))u=Math.max(s.width,
+s.height),t=Math.floor(s.width*E/u),E=Math.floor(s.height*E/u),u=document.createElement("canvas"),u.width=t,u.height=E,u.getContext("2d").drawImage(s,0,0,s.width,s.height,0,0,t,E),s=u}else s=h.image[n];l[r]=s}n=k[0];l=0===(n.width&n.width-1)&&0===(n.height&n.height-1);r=A(h.format);s=A(h.type);w(j.TEXTURE_CUBE_MAP,h,l);for(n=0;6>n;n++)j.texImage2D(j.TEXTURE_CUBE_MAP_POSITIVE_X+n,0,r,r,s,k[n]);h.generateMipmaps&&l&&j.generateMipmap(j.TEXTURE_CUBE_MAP);h.needsUpdate=!1;if(h.onUpdated)h.onUpdated()}else j.activeTexture(j.TEXTURE0+
+k),j.bindTexture(j.TEXTURE_CUBE_MAP,h.image.__webglTextureCube)}else n instanceof THREE.WebGLRenderTargetCube?(h=n,j.activeTexture(j.TEXTURE0+k),j.bindTexture(j.TEXTURE_CUBE_MAP,h.__webglTexture)):G.setTexture(n,k)}else if("tv"===l){if(!h._array){h._array=[];for(l=0,r=h.texture.length;l<r;l++)h._array[l]=k+l}j.uniform1iv(n,h._array);for(l=0,r=h.texture.length;l<r;l++)(n=h.texture[l])&&G.setTexture(n,h._array[l])}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&
 null!==g.cameraPosition)b=a.matrixWorld.getPosition(),j.uniform3f(g.cameraPosition,b.x,b.y,b.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.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){ha!==a&&(a?j.enable(j.POLYGON_OFFSET_FILL):j.disable(j.POLYGON_OFFSET_FILL),ha=a);if(a&&(Ta!==b||oa!==c))j.polygonOffset(b,
-c),Ta=b,oa=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 w(a,b,c){c?(j.texParameteri(a,j.TEXTURE_WRAP_S,y(b.wrapS)),j.texParameteri(a,j.TEXTURE_WRAP_T,y(b.wrapT)),j.texParameteri(a,j.TEXTURE_MAG_FILTER,y(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,y(b.minFilter))):
+(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){fa!==a&&(a?j.enable(j.POLYGON_OFFSET_FILL):j.disable(j.POLYGON_OFFSET_FILL),fa=a);if(a&&(Ua!==b||Ka!==c))j.polygonOffset(b,
+c),Ua=b,Ka=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 w(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,v(b.magFilter)),j.texParameteri(a,j.TEXTURE_MIN_FILTER,v(b.minFilter)))}function u(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 v(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return j.NEAREST;default:return j.LINEAR}}function y(a){switch(a){case THREE.RepeatWrapping:return j.REPEAT;case THREE.ClampToEdgeWrapping:return j.CLAMP_TO_EDGE;case THREE.MirroredRepeatWrapping:return j.MIRRORED_REPEAT;
+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 v(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||{},D=void 0!==a.canvas?a.canvas:document.createElement("canvas"),C=void 0!==a.precision?a.precision:"mediump",B=void 0!==a.alpha?a.alpha:!0,E=void 0!==a.premultipliedAlpha?
-a.premultipliedAlpha:!0,J=void 0!==a.antialias?a.antialias:!1,N=void 0!==a.stencil?a.stencil:!0,S=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,K=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),O=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.shadowMapEnabled=
-this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.shadowMapCascade=this.shadowMapDebug=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;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 H=this,j,Z=[],A=null,F=null,P=-1,R=null,ea=null,ia=0,ca=null,V=null,ba=null,U=null,aa=null,
-ha=null,Ta=null,oa=null,Ka=null,Ea=0,Ba=0,ka=0,db=0,lb=0,eb=0,Za=new THREE.Frustum,$a=new THREE.Matrix4,Sa=new THREE.Vector4,Fa=new THREE.Vector3,ya={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",{alpha:B,premultipliedAlpha:E,antialias:J,stencil:N,preserveDrawingBuffer:S})))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(K.r,K.g,K.b,O);this.context=j;var za=j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
-j.getParameter(j.MAX_TEXTURE_SIZE);var Qa=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){Ea=a;Ba=b;ka=c;db=d;j.viewport(Ea,Ba,ka,db)};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){K.setHex(a);O=b;j.clearColor(K.r,K.g,K.b,O)};this.setClearColor=function(a,b){K.copy(a);O=b;j.clearColor(K.r,K.g,K.b,O)};this.getClearColor=function(){return K};this.getClearAlpha=function(){return O};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);
+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||{},B=void 0!==a.canvas?a.canvas:document.createElement("canvas"),C=void 0!==a.precision?a.precision:"mediump",D=void 0!==a.alpha?a.alpha:!0,I=void 0!==a.premultipliedAlpha?
+a.premultipliedAlpha:!0,K=void 0!==a.antialias?a.antialias:!1,O=void 0!==a.stencil?a.stencil:!0,S=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,L=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),P=void 0!==a.clearAlpha?a.clearAlpha:0,H=void 0!==a.maxLights?a.maxLights:4;this.domElement=B;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapEnabled=
+this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.shadowMapCascade=this.shadowMapDebug=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;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 G=this,j,X=[],z=null,E=null,Q=-1,N=null,ea=null,ia=0,$=null,aa=null,ba=null,Y=null,ca=null,
+fa=null,Ua=null,Ka=null,na=null,Ha=0,ra=0,qa=0,ib=0,Va=0,lb=0,db=new THREE.Frustum,Wa=new THREE.Matrix4,$a=new THREE.Vector4,La=new THREE.Vector3,ta={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};j=function(){var a;try{if(!(a=B.getContext("experimental-webgl",{alpha:D,premultipliedAlpha:I,antialias:K,stencil:O,preserveDrawingBuffer:S})))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,P);this.context=j;var Aa=j.getParameter(j.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
+j.getParameter(j.MAX_TEXTURE_SIZE);var Fa=j.getParameter(j.MAX_CUBE_MAP_TEXTURE_SIZE);this.getContext=function(){return j};this.supportsVertexTextures=function(){return 0<Aa};this.setSize=function(a,b){B.width=a;B.height=b;this.setViewport(0,0,B.width,B.height)};this.setViewport=function(a,b,c,d){Ha=a;ra=b;qa=c;ib=d;j.viewport(Ha,ra,qa,ib)};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);P=b;j.clearColor(L.r,L.g,L.b,P)};this.setClearColor=function(a,b){L.copy(a);P=b;j.clearColor(L.r,L.g,L.b,P)};this.getClearColor=function(){return L};this.getClearAlpha=function(){return P};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]),j.deleteBuffer(c.__webglMorphNormalsBuffers[d]);
-if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)j.deleteBuffer(c.__webglCustomAttributesList[d].buffer);H.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),H.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),H.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=
-a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),H.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,j.deleteTexture(a.__webglTexture),H.info.memory.textures--};this.updateShadowMap=function(a,b){A=null;P=R=aa=U=ba=-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,m,n,l,o=3*a.count;for(l=0;l<o;l+=9)c=a.normalArray,d=c[l],e=c[l+1],f=c[l+2],g=c[l+3],i=c[l+4],m=c[l+5],h=c[l+6],k=c[l+7],n=c[l+8],d=(d+g+h)/3,e=(e+i+k)/3,f=
-(f+m+n)/3,c[l]=d,c[l+1]=e,c[l+2]=f,c[l+3]=d,c[l+4]=e,c[l+5]=f,c[l+6]=d,c[l+7]=e,c[l+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=n(a,b,c,d,f),a=c.attributes,b=!1,d=16777215*e.id+2*c.id+(d.wireframe?1:0),d!==R&&(R=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),H.info.render.calls++,H.info.render.vertices+=f[d].count,H.info.render.faces+=f[d].count/3}};this.renderBuffer=function(a,
-b,c,d,e,f){if(0!==d.opacity){var g,h,c=n(a,b,c,d,f),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0);c!==R&&(R=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),d.morphNormals&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[i[g]]),j.vertexAttribPointer(c["morphNormal"+g],3,j.FLOAT,!1,0,0)),f.__webglMorphTargetInfluences[g]=
-h[i[g]],g++}else{var i=[],k=-1,m=0;h=f.morphTargetInfluences;var l,o=h.length;g=0;for(-1!==f.morphTargetBase&&(i[f.morphTargetBase]=!0);g<d.numSupportedMorphTargets;){for(l=0;l<o;l++)!i[l]&&h[l]>k&&(m=l,k=h[m]);j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[m]);j.vertexAttribPointer(c["morphTarget"+g],3,j.FLOAT,!1,0,0);d.morphNormals&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[m]),j.vertexAttribPointer(c["morphNormal"+g],3,j.FLOAT,!1,0,0));f.__webglMorphTargetInfluences[g]=
-k;i[m]=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!==Ka&&(j.lineWidth(d),Ka=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)),H.info.render.calls++,H.info.render.vertices+=
-e.__webglFaceCount,H.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==Ka&&(j.lineWidth(d),Ka=d),j.drawArrays(f,0,e.__webglLineCount),H.info.render.calls++):f instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),H.info.render.calls++,H.info.render.points+=e.__webglParticleCount):f instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,0,e.__webglVertexCount),H.info.render.calls++)}};this.render=
-function(a,b,c,d){var e,f,m,l,n=a.lights,o=a.fog;P=-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);H.info.render.calls=0;H.info.render.vertices=0;H.info.render.faces=0;H.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);$a.multiply(b.projectionMatrix,b.matrixWorldInverse);Za.setFromMatrix($a);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);l=a.__webglObjects;for(d=0,e=l.length;d<e;d++)if(f=l[d],m=f.object,f.render=!1,m.visible&&(!(m instanceof THREE.Mesh||m instanceof THREE.ParticleSystem)||!m.frustumCulled||Za.contains(m))){m.matrixWorld.flattenToArray(m._objectMatrixArray);
-r(m,b);var p=f,q=p.object,t=p.buffer,F=void 0,F=F=void 0,F=q.material;if(F instanceof THREE.MeshFaceMaterial){if(F=t.materialIndex,0<=F)F=q.geometry.materials[F],F.transparent?(p.transparent=F,p.opaque=null):(p.opaque=F,p.transparent=null)}else if(F)F.transparent?(p.transparent=F,p.opaque=null):(p.opaque=F,p.transparent=null);f.render=!0;if(this.sortObjects)m.renderDepth?f.z=m.renderDepth:(Sa.copy(m.position),$a.multiplyVector3(Sa),f.z=Sa.z)}this.sortObjects&&l.sort(g);l=a.__webglObjectsImmediate;
-for(d=0,e=l.length;d<e;d++)if(f=l[d],m=f.object,m.visible)m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),r(m,b),m=f.object.material,m.transparent?(f.transparent=m,f.opaque=null):(f.opaque=m,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,n,o,!0,a.overrideMaterial),k(a.__webglObjectsImmediate,"",b,n,o,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),i(a.__webglObjects,!0,"opaque",b,n,o,!1),k(a.__webglObjectsImmediate,"opaque",b,n,o,!1),i(a.__webglObjects,!1,"transparent",b,n,o,!0),k(a.__webglObjectsImmediate,"transparent",b,n,o,!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=n(a,b,c,d,e);R=-1;H.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(f,j,Za):e.render(function(a){H.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,k=void 0,n=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(k=
-g.geometry,k instanceof THREE.Geometry){if(void 0===k.geometryGroups){var r=k,s=void 0,t=void 0,F=void 0,u=void 0,w=void 0,v=void 0,A=void 0,P={},C=r.morphTargets.length;r.geometryGroups={};for(s=0,t=r.faces.length;s<t;s++)F=r.faces[s],u=F.materialIndex,v=void 0!==u?u:-1,void 0===P[v]&&(P[v]={hash:v,counter:0}),A=P[v].hash+"_"+P[v].counter,void 0===r.geometryGroups[A]&&(r.geometryGroups[A]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:C}),w=F instanceof THREE.Face3?3:4,65535<r.geometryGroups[A].vertices+
-w&&(P[v].counter+=1,A=P[v].hash+"_"+P[v].counter,void 0===r.geometryGroups[A]&&(r.geometryGroups[A]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:C})),F instanceof THREE.Face3?r.geometryGroups[A].faces3.push(s):r.geometryGroups[A].faces4.push(s),r.geometryGroups[A].vertices+=w;r.geometryGroupsList=[];var B=void 0;for(B in r.geometryGroups)r.geometryGroups[B].id=ia++,r.geometryGroupsList.push(r.geometryGroups[B])}for(i in k.geometryGroups)if(n=k.geometryGroups[i],!n.__webglVertexBuffer){var y=
-n;y.__webglVertexBuffer=j.createBuffer();y.__webglNormalBuffer=j.createBuffer();y.__webglTangentBuffer=j.createBuffer();y.__webglColorBuffer=j.createBuffer();y.__webglUVBuffer=j.createBuffer();y.__webglUV2Buffer=j.createBuffer();y.__webglSkinVertexABuffer=j.createBuffer();y.__webglSkinVertexBBuffer=j.createBuffer();y.__webglSkinIndicesBuffer=j.createBuffer();y.__webglSkinWeightsBuffer=j.createBuffer();y.__webglFaceBuffer=j.createBuffer();y.__webglLineBuffer=j.createBuffer();if(y.numMorphTargets){var R=
-void 0,D=void 0;y.__webglMorphTargetsBuffers=[];y.__webglMorphNormalsBuffers=[];for(R=0,D=y.numMorphTargets;R<D;R++)y.__webglMorphTargetsBuffers.push(j.createBuffer()),y.__webglMorphNormalsBuffers.push(j.createBuffer())}H.info.memory.geometries++;var E=n,M=g,K=M.geometry,J=E.faces3,ea=E.faces4,V=3*J.length+4*ea.length,ca=1*J.length+2*ea.length,N=3*J.length+4*ea.length,U=c(M,E),ba=e(U),aa=d(U),O=U.vertexColors?U.vertexColors:!1;E.__vertexArray=new Float32Array(3*V);if(aa)E.__normalArray=new Float32Array(3*
-V);if(K.hasTangents)E.__tangentArray=new Float32Array(4*V);if(O)E.__colorArray=new Float32Array(3*V);if(ba){if(0<K.faceUvs.length||0<K.faceVertexUvs.length)E.__uvArray=new Float32Array(2*V);if(1<K.faceUvs.length||1<K.faceVertexUvs.length)E.__uv2Array=new Float32Array(2*V)}if(M.geometry.skinWeights.length&&M.geometry.skinIndices.length)E.__skinVertexAArray=new Float32Array(4*V),E.__skinVertexBArray=new Float32Array(4*V),E.__skinIndexArray=new Float32Array(4*V),E.__skinWeightArray=new Float32Array(4*
-V);E.__faceArray=new Uint16Array(3*ca);E.__lineArray=new Uint16Array(2*N);if(E.numMorphTargets){E.__morphTargetsArrays=[];E.__morphNormalsArrays=[];for(var S=0,ha=E.numMorphTargets;S<ha;S++)E.__morphTargetsArrays.push(new Float32Array(3*V)),E.__morphNormalsArrays.push(new Float32Array(3*V))}E.__webglFaceCount=3*ca;E.__webglLineCount=2*N;if(U.attributes){if(void 0===E.__webglCustomAttributesList)E.__webglCustomAttributesList=[];var Z=void 0;for(Z in U.attributes){var Ta=U.attributes[Z],oa={},Ka;for(Ka in Ta)oa[Ka]=
-Ta[Ka];if(!oa.__webglInitialized||oa.createUniqueBuffers){oa.__webglInitialized=!0;var ka=1;"v2"===oa.type?ka=2:"v3"===oa.type?ka=3:"v4"===oa.type?ka=4:"c"===oa.type&&(ka=3);oa.size=ka;oa.array=new Float32Array(V*ka);oa.buffer=j.createBuffer();oa.buffer.belongsToAttribute=Z;Ta.needsUpdate=!0;oa.__original=Ta}E.__webglCustomAttributesList.push(oa)}}E.__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(g instanceof THREE.Ribbon){if(k=g.geometry,!k.__webglVertexBuffer){var Ba=k;Ba.__webglVertexBuffer=j.createBuffer();Ba.__webglColorBuffer=j.createBuffer();H.info.memory.geometries++;var Ea=k,ya=Ea.vertices.length;Ea.__vertexArray=new Float32Array(3*ya);Ea.__colorArray=new Float32Array(3*ya);Ea.__webglVertexCount=ya;k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(g instanceof THREE.Line){if(k=g.geometry,!k.__webglVertexBuffer){var za=k;za.__webglVertexBuffer=j.createBuffer();za.__webglColorBuffer=
-j.createBuffer();H.info.memory.geometries++;var Fa=k,Qa=g,db=Fa.vertices.length;Fa.__vertexArray=new Float32Array(3*db);Fa.__colorArray=new Float32Array(3*db);Fa.__webglLineCount=db;b(Fa,Qa);k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(g instanceof THREE.ParticleSystem&&(k=g.geometry,!k.__webglVertexBuffer)){var $a=k;$a.__webglVertexBuffer=j.createBuffer();$a.__webglColorBuffer=j.createBuffer();H.info.geometries++;var Sa=k,lb=g,eb=Sa.vertices.length;Sa.__vertexArray=new Float32Array(3*eb);Sa.__colorArray=
-new Float32Array(3*eb);Sa.__sortArray=[];Sa.__webglParticleCount=eb;b(Sa,lb);k.__dirtyVertices=!0;k.__dirtyColors=!0}if(!g.__webglActive){if(g instanceof THREE.Mesh)if(k=g.geometry,k instanceof THREE.BufferGeometry)l(h.__webglObjects,k,g);else for(i in k.geometryGroups)n=k.geometryGroups[i],l(h.__webglObjects,n,g);else g instanceof THREE.Ribbon||g instanceof THREE.Line||g instanceof THREE.ParticleSystem?(k=g.geometry,l(h.__webglObjects,k,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 gb=a.__objectsRemoved[0],Za=a;gb instanceof THREE.Mesh||gb instanceof THREE.ParticleSystem||gb instanceof THREE.Ribbon||gb instanceof THREE.Line?o(Za.__webglObjects,gb):gb instanceof THREE.Sprite?q(Za.__webglSprites,
-gb):gb instanceof THREE.LensFlare?q(Za.__webglFlares,gb):(gb instanceof THREE.MarchingCubes||gb.immediateRenderCallback)&&o(Za.__webglObjectsImmediate,gb);gb.__webglActive=!1;a.__objectsRemoved.splice(0,1)}for(var Vc=0,qd=a.__webglObjects.length;Vc<qd;Vc++){var nb=a.__webglObjects[Vc].object,ja=nb.geometry,qc=void 0,ic=void 0,Xa=void 0;if(nb instanceof THREE.Mesh)if(ja instanceof THREE.BufferGeometry)ja.__dirtyVertices=!1,ja.__dirtyElements=!1,ja.__dirtyUvs=!1,ja.__dirtyNormals=!1,ja.__dirtyColors=
-!1;else{for(var Wc=0,rd=ja.geometryGroupsList.length;Wc<rd;Wc++)if(qc=ja.geometryGroupsList[Wc],Xa=c(nb,qc),ic=Xa.attributes&&p(Xa),ja.__dirtyVertices||ja.__dirtyMorphTargets||ja.__dirtyElements||ja.__dirtyUvs||ja.__dirtyNormals||ja.__dirtyColors||ja.__dirtyTangents||ic){var fa=qc,sd=nb,ab=j.DYNAMIC_DRAW,td=!ja.dynamic,bc=Xa;if(fa.__inittedArrays){var fd=d(bc),Xc=bc.vertexColors?bc.vertexColors:!1,gd=e(bc),Fc=fd===THREE.SmoothShading,G=void 0,T=void 0,kb=void 0,L=void 0,jc=void 0,Ob=void 0,ob=void 0,
-Gc=void 0,Hb=void 0,kc=void 0,lc=void 0,W=void 0,X=void 0,Y=void 0,pa=void 0,pb=void 0,qb=void 0,rb=void 0,rc=void 0,sb=void 0,tb=void 0,ub=void 0,sc=void 0,vb=void 0,wb=void 0,xb=void 0,tc=void 0,yb=void 0,zb=void 0,Ab=void 0,uc=void 0,Bb=void 0,Cb=void 0,Db=void 0,vc=void 0,Pb=void 0,Qb=void 0,Rb=void 0,Hc=void 0,Sb=void 0,Tb=void 0,Ub=void 0,Ic=void 0,la=void 0,hd=void 0,Vb=void 0,mc=void 0,nc=void 0,La=void 0,id=void 0,Ia=void 0,Ja=void 0,Wb=void 0,Ib=void 0,Aa=0,Ga=0,Jb=0,Kb=0,hb=0,Ra=0,qa=0,
-Ua=0,Ca=0,I=0,da=0,z=0,bb=void 0,Ma=fa.__vertexArray,wc=fa.__uvArray,xc=fa.__uv2Array,ib=fa.__normalArray,sa=fa.__tangentArray,Na=fa.__colorArray,ta=fa.__skinVertexAArray,ua=fa.__skinVertexBArray,va=fa.__skinIndexArray,wa=fa.__skinWeightArray,Yc=fa.__morphTargetsArrays,Zc=fa.__morphNormalsArrays,$c=fa.__webglCustomAttributesList,x=void 0,Eb=fa.__faceArray,cb=fa.__lineArray,Va=sd.geometry,ud=Va.__dirtyElements,jd=Va.__dirtyUvs,vd=Va.__dirtyNormals,wd=Va.__dirtyTangents,xd=Va.__dirtyColors,yd=Va.__dirtyMorphTargets,
-cc=Va.vertices,ma=fa.faces3,na=fa.faces4,Da=Va.faces,ad=Va.faceVertexUvs[0],bd=Va.faceVertexUvs[1],dc=Va.skinVerticesA,ec=Va.skinVerticesB,fc=Va.skinIndices,Xb=Va.skinWeights,Yb=Va.morphTargets,Jc=Va.morphNormals;if(Va.__dirtyVertices){for(G=0,T=ma.length;G<T;G++)L=Da[ma[G]],W=cc[L.a].position,X=cc[L.b].position,Y=cc[L.c].position,Ma[Ga]=W.x,Ma[Ga+1]=W.y,Ma[Ga+2]=W.z,Ma[Ga+3]=X.x,Ma[Ga+4]=X.y,Ma[Ga+5]=X.z,Ma[Ga+6]=Y.x,Ma[Ga+7]=Y.y,Ma[Ga+8]=Y.z,Ga+=9;for(G=0,T=na.length;G<T;G++)L=Da[na[G]],W=cc[L.a].position,
-X=cc[L.b].position,Y=cc[L.c].position,pa=cc[L.d].position,Ma[Ga]=W.x,Ma[Ga+1]=W.y,Ma[Ga+2]=W.z,Ma[Ga+3]=X.x,Ma[Ga+4]=X.y,Ma[Ga+5]=X.z,Ma[Ga+6]=Y.x,Ma[Ga+7]=Y.y,Ma[Ga+8]=Y.z,Ma[Ga+9]=pa.x,Ma[Ga+10]=pa.y,Ma[Ga+11]=pa.z,Ga+=12;j.bindBuffer(j.ARRAY_BUFFER,fa.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Ma,ab)}if(yd)for(La=0,id=Yb.length;La<id;La++){da=0;for(G=0,T=ma.length;G<T;G++){Wb=ma[G];L=Da[Wb];W=Yb[La].vertices[L.a].position;X=Yb[La].vertices[L.b].position;Y=Yb[La].vertices[L.c].position;Ia=
-Yc[La];Ia[da]=W.x;Ia[da+1]=W.y;Ia[da+2]=W.z;Ia[da+3]=X.x;Ia[da+4]=X.y;Ia[da+5]=X.z;Ia[da+6]=Y.x;Ia[da+7]=Y.y;Ia[da+8]=Y.z;if(bc.morphNormals)Fc?(Ib=Jc[La].vertexNormals[Wb],sb=Ib.a,tb=Ib.b,ub=Ib.c):ub=tb=sb=Jc[La].faceNormals[Wb],Ja=Zc[La],Ja[da]=sb.x,Ja[da+1]=sb.y,Ja[da+2]=sb.z,Ja[da+3]=tb.x,Ja[da+4]=tb.y,Ja[da+5]=tb.z,Ja[da+6]=ub.x,Ja[da+7]=ub.y,Ja[da+8]=ub.z;da+=9}for(G=0,T=na.length;G<T;G++){Wb=na[G];L=Da[Wb];W=Yb[La].vertices[L.a].position;X=Yb[La].vertices[L.b].position;Y=Yb[La].vertices[L.c].position;
-pa=Yb[La].vertices[L.d].position;Ia=Yc[La];Ia[da]=W.x;Ia[da+1]=W.y;Ia[da+2]=W.z;Ia[da+3]=X.x;Ia[da+4]=X.y;Ia[da+5]=X.z;Ia[da+6]=Y.x;Ia[da+7]=Y.y;Ia[da+8]=Y.z;Ia[da+9]=pa.x;Ia[da+10]=pa.y;Ia[da+11]=pa.z;if(bc.morphNormals)Fc?(Ib=Jc[La].vertexNormals[Wb],sb=Ib.a,tb=Ib.b,ub=Ib.c,sc=Ib.d):sc=ub=tb=sb=Jc[La].faceNormals[Wb],Ja=Zc[La],Ja[da]=sb.x,Ja[da+1]=sb.y,Ja[da+2]=sb.z,Ja[da+3]=tb.x,Ja[da+4]=tb.y,Ja[da+5]=tb.z,Ja[da+6]=ub.x,Ja[da+7]=ub.y,Ja[da+8]=ub.z,Ja[da+9]=sc.x,Ja[da+10]=sc.y,Ja[da+11]=sc.z;da+=
-12}j.bindBuffer(j.ARRAY_BUFFER,fa.__webglMorphTargetsBuffers[La]);j.bufferData(j.ARRAY_BUFFER,Yc[La],ab);bc.morphNormals&&(j.bindBuffer(j.ARRAY_BUFFER,fa.__webglMorphNormalsBuffers[La]),j.bufferData(j.ARRAY_BUFFER,Zc[La],ab))}if(Xb.length){for(G=0,T=ma.length;G<T;G++)L=Da[ma[G]],yb=Xb[L.a],zb=Xb[L.b],Ab=Xb[L.c],wa[I]=yb.x,wa[I+1]=yb.y,wa[I+2]=yb.z,wa[I+3]=yb.w,wa[I+4]=zb.x,wa[I+5]=zb.y,wa[I+6]=zb.z,wa[I+7]=zb.w,wa[I+8]=Ab.x,wa[I+9]=Ab.y,wa[I+10]=Ab.z,wa[I+11]=Ab.w,Bb=fc[L.a],Cb=fc[L.b],Db=fc[L.c],
-va[I]=Bb.x,va[I+1]=Bb.y,va[I+2]=Bb.z,va[I+3]=Bb.w,va[I+4]=Cb.x,va[I+5]=Cb.y,va[I+6]=Cb.z,va[I+7]=Cb.w,va[I+8]=Db.x,va[I+9]=Db.y,va[I+10]=Db.z,va[I+11]=Db.w,Pb=dc[L.a],Qb=dc[L.b],Rb=dc[L.c],ta[I]=Pb.x,ta[I+1]=Pb.y,ta[I+2]=Pb.z,ta[I+3]=1,ta[I+4]=Qb.x,ta[I+5]=Qb.y,ta[I+6]=Qb.z,ta[I+7]=1,ta[I+8]=Rb.x,ta[I+9]=Rb.y,ta[I+10]=Rb.z,ta[I+11]=1,Sb=ec[L.a],Tb=ec[L.b],Ub=ec[L.c],ua[I]=Sb.x,ua[I+1]=Sb.y,ua[I+2]=Sb.z,ua[I+3]=1,ua[I+4]=Tb.x,ua[I+5]=Tb.y,ua[I+6]=Tb.z,ua[I+7]=1,ua[I+8]=Ub.x,ua[I+9]=Ub.y,ua[I+10]=Ub.z,
-ua[I+11]=1,I+=12;for(G=0,T=na.length;G<T;G++)L=Da[na[G]],yb=Xb[L.a],zb=Xb[L.b],Ab=Xb[L.c],uc=Xb[L.d],wa[I]=yb.x,wa[I+1]=yb.y,wa[I+2]=yb.z,wa[I+3]=yb.w,wa[I+4]=zb.x,wa[I+5]=zb.y,wa[I+6]=zb.z,wa[I+7]=zb.w,wa[I+8]=Ab.x,wa[I+9]=Ab.y,wa[I+10]=Ab.z,wa[I+11]=Ab.w,wa[I+12]=uc.x,wa[I+13]=uc.y,wa[I+14]=uc.z,wa[I+15]=uc.w,Bb=fc[L.a],Cb=fc[L.b],Db=fc[L.c],vc=fc[L.d],va[I]=Bb.x,va[I+1]=Bb.y,va[I+2]=Bb.z,va[I+3]=Bb.w,va[I+4]=Cb.x,va[I+5]=Cb.y,va[I+6]=Cb.z,va[I+7]=Cb.w,va[I+8]=Db.x,va[I+9]=Db.y,va[I+10]=Db.z,va[I+
-11]=Db.w,va[I+12]=vc.x,va[I+13]=vc.y,va[I+14]=vc.z,va[I+15]=vc.w,Pb=dc[L.a],Qb=dc[L.b],Rb=dc[L.c],Hc=dc[L.d],ta[I]=Pb.x,ta[I+1]=Pb.y,ta[I+2]=Pb.z,ta[I+3]=1,ta[I+4]=Qb.x,ta[I+5]=Qb.y,ta[I+6]=Qb.z,ta[I+7]=1,ta[I+8]=Rb.x,ta[I+9]=Rb.y,ta[I+10]=Rb.z,ta[I+11]=1,ta[I+12]=Hc.x,ta[I+13]=Hc.y,ta[I+14]=Hc.z,ta[I+15]=1,Sb=ec[L.a],Tb=ec[L.b],Ub=ec[L.c],Ic=ec[L.d],ua[I]=Sb.x,ua[I+1]=Sb.y,ua[I+2]=Sb.z,ua[I+3]=1,ua[I+4]=Tb.x,ua[I+5]=Tb.y,ua[I+6]=Tb.z,ua[I+7]=1,ua[I+8]=Ub.x,ua[I+9]=Ub.y,ua[I+10]=Ub.z,ua[I+11]=1,ua[I+
-12]=Ic.x,ua[I+13]=Ic.y,ua[I+14]=Ic.z,ua[I+15]=1,I+=16;0<I&&(j.bindBuffer(j.ARRAY_BUFFER,fa.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,ta,ab),j.bindBuffer(j.ARRAY_BUFFER,fa.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,ua,ab),j.bindBuffer(j.ARRAY_BUFFER,fa.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,va,ab),j.bindBuffer(j.ARRAY_BUFFER,fa.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,wa,ab))}if(xd&&Xc){for(G=0,T=ma.length;G<T;G++)L=Da[ma[G]],ob=L.vertexColors,Gc=
-L.color,3===ob.length&&Xc===THREE.VertexColors?(vb=ob[0],wb=ob[1],xb=ob[2]):xb=wb=vb=Gc,Na[Ca]=vb.r,Na[Ca+1]=vb.g,Na[Ca+2]=vb.b,Na[Ca+3]=wb.r,Na[Ca+4]=wb.g,Na[Ca+5]=wb.b,Na[Ca+6]=xb.r,Na[Ca+7]=xb.g,Na[Ca+8]=xb.b,Ca+=9;for(G=0,T=na.length;G<T;G++)L=Da[na[G]],ob=L.vertexColors,Gc=L.color,4===ob.length&&Xc===THREE.VertexColors?(vb=ob[0],wb=ob[1],xb=ob[2],tc=ob[3]):tc=xb=wb=vb=Gc,Na[Ca]=vb.r,Na[Ca+1]=vb.g,Na[Ca+2]=vb.b,Na[Ca+3]=wb.r,Na[Ca+4]=wb.g,Na[Ca+5]=wb.b,Na[Ca+6]=xb.r,Na[Ca+7]=xb.g,Na[Ca+8]=xb.b,
-Na[Ca+9]=tc.r,Na[Ca+10]=tc.g,Na[Ca+11]=tc.b,Ca+=12;0<Ca&&(j.bindBuffer(j.ARRAY_BUFFER,fa.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,Na,ab))}if(wd&&Va.hasTangents){for(G=0,T=ma.length;G<T;G++)L=Da[ma[G]],Hb=L.vertexTangents,pb=Hb[0],qb=Hb[1],rb=Hb[2],sa[qa]=pb.x,sa[qa+1]=pb.y,sa[qa+2]=pb.z,sa[qa+3]=pb.w,sa[qa+4]=qb.x,sa[qa+5]=qb.y,sa[qa+6]=qb.z,sa[qa+7]=qb.w,sa[qa+8]=rb.x,sa[qa+9]=rb.y,sa[qa+10]=rb.z,sa[qa+11]=rb.w,qa+=12;for(G=0,T=na.length;G<T;G++)L=Da[na[G]],Hb=L.vertexTangents,pb=Hb[0],qb=
-Hb[1],rb=Hb[2],rc=Hb[3],sa[qa]=pb.x,sa[qa+1]=pb.y,sa[qa+2]=pb.z,sa[qa+3]=pb.w,sa[qa+4]=qb.x,sa[qa+5]=qb.y,sa[qa+6]=qb.z,sa[qa+7]=qb.w,sa[qa+8]=rb.x,sa[qa+9]=rb.y,sa[qa+10]=rb.z,sa[qa+11]=rb.w,sa[qa+12]=rc.x,sa[qa+13]=rc.y,sa[qa+14]=rc.z,sa[qa+15]=rc.w,qa+=16;j.bindBuffer(j.ARRAY_BUFFER,fa.__webglTangentBuffer);j.bufferData(j.ARRAY_BUFFER,sa,ab)}if(vd&&fd){for(G=0,T=ma.length;G<T;G++)if(L=Da[ma[G]],jc=L.vertexNormals,Ob=L.normal,3===jc.length&&Fc)for(la=0;3>la;la++)Vb=jc[la],ib[Ra]=Vb.x,ib[Ra+1]=Vb.y,
-ib[Ra+2]=Vb.z,Ra+=3;else for(la=0;3>la;la++)ib[Ra]=Ob.x,ib[Ra+1]=Ob.y,ib[Ra+2]=Ob.z,Ra+=3;for(G=0,T=na.length;G<T;G++)if(L=Da[na[G]],jc=L.vertexNormals,Ob=L.normal,4===jc.length&&Fc)for(la=0;4>la;la++)Vb=jc[la],ib[Ra]=Vb.x,ib[Ra+1]=Vb.y,ib[Ra+2]=Vb.z,Ra+=3;else for(la=0;4>la;la++)ib[Ra]=Ob.x,ib[Ra+1]=Ob.y,ib[Ra+2]=Ob.z,Ra+=3;j.bindBuffer(j.ARRAY_BUFFER,fa.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,ib,ab)}if(jd&&ad&&gd){for(G=0,T=ma.length;G<T;G++)if(kb=ma[G],L=Da[kb],kc=ad[kb],void 0!==kc)for(la=
-0;3>la;la++)mc=kc[la],wc[Jb]=mc.u,wc[Jb+1]=mc.v,Jb+=2;for(G=0,T=na.length;G<T;G++)if(kb=na[G],L=Da[kb],kc=ad[kb],void 0!==kc)for(la=0;4>la;la++)mc=kc[la],wc[Jb]=mc.u,wc[Jb+1]=mc.v,Jb+=2;0<Jb&&(j.bindBuffer(j.ARRAY_BUFFER,fa.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,wc,ab))}if(jd&&bd&&gd){for(G=0,T=ma.length;G<T;G++)if(kb=ma[G],L=Da[kb],lc=bd[kb],void 0!==lc)for(la=0;3>la;la++)nc=lc[la],xc[Kb]=nc.u,xc[Kb+1]=nc.v,Kb+=2;for(G=0,T=na.length;G<T;G++)if(kb=na[G],L=Da[kb],lc=bd[kb],void 0!==lc)for(la=
-0;4>la;la++)nc=lc[la],xc[Kb]=nc.u,xc[Kb+1]=nc.v,Kb+=2;0<Kb&&(j.bindBuffer(j.ARRAY_BUFFER,fa.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,xc,ab))}if(ud){for(G=0,T=ma.length;G<T;G++)L=Da[ma[G]],Eb[hb]=Aa,Eb[hb+1]=Aa+1,Eb[hb+2]=Aa+2,hb+=3,cb[Ua]=Aa,cb[Ua+1]=Aa+1,cb[Ua+2]=Aa,cb[Ua+3]=Aa+2,cb[Ua+4]=Aa+1,cb[Ua+5]=Aa+2,Ua+=6,Aa+=3;for(G=0,T=na.length;G<T;G++)L=Da[na[G]],Eb[hb]=Aa,Eb[hb+1]=Aa+1,Eb[hb+2]=Aa+3,Eb[hb+3]=Aa+1,Eb[hb+4]=Aa+2,Eb[hb+5]=Aa+3,hb+=6,cb[Ua]=Aa,cb[Ua+1]=Aa+1,cb[Ua+2]=Aa,cb[Ua+3]=Aa+
-3,cb[Ua+4]=Aa+1,cb[Ua+5]=Aa+2,cb[Ua+6]=Aa+2,cb[Ua+7]=Aa+3,Ua+=8,Aa+=4;j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,fa.__webglFaceBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,Eb,ab);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,fa.__webglLineBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,cb,ab)}if($c)for(la=0,hd=$c.length;la<hd;la++)if(x=$c[la],x.__original.needsUpdate){z=0;if(1===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){for(G=0,T=ma.length;G<T;G++)L=Da[ma[G]],x.array[z]=x.value[L.a],x.array[z+1]=x.value[L.b],
-x.array[z+2]=x.value[L.c],z+=3;for(G=0,T=na.length;G<T;G++)L=Da[na[G]],x.array[z]=x.value[L.a],x.array[z+1]=x.value[L.b],x.array[z+2]=x.value[L.c],x.array[z+3]=x.value[L.d],z+=4}else{if("faces"===x.boundTo){for(G=0,T=ma.length;G<T;G++)bb=x.value[ma[G]],x.array[z]=bb,x.array[z+1]=bb,x.array[z+2]=bb,z+=3;for(G=0,T=na.length;G<T;G++)bb=x.value[na[G]],x.array[z]=bb,x.array[z+1]=bb,x.array[z+2]=bb,x.array[z+3]=bb,z+=4}}else if(2===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){for(G=0,T=ma.length;G<
-T;G++)L=Da[ma[G]],W=x.value[L.a],X=x.value[L.b],Y=x.value[L.c],x.array[z]=W.x,x.array[z+1]=W.y,x.array[z+2]=X.x,x.array[z+3]=X.y,x.array[z+4]=Y.x,x.array[z+5]=Y.y,z+=6;for(G=0,T=na.length;G<T;G++)L=Da[na[G]],W=x.value[L.a],X=x.value[L.b],Y=x.value[L.c],pa=x.value[L.d],x.array[z]=W.x,x.array[z+1]=W.y,x.array[z+2]=X.x,x.array[z+3]=X.y,x.array[z+4]=Y.x,x.array[z+5]=Y.y,x.array[z+6]=pa.x,x.array[z+7]=pa.y,z+=8}else{if("faces"===x.boundTo){for(G=0,T=ma.length;G<T;G++)Y=X=W=bb=x.value[ma[G]],x.array[z]=
-W.x,x.array[z+1]=W.y,x.array[z+2]=X.x,x.array[z+3]=X.y,x.array[z+4]=Y.x,x.array[z+5]=Y.y,z+=6;for(G=0,T=na.length;G<T;G++)pa=Y=X=W=bb=x.value[na[G]],x.array[z]=W.x,x.array[z+1]=W.y,x.array[z+2]=X.x,x.array[z+3]=X.y,x.array[z+4]=Y.x,x.array[z+5]=Y.y,x.array[z+6]=pa.x,x.array[z+7]=pa.y,z+=8}}else if(3===x.size){var ga;ga="c"===x.type?["r","g","b"]:["x","y","z"];if(void 0===x.boundTo||"vertices"===x.boundTo){for(G=0,T=ma.length;G<T;G++)L=Da[ma[G]],W=x.value[L.a],X=x.value[L.b],Y=x.value[L.c],x.array[z]=
-W[ga[0]],x.array[z+1]=W[ga[1]],x.array[z+2]=W[ga[2]],x.array[z+3]=X[ga[0]],x.array[z+4]=X[ga[1]],x.array[z+5]=X[ga[2]],x.array[z+6]=Y[ga[0]],x.array[z+7]=Y[ga[1]],x.array[z+8]=Y[ga[2]],z+=9;for(G=0,T=na.length;G<T;G++)L=Da[na[G]],W=x.value[L.a],X=x.value[L.b],Y=x.value[L.c],pa=x.value[L.d],x.array[z]=W[ga[0]],x.array[z+1]=W[ga[1]],x.array[z+2]=W[ga[2]],x.array[z+3]=X[ga[0]],x.array[z+4]=X[ga[1]],x.array[z+5]=X[ga[2]],x.array[z+6]=Y[ga[0]],x.array[z+7]=Y[ga[1]],x.array[z+8]=Y[ga[2]],x.array[z+9]=pa[ga[0]],
-x.array[z+10]=pa[ga[1]],x.array[z+11]=pa[ga[2]],z+=12}else if("faces"===x.boundTo){for(G=0,T=ma.length;G<T;G++)Y=X=W=bb=x.value[ma[G]],x.array[z]=W[ga[0]],x.array[z+1]=W[ga[1]],x.array[z+2]=W[ga[2]],x.array[z+3]=X[ga[0]],x.array[z+4]=X[ga[1]],x.array[z+5]=X[ga[2]],x.array[z+6]=Y[ga[0]],x.array[z+7]=Y[ga[1]],x.array[z+8]=Y[ga[2]],z+=9;for(G=0,T=na.length;G<T;G++)pa=Y=X=W=bb=x.value[na[G]],x.array[z]=W[ga[0]],x.array[z+1]=W[ga[1]],x.array[z+2]=W[ga[2]],x.array[z+3]=X[ga[0]],x.array[z+4]=X[ga[1]],x.array[z+
-5]=X[ga[2]],x.array[z+6]=Y[ga[0]],x.array[z+7]=Y[ga[1]],x.array[z+8]=Y[ga[2]],x.array[z+9]=pa[ga[0]],x.array[z+10]=pa[ga[1]],x.array[z+11]=pa[ga[2]],z+=12}}else if(4===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){for(G=0,T=ma.length;G<T;G++)L=Da[ma[G]],W=x.value[L.a],X=x.value[L.b],Y=x.value[L.c],x.array[z]=W.x,x.array[z+1]=W.y,x.array[z+2]=W.z,x.array[z+3]=W.w,x.array[z+4]=X.x,x.array[z+5]=X.y,x.array[z+6]=X.z,x.array[z+7]=X.w,x.array[z+8]=Y.x,x.array[z+9]=Y.y,x.array[z+10]=Y.z,x.array[z+
-11]=Y.w,z+=12;for(G=0,T=na.length;G<T;G++)L=Da[na[G]],W=x.value[L.a],X=x.value[L.b],Y=x.value[L.c],pa=x.value[L.d],x.array[z]=W.x,x.array[z+1]=W.y,x.array[z+2]=W.z,x.array[z+3]=W.w,x.array[z+4]=X.x,x.array[z+5]=X.y,x.array[z+6]=X.z,x.array[z+7]=X.w,x.array[z+8]=Y.x,x.array[z+9]=Y.y,x.array[z+10]=Y.z,x.array[z+11]=Y.w,x.array[z+12]=pa.x,x.array[z+13]=pa.y,x.array[z+14]=pa.z,x.array[z+15]=pa.w,z+=16}else if("faces"===x.boundTo){for(G=0,T=ma.length;G<T;G++)Y=X=W=bb=x.value[ma[G]],x.array[z]=W.x,x.array[z+
-1]=W.y,x.array[z+2]=W.z,x.array[z+3]=W.w,x.array[z+4]=X.x,x.array[z+5]=X.y,x.array[z+6]=X.z,x.array[z+7]=X.w,x.array[z+8]=Y.x,x.array[z+9]=Y.y,x.array[z+10]=Y.z,x.array[z+11]=Y.w,z+=12;for(G=0,T=na.length;G<T;G++)pa=Y=X=W=bb=x.value[na[G]],x.array[z]=W.x,x.array[z+1]=W.y,x.array[z+2]=W.z,x.array[z+3]=W.w,x.array[z+4]=X.x,x.array[z+5]=X.y,x.array[z+6]=X.z,x.array[z+7]=X.w,x.array[z+8]=Y.x,x.array[z+9]=Y.y,x.array[z+10]=Y.z,x.array[z+11]=Y.w,x.array[z+12]=pa.x,x.array[z+13]=pa.y,x.array[z+14]=pa.z,
-x.array[z+15]=pa.w,z+=16}j.bindBuffer(j.ARRAY_BUFFER,x.buffer);j.bufferData(j.ARRAY_BUFFER,x.array,ab)}td&&(delete fa.__inittedArrays,delete fa.__colorArray,delete fa.__normalArray,delete fa.__tangentArray,delete fa.__uvArray,delete fa.__uv2Array,delete fa.__faceArray,delete fa.__vertexArray,delete fa.__lineArray,delete fa.__skinVertexAArray,delete fa.__skinVertexBArray,delete fa.__skinIndexArray,delete fa.__skinWeightArray)}}ja.__dirtyVertices=!1;ja.__dirtyMorphTargets=!1;ja.__dirtyElements=!1;ja.__dirtyUvs=
-!1;ja.__dirtyNormals=!1;ja.__dirtyColors=!1;ja.__dirtyTangents=!1;Xa.attributes&&m(Xa)}else if(nb instanceof THREE.Ribbon){if(ja.__dirtyVertices||ja.__dirtyColors){var Zb=ja,kd=j.DYNAMIC_DRAW,yc=void 0,zc=void 0,Kc=void 0,$b=void 0,Lc=void 0,ld=Zb.vertices,md=Zb.colors,zd=ld.length,Ad=md.length,Mc=Zb.__vertexArray,Nc=Zb.__colorArray,Bd=Zb.__dirtyColors;if(Zb.__dirtyVertices){for(yc=0;yc<zd;yc++)Kc=ld[yc].position,$b=3*yc,Mc[$b]=Kc.x,Mc[$b+1]=Kc.y,Mc[$b+2]=Kc.z;j.bindBuffer(j.ARRAY_BUFFER,Zb.__webglVertexBuffer);
-j.bufferData(j.ARRAY_BUFFER,Mc,kd)}if(Bd){for(zc=0;zc<Ad;zc++)Lc=md[zc],$b=3*zc,Nc[$b]=Lc.r,Nc[$b+1]=Lc.g,Nc[$b+2]=Lc.b;j.bindBuffer(j.ARRAY_BUFFER,Zb.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,Nc,kd)}}ja.__dirtyVertices=!1;ja.__dirtyColors=!1}else if(nb instanceof THREE.Line){Xa=c(nb,qc);ic=Xa.attributes&&p(Xa);if(ja.__dirtyVertices||ja.__dirtyColors||ic){var Lb=ja,cd=j.DYNAMIC_DRAW,Ac=void 0,Bc=void 0,Oc=void 0,xa=void 0,Pc=void 0,nd=Lb.vertices,od=Lb.colors,Cd=nd.length,Dd=od.length,Qc=Lb.__vertexArray,
-Rc=Lb.__colorArray,Ed=Lb.__dirtyColors,dd=Lb.__webglCustomAttributesList,Sc=void 0,pd=void 0,Pa=void 0,oc=void 0,Ya=void 0,ra=void 0;if(Lb.__dirtyVertices){for(Ac=0;Ac<Cd;Ac++)Oc=nd[Ac].position,xa=3*Ac,Qc[xa]=Oc.x,Qc[xa+1]=Oc.y,Qc[xa+2]=Oc.z;j.bindBuffer(j.ARRAY_BUFFER,Lb.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Qc,cd)}if(Ed){for(Bc=0;Bc<Dd;Bc++)Pc=od[Bc],xa=3*Bc,Rc[xa]=Pc.r,Rc[xa+1]=Pc.g,Rc[xa+2]=Pc.b;j.bindBuffer(j.ARRAY_BUFFER,Lb.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,Rc,cd)}if(dd)for(Sc=
-0,pd=dd.length;Sc<pd;Sc++)if(ra=dd[Sc],ra.needsUpdate&&(void 0===ra.boundTo||"vertices"===ra.boundTo)){xa=0;oc=ra.value.length;if(1===ra.size)for(Pa=0;Pa<oc;Pa++)ra.array[Pa]=ra.value[Pa];else if(2===ra.size)for(Pa=0;Pa<oc;Pa++)Ya=ra.value[Pa],ra.array[xa]=Ya.x,ra.array[xa+1]=Ya.y,xa+=2;else if(3===ra.size)if("c"===ra.type)for(Pa=0;Pa<oc;Pa++)Ya=ra.value[Pa],ra.array[xa]=Ya.r,ra.array[xa+1]=Ya.g,ra.array[xa+2]=Ya.b,xa+=3;else for(Pa=0;Pa<oc;Pa++)Ya=ra.value[Pa],ra.array[xa]=Ya.x,ra.array[xa+1]=Ya.y,
-ra.array[xa+2]=Ya.z,xa+=3;else if(4===ra.size)for(Pa=0;Pa<oc;Pa++)Ya=ra.value[Pa],ra.array[xa]=Ya.x,ra.array[xa+1]=Ya.y,ra.array[xa+2]=Ya.z,ra.array[xa+3]=Ya.w,xa+=4;j.bindBuffer(j.ARRAY_BUFFER,ra.buffer);j.bufferData(j.ARRAY_BUFFER,ra.array,cd)}}ja.__dirtyVertices=!1;ja.__dirtyColors=!1;Xa.attributes&&m(Xa)}else if(nb instanceof THREE.ParticleSystem)Xa=c(nb,qc),ic=Xa.attributes&&p(Xa),(ja.__dirtyVertices||ja.__dirtyColors||nb.sortParticles||ic)&&f(ja,j.DYNAMIC_DRAW,nb),ja.__dirtyVertices=!1,ja.__dirtyColors=
-!1,Xa.attributes&&m(Xa)}};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 m,l;f=k=0;for(m=0,l=b.length;m<l;m++)e=b[m],e.onlyShadow||(e instanceof THREE.DirectionalLight&&f++,e instanceof THREE.PointLight&&k++,e instanceof THREE.SpotLight&&k++);k+f<=M?m=f:(m=Math.ceil(M*f/(k+f)),k=M-m);e=m;f=k;var n=0;for(k=0,m=b.length;k<m;k++)l=b[k],l.castShadow&&(l instanceof THREE.SpotLight&&n++,l instanceof THREE.DirectionalLight&&!l.shadowCascade&&n++);var o=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)o=d.bones.length;
-var p;a:{m=a.fragmentShader;l=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,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:e,maxPointLights:f,maxBones:o,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,
-shadowMapCascade:this.shadowMapCascade,maxShadows:n,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround},q,d=[];i?d.push(i):(d.push(m),d.push(l));for(q in c)d.push(q),d.push(c[q]);i=d.join();for(q=0,d=Z.length;q<d;q++)if(Z[q].code===i){p=Z[q].program;break a}q=j.createProgram();d=[0<za?"#define VERTEX_TEXTURES":"",H.gammaInput?"#define GAMMA_INPUT":"",H.gammaOutput?"#define GAMMA_OUTPUT":"",H.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.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":
-"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute 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;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\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:"",H.gammaInput?"#define GAMMA_INPUT":"",H.gammaOutput?"#define GAMMA_OUTPUT":"",H.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.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");j.attachShader(q,t("fragment",e+m));j.attachShader(q,t("vertex",d+l));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,boneGlobalMatrices,morphTargetInfluences".split(",");for(r in k)d.push(r);r=d;for(d=0,k=r.length;d<k;d++)m=r[d],q.uniforms[m]=j.getUniformLocation(q,m);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,skinWeight".split(",");
-for(r=0;r<c.maxMorphTargets;r++)d.push("morphTarget"+r);for(r=0;r<c.maxMorphNormals;r++)d.push("morphNormal"+r);for(p in b)d.push(p);p=d;for(r=0,b=p.length;r<b;r++)c=p[r],q.attributes[c]=j.getAttribLocation(q,c);q.id=Z.length;Z.push({program:q,code:i});H.info.memory.programs=Z.length;p=q}a.program=p;p=a.program.attributes;0<=p.position&&j.enableVertexAttribArray(p.position);0<=p.color&&j.enableVertexAttribArray(p.color);0<=p.normal&&j.enableVertexAttribArray(p.normal);0<=p.tangent&&j.enableVertexAttribArray(p.tangent);
+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);var d=void 0,e=void 0;if(c.numMorphTargets)for(d=0,e=c.numMorphTargets;d<e;d++)j.deleteBuffer(c.__webglMorphTargetsBuffers[d]);if(c.numMorphNormals)for(d=
+0,e=c.numMorphNormals;d<e;d++)j.deleteBuffer(c.__webglMorphNormalsBuffers[d]);if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)j.deleteBuffer(c.__webglCustomAttributesList[d].buffer);G.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),G.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),
+G.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,j.deleteBuffer(a.__webglVertexBuffer),j.deleteBuffer(a.__webglColorBuffer),G.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,j.deleteTexture(a.__webglTexture),G.info.memory.textures--};this.updateShadowMap=function(a,b){z=null;Q=N=ca=Y=ba=-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,m,k,n,l,o=3*a.count;for(l=0;l<o;l+=9)c=a.normalArray,d=c[l],e=c[l+1],f=c[l+2],g=c[l+3],i=c[l+
+4],k=c[l+5],h=c[l+6],m=c[l+7],n=c[l+8],d=(d+g+h)/3,e=(e+i+m)/3,f=(f+k+n)/3,c[l]=d,c[l+1]=e,c[l+2]=f,c[l+3]=d,c[l+4]=e,c[l+5]=f,c[l+6]=d,c[l+7]=e,c[l+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!==N&&(N=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),G.info.render.calls++,G.info.render.vertices+=f[d].count,
+G.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!==N&&(N=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),d.morphNormals&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[i[g]]),j.vertexAttribPointer(c["morphNormal"+
+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,o=h.length;g=0;for(-1!==f.morphTargetBase&&(i[f.morphTargetBase]=!0);g<d.numSupportedMorphTargets;){for(n=0;n<o;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);d.morphNormals&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[l]),j.vertexAttribPointer(c["morphNormal"+
+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!==na&&(j.lineWidth(d),na=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)),G.info.render.calls++,G.info.render.vertices+=e.__webglFaceCount,G.info.render.faces+=e.__webglFaceCount/3):f instanceof THREE.Line?(f=f.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==na&&(j.lineWidth(d),na=d),j.drawArrays(f,0,e.__webglLineCount),G.info.render.calls++):f instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),G.info.render.calls++,G.info.render.points+=e.__webglParticleCount):f instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,
+0,e.__webglVertexCount),G.info.render.calls++)}};this.render=function(a,b,c,d){var e,f,m,n,l=a.lights,o=a.fog;Q=-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);G.info.render.calls=0;G.info.render.vertices=0;G.info.render.faces=0;G.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);Wa.multiply(b.projectionMatrix,b.matrixWorldInverse);db.setFromMatrix(Wa);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(f=n[d],m=f.object,f.render=!1,m.visible&&(!(m instanceof
+THREE.Mesh||m instanceof THREE.ParticleSystem)||!m.frustumCulled||db.contains(m))){m.matrixWorld.flattenToArray(m._objectMatrixArray);r(m,b);var p=f,q=p.object,t=p.buffer,E=void 0,E=E=void 0,E=q.material;if(E instanceof THREE.MeshFaceMaterial){if(E=t.materialIndex,0<=E)E=q.geometry.materials[E],E.transparent?(p.transparent=E,p.opaque=null):(p.opaque=E,p.transparent=null)}else if(E)E.transparent?(p.transparent=E,p.opaque=null):(p.opaque=E,p.transparent=null);f.render=!0;if(this.sortObjects)m.renderDepth?
+f.z=m.renderDepth:($a.copy(m.position),Wa.multiplyVector3($a),f.z=$a.z)}this.sortObjects&&n.sort(g);n=a.__webglObjectsImmediate;for(d=0,e=n.length;d<e;d++)if(f=n[d],m=f.object,m.visible)m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),r(m,b),m=f.object.material,m.transparent?(f.transparent=m,f.opaque=null):(f.opaque=m,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,l,o,!0,a.overrideMaterial),k(a.__webglObjectsImmediate,"",b,l,o,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),i(a.__webglObjects,!0,"opaque",b,l,o,!1),k(a.__webglObjectsImmediate,"opaque",b,l,o,!1),i(a.__webglObjects,!1,"transparent",b,l,o,!0),k(a.__webglObjectsImmediate,"transparent",b,l,o,!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);N=-1;G.setObjectFaces(e);e.immediateRenderCallback?
+e.immediateRenderCallback(f,j,db):e.render(function(a){G.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,m=void 0,k=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(m=g.geometry,m instanceof THREE.Geometry){if(void 0===m.geometryGroups){var r=m,s=void 0,t=void 0,E=void 0,u=void 0,w=void 0,v=void 0,z=void 0,Q={},C=r.morphTargets.length,D=r.morphNormals.length;r.geometryGroups={};for(s=0,t=r.faces.length;s<t;s++)E=r.faces[s],u=E.materialIndex,v=void 0!==u?u:-1,void 0===Q[v]&&(Q[v]={hash:v,counter:0}),z=Q[v].hash+"_"+Q[v].counter,void 0===r.geometryGroups[z]&&(r.geometryGroups[z]=
+{faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:C,numMorphNormals:D}),w=E instanceof THREE.Face3?3:4,65535<r.geometryGroups[z].vertices+w&&(Q[v].counter+=1,z=Q[v].hash+"_"+Q[v].counter,void 0===r.geometryGroups[z]&&(r.geometryGroups[z]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:C,numMorphNormals:D})),E instanceof THREE.Face3?r.geometryGroups[z].faces3.push(s):r.geometryGroups[z].faces4.push(s),r.geometryGroups[z].vertices+=w;r.geometryGroupsList=[];var A=void 0;
+for(A in r.geometryGroups)r.geometryGroups[A].id=ia++,r.geometryGroupsList.push(r.geometryGroups[A])}for(i in m.geometryGroups)if(k=m.geometryGroups[i],!k.__webglVertexBuffer){var N=k;N.__webglVertexBuffer=j.createBuffer();N.__webglNormalBuffer=j.createBuffer();N.__webglTangentBuffer=j.createBuffer();N.__webglColorBuffer=j.createBuffer();N.__webglUVBuffer=j.createBuffer();N.__webglUV2Buffer=j.createBuffer();N.__webglSkinVertexABuffer=j.createBuffer();N.__webglSkinVertexBBuffer=j.createBuffer();N.__webglSkinIndicesBuffer=
+j.createBuffer();N.__webglSkinWeightsBuffer=j.createBuffer();N.__webglFaceBuffer=j.createBuffer();N.__webglLineBuffer=j.createBuffer();var B=void 0,I=void 0;if(N.numMorphTargets){N.__webglMorphTargetsBuffers=[];for(B=0,I=N.numMorphTargets;B<I;B++)N.__webglMorphTargetsBuffers.push(j.createBuffer())}if(N.numMorphNormals){N.__webglMorphNormalsBuffers=[];for(B=0,I=N.numMorphNormals;B<I;B++)N.__webglMorphNormalsBuffers.push(j.createBuffer())}G.info.memory.geometries++;var H=k,L=g,K=L.geometry,ea=H.faces3,
+aa=H.faces4,$=3*ea.length+4*aa.length,O=1*ea.length+2*aa.length,Y=3*ea.length+4*aa.length,ba=c(L,H),ca=e(ba),P=d(ba),S=ba.vertexColors?ba.vertexColors:!1;H.__vertexArray=new Float32Array(3*$);if(P)H.__normalArray=new Float32Array(3*$);if(K.hasTangents)H.__tangentArray=new Float32Array(4*$);if(S)H.__colorArray=new Float32Array(3*$);if(ca){if(0<K.faceUvs.length||0<K.faceVertexUvs.length)H.__uvArray=new Float32Array(2*$);if(1<K.faceUvs.length||1<K.faceVertexUvs.length)H.__uv2Array=new Float32Array(2*
+$)}if(L.geometry.skinWeights.length&&L.geometry.skinIndices.length)H.__skinVertexAArray=new Float32Array(4*$),H.__skinVertexBArray=new Float32Array(4*$),H.__skinIndexArray=new Float32Array(4*$),H.__skinWeightArray=new Float32Array(4*$);H.__faceArray=new Uint16Array(3*O);H.__lineArray=new Uint16Array(2*Y);var fa=void 0,X=void 0;if(H.numMorphTargets){H.__morphTargetsArrays=[];for(fa=0,X=H.numMorphTargets;fa<X;fa++)H.__morphTargetsArrays.push(new Float32Array(3*$))}if(H.numMorphNormals){H.__morphNormalsArrays=
+[];for(fa=0,X=H.numMorphNormals;fa<X;fa++)H.__morphNormalsArrays.push(new Float32Array(3*$))}H.__webglFaceCount=3*O;H.__webglLineCount=2*Y;if(ba.attributes){if(void 0===H.__webglCustomAttributesList)H.__webglCustomAttributesList=[];var Ua=void 0;for(Ua in ba.attributes){var Ka=ba.attributes[Ua],na={},qa;for(qa in Ka)na[qa]=Ka[qa];if(!na.__webglInitialized||na.createUniqueBuffers){na.__webglInitialized=!0;var ra=1;"v2"===na.type?ra=2:"v3"===na.type?ra=3:"v4"===na.type?ra=4:"c"===na.type&&(ra=3);na.size=
+ra;na.array=new Float32Array($*ra);na.buffer=j.createBuffer();na.buffer.belongsToAttribute=Ua;Ka.needsUpdate=!0;na.__original=Ka}H.__webglCustomAttributesList.push(na)}}H.__inittedArrays=!0;m.__dirtyVertices=!0;m.__dirtyMorphTargets=!0;m.__dirtyElements=!0;m.__dirtyUvs=!0;m.__dirtyNormals=!0;m.__dirtyTangents=!0;m.__dirtyColors=!0}}}else if(g instanceof THREE.Ribbon){if(m=g.geometry,!m.__webglVertexBuffer){var Ha=m;Ha.__webglVertexBuffer=j.createBuffer();Ha.__webglColorBuffer=j.createBuffer();G.info.memory.geometries++;
+var ta=m,Aa=ta.vertices.length;ta.__vertexArray=new Float32Array(3*Aa);ta.__colorArray=new Float32Array(3*Aa);ta.__webglVertexCount=Aa;m.__dirtyVertices=!0;m.__dirtyColors=!0}}else if(g instanceof THREE.Line){if(m=g.geometry,!m.__webglVertexBuffer){var La=m;La.__webglVertexBuffer=j.createBuffer();La.__webglColorBuffer=j.createBuffer();G.info.memory.geometries++;var Fa=m,ib=g,Wa=Fa.vertices.length;Fa.__vertexArray=new Float32Array(3*Wa);Fa.__colorArray=new Float32Array(3*Wa);Fa.__webglLineCount=Wa;
+b(Fa,ib);m.__dirtyVertices=!0;m.__dirtyColors=!0}}else if(g instanceof THREE.ParticleSystem&&(m=g.geometry,!m.__webglVertexBuffer)){var $a=m;$a.__webglVertexBuffer=j.createBuffer();$a.__webglColorBuffer=j.createBuffer();G.info.geometries++;var Va=m,lb=g,db=Va.vertices.length;Va.__vertexArray=new Float32Array(3*db);Va.__colorArray=new Float32Array(3*db);Va.__sortArray=[];Va.__webglParticleCount=db;b(Va,lb);m.__dirtyVertices=!0;m.__dirtyColors=!0}if(!g.__webglActive){if(g instanceof THREE.Mesh)if(m=
+g.geometry,m instanceof THREE.BufferGeometry)l(h.__webglObjects,m,g);else for(i in m.geometryGroups)k=m.geometryGroups[i],l(h.__webglObjects,k,g);else g instanceof THREE.Ribbon||g instanceof THREE.Line||g instanceof THREE.ParticleSystem?(m=g.geometry,l(h.__webglObjects,m,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 fb=a.__objectsRemoved[0],Fc=a;fb instanceof THREE.Mesh||fb instanceof THREE.ParticleSystem||fb instanceof THREE.Ribbon||fb instanceof THREE.Line?o(Fc.__webglObjects,fb):fb instanceof THREE.Sprite?q(Fc.__webglSprites,fb):fb instanceof THREE.LensFlare?q(Fc.__webglFlares,fb):(fb instanceof THREE.MarchingCubes||fb.immediateRenderCallback)&&o(Fc.__webglObjectsImmediate,fb);fb.__webglActive=
+!1;a.__objectsRemoved.splice(0,1)}for(var Wc=0,rd=a.__webglObjects.length;Wc<rd;Wc++){var nb=a.__webglObjects[Wc].object,ja=nb.geometry,qc=void 0,ic=void 0,Ya=void 0;if(nb instanceof THREE.Mesh)if(ja instanceof THREE.BufferGeometry)ja.__dirtyVertices=!1,ja.__dirtyElements=!1,ja.__dirtyUvs=!1,ja.__dirtyNormals=!1,ja.__dirtyColors=!1;else{for(var Xc=0,sd=ja.geometryGroupsList.length;Xc<sd;Xc++)if(qc=ja.geometryGroupsList[Xc],Ya=c(nb,qc),ic=Ya.attributes&&p(Ya),ja.__dirtyVertices||ja.__dirtyMorphTargets||
+ja.__dirtyElements||ja.__dirtyUvs||ja.__dirtyNormals||ja.__dirtyColors||ja.__dirtyTangents||ic){var ga=qc,td=nb,ab=j.DYNAMIC_DRAW,ud=!ja.dynamic,bc=Ya;if(ga.__inittedArrays){var gd=d(bc),Yc=bc.vertexColors?bc.vertexColors:!1,hd=e(bc),Gc=gd===THREE.SmoothShading,F=void 0,T=void 0,kb=void 0,M=void 0,jc=void 0,Ob=void 0,ob=void 0,Hc=void 0,Hb=void 0,kc=void 0,lc=void 0,U=void 0,V=void 0,W=void 0,oa=void 0,pb=void 0,qb=void 0,rb=void 0,rc=void 0,sb=void 0,tb=void 0,ub=void 0,sc=void 0,vb=void 0,wb=void 0,
+xb=void 0,tc=void 0,yb=void 0,zb=void 0,Ab=void 0,uc=void 0,Bb=void 0,Cb=void 0,Db=void 0,vc=void 0,Pb=void 0,Qb=void 0,Rb=void 0,Ic=void 0,Sb=void 0,Tb=void 0,Ub=void 0,Jc=void 0,ka=void 0,id=void 0,Vb=void 0,mc=void 0,nc=void 0,Ma=void 0,jd=void 0,Ia=void 0,Ja=void 0,Wb=void 0,Ib=void 0,Ba=0,Ea=0,Jb=0,Kb=0,gb=0,Ra=0,pa=0,Sa=0,Ca=0,J=0,da=0,y=0,bb=void 0,Na=ga.__vertexArray,wc=ga.__uvArray,xc=ga.__uv2Array,hb=ga.__normalArray,ua=ga.__tangentArray,Oa=ga.__colorArray,va=ga.__skinVertexAArray,wa=ga.__skinVertexBArray,
+xa=ga.__skinIndexArray,ya=ga.__skinWeightArray,Zc=ga.__morphTargetsArrays,$c=ga.__morphNormalsArrays,ad=ga.__webglCustomAttributesList,x=void 0,Eb=ga.__faceArray,cb=ga.__lineArray,Ta=td.geometry,vd=Ta.__dirtyElements,kd=Ta.__dirtyUvs,wd=Ta.__dirtyNormals,xd=Ta.__dirtyTangents,yd=Ta.__dirtyColors,zd=Ta.__dirtyMorphTargets,cc=Ta.vertices,la=ga.faces3,ma=ga.faces4,Da=Ta.faces,bd=Ta.faceVertexUvs[0],cd=Ta.faceVertexUvs[1],dc=Ta.skinVerticesA,ec=Ta.skinVerticesB,fc=Ta.skinIndices,Xb=Ta.skinWeights,Yb=
+Ta.morphTargets,Kc=Ta.morphNormals;if(Ta.__dirtyVertices){for(F=0,T=la.length;F<T;F++)M=Da[la[F]],U=cc[M.a].position,V=cc[M.b].position,W=cc[M.c].position,Na[Ea]=U.x,Na[Ea+1]=U.y,Na[Ea+2]=U.z,Na[Ea+3]=V.x,Na[Ea+4]=V.y,Na[Ea+5]=V.z,Na[Ea+6]=W.x,Na[Ea+7]=W.y,Na[Ea+8]=W.z,Ea+=9;for(F=0,T=ma.length;F<T;F++)M=Da[ma[F]],U=cc[M.a].position,V=cc[M.b].position,W=cc[M.c].position,oa=cc[M.d].position,Na[Ea]=U.x,Na[Ea+1]=U.y,Na[Ea+2]=U.z,Na[Ea+3]=V.x,Na[Ea+4]=V.y,Na[Ea+5]=V.z,Na[Ea+6]=W.x,Na[Ea+7]=W.y,Na[Ea+
+8]=W.z,Na[Ea+9]=oa.x,Na[Ea+10]=oa.y,Na[Ea+11]=oa.z,Ea+=12;j.bindBuffer(j.ARRAY_BUFFER,ga.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Na,ab)}if(zd)for(Ma=0,jd=Yb.length;Ma<jd;Ma++){da=0;for(F=0,T=la.length;F<T;F++){Wb=la[F];M=Da[Wb];U=Yb[Ma].vertices[M.a].position;V=Yb[Ma].vertices[M.b].position;W=Yb[Ma].vertices[M.c].position;Ia=Zc[Ma];Ia[da]=U.x;Ia[da+1]=U.y;Ia[da+2]=U.z;Ia[da+3]=V.x;Ia[da+4]=V.y;Ia[da+5]=V.z;Ia[da+6]=W.x;Ia[da+7]=W.y;Ia[da+8]=W.z;if(bc.morphNormals)Gc?(Ib=Kc[Ma].vertexNormals[Wb],
+sb=Ib.a,tb=Ib.b,ub=Ib.c):ub=tb=sb=Kc[Ma].faceNormals[Wb],Ja=$c[Ma],Ja[da]=sb.x,Ja[da+1]=sb.y,Ja[da+2]=sb.z,Ja[da+3]=tb.x,Ja[da+4]=tb.y,Ja[da+5]=tb.z,Ja[da+6]=ub.x,Ja[da+7]=ub.y,Ja[da+8]=ub.z;da+=9}for(F=0,T=ma.length;F<T;F++){Wb=ma[F];M=Da[Wb];U=Yb[Ma].vertices[M.a].position;V=Yb[Ma].vertices[M.b].position;W=Yb[Ma].vertices[M.c].position;oa=Yb[Ma].vertices[M.d].position;Ia=Zc[Ma];Ia[da]=U.x;Ia[da+1]=U.y;Ia[da+2]=U.z;Ia[da+3]=V.x;Ia[da+4]=V.y;Ia[da+5]=V.z;Ia[da+6]=W.x;Ia[da+7]=W.y;Ia[da+8]=W.z;Ia[da+
+9]=oa.x;Ia[da+10]=oa.y;Ia[da+11]=oa.z;if(bc.morphNormals)Gc?(Ib=Kc[Ma].vertexNormals[Wb],sb=Ib.a,tb=Ib.b,ub=Ib.c,sc=Ib.d):sc=ub=tb=sb=Kc[Ma].faceNormals[Wb],Ja=$c[Ma],Ja[da]=sb.x,Ja[da+1]=sb.y,Ja[da+2]=sb.z,Ja[da+3]=tb.x,Ja[da+4]=tb.y,Ja[da+5]=tb.z,Ja[da+6]=ub.x,Ja[da+7]=ub.y,Ja[da+8]=ub.z,Ja[da+9]=sc.x,Ja[da+10]=sc.y,Ja[da+11]=sc.z;da+=12}j.bindBuffer(j.ARRAY_BUFFER,ga.__webglMorphTargetsBuffers[Ma]);j.bufferData(j.ARRAY_BUFFER,Zc[Ma],ab);bc.morphNormals&&(j.bindBuffer(j.ARRAY_BUFFER,ga.__webglMorphNormalsBuffers[Ma]),
+j.bufferData(j.ARRAY_BUFFER,$c[Ma],ab))}if(Xb.length){for(F=0,T=la.length;F<T;F++)M=Da[la[F]],yb=Xb[M.a],zb=Xb[M.b],Ab=Xb[M.c],ya[J]=yb.x,ya[J+1]=yb.y,ya[J+2]=yb.z,ya[J+3]=yb.w,ya[J+4]=zb.x,ya[J+5]=zb.y,ya[J+6]=zb.z,ya[J+7]=zb.w,ya[J+8]=Ab.x,ya[J+9]=Ab.y,ya[J+10]=Ab.z,ya[J+11]=Ab.w,Bb=fc[M.a],Cb=fc[M.b],Db=fc[M.c],xa[J]=Bb.x,xa[J+1]=Bb.y,xa[J+2]=Bb.z,xa[J+3]=Bb.w,xa[J+4]=Cb.x,xa[J+5]=Cb.y,xa[J+6]=Cb.z,xa[J+7]=Cb.w,xa[J+8]=Db.x,xa[J+9]=Db.y,xa[J+10]=Db.z,xa[J+11]=Db.w,Pb=dc[M.a],Qb=dc[M.b],Rb=dc[M.c],
+va[J]=Pb.x,va[J+1]=Pb.y,va[J+2]=Pb.z,va[J+3]=1,va[J+4]=Qb.x,va[J+5]=Qb.y,va[J+6]=Qb.z,va[J+7]=1,va[J+8]=Rb.x,va[J+9]=Rb.y,va[J+10]=Rb.z,va[J+11]=1,Sb=ec[M.a],Tb=ec[M.b],Ub=ec[M.c],wa[J]=Sb.x,wa[J+1]=Sb.y,wa[J+2]=Sb.z,wa[J+3]=1,wa[J+4]=Tb.x,wa[J+5]=Tb.y,wa[J+6]=Tb.z,wa[J+7]=1,wa[J+8]=Ub.x,wa[J+9]=Ub.y,wa[J+10]=Ub.z,wa[J+11]=1,J+=12;for(F=0,T=ma.length;F<T;F++)M=Da[ma[F]],yb=Xb[M.a],zb=Xb[M.b],Ab=Xb[M.c],uc=Xb[M.d],ya[J]=yb.x,ya[J+1]=yb.y,ya[J+2]=yb.z,ya[J+3]=yb.w,ya[J+4]=zb.x,ya[J+5]=zb.y,ya[J+6]=
+zb.z,ya[J+7]=zb.w,ya[J+8]=Ab.x,ya[J+9]=Ab.y,ya[J+10]=Ab.z,ya[J+11]=Ab.w,ya[J+12]=uc.x,ya[J+13]=uc.y,ya[J+14]=uc.z,ya[J+15]=uc.w,Bb=fc[M.a],Cb=fc[M.b],Db=fc[M.c],vc=fc[M.d],xa[J]=Bb.x,xa[J+1]=Bb.y,xa[J+2]=Bb.z,xa[J+3]=Bb.w,xa[J+4]=Cb.x,xa[J+5]=Cb.y,xa[J+6]=Cb.z,xa[J+7]=Cb.w,xa[J+8]=Db.x,xa[J+9]=Db.y,xa[J+10]=Db.z,xa[J+11]=Db.w,xa[J+12]=vc.x,xa[J+13]=vc.y,xa[J+14]=vc.z,xa[J+15]=vc.w,Pb=dc[M.a],Qb=dc[M.b],Rb=dc[M.c],Ic=dc[M.d],va[J]=Pb.x,va[J+1]=Pb.y,va[J+2]=Pb.z,va[J+3]=1,va[J+4]=Qb.x,va[J+5]=Qb.y,
+va[J+6]=Qb.z,va[J+7]=1,va[J+8]=Rb.x,va[J+9]=Rb.y,va[J+10]=Rb.z,va[J+11]=1,va[J+12]=Ic.x,va[J+13]=Ic.y,va[J+14]=Ic.z,va[J+15]=1,Sb=ec[M.a],Tb=ec[M.b],Ub=ec[M.c],Jc=ec[M.d],wa[J]=Sb.x,wa[J+1]=Sb.y,wa[J+2]=Sb.z,wa[J+3]=1,wa[J+4]=Tb.x,wa[J+5]=Tb.y,wa[J+6]=Tb.z,wa[J+7]=1,wa[J+8]=Ub.x,wa[J+9]=Ub.y,wa[J+10]=Ub.z,wa[J+11]=1,wa[J+12]=Jc.x,wa[J+13]=Jc.y,wa[J+14]=Jc.z,wa[J+15]=1,J+=16;0<J&&(j.bindBuffer(j.ARRAY_BUFFER,ga.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,va,ab),j.bindBuffer(j.ARRAY_BUFFER,
+ga.__webglSkinVertexBBuffer),j.bufferData(j.ARRAY_BUFFER,wa,ab),j.bindBuffer(j.ARRAY_BUFFER,ga.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,xa,ab),j.bindBuffer(j.ARRAY_BUFFER,ga.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,ya,ab))}if(yd&&Yc){for(F=0,T=la.length;F<T;F++)M=Da[la[F]],ob=M.vertexColors,Hc=M.color,3===ob.length&&Yc===THREE.VertexColors?(vb=ob[0],wb=ob[1],xb=ob[2]):xb=wb=vb=Hc,Oa[Ca]=vb.r,Oa[Ca+1]=vb.g,Oa[Ca+2]=vb.b,Oa[Ca+3]=wb.r,Oa[Ca+4]=wb.g,Oa[Ca+5]=wb.b,Oa[Ca+6]=xb.r,
+Oa[Ca+7]=xb.g,Oa[Ca+8]=xb.b,Ca+=9;for(F=0,T=ma.length;F<T;F++)M=Da[ma[F]],ob=M.vertexColors,Hc=M.color,4===ob.length&&Yc===THREE.VertexColors?(vb=ob[0],wb=ob[1],xb=ob[2],tc=ob[3]):tc=xb=wb=vb=Hc,Oa[Ca]=vb.r,Oa[Ca+1]=vb.g,Oa[Ca+2]=vb.b,Oa[Ca+3]=wb.r,Oa[Ca+4]=wb.g,Oa[Ca+5]=wb.b,Oa[Ca+6]=xb.r,Oa[Ca+7]=xb.g,Oa[Ca+8]=xb.b,Oa[Ca+9]=tc.r,Oa[Ca+10]=tc.g,Oa[Ca+11]=tc.b,Ca+=12;0<Ca&&(j.bindBuffer(j.ARRAY_BUFFER,ga.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,Oa,ab))}if(xd&&Ta.hasTangents){for(F=0,T=la.length;F<
+T;F++)M=Da[la[F]],Hb=M.vertexTangents,pb=Hb[0],qb=Hb[1],rb=Hb[2],ua[pa]=pb.x,ua[pa+1]=pb.y,ua[pa+2]=pb.z,ua[pa+3]=pb.w,ua[pa+4]=qb.x,ua[pa+5]=qb.y,ua[pa+6]=qb.z,ua[pa+7]=qb.w,ua[pa+8]=rb.x,ua[pa+9]=rb.y,ua[pa+10]=rb.z,ua[pa+11]=rb.w,pa+=12;for(F=0,T=ma.length;F<T;F++)M=Da[ma[F]],Hb=M.vertexTangents,pb=Hb[0],qb=Hb[1],rb=Hb[2],rc=Hb[3],ua[pa]=pb.x,ua[pa+1]=pb.y,ua[pa+2]=pb.z,ua[pa+3]=pb.w,ua[pa+4]=qb.x,ua[pa+5]=qb.y,ua[pa+6]=qb.z,ua[pa+7]=qb.w,ua[pa+8]=rb.x,ua[pa+9]=rb.y,ua[pa+10]=rb.z,ua[pa+11]=rb.w,
+ua[pa+12]=rc.x,ua[pa+13]=rc.y,ua[pa+14]=rc.z,ua[pa+15]=rc.w,pa+=16;j.bindBuffer(j.ARRAY_BUFFER,ga.__webglTangentBuffer);j.bufferData(j.ARRAY_BUFFER,ua,ab)}if(wd&&gd){for(F=0,T=la.length;F<T;F++)if(M=Da[la[F]],jc=M.vertexNormals,Ob=M.normal,3===jc.length&&Gc)for(ka=0;3>ka;ka++)Vb=jc[ka],hb[Ra]=Vb.x,hb[Ra+1]=Vb.y,hb[Ra+2]=Vb.z,Ra+=3;else for(ka=0;3>ka;ka++)hb[Ra]=Ob.x,hb[Ra+1]=Ob.y,hb[Ra+2]=Ob.z,Ra+=3;for(F=0,T=ma.length;F<T;F++)if(M=Da[ma[F]],jc=M.vertexNormals,Ob=M.normal,4===jc.length&&Gc)for(ka=
+0;4>ka;ka++)Vb=jc[ka],hb[Ra]=Vb.x,hb[Ra+1]=Vb.y,hb[Ra+2]=Vb.z,Ra+=3;else for(ka=0;4>ka;ka++)hb[Ra]=Ob.x,hb[Ra+1]=Ob.y,hb[Ra+2]=Ob.z,Ra+=3;j.bindBuffer(j.ARRAY_BUFFER,ga.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,hb,ab)}if(kd&&bd&&hd){for(F=0,T=la.length;F<T;F++)if(kb=la[F],M=Da[kb],kc=bd[kb],void 0!==kc)for(ka=0;3>ka;ka++)mc=kc[ka],wc[Jb]=mc.u,wc[Jb+1]=mc.v,Jb+=2;for(F=0,T=ma.length;F<T;F++)if(kb=ma[F],M=Da[kb],kc=bd[kb],void 0!==kc)for(ka=0;4>ka;ka++)mc=kc[ka],wc[Jb]=mc.u,wc[Jb+1]=mc.v,Jb+=
+2;0<Jb&&(j.bindBuffer(j.ARRAY_BUFFER,ga.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,wc,ab))}if(kd&&cd&&hd){for(F=0,T=la.length;F<T;F++)if(kb=la[F],M=Da[kb],lc=cd[kb],void 0!==lc)for(ka=0;3>ka;ka++)nc=lc[ka],xc[Kb]=nc.u,xc[Kb+1]=nc.v,Kb+=2;for(F=0,T=ma.length;F<T;F++)if(kb=ma[F],M=Da[kb],lc=cd[kb],void 0!==lc)for(ka=0;4>ka;ka++)nc=lc[ka],xc[Kb]=nc.u,xc[Kb+1]=nc.v,Kb+=2;0<Kb&&(j.bindBuffer(j.ARRAY_BUFFER,ga.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,xc,ab))}if(vd){for(F=0,T=la.length;F<T;F++)M=
+Da[la[F]],Eb[gb]=Ba,Eb[gb+1]=Ba+1,Eb[gb+2]=Ba+2,gb+=3,cb[Sa]=Ba,cb[Sa+1]=Ba+1,cb[Sa+2]=Ba,cb[Sa+3]=Ba+2,cb[Sa+4]=Ba+1,cb[Sa+5]=Ba+2,Sa+=6,Ba+=3;for(F=0,T=ma.length;F<T;F++)M=Da[ma[F]],Eb[gb]=Ba,Eb[gb+1]=Ba+1,Eb[gb+2]=Ba+3,Eb[gb+3]=Ba+1,Eb[gb+4]=Ba+2,Eb[gb+5]=Ba+3,gb+=6,cb[Sa]=Ba,cb[Sa+1]=Ba+1,cb[Sa+2]=Ba,cb[Sa+3]=Ba+3,cb[Sa+4]=Ba+1,cb[Sa+5]=Ba+2,cb[Sa+6]=Ba+2,cb[Sa+7]=Ba+3,Sa+=8,Ba+=4;j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,ga.__webglFaceBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,Eb,ab);j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,
+ga.__webglLineBuffer);j.bufferData(j.ELEMENT_ARRAY_BUFFER,cb,ab)}if(ad)for(ka=0,id=ad.length;ka<id;ka++)if(x=ad[ka],x.__original.needsUpdate){y=0;if(1===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){for(F=0,T=la.length;F<T;F++)M=Da[la[F]],x.array[y]=x.value[M.a],x.array[y+1]=x.value[M.b],x.array[y+2]=x.value[M.c],y+=3;for(F=0,T=ma.length;F<T;F++)M=Da[ma[F]],x.array[y]=x.value[M.a],x.array[y+1]=x.value[M.b],x.array[y+2]=x.value[M.c],x.array[y+3]=x.value[M.d],y+=4}else{if("faces"===x.boundTo){for(F=
+0,T=la.length;F<T;F++)bb=x.value[la[F]],x.array[y]=bb,x.array[y+1]=bb,x.array[y+2]=bb,y+=3;for(F=0,T=ma.length;F<T;F++)bb=x.value[ma[F]],x.array[y]=bb,x.array[y+1]=bb,x.array[y+2]=bb,x.array[y+3]=bb,y+=4}}else if(2===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){for(F=0,T=la.length;F<T;F++)M=Da[la[F]],U=x.value[M.a],V=x.value[M.b],W=x.value[M.c],x.array[y]=U.x,x.array[y+1]=U.y,x.array[y+2]=V.x,x.array[y+3]=V.y,x.array[y+4]=W.x,x.array[y+5]=W.y,y+=6;for(F=0,T=ma.length;F<T;F++)M=Da[ma[F]],
+U=x.value[M.a],V=x.value[M.b],W=x.value[M.c],oa=x.value[M.d],x.array[y]=U.x,x.array[y+1]=U.y,x.array[y+2]=V.x,x.array[y+3]=V.y,x.array[y+4]=W.x,x.array[y+5]=W.y,x.array[y+6]=oa.x,x.array[y+7]=oa.y,y+=8}else{if("faces"===x.boundTo){for(F=0,T=la.length;F<T;F++)W=V=U=bb=x.value[la[F]],x.array[y]=U.x,x.array[y+1]=U.y,x.array[y+2]=V.x,x.array[y+3]=V.y,x.array[y+4]=W.x,x.array[y+5]=W.y,y+=6;for(F=0,T=ma.length;F<T;F++)oa=W=V=U=bb=x.value[ma[F]],x.array[y]=U.x,x.array[y+1]=U.y,x.array[y+2]=V.x,x.array[y+
+3]=V.y,x.array[y+4]=W.x,x.array[y+5]=W.y,x.array[y+6]=oa.x,x.array[y+7]=oa.y,y+=8}}else if(3===x.size){var ha;ha="c"===x.type?["r","g","b"]:["x","y","z"];if(void 0===x.boundTo||"vertices"===x.boundTo){for(F=0,T=la.length;F<T;F++)M=Da[la[F]],U=x.value[M.a],V=x.value[M.b],W=x.value[M.c],x.array[y]=U[ha[0]],x.array[y+1]=U[ha[1]],x.array[y+2]=U[ha[2]],x.array[y+3]=V[ha[0]],x.array[y+4]=V[ha[1]],x.array[y+5]=V[ha[2]],x.array[y+6]=W[ha[0]],x.array[y+7]=W[ha[1]],x.array[y+8]=W[ha[2]],y+=9;for(F=0,T=ma.length;F<
+T;F++)M=Da[ma[F]],U=x.value[M.a],V=x.value[M.b],W=x.value[M.c],oa=x.value[M.d],x.array[y]=U[ha[0]],x.array[y+1]=U[ha[1]],x.array[y+2]=U[ha[2]],x.array[y+3]=V[ha[0]],x.array[y+4]=V[ha[1]],x.array[y+5]=V[ha[2]],x.array[y+6]=W[ha[0]],x.array[y+7]=W[ha[1]],x.array[y+8]=W[ha[2]],x.array[y+9]=oa[ha[0]],x.array[y+10]=oa[ha[1]],x.array[y+11]=oa[ha[2]],y+=12}else if("faces"===x.boundTo){for(F=0,T=la.length;F<T;F++)W=V=U=bb=x.value[la[F]],x.array[y]=U[ha[0]],x.array[y+1]=U[ha[1]],x.array[y+2]=U[ha[2]],x.array[y+
+3]=V[ha[0]],x.array[y+4]=V[ha[1]],x.array[y+5]=V[ha[2]],x.array[y+6]=W[ha[0]],x.array[y+7]=W[ha[1]],x.array[y+8]=W[ha[2]],y+=9;for(F=0,T=ma.length;F<T;F++)oa=W=V=U=bb=x.value[ma[F]],x.array[y]=U[ha[0]],x.array[y+1]=U[ha[1]],x.array[y+2]=U[ha[2]],x.array[y+3]=V[ha[0]],x.array[y+4]=V[ha[1]],x.array[y+5]=V[ha[2]],x.array[y+6]=W[ha[0]],x.array[y+7]=W[ha[1]],x.array[y+8]=W[ha[2]],x.array[y+9]=oa[ha[0]],x.array[y+10]=oa[ha[1]],x.array[y+11]=oa[ha[2]],y+=12}}else if(4===x.size)if(void 0===x.boundTo||"vertices"===
+x.boundTo){for(F=0,T=la.length;F<T;F++)M=Da[la[F]],U=x.value[M.a],V=x.value[M.b],W=x.value[M.c],x.array[y]=U.x,x.array[y+1]=U.y,x.array[y+2]=U.z,x.array[y+3]=U.w,x.array[y+4]=V.x,x.array[y+5]=V.y,x.array[y+6]=V.z,x.array[y+7]=V.w,x.array[y+8]=W.x,x.array[y+9]=W.y,x.array[y+10]=W.z,x.array[y+11]=W.w,y+=12;for(F=0,T=ma.length;F<T;F++)M=Da[ma[F]],U=x.value[M.a],V=x.value[M.b],W=x.value[M.c],oa=x.value[M.d],x.array[y]=U.x,x.array[y+1]=U.y,x.array[y+2]=U.z,x.array[y+3]=U.w,x.array[y+4]=V.x,x.array[y+5]=
+V.y,x.array[y+6]=V.z,x.array[y+7]=V.w,x.array[y+8]=W.x,x.array[y+9]=W.y,x.array[y+10]=W.z,x.array[y+11]=W.w,x.array[y+12]=oa.x,x.array[y+13]=oa.y,x.array[y+14]=oa.z,x.array[y+15]=oa.w,y+=16}else if("faces"===x.boundTo){for(F=0,T=la.length;F<T;F++)W=V=U=bb=x.value[la[F]],x.array[y]=U.x,x.array[y+1]=U.y,x.array[y+2]=U.z,x.array[y+3]=U.w,x.array[y+4]=V.x,x.array[y+5]=V.y,x.array[y+6]=V.z,x.array[y+7]=V.w,x.array[y+8]=W.x,x.array[y+9]=W.y,x.array[y+10]=W.z,x.array[y+11]=W.w,y+=12;for(F=0,T=ma.length;F<
+T;F++)oa=W=V=U=bb=x.value[ma[F]],x.array[y]=U.x,x.array[y+1]=U.y,x.array[y+2]=U.z,x.array[y+3]=U.w,x.array[y+4]=V.x,x.array[y+5]=V.y,x.array[y+6]=V.z,x.array[y+7]=V.w,x.array[y+8]=W.x,x.array[y+9]=W.y,x.array[y+10]=W.z,x.array[y+11]=W.w,x.array[y+12]=oa.x,x.array[y+13]=oa.y,x.array[y+14]=oa.z,x.array[y+15]=oa.w,y+=16}j.bindBuffer(j.ARRAY_BUFFER,x.buffer);j.bufferData(j.ARRAY_BUFFER,x.array,ab)}ud&&(delete ga.__inittedArrays,delete ga.__colorArray,delete ga.__normalArray,delete ga.__tangentArray,delete ga.__uvArray,
+delete ga.__uv2Array,delete ga.__faceArray,delete ga.__vertexArray,delete ga.__lineArray,delete ga.__skinVertexAArray,delete ga.__skinVertexBArray,delete ga.__skinIndexArray,delete ga.__skinWeightArray)}}ja.__dirtyVertices=!1;ja.__dirtyMorphTargets=!1;ja.__dirtyElements=!1;ja.__dirtyUvs=!1;ja.__dirtyNormals=!1;ja.__dirtyColors=!1;ja.__dirtyTangents=!1;Ya.attributes&&n(Ya)}else if(nb instanceof THREE.Ribbon){if(ja.__dirtyVertices||ja.__dirtyColors){var Zb=ja,ld=j.DYNAMIC_DRAW,yc=void 0,zc=void 0,Lc=
+void 0,$b=void 0,Mc=void 0,md=Zb.vertices,nd=Zb.colors,Ad=md.length,Bd=nd.length,Nc=Zb.__vertexArray,Oc=Zb.__colorArray,Cd=Zb.__dirtyColors;if(Zb.__dirtyVertices){for(yc=0;yc<Ad;yc++)Lc=md[yc].position,$b=3*yc,Nc[$b]=Lc.x,Nc[$b+1]=Lc.y,Nc[$b+2]=Lc.z;j.bindBuffer(j.ARRAY_BUFFER,Zb.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Nc,ld)}if(Cd){for(zc=0;zc<Bd;zc++)Mc=nd[zc],$b=3*zc,Oc[$b]=Mc.r,Oc[$b+1]=Mc.g,Oc[$b+2]=Mc.b;j.bindBuffer(j.ARRAY_BUFFER,Zb.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,
+Oc,ld)}}ja.__dirtyVertices=!1;ja.__dirtyColors=!1}else if(nb instanceof THREE.Line){Ya=c(nb,qc);ic=Ya.attributes&&p(Ya);if(ja.__dirtyVertices||ja.__dirtyColors||ic){var Lb=ja,dd=j.DYNAMIC_DRAW,Ac=void 0,Bc=void 0,Pc=void 0,za=void 0,Qc=void 0,od=Lb.vertices,pd=Lb.colors,Dd=od.length,Ed=pd.length,Rc=Lb.__vertexArray,Sc=Lb.__colorArray,Fd=Lb.__dirtyColors,ed=Lb.__webglCustomAttributesList,Tc=void 0,qd=void 0,Qa=void 0,oc=void 0,Za=void 0,sa=void 0;if(Lb.__dirtyVertices){for(Ac=0;Ac<Dd;Ac++)Pc=od[Ac].position,
+za=3*Ac,Rc[za]=Pc.x,Rc[za+1]=Pc.y,Rc[za+2]=Pc.z;j.bindBuffer(j.ARRAY_BUFFER,Lb.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Rc,dd)}if(Fd){for(Bc=0;Bc<Ed;Bc++)Qc=pd[Bc],za=3*Bc,Sc[za]=Qc.r,Sc[za+1]=Qc.g,Sc[za+2]=Qc.b;j.bindBuffer(j.ARRAY_BUFFER,Lb.__webglColorBuffer);j.bufferData(j.ARRAY_BUFFER,Sc,dd)}if(ed)for(Tc=0,qd=ed.length;Tc<qd;Tc++)if(sa=ed[Tc],sa.needsUpdate&&(void 0===sa.boundTo||"vertices"===sa.boundTo)){za=0;oc=sa.value.length;if(1===sa.size)for(Qa=0;Qa<oc;Qa++)sa.array[Qa]=sa.value[Qa];
+else if(2===sa.size)for(Qa=0;Qa<oc;Qa++)Za=sa.value[Qa],sa.array[za]=Za.x,sa.array[za+1]=Za.y,za+=2;else if(3===sa.size)if("c"===sa.type)for(Qa=0;Qa<oc;Qa++)Za=sa.value[Qa],sa.array[za]=Za.r,sa.array[za+1]=Za.g,sa.array[za+2]=Za.b,za+=3;else for(Qa=0;Qa<oc;Qa++)Za=sa.value[Qa],sa.array[za]=Za.x,sa.array[za+1]=Za.y,sa.array[za+2]=Za.z,za+=3;else if(4===sa.size)for(Qa=0;Qa<oc;Qa++)Za=sa.value[Qa],sa.array[za]=Za.x,sa.array[za+1]=Za.y,sa.array[za+2]=Za.z,sa.array[za+3]=Za.w,za+=4;j.bindBuffer(j.ARRAY_BUFFER,
+sa.buffer);j.bufferData(j.ARRAY_BUFFER,sa.array,dd)}}ja.__dirtyVertices=!1;ja.__dirtyColors=!1;Ya.attributes&&n(Ya)}else if(nb instanceof THREE.ParticleSystem)Ya=c(nb,qc),ic=Ya.attributes&&p(Ya),(ja.__dirtyVertices||ja.__dirtyColors||nb.sortParticles||ic)&&f(ja,j.DYNAMIC_DRAW,nb),ja.__dirtyVertices=!1,ja.__dirtyColors=!1,Ya.attributes&&n(Ya)}};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 m=THREE.ShaderLib[i];a.uniforms=THREE.UniformsUtils.clone(m.uniforms);a.vertexShader=m.vertexShader;a.fragmentShader=m.fragmentShader}var k,n;f=m=0;for(k=0,n=b.length;k<n;k++)e=b[k],e.onlyShadow||(e instanceof THREE.DirectionalLight&&f++,e instanceof
+THREE.PointLight&&m++,e instanceof THREE.SpotLight&&m++);m+f<=H?k=f:(k=Math.ceil(H*f/(m+f)),m=H-k);e=k;f=m;var l=0;for(m=0,k=b.length;m<k;m++)n=b[m],n.castShadow&&(n instanceof THREE.SpotLight&&l++,n instanceof THREE.DirectionalLight&&!n.shadowCascade&&l++);var o=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)o=d.bones.length;var p;a:{k=a.fragmentShader;n=a.vertexShader;var m=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,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:e,maxPointLights:f,maxBones:o,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,shadowMapCascade:this.shadowMapCascade,maxShadows:l,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround},q,d=[];i?d.push(i):
+(d.push(k),d.push(n));for(q in c)d.push(q),d.push(c[q]);i=d.join();for(q=0,d=X.length;q<d;q++)if(X[q].code===i){p=X[q].program;break a}q=j.createProgram();d=[0<Aa?"#define VERTEX_TEXTURES":"",G.gammaInput?"#define GAMMA_INPUT":"",G.gammaOutput?"#define GAMMA_OUTPUT":"",G.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.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",
+c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute 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;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\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:"",G.gammaInput?"#define GAMMA_INPUT":"",G.gammaOutput?"#define GAMMA_OUTPUT":"",G.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.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");j.attachShader(q,t("fragment",e+k));j.attachShader(q,t("vertex",d+n));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,boneGlobalMatrices,morphTargetInfluences".split(",");for(r in m)d.push(r);r=d;for(d=0,m=r.length;d<m;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(r=0;r<c.maxMorphNormals;r++)d.push("morphNormal"+r);for(p in b)d.push(p);p=d;for(r=0,b=p.length;r<b;r++)c=p[r],q.attributes[c]=j.getAttribLocation(q,c);q.id=X.length;X.push({program:q,code:i});G.info.memory.programs=X.length;p=q}a.program=p;p=a.program.attributes;0<=p.position&&j.enableVertexAttribArray(p.position);0<=p.color&&j.enableVertexAttribArray(p.color);0<=p.normal&&j.enableVertexAttribArray(p.normal);0<=p.tangent&&j.enableVertexAttribArray(p.tangent);
 a.skinning&&0<=p.skinVertexA&&0<=p.skinVertexB&&0<=p.skinIndex&&0<=p.skinWeight&&(j.enableVertexAttribArray(p.skinVertexA),j.enableVertexAttribArray(p.skinVertexB),j.enableVertexAttribArray(p.skinIndex),j.enableVertexAttribArray(p.skinWeight));if(a.attributes)for(h in a.attributes)void 0!==p[h]&&0<=p[h]&&j.enableVertexAttribArray(p[h]);if(a.morphTargets){a.numSupportedMorphTargets=0;q="morphTarget";for(h=0;h<this.maxMorphTargets;h++)r=q+h,0<=p[r]&&(j.enableVertexAttribArray(p[r]),a.numSupportedMorphTargets++)}if(a.morphNormals){a.numSupportedMorphNormals=
-0;q="morphNormal";for(h=0;h<this.maxMorphNormals;h++)r=q+h,0<=p[r]&&(j.enableVertexAttribArray(p[r]),a.numSupportedMorphNormals++)}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(ca!==a.doubleSided)a.doubleSided?
-j.disable(j.CULL_FACE):j.enable(j.CULL_FACE),ca=a.doubleSided;if(V!==a.flipSided)a.flipSided?j.frontFace(j.CW):j.frontFace(j.CCW),V=a.flipSided};this.setDepthTest=function(a){U!==a&&(a?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST),U=a)};this.setDepthWrite=function(a){aa!==a&&(j.depthMask(a),aa=a)};this.setBlending=function(a){if(a!==ba){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)}ba=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=j.createTexture(),H.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=y(a.format),f=y(a.type);w(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=y(a.format),e=y(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];j.bindTexture(j.TEXTURE_CUBE_MAP,a.__webglTexture);w(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+
+0;q="morphNormal";for(h=0;h<this.maxMorphNormals;h++)r=q+h,0<=p[r]&&(j.enableVertexAttribArray(p[r]),a.numSupportedMorphNormals++)}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(aa!==a.flipSided)a.flipSided?j.frontFace(j.CW):j.frontFace(j.CCW),aa=a.flipSided};this.setDepthTest=function(a){Y!==a&&(a?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST),Y=a)};this.setDepthWrite=function(a){ca!==a&&(j.depthMask(a),ca=a)};this.setBlending=function(a){if(a!==ba){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)}ba=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=j.createTexture(),G.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);w(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);w(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);u(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=j.createFramebuffer(),a.__webglRenderbuffer=j.createRenderbuffer(),j.bindTexture(j.TEXTURE_2D,a.__webglTexture),w(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),u(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=ka,a=db,e=Ea,c=Ba);b!==F&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(e,c,d,a),F=b);lb=d;eb=a};this.shadowMapPlugin=
+a.__webglFramebuffer),j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,d,a.__webglTexture,0),u(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=ib,e=Ha,c=ra);b!==E&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(e,c,d,a),E=b);Va=d;lb=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};
@@ -364,19 +366,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,k=f.faces,l=a.faceVertexUvs[0],p=f.faceVertexUvs[0],m={},o=0;o<a.materials.length;o++)m[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 n=new THREE.Vertex(h[o].position.clone());c&&c.multiplyVector3(n.position);g.push(n)}for(o=
-0,q=k.length;o<q;o++){var g=k[o],r,s,t=g.vertexNormals,w=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(n=t.length;h<n;h++)s=t[h].clone(),d&&d.multiplyVector3(s),r.vertexNormals.push(s);r.color.copy(g.color);h=0;for(n=w.length;h<n;h++)s=w[h],r.vertexColors.push(s.clone());if(void 0!==g.materialIndex){h=f.materials[g.materialIndex];n=h.id;
-w=m[n];if(void 0===w)w=a.materials.length,m[n]=w,a.materials.push(h);r.materialIndex=w}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(n=c.length;h<n;h++)d.push(new THREE.UV(c[h].u,c[h].v));l.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,k=f.faces,l=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=k.length;o<q;o++){var g=k[o],r,s,t=g.vertexNormals,w=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=w.length;h<m;h++)s=w[h],r.vertexColors.push(s.clone());if(void 0!==g.materialIndex){h=f.materials[g.materialIndex];m=h.id;
+w=n[m];if(void 0===w)w=a.materials.length,n[m]=w,a.materials.push(h);r.materialIndex=w}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));l.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,k,l=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=l.length;d<g;d++)k=l[d],i.vertexNormals.push(k.clone());i.color.copy(h.color);d=0;for(g=p.length;d<g;d++)k=p[d],i.vertexColors.push(k.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 k[e]>a?b(c,e-1):k[e]<a?b(e+1,d):e}return b(0,k.length-1)}var d,e,f=a.faces,g=a.vertices,h=f.length,i=0,k=[],l,p,m,o;for(e=0;e<h;e++){d=f[e];if(d instanceof THREE.Face3)l=g[d.a].position,p=g[d.b].position,m=g[d.c].position,d._area=THREE.GeometryUtils.triangleArea(l,p,m);else if(d instanceof
-THREE.Face4)l=g[d.a].position,p=g[d.b].position,m=g[d.c].position,o=g[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(l,p,o),d._area2=THREE.GeometryUtils.triangleArea(p,m,o),d._area=d._area1+d._area2;i+=d._area;k[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 k[e]>a?b(c,e-1):k[e]<a?b(e+1,d):e}return b(0,k.length-1)}var d,e,f=a.faces,g=a.vertices,h=f.length,i=0,k=[],l,p,n,o;for(e=0;e<h;e++){d=f[e];if(d instanceof THREE.Face3)l=g[d.a].position,p=g[d.b].position,n=g[d.c].position,d._area=THREE.GeometryUtils.triangleArea(l,p,n);else if(d instanceof
+THREE.Face4)l=g[d.a].position,p=g[d.b].position,n=g[d.c].position,o=g[d.d].position,d._area1=THREE.GeometryUtils.triangleArea(l,p,o),d._area2=THREE.GeometryUtils.triangleArea(p,n,o),d._area=d._area1+d._area2;i+=d._area;k[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:"anonymous",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=this.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),k=i.data,l=0;l<d;l++)for(var p=1;p<e;p++){var m=0>p-1?e-1:p-1,o=(p+1)%e,q=0>l-1?d-1:l-1,n=(l+1)%d,r=[],s=[0,0,h[4*(p*d+l)]/255*b];r.push([-1,0,h[4*(p*d+q)]/255*b]);r.push([-1,-1,h[4*(m*d+q)]/255*b]);r.push([0,-1,
-h[4*(m*d+l)]/255*b]);r.push([1,-1,h[4*(m*d+n)]/255*b]);r.push([1,0,h[4*(p*d+n)]/255*b]);r.push([1,1,h[4*(o*d+n)]/255*b]);r.push([0,1,h[4*(o*d+l)]/255*b]);r.push([-1,1,h[4*(o*d+q)]/255*b]);m=[];q=r.length;for(o=0;o<q;o++){var n=r[o],t=r[(o+1)%q],n=[n[0]-s[0],n[1]-s[1],n[2]-s[2]],t=[t[0]-s[0],t[1]-s[1],t[2]-s[2]];m.push(c([n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]))}r=[0,0,0];for(o=0;o<m.length;o++)r[0]+=m[o][0],r[1]+=m[o][1],r[2]+=m[o][2];r[0]/=m.length;r[1]/=m.length;r[2]/=m.length;
+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),k=i.data,l=0;l<d;l++)for(var p=1;p<e;p++){var n=0>p-1?e-1:p-1,o=(p+1)%e,q=0>l-1?d-1:l-1,m=(l+1)%d,r=[],s=[0,0,h[4*(p*d+l)]/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+l)]/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+l)]/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+l);k[s]=255*((r[0]+1)/2)|0;k[s+1]=255*(r[1]+0.5)|0;k[s+2]=255*r[2]|0;k[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?
@@ -426,9 +428,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,k,l,p,m,o,q,n;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];m=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++)n=g/a,f=THREE.Shape.Utils.b2(n,o,p,h),n=THREE.Shape.Utils.b2(n,q,m,
-i),c.push(new THREE.Vector2(f,n));break;case THREE.PathActions.BEZIER_CURVE_TO:h=f[4];i=f[5];p=f[0];m=f[1];k=f[2];l=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++)n=g/a,f=THREE.Shape.Utils.b3(n,o,p,k,h),n=THREE.Shape.Utils.b3(n,q,m,l,i),c.push(new THREE.Vector2(f,n));break;case THREE.PathActions.CSPLINE_THRU:g=this.actions[d-1].args;g=[new THREE.Vector2(g[g.length-2],g[g.length-1])];n=a*f[0].length;g=g.concat(f[0]);f=new THREE.SplineCurve(g);
-for(g=1;g<=n;g++)c.push(f.getPointAt(g/n));break;case THREE.PathActions.ARC:g=this.actions[d-1].args;h=f[0];i=f[1];k=f[2];p=f[3];n=f[4];m=!!f[5];l=g[g.length-2];o=g[g.length-1];0==g.length&&(l=o=0);q=n-p;var r=2*a;for(g=1;g<=r;g++)n=g/r,m||(n=1-n),n=p+n*q,f=l+h+k*Math.cos(n),n=o+i+k*Math.sin(n),c.push(new THREE.Vector2(f,n))}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,k,l,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];k=f[2];l=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,k,h),m=THREE.Shape.Utils.b3(m,q,n,l,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];k=f[2];p=f[3];m=f[4];n=!!f[5];l=g[g.length-2];o=g[g.length-1];0==g.length&&(l=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=l+h+k*Math.cos(m),m=o+i+k*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,k,l,p;for(h=0,i=g.length;h<i;h++)k=g[h],l=k.x,p=k.y,k.x=a*l+b*p+c,k.y=d*p+e*l+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()};
@@ -436,8 +438,8 @@ THREE.Path.prototype.toShapes=function(){var a,b,c,d,e=[],f=new THREE.Path;for(a
 b;a++)f=e[a],THREE.Shape.Utils.isClockWise(f.getPoints())?(g.actions=f.actions,g.curves=f.curves,d.push(g),g=new THREE.Shape):g.holes.push(f)}else{for(a=0,b=e.length;a<b;a++)f=e[a],THREE.Shape.Utils.isClockWise(f.getPoints())?(g&&d.push(g),g=new THREE.Shape,g.actions=f.actions,g.curves=f.curves):g.holes.push(f);d.push(g)}return d};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,k,l,p,m,o,q=[];for(i=0;i<b.length;i++){k=b[i];Array.prototype.push.apply(d,k);f=Number.POSITIVE_INFINITY;for(e=0;e<k.length;e++){m=k[e];o=[];for(p=0;p<c.length;p++)l=c[p],l=m.distanceToSquared(l),o.push(l),l<f&&(f=l,g=e,h=p)}e=0<=h-1?h-1:c.length-1;f=0<=g-1?g-1:k.length-1;var n=[k[g],c[h],c[e]];p=THREE.FontUtils.Triangulate.area(n);var r=[k[g],k[f],c[h]];m=THREE.FontUtils.Triangulate.area(r);o=h;l=g;h+=1;g+=-1;0>
-h&&(h+=c.length);h%=c.length;0>g&&(g+=k.length);g%=k.length;e=0<=h-1?h-1:c.length-1;f=0<=g-1?g-1:k.length-1;n=[k[g],c[h],c[e]];n=THREE.FontUtils.Triangulate.area(n);r=[k[g],k[f],c[h]];r=THREE.FontUtils.Triangulate.area(r);p+m>n+r&&(h=o,g=l,0>h&&(h+=c.length),h%=c.length,0>g&&(g+=k.length),g%=k.length,e=0<=h-1?h-1:c.length-1,f=0<=g-1?g-1:k.length-1);p=c.slice(0,h);m=c.slice(h);o=k.slice(g);l=k.slice(0,g);f=[k[g],k[f],c[h]];q.push([k[g],c[h],c[e]]);q.push(f);c=p.concat(o).concat(l).concat(m)}return{shape:c,
+THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),e,f,g,h,i,k,l,p,n,o,q=[];for(i=0;i<b.length;i++){k=b[i];Array.prototype.push.apply(d,k);f=Number.POSITIVE_INFINITY;for(e=0;e<k.length;e++){n=k[e];o=[];for(p=0;p<c.length;p++)l=c[p],l=n.distanceToSquared(l),o.push(l),l<f&&(f=l,g=e,h=p)}e=0<=h-1?h-1:c.length-1;f=0<=g-1?g-1:k.length-1;var m=[k[g],c[h],c[e]];p=THREE.FontUtils.Triangulate.area(m);var r=[k[g],k[f],c[h]];n=THREE.FontUtils.Triangulate.area(r);o=h;l=g;h+=1;g+=-1;0>
+h&&(h+=c.length);h%=c.length;0>g&&(g+=k.length);g%=k.length;e=0<=h-1?h-1:c.length-1;f=0<=g-1?g-1:k.length-1;m=[k[g],c[h],c[e]];m=THREE.FontUtils.Triangulate.area(m);r=[k[g],k[f],c[h]];r=THREE.FontUtils.Triangulate.area(r);p+n>m+r&&(h=o,g=l,0>h&&(h+=c.length),h%=c.length,0>g&&(g+=k.length),g%=k.length,e=0<=h-1?h-1:c.length-1,f=0<=g-1?g-1:k.length-1);p=c.slice(0,h);n=c.slice(h);o=k.slice(g);l=k.slice(0,g);f=[k[g],k[f],c[h]];q.push([k[g],c[h],c[e]]);q.push(f);c=p.concat(o).concat(l).concat(n)}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,k={};for(f=0,g=d.length;f<g;f++)i=d[f].x+":"+d[f].y,void 0!==k[i]&&console.log("Duplicate point",i),k[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=k[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=k[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};
@@ -451,8 +453,8 @@ 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,k,l=this.data.JIT.hierarchy,p,m;m=this.currentTime+=a*this.timeScale;p=this.currentTime%=this.data.length;k=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!==l[o][k])a instanceof THREE.Bone?(a.skinMatrix=l[o][k],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!1):(a.matrix=
-l[o][k],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 n=0;3>n;n++){c=b[n];g=i.prevKey[c];h=i.nextKey[c];if(h.time<=m){if(p<m)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]=
+THREE.Animation.prototype.update=function(a){if(this.isPlaying){var b=["pos","rot","scl"],c,d,e,f,g,h,i,k,l=this.data.JIT.hierarchy,p,n;n=this.currentTime+=a*this.timeScale;p=this.currentTime%=this.data.length;k=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!==l[o][k])a instanceof THREE.Bone?(a.skinMatrix=l[o][k],a.matrixAutoUpdate=!1,a.matrixWorldNeedsUpdate=!1):(a.matrix=
+l[o][k],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===l[0][k]){this.hierarchy[0].updateMatrixWorld(!0);for(o=0;o<this.hierarchy.length;o++)l[o][k]=this.hierarchy[o]instanceof THREE.Bone?this.hierarchy[o].skinMatrix.clone():this.hierarchy[o].matrix.clone()}}};
@@ -466,7 +468,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,k=this.hierarchy.length;a<k;a++){var l=this.data.hierarchy[a].keys,f=this.data.hierarchy[a].sids;d=l.length-1;e=this.hierarchy[a];if(l.length){for(l=
 0;l<f.length;l++)g=f[l],(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(k=this.hierarchy.length;a<k;a++){d=this.hierarchy[a];b=this.data.hierarchy[a];var l=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(l.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=l[0];for(c=l[1];c.time<g;)b=c,c=l[b.index+1]}else if(!i)for(var m=l.length-1;c.time<g&&c.index!==m;)b=c,c=l[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=l[0];for(c=l[1];c.time<g;)b=c,c=l[b.index+1]}else if(!i)for(var n=l.length-1;c.time<g&&c.index!==n;)b=c,c=l[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=
@@ -505,12 +507,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,k=0,l=0,p=0,m=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*m)}b=a*this.movementSpeed;this.object.translateZ(-b*(0<i||this.autoForward&&!(0>i)?1:i));this.object.translateX(b*k);this.object.translateY(b*l);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,k=0,l=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*k);this.object.translateY(b*l);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;m=(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-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){switch(a.keyCode){case 38:case 87:i=1;break;case 37:case 65:k=-1;break;case 40:case 83:i=-1;break;case 39:case 68:k=1;break;case 81:g=!0;h=1;break;case 69:g=!0;h=-1;break;case 82:l=1;break;case 70:l=-1}},!1);this.domElement.addEventListener("keyup",function(a){switch(a.keyCode){case 38:case 87:i=0;break;case 37:case 65:k=0;break;case 40:case 83:i=0;break;case 39:case 68:k=0;break;case 81:g=!1;break;case 69:g=!1;break;case 82:l=0;break;case 70:l=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,k=new THREE.Vector2,l=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*
@@ -520,39 +522,39 @@ c.target.addSelf(b);c.staticMoving?l=p:l.addSelf(a.sub(p,l).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=k=c.getMouseOnScreen(a.clientX,a.clientY),l=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?k=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=k=c.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(l=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,m,l){var n,o=d||1,p=e||1,q=h/2,r=i/2,s=k.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",p=f||1;else if("z"===a&&"y"===b||"y"===a&&"z"===b)n="x",o=f||1;var j=o+1,t=p+1,w=h/o,F=i/p,P=new THREE.Vector3;P[n]=0<m?1:-1;for(h=0;h<t;h++)for(i=0;i<j;i++){var R=new THREE.Vector3;R[a]=(i*w-q)*c;R[b]=(h*F-r)*g;R[n]=m;k.vertices.push(new THREE.Vertex(R))}for(h=0;h<p;h++)for(i=0;i<o;i++)a=
-new THREE.Face4(i+j*h+s,i+j*(h+1)+s,i+1+j*(h+1)+s,i+1+j*h+s),a.normal.copy(P),a.vertexNormals.push(P.clone(),P.clone(),P.clone(),P.clone()),a.materialIndex=l,k.faces.push(a),k.faceVertexUvs[0].push([new THREE.UV(i/o,h/p),new THREE.UV(i/o,(h+1)/p),new THREE.UV((i+1)/o,(h+1)/p),new THREE.UV((i+1)/o,h/p)])}THREE.Geometry.call(this);var k=this,l=a/2,p=b/2,m=c/2,o,q,n,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;n=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 w in h)void 0!==this.sides[w]&&(this.sides[w]=h[w]);this.sides.px&&i("z","y",-1,-1,c,b,l,o);this.sides.nx&&i("z","y",1,-1,c,b,-l,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,m,n);this.sides.nz&&i("x","y",-1,-1,a,b,-m,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,m,l){var n,o=d||1,p=e||1,q=h/2,r=i/2,s=k.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",p=f||1;else if("z"===a&&"y"===b||"y"===a&&"z"===b)n="x",o=f||1;var j=o+1,t=p+1,w=h/o,E=i/p,Q=new THREE.Vector3;Q[n]=0<m?1:-1;for(h=0;h<t;h++)for(i=0;i<j;i++){var N=new THREE.Vector3;N[a]=(i*w-q)*c;N[b]=(h*E-r)*g;N[n]=m;k.vertices.push(new THREE.Vertex(N))}for(h=0;h<p;h++)for(i=0;i<o;i++)a=
+new THREE.Face4(i+j*h+s,i+j*(h+1)+s,i+1+j*(h+1)+s,i+1+j*h+s),a.normal.copy(Q),a.vertexNormals.push(Q.clone(),Q.clone(),Q.clone(),Q.clone()),a.materialIndex=l,k.faces.push(a),k.faceVertexUvs[0].push([new THREE.UV(i/o,h/p),new THREE.UV(i/o,(h+1)/p),new THREE.UV((i+1)/o,(h+1)/p),new THREE.UV((i+1)/o,h/p)])}THREE.Geometry.call(this);var k=this,l=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 w in h)void 0!==this.sides[w]&&(this.sides[w]=h[w]);this.sides.px&&i("z","y",-1,-1,c,b,l,o);this.sides.nx&&i("z","y",1,-1,c,b,-l,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.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,k=[],l=[];for(i=0;i<=e;i++){var p=[],m=[],o=i/e,q=o*(b-a)+a;for(h=0;h<=d;h++){var n=h/d,r=q*Math.sin(2*n*Math.PI),s=-o*c+g,t=q*Math.cos(2*n*Math.PI);this.vertices.push(new THREE.Vertex(new THREE.Vector3(r,s,t)));p.push(this.vertices.length-1);m.push(new THREE.UV(n,o))}k.push(p);l.push(m)}for(i=0;i<e;i++)for(h=0;h<d;h++){var c=k[i][h],p=k[i+1][h],
-m=k[i+1][h+1],o=k[i][h+1],q=this.vertices[c].position.clone().setY(0).normalize(),n=this.vertices[p].position.clone().setY(0).normalize(),r=this.vertices[m].position.clone().setY(0).normalize(),s=this.vertices[o].position.clone().setY(0).normalize(),t=l[i][h].clone(),w=l[i+1][h].clone(),u=l[i+1][h+1].clone(),v=l[i][h+1].clone();this.faces.push(new THREE.Face4(c,p,m,o,[q,n,r,s]));this.faceVertexUvs[0].push([t,w,u,v])}if(!f&&0<a){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,g,0)));for(h=
-0;h<d;h++)c=k[0][h],p=k[0][h+1],m=this.vertices.length-1,q=new THREE.Vector3(0,1,0),n=new THREE.Vector3(0,1,0),r=new THREE.Vector3(0,1,0),t=l[0][h].clone(),w=l[0][h+1].clone(),u=new THREE.UV(w.u,0),this.faces.push(new THREE.Face3(c,p,m,[q,n,r])),this.faceVertexUvs[0].push([t,w,u])}if(!f&&0<b){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-g,0)));for(h=0;h<d;h++)c=k[i][h+1],p=k[i][h],m=this.vertices.length-1,q=new THREE.Vector3(0,-1,0),n=new THREE.Vector3(0,-1,0),r=new THREE.Vector3(0,-1,
-0),t=l[i][h+1].clone(),w=l[i][h].clone(),u=new THREE.UV(w.u,1),this.faces.push(new THREE.Face3(c,p,m,[q,n,r])),this.faceVertexUvs[0].push([t,w,u])}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,k=[],l=[];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))}k.push(p);l.push(n)}for(i=0;i<e;i++)for(h=0;h<d;h++){var c=k[i][h],p=k[i+1][h],
+n=k[i+1][h+1],o=k[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=l[i][h].clone(),w=l[i+1][h].clone(),u=l[i+1][h+1].clone(),v=l[i][h+1].clone();this.faces.push(new THREE.Face4(c,p,n,o,[q,m,r,s]));this.faceVertexUvs[0].push([t,w,u,v])}if(!f&&0<a){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,g,0)));for(h=
+0;h<d;h++)c=k[0][h],p=k[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=l[0][h].clone(),w=l[0][h+1].clone(),u=new THREE.UV(w.u,0),this.faces.push(new THREE.Face3(c,p,n,[q,m,r])),this.faceVertexUvs[0].push([t,w,u])}if(!f&&0<b){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-g,0)));for(h=0;h<d;h++)c=k[i][h+1],p=k[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=l[i][h+1].clone(),w=l[i][h].clone(),u=new THREE.UV(w.u,1),this.faces.push(new THREE.Face3(c,p,n,[q,m,r])),this.faceVertexUvs[0].push([t,w,u])}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,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(j=a.length;0<=--j;){A=j;F=j-1;0>F&&(F=a.length-1);for(var b=
-0,c=o+2*l,b=0;b<c;b++){var d=O*b,e=O*(b+1),f=ia+A+d,g=ia+A+e,k=f,d=ia+F+d,e=ia+F+e,m=g,k=k+E,d=d+E,e=e+E,m=m+E;B.faces.push(new THREE.Face4(k,d,e,m,null,null,u));void 0!==u&&(k=b/c,d=(b+1)/c,e=h+2*i,f=(B.vertices[f].position.z+i)/e,g=(B.vertices[g].position.z+i)/e,B.faceVertexUvs[0].push([new THREE.UV(f,k),new THREE.UV(g,k),new THREE.UV(g,d),new THREE.UV(f,d)]))}}}function f(a,b,c){B.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function g(a,b,c){a+=E;b+=E;c+=E;B.faces.push(new THREE.Face3(a,
-b,c,null,null,w));if(void 0!==w){var d=v.minX,e=v.minY,f=v.maxY,g=v.maxX,h=B.vertices[b].position.x-d,b=B.vertices[b].position.y-e,j=B.vertices[c].position.x-d,c=B.vertices[c].position.y-e;B.faceVertexUvs[0].push([new THREE.UV((B.vertices[a].position.x-d)/g,(B.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,k=void 0!==b.bevelSize?b.bevelSize:i-2,l=void 0!==b.bevelSegments?b.bevelSegments:
-3,p=void 0!==b.bevelEnabled?b.bevelEnabled:!0,m=void 0!==b.curveSegments?b.curveSegments:12,o=void 0!==b.steps?b.steps:1,q=b.bendPath,n=b.extrudePath,r,s=!1,t=void 0!==b.useSpacedPoints?b.useSpacedPoints:!1,w=b.material,u=b.extrudeMaterial,v=this.shapebb;if(n)r=n.getPoints(m),o=r.length,s=!0,p=!1;p||(k=i=l=0);var y,D,C,B=this,E=this.vertices.length;q&&a.addWrapPath(q);m=t?a.extractAllSpacedPoints(m):a.extractAllPoints(m);q=m.shape;m=m.holes;if(n=!THREE.Shape.Utils.isClockWise(q)){q=q.reverse();for(D=
-0,C=m.length;D<C;D++)y=m[D],THREE.Shape.Utils.isClockWise(y)&&(m[D]=y.reverse());n=!1}n=THREE.Shape.Utils.triangulateShape(q,m);t=q;for(D=0,C=m.length;D<C;D++)y=m[D],q=q.concat(y);for(var J,N,S,K,O=q.length,M=n.length,H=[],j=0,Z=t.length,A=Z-1,F=j+1;j<Z;j++,A++,F++)A===Z&&(A=0),F===Z&&(F=0),H[j]=d(t[j],t[A],t[F]);var P=[],R,ea=H.concat();for(D=0,C=m.length;D<C;D++){y=m[D];R=[];for(j=0,Z=y.length,A=Z-1,F=j+1;j<Z;j++,A++,F++)A===Z&&(A=0),F===Z&&(F=0),R[j]=d(y[j],y[A],y[F]);P.push(R);ea=ea.concat(R)}for(J=
-0;J<l;J++){N=J/l;S=i*(1-N);N=k*Math.sin(N*Math.PI/2);for(j=0,Z=t.length;j<Z;j++)K=c(t[j],H[j],N),f(K.x,K.y,-S);for(D=0,C=m.length;D<C;D++){y=m[D];R=P[D];for(j=0,Z=y.length;j<Z;j++)K=c(y[j],R[j],N),f(K.x,K.y,-S)}}N=k;for(j=0;j<O;j++)K=p?c(q[j],ea[j],N):q[j],s?f(K.x,K.y+r[0].y,r[0].x):f(K.x,K.y,0);for(J=1;J<=o;J++)for(j=0;j<O;j++)K=p?c(q[j],ea[j],N):q[j],s?f(K.x,K.y+r[J-1].y,r[J-1].x):f(K.x,K.y,h/o*J);for(J=l-1;0<=J;J--){N=J/l;S=i*(1-N);N=k*Math.sin(N*Math.PI/2);for(j=0,Z=t.length;j<Z;j++)K=c(t[j],
-H[j],N),f(K.x,K.y,h+S);for(D=0,C=m.length;D<C;D++){y=m[D];R=P[D];for(j=0,Z=y.length;j<Z;j++)K=c(y[j],R[j],N),s?f(K.x,K.y+r[o-1].y,r[o-1].x+S):f(K.x,K.y,h+S)}}if(p){p=0*O;for(j=0;j<M;j++)k=n[j],g(k[2]+p,k[1]+p,k[0]+p);p=O*(o+2*l);for(j=0;j<M;j++)k=n[j],g(k[0]+p,k[1]+p,k[2]+p)}else{for(j=0;j<M;j++)k=n[j],g(k[2],k[1],k[0]);for(j=0;j<M;j++)k=n[j],g(k[0]+O*o,k[1]+O*o,k[2]+O*o)}var ia=0;e(t);ia+=t.length;for(D=0,C=m.length;D<C;D++)y=m[D],e(y),ia+=y.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;
+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(j=a.length;0<=--j;){z=j;E=j-1;0>E&&(E=a.length-1);for(var b=
+0,c=o+2*l,b=0;b<c;b++){var d=P*b,e=P*(b+1),f=ia+z+d,g=ia+z+e,m=f,d=ia+E+d,e=ia+E+e,k=g,m=m+I,d=d+I,e=e+I,k=k+I;D.faces.push(new THREE.Face4(m,d,e,k,null,null,u));void 0!==u&&(m=b/c,d=(b+1)/c,e=h+2*i,f=(D.vertices[f].position.z+i)/e,g=(D.vertices[g].position.z+i)/e,D.faceVertexUvs[0].push([new THREE.UV(f,m),new THREE.UV(g,m),new THREE.UV(g,d),new THREE.UV(f,d)]))}}}function f(a,b,c){D.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function g(a,b,c){a+=I;b+=I;c+=I;D.faces.push(new THREE.Face3(a,
+b,c,null,null,w));if(void 0!==w){var d=v.minX,e=v.minY,f=v.maxY,g=v.maxX,h=D.vertices[b].position.x-d,b=D.vertices[b].position.y-e,j=D.vertices[c].position.x-d,c=D.vertices[c].position.y-e;D.faceVertexUvs[0].push([new THREE.UV((D.vertices[a].position.x-d)/g,(D.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,k=void 0!==b.bevelSize?b.bevelSize:i-2,l=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,w=b.material,u=b.extrudeMaterial,v=this.shapebb;if(m)r=m.getPoints(n),o=r.length,s=!0,p=!1;p||(k=i=l=0);var A,B,C,D=this,I=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(B=
+0,C=n.length;B<C;B++)A=n[B],THREE.Shape.Utils.isClockWise(A)&&(n[B]=A.reverse());m=!1}m=THREE.Shape.Utils.triangulateShape(q,n);t=q;for(B=0,C=n.length;B<C;B++)A=n[B],q=q.concat(A);for(var K,O,S,L,P=q.length,H=m.length,G=[],j=0,X=t.length,z=X-1,E=j+1;j<X;j++,z++,E++)z===X&&(z=0),E===X&&(E=0),G[j]=d(t[j],t[z],t[E]);var Q=[],N,ea=G.concat();for(B=0,C=n.length;B<C;B++){A=n[B];N=[];for(j=0,X=A.length,z=X-1,E=j+1;j<X;j++,z++,E++)z===X&&(z=0),E===X&&(E=0),N[j]=d(A[j],A[z],A[E]);Q.push(N);ea=ea.concat(N)}for(K=
+0;K<l;K++){O=K/l;S=i*(1-O);O=k*Math.sin(O*Math.PI/2);for(j=0,X=t.length;j<X;j++)L=c(t[j],G[j],O),f(L.x,L.y,-S);for(B=0,C=n.length;B<C;B++){A=n[B];N=Q[B];for(j=0,X=A.length;j<X;j++)L=c(A[j],N[j],O),f(L.x,L.y,-S)}}O=k;for(j=0;j<P;j++)L=p?c(q[j],ea[j],O):q[j],s?f(L.x,L.y+r[0].y,r[0].x):f(L.x,L.y,0);for(K=1;K<=o;K++)for(j=0;j<P;j++)L=p?c(q[j],ea[j],O):q[j],s?f(L.x,L.y+r[K-1].y,r[K-1].x):f(L.x,L.y,h/o*K);for(K=l-1;0<=K;K--){O=K/l;S=i*(1-O);O=k*Math.sin(O*Math.PI/2);for(j=0,X=t.length;j<X;j++)L=c(t[j],
+G[j],O),f(L.x,L.y,h+S);for(B=0,C=n.length;B<C;B++){A=n[B];N=Q[B];for(j=0,X=A.length;j<X;j++)L=c(A[j],N[j],O),s?f(L.x,L.y+r[o-1].y,r[o-1].x+S):f(L.x,L.y,h+S)}}if(p){p=0*P;for(j=0;j<H;j++)k=m[j],g(k[2]+p,k[1]+p,k[0]+p);p=P*(o+2*l);for(j=0;j<H;j++)k=m[j],g(k[0]+p,k[1]+p,k[2]+p)}else{for(j=0;j<H;j++)k=m[j],g(k[2],k[1],k[0]);for(j=0;j<H;j++)k=m[j],g(k[0]+P*o,k[1]+P*o,k[2]+P*o)}var ia=0;e(t);ia+=t.length;for(B=0,C=n.length;B<C;B++)A=n[B],e(A),ia+=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.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;this.angle=c||2*Math.PI;for(var b=this.angle/this.steps,c=[],d=[],e=[],f=[],g=(new THREE.Matrix4).setRotationZ(b),h=0;h<a.length;h++)this.vertices.push(new THREE.Vertex(a[h])),c[h]=a[h].clone(),d[h]=this.vertices.length-1;for(var i=0;i<=this.angle+0.0010;i+=b){for(h=0;h<c.length;h++)i<this.angle?(c[h]=g.multiplyVector3(c[h].clone()),this.vertices.push(new THREE.Vertex(c[h])),e[h]=this.vertices.length-1):e=f;0==i&&(f=d);
 for(h=0;h<d.length-1;h++)this.faces.push(new THREE.Face4(e[h],e[h+1],d[h+1],d[h])),this.faceVertexUvs[0].push([new THREE.UV(1-i/this.angle,h/a.length),new THREE.UV(1-i/this.angle,(h+1)/a.length),new THREE.UV(1-(i-b)/this.angle,(h+1)/a.length),new THREE.UV(1-(i-b)/this.angle,h/a.length)]);d=e;e=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
 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,k=b/d,l=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*k-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(l),e.vertexNormals.push(l.clone(),l.clone(),l.clone(),l.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,k=[],l=[];for(i=0;i<=c;i++){var p=[],m=[];for(h=0;h<=b;h++){var o=h/b,q=i/c,n=-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(n,r,s)));p.push(this.vertices.length-1);m.push(new THREE.UV(o,
-q))}k.push(p);l.push(m)}for(i=0;i<c;i++)for(h=0;h<b;h++){var d=k[i][h+1],e=k[i][h],f=k[i+1][h],g=k[i+1][h+1],p=this.vertices[d].position.clone().normalize(),m=this.vertices[e].position.clone().normalize(),o=this.vertices[f].position.clone().normalize(),q=this.vertices[g].position.clone().normalize(),n=l[i][h+1].clone(),r=l[i][h].clone(),s=l[i+1][h].clone(),t=l[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([n,
-s,t])):Math.abs(this.vertices[f].position.y)==a?(this.faces.push(new THREE.Face3(d,e,f,[p,m,o])),this.faceVertexUvs[0].push([n,r,s])):(this.faces.push(new THREE.Face4(d,e,f,g,[p,m,o,q])),this.faceVertexUvs[0].push([n,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,k=[],l=[];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))}k.push(p);l.push(n)}for(i=0;i<c;i++)for(h=0;h<b;h++){var d=k[i][h+1],e=k[i][h],f=k[i+1][h],g=k[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=l[i][h+1].clone(),r=l[i][h].clone(),s=l[i+1][h].clone(),t=l[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.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,k,l,p,m,o,q,n,r,s=b.glyphs[a]||b.glyphs["?"];if(s){if(s.o){b=s._cachedOutline||(s._cachedOutline=s.o.split(" "));k=b.length;for(a=0;a<k;)switch(i=b[a++],i){case "m":i=b[a++]*c+d;l=b[a++]*c;f.push(new THREE.Vector2(i,l));e.moveTo(i,l);break;case "l":i=b[a++]*c+d;l=b[a++]*c;f.push(new THREE.Vector2(i,
-l));e.lineTo(i,l);break;case "q":i=b[a++]*c+d;l=b[a++]*c;o=b[a++]*c+d;q=b[a++]*c;e.quadraticCurveTo(o,q,i,l);if(g=f[f.length-1]){p=g.x;m=g.y;for(g=1,h=this.divisions;g<=h;g++){var t=g/h,w=THREE.Shape.Utils.b2(t,p,o,i),t=THREE.Shape.Utils.b2(t,m,q,l);f.push(new THREE.Vector2(w,t))}}break;case "b":if(i=b[a++]*c+d,l=b[a++]*c,o=b[a++]*c+d,q=b[a++]*-c,n=b[a++]*c+d,r=b[a++]*-c,e.bezierCurveTo(i,l,o,q,n,r),g=f[f.length-1]){p=g.x;m=g.y;for(g=1,h=this.divisions;g<=h;g++)t=g/h,w=THREE.Shape.Utils.b3(t,p,o,
-n,i),t=THREE.Shape.Utils.b3(t,m,q,r,l),f.push(new THREE.Vector2(w,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,k,l;if(0<b(a))for(k=0;k<e;k++)g[k]=k;else for(k=0;k<e;k++)g[k]=e-1-k;var p=2*e;for(k=e-1;2<e;){if(0>=p--){console.log("Warning, unable to triangulate polygon!");break}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);l=k+1;e<=l&&(l=0);var m;a:{m=a;var o=i,q=k,n=l,r=e,s=g,t=void 0,w=void 0,u=void 0,v=void 0,y=void 0,
-D=void 0,C=void 0,B=void 0,E=void 0,w=m[s[o]].x,u=m[s[o]].y,v=m[s[q]].x,y=m[s[q]].y,D=m[s[n]].x,C=m[s[n]].y;if(1.0E-10>(v-w)*(C-u)-(y-u)*(D-w))m=!1;else{for(t=0;t<r;t++)if(!(t==o||t==q||t==n)){var B=m[s[t]].x,E=m[s[t]].y,J=void 0,N=void 0,S=void 0,K=void 0,O=void 0,M=void 0,H=void 0,j=void 0,Z=void 0,A=void 0,F=void 0,P=void 0,J=S=O=void 0,J=D-v,N=C-y,S=w-D,K=u-C,O=v-w,M=y-u,H=B-w,j=E-u,Z=B-v,A=E-y,F=B-D,P=E-C,J=J*A-N*Z,O=O*j-M*H,S=S*P-K*F;if(0<=J&&0<=S&&0<=O){m=!1;break a}}m=!0}}if(m){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,k,l,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(" "));k=b.length;for(a=0;a<k;)switch(i=b[a++],i){case "m":i=b[a++]*c+d;l=b[a++]*c;f.push(new THREE.Vector2(i,l));e.moveTo(i,l);break;case "l":i=b[a++]*c+d;l=b[a++]*c;f.push(new THREE.Vector2(i,
+l));e.lineTo(i,l);break;case "q":i=b[a++]*c+d;l=b[a++]*c;o=b[a++]*c+d;q=b[a++]*c;e.quadraticCurveTo(o,q,i,l);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,w=THREE.Shape.Utils.b2(t,p,o,i),t=THREE.Shape.Utils.b2(t,n,q,l);f.push(new THREE.Vector2(w,t))}}break;case "b":if(i=b[a++]*c+d,l=b[a++]*c,o=b[a++]*c+d,q=b[a++]*-c,m=b[a++]*c+d,r=b[a++]*-c,e.bezierCurveTo(i,l,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,w=THREE.Shape.Utils.b3(t,p,o,
+m,i),t=THREE.Shape.Utils.b3(t,n,q,r,l),f.push(new THREE.Vector2(w,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,k,l;if(0<b(a))for(k=0;k<e;k++)g[k]=k;else for(k=0;k<e;k++)g[k]=e-1-k;var p=2*e;for(k=e-1;2<e;){if(0>=p--){console.log("Warning, unable to triangulate polygon!");break}i=k;e<=i&&(i=0);k=i+1;e<=k&&(k=0);l=k+1;e<=l&&(l=0);var n;a:{n=a;var o=i,q=k,m=l,r=e,s=g,t=void 0,w=void 0,u=void 0,v=void 0,A=void 0,
+B=void 0,C=void 0,D=void 0,I=void 0,w=n[s[o]].x,u=n[s[o]].y,v=n[s[q]].x,A=n[s[q]].y,B=n[s[m]].x,C=n[s[m]].y;if(1.0E-10>(v-w)*(C-u)-(A-u)*(B-w))n=!1;else{for(t=0;t<r;t++)if(!(t==o||t==q||t==m)){var D=n[s[t]].x,I=n[s[t]].y,K=void 0,O=void 0,S=void 0,L=void 0,P=void 0,H=void 0,G=void 0,j=void 0,X=void 0,z=void 0,E=void 0,Q=void 0,K=S=P=void 0,K=B-v,O=C-A,S=w-B,L=u-C,P=v-w,H=A-u,G=D-w,j=I-u,X=D-v,z=I-A,E=D-B,Q=I-C,K=K*z-O*X,P=P*j-H*G,S=S*Q-L*E;if(0<=K&&0<=S&&0<=P){n=!1;break a}}n=!0}}if(n){f.push([a[g[i]],
 a[g[k]],a[g[l]]]);h.push([g[i],g[k],g[l]]);for(i=k,l=k+1;l<e;i++,l++)g[i]=g[l];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);
@@ -575,13 +577,13 @@ this.update(a);this.lines=new THREE.Line(this.lineGeometry,this.lineMaterial,THR
 THREE.CameraHelper.prototype.update=function(a){function b(a,b,f,g){THREE.CameraHelper.__v.set(b,f,g);THREE.CameraHelper.__projector.unprojectVector(THREE.CameraHelper.__v,THREE.CameraHelper.__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.CameraHelper.__v)}}var c=this;THREE.CameraHelper.__c.projectionMatrix.copy(a.projectionMatrix);b("c",0,0,-1);b("t",0,0,1);b("n1",-1,-1,-1);b("n2",1,-1,-1);b("n3",-1,1,-1);b("n4",1,1,-1);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,-1);b("u2",-0.7,1.1,-1);b("u3",0,2,-1);b("cf1",-1,0,1);b("cf2",1,0,1);b("cf3",0,-1,1);b("cf4",0,1,1);b("cn1",-1,0,-1);b("cn2",1,0,-1);b("cn3",0,-1,-1);b("cn4",0,1,-1);this.lineGeometry.__dirtyVertices=!0};THREE.CameraHelper.__projector=new THREE.Projector;THREE.CameraHelper.__v=new THREE.Vector3;THREE.CameraHelper.__c=new THREE.Camera;
 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,n,p,o=0;4>o;o++){p=i[o];l=new THREE.Color;l.setRGB(0,0,0);for(var q=0;q<p.length;q++)n=h.vertexColors[p[q]-1],l.r+=n.r,l.g+=n.g,l.b+=n.b;l.r/=p.length;l.g/=p.length;l.b/=p.length;k.vertexColors[o]=l}}e.push(k);(!g.supportUVs||0!=m.length)&&f.push([m[a],m[b],m[c],m[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(),k=[],l={},p={},m=[],o,q,n,r,s,t=a.faceVertexUvs[0];for(o=0,q=t.length;o<q;o++)for(n=0,r=t[o].length;n<r;n++)s=d[o]["abcd".charAt(n)],m[s]||(m[s]=t[o][n]);var w;for(o=0,q=d.length;o<q;o++)if(s=d[o],k.push(s.centroid),i.push(new THREE.Vertex(s.centroid)),g.supportUVs&&0!=m.length){w=new THREE.UV;if(s instanceof THREE.Face3)w.u=m[s.a].u+m[s.b].u+m[s.c].u,w.v=m[s.a].v+m[s.b].v+m[s.c].v,w.u/=3,w.v/=3;else if(s instanceof THREE.Face4)w.u=
-m[s.a].u+m[s.b].u+m[s.c].u+m[s.d].u,w.v=m[s.a].v+m[s.b].v+m[s.c].v+m[s.d].v,w.u/=4,w.v/=4;m.push(w)}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 u=0,t=h.length,v,y,D={},C={},B=function(a,
-b){void 0===D[a]&&(D[a]=[]);D[a].push(b)},E=function(a,b){void 0===C[a]&&(C[a]={});C[a][b]=null};for(o in q){w=q[o];v=o.split("_");y=v[0];v=v[1];B(y,[y,v]);B(v,[y,v]);for(n=0,r=w.length;n<r;n++)s=w[n],E(y,s,o),E(v,s,o);2>w.length&&(p[o]=!0)}for(o in q)if(w=q[o],s=w[0],w=w[1],v=o.split("_"),y=v[0],v=v[1],r=new THREE.Vector3,p[o]?(r.addSelf(h[y].position),r.addSelf(h[v].position),r.multiplyScalar(0.5)):(r.addSelf(k[s]),r.addSelf(k[w]),r.addSelf(h[y].position),r.addSelf(h[v].position),r.multiplyScalar(0.25)),
-l[o]=t+d.length+u,i.push(new THREE.Vertex(r)),u++,g.supportUVs&&0!=m.length)w=new THREE.UV,w.u=m[y].u+m[v].u,w.v=m[y].v+m[v].v,w.u/=2,w.v/=2,m.push(w);var J,N;v=["123","12","2","23"];r=["123","23","3","31"];var B=["123","31","1","12"],E=["1234","12","2","23"],S=["1234","23","3","34"],K=["1234","34","4","41"],O=["1234","41","1","12"];for(o=0,q=k.length;o<q;o++)s=d[o],w=t+o,s instanceof THREE.Face3?(u=c(s.a,s.b),y=c(s.b,s.c),J=c(s.c,s.a),b(w,l[u],s.b,l[y],s,v),b(w,l[y],s.c,l[J],s,r),b(w,l[J],s.a,l[u],
-s,B)):s instanceof THREE.Face4?(u=c(s.a,s.b),y=c(s.b,s.c),J=c(s.c,s.d),N=c(s.d,s.a),b(w,l[u],s.b,l[y],s,E),b(w,l[y],s.c,l[J],s,S),b(w,l[J],s.d,l[N],s,K),b(w,l[N],s.a,l[u],s,O)):console.log("face should be a face!",s);d=i;i=new THREE.Vector3;l=new THREE.Vector3;for(o=0,q=h.length;o<q;o++)if(void 0!==D[o]){i.set(0,0,0);l.set(0,0,0);s=new THREE.Vector3(0,0,0);w=0;for(n in C[o])i.addSelf(k[n]),w++;u=0;t=D[o].length;for(n=0;n<t;n++)p[c(D[o][n][0],D[o][n][1])]&&u++;if(2!=u){i.divideScalar(w);for(n=0;n<
-t;n++)w=D[o][n],w=h[w[0]].position.clone().addSelf(h[w[1]].position).divideScalar(2),l.addSelf(w);l.divideScalar(t);s.addSelf(h[o].position);s.multiplyScalar(t-3);s.addSelf(i);s.addSelf(l.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 m=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(g.useOldVertexColors){m.vertexColors=[];for(var k,l,p,o=0;4>o;o++){p=i[o];k=new THREE.Color;k.setRGB(0,0,0);for(var q=0;q<p.length;q++)l=h.vertexColors[p[q]-1],k.r+=l.r,k.g+=l.g,k.b+=l.b;k.r/=p.length;k.g/=p.length;k.b/=p.length;m.vertexColors[o]=k}}e.push(m);(!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(),k=[],l={},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 w;for(o=0,q=d.length;o<q;o++)if(s=d[o],k.push(s.centroid),i.push(new THREE.Vertex(s.centroid)),g.supportUVs&&0!=n.length){w=new THREE.UV;if(s instanceof THREE.Face3)w.u=n[s.a].u+n[s.b].u+n[s.c].u,w.v=n[s.a].v+n[s.b].v+n[s.c].v,w.u/=3,w.v/=3;else if(s instanceof THREE.Face4)w.u=
+n[s.a].u+n[s.b].u+n[s.c].u+n[s.d].u,w.v=n[s.a].v+n[s.b].v+n[s.c].v+n[s.d].v,w.u/=4,w.v/=4;n.push(w)}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 u=0,t=h.length,v,A,B={},C={},D=function(a,
+b){void 0===B[a]&&(B[a]=[]);B[a].push(b)},I=function(a,b){void 0===C[a]&&(C[a]={});C[a][b]=null};for(o in q){w=q[o];v=o.split("_");A=v[0];v=v[1];D(A,[A,v]);D(v,[A,v]);for(m=0,r=w.length;m<r;m++)s=w[m],I(A,s,o),I(v,s,o);2>w.length&&(p[o]=!0)}for(o in q)if(w=q[o],s=w[0],w=w[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(k[s]),r.addSelf(k[w]),r.addSelf(h[A].position),r.addSelf(h[v].position),r.multiplyScalar(0.25)),
+l[o]=t+d.length+u,i.push(new THREE.Vertex(r)),u++,g.supportUVs&&0!=n.length)w=new THREE.UV,w.u=n[A].u+n[v].u,w.v=n[A].v+n[v].v,w.u/=2,w.v/=2,n.push(w);var K,O;v=["123","12","2","23"];r=["123","23","3","31"];var D=["123","31","1","12"],I=["1234","12","2","23"],S=["1234","23","3","34"],L=["1234","34","4","41"],P=["1234","41","1","12"];for(o=0,q=k.length;o<q;o++)s=d[o],w=t+o,s instanceof THREE.Face3?(u=c(s.a,s.b),A=c(s.b,s.c),K=c(s.c,s.a),b(w,l[u],s.b,l[A],s,v),b(w,l[A],s.c,l[K],s,r),b(w,l[K],s.a,l[u],
+s,D)):s instanceof THREE.Face4?(u=c(s.a,s.b),A=c(s.b,s.c),K=c(s.c,s.d),O=c(s.d,s.a),b(w,l[u],s.b,l[A],s,I),b(w,l[A],s.c,l[K],s,S),b(w,l[K],s.d,l[O],s,L),b(w,l[O],s.a,l[u],s,P)):console.log("face should be a face!",s);d=i;i=new THREE.Vector3;l=new THREE.Vector3;for(o=0,q=h.length;o<q;o++)if(void 0!==B[o]){i.set(0,0,0);l.set(0,0,0);s=new THREE.Vector3(0,0,0);w=0;for(m in C[o])i.addSelf(k[m]),w++;u=0;t=B[o].length;for(m=0;m<t;m++)p[c(B[o][m][0],B[o][m][1])]&&u++;if(2!=u){i.divideScalar(w);for(m=0;m<
+t;m++)w=B[o][m],w=h[w[0]].position.clone().addSelf(h[w[1]].position).divideScalar(2),l.addSelf(w);l.divideScalar(t);s.addSelf(h[o].position);s.multiplyScalar(t-3);s.addSelf(i);s.addSelf(l.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.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:"anonymous",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=
@@ -597,127 +599,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,k,l,p,m,o,q,n,r,s,t,w,u,v;function y(a){return a%4?4-a%4:0}function D(a,b){return(new Uint8Array(a,b,1))[0]}function C(a,b){return(new Uint32Array(a,b,1))[0]}function B(b,c){var d,e,f,g,h,i,k,l,m=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=m[3*d];f=m[3*d+1];g=m[3*d+2];h=j[2*e];e=j[2*e+1];i=j[2*f];k=j[2*f+1];f=j[2*g];l=j[2*g+1];g=O.faceVertexUvs[0];var n=[];n.push(new THREE.UV(h,e));n.push(new THREE.UV(i,k));
-n.push(new THREE.UV(f,l));g.push(n)}}function E(b,c){var d,e,f,g,h,i,k,l,m,n,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=j[2*e];e=j[2*e+1];k=j[2*f];m=j[2*f+1];l=j[2*g];n=j[2*g+1];g=j[2*h];f=j[2*h+1];h=O.faceVertexUvs[0];var p=[];p.push(new THREE.UV(i,e));p.push(new THREE.UV(k,m));p.push(new THREE.UV(l,n));p.push(new THREE.UV(g,f));h.push(p)}}function J(b,c,d){for(var e,f,g,h,c=new Uint32Array(a,c,3*b),j=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=j[d],O.faces.push(new THREE.Face3(e,f,g,null,null,h))}function N(b,c,d){for(var e,f,g,h,j,c=new Uint32Array(a,c,4*b),i=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],j=i[d],O.faces.push(new THREE.Face4(e,f,g,h,null,null,j))}function S(b,c,d,e){for(var f,g,h,j,i,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];i=d[3*e];k=d[3*e+1];l=d[3*e+2];j=m[e];var n=H[3*k],o=H[3*k+1];k=
-H[3*k+2];var p=H[3*l],q=H[3*l+1];l=H[3*l+2];O.faces.push(new THREE.Face3(f,g,h,[new THREE.Vector3(H[3*i],H[3*i+1],H[3*i+2]),new THREE.Vector3(n,o,k),new THREE.Vector3(p,q,l)],null,j))}}function K(b,c,d,e){for(var f,g,h,j,i,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];j=c[4*e+3];k=d[4*e];l=d[4*e+1];m=d[4*e+2];n=d[4*e+3];i=o[e];var p=H[3*l],q=H[3*l+1];l=H[3*l+2];var r=H[3*m],s=H[3*m+1];m=H[3*m+2];var t=H[3*n],u=H[3*
-n+1];n=H[3*n+2];O.faces.push(new THREE.Face4(f,g,h,j,[new THREE.Vector3(H[3*k],H[3*k+1],H[3*k+2]),new THREE.Vector3(p,q,l),new THREE.Vector3(r,s,m),new THREE.Vector3(t,u,n)],null,i))}}var O=this,M=0,H=[],j=[],Z,A;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(O,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,M,12);e=D(a,M+12);D(a,M+13);D(a,M+14);D(a,M+15);i=D(a,M+16);k=D(a,M+17);l=D(a,M+18);p=D(a,M+19);m=C(a,M+20);
-o=C(a,M+20+4);q=C(a,M+20+8);b=C(a,M+20+12);n=C(a,M+20+16);r=C(a,M+20+20);s=C(a,M+20+24);t=C(a,M+20+28);w=C(a,M+20+32);u=C(a,M+20+36);v=C(a,M+20+40);"Three.js 003"!==c&&console.warn("DEPRECATED: binary model seems to be using old format");M+=e;c=3*i+p;A=4*i+p;e=b*c;Z=n*(c+3*k);i=r*(c+3*l);p=s*(c+3*k+3*l);c=t*A;k=w*(A+4*k);l=u*(A+4*l);M+=function(b){var b=new Float32Array(a,b,3*m),c,d,e,f;for(c=0;c<m;c++)d=b[3*c],e=b[3*c+1],f=b[3*c+2],O.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,f)));return 3*
-m*Float32Array.BYTES_PER_ELEMENT}(M);M+=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],H.push(d/127,e/127,f/127)}return 3*o*Int8Array.BYTES_PER_ELEMENT}(M);M+=y(3*o);M+=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],j.push(d,e)}return 2*q*Float32Array.BYTES_PER_ELEMENT}(M);e=M+e+y(2*b);Z=e+Z+y(2*n);i=Z+i+y(2*r);p=i+p+y(2*s);c=p+c+y(2*t);k=c+k+y(2*w);l=k+l+y(2*u);(function(a){if(r){var b=a+3*r*Uint32Array.BYTES_PER_ELEMENT;
-J(r,a,b+3*r*Uint32Array.BYTES_PER_ELEMENT);B(r,b)}})(Z);(function(a){if(s){var b=a+3*s*Uint32Array.BYTES_PER_ELEMENT,c=b+3*s*Uint32Array.BYTES_PER_ELEMENT;S(s,a,b,c+3*s*Uint32Array.BYTES_PER_ELEMENT);B(s,c)}})(i);(function(a){if(u){var b=a+4*u*Uint32Array.BYTES_PER_ELEMENT;N(u,a,b+4*u*Uint32Array.BYTES_PER_ELEMENT);E(u,b)}})(k);(function(a){if(v){var b=a+4*v*Uint32Array.BYTES_PER_ELEMENT,c=b+4*v*Uint32Array.BYTES_PER_ELEMENT;K(v,a,b,c+4*v*Uint32Array.BYTES_PER_ELEMENT);E(v,c)}})(l);b&&J(b,M,M+3*b*
-Uint32Array.BYTES_PER_ELEMENT);(function(a){if(n){var b=a+3*n*Uint32Array.BYTES_PER_ELEMENT;S(n,a,b,b+3*n*Uint32Array.BYTES_PER_ELEMENT)}})(e);t&&N(t,p,p+4*t*Uint32Array.BYTES_PER_ELEMENT);(function(a){if(w){var b=a+4*w*Uint32Array.BYTES_PER_ELEMENT;K(w,a,b,b+4*w*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){U=a;d=d||Ta;void 0!==e&&(a=e.split("/"),a.pop(),Sa=1>a.length?"":a.join("/")+"/");if((a=U.evaluate("//dae:asset",U,F,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(e=0;e<a.childNodes.length;e++){var j=a.childNodes[e];switch(j.nodeName){case "unit":(j=j.getAttribute("meter"))&&parseFloat(j);break;case "up_axis":Ha=j.textContent.charAt(0)}}if(!Qa.convertUpAxis||Ha===Qa.upAxis)Wa=null;else switch(Ha){case "X":Wa="Y"===Qa.upAxis?
-"XtoY":"XtoZ";break;case "Y":Wa="X"===Qa.upAxis?"YtoX":"YtoZ";break;case "Z":Wa="X"===Qa.upAxis?"ZtoX":"ZtoY"}Ka=b("//dae:library_images/dae:image",g,"image");db=b("//dae:library_materials/dae:material",C,"material");lb=b("//dae:library_effects/dae:effect",S,"effect");ka=b("//dae:library_geometries/dae:geometry",r,"geometry");eb=b(".//dae:library_cameras/dae:camera",Z,"camera");Ba=b("//dae:library_controllers/dae:controller",h,"controller");Ea=b("//dae:library_animations/dae:animation",O,"animation");
-$a=b(".//dae:library_visual_scenes/dae:visual_scene",l,"visual_scene");Fa=[];ya=[];(a=U.evaluate(".//dae:scene/dae:instance_visual_scene",U,F,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),ha=$a[a]):ha=null;aa=new THREE.Object3D;for(a=0;a<ha.nodes.length;a++)aa.add(f(ha.nodes[a]));Za=[];c(aa);a={scene:aa,morphs:Fa,skins:ya,animations:Za,dae:{images:Ka,materials:db,cameras:eb,effects:lb,geometries:ka,controllers:Ba,animations:Ea,visualScenes:$a,
-scene:ha}};d&&d(a);return a}function b(a,b,c){for(var a=U.evaluate(a,U,F,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=ha.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};Za.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=Ba[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 Ea)for(var j=Ea[e],i=0;i<j.sampler.length;i++){var k=j.sampler[i];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=ha.getChildById(b.skeleton[0],!0)||ha.getChildBySid(b.skeleton[0],!0),l,m,g=new THREE.Vector3,n,i=0;i<a.vertices.length;i++)f.skin.bindShapeMatrix.multiplyVector3(a.vertices[i].position);
-for(c=0;c<e;c++){h=[];j=[];for(i=0;i<a.vertices.length;i++)j.push(new THREE.Vertex(new THREE.Vector3));d(b,h,c);i=h;k=f.skin;for(m=0;m<i.length;m++)if(l=i[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(i=0;i<h.length;i++)if("JOINT"==h[i].type)for(k=0;k<h[i].weights.length;k++)l=h[i].weights[k],m=l.index,l=l.weight,n=a.vertices[m],m=j[m],g.x=n.position.x,g.y=n.position.y,g.z=n.position.z,h[i].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:j})}}}function f(a){var b=new THREE.Object3D,c,d,g,h;for(g=0;g<a.controllers.length;g++){var i=Ba[a.controllers[g].url];switch(i.type){case "skin":if(ka[i.skin.source]){var j=
-new n;j.url=i.skin.source;j.instance_material=a.controllers[g].instance_material;a.geometries.push(j);c=a.controllers[g]}else if(Ba[i.skin.source]&&(d=i=Ba[i.skin.source],i.morph&&ka[i.morph.source]))j=new n,j.url=i.morph.source,j.instance_material=a.controllers[g].instance_material,a.geometries.push(j);break;case "morph":if(ka[i.morph.source])j=new n,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=ka[i.url],k={},l=[],m=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=lb[db[p.target].instance_effect.url].shader;q.material.opacity=!q.material.opacity?1:q.material.opacity;k[p.symbol]=m;l.push(q.material);p=q.material;m++}j=p||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});i=i.mesh.geometry3js;if(1<m){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=Ba[c.url],j.skinInstanceController=c,j.name="skin_"+ya.length,ya.push(j);else if(void 0!==d){h=i;k=d instanceof o?Ba[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(m=ka[k.targets[l]],m.mesh&&m.mesh.primitives&&m.mesh.primitives.length)m=m.mesh.primitives[0].geometry,
-m.vertices.length===h.vertices.length&&h.morphTargets.push({name:"target_1",vertices:m.vertices});h.morphTargets.push({name:"target_Z",vertices:h.vertices})}j.morphTargets=!0;j=new THREE.Mesh(i,j);j.name="morph_"+Fa.length;Fa.push(j)}else j=new THREE.Mesh(i,j);1<a.geometries.length?b.add(j):b=j}}for(g=0;g<a.cameras.length;g++)b=eb[a.cameras[g].url],b=new THREE.PerspectiveCamera(b.fov,b.aspect_ratio,b.znear,b.zfar);b.name=a.id||"";b.matrix=a.matrix;g=a.matrix.decompose();b.position=g[0];b.quaternion=
-g[1];b.useQuaternion=!0;b.scale=g[2];Qa.centerGeometry&&b.geometry&&(g=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(g.multiplySelf(b.scale)),b.position.subSelf(g));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 k(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];
-this.joints=[];this.weights=[]}function l(){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 m(){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 n(){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 w(){this.material="";this.count=0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function u(){this.source="";this.stride=this.count=0;this.params=[]}function v(){this.input={}}function y(){this.semantic="";this.offset=0;this.source="";this.set=0}function D(a){this.id=a;this.type=null}function C(){this.name=this.id="";this.instance_effect=null}
-function B(){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 E(a,b){this.type=a;this.effect=b;this.material=null}function J(a){this.effect=a;this.format=this.init_from=null}function N(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function S(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function K(){this.url=""}
-function O(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function M(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=this.dotSyntax=this.sid=this.fullSid=null}function H(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 j(a){this.targets=[];this.time=a}function Z(){this.name=this.id=""}function A(){this.url=""}function F(a){return"dae"==
-a?"http://www.collada.org/2005/11/COLLADASchema":null}function P(a){for(var a=ea(a),b=[],c=0,d=a.length;c<d;c++)b.push(parseFloat(a[c]));return b}function R(a){for(var a=ea(a),b=[],c=0,d=a.length;c<d;c++)b.push(parseInt(a[c],10));return b}function ea(a){return 0<a.length?a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/):[]}function ia(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function ca(a,b){if(Qa.convertUpAxis&&Ha!==Qa.upAxis)switch(Wa){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 V(a,b){var c=[a[b],a[b+1],a[b+2]];ca(c,-1);return new THREE.Vector3(c[0],c[1],c[2])}function ba(a){if(Qa.convertUpAxis){var b=[a[0],a[4],a[8]];ca(b,-1);a[0]=b[0];a[4]=b[1];a[8]=b[2];b=[a[1],a[5],a[9]];ca(b,-1);a[1]=b[0];a[5]=b[1];a[9]=b[2];b=[a[2],
-a[6],a[10]];ca(b,-1);a[2]=b[0];a[6]=b[1];a[10]=b[2];b=[a[0],a[1],a[2]];ca(b,-1);a[0]=b[0];a[1]=b[1];a[2]=b[2];b=[a[4],a[5],a[6]];ca(b,-1);a[4]=b[0];a[5]=b[1];a[6]=b[2];b=[a[8],a[9],a[10]];ca(b,-1);a[8]=b[0];a[9]=b[1];a[10]=b[2];b=[a[3],a[7],a[11]];ca(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 U=null,aa=null,ha,Ta=null,oa={},Ka={},Ea={},Ba={},ka={},db={},lb={},eb={},Za,$a,Sa,Fa,ya,za=THREE.SmoothShading,
-Qa={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y"},Ha="Y",Wa=null,mb=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 k).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 y).parse(d))}}return b};k.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=P(f.textContent);this.bindShapeMatrix=ba(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};k.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 y).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()}}};k.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 y).parse(g));break;case "v":c=R(g.textContent);break;case "vcount":d=R(g.textContent)}}for(f=g=0;f<d.length;f++){for(var h=d[f],j=[],i=0;i<h;i++){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]}}j.push(k);g+=e.length}for(i=0;i<j.length;i++)j[i].index=f;this.weights.push(j)}};l.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};l.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};l.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");
+THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var e=function(b){var c,e,i,k,l,p,n,o,q,m,r,s,t,w,u,v;function A(a){return a%4?4-a%4:0}function B(a,b){return(new Uint8Array(a,b,1))[0]}function C(a,b){return(new Uint32Array(a,b,1))[0]}function D(b,c){var d,e,f,g,h,i,k,m,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=j[2*e];e=j[2*e+1];i=j[2*f];k=j[2*f+1];f=j[2*g];m=j[2*g+1];g=P.faceVertexUvs[0];var n=[];n.push(new THREE.UV(h,e));n.push(new THREE.UV(i,k));
+n.push(new THREE.UV(f,m));g.push(n)}}function I(b,c){var d,e,f,g,h,i,k,m,l,n,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=j[2*e];e=j[2*e+1];k=j[2*f];l=j[2*f+1];m=j[2*g];n=j[2*g+1];g=j[2*h];f=j[2*h+1];h=P.faceVertexUvs[0];var p=[];p.push(new THREE.UV(i,e));p.push(new THREE.UV(k,l));p.push(new THREE.UV(m,n));p.push(new THREE.UV(g,f));h.push(p)}}function K(b,c,d){for(var e,f,g,h,c=new Uint32Array(a,c,3*b),j=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=j[d],P.faces.push(new THREE.Face3(e,f,g,null,null,h))}function O(b,c,d){for(var e,f,g,h,j,c=new Uint32Array(a,c,4*b),i=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],j=i[d],P.faces.push(new THREE.Face4(e,f,g,h,null,null,j))}function S(b,c,d,e){for(var f,g,h,j,i,k,m,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),l=new Uint16Array(a,e,b),e=0;e<b;e++){f=c[3*e];g=c[3*e+1];h=c[3*e+2];i=d[3*e];k=d[3*e+1];m=d[3*e+2];j=l[e];var n=G[3*k],o=G[3*k+1];k=
+G[3*k+2];var p=G[3*m],q=G[3*m+1];m=G[3*m+2];P.faces.push(new THREE.Face3(f,g,h,[new THREE.Vector3(G[3*i],G[3*i+1],G[3*i+2]),new THREE.Vector3(n,o,k),new THREE.Vector3(p,q,m)],null,j))}}function L(b,c,d,e){for(var f,g,h,j,i,k,m,l,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];j=c[4*e+3];k=d[4*e];m=d[4*e+1];l=d[4*e+2];n=d[4*e+3];i=o[e];var p=G[3*m],q=G[3*m+1];m=G[3*m+2];var r=G[3*l],s=G[3*l+1];l=G[3*l+2];var t=G[3*n],u=G[3*
+n+1];n=G[3*n+2];P.faces.push(new THREE.Face4(f,g,h,j,[new THREE.Vector3(G[3*k],G[3*k+1],G[3*k+2]),new THREE.Vector3(p,q,m),new THREE.Vector3(r,s,l),new THREE.Vector3(t,u,n)],null,i))}}var P=this,H=0,G=[],j=[],X,z;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,H,12);e=B(a,H+12);B(a,H+13);B(a,H+14);B(a,H+15);i=B(a,H+16);k=B(a,H+17);l=B(a,H+18);p=B(a,H+19);n=C(a,H+20);
+o=C(a,H+20+4);q=C(a,H+20+8);b=C(a,H+20+12);m=C(a,H+20+16);r=C(a,H+20+20);s=C(a,H+20+24);t=C(a,H+20+28);w=C(a,H+20+32);u=C(a,H+20+36);v=C(a,H+20+40);"Three.js 003"!==c&&console.warn("DEPRECATED: binary model seems to be using old format");H+=e;c=3*i+p;z=4*i+p;e=b*c;X=m*(c+3*k);i=r*(c+3*l);p=s*(c+3*k+3*l);c=t*z;k=w*(z+4*k);l=u*(z+4*l);H+=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}(H);H+=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],G.push(d/127,e/127,f/127)}return 3*o*Int8Array.BYTES_PER_ELEMENT}(H);H+=A(3*o);H+=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],j.push(d,e)}return 2*q*Float32Array.BYTES_PER_ELEMENT}(H);e=H+e+A(2*b);X=e+X+A(2*m);i=X+i+A(2*r);p=i+p+A(2*s);c=p+c+A(2*t);k=c+k+A(2*w);l=k+l+A(2*u);(function(a){if(r){var b=a+3*r*Uint32Array.BYTES_PER_ELEMENT;
+K(r,a,b+3*r*Uint32Array.BYTES_PER_ELEMENT);D(r,b)}})(X);(function(a){if(s){var b=a+3*s*Uint32Array.BYTES_PER_ELEMENT,c=b+3*s*Uint32Array.BYTES_PER_ELEMENT;S(s,a,b,c+3*s*Uint32Array.BYTES_PER_ELEMENT);D(s,c)}})(i);(function(a){if(u){var b=a+4*u*Uint32Array.BYTES_PER_ELEMENT;O(u,a,b+4*u*Uint32Array.BYTES_PER_ELEMENT);I(u,b)}})(k);(function(a){if(v){var b=a+4*v*Uint32Array.BYTES_PER_ELEMENT,c=b+4*v*Uint32Array.BYTES_PER_ELEMENT;L(v,a,b,c+4*v*Uint32Array.BYTES_PER_ELEMENT);I(v,c)}})(l);b&&K(b,H,H+3*b*
+Uint32Array.BYTES_PER_ELEMENT);(function(a){if(m){var b=a+3*m*Uint32Array.BYTES_PER_ELEMENT;S(m,a,b,b+3*m*Uint32Array.BYTES_PER_ELEMENT)}})(e);t&&O(t,p,p+4*t*Uint32Array.BYTES_PER_ELEMENT);(function(a){if(w){var b=a+4*w*Uint32Array.BYTES_PER_ELEMENT;L(w,a,b,b+4*w*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){Y=a;d=d||Ua;void 0!==e&&(a=e.split("/"),a.pop(),$a=1>a.length?"":a.join("/")+"/");if((a=Y.evaluate("//dae:asset",Y,E,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(e=0;e<a.childNodes.length;e++){var j=a.childNodes[e];switch(j.nodeName){case "unit":(j=j.getAttribute("meter"))&&parseFloat(j);break;case "up_axis":Ga=j.textContent.charAt(0)}}if(!Fa.convertUpAxis||Ga===Fa.upAxis)Xa=null;else switch(Ga){case "X":Xa="Y"===Fa.upAxis?
+"XtoY":"XtoZ";break;case "Y":Xa="X"===Fa.upAxis?"YtoX":"YtoZ";break;case "Z":Xa="X"===Fa.upAxis?"ZtoX":"ZtoY"}na=b("//dae:library_images/dae:image",g,"image");ib=b("//dae:library_materials/dae:material",C,"material");Va=b("//dae:library_effects/dae:effect",S,"effect");qa=b("//dae:library_geometries/dae:geometry",r,"geometry");lb=b(".//dae:library_cameras/dae:camera",X,"camera");ra=b("//dae:library_controllers/dae:controller",h,"controller");Ha=b("//dae:library_animations/dae:animation",P,"animation");
+Wa=b(".//dae:library_visual_scenes/dae:visual_scene",l,"visual_scene");La=[];ta=[];(a=Y.evaluate(".//dae:scene/dae:instance_visual_scene",Y,E,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),fa=Wa[a]):fa=null;ca=new THREE.Object3D;for(a=0;a<fa.nodes.length;a++)ca.add(f(fa.nodes[a]));db=[];c(ca);a={scene:ca,morphs:La,skins:ta,animations:db,dae:{images:na,materials:ib,cameras:lb,effects:Va,geometries:qa,controllers:ra,animations:Ha,visualScenes:Wa,
+scene:fa}};d&&d(a);return a}function b(a,b,c){for(var a=Y.evaluate(a,Y,E,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=fa.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};db.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=ra[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 Ha)for(var j=Ha[e],i=0;i<j.sampler.length;i++){var m=j.sampler[i];m.create();c=Math.min(c,m.startTime);g=Math.max(g,m.endTime);h=Math.max(h,m.input.length)}e=h;for(var b=fa.getChildById(b.skeleton[0],!0)||fa.getChildBySid(b.skeleton[0],!0),k,l,g=new THREE.Vector3,n,i=0;i<a.vertices.length;i++)f.skin.bindShapeMatrix.multiplyVector3(a.vertices[i].position);
+for(c=0;c<e;c++){h=[];j=[];for(i=0;i<a.vertices.length;i++)j.push(new THREE.Vertex(new THREE.Vector3));d(b,h,c);i=h;m=f.skin;for(l=0;l<i.length;l++)if(k=i[l],n=-1,"JOINT"==k.type){for(var o=0;o<m.joints.length;o++)if(k.sid==m.joints[o]){n=o;break}if(0<=n){o=m.invBindMatrices[n];k.invBindMatrix=o;k.skinningMatrix=new THREE.Matrix4;k.skinningMatrix.multiply(k.world,o);k.weights=[];for(o=0;o<m.weights.length;o++)for(var p=0;p<m.weights[o].length;p++){var q=m.weights[o][p];q.joint==n&&k.weights.push(q)}}else throw"ColladaLoader: Could not find joint '"+
+k.sid+"'.";}for(i=0;i<h.length;i++)if("JOINT"==h[i].type)for(m=0;m<h[i].weights.length;m++)k=h[i].weights[m],l=k.index,k=k.weight,n=a.vertices[l],l=j[l],g.x=n.position.x,g.y=n.position.y,g.z=n.position.z,h[i].skinningMatrix.multiplyVector3(g),l.position.x+=g.x*k,l.position.y+=g.y*k,l.position.z+=g.z*k;a.morphTargets.push({name:"target_"+c,vertices:j})}}}function f(a){var b=new THREE.Object3D,c,d,g,h;for(g=0;g<a.controllers.length;g++){var j=ra[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(ra[j.skin.source]&&(d=j=ra[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],k={},l=[],n=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=Va[ib[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++}i=p||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});j=j.mesh.geometry3js;if(1<n){i=new THREE.MeshFaceMaterial;j.materials=
+l;for(h=0;h<j.faces.length;h++)l=j.faces[h],l.materialIndex=k[l.daeMaterial]}if(void 0!==c)e(j,c),i.morphTargets=!0,i=new THREE.SkinnedMesh(j,i),i.skeleton=c.skeleton,i.skinController=ra[c.url],i.skinInstanceController=c,i.name="skin_"+ta.length,ta.push(i);else if(void 0!==d){h=j;k=d instanceof o?ra[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})}i.morphTargets=!0;i=new THREE.Mesh(j,i);i.name="morph_"+La.length;La.push(i)}else i=new THREE.Mesh(j,i);1<a.geometries.length?b.add(i):b=i}}for(g=0;g<a.cameras.length;g++)b=lb[a.cameras[g].url],b=new THREE.PerspectiveCamera(b.fov,b.aspect_ratio,b.znear,b.zfar);b.name=a.id||"";b.matrix=a.matrix;g=a.matrix.decompose();b.position=g[0];b.quaternion=
+g[1];b.useQuaternion=!0;b.scale=g[2];Fa.centerGeometry&&b.geometry&&(g=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(g.multiplySelf(b.scale)),b.position.subSelf(g));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 k(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];
+this.joints=[];this.weights=[]}function l(){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 w(){this.material="";this.count=0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function u(){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 B(a){this.id=a;this.type=null}function C(){this.name=this.id="";this.instance_effect=null}
+function D(){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 I(a,b){this.type=a;this.effect=b;this.material=null}function K(a){this.effect=a;this.format=this.init_from=null}function O(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function S(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function L(){this.url=""}
+function P(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function H(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=this.dotSyntax=this.sid=this.fullSid=null}function G(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 j(a){this.targets=[];this.time=a}function X(){this.name=this.id=""}function z(){this.url=""}function E(a){return"dae"==
+a?"http://www.collada.org/2005/11/COLLADASchema":null}function Q(a){for(var a=ea(a),b=[],c=0,d=a.length;c<d;c++)b.push(parseFloat(a[c]));return b}function N(a){for(var a=ea(a),b=[],c=0,d=a.length;c<d;c++)b.push(parseInt(a[c],10));return b}function ea(a){return 0<a.length?a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/):[]}function ia(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function $(a,b){if(Fa.convertUpAxis&&Ga!==Fa.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 aa(a,b){var c=[a[b],a[b+1],a[b+2]];$(c,-1);return new THREE.Vector3(c[0],c[1],c[2])}function ba(a){if(Fa.convertUpAxis){var b=[a[0],a[4],a[8]];$(b,-1);a[0]=b[0];a[4]=b[1];a[8]=b[2];b=[a[1],a[5],a[9]];$(b,-1);a[1]=b[0];a[5]=b[1];a[9]=b[2];b=[a[2],a[6],
+a[10]];$(b,-1);a[2]=b[0];a[6]=b[1];a[10]=b[2];b=[a[0],a[1],a[2]];$(b,-1);a[0]=b[0];a[1]=b[1];a[2]=b[2];b=[a[4],a[5],a[6]];$(b,-1);a[4]=b[0];a[5]=b[1];a[6]=b[2];b=[a[8],a[9],a[10]];$(b,-1);a[8]=b[0];a[9]=b[1];a[10]=b[2];b=[a[3],a[7],a[11]];$(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 Y=null,ca=null,fa,Ua=null,Ka={},na={},Ha={},ra={},qa={},ib={},Va={},lb={},db,Wa,$a,La,ta,Aa=THREE.SmoothShading,
+Fa={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y"},Ga="Y",Xa=null,mb=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 k).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 B).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};k.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=Q(f.textContent);this.bindShapeMatrix=ba(f);break;case "source":f=(new B).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};k.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()}}};k.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=N(g.textContent);break;case "vcount":d=N(g.textContent)}}for(f=g=0;f<d.length;f++){for(var h=d[f],j=[],i=0;i<h;i++){for(var k={},m=0;m<e.length;m++){var l=e[m],n=c[g+l.offset];switch(l.semantic){case "JOINT":k.joint=
+n;break;case "WEIGHT":k.weight=b[l.source].data[n]}}j.push(k);g+=e.length}for(i=0;i<j.length;i++)j[i].index=f;this.weights.push(j)}};l.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};l.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};l.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.cameras=[];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":this.cameras.push((new A).parse(b));break;case "instance_controller":this.controllers.push((new o).parse(b));break;case "instance_geometry":this.geometries.push((new n).parse(b));break;case "instance_light":break;case "instance_node":b=b.getAttribute("url").replace(/^#/,"");(b=U.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",U,F,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 m).parse(b));
-break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in Ea)for(var e=Ea[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(Qa.convertUpAxis)switch(g){case "X":switch(Wa){case "XtoY":case "XtoZ":case "YtoX":g=
-"Y";break;case "ZtoX":g="Z"}break;case "Y":switch(Wa){case "XtoY":case "YtoX":case "ZtoX":g="X";break;case "XtoZ":case "YtoZ":case "ZtoY":g="Z"}break;case "Z":switch(Wa){case "XtoZ":g="X";break;case "YtoZ":case "ZtoX":case "ZtoY":g="Y"}}var h=b.sampler,i=h.input,k=this.getTransformBySid(b.sid);if(k){-1===a.indexOf(f)&&a.push(f);b=0;for(var l=i.length;b<l;b++){var q=i[b],r=h.getData(k.type,b),s;s=null;for(var t=0,u=d.length;t<u&&null==s;t++){var v=d[t];if(v.time===q)s=v;else if(v.time>q)break}if(!s){s=
+break;case "instance_camera":this.cameras.push((new z).parse(b));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=Y.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",Y,E,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 Ha)for(var e=Ha[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(Fa.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,k=this.getTransformBySid(b.sid);if(k){-1===a.indexOf(f)&&a.push(f);b=0;for(var l=i.length;b<l;b++){var q=i[b],r=h.getData(k.type,b),s;s=null;for(var t=0,u=d.length;t<u&&null==s;t++){var v=d[t];if(v.time===q)s=v;else if(v.time>q)break}if(!s){s=
 new j(q);t=-1;u=0;for(v=d.length;u<v&&-1==t;u++)d[u].time>=q&&(t=u);q=t;d.splice(-1==q?d.length:q,0,s)}s.addTarget(f,k,g,r)}}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(s=d[b],!s.hasTarget(e)){h=d;f=s;k=b;g=e;i=void 0;a:{i=k?k-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(k+=1;k<h.length;k++)if(l=h[k],l.hasTarget(g))break a;l=null}if(i&&l){h=(f.time-i.time)/(l.time-
-i.time);i=i.getTarget(g);k=l.getTarget(g).data;l=i.data;r=void 0;if(l.length){r=[];for(q=0;q<l.length;++q)r[q]=l[q]+(k[q]-l[q])*h}else r=l+(k-l)*h;f.addTarget(g,i.transform,i.member,r)}}}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)};m.prototype.parse=function(a){this.sid=a.getAttribute("sid");this.type=a.nodeName;this.data=P(a.textContent);this.convert();
-return this};m.prototype.convert=function(){switch(this.type){case "matrix":this.obj=ba(this.data);break;case "rotate":this.angle=this.data[3]*mb;case "translate":ca(this.data,-1);this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;case "scale":ca(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)}};m.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)}};m.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*mb;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2],this.angle=a[3]*mb}}};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=U.evaluate(".//dae:instance_material",
-c,F,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};n.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=
-U.evaluate(".//dae:instance_material",c,F,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==oa[d]&&(oa[d]=(new D(d)).parse(c));break;case "vertices":this.vertices=(new v).parse(c);break;case "triangles":this.primitives.push((new w).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=oa[this.vertices.input.POSITION.source].data;for(b=0;b<a.length;b+=3)this.geometry3js.vertices.push(new THREE.Vertex(V(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=0,o=[];for(d=0;d<g.length;d++){h=g[d];var p=h.offset+1,n=n<p?p:n;switch(h.semantic){case "TEXCOORD":o.push(h.set)}}for(;c<
-f.length;){var q=[],r=[],p={},s=[];a.vcount&&(m=a.vcount[l++]);for(d=0;d<m;d++)for(e=0;e<g.length;e++)switch(h=g[e],k=oa[h.source],i=f[c+d*n+h.offset],j=k.accessor.params.length,j*=i,h.semantic){case "VERTEX":q.push(i);break;case "NORMAL":r.push(V(k.data,j));break;case "TEXCOORD":void 0===p[h.set]&&(p[h.set]=[]);p[h.set].push(new THREE.UV(k.data[j],1-k.data[j+1]));break;case "COLOR":s.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(q[0],
-q[1],q[2],[r[0],r[1],r[2]],s.length?s:new THREE.Color));else if(4===m)d.push(new THREE.Face4(q[0],q[1],q[2],q[3],[r[0],r[1],r[2],r[3]],s.length?s:new THREE.Color));else if(4<m&&Qa.subdivideFaces){s=s.length?s:new THREE.Color;for(e=1;e<m-1;)d.push(new THREE.Face3(q[0],q[e],q[e+1],[r[0],r[e++],r[e]],s))}if(d.length){q=0;for(r=d.length;q<r;q++){e=d[q];e.daeMaterial=a.material;b.faces.push(e);for(e=0;e<o.length;e++)s=p[o[e]],s=4<m?[s[0],s[q+1],s[q+2]]:4===m?[s[0],s[1],s[2],s[3]]:[s[0],s[1],s[2]],b.faceVertexUvs[e]||
-(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(s)}}else console.log("dropped face with vcount "+m+" for geometry with id: "+b.id);c+=n*m}};t.prototype=new w;t.prototype.constructor=t;w.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};w.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=ia(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 y).parse(a.childNodes[b]));break;case "vcount":this.vcount=R(c.textContent);break;case "p":this.p=R(c.textContent)}}return this};u.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=ia(a,"count",0);this.stride=ia(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 y).parse(a.childNodes[b]);this.input[c.semantic]=c}return this};y.prototype.parse=function(a){this.semantic=a.getAttribute("semantic");this.source=a.getAttribute("source").replace(/^#/,"");this.set=ia(a,"set",-1);this.offset=ia(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=ea(c.textContent),e=[],f=0,g=d.length;f<g;f++)e.push("true"==d[f]||"1"==d[f]?!0:!1);this.data=e;this.type=c.nodeName;break;case "float_array":this.data=P(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=R(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=ea(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 u).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=ba(c);a.push(c)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};C.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 K).parse(a.childNodes[b]);break}return this};B.prototype.isColor=function(){return null==this.texture};B.prototype.isTexture=function(){return null!=this.texture};B.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=P(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};B.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};E.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 B).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=U.evaluate(".//dae:float",c,F,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};E.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 B)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=Ka[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture(Sa+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=za;return this.material=new THREE.MeshLambertMaterial(a)};J.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};N.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};
+i.time);i=i.getTarget(g);k=l.getTarget(g).data;l=i.data;r=void 0;if(l.length){r=[];for(q=0;q<l.length;++q)r[q]=l[q]+(k[q]-l[q])*h}else r=l+(k-l)*h;f.addTarget(g,i.transform,i.member,r)}}}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=Q(a.textContent);this.convert();
+return this};n.prototype.convert=function(){switch(this.type){case "matrix":this.obj=ba(this.data);break;case "rotate":this.angle=this.data[3]*mb;case "translate":$(this.data,-1);this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;case "scale":$(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*mb;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2],this.angle=a[3]*mb}}};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=Y.evaluate(".//dae:instance_material",
+c,E,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=
+Y.evaluate(".//dae:instance_material",c,E,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==Ka[d]&&(Ka[d]=(new B(d)).parse(c));break;case "vertices":this.vertices=(new v).parse(c);break;case "triangles":this.primitives.push((new w).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=Ka[this.vertices.input.POSITION.source].data;for(b=0;b<a.length;b+=3)this.geometry3js.vertices.push(new THREE.Vertex(aa(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,m=0,l=3,n=0,o=[];for(d=0;d<g.length;d++){h=g[d];var p=h.offset+1,n=n<p?p:n;switch(h.semantic){case "TEXCOORD":o.push(h.set)}}for(;c<
+f.length;){var q=[],r=[],p={},s=[];a.vcount&&(l=a.vcount[m++]);for(d=0;d<l;d++)for(e=0;e<g.length;e++)switch(h=g[e],k=Ka[h.source],i=f[c+d*n+h.offset],j=k.accessor.params.length,j*=i,h.semantic){case "VERTEX":q.push(i);break;case "NORMAL":r.push(aa(k.data,j));break;case "TEXCOORD":void 0===p[h.set]&&(p[h.set]=[]);p[h.set].push(new THREE.UV(k.data[j],1-k.data[j+1]));break;case "COLOR":s.push((new THREE.Color).setRGB(k.data[j],k.data[j+1],k.data[j+2]))}e=null;d=[];if(3===l)d.push(new THREE.Face3(q[0],
+q[1],q[2],[r[0],r[1],r[2]],s.length?s:new THREE.Color));else if(4===l)d.push(new THREE.Face4(q[0],q[1],q[2],q[3],[r[0],r[1],r[2],r[3]],s.length?s:new THREE.Color));else if(4<l&&Fa.subdivideFaces){s=s.length?s:new THREE.Color;for(e=1;e<l-1;)d.push(new THREE.Face3(q[0],q[e],q[e+1],[r[0],r[e++],r[e]],s))}if(d.length){q=0;for(r=d.length;q<r;q++){e=d[q];e.daeMaterial=a.material;b.faces.push(e);for(e=0;e<o.length;e++)s=p[o[e]],s=4<l?[s[0],s[q+1],s[q+2]]:4===l?[s[0],s[1],s[2],s[3]]:[s[0],s[1],s[2]],b.faceVertexUvs[e]||
+(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(s)}}else console.log("dropped face with vcount "+l+" for geometry with id: "+b.id);c+=n*l}};t.prototype=new w;t.prototype.constructor=t;w.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};w.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=ia(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=N(c.textContent);break;case "p":this.p=N(c.textContent)}}return this};u.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=ia(a,"count",0);this.stride=ia(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=ia(a,"set",-1);this.offset=ia(a,"offset",0);if("TEXCOORD"==this.semantic&&0>this.set)this.set=0;return this};B.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=ea(c.textContent),e=[],f=0,g=d.length;f<g;f++)e.push("true"==d[f]||"1"==d[f]?!0:!1);this.data=e;this.type=c.nodeName;break;case "float_array":this.data=Q(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=N(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=ea(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 u).parse(c.childNodes[d]);break}}}return this};B.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=ba(c);a.push(c)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};C.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 L).parse(a.childNodes[b]);break}return this};D.prototype.isColor=function(){return null==this.texture};D.prototype.isTexture=function(){return null!=this.texture};D.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=Q(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};D.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};I.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 D).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=Y.evaluate(".//dae:float",c,E,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};I.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 D)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($a+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=Aa;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};O.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};
 S.prototype.create=function(){if(null==this.shader)return null};S.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};S.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 J(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new N(this)).parse(d);this.sampler.sid=b;break;case "extra":break;default:console.log(d.nodeName)}}};S.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};
-S.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 E(c.nodeName,this)).parse(c)}}};K.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};O.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 H(this)).parse(c));break;case "channel":this.channel.push((new M(this)).parse(c))}}return this};M.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};H.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 y).parse(c))}}return this};H.prototype.create=function(){for(var a=0;a<this.inputs.length;a++){var b=
+(new K(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new O(this)).parse(d);this.sampler.sid=b;break;case "extra":break;default:console.log(d.nodeName)}}};S.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};
+S.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 I(c.nodeName,this)).parse(c)}}};L.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 B).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new G(this)).parse(c));break;case "channel":this.channel.push((new H(this)).parse(c))}}return this};H.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};G.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};G.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}};H.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":ca(c,-1);break;case "scale":ca(c,1)}}else c=this.output[b];return c};j.prototype.addTarget=function(a,b,c,d){this.targets.push({sid:a,member:c,transform:b,data:d})};j.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)}};j.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};j.prototype.hasTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return!0;return!1};j.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)}};Z.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "optics":this.parseOptics(c)}}return this};Z.prototype.parseOptics=
-function(a){for(var b=0;b<a.childNodes.length;b++)if("technique_common"==a.childNodes[b].nodeName)for(var c=a.childNodes[b],d=0;d<c.childNodes.length;d++)if("perspective"==c.childNodes[d].nodeName)for(var e=c.childNodes[d],f=0;f<e.childNodes.length;f++){var g=e.childNodes[f];switch(g.nodeName){case "xfov":this.fov=g.textContent;break;case "znear":this.znear=0.4;break;case "zfar":this.zfar=1E15;break;case "aspect_ratio":this.aspect_ratio=g.textContent}}return this};A.prototype.parse=function(a){this.url=
-a.getAttribute("url").replace(/^#/,"");return this};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?(Ta=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){za=a},applySkin:e,geometries:ka,options:Qa}};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;
+this.endTime=Math.max(this.endTime,this.input[a]);this.duration=this.endTime-this.startTime}};G.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":$(c,-1);break;case "scale":$(c,1)}}else c=this.output[b];return c};j.prototype.addTarget=function(a,b,c,d){this.targets.push({sid:a,member:c,transform:b,data:d})};j.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)}};j.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};j.prototype.hasTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return!0;return!1};j.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)}};X.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "optics":this.parseOptics(c)}}return this};X.prototype.parseOptics=
+function(a){for(var b=0;b<a.childNodes.length;b++)if("technique_common"==a.childNodes[b].nodeName)for(var c=a.childNodes[b],d=0;d<c.childNodes.length;d++)if("perspective"==c.childNodes[d].nodeName)for(var e=c.childNodes[d],f=0;f<e.childNodes.length;f++){var g=e.childNodes[f];switch(g.nodeName){case "xfov":this.fov=g.textContent;break;case "znear":this.znear=0.4;break;case "zfar":this.zfar=1E15;break;case "aspect_ratio":this.aspect_ratio=g.textContent}}return this};z.prototype.parse=function(a){this.url=
+a.getAttribute("url").replace(/^#/,"");return this};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?(Ua=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){Aa=a},applySkin:e,geometries:qa,options:Fa}};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,k,l,p,m,o,q,n,r,s,t,w,u=a.faces;p=a.vertices;var v=a.normals,y=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]=[];k=0;for(l=p.length;k<
-l;)m=new THREE.Vertex,m.position.x=p[k++]*b,m.position.y=p[k++]*b,m.position.z=p[k++]*b,d.vertices.push(m);k=0;for(l=u.length;k<l;){b=u[k++];p=b&1;i=b&2;c=b&4;e=b&8;o=b&16;m=b&32;n=b&64;b&=128;p?(r=new THREE.Face4,r.a=u[k++],r.b=u[k++],r.c=u[k++],r.d=u[k++],p=4):(r=new THREE.Face3,r.a=u[k++],r.b=u[k++],r.c=u[k++],p=3);if(i)i=u[k++],r.materialIndex=i;i=d.faces.length;if(c)for(c=0;c<D;c++)s=a.uvs[c],q=u[k++],w=s[2*q],q=s[2*q+1],d.faceUvs[c][i]=new THREE.UV(w,q);if(e)for(c=0;c<D;c++){s=a.uvs[c];t=[];
-for(e=0;e<p;e++)q=u[k++],w=s[2*q],q=s[2*q+1],t[e]=new THREE.UV(w,q);d.faceVertexUvs[c][i]=t}if(o)o=3*u[k++],e=new THREE.Vector3,e.x=v[o++],e.y=v[o++],e.z=v[o],r.normal=e;if(m)for(c=0;c<p;c++)o=3*u[k++],e=new THREE.Vector3,e.x=v[o++],e.y=v[o++],e.z=v[o],r.vertexNormals.push(e);if(n)m=u[k++],m=new THREE.Color(y[m]),r.color=m;if(b)for(c=0;c<p;c++)m=u[k++],m=new THREE.Color(y[m]),r.vertexColors.push(m);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,k,l,p,m,o,q,n,r;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=[];d.morphNormals[c]={};
-d.morphNormals[c].faceNormals=[];d.morphNormals[c].vertexNormals=[];o=d.morphTargets[c].vertices;q=a.morphTargets[c].vertices;n=d.morphNormals[c].faceNormals;r=d.morphNormals[c].vertexNormals;for(i=0,k=q.length;i<k;i+=3)l=q[i]*b,p=q[i+1]*b,m=q[i+2]*b,o.push(new THREE.Vertex(new THREE.Vector3(l,p,m)));for(i=0,k=d.faces.length;i<k;i++)p=d.faces[i],l=new THREE.Vector3,p=p instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,
-d:new THREE.Vector3},n.push(l),r.push(p)}}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=[];r=d.morphColors[c].colors;i=a.morphColors[c].colors;for(b=0,n=i.length;b<n;b+=3)k=new THREE.Color(16755200),k.setRGB(i[b],i[b+1],i[b+2]),r.push(k)}})(e);d.computeCentroids();d.computeMorphNormals();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.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,k,l,p,n,o,q,m,r,s,t,w,u=a.faces;p=a.vertices;var v=a.normals,A=a.colors,B=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&B++;for(c=0;c<B;c++)d.faceUvs[c]=[],d.faceVertexUvs[c]=[];k=0;for(l=p.length;k<
+l;)n=new THREE.Vertex,n.position.x=p[k++]*b,n.position.y=p[k++]*b,n.position.z=p[k++]*b,d.vertices.push(n);k=0;for(l=u.length;k<l;){b=u[k++];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=u[k++],r.b=u[k++],r.c=u[k++],r.d=u[k++],p=4):(r=new THREE.Face3,r.a=u[k++],r.b=u[k++],r.c=u[k++],p=3);if(i)i=u[k++],r.materialIndex=i;i=d.faces.length;if(c)for(c=0;c<B;c++)s=a.uvs[c],q=u[k++],w=s[2*q],q=s[2*q+1],d.faceUvs[c][i]=new THREE.UV(w,q);if(e)for(c=0;c<B;c++){s=a.uvs[c];t=[];
+for(e=0;e<p;e++)q=u[k++],w=s[2*q],q=s[2*q+1],t[e]=new THREE.UV(w,q);d.faceVertexUvs[c][i]=t}if(o)o=3*u[k++],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*u[k++],e=new THREE.Vector3,e.x=v[o++],e.y=v[o++],e.z=v[o],r.vertexNormals.push(e);if(m)n=u[k++],n=new THREE.Color(A[n]),r.color=n;if(b)for(c=0;c<p;c++)n=u[k++],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,k,l,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,k=q.length;i<k;i+=3)l=q[i]*b,p=q[i+1]*b,n=q[i+2]*b,o.push(new THREE.Vertex(new THREE.Vector3(l,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=[];k=d.morphColors[c].colors;l=a.morphColors[c].colors;for(b=0,i=l.length;b<i;b+=3)p=new THREE.Color(16755200),p.setRGB(l[b],l[b+1],l[b+2]),k.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)}catch(f){console.warn("DEPRECATED: ["+a+"] seems to be using old model format")}c.createScene(e,b,a)}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:k+"/"+a}function e(){var a;for(m in K.objects)if(!A.objects[m])if(s=K.objects[m],void 0!==s.geometry){if(E=A.geometries[s.geometry]){a=!1;J=A.materials[s.materials[0]];(a=J instanceof THREE.ShaderMaterial)&&E.computeTangents();u=s.position;v=s.rotation;y=s.quaternion;D=s.scale;y=0;0==s.materials.length&&(J=new THREE.MeshFaceMaterial);1<s.materials.length&&(J=new THREE.MeshFaceMaterial);a=new THREE.Mesh(E,
-J);a.name=m;a.position.set(u[0],u[1],u[2]);y?(a.quaternion.set(y[0],y[1],y[2],y[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;A.scene.add(a);A.objects[m]=a;if(s.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);A.scene.collisions.colliders.push(b)}if(s.castsShadow)b=new THREE.ShadowVolume(E),A.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},
-A.triggers[a.name]=b)}}else u=s.position,v=s.rotation,y=s.quaternion,D=s.scale,y=0,a=new THREE.Object3D,a.name=m,a.position.set(u[0],u[1],u[2]),y?(a.quaternion.set(y[0],y[1],y[2],y[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,A.scene.add(a),A.objects[m]=a,A.empties[m]=a,s.trigger&&"none"!=s.trigger.toLowerCase()&&(b={type:s.trigger,object:s},A.triggers[a.name]=b)}function f(a){return function(b){A.geometries[a]=b;e();
-M-=1;i.onLoadComplete();h()}}function g(a){return function(b){A.geometries[a]=b}}function h(){i.callbackProgress({totalModels:j,totalTextures:Z,loadedModels:j-M,loadedTextures:Z-H},A);i.onLoadProgress();0==M&&0==H&&b(A)}var i=this,k=THREE.Loader.prototype.extractUrlbase(c),l,p,m,o,q,n,r,s,t,w,u,v,y,D,C,B,E,J,N,S,K,O,M,H,j,Z,A;K=a;c=new THREE.BinaryLoader;O=new THREE.JSONLoader;H=M=0;A={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},
-empties:{}};a=!1;for(m in K.objects)if(s=K.objects[m],s.meshCollider){a=!0;break}if(a)A.scene.collisions=new THREE.CollisionSystem;if(K.transform)a=K.transform.position,t=K.transform.rotation,C=K.transform.scale,a&&A.scene.position.set(a[0],a[1],a[2]),t&&A.scene.rotation.set(t[0],t[1],t[2]),C&&A.scene.scale.set(C[0],C[1],C[2]),(a||t||C)&&A.scene.updateMatrix();a=function(){H-=1;h();i.onLoadComplete()};for(q in K.cameras)C=K.cameras[q],"perspective"==C.type?N=new THREE.PerspectiveCamera(C.fov,C.aspect,
-C.near,C.far):"ortho"==C.type&&(N=new THREE.OrthographicCamera(C.left,C.right,C.top,C.bottom,C.near,C.far)),u=C.position,t=C.target,C=C.up,N.position.set(u[0],u[1],u[2]),N.target=new THREE.Vector3(t[0],t[1],t[2]),C&&N.up.set(C[0],C[1],C[2]),A.cameras[q]=N;for(o in K.lights)t=K.lights[o],q=void 0!==t.color?t.color:16777215,N=void 0!==t.intensity?t.intensity:1,"directional"==t.type?(u=t.direction,w=new THREE.DirectionalLight(q,N),w.position.set(u[0],u[1],u[2]),w.position.normalize()):"point"==t.type?
-(u=t.position,w=t.distance,w=new THREE.PointLight(q,N,w),w.position.set(u[0],u[1],u[2])):"ambient"==t.type&&(w=new THREE.AmbientLight(q)),A.scene.add(w),A.lights[o]=w;for(n in K.fogs)o=K.fogs[n],"linear"==o.type?S=new THREE.Fog(0,o.near,o.far):"exp2"==o.type&&(S=new THREE.FogExp2(0,o.density)),C=o.color,S.color.setRGB(C[0],C[1],C[2]),A.fogs[n]=S;if(A.cameras&&K.defaults.camera)A.currentCamera=A.cameras[K.defaults.camera];if(A.fogs&&K.defaults.fog)A.scene.fog=A.fogs[K.defaults.fog];C=K.defaults.bgcolor;
-A.bgColor=new THREE.Color;A.bgColor.setRGB(C[0],C[1],C[2]);A.bgColorAlpha=K.defaults.bgalpha;for(l in K.geometries)if(n=K.geometries[l],"bin_mesh"==n.type||"ascii_mesh"==n.type)M+=1,i.onLoadStart();j=M;for(l in K.geometries)if(n=K.geometries[l],"cube"==n.type)E=new THREE.CubeGeometry(n.width,n.height,n.depth,n.segmentsWidth,n.segmentsHeight,n.segmentsDepth,null,n.flipped,n.sides),A.geometries[l]=E;else if("plane"==n.type)E=new THREE.PlaneGeometry(n.width,n.height,n.segmentsWidth,n.segmentsHeight),
-A.geometries[l]=E;else if("sphere"==n.type)E=new THREE.SphereGeometry(n.radius,n.segmentsWidth,n.segmentsHeight),A.geometries[l]=E;else if("cylinder"==n.type)E=new THREE.CylinderGeometry(n.topRad,n.botRad,n.height,n.radSegs,n.heightSegs),A.geometries[l]=E;else if("torus"==n.type)E=new THREE.TorusGeometry(n.radius,n.tube,n.segmentsR,n.segmentsT),A.geometries[l]=E;else if("icosahedron"==n.type)E=new THREE.IcosahedronGeometry(n.radius,n.subdivisions),A.geometries[l]=E;else if("bin_mesh"==n.type)c.load(d(n.url,
-K.urlBaseType),f(l));else if("ascii_mesh"==n.type)O.load(d(n.url,K.urlBaseType),f(l));else if("embedded_mesh"==n.type)n=K.embeds[n.id],n.metadata=K.metadata,n&&O.createModel(n,g(l),"");for(r in K.textures)if(l=K.textures[r],l.url instanceof Array){H+=l.url.length;for(n=0;n<l.url.length;n++)i.onLoadStart()}else H+=1,i.onLoadStart();Z=H;for(r in K.textures){l=K.textures[r];if(void 0!=l.mapping&&void 0!=THREE[l.mapping])l.mapping=new THREE[l.mapping];if(l.url instanceof Array){n=[];for(S=0;S<l.url.length;S++)n[S]=
-d(l.url[S],K.urlBaseType);n=THREE.ImageUtils.loadTextureCube(n,l.mapping,a)}else{n=THREE.ImageUtils.loadTexture(d(l.url,K.urlBaseType),l.mapping,a);if(void 0!=THREE[l.minFilter])n.minFilter=THREE[l.minFilter];if(void 0!=THREE[l.magFilter])n.magFilter=THREE[l.magFilter];if(l.repeat){n.repeat.set(l.repeat[0],l.repeat[1]);if(1!=l.repeat[0])n.wrapS=THREE.RepeatWrapping;if(1!=l.repeat[1])n.wrapT=THREE.RepeatWrapping}l.offset&&n.offset.set(l.offset[0],l.offset[1]);if(l.wrap){S={repeat:THREE.RepeatWrapping,
-mirror:THREE.MirroredRepeatWrapping};if(void 0!==S[l.wrap[0]])n.wrapS=S[l.wrap[0]];if(void 0!==S[l.wrap[1]])n.wrapT=S[l.wrap[1]]}}A.textures[r]=n}for(p in K.materials){r=K.materials[p];for(B in r.parameters)if("envMap"==B||"map"==B||"lightMap"==B)r.parameters[B]=A.textures[r.parameters[B]];else if("shading"==B)r.parameters[B]="flat"==r.parameters[B]?THREE.FlatShading:THREE.SmoothShading;else if("blending"==B)r.parameters[B]=THREE[r.parameters[B]]?THREE[r.parameters[B]]:THREE.NormalBlending;else if("combine"==
-B)r.parameters[B]="MixOperation"==r.parameters[B]?THREE.MixOperation:THREE.MultiplyOperation;else if("vertexColors"==B)if("face"==r.parameters[B])r.parameters[B]=THREE.FaceColors;else if(r.parameters[B])r.parameters[B]=THREE.VertexColors;if(void 0!==r.parameters.opacity&&1>r.parameters.opacity)r.parameters.transparent=!0;if(r.parameters.normalMap){l=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(l.uniforms);n=r.parameters.color;S=r.parameters.specular;c=r.parameters.ambient;O=r.parameters.shininess;
-a.tNormal.texture=A.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=A.textures[r.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(n);a.uSpecularColor.value.setHex(S);a.uAmbientColor.value.setHex(c);
-a.uShininess.value=O;if(r.parameters.opacity)a.uOpacity.value=r.parameters.opacity;J=new THREE.ShaderMaterial({fragmentShader:l.fragmentShader,vertexShader:l.vertexShader,uniforms:a,lights:!0,fog:!0})}else J=new THREE[r.type](r.parameters);A.materials[p]=J}e();i.callbackSync(A);h()};THREE.UTF8Loader=function(){};THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
+THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return"relativeToHTML"==b?a:k+"/"+a}function e(){var a;for(n in L.objects)if(!z.objects[n])if(s=L.objects[n],void 0!==s.geometry){if(I=z.geometries[s.geometry]){a=!1;K=z.materials[s.materials[0]];(a=K instanceof THREE.ShaderMaterial)&&I.computeTangents();u=s.position;v=s.rotation;A=s.quaternion;B=s.scale;A=0;0==s.materials.length&&(K=new THREE.MeshFaceMaterial);1<s.materials.length&&(K=new THREE.MeshFaceMaterial);a=new THREE.Mesh(I,
+K);a.name=n;a.position.set(u[0],u[1],u[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(B[0],B[1],B[2]);a.visible=s.visible;z.scene.add(a);z.objects[n]=a;if(s.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);z.scene.collisions.colliders.push(b)}if(s.castsShadow)b=new THREE.ShadowVolume(I),z.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},
+z.triggers[a.name]=b)}}else u=s.position,v=s.rotation,A=s.quaternion,B=s.scale,A=0,a=new THREE.Object3D,a.name=n,a.position.set(u[0],u[1],u[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(B[0],B[1],B[2]),a.visible=void 0!==s.visible?s.visible:!1,z.scene.add(a),z.objects[n]=a,z.empties[n]=a,s.trigger&&"none"!=s.trigger.toLowerCase()&&(b={type:s.trigger,object:s},z.triggers[a.name]=b)}function f(a){return function(b){z.geometries[a]=b;e();
+H-=1;i.onLoadComplete();h()}}function g(a){return function(b){z.geometries[a]=b}}function h(){i.callbackProgress({totalModels:j,totalTextures:X,loadedModels:j-H,loadedTextures:X-G},z);i.onLoadProgress();0==H&&0==G&&b(z)}var i=this,k=THREE.Loader.prototype.extractUrlbase(c),l,p,n,o,q,m,r,s,t,w,u,v,A,B,C,D,I,K,O,S,L,P,H,G,j,X,z;L=a;c=new THREE.BinaryLoader;P=new THREE.JSONLoader;G=H=0;z={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},
+empties:{}};a=!1;for(n in L.objects)if(s=L.objects[n],s.meshCollider){a=!0;break}if(a)z.scene.collisions=new THREE.CollisionSystem;if(L.transform)a=L.transform.position,t=L.transform.rotation,C=L.transform.scale,a&&z.scene.position.set(a[0],a[1],a[2]),t&&z.scene.rotation.set(t[0],t[1],t[2]),C&&z.scene.scale.set(C[0],C[1],C[2]),(a||t||C)&&z.scene.updateMatrix();a=function(){G-=1;h();i.onLoadComplete()};for(q in L.cameras)C=L.cameras[q],"perspective"==C.type?O=new THREE.PerspectiveCamera(C.fov,C.aspect,
+C.near,C.far):"ortho"==C.type&&(O=new THREE.OrthographicCamera(C.left,C.right,C.top,C.bottom,C.near,C.far)),u=C.position,t=C.target,C=C.up,O.position.set(u[0],u[1],u[2]),O.target=new THREE.Vector3(t[0],t[1],t[2]),C&&O.up.set(C[0],C[1],C[2]),z.cameras[q]=O;for(o in L.lights)t=L.lights[o],q=void 0!==t.color?t.color:16777215,O=void 0!==t.intensity?t.intensity:1,"directional"==t.type?(u=t.direction,w=new THREE.DirectionalLight(q,O),w.position.set(u[0],u[1],u[2]),w.position.normalize()):"point"==t.type?
+(u=t.position,w=t.distance,w=new THREE.PointLight(q,O,w),w.position.set(u[0],u[1],u[2])):"ambient"==t.type&&(w=new THREE.AmbientLight(q)),z.scene.add(w),z.lights[o]=w;for(m in L.fogs)o=L.fogs[m],"linear"==o.type?S=new THREE.Fog(0,o.near,o.far):"exp2"==o.type&&(S=new THREE.FogExp2(0,o.density)),C=o.color,S.color.setRGB(C[0],C[1],C[2]),z.fogs[m]=S;if(z.cameras&&L.defaults.camera)z.currentCamera=z.cameras[L.defaults.camera];if(z.fogs&&L.defaults.fog)z.scene.fog=z.fogs[L.defaults.fog];C=L.defaults.bgcolor;
+z.bgColor=new THREE.Color;z.bgColor.setRGB(C[0],C[1],C[2]);z.bgColorAlpha=L.defaults.bgalpha;for(l in L.geometries)if(m=L.geometries[l],"bin_mesh"==m.type||"ascii_mesh"==m.type)H+=1,i.onLoadStart();j=H;for(l in L.geometries)if(m=L.geometries[l],"cube"==m.type)I=new THREE.CubeGeometry(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,m.sides),z.geometries[l]=I;else if("plane"==m.type)I=new THREE.PlaneGeometry(m.width,m.height,m.segmentsWidth,m.segmentsHeight),
+z.geometries[l]=I;else if("sphere"==m.type)I=new THREE.SphereGeometry(m.radius,m.segmentsWidth,m.segmentsHeight),z.geometries[l]=I;else if("cylinder"==m.type)I=new THREE.CylinderGeometry(m.topRad,m.botRad,m.height,m.radSegs,m.heightSegs),z.geometries[l]=I;else if("torus"==m.type)I=new THREE.TorusGeometry(m.radius,m.tube,m.segmentsR,m.segmentsT),z.geometries[l]=I;else if("icosahedron"==m.type)I=new THREE.IcosahedronGeometry(m.radius,m.subdivisions),z.geometries[l]=I;else if("bin_mesh"==m.type)c.load(d(m.url,
+L.urlBaseType),f(l));else if("ascii_mesh"==m.type)P.load(d(m.url,L.urlBaseType),f(l));else if("embedded_mesh"==m.type)m=L.embeds[m.id],m.metadata=L.metadata,m&&P.createModel(m,g(l),"");for(r in L.textures)if(l=L.textures[r],l.url instanceof Array){G+=l.url.length;for(m=0;m<l.url.length;m++)i.onLoadStart()}else G+=1,i.onLoadStart();X=G;for(r in L.textures){l=L.textures[r];if(void 0!=l.mapping&&void 0!=THREE[l.mapping])l.mapping=new THREE[l.mapping];if(l.url instanceof Array){m=[];for(S=0;S<l.url.length;S++)m[S]=
+d(l.url[S],L.urlBaseType);m=THREE.ImageUtils.loadTextureCube(m,l.mapping,a)}else{m=THREE.ImageUtils.loadTexture(d(l.url,L.urlBaseType),l.mapping,a);if(void 0!=THREE[l.minFilter])m.minFilter=THREE[l.minFilter];if(void 0!=THREE[l.magFilter])m.magFilter=THREE[l.magFilter];if(l.repeat){m.repeat.set(l.repeat[0],l.repeat[1]);if(1!=l.repeat[0])m.wrapS=THREE.RepeatWrapping;if(1!=l.repeat[1])m.wrapT=THREE.RepeatWrapping}l.offset&&m.offset.set(l.offset[0],l.offset[1]);if(l.wrap){S={repeat:THREE.RepeatWrapping,
+mirror:THREE.MirroredRepeatWrapping};if(void 0!==S[l.wrap[0]])m.wrapS=S[l.wrap[0]];if(void 0!==S[l.wrap[1]])m.wrapT=S[l.wrap[1]]}}z.textures[r]=m}for(p in L.materials){r=L.materials[p];for(D in r.parameters)if("envMap"==D||"map"==D||"lightMap"==D)r.parameters[D]=z.textures[r.parameters[D]];else if("shading"==D)r.parameters[D]="flat"==r.parameters[D]?THREE.FlatShading:THREE.SmoothShading;else if("blending"==D)r.parameters[D]=THREE[r.parameters[D]]?THREE[r.parameters[D]]:THREE.NormalBlending;else if("combine"==
+D)r.parameters[D]="MixOperation"==r.parameters[D]?THREE.MixOperation:THREE.MultiplyOperation;else if("vertexColors"==D)if("face"==r.parameters[D])r.parameters[D]=THREE.FaceColors;else if(r.parameters[D])r.parameters[D]=THREE.VertexColors;if(void 0!==r.parameters.opacity&&1>r.parameters.opacity)r.parameters.transparent=!0;if(r.parameters.normalMap){l=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(l.uniforms);m=r.parameters.color;S=r.parameters.specular;c=r.parameters.ambient;P=r.parameters.shininess;
+a.tNormal.texture=z.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=z.textures[r.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(m);a.uSpecularColor.value.setHex(S);a.uAmbientColor.value.setHex(c);
+a.uShininess.value=P;if(r.parameters.opacity)a.uOpacity.value=r.parameters.opacity;K=new THREE.ShaderMaterial({fragmentShader:l.fragmentShader,vertexShader:l.vertexShader,uniforms:a,lights:!0,fog:!0})}else K=new THREE[r.type](r.parameters);z.materials[p]=K}e();i.callbackSync(z);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),k=[],l=[];(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,l.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,k.push(d,e,f)})(g[0],8,5);(function(a){var c,d,e,f,g,i,t,w,u,v=a.length;for(c=0;c<v;c+=3){d=a[c];e=a[c+1];f=a[c+2];g=b;w=d;u=e;i=f;var y=k[3*e],D=k[3*e+1],C=k[3*e+2],B=k[3*f],E=k[3*f+1],J=k[3*f+2];t=new THREE.Vector3(k[3*d],k[3*d+1],k[3*d+2]);y=new THREE.Vector3(y,D,C);B=new THREE.Vector3(B,E,J);g.faces.push(new THREE.Face3(w,u,i,[t,y,B],null,0));g=l[2*d];d=l[2*d+1];i=l[2*e];t=l[2*e+1];w=l[2*
+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,k.push(d,e,f)})(g[0],8,5);(function(a){var c,d,e,f,g,i,t,w,u,v=a.length;for(c=0;c<v;c+=3){d=a[c];e=a[c+1];f=a[c+2];g=b;w=d;u=e;i=f;var A=k[3*e],B=k[3*e+1],C=k[3*e+2],D=k[3*f],I=k[3*f+1],K=k[3*f+2];t=new THREE.Vector3(k[3*d],k[3*d+1],k[3*d+2]);A=new THREE.Vector3(A,B,C);D=new THREE.Vector3(D,I,K);g.faces.push(new THREE.Face3(w,u,i,[t,A,D],null,0));g=l[2*d];d=l[2*d+1];i=l[2*e];t=l[2*e+1];w=l[2*
 f];u=l[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(w,u));f.push(t)}})(g[1]);this.computeCentroids();this.computeFaceNormals()};g.prototype=new THREE.Geometry;g.prototype.constructor=g;b(new g)};
 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,k,l,p){g=(g-l)/(p-l);l=this.normal_cache;b[f]=h+g*this.delta;b[f+1]=i;b[f+2]=k;e[f]=this.lerp(l[a],l[a+3],g);e[f+1]=this.lerp(l[a+1],l[a+4],g);e[f+2]=this.lerp(l[a+2],l[a+5],g)};this.VIntY=function(a,b,e,f,g,h,i,k,l,p){g=(g-l)/(p-l);l=this.normal_cache;b[f]=h;b[f+1]=i+g*this.delta;b[f+2]=k;b=a+3*this.yd;
 e[f]=this.lerp(l[a],l[b],g);e[f+1]=this.lerp(l[a+1],l[b+1],g);e[f+2]=this.lerp(l[a+2],l[b+2],g)};this.VIntZ=function(a,b,e,f,g,h,i,k,l,p){g=(g-l)/(p-l);l=this.normal_cache;b[f]=h;b[f+1]=i;b[f+2]=k+g*this.delta;b=a+3*this.zd;e[f]=this.lerp(l[a],l[b],g);e[f+1]=this.lerp(l[a+1],l[b+1],g);e[f+2]=this.lerp(l[a+2],l[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,k=f+this.yd,l=f+this.zd,p=i+this.yd,m=i+this.zd,o=f+this.yd+this.zd,q=i+this.yd+this.zd,n=0,r=this.field[f],s=this.field[i],t=this.field[k],w=this.field[p],u=this.field[l],v=this.field[m],y=this.field[o],D=this.field[q];r<g&&(n|=1);s<g&&(n|=2);t<g&&(n|=8);w<g&&(n|=4);u<g&&(n|=16);v<g&&(n|=32);y<g&&(n|=128);D<g&&(n|=64);var C=THREE.edgeTable[n];if(0===C)return 0;var B=this.delta,E=a+
-B,J=b+B,B=e+B;C&1&&(this.compNorm(f),this.compNorm(i),this.VIntX(3*f,this.vlist,this.nlist,0,g,a,b,e,r,s));C&2&&(this.compNorm(i),this.compNorm(p),this.VIntY(3*i,this.vlist,this.nlist,3,g,E,b,e,s,w));C&4&&(this.compNorm(k),this.compNorm(p),this.VIntX(3*k,this.vlist,this.nlist,6,g,a,J,e,t,w));C&8&&(this.compNorm(f),this.compNorm(k),this.VIntY(3*f,this.vlist,this.nlist,9,g,a,b,e,r,t));C&16&&(this.compNorm(l),this.compNorm(m),this.VIntX(3*l,this.vlist,this.nlist,12,g,a,b,B,u,v));C&32&&(this.compNorm(m),
-this.compNorm(q),this.VIntY(3*m,this.vlist,this.nlist,15,g,E,b,B,v,D));C&64&&(this.compNorm(o),this.compNorm(q),this.VIntX(3*o,this.vlist,this.nlist,18,g,a,J,B,y,D));C&128&&(this.compNorm(l),this.compNorm(o),this.VIntY(3*l,this.vlist,this.nlist,21,g,a,b,B,u,y));C&256&&(this.compNorm(f),this.compNorm(l),this.VIntZ(3*f,this.vlist,this.nlist,24,g,a,b,e,r,u));C&512&&(this.compNorm(i),this.compNorm(m),this.VIntZ(3*i,this.vlist,this.nlist,27,g,E,b,e,s,v));C&1024&&(this.compNorm(p),this.compNorm(q),this.VIntZ(3*
-p,this.vlist,this.nlist,30,g,E,J,e,w,D));C&2048&&(this.compNorm(k),this.compNorm(o),this.VIntZ(3*k,this.vlist,this.nlist,33,g,a,J,e,t,y));n<<=4;for(g=f=0;-1!=THREE.triTable[n+g];)a=n+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,k=f+this.yd,l=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[k],w=this.field[p],u=this.field[l],v=this.field[n],A=this.field[o],B=this.field[q];r<g&&(m|=1);s<g&&(m|=2);t<g&&(m|=8);w<g&&(m|=4);u<g&&(m|=16);v<g&&(m|=32);A<g&&(m|=128);B<g&&(m|=64);var C=THREE.edgeTable[m];if(0===C)return 0;var D=this.delta,I=a+
+D,K=b+D,D=e+D;C&1&&(this.compNorm(f),this.compNorm(i),this.VIntX(3*f,this.vlist,this.nlist,0,g,a,b,e,r,s));C&2&&(this.compNorm(i),this.compNorm(p),this.VIntY(3*i,this.vlist,this.nlist,3,g,I,b,e,s,w));C&4&&(this.compNorm(k),this.compNorm(p),this.VIntX(3*k,this.vlist,this.nlist,6,g,a,K,e,t,w));C&8&&(this.compNorm(f),this.compNorm(k),this.VIntY(3*f,this.vlist,this.nlist,9,g,a,b,e,r,t));C&16&&(this.compNorm(l),this.compNorm(n),this.VIntX(3*l,this.vlist,this.nlist,12,g,a,b,D,u,v));C&32&&(this.compNorm(n),
+this.compNorm(q),this.VIntY(3*n,this.vlist,this.nlist,15,g,I,b,D,v,B));C&64&&(this.compNorm(o),this.compNorm(q),this.VIntX(3*o,this.vlist,this.nlist,18,g,a,K,D,A,B));C&128&&(this.compNorm(l),this.compNorm(o),this.VIntY(3*l,this.vlist,this.nlist,21,g,a,b,D,u,A));C&256&&(this.compNorm(f),this.compNorm(l),this.VIntZ(3*f,this.vlist,this.nlist,24,g,a,b,e,r,u));C&512&&(this.compNorm(i),this.compNorm(n),this.VIntZ(3*i,this.vlist,this.nlist,27,g,I,b,e,s,v));C&1024&&(this.compNorm(p),this.compNorm(q),this.VIntZ(3*
+p,this.vlist,this.nlist,30,g,I,K,e,w,B));C&2048&&(this.compNorm(k),this.compNorm(o),this.VIntZ(3*k,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,k=b*this.size,l=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 m=Math.floor(k-h);1>m&&(m=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var o=Math.floor(l-h);1>o&&(o=1);h=Math.floor(l+h);h>this.size-1&&(h=this.size-
-1);for(var q,n,r,s,t,w,u,l=p;l<i;l++){r=this.size2*l;t=l/this.size-e;w=t*t;for(p=m;p<k;p++){n=r+this.size*p;q=p/this.size-b;u=q*q;for(q=o;q<h;q++)s=q/this.size-a,s=f/(1.0E-6+s*s+u+w)-g,0<s&&(this.field[n+q]+=s)}}};this.addPlaneX=function(a,b){var e,f,g,h,i,k=this.size,l=this.yd,p=this.zd,m=this.field,o=k*Math.sqrt(a/b);o>k&&(o=k);for(e=0;e<o;e++)if(f=e/k,f*=f,h=a/(1.0E-4+f)-b,0<h)for(f=0;f<k;f++){i=e+f*l;for(g=0;g<k;g++)m[p*g+i]+=h}};this.addPlaneY=function(a,b){var e,f,g,h,i,k,l=this.size,p=this.yd,
-m=this.zd,o=this.field,q=l*Math.sqrt(a/b);q>l&&(q=l);for(f=0;f<q;f++)if(e=f/l,e*=e,h=a/(1.0E-4+e)-b,0<h){i=f*p;for(e=0;e<l;e++){k=i+e;for(g=0;g<l;g++)o[m*g+k]+=h}}};this.addPlaneZ=function(a,b){var e,f,g,h,i,k,l=this.size,p=this.yd,m=this.zd,o=this.field,q=l*Math.sqrt(a/b);q>l&&(q=l);for(g=0;g<q;g++)if(e=g/l,e*=e,h=a/(1.0E-4+e)-b,0<h){i=m*g;for(f=0;f<l;f++){k=i+f*p;for(e=0;e<l;e++)o[k+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,k,l,p,m=this.size-2;for(g=1;g<m;g++){p=this.size2*g;k=(g-this.halfsize)/this.halfsize;for(f=1;f<m;f++){l=p+this.size*f;i=(f-this.halfsize)/this.halfsize;for(e=1;e<m;e++)h=(e-this.halfsize)/this.halfsize,b=l+e,this.polygonize(h,i,k,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,k,l,p,m,o;for(g=0;g<f.count;g++)m=3*g,l=m+1,o=m+2,h=f.positionArray[m],i=f.positionArray[l],k=
-f.positionArray[o],p=new THREE.Vector3(h,i,k),h=f.normalArray[m],i=f.normalArray[l],k=f.normalArray[o],m=new THREE.Vector3(h,i,k),m.normalize(),l=new THREE.Vertex(p),b.vertices.push(l),e.push(m);p=f.count/3;for(g=0;g<p;g++)m=3*(a+g),l=m+1,o=m+2,h=e[m],i=e[l],k=e[o],m=new THREE.Face3(m,l,o,[h,i,k]),b.faces.push(m);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,k=b*this.size,l=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(k-h);1>n&&(n=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var o=Math.floor(l-h);1>o&&(o=1);h=Math.floor(l+h);h>this.size-1&&(h=this.size-
+1);for(var q,m,r,s,t,w,u,l=p;l<i;l++){r=this.size2*l;t=l/this.size-e;w=t*t;for(p=n;p<k;p++){m=r+this.size*p;q=p/this.size-b;u=q*q;for(q=o;q<h;q++)s=q/this.size-a,s=f/(1.0E-6+s*s+u+w)-g,0<s&&(this.field[m+q]+=s)}}};this.addPlaneX=function(a,b){var e,f,g,h,i,k=this.size,l=this.yd,p=this.zd,n=this.field,o=k*Math.sqrt(a/b);o>k&&(o=k);for(e=0;e<o;e++)if(f=e/k,f*=f,h=a/(1.0E-4+f)-b,0<h)for(f=0;f<k;f++){i=e+f*l;for(g=0;g<k;g++)n[p*g+i]+=h}};this.addPlaneY=function(a,b){var e,f,g,h,i,k,l=this.size,p=this.yd,
+n=this.zd,o=this.field,q=l*Math.sqrt(a/b);q>l&&(q=l);for(f=0;f<q;f++)if(e=f/l,e*=e,h=a/(1.0E-4+e)-b,0<h){i=f*p;for(e=0;e<l;e++){k=i+e;for(g=0;g<l;g++)o[n*g+k]+=h}}};this.addPlaneZ=function(a,b){var e,f,g,h,i,k,l=this.size,p=this.yd,n=this.zd,o=this.field,q=l*Math.sqrt(a/b);q>l&&(q=l);for(g=0;g<q;g++)if(e=g/l,e*=e,h=a/(1.0E-4+e)-b,0<h){i=n*g;for(f=0;f<l;f++){k=i+f*p;for(e=0;e<l;e++)o[k+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,k,l,p,n=this.size-2;for(g=1;g<n;g++){p=this.size2*g;k=(g-this.halfsize)/this.halfsize;for(f=1;f<n;f++){l=p+this.size*f;i=(f-this.halfsize)/this.halfsize;for(e=1;e<n;e++)h=(e-this.halfsize)/this.halfsize,b=l+e,this.polygonize(h,i,k,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,k,l,p,n,o;for(g=0;g<f.count;g++)n=3*g,l=n+1,o=n+2,h=f.positionArray[n],i=f.positionArray[l],k=
+f.positionArray[o],p=new THREE.Vector3(h,i,k),h=f.normalArray[n],i=f.normalArray[l],k=f.normalArray[o],n=new THREE.Vector3(h,i,k),n.normalize(),l=new THREE.Vertex(p),b.vertices.push(l),e.push(n);p=f.count/3;for(g=0;g<p;g++)n=3*(a+g),l=n+1,o=n+2,h=e[n],i=e[l],k=e[o],n=new THREE.Face3(n,l,o,[h,i,k]),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;
 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]);
@@ -744,38 +745,38 @@ THREE.triTable=new Int32Array([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0
 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.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)};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,e,f){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===f&&(f=1);void 0===e&&(e=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:e,blending:d})};
 THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,c,d=2*-this.positionScreen.x,e=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+e*c.distance,c.wantedRotation=0.25*c.x*Math.PI,c.rotation+=0.25*(c.wantedRotation-c.rotation)};
-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,k,l,p,m,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,k,l,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++]=
 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)?(k=!1,l=a(THREE.ShaderFlares.lensFlare)):(k=!0,l=a(THREE.ShaderFlares.lensFlareVertexTexture));p={};m={};p.vertex=b.getAttribLocation(l,"position");p.uv=b.getAttribLocation(l,"uv");m.renderType=b.getUniformLocation(l,"renderType");m.map=b.getUniformLocation(l,"map");m.occlusionMap=b.getUniformLocation(l,"occlusionMap");m.opacity=b.getUniformLocation(l,"opacity");m.color=b.getUniformLocation(l,
-"color");m.scale=b.getUniformLocation(l,"scale");m.rotation=b.getUniformLocation(l,"rotation");m.screenPosition=b.getUniformLocation(l,"screenPosition");o=!1};this.render=function(a,d,e,s){var a=a.__webglFlares,t=a.length;if(t){var w=new THREE.Vector3,u=s/e,v=0.5*e,y=0.5*s,D=16/s,C=new THREE.Vector2(D*u,D),B=new THREE.Vector3(1,1,0),E=new THREE.Vector2(1,1),J=m,D=p;b.useProgram(l);o||(b.enableVertexAttribArray(p.vertex),b.enableVertexAttribArray(p.uv),o=!0);b.uniform1i(J.occlusionMap,0);b.uniform1i(J.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 N,S,K,O,M;for(N=0;N<t;N++)if(D=16/s,C.set(D*u,D),O=a[N],w.set(O.matrixWorld.n14,O.matrixWorld.n24,O.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(w),d.projectionMatrix.multiplyVector3(w),B.copy(w),E.x=B.x*v+v,E.y=B.y*y+y,k||0<E.x&&E.x<e&&0<E.y&&E.y<s){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
-h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,E.x-8,E.y-8,16,16,0);b.uniform1i(J.renderType,0);b.uniform2f(J.scale,C.x,C.y);b.uniform3f(J.screenPosition,B.x,B.y,B.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,E.x-8,E.y-8,16,16,0);b.uniform1i(J.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);O.positionScreen.copy(B);O.customUpdateCallback?O.customUpdateCallback(O):O.updateLensFlares();b.uniform1i(J.renderType,2);b.enable(b.BLEND);for(S=0,K=O.lensFlares.length;S<K;S++)if(M=O.lensFlares[S],0.0010<M.opacity&&0.0010<M.scale)B.x=M.x,B.y=M.y,B.z=M.z,D=M.size*M.scale/s,C.x=D*u,C.y=D,b.uniform3f(J.screenPosition,B.x,B.y,B.z),b.uniform2f(J.scale,C.x,C.y),b.uniform1f(J.rotation,M.rotation),b.uniform1f(J.opacity,M.opacity),b.uniform3f(J.color,M.color.r,M.color.g,M.color.b),
-c.setBlending(M.blending),c.setTexture(M.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)?(k=!1,l=a(THREE.ShaderFlares.lensFlare)):(k=!0,l=a(THREE.ShaderFlares.lensFlareVertexTexture));p={};n={};p.vertex=b.getAttribLocation(l,"position");p.uv=b.getAttribLocation(l,"uv");n.renderType=b.getUniformLocation(l,"renderType");n.map=b.getUniformLocation(l,"map");n.occlusionMap=b.getUniformLocation(l,"occlusionMap");n.opacity=b.getUniformLocation(l,"opacity");n.color=b.getUniformLocation(l,
+"color");n.scale=b.getUniformLocation(l,"scale");n.rotation=b.getUniformLocation(l,"rotation");n.screenPosition=b.getUniformLocation(l,"screenPosition");o=!1};this.render=function(a,d,e,s){var a=a.__webglFlares,t=a.length;if(t){var w=new THREE.Vector3,u=s/e,v=0.5*e,A=0.5*s,B=16/s,C=new THREE.Vector2(B*u,B),D=new THREE.Vector3(1,1,0),I=new THREE.Vector2(1,1),K=n,B=p;b.useProgram(l);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(B.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(B.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,g);b.disable(b.CULL_FACE);b.depthMask(!1);var O,S,L,P,H;for(O=0;O<t;O++)if(B=16/s,C.set(B*u,B),P=a[O],w.set(P.matrixWorld.n14,P.matrixWorld.n24,P.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(w),d.projectionMatrix.multiplyVector3(w),D.copy(w),I.x=D.x*v+v,I.y=D.y*A+A,k||0<I.x&&I.x<e&&0<I.y&&I.y<s){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
+h);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,I.x-8,I.y-8,16,16,0);b.uniform1i(K.renderType,0);b.uniform2f(K.scale,C.x,C.y);b.uniform3f(K.screenPosition,D.x,D.y,D.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,I.x-8,I.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(D);P.customUpdateCallback?P.customUpdateCallback(P):P.updateLensFlares();b.uniform1i(K.renderType,2);b.enable(b.BLEND);for(S=0,L=P.lensFlares.length;S<L;S++)if(H=P.lensFlares[S],0.0010<H.opacity&&0.0010<H.scale)D.x=H.x,D.y=H.y,D.z=H.z,B=H.size*H.scale/s,C.x=B*u,C.y=B,b.uniform3f(K.screenPosition,D.x,D.y,D.z),b.uniform2f(K.scale,C.x,C.y),b.uniform1f(K.rotation,H.rotation),b.uniform1f(K.opacity,H.opacity),b.uniform3f(K.color,H.color.r,H.color.g,H.color.b),
+c.setBlending(H.blending),c.setTexture(H.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=new THREE.Frustum,f=new THREE.Matrix4,g=new THREE.Vector3,h=new THREE.Vector3;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render=function(a,
-c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(i,k){var l,p,m,o,q,n,r,s,t,w=[];o=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(l=0,p=i.lights.length;l<p;l++)if(m=i.lights[l],m.castShadow)if(m instanceof THREE.DirectionalLight&&m.shadowCascade)for(q=0;q<m.shadowCascadeCount;q++){var u;if(m.shadowCascadeArray[q])u=m.shadowCascadeArray[q];else{t=m;r=q;u=new THREE.DirectionalLight;u.isVirtual=!0;u.onlyShadow=
-!0;u.castShadow=!0;u.shadowCameraNear=t.shadowCameraNear;u.shadowCameraFar=t.shadowCameraFar;u.shadowCameraLeft=t.shadowCameraLeft;u.shadowCameraRight=t.shadowCameraRight;u.shadowCameraBottom=t.shadowCameraBottom;u.shadowCameraTop=t.shadowCameraTop;u.shadowCameraVisible=t.shadowCameraVisible;u.shadowDarkness=t.shadowDarkness;u.shadowBias=t.shadowCascadeBias[r];u.shadowMapWidth=t.shadowCascadeWidth[r];u.shadowMapHeight=t.shadowCascadeHeight[r];u.pointsWorld=[];u.pointsFrustum=[];s=u.pointsWorld;n=
-u.pointsFrustum;for(var v=0;8>v;v++)s[v]=new THREE.Vector3,n[v]=new THREE.Vector3;s=t.shadowCascadeNearZ[r];t=t.shadowCascadeFarZ[r];n[0].set(-1,-1,s);n[1].set(1,-1,s);n[2].set(-1,1,s);n[3].set(1,1,s);n[4].set(-1,-1,t);n[5].set(1,-1,t);n[6].set(-1,1,t);n[7].set(1,1,t);u.originalCamera=k;n=new THREE.Gyroscope;n.position=m.shadowCascadeOffset;n.add(u);n.add(u.target);k.add(n);m.shadowCascadeArray[q]=u;console.log("Created virtualLight",u)}r=m;s=q;t=r.shadowCascadeArray[s];t.position.copy(r.position);
-t.target.position.copy(r.target.position);t.lookAt(t.target);t.shadowCameraVisible=r.shadowCameraVisible;t.shadowDarkness=r.shadowDarkness;t.shadowBias=r.shadowCascadeBias[s];n=r.shadowCascadeNearZ[s];r=r.shadowCascadeFarZ[s];t=t.pointsFrustum;t[0].z=n;t[1].z=n;t[2].z=n;t[3].z=n;t[4].z=r;t[5].z=r;t[6].z=r;t[7].z=r;w[o]=u;o++}else w[o]=m,o++;for(l=0,p=w.length;l<p;l++){m=w[l];if(!m.shadowMap)m.shadowMap=new THREE.WebGLRenderTarget(m.shadowMapWidth,m.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
-format:THREE.RGBAFormat}),m.shadowMapSize=new THREE.Vector2(m.shadowMapWidth,m.shadowMapHeight),m.shadowMatrix=new THREE.Matrix4;if(!m.shadowCamera){if(m instanceof THREE.SpotLight)m.shadowCamera=new THREE.PerspectiveCamera(m.shadowCameraFov,m.shadowMapWidth/m.shadowMapHeight,m.shadowCameraNear,m.shadowCameraFar);else if(m instanceof THREE.DirectionalLight)m.shadowCamera=new THREE.OrthographicCamera(m.shadowCameraLeft,m.shadowCameraRight,m.shadowCameraTop,m.shadowCameraBottom,m.shadowCameraNear,m.shadowCameraFar);
-else{console.error("Unsupported light type for shadow");continue}i.add(m.shadowCamera);b.autoUpdateScene&&i.updateMatrixWorld()}if(m.shadowCameraVisible&&!m.cameraHelper)m.cameraHelper=new THREE.CameraHelper(m.shadowCamera),m.shadowCamera.add(m.cameraHelper);if(m.isVirtual&&u.originalCamera==k){q=k;o=m.shadowCamera;n=m.pointsFrustum;t=m.pointsWorld;g.set(Infinity,Infinity,Infinity);h.set(-Infinity,-Infinity,-Infinity);for(r=0;8>r;r++){s=t[r];s.copy(n[r]);THREE.ShadowMapPlugin.__projector.unprojectVector(s,
-q);o.matrixWorldInverse.multiplyVector3(s);if(s.x<g.x)g.x=s.x;if(s.x>h.x)h.x=s.x;if(s.y<g.y)g.y=s.y;if(s.y>h.y)h.y=s.y;if(s.z<g.z)g.z=s.z;if(s.z>h.z)h.z=s.z}o.left=g.x;o.right=h.x;o.top=h.y;o.bottom=g.y;o.updateProjectionMatrix()}o=m.shadowMap;n=m.shadowMatrix;q=m.shadowCamera;q.position.copy(m.matrixWorld.getPosition());q.lookAt(m.target.matrixWorld.getPosition());q.updateMatrixWorld();q.matrixWorldInverse.getInverse(q.matrixWorld);if(m.cameraHelper)m.cameraHelper.lines.visible=m.shadowCameraVisible;
-m.shadowCameraVisible&&m.cameraHelper.update(m.shadowCamera);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(q.projectionMatrix);n.multiplySelf(q.matrixWorldInverse);if(!q._viewMatrixArray)q._viewMatrixArray=new Float32Array(16);q.matrixWorldInverse.flattenToArray(q._viewMatrixArray);if(!q._projectionMatrixArray)q._projectionMatrixArray=new Float32Array(16);q.projectionMatrix.flattenToArray(q._projectionMatrixArray);f.multiply(q.projectionMatrix,q.matrixWorldInverse);e.setFromMatrix(f);
-b.setRenderTarget(o);b.clear();t=i.__webglObjects;for(m=0,o=t.length;m<o;m++)if(r=t[m],n=r.object,r.render=!1,n.visible&&n.castShadow&&(!(n instanceof THREE.Mesh)||!n.frustumCulled||e.contains(n)))n.matrixWorld.flattenToArray(n._objectMatrixArray),n._modelViewMatrix.multiplyToArray(q.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray),r.render=!0;for(m=0,o=t.length;m<o;m++)if(r=t[m],r.render)n=r.object,r=r.buffer,b.setObjectFaces(n),s=n.customDepthMaterial?n.customDepthMaterial:n.geometry.morphTargets.length?
-d:c,r instanceof THREE.BufferGeometry?b.renderBufferDirect(q,i.lights,null,s,r,n):b.renderBuffer(q,i.lights,null,s,r,n);t=i.__webglObjectsImmediate;for(m=0,o=t.length;m<o;m++)r=t[m],n=r.object,n.visible&&n.castShadow&&(n.matrixAutoUpdate&&n.matrixWorld.flattenToArray(n._objectMatrixArray),n._modelViewMatrix.multiplyToArray(q.matrixWorldInverse,n.matrixWorld,n._modelViewMatrixArray),b.renderImmediateObject(q,i.lights,null,c,n))}l=b.getClearColor();p=b.getClearAlpha();a.clearColor(l.r,l.g,l.b,p);a.enable(a.BLEND);
+c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(i,k){var l,p,n,o,q,m,r,s,t,w=[];o=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(l=0,p=i.lights.length;l<p;l++)if(n=i.lights[l],n.castShadow)if(n instanceof THREE.DirectionalLight&&n.shadowCascade)for(q=0;q<n.shadowCascadeCount;q++){var u;if(n.shadowCascadeArray[q])u=n.shadowCascadeArray[q];else{t=n;r=q;u=new THREE.DirectionalLight;u.isVirtual=!0;u.onlyShadow=
+!0;u.castShadow=!0;u.shadowCameraNear=t.shadowCameraNear;u.shadowCameraFar=t.shadowCameraFar;u.shadowCameraLeft=t.shadowCameraLeft;u.shadowCameraRight=t.shadowCameraRight;u.shadowCameraBottom=t.shadowCameraBottom;u.shadowCameraTop=t.shadowCameraTop;u.shadowCameraVisible=t.shadowCameraVisible;u.shadowDarkness=t.shadowDarkness;u.shadowBias=t.shadowCascadeBias[r];u.shadowMapWidth=t.shadowCascadeWidth[r];u.shadowMapHeight=t.shadowCascadeHeight[r];u.pointsWorld=[];u.pointsFrustum=[];s=u.pointsWorld;m=
+u.pointsFrustum;for(var v=0;8>v;v++)s[v]=new THREE.Vector3,m[v]=new THREE.Vector3;s=t.shadowCascadeNearZ[r];t=t.shadowCascadeFarZ[r];m[0].set(-1,-1,s);m[1].set(1,-1,s);m[2].set(-1,1,s);m[3].set(1,1,s);m[4].set(-1,-1,t);m[5].set(1,-1,t);m[6].set(-1,1,t);m[7].set(1,1,t);u.originalCamera=k;m=new THREE.Gyroscope;m.position=n.shadowCascadeOffset;m.add(u);m.add(u.target);k.add(m);n.shadowCascadeArray[q]=u;console.log("Created virtualLight",u)}r=n;s=q;t=r.shadowCascadeArray[s];t.position.copy(r.position);
+t.target.position.copy(r.target.position);t.lookAt(t.target);t.shadowCameraVisible=r.shadowCameraVisible;t.shadowDarkness=r.shadowDarkness;t.shadowBias=r.shadowCascadeBias[s];m=r.shadowCascadeNearZ[s];r=r.shadowCascadeFarZ[s];t=t.pointsFrustum;t[0].z=m;t[1].z=m;t[2].z=m;t[3].z=m;t[4].z=r;t[5].z=r;t[6].z=r;t[7].z=r;w[o]=u;o++}else w[o]=n,o++;for(l=0,p=w.length;l<p;l++){n=w[l];if(!n.shadowMap)n.shadowMap=new THREE.WebGLRenderTarget(n.shadowMapWidth,n.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
+format:THREE.RGBAFormat}),n.shadowMapSize=new THREE.Vector2(n.shadowMapWidth,n.shadowMapHeight),n.shadowMatrix=new THREE.Matrix4;if(!n.shadowCamera){if(n instanceof THREE.SpotLight)n.shadowCamera=new THREE.PerspectiveCamera(n.shadowCameraFov,n.shadowMapWidth/n.shadowMapHeight,n.shadowCameraNear,n.shadowCameraFar);else if(n instanceof THREE.DirectionalLight)n.shadowCamera=new THREE.OrthographicCamera(n.shadowCameraLeft,n.shadowCameraRight,n.shadowCameraTop,n.shadowCameraBottom,n.shadowCameraNear,n.shadowCameraFar);
+else{console.error("Unsupported light type for shadow");continue}i.add(n.shadowCamera);b.autoUpdateScene&&i.updateMatrixWorld()}if(n.shadowCameraVisible&&!n.cameraHelper)n.cameraHelper=new THREE.CameraHelper(n.shadowCamera),n.shadowCamera.add(n.cameraHelper);if(n.isVirtual&&u.originalCamera==k){q=k;o=n.shadowCamera;m=n.pointsFrustum;t=n.pointsWorld;g.set(Infinity,Infinity,Infinity);h.set(-Infinity,-Infinity,-Infinity);for(r=0;8>r;r++){s=t[r];s.copy(m[r]);THREE.ShadowMapPlugin.__projector.unprojectVector(s,
+q);o.matrixWorldInverse.multiplyVector3(s);if(s.x<g.x)g.x=s.x;if(s.x>h.x)h.x=s.x;if(s.y<g.y)g.y=s.y;if(s.y>h.y)h.y=s.y;if(s.z<g.z)g.z=s.z;if(s.z>h.z)h.z=s.z}o.left=g.x;o.right=h.x;o.top=h.y;o.bottom=g.y;o.updateProjectionMatrix()}o=n.shadowMap;m=n.shadowMatrix;q=n.shadowCamera;q.position.copy(n.matrixWorld.getPosition());q.lookAt(n.target.matrixWorld.getPosition());q.updateMatrixWorld();q.matrixWorldInverse.getInverse(q.matrixWorld);if(n.cameraHelper)n.cameraHelper.lines.visible=n.shadowCameraVisible;
+n.shadowCameraVisible&&n.cameraHelper.update(n.shadowCamera);m.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);m.multiplySelf(q.projectionMatrix);m.multiplySelf(q.matrixWorldInverse);if(!q._viewMatrixArray)q._viewMatrixArray=new Float32Array(16);q.matrixWorldInverse.flattenToArray(q._viewMatrixArray);if(!q._projectionMatrixArray)q._projectionMatrixArray=new Float32Array(16);q.projectionMatrix.flattenToArray(q._projectionMatrixArray);f.multiply(q.projectionMatrix,q.matrixWorldInverse);e.setFromMatrix(f);
+b.setRenderTarget(o);b.clear();t=i.__webglObjects;for(n=0,o=t.length;n<o;n++)if(r=t[n],m=r.object,r.render=!1,m.visible&&m.castShadow&&(!(m instanceof THREE.Mesh)||!m.frustumCulled||e.contains(m)))m.matrixWorld.flattenToArray(m._objectMatrixArray),m._modelViewMatrix.multiplyToArray(q.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray),r.render=!0;for(n=0,o=t.length;n<o;n++)if(r=t[n],r.render)m=r.object,r=r.buffer,b.setObjectFaces(m),s=m.customDepthMaterial?m.customDepthMaterial:m.geometry.morphTargets.length?
+d:c,r instanceof THREE.BufferGeometry?b.renderBufferDirect(q,i.lights,null,s,r,m):b.renderBuffer(q,i.lights,null,s,r,m);t=i.__webglObjectsImmediate;for(n=0,o=t.length;n<o;n++)r=t[n],m=r.object,m.visible&&m.castShadow&&(m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),m._modelViewMatrix.multiplyToArray(q.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray),b.renderImmediateObject(q,i.lights,null,c,m))}l=b.getClearColor();p=b.getClearAlpha();a.clearColor(l.r,l.g,l.b,p);a.enable(a.BLEND);
 b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;
 THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,e,f,g,h,i,k,l;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,m=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(m,o);b.attachShader(m,q);b.linkProgram(m);h=m;i={};k={};i.position=b.getAttribLocation(h,"position");i.uv=b.getAttribLocation(h,"uv");k.uvOffset=b.getUniformLocation(h,"uvOffset");k.uvScale=b.getUniformLocation(h,
+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={};k={};i.position=b.getAttribLocation(h,"position");i.uv=b.getAttribLocation(h,"uv");k.uvOffset=b.getUniformLocation(h,"uvOffset");k.uvScale=b.getUniformLocation(h,
 "uvScale");k.rotation=b.getUniformLocation(h,"rotation");k.scale=b.getUniformLocation(h,"scale");k.alignment=b.getUniformLocation(h,"alignment");k.color=b.getUniformLocation(h,"color");k.map=b.getUniformLocation(h,"map");k.opacity=b.getUniformLocation(h,"opacity");k.useScreenCoordinates=b.getUniformLocation(h,"useScreenCoordinates");k.affectedByDistance=b.getUniformLocation(h,"affectedByDistance");k.screenPosition=b.getUniformLocation(h,"screenPosition");k.modelViewMatrix=b.getUniformLocation(h,"modelViewMatrix");
-k.projectionMatrix=b.getUniformLocation(h,"projectionMatrix");l=!1};this.render=function(d,e,o,q){var d=d.__webglSprites,n=d.length;if(n){var r=i,s=k,t=q/o,o=0.5*o,w=0.5*q,u=!0;b.useProgram(h);l||(b.enableVertexAttribArray(r.position),b.enableVertexAttribArray(r.uv),l=!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,y=[],r=0;r<n;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<n;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,(w-v.position.y)/w,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),y[0]=e*t*v.scale.x,y[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,y),v.mergeWith3D&&!u?(b.enable(b.DEPTH_TEST),u=!0):!v.mergeWith3D&&u&&(b.disable(b.DEPTH_TEST),u=!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,k,l,p;e.matrixAutoUpdate=f.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},m=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:m},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}"}),
-n=new THREE.Scene;n.add(new THREE.Mesh(new THREE.PlaneGeometry(2,2),a));n.add(q);this.setSize=function(a,d){c.call(b,a,d);m.width=a;m.height=d;o.width=a;o.height=d};this.render=function(a,c){a.updateMatrixWorld();if(i!==c.aspect||k!==c.near||l!==c.far||p!==c.fov){i=c.aspect;k=c.near;l=c.far;p=c.fov;var t=c.projectionMatrix.clone(),w=0.5*(125/30),u=w*k/125,v=k*Math.tan(p*Math.PI/360),y;g.n14=w;h.n14=-w;w=-v*i+u;y=v*i+u;t.n11=2*k/(y-w);t.n13=(y+w)/(y-w);e.projectionMatrix.copy(t);w=-v*i-u;y=v*i-u;t.n11=
-2*k/(y-w);t.n13=(y+w)/(y-w);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,m,!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);n.updateMatrixWorld();d.call(b,n,q)}};
+k.projectionMatrix=b.getUniformLocation(h,"projectionMatrix");l=!1};this.render=function(d,e,o,q){var d=d.__webglSprites,m=d.length;if(m){var r=i,s=k,t=q/o,o=0.5*o,w=0.5*q,u=!0;b.useProgram(h);l||(b.enableVertexAttribArray(r.position),b.enableVertexAttribArray(r.uv),l=!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,(w-v.position.y)/w,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&&!u?(b.enable(b.DEPTH_TEST),u=!0):!v.mergeWith3D&&u&&(b.disable(b.DEPTH_TEST),u=!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,k,l,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||k!==c.near||l!==c.far||p!==c.fov){i=c.aspect;k=c.near;l=c.far;p=c.fov;var t=c.projectionMatrix.clone(),w=0.5*(125/30),u=w*k/125,v=k*Math.tan(p*Math.PI/360),A;g.n14=w;h.n14=-w;w=-v*i+u;A=v*i+u;t.n11=2*k/(A-w);t.n13=(A+w)/(A-w);e.projectionMatrix.copy(t);w=-v*i-u;A=v*i-u;t.n11=
+2*k/(A-w);t.n13=(A+w)/(A-w);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)}};
 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}"},

+ 70 - 69
build/custom/ThreeCanvas.js

@@ -18,66 +18,66 @@ this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;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);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());p=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(j>a.geometry.boundingSphere.radius*Math.max(p.x,Math.max(p.y,p.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}};
+THREE.Ray=function(a,b){function c(a,b,c){j.sub(c,a);q=j.dot(b);x=p.add(a,i.copy(b).multiplyScalar(q));return v=c.distanceTo(x)}function d(a,b,c,d){j.sub(d,b);p.sub(c,b);i.sub(a,b);I=j.dot(j);G=j.dot(p);w=j.dot(i);H=p.dot(p);A=p.dot(i);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,h=new THREE.Vector3,m=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3,o=new THREE.Vector3,n=new THREE.Vector3;this.intersectObject=function(a){for(var b,i=[],j=0,p=a.children.length;j<p;j++)Array.prototype.push.apply(i,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};i.push(b)}else if(a instanceof THREE.Mesh){j=c(this.origin,this.direction,a.matrixWorld.getPosition());p=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(j>a.geometry.boundingSphere.radius*Math.max(p.x,Math.max(p.y,p.z)))return i;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),k.copy(this.direction),t=a.matrixWorld,l=t.multiplyVector3(l.copy(b.centroid)).subSelf(m),o=a.matrixRotationWorld.multiplyVector3(o.copy(b.normal)),q=k.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,k.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},i.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)),h=t.multiplyVector3(h.copy(E[b.d].position)),d(n,e,f,h)||d(n,f,g,h)))b={distance:m.distanceTo(n),point:n.clone(),face:b,object:a},i.push(b)}return i};var j=new THREE.Vector3,p=new THREE.Vector3,i=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,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,l,o){h=!1;b=f;c=g;d=l;e=o;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,l,o,n,j){h?(h=!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){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,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,
-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*=
+THREE.Matrix4=function(a,b,c,d,e,f,g,h,m,k,l,o,n,j,p,i){this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==f?f:1,g||0,h||0,m||0,k||0,void 0!==l?l:1,o||0,n||0,j||0,p||0,void 0!==i?i: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,m,k,l,o,n,j,p,i){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=m;this.n32=k;this.n33=l;this.n34=o;this.n41=n;this.n42=j;this.n43=p;this.n44=i;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,m=a.n23,k=a.n24,l=a.n31,o=a.n32,n=a.n33,j=a.n34,p=a.n41,i=a.n42,q=a.n43,
+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+h*H+m*s+k*ca;this.n22=g*I+h*A+m*D+k*N;this.n23=g*G+h*F+m*J+k*P;this.n24=g*w+h*r+m*Z+k*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+i*H+q*s+x*ca;this.n42=p*I+i*A+q*D+x*N;this.n43=p*
+G+i*F+q*J+x*P;this.n44=p*w+i*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;
+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,m=this.n31,k=this.n32,l=this.n33,o=this.n34,n=this.n41,j=this.n42,p=this.n43,i=this.n44;return d*g*k*n-c*h*k*n-d*f*l*n+b*h*l*n+c*f*o*n-b*g*o*n-d*g*m*j+c*h*m*j+d*e*l*j-a*h*l*j-c*e*o*j+a*g*o*j+d*f*m*p-b*h*m*p-d*e*k*p+a*h*k*p+b*e*o*p-a*f*o*p-c*f*m*i+b*g*m*i+c*e*k*i-a*g*k*i-b*e*l*i+a*f*l*i},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,i=a.z,m=e*f,h=e*g;this.set(m*f+c,m*g-d*i,m*i+d*g,0,m*g+d*i,h*g+c,h*i-d*f,0,m*i-d*g,h*i+d*f,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},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,i=a.n23,m=a.n24,h=a.n31,l=a.n32,o=a.n33,n=a.n34,j=a.n41,p=a.n42,k=a.n43,q=a.n44;this.n11=i*n*p-m*o*p+m*l*k-g*n*k-i*l*q+g*o*q;this.n12=e*o*p-d*n*p-e*l*k+c*n*k+d*l*q-c*o*q;this.n13=d*m*p-e*i*p+e*g*k-c*m*k-d*g*q+c*i*q;this.n14=e*i*l-d*m*l-e*g*o+c*m*o+d*g*n-c*i*n;this.n21=m*o*j-i*n*j-m*h*k+f*n*k+i*h*q-f*o*q;this.n22=d*n*j-e*o*j+
-e*h*k-b*n*k-d*h*q+b*o*q;this.n23=e*i*j-d*m*j-e*f*k+b*m*k+d*f*q-b*i*q;this.n24=d*m*h-e*i*h+e*f*o-b*m*o-d*f*n+b*i*n;this.n31=g*n*j-m*l*j+m*h*p-f*n*p-g*h*q+f*l*q;this.n32=e*l*j-c*n*j-e*h*p+b*n*p+c*h*q-b*l*q;this.n33=c*m*j-e*g*j+e*f*p-b*m*p-c*f*q+b*g*q;this.n34=e*g*h-c*m*h-e*f*l+b*m*l+c*f*n-b*g*n;this.n41=i*l*j-g*o*j-i*h*p+f*o*p+g*h*k-f*l*k;this.n42=c*o*j-d*l*j+d*h*p-b*o*p-c*h*k+b*l*k;this.n43=d*g*j-c*i*j-d*f*p+b*i*p+c*f*k-b*g*k;this.n44=c*i*h-d*g*h+d*f*l-b*i*l-c*f*o+b*g*o;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),i=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var m=g*i,h=g*e,l=d*i,o=d*e;this.n11=m+o*c;this.n12=l*c-h;this.n13=f*d;this.n21=f*e;this.n22=f*i;this.n23=-c;this.n31=h*c-l;this.n32=o+m*c;this.n33=f*g;break;case "ZXY":m=g*i;h=g*e;l=d*i;o=d*e;this.n11=m-o*c;this.n12=-f*e;this.n13=l+h*c;this.n21=h+l*c;this.n22=f*i;this.n23=o-m*c;this.n31=-f*d;this.n32=c;this.n33=f*g;break;case "ZYX":m=
-f*i;h=f*e;l=c*i;o=c*e;this.n11=g*i;this.n12=l*d-h;this.n13=m*d+o;this.n21=g*e;this.n22=o*d+m;this.n23=h*d-l;this.n31=-d;this.n32=c*g;this.n33=f*g;break;case "YZX":m=f*g;h=f*d;l=c*g;o=c*d;this.n11=g*i;this.n12=o-m*e;this.n13=l*e+h;this.n21=e;this.n22=f*i;this.n23=-c*i;this.n31=-d*i;this.n32=h*e+l;this.n33=m-o*e;break;case "XZY":m=f*g;h=f*d;l=c*g;o=c*d;this.n11=g*i;this.n12=-e;this.n13=d*i;this.n21=m*e+o;this.n22=f*i;this.n23=h*e-l;this.n31=l*e-h;this.n32=c*i;this.n33=o*e+m;break;default:m=f*i,h=f*
-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*d,this.n23=-c*g,this.n31=o-m*d,this.n32=l+h*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,i=d+d,a=b*f,m=b*g,b=b*i,h=c*g,c=c*i,d=d*i,f=e*f,g=e*g,e=e*i;this.n11=1-(h+d);this.n12=m-e;this.n13=b+g;this.n21=m+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+h);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=
+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,m=e*f,k=e*g;this.set(m*f+c,m*g-d*h,m*h+d*g,0,m*g+d*h,k*g+c,k*h-d*f,0,m*h-d*g,k*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,m=a.n24,k=a.n31,l=a.n32,o=a.n33,n=a.n34,j=a.n41,p=a.n42,i=a.n43,q=a.n44;this.n11=h*n*p-m*o*p+m*l*i-g*n*i-h*l*q+g*o*q;this.n12=e*o*p-d*n*p-e*l*i+c*n*i+d*l*q-c*o*q;this.n13=d*m*p-e*h*p+e*g*i-c*m*i-d*g*q+c*h*q;this.n14=e*h*l-d*m*l-e*g*o+c*m*o+d*g*n-c*h*n;this.n21=m*o*j-h*n*j-m*k*i+f*n*i+h*k*q-f*o*q;this.n22=d*n*j-e*o*j+
+e*k*i-b*n*i-d*k*q+b*o*q;this.n23=e*h*j-d*m*j-e*f*i+b*m*i+d*f*q-b*h*q;this.n24=d*m*k-e*h*k+e*f*o-b*m*o-d*f*n+b*h*n;this.n31=g*n*j-m*l*j+m*k*p-f*n*p-g*k*q+f*l*q;this.n32=e*l*j-c*n*j-e*k*p+b*n*p+c*k*q-b*l*q;this.n33=c*m*j-e*g*j+e*f*p-b*m*p-c*f*q+b*g*q;this.n34=e*g*k-c*m*k-e*f*l+b*m*l+c*f*n-b*g*n;this.n41=h*l*j-g*o*j-h*k*p+f*o*p+g*k*i-f*l*i;this.n42=c*o*j-d*l*j+d*k*p-b*o*p-c*k*i+b*l*i;this.n43=d*g*j-c*h*j-d*f*p+b*h*p+c*f*i-b*g*i;this.n44=c*h*k-d*g*k+d*f*l-b*h*l-c*f*o+b*g*o;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 m=g*h,k=g*e,l=d*h,o=d*e;this.n11=m+o*c;this.n12=l*c-k;this.n13=f*d;this.n21=f*e;this.n22=f*h;this.n23=-c;this.n31=k*c-l;this.n32=o+m*c;this.n33=f*g;break;case "ZXY":m=g*h;k=g*e;l=d*h;o=d*e;this.n11=m-o*c;this.n12=-f*e;this.n13=l+k*c;this.n21=k+l*c;this.n22=f*h;this.n23=o-m*c;this.n31=-f*d;this.n32=c;this.n33=f*g;break;case "ZYX":m=
+f*h;k=f*e;l=c*h;o=c*e;this.n11=g*h;this.n12=l*d-k;this.n13=m*d+o;this.n21=g*e;this.n22=o*d+m;this.n23=k*d-l;this.n31=-d;this.n32=c*g;this.n33=f*g;break;case "YZX":m=f*g;k=f*d;l=c*g;o=c*d;this.n11=g*h;this.n12=o-m*e;this.n13=l*e+k;this.n21=e;this.n22=f*h;this.n23=-c*h;this.n31=-d*h;this.n32=k*e+l;this.n33=m-o*e;break;case "XZY":m=f*g;k=f*d;l=c*g;o=c*d;this.n11=g*h;this.n12=-e;this.n13=d*h;this.n21=m*e+o;this.n22=f*h;this.n23=k*e-l;this.n31=l*e-k;this.n32=c*h;this.n33=o*e+m;break;default:m=f*h,k=f*
+e,l=c*h,o=c*e,this.n11=g*h,this.n12=-g*e,this.n13=d,this.n21=k+l*d,this.n22=m-o*d,this.n23=-c*g,this.n31=o-m*d,this.n32=l+k*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,m=b*g,b=b*h,k=c*g,c=c*h,d=d*h,f=e*f,g=e*g,e=e*h;this.n11=1-(k+d);this.n12=m-e;this.n13=b+g;this.n21=m+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+k);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,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},
+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,m=Math.cos(b),k=Math.sin(b),l=1-m,o=c*d*l,n=c*e*l,l=d*e*l,c=c*k,j=d*k,k=e*k,e=f+(1-f)*m,f=o+k,d=n-j,o=o-k,g=g+(1-g)*m,k=l+c,n=n+j,l=l-c,h=h+(1-h)*m,m=this.n11,c=this.n21,j=this.n31,p=this.n41,i=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*i+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*i+k*I;this.n22=
+o*c+g*q+k*G;this.n32=o*j+g*x+k*w;this.n42=o*p+g*v+k*H;this.n13=n*m+l*i+h*I;this.n23=n*c+l*q+h*G;this.n33=n*j+l*x+h*w;this.n43=n*p+l*v+h*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,h=this.n33,m=this.n43,k=Math.cos(a),a=Math.sin(a);this.n12=k*b+a*f;this.n22=k*c+a*g;this.n32=k*d+a*h;this.n42=k*e+a*m;this.n13=k*f-a*b;this.n23=k*g-a*c;this.n33=k*h-a*d;this.n43=k*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,h=this.n33,m=this.n43,k=Math.cos(a),a=Math.sin(a);this.n11=k*b-a*f;this.n21=k*c-a*g;this.n31=k*d-a*h;this.n41=k*e-a*m;this.n13=k*f+a*b;this.n23=k*g+a*c;this.n33=k*h+a*d;this.n43=k*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,h=this.n32,m=this.n42,k=Math.cos(a),a=Math.sin(a);this.n11=k*b+a*f;this.n21=k*c+a*g;this.n31=k*d+a*h;this.n41=k*e+a*m;this.n12=k*f-a*b;this.n22=k*g-a*c;this.n32=k*h-a*d;this.n42=k*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};
+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,m=-a.n32*a.n11+a.n31*a.n12,k=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*k;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*m;c[6]=a*k;c[7]=a*l;c[8]=a*o;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var e,a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,i,m,h;g=new THREE.Matrix4;i=b-a;m=c-d;h=f-e;g.n11=2/i;g.n12=0;g.n13=0;g.n14=-((b+a)/i);g.n21=0;g.n22=2/m;g.n23=0;g.n24=-((c+d)/m);g.n31=0;g.n32=0;g.n33=-2/h;g.n34=-((f+e)/h);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};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.makeOrtho=function(a,b,c,d,e,f){var g,h,m,k;g=new THREE.Matrix4;h=b-a;m=c-d;k=f-e;g.n11=2/h;g.n12=0;g.n13=0;g.n14=-((b+a)/h);g.n21=0;g.n22=2/m;g.n23=0;g.n24=-((c+d)/m);g.n31=0;g.n32=0;g.n33=-2/k;g.n34=-((f+e)/k);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__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.id=THREE.Object3DCount++;this.name="";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=!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(a===
 this)console.warn("THREE: Object3D.add(): An object can't be added as a child of itself.");else 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,e;for(c=0,d=this.children.length;c<d;c++){e=this.children[c];if(e.name===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,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,
+THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=k[m]=k[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,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,m,k=[],l,o,n=[],j,p=[],i,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)-
+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++)h=b(),h.positionWorld.copy(Q[E].position),u.multiplyVector3(h.positionWorld),
+h.positionScreen.copy(h.positionWorld),F.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<H;for(Q=0,E=L.length;Q<E;Q++){t=L[Q];if(t instanceof THREE.Face3)if(y=k[t.a],O=k[t.b],M=k[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=k[t.a],O=k[t.b],M=k[t.c],V=k[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=
+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=k[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++,i=K,i.v1.positionScreen.copy(D),i.v2.positionScreen.copy(J),i.z=Math.max(D.z,J.z),i.material=z,w.elements.push(i)}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.x=a||0;this.y=b||0;this.z=c||0;this.w=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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},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*
+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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},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=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,i=a.z,a=a.w;this.x=b*a+e*f+c*i-d*g;this.y=c*a+e*g+d*f-b*i;this.z=d*a+e*i+b*g-c*f;this.w=e*a-b*f-c*g-d*i;return this},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,e=a.z,f=this.x,g=this.y,i=this.z,m=this.w,h=m*c+g*e-i*d,l=m*d+i*c-f*e,o=m*e+f*d-g*c,c=-f*c-g*d-i*e;b.x=h*m+c*-f+l*-i-o*-g;b.y=l*m+c*-g+o*-f-h*-i;b.z=o*m+c*-i+h*-g-l*-f;return b}};
+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,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;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,e=a.z,f=this.x,g=this.y,h=this.z,m=this.w,k=m*c+g*e-h*d,l=m*d+h*c-f*e,o=m*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=k*m+c*-f+l*-h-o*-g;b.y=l*m+c*-g+o*-f-k*-h;b.z=o*m+c*-h+k*-g-l*-f;return b}};
 THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))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)/e;d=Math.sin(d*f)/e;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,e,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=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
@@ -85,16 +85,17 @@ THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;ret
 THREE.Geometry=function(){this.id=THREE.GeometryCount++;this.vertices=[];this.colors=[];this.materials=[];this.faces=[];this.faceUvs=[[]];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphColors=[];this.morphNormals=[];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 e=this.faces[c];b.multiplyVector3(e.normal);for(var f=0,g=e.vertexNormals.length;f<g;f++)b.multiplyVector3(e.vertexNormals[f]);a.multiplyVector3(e.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,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=
+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]))},computeMorphNormals:function(){var a,
-b,c,d,e;for(c=0,d=this.faces.length;c<d;c++){e=this.faces[c];e.__originalVertexNormals=[];for(a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]=e.vertexNormals[a].clone()}var f=new THREE.Geometry;f.faces=this.faces;for(a=0,b=this.morphTargets.length;a<b;a++){var g=this.morphNormals[a];f.vertices=this.morphTargets[a].vertices;f.computeFaceNormals();f.computeVertexNormals();var i,m;for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],i=g.faceNormals[c],m=g.vertexNormals[c],i.copy(e.normal),
-e instanceof THREE.Face3?(m.a.copy(e.vertexNormals[0]),m.b.copy(e.vertexNormals[1]),m.c.copy(e.vertexNormals[2])):(m.a.copy(e.vertexNormals[0]),m.b.copy(e.vertexNormals[1]),m.c.copy(e.vertexNormals[2]),m.d.copy(e.vertexNormals[3]))}for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){function a(a,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]],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(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);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}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};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;
+b,c,d,e;for(c=0,d=this.faces.length;c<d;c++){e=this.faces[c];e.__originalFaceNormal?e.__originalFaceNormal.copy(e.normal):e.__originalFaceNormal=e.normal.clone();if(!e.__originalVertexNormals)e.__originalVertexNormals=[];for(a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]?e.__originalVertexNormals[a].copy(e.vertexNormals[a]):e.__originalVertexNormals[a]=e.vertexNormals[a].clone()}var f=new THREE.Geometry;f.faces=this.faces;for(a=0,b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]=
+{};this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=[];var g=this.morphNormals[a].faceNormals,h=this.morphNormals[a].vertexNormals,m,k;for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],m=new THREE.Vector3,k=e instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,d:new THREE.Vector3},g.push(m),h.push(k)}g=this.morphNormals[a];f.vertices=this.morphTargets[a].vertices;f.computeFaceNormals();
+f.computeVertexNormals();for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],m=g.faceNormals[c],k=g.vertexNormals[c],m.copy(e.normal),e instanceof THREE.Face3?(k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2])):(k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2]),k.d.copy(e.vertexNormals[3]))}for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],e.normal=e.__originalFaceNormal,e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){function a(a,
+b,c,d,e,f,F){h=a.vertices[b].position;m=a.vertices[c].position;k=a.vertices[d].position;l=g[e];o=g[f];n=g[F];j=m.x-h.x;p=k.x-h.x;i=m.y-h.y;q=k.y-h.y;x=m.z-h.z;v=k.z-h.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*i-w*q)*A,(H*x-w*v)*A);J.set((I*p-G*j)*A,(I*q-G*i)*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,h,m,k,l,o,n,j,p,i,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]],
+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(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);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}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};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;
 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;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;
@@ -120,7 +121,7 @@ THREE.MeshPhongMaterial.prototype.constructor=THREE.MeshPhongMaterial;THREE.Mesh
 THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);a=a||{};this.shading=a.shading?a.shading:THREE.FlatShading;this.wireframe=a.wireframe?a.wireframe:!1;this.wireframeLinewidth=a.wireframeLinewidth?a.wireframeLinewidth:1};THREE.MeshNormalMaterial.prototype=new THREE.Material;THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;THREE.MeshFaceMaterial=function(){};
 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.ParticleCanvasMaterial=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.program=void 0!==a.program?a.program:function(){}};THREE.ParticleCanvasMaterial.prototype=new THREE.Material;THREE.ParticleCanvasMaterial.prototype.constructor=THREE.ParticleCanvasMaterial;
-THREE.Texture=function(a,b,c,d,e,f,g,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!==e?e:THREE.LinearFilter;this.minFilter=void 0!==f?f:THREE.LinearMipMapLinearFilter;this.format=void 0!==g?g: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,e,f,g,h){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!==e?e:THREE.LinearFilter;this.minFilter=void 0!==f?f:THREE.LinearMipMapLinearFilter;this.format=void 0!==g?g:THREE.RGBAFormat;this.type=void 0!==h?h: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.Particle=function(a){THREE.Object3D.call(this);this.material=a};THREE.Particle.prototype=new THREE.Object3D;THREE.Particle.prototype.constructor=THREE.Particle;
@@ -136,38 +137,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(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");
+THREE.CanvasRenderer=function(a){function b(a){if(v!=a)i.globalAlpha=v=a}function c(a){if(I!=a){switch(a){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}I=a}}function d(a){if(G!=a)i.strokeStyle=G=a}function e(a){if(w!=a)i.fillStyle=w=a}var a=a||{},f=this,g,h,m,k=new THREE.Projector,l=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
+o,n,j,p,i=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 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,
+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(){i.setTransform(1,0,0,-1,j,p);Y.isEmpty()||(Y.minSelf(la),Y.inflate(2),1>x&&i.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+")"),i.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,h,k,l;for(e=0,f=a.length;e<f;e++)g=a[e],h=g.color,
+g instanceof THREE.DirectionalLight?(k=g.matrixWorld.getPosition(),l=c.dot(k),0>=l||(l*=g.intensity,d.r+=h.r*l,d.g+=h.g*l,d.b+=h.b*l)):g instanceof THREE.PointLight&&(k=g.matrixWorld.getPosition(),l=c.dot(R.sub(k,b).normalize()),0>=l||(l*=0==g.distance?1:1-Math.min(b.distanceTo(k)/g.distance,1),0!=l&&(l*=g.intensity,d.r+=h.r*l,d.g+=h.g*l,d.b+=h.b*l)))}function q(a,f,g){b(g.opacity);c(g.blending);var h,l,k,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,k=f.scale.y*p,h=g*za,l=k*o,X.set(a.x-h,a.y-l,a.x+h,a.y+l),la.intersects(X)&&(i.save(),i.translate(a.x,a.y),i.rotate(-f.rotation),i.scale(g,-k),i.translate(-za,-o),i.drawImage(m,0,0),i.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=f.scale.x*j,l=f.scale.y*p,X.set(a.x-h,a.y-l,a.x+h,a.y+l),la.intersects(X)&&(d(g.color.getContextStyle()),e(g.color.getContextStyle()),i.save(),i.translate(a.x,a.y),i.rotate(-f.rotation),i.scale(h,l),g.program(i),i.restore()))}function w(a,
+e,f,g){b(g.opacity);c(g.blending);i.beginPath();i.moveTo(a.positionScreen.x,a.positionScreen.y);i.lineTo(e.positionScreen.x,e.positionScreen.y);i.closePath();if(g instanceof THREE.LineBasicMaterial){a=g.linewidth;if(H!=a)i.lineWidth=H=a;a=g.linecap;if(A!=a)i.lineCap=A=a;a=g.linejoin;if(F!=a)i.lineJoin=F=a;d(g.color.getContextStyle());i.stroke();X.inflate(2*g.linewidth)}}function v(a,d,e,g,h,k,i,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&&($=i.uvs[0],Aa(N,P,S,T,E,t,$[g].u,$[g].v,$[h].u,$[h].v,$[k].u,$[k].v,j.map));else if(j.envMap){if(j.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=l.matrixWorldInverse,R.copy(i.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(i.vertexNormalsWorld[h]),
+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(i.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&&($=i.uvs[0],Aa(N,P,S,T,E,t,$[g].u,$[g].v,
+$[h].u,$[h].v,$[k].u,$[k].v,j.map)),c(THREE.SubtractiveBlending)),xa?!j.wireframe&&j.shading==THREE.SmoothShading&&3==i.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,i.v1.positionWorld,i.vertexNormalsWorld[0],C),n(m,i.v2.positionWorld,i.vertexNormalsWorld[1],z),n(m,i.v3.positionWorld,i.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,i.centroidWorld,i.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);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=
+qa(i.normalWorld.x),u.g=qa(i.normalWorld.y),u.b=qa(i.normalWorld.z),j.wireframe?ia(u,j.wireframeLinewidth,j.wireframeLinecap,j.wireframeLinejoin):ha(u)}function I(a,d,e,g,h,j,k,i,o){f.info.render.vertices+=4;f.info.render.faces++;b(i.opacity);c(i.blending);if(i.map||i.envMap)v(a,d,g,0,1,3,k,i,o),v(h,e,j,1,2,3,k,i,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=h.positionScreen.x,
+M=h.positionScreen.y,V=j.positionScreen.x,K=j.positionScreen.y,i instanceof THREE.MeshBasicMaterial)G(N,P,S,T,E,t,Q,y),i.wireframe?ia(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(i.color);else if(i instanceof THREE.MeshLambertMaterial)xa?!i.wireframe&&i.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(i.color.r*C.r,1)),C.g=Math.max(0,Math.min(i.color.g*C.g,1)),C.b=Math.max(0,Math.min(i.color.b*C.b,1)),z.r=Math.max(0,Math.min(i.color.r*z.r,1)),z.g=Math.max(0,Math.min(i.color.g*z.g,1)),z.b=Math.max(0,Math.min(i.color.b*z.b,1)),B.r=Math.max(0,Math.min(i.color.r*B.r,1)),B.g=Math.max(0,Math.min(i.color.g*B.g,1)),B.b=Math.max(0,Math.min(i.color.b*B.b,1)),L.r=Math.max(0,Math.min(i.color.r*
+L.r,1)),L.g=Math.max(0,Math.min(i.color.g*L.g,1)),L.b=Math.max(0,Math.min(i.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(i.color.r*u.r,1)),u.g=Math.max(0,Math.min(i.color.g*u.g,1)),u.b=Math.max(0,Math.min(i.color.b*u.b,1)),G(N,P,S,T,E,t,Q,y),i.wireframe?ia(u,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(u)):(G(N,P,S,
+T,E,t,Q,y),i.wireframe?ia(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(i.color));else if(i 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),i.wireframe?ia(u,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(u);else if(i 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){i.beginPath();i.moveTo(a,b);i.lineTo(c,d);i.lineTo(e,f);i.lineTo(a,b);i.closePath()}function G(a,b,c,d,e,f,g,h){i.beginPath();i.moveTo(a,b);i.lineTo(c,d);i.lineTo(e,f);i.lineTo(g,h);i.lineTo(a,b);i.closePath()}function ia(a,b,c,e){if(H!=b)i.lineWidth=H=b;if(A!=c)i.lineCap=A=c;if(F!=e)i.lineJoin=F=e;d(a.getContextStyle());
+i.stroke();X.inflate(2*b)}function ha(a){e(a.getContextStyle());i.fill()}function Aa(a,b,c,d,f,g,h,j,k,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]=i.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,j=(j+q)*s,c=c-a,d=d-
+b,f=f-a,g=g-b,k=(k+p)*r-h,l=(l+q)*s-j,m=(m+p)*r-h,o=(o+q)*s-j,p=k*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(j)*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=(k*f-m*c)*p,d=(k*g-m*d)*p,a=a-n*h-c*j,h=b-l*h-d*j,i.save(),i.transform(n,
+l,c,d,a,h),i.fill(),i.restore()}}function pa(a,b,c,d,e,f,g,h,j,k,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;j=j*o-g;k=k*p-h;l=l*o-g;m=m*p-h;p=1/(j*m-l*k);o=(m*c-k*e)*p;k=(m*d-k*f)*p;c=(j*e-l*c)*p;d=(j*f-l*d)*p;a=a-o*g-c*h;b=b-k*g-d*h;i.save();i.transform(o,k,c,d,a,b);i.clip();i.drawImage(n,0,0);i.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,
+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():i.setTransform(1,0,0,-1,j,p);f.info.render.vertices=0;f.info.render.faces=0;g=k.projectScene(a,l,this.sortElements);h=g.elements;m=g.lights;(xa=0<m.length)&&o(m);for(wa=0,Ha=h.length;wa<Ha;wa++)if(U=h[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)&&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)};
+I(r,s,D,J,Z,ca,U,ba,a);Y.addRectangle(X)}i.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:"anonymous",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=this.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=[],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}};
+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,m=g.createImageData(d,e),k=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,i=(l+1)%d,q=[],x=[0,0,h[4*(o*d+l)]/255*b];q.push([-1,0,h[4*(o*d+p)]/255*b]);q.push([-1,-1,h[4*(n*d+p)]/255*b]);q.push([0,-1,
+h[4*(n*d+l)]/255*b]);q.push([1,-1,h[4*(n*d+i)]/255*b]);q.push([1,0,h[4*(o*d+i)]/255*b]);q.push([1,1,h[4*(j*d+i)]/255*b]);q.push([0,1,h[4*(j*d+l)]/255*b]);q.push([-1,1,h[4*(j*d+p)]/255*b]);n=[];p=q.length;for(j=0;j<p;j++){var i=q[j],v=q[(j+1)%p],i=[i[0]-x[0],i[1]-x[1],i[2]-x[2]],v=[v[0]-x[0],v[1]-x[1],v[2]-x[2]];n.push(c([i[1]*v[2]-i[2]*v[1],i[2]*v[0]-i[0]*v[2],i[0]*v[1]-i[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);k[x]=255*((q[0]+1)/2)|0;k[x+1]=255*(q[1]+0.5)|0;k[x+2]=255*q[2]|0;k[x+3]=255}g.putImageData(m,0,0);return f}};

+ 78 - 79
build/custom/ThreeExtras.js

@@ -2,8 +2,8 @@
 'use strict';THREE.ColorUtils={adjustHSV:function(a,b,c,d){var f=THREE.ColorUtils.__hsv;THREE.ColorUtils.rgbToHsv(a,f);f.h=THREE.Math.clamp(f.h+b,0,1);f.s=THREE.Math.clamp(f.s+c,0,1);f.v=THREE.Math.clamp(f.v+d,0,1);a.setHSV(f.h,f.s,f.v)},rgbToHsv:function(a,b){var c=a.r,d=a.g,f=a.b,g=Math.max(Math.max(c,d),f),e=Math.min(Math.min(c,d),f);if(e===g)e=c=0;else{var h=g-e,e=h/g,c=(c===g?(d-f)/h:d===g?2+(f-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=e;b.v=g;return b}};
 THREE.ColorUtils.__hsv={h:0,s:0,v:0};
 THREE.GeometryUtils={merge:function(a,b){for(var c,d,f=a.vertices.length,g=b instanceof THREE.Mesh?b.geometry:b,e=a.vertices,h=g.vertices,i=a.faces,k=g.faces,j=a.faceVertexUvs[0],q=g.faceVertexUvs[0],l={},n=0;n<a.materials.length;n++)l[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,r=h.length;n<r;n++){var m=new THREE.Vertex(h[n].position.clone());c&&c.multiplyVector3(m.position);e.push(m)}for(n=
-0,r=k.length;n<r;n++){var e=k[n],o,p,s=e.vertexNormals,t=e.vertexColors;e instanceof THREE.Face3?o=new THREE.Face3(e.a+f,e.b+f,e.c+f):e instanceof THREE.Face4&&(o=new THREE.Face4(e.a+f,e.b+f,e.c+f,e.d+f));o.normal.copy(e.normal);d&&d.multiplyVector3(o.normal);h=0;for(m=s.length;h<m;h++)p=s[h].clone(),d&&d.multiplyVector3(p),o.vertexNormals.push(p);o.color.copy(e.color);h=0;for(m=t.length;h<m;h++)p=t[h],o.vertexColors.push(p.clone());if(void 0!==e.materialIndex){h=g.materials[e.materialIndex];m=h.id;
-t=l[m];if(void 0===t)t=a.materials.length,l[m]=t,a.materials.push(h);o.materialIndex=t}o.centroid.copy(e.centroid);c&&c.multiplyVector3(o.centroid);i.push(o)}for(n=0,r=q.length;n<r;n++){c=q[n];d=[];h=0;for(m=c.length;h<m;h++)d.push(new THREE.UV(c[h].u,c[h].v));j.push(d)}},clone:function(a){var b=new THREE.Geometry,c,d=a.vertices,f=a.faces,g=a.faceVertexUvs[0];if(a.materials)b.materials=a.materials.slice();for(a=0,c=d.length;a<c;a++){var e=new THREE.Vertex(d[a].position.clone());b.vertices.push(e)}for(a=
+0,r=k.length;n<r;n++){var e=k[n],p,o,s=e.vertexNormals,t=e.vertexColors;e instanceof THREE.Face3?p=new THREE.Face3(e.a+f,e.b+f,e.c+f):e instanceof THREE.Face4&&(p=new THREE.Face4(e.a+f,e.b+f,e.c+f,e.d+f));p.normal.copy(e.normal);d&&d.multiplyVector3(p.normal);h=0;for(m=s.length;h<m;h++)o=s[h].clone(),d&&d.multiplyVector3(o),p.vertexNormals.push(o);p.color.copy(e.color);h=0;for(m=t.length;h<m;h++)o=t[h],p.vertexColors.push(o.clone());if(void 0!==e.materialIndex){h=g.materials[e.materialIndex];m=h.id;
+t=l[m];if(void 0===t)t=a.materials.length,l[m]=t,a.materials.push(h);p.materialIndex=t}p.centroid.copy(e.centroid);c&&c.multiplyVector3(p.centroid);i.push(p)}for(n=0,r=q.length;n<r;n++){c=q[n];d=[];h=0;for(m=c.length;h<m;h++)d.push(new THREE.UV(c[h].u,c[h].v));j.push(d)}},clone:function(a){var b=new THREE.Geometry,c,d=a.vertices,f=a.faces,g=a.faceVertexUvs[0];if(a.materials)b.materials=a.materials.slice();for(a=0,c=d.length;a<c;a++){var e=new THREE.Vertex(d[a].position.clone());b.vertices.push(e)}for(a=
 0,c=f.length;a<c;a++){var h=f[a],i,k,j=h.vertexNormals,q=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(e=j.length;d<e;d++)k=j[d],i.vertexNormals.push(k.clone());i.color.copy(h.color);d=0;for(e=q.length;d<e;d++)k=q[d],i.vertexColors.push(k.clone());i.materialIndex=h.materialIndex;i.centroid.copy(h.centroid);b.faces.push(i)}for(a=0,c=g.length;a<c;a++){f=g[a];i=[];d=0;for(e=f.length;d<
 e;d++)i.push(new THREE.UV(f[d].u,f[d].v));b.faceVertexUvs[0].push(i)}return b},randomPointInTriangle:function(a,b,c){var d,f,g,e=new THREE.Vector3,h=THREE.GeometryUtils.__v1;d=THREE.GeometryUtils.random();f=THREE.GeometryUtils.random();1<d+f&&(d=1-d,f=1-f);g=1-d-f;e.copy(a);e.multiplyScalar(d);h.copy(b);h.multiplyScalar(f);e.addSelf(h);h.copy(c);h.multiplyScalar(g);e.addSelf(h);return e},randomPointInFace:function(a,b,c){var d,f,g;if(a instanceof THREE.Face3)return d=b.vertices[a.a].position,f=b.vertices[a.b].position,
 g=b.vertices[a.c].position,THREE.GeometryUtils.randomPointInTriangle(d,f,g);if(a instanceof THREE.Face4){d=b.vertices[a.a].position;f=b.vertices[a.b].position;g=b.vertices[a.c].position;var b=b.vertices[a.d].position,e;c?a._area1&&a._area2?(c=a._area1,e=a._area2):(c=THREE.GeometryUtils.triangleArea(d,f,b),e=THREE.GeometryUtils.triangleArea(f,g,b),a._area1=c,a._area2=e):(c=THREE.GeometryUtils.triangleArea(d,f,b),e=THREE.GeometryUtils.triangleArea(f,g,b));return THREE.GeometryUtils.random()*(c+e)<c?
@@ -12,9 +12,9 @@ THREE.Face4)j=e[d.a].position,q=e[d.b].position,l=e[d.c].position,n=e[d.d].posit
 (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],f=0,g=d.length;f<g;f++)1!==d[f].u&&(d[f].u-=Math.floor(d[f].u)),1!==d[f].v&&(d[f].v-=Math.floor(d[f].v))}};THREE.GeometryUtils.random=THREE.Math.random16;
 THREE.GeometryUtils.__v1=new THREE.Vector3;
 THREE.ImageUtils={crossOrigin:"anonymous",loadTexture:function(a,b,c){var d=new Image,f=new THREE.Texture(d,b);d.onload=function(){f.needsUpdate=!0;c&&c(this)};d.crossOrigin=this.crossOrigin;d.src=a;return f},loadTextureCube:function(a,b,c){var d,f=[],g=new THREE.Texture(f,b);f.loadCount=0;for(b=0,d=a.length;b<d;++b)f[b]=new Image,f[b].onload=function(){f.loadCount+=1;if(6===f.loadCount)g.needsUpdate=!0;c&&c(this)},f[b].crossOrigin=this.crossOrigin,f[b].src=a[b];return g},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,f=a.height,g=document.createElement("canvas");g.width=d;g.height=f;var e=g.getContext("2d");e.drawImage(a,0,0);for(var h=e.getImageData(0,0,d,f).data,i=e.createImageData(d,f),k=i.data,j=0;j<d;j++)for(var q=1;q<f;q++){var l=0>q-1?f-1:q-1,n=(q+1)%f,r=0>j-1?d-1:j-1,m=(j+1)%d,o=[],p=[0,0,h[4*(q*d+j)]/255*b];o.push([-1,0,h[4*(q*d+r)]/255*b]);o.push([-1,-1,h[4*(l*d+r)]/255*b]);o.push([0,-1,
-h[4*(l*d+j)]/255*b]);o.push([1,-1,h[4*(l*d+m)]/255*b]);o.push([1,0,h[4*(q*d+m)]/255*b]);o.push([1,1,h[4*(n*d+m)]/255*b]);o.push([0,1,h[4*(n*d+j)]/255*b]);o.push([-1,1,h[4*(n*d+r)]/255*b]);l=[];r=o.length;for(n=0;n<r;n++){var m=o[n],s=o[(n+1)%r],m=[m[0]-p[0],m[1]-p[1],m[2]-p[2]],s=[s[0]-p[0],s[1]-p[1],s[2]-p[2]];l.push(c([m[1]*s[2]-m[2]*s[1],m[2]*s[0]-m[0]*s[2],m[0]*s[1]-m[1]*s[0]]))}o=[0,0,0];for(n=0;n<l.length;n++)o[0]+=l[n][0],o[1]+=l[n][1],o[2]+=l[n][2];o[0]/=l.length;o[1]/=l.length;o[2]/=l.length;
-p=4*(q*d+j);k[p]=255*((o[0]+1)/2)|0;k[p+1]=255*(o[1]+0.5)|0;k[p+2]=255*o[2]|0;k[p+3]=255}e.putImageData(i,0,0);return g}};
+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,f=a.height,g=document.createElement("canvas");g.width=d;g.height=f;var e=g.getContext("2d");e.drawImage(a,0,0);for(var h=e.getImageData(0,0,d,f).data,i=e.createImageData(d,f),k=i.data,j=0;j<d;j++)for(var q=1;q<f;q++){var l=0>q-1?f-1:q-1,n=(q+1)%f,r=0>j-1?d-1:j-1,m=(j+1)%d,p=[],o=[0,0,h[4*(q*d+j)]/255*b];p.push([-1,0,h[4*(q*d+r)]/255*b]);p.push([-1,-1,h[4*(l*d+r)]/255*b]);p.push([0,-1,
+h[4*(l*d+j)]/255*b]);p.push([1,-1,h[4*(l*d+m)]/255*b]);p.push([1,0,h[4*(q*d+m)]/255*b]);p.push([1,1,h[4*(n*d+m)]/255*b]);p.push([0,1,h[4*(n*d+j)]/255*b]);p.push([-1,1,h[4*(n*d+r)]/255*b]);l=[];r=p.length;for(n=0;n<r;n++){var m=p[n],s=p[(n+1)%r],m=[m[0]-o[0],m[1]-o[1],m[2]-o[2]],s=[s[0]-o[0],s[1]-o[1],s[2]-o[2]];l.push(c([m[1]*s[2]-m[2]*s[1],m[2]*s[0]-m[0]*s[2],m[0]*s[1]-m[1]*s[0]]))}p=[0,0,0];for(n=0;n<l.length;n++)p[0]+=l[n][0],p[1]+=l[n][1],p[2]+=l[n][2];p[0]/=l.length;p[1]/=l.length;p[2]/=l.length;
+o=4*(q*d+j);k[o]=255*((p[0]+1)/2)|0;k[o+1]=255*(p[1]+0.5)|0;k[o+2]=255*p[2]|0;k[o+3]=255}e.putImageData(i,0,0);return g}};
 THREE.SceneUtils={showHierarchy:function(a,b){THREE.SceneUtils.traverseHierarchy(a,function(a){a.visible=b})},traverseHierarchy:function(a,b){var c,d,f=a.children.length;for(d=0;d<f;d++)c=a.children[d],b(c),THREE.SceneUtils.traverseHierarchy(c,b)},createMultiMaterialObject:function(a,b){var c,d=b.length,f=new THREE.Object3D;for(c=0;c<d;c++){var g=new THREE.Mesh(a,b[c]);f.add(g)}return f},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?
 (b=new THREE.ParticleSystem(a.geometry,a.material),b.sortParticles=a.sortParticles):a instanceof THREE.Particle?b=new THREE.Particle(a.material):a instanceof THREE.Sprite?(b=new THREE.Sprite({}),b.color.copy(a.color),b.map=a.map,b.blending=a.blending,b.useScreenCoordinates=a.useScreenCoordinates,b.mergeWith3D=a.mergeWith3D,b.affectedByDistance=a.affectedByDistance,b.scaleByViewport=a.scaleByViewport,b.alignment=a.alignment,b.rotation3d.copy(a.rotation3d),b.rotation=a.rotation,b.opacity=a.opacity,
@@ -65,7 +65,7 @@ THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arg
 THREE.Path.prototype.arc=function(a,b,c,d,f,g){var e=Array.prototype.slice.call(arguments);this.curves.push(new THREE.ArcCurve(a,b,c,d,f,g));this.actions.push({action:THREE.PathActions.ARC,args:e})};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,f,g,e,h,i,k,j,q,l,n,r,m;for(d=0,f=this.actions.length;d<f;d++)switch(g=this.actions[d],e=g.action,g=g.args,e){case THREE.PathActions.LINE_TO:c.push(new THREE.Vector2(g[0],g[1]));break;case THREE.PathActions.QUADRATIC_CURVE_TO:h=g[2];i=g[3];q=g[0];l=g[1];0<c.length?(e=c[c.length-1],n=e.x,r=e.y):(e=this.actions[d-1].args,n=e[e.length-2],r=e[e.length-1]);for(e=1;e<=a;e++)m=e/a,g=THREE.Shape.Utils.b2(m,n,q,h),m=THREE.Shape.Utils.b2(m,r,l,
 i),c.push(new THREE.Vector2(g,m));break;case THREE.PathActions.BEZIER_CURVE_TO:h=g[4];i=g[5];q=g[0];l=g[1];k=g[2];j=g[3];0<c.length?(e=c[c.length-1],n=e.x,r=e.y):(e=this.actions[d-1].args,n=e[e.length-2],r=e[e.length-1]);for(e=1;e<=a;e++)m=e/a,g=THREE.Shape.Utils.b3(m,n,q,k,h),m=THREE.Shape.Utils.b3(m,r,l,j,i),c.push(new THREE.Vector2(g,m));break;case THREE.PathActions.CSPLINE_THRU:e=this.actions[d-1].args;e=[new THREE.Vector2(e[e.length-2],e[e.length-1])];m=a*g[0].length;e=e.concat(g[0]);g=new THREE.SplineCurve(e);
-for(e=1;e<=m;e++)c.push(g.getPointAt(e/m));break;case THREE.PathActions.ARC:e=this.actions[d-1].args;h=g[0];i=g[1];k=g[2];q=g[3];m=g[4];l=!!g[5];j=e[e.length-2];n=e[e.length-1];0==e.length&&(j=n=0);r=m-q;var o=2*a;for(e=1;e<=o;e++)m=e/o,l||(m=1-m),m=q+m*r,g=j+h+k*Math.cos(m),m=n+i+k*Math.sin(m),c.push(new THREE.Vector2(g,m))}b&&c.push(c[0]);return c};THREE.Path.prototype.transform=function(a,b){this.getBoundingBox();return this.getWrapPoints(this.getPoints(b),a)};
+for(e=1;e<=m;e++)c.push(g.getPointAt(e/m));break;case THREE.PathActions.ARC:e=this.actions[d-1].args;h=g[0];i=g[1];k=g[2];q=g[3];m=g[4];l=!!g[5];j=e[e.length-2];n=e[e.length-1];0==e.length&&(j=n=0);r=m-q;var p=2*a;for(e=1;e<=p;e++)m=e/p,l||(m=1-m),m=q+m*r,g=j+h+k*Math.cos(m),m=n+i+k*Math.sin(m),c.push(new THREE.Vector2(g,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,f,g){var e=this.getPoints(),h,i,k,j,q;for(h=0,i=e.length;h<i;h++)k=e[h],j=k.x,q=k.y,k.x=a*j+b*q+c,k.y=d*q+f*j+g;return e};
 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,f;for(a=0,c=this.actions.length;a<c;a++)d=this.actions[a],f=d.args,d=d.action,d!=THREE.PathActions.CSPLINE_THRU&&b[d].apply(b,f);b.stroke();b.closePath();b.strokeStyle="red";d=
 this.getPoints();for(a=0,c=d.length;a<c;a++)f=d[a],b.beginPath(),b.arc(f.x,f.y,1.5,0,2*Math.PI,!1),b.stroke(),b.closePath()};
@@ -73,8 +73,8 @@ THREE.Path.prototype.toShapes=function(){var a,b,c,d,f=[],g=new THREE.Path;for(a
 b;a++)g=f[a],THREE.Shape.Utils.isClockWise(g.getPoints())?(e.actions=g.actions,e.curves=g.curves,d.push(e),e=new THREE.Shape):e.holes.push(g)}else{for(a=0,b=f.length;a<b;a++)g=f[a],THREE.Shape.Utils.isClockWise(g.getPoints())?(e&&d.push(e),e=new THREE.Shape,e.actions=g.actions,e.curves=g.curves):e.holes.push(g);d.push(e)}return d};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(),f,g,e,h,i,k,j,q,l,n,r=[];for(i=0;i<b.length;i++){k=b[i];Array.prototype.push.apply(d,k);g=Number.POSITIVE_INFINITY;for(f=0;f<k.length;f++){l=k[f];n=[];for(q=0;q<c.length;q++)j=c[q],j=l.distanceToSquared(j),n.push(j),j<g&&(g=j,e=f,h=q)}f=0<=h-1?h-1:c.length-1;g=0<=e-1?e-1:k.length-1;var m=[k[e],c[h],c[f]];q=THREE.FontUtils.Triangulate.area(m);var o=[k[e],k[g],c[h]];l=THREE.FontUtils.Triangulate.area(o);n=h;j=e;h+=1;e+=-1;0>
-h&&(h+=c.length);h%=c.length;0>e&&(e+=k.length);e%=k.length;f=0<=h-1?h-1:c.length-1;g=0<=e-1?e-1:k.length-1;m=[k[e],c[h],c[f]];m=THREE.FontUtils.Triangulate.area(m);o=[k[e],k[g],c[h]];o=THREE.FontUtils.Triangulate.area(o);q+l>m+o&&(h=n,e=j,0>h&&(h+=c.length),h%=c.length,0>e&&(e+=k.length),e%=k.length,f=0<=h-1?h-1:c.length-1,g=0<=e-1?e-1:k.length-1);q=c.slice(0,h);l=c.slice(h);n=k.slice(e);j=k.slice(0,e);g=[k[e],k[g],c[h]];r.push([k[e],c[h],c[f]]);r.push(g);c=q.concat(n).concat(j).concat(l)}return{shape:c,
+THREE.Shape.Utils={removeHoles:function(a,b){var c=a.concat(),d=c.concat(),f,g,e,h,i,k,j,q,l,n,r=[];for(i=0;i<b.length;i++){k=b[i];Array.prototype.push.apply(d,k);g=Number.POSITIVE_INFINITY;for(f=0;f<k.length;f++){l=k[f];n=[];for(q=0;q<c.length;q++)j=c[q],j=l.distanceToSquared(j),n.push(j),j<g&&(g=j,e=f,h=q)}f=0<=h-1?h-1:c.length-1;g=0<=e-1?e-1:k.length-1;var m=[k[e],c[h],c[f]];q=THREE.FontUtils.Triangulate.area(m);var p=[k[e],k[g],c[h]];l=THREE.FontUtils.Triangulate.area(p);n=h;j=e;h+=1;e+=-1;0>
+h&&(h+=c.length);h%=c.length;0>e&&(e+=k.length);e%=k.length;f=0<=h-1?h-1:c.length-1;g=0<=e-1?e-1:k.length-1;m=[k[e],c[h],c[f]];m=THREE.FontUtils.Triangulate.area(m);p=[k[e],k[g],c[h]];p=THREE.FontUtils.Triangulate.area(p);q+l>m+p&&(h=n,e=j,0>h&&(h+=c.length),h%=c.length,0>e&&(e+=k.length),e%=k.length,f=0<=h-1?h-1:c.length-1,g=0<=e-1?e-1:k.length-1);q=c.slice(0,h);l=c.slice(h);n=k.slice(e);j=k.slice(0,e);g=[k[e],k[g],c[h]];r.push([k[e],c[h],c[f]]);r.push(g);c=q.concat(n).concat(j).concat(l)}return{shape:c,
 isolatedPts:r,allpoints:d}},triangulateShape:function(a,b){var c=THREE.Shape.Utils.removeHoles(a,b),d=c.allpoints,f=c.isolatedPts,c=THREE.FontUtils.Triangulate(c.shape,!1),g,e,h,i,k={};for(g=0,e=d.length;g<e;g++)i=d[g].x+":"+d[g].y,void 0!==k[i]&&console.log("Duplicate point",i),k[i]=g;for(g=0,e=c.length;g<e;g++){h=c[g];for(d=0;3>d;d++)i=h[d].x+":"+h[d].y,i=k[i],void 0!==i&&(h[d]=i)}for(g=0,e=f.length;g<e;g++){h=f[g];for(d=0;3>d;d++)i=h[d].x+":"+h[d].y,i=k[i],void 0!==i&&(h[d]=i)}return c.concat(f)},
 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,f){return this.b3p0(a,b)+this.b3p1(a,c)+this.b3p2(a,d)+
 this.b3p3(a,f)}};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",f=void 0!==b.weight?b.weight:"normal",g=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=f;THREE.FontUtils.style=g};
@@ -124,7 +124,7 @@ function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:
 this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b);a*=this.lookSpeed;this.activeLook||(a=0);this.lon+=this.mouseX*a;this.lookVertical&&(this.lat-=this.mouseY*a);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;var b=this.target,c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);b=1;this.constrainVertical&&
 (b=Math.PI/(this.verticalMax-this.verticalMin));this.lon+=this.mouseX*a;this.lookVertical&&(this.lat-=this.mouseY*a*b);this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*Math.PI/180;this.theta=this.lon*Math.PI/180;if(this.constrainVertical)this.phi=THREE.Math.mapLinear(this.phi,0,Math.PI,this.verticalMin,this.verticalMax);b=this.target;c=this.object.position;b.x=c.x+100*Math.sin(this.phi)*Math.cos(this.theta);b.y=c.y+100*Math.cos(this.phi);b.z=c.z+100*Math.sin(this.phi)*Math.sin(this.theta);
 this.object.lookAt(b)}};this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1);this.domElement.addEventListener("mousemove",c(this,this.onMouseMove),!1);this.domElement.addEventListener("mousedown",c(this,this.onMouseDown),!1);this.domElement.addEventListener("mouseup",c(this,this.onMouseUp),!1);this.domElement.addEventListener("keydown",c(this,this.onKeyDown),!1);this.domElement.addEventListener("keyup",c(this,this.onKeyUp),!1)};
-THREE.PathControls=function(a,b){function c(a){return 1>(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function f(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),o=g.length,p=0;f=o-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f<o-1;f++)p=d*h.chunks[f]/h.total,b.keys[f]={time:p,pos:g[f]};e.hierarchy[0]=b;THREE.AnimationHandler.add(e);
+THREE.PathControls=function(a,b){function c(a){return 1>(a*=2)?0.5*a*a:-0.5*(--a*(a-2)-1)}function d(a,b){return function(){b.apply(a,arguments)}}function f(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},f,g=b.getControlPointsArray(),h=b.getLength(),p=g.length,o=0;f=p-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:g[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[f]={time:d,pos:g[f],rot:[0,0,0,1],scl:[1,1,1]};for(f=1;f<p-1;f++)o=d*h.chunks[f]/h.total,b.keys[f]={time:o,pos:g[f]};e.hierarchy[0]=b;THREE.AnimationHandler.add(e);
 return new THREE.Animation(a,c,THREE.AnimationHandler.CATMULLROM_FORWARD,!1)}function g(a,b){var c,d,f=new THREE.Geometry;for(c=0;c<a.points.length*b;c++)d=c/(a.points.length*b),d=a.getPoint(d),f.vertices[c]=new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.z));return f}this.object=a;this.domElement=void 0!==b?b:document;this.id="PathControls"+THREE.PathControlsIdCounter++;this.duration=1E4;this.waypoints=[];this.useConstantSpeed=!0;this.resamplingCoef=50;this.debugPath=new THREE.Object3D;this.debugDummy=
 new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.0050;this.lookHorizontal=this.lookVertical=!0;this.verticalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.horizontalAngleMap={srcRange:[0,2*Math.PI],dstRange:[0,2*Math.PI]};this.target=new THREE.Object3D;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=0;this.domElement===document?(this.viewHalfX=window.innerWidth/2,this.viewHalfY=window.innerHeight/2):(this.viewHalfX=this.domElement.offsetWidth/
 2,this.viewHalfY=this.domElement.offsetHeight/2,this.domElement.setAttribute("tabindex",-1));var e=2*Math.PI,h=Math.PI/180;this.update=function(a){var b;this.lookHorizontal&&(this.lon+=this.mouseX*this.lookSpeed*a);this.lookVertical&&(this.lat-=this.mouseY*this.lookSpeed*a);this.lon=Math.max(0,Math.min(360,this.lon));this.lat=Math.max(-85,Math.min(85,this.lat));this.phi=(90-this.lat)*h;this.theta=this.lon*h;a=this.phi%e;this.phi=0<=a?a:a+e;b=this.verticalAngleMap.srcRange;a=this.verticalAngleMap.dstRange;
@@ -157,39 +157,39 @@ c.target.addSelf(b);c.staticMoving?j=q:j.addSelf(a.sub(q,j).multiplyScalar(c.dyn
 c.object.position.add(c.target,g);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&&(e=h=c.getMouseProjectionOnBall(a.clientX,a.clientY),i=k=c.getMouseOnScreen(a.clientX,a.clientY),j=q=c.getMouseOnScreen(a.clientX,a.clientY),d=!1),-1!==f&&(0===f&&!c.noRotate?h=c.getMouseProjectionOnBall(a.clientX,a.clientY):1===f&&!c.noZoom?k=c.getMouseOnScreen(a.clientX,
 a.clientY):2===f&&!c.noPan&&(q=c.getMouseOnScreen(a.clientX,a.clientY))))},!1);this.domElement.addEventListener("mousedown",function(a){if(c.enabled&&(a.preventDefault(),a.stopPropagation(),-1===f))f=a.button,0===f&&!c.noRotate?e=h=c.getMouseProjectionOnBall(a.clientX,a.clientY):1===f&&!c.noZoom?i=k=c.getMouseOnScreen(a.clientX,a.clientY):this.noPan||(j=q=c.getMouseOnScreen(a.clientX,a.clientY))},!1);this.domElement.addEventListener("mouseup",function(a){c.enabled&&(a.preventDefault(),a.stopPropagation(),
 f=-1)},!1);window.addEventListener("keydown",function(a){c.enabled&&-1===f&&(a.keyCode===c.keys[0]&&!c.noRotate?f=0:a.keyCode===c.keys[1]&&!c.noZoom?f=1:a.keyCode===c.keys[2]&&!c.noPan&&(f=2),-1!==f&&(d=!0))},!1);window.addEventListener("keyup",function(){c.enabled&&-1!==f&&(f=-1)},!1)};
-THREE.CubeGeometry=function(a,b,c,d,f,g,e,h){function i(a,b,c,e,h,i,l,m){var j,n=d||1,q=f||1,r=h/2,p=i/2,o=k.vertices.length;if("x"===a&&"y"===b||"y"===a&&"x"===b)j="z";else if("x"===a&&"z"===b||"z"===a&&"x"===b)j="y",q=g||1;else if("z"===a&&"y"===b||"y"===a&&"z"===b)j="x",n=g||1;var s=n+1,t=q+1,C=h/n,L=i/q,N=new THREE.Vector3;N[j]=0<l?1:-1;for(h=0;h<t;h++)for(i=0;i<s;i++){var M=new THREE.Vector3;M[a]=(i*C-r)*c;M[b]=(h*L-p)*e;M[j]=l;k.vertices.push(new THREE.Vertex(M))}for(h=0;h<q;h++)for(i=0;i<n;i++)a=
-new THREE.Face4(i+s*h+o,i+s*(h+1)+o,i+1+s*(h+1)+o,i+1+s*h+o),a.normal.copy(N),a.vertexNormals.push(N.clone(),N.clone(),N.clone(),N.clone()),a.materialIndex=m,k.faces.push(a),k.faceVertexUvs[0].push([new THREE.UV(i/n,h/q),new THREE.UV(i/n,(h+1)/q),new THREE.UV((i+1)/n,(h+1)/q),new THREE.UV((i+1)/n,h/q)])}THREE.Geometry.call(this);var k=this,j=a/2,q=b/2,l=c/2,n,r,m,o,p,s;if(void 0!==e){if(e instanceof Array)this.materials=e;else{this.materials=[];for(n=0;6>n;n++)this.materials.push(e)}n=0;o=1;r=2;p=
-3;m=4;s=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(void 0!=h)for(var t in h)void 0!==this.sides[t]&&(this.sides[t]=h[t]);this.sides.px&&i("z","y",-1,-1,c,b,j,n);this.sides.nx&&i("z","y",1,-1,c,b,-j,o);this.sides.py&&i("x","z",1,1,a,c,q,r);this.sides.ny&&i("x","z",1,-1,a,c,-q,p);this.sides.pz&&i("x","y",1,-1,a,b,l,m);this.sides.nz&&i("x","y",-1,-1,a,b,-l,s);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=new THREE.Geometry;
+THREE.CubeGeometry=function(a,b,c,d,f,g,e,h){function i(a,b,c,e,h,i,l,j){var m,n=d||1,q=f||1,r=h/2,o=i/2,p=k.vertices.length;if("x"===a&&"y"===b||"y"===a&&"x"===b)m="z";else if("x"===a&&"z"===b||"z"===a&&"x"===b)m="y",q=g||1;else if("z"===a&&"y"===b||"y"===a&&"z"===b)m="x",n=g||1;var s=n+1,t=q+1,C=h/n,L=i/q,N=new THREE.Vector3;N[m]=0<l?1:-1;for(h=0;h<t;h++)for(i=0;i<s;i++){var M=new THREE.Vector3;M[a]=(i*C-r)*c;M[b]=(h*L-o)*e;M[m]=l;k.vertices.push(new THREE.Vertex(M))}for(h=0;h<q;h++)for(i=0;i<n;i++)a=
+new THREE.Face4(i+s*h+p,i+s*(h+1)+p,i+1+s*(h+1)+p,i+1+s*h+p),a.normal.copy(N),a.vertexNormals.push(N.clone(),N.clone(),N.clone(),N.clone()),a.materialIndex=j,k.faces.push(a),k.faceVertexUvs[0].push([new THREE.UV(i/n,h/q),new THREE.UV(i/n,(h+1)/q),new THREE.UV((i+1)/n,(h+1)/q),new THREE.UV((i+1)/n,h/q)])}THREE.Geometry.call(this);var k=this,j=a/2,q=b/2,l=c/2,n,r,m,p,o,s;if(void 0!==e){if(e instanceof Array)this.materials=e;else{this.materials=[];for(n=0;6>n;n++)this.materials.push(e)}n=0;p=1;r=2;o=
+3;m=4;s=5}else this.materials=[];this.sides={px:!0,nx:!0,py:!0,ny:!0,pz:!0,nz:!0};if(void 0!=h)for(var t in h)void 0!==this.sides[t]&&(this.sides[t]=h[t]);this.sides.px&&i("z","y",-1,-1,c,b,j,n);this.sides.nx&&i("z","y",1,-1,c,b,-j,p);this.sides.py&&i("x","z",1,1,a,c,q,r);this.sides.ny&&i("x","z",1,-1,a,c,-q,o);this.sides.pz&&i("x","y",1,-1,a,b,l,m);this.sides.nz&&i("x","y",-1,-1,a,b,-l,s);this.computeCentroids();this.mergeVertices()};THREE.CubeGeometry.prototype=new THREE.Geometry;
 THREE.CubeGeometry.prototype.constructor=THREE.CubeGeometry;
-THREE.CylinderGeometry=function(a,b,c,d,f,g){THREE.Geometry.call(this);var a=void 0!==a?a:20,b=void 0!==b?b:20,c=void 0!==c?c:100,e=c/2,d=d||8,f=f||1,h,i,k=[],j=[];for(i=0;i<=f;i++){var q=[],l=[],n=i/f,r=n*(b-a)+a;for(h=0;h<=d;h++){var m=h/d,o=r*Math.sin(2*m*Math.PI),p=-n*c+e,s=r*Math.cos(2*m*Math.PI);this.vertices.push(new THREE.Vertex(new THREE.Vector3(o,p,s)));q.push(this.vertices.length-1);l.push(new THREE.UV(m,n))}k.push(q);j.push(l)}for(i=0;i<f;i++)for(h=0;h<d;h++){var c=k[i][h],q=k[i+1][h],
-l=k[i+1][h+1],n=k[i][h+1],r=this.vertices[c].position.clone().setY(0).normalize(),m=this.vertices[q].position.clone().setY(0).normalize(),o=this.vertices[l].position.clone().setY(0).normalize(),p=this.vertices[n].position.clone().setY(0).normalize(),s=j[i][h].clone(),t=j[i+1][h].clone(),u=j[i+1][h+1].clone(),v=j[i][h+1].clone();this.faces.push(new THREE.Face4(c,q,l,n,[r,m,o,p]));this.faceVertexUvs[0].push([s,t,u,v])}if(!g&&0<a){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,e,0)));for(h=
-0;h<d;h++)c=k[0][h],q=k[0][h+1],l=this.vertices.length-1,r=new THREE.Vector3(0,1,0),m=new THREE.Vector3(0,1,0),o=new THREE.Vector3(0,1,0),s=j[0][h].clone(),t=j[0][h+1].clone(),u=new THREE.UV(t.u,0),this.faces.push(new THREE.Face3(c,q,l,[r,m,o])),this.faceVertexUvs[0].push([s,t,u])}if(!g&&0<b){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-e,0)));for(h=0;h<d;h++)c=k[i][h+1],q=k[i][h],l=this.vertices.length-1,r=new THREE.Vector3(0,-1,0),m=new THREE.Vector3(0,-1,0),o=new THREE.Vector3(0,-1,
-0),s=j[i][h+1].clone(),t=j[i][h].clone(),u=new THREE.UV(t.u,1),this.faces.push(new THREE.Face3(c,q,l,[r,m,o])),this.faceVertexUvs[0].push([s,t,u])}this.computeCentroids();this.computeFaceNormals()};THREE.CylinderGeometry.prototype=new THREE.Geometry;THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
+THREE.CylinderGeometry=function(a,b,c,d,f,g){THREE.Geometry.call(this);var a=void 0!==a?a:20,b=void 0!==b?b:20,c=void 0!==c?c:100,e=c/2,d=d||8,f=f||1,h,i,k=[],j=[];for(i=0;i<=f;i++){var q=[],l=[],n=i/f,r=n*(b-a)+a;for(h=0;h<=d;h++){var m=h/d,p=r*Math.sin(2*m*Math.PI),o=-n*c+e,s=r*Math.cos(2*m*Math.PI);this.vertices.push(new THREE.Vertex(new THREE.Vector3(p,o,s)));q.push(this.vertices.length-1);l.push(new THREE.UV(m,n))}k.push(q);j.push(l)}for(i=0;i<f;i++)for(h=0;h<d;h++){var c=k[i][h],q=k[i+1][h],
+l=k[i+1][h+1],n=k[i][h+1],r=this.vertices[c].position.clone().setY(0).normalize(),m=this.vertices[q].position.clone().setY(0).normalize(),p=this.vertices[l].position.clone().setY(0).normalize(),o=this.vertices[n].position.clone().setY(0).normalize(),s=j[i][h].clone(),t=j[i+1][h].clone(),u=j[i+1][h+1].clone(),v=j[i][h+1].clone();this.faces.push(new THREE.Face4(c,q,l,n,[r,m,p,o]));this.faceVertexUvs[0].push([s,t,u,v])}if(!g&&0<a){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,e,0)));for(h=
+0;h<d;h++)c=k[0][h],q=k[0][h+1],l=this.vertices.length-1,r=new THREE.Vector3(0,1,0),m=new THREE.Vector3(0,1,0),p=new THREE.Vector3(0,1,0),s=j[0][h].clone(),t=j[0][h+1].clone(),u=new THREE.UV(t.u,0),this.faces.push(new THREE.Face3(c,q,l,[r,m,p])),this.faceVertexUvs[0].push([s,t,u])}if(!g&&0<b){this.vertices.push(new THREE.Vertex(new THREE.Vector3(0,-e,0)));for(h=0;h<d;h++)c=k[i][h+1],q=k[i][h],l=this.vertices.length-1,r=new THREE.Vector3(0,-1,0),m=new THREE.Vector3(0,-1,0),p=new THREE.Vector3(0,-1,
+0),s=j[i][h+1].clone(),t=j[i][h].clone(),u=new THREE.UV(t.u,1),this.faces.push(new THREE.Face3(c,q,l,[r,m,p])),this.faceVertexUvs[0].push([s,t,u])}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,f=a.length;this.shapebb=a[f-1].getBoundingBox();for(d=0;d<f;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 f(a){for(y=a.length;0<=--y;){C=y;L=y-1;0>L&&(L=a.length-1);for(var b=
 0,c=n+2*j,b=0;b<c;b++){var d=H*b,e=H*(b+1),f=O+C+d,g=O+C+e,l=f,d=O+L+d,e=O+L+e,k=g,l=l+F,d=d+F,e=e+F,k=k+F;A.faces.push(new THREE.Face4(l,d,e,k,null,null,u));void 0!==u&&(l=b/c,d=(b+1)/c,e=h+2*i,f=(A.vertices[f].position.z+i)/e,g=(A.vertices[g].position.z+i)/e,A.faceVertexUvs[0].push([new THREE.UV(f,l),new THREE.UV(g,l),new THREE.UV(g,d),new THREE.UV(f,d)]))}}}function g(a,b,c){A.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function e(a,b,c){a+=F;b+=F;c+=F;A.faces.push(new THREE.Face3(a,
 b,c,null,null,t));if(void 0!==t){var d=v.minX,e=v.minY,f=v.maxY,g=v.maxX,h=A.vertices[b].position.x-d,b=A.vertices[b].position.y-e,i=A.vertices[c].position.x-d,c=A.vertices[c].position.y-e;A.faceVertexUvs[0].push([new THREE.UV((A.vertices[a].position.x-d)/g,(A.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,k=void 0!==b.bevelSize?b.bevelSize:i-2,j=void 0!==b.bevelSegments?b.bevelSegments:
-3,q=void 0!==b.bevelEnabled?b.bevelEnabled:!0,l=void 0!==b.curveSegments?b.curveSegments:12,n=void 0!==b.steps?b.steps:1,r=b.bendPath,m=b.extrudePath,o,p=!1,s=void 0!==b.useSpacedPoints?b.useSpacedPoints:!1,t=b.material,u=b.extrudeMaterial,v=this.shapebb;if(m)o=m.getPoints(l),n=o.length,p=!0,q=!1;q||(k=i=j=0);var w,z,x,A=this,F=this.vertices.length;r&&a.addWrapPath(r);l=s?a.extractAllSpacedPoints(l):a.extractAllPoints(l);r=l.shape;l=l.holes;if(m=!THREE.Shape.Utils.isClockWise(r)){r=r.reverse();for(z=
+3,q=void 0!==b.bevelEnabled?b.bevelEnabled:!0,l=void 0!==b.curveSegments?b.curveSegments:12,n=void 0!==b.steps?b.steps:1,r=b.bendPath,m=b.extrudePath,p,o=!1,s=void 0!==b.useSpacedPoints?b.useSpacedPoints:!1,t=b.material,u=b.extrudeMaterial,v=this.shapebb;if(m)p=m.getPoints(l),n=p.length,o=!0,q=!1;q||(k=i=j=0);var w,z,x,A=this,F=this.vertices.length;r&&a.addWrapPath(r);l=s?a.extractAllSpacedPoints(l):a.extractAllPoints(l);r=l.shape;l=l.holes;if(m=!THREE.Shape.Utils.isClockWise(r)){r=r.reverse();for(z=
 0,x=l.length;z<x;z++)w=l[z],THREE.Shape.Utils.isClockWise(w)&&(l[z]=w.reverse());m=!1}m=THREE.Shape.Utils.triangulateShape(r,l);s=r;for(z=0,x=l.length;z<x;z++)w=l[z],r=r.concat(w);for(var E,J,G,B,H=r.length,D=m.length,I=[],y=0,K=s.length,C=K-1,L=y+1;y<K;y++,C++,L++)C===K&&(C=0),L===K&&(L=0),I[y]=d(s[y],s[C],s[L]);var N=[],M,S=I.concat();for(z=0,x=l.length;z<x;z++){w=l[z];M=[];for(y=0,K=w.length,C=K-1,L=y+1;y<K;y++,C++,L++)C===K&&(C=0),L===K&&(L=0),M[y]=d(w[y],w[C],w[L]);N.push(M);S=S.concat(M)}for(E=
-0;E<j;E++){J=E/j;G=i*(1-J);J=k*Math.sin(J*Math.PI/2);for(y=0,K=s.length;y<K;y++)B=c(s[y],I[y],J),g(B.x,B.y,-G);for(z=0,x=l.length;z<x;z++){w=l[z];M=N[z];for(y=0,K=w.length;y<K;y++)B=c(w[y],M[y],J),g(B.x,B.y,-G)}}J=k;for(y=0;y<H;y++)B=q?c(r[y],S[y],J):r[y],p?g(B.x,B.y+o[0].y,o[0].x):g(B.x,B.y,0);for(E=1;E<=n;E++)for(y=0;y<H;y++)B=q?c(r[y],S[y],J):r[y],p?g(B.x,B.y+o[E-1].y,o[E-1].x):g(B.x,B.y,h/n*E);for(E=j-1;0<=E;E--){J=E/j;G=i*(1-J);J=k*Math.sin(J*Math.PI/2);for(y=0,K=s.length;y<K;y++)B=c(s[y],I[y],
-J),g(B.x,B.y,h+G);for(z=0,x=l.length;z<x;z++){w=l[z];M=N[z];for(y=0,K=w.length;y<K;y++)B=c(w[y],M[y],J),p?g(B.x,B.y+o[n-1].y,o[n-1].x+G):g(B.x,B.y,h+G)}}if(q){q=0*H;for(y=0;y<D;y++)k=m[y],e(k[2]+q,k[1]+q,k[0]+q);q=H*(n+2*j);for(y=0;y<D;y++)k=m[y],e(k[0]+q,k[1]+q,k[2]+q)}else{for(y=0;y<D;y++)k=m[y],e(k[2],k[1],k[0]);for(y=0;y<D;y++)k=m[y],e(k[0]+H*n,k[1]+H*n,k[2]+H*n)}var O=0;f(s);O+=s.length;for(z=0,x=l.length;z<x;z++)w=l[z],f(w),O+=w.length};THREE.ExtrudeGeometry.__v1=new THREE.Vector2;
+0;E<j;E++){J=E/j;G=i*(1-J);J=k*Math.sin(J*Math.PI/2);for(y=0,K=s.length;y<K;y++)B=c(s[y],I[y],J),g(B.x,B.y,-G);for(z=0,x=l.length;z<x;z++){w=l[z];M=N[z];for(y=0,K=w.length;y<K;y++)B=c(w[y],M[y],J),g(B.x,B.y,-G)}}J=k;for(y=0;y<H;y++)B=q?c(r[y],S[y],J):r[y],o?g(B.x,B.y+p[0].y,p[0].x):g(B.x,B.y,0);for(E=1;E<=n;E++)for(y=0;y<H;y++)B=q?c(r[y],S[y],J):r[y],o?g(B.x,B.y+p[E-1].y,p[E-1].x):g(B.x,B.y,h/n*E);for(E=j-1;0<=E;E--){J=E/j;G=i*(1-J);J=k*Math.sin(J*Math.PI/2);for(y=0,K=s.length;y<K;y++)B=c(s[y],I[y],
+J),g(B.x,B.y,h+G);for(z=0,x=l.length;z<x;z++){w=l[z];M=N[z];for(y=0,K=w.length;y<K;y++)B=c(w[y],M[y],J),o?g(B.x,B.y+p[n-1].y,p[n-1].x+G):g(B.x,B.y,h+G)}}if(q){q=0*H;for(y=0;y<D;y++)k=m[y],e(k[2]+q,k[1]+q,k[0]+q);q=H*(n+2*j);for(y=0;y<D;y++)k=m[y],e(k[0]+q,k[1]+q,k[2]+q)}else{for(y=0;y<D;y++)k=m[y],e(k[2],k[1],k[0]);for(y=0;y<D;y++)k=m[y],e(k[0]+H*n,k[1]+H*n,k[2]+H*n)}var O=0;f(s);O+=s.length;for(z=0,x=l.length;z<x;z++)w=l[z],f(w),O+=w.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.LatheGeometry=function(a,b,c){THREE.Geometry.call(this);this.steps=b||12;this.angle=c||2*Math.PI;for(var b=this.angle/this.steps,c=[],d=[],f=[],g=[],e=(new THREE.Matrix4).setRotationZ(b),h=0;h<a.length;h++)this.vertices.push(new THREE.Vertex(a[h])),c[h]=a[h].clone(),d[h]=this.vertices.length-1;for(var i=0;i<=this.angle+0.0010;i+=b){for(h=0;h<c.length;h++)i<this.angle?(c[h]=e.multiplyVector3(c[h].clone()),this.vertices.push(new THREE.Vertex(c[h])),f[h]=this.vertices.length-1):f=g;0==i&&(g=d);
 for(h=0;h<d.length-1;h++)this.faces.push(new THREE.Face4(f[h],f[h+1],d[h+1],d[h])),this.faceVertexUvs[0].push([new THREE.UV(1-i/this.angle,h/a.length),new THREE.UV(1-i/this.angle,(h+1)/a.length),new THREE.UV(1-(i-b)/this.angle,(h+1)/a.length),new THREE.UV(1-(i-b)/this.angle,h/a.length)]);d=f;f=[]}this.computeCentroids();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=new THREE.Geometry;THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
 THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);for(var f=a/2,g=b/2,c=c||1,d=d||1,e=c+1,h=d+1,i=a/c,k=b/d,j=new THREE.Vector3(0,0,1),a=0;a<h;a++)for(b=0;b<e;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*i-f,-(a*k-g),0)));for(a=0;a<d;a++)for(b=0;b<c;b++)f=new THREE.Face4(b+e*a,b+e*(a+1),b+1+e*(a+1),b+1+e*a),f.normal.copy(j),f.vertexNormals.push(j.clone(),j.clone(),j.clone(),j.clone()),this.faces.push(f),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,f,g,e){THREE.Geometry.call(this);var a=a||50,d=void 0!==d?d:0,f=void 0!==f?f:2*Math.PI,g=void 0!==g?g:0,e=void 0!==e?e:Math.PI,b=Math.max(3,Math.floor(b)||8),c=Math.max(2,Math.floor(c)||6),h,i,k=[],j=[];for(i=0;i<=c;i++){var q=[],l=[];for(h=0;h<=b;h++){var n=h/b,r=i/c,m=-a*Math.cos(d+n*f)*Math.sin(g+r*e),o=a*Math.cos(g+r*e),p=a*Math.sin(d+n*f)*Math.sin(g+r*e);this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,o,p)));q.push(this.vertices.length-1);l.push(new THREE.UV(n,
-r))}k.push(q);j.push(l)}for(i=0;i<c;i++)for(h=0;h<b;h++){var d=k[i][h+1],f=k[i][h],g=k[i+1][h],e=k[i+1][h+1],q=this.vertices[d].position.clone().normalize(),l=this.vertices[f].position.clone().normalize(),n=this.vertices[g].position.clone().normalize(),r=this.vertices[e].position.clone().normalize(),m=j[i][h+1].clone(),o=j[i][h].clone(),p=j[i+1][h].clone(),s=j[i+1][h+1].clone();Math.abs(this.vertices[d].position.y)==a?(this.faces.push(new THREE.Face3(d,g,e,[q,n,r])),this.faceVertexUvs[0].push([m,
-p,s])):Math.abs(this.vertices[g].position.y)==a?(this.faces.push(new THREE.Face3(d,f,g,[q,l,n])),this.faceVertexUvs[0].push([m,o,p])):(this.faces.push(new THREE.Face4(d,f,g,e,[q,l,n,r])),this.faceVertexUvs[0].push([m,o,p,s]))}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,f,g,e){THREE.Geometry.call(this);var a=a||50,d=void 0!==d?d:0,f=void 0!==f?f:2*Math.PI,g=void 0!==g?g:0,e=void 0!==e?e:Math.PI,b=Math.max(3,Math.floor(b)||8),c=Math.max(2,Math.floor(c)||6),h,i,k=[],j=[];for(i=0;i<=c;i++){var q=[],l=[];for(h=0;h<=b;h++){var n=h/b,r=i/c,m=-a*Math.cos(d+n*f)*Math.sin(g+r*e),p=a*Math.cos(g+r*e),o=a*Math.sin(d+n*f)*Math.sin(g+r*e);this.vertices.push(new THREE.Vertex(new THREE.Vector3(m,p,o)));q.push(this.vertices.length-1);l.push(new THREE.UV(n,
+r))}k.push(q);j.push(l)}for(i=0;i<c;i++)for(h=0;h<b;h++){var d=k[i][h+1],f=k[i][h],g=k[i+1][h],e=k[i+1][h+1],q=this.vertices[d].position.clone().normalize(),l=this.vertices[f].position.clone().normalize(),n=this.vertices[g].position.clone().normalize(),r=this.vertices[e].position.clone().normalize(),m=j[i][h+1].clone(),p=j[i][h].clone(),o=j[i+1][h].clone(),s=j[i+1][h+1].clone();Math.abs(this.vertices[d].position.y)==a?(this.faces.push(new THREE.Face3(d,g,e,[q,n,r])),this.faceVertexUvs[0].push([m,
+o,s])):Math.abs(this.vertices[g].position.y)==a?(this.faces.push(new THREE.Face3(d,f,g,[q,l,n])),this.faceVertexUvs[0].push([m,p,o])):(this.faces.push(new THREE.Face4(d,f,g,e,[q,l,n,r])),this.faceVertexUvs[0].push([m,p,o,s]))}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,f=(""+a).split(""),g=f.length,e=[],a=0;a<g;a++){var h=new THREE.Path,h=this.extractGlyphPoints(f[a],b,c,d,h),d=d+h.offset;e.push(h.path)}return{paths:e,offset:d/2}},extractGlyphPoints:function(a,b,c,d,f){var g=[],e,h,i,k,j,q,l,n,r,m,o,p=b.glyphs[a]||b.glyphs["?"];if(p){if(p.o){b=p._cachedOutline||(p._cachedOutline=p.o.split(" "));k=b.length;for(a=0;a<k;)switch(i=b[a++],i){case "m":i=b[a++]*c+d;j=b[a++]*c;g.push(new THREE.Vector2(i,j));f.moveTo(i,j);break;case "l":i=b[a++]*c+d;j=b[a++]*c;g.push(new THREE.Vector2(i,
-j));f.lineTo(i,j);break;case "q":i=b[a++]*c+d;j=b[a++]*c;n=b[a++]*c+d;r=b[a++]*c;f.quadraticCurveTo(n,r,i,j);if(e=g[g.length-1]){q=e.x;l=e.y;for(e=1,h=this.divisions;e<=h;e++){var s=e/h,t=THREE.Shape.Utils.b2(s,q,n,i),s=THREE.Shape.Utils.b2(s,l,r,j);g.push(new THREE.Vector2(t,s))}}break;case "b":if(i=b[a++]*c+d,j=b[a++]*c,n=b[a++]*c+d,r=b[a++]*-c,m=b[a++]*c+d,o=b[a++]*-c,f.bezierCurveTo(i,j,n,r,m,o),e=g[g.length-1]){q=e.x;l=e.y;for(e=1,h=this.divisions;e<=h;e++)s=e/h,t=THREE.Shape.Utils.b3(s,q,n,
-m,i),s=THREE.Shape.Utils.b3(s,l,r,o,j),g.push(new THREE.Vector2(t,s))}}}return{offset:p.ha*c,points:g,path:f}}}};
-(function(a){var b=function(a){for(var b=a.length,f=0,g=b-1,e=0;e<b;g=e++)f+=a[g].x*a[e].y-a[e].x*a[g].y;return 0.5*f};a.Triangulate=function(a,d){var f=a.length;if(3>f)return null;var g=[],e=[],h=[],i,k,j;if(0<b(a))for(k=0;k<f;k++)e[k]=k;else for(k=0;k<f;k++)e[k]=f-1-k;var q=2*f;for(k=f-1;2<f;){if(0>=q--){console.log("Warning, unable to triangulate polygon!");break}i=k;f<=i&&(i=0);k=i+1;f<=k&&(k=0);j=k+1;f<=j&&(j=0);var l;a:{l=a;var n=i,r=k,m=j,o=f,p=e,s=void 0,t=void 0,u=void 0,v=void 0,w=void 0,
-z=void 0,x=void 0,A=void 0,F=void 0,t=l[p[n]].x,u=l[p[n]].y,v=l[p[r]].x,w=l[p[r]].y,z=l[p[m]].x,x=l[p[m]].y;if(1.0E-10>(v-t)*(x-u)-(w-u)*(z-t))l=!1;else{for(s=0;s<o;s++)if(!(s==n||s==r||s==m)){var A=l[p[s]].x,F=l[p[s]].y,E=void 0,J=void 0,G=void 0,B=void 0,H=void 0,D=void 0,I=void 0,y=void 0,K=void 0,C=void 0,L=void 0,N=void 0,E=G=H=void 0,E=z-v,J=x-w,G=t-z,B=u-x,H=v-t,D=w-u,I=A-t,y=F-u,K=A-v,C=F-w,L=A-z,N=F-x,E=E*C-J*K,H=H*y-D*I,G=G*N-B*L;if(0<=E&&0<=G&&0<=H){l=!1;break a}}l=!0}}if(l){g.push([a[e[i]],
+0,f=(""+a).split(""),g=f.length,e=[],a=0;a<g;a++){var h=new THREE.Path,h=this.extractGlyphPoints(f[a],b,c,d,h),d=d+h.offset;e.push(h.path)}return{paths:e,offset:d/2}},extractGlyphPoints:function(a,b,c,d,f){var g=[],e,h,i,k,j,q,l,n,r,m,p,o=b.glyphs[a]||b.glyphs["?"];if(o){if(o.o){b=o._cachedOutline||(o._cachedOutline=o.o.split(" "));k=b.length;for(a=0;a<k;)switch(i=b[a++],i){case "m":i=b[a++]*c+d;j=b[a++]*c;g.push(new THREE.Vector2(i,j));f.moveTo(i,j);break;case "l":i=b[a++]*c+d;j=b[a++]*c;g.push(new THREE.Vector2(i,
+j));f.lineTo(i,j);break;case "q":i=b[a++]*c+d;j=b[a++]*c;n=b[a++]*c+d;r=b[a++]*c;f.quadraticCurveTo(n,r,i,j);if(e=g[g.length-1]){q=e.x;l=e.y;for(e=1,h=this.divisions;e<=h;e++){var s=e/h,t=THREE.Shape.Utils.b2(s,q,n,i),s=THREE.Shape.Utils.b2(s,l,r,j);g.push(new THREE.Vector2(t,s))}}break;case "b":if(i=b[a++]*c+d,j=b[a++]*c,n=b[a++]*c+d,r=b[a++]*-c,m=b[a++]*c+d,p=b[a++]*-c,f.bezierCurveTo(i,j,n,r,m,p),e=g[g.length-1]){q=e.x;l=e.y;for(e=1,h=this.divisions;e<=h;e++)s=e/h,t=THREE.Shape.Utils.b3(s,q,n,
+m,i),s=THREE.Shape.Utils.b3(s,l,r,p,j),g.push(new THREE.Vector2(t,s))}}}return{offset:o.ha*c,points:g,path:f}}}};
+(function(a){var b=function(a){for(var b=a.length,f=0,g=b-1,e=0;e<b;g=e++)f+=a[g].x*a[e].y-a[e].x*a[g].y;return 0.5*f};a.Triangulate=function(a,d){var f=a.length;if(3>f)return null;var g=[],e=[],h=[],i,k,j;if(0<b(a))for(k=0;k<f;k++)e[k]=k;else for(k=0;k<f;k++)e[k]=f-1-k;var q=2*f;for(k=f-1;2<f;){if(0>=q--){console.log("Warning, unable to triangulate polygon!");break}i=k;f<=i&&(i=0);k=i+1;f<=k&&(k=0);j=k+1;f<=j&&(j=0);var l;a:{l=a;var n=i,r=k,m=j,p=f,o=e,s=void 0,t=void 0,u=void 0,v=void 0,w=void 0,
+z=void 0,x=void 0,A=void 0,F=void 0,t=l[o[n]].x,u=l[o[n]].y,v=l[o[r]].x,w=l[o[r]].y,z=l[o[m]].x,x=l[o[m]].y;if(1.0E-10>(v-t)*(x-u)-(w-u)*(z-t))l=!1;else{for(s=0;s<p;s++)if(!(s==n||s==r||s==m)){var A=l[o[s]].x,F=l[o[s]].y,E=void 0,J=void 0,G=void 0,B=void 0,H=void 0,D=void 0,I=void 0,y=void 0,K=void 0,C=void 0,L=void 0,N=void 0,E=G=H=void 0,E=z-v,J=x-w,G=t-z,B=u-x,H=v-t,D=w-u,I=A-t,y=F-u,K=A-v,C=F-w,L=A-z,N=F-x,E=E*C-J*K,H=H*y-D*I,G=G*N-B*L;if(0<=E&&0<=G&&0<=H){l=!1;break a}}l=!0}}if(l){g.push([a[e[i]],
 a[e[k]],a[e[j]]]);h.push([e[i],e[k],e[j]]);for(i=k,j=k+1;j<f;i++,j++)e[i]=e[j];f--;q=2*f}}return d?h:g};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,f){THREE.Geometry.call(this);this.radius=a||100;this.tube=b||40;this.segmentsR=c||8;this.segmentsT=d||6;this.arc=f||2*Math.PI;f=new THREE.Vector3;a=[];b=[];for(c=0;c<=this.segmentsR;c++)for(d=0;d<=this.segmentsT;d++){var g=d/this.segmentsT*this.arc,e=2*c/this.segmentsR*Math.PI;f.x=this.radius*Math.cos(g);f.y=this.radius*Math.sin(g);var h=new THREE.Vector3;h.x=(this.radius+this.tube*Math.cos(e))*Math.cos(g);h.y=(this.radius+this.tube*Math.cos(e))*Math.sin(g);h.z=
 this.tube*Math.sin(e);this.vertices.push(new THREE.Vertex(h));a.push(new THREE.UV(d/this.segmentsT,1-c/this.segmentsR));b.push(h.clone().subSelf(f).normalize())}for(c=1;c<=this.segmentsR;c++)for(d=1;d<=this.segmentsT;d++){var f=(this.segmentsT+1)*c+d-1,g=(this.segmentsT+1)*(c-1)+d-1,e=(this.segmentsT+1)*(c-1)+d,h=(this.segmentsT+1)*c+d,i=new THREE.Face4(f,g,e,h,[b[f],b[g],b[e],b[h]]);i.normal.addSelf(b[f]);i.normal.addSelf(b[g]);i.normal.addSelf(b[e]);i.normal.addSelf(b[h]);i.normal.normalize();this.faces.push(i);
@@ -213,12 +213,12 @@ THREE.CameraHelper.prototype.update=function(a){function b(a,b,g,e){THREE.Camera
 1);b("f2",1,-1,1);b("f3",-1,1,1);b("f4",1,1,1);b("u1",0.7,1.1,-1);b("u2",-0.7,1.1,-1);b("u3",0,2,-1);b("cf1",-1,0,1);b("cf2",1,0,1);b("cf3",0,-1,1);b("cf4",0,1,1);b("cn1",-1,0,-1);b("cn2",1,0,-1);b("cn3",0,-1,-1);b("cn4",0,1,-1);this.lineGeometry.__dirtyVertices=!0};THREE.CameraHelper.__projector=new THREE.Projector;THREE.CameraHelper.__v=new THREE.Vector3;THREE.CameraHelper.__c=new THREE.Camera;
 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(e.useOldVertexColors){k.vertexColors=[];for(var j,m,q,n=0;4>n;n++){q=i[n];j=new THREE.Color;j.setRGB(0,0,0);for(var o=0;o<q.length;o++)m=h.vertexColors[q[o]-1],j.r+=m.r,j.g+=m.g,j.b+=m.b;j.r/=q.length;j.g/=q.length;j.b/=q.length;k.vertexColors[n]=j}}f.push(k);(!e.supportUVs||0!=l.length)&&g.push([l[a],l[b],l[c],l[d]])}function c(a,b){return Math.min(a,b)+"_"+Math.max(a,
-b)}var d=[],f=[],g=[],e=this,h=a.vertices,d=a.faces,i=h.concat(),k=[],j={},q={},l=[],n,r,m,o,p,s=a.faceVertexUvs[0];for(n=0,r=s.length;n<r;n++)for(m=0,o=s[n].length;m<o;m++)p=d[n]["abcd".charAt(m)],l[p]||(l[p]=s[n][m]);var t;for(n=0,r=d.length;n<r;n++)if(p=d[n],k.push(p.centroid),i.push(new THREE.Vertex(p.centroid)),e.supportUVs&&0!=l.length){t=new THREE.UV;if(p instanceof THREE.Face3)t.u=l[p.a].u+l[p.b].u+l[p.c].u,t.v=l[p.a].v+l[p.b].v+l[p.c].v,t.u/=3,t.v/=3;else if(p instanceof THREE.Face4)t.u=
-l[p.a].u+l[p.b].u+l[p.c].u+l[p.d].u,t.v=l[p.a].v+l[p.b].v+l[p.c].v+l[p.d].v,t.u/=4,t.v/=4;l.push(t)}r=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 u=0,s=h.length,v,w,z={},x={},A=function(a,
-b){void 0===z[a]&&(z[a]=[]);z[a].push(b)},F=function(a,b){void 0===x[a]&&(x[a]={});x[a][b]=null};for(n in r){t=r[n];v=n.split("_");w=v[0];v=v[1];A(w,[w,v]);A(v,[w,v]);for(m=0,o=t.length;m<o;m++)p=t[m],F(w,p,n),F(v,p,n);2>t.length&&(q[n]=!0)}for(n in r)if(t=r[n],p=t[0],t=t[1],v=n.split("_"),w=v[0],v=v[1],o=new THREE.Vector3,q[n]?(o.addSelf(h[w].position),o.addSelf(h[v].position),o.multiplyScalar(0.5)):(o.addSelf(k[p]),o.addSelf(k[t]),o.addSelf(h[w].position),o.addSelf(h[v].position),o.multiplyScalar(0.25)),
-j[n]=s+d.length+u,i.push(new THREE.Vertex(o)),u++,e.supportUVs&&0!=l.length)t=new THREE.UV,t.u=l[w].u+l[v].u,t.v=l[w].v+l[v].v,t.u/=2,t.v/=2,l.push(t);var E,J;v=["123","12","2","23"];o=["123","23","3","31"];var A=["123","31","1","12"],F=["1234","12","2","23"],G=["1234","23","3","34"],B=["1234","34","4","41"],H=["1234","41","1","12"];for(n=0,r=k.length;n<r;n++)p=d[n],t=s+n,p instanceof THREE.Face3?(u=c(p.a,p.b),w=c(p.b,p.c),E=c(p.c,p.a),b(t,j[u],p.b,j[w],p,v),b(t,j[w],p.c,j[E],p,o),b(t,j[E],p.a,j[u],
-p,A)):p instanceof THREE.Face4?(u=c(p.a,p.b),w=c(p.b,p.c),E=c(p.c,p.d),J=c(p.d,p.a),b(t,j[u],p.b,j[w],p,F),b(t,j[w],p.c,j[E],p,G),b(t,j[E],p.d,j[J],p,B),b(t,j[J],p.a,j[u],p,H)):console.log("face should be a face!",p);d=i;i=new THREE.Vector3;j=new THREE.Vector3;for(n=0,r=h.length;n<r;n++)if(void 0!==z[n]){i.set(0,0,0);j.set(0,0,0);p=new THREE.Vector3(0,0,0);t=0;for(m in x[n])i.addSelf(k[m]),t++;u=0;s=z[n].length;for(m=0;m<s;m++)q[c(z[n][m][0],z[n][m][1])]&&u++;if(2!=u){i.divideScalar(t);for(m=0;m<
-s;m++)t=z[n][m],t=h[t[0]].position.clone().addSelf(h[t[1]].position).divideScalar(2),j.addSelf(t);j.divideScalar(s);p.addSelf(h[n].position);p.multiplyScalar(s-3);p.addSelf(i);p.addSelf(j.multiplyScalar(2));p.divideScalar(s);d[n].position=p}}a.vertices=d;a.faces=f;a.faceVertexUvs[0]=g;delete a.__tmpVertices;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals()};
+b)}var d=[],f=[],g=[],e=this,h=a.vertices,d=a.faces,i=h.concat(),k=[],j={},q={},l=[],n,r,m,p,o,s=a.faceVertexUvs[0];for(n=0,r=s.length;n<r;n++)for(m=0,p=s[n].length;m<p;m++)o=d[n]["abcd".charAt(m)],l[o]||(l[o]=s[n][m]);var t;for(n=0,r=d.length;n<r;n++)if(o=d[n],k.push(o.centroid),i.push(new THREE.Vertex(o.centroid)),e.supportUVs&&0!=l.length){t=new THREE.UV;if(o instanceof THREE.Face3)t.u=l[o.a].u+l[o.b].u+l[o.c].u,t.v=l[o.a].v+l[o.b].v+l[o.c].v,t.u/=3,t.v/=3;else if(o instanceof THREE.Face4)t.u=
+l[o.a].u+l[o.b].u+l[o.c].u+l[o.d].u,t.v=l[o.a].v+l[o.b].v+l[o.c].v+l[o.d].v,t.u/=4,t.v/=4;l.push(t)}r=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 u=0,s=h.length,v,w,z={},x={},A=function(a,
+b){void 0===z[a]&&(z[a]=[]);z[a].push(b)},F=function(a,b){void 0===x[a]&&(x[a]={});x[a][b]=null};for(n in r){t=r[n];v=n.split("_");w=v[0];v=v[1];A(w,[w,v]);A(v,[w,v]);for(m=0,p=t.length;m<p;m++)o=t[m],F(w,o,n),F(v,o,n);2>t.length&&(q[n]=!0)}for(n in r)if(t=r[n],o=t[0],t=t[1],v=n.split("_"),w=v[0],v=v[1],p=new THREE.Vector3,q[n]?(p.addSelf(h[w].position),p.addSelf(h[v].position),p.multiplyScalar(0.5)):(p.addSelf(k[o]),p.addSelf(k[t]),p.addSelf(h[w].position),p.addSelf(h[v].position),p.multiplyScalar(0.25)),
+j[n]=s+d.length+u,i.push(new THREE.Vertex(p)),u++,e.supportUVs&&0!=l.length)t=new THREE.UV,t.u=l[w].u+l[v].u,t.v=l[w].v+l[v].v,t.u/=2,t.v/=2,l.push(t);var E,J;v=["123","12","2","23"];p=["123","23","3","31"];var A=["123","31","1","12"],F=["1234","12","2","23"],G=["1234","23","3","34"],B=["1234","34","4","41"],H=["1234","41","1","12"];for(n=0,r=k.length;n<r;n++)o=d[n],t=s+n,o instanceof THREE.Face3?(u=c(o.a,o.b),w=c(o.b,o.c),E=c(o.c,o.a),b(t,j[u],o.b,j[w],o,v),b(t,j[w],o.c,j[E],o,p),b(t,j[E],o.a,j[u],
+o,A)):o instanceof THREE.Face4?(u=c(o.a,o.b),w=c(o.b,o.c),E=c(o.c,o.d),J=c(o.d,o.a),b(t,j[u],o.b,j[w],o,F),b(t,j[w],o.c,j[E],o,G),b(t,j[E],o.d,j[J],o,B),b(t,j[J],o.a,j[u],o,H)):console.log("face should be a face!",o);d=i;i=new THREE.Vector3;j=new THREE.Vector3;for(n=0,r=h.length;n<r;n++)if(void 0!==z[n]){i.set(0,0,0);j.set(0,0,0);o=new THREE.Vector3(0,0,0);t=0;for(m in x[n])i.addSelf(k[m]),t++;u=0;s=z[n].length;for(m=0;m<s;m++)q[c(z[n][m][0],z[n][m][1])]&&u++;if(2!=u){i.divideScalar(t);for(m=0;m<
+s;m++)t=z[n][m],t=h[t[0]].position.clone().addSelf(h[t[1]].position).divideScalar(2),j.addSelf(t);j.divideScalar(s);o.addSelf(h[n].position);o.multiplyScalar(s-3);o.addSelf(i);o.addSelf(j.multiplyScalar(2));o.divideScalar(s);d[n].position=o}}a.vertices=d;a.faces=f;a.faceVertexUvs[0]=g;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:"anonymous",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=
@@ -234,17 +234,17 @@ THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,f,g){var e=new XMLHtt
 e.status+"]")};e.open("GET",b,!0);e.overrideMimeType&&e.overrideMimeType("text/plain; charset=x-user-defined");e.setRequestHeader("Content-Type","text/plain");e.send(null)};
 THREE.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,f){var g=new XMLHttpRequest,e=c+"/"+a.buffers,h=0;g.onreadystatechange=function(){4==g.readyState?200==g.status||0==g.status?THREE.BinaryLoader.prototype.createBinModel(g.response,b,d,a.materials):console.error("Couldn't load ["+e+"] ["+g.status+"]"):3==g.readyState?f&&(0==h&&(h=g.getResponseHeader("Content-Length")),f({total:h,loaded:g.responseText.length})):2==g.readyState&&(h=g.getResponseHeader("Content-Length"))};g.open("GET",e,!0);
 g.responseType="arraybuffer";g.send(null)};
-THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var f=function(b){var c,f,i,k,j,q,l,n,r,m,o,p,s,t,u,v;function w(a){return a%4?4-a%4:0}function z(a,b){return(new Uint8Array(a,b,1))[0]}function x(a,b){return(new Uint32Array(a,b,1))[0]}function A(b,c){var d,e,f,g,h,i,j,k,m=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=m[3*d];f=m[3*d+1];g=m[3*d+2];h=y[2*e];e=y[2*e+1];i=y[2*f];j=y[2*f+1];f=y[2*g];k=y[2*g+1];g=H.faceVertexUvs[0];var l=[];l.push(new THREE.UV(h,e));l.push(new THREE.UV(i,j));
+THREE.BinaryLoader.prototype.createBinModel=function(a,b,c,d){var f=function(b){var c,f,i,k,j,q,l,n,r,m,p,o,s,t,u,v;function w(a){return a%4?4-a%4:0}function z(a,b){return(new Uint8Array(a,b,1))[0]}function x(a,b){return(new Uint32Array(a,b,1))[0]}function A(b,c){var d,e,f,g,h,i,j,k,m=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=m[3*d];f=m[3*d+1];g=m[3*d+2];h=y[2*e];e=y[2*e+1];i=y[2*f];j=y[2*f+1];f=y[2*g];k=y[2*g+1];g=H.faceVertexUvs[0];var l=[];l.push(new THREE.UV(h,e));l.push(new THREE.UV(i,j));
 l.push(new THREE.UV(f,k));g.push(l)}}function F(b,c){var d,e,f,g,h,i,j,k,m,l,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=y[2*e];e=y[2*e+1];j=y[2*f];m=y[2*f+1];k=y[2*g];l=y[2*g+1];g=y[2*h];f=y[2*h+1];h=H.faceVertexUvs[0];var q=[];q.push(new THREE.UV(i,e));q.push(new THREE.UV(j,m));q.push(new THREE.UV(k,l));q.push(new THREE.UV(g,f));h.push(q)}}function E(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],H.faces.push(new THREE.Face3(e,f,g,null,null,h))}function J(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],H.faces.push(new THREE.Face4(e,f,g,h,null,null,i))}function G(b,c,d,e){for(var f,g,h,i,j,k,m,c=new Uint32Array(a,c,3*b),d=new Uint32Array(a,d,3*b),l=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];m=d[3*e+2];i=l[e];var n=I[3*k],q=I[3*k+1];k=
 I[3*k+2];var o=I[3*m],p=I[3*m+1];m=I[3*m+2];H.faces.push(new THREE.Face3(f,g,h,[new THREE.Vector3(I[3*j],I[3*j+1],I[3*j+2]),new THREE.Vector3(n,q,k),new THREE.Vector3(o,p,m)],null,i))}}function B(b,c,d,e){for(var f,g,h,i,j,k,m,l,n,c=new Uint32Array(a,c,4*b),d=new Uint32Array(a,d,4*b),q=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];m=d[4*e+1];l=d[4*e+2];n=d[4*e+3];j=q[e];var o=I[3*m],p=I[3*m+1];m=I[3*m+2];var r=I[3*l],s=I[3*l+1];l=I[3*l+2];var t=I[3*n],u=I[3*
 n+1];n=I[3*n+2];H.faces.push(new THREE.Face4(f,g,h,i,[new THREE.Vector3(I[3*k],I[3*k+1],I[3*k+2]),new THREE.Vector3(o,p,m),new THREE.Vector3(r,s,l),new THREE.Vector3(t,u,n)],null,j))}}var H=this,D=0,I=[],y=[],K,C;THREE.Geometry.call(this);THREE.Loader.prototype.initMaterials(H,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,D,12);f=z(a,D+12);z(a,D+13);z(a,D+14);z(a,D+15);i=z(a,D+16);k=z(a,D+17);j=z(a,D+18);q=z(a,D+19);l=x(a,D+20);
-n=x(a,D+20+4);r=x(a,D+20+8);b=x(a,D+20+12);m=x(a,D+20+16);o=x(a,D+20+20);p=x(a,D+20+24);s=x(a,D+20+28);t=x(a,D+20+32);u=x(a,D+20+36);v=x(a,D+20+40);"Three.js 003"!==c&&console.warn("DEPRECATED: binary model seems to be using old format");D+=f;c=3*i+q;C=4*i+q;f=b*c;K=m*(c+3*k);i=o*(c+3*j);q=p*(c+3*k+3*j);c=s*C;k=t*(C+4*k);j=u*(C+4*j);D+=function(b){var b=new Float32Array(a,b,3*l),c,d,e,f;for(c=0;c<l;c++)d=b[3*c],e=b[3*c+1],f=b[3*c+2],H.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,f)));return 3*
-l*Float32Array.BYTES_PER_ELEMENT}(D);D+=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],I.push(d/127,e/127,f/127)}return 3*n*Int8Array.BYTES_PER_ELEMENT}(D);D+=w(3*n);D+=function(b){if(r){var b=new Float32Array(a,b,2*r),c,d,e;for(c=0;c<r;c++)d=b[2*c],e=b[2*c+1],y.push(d,e)}return 2*r*Float32Array.BYTES_PER_ELEMENT}(D);f=D+f+w(2*b);K=f+K+w(2*m);i=K+i+w(2*o);q=i+q+w(2*p);c=q+c+w(2*s);k=c+k+w(2*t);j=k+j+w(2*u);(function(a){if(o){var b=a+3*o*Uint32Array.BYTES_PER_ELEMENT;
-E(o,a,b+3*o*Uint32Array.BYTES_PER_ELEMENT);A(o,b)}})(K);(function(a){if(p){var b=a+3*p*Uint32Array.BYTES_PER_ELEMENT,c=b+3*p*Uint32Array.BYTES_PER_ELEMENT;G(p,a,b,c+3*p*Uint32Array.BYTES_PER_ELEMENT);A(p,c)}})(i);(function(a){if(u){var b=a+4*u*Uint32Array.BYTES_PER_ELEMENT;J(u,a,b+4*u*Uint32Array.BYTES_PER_ELEMENT);F(u,b)}})(k);(function(a){if(v){var b=a+4*v*Uint32Array.BYTES_PER_ELEMENT,c=b+4*v*Uint32Array.BYTES_PER_ELEMENT;B(v,a,b,c+4*v*Uint32Array.BYTES_PER_ELEMENT);F(v,c)}})(j);b&&E(b,D,D+3*b*
+n=x(a,D+20+4);r=x(a,D+20+8);b=x(a,D+20+12);m=x(a,D+20+16);p=x(a,D+20+20);o=x(a,D+20+24);s=x(a,D+20+28);t=x(a,D+20+32);u=x(a,D+20+36);v=x(a,D+20+40);"Three.js 003"!==c&&console.warn("DEPRECATED: binary model seems to be using old format");D+=f;c=3*i+q;C=4*i+q;f=b*c;K=m*(c+3*k);i=p*(c+3*j);q=o*(c+3*k+3*j);c=s*C;k=t*(C+4*k);j=u*(C+4*j);D+=function(b){var b=new Float32Array(a,b,3*l),c,d,e,f;for(c=0;c<l;c++)d=b[3*c],e=b[3*c+1],f=b[3*c+2],H.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,f)));return 3*
+l*Float32Array.BYTES_PER_ELEMENT}(D);D+=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],I.push(d/127,e/127,f/127)}return 3*n*Int8Array.BYTES_PER_ELEMENT}(D);D+=w(3*n);D+=function(b){if(r){var b=new Float32Array(a,b,2*r),c,d,e;for(c=0;c<r;c++)d=b[2*c],e=b[2*c+1],y.push(d,e)}return 2*r*Float32Array.BYTES_PER_ELEMENT}(D);f=D+f+w(2*b);K=f+K+w(2*m);i=K+i+w(2*p);q=i+q+w(2*o);c=q+c+w(2*s);k=c+k+w(2*t);j=k+j+w(2*u);(function(a){if(p){var b=a+3*p*Uint32Array.BYTES_PER_ELEMENT;
+E(p,a,b+3*p*Uint32Array.BYTES_PER_ELEMENT);A(p,b)}})(K);(function(a){if(o){var b=a+3*o*Uint32Array.BYTES_PER_ELEMENT,c=b+3*o*Uint32Array.BYTES_PER_ELEMENT;G(o,a,b,c+3*o*Uint32Array.BYTES_PER_ELEMENT);A(o,c)}})(i);(function(a){if(u){var b=a+4*u*Uint32Array.BYTES_PER_ELEMENT;J(u,a,b+4*u*Uint32Array.BYTES_PER_ELEMENT);F(u,b)}})(k);(function(a){if(v){var b=a+4*v*Uint32Array.BYTES_PER_ELEMENT,c=b+4*v*Uint32Array.BYTES_PER_ELEMENT;B(v,a,b,c+4*v*Uint32Array.BYTES_PER_ELEMENT);F(v,c)}})(j);b&&E(b,D,D+3*b*
 Uint32Array.BYTES_PER_ELEMENT);(function(a){if(m){var b=a+3*m*Uint32Array.BYTES_PER_ELEMENT;G(m,a,b,b+3*m*Uint32Array.BYTES_PER_ELEMENT)}})(f);s&&J(s,q,q+4*s*Uint32Array.BYTES_PER_ELEMENT);(function(a){if(t){var b=a+4*t*Uint32Array.BYTES_PER_ELEMENT;B(t,a,b,b+4*t*Uint32Array.BYTES_PER_ELEMENT)}})(c);this.computeCentroids();this.computeFaceNormals();THREE.Loader.prototype.hasNormals(this)&&this.computeTangents()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f(c))};
 THREE.ColladaLoader=function(){function a(a,d,f){Q=a;d=d||la;void 0!==f&&(a=f.split("/"),a.pop(),ma=1>a.length?"":a.join("/")+"/");if((a=Q.evaluate("//dae:asset",Q,L,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&a.childNodes)for(f=0;f<a.childNodes.length;f++){var i=a.childNodes[f];switch(i.nodeName){case "unit":(i=i.getAttribute("meter"))&&parseFloat(i);break;case "up_axis":$=i.textContent.charAt(0)}}if(!R.convertUpAxis||$===R.upAxis)W=null;else switch($){case "X":W="Y"===R.upAxis?
-"XtoY":"XtoZ";break;case "Y":W="X"===R.upAxis?"YtoX":"YtoZ";break;case "Z":W="X"===R.upAxis?"ZtoX":"ZtoY"}da=b("//dae:library_images/dae:image",e,"image");ea=b("//dae:library_materials/dae:material",x,"material");fa=b("//dae:library_effects/dae:effect",G,"effect");V=b("//dae:library_geometries/dae:geometry",o,"geometry");ga=b(".//dae:library_cameras/dae:camera",K,"camera");U=b("//dae:library_controllers/dae:controller",h,"controller");X=b("//dae:library_animations/dae:animation",H,"animation");ha=
+"XtoY":"XtoZ";break;case "Y":W="X"===R.upAxis?"YtoX":"YtoZ";break;case "Z":W="X"===R.upAxis?"ZtoX":"ZtoY"}da=b("//dae:library_images/dae:image",e,"image");ea=b("//dae:library_materials/dae:material",x,"material");fa=b("//dae:library_effects/dae:effect",G,"effect");V=b("//dae:library_geometries/dae:geometry",p,"geometry");ga=b(".//dae:library_cameras/dae:camera",K,"camera");U=b("//dae:library_controllers/dae:controller",h,"controller");X=b("//dae:library_animations/dae:animation",H,"animation");ha=
 b(".//dae:library_visual_scenes/dae:visual_scene",j,"visual_scene");aa=[];ba=[];(a=Q.evaluate(".//dae:scene/dae:instance_visual_scene",Q,L,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),T=ha[a]):T=null;Y=new THREE.Object3D;for(a=0;a<T.nodes.length;a++)Y.add(g(T.nodes[a]));ia=[];c(Y);a={scene:Y,morphs:aa,skins:ba,animations:ia,dae:{images:da,materials:ea,cameras:ga,effects:fa,geometries:V,controllers:U,animations:X,visualScenes:ha,scene:T}};d&&
 d(a);return a}function b(a,b,c){for(var a=Q.evaluate(a,Q,L,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=T.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};ia.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 f(a,b,c){var e,f=U[b.url];if(!f||!f.skin)console.log("ColladaLoader: Could not find skin controller.");
@@ -256,8 +256,8 @@ new m;j.url=i.skin.source;j.instance_material=a.controllers[e].instance_material
 l;for(h=0;h<i.faces.length;h++)l=i.faces[h],l.materialIndex=k[l.daeMaterial]}if(void 0!==c)f(i,c),j.morphTargets=!0,j=new THREE.SkinnedMesh(i,j),j.skeleton=c.skeleton,j.skinController=U[c.url],j.skinInstanceController=c,j.name="skin_"+ba.length,ba.push(j);else if(void 0!==d){h=i;k=d instanceof n?U[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(q=V[k.targets[l]],q.mesh&&q.mesh.primitives&&q.mesh.primitives.length)q=q.mesh.primitives[0].geometry,
 q.vertices.length===h.vertices.length&&h.morphTargets.push({name:"target_1",vertices:q.vertices});h.morphTargets.push({name:"target_Z",vertices:h.vertices})}j.morphTargets=!0;j=new THREE.Mesh(i,j);j.name="morph_"+aa.length;aa.push(j)}else j=new THREE.Mesh(i,j);1<a.geometries.length?b.add(j):b=j}}for(e=0;e<a.cameras.length;e++)b=ga[a.cameras[e].url],b=new THREE.PerspectiveCamera(b.fov,b.aspect_ratio,b.znear,b.zfar);b.name=a.id||"";b.matrix=a.matrix;e=a.matrix.decompose();b.position=e[0];b.quaternion=
 e[1];b.useQuaternion=!0;b.scale=e[2];R.centerGeometry&&b.geometry&&(e=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(e.multiplySelf(b.scale)),b.position.subSelf(e));for(e=0;e<a.nodes.length;e++)b.add(g(a.nodes[e],a));return b}function e(){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 k(){this.source="";this.bindShapeMatrix=null;this.invBindMatrices=[];
-this.joints=[];this.weights=[]}function j(){this.name=this.id="";this.nodes=[];this.scene=new THREE.Object3D}function q(){this.sid=this.name=this.id="";this.nodes=[];this.controllers=[];this.transforms=[];this.geometries=[];this.channels=[];this.matrix=new THREE.Matrix4}function l(){this.type=this.sid="";this.data=[];this.obj=null}function n(){this.url="";this.skeleton=[];this.instance_material=[]}function r(){this.target=this.symbol=""}function m(){this.url="";this.instance_material=[]}function o(){this.id=
-"";this.mesh=null}function p(a){this.geometry=a.id;this.primitives=[];this.geometry3js=this.vertices=null}function s(){}function t(){this.material="";this.count=0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function u(){this.source="";this.stride=this.count=0;this.params=[]}function v(){this.input={}}function w(){this.semantic="";this.offset=0;this.source="";this.set=0}function z(a){this.id=a;this.type=null}function x(){this.name=this.id="";this.instance_effect=null}
+this.joints=[];this.weights=[]}function j(){this.name=this.id="";this.nodes=[];this.scene=new THREE.Object3D}function q(){this.sid=this.name=this.id="";this.nodes=[];this.controllers=[];this.transforms=[];this.geometries=[];this.channels=[];this.matrix=new THREE.Matrix4}function l(){this.type=this.sid="";this.data=[];this.obj=null}function n(){this.url="";this.skeleton=[];this.instance_material=[]}function r(){this.target=this.symbol=""}function m(){this.url="";this.instance_material=[]}function p(){this.id=
+"";this.mesh=null}function o(a){this.geometry=a.id;this.primitives=[];this.geometry3js=this.vertices=null}function s(){}function t(){this.material="";this.count=0;this.inputs=[];this.vcount=null;this.p=[];this.geometry=new THREE.Geometry}function u(){this.source="";this.stride=this.count=0;this.params=[]}function v(){this.input={}}function w(){this.semantic="";this.offset=0;this.source="";this.set=0}function z(a){this.id=a;this.type=null}function x(){this.name=this.id="";this.instance_effect=null}
 function A(){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 E(a){this.effect=a;this.format=this.init_from=null}function J(a){this.effect=a;this.mipfilter=this.magfilter=this.minfilter=this.wrap_t=this.wrap_s=this.source=null}function G(){this.name=this.id="";this.sampler=this.surface=this.shader=null}function B(){this.url=""}
 function H(){this.name=this.id="";this.source={};this.sampler=[];this.channel=[]}function D(a){this.animation=a;this.target=this.source="";this.member=this.arrIndices=this.arrSyntax=this.dotSyntax=this.sid=this.fullSid=null}function I(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 y(a){this.targets=[];this.time=a}function K(){this.name=this.id=""}function C(){this.url=""}function L(a){return"dae"==
 a?"http://www.collada.org/2005/11/COLLADASchema":null}function N(a){for(var a=S(a),b=[],c=0,d=a.length;c<d;c++)b.push(parseFloat(a[c]));return b}function M(a){for(var a=S(a),b=[],c=0,d=a.length;c<d;c++)b.push(parseInt(a[c],10));return b}function S(a){return 0<a.length?a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/):[]}function O(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function P(a,b){if(R.convertUpAxis&&$!==R.upAxis)switch(W){case "XtoY":var c=a[0];a[0]=b*a[1];a[1]=c;
@@ -281,9 +281,9 @@ return this};l.prototype.convert=function(){switch(this.type){case "matrix":this
 break;case "translate":a.translate(this.obj);break;case "rotate":a.rotateByAxis(this.obj,this.angle);break;case "scale":a.scale(this.obj)}};l.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*ja;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2],this.angle=a[3]*ja}}};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=Q.evaluate(".//dae:instance_material",
 c,L,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(var d=c.iterateNext();d;)this.instance_material.push((new r).parse(d)),d=c.iterateNext()}}return this};r.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=
-Q.evaluate(".//dae:instance_material",c,L,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(b=a.iterateNext();b;)this.instance_material.push((new r).parse(b)),b=a.iterateNext();break}}return this};o.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 p(this)).parse(c)}}return this};p.prototype.parse=function(a){this.primitives=[];var b;for(b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];
+Q.evaluate(".//dae:instance_material",c,L,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null))for(b=a.iterateNext();b;)this.instance_material.push((new r).parse(b)),b=a.iterateNext();break}}return this};p.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 o(this)).parse(c)}}return this};o.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==Z[d]&&(Z[d]=(new z(d)).parse(c));break;case "vertices":this.vertices=(new v).parse(c);break;case "triangles":this.primitives.push((new t).parse(c));break;case "polygons":console.warn("polygon holes not yet supported!");case "polylist":this.primitives.push((new s).parse(c))}}this.geometry3js=new THREE.Geometry;a=Z[this.vertices.input.POSITION.source].data;for(b=0;b<a.length;b+=3)this.geometry3js.vertices.push(new THREE.Vertex(ka(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};p.prototype.handlePrimitive=function(a,b){var c=0,d,e,f=a.p,g=a.inputs,h,i,j,k,m=0,l=3,n=0,q=[];for(d=0;d<g.length;d++){h=g[d];var o=h.offset+1,n=n<o?o:n;switch(h.semantic){case "TEXCOORD":q.push(h.set)}}for(;c<
+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};o.prototype.handlePrimitive=function(a,b){var c=0,d,e,f=a.p,g=a.inputs,h,i,j,k,m=0,l=3,n=0,q=[];for(d=0;d<g.length;d++){h=g[d];var o=h.offset+1,n=n<o?o:n;switch(h.semantic){case "TEXCOORD":q.push(h.set)}}for(;c<
 f.length;){var p=[],r=[],o={},s=[];a.vcount&&(l=a.vcount[m++]);for(d=0;d<l;d++)for(e=0;e<g.length;e++)switch(h=g[e],k=Z[h.source],i=f[c+d*n+h.offset],j=k.accessor.params.length,j*=i,h.semantic){case "VERTEX":p.push(i);break;case "NORMAL":r.push(ka(k.data,j));break;case "TEXCOORD":void 0===o[h.set]&&(o[h.set]=[]);o[h.set].push(new THREE.UV(k.data[j],1-k.data[j+1]));break;case "COLOR":s.push((new THREE.Color).setRGB(k.data[j],k.data[j+1],k.data[j+2]))}e=null;d=[];if(3===l)d.push(new THREE.Face3(p[0],
 p[1],p[2],[r[0],r[1],r[2]],s.length?s:new THREE.Color));else if(4===l)d.push(new THREE.Face4(p[0],p[1],p[2],p[3],[r[0],r[1],r[2],r[3]],s.length?s:new THREE.Color));else if(4<l&&R.subdivideFaces){s=s.length?s:new THREE.Color;for(e=1;e<l-1;)d.push(new THREE.Face3(p[0],p[e],p[e+1],[r[0],r[e++],r[e]],s))}if(d.length){p=0;for(r=d.length;p<r;p++){e=d[p];e.daeMaterial=a.material;b.faces.push(e);for(e=0;e<q.length;e++)s=o[q[e]],s=4<l?[s[0],s[p+1],s[p+2]]:4===l?[s[0],s[1],s[2],s[3]]:[s[0],s[1],s[2]],b.faceVertexUvs[e]||
 (b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(s)}}else console.log("dropped face with vcount "+l+" for geometry with id: "+b.id);c+=n*l}};s.prototype=new t;s.prototype.constructor=s;t.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};t.prototype.parse=function(a){this.inputs=[];this.material=a.getAttribute("material");this.count=O(a,"count",0);for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];
@@ -313,45 +313,44 @@ d({total:e,loaded:f.responseText.length}))};f.open("GET",b,!0);f.send(null)}else
 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,f){var g=new XMLHttpRequest,e=0;g.onreadystatechange=function(){if(4==g.readyState)if(200==g.status||0==g.status){try{var h=JSON.parse(g.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+"] ["+g.status+"]");else 3==g.readyState?f&&(0==e&&(e=g.getResponseHeader("Content-Length")),f({total:e,loaded:g.responseText.length})):
 2==g.readyState&&(e=g.getResponseHeader("Content-Length"))};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.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,f=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,f,i,k,j,q,l,n,r,m,o,p,s,t,u=a.faces;q=a.vertices;var v=a.normals,w=a.colors,z=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&z++;for(c=0;c<z;c++)d.faceUvs[c]=[],d.faceVertexUvs[c]=[];k=0;for(j=q.length;k<
-j;)l=new THREE.Vertex,l.position.x=q[k++]*b,l.position.y=q[k++]*b,l.position.z=q[k++]*b,d.vertices.push(l);k=0;for(j=u.length;k<j;){b=u[k++];q=b&1;i=b&2;c=b&4;f=b&8;n=b&16;l=b&32;m=b&64;b&=128;q?(o=new THREE.Face4,o.a=u[k++],o.b=u[k++],o.c=u[k++],o.d=u[k++],q=4):(o=new THREE.Face3,o.a=u[k++],o.b=u[k++],o.c=u[k++],q=3);if(i)i=u[k++],o.materialIndex=i;i=d.faces.length;if(c)for(c=0;c<z;c++)p=a.uvs[c],r=u[k++],t=p[2*r],r=p[2*r+1],d.faceUvs[c][i]=new THREE.UV(t,r);if(f)for(c=0;c<z;c++){p=a.uvs[c];s=[];
-for(f=0;f<q;f++)r=u[k++],t=p[2*r],r=p[2*r+1],s[f]=new THREE.UV(t,r);d.faceVertexUvs[c][i]=s}if(n)n=3*u[k++],f=new THREE.Vector3,f.x=v[n++],f.y=v[n++],f.z=v[n],o.normal=f;if(l)for(c=0;c<q;c++)n=3*u[k++],f=new THREE.Vector3,f.x=v[n++],f.y=v[n++],f.z=v[n],o.vertexNormals.push(f);if(m)l=u[k++],l=new THREE.Color(w[l]),o.color=l;if(b)for(c=0;c<q;c++)l=u[k++],l=new THREE.Color(w[l]),o.vertexColors.push(l);d.faces.push(o)}}})(f);(function(){var b,c,f,i;if(a.skinWeights)for(b=0,c=a.skinWeights.length;b<c;b+=
-2)f=a.skinWeights[b],i=a.skinWeights[b+1],d.skinWeights.push(new THREE.Vector4(f,i,0,0));if(a.skinIndices)for(b=0,c=a.skinIndices.length;b<c;b+=2)f=a.skinIndices[b],i=a.skinIndices[b+1],d.skinIndices.push(new THREE.Vector4(f,i,0,0));d.bones=a.bones;d.animation=a.animation})();(function(b){if(void 0!==a.morphTargets){var c,f,i,k,j,q,l,n,r,m,o;for(c=0,f=a.morphTargets.length;c<f;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];d.morphNormals[c]={};
-d.morphNormals[c].faceNormals=[];d.morphNormals[c].vertexNormals=[];n=d.morphTargets[c].vertices;r=a.morphTargets[c].vertices;m=d.morphNormals[c].faceNormals;o=d.morphNormals[c].vertexNormals;for(i=0,k=r.length;i<k;i+=3)j=r[i]*b,q=r[i+1]*b,l=r[i+2]*b,n.push(new THREE.Vertex(new THREE.Vector3(j,q,l)));for(i=0,k=d.faces.length;i<k;i++)q=d.faces[i],j=new THREE.Vector3,q=q instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,
-d:new THREE.Vector3},m.push(j),o.push(q)}}if(void 0!==a.morphColors)for(c=0,f=a.morphColors.length;c<f;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];o=d.morphColors[c].colors;i=a.morphColors[c].colors;for(b=0,m=i.length;b<m;b+=3)k=new THREE.Color(16755200),k.setRGB(i[b],i[b+1],i[b+2]),o.push(k)}})(f);d.computeCentroids();d.computeMorphNormals();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.JSONLoader.prototype.createModel=function(a,b,c){var d=new THREE.Geometry,f=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,f,i,k,j,q,l,n,r,m,p,o,s,t,u=a.faces;q=a.vertices;var v=a.normals,w=a.colors,z=0;for(c=0;c<a.uvs.length;c++)a.uvs[c].length&&z++;for(c=0;c<z;c++)d.faceUvs[c]=[],d.faceVertexUvs[c]=[];k=0;for(j=q.length;k<
+j;)l=new THREE.Vertex,l.position.x=q[k++]*b,l.position.y=q[k++]*b,l.position.z=q[k++]*b,d.vertices.push(l);k=0;for(j=u.length;k<j;){b=u[k++];q=b&1;i=b&2;c=b&4;f=b&8;n=b&16;l=b&32;m=b&64;b&=128;q?(p=new THREE.Face4,p.a=u[k++],p.b=u[k++],p.c=u[k++],p.d=u[k++],q=4):(p=new THREE.Face3,p.a=u[k++],p.b=u[k++],p.c=u[k++],q=3);if(i)i=u[k++],p.materialIndex=i;i=d.faces.length;if(c)for(c=0;c<z;c++)o=a.uvs[c],r=u[k++],t=o[2*r],r=o[2*r+1],d.faceUvs[c][i]=new THREE.UV(t,r);if(f)for(c=0;c<z;c++){o=a.uvs[c];s=[];
+for(f=0;f<q;f++)r=u[k++],t=o[2*r],r=o[2*r+1],s[f]=new THREE.UV(t,r);d.faceVertexUvs[c][i]=s}if(n)n=3*u[k++],f=new THREE.Vector3,f.x=v[n++],f.y=v[n++],f.z=v[n],p.normal=f;if(l)for(c=0;c<q;c++)n=3*u[k++],f=new THREE.Vector3,f.x=v[n++],f.y=v[n++],f.z=v[n],p.vertexNormals.push(f);if(m)l=u[k++],l=new THREE.Color(w[l]),p.color=l;if(b)for(c=0;c<q;c++)l=u[k++],l=new THREE.Color(w[l]),p.vertexColors.push(l);d.faces.push(p)}}})(f);(function(){var b,c,f,i;if(a.skinWeights)for(b=0,c=a.skinWeights.length;b<c;b+=
+2)f=a.skinWeights[b],i=a.skinWeights[b+1],d.skinWeights.push(new THREE.Vector4(f,i,0,0));if(a.skinIndices)for(b=0,c=a.skinIndices.length;b<c;b+=2)f=a.skinIndices[b],i=a.skinIndices[b+1],d.skinIndices.push(new THREE.Vector4(f,i,0,0));d.bones=a.bones;d.animation=a.animation})();(function(b){if(void 0!==a.morphTargets){var c,f,i,k,j,q,l,n,r;for(c=0,f=a.morphTargets.length;c<f;c++){d.morphTargets[c]={};d.morphTargets[c].name=a.morphTargets[c].name;d.morphTargets[c].vertices=[];n=d.morphTargets[c].vertices;
+r=a.morphTargets[c].vertices;for(i=0,k=r.length;i<k;i+=3)j=r[i]*b,q=r[i+1]*b,l=r[i+2]*b,n.push(new THREE.Vertex(new THREE.Vector3(j,q,l)))}}if(void 0!==a.morphColors)for(c=0,f=a.morphColors.length;c<f;c++){d.morphColors[c]={};d.morphColors[c].name=a.morphColors[c].name;d.morphColors[c].colors=[];k=d.morphColors[c].colors;j=a.morphColors[c].colors;for(b=0,i=j.length;b<i;b+=3)q=new THREE.Color(16755200),q.setRGB(j[b],j[b+1],j[b+2]),k.push(q)}})(f);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 f=JSON.parse(d.responseText)}catch(g){console.warn("DEPRECATED: ["+a+"] seems to be using old model format")}c.createScene(f,b,a)}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:k+"/"+a}function f(){var a;for(l in B.objects)if(!C.objects[l])if(p=B.objects[l],void 0!==p.geometry){if(F=C.geometries[p.geometry]){a=!1;E=C.materials[p.materials[0]];(a=E instanceof THREE.ShaderMaterial)&&F.computeTangents();u=p.position;v=p.rotation;w=p.quaternion;z=p.scale;w=0;0==p.materials.length&&(E=new THREE.MeshFaceMaterial);1<p.materials.length&&(E=new THREE.MeshFaceMaterial);a=new THREE.Mesh(F,
-E);a.name=l;a.position.set(u[0],u[1],u[2]);w?(a.quaternion.set(w[0],w[1],w[2],w[3]),a.useQuaternion=!0):a.rotation.set(v[0],v[1],v[2]);a.scale.set(z[0],z[1],z[2]);a.visible=p.visible;C.scene.add(a);C.objects[l]=a;if(p.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);C.scene.collisions.colliders.push(b)}if(p.castsShadow)b=new THREE.ShadowVolume(F),C.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;p.trigger&&"none"!=p.trigger.toLowerCase()&&(b={type:p.trigger,object:p},
-C.triggers[a.name]=b)}}else u=p.position,v=p.rotation,w=p.quaternion,z=p.scale,w=0,a=new THREE.Object3D,a.name=l,a.position.set(u[0],u[1],u[2]),w?(a.quaternion.set(w[0],w[1],w[2],w[3]),a.useQuaternion=!0):a.rotation.set(v[0],v[1],v[2]),a.scale.set(z[0],z[1],z[2]),a.visible=void 0!==p.visible?p.visible:!1,C.scene.add(a),C.objects[l]=a,C.empties[l]=a,p.trigger&&"none"!=p.trigger.toLowerCase()&&(b={type:p.trigger,object:p},C.triggers[a.name]=b)}function g(a){return function(b){C.geometries[a]=b;f();
-D-=1;i.onLoadComplete();h()}}function e(a){return function(b){C.geometries[a]=b}}function h(){i.callbackProgress({totalModels:y,totalTextures:K,loadedModels:y-D,loadedTextures:K-I},C);i.onLoadProgress();0==D&&0==I&&b(C)}var i=this,k=THREE.Loader.prototype.extractUrlbase(c),j,q,l,n,r,m,o,p,s,t,u,v,w,z,x,A,F,E,J,G,B,H,D,I,y,K,C;B=a;c=new THREE.BinaryLoader;H=new THREE.JSONLoader;I=D=0;C={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},
-empties:{}};a=!1;for(l in B.objects)if(p=B.objects[l],p.meshCollider){a=!0;break}if(a)C.scene.collisions=new THREE.CollisionSystem;if(B.transform)a=B.transform.position,s=B.transform.rotation,x=B.transform.scale,a&&C.scene.position.set(a[0],a[1],a[2]),s&&C.scene.rotation.set(s[0],s[1],s[2]),x&&C.scene.scale.set(x[0],x[1],x[2]),(a||s||x)&&C.scene.updateMatrix();a=function(){I-=1;h();i.onLoadComplete()};for(r in B.cameras)x=B.cameras[r],"perspective"==x.type?J=new THREE.PerspectiveCamera(x.fov,x.aspect,
+THREE.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return"relativeToHTML"==b?a:k+"/"+a}function f(){var a;for(l in B.objects)if(!C.objects[l])if(o=B.objects[l],void 0!==o.geometry){if(F=C.geometries[o.geometry]){a=!1;E=C.materials[o.materials[0]];(a=E instanceof THREE.ShaderMaterial)&&F.computeTangents();u=o.position;v=o.rotation;w=o.quaternion;z=o.scale;w=0;0==o.materials.length&&(E=new THREE.MeshFaceMaterial);1<o.materials.length&&(E=new THREE.MeshFaceMaterial);a=new THREE.Mesh(F,
+E);a.name=l;a.position.set(u[0],u[1],u[2]);w?(a.quaternion.set(w[0],w[1],w[2],w[3]),a.useQuaternion=!0):a.rotation.set(v[0],v[1],v[2]);a.scale.set(z[0],z[1],z[2]);a.visible=o.visible;C.scene.add(a);C.objects[l]=a;if(o.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);C.scene.collisions.colliders.push(b)}if(o.castsShadow)b=new THREE.ShadowVolume(F),C.scene.add(b),b.position=a.position,b.rotation=a.rotation,b.scale=a.scale;o.trigger&&"none"!=o.trigger.toLowerCase()&&(b={type:o.trigger,object:o},
+C.triggers[a.name]=b)}}else u=o.position,v=o.rotation,w=o.quaternion,z=o.scale,w=0,a=new THREE.Object3D,a.name=l,a.position.set(u[0],u[1],u[2]),w?(a.quaternion.set(w[0],w[1],w[2],w[3]),a.useQuaternion=!0):a.rotation.set(v[0],v[1],v[2]),a.scale.set(z[0],z[1],z[2]),a.visible=void 0!==o.visible?o.visible:!1,C.scene.add(a),C.objects[l]=a,C.empties[l]=a,o.trigger&&"none"!=o.trigger.toLowerCase()&&(b={type:o.trigger,object:o},C.triggers[a.name]=b)}function g(a){return function(b){C.geometries[a]=b;f();
+D-=1;i.onLoadComplete();h()}}function e(a){return function(b){C.geometries[a]=b}}function h(){i.callbackProgress({totalModels:y,totalTextures:K,loadedModels:y-D,loadedTextures:K-I},C);i.onLoadProgress();0==D&&0==I&&b(C)}var i=this,k=THREE.Loader.prototype.extractUrlbase(c),j,q,l,n,r,m,p,o,s,t,u,v,w,z,x,A,F,E,J,G,B,H,D,I,y,K,C;B=a;c=new THREE.BinaryLoader;H=new THREE.JSONLoader;I=D=0;C={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},
+empties:{}};a=!1;for(l in B.objects)if(o=B.objects[l],o.meshCollider){a=!0;break}if(a)C.scene.collisions=new THREE.CollisionSystem;if(B.transform)a=B.transform.position,s=B.transform.rotation,x=B.transform.scale,a&&C.scene.position.set(a[0],a[1],a[2]),s&&C.scene.rotation.set(s[0],s[1],s[2]),x&&C.scene.scale.set(x[0],x[1],x[2]),(a||s||x)&&C.scene.updateMatrix();a=function(){I-=1;h();i.onLoadComplete()};for(r in B.cameras)x=B.cameras[r],"perspective"==x.type?J=new THREE.PerspectiveCamera(x.fov,x.aspect,
 x.near,x.far):"ortho"==x.type&&(J=new THREE.OrthographicCamera(x.left,x.right,x.top,x.bottom,x.near,x.far)),u=x.position,s=x.target,x=x.up,J.position.set(u[0],u[1],u[2]),J.target=new THREE.Vector3(s[0],s[1],s[2]),x&&J.up.set(x[0],x[1],x[2]),C.cameras[r]=J;for(n in B.lights)s=B.lights[n],r=void 0!==s.color?s.color:16777215,J=void 0!==s.intensity?s.intensity:1,"directional"==s.type?(u=s.direction,t=new THREE.DirectionalLight(r,J),t.position.set(u[0],u[1],u[2]),t.position.normalize()):"point"==s.type?
 (u=s.position,t=s.distance,t=new THREE.PointLight(r,J,t),t.position.set(u[0],u[1],u[2])):"ambient"==s.type&&(t=new THREE.AmbientLight(r)),C.scene.add(t),C.lights[n]=t;for(m in B.fogs)n=B.fogs[m],"linear"==n.type?G=new THREE.Fog(0,n.near,n.far):"exp2"==n.type&&(G=new THREE.FogExp2(0,n.density)),x=n.color,G.color.setRGB(x[0],x[1],x[2]),C.fogs[m]=G;if(C.cameras&&B.defaults.camera)C.currentCamera=C.cameras[B.defaults.camera];if(C.fogs&&B.defaults.fog)C.scene.fog=C.fogs[B.defaults.fog];x=B.defaults.bgcolor;
 C.bgColor=new THREE.Color;C.bgColor.setRGB(x[0],x[1],x[2]);C.bgColorAlpha=B.defaults.bgalpha;for(j in B.geometries)if(m=B.geometries[j],"bin_mesh"==m.type||"ascii_mesh"==m.type)D+=1,i.onLoadStart();y=D;for(j in B.geometries)if(m=B.geometries[j],"cube"==m.type)F=new THREE.CubeGeometry(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,m.sides),C.geometries[j]=F;else if("plane"==m.type)F=new THREE.PlaneGeometry(m.width,m.height,m.segmentsWidth,m.segmentsHeight),
 C.geometries[j]=F;else if("sphere"==m.type)F=new THREE.SphereGeometry(m.radius,m.segmentsWidth,m.segmentsHeight),C.geometries[j]=F;else if("cylinder"==m.type)F=new THREE.CylinderGeometry(m.topRad,m.botRad,m.height,m.radSegs,m.heightSegs),C.geometries[j]=F;else if("torus"==m.type)F=new THREE.TorusGeometry(m.radius,m.tube,m.segmentsR,m.segmentsT),C.geometries[j]=F;else if("icosahedron"==m.type)F=new THREE.IcosahedronGeometry(m.radius,m.subdivisions),C.geometries[j]=F;else if("bin_mesh"==m.type)c.load(d(m.url,
-B.urlBaseType),g(j));else if("ascii_mesh"==m.type)H.load(d(m.url,B.urlBaseType),g(j));else if("embedded_mesh"==m.type)m=B.embeds[m.id],m.metadata=B.metadata,m&&H.createModel(m,e(j),"");for(o in B.textures)if(j=B.textures[o],j.url instanceof Array){I+=j.url.length;for(m=0;m<j.url.length;m++)i.onLoadStart()}else I+=1,i.onLoadStart();K=I;for(o in B.textures){j=B.textures[o];if(void 0!=j.mapping&&void 0!=THREE[j.mapping])j.mapping=new THREE[j.mapping];if(j.url instanceof Array){m=[];for(G=0;G<j.url.length;G++)m[G]=
+B.urlBaseType),g(j));else if("ascii_mesh"==m.type)H.load(d(m.url,B.urlBaseType),g(j));else if("embedded_mesh"==m.type)m=B.embeds[m.id],m.metadata=B.metadata,m&&H.createModel(m,e(j),"");for(p in B.textures)if(j=B.textures[p],j.url instanceof Array){I+=j.url.length;for(m=0;m<j.url.length;m++)i.onLoadStart()}else I+=1,i.onLoadStart();K=I;for(p in B.textures){j=B.textures[p];if(void 0!=j.mapping&&void 0!=THREE[j.mapping])j.mapping=new THREE[j.mapping];if(j.url instanceof Array){m=[];for(G=0;G<j.url.length;G++)m[G]=
 d(j.url[G],B.urlBaseType);m=THREE.ImageUtils.loadTextureCube(m,j.mapping,a)}else{m=THREE.ImageUtils.loadTexture(d(j.url,B.urlBaseType),j.mapping,a);if(void 0!=THREE[j.minFilter])m.minFilter=THREE[j.minFilter];if(void 0!=THREE[j.magFilter])m.magFilter=THREE[j.magFilter];if(j.repeat){m.repeat.set(j.repeat[0],j.repeat[1]);if(1!=j.repeat[0])m.wrapS=THREE.RepeatWrapping;if(1!=j.repeat[1])m.wrapT=THREE.RepeatWrapping}j.offset&&m.offset.set(j.offset[0],j.offset[1]);if(j.wrap){G={repeat:THREE.RepeatWrapping,
-mirror:THREE.MirroredRepeatWrapping};if(void 0!==G[j.wrap[0]])m.wrapS=G[j.wrap[0]];if(void 0!==G[j.wrap[1]])m.wrapT=G[j.wrap[1]]}}C.textures[o]=m}for(q in B.materials){o=B.materials[q];for(A in o.parameters)if("envMap"==A||"map"==A||"lightMap"==A)o.parameters[A]=C.textures[o.parameters[A]];else if("shading"==A)o.parameters[A]="flat"==o.parameters[A]?THREE.FlatShading:THREE.SmoothShading;else if("blending"==A)o.parameters[A]=THREE[o.parameters[A]]?THREE[o.parameters[A]]:THREE.NormalBlending;else if("combine"==
-A)o.parameters[A]="MixOperation"==o.parameters[A]?THREE.MixOperation:THREE.MultiplyOperation;else if("vertexColors"==A)if("face"==o.parameters[A])o.parameters[A]=THREE.FaceColors;else if(o.parameters[A])o.parameters[A]=THREE.VertexColors;if(void 0!==o.parameters.opacity&&1>o.parameters.opacity)o.parameters.transparent=!0;if(o.parameters.normalMap){j=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(j.uniforms);m=o.parameters.color;G=o.parameters.specular;c=o.parameters.ambient;H=o.parameters.shininess;
-a.tNormal.texture=C.textures[o.parameters.normalMap];if(o.parameters.normalMapFactor)a.uNormalScale.value=o.parameters.normalMapFactor;if(o.parameters.map)a.tDiffuse.texture=o.parameters.map,a.enableDiffuse.value=!0;if(o.parameters.lightMap)a.tAO.texture=o.parameters.lightMap,a.enableAO.value=!0;if(o.parameters.specularMap)a.tSpecular.texture=C.textures[o.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(m);a.uSpecularColor.value.setHex(G);a.uAmbientColor.value.setHex(c);
-a.uShininess.value=H;if(o.parameters.opacity)a.uOpacity.value=o.parameters.opacity;E=new THREE.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:a,lights:!0,fog:!0})}else E=new THREE[o.type](o.parameters);C.materials[q]=E}f();i.callbackSync(C);h()};THREE.UTF8Loader=function(){};THREE.UTF8Loader.prototype=new THREE.UTF8Loader;THREE.UTF8Loader.prototype.constructor=THREE.UTF8Loader;
+mirror:THREE.MirroredRepeatWrapping};if(void 0!==G[j.wrap[0]])m.wrapS=G[j.wrap[0]];if(void 0!==G[j.wrap[1]])m.wrapT=G[j.wrap[1]]}}C.textures[p]=m}for(q in B.materials){p=B.materials[q];for(A in p.parameters)if("envMap"==A||"map"==A||"lightMap"==A)p.parameters[A]=C.textures[p.parameters[A]];else if("shading"==A)p.parameters[A]="flat"==p.parameters[A]?THREE.FlatShading:THREE.SmoothShading;else if("blending"==A)p.parameters[A]=THREE[p.parameters[A]]?THREE[p.parameters[A]]:THREE.NormalBlending;else if("combine"==
+A)p.parameters[A]="MixOperation"==p.parameters[A]?THREE.MixOperation:THREE.MultiplyOperation;else if("vertexColors"==A)if("face"==p.parameters[A])p.parameters[A]=THREE.FaceColors;else if(p.parameters[A])p.parameters[A]=THREE.VertexColors;if(void 0!==p.parameters.opacity&&1>p.parameters.opacity)p.parameters.transparent=!0;if(p.parameters.normalMap){j=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(j.uniforms);m=p.parameters.color;G=p.parameters.specular;c=p.parameters.ambient;H=p.parameters.shininess;
+a.tNormal.texture=C.textures[p.parameters.normalMap];if(p.parameters.normalMapFactor)a.uNormalScale.value=p.parameters.normalMapFactor;if(p.parameters.map)a.tDiffuse.texture=p.parameters.map,a.enableDiffuse.value=!0;if(p.parameters.lightMap)a.tAO.texture=p.parameters.lightMap,a.enableAO.value=!0;if(p.parameters.specularMap)a.tSpecular.texture=C.textures[p.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(m);a.uSpecularColor.value.setHex(G);a.uAmbientColor.value.setHex(c);
+a.uShininess.value=H;if(p.parameters.opacity)a.uOpacity.value=p.parameters.opacity;E=new THREE.ShaderMaterial({fragmentShader:j.fragmentShader,vertexShader:j.vertexShader,uniforms:a,lights:!0,fog:!0})}else E=new THREE[p.type](p.parameters);C.materials[q]=E}f();i.callbackSync(C);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,f=void 0!==c.scale?c.scale:1,g=void 0!==c.offsetX?c.offsetX:0,e=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,f,g,e,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,f=0;8>f;f++){for(var g=0,e=0;e<b;++e){var h=a.charCodeAt(e+d),g=g+(h>>1^-(h&1));c[8*e+f]=g}d+=b}b=a.length-d;g=new Uint16Array(b);for(f=e=0;f<b;f++)h=a.charCodeAt(f+d),g[f]=e-h,0==h&&e++;return[c,g]};
-THREE.UTF8Loader.prototype.createModel=function(a,b,c,d,f,g){var e=function(){var b=this;b.materials=[];THREE.Geometry.call(this);var e=THREE.UTF8Loader.prototype.decompressMesh(a),k=[],j=[];(function(a,e,i){for(var j,k,o,p=a.length;i<p;i+=e)j=a[i],k=a[i+1],o=a[i+2],j=j/16383*c,k=k/16383*c,o=o/16383*c,j+=d,k+=f,o+=g,b.vertices.push(new THREE.Vertex(new THREE.Vector3(j,k,o)))})(e[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,j.push(d,1-e)})(e[0],8,3);(function(a,
+THREE.UTF8Loader.prototype.createModel=function(a,b,c,d,f,g){var e=function(){var b=this;b.materials=[];THREE.Geometry.call(this);var e=THREE.UTF8Loader.prototype.decompressMesh(a),k=[],j=[];(function(a,e,i){for(var j,k,p,o=a.length;i<o;i+=e)j=a[i],k=a[i+1],p=a[i+2],j=j/16383*c,k=k/16383*c,p=p/16383*c,j+=d,k+=f,p+=g,b.vertices.push(new THREE.Vertex(new THREE.Vector3(j,k,p)))})(e[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,j.push(d,1-e)})(e[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,k.push(d,e,f)})(e[0],8,5);(function(a){var c,d,e,f,g,i,s,t,u,v=a.length;for(c=0;c<v;c+=3){d=a[c];e=a[c+1];f=a[c+2];g=b;t=d;u=e;i=f;var w=k[3*e],z=k[3*e+1],x=k[3*e+2],A=k[3*f],F=k[3*f+1],E=k[3*f+2];s=new THREE.Vector3(k[3*d],k[3*d+1],k[3*d+2]);w=new THREE.Vector3(w,z,x);A=new THREE.Vector3(A,F,E);g.faces.push(new THREE.Face3(t,u,i,[s,w,A],null,0));g=j[2*d];d=j[2*d+1];i=j[2*e];s=j[2*e+1];t=j[2*
 f];u=j[2*f+1];f=b.faceVertexUvs[0];e=i;i=s;s=[];s.push(new THREE.UV(g,d));s.push(new THREE.UV(e,i));s.push(new THREE.UV(t,u));f.push(s)}})(e[1]);this.computeCentroids();this.computeFaceNormals()};e.prototype=new THREE.Geometry;e.prototype.constructor=e;b(new e)};
 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,f){return a+(b-a)*f};this.VIntX=function(a,b,f,g,e,h,i,k,j,q){e=(e-j)/(q-j);j=this.normal_cache;b[g]=h+e*this.delta;b[g+1]=i;b[g+2]=k;f[g]=this.lerp(j[a],j[a+3],e);f[g+1]=this.lerp(j[a+1],j[a+4],e);f[g+2]=this.lerp(j[a+2],j[a+5],e)};this.VIntY=function(a,b,f,g,e,h,i,k,j,q){e=(e-j)/(q-j);j=this.normal_cache;b[g]=h;b[g+1]=i+e*this.delta;b[g+2]=k;b=a+3*this.yd;
 f[g]=this.lerp(j[a],j[b],e);f[g+1]=this.lerp(j[a+1],j[b+1],e);f[g+2]=this.lerp(j[a+2],j[b+2],e)};this.VIntZ=function(a,b,f,g,e,h,i,k,j,q){e=(e-j)/(q-j);j=this.normal_cache;b[g]=h;b[g+1]=i;b[g+2]=k+e*this.delta;b=a+3*this.zd;f[g]=this.lerp(j[a],j[b],e);f[g+1]=this.lerp(j[a+1],j[b+1],e);f[g+2]=this.lerp(j[a+2],j[b+2],e)};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,f,g,e,h){var i=g+1,k=g+this.yd,j=g+this.zd,q=i+this.yd,l=i+this.zd,n=g+this.yd+this.zd,r=i+this.yd+this.zd,m=0,o=this.field[g],p=this.field[i],s=this.field[k],t=this.field[q],u=this.field[j],v=this.field[l],w=this.field[n],z=this.field[r];o<e&&(m|=1);p<e&&(m|=2);s<e&&(m|=8);t<e&&(m|=4);u<e&&(m|=16);v<e&&(m|=32);w<e&&(m|=128);z<e&&(m|=64);var x=THREE.edgeTable[m];if(0===x)return 0;var A=this.delta,F=a+
-A,E=b+A,A=f+A;x&1&&(this.compNorm(g),this.compNorm(i),this.VIntX(3*g,this.vlist,this.nlist,0,e,a,b,f,o,p));x&2&&(this.compNorm(i),this.compNorm(q),this.VIntY(3*i,this.vlist,this.nlist,3,e,F,b,f,p,t));x&4&&(this.compNorm(k),this.compNorm(q),this.VIntX(3*k,this.vlist,this.nlist,6,e,a,E,f,s,t));x&8&&(this.compNorm(g),this.compNorm(k),this.VIntY(3*g,this.vlist,this.nlist,9,e,a,b,f,o,s));x&16&&(this.compNorm(j),this.compNorm(l),this.VIntX(3*j,this.vlist,this.nlist,12,e,a,b,A,u,v));x&32&&(this.compNorm(l),
-this.compNorm(r),this.VIntY(3*l,this.vlist,this.nlist,15,e,F,b,A,v,z));x&64&&(this.compNorm(n),this.compNorm(r),this.VIntX(3*n,this.vlist,this.nlist,18,e,a,E,A,w,z));x&128&&(this.compNorm(j),this.compNorm(n),this.VIntY(3*j,this.vlist,this.nlist,21,e,a,b,A,u,w));x&256&&(this.compNorm(g),this.compNorm(j),this.VIntZ(3*g,this.vlist,this.nlist,24,e,a,b,f,o,u));x&512&&(this.compNorm(i),this.compNorm(l),this.VIntZ(3*i,this.vlist,this.nlist,27,e,F,b,f,p,v));x&1024&&(this.compNorm(q),this.compNorm(r),this.VIntZ(3*
+this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,f,g,e,h){var i=g+1,k=g+this.yd,j=g+this.zd,q=i+this.yd,l=i+this.zd,n=g+this.yd+this.zd,r=i+this.yd+this.zd,m=0,p=this.field[g],o=this.field[i],s=this.field[k],t=this.field[q],u=this.field[j],v=this.field[l],w=this.field[n],z=this.field[r];p<e&&(m|=1);o<e&&(m|=2);s<e&&(m|=8);t<e&&(m|=4);u<e&&(m|=16);v<e&&(m|=32);w<e&&(m|=128);z<e&&(m|=64);var x=THREE.edgeTable[m];if(0===x)return 0;var A=this.delta,F=a+
+A,E=b+A,A=f+A;x&1&&(this.compNorm(g),this.compNorm(i),this.VIntX(3*g,this.vlist,this.nlist,0,e,a,b,f,p,o));x&2&&(this.compNorm(i),this.compNorm(q),this.VIntY(3*i,this.vlist,this.nlist,3,e,F,b,f,o,t));x&4&&(this.compNorm(k),this.compNorm(q),this.VIntX(3*k,this.vlist,this.nlist,6,e,a,E,f,s,t));x&8&&(this.compNorm(g),this.compNorm(k),this.VIntY(3*g,this.vlist,this.nlist,9,e,a,b,f,p,s));x&16&&(this.compNorm(j),this.compNorm(l),this.VIntX(3*j,this.vlist,this.nlist,12,e,a,b,A,u,v));x&32&&(this.compNorm(l),
+this.compNorm(r),this.VIntY(3*l,this.vlist,this.nlist,15,e,F,b,A,v,z));x&64&&(this.compNorm(n),this.compNorm(r),this.VIntX(3*n,this.vlist,this.nlist,18,e,a,E,A,w,z));x&128&&(this.compNorm(j),this.compNorm(n),this.VIntY(3*j,this.vlist,this.nlist,21,e,a,b,A,u,w));x&256&&(this.compNorm(g),this.compNorm(j),this.VIntZ(3*g,this.vlist,this.nlist,24,e,a,b,f,p,u));x&512&&(this.compNorm(i),this.compNorm(l),this.VIntZ(3*i,this.vlist,this.nlist,27,e,F,b,f,o,v));x&1024&&(this.compNorm(q),this.compNorm(r),this.VIntZ(3*
 q,this.vlist,this.nlist,30,e,F,E,f,t,z));x&2048&&(this.compNorm(k),this.compNorm(n),this.VIntZ(3*k,this.vlist,this.nlist,33,e,a,E,f,s,w));m<<=4;for(e=g=0;-1!=THREE.triTable[m+e];)a=m+e,b=a+1,f=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[f],h),e+=3,g++;return g};this.posnormtriv=function(a,b,f,g,e,h){var i=3*this.count;this.positionArray[i]=a[f];this.positionArray[i+1]=a[f+1];this.positionArray[i+2]=a[f+2];this.positionArray[i+3]=a[g];this.positionArray[i+
 4]=a[g+1];this.positionArray[i+5]=a[g+2];this.positionArray[i+6]=a[e];this.positionArray[i+7]=a[e+1];this.positionArray[i+8]=a[e+2];this.normalArray[i]=b[f];this.normalArray[i+1]=b[f+1];this.normalArray[i+2]=b[f+2];this.normalArray[i+3]=b[g];this.normalArray[i+4]=b[g+1];this.normalArray[i+5]=b[g+2];this.normalArray[i+6]=b[e];this.normalArray[i+7]=b[e+1];this.normalArray[i+8]=b[e+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,f,g,e){var h=this.size*Math.sqrt(g/e),i=f*this.size,k=b*this.size,j=a*this.size,q=Math.floor(i-h);1>q&&(q=1);i=Math.floor(i+h);i>this.size-1&&(i=this.size-1);var l=Math.floor(k-h);1>l&&(l=1);k=Math.floor(k+h);k>this.size-1&&(k=this.size-1);var n=Math.floor(j-h);1>n&&(n=1);h=Math.floor(j+h);h>this.size-1&&(h=this.size-
-1);for(var r,m,o,p,s,t,u,j=q;j<i;j++){o=this.size2*j;s=j/this.size-f;t=s*s;for(q=l;q<k;q++){m=o+this.size*q;r=q/this.size-b;u=r*r;for(r=n;r<h;r++)p=r/this.size-a,p=g/(1.0E-6+p*p+u+t)-e,0<p&&(this.field[m+r]+=p)}}};this.addPlaneX=function(a,b){var f,g,e,h,i,k=this.size,j=this.yd,q=this.zd,l=this.field,n=k*Math.sqrt(a/b);n>k&&(n=k);for(f=0;f<n;f++)if(g=f/k,g*=g,h=a/(1.0E-4+g)-b,0<h)for(g=0;g<k;g++){i=f+g*j;for(e=0;e<k;e++)l[q*e+i]+=h}};this.addPlaneY=function(a,b){var f,g,e,h,i,k,j=this.size,q=this.yd,
+1);for(var r,m,p,o,s,t,u,j=q;j<i;j++){p=this.size2*j;s=j/this.size-f;t=s*s;for(q=l;q<k;q++){m=p+this.size*q;r=q/this.size-b;u=r*r;for(r=n;r<h;r++)o=r/this.size-a,o=g/(1.0E-6+o*o+u+t)-e,0<o&&(this.field[m+r]+=o)}}};this.addPlaneX=function(a,b){var f,g,e,h,i,k=this.size,j=this.yd,q=this.zd,l=this.field,n=k*Math.sqrt(a/b);n>k&&(n=k);for(f=0;f<n;f++)if(g=f/k,g*=g,h=a/(1.0E-4+g)-b,0<h)for(g=0;g<k;g++){i=f+g*j;for(e=0;e<k;e++)l[q*e+i]+=h}};this.addPlaneY=function(a,b){var f,g,e,h,i,k,j=this.size,q=this.yd,
 l=this.zd,n=this.field,r=j*Math.sqrt(a/b);r>j&&(r=j);for(g=0;g<r;g++)if(f=g/j,f*=f,h=a/(1.0E-4+f)-b,0<h){i=g*q;for(f=0;f<j;f++){k=i+f;for(e=0;e<j;e++)n[l*e+k]+=h}}};this.addPlaneZ=function(a,b){var f,g,e,h,i,k,j=this.size,q=this.yd,l=this.zd,n=this.field,r=j*Math.sqrt(a/b);r>j&&(r=j);for(e=0;e<r;e++)if(f=e/j,f*=f,h=a/(1.0E-4+f)-b,0<h){i=l*e;for(g=0;g<j;g++){k=i+g*q;for(f=0;f<j;f++)n[k+f]+=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,f,g,e,h,i,k,j,q,l=this.size-2;for(e=1;e<l;e++){q=this.size2*e;k=(e-this.halfsize)/this.halfsize;for(g=1;g<l;g++){j=q+this.size*g;i=(g-this.halfsize)/this.halfsize;for(f=1;f<l;f++)h=(f-this.halfsize)/this.halfsize,b=j+f,this.polygonize(h,i,k,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,f=[];this.render(function(g){var e,h,i,k,j,q,l,n;for(e=0;e<g.count;e++)l=3*e,j=l+1,n=l+2,h=g.positionArray[l],i=g.positionArray[j],k=
 g.positionArray[n],q=new THREE.Vector3(h,i,k),h=g.normalArray[l],i=g.normalArray[j],k=g.normalArray[n],l=new THREE.Vector3(h,i,k),l.normalize(),j=new THREE.Vertex(q),b.vertices.push(j),f.push(l);q=g.count/3;for(e=0;e<q;e++)l=3*(a+e),j=l+1,n=l+2,h=f[l],i=f[j],k=f[n],l=new THREE.Face3(l,j,n,[h,i,k]),b.faces.push(l);a+=q;g.count=0});return b};this.init(a)};THREE.MarchingCubes.prototype=new THREE.Object3D;THREE.MarchingCubes.prototype.constructor=THREE.MarchingCubes;
@@ -385,30 +384,30 @@ THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.creat
 0;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]=0;d[r++]=1;r=0;f[r++]=0;f[r++]=1;f[r++]=2;f[r++]=0;f[r++]=2;f[r++]=3;g=b.createBuffer();e=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,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)?(k=!1,j=a(THREE.ShaderFlares.lensFlare)):(k=!0,j=a(THREE.ShaderFlares.lensFlareVertexTexture));q={};l={};q.vertex=b.getAttribLocation(j,"position");q.uv=b.getAttribLocation(j,"uv");l.renderType=b.getUniformLocation(j,"renderType");l.map=b.getUniformLocation(j,"map");l.occlusionMap=b.getUniformLocation(j,"occlusionMap");l.opacity=b.getUniformLocation(j,"opacity");l.color=b.getUniformLocation(j,
-"color");l.scale=b.getUniformLocation(j,"scale");l.rotation=b.getUniformLocation(j,"rotation");l.screenPosition=b.getUniformLocation(j,"screenPosition");n=!1};this.render=function(a,d,f,p){var a=a.__webglFlares,s=a.length;if(s){var t=new THREE.Vector3,u=p/f,v=0.5*f,w=0.5*p,z=16/p,x=new THREE.Vector2(z*u,z),A=new THREE.Vector3(1,1,0),F=new THREE.Vector2(1,1),E=l,z=q;b.useProgram(j);n||(b.enableVertexAttribArray(q.vertex),b.enableVertexAttribArray(q.uv),n=!0);b.uniform1i(E.occlusionMap,0);b.uniform1i(E.map,
-1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(z.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(z.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e);b.disable(b.CULL_FACE);b.depthMask(!1);var J,G,B,H,D;for(J=0;J<s;J++)if(z=16/p,x.set(z*u,z),H=a[J],t.set(H.matrixWorld.n14,H.matrixWorld.n24,H.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(t),d.projectionMatrix.multiplyVector3(t),A.copy(t),F.x=A.x*v+v,F.y=A.y*w+w,k||0<F.x&&F.x<f&&0<F.y&&F.y<p){b.activeTexture(b.TEXTURE1);b.bindTexture(b.TEXTURE_2D,
+"color");l.scale=b.getUniformLocation(j,"scale");l.rotation=b.getUniformLocation(j,"rotation");l.screenPosition=b.getUniformLocation(j,"screenPosition");n=!1};this.render=function(a,d,f,o){var a=a.__webglFlares,s=a.length;if(s){var t=new THREE.Vector3,u=o/f,v=0.5*f,w=0.5*o,z=16/o,x=new THREE.Vector2(z*u,z),A=new THREE.Vector3(1,1,0),F=new THREE.Vector2(1,1),E=l,z=q;b.useProgram(j);n||(b.enableVertexAttribArray(q.vertex),b.enableVertexAttribArray(q.uv),n=!0);b.uniform1i(E.occlusionMap,0);b.uniform1i(E.map,
+1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(z.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(z.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e);b.disable(b.CULL_FACE);b.depthMask(!1);var J,G,B,H,D;for(J=0;J<s;J++)if(z=16/o,x.set(z*u,z),H=a[J],t.set(H.matrixWorld.n14,H.matrixWorld.n24,H.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(t),d.projectionMatrix.multiplyVector3(t),A.copy(t),F.x=A.x*v+v,F.y=A.y*w+w,k||0<F.x&&F.x<f&&0<F.y&&F.y<o){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(E.renderType,0);b.uniform2f(E.scale,x.x,x.y);b.uniform3f(E.screenPosition,A.x,A.y,A.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(E.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);H.positionScreen.copy(A);H.customUpdateCallback?H.customUpdateCallback(H):H.updateLensFlares();b.uniform1i(E.renderType,2);b.enable(b.BLEND);for(G=0,B=H.lensFlares.length;G<B;G++)if(D=H.lensFlares[G],0.0010<D.opacity&&0.0010<D.scale)A.x=D.x,A.y=D.y,A.z=D.z,z=D.size*D.scale/p,x.x=z*u,x.y=z,b.uniform3f(E.screenPosition,A.x,A.y,A.z),b.uniform2f(E.scale,x.x,x.y),b.uniform1f(E.rotation,D.rotation),b.uniform1f(E.opacity,D.opacity),b.uniform3f(E.color,D.color.r,D.color.g,D.color.b),
+6,b.UNSIGNED_SHORT,0);H.positionScreen.copy(A);H.customUpdateCallback?H.customUpdateCallback(H):H.updateLensFlares();b.uniform1i(E.renderType,2);b.enable(b.BLEND);for(G=0,B=H.lensFlares.length;G<B;G++)if(D=H.lensFlares[G],0.0010<D.opacity&&0.0010<D.scale)A.x=D.x,A.y=D.y,A.z=D.z,z=D.size*D.scale/o,x.x=z*u,x.y=z,b.uniform3f(E.screenPosition,A.x,A.y,A.z),b.uniform2f(E.scale,x.x,x.y),b.uniform1f(E.rotation,D.rotation),b.uniform1f(E.opacity,D.opacity),b.uniform3f(E.color,D.color.r,D.color.g,D.color.b),
 c.setBlending(D.blending),c.setTexture(D.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,f=new THREE.Frustum,g=new THREE.Matrix4,e=new THREE.Vector3,h=new THREE.Vector3;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,f=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:f,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render=function(a,
-c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(i,k){var j,q,l,n,r,m,o,p,s,t=[];n=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(j=0,q=i.lights.length;j<q;j++)if(l=i.lights[j],l.castShadow)if(l instanceof THREE.DirectionalLight&&l.shadowCascade)for(r=0;r<l.shadowCascadeCount;r++){var u;if(l.shadowCascadeArray[r])u=l.shadowCascadeArray[r];else{s=l;o=r;u=new THREE.DirectionalLight;u.isVirtual=!0;u.onlyShadow=
-!0;u.castShadow=!0;u.shadowCameraNear=s.shadowCameraNear;u.shadowCameraFar=s.shadowCameraFar;u.shadowCameraLeft=s.shadowCameraLeft;u.shadowCameraRight=s.shadowCameraRight;u.shadowCameraBottom=s.shadowCameraBottom;u.shadowCameraTop=s.shadowCameraTop;u.shadowCameraVisible=s.shadowCameraVisible;u.shadowDarkness=s.shadowDarkness;u.shadowBias=s.shadowCascadeBias[o];u.shadowMapWidth=s.shadowCascadeWidth[o];u.shadowMapHeight=s.shadowCascadeHeight[o];u.pointsWorld=[];u.pointsFrustum=[];p=u.pointsWorld;m=
-u.pointsFrustum;for(var v=0;8>v;v++)p[v]=new THREE.Vector3,m[v]=new THREE.Vector3;p=s.shadowCascadeNearZ[o];s=s.shadowCascadeFarZ[o];m[0].set(-1,-1,p);m[1].set(1,-1,p);m[2].set(-1,1,p);m[3].set(1,1,p);m[4].set(-1,-1,s);m[5].set(1,-1,s);m[6].set(-1,1,s);m[7].set(1,1,s);u.originalCamera=k;m=new THREE.Gyroscope;m.position=l.shadowCascadeOffset;m.add(u);m.add(u.target);k.add(m);l.shadowCascadeArray[r]=u;console.log("Created virtualLight",u)}o=l;p=r;s=o.shadowCascadeArray[p];s.position.copy(o.position);
-s.target.position.copy(o.target.position);s.lookAt(s.target);s.shadowCameraVisible=o.shadowCameraVisible;s.shadowDarkness=o.shadowDarkness;s.shadowBias=o.shadowCascadeBias[p];m=o.shadowCascadeNearZ[p];o=o.shadowCascadeFarZ[p];s=s.pointsFrustum;s[0].z=m;s[1].z=m;s[2].z=m;s[3].z=m;s[4].z=o;s[5].z=o;s[6].z=o;s[7].z=o;t[n]=u;n++}else t[n]=l,n++;for(j=0,q=t.length;j<q;j++){l=t[j];if(!l.shadowMap)l.shadowMap=new THREE.WebGLRenderTarget(l.shadowMapWidth,l.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
+c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(i,k){var j,q,l,n,r,m,p,o,s,t=[];n=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(j=0,q=i.lights.length;j<q;j++)if(l=i.lights[j],l.castShadow)if(l instanceof THREE.DirectionalLight&&l.shadowCascade)for(r=0;r<l.shadowCascadeCount;r++){var u;if(l.shadowCascadeArray[r])u=l.shadowCascadeArray[r];else{s=l;p=r;u=new THREE.DirectionalLight;u.isVirtual=!0;u.onlyShadow=
+!0;u.castShadow=!0;u.shadowCameraNear=s.shadowCameraNear;u.shadowCameraFar=s.shadowCameraFar;u.shadowCameraLeft=s.shadowCameraLeft;u.shadowCameraRight=s.shadowCameraRight;u.shadowCameraBottom=s.shadowCameraBottom;u.shadowCameraTop=s.shadowCameraTop;u.shadowCameraVisible=s.shadowCameraVisible;u.shadowDarkness=s.shadowDarkness;u.shadowBias=s.shadowCascadeBias[p];u.shadowMapWidth=s.shadowCascadeWidth[p];u.shadowMapHeight=s.shadowCascadeHeight[p];u.pointsWorld=[];u.pointsFrustum=[];o=u.pointsWorld;m=
+u.pointsFrustum;for(var v=0;8>v;v++)o[v]=new THREE.Vector3,m[v]=new THREE.Vector3;o=s.shadowCascadeNearZ[p];s=s.shadowCascadeFarZ[p];m[0].set(-1,-1,o);m[1].set(1,-1,o);m[2].set(-1,1,o);m[3].set(1,1,o);m[4].set(-1,-1,s);m[5].set(1,-1,s);m[6].set(-1,1,s);m[7].set(1,1,s);u.originalCamera=k;m=new THREE.Gyroscope;m.position=l.shadowCascadeOffset;m.add(u);m.add(u.target);k.add(m);l.shadowCascadeArray[r]=u;console.log("Created virtualLight",u)}p=l;o=r;s=p.shadowCascadeArray[o];s.position.copy(p.position);
+s.target.position.copy(p.target.position);s.lookAt(s.target);s.shadowCameraVisible=p.shadowCameraVisible;s.shadowDarkness=p.shadowDarkness;s.shadowBias=p.shadowCascadeBias[o];m=p.shadowCascadeNearZ[o];p=p.shadowCascadeFarZ[o];s=s.pointsFrustum;s[0].z=m;s[1].z=m;s[2].z=m;s[3].z=m;s[4].z=p;s[5].z=p;s[6].z=p;s[7].z=p;t[n]=u;n++}else t[n]=l,n++;for(j=0,q=t.length;j<q;j++){l=t[j];if(!l.shadowMap)l.shadowMap=new THREE.WebGLRenderTarget(l.shadowMapWidth,l.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
 format:THREE.RGBAFormat}),l.shadowMapSize=new THREE.Vector2(l.shadowMapWidth,l.shadowMapHeight),l.shadowMatrix=new THREE.Matrix4;if(!l.shadowCamera){if(l instanceof THREE.SpotLight)l.shadowCamera=new THREE.PerspectiveCamera(l.shadowCameraFov,l.shadowMapWidth/l.shadowMapHeight,l.shadowCameraNear,l.shadowCameraFar);else if(l instanceof THREE.DirectionalLight)l.shadowCamera=new THREE.OrthographicCamera(l.shadowCameraLeft,l.shadowCameraRight,l.shadowCameraTop,l.shadowCameraBottom,l.shadowCameraNear,l.shadowCameraFar);
-else{console.error("Unsupported light type for shadow");continue}i.add(l.shadowCamera);b.autoUpdateScene&&i.updateMatrixWorld()}if(l.shadowCameraVisible&&!l.cameraHelper)l.cameraHelper=new THREE.CameraHelper(l.shadowCamera),l.shadowCamera.add(l.cameraHelper);if(l.isVirtual&&u.originalCamera==k){r=k;n=l.shadowCamera;m=l.pointsFrustum;s=l.pointsWorld;e.set(Infinity,Infinity,Infinity);h.set(-Infinity,-Infinity,-Infinity);for(o=0;8>o;o++){p=s[o];p.copy(m[o]);THREE.ShadowMapPlugin.__projector.unprojectVector(p,
-r);n.matrixWorldInverse.multiplyVector3(p);if(p.x<e.x)e.x=p.x;if(p.x>h.x)h.x=p.x;if(p.y<e.y)e.y=p.y;if(p.y>h.y)h.y=p.y;if(p.z<e.z)e.z=p.z;if(p.z>h.z)h.z=p.z}n.left=e.x;n.right=h.x;n.top=h.y;n.bottom=e.y;n.updateProjectionMatrix()}n=l.shadowMap;m=l.shadowMatrix;r=l.shadowCamera;r.position.copy(l.matrixWorld.getPosition());r.lookAt(l.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld);if(l.cameraHelper)l.cameraHelper.lines.visible=l.shadowCameraVisible;
+else{console.error("Unsupported light type for shadow");continue}i.add(l.shadowCamera);b.autoUpdateScene&&i.updateMatrixWorld()}if(l.shadowCameraVisible&&!l.cameraHelper)l.cameraHelper=new THREE.CameraHelper(l.shadowCamera),l.shadowCamera.add(l.cameraHelper);if(l.isVirtual&&u.originalCamera==k){r=k;n=l.shadowCamera;m=l.pointsFrustum;s=l.pointsWorld;e.set(Infinity,Infinity,Infinity);h.set(-Infinity,-Infinity,-Infinity);for(p=0;8>p;p++){o=s[p];o.copy(m[p]);THREE.ShadowMapPlugin.__projector.unprojectVector(o,
+r);n.matrixWorldInverse.multiplyVector3(o);if(o.x<e.x)e.x=o.x;if(o.x>h.x)h.x=o.x;if(o.y<e.y)e.y=o.y;if(o.y>h.y)h.y=o.y;if(o.z<e.z)e.z=o.z;if(o.z>h.z)h.z=o.z}n.left=e.x;n.right=h.x;n.top=h.y;n.bottom=e.y;n.updateProjectionMatrix()}n=l.shadowMap;m=l.shadowMatrix;r=l.shadowCamera;r.position.copy(l.matrixWorld.getPosition());r.lookAt(l.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld);if(l.cameraHelper)l.cameraHelper.lines.visible=l.shadowCameraVisible;
 l.shadowCameraVisible&&l.cameraHelper.update(l.shadowCamera);m.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);m.multiplySelf(r.projectionMatrix);m.multiplySelf(r.matrixWorldInverse);if(!r._viewMatrixArray)r._viewMatrixArray=new Float32Array(16);r.matrixWorldInverse.flattenToArray(r._viewMatrixArray);if(!r._projectionMatrixArray)r._projectionMatrixArray=new Float32Array(16);r.projectionMatrix.flattenToArray(r._projectionMatrixArray);g.multiply(r.projectionMatrix,r.matrixWorldInverse);f.setFromMatrix(g);
-b.setRenderTarget(n);b.clear();s=i.__webglObjects;for(l=0,n=s.length;l<n;l++)if(o=s[l],m=o.object,o.render=!1,m.visible&&m.castShadow&&(!(m instanceof THREE.Mesh)||!m.frustumCulled||f.contains(m)))m.matrixWorld.flattenToArray(m._objectMatrixArray),m._modelViewMatrix.multiplyToArray(r.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray),o.render=!0;for(l=0,n=s.length;l<n;l++)if(o=s[l],o.render)m=o.object,o=o.buffer,b.setObjectFaces(m),p=m.customDepthMaterial?m.customDepthMaterial:m.geometry.morphTargets.length?
-d:c,o instanceof THREE.BufferGeometry?b.renderBufferDirect(r,i.lights,null,p,o,m):b.renderBuffer(r,i.lights,null,p,o,m);s=i.__webglObjectsImmediate;for(l=0,n=s.length;l<n;l++)o=s[l],m=o.object,m.visible&&m.castShadow&&(m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),m._modelViewMatrix.multiplyToArray(r.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray),b.renderImmediateObject(r,i.lights,null,c,m))}j=b.getClearColor();q=b.getClearAlpha();a.clearColor(j.r,j.g,j.b,q);a.enable(a.BLEND);
+b.setRenderTarget(n);b.clear();s=i.__webglObjects;for(l=0,n=s.length;l<n;l++)if(p=s[l],m=p.object,p.render=!1,m.visible&&m.castShadow&&(!(m instanceof THREE.Mesh)||!m.frustumCulled||f.contains(m)))m.matrixWorld.flattenToArray(m._objectMatrixArray),m._modelViewMatrix.multiplyToArray(r.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray),p.render=!0;for(l=0,n=s.length;l<n;l++)if(p=s[l],p.render)m=p.object,p=p.buffer,b.setObjectFaces(m),o=m.customDepthMaterial?m.customDepthMaterial:m.geometry.morphTargets.length?
+d:c,p instanceof THREE.BufferGeometry?b.renderBufferDirect(r,i.lights,null,o,p,m):b.renderBuffer(r,i.lights,null,o,p,m);s=i.__webglObjectsImmediate;for(l=0,n=s.length;l<n;l++)p=s[l],m=p.object,m.visible&&m.castShadow&&(m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),m._modelViewMatrix.multiplyToArray(r.matrixWorldInverse,m.matrixWorld,m._modelViewMatrixArray),b.renderImmediateObject(r,i.lights,null,c,m))}j=b.getClearColor();q=b.getClearAlpha();a.clearColor(j.r,j.g,j.b,q);a.enable(a.BLEND);
 b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;
 THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,f,g,e,h,i,k,j;this.init=function(a){b=a.context;c=a;d=new Float32Array(16);f=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;f[a++]=0;f[a++]=1;f[a++]=2;f[a++]=0;f[a++]=2;f[a++]=3;g=b.createBuffer();e=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
 e);b.bufferData(b.ELEMENT_ARRAY_BUFFER,f,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,l=b.createProgram(),n=b.createShader(b.FRAGMENT_SHADER),r=b.createShader(b.VERTEX_SHADER);b.shaderSource(n,a.fragmentShader);b.shaderSource(r,a.vertexShader);b.compileShader(n);b.compileShader(r);b.attachShader(l,n);b.attachShader(l,r);b.linkProgram(l);h=l;i={};k={};i.position=b.getAttribLocation(h,"position");i.uv=b.getAttribLocation(h,"uv");k.uvOffset=b.getUniformLocation(h,"uvOffset");k.uvScale=b.getUniformLocation(h,
 "uvScale");k.rotation=b.getUniformLocation(h,"rotation");k.scale=b.getUniformLocation(h,"scale");k.alignment=b.getUniformLocation(h,"alignment");k.color=b.getUniformLocation(h,"color");k.map=b.getUniformLocation(h,"map");k.opacity=b.getUniformLocation(h,"opacity");k.useScreenCoordinates=b.getUniformLocation(h,"useScreenCoordinates");k.affectedByDistance=b.getUniformLocation(h,"affectedByDistance");k.screenPosition=b.getUniformLocation(h,"screenPosition");k.modelViewMatrix=b.getUniformLocation(h,"modelViewMatrix");
-k.projectionMatrix=b.getUniformLocation(h,"projectionMatrix");j=!1};this.render=function(d,f,n,r){var d=d.__webglSprites,m=d.length;if(m){var o=i,p=k,s=r/n,n=0.5*n,t=0.5*r,u=!0;b.useProgram(h);j||(b.enableVertexAttribArray(o.position),b.enableVertexAttribArray(o.uv),j=!0);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(o.position,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(o.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e);b.uniformMatrix4fv(p.projectionMatrix,
-!1,f._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(p.map,0);for(var v,w=[],o=0;o<m;o++)if(v=d[o],v.visible&&0!==v.opacity)v.useScreenCoordinates?v.z=-v.position.z:(v._modelViewMatrix.multiplyToArray(f.matrixWorldInverse,v.matrixWorld,v._modelViewMatrixArray),v.z=-v._modelViewMatrix.n34);d.sort(a);for(o=0;o<m;o++)v=d[o],v.visible&&0!==v.opacity&&v.map&&v.map.image&&v.map.image.width&&(v.useScreenCoordinates?(b.uniform1i(p.useScreenCoordinates,1),b.uniform3f(p.screenPosition,(v.position.x-
-n)/n,(t-v.position.y)/t,Math.max(0,Math.min(1,v.position.z)))):(b.uniform1i(p.useScreenCoordinates,0),b.uniform1i(p.affectedByDistance,v.affectedByDistance?1:0),b.uniformMatrix4fv(p.modelViewMatrix,!1,v._modelViewMatrixArray)),f=v.map.image.width/(v.scaleByViewport?r:1),w[0]=f*s*v.scale.x,w[1]=f*v.scale.y,b.uniform2f(p.uvScale,v.uvScale.x,v.uvScale.y),b.uniform2f(p.uvOffset,v.uvOffset.x,v.uvOffset.y),b.uniform2f(p.alignment,v.alignment.x,v.alignment.y),b.uniform1f(p.opacity,v.opacity),b.uniform3f(p.color,
-v.color.r,v.color.g,v.color.b),b.uniform1f(p.rotation,v.rotation),b.uniform2fv(p.scale,w),v.mergeWith3D&&!u?(b.enable(b.DEPTH_TEST),u=!0):!v.mergeWith3D&&u&&(b.disable(b.DEPTH_TEST),u=!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)}}};
+k.projectionMatrix=b.getUniformLocation(h,"projectionMatrix");j=!1};this.render=function(d,f,n,r){var d=d.__webglSprites,m=d.length;if(m){var p=i,o=k,s=r/n,n=0.5*n,t=0.5*r,u=!0;b.useProgram(h);j||(b.enableVertexAttribArray(p.position),b.enableVertexAttribArray(p.uv),j=!0);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(p.position,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(p.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,e);b.uniformMatrix4fv(o.projectionMatrix,
+!1,f._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(o.map,0);for(var v,w=[],p=0;p<m;p++)if(v=d[p],v.visible&&0!==v.opacity)v.useScreenCoordinates?v.z=-v.position.z:(v._modelViewMatrix.multiplyToArray(f.matrixWorldInverse,v.matrixWorld,v._modelViewMatrixArray),v.z=-v._modelViewMatrix.n34);d.sort(a);for(p=0;p<m;p++)v=d[p],v.visible&&0!==v.opacity&&v.map&&v.map.image&&v.map.image.width&&(v.useScreenCoordinates?(b.uniform1i(o.useScreenCoordinates,1),b.uniform3f(o.screenPosition,(v.position.x-
+n)/n,(t-v.position.y)/t,Math.max(0,Math.min(1,v.position.z)))):(b.uniform1i(o.useScreenCoordinates,0),b.uniform1i(o.affectedByDistance,v.affectedByDistance?1:0),b.uniformMatrix4fv(o.modelViewMatrix,!1,v._modelViewMatrixArray)),f=v.map.image.width/(v.scaleByViewport?r:1),w[0]=f*s*v.scale.x,w[1]=f*v.scale.y,b.uniform2f(o.uvScale,v.uvScale.x,v.uvScale.y),b.uniform2f(o.uvOffset,v.uvOffset.x,v.uvOffset.y),b.uniform2f(o.alignment,v.alignment.x,v.alignment.y),b.uniform1f(o.opacity,v.opacity),b.uniform3f(o.color,
+v.color.r,v.color.g,v.color.b),b.uniform1f(o.rotation,v.rotation),b.uniform2fv(o.scale,w),v.mergeWith3D&&!u?(b.enable(b.DEPTH_TEST),u=!0):!v.mergeWith3D&&u&&(b.disable(b.DEPTH_TEST),u=!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,f=new THREE.PerspectiveCamera,g=new THREE.PerspectiveCamera,e=new THREE.Matrix4,h=new THREE.Matrix4,i,k,j,q;f.matrixAutoUpdate=g.matrixAutoUpdate=!1;var a={minFilter:THREE.LinearFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat},l=new THREE.WebGLRenderTarget(512,512,a),n=new THREE.WebGLRenderTarget(512,512,a),r=new THREE.PerspectiveCamera(53,
 1,1,1E4);r.position.z=2;var a=new THREE.ShaderMaterial({uniforms:{mapLeft:{type:"t",value:0,texture:l},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(r);this.setSize=function(a,d){c.call(b,a,d);l.width=a;l.height=d;n.width=a;n.height=d};this.render=function(a,c){a.updateMatrixWorld();if(i!==c.aspect||k!==c.near||j!==c.far||q!==c.fov){i=c.aspect;k=c.near;j=c.far;q=c.fov;var s=c.projectionMatrix.clone(),t=0.5*(125/30),u=t*k/125,v=k*Math.tan(q*Math.PI/360),w;e.n14=t;h.n14=-t;t=-v*i+u;w=v*i+u;s.n11=2*k/(w-t);s.n13=(w+t)/(w-t);f.projectionMatrix.copy(s);t=-v*i-u;w=v*i-u;s.n11=

+ 53 - 52
build/custom/ThreeSVG.js

@@ -18,66 +18,66 @@ this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;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){l.sub(c,a);q=l.dot(b);y=p.add(a,o.copy(b).multiplyScalar(q));return u=c.distanceTo(y)}function d(a,b,c,d){l.sub(d,b);p.sub(c,b);o.sub(a,b);E=l.dot(l);t=l.dot(p);v=l.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,k=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,l=[],o=0,p=a.children.length;o<p;o++)Array.prototype.push.apply(l,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};l.push(b)}else if(a instanceof THREE.Mesh){o=c(this.origin,this.direction,a.matrixWorld.getPosition());p=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(o>a.geometry.boundingSphere.radius*Math.max(p.x,Math.max(p.y,p.z)))return l;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],k.copy(this.origin),j.copy(this.direction),r=a.matrixWorld,i=r.multiplyVector3(i.copy(b.centroid)).subSelf(k),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(k,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:k.distanceTo(n),point:n.clone(),face:b,object:a},l.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:k.distanceTo(n),point:n.clone(),face:b,object:a},l.push(b)}return l};var l=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,l){h?(h=!1,b=f<i?f<n?f:n:i<n?i:n,c=g<m?g<l?g:l:m<l?m:l,d=f>i?f>n?f:n:i>n?i:n,e=g>m?g>l?g:l:m>l?m:l):(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<l?g<c?g:c:l<c?l:c:m<l?m<c?m:c:l<c?l: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>l?g>e?g:e:l>e?l:e:m>l?m>e?m:e:l>e?l: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>
+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,i=new THREE.Vector3,j=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());p=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(o>a.geometry.boundingSphere.radius*Math.max(p.x,Math.max(p.y,p.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),i.copy(this.direction),r=a.matrixWorld,j=r.multiplyVector3(j.copy(b.centroid)).subSelf(l),m=a.matrixRotationWorld.multiplyVector3(m.copy(b.normal)),q=i.dot(m),!(1.0E-4>Math.abs(q))&&(t=m.dot(j)/q,!(0>t)&&(a.doubleSided||(a.flipSided?0<q:0>q))))if(n.add(l,i.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,j,m){h=!1;b=f;c=g;d=j;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,j,m,n,k){h?(h=!1,b=f<j?f<n?f:n:j<n?j:n,c=g<m?g<k?g:k:m<k?m:k,d=f>j?f>n?f:n:j>n?j:n,e=g>m?g>k?g:k:m>k?m:k):(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<m?g<k?g<c?g:c:k<c?k:c:m<k?m<c?m:c:k<c?k: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>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}};
 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,k,j,i,m,n,l,p,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,j||0,void 0!==i?i:1,m||0,n||0,l||0,p||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,j,i,m,n,l,p,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=j;this.n33=i;this.n34=m;this.n41=n;this.n42=l;this.n43=p;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,j=a.n24,i=a.n31,m=a.n32,n=a.n33,l=a.n34,p=a.n41,o=a.n42,q=a.n43,
-y=a.n44,u=b.n11,E=b.n12,t=b.n13,v=b.n14,B=b.n21,w=b.n22,z=b.n23,G=b.n24,C=b.n31,I=b.n32,A=b.n33,K=b.n34,M=b.n41,L=b.n42,Q=b.n43,S=b.n44;this.n11=c*u+d*B+e*C+f*M;this.n12=c*E+d*w+e*I+f*L;this.n13=c*t+d*z+e*A+f*Q;this.n14=c*v+d*G+e*K+f*S;this.n21=g*u+h*B+k*C+j*M;this.n22=g*E+h*w+k*I+j*L;this.n23=g*t+h*z+k*A+j*Q;this.n24=g*v+h*G+k*K+j*S;this.n31=i*u+m*B+n*C+l*M;this.n32=i*E+m*w+n*I+l*L;this.n33=i*t+m*z+n*A+l*Q;this.n34=i*v+m*G+n*K+l*S;this.n41=p*u+o*B+q*C+y*M;this.n42=p*E+o*w+q*I+y*L;this.n43=p*t+o*
+THREE.Matrix4=function(a,b,c,d,e,f,g,h,l,i,j,m,n,k,p,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,l||0,i||0,void 0!==j?j:1,m||0,n||0,k||0,p||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,l,i,j,m,n,k,p,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=l;this.n32=i;this.n33=j;this.n34=m;this.n41=n;this.n42=k;this.n43=p;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,l=a.n23,i=a.n24,j=a.n31,m=a.n32,n=a.n33,k=a.n34,p=a.n41,o=a.n42,q=a.n43,
+y=a.n44,u=b.n11,E=b.n12,t=b.n13,v=b.n14,B=b.n21,w=b.n22,z=b.n23,G=b.n24,C=b.n31,I=b.n32,A=b.n33,K=b.n34,M=b.n41,L=b.n42,Q=b.n43,S=b.n44;this.n11=c*u+d*B+e*C+f*M;this.n12=c*E+d*w+e*I+f*L;this.n13=c*t+d*z+e*A+f*Q;this.n14=c*v+d*G+e*K+f*S;this.n21=g*u+h*B+l*C+i*M;this.n22=g*E+h*w+l*I+i*L;this.n23=g*t+h*z+l*A+i*Q;this.n24=g*v+h*G+l*K+i*S;this.n31=j*u+m*B+n*C+k*M;this.n32=j*E+m*w+n*I+k*L;this.n33=j*t+m*z+n*A+k*Q;this.n34=j*v+m*G+n*K+k*S;this.n41=p*u+o*B+q*C+y*M;this.n42=p*E+o*w+q*I+y*L;this.n43=p*t+o*
 z+q*A+y*Q;this.n44=p*v+o*G+q*K+y*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,j=this.n32,i=this.n33,m=this.n34,n=this.n41,l=this.n42,p=this.n43,o=this.n44;return d*g*j*n-c*h*j*n-d*f*i*n+b*h*i*n+c*f*m*n-b*g*m*n-d*g*k*l+c*h*k*l+d*e*i*l-a*h*i*l-c*e*m*l+a*g*m*l+d*f*k*p-b*h*k*p-d*e*j*p+a*h*j*p+b*e*m*p-a*f*m*p-c*f*k*o+b*g*k*o+c*e*j*o-a*g*j*o-b*e*i*o+a*f*i*o},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,l=this.n31,i=this.n32,j=this.n33,m=this.n34,n=this.n41,k=this.n42,p=this.n43,o=this.n44;return d*g*i*n-c*h*i*n-d*f*j*n+b*h*j*n+c*f*m*n-b*g*m*n-d*g*l*k+c*h*l*k+d*e*j*k-a*h*j*k-c*e*m*k+a*g*m*k+d*f*l*p-b*h*l*p-d*e*i*p+a*h*i*p+b*e*m*p-a*f*m*p-c*f*l*o+b*g*l*o+c*e*i*o-a*g*i*o-b*e*j*o+a*f*j*o},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,k=e*f,j=e*g;this.set(k*f+c,k*g-d*h,k*h+d*g,0,k*g+d*h,j*g+c,j*h-d*f,0,k*h-d*g,j*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,k=a.n24,j=a.n31,i=a.n32,m=a.n33,n=a.n34,l=a.n41,p=a.n42,o=a.n43,q=a.n44;this.n11=h*n*p-k*m*p+k*i*o-g*n*o-h*i*q+g*m*q;this.n12=e*m*p-d*n*p-e*i*o+c*n*o+d*i*q-c*m*q;this.n13=d*k*p-e*h*p+e*g*o-c*k*o-d*g*q+c*h*q;this.n14=e*h*i-d*k*i-e*g*m+c*k*m+d*g*n-c*h*n;this.n21=k*m*l-h*n*l-k*j*o+f*n*o+h*j*q-f*m*q;this.n22=d*n*l-e*m*l+
-e*j*o-b*n*o-d*j*q+b*m*q;this.n23=e*h*l-d*k*l-e*f*o+b*k*o+d*f*q-b*h*q;this.n24=d*k*j-e*h*j+e*f*m-b*k*m-d*f*n+b*h*n;this.n31=g*n*l-k*i*l+k*j*p-f*n*p-g*j*q+f*i*q;this.n32=e*i*l-c*n*l-e*j*p+b*n*p+c*j*q-b*i*q;this.n33=c*k*l-e*g*l+e*f*p-b*k*p-c*f*q+b*g*q;this.n34=e*g*j-c*k*j-e*f*i+b*k*i+c*f*n-b*g*n;this.n41=h*i*l-g*m*l-h*j*p+f*m*p+g*j*o-f*i*o;this.n42=c*m*l-d*i*l+d*j*p-b*m*p-c*j*o+b*i*o;this.n43=d*g*l-c*h*l-d*f*p+b*h*p+c*f*o-b*g*o;this.n44=c*h*j-d*g*j+d*f*i-b*h*i-c*f*m+b*g*m;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 k=g*h,j=g*e,i=d*h,m=d*e;this.n11=k+m*c;this.n12=i*c-j;this.n13=f*d;this.n21=f*e;this.n22=f*h;this.n23=-c;this.n31=j*c-i;this.n32=m+k*c;this.n33=f*g;break;case "ZXY":k=g*h;j=g*e;i=d*h;m=d*e;this.n11=k-m*c;this.n12=-f*e;this.n13=i+j*c;this.n21=j+i*c;this.n22=f*h;this.n23=m-k*c;this.n31=-f*d;this.n32=c;this.n33=f*g;break;case "ZYX":k=
-f*h;j=f*e;i=c*h;m=c*e;this.n11=g*h;this.n12=i*d-j;this.n13=k*d+m;this.n21=g*e;this.n22=m*d+k;this.n23=j*d-i;this.n31=-d;this.n32=c*g;this.n33=f*g;break;case "YZX":k=f*g;j=f*d;i=c*g;m=c*d;this.n11=g*h;this.n12=m-k*e;this.n13=i*e+j;this.n21=e;this.n22=f*h;this.n23=-c*h;this.n31=-d*h;this.n32=j*e+i;this.n33=k-m*e;break;case "XZY":k=f*g;j=f*d;i=c*g;m=c*d;this.n11=g*h;this.n12=-e;this.n13=d*h;this.n21=k*e+m;this.n22=f*h;this.n23=j*e-i;this.n31=i*e-j;this.n32=c*h;this.n33=m*e+k;break;default:k=f*h,j=f*
-e,i=c*h,m=c*e,this.n11=g*h,this.n12=-g*e,this.n13=d,this.n21=j+i*d,this.n22=k-m*d,this.n23=-c*g,this.n31=m-k*d,this.n32=i+j*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,k=b*g,b=b*h,j=c*g,c=c*h,d=d*h,f=e*f,g=e*g,e=e*h;this.n11=1-(j+d);this.n12=k-e;this.n13=b+g;this.n21=k+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+j);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=
+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,l=e*f,i=e*g;this.set(l*f+c,l*g-d*h,l*h+d*g,0,l*g+d*h,i*g+c,i*h-d*f,0,l*h-d*g,i*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,l=a.n24,i=a.n31,j=a.n32,m=a.n33,n=a.n34,k=a.n41,p=a.n42,o=a.n43,q=a.n44;this.n11=h*n*p-l*m*p+l*j*o-g*n*o-h*j*q+g*m*q;this.n12=e*m*p-d*n*p-e*j*o+c*n*o+d*j*q-c*m*q;this.n13=d*l*p-e*h*p+e*g*o-c*l*o-d*g*q+c*h*q;this.n14=e*h*j-d*l*j-e*g*m+c*l*m+d*g*n-c*h*n;this.n21=l*m*k-h*n*k-l*i*o+f*n*o+h*i*q-f*m*q;this.n22=d*n*k-e*m*k+
+e*i*o-b*n*o-d*i*q+b*m*q;this.n23=e*h*k-d*l*k-e*f*o+b*l*o+d*f*q-b*h*q;this.n24=d*l*i-e*h*i+e*f*m-b*l*m-d*f*n+b*h*n;this.n31=g*n*k-l*j*k+l*i*p-f*n*p-g*i*q+f*j*q;this.n32=e*j*k-c*n*k-e*i*p+b*n*p+c*i*q-b*j*q;this.n33=c*l*k-e*g*k+e*f*p-b*l*p-c*f*q+b*g*q;this.n34=e*g*i-c*l*i-e*f*j+b*l*j+c*f*n-b*g*n;this.n41=h*j*k-g*m*k-h*i*p+f*m*p+g*i*o-f*j*o;this.n42=c*m*k-d*j*k+d*i*p-b*m*p-c*i*o+b*j*o;this.n43=d*g*k-c*h*k-d*f*p+b*h*p+c*f*o-b*g*o;this.n44=c*h*i-d*g*i+d*f*j-b*h*j-c*f*m+b*g*m;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 l=g*h,i=g*e,j=d*h,m=d*e;this.n11=l+m*c;this.n12=j*c-i;this.n13=f*d;this.n21=f*e;this.n22=f*h;this.n23=-c;this.n31=i*c-j;this.n32=m+l*c;this.n33=f*g;break;case "ZXY":l=g*h;i=g*e;j=d*h;m=d*e;this.n11=l-m*c;this.n12=-f*e;this.n13=j+i*c;this.n21=i+j*c;this.n22=f*h;this.n23=m-l*c;this.n31=-f*d;this.n32=c;this.n33=f*g;break;case "ZYX":l=
+f*h;i=f*e;j=c*h;m=c*e;this.n11=g*h;this.n12=j*d-i;this.n13=l*d+m;this.n21=g*e;this.n22=m*d+l;this.n23=i*d-j;this.n31=-d;this.n32=c*g;this.n33=f*g;break;case "YZX":l=f*g;i=f*d;j=c*g;m=c*d;this.n11=g*h;this.n12=m-l*e;this.n13=j*e+i;this.n21=e;this.n22=f*h;this.n23=-c*h;this.n31=-d*h;this.n32=i*e+j;this.n33=l-m*e;break;case "XZY":l=f*g;i=f*d;j=c*g;m=c*d;this.n11=g*h;this.n12=-e;this.n13=d*h;this.n21=l*e+m;this.n22=f*h;this.n23=i*e-j;this.n31=j*e-i;this.n32=c*h;this.n33=m*e+l;break;default:l=f*h,i=f*
+e,j=c*h,m=c*e,this.n11=g*h,this.n12=-g*e,this.n13=d,this.n21=i+j*d,this.n22=l-m*d,this.n23=-c*g,this.n31=m-l*d,this.n32=j+i*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,l=b*g,b=b*h,i=c*g,c=c*h,d=d*h,f=e*f,g=e*g,e=e*h;this.n11=1-(i+d);this.n12=l-e;this.n13=b+g;this.n21=l+e;this.n22=1-(a+d);this.n23=c-f;this.n31=b-g;this.n32=c+f;this.n33=1-(a+i);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,k=Math.cos(b),j=Math.sin(b),i=1-k,m=c*d*i,n=c*e*i,i=d*e*i,c=c*j,l=d*j,j=e*j,e=f+(1-f)*k,f=m+j,d=n-l,m=m-j,g=g+(1-g)*k,j=i+c,n=n+l,i=i-c,h=h+(1-h)*k,k=this.n11,c=this.n21,l=this.n31,p=this.n41,o=this.n12,q=this.n22,y=this.n32,u=this.n42,E=this.n13,t=this.n23,v=this.n33,B=this.n43;this.n11=e*k+f*o+d*E;this.n21=e*c+f*q+d*t;this.n31=e*l+f*y+d*v;this.n41=e*p+f*u+d*B;this.n12=m*k+g*o+j*E;this.n22=
-m*c+g*q+j*t;this.n32=m*l+g*y+j*v;this.n42=m*p+g*u+j*B;this.n13=n*k+i*o+h*E;this.n23=n*c+i*q+h*t;this.n33=n*l+i*y+h*v;this.n43=n*p+i*u+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,j=Math.cos(a),a=Math.sin(a);this.n12=j*b+a*f;this.n22=j*c+a*g;this.n32=j*d+a*h;this.n42=j*e+a*k;this.n13=j*f-a*b;this.n23=j*g-a*c;this.n33=j*h-a*d;this.n43=j*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,j=Math.cos(a),a=Math.sin(a);this.n11=j*b-a*f;this.n21=j*c-a*g;this.n31=j*d-a*h;this.n41=j*e-a*k;this.n13=j*f+a*b;this.n23=j*g+a*c;this.n33=j*h+a*d;this.n43=j*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,j=Math.cos(a),a=Math.sin(a);this.n11=j*b+a*f;this.n21=j*c+a*g;this.n31=j*d+a*h;this.n41=j*e+a*k;this.n12=j*f-a*b;this.n22=j*g-a*c;this.n32=j*h-a*d;this.n42=j*k-a*e;return this},
+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,l=Math.cos(b),i=Math.sin(b),j=1-l,m=c*d*j,n=c*e*j,j=d*e*j,c=c*i,k=d*i,i=e*i,e=f+(1-f)*l,f=m+i,d=n-k,m=m-i,g=g+(1-g)*l,i=j+c,n=n+k,j=j-c,h=h+(1-h)*l,l=this.n11,c=this.n21,k=this.n31,p=this.n41,o=this.n12,q=this.n22,y=this.n32,u=this.n42,E=this.n13,t=this.n23,v=this.n33,B=this.n43;this.n11=e*l+f*o+d*E;this.n21=e*c+f*q+d*t;this.n31=e*k+f*y+d*v;this.n41=e*p+f*u+d*B;this.n12=m*l+g*o+i*E;this.n22=
+m*c+g*q+i*t;this.n32=m*k+g*y+i*v;this.n42=m*p+g*u+i*B;this.n13=n*l+j*o+h*E;this.n23=n*c+j*q+h*t;this.n33=n*k+j*y+h*v;this.n43=n*p+j*u+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,l=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*l;this.n13=i*f-a*b;this.n23=i*g-a*c;this.n33=i*h-a*d;this.n43=i*l-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,l=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*l;this.n13=i*f+a*b;this.n23=i*g+a*c;this.n33=i*h+a*d;this.n43=i*l+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,l=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*l;this.n12=i*f-a*b;this.n22=i*g-a*c;this.n32=i*h-a*d;this.n42=i*l-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,j=a.n23*a.n12-a.n22*a.n13,i=-a.n23*a.n11+a.n21*a.n13,m=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*g+a.n31*j;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*j;c[7]=a*i;c[8]=a*m;return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,l=-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,m=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*l;c[6]=a*i;c[7]=a*j;c[8]=a*m;return b};
 THREE.Matrix4.makeFrustum=function(a,b,c,d,e,f){var g;g=new THREE.Matrix4;g.n11=2*e/(b-a);g.n12=0;g.n13=(b+a)/(b-a);g.n14=0;g.n21=0;g.n22=2*e/(d-c);g.n23=(d+c)/(d-c);g.n24=0;g.n31=0;g.n32=0;g.n33=-(f+e)/(f-e);g.n34=-2*f*e/(f-e);g.n41=0;g.n42=0;g.n43=-1;g.n44=0;return g};THREE.Matrix4.makePerspective=function(a,b,c,d){var e,a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,e,f){var g,h,k,j;g=new THREE.Matrix4;h=b-a;k=c-d;j=f-e;g.n11=2/h;g.n12=0;g.n13=0;g.n14=-((b+a)/h);g.n21=0;g.n22=2/k;g.n23=0;g.n24=-((c+d)/k);g.n31=0;g.n32=0;g.n33=-2/j;g.n34=-((f+e)/j);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};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.makeOrtho=function(a,b,c,d,e,f){var g,h,l,i;g=new THREE.Matrix4;h=b-a;l=c-d;i=f-e;g.n11=2/h;g.n12=0;g.n13=0;g.n14=-((b+a)/h);g.n21=0;g.n22=2/l;g.n23=0;g.n24=-((c+d)/l);g.n31=0;g.n32=0;g.n33=-2/i;g.n34=-((f+e)/i);g.n41=0;g.n42=0;g.n43=0;g.n44=1;return g};THREE.Matrix4.__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.id=THREE.Object3DCount++;this.name="";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=!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(a===
 this)console.warn("THREE: Object3D.add(): An object can't be added as a child of itself.");else 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,e;for(c=0,d=this.children.length;c<d;c++){e=this.children[c];if(e.name===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=j[k]=j[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,j=[],i,m,n=[],l,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,
+THREE.Projector=function(){function a(){var a=g[f]=g[f]||new THREE.RenderableObject;f++;return a}function b(){var a=i[l]=i[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,i=[],j,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,r,s,x,D,F,J,H,O,P,U,X,V,W,R;E=q=l=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,k=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[l]=p[l]||new THREE.RenderableFace4,l++,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[k-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=i[r.a],D=i[r.b],F=i[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++,j=J,j.v1.copy(x),j.v2.copy(D),j.v3.copy(F);else continue;else if(r instanceof THREE.Face4)if(x=i[r.a],D=i[r.b],F=i[r.c],J=i[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++,j=R,j.v1.copy(x),j.v2.copy(D),j.v3.copy(F),j.v4.copy(J);else continue;j.normalWorld.copy(r.normal);P.multiplyVector3(j.normalWorld);j.centroidWorld.copy(r.centroid);O.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);z.multiplyVector3(j.centroidScreen);F=r.vertexNormals;for(x=0,D=F.length;x<D;x++)J=j.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++)j.uvs[x][F]=R[F];j.material=U;j.faceMaterial=null!==r.materialIndex?X[r.materialIndex]:null;j.z=j.centroidScreen.z;v.elements.push(j)}}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=i[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.x=a||0;this.y=b||0;this.z=c||0;this.w=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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},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=this.x,c=this.y,d=this.z,e=this.w,f=a.x,g=a.y,h=a.z,a=a.w;this.x=b*a+e*f+c*h-d*g;this.y=c*a+e*g+d*f-b*h;this.z=d*a+e*h+b*g-c*f;this.w=e*a-b*f-c*g-d*h;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,e=a.z,f=this.x,g=this.y,h=this.z,k=this.w,j=k*c+g*e-h*d,i=k*d+h*c-f*e,m=k*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=j*k+c*-f+i*-h-m*-g;b.y=i*k+c*-g+m*-f-j*-h;b.z=m*k+c*-h+j*-g-i*-f;return b}};
+a);var c=a.x,d=a.y,e=a.z,f=this.x,g=this.y,h=this.z,l=this.w,i=l*c+g*e-h*d,j=l*d+h*c-f*e,m=l*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=i*l+c*-f+j*-h-m*-g;b.y=j*l+c*-g+m*-f-i*-h;b.z=m*l+c*-h+i*-g-j*-f;return b}};
 THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var f=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))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)/e;d=Math.sin(d*f)/e;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,e,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=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=f;this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,f,g){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=f instanceof THREE.Color?f:new THREE.Color;this.vertexColors=f instanceof Array?f:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
@@ -88,13 +88,14 @@ 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]))},computeMorphNormals:function(){var a,
-b,c,d,e;for(c=0,d=this.faces.length;c<d;c++){e=this.faces[c];e.__originalVertexNormals=[];for(a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]=e.vertexNormals[a].clone()}var f=new THREE.Geometry;f.faces=this.faces;for(a=0,b=this.morphTargets.length;a<b;a++){var g=this.morphNormals[a];f.vertices=this.morphTargets[a].vertices;f.computeFaceNormals();f.computeVertexNormals();var h,k;for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],h=g.faceNormals[c],k=g.vertexNormals[c],h.copy(e.normal),
-e instanceof THREE.Face3?(k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2])):(k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2]),k.d.copy(e.vertexNormals[3]))}for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){function a(a,b,c,d,e,f,D){h=a.vertices[b].position;k=a.vertices[c].position;j=a.vertices[d].position;i=g[e];m=g[f];n=g[D];l=k.x-h.x;p=j.x-h.x;o=k.y-
-h.y;q=j.y-h.y;y=k.z-h.z;u=j.z-h.z;E=m.u-i.u;t=n.u-i.u;v=m.v-i.v;B=n.v-i.v;w=1/(E*B-t*v);I.set((B*l-v*p)*w,(B*o-v*q)*w,(B*y-v*u)*w);A.set((E*p-t*l)*w,(E*q-t*o)*w,(E*u-t*y)*w);G[b].addSelf(I);G[c].addSelf(I);G[d].addSelf(I);C[b].addSelf(A);C[c].addSelf(A);C[d].addSelf(A)}var b,c,d,e,f,g,h,k,j,i,m,n,l,p,o,q,y,u,E,t,v,B,w,z,G=[],C=[],I=new THREE.Vector3,A=new THREE.Vector3,K=new THREE.Vector3,M=new THREE.Vector3,L=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)G[b]=new THREE.Vector3,C[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 Q=["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++)L.copy(f.vertexNormals[d]),e=f[Q[d]],z=G[e],K.copy(z),K.subSelf(L.multiplyScalar(L.dot(z))).normalize(),M.cross(f.vertexNormals[d],z),e=M.dot(C[e]),e=0>e?-1:1,f.vertexTangents[d]=
-new THREE.Vector4(K.x,K.y,K.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);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}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};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;
+b,c,d,e;for(c=0,d=this.faces.length;c<d;c++){e=this.faces[c];e.__originalFaceNormal?e.__originalFaceNormal.copy(e.normal):e.__originalFaceNormal=e.normal.clone();if(!e.__originalVertexNormals)e.__originalVertexNormals=[];for(a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]?e.__originalVertexNormals[a].copy(e.vertexNormals[a]):e.__originalVertexNormals[a]=e.vertexNormals[a].clone()}var f=new THREE.Geometry;f.faces=this.faces;for(a=0,b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]=
+{};this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=[];var g=this.morphNormals[a].faceNormals,h=this.morphNormals[a].vertexNormals,l,i;for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],l=new THREE.Vector3,i=e instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,d:new THREE.Vector3},g.push(l),h.push(i)}g=this.morphNormals[a];f.vertices=this.morphTargets[a].vertices;f.computeFaceNormals();
+f.computeVertexNormals();for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],l=g.faceNormals[c],i=g.vertexNormals[c],l.copy(e.normal),e instanceof THREE.Face3?(i.a.copy(e.vertexNormals[0]),i.b.copy(e.vertexNormals[1]),i.c.copy(e.vertexNormals[2])):(i.a.copy(e.vertexNormals[0]),i.b.copy(e.vertexNormals[1]),i.c.copy(e.vertexNormals[2]),i.d.copy(e.vertexNormals[3]))}for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],e.normal=e.__originalFaceNormal,e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){function a(a,
+b,c,d,e,f,D){h=a.vertices[b].position;l=a.vertices[c].position;i=a.vertices[d].position;j=g[e];m=g[f];n=g[D];k=l.x-h.x;p=i.x-h.x;o=l.y-h.y;q=i.y-h.y;y=l.z-h.z;u=i.z-h.z;E=m.u-j.u;t=n.u-j.u;v=m.v-j.v;B=n.v-j.v;w=1/(E*B-t*v);I.set((B*k-v*p)*w,(B*o-v*q)*w,(B*y-v*u)*w);A.set((E*p-t*k)*w,(E*q-t*o)*w,(E*u-t*y)*w);G[b].addSelf(I);G[c].addSelf(I);G[d].addSelf(I);C[b].addSelf(A);C[c].addSelf(A);C[d].addSelf(A)}var b,c,d,e,f,g,h,l,i,j,m,n,k,p,o,q,y,u,E,t,v,B,w,z,G=[],C=[],I=new THREE.Vector3,A=new THREE.Vector3,
+K=new THREE.Vector3,M=new THREE.Vector3,L=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)G[b]=new THREE.Vector3,C[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 Q=["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++)L.copy(f.vertexNormals[d]),e=f[Q[d]],
+z=G[e],K.copy(z),K.subSelf(L.multiplyScalar(L.dot(z))).normalize(),M.cross(f.vertexNormals[d],z),e=M.dot(C[e]),e=0>e?-1:1,f.vertexTangents[d]=new THREE.Vector4(K.x,K.y,K.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);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}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};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;
 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;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;
@@ -135,23 +136,23 @@ 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.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,k=document.createElementNS("http://www.w3.org/2000/svg","svg"),j,i,m,n,l,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=k;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;k.setAttribute("viewBox",-m+" "+-n+" "+j+" "+i);k.setAttribute("width",j);k.setAttribute("height",i);y.set(-m,-n,m,n)};this.clear=function(){for(;0<k.childNodes.length;)k.removeChild(k.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)l=r,l.x*=
-m,l.y*=-n;else if(r instanceof THREE.RenderableLine){if(l=r.v1,p=r.v2,l.positionScreen.x*=m,l.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,u.addPoint(l.positionScreen.x,l.positionScreen.y),u.addPoint(p.positionScreen.x,p.positionScreen.y),y.intersects(u)){r=l;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),k.appendChild(A))}}else if(r instanceof THREE.RenderableFace3){if(l=r.v1,p=r.v2,o=r.v3,l.positionScreen.x*=m,l.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,o.positionScreen.x*=
-m,o.positionScreen.y*=-n,u.addPoint(l.positionScreen.x,l.positionScreen.y),u.addPoint(p.positionScreen.x,p.positionScreen.y),u.addPoint(o.positionScreen.x,o.positionScreen.y),y.intersects(u)){var x=l,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?
+THREE.SVGRenderer=function(){function a(a,b,c,d){var e,f,g,h,i,j;for(e=0,f=a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(i=g.matrixWorld.getPosition(),j=c.dot(i),0>=j||(j*=g.intensity,d.r+=h.r*j,d.g+=h.g*j,d.b+=h.b*j)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),j=c.dot(G.sub(i,b).normalize()),0>=j||(j*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=j&&(j*=g.intensity,d.r+=h.r*j,d.g+=h.g*j,d.b+=h.b*j)))}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"),i,j,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){i=a;j=b;m=i/2;n=j/2;l.setAttribute("viewBox",-m+" "+-n+" "+i+" "+j);l.setAttribute("width",i);l.setAttribute("height",j);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);k.appendChild(A)}}else if(r instanceof THREE.RenderableFace4&&(l=r.v1,p=r.v2,o=r.v3,q=r.v4,l.positionScreen.x*=m,l.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(l.positionScreen.x,
-l.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=l,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?
+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);k.appendChild(A)}}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};
+"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};
 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:"anonymous",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=this.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),j=k.data,i=0;i<d;i++)for(var m=1;m<e;m++){var n=0>m-1?e-1:m-1,l=(m+1)%e,p=0>i-1?d-1:i-1,o=(i+1)%d,q=[],y=[0,0,h[4*(m*d+i)]/255*b];q.push([-1,0,h[4*(m*d+p)]/255*b]);q.push([-1,-1,h[4*(n*d+p)]/255*b]);q.push([0,-1,
-h[4*(n*d+i)]/255*b]);q.push([1,-1,h[4*(n*d+o)]/255*b]);q.push([1,0,h[4*(m*d+o)]/255*b]);q.push([1,1,h[4*(l*d+o)]/255*b]);q.push([0,1,h[4*(l*d+i)]/255*b]);q.push([-1,1,h[4*(l*d+p)]/255*b]);n=[];p=q.length;for(l=0;l<p;l++){var o=q[l],u=q[(l+1)%p],o=[o[0]-y[0],o[1]-y[1],o[2]-y[2]],u=[u[0]-y[0],u[1]-y[1],u[2]-y[2]];n.push(c([o[1]*u[2]-o[2]*u[1],o[2]*u[0]-o[0]*u[2],o[0]*u[1]-o[1]*u[0]]))}q=[0,0,0];for(l=0;l<n.length;l++)q[0]+=n[l][0],q[1]+=n[l][1],q[2]+=n[l][2];q[0]/=n.length;q[1]/=n.length;q[2]/=n.length;
-y=4*(m*d+i);j[y]=255*((q[0]+1)/2)|0;j[y+1]=255*(q[1]+0.5)|0;j[y+2]=255*q[2]|0;j[y+3]=255}g.putImageData(k,0,0);return f}};
+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,l=g.createImageData(d,e),i=l.data,j=0;j<d;j++)for(var m=1;m<e;m++){var n=0>m-1?e-1:m-1,k=(m+1)%e,p=0>j-1?d-1:j-1,o=(j+1)%d,q=[],y=[0,0,h[4*(m*d+j)]/255*b];q.push([-1,0,h[4*(m*d+p)]/255*b]);q.push([-1,-1,h[4*(n*d+p)]/255*b]);q.push([0,-1,
+h[4*(n*d+j)]/255*b]);q.push([1,-1,h[4*(n*d+o)]/255*b]);q.push([1,0,h[4*(m*d+o)]/255*b]);q.push([1,1,h[4*(k*d+o)]/255*b]);q.push([0,1,h[4*(k*d+j)]/255*b]);q.push([-1,1,h[4*(k*d+p)]/255*b]);n=[];p=q.length;for(k=0;k<p;k++){var o=q[k],u=q[(k+1)%p],o=[o[0]-y[0],o[1]-y[1],o[2]-y[2]],u=[u[0]-y[0],u[1]-y[1],u[2]-y[2]];n.push(c([o[1]*u[2]-o[2]*u[1],o[2]*u[0]-o[0]*u[2],o[0]*u[1]-o[1]*u[0]]))}q=[0,0,0];for(k=0;k<n.length;k++)q[0]+=n[k][0],q[1]+=n[k][1],q[2]+=n[k][2];q[0]/=n.length;q[1]/=n.length;q[2]/=n.length;
+y=4*(m*d+j);i[y]=255*((q[0]+1)/2)|0;i[y+1]=255*(q[1]+0.5)|0;i[y+2]=255*q[2]|0;i[y+3]=255}g.putImageData(l,0,0);return f}};

+ 194 - 192
build/custom/ThreeWebGL.js

@@ -18,66 +18,66 @@ this.z=a.z-b.z;this.w=a.w-b.w;return this},subSelf:function(a){this.x-=a.x;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){p.sub(c,a);r=p.dot(b);y=q.add(a,o.copy(b).multiplyScalar(r));return u=c.distanceTo(y)}function d(a,b,c,d){p.sub(d,b);q.sub(c,b);o.sub(a,b);L=p.dot(p);A=p.dot(q);v=p.dot(o);B=q.dot(q);C=q.dot(o);I=1/(L*B-A*A);M=(B*v-A*C)*I;N=(L*C-A*v)*I;return 0<=M&&0<=N&&1>M+N}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,g=new THREE.Vector3,h=new THREE.Vector3,i=new THREE.Vector3,k=new THREE.Vector3,m=new THREE.Vector3,j=new THREE.Vector3,n=new THREE.Vector3,l=new THREE.Vector3;this.intersectObject=function(a){for(var b,q=[],p=0,o=a.children.length;p<o;p++)Array.prototype.push.apply(q,this.intersectObject(a.children[p]));if(a instanceof THREE.Particle){p=
-c(this.origin,this.direction,a.matrixWorld.getPosition());if(p>a.scale.x)return[];b={distance:p,point:a.position,face:null,object:a};q.push(b)}else if(a instanceof THREE.Mesh){p=c(this.origin,this.direction,a.matrixWorld.getPosition());o=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(p>a.geometry.boundingSphere.radius*Math.max(o.x,Math.max(o.y,o.z)))return q;var r,y,f=a.geometry,u=f.vertices,v;a.matrixRotationWorld.extractRotation(a.matrixWorld);
-for(p=0,o=f.faces.length;p<o;p++)if(b=f.faces[p],k.copy(this.origin),m.copy(this.direction),v=a.matrixWorld,j=v.multiplyVector3(j.copy(b.centroid)).subSelf(k),n=a.matrixRotationWorld.multiplyVector3(n.copy(b.normal)),r=m.dot(n),!(1.0E-4>Math.abs(r))&&(y=n.dot(j)/r,!(0>y)&&(a.doubleSided||(a.flipSided?0<r:0>r))))if(l.add(k,m.multiplyScalar(y)),b instanceof THREE.Face3)e=v.multiplyVector3(e.copy(u[b.a].position)),g=v.multiplyVector3(g.copy(u[b.b].position)),h=v.multiplyVector3(h.copy(u[b.c].position)),
-d(l,e,g,h)&&(b={distance:k.distanceTo(l),point:l.clone(),face:b,object:a},q.push(b));else if(b instanceof THREE.Face4&&(e=v.multiplyVector3(e.copy(u[b.a].position)),g=v.multiplyVector3(g.copy(u[b.b].position)),h=v.multiplyVector3(h.copy(u[b.c].position)),i=v.multiplyVector3(i.copy(u[b.d].position)),d(l,e,g,i)||d(l,g,h,i)))b={distance:k.distanceTo(l),point:l.clone(),face:b,object:a},q.push(b)}return q};var p=new THREE.Vector3,q=new THREE.Vector3,o=new THREE.Vector3,r,y,u,L,A,v,B,C,I,M,N};
+THREE.Ray=function(a,b){function c(a,b,c){p.sub(c,a);q=p.dot(b);y=r.add(a,o.copy(b).multiplyScalar(q));return u=c.distanceTo(y)}function d(a,b,c,d){p.sub(d,b);r.sub(c,b);o.sub(a,b);K=p.dot(p);A=p.dot(r);v=p.dot(o);B=r.dot(r);C=r.dot(o);I=1/(K*B-A*A);L=(B*v-A*C)*I;M=(K*C-A*v)*I;return 0<=L&&0<=M&&1>L+M}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,g=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,r=[],p=0,o=a.children.length;p<o;p++)Array.prototype.push.apply(r,this.intersectObject(a.children[p]));if(a instanceof THREE.Particle){p=
+c(this.origin,this.direction,a.matrixWorld.getPosition());if(p>a.scale.x)return[];b={distance:p,point:a.position,face:null,object:a};r.push(b)}else if(a instanceof THREE.Mesh){p=c(this.origin,this.direction,a.matrixWorld.getPosition());o=THREE.Frustum.__v1.set(a.matrixWorld.getColumnX().length(),a.matrixWorld.getColumnY().length(),a.matrixWorld.getColumnZ().length());if(p>a.geometry.boundingSphere.radius*Math.max(o.x,Math.max(o.y,o.z)))return r;var q,y,f=a.geometry,u=f.vertices,v;a.matrixRotationWorld.extractRotation(a.matrixWorld);
+for(p=0,o=f.faces.length;p<o;p++)if(b=f.faces[p],k.copy(this.origin),l.copy(this.direction),v=a.matrixWorld,j=v.multiplyVector3(j.copy(b.centroid)).subSelf(k),n=a.matrixRotationWorld.multiplyVector3(n.copy(b.normal)),q=l.dot(n),!(1.0E-4>Math.abs(q))&&(y=n.dot(j)/q,!(0>y)&&(a.doubleSided||(a.flipSided?0<q:0>q))))if(m.add(k,l.multiplyScalar(y)),b instanceof THREE.Face3)e=v.multiplyVector3(e.copy(u[b.a].position)),g=v.multiplyVector3(g.copy(u[b.b].position)),h=v.multiplyVector3(h.copy(u[b.c].position)),
+d(m,e,g,h)&&(b={distance:k.distanceTo(m),point:m.clone(),face:b,object:a},r.push(b));else if(b instanceof THREE.Face4&&(e=v.multiplyVector3(e.copy(u[b.a].position)),g=v.multiplyVector3(g.copy(u[b.b].position)),h=v.multiplyVector3(h.copy(u[b.c].position)),i=v.multiplyVector3(i.copy(u[b.d].position)),d(m,e,g,i)||d(m,g,h,i)))b={distance:k.distanceTo(m),point:m.clone(),face:b,object:a},r.push(b)}return r};var p=new THREE.Vector3,r=new THREE.Vector3,o=new THREE.Vector3,q,y,u,K,A,v,B,C,I,L,M};
 THREE.Rectangle=function(){function a(){g=d-b;h=e-c}var b,c,d,e,g,h,i=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return h};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,h,j,n){i=!1;b=g;c=h;d=j;e=n;a()};this.addPoint=function(g,h){i?(i=!1,b=g,c=h,d=g,e=h):(b=b<g?b:g,c=c<h?c:h,d=d>g?d:g,e=e>h?e:h);a()};this.add3Points=
-function(g,h,j,n,l,p){i?(i=!1,b=g<j?g<l?g:l:j<l?j:l,c=h<n?h<p?h:p:n<p?n:p,d=g>j?g>l?g:l:j>l?j:l,e=h>n?h>p?h:p:n>p?n:p):(b=g<j?g<l?g<b?g:b:l<b?l:b:j<l?j<b?j:b:l<b?l:b,c=h<n?h<p?h<c?h:c:p<c?p:c:n<p?n<c?n:c:p<c?p:c,d=g>j?g>l?g>d?g:d:l>d?l:d:j>l?j>d?j:d:l>d?l:d,e=h>n?h>p?h>e?h:e:p>e?p:e:n>p?n>e?n:e:p>e?p:e);a()};this.addRectangle=function(g){i?(i=!1,b=g.getLeft(),c=g.getTop(),d=g.getRight(),e=g.getBottom()):(b=b<g.getLeft()?b:g.getLeft(),c=c<g.getTop()?c:g.getTop(),d=d>g.getRight()?d:g.getRight(),e=e>
+function(g,h,j,n,m,p){i?(i=!1,b=g<j?g<m?g:m:j<m?j:m,c=h<n?h<p?h:p:n<p?n:p,d=g>j?g>m?g:m:j>m?j:m,e=h>n?h>p?h:p:n>p?n:p):(b=g<j?g<m?g<b?g:b:m<b?m:b:j<m?j<b?j:b:m<b?m:b,c=h<n?h<p?h<c?h:c:p<c?p:c:n<p?n<c?n:c:p<c?p:c,d=g>j?g>m?g>d?g:d:m>d?m:d:j>m?j>d?j:d:m>d?m:d,e=h>n?h>p?h>e?h:e:p>e?p:e:n>p?n>e?n:e:p>e?p:e);a()};this.addRectangle=function(g){i?(i=!1,b=g.getLeft(),c=g.getTop(),d=g.getRight(),e=g.getBottom()):(b=b<g.getLeft()?b:g.getLeft(),c=c<g.getTop()?c:g.getTop(),d=d>g.getRight()?d:g.getRight(),e=e>
 g.getBottom()?e:g.getBottom());a()};this.inflate=function(g){b-=g;c-=g;d+=g;e+=g;a()};this.minSelf=function(g){b=b>g.getLeft()?b:g.getLeft();c=c>g.getTop()?c:g.getTop();d=d<g.getRight()?d:g.getRight();e=e<g.getBottom()?e:g.getBottom();a()};this.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}};
 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,g,h,i,k,m,j,n,l,p,q,o){this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==g?g:1,h||0,i||0,k||0,m||0,void 0!==j?j:1,n||0,l||0,p||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,g,h,i,k,m,j,n,l,p,q,o){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=i;this.n31=k;this.n32=m;this.n33=j;this.n34=n;this.n41=l;this.n42=p;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,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(0===g.length())g.z=1;d.cross(c,g).normalize();0===d.length()&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,i=a.n22,k=a.n23,m=a.n24,j=a.n31,n=a.n32,l=a.n33,p=a.n34,q=a.n41,o=a.n42,r=a.n43,
-y=a.n44,u=b.n11,L=b.n12,A=b.n13,v=b.n14,B=b.n21,C=b.n22,I=b.n23,M=b.n24,N=b.n31,J=b.n32,T=b.n33,wa=b.n34,la=b.n41,aa=b.n42,$=b.n43,E=b.n44;this.n11=c*u+d*B+e*N+g*la;this.n12=c*L+d*C+e*J+g*aa;this.n13=c*A+d*I+e*T+g*$;this.n14=c*v+d*M+e*wa+g*E;this.n21=h*u+i*B+k*N+m*la;this.n22=h*L+i*C+k*J+m*aa;this.n23=h*A+i*I+k*T+m*$;this.n24=h*v+i*M+k*wa+m*E;this.n31=j*u+n*B+l*N+p*la;this.n32=j*L+n*C+l*J+p*aa;this.n33=j*A+n*I+l*T+p*$;this.n34=j*v+n*M+l*wa+p*E;this.n41=q*u+o*B+r*N+y*la;this.n42=q*L+o*C+r*J+y*aa;this.n43=
-q*A+o*I+r*T+y*$;this.n44=q*v+o*M+r*wa+y*E;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,e,g,h,i,k,l,j,n,m,p,r,o){this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==g?g:1,h||0,i||0,k||0,l||0,void 0!==j?j:1,n||0,m||0,p||0,r||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,g,h,i,k,l,j,n,m,p,r,o){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=g;this.n23=h;this.n24=i;this.n31=k;this.n32=l;this.n33=j;this.n34=n;this.n41=m;this.n42=p;this.n43=r;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,g=THREE.Matrix4.__v3;g.sub(a,b).normalize();if(0===g.length())g.z=1;d.cross(c,g).normalize();0===d.length()&&(g.x+=1.0E-4,d.cross(c,g).normalize());e.cross(g,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=g.x;this.n21=d.y;this.n22=e.y;this.n23=g.y;this.n31=d.z;this.n32=e.z;this.n33=g.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,g=a.n14,h=a.n21,i=a.n22,k=a.n23,l=a.n24,j=a.n31,n=a.n32,m=a.n33,p=a.n34,r=a.n41,o=a.n42,q=a.n43,
+y=a.n44,u=b.n11,K=b.n12,A=b.n13,v=b.n14,B=b.n21,C=b.n22,I=b.n23,L=b.n24,M=b.n31,N=b.n32,S=b.n33,xa=b.n34,ma=b.n41,T=b.n42,aa=b.n43,E=b.n44;this.n11=c*u+d*B+e*M+g*ma;this.n12=c*K+d*C+e*N+g*T;this.n13=c*A+d*I+e*S+g*aa;this.n14=c*v+d*L+e*xa+g*E;this.n21=h*u+i*B+k*M+l*ma;this.n22=h*K+i*C+k*N+l*T;this.n23=h*A+i*I+k*S+l*aa;this.n24=h*v+i*L+k*xa+l*E;this.n31=j*u+n*B+m*M+p*ma;this.n32=j*K+n*C+m*N+p*T;this.n33=j*A+n*I+m*S+p*aa;this.n34=j*v+n*L+m*xa+p*E;this.n41=r*u+o*B+q*M+y*ma;this.n42=r*K+o*C+q*N+y*T;this.n43=
+r*A+o*I+q*S+y*aa;this.n44=r*v+o*L+q*xa+y*E;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,g=this.n22,h=this.n23,i=this.n24,k=this.n31,m=this.n32,j=this.n33,n=this.n34,l=this.n41,p=this.n42,q=this.n43,o=this.n44;return d*h*m*l-c*i*m*l-d*g*j*l+b*i*j*l+c*g*n*l-b*h*n*l-d*h*k*p+c*i*k*p+d*e*j*p-a*i*j*p-c*e*n*p+a*h*n*p+d*g*k*q-b*i*k*q-d*e*m*q+a*i*m*q+b*e*n*q-a*g*n*q-c*g*k*o+b*h*k*o+c*e*m*o-a*h*m*o-
+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,g=this.n22,h=this.n23,i=this.n24,k=this.n31,l=this.n32,j=this.n33,n=this.n34,m=this.n41,p=this.n42,r=this.n43,o=this.n44;return d*h*l*m-c*i*l*m-d*g*j*m+b*i*j*m+c*g*n*m-b*h*n*m-d*h*k*p+c*i*k*p+d*e*j*p-a*i*j*p-c*e*n*p+a*h*n*p+d*g*k*r-b*i*k*r-d*e*l*r+a*i*l*r+b*e*n*r-a*g*n*r-c*g*k*o+b*h*k*o+c*e*l*o-a*h*l*o-
 b*e*j*o+a*g*j*o},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,g=a.x,h=a.y,i=a.z,k=e*g,m=e*h;this.set(k*g+c,k*h-d*i,k*i+d*h,0,k*h+d*i,m*h+c,m*i-d*g,0,k*i-d*h,m*i+d*g,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},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,g=a.n21,h=a.n22,i=a.n23,k=a.n24,m=a.n31,j=a.n32,n=a.n33,l=a.n34,p=a.n41,q=a.n42,o=a.n43,r=a.n44;this.n11=i*l*q-k*n*q+k*j*o-h*l*o-i*j*r+h*n*r;this.n12=e*n*q-d*l*q-e*j*o+c*l*o+d*j*r-c*n*r;this.n13=d*k*q-e*i*q+e*h*o-c*k*o-d*h*r+c*i*r;this.n14=e*i*j-d*k*j-e*h*n+c*k*n+d*h*l-c*i*l;this.n21=k*n*p-i*l*p-k*m*o+g*l*o+i*m*r-g*n*r;this.n22=d*l*p-e*n*p+
-e*m*o-b*l*o-d*m*r+b*n*r;this.n23=e*i*p-d*k*p-e*g*o+b*k*o+d*g*r-b*i*r;this.n24=d*k*m-e*i*m+e*g*n-b*k*n-d*g*l+b*i*l;this.n31=h*l*p-k*j*p+k*m*q-g*l*q-h*m*r+g*j*r;this.n32=e*j*p-c*l*p-e*m*q+b*l*q+c*m*r-b*j*r;this.n33=c*k*p-e*h*p+e*g*q-b*k*q-c*g*r+b*h*r;this.n34=e*h*m-c*k*m-e*g*j+b*k*j+c*g*l-b*h*l;this.n41=i*j*p-h*n*p-i*m*q+g*n*q+h*m*o-g*j*o;this.n42=c*n*p-d*j*p+d*m*q-b*n*q-c*m*o+b*j*o;this.n43=d*h*p-c*i*p-d*g*q+b*i*q+c*g*o-b*h*o;this.n44=c*i*m-d*h*m+d*g*j-b*i*j-c*g*n+b*h*n;this.multiplyScalar(1/a.determinant());
-return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,e=a.z,g=Math.cos(c),c=Math.sin(c),h=Math.cos(d),d=Math.sin(d),i=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var k=h*i,m=h*e,j=d*i,n=d*e;this.n11=k+n*c;this.n12=j*c-m;this.n13=g*d;this.n21=g*e;this.n22=g*i;this.n23=-c;this.n31=m*c-j;this.n32=n+k*c;this.n33=g*h;break;case "ZXY":k=h*i;m=h*e;j=d*i;n=d*e;this.n11=k-n*c;this.n12=-g*e;this.n13=j+m*c;this.n21=m+j*c;this.n22=g*i;this.n23=n-k*c;this.n31=-g*d;this.n32=c;this.n33=g*h;break;case "ZYX":k=
-g*i;m=g*e;j=c*i;n=c*e;this.n11=h*i;this.n12=j*d-m;this.n13=k*d+n;this.n21=h*e;this.n22=n*d+k;this.n23=m*d-j;this.n31=-d;this.n32=c*h;this.n33=g*h;break;case "YZX":k=g*h;m=g*d;j=c*h;n=c*d;this.n11=h*i;this.n12=n-k*e;this.n13=j*e+m;this.n21=e;this.n22=g*i;this.n23=-c*i;this.n31=-d*i;this.n32=m*e+j;this.n33=k-n*e;break;case "XZY":k=g*h;m=g*d;j=c*h;n=c*d;this.n11=h*i;this.n12=-e;this.n13=d*i;this.n21=k*e+n;this.n22=g*i;this.n23=m*e-j;this.n31=j*e-m;this.n32=c*i;this.n33=n*e+k;break;default:k=g*i,m=g*
-e,j=c*i,n=c*e,this.n11=h*i,this.n12=-h*e,this.n13=d,this.n21=m+j*d,this.n22=k-n*d,this.n23=-c*h,this.n31=n-k*d,this.n32=j+m*d,this.n33=g*h}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,g=b+b,h=c+c,i=d+d,a=b*g,k=b*h,b=b*i,m=c*h,c=c*i,d=d*i,g=e*g,h=e*h,e=e*i;this.n11=1-(m+d);this.n12=k-e;this.n13=b+h;this.n21=k+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-h;this.n32=c+g;this.n33=1-(a+m);return this},scale:function(a){var b=a.x,c=a.y,a=a.z;this.n11*=b;this.n12*=c;this.n13*=
+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,g=a.x,h=a.y,i=a.z,k=e*g,l=e*h;this.set(k*g+c,k*h-d*i,k*i+d*h,0,k*h+d*i,l*h+c,l*i-d*g,0,k*i-d*h,l*i+d*g,e*i*i+c,0,0,0,0,1);return this},setPosition:function(a){this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},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,g=a.n21,h=a.n22,i=a.n23,k=a.n24,l=a.n31,j=a.n32,n=a.n33,m=a.n34,p=a.n41,r=a.n42,o=a.n43,q=a.n44;this.n11=i*m*r-k*n*r+k*j*o-h*m*o-i*j*q+h*n*q;this.n12=e*n*r-d*m*r-e*j*o+c*m*o+d*j*q-c*n*q;this.n13=d*k*r-e*i*r+e*h*o-c*k*o-d*h*q+c*i*q;this.n14=e*i*j-d*k*j-e*h*n+c*k*n+d*h*m-c*i*m;this.n21=k*n*p-i*m*p-k*l*o+g*m*o+i*l*q-g*n*q;this.n22=d*m*p-e*n*p+
+e*l*o-b*m*o-d*l*q+b*n*q;this.n23=e*i*p-d*k*p-e*g*o+b*k*o+d*g*q-b*i*q;this.n24=d*k*l-e*i*l+e*g*n-b*k*n-d*g*m+b*i*m;this.n31=h*m*p-k*j*p+k*l*r-g*m*r-h*l*q+g*j*q;this.n32=e*j*p-c*m*p-e*l*r+b*m*r+c*l*q-b*j*q;this.n33=c*k*p-e*h*p+e*g*r-b*k*r-c*g*q+b*h*q;this.n34=e*h*l-c*k*l-e*g*j+b*k*j+c*g*m-b*h*m;this.n41=i*j*p-h*n*p-i*l*r+g*n*r+h*l*o-g*j*o;this.n42=c*n*p-d*j*p+d*l*r-b*n*r-c*l*o+b*j*o;this.n43=d*h*p-c*i*p-d*g*r+b*i*r+c*g*o-b*h*o;this.n44=c*i*l-d*h*l+d*g*j-b*i*j-c*g*n+b*h*n;this.multiplyScalar(1/a.determinant());
+return this},setRotationFromEuler:function(a,b){var c=a.x,d=a.y,e=a.z,g=Math.cos(c),c=Math.sin(c),h=Math.cos(d),d=Math.sin(d),i=Math.cos(e),e=Math.sin(e);switch(b){case "YXZ":var k=h*i,l=h*e,j=d*i,n=d*e;this.n11=k+n*c;this.n12=j*c-l;this.n13=g*d;this.n21=g*e;this.n22=g*i;this.n23=-c;this.n31=l*c-j;this.n32=n+k*c;this.n33=g*h;break;case "ZXY":k=h*i;l=h*e;j=d*i;n=d*e;this.n11=k-n*c;this.n12=-g*e;this.n13=j+l*c;this.n21=l+j*c;this.n22=g*i;this.n23=n-k*c;this.n31=-g*d;this.n32=c;this.n33=g*h;break;case "ZYX":k=
+g*i;l=g*e;j=c*i;n=c*e;this.n11=h*i;this.n12=j*d-l;this.n13=k*d+n;this.n21=h*e;this.n22=n*d+k;this.n23=l*d-j;this.n31=-d;this.n32=c*h;this.n33=g*h;break;case "YZX":k=g*h;l=g*d;j=c*h;n=c*d;this.n11=h*i;this.n12=n-k*e;this.n13=j*e+l;this.n21=e;this.n22=g*i;this.n23=-c*i;this.n31=-d*i;this.n32=l*e+j;this.n33=k-n*e;break;case "XZY":k=g*h;l=g*d;j=c*h;n=c*d;this.n11=h*i;this.n12=-e;this.n13=d*i;this.n21=k*e+n;this.n22=g*i;this.n23=l*e-j;this.n31=j*e-l;this.n32=c*i;this.n33=n*e+k;break;default:k=g*i,l=g*
+e,j=c*i,n=c*e,this.n11=h*i,this.n12=-h*e,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=g*h}return this},setRotationFromQuaternion:function(a){var b=a.x,c=a.y,d=a.z,e=a.w,g=b+b,h=c+c,i=d+d,a=b*g,k=b*h,b=b*i,l=c*h,c=c*i,d=d*i,g=e*g,h=e*h,e=e*i;this.n11=1-(l+d);this.n12=k-e;this.n13=b+h;this.n21=k+e;this.n22=1-(a+d);this.n23=c-g;this.n31=b-h;this.n32=c+g;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,g=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);g.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=g.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,g=Math.sqrt(c*c+d*d+e*e),c=c/g,d=d/g,e=e/g,g=c*c,h=d*d,i=e*e,k=Math.cos(b),m=Math.sin(b),j=1-k,n=c*d*j,l=c*e*j,j=d*e*j,c=c*m,p=d*m,m=e*m,e=g+(1-g)*k,g=n+m,d=l-p,n=n-m,h=h+(1-h)*k,m=j+c,l=l+p,j=j-c,i=i+(1-i)*k,k=this.n11,c=this.n21,p=this.n31,q=this.n41,o=this.n12,r=this.n22,y=this.n32,u=this.n42,L=this.n13,A=this.n23,v=this.n33,B=this.n43;this.n11=e*k+g*o+d*L;this.n21=e*c+g*r+d*A;this.n31=e*p+g*y+d*v;this.n41=e*q+g*u+d*B;this.n12=n*k+h*o+m*L;this.n22=
-n*c+h*r+m*A;this.n32=n*p+h*y+m*v;this.n42=n*q+h*u+m*B;this.n13=l*k+j*o+i*L;this.n23=l*c+j*r+i*A;this.n33=l*p+j*y+i*v;this.n43=l*q+j*u+i*B;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,g=this.n13,h=this.n23,i=this.n33,k=this.n43,m=Math.cos(a),a=Math.sin(a);this.n12=m*b+a*g;this.n22=m*c+a*h;this.n32=m*d+a*i;this.n42=m*e+a*k;this.n13=m*g-a*b;this.n23=m*h-a*c;this.n33=m*i-a*d;this.n43=m*k-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,
-g=this.n13,h=this.n23,i=this.n33,k=this.n43,m=Math.cos(a),a=Math.sin(a);this.n11=m*b-a*g;this.n21=m*c-a*h;this.n31=m*d-a*i;this.n41=m*e-a*k;this.n13=m*g+a*b;this.n23=m*h+a*c;this.n33=m*i+a*d;this.n43=m*k+a*e;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,g=this.n12,h=this.n22,i=this.n32,k=this.n42,m=Math.cos(a),a=Math.sin(a);this.n11=m*b+a*g;this.n21=m*c+a*h;this.n31=m*d+a*i;this.n41=m*e+a*k;this.n12=m*g-a*b;this.n22=m*h-a*c;this.n32=m*i-a*d;this.n42=m*k-a*e;return this},
+a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,g=Math.sqrt(c*c+d*d+e*e),c=c/g,d=d/g,e=e/g,g=c*c,h=d*d,i=e*e,k=Math.cos(b),l=Math.sin(b),j=1-k,n=c*d*j,m=c*e*j,j=d*e*j,c=c*l,p=d*l,l=e*l,e=g+(1-g)*k,g=n+l,d=m-p,n=n-l,h=h+(1-h)*k,l=j+c,m=m+p,j=j-c,i=i+(1-i)*k,k=this.n11,c=this.n21,p=this.n31,r=this.n41,o=this.n12,q=this.n22,y=this.n32,u=this.n42,K=this.n13,A=this.n23,v=this.n33,B=this.n43;this.n11=e*k+g*o+d*K;this.n21=e*c+g*q+d*A;this.n31=e*p+g*y+d*v;this.n41=e*r+g*u+d*B;this.n12=n*k+h*o+l*K;this.n22=
+n*c+h*q+l*A;this.n32=n*p+h*y+l*v;this.n42=n*r+h*u+l*B;this.n13=m*k+j*o+i*K;this.n23=m*c+j*q+i*A;this.n33=m*p+j*y+i*v;this.n43=m*r+j*u+i*B;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,g=this.n13,h=this.n23,i=this.n33,k=this.n43,l=Math.cos(a),a=Math.sin(a);this.n12=l*b+a*g;this.n22=l*c+a*h;this.n32=l*d+a*i;this.n42=l*e+a*k;this.n13=l*g-a*b;this.n23=l*h-a*c;this.n33=l*i-a*d;this.n43=l*k-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,
+g=this.n13,h=this.n23,i=this.n33,k=this.n43,l=Math.cos(a),a=Math.sin(a);this.n11=l*b-a*g;this.n21=l*c-a*h;this.n31=l*d-a*i;this.n41=l*e-a*k;this.n13=l*g+a*b;this.n23=l*h+a*c;this.n33=l*i+a*d;this.n43=l*k+a*e;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,g=this.n12,h=this.n22,i=this.n32,k=this.n42,l=Math.cos(a),a=Math.sin(a);this.n11=l*b+a*g;this.n21=l*c+a*h;this.n31=l*d+a*i;this.n41=l*e+a*k;this.n12=l*g-a*b;this.n22=l*h-a*c;this.n32=l*i-a*d;this.n42=l*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,g=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,m=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*m;if(0===a)return null;a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*h;c[4]=a*i;c[5]=a*k;c[6]=a*m;c[7]=a*j;c[8]=a*n;return b};
+THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,g=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*e;c[2]=a*g;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,e,g){var h;h=new THREE.Matrix4;h.n11=2*e/(b-a);h.n12=0;h.n13=(b+a)/(b-a);h.n14=0;h.n21=0;h.n22=2*e/(d-c);h.n23=(d+c)/(d-c);h.n24=0;h.n31=0;h.n32=0;h.n33=-(g+e)/(g-e);h.n34=-2*g*e/(g-e);h.n41=0;h.n42=0;h.n43=-1;h.n44=0;return h};THREE.Matrix4.makePerspective=function(a,b,c,d){var e,a=c*Math.tan(a*Math.PI/360);e=-a;return THREE.Matrix4.makeFrustum(e*b,a*b,e,a,c,d)};
-THREE.Matrix4.makeOrtho=function(a,b,c,d,e,g){var h,i,k,m;h=new THREE.Matrix4;i=b-a;k=c-d;m=g-e;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/m;h.n34=-((g+e)/m);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.makeOrtho=function(a,b,c,d,e,g){var h,i,k,l;h=new THREE.Matrix4;i=b-a;k=c-d;l=g-e;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=-((g+e)/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.id=THREE.Object3DCount++;this.name="";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=!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(a===
 this)console.warn("THREE: Object3D.add(): An object can't be added as a child of itself.");else 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,e;for(c=0,d=this.children.length;c<d;c++){e=this.children[c];if(e.name===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=h[g]=h[g]||new THREE.RenderableObject;g++;return a}function b(){var a=m[k]=m[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,g,h=[],i,k,m=[],j,n,l=[],p,q=[],o,r,y=[],u,L,A=[],v={objects:[],sprites:[],lights:[],elements:[]},B=new THREE.Vector3,C=new THREE.Vector4,I=new THREE.Matrix4,M=new THREE.Matrix4,N=new THREE.Frustum,J=new THREE.Vector4,T=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);I.multiply(b.projectionMatrix,b.matrixWorldInverse);I.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);I.multiply(b.matrixWorld,
-b.projectionMatrixInverse);I.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){g=0;v.objects.length=0;v.sprites.length=0;v.lights.length=0;var h=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||N.contains(b))?(I.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?(I.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,f=b.children.length;c<f;c++)h(b.children[c])}};h(b);d&&v.objects.sort(c);return v};this.projectScene=function(a,e,g){var h=e.near,E=e.far,f,B,ca,pa,R,K,X,Aa,da,Ha,Da,Oa,Pa,Qa,Ua,Va;L=r=p=n=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);I.multiply(e.projectionMatrix,e.matrixWorldInverse);N.setFromMatrix(I);v=this.projectGraph(a,!1);for(a=0,f=v.objects.length;a<f;a++)if(da=v.objects[a].object,Ha=da.matrixWorld,Oa=da.material,k=0,da instanceof THREE.Mesh){Da=da.geometry;Pa=da.geometry.materials;pa=Da.vertices;Qa=Da.faces;Ua=Da.faceVertexUvs;Da=da.matrixRotationWorld.extractRotation(Ha);for(B=0,ca=pa.length;B<ca;B++)i=b(),i.positionWorld.copy(pa[B].position),
-Ha.multiplyVector3(i.positionWorld),i.positionScreen.copy(i.positionWorld),I.multiplyVector4(i.positionScreen),i.positionScreen.x/=i.positionScreen.w,i.positionScreen.y/=i.positionScreen.w,i.visible=i.positionScreen.z>h&&i.positionScreen.z<E;for(pa=0,B=Qa.length;pa<B;pa++){ca=Qa[pa];if(ca instanceof THREE.Face3)if(R=m[ca.a],K=m[ca.b],X=m[ca.c],R.visible&&K.visible&&X.visible&&(da.doubleSided||da.flipSided!=0>(X.positionScreen.x-R.positionScreen.x)*(K.positionScreen.y-R.positionScreen.y)-(X.positionScreen.y-
-R.positionScreen.y)*(K.positionScreen.x-R.positionScreen.x)))Aa=l[n]=l[n]||new THREE.RenderableFace3,n++,j=Aa,j.v1.copy(R),j.v2.copy(K),j.v3.copy(X);else continue;else if(ca instanceof THREE.Face4)if(R=m[ca.a],K=m[ca.b],X=m[ca.c],Aa=m[ca.d],R.visible&&K.visible&&X.visible&&Aa.visible&&(da.doubleSided||da.flipSided!=(0>(Aa.positionScreen.x-R.positionScreen.x)*(K.positionScreen.y-R.positionScreen.y)-(Aa.positionScreen.y-R.positionScreen.y)*(K.positionScreen.x-R.positionScreen.x)||0>(K.positionScreen.x-
-X.positionScreen.x)*(Aa.positionScreen.y-X.positionScreen.y)-(K.positionScreen.y-X.positionScreen.y)*(Aa.positionScreen.x-X.positionScreen.x))))Va=q[p]=q[p]||new THREE.RenderableFace4,p++,j=Va,j.v1.copy(R),j.v2.copy(K),j.v3.copy(X),j.v4.copy(Aa);else continue;j.normalWorld.copy(ca.normal);Da.multiplyVector3(j.normalWorld);j.centroidWorld.copy(ca.centroid);Ha.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);I.multiplyVector3(j.centroidScreen);X=ca.vertexNormals;for(R=0,K=X.length;R<
-K;R++)Aa=j.vertexNormalsWorld[R],Aa.copy(X[R]),Da.multiplyVector3(Aa);for(R=0,K=Ua.length;R<K;R++)if(Va=Ua[R][pa])for(X=0,Aa=Va.length;X<Aa;X++)j.uvs[R][X]=Va[X];j.material=Oa;j.faceMaterial=null!==ca.materialIndex?Pa[ca.materialIndex]:null;j.z=j.centroidScreen.z;v.elements.push(j)}}else if(da instanceof THREE.Line){M.multiply(I,Ha);pa=da.geometry.vertices;R=b();R.positionScreen.copy(pa[0].position);M.multiplyVector4(R.positionScreen);for(B=1,ca=pa.length;B<ca;B++)if(R=b(),R.positionScreen.copy(pa[B].position),
-M.multiplyVector4(R.positionScreen),K=m[k-2],J.copy(R.positionScreen),T.copy(K.positionScreen),d(J,T))J.multiplyScalar(1/J.w),T.multiplyScalar(1/T.w),da=y[r]=y[r]||new THREE.RenderableLine,r++,o=da,o.v1.positionScreen.copy(J),o.v2.positionScreen.copy(T),o.z=Math.max(J.z,T.z),o.material=Oa,v.elements.push(o)}for(a=0,f=v.sprites.length;a<f;a++)if(da=v.sprites[a].object,Ha=da.matrixWorld,da instanceof THREE.Particle&&(C.set(Ha.n14,Ha.n24,Ha.n34,1),I.multiplyVector4(C),C.z/=C.w,0<C.z&&1>C.z))h=A[L]=A[L]||
-new THREE.RenderableParticle,L++,u=h,u.x=C.x/C.w,u.y=C.y/C.w,u.z=C.z,u.rotation=da.rotation.z,u.scale.x=da.scale.x*Math.abs(u.x-(C.x+e.projectionMatrix.n11)/(C.w+e.projectionMatrix.n14)),u.scale.y=da.scale.y*Math.abs(u.y-(C.y+e.projectionMatrix.n22)/(C.w+e.projectionMatrix.n24)),u.material=da.material,v.elements.push(u);g&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
+THREE.Projector=function(){function a(){var a=h[g]=h[g]||new THREE.RenderableObject;g++;return a}function b(){var a=l[k]=l[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,g,h=[],i,k,l=[],j,n,m=[],p,r=[],o,q,y=[],u,K,A=[],v={objects:[],sprites:[],lights:[],elements:[]},B=new THREE.Vector3,C=new THREE.Vector4,I=new THREE.Matrix4,L=new THREE.Matrix4,M=new THREE.Frustum,N=new THREE.Vector4,S=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);I.multiply(b.projectionMatrix,b.matrixWorldInverse);I.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);I.multiply(b.matrixWorld,
+b.projectionMatrixInverse);I.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){g=0;v.objects.length=0;v.sprites.length=0;v.lights.length=0;var h=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||M.contains(b))?(I.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?(I.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,f=b.children.length;c<f;c++)h(b.children[c])}};h(b);d&&v.objects.sort(c);return v};this.projectScene=function(a,e,g){var h=e.near,E=e.far,f,B,ca,qa,J,X,Y,Ba,da,Ja,Ea,Ra,Fa,Sa,Wa,La;K=q=p=n=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);I.multiply(e.projectionMatrix,e.matrixWorldInverse);M.setFromMatrix(I);v=this.projectGraph(a,!1);for(a=0,f=v.objects.length;a<f;a++)if(da=v.objects[a].object,Ja=da.matrixWorld,Ra=da.material,k=0,da instanceof THREE.Mesh){Ea=da.geometry;Fa=da.geometry.materials;qa=Ea.vertices;Sa=Ea.faces;Wa=Ea.faceVertexUvs;Ea=da.matrixRotationWorld.extractRotation(Ja);for(B=0,ca=qa.length;B<ca;B++)i=b(),i.positionWorld.copy(qa[B].position),
+Ja.multiplyVector3(i.positionWorld),i.positionScreen.copy(i.positionWorld),I.multiplyVector4(i.positionScreen),i.positionScreen.x/=i.positionScreen.w,i.positionScreen.y/=i.positionScreen.w,i.visible=i.positionScreen.z>h&&i.positionScreen.z<E;for(qa=0,B=Sa.length;qa<B;qa++){ca=Sa[qa];if(ca instanceof THREE.Face3)if(J=l[ca.a],X=l[ca.b],Y=l[ca.c],J.visible&&X.visible&&Y.visible&&(da.doubleSided||da.flipSided!=0>(Y.positionScreen.x-J.positionScreen.x)*(X.positionScreen.y-J.positionScreen.y)-(Y.positionScreen.y-
+J.positionScreen.y)*(X.positionScreen.x-J.positionScreen.x)))Ba=m[n]=m[n]||new THREE.RenderableFace3,n++,j=Ba,j.v1.copy(J),j.v2.copy(X),j.v3.copy(Y);else continue;else if(ca instanceof THREE.Face4)if(J=l[ca.a],X=l[ca.b],Y=l[ca.c],Ba=l[ca.d],J.visible&&X.visible&&Y.visible&&Ba.visible&&(da.doubleSided||da.flipSided!=(0>(Ba.positionScreen.x-J.positionScreen.x)*(X.positionScreen.y-J.positionScreen.y)-(Ba.positionScreen.y-J.positionScreen.y)*(X.positionScreen.x-J.positionScreen.x)||0>(X.positionScreen.x-
+Y.positionScreen.x)*(Ba.positionScreen.y-Y.positionScreen.y)-(X.positionScreen.y-Y.positionScreen.y)*(Ba.positionScreen.x-Y.positionScreen.x))))La=r[p]=r[p]||new THREE.RenderableFace4,p++,j=La,j.v1.copy(J),j.v2.copy(X),j.v3.copy(Y),j.v4.copy(Ba);else continue;j.normalWorld.copy(ca.normal);Ea.multiplyVector3(j.normalWorld);j.centroidWorld.copy(ca.centroid);Ja.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);I.multiplyVector3(j.centroidScreen);Y=ca.vertexNormals;for(J=0,X=Y.length;J<
+X;J++)Ba=j.vertexNormalsWorld[J],Ba.copy(Y[J]),Ea.multiplyVector3(Ba);for(J=0,X=Wa.length;J<X;J++)if(La=Wa[J][qa])for(Y=0,Ba=La.length;Y<Ba;Y++)j.uvs[J][Y]=La[Y];j.material=Ra;j.faceMaterial=null!==ca.materialIndex?Fa[ca.materialIndex]:null;j.z=j.centroidScreen.z;v.elements.push(j)}}else if(da instanceof THREE.Line){L.multiply(I,Ja);qa=da.geometry.vertices;J=b();J.positionScreen.copy(qa[0].position);L.multiplyVector4(J.positionScreen);for(B=1,ca=qa.length;B<ca;B++)if(J=b(),J.positionScreen.copy(qa[B].position),
+L.multiplyVector4(J.positionScreen),X=l[k-2],N.copy(J.positionScreen),S.copy(X.positionScreen),d(N,S))N.multiplyScalar(1/N.w),S.multiplyScalar(1/S.w),da=y[q]=y[q]||new THREE.RenderableLine,q++,o=da,o.v1.positionScreen.copy(N),o.v2.positionScreen.copy(S),o.z=Math.max(N.z,S.z),o.material=Ra,v.elements.push(o)}for(a=0,f=v.sprites.length;a<f;a++)if(da=v.sprites[a].object,Ja=da.matrixWorld,da instanceof THREE.Particle&&(C.set(Ja.n14,Ja.n24,Ja.n34,1),I.multiplyVector4(C),C.z/=C.w,0<C.z&&1>C.z))h=A[K]=A[K]||
+new THREE.RenderableParticle,K++,u=h,u.x=C.x/C.w,u.y=C.y/C.w,u.z=C.z,u.rotation=da.rotation.z,u.scale.x=da.scale.x*Math.abs(u.x-(C.x+e.projectionMatrix.n11)/(C.w+e.projectionMatrix.n14)),u.scale.y=da.scale.y*Math.abs(u.y-(C.y+e.projectionMatrix.n22)/(C.w+e.projectionMatrix.n24)),u.material=da.material,v.elements.push(u);g&&v.elements.sort(c);return v}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=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},clone:function(){return new THREE.Quaternion(this.x,this.y,this.z,this.w)},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),g=Math.cos(c),c=Math.sin(c),h=a*b,i=d*e;this.w=h*g-i*c;this.x=h*c+i*g;this.y=d*b*g+a*e*c;this.z=a*e*
 g-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,e=this.w,g=a.x,h=a.y,i=a.z,a=a.w;this.x=b*a+e*g+c*i-d*h;this.y=c*a+e*h+d*g-b*i;this.z=d*a+e*i+b*h-c*g;this.w=e*a-b*g-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,e=a.z,g=this.x,h=this.y,i=this.z,k=this.w,m=k*c+h*e-i*d,j=k*d+i*c-g*e,n=k*e+g*d-h*c,c=-g*c-h*d-i*e;b.x=m*k+c*-g+j*-i-n*-h;b.y=j*k+c*-h+n*-g-m*-i;b.z=n*k+c*-i+m*-h-j*-g;return b}};
+a);var c=a.x,d=a.y,e=a.z,g=this.x,h=this.y,i=this.z,k=this.w,l=k*c+h*e-i*d,j=k*d+i*c-g*e,n=k*e+g*d-h*c,c=-g*c-h*d-i*e;b.x=l*k+c*-g+j*-i-n*-h;b.y=j*k+c*-h+n*-g-l*-i;b.z=n*k+c*-i+l*-h-j*-g;return b}};
 THREE.Quaternion.slerp=function(a,b,c,d){var e=a.w*b.w+a.x*b.x+a.y*b.y+a.z*b.z;0>e?(c.w=-b.w,c.x=-b.x,c.y=-b.y,c.z=-b.z,e=-e):c.copy(b);if(1<=Math.abs(e))return c.w=a.w,c.x=a.x,c.y=a.y,c.z=a.z,c;var g=Math.acos(e),e=Math.sqrt(1-e*e);if(0.0010>Math.abs(e))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)*g)/e;d=Math.sin(d*g)/e;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,e,g){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=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=e instanceof Array?e:[];this.vertexTangents=[];this.materialIndex=g;this.centroid=new THREE.Vector3};
 THREE.Face4=function(a,b,c,d,e,g,h){this.a=a;this.b=b;this.c=c;this.d=d;this.normal=e instanceof THREE.Vector3?e:new THREE.Vector3;this.vertexNormals=e instanceof Array?e:[];this.color=g instanceof THREE.Color?g:new THREE.Color;this.vertexColors=g instanceof Array?g:[];this.vertexTangents=[];this.materialIndex=h;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
@@ -88,16 +88,17 @@ b;a++)c=this.faces[a],c.centroid.set(0,0,0),c instanceof THREE.Face3?(c.centroid
 b,c,d,e,g,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],e=this.vertices[c.b],g=this.vertices[c.c],h.sub(g.position,e.position),i.sub(d.position,e.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]))},computeMorphNormals:function(){var a,
-b,c,d,e;for(c=0,d=this.faces.length;c<d;c++){e=this.faces[c];e.__originalVertexNormals=[];for(a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]=e.vertexNormals[a].clone()}var g=new THREE.Geometry;g.faces=this.faces;for(a=0,b=this.morphTargets.length;a<b;a++){var h=this.morphNormals[a];g.vertices=this.morphTargets[a].vertices;g.computeFaceNormals();g.computeVertexNormals();var i,k;for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],i=h.faceNormals[c],k=h.vertexNormals[c],i.copy(e.normal),
-e instanceof THREE.Face3?(k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2])):(k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2]),k.d.copy(e.vertexNormals[3]))}for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){function a(a,b,c,d,e,g,I){i=a.vertices[b].position;k=a.vertices[c].position;m=a.vertices[d].position;j=h[e];n=h[g];l=h[I];p=k.x-i.x;q=m.x-i.x;o=k.y-
-i.y;r=m.y-i.y;y=k.z-i.z;u=m.z-i.z;L=n.u-j.u;A=l.u-j.u;v=n.v-j.v;B=l.v-j.v;C=1/(L*B-A*v);J.set((B*p-v*q)*C,(B*o-v*r)*C,(B*y-v*u)*C);T.set((L*q-A*p)*C,(L*r-A*o)*C,(L*u-A*y)*C);M[b].addSelf(J);M[c].addSelf(J);M[d].addSelf(J);N[b].addSelf(T);N[c].addSelf(T);N[d].addSelf(T)}var b,c,d,e,g,h,i,k,m,j,n,l,p,q,o,r,y,u,L,A,v,B,C,I,M=[],N=[],J=new THREE.Vector3,T=new THREE.Vector3,wa=new THREE.Vector3,la=new THREE.Vector3,aa=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)M[b]=new THREE.Vector3,N[b]=
-new THREE.Vector3;for(b=0,c=this.faces.length;b<c;b++)g=this.faces[b],h=this.faceVertexUvs[0][b],g instanceof THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):g instanceof THREE.Face4&&(a(this,g.a,g.b,g.c,0,1,2),a(this,g.a,g.b,g.d,0,1,3));var $=["a","b","c","d"];for(b=0,c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++)aa.copy(g.vertexNormals[d]),e=g[$[d]],I=M[e],wa.copy(I),wa.subSelf(aa.multiplyScalar(aa.dot(I))).normalize(),la.cross(g.vertexNormals[d],I),e=la.dot(N[e]),e=0>
-e?-1:1,g.vertexTangents[d]=new THREE.Vector4(wa.x,wa.y,wa.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);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}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};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),g,h;for(g=0,h=this.vertices.length;g<h;g++)d=this.vertices[g].position,d=[Math.round(d.x*e),Math.round(d.y*
-e),Math.round(d.z*e)].join("_"),void 0===a[d]?(a[d]=g,b.push(this.vertices[g]),c[g]=b.length-1):c[g]=c[a[d]];for(g=0,h=this.faces.length;g<h;g++)if(a=this.faces[g],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,g,h){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*h+(-3*(b-c)-2*a-d)*g+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,g,h,i,k,m,j,n,l;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;g=Math.floor(e);h=e-g;c[0]=0===g?g:g-1;c[1]=g;c[2]=g>this.points.length-2?g:g+1;c[3]=g>this.points.length-3?g:g+2;m=this.points[c[0]];j=this.points[c[1]];
-n=this.points[c[2]];l=this.points[c[3]];i=h*h;k=h*i;d.x=b(m.x,j.x,n.x,l.x,h,i,k);d.y=b(m.y,j.y,n.y,l.y,h,i,k);d.z=b(m.z,j.z,n.z,l.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,e=b=b=0,g=new THREE.Vector3,h=new THREE.Vector3,i=[],j=0;i[0]=0;a||(a=100);c=this.points.length*a;g.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,d=this.getPoint(b),h.copy(d),j+=h.distanceTo(g),
-g.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(i[b]=j,e=b);i[i.length]=j;return{chunks:i,total:j}};this.reparametrizeByArcLength=function(a){var b,c,d,e,g,h,i=[],j=new THREE.Vector3,l=this.getLength();i.push(j.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=l.chunks[b]-l.chunks[b-1];h=Math.ceil(a*c/l.total);e=(b-1)/(this.points.length-1);g=b/(this.points.length-1);for(c=1;c<h-1;c++)d=e+c*(1/h)*(g-e),d=this.getPoint(d),i.push(j.copy(d).clone());i.push(j.copy(this.points[b]).clone())}this.points=
+b,c,d,e;for(c=0,d=this.faces.length;c<d;c++){e=this.faces[c];e.__originalFaceNormal?e.__originalFaceNormal.copy(e.normal):e.__originalFaceNormal=e.normal.clone();if(!e.__originalVertexNormals)e.__originalVertexNormals=[];for(a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]?e.__originalVertexNormals[a].copy(e.vertexNormals[a]):e.__originalVertexNormals[a]=e.vertexNormals[a].clone()}var g=new THREE.Geometry;g.faces=this.faces;for(a=0,b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]=
+{};this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=[];var h=this.morphNormals[a].faceNormals,i=this.morphNormals[a].vertexNormals,k,l;for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],k=new THREE.Vector3,l=e instanceof THREE.Face3?{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3}:{a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3,d:new THREE.Vector3},h.push(k),i.push(l)}h=this.morphNormals[a];g.vertices=this.morphTargets[a].vertices;g.computeFaceNormals();
+g.computeVertexNormals();for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],k=h.faceNormals[c],l=h.vertexNormals[c],k.copy(e.normal),e instanceof THREE.Face3?(l.a.copy(e.vertexNormals[0]),l.b.copy(e.vertexNormals[1]),l.c.copy(e.vertexNormals[2])):(l.a.copy(e.vertexNormals[0]),l.b.copy(e.vertexNormals[1]),l.c.copy(e.vertexNormals[2]),l.d.copy(e.vertexNormals[3]))}for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],e.normal=e.__originalFaceNormal,e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){function a(a,
+b,c,d,e,g,I){i=a.vertices[b].position;k=a.vertices[c].position;l=a.vertices[d].position;j=h[e];n=h[g];m=h[I];p=k.x-i.x;r=l.x-i.x;o=k.y-i.y;q=l.y-i.y;y=k.z-i.z;u=l.z-i.z;K=n.u-j.u;A=m.u-j.u;v=n.v-j.v;B=m.v-j.v;C=1/(K*B-A*v);N.set((B*p-v*r)*C,(B*o-v*q)*C,(B*y-v*u)*C);S.set((K*r-A*p)*C,(K*q-A*o)*C,(K*u-A*y)*C);L[b].addSelf(N);L[c].addSelf(N);L[d].addSelf(N);M[b].addSelf(S);M[c].addSelf(S);M[d].addSelf(S)}var b,c,d,e,g,h,i,k,l,j,n,m,p,r,o,q,y,u,K,A,v,B,C,I,L=[],M=[],N=new THREE.Vector3,S=new THREE.Vector3,
+xa=new THREE.Vector3,ma=new THREE.Vector3,T=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)L[b]=new THREE.Vector3,M[b]=new THREE.Vector3;for(b=0,c=this.faces.length;b<c;b++)g=this.faces[b],h=this.faceVertexUvs[0][b],g instanceof THREE.Face3?a(this,g.a,g.b,g.c,0,1,2):g instanceof THREE.Face4&&(a(this,g.a,g.b,g.c,0,1,2),a(this,g.a,g.b,g.d,0,1,3));var aa=["a","b","c","d"];for(b=0,c=this.faces.length;b<c;b++){g=this.faces[b];for(d=0;d<g.vertexNormals.length;d++)T.copy(g.vertexNormals[d]),e=
+g[aa[d]],I=L[e],xa.copy(I),xa.subSelf(T.multiplyScalar(T.dot(I))).normalize(),ma.cross(g.vertexNormals[d],I),e=ma.dot(M[e]),e=0>e?-1:1,g.vertexTangents[d]=new THREE.Vector4(xa.x,xa.y,xa.z,e)}this.hasTangents=!0},computeBoundingBox:function(){if(!this.boundingBox)this.boundingBox={min:new THREE.Vector3,max:new THREE.Vector3};if(0<this.vertices.length){var a;a=this.vertices[0].position;this.boundingBox.min.copy(a);this.boundingBox.max.copy(a);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}}else this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0)},computeBoundingSphere:function(){if(!this.boundingSphere)this.boundingSphere={radius:0};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),g,h;for(g=0,h=this.vertices.length;g<h;g++)d=this.vertices[g].position,d=[Math.round(d.x*e),Math.round(d.y*e),Math.round(d.z*e)].join("_"),void 0===a[d]?(a[d]=g,b.push(this.vertices[g]),c[g]=b.length-1):c[g]=c[a[d]];for(g=0,h=this.faces.length;g<h;g++)if(a=this.faces[g],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,g,h){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*h+(-3*(b-c)-2*a-d)*g+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,g,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){e=(this.points.length-1)*a;g=Math.floor(e);h=e-g;c[0]=0===g?g:g-1;c[1]=g;c[2]=g>this.points.length-2?g:g+1;c[3]=g>this.points.length-3?g:g+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,e=b=b=0,g=new THREE.Vector3,h=new THREE.Vector3,i=[],j=0;i[0]=0;a||(a=100);c=this.points.length*a;g.copy(this.points[0]);for(a=1;a<c;a++)b=a/c,d=this.getPoint(b),h.copy(d),j+=h.distanceTo(g),
+g.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(i[b]=j,e=b);i[i.length]=j;return{chunks:i,total:j}};this.reparametrizeByArcLength=function(a){var b,c,d,e,g,h,i=[],j=new THREE.Vector3,m=this.getLength();i.push(j.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=m.chunks[b]-m.chunks[b-1];h=Math.ceil(a*c/m.total);e=(b-1)/(this.points.length-1);g=b/(this.points.length-1);for(c=1;c<h-1;c++)d=e+c*(1/h)*(g-e),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,e,g){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!==g?g: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;
@@ -130,7 +131,7 @@ a.fog?a.fog:!1;this.lights=void 0!==a.lights?a.lights:!1;this.vertexColors=void
 THREE.Texture=function(a,b,c,d,e,g,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!==e?e:THREE.LinearFilter;this.minFilter=void 0!==g?g: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,e,g,h,i,k,m){THREE.Texture.call(this,null,g,h,i,k,m,d,e);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,e,g,h,i,k,l){THREE.Texture.call(this,null,g,h,i,k,l,d,e);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;
@@ -189,124 +190,125 @@ 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 g=d.attributes[e];if(!g.__webglInitialized||g.createUniqueBuffers){g.__webglInitialized=!0;var h=1;"v2"===g.type?h=2:"v3"===g.type?h=3:"v4"===g.type?h=4:"c"===g.type&&(h=3);g.size=h;g.array=new Float32Array(c*h);g.buffer=f.createBuffer();g.buffer.belongsToAttribute=e;g.needsUpdate=!0}a.__webglCustomAttributesList.push(g)}}}
 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 g(a,b,c){var d,e,g,h,i=a.vertices;h=i.length;
-var j=a.colors,l=j.length,k=a.__vertexArray,m=a.__colorArray,n=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,q=a.__webglCustomAttributesList;if(c.sortParticles){Wa.multiplySelf(c.matrixWorld);for(d=0;d<h;d++)e=i[d].position,Ja.copy(e),Wa.multiplyVector3(Ja),n[d]=[Ja.z,d];n.sort(function(a,b){return b[0]-a[0]});for(d=0;d<h;d++)e=i[n[d][1]].position,g=3*d,k[g]=e.x,k[g+1]=e.y,k[g+2]=e.z;for(d=0;d<l;d++)g=3*d,e=j[n[d][1]],m[g]=e.r,m[g+1]=e.g,m[g+2]=e.b;if(q)for(j=0,l=q.length;j<l;j++)if(i=q[j],
+var j=a.colors,m=j.length,l=a.__vertexArray,k=a.__colorArray,n=a.__sortArray,o=a.__dirtyVertices,p=a.__dirtyColors,r=a.__webglCustomAttributesList;if(c.sortParticles){Xa.multiplySelf(c.matrixWorld);for(d=0;d<h;d++)e=i[d].position,Ma.copy(e),Xa.multiplyVector3(Ma),n[d]=[Ma.z,d];n.sort(function(a,b){return b[0]-a[0]});for(d=0;d<h;d++)e=i[n[d][1]].position,g=3*d,l[g]=e.x,l[g+1]=e.y,l[g+2]=e.z;for(d=0;d<m;d++)g=3*d,e=j[n[d][1]],k[g]=e.r,k[g+1]=e.g,k[g+2]=e.b;if(r)for(j=0,m=r.length;j<m;j++)if(i=r[j],
 void 0===i.boundTo||"vertices"===i.boundTo)if(g=0,e=i.value.length,1===i.size)for(d=0;d<e;d++)h=n[d][1],i.array[d]=i.value[h];else if(2===i.size)for(d=0;d<e;d++)h=n[d][1],h=i.value[h],i.array[g]=h.x,i.array[g+1]=h.y,g+=2;else if(3===i.size)if("c"===i.type)for(d=0;d<e;d++)h=n[d][1],h=i.value[h],i.array[g]=h.r,i.array[g+1]=h.g,i.array[g+2]=h.b,g+=3;else for(d=0;d<e;d++)h=n[d][1],h=i.value[h],i.array[g]=h.x,i.array[g+1]=h.y,i.array[g+2]=h.z,g+=3;else if(4===i.size)for(d=0;d<e;d++)h=n[d][1],h=i.value[h],
-i.array[g]=h.x,i.array[g+1]=h.y,i.array[g+2]=h.z,i.array[g+3]=h.w,g+=4}else{if(o)for(d=0;d<h;d++)e=i[d].position,g=3*d,k[g]=e.x,k[g+1]=e.y,k[g+2]=e.z;if(p)for(d=0;d<l;d++)e=j[d],g=3*d,m[g]=e.r,m[g+1]=e.g,m[g+2]=e.b;if(q)for(j=0,l=q.length;j<l;j++)if(i=q[j],i.needsUpdate&&(void 0===i.boundTo||"vertices"===i.boundTo))if(e=i.value.length,g=0,1===i.size)for(d=0;d<e;d++)i.array[d]=i.value[d];else if(2===i.size)for(d=0;d<e;d++)h=i.value[d],i.array[g]=h.x,i.array[g+1]=h.y,g+=2;else if(3===i.size)if("c"===
-i.type)for(d=0;d<e;d++)h=i.value[d],i.array[g]=h.r,i.array[g+1]=h.g,i.array[g+2]=h.b,g+=3;else for(d=0;d<e;d++)h=i.value[d],i.array[g]=h.x,i.array[g+1]=h.y,i.array[g+2]=h.z,g+=3;else if(4===i.size)for(d=0;d<e;d++)h=i.value[d],i.array[g]=h.x,i.array[g+1]=h.y,i.array[g+2]=h.z,i.array[g+3]=h.w,g+=4}if(o||c.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,a.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,k,b);if(p||c.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,a.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,
-m,b);if(q)for(j=0,l=q.length;j<l;j++)if(i=q[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++)X=ca=null,R=K=Pa=Oa=Da=-1,a[d].render(b,c,kc,lc),X=ca=null,R=K=Pa=Oa=Da=-1}function k(a,b,c,d,f,e,g,h){var i,j,l,k;b?(j=a.length-1,k=b=-1):(j=0,b=a.length,k=1);for(var m=j;m!==b;m+=k)if(i=a[m],i.render){j=i.object;l=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;
-g&&E.setBlending(i.blending);E.setDepthTest(i.depthTest);E.setDepthWrite(i.depthWrite);y(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}E.setObjectFaces(j);l instanceof THREE.BufferGeometry?E.renderBufferDirect(d,f,e,i,l,j):E.renderBuffer(d,f,e,i,l,j)}}function m(a,b,c,d,f,e,g){for(var h,i,j=0,l=a.length;j<l;j++)if(h=a[j],i=h.object,i.visible){if(g)h=g;else{h=h[b];if(!h)continue;e&&E.setBlending(h.blending);E.setDepthTest(h.depthTest);E.setDepthWrite(h.depthWrite);y(h.polygonOffset,h.polygonOffsetFactor,
-h.polygonOffsetUnits)}E.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 l(a){for(var b in a.attributes)a.attributes[b].needsUpdate=!1}function p(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 o(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 g=0,h=E.maxMorphTargets;g<h;g++)e.__webglMorphTargetInfluences[g]=0}var i=!1,g=d.program,h=g.uniforms,j=d.uniforms;g!==ca&&(f.useProgram(g),ca=g,i=!0);if(d.id!==R)R=d.id,i=!0;if(i||a!==X)f.uniformMatrix4fv(h.projectionMatrix,!1,a._projectionMatrixArray),a!==X&&(X=a);if(i){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 l,k=0,m=0,n=0,q,o,p,r=mc,u=r.directional.colors,y=r.directional.positions,v=r.point.colors,A=r.point.positions,I=r.point.distances,M=0,J=0,N=p=0;for(c=0,i=b.length;c<i;c++)if(l=b[c],!l.onlyShadow)if(q=l.color,o=l.intensity,p=l.distance,l instanceof THREE.AmbientLight)E.gammaInput?(k+=q.r*q.r,m+=q.g*q.g,n+=q.b*q.b):(k+=q.r,m+=q.g,n+=q.b);else if(l instanceof THREE.DirectionalLight)p=
-3*M,E.gammaInput?(u[p]=q.r*q.r*o*o,u[p+1]=q.g*q.g*o*o,u[p+2]=q.b*q.b*o*o):(u[p]=q.r*o,u[p+1]=q.g*o,u[p+2]=q.b*o),mb.copy(l.matrixWorld.getPosition()),mb.subSelf(l.target.matrixWorld.getPosition()),mb.normalize(),y[p]=mb.x,y[p+1]=mb.y,y[p+2]=mb.z,M+=1;else if(l instanceof THREE.PointLight||l instanceof THREE.SpotLight)N=3*J,E.gammaInput?(v[N]=q.r*q.r*o*o,v[N+1]=q.g*q.g*o*o,v[N+2]=q.b*q.b*o*o):(v[N]=q.r*o,v[N+1]=q.g*o,v[N+2]=q.b*o),l=l.matrixWorld.getPosition(),A[N]=l.x,A[N+1]=l.y,A[N+2]=l.z,I[J]=p,
-J+=1;for(c=3*M,i=u.length;c<i;c++)u[c]=0;for(c=3*J,i=v.length;c<i;c++)v[c]=0;r.point.length=J;r.directional.length=M;r.ambient[0]=k;r.ambient[1]=m;r.ambient[2]=n;c=mc;j.ambientLightColor.value=c.ambient;j.directionalLightColor.value=c.directional.colors;j.directionalLightDirection.value=c.directional.positions;j.pointLightColor.value=c.point.colors;j.pointLightPosition.value=c.point.positions;j.pointLightDistance.value=c.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||
+i.array[g]=h.x,i.array[g+1]=h.y,i.array[g+2]=h.z,i.array[g+3]=h.w,g+=4}else{if(o)for(d=0;d<h;d++)e=i[d].position,g=3*d,l[g]=e.x,l[g+1]=e.y,l[g+2]=e.z;if(p)for(d=0;d<m;d++)e=j[d],g=3*d,k[g]=e.r,k[g+1]=e.g,k[g+2]=e.b;if(r)for(j=0,m=r.length;j<m;j++)if(i=r[j],i.needsUpdate&&(void 0===i.boundTo||"vertices"===i.boundTo))if(e=i.value.length,g=0,1===i.size)for(d=0;d<e;d++)i.array[d]=i.value[d];else if(2===i.size)for(d=0;d<e;d++)h=i.value[d],i.array[g]=h.x,i.array[g+1]=h.y,g+=2;else if(3===i.size)if("c"===
+i.type)for(d=0;d<e;d++)h=i.value[d],i.array[g]=h.r,i.array[g+1]=h.g,i.array[g+2]=h.b,g+=3;else for(d=0;d<e;d++)h=i.value[d],i.array[g]=h.x,i.array[g+1]=h.y,i.array[g+2]=h.z,g+=3;else if(4===i.size)for(d=0;d<e;d++)h=i.value[d],i.array[g]=h.x,i.array[g+1]=h.y,i.array[g+2]=h.z,i.array[g+3]=h.w,g+=4}if(o||c.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,a.__webglVertexBuffer),f.bufferData(f.ARRAY_BUFFER,l,b);if(p||c.sortParticles)f.bindBuffer(f.ARRAY_BUFFER,a.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,
+k,b);if(r)for(j=0,m=r.length;j<m;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++)Y=ca=null,J=X=Fa=Ra=Ea=-1,a[d].render(b,c,lc,mc),Y=ca=null,J=X=Fa=Ra=Ea=-1}function k(a,b,c,d,f,e,g,h){var i,j,m,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;m=i.buffer;if(h)i=h;else{i=i[c];if(!i)continue;
+g&&E.setBlending(i.blending);E.setDepthTest(i.depthTest);E.setDepthWrite(i.depthWrite);y(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}E.setObjectFaces(j);m instanceof THREE.BufferGeometry?E.renderBufferDirect(d,f,e,i,m,j):E.renderBuffer(d,f,e,i,m,j)}}function l(a,b,c,d,f,e,g){for(var h,i,j=0,m=a.length;j<m;j++)if(h=a[j],i=h.object,i.visible){if(g)h=g;else{h=h[b];if(!h)continue;e&&E.setBlending(h.blending);E.setDepthTest(h.depthTest);E.setDepthWrite(h.depthWrite);y(h.polygonOffset,h.polygonOffsetFactor,
+h.polygonOffsetUnits)}E.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 p(a,b){for(var c=a.length-1;0<=c;c--)a[c].object===b&&a.splice(c,1)}function r(a,b){for(var c=a.length-1;0<=c;c--)a[c]===b&&a.splice(c,1)}function o(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 g=0,h=E.maxMorphTargets;g<h;g++)e.__webglMorphTargetInfluences[g]=0}var i=!1,g=d.program,h=g.uniforms,j=d.uniforms;g!==ca&&(f.useProgram(g),ca=g,i=!0);if(d.id!==J)J=d.id,i=!0;if(i||a!==Y)f.uniformMatrix4fv(h.projectionMatrix,!1,a._projectionMatrixArray),a!==Y&&(Y=a);if(i){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 m,l=0,k=0,n=0,r,o,p,q=nc,u=q.directional.colors,y=q.directional.positions,v=q.point.colors,A=q.point.positions,I=q.point.distances,L=0,N=0,M=p=0;for(c=0,i=b.length;c<i;c++)if(m=b[c],!m.onlyShadow)if(r=m.color,o=m.intensity,p=m.distance,m instanceof THREE.AmbientLight)E.gammaInput?(l+=r.r*r.r,k+=r.g*r.g,n+=r.b*r.b):(l+=r.r,k+=r.g,n+=r.b);else if(m instanceof THREE.DirectionalLight)p=
+3*L,E.gammaInput?(u[p]=r.r*r.r*o*o,u[p+1]=r.g*r.g*o*o,u[p+2]=r.b*r.b*o*o):(u[p]=r.r*o,u[p+1]=r.g*o,u[p+2]=r.b*o),nb.copy(m.matrixWorld.getPosition()),nb.subSelf(m.target.matrixWorld.getPosition()),nb.normalize(),y[p]=nb.x,y[p+1]=nb.y,y[p+2]=nb.z,L+=1;else if(m instanceof THREE.PointLight||m instanceof THREE.SpotLight)M=3*N,E.gammaInput?(v[M]=r.r*r.r*o*o,v[M+1]=r.g*r.g*o*o,v[M+2]=r.b*r.b*o*o):(v[M]=r.r*o,v[M+1]=r.g*o,v[M+2]=r.b*o),m=m.matrixWorld.getPosition(),A[M]=m.x,A[M+1]=m.y,A[M+2]=m.z,I[N]=p,
+N+=1;for(c=3*L,i=u.length;c<i;c++)u[c]=0;for(c=3*N,i=v.length;c<i;c++)v[c]=0;q.point.length=N;q.directional.length=L;q.ambient[0]=l;q.ambient[1]=k;q.ambient[2]=n;c=nc;j.ambientLightColor.value=c.ambient;j.directionalLightColor.value=c.directional.colors;j.directionalLightDirection.value=c.directional.positions;j.pointLightColor.value=c.point.colors;j.pointLightPosition.value=c.point.positions;j.pointLightDistance.value=c.point.distances}if(d instanceof THREE.MeshBasicMaterial||d instanceof THREE.MeshLambertMaterial||
 d instanceof THREE.MeshPhongMaterial)j.opacity.value=d.opacity,E.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=C.height/2,j.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)j.shininess.value=d.shininess,E.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)E.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){i=
-c=0;for(k=b.length;i<k;i++)if(m=b[i],m.castShadow&&(m instanceof THREE.SpotLight||m instanceof THREE.DirectionalLight&&!m.shadowCascade))j.shadowMap.texture[c]=m.shadowMap,j.shadowMapSize.value[c]=m.shadowMapSize,j.shadowMatrix.value[c]=m.shadowMatrix,j.shadowDarkness.value[c]=m.shadowDarkness,j.shadowBias.value[c]=m.shadowBias,c++}b=d.uniformsList;for(j=0,c=b.length;j<c;j++)if(m=g.uniforms[b[j][1]])if(i=b[j][0],n=i.type,k=i.value,"i"===n)f.uniform1i(m,k);else if("f"===n)f.uniform1f(m,k);else if("v2"===
-n)f.uniform2f(m,k.x,k.y);else if("v3"===n)f.uniform3f(m,k.x,k.y,k.z);else if("v4"===n)f.uniform4f(m,k.x,k.y,k.z,k.w);else if("c"===n)f.uniform3f(m,k.r,k.g,k.b);else if("fv1"===n)f.uniform1fv(m,k);else if("fv"===n)f.uniform3fv(m,k);else if("v2v"===n){if(!i._array)i._array=new Float32Array(2*k.length);for(n=0,r=k.length;n<r;n++)u=2*n,i._array[u]=k[n].x,i._array[u+1]=k[n].y;f.uniform2fv(m,i._array)}else if("v3v"===n){if(!i._array)i._array=new Float32Array(3*k.length);for(n=0,r=k.length;n<r;n++)u=3*n,
-i._array[u]=k[n].x,i._array[u+1]=k[n].y,i._array[u+2]=k[n].z;f.uniform3fv(m,i._array)}else if("v4v"==n){if(!i._array)i._array=new Float32Array(4*k.length);for(n=0,r=k.length;n<r;n++)u=4*n,i._array[u]=k[n].x,i._array[u+1]=k[n].y,i._array[u+2]=k[n].z,i._array[u+3]=k[n].w;f.uniform4fv(m,i._array)}else if("m4"===n){if(!i._array)i._array=new Float32Array(16);k.flattenToArray(i._array);f.uniformMatrix4fv(m,!1,i._array)}else if("m4v"===n){if(!i._array)i._array=new Float32Array(16*k.length);for(n=0,r=k.length;n<
-r;n++)k[n].flattenToArrayOffset(i._array,16*n);f.uniformMatrix4fv(m,!1,i._array)}else if("t"===n){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++){n=k;r=m;if(E.autoScaleCubemaps){if(u=i.image[m],v=Dc,!(u.width<=v&&u.height<=v))A=Math.max(u.width,
-u.height),y=Math.floor(u.width*v/A),v=Math.floor(u.height*v/A),A=document.createElement("canvas"),A.width=y,A.height=v,A.getContext("2d").drawImage(u,0,0,u.width,u.height,0,0,y,v),u=A}else u=i.image[m];n[r]=u}m=k[0];n=0===(m.width&m.width-1)&&0===(m.height&m.height-1);r=B(i.format);u=B(i.type);L(f.TEXTURE_CUBE_MAP,i,n);for(m=0;6>m;m++)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+m,0,r,r,u,k[m]);i.generateMipmaps&&n&&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)):E.setTexture(m,k)}else if("tv"===n){if(!i._array){i._array=[];for(n=0,r=i.texture.length;n<r;n++)i._array[n]=k+n}f.uniform1iv(m,i._array);for(n=0,r=i.texture.length;n<r;n++)(m=i.texture[n])&&E.setTexture(m,i._array[n])}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&
+c=0;for(l=b.length;i<l;i++)if(k=b[i],k.castShadow&&(k instanceof THREE.SpotLight||k instanceof THREE.DirectionalLight&&!k.shadowCascade))j.shadowMap.texture[c]=k.shadowMap,j.shadowMapSize.value[c]=k.shadowMapSize,j.shadowMatrix.value[c]=k.shadowMatrix,j.shadowDarkness.value[c]=k.shadowDarkness,j.shadowBias.value[c]=k.shadowBias,c++}b=d.uniformsList;for(j=0,c=b.length;j<c;j++)if(k=g.uniforms[b[j][1]])if(i=b[j][0],n=i.type,l=i.value,"i"===n)f.uniform1i(k,l);else if("f"===n)f.uniform1f(k,l);else if("v2"===
+n)f.uniform2f(k,l.x,l.y);else if("v3"===n)f.uniform3f(k,l.x,l.y,l.z);else if("v4"===n)f.uniform4f(k,l.x,l.y,l.z,l.w);else if("c"===n)f.uniform3f(k,l.r,l.g,l.b);else if("fv1"===n)f.uniform1fv(k,l);else if("fv"===n)f.uniform3fv(k,l);else if("v2v"===n){if(!i._array)i._array=new Float32Array(2*l.length);for(n=0,q=l.length;n<q;n++)u=2*n,i._array[u]=l[n].x,i._array[u+1]=l[n].y;f.uniform2fv(k,i._array)}else if("v3v"===n){if(!i._array)i._array=new Float32Array(3*l.length);for(n=0,q=l.length;n<q;n++)u=3*n,
+i._array[u]=l[n].x,i._array[u+1]=l[n].y,i._array[u+2]=l[n].z;f.uniform3fv(k,i._array)}else if("v4v"==n){if(!i._array)i._array=new Float32Array(4*l.length);for(n=0,q=l.length;n<q;n++)u=4*n,i._array[u]=l[n].x,i._array[u+1]=l[n].y,i._array[u+2]=l[n].z,i._array[u+3]=l[n].w;f.uniform4fv(k,i._array)}else if("m4"===n){if(!i._array)i._array=new Float32Array(16);l.flattenToArray(i._array);f.uniformMatrix4fv(k,!1,i._array)}else if("m4v"===n){if(!i._array)i._array=new Float32Array(16*l.length);for(n=0,q=l.length;n<
+q;n++)l[n].flattenToArrayOffset(i._array,16*n);f.uniformMatrix4fv(k,!1,i._array)}else if("t"===n){if(f.uniform1i(k,l),k=i.texture)if(k.image instanceof Array&&6===k.image.length){if(i=k,6===i.image.length)if(i.needsUpdate){if(!i.image.__webglTextureCube)i.image.__webglTextureCube=f.createTexture();f.activeTexture(f.TEXTURE0+l);f.bindTexture(f.TEXTURE_CUBE_MAP,i.image.__webglTextureCube);l=[];for(k=0;6>k;k++){n=l;q=k;if(E.autoScaleCubemaps){if(u=i.image[k],v=Ec,!(u.width<=v&&u.height<=v))A=Math.max(u.width,
+u.height),y=Math.floor(u.width*v/A),v=Math.floor(u.height*v/A),A=document.createElement("canvas"),A.width=y,A.height=v,A.getContext("2d").drawImage(u,0,0,u.width,u.height,0,0,y,v),u=A}else u=i.image[k];n[q]=u}k=l[0];n=0===(k.width&k.width-1)&&0===(k.height&k.height-1);q=B(i.format);u=B(i.type);K(f.TEXTURE_CUBE_MAP,i,n);for(k=0;6>k;k++)f.texImage2D(f.TEXTURE_CUBE_MAP_POSITIVE_X+k,0,q,q,u,l[k]);i.generateMipmaps&&n&&f.generateMipmap(f.TEXTURE_CUBE_MAP);i.needsUpdate=!1;if(i.onUpdated)i.onUpdated()}else f.activeTexture(f.TEXTURE0+
+l),f.bindTexture(f.TEXTURE_CUBE_MAP,i.image.__webglTextureCube)}else k instanceof THREE.WebGLRenderTargetCube?(i=k,f.activeTexture(f.TEXTURE0+l),f.bindTexture(f.TEXTURE_CUBE_MAP,i.__webglTexture)):E.setTexture(k,l)}else if("tv"===n){if(!i._array){i._array=[];for(n=0,q=i.texture.length;n<q;n++)i._array[n]=l+n}f.uniform1iv(k,i._array);for(n=0,q=i.texture.length;n<q;n++)(k=i.texture[n])&&E.setTexture(k,i._array[n])}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&
 null!==h.cameraPosition)b=a.matrixWorld.getPosition(),f.uniform3f(h.cameraPosition,b.x,b.y,b.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.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 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 y(a,b,c){Qa!==a&&(a?f.enable(f.POLYGON_OFFSET_FILL):f.disable(f.POLYGON_OFFSET_FILL),Qa=a);if(a&&(Ua!==b||Va!==c))f.polygonOffset(b,
-c),Ua=b,Va=c}function u(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 L(a,b,c){c?(f.texParameteri(a,f.TEXTURE_WRAP_S,B(b.wrapS)),f.texParameteri(a,f.TEXTURE_WRAP_T,B(b.wrapT)),f.texParameteri(a,f.TEXTURE_MAG_FILTER,B(b.magFilter)),f.texParameteri(a,f.TEXTURE_MIN_FILTER,B(b.minFilter))):
+(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&null!==h.objectMatrix&&f.uniformMatrix4fv(h.objectMatrix,!1,e._objectMatrixArray);return g}function q(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){Sa!==a&&(a?f.enable(f.POLYGON_OFFSET_FILL):f.disable(f.POLYGON_OFFSET_FILL),Sa=a);if(a&&(Wa!==b||La!==c))f.polygonOffset(b,
+c),Wa=b,La=c}function u(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,B(b.wrapS)),f.texParameteri(a,f.TEXTURE_WRAP_T,B(b.wrapT)),f.texParameteri(a,f.TEXTURE_MAG_FILTER,B(b.magFilter)),f.texParameteri(a,f.TEXTURE_MIN_FILTER,B(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,v(b.magFilter)),f.texParameteri(a,f.TEXTURE_MIN_FILTER,v(b.minFilter)))}function A(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 v(a){switch(a){case THREE.NearestFilter:case THREE.NearestMipMapNearestFilter:case THREE.NearestMipMapLinearFilter:return f.NEAREST;default:return f.LINEAR}}function B(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||{},C=void 0!==a.canvas?a.canvas:document.createElement("canvas"),I=void 0!==a.precision?a.precision:"mediump",M=void 0!==a.alpha?a.alpha:!0,N=void 0!==a.premultipliedAlpha?
-a.premultipliedAlpha:!0,J=void 0!==a.antialias?a.antialias:!1,T=void 0!==a.stencil?a.stencil:!0,wa=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,la=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),aa=void 0!==a.clearAlpha?a.clearAlpha:0,$=void 0!==a.maxLights?a.maxLights:4;this.domElement=C;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapEnabled=
-this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.shadowMapCascade=this.shadowMapDebug=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;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 E=this,f,Ta=[],ca=null,pa=null,R=-1,K=null,X=null,Aa=0,da=null,Ha=null,Da=null,Oa=null,Pa=
-null,Qa=null,Ua=null,Va=null,sb=null,Mb=0,Wb=0,Gb=0,Nb=0,kc=0,lc=0,Xb=new THREE.Frustum,Wa=new THREE.Matrix4,Ja=new THREE.Vector4,mb=new THREE.Vector3,mc={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};f=function(){var a;try{if(!(a=C.getContext("experimental-webgl",{alpha:M,premultipliedAlpha:N,antialias:J,stencil:T,preserveDrawingBuffer:wa})))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(la.r,la.g,la.b,aa);this.context=f;var nc=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
-f.getParameter(f.MAX_TEXTURE_SIZE);var Dc=f.getParameter(f.MAX_CUBE_MAP_TEXTURE_SIZE);this.getContext=function(){return f};this.supportsVertexTextures=function(){return 0<nc};this.setSize=function(a,b){C.width=a;C.height=b;this.setViewport(0,0,C.width,C.height)};this.setViewport=function(a,b,c,d){Mb=a;Wb=b;Gb=c;Nb=d;f.viewport(Mb,Wb,Gb,Nb)};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){la.setHex(a);aa=b;f.clearColor(la.r,la.g,la.b,aa)};this.setClearColor=function(a,b){la.copy(a);aa=b;f.clearColor(la.r,la.g,la.b,aa)};this.getClearColor=function(){return la};this.getClearAlpha=function(){return aa};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);
+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||{},C=void 0!==a.canvas?a.canvas:document.createElement("canvas"),I=void 0!==a.precision?a.precision:"mediump",L=void 0!==a.alpha?a.alpha:!0,M=void 0!==a.premultipliedAlpha?
+a.premultipliedAlpha:!0,N=void 0!==a.antialias?a.antialias:!1,S=void 0!==a.stencil?a.stencil:!0,xa=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,ma=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),T=void 0!==a.clearAlpha?a.clearAlpha:0,aa=void 0!==a.maxLights?a.maxLights:4;this.domElement=C;this.context=null;this.autoUpdateScene=this.autoUpdateObjects=this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.shadowMapEnabled=
+this.physicallyBasedShading=this.gammaOutput=this.gammaInput=!1;this.shadowMapCullFrontFaces=this.shadowMapSoft=this.shadowMapAutoUpdate=!0;this.shadowMapCascade=this.shadowMapDebug=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;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 E=this,f,Va=[],ca=null,qa=null,J=-1,X=null,Y=null,Ba=0,da=null,Ja=null,Ea=null,Ra=null,Fa=
+null,Sa=null,Wa=null,La=null,tb=null,Nb=0,Xb=0,Hb=0,Ob=0,lc=0,mc=0,Yb=new THREE.Frustum,Xa=new THREE.Matrix4,Ma=new THREE.Vector4,nb=new THREE.Vector3,nc={ambient:[0,0,0],directional:{length:0,colors:[],positions:[]},point:{length:0,colors:[],positions:[],distances:[]}};f=function(){var a;try{if(!(a=C.getContext("experimental-webgl",{alpha:L,premultipliedAlpha:M,antialias:N,stencil:S,preserveDrawingBuffer:xa})))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(ma.r,ma.g,ma.b,T);this.context=f;var oc=f.getParameter(f.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
+f.getParameter(f.MAX_TEXTURE_SIZE);var Ec=f.getParameter(f.MAX_CUBE_MAP_TEXTURE_SIZE);this.getContext=function(){return f};this.supportsVertexTextures=function(){return 0<oc};this.setSize=function(a,b){C.width=a;C.height=b;this.setViewport(0,0,C.width,C.height)};this.setViewport=function(a,b,c,d){Nb=a;Xb=b;Hb=c;Ob=d;f.viewport(Nb,Xb,Hb,Ob)};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){ma.setHex(a);T=b;f.clearColor(ma.r,ma.g,ma.b,T)};this.setClearColor=function(a,b){ma.copy(a);T=b;f.clearColor(ma.r,ma.g,ma.b,T)};this.getClearColor=function(){return ma};this.getClearAlpha=function(){return T};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]),f.deleteBuffer(c.__webglMorphNormalsBuffers[d]);
-if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)f.deleteBuffer(c.__webglCustomAttributesList[d].buffer);E.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),E.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),E.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=
-a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),E.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,f.deleteTexture(a.__webglTexture),E.info.memory.textures--};this.updateShadowMap=function(a,b){ca=null;R=K=Pa=Oa=Da=-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,k,m,n,l,q=3*a.count;for(l=0;l<q;l+=9)c=a.normalArray,d=c[l],e=c[l+1],g=c[l+2],h=c[l+3],j=c[l+4],m=c[l+5],i=c[l+6],k=c[l+7],n=c[l+8],d=(d+h+i)/3,e=(e+j+k)/3,g=
-(g+m+n)/3,c[l]=d,c[l+1]=e,c[l+2]=g,c[l+3]=d,c[l+4]=e,c[l+5]=g,c[l+6]=d,c[l+7]=e,c[l+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=o(a,b,c,d,g),a=c.attributes,b=!1,d=16777215*e.id+2*c.id+(d.wireframe?1:0),d!==K&&(K=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),E.info.render.calls++,E.info.render.vertices+=g[d].count,E.info.render.faces+=g[d].count/3}};this.renderBuffer=function(a,
-b,c,d,e,g){if(0!==d.opacity){var h,i,c=o(a,b,c,d,g),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0);c!==K&&(K=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),d.morphNormals&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[j[h]]),f.vertexAttribPointer(c["morphNormal"+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 m,n=i.length;h=0;for(-1!==g.morphTargetBase&&(j[g.morphTargetBase]=!0);h<d.numSupportedMorphTargets;){for(m=0;m<n;m++)!j[m]&&i[m]>l&&(k=m,l=i[k]);f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[k]);f.vertexAttribPointer(c["morphTarget"+h],3,f.FLOAT,!1,0,0);d.morphNormals&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[k]),f.vertexAttribPointer(c["morphNormal"+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!==sb&&(f.lineWidth(d),sb=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)),E.info.render.calls++,E.info.render.vertices+=
-e.__webglFaceCount,E.info.render.faces+=e.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?f.LINE_STRIP:f.LINES,d=d.linewidth,d!==sb&&(f.lineWidth(d),sb=d),f.drawArrays(g,0,e.__webglLineCount),E.info.render.calls++):g instanceof THREE.ParticleSystem?(f.drawArrays(f.POINTS,0,e.__webglParticleCount),E.info.render.calls++,E.info.render.points+=e.__webglParticleCount):g instanceof THREE.Ribbon&&(f.drawArrays(f.TRIANGLE_STRIP,0,e.__webglVertexCount),E.info.render.calls++)}};this.render=
-function(a,b,c,d){var e,g,j,l,n=a.lights,q=a.fog;R=-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);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);Wa.multiply(b.projectionMatrix,b.matrixWorldInverse);Xb.setFromMatrix(Wa);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);l=a.__webglObjects;for(d=0,e=l.length;d<e;d++)if(g=l[d],j=g.object,g.render=!1,j.visible&&(!(j instanceof THREE.Mesh||j instanceof THREE.ParticleSystem)||!j.frustumCulled||Xb.contains(j))){j.matrixWorld.flattenToArray(j._objectMatrixArray);
-r(j,b);var o=g,p=o.object,u=o.buffer,v=void 0,v=v=void 0,v=p.material;if(v instanceof THREE.MeshFaceMaterial){if(v=u.materialIndex,0<=v)v=p.geometry.materials[v],v.transparent?(o.transparent=v,o.opaque=null):(o.opaque=v,o.transparent=null)}else if(v)v.transparent?(o.transparent=v,o.opaque=null):(o.opaque=v,o.transparent=null);g.render=!0;if(this.sortObjects)j.renderDepth?g.z=j.renderDepth:(Ja.copy(j.position),Wa.multiplyVector3(Ja),g.z=Ja.z)}this.sortObjects&&l.sort(h);l=a.__webglObjectsImmediate;
-for(d=0,e=l.length;d<e;d++)if(g=l[d],j=g.object,j.visible)j.matrixAutoUpdate&&j.matrixWorld.flattenToArray(j._objectMatrixArray),r(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,n,q,!0,a.overrideMaterial),m(a.__webglObjectsImmediate,"",b,n,q,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),k(a.__webglObjects,!0,"opaque",b,n,q,!1),m(a.__webglObjectsImmediate,"opaque",b,n,q,!1),k(a.__webglObjects,!1,"transparent",b,n,q,!0),m(a.__webglObjectsImmediate,"transparent",b,n,q,!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.setDepthTest(!0);this.setDepthWrite(!0)};this.renderImmediateObject=function(a,b,c,d,e){var g=o(a,b,c,d,e);K=-1;E.setObjectFaces(e);e.immediateRenderCallback?e.immediateRenderCallback(g,f,Xb):e.render(function(a){E.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,m=void 0,k=void 0,o=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 r=k,u=void 0,v=void 0,y=void 0,A=void 0,L=void 0,C=void 0,B=void 0,I={},M=r.morphTargets.length;r.geometryGroups={};for(u=0,v=r.faces.length;u<v;u++)y=r.faces[u],A=y.materialIndex,C=void 0!==A?A:-1,void 0===I[C]&&(I[C]={hash:C,counter:0}),B=I[C].hash+"_"+I[C].counter,void 0===r.geometryGroups[B]&&(r.geometryGroups[B]={faces3:[],faces4:[],materialIndex:A,vertices:0,numMorphTargets:M}),L=y instanceof THREE.Face3?3:4,65535<r.geometryGroups[B].vertices+
-L&&(I[C].counter+=1,B=I[C].hash+"_"+I[C].counter,void 0===r.geometryGroups[B]&&(r.geometryGroups[B]={faces3:[],faces4:[],materialIndex:A,vertices:0,numMorphTargets:M})),y instanceof THREE.Face3?r.geometryGroups[B].faces3.push(u):r.geometryGroups[B].faces4.push(u),r.geometryGroups[B].vertices+=L;r.geometryGroupsList=[];var N=void 0;for(N in r.geometryGroups)r.geometryGroups[N].id=Aa++,r.geometryGroupsList.push(r.geometryGroups[N])}for(m in k.geometryGroups)if(o=k.geometryGroups[m],!o.__webglVertexBuffer){var J=
-o;J.__webglVertexBuffer=f.createBuffer();J.__webglNormalBuffer=f.createBuffer();J.__webglTangentBuffer=f.createBuffer();J.__webglColorBuffer=f.createBuffer();J.__webglUVBuffer=f.createBuffer();J.__webglUV2Buffer=f.createBuffer();J.__webglSkinVertexABuffer=f.createBuffer();J.__webglSkinVertexBBuffer=f.createBuffer();J.__webglSkinIndicesBuffer=f.createBuffer();J.__webglSkinWeightsBuffer=f.createBuffer();J.__webglFaceBuffer=f.createBuffer();J.__webglLineBuffer=f.createBuffer();if(J.numMorphTargets){var R=
-void 0,aa=void 0;J.__webglMorphTargetsBuffers=[];J.__webglMorphNormalsBuffers=[];for(R=0,aa=J.numMorphTargets;R<aa;R++)J.__webglMorphTargetsBuffers.push(f.createBuffer()),J.__webglMorphNormalsBuffers.push(f.createBuffer())}E.info.memory.geometries++;var K=o,$=h,X=$.geometry,ca=K.faces3,da=K.faces4,T=3*ca.length+4*da.length,la=1*ca.length+2*da.length,wa=3*ca.length+4*da.length,pa=c($,K),Da=e(pa),Ha=d(pa),Oa=pa.vertexColors?pa.vertexColors:!1;K.__vertexArray=new Float32Array(3*T);if(Ha)K.__normalArray=
-new Float32Array(3*T);if(X.hasTangents)K.__tangentArray=new Float32Array(4*T);if(Oa)K.__colorArray=new Float32Array(3*T);if(Da){if(0<X.faceUvs.length||0<X.faceVertexUvs.length)K.__uvArray=new Float32Array(2*T);if(1<X.faceUvs.length||1<X.faceVertexUvs.length)K.__uv2Array=new Float32Array(2*T)}if($.geometry.skinWeights.length&&$.geometry.skinIndices.length)K.__skinVertexAArray=new Float32Array(4*T),K.__skinVertexBArray=new Float32Array(4*T),K.__skinIndexArray=new Float32Array(4*T),K.__skinWeightArray=
-new Float32Array(4*T);K.__faceArray=new Uint16Array(3*la);K.__lineArray=new Uint16Array(2*wa);if(K.numMorphTargets){K.__morphTargetsArrays=[];K.__morphNormalsArrays=[];for(var Pa=0,Va=K.numMorphTargets;Pa<Va;Pa++)K.__morphTargetsArrays.push(new Float32Array(3*T)),K.__morphNormalsArrays.push(new Float32Array(3*T))}K.__webglFaceCount=3*la;K.__webglLineCount=2*wa;if(pa.attributes){if(void 0===K.__webglCustomAttributesList)K.__webglCustomAttributesList=[];var Ta=void 0;for(Ta in pa.attributes){var Qa=
-pa.attributes[Ta],Ia={},Ua;for(Ua in Qa)Ia[Ua]=Qa[Ua];if(!Ia.__webglInitialized||Ia.createUniqueBuffers){Ia.__webglInitialized=!0;var Ja=1;"v2"===Ia.type?Ja=2:"v3"===Ia.type?Ja=3:"v4"===Ia.type?Ja=4:"c"===Ia.type&&(Ja=3);Ia.size=Ja;Ia.array=new Float32Array(T*Ja);Ia.buffer=f.createBuffer();Ia.buffer.belongsToAttribute=Ta;Qa.needsUpdate=!0;Ia.__original=Qa}K.__webglCustomAttributesList.push(Ia)}}K.__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 mb=k;mb.__webglVertexBuffer=f.createBuffer();mb.__webglColorBuffer=f.createBuffer();E.info.memory.geometries++;var Wa=k,sb=Wa.vertices.length;Wa.__vertexArray=new Float32Array(3*sb);Wa.__colorArray=new Float32Array(3*sb);Wa.__webglVertexCount=sb;k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(h instanceof THREE.Line){if(k=h.geometry,!k.__webglVertexBuffer){var Mb=
-k;Mb.__webglVertexBuffer=f.createBuffer();Mb.__webglColorBuffer=f.createBuffer();E.info.memory.geometries++;var Yb=k,Wb=h,Gb=Yb.vertices.length;Yb.__vertexArray=new Float32Array(3*Gb);Yb.__colorArray=new Float32Array(3*Gb);Yb.__webglLineCount=Gb;b(Yb,Wb);k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(h instanceof THREE.ParticleSystem&&(k=h.geometry,!k.__webglVertexBuffer)){var Nb=k;Nb.__webglVertexBuffer=f.createBuffer();Nb.__webglColorBuffer=f.createBuffer();E.info.geometries++;var Ob=k,Xb=h,Ec=
-Ob.vertices.length;Ob.__vertexArray=new Float32Array(3*Ec);Ob.__colorArray=new Float32Array(3*Ec);Ob.__sortArray=[];Ob.__webglParticleCount=Ec;b(Ob,Xb);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(m in k.geometryGroups)o=k.geometryGroups[m],j(i.__webglObjects,o,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 Ka=a.__objectsRemoved[0],oc=a;Ka instanceof THREE.Mesh||Ka instanceof THREE.ParticleSystem||Ka instanceof THREE.Ribbon||Ka instanceof THREE.Line?
-p(oc.__webglObjects,Ka):Ka instanceof THREE.Sprite?q(oc.__webglSprites,Ka):Ka instanceof THREE.LensFlare?q(oc.__webglFlares,Ka):(Ka instanceof THREE.MarchingCubes||Ka.immediateRenderCallback)&&p(oc.__webglObjectsImmediate,Ka);Ka.__webglActive=!1;a.__objectsRemoved.splice(0,1)}for(var Fc=0,kc=a.__webglObjects.length;Fc<kc;Fc++){var Ra=a.__webglObjects[Fc].object,S=Ra.geometry,Zb=void 0,Pb=void 0,Ba=void 0;if(Ra instanceof THREE.Mesh)if(S instanceof THREE.BufferGeometry)S.__dirtyVertices=!1,S.__dirtyElements=
-!1,S.__dirtyUvs=!1,S.__dirtyNormals=!1,S.__dirtyColors=!1;else{for(var Gc=0,lc=S.geometryGroupsList.length;Gc<lc;Gc++)if(Zb=S.geometryGroupsList[Gc],Ba=c(Ra,Zb),Pb=Ba.attributes&&n(Ba),S.__dirtyVertices||S.__dirtyMorphTargets||S.__dirtyElements||S.__dirtyUvs||S.__dirtyNormals||S.__dirtyColors||S.__dirtyTangents||Pb){var P=Zb,mc=Ra,Ea=f.DYNAMIC_DRAW,nc=!S.dynamic,Hb=Ba;if(P.__inittedArrays){var Pc=d(Hb),Hc=Hb.vertexColors?Hb.vertexColors:!1,Qc=e(Hb),pc=Pc===THREE.SmoothShading,w=void 0,D=void 0,Na=
-void 0,z=void 0,Qb=void 0,tb=void 0,Sa=void 0,qc=void 0,nb=void 0,Rb=void 0,Sb=void 0,F=void 0,G=void 0,H=void 0,Y=void 0,Xa=void 0,Ya=void 0,Za=void 0,$b=void 0,$a=void 0,ab=void 0,bb=void 0,ac=void 0,cb=void 0,db=void 0,eb=void 0,bc=void 0,fb=void 0,gb=void 0,hb=void 0,cc=void 0,ib=void 0,jb=void 0,kb=void 0,dc=void 0,ub=void 0,vb=void 0,wb=void 0,rc=void 0,xb=void 0,yb=void 0,zb=void 0,sc=void 0,U=void 0,Rc=void 0,Ab=void 0,Tb=void 0,Ub=void 0,sa=void 0,Sc=void 0,qa=void 0,ra=void 0,Bb=void 0,
-ob=void 0,ka=0,oa=0,pb=0,qb=0,La=0,xa=0,Z=0,ya=0,ma=0,x=0,O=0,t=0,Fa=void 0,ta=P.__vertexArray,ec=P.__uvArray,fc=P.__uv2Array,Ma=P.__normalArray,ea=P.__tangentArray,ua=P.__colorArray,fa=P.__skinVertexAArray,ga=P.__skinVertexBArray,ha=P.__skinIndexArray,ia=P.__skinWeightArray,Ic=P.__morphTargetsArrays,Jc=P.__morphNormalsArrays,Kc=P.__webglCustomAttributesList,s=void 0,lb=P.__faceArray,Ga=P.__lineArray,za=mc.geometry,Dc=za.__dirtyElements,Tc=za.__dirtyUvs,$c=za.__dirtyNormals,ad=za.__dirtyTangents,
-bd=za.__dirtyColors,cd=za.__dirtyMorphTargets,Ib=za.vertices,V=P.faces3,W=P.faces4,na=za.faces,Lc=za.faceVertexUvs[0],Mc=za.faceVertexUvs[1],Jb=za.skinVerticesA,Kb=za.skinVerticesB,Lb=za.skinIndices,Cb=za.skinWeights,Db=za.morphTargets,tc=za.morphNormals;if(za.__dirtyVertices){for(w=0,D=V.length;w<D;w++)z=na[V[w]],F=Ib[z.a].position,G=Ib[z.b].position,H=Ib[z.c].position,ta[oa]=F.x,ta[oa+1]=F.y,ta[oa+2]=F.z,ta[oa+3]=G.x,ta[oa+4]=G.y,ta[oa+5]=G.z,ta[oa+6]=H.x,ta[oa+7]=H.y,ta[oa+8]=H.z,oa+=9;for(w=0,
-D=W.length;w<D;w++)z=na[W[w]],F=Ib[z.a].position,G=Ib[z.b].position,H=Ib[z.c].position,Y=Ib[z.d].position,ta[oa]=F.x,ta[oa+1]=F.y,ta[oa+2]=F.z,ta[oa+3]=G.x,ta[oa+4]=G.y,ta[oa+5]=G.z,ta[oa+6]=H.x,ta[oa+7]=H.y,ta[oa+8]=H.z,ta[oa+9]=Y.x,ta[oa+10]=Y.y,ta[oa+11]=Y.z,oa+=12;f.bindBuffer(f.ARRAY_BUFFER,P.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,ta,Ea)}if(cd)for(sa=0,Sc=Db.length;sa<Sc;sa++){O=0;for(w=0,D=V.length;w<D;w++){Bb=V[w];z=na[Bb];F=Db[sa].vertices[z.a].position;G=Db[sa].vertices[z.b].position;
-H=Db[sa].vertices[z.c].position;qa=Ic[sa];qa[O]=F.x;qa[O+1]=F.y;qa[O+2]=F.z;qa[O+3]=G.x;qa[O+4]=G.y;qa[O+5]=G.z;qa[O+6]=H.x;qa[O+7]=H.y;qa[O+8]=H.z;if(Hb.morphNormals)pc?(ob=tc[sa].vertexNormals[Bb],$a=ob.a,ab=ob.b,bb=ob.c):bb=ab=$a=tc[sa].faceNormals[Bb],ra=Jc[sa],ra[O]=$a.x,ra[O+1]=$a.y,ra[O+2]=$a.z,ra[O+3]=ab.x,ra[O+4]=ab.y,ra[O+5]=ab.z,ra[O+6]=bb.x,ra[O+7]=bb.y,ra[O+8]=bb.z;O+=9}for(w=0,D=W.length;w<D;w++){Bb=W[w];z=na[Bb];F=Db[sa].vertices[z.a].position;G=Db[sa].vertices[z.b].position;H=Db[sa].vertices[z.c].position;
-Y=Db[sa].vertices[z.d].position;qa=Ic[sa];qa[O]=F.x;qa[O+1]=F.y;qa[O+2]=F.z;qa[O+3]=G.x;qa[O+4]=G.y;qa[O+5]=G.z;qa[O+6]=H.x;qa[O+7]=H.y;qa[O+8]=H.z;qa[O+9]=Y.x;qa[O+10]=Y.y;qa[O+11]=Y.z;if(Hb.morphNormals)pc?(ob=tc[sa].vertexNormals[Bb],$a=ob.a,ab=ob.b,bb=ob.c,ac=ob.d):ac=bb=ab=$a=tc[sa].faceNormals[Bb],ra=Jc[sa],ra[O]=$a.x,ra[O+1]=$a.y,ra[O+2]=$a.z,ra[O+3]=ab.x,ra[O+4]=ab.y,ra[O+5]=ab.z,ra[O+6]=bb.x,ra[O+7]=bb.y,ra[O+8]=bb.z,ra[O+9]=ac.x,ra[O+10]=ac.y,ra[O+11]=ac.z;O+=12}f.bindBuffer(f.ARRAY_BUFFER,
-P.__webglMorphTargetsBuffers[sa]);f.bufferData(f.ARRAY_BUFFER,Ic[sa],Ea);Hb.morphNormals&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglMorphNormalsBuffers[sa]),f.bufferData(f.ARRAY_BUFFER,Jc[sa],Ea))}if(Cb.length){for(w=0,D=V.length;w<D;w++)z=na[V[w]],fb=Cb[z.a],gb=Cb[z.b],hb=Cb[z.c],ia[x]=fb.x,ia[x+1]=fb.y,ia[x+2]=fb.z,ia[x+3]=fb.w,ia[x+4]=gb.x,ia[x+5]=gb.y,ia[x+6]=gb.z,ia[x+7]=gb.w,ia[x+8]=hb.x,ia[x+9]=hb.y,ia[x+10]=hb.z,ia[x+11]=hb.w,ib=Lb[z.a],jb=Lb[z.b],kb=Lb[z.c],ha[x]=ib.x,ha[x+1]=ib.y,ha[x+2]=ib.z,
-ha[x+3]=ib.w,ha[x+4]=jb.x,ha[x+5]=jb.y,ha[x+6]=jb.z,ha[x+7]=jb.w,ha[x+8]=kb.x,ha[x+9]=kb.y,ha[x+10]=kb.z,ha[x+11]=kb.w,ub=Jb[z.a],vb=Jb[z.b],wb=Jb[z.c],fa[x]=ub.x,fa[x+1]=ub.y,fa[x+2]=ub.z,fa[x+3]=1,fa[x+4]=vb.x,fa[x+5]=vb.y,fa[x+6]=vb.z,fa[x+7]=1,fa[x+8]=wb.x,fa[x+9]=wb.y,fa[x+10]=wb.z,fa[x+11]=1,xb=Kb[z.a],yb=Kb[z.b],zb=Kb[z.c],ga[x]=xb.x,ga[x+1]=xb.y,ga[x+2]=xb.z,ga[x+3]=1,ga[x+4]=yb.x,ga[x+5]=yb.y,ga[x+6]=yb.z,ga[x+7]=1,ga[x+8]=zb.x,ga[x+9]=zb.y,ga[x+10]=zb.z,ga[x+11]=1,x+=12;for(w=0,D=W.length;w<
-D;w++)z=na[W[w]],fb=Cb[z.a],gb=Cb[z.b],hb=Cb[z.c],cc=Cb[z.d],ia[x]=fb.x,ia[x+1]=fb.y,ia[x+2]=fb.z,ia[x+3]=fb.w,ia[x+4]=gb.x,ia[x+5]=gb.y,ia[x+6]=gb.z,ia[x+7]=gb.w,ia[x+8]=hb.x,ia[x+9]=hb.y,ia[x+10]=hb.z,ia[x+11]=hb.w,ia[x+12]=cc.x,ia[x+13]=cc.y,ia[x+14]=cc.z,ia[x+15]=cc.w,ib=Lb[z.a],jb=Lb[z.b],kb=Lb[z.c],dc=Lb[z.d],ha[x]=ib.x,ha[x+1]=ib.y,ha[x+2]=ib.z,ha[x+3]=ib.w,ha[x+4]=jb.x,ha[x+5]=jb.y,ha[x+6]=jb.z,ha[x+7]=jb.w,ha[x+8]=kb.x,ha[x+9]=kb.y,ha[x+10]=kb.z,ha[x+11]=kb.w,ha[x+12]=dc.x,ha[x+13]=dc.y,
-ha[x+14]=dc.z,ha[x+15]=dc.w,ub=Jb[z.a],vb=Jb[z.b],wb=Jb[z.c],rc=Jb[z.d],fa[x]=ub.x,fa[x+1]=ub.y,fa[x+2]=ub.z,fa[x+3]=1,fa[x+4]=vb.x,fa[x+5]=vb.y,fa[x+6]=vb.z,fa[x+7]=1,fa[x+8]=wb.x,fa[x+9]=wb.y,fa[x+10]=wb.z,fa[x+11]=1,fa[x+12]=rc.x,fa[x+13]=rc.y,fa[x+14]=rc.z,fa[x+15]=1,xb=Kb[z.a],yb=Kb[z.b],zb=Kb[z.c],sc=Kb[z.d],ga[x]=xb.x,ga[x+1]=xb.y,ga[x+2]=xb.z,ga[x+3]=1,ga[x+4]=yb.x,ga[x+5]=yb.y,ga[x+6]=yb.z,ga[x+7]=1,ga[x+8]=zb.x,ga[x+9]=zb.y,ga[x+10]=zb.z,ga[x+11]=1,ga[x+12]=sc.x,ga[x+13]=sc.y,ga[x+14]=sc.z,
-ga[x+15]=1,x+=16;0<x&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglSkinVertexABuffer),f.bufferData(f.ARRAY_BUFFER,fa,Ea),f.bindBuffer(f.ARRAY_BUFFER,P.__webglSkinVertexBBuffer),f.bufferData(f.ARRAY_BUFFER,ga,Ea),f.bindBuffer(f.ARRAY_BUFFER,P.__webglSkinIndicesBuffer),f.bufferData(f.ARRAY_BUFFER,ha,Ea),f.bindBuffer(f.ARRAY_BUFFER,P.__webglSkinWeightsBuffer),f.bufferData(f.ARRAY_BUFFER,ia,Ea))}if(bd&&Hc){for(w=0,D=V.length;w<D;w++)z=na[V[w]],Sa=z.vertexColors,qc=z.color,3===Sa.length&&Hc===THREE.VertexColors?
-(cb=Sa[0],db=Sa[1],eb=Sa[2]):eb=db=cb=qc,ua[ma]=cb.r,ua[ma+1]=cb.g,ua[ma+2]=cb.b,ua[ma+3]=db.r,ua[ma+4]=db.g,ua[ma+5]=db.b,ua[ma+6]=eb.r,ua[ma+7]=eb.g,ua[ma+8]=eb.b,ma+=9;for(w=0,D=W.length;w<D;w++)z=na[W[w]],Sa=z.vertexColors,qc=z.color,4===Sa.length&&Hc===THREE.VertexColors?(cb=Sa[0],db=Sa[1],eb=Sa[2],bc=Sa[3]):bc=eb=db=cb=qc,ua[ma]=cb.r,ua[ma+1]=cb.g,ua[ma+2]=cb.b,ua[ma+3]=db.r,ua[ma+4]=db.g,ua[ma+5]=db.b,ua[ma+6]=eb.r,ua[ma+7]=eb.g,ua[ma+8]=eb.b,ua[ma+9]=bc.r,ua[ma+10]=bc.g,ua[ma+11]=bc.b,ma+=
-12;0<ma&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,ua,Ea))}if(ad&&za.hasTangents){for(w=0,D=V.length;w<D;w++)z=na[V[w]],nb=z.vertexTangents,Xa=nb[0],Ya=nb[1],Za=nb[2],ea[Z]=Xa.x,ea[Z+1]=Xa.y,ea[Z+2]=Xa.z,ea[Z+3]=Xa.w,ea[Z+4]=Ya.x,ea[Z+5]=Ya.y,ea[Z+6]=Ya.z,ea[Z+7]=Ya.w,ea[Z+8]=Za.x,ea[Z+9]=Za.y,ea[Z+10]=Za.z,ea[Z+11]=Za.w,Z+=12;for(w=0,D=W.length;w<D;w++)z=na[W[w]],nb=z.vertexTangents,Xa=nb[0],Ya=nb[1],Za=nb[2],$b=nb[3],ea[Z]=Xa.x,ea[Z+1]=Xa.y,ea[Z+2]=Xa.z,ea[Z+
-3]=Xa.w,ea[Z+4]=Ya.x,ea[Z+5]=Ya.y,ea[Z+6]=Ya.z,ea[Z+7]=Ya.w,ea[Z+8]=Za.x,ea[Z+9]=Za.y,ea[Z+10]=Za.z,ea[Z+11]=Za.w,ea[Z+12]=$b.x,ea[Z+13]=$b.y,ea[Z+14]=$b.z,ea[Z+15]=$b.w,Z+=16;f.bindBuffer(f.ARRAY_BUFFER,P.__webglTangentBuffer);f.bufferData(f.ARRAY_BUFFER,ea,Ea)}if($c&&Pc){for(w=0,D=V.length;w<D;w++)if(z=na[V[w]],Qb=z.vertexNormals,tb=z.normal,3===Qb.length&&pc)for(U=0;3>U;U++)Ab=Qb[U],Ma[xa]=Ab.x,Ma[xa+1]=Ab.y,Ma[xa+2]=Ab.z,xa+=3;else for(U=0;3>U;U++)Ma[xa]=tb.x,Ma[xa+1]=tb.y,Ma[xa+2]=tb.z,xa+=3;
-for(w=0,D=W.length;w<D;w++)if(z=na[W[w]],Qb=z.vertexNormals,tb=z.normal,4===Qb.length&&pc)for(U=0;4>U;U++)Ab=Qb[U],Ma[xa]=Ab.x,Ma[xa+1]=Ab.y,Ma[xa+2]=Ab.z,xa+=3;else for(U=0;4>U;U++)Ma[xa]=tb.x,Ma[xa+1]=tb.y,Ma[xa+2]=tb.z,xa+=3;f.bindBuffer(f.ARRAY_BUFFER,P.__webglNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Ma,Ea)}if(Tc&&Lc&&Qc){for(w=0,D=V.length;w<D;w++)if(Na=V[w],z=na[Na],Rb=Lc[Na],void 0!==Rb)for(U=0;3>U;U++)Tb=Rb[U],ec[pb]=Tb.u,ec[pb+1]=Tb.v,pb+=2;for(w=0,D=W.length;w<D;w++)if(Na=W[w],z=na[Na],
-Rb=Lc[Na],void 0!==Rb)for(U=0;4>U;U++)Tb=Rb[U],ec[pb]=Tb.u,ec[pb+1]=Tb.v,pb+=2;0<pb&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglUVBuffer),f.bufferData(f.ARRAY_BUFFER,ec,Ea))}if(Tc&&Mc&&Qc){for(w=0,D=V.length;w<D;w++)if(Na=V[w],z=na[Na],Sb=Mc[Na],void 0!==Sb)for(U=0;3>U;U++)Ub=Sb[U],fc[qb]=Ub.u,fc[qb+1]=Ub.v,qb+=2;for(w=0,D=W.length;w<D;w++)if(Na=W[w],z=na[Na],Sb=Mc[Na],void 0!==Sb)for(U=0;4>U;U++)Ub=Sb[U],fc[qb]=Ub.u,fc[qb+1]=Ub.v,qb+=2;0<qb&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglUV2Buffer),f.bufferData(f.ARRAY_BUFFER,
-fc,Ea))}if(Dc){for(w=0,D=V.length;w<D;w++)z=na[V[w]],lb[La]=ka,lb[La+1]=ka+1,lb[La+2]=ka+2,La+=3,Ga[ya]=ka,Ga[ya+1]=ka+1,Ga[ya+2]=ka,Ga[ya+3]=ka+2,Ga[ya+4]=ka+1,Ga[ya+5]=ka+2,ya+=6,ka+=3;for(w=0,D=W.length;w<D;w++)z=na[W[w]],lb[La]=ka,lb[La+1]=ka+1,lb[La+2]=ka+3,lb[La+3]=ka+1,lb[La+4]=ka+2,lb[La+5]=ka+3,La+=6,Ga[ya]=ka,Ga[ya+1]=ka+1,Ga[ya+2]=ka,Ga[ya+3]=ka+3,Ga[ya+4]=ka+1,Ga[ya+5]=ka+2,Ga[ya+6]=ka+2,Ga[ya+7]=ka+3,ya+=8,ka+=4;f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,P.__webglFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,
-lb,Ea);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,P.__webglLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ga,Ea)}if(Kc)for(U=0,Rc=Kc.length;U<Rc;U++)if(s=Kc[U],s.__original.needsUpdate){t=0;if(1===s.size)if(void 0===s.boundTo||"vertices"===s.boundTo){for(w=0,D=V.length;w<D;w++)z=na[V[w]],s.array[t]=s.value[z.a],s.array[t+1]=s.value[z.b],s.array[t+2]=s.value[z.c],t+=3;for(w=0,D=W.length;w<D;w++)z=na[W[w]],s.array[t]=s.value[z.a],s.array[t+1]=s.value[z.b],s.array[t+2]=s.value[z.c],s.array[t+3]=s.value[z.d],
-t+=4}else{if("faces"===s.boundTo){for(w=0,D=V.length;w<D;w++)Fa=s.value[V[w]],s.array[t]=Fa,s.array[t+1]=Fa,s.array[t+2]=Fa,t+=3;for(w=0,D=W.length;w<D;w++)Fa=s.value[W[w]],s.array[t]=Fa,s.array[t+1]=Fa,s.array[t+2]=Fa,s.array[t+3]=Fa,t+=4}}else if(2===s.size)if(void 0===s.boundTo||"vertices"===s.boundTo){for(w=0,D=V.length;w<D;w++)z=na[V[w]],F=s.value[z.a],G=s.value[z.b],H=s.value[z.c],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=G.x,s.array[t+3]=G.y,s.array[t+4]=H.x,s.array[t+5]=H.y,t+=6;for(w=
-0,D=W.length;w<D;w++)z=na[W[w]],F=s.value[z.a],G=s.value[z.b],H=s.value[z.c],Y=s.value[z.d],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=G.x,s.array[t+3]=G.y,s.array[t+4]=H.x,s.array[t+5]=H.y,s.array[t+6]=Y.x,s.array[t+7]=Y.y,t+=8}else{if("faces"===s.boundTo){for(w=0,D=V.length;w<D;w++)H=G=F=Fa=s.value[V[w]],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=G.x,s.array[t+3]=G.y,s.array[t+4]=H.x,s.array[t+5]=H.y,t+=6;for(w=0,D=W.length;w<D;w++)Y=H=G=F=Fa=s.value[W[w]],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+
-2]=G.x,s.array[t+3]=G.y,s.array[t+4]=H.x,s.array[t+5]=H.y,s.array[t+6]=Y.x,s.array[t+7]=Y.y,t+=8}}else if(3===s.size){var Q;Q="c"===s.type?["r","g","b"]:["x","y","z"];if(void 0===s.boundTo||"vertices"===s.boundTo){for(w=0,D=V.length;w<D;w++)z=na[V[w]],F=s.value[z.a],G=s.value[z.b],H=s.value[z.c],s.array[t]=F[Q[0]],s.array[t+1]=F[Q[1]],s.array[t+2]=F[Q[2]],s.array[t+3]=G[Q[0]],s.array[t+4]=G[Q[1]],s.array[t+5]=G[Q[2]],s.array[t+6]=H[Q[0]],s.array[t+7]=H[Q[1]],s.array[t+8]=H[Q[2]],t+=9;for(w=0,D=W.length;w<
-D;w++)z=na[W[w]],F=s.value[z.a],G=s.value[z.b],H=s.value[z.c],Y=s.value[z.d],s.array[t]=F[Q[0]],s.array[t+1]=F[Q[1]],s.array[t+2]=F[Q[2]],s.array[t+3]=G[Q[0]],s.array[t+4]=G[Q[1]],s.array[t+5]=G[Q[2]],s.array[t+6]=H[Q[0]],s.array[t+7]=H[Q[1]],s.array[t+8]=H[Q[2]],s.array[t+9]=Y[Q[0]],s.array[t+10]=Y[Q[1]],s.array[t+11]=Y[Q[2]],t+=12}else if("faces"===s.boundTo){for(w=0,D=V.length;w<D;w++)H=G=F=Fa=s.value[V[w]],s.array[t]=F[Q[0]],s.array[t+1]=F[Q[1]],s.array[t+2]=F[Q[2]],s.array[t+3]=G[Q[0]],s.array[t+
-4]=G[Q[1]],s.array[t+5]=G[Q[2]],s.array[t+6]=H[Q[0]],s.array[t+7]=H[Q[1]],s.array[t+8]=H[Q[2]],t+=9;for(w=0,D=W.length;w<D;w++)Y=H=G=F=Fa=s.value[W[w]],s.array[t]=F[Q[0]],s.array[t+1]=F[Q[1]],s.array[t+2]=F[Q[2]],s.array[t+3]=G[Q[0]],s.array[t+4]=G[Q[1]],s.array[t+5]=G[Q[2]],s.array[t+6]=H[Q[0]],s.array[t+7]=H[Q[1]],s.array[t+8]=H[Q[2]],s.array[t+9]=Y[Q[0]],s.array[t+10]=Y[Q[1]],s.array[t+11]=Y[Q[2]],t+=12}}else if(4===s.size)if(void 0===s.boundTo||"vertices"===s.boundTo){for(w=0,D=V.length;w<D;w++)z=
-na[V[w]],F=s.value[z.a],G=s.value[z.b],H=s.value[z.c],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=F.z,s.array[t+3]=F.w,s.array[t+4]=G.x,s.array[t+5]=G.y,s.array[t+6]=G.z,s.array[t+7]=G.w,s.array[t+8]=H.x,s.array[t+9]=H.y,s.array[t+10]=H.z,s.array[t+11]=H.w,t+=12;for(w=0,D=W.length;w<D;w++)z=na[W[w]],F=s.value[z.a],G=s.value[z.b],H=s.value[z.c],Y=s.value[z.d],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=F.z,s.array[t+3]=F.w,s.array[t+4]=G.x,s.array[t+5]=G.y,s.array[t+6]=G.z,s.array[t+7]=G.w,s.array[t+
-8]=H.x,s.array[t+9]=H.y,s.array[t+10]=H.z,s.array[t+11]=H.w,s.array[t+12]=Y.x,s.array[t+13]=Y.y,s.array[t+14]=Y.z,s.array[t+15]=Y.w,t+=16}else if("faces"===s.boundTo){for(w=0,D=V.length;w<D;w++)H=G=F=Fa=s.value[V[w]],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=F.z,s.array[t+3]=F.w,s.array[t+4]=G.x,s.array[t+5]=G.y,s.array[t+6]=G.z,s.array[t+7]=G.w,s.array[t+8]=H.x,s.array[t+9]=H.y,s.array[t+10]=H.z,s.array[t+11]=H.w,t+=12;for(w=0,D=W.length;w<D;w++)Y=H=G=F=Fa=s.value[W[w]],s.array[t]=F.x,s.array[t+
-1]=F.y,s.array[t+2]=F.z,s.array[t+3]=F.w,s.array[t+4]=G.x,s.array[t+5]=G.y,s.array[t+6]=G.z,s.array[t+7]=G.w,s.array[t+8]=H.x,s.array[t+9]=H.y,s.array[t+10]=H.z,s.array[t+11]=H.w,s.array[t+12]=Y.x,s.array[t+13]=Y.y,s.array[t+14]=Y.z,s.array[t+15]=Y.w,t+=16}f.bindBuffer(f.ARRAY_BUFFER,s.buffer);f.bufferData(f.ARRAY_BUFFER,s.array,Ea)}nc&&(delete P.__inittedArrays,delete P.__colorArray,delete P.__normalArray,delete P.__tangentArray,delete P.__uvArray,delete P.__uv2Array,delete P.__faceArray,delete P.__vertexArray,
-delete P.__lineArray,delete P.__skinVertexAArray,delete P.__skinVertexBArray,delete P.__skinIndexArray,delete P.__skinWeightArray)}}S.__dirtyVertices=!1;S.__dirtyMorphTargets=!1;S.__dirtyElements=!1;S.__dirtyUvs=!1;S.__dirtyNormals=!1;S.__dirtyColors=!1;S.__dirtyTangents=!1;Ba.attributes&&l(Ba)}else if(Ra instanceof THREE.Ribbon){if(S.__dirtyVertices||S.__dirtyColors){var Eb=S,Uc=f.DYNAMIC_DRAW,gc=void 0,hc=void 0,uc=void 0,Fb=void 0,vc=void 0,Vc=Eb.vertices,Wc=Eb.colors,dd=Vc.length,ed=Wc.length,
-wc=Eb.__vertexArray,xc=Eb.__colorArray,fd=Eb.__dirtyColors;if(Eb.__dirtyVertices){for(gc=0;gc<dd;gc++)uc=Vc[gc].position,Fb=3*gc,wc[Fb]=uc.x,wc[Fb+1]=uc.y,wc[Fb+2]=uc.z;f.bindBuffer(f.ARRAY_BUFFER,Eb.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,wc,Uc)}if(fd){for(hc=0;hc<ed;hc++)vc=Wc[hc],Fb=3*hc,xc[Fb]=vc.r,xc[Fb+1]=vc.g,xc[Fb+2]=vc.b;f.bindBuffer(f.ARRAY_BUFFER,Eb.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,xc,Uc)}}S.__dirtyVertices=!1;S.__dirtyColors=!1}else if(Ra instanceof THREE.Line){Ba=
-c(Ra,Zb);Pb=Ba.attributes&&n(Ba);if(S.__dirtyVertices||S.__dirtyColors||Pb){var rb=S,Nc=f.DYNAMIC_DRAW,ic=void 0,jc=void 0,yc=void 0,ja=void 0,zc=void 0,Xc=rb.vertices,Yc=rb.colors,gd=Xc.length,hd=Yc.length,Ac=rb.__vertexArray,Bc=rb.__colorArray,id=rb.__dirtyColors,Oc=rb.__webglCustomAttributesList,Cc=void 0,Zc=void 0,va=void 0,Vb=void 0,Ca=void 0,ba=void 0;if(rb.__dirtyVertices){for(ic=0;ic<gd;ic++)yc=Xc[ic].position,ja=3*ic,Ac[ja]=yc.x,Ac[ja+1]=yc.y,Ac[ja+2]=yc.z;f.bindBuffer(f.ARRAY_BUFFER,rb.__webglVertexBuffer);
-f.bufferData(f.ARRAY_BUFFER,Ac,Nc)}if(id){for(jc=0;jc<hd;jc++)zc=Yc[jc],ja=3*jc,Bc[ja]=zc.r,Bc[ja+1]=zc.g,Bc[ja+2]=zc.b;f.bindBuffer(f.ARRAY_BUFFER,rb.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,Bc,Nc)}if(Oc)for(Cc=0,Zc=Oc.length;Cc<Zc;Cc++)if(ba=Oc[Cc],ba.needsUpdate&&(void 0===ba.boundTo||"vertices"===ba.boundTo)){ja=0;Vb=ba.value.length;if(1===ba.size)for(va=0;va<Vb;va++)ba.array[va]=ba.value[va];else if(2===ba.size)for(va=0;va<Vb;va++)Ca=ba.value[va],ba.array[ja]=Ca.x,ba.array[ja+1]=Ca.y,
-ja+=2;else if(3===ba.size)if("c"===ba.type)for(va=0;va<Vb;va++)Ca=ba.value[va],ba.array[ja]=Ca.r,ba.array[ja+1]=Ca.g,ba.array[ja+2]=Ca.b,ja+=3;else for(va=0;va<Vb;va++)Ca=ba.value[va],ba.array[ja]=Ca.x,ba.array[ja+1]=Ca.y,ba.array[ja+2]=Ca.z,ja+=3;else if(4===ba.size)for(va=0;va<Vb;va++)Ca=ba.value[va],ba.array[ja]=Ca.x,ba.array[ja+1]=Ca.y,ba.array[ja+2]=Ca.z,ba.array[ja+3]=Ca.w,ja+=4;f.bindBuffer(f.ARRAY_BUFFER,ba.buffer);f.bufferData(f.ARRAY_BUFFER,ba.array,Nc)}}S.__dirtyVertices=!1;S.__dirtyColors=
-!1;Ba.attributes&&l(Ba)}else if(Ra instanceof THREE.ParticleSystem)Ba=c(Ra,Zb),Pb=Ba.attributes&&n(Ba),(S.__dirtyVertices||S.__dirtyColors||Ra.sortParticles||Pb)&&g(S,f.DYNAMIC_DRAW,Ra),S.__dirtyVertices=!1,S.__dirtyColors=!1,Ba.attributes&&l(Ba)}};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,m;g=k=0;for(l=0,m=b.length;l<m;l++)e=b[l],e.onlyShadow||(e instanceof THREE.DirectionalLight&&g++,e instanceof THREE.PointLight&&k++,e instanceof THREE.SpotLight&&k++);k+g<=$?l=g:(l=Math.ceil($*g/(k+g)),k=$-
-l);e=l;g=k;var n=0;for(k=0,l=b.length;k<l;k++)m=b[k],m.castShadow&&(m instanceof THREE.SpotLight&&n++,m instanceof THREE.DirectionalLight&&!m.shadowCascade&&n++);var q=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)q=d.bones.length;var o;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,morphNormals:a.morphNormals,
-maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:e,maxPointLights:g,maxBones:q,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,shadowMapCascade:this.shadowMapCascade,maxShadows:n,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround},p,d=[];j?d.push(j):(d.push(l),d.push(m));for(p in c)d.push(p),d.push(c[p]);j=d.join();for(p=0,d=Ta.length;p<d;p++)if(Ta[p].code===
-j){o=Ta[p].program;break a}p=f.createProgram();d=[0<nc?"#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.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute 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;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\n#endif\n#ifdef USE_SKINNING\nattribute vec4 skinVertexA;\nattribute vec4 skinVertexB;\nattribute vec4 skinIndex;\nattribute vec4 skinWeight;\n#endif\n"].join("\n");
+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);var d=void 0,e=void 0;if(c.numMorphTargets)for(d=0,e=c.numMorphTargets;d<e;d++)f.deleteBuffer(c.__webglMorphTargetsBuffers[d]);if(c.numMorphNormals)for(d=
+0,e=c.numMorphNormals;d<e;d++)f.deleteBuffer(c.__webglMorphNormalsBuffers[d]);if(c.__webglCustomAttributesList)for(d in d=void 0,c.__webglCustomAttributesList)f.deleteBuffer(c.__webglCustomAttributesList[d].buffer);E.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),E.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),
+E.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),E.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,f.deleteTexture(a.__webglTexture),E.info.memory.textures--};this.updateShadowMap=function(a,b){ca=null;J=X=Fa=Ra=Ea=-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,r=3*a.count;for(m=0;m<r;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=o(a,b,c,d,g),a=c.attributes,b=!1,d=16777215*e.id+2*c.id+(d.wireframe?
+1:0),d!==X&&(X=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),E.info.render.calls++,E.info.render.vertices+=g[d].count,
+E.info.render.faces+=g[d].count/3}};this.renderBuffer=function(a,b,c,d,e,g){if(0!==d.opacity){var h,i,c=o(a,b,c,d,g),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0);c!==X&&(X=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),d.morphNormals&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[j[h]]),f.vertexAttribPointer(c["morphNormal"+
+h],3,f.FLOAT,!1,0,0)),g.__webglMorphTargetInfluences[h]=i[j[h]],h++}else{var j=[],l=-1,m=0;i=g.morphTargetInfluences;var k,n=i.length;h=0;for(-1!==g.morphTargetBase&&(j[g.morphTargetBase]=!0);h<d.numSupportedMorphTargets;){for(k=0;k<n;k++)!j[k]&&i[k]>l&&(m=k,l=i[m]);f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[m]);f.vertexAttribPointer(c["morphTarget"+h],3,f.FLOAT,!1,0,0);d.morphNormals&&(f.bindBuffer(f.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[m]),f.vertexAttribPointer(c["morphNormal"+
+h],3,f.FLOAT,!1,0,0));g.__webglMorphTargetInfluences[h]=l;j[m]=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!==tb&&(f.lineWidth(d),tb=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)),E.info.render.calls++,E.info.render.vertices+=e.__webglFaceCount,E.info.render.faces+=e.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?f.LINE_STRIP:f.LINES,d=d.linewidth,d!==tb&&(f.lineWidth(d),tb=d),f.drawArrays(g,0,e.__webglLineCount),E.info.render.calls++):g instanceof THREE.ParticleSystem?(f.drawArrays(f.POINTS,0,e.__webglParticleCount),E.info.render.calls++,E.info.render.points+=e.__webglParticleCount):g instanceof THREE.Ribbon&&(f.drawArrays(f.TRIANGLE_STRIP,
+0,e.__webglVertexCount),E.info.render.calls++)}};this.render=function(a,b,c,d){var e,g,j,m,n=a.lights,r=a.fog;J=-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);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);Xa.multiply(b.projectionMatrix,b.matrixWorldInverse);Yb.setFromMatrix(Xa);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(g=m[d],j=g.object,g.render=!1,j.visible&&(!(j instanceof
+THREE.Mesh||j instanceof THREE.ParticleSystem)||!j.frustumCulled||Yb.contains(j))){j.matrixWorld.flattenToArray(j._objectMatrixArray);q(j,b);var o=g,p=o.object,u=o.buffer,v=void 0,v=v=void 0,v=p.material;if(v instanceof THREE.MeshFaceMaterial){if(v=u.materialIndex,0<=v)v=p.geometry.materials[v],v.transparent?(o.transparent=v,o.opaque=null):(o.opaque=v,o.transparent=null)}else if(v)v.transparent?(o.transparent=v,o.opaque=null):(o.opaque=v,o.transparent=null);g.render=!0;if(this.sortObjects)j.renderDepth?
+g.z=j.renderDepth:(Ma.copy(j.position),Xa.multiplyVector3(Ma),g.z=Ma.z)}this.sortObjects&&m.sort(h);m=a.__webglObjectsImmediate;for(d=0,e=m.length;d<e;d++)if(g=m[d],j=g.object,j.visible)j.matrixAutoUpdate&&j.matrixWorld.flattenToArray(j._objectMatrixArray),q(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,n,r,!0,a.overrideMaterial),l(a.__webglObjectsImmediate,"",b,n,r,!1,a.overrideMaterial)):(this.setBlending(THREE.NormalBlending),k(a.__webglObjects,!0,"opaque",b,n,r,!1),l(a.__webglObjectsImmediate,"opaque",b,n,r,!1),k(a.__webglObjects,!1,"transparent",b,n,r,!0),l(a.__webglObjectsImmediate,"transparent",b,n,r,!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.setDepthTest(!0);this.setDepthWrite(!0)};this.renderImmediateObject=function(a,b,c,d,e){var g=o(a,b,c,d,e);X=-1;E.setObjectFaces(e);e.immediateRenderCallback?
+e.immediateRenderCallback(g,f,Yb):e.render(function(a){E.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,o=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 q=k,u=void 0,v=void 0,y=void 0,A=void 0,K=void 0,C=void 0,B=void 0,I={},L=q.morphTargets.length,M=q.morphNormals.length;q.geometryGroups={};for(u=0,v=q.faces.length;u<v;u++)y=q.faces[u],A=y.materialIndex,C=void 0!==A?A:-1,void 0===I[C]&&(I[C]={hash:C,counter:0}),B=I[C].hash+"_"+I[C].counter,void 0===q.geometryGroups[B]&&(q.geometryGroups[B]=
+{faces3:[],faces4:[],materialIndex:A,vertices:0,numMorphTargets:L,numMorphNormals:M}),K=y instanceof THREE.Face3?3:4,65535<q.geometryGroups[B].vertices+K&&(I[C].counter+=1,B=I[C].hash+"_"+I[C].counter,void 0===q.geometryGroups[B]&&(q.geometryGroups[B]={faces3:[],faces4:[],materialIndex:A,vertices:0,numMorphTargets:L,numMorphNormals:M})),y instanceof THREE.Face3?q.geometryGroups[B].faces3.push(u):q.geometryGroups[B].faces4.push(u),q.geometryGroups[B].vertices+=K;q.geometryGroupsList=[];var N=void 0;
+for(N in q.geometryGroups)q.geometryGroups[N].id=Ba++,q.geometryGroupsList.push(q.geometryGroups[N])}for(l in k.geometryGroups)if(o=k.geometryGroups[l],!o.__webglVertexBuffer){var J=o;J.__webglVertexBuffer=f.createBuffer();J.__webglNormalBuffer=f.createBuffer();J.__webglTangentBuffer=f.createBuffer();J.__webglColorBuffer=f.createBuffer();J.__webglUVBuffer=f.createBuffer();J.__webglUV2Buffer=f.createBuffer();J.__webglSkinVertexABuffer=f.createBuffer();J.__webglSkinVertexBBuffer=f.createBuffer();J.__webglSkinIndicesBuffer=
+f.createBuffer();J.__webglSkinWeightsBuffer=f.createBuffer();J.__webglFaceBuffer=f.createBuffer();J.__webglLineBuffer=f.createBuffer();var T=void 0,X=void 0;if(J.numMorphTargets){J.__webglMorphTargetsBuffers=[];for(T=0,X=J.numMorphTargets;T<X;T++)J.__webglMorphTargetsBuffers.push(f.createBuffer())}if(J.numMorphNormals){J.__webglMorphNormalsBuffers=[];for(T=0,X=J.numMorphNormals;T<X;T++)J.__webglMorphNormalsBuffers.push(f.createBuffer())}E.info.memory.geometries++;var ea=o,aa=h,Y=aa.geometry,ca=ea.faces3,
+da=ea.faces4,S=3*ca.length+4*da.length,ma=1*ca.length+2*da.length,xa=3*ca.length+4*da.length,qa=c(aa,ea),Ea=e(qa),Ja=d(qa),Ra=qa.vertexColors?qa.vertexColors:!1;ea.__vertexArray=new Float32Array(3*S);if(Ja)ea.__normalArray=new Float32Array(3*S);if(Y.hasTangents)ea.__tangentArray=new Float32Array(4*S);if(Ra)ea.__colorArray=new Float32Array(3*S);if(Ea){if(0<Y.faceUvs.length||0<Y.faceVertexUvs.length)ea.__uvArray=new Float32Array(2*S);if(1<Y.faceUvs.length||1<Y.faceVertexUvs.length)ea.__uv2Array=new Float32Array(2*
+S)}if(aa.geometry.skinWeights.length&&aa.geometry.skinIndices.length)ea.__skinVertexAArray=new Float32Array(4*S),ea.__skinVertexBArray=new Float32Array(4*S),ea.__skinIndexArray=new Float32Array(4*S),ea.__skinWeightArray=new Float32Array(4*S);ea.__faceArray=new Uint16Array(3*ma);ea.__lineArray=new Uint16Array(2*xa);var Fa=void 0,La=void 0;if(ea.numMorphTargets){ea.__morphTargetsArrays=[];for(Fa=0,La=ea.numMorphTargets;Fa<La;Fa++)ea.__morphTargetsArrays.push(new Float32Array(3*S))}if(ea.numMorphNormals){ea.__morphNormalsArrays=
+[];for(Fa=0,La=ea.numMorphNormals;Fa<La;Fa++)ea.__morphNormalsArrays.push(new Float32Array(3*S))}ea.__webglFaceCount=3*ma;ea.__webglLineCount=2*xa;if(qa.attributes){if(void 0===ea.__webglCustomAttributesList)ea.__webglCustomAttributesList=[];var Va=void 0;for(Va in qa.attributes){var Sa=qa.attributes[Va],Ka={},Wa;for(Wa in Sa)Ka[Wa]=Sa[Wa];if(!Ka.__webglInitialized||Ka.createUniqueBuffers){Ka.__webglInitialized=!0;var Ma=1;"v2"===Ka.type?Ma=2:"v3"===Ka.type?Ma=3:"v4"===Ka.type?Ma=4:"c"===Ka.type&&
+(Ma=3);Ka.size=Ma;Ka.array=new Float32Array(S*Ma);Ka.buffer=f.createBuffer();Ka.buffer.belongsToAttribute=Va;Sa.needsUpdate=!0;Ka.__original=Sa}ea.__webglCustomAttributesList.push(Ka)}}ea.__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 nb=k;nb.__webglVertexBuffer=f.createBuffer();nb.__webglColorBuffer=f.createBuffer();
+E.info.memory.geometries++;var Xa=k,tb=Xa.vertices.length;Xa.__vertexArray=new Float32Array(3*tb);Xa.__colorArray=new Float32Array(3*tb);Xa.__webglVertexCount=tb;k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(h instanceof THREE.Line){if(k=h.geometry,!k.__webglVertexBuffer){var Nb=k;Nb.__webglVertexBuffer=f.createBuffer();Nb.__webglColorBuffer=f.createBuffer();E.info.memory.geometries++;var Zb=k,Xb=h,Hb=Zb.vertices.length;Zb.__vertexArray=new Float32Array(3*Hb);Zb.__colorArray=new Float32Array(3*
+Hb);Zb.__webglLineCount=Hb;b(Zb,Xb);k.__dirtyVertices=!0;k.__dirtyColors=!0}}else if(h instanceof THREE.ParticleSystem&&(k=h.geometry,!k.__webglVertexBuffer)){var Ob=k;Ob.__webglVertexBuffer=f.createBuffer();Ob.__webglColorBuffer=f.createBuffer();E.info.geometries++;var Pb=k,Yb=h,Fc=Pb.vertices.length;Pb.__vertexArray=new Float32Array(3*Fc);Pb.__colorArray=new Float32Array(3*Fc);Pb.__sortArray=[];Pb.__webglParticleCount=Fc;b(Pb,Yb);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)o=k.geometryGroups[l],j(i.__webglObjects,o,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 Na=a.__objectsRemoved[0],pc=a;Na instanceof THREE.Mesh||Na instanceof THREE.ParticleSystem||Na instanceof THREE.Ribbon||Na instanceof THREE.Line?p(pc.__webglObjects,Na):Na instanceof THREE.Sprite?r(pc.__webglSprites,Na):Na instanceof THREE.LensFlare?r(pc.__webglFlares,Na):(Na instanceof THREE.MarchingCubes||Na.immediateRenderCallback)&&p(pc.__webglObjectsImmediate,
+Na);Na.__webglActive=!1;a.__objectsRemoved.splice(0,1)}for(var Gc=0,lc=a.__webglObjects.length;Gc<lc;Gc++){var Ta=a.__webglObjects[Gc].object,R=Ta.geometry,$b=void 0,Qb=void 0,Ca=void 0;if(Ta instanceof THREE.Mesh)if(R instanceof THREE.BufferGeometry)R.__dirtyVertices=!1,R.__dirtyElements=!1,R.__dirtyUvs=!1,R.__dirtyNormals=!1,R.__dirtyColors=!1;else{for(var Hc=0,mc=R.geometryGroupsList.length;Hc<mc;Hc++)if($b=R.geometryGroupsList[Hc],Ca=c(Ta,$b),Qb=Ca.attributes&&n(Ca),R.__dirtyVertices||R.__dirtyMorphTargets||
+R.__dirtyElements||R.__dirtyUvs||R.__dirtyNormals||R.__dirtyColors||R.__dirtyTangents||Qb){var P=$b,nc=Ta,Ga=f.DYNAMIC_DRAW,oc=!R.dynamic,Ib=Ca;if(P.__inittedArrays){var Qc=d(Ib),Ic=Ib.vertexColors?Ib.vertexColors:!1,Rc=e(Ib),qc=Qc===THREE.SmoothShading,w=void 0,D=void 0,Qa=void 0,z=void 0,Rb=void 0,ub=void 0,Ua=void 0,rc=void 0,ob=void 0,Sb=void 0,Tb=void 0,F=void 0,G=void 0,H=void 0,Z=void 0,Ya=void 0,Za=void 0,$a=void 0,ac=void 0,ab=void 0,bb=void 0,cb=void 0,bc=void 0,db=void 0,eb=void 0,fb=void 0,
+cc=void 0,gb=void 0,hb=void 0,ib=void 0,dc=void 0,jb=void 0,kb=void 0,lb=void 0,ec=void 0,vb=void 0,wb=void 0,xb=void 0,sc=void 0,yb=void 0,zb=void 0,Ab=void 0,tc=void 0,U=void 0,Sc=void 0,Bb=void 0,Ub=void 0,Vb=void 0,ta=void 0,Tc=void 0,ra=void 0,sa=void 0,Cb=void 0,pb=void 0,la=0,pa=0,qb=0,rb=0,Oa=0,ya=0,$=0,za=0,na=0,x=0,O=0,t=0,Ha=void 0,ua=P.__vertexArray,fc=P.__uvArray,gc=P.__uv2Array,Pa=P.__normalArray,fa=P.__tangentArray,va=P.__colorArray,ga=P.__skinVertexAArray,ha=P.__skinVertexBArray,ia=
+P.__skinIndexArray,ja=P.__skinWeightArray,Jc=P.__morphTargetsArrays,Kc=P.__morphNormalsArrays,Lc=P.__webglCustomAttributesList,s=void 0,mb=P.__faceArray,Ia=P.__lineArray,Aa=nc.geometry,Ec=Aa.__dirtyElements,Uc=Aa.__dirtyUvs,ad=Aa.__dirtyNormals,bd=Aa.__dirtyTangents,cd=Aa.__dirtyColors,dd=Aa.__dirtyMorphTargets,Jb=Aa.vertices,V=P.faces3,W=P.faces4,oa=Aa.faces,Mc=Aa.faceVertexUvs[0],Nc=Aa.faceVertexUvs[1],Kb=Aa.skinVerticesA,Lb=Aa.skinVerticesB,Mb=Aa.skinIndices,Db=Aa.skinWeights,Eb=Aa.morphTargets,
+uc=Aa.morphNormals;if(Aa.__dirtyVertices){for(w=0,D=V.length;w<D;w++)z=oa[V[w]],F=Jb[z.a].position,G=Jb[z.b].position,H=Jb[z.c].position,ua[pa]=F.x,ua[pa+1]=F.y,ua[pa+2]=F.z,ua[pa+3]=G.x,ua[pa+4]=G.y,ua[pa+5]=G.z,ua[pa+6]=H.x,ua[pa+7]=H.y,ua[pa+8]=H.z,pa+=9;for(w=0,D=W.length;w<D;w++)z=oa[W[w]],F=Jb[z.a].position,G=Jb[z.b].position,H=Jb[z.c].position,Z=Jb[z.d].position,ua[pa]=F.x,ua[pa+1]=F.y,ua[pa+2]=F.z,ua[pa+3]=G.x,ua[pa+4]=G.y,ua[pa+5]=G.z,ua[pa+6]=H.x,ua[pa+7]=H.y,ua[pa+8]=H.z,ua[pa+9]=Z.x,ua[pa+
+10]=Z.y,ua[pa+11]=Z.z,pa+=12;f.bindBuffer(f.ARRAY_BUFFER,P.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,ua,Ga)}if(dd)for(ta=0,Tc=Eb.length;ta<Tc;ta++){O=0;for(w=0,D=V.length;w<D;w++){Cb=V[w];z=oa[Cb];F=Eb[ta].vertices[z.a].position;G=Eb[ta].vertices[z.b].position;H=Eb[ta].vertices[z.c].position;ra=Jc[ta];ra[O]=F.x;ra[O+1]=F.y;ra[O+2]=F.z;ra[O+3]=G.x;ra[O+4]=G.y;ra[O+5]=G.z;ra[O+6]=H.x;ra[O+7]=H.y;ra[O+8]=H.z;if(Ib.morphNormals)qc?(pb=uc[ta].vertexNormals[Cb],ab=pb.a,bb=pb.b,cb=pb.c):cb=bb=ab=
+uc[ta].faceNormals[Cb],sa=Kc[ta],sa[O]=ab.x,sa[O+1]=ab.y,sa[O+2]=ab.z,sa[O+3]=bb.x,sa[O+4]=bb.y,sa[O+5]=bb.z,sa[O+6]=cb.x,sa[O+7]=cb.y,sa[O+8]=cb.z;O+=9}for(w=0,D=W.length;w<D;w++){Cb=W[w];z=oa[Cb];F=Eb[ta].vertices[z.a].position;G=Eb[ta].vertices[z.b].position;H=Eb[ta].vertices[z.c].position;Z=Eb[ta].vertices[z.d].position;ra=Jc[ta];ra[O]=F.x;ra[O+1]=F.y;ra[O+2]=F.z;ra[O+3]=G.x;ra[O+4]=G.y;ra[O+5]=G.z;ra[O+6]=H.x;ra[O+7]=H.y;ra[O+8]=H.z;ra[O+9]=Z.x;ra[O+10]=Z.y;ra[O+11]=Z.z;if(Ib.morphNormals)qc?
+(pb=uc[ta].vertexNormals[Cb],ab=pb.a,bb=pb.b,cb=pb.c,bc=pb.d):bc=cb=bb=ab=uc[ta].faceNormals[Cb],sa=Kc[ta],sa[O]=ab.x,sa[O+1]=ab.y,sa[O+2]=ab.z,sa[O+3]=bb.x,sa[O+4]=bb.y,sa[O+5]=bb.z,sa[O+6]=cb.x,sa[O+7]=cb.y,sa[O+8]=cb.z,sa[O+9]=bc.x,sa[O+10]=bc.y,sa[O+11]=bc.z;O+=12}f.bindBuffer(f.ARRAY_BUFFER,P.__webglMorphTargetsBuffers[ta]);f.bufferData(f.ARRAY_BUFFER,Jc[ta],Ga);Ib.morphNormals&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglMorphNormalsBuffers[ta]),f.bufferData(f.ARRAY_BUFFER,Kc[ta],Ga))}if(Db.length){for(w=
+0,D=V.length;w<D;w++)z=oa[V[w]],gb=Db[z.a],hb=Db[z.b],ib=Db[z.c],ja[x]=gb.x,ja[x+1]=gb.y,ja[x+2]=gb.z,ja[x+3]=gb.w,ja[x+4]=hb.x,ja[x+5]=hb.y,ja[x+6]=hb.z,ja[x+7]=hb.w,ja[x+8]=ib.x,ja[x+9]=ib.y,ja[x+10]=ib.z,ja[x+11]=ib.w,jb=Mb[z.a],kb=Mb[z.b],lb=Mb[z.c],ia[x]=jb.x,ia[x+1]=jb.y,ia[x+2]=jb.z,ia[x+3]=jb.w,ia[x+4]=kb.x,ia[x+5]=kb.y,ia[x+6]=kb.z,ia[x+7]=kb.w,ia[x+8]=lb.x,ia[x+9]=lb.y,ia[x+10]=lb.z,ia[x+11]=lb.w,vb=Kb[z.a],wb=Kb[z.b],xb=Kb[z.c],ga[x]=vb.x,ga[x+1]=vb.y,ga[x+2]=vb.z,ga[x+3]=1,ga[x+4]=wb.x,
+ga[x+5]=wb.y,ga[x+6]=wb.z,ga[x+7]=1,ga[x+8]=xb.x,ga[x+9]=xb.y,ga[x+10]=xb.z,ga[x+11]=1,yb=Lb[z.a],zb=Lb[z.b],Ab=Lb[z.c],ha[x]=yb.x,ha[x+1]=yb.y,ha[x+2]=yb.z,ha[x+3]=1,ha[x+4]=zb.x,ha[x+5]=zb.y,ha[x+6]=zb.z,ha[x+7]=1,ha[x+8]=Ab.x,ha[x+9]=Ab.y,ha[x+10]=Ab.z,ha[x+11]=1,x+=12;for(w=0,D=W.length;w<D;w++)z=oa[W[w]],gb=Db[z.a],hb=Db[z.b],ib=Db[z.c],dc=Db[z.d],ja[x]=gb.x,ja[x+1]=gb.y,ja[x+2]=gb.z,ja[x+3]=gb.w,ja[x+4]=hb.x,ja[x+5]=hb.y,ja[x+6]=hb.z,ja[x+7]=hb.w,ja[x+8]=ib.x,ja[x+9]=ib.y,ja[x+10]=ib.z,ja[x+
+11]=ib.w,ja[x+12]=dc.x,ja[x+13]=dc.y,ja[x+14]=dc.z,ja[x+15]=dc.w,jb=Mb[z.a],kb=Mb[z.b],lb=Mb[z.c],ec=Mb[z.d],ia[x]=jb.x,ia[x+1]=jb.y,ia[x+2]=jb.z,ia[x+3]=jb.w,ia[x+4]=kb.x,ia[x+5]=kb.y,ia[x+6]=kb.z,ia[x+7]=kb.w,ia[x+8]=lb.x,ia[x+9]=lb.y,ia[x+10]=lb.z,ia[x+11]=lb.w,ia[x+12]=ec.x,ia[x+13]=ec.y,ia[x+14]=ec.z,ia[x+15]=ec.w,vb=Kb[z.a],wb=Kb[z.b],xb=Kb[z.c],sc=Kb[z.d],ga[x]=vb.x,ga[x+1]=vb.y,ga[x+2]=vb.z,ga[x+3]=1,ga[x+4]=wb.x,ga[x+5]=wb.y,ga[x+6]=wb.z,ga[x+7]=1,ga[x+8]=xb.x,ga[x+9]=xb.y,ga[x+10]=xb.z,
+ga[x+11]=1,ga[x+12]=sc.x,ga[x+13]=sc.y,ga[x+14]=sc.z,ga[x+15]=1,yb=Lb[z.a],zb=Lb[z.b],Ab=Lb[z.c],tc=Lb[z.d],ha[x]=yb.x,ha[x+1]=yb.y,ha[x+2]=yb.z,ha[x+3]=1,ha[x+4]=zb.x,ha[x+5]=zb.y,ha[x+6]=zb.z,ha[x+7]=1,ha[x+8]=Ab.x,ha[x+9]=Ab.y,ha[x+10]=Ab.z,ha[x+11]=1,ha[x+12]=tc.x,ha[x+13]=tc.y,ha[x+14]=tc.z,ha[x+15]=1,x+=16;0<x&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglSkinVertexABuffer),f.bufferData(f.ARRAY_BUFFER,ga,Ga),f.bindBuffer(f.ARRAY_BUFFER,P.__webglSkinVertexBBuffer),f.bufferData(f.ARRAY_BUFFER,ha,Ga),
+f.bindBuffer(f.ARRAY_BUFFER,P.__webglSkinIndicesBuffer),f.bufferData(f.ARRAY_BUFFER,ia,Ga),f.bindBuffer(f.ARRAY_BUFFER,P.__webglSkinWeightsBuffer),f.bufferData(f.ARRAY_BUFFER,ja,Ga))}if(cd&&Ic){for(w=0,D=V.length;w<D;w++)z=oa[V[w]],Ua=z.vertexColors,rc=z.color,3===Ua.length&&Ic===THREE.VertexColors?(db=Ua[0],eb=Ua[1],fb=Ua[2]):fb=eb=db=rc,va[na]=db.r,va[na+1]=db.g,va[na+2]=db.b,va[na+3]=eb.r,va[na+4]=eb.g,va[na+5]=eb.b,va[na+6]=fb.r,va[na+7]=fb.g,va[na+8]=fb.b,na+=9;for(w=0,D=W.length;w<D;w++)z=oa[W[w]],
+Ua=z.vertexColors,rc=z.color,4===Ua.length&&Ic===THREE.VertexColors?(db=Ua[0],eb=Ua[1],fb=Ua[2],cc=Ua[3]):cc=fb=eb=db=rc,va[na]=db.r,va[na+1]=db.g,va[na+2]=db.b,va[na+3]=eb.r,va[na+4]=eb.g,va[na+5]=eb.b,va[na+6]=fb.r,va[na+7]=fb.g,va[na+8]=fb.b,va[na+9]=cc.r,va[na+10]=cc.g,va[na+11]=cc.b,na+=12;0<na&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,va,Ga))}if(bd&&Aa.hasTangents){for(w=0,D=V.length;w<D;w++)z=oa[V[w]],ob=z.vertexTangents,Ya=ob[0],Za=ob[1],$a=ob[2],fa[$]=
+Ya.x,fa[$+1]=Ya.y,fa[$+2]=Ya.z,fa[$+3]=Ya.w,fa[$+4]=Za.x,fa[$+5]=Za.y,fa[$+6]=Za.z,fa[$+7]=Za.w,fa[$+8]=$a.x,fa[$+9]=$a.y,fa[$+10]=$a.z,fa[$+11]=$a.w,$+=12;for(w=0,D=W.length;w<D;w++)z=oa[W[w]],ob=z.vertexTangents,Ya=ob[0],Za=ob[1],$a=ob[2],ac=ob[3],fa[$]=Ya.x,fa[$+1]=Ya.y,fa[$+2]=Ya.z,fa[$+3]=Ya.w,fa[$+4]=Za.x,fa[$+5]=Za.y,fa[$+6]=Za.z,fa[$+7]=Za.w,fa[$+8]=$a.x,fa[$+9]=$a.y,fa[$+10]=$a.z,fa[$+11]=$a.w,fa[$+12]=ac.x,fa[$+13]=ac.y,fa[$+14]=ac.z,fa[$+15]=ac.w,$+=16;f.bindBuffer(f.ARRAY_BUFFER,P.__webglTangentBuffer);
+f.bufferData(f.ARRAY_BUFFER,fa,Ga)}if(ad&&Qc){for(w=0,D=V.length;w<D;w++)if(z=oa[V[w]],Rb=z.vertexNormals,ub=z.normal,3===Rb.length&&qc)for(U=0;3>U;U++)Bb=Rb[U],Pa[ya]=Bb.x,Pa[ya+1]=Bb.y,Pa[ya+2]=Bb.z,ya+=3;else for(U=0;3>U;U++)Pa[ya]=ub.x,Pa[ya+1]=ub.y,Pa[ya+2]=ub.z,ya+=3;for(w=0,D=W.length;w<D;w++)if(z=oa[W[w]],Rb=z.vertexNormals,ub=z.normal,4===Rb.length&&qc)for(U=0;4>U;U++)Bb=Rb[U],Pa[ya]=Bb.x,Pa[ya+1]=Bb.y,Pa[ya+2]=Bb.z,ya+=3;else for(U=0;4>U;U++)Pa[ya]=ub.x,Pa[ya+1]=ub.y,Pa[ya+2]=ub.z,ya+=3;
+f.bindBuffer(f.ARRAY_BUFFER,P.__webglNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Pa,Ga)}if(Uc&&Mc&&Rc){for(w=0,D=V.length;w<D;w++)if(Qa=V[w],z=oa[Qa],Sb=Mc[Qa],void 0!==Sb)for(U=0;3>U;U++)Ub=Sb[U],fc[qb]=Ub.u,fc[qb+1]=Ub.v,qb+=2;for(w=0,D=W.length;w<D;w++)if(Qa=W[w],z=oa[Qa],Sb=Mc[Qa],void 0!==Sb)for(U=0;4>U;U++)Ub=Sb[U],fc[qb]=Ub.u,fc[qb+1]=Ub.v,qb+=2;0<qb&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglUVBuffer),f.bufferData(f.ARRAY_BUFFER,fc,Ga))}if(Uc&&Nc&&Rc){for(w=0,D=V.length;w<D;w++)if(Qa=V[w],z=oa[Qa],
+Tb=Nc[Qa],void 0!==Tb)for(U=0;3>U;U++)Vb=Tb[U],gc[rb]=Vb.u,gc[rb+1]=Vb.v,rb+=2;for(w=0,D=W.length;w<D;w++)if(Qa=W[w],z=oa[Qa],Tb=Nc[Qa],void 0!==Tb)for(U=0;4>U;U++)Vb=Tb[U],gc[rb]=Vb.u,gc[rb+1]=Vb.v,rb+=2;0<rb&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglUV2Buffer),f.bufferData(f.ARRAY_BUFFER,gc,Ga))}if(Ec){for(w=0,D=V.length;w<D;w++)z=oa[V[w]],mb[Oa]=la,mb[Oa+1]=la+1,mb[Oa+2]=la+2,Oa+=3,Ia[za]=la,Ia[za+1]=la+1,Ia[za+2]=la,Ia[za+3]=la+2,Ia[za+4]=la+1,Ia[za+5]=la+2,za+=6,la+=3;for(w=0,D=W.length;w<D;w++)z=
+oa[W[w]],mb[Oa]=la,mb[Oa+1]=la+1,mb[Oa+2]=la+3,mb[Oa+3]=la+1,mb[Oa+4]=la+2,mb[Oa+5]=la+3,Oa+=6,Ia[za]=la,Ia[za+1]=la+1,Ia[za+2]=la,Ia[za+3]=la+3,Ia[za+4]=la+1,Ia[za+5]=la+2,Ia[za+6]=la+2,Ia[za+7]=la+3,za+=8,la+=4;f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,P.__webglFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,mb,Ga);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,P.__webglLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ia,Ga)}if(Lc)for(U=0,Sc=Lc.length;U<Sc;U++)if(s=Lc[U],s.__original.needsUpdate){t=0;if(1===s.size)if(void 0===
+s.boundTo||"vertices"===s.boundTo){for(w=0,D=V.length;w<D;w++)z=oa[V[w]],s.array[t]=s.value[z.a],s.array[t+1]=s.value[z.b],s.array[t+2]=s.value[z.c],t+=3;for(w=0,D=W.length;w<D;w++)z=oa[W[w]],s.array[t]=s.value[z.a],s.array[t+1]=s.value[z.b],s.array[t+2]=s.value[z.c],s.array[t+3]=s.value[z.d],t+=4}else{if("faces"===s.boundTo){for(w=0,D=V.length;w<D;w++)Ha=s.value[V[w]],s.array[t]=Ha,s.array[t+1]=Ha,s.array[t+2]=Ha,t+=3;for(w=0,D=W.length;w<D;w++)Ha=s.value[W[w]],s.array[t]=Ha,s.array[t+1]=Ha,s.array[t+
+2]=Ha,s.array[t+3]=Ha,t+=4}}else if(2===s.size)if(void 0===s.boundTo||"vertices"===s.boundTo){for(w=0,D=V.length;w<D;w++)z=oa[V[w]],F=s.value[z.a],G=s.value[z.b],H=s.value[z.c],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=G.x,s.array[t+3]=G.y,s.array[t+4]=H.x,s.array[t+5]=H.y,t+=6;for(w=0,D=W.length;w<D;w++)z=oa[W[w]],F=s.value[z.a],G=s.value[z.b],H=s.value[z.c],Z=s.value[z.d],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=G.x,s.array[t+3]=G.y,s.array[t+4]=H.x,s.array[t+5]=H.y,s.array[t+6]=Z.x,s.array[t+
+7]=Z.y,t+=8}else{if("faces"===s.boundTo){for(w=0,D=V.length;w<D;w++)H=G=F=Ha=s.value[V[w]],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=G.x,s.array[t+3]=G.y,s.array[t+4]=H.x,s.array[t+5]=H.y,t+=6;for(w=0,D=W.length;w<D;w++)Z=H=G=F=Ha=s.value[W[w]],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=G.x,s.array[t+3]=G.y,s.array[t+4]=H.x,s.array[t+5]=H.y,s.array[t+6]=Z.x,s.array[t+7]=Z.y,t+=8}}else if(3===s.size){var Q;Q="c"===s.type?["r","g","b"]:["x","y","z"];if(void 0===s.boundTo||"vertices"===s.boundTo){for(w=
+0,D=V.length;w<D;w++)z=oa[V[w]],F=s.value[z.a],G=s.value[z.b],H=s.value[z.c],s.array[t]=F[Q[0]],s.array[t+1]=F[Q[1]],s.array[t+2]=F[Q[2]],s.array[t+3]=G[Q[0]],s.array[t+4]=G[Q[1]],s.array[t+5]=G[Q[2]],s.array[t+6]=H[Q[0]],s.array[t+7]=H[Q[1]],s.array[t+8]=H[Q[2]],t+=9;for(w=0,D=W.length;w<D;w++)z=oa[W[w]],F=s.value[z.a],G=s.value[z.b],H=s.value[z.c],Z=s.value[z.d],s.array[t]=F[Q[0]],s.array[t+1]=F[Q[1]],s.array[t+2]=F[Q[2]],s.array[t+3]=G[Q[0]],s.array[t+4]=G[Q[1]],s.array[t+5]=G[Q[2]],s.array[t+
+6]=H[Q[0]],s.array[t+7]=H[Q[1]],s.array[t+8]=H[Q[2]],s.array[t+9]=Z[Q[0]],s.array[t+10]=Z[Q[1]],s.array[t+11]=Z[Q[2]],t+=12}else if("faces"===s.boundTo){for(w=0,D=V.length;w<D;w++)H=G=F=Ha=s.value[V[w]],s.array[t]=F[Q[0]],s.array[t+1]=F[Q[1]],s.array[t+2]=F[Q[2]],s.array[t+3]=G[Q[0]],s.array[t+4]=G[Q[1]],s.array[t+5]=G[Q[2]],s.array[t+6]=H[Q[0]],s.array[t+7]=H[Q[1]],s.array[t+8]=H[Q[2]],t+=9;for(w=0,D=W.length;w<D;w++)Z=H=G=F=Ha=s.value[W[w]],s.array[t]=F[Q[0]],s.array[t+1]=F[Q[1]],s.array[t+2]=F[Q[2]],
+s.array[t+3]=G[Q[0]],s.array[t+4]=G[Q[1]],s.array[t+5]=G[Q[2]],s.array[t+6]=H[Q[0]],s.array[t+7]=H[Q[1]],s.array[t+8]=H[Q[2]],s.array[t+9]=Z[Q[0]],s.array[t+10]=Z[Q[1]],s.array[t+11]=Z[Q[2]],t+=12}}else if(4===s.size)if(void 0===s.boundTo||"vertices"===s.boundTo){for(w=0,D=V.length;w<D;w++)z=oa[V[w]],F=s.value[z.a],G=s.value[z.b],H=s.value[z.c],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=F.z,s.array[t+3]=F.w,s.array[t+4]=G.x,s.array[t+5]=G.y,s.array[t+6]=G.z,s.array[t+7]=G.w,s.array[t+8]=H.x,s.array[t+
+9]=H.y,s.array[t+10]=H.z,s.array[t+11]=H.w,t+=12;for(w=0,D=W.length;w<D;w++)z=oa[W[w]],F=s.value[z.a],G=s.value[z.b],H=s.value[z.c],Z=s.value[z.d],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=F.z,s.array[t+3]=F.w,s.array[t+4]=G.x,s.array[t+5]=G.y,s.array[t+6]=G.z,s.array[t+7]=G.w,s.array[t+8]=H.x,s.array[t+9]=H.y,s.array[t+10]=H.z,s.array[t+11]=H.w,s.array[t+12]=Z.x,s.array[t+13]=Z.y,s.array[t+14]=Z.z,s.array[t+15]=Z.w,t+=16}else if("faces"===s.boundTo){for(w=0,D=V.length;w<D;w++)H=G=F=Ha=s.value[V[w]],
+s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=F.z,s.array[t+3]=F.w,s.array[t+4]=G.x,s.array[t+5]=G.y,s.array[t+6]=G.z,s.array[t+7]=G.w,s.array[t+8]=H.x,s.array[t+9]=H.y,s.array[t+10]=H.z,s.array[t+11]=H.w,t+=12;for(w=0,D=W.length;w<D;w++)Z=H=G=F=Ha=s.value[W[w]],s.array[t]=F.x,s.array[t+1]=F.y,s.array[t+2]=F.z,s.array[t+3]=F.w,s.array[t+4]=G.x,s.array[t+5]=G.y,s.array[t+6]=G.z,s.array[t+7]=G.w,s.array[t+8]=H.x,s.array[t+9]=H.y,s.array[t+10]=H.z,s.array[t+11]=H.w,s.array[t+12]=Z.x,s.array[t+13]=Z.y,
+s.array[t+14]=Z.z,s.array[t+15]=Z.w,t+=16}f.bindBuffer(f.ARRAY_BUFFER,s.buffer);f.bufferData(f.ARRAY_BUFFER,s.array,Ga)}oc&&(delete P.__inittedArrays,delete P.__colorArray,delete P.__normalArray,delete P.__tangentArray,delete P.__uvArray,delete P.__uv2Array,delete P.__faceArray,delete P.__vertexArray,delete P.__lineArray,delete P.__skinVertexAArray,delete P.__skinVertexBArray,delete P.__skinIndexArray,delete P.__skinWeightArray)}}R.__dirtyVertices=!1;R.__dirtyMorphTargets=!1;R.__dirtyElements=!1;
+R.__dirtyUvs=!1;R.__dirtyNormals=!1;R.__dirtyColors=!1;R.__dirtyTangents=!1;Ca.attributes&&m(Ca)}else if(Ta instanceof THREE.Ribbon){if(R.__dirtyVertices||R.__dirtyColors){var Fb=R,Vc=f.DYNAMIC_DRAW,hc=void 0,ic=void 0,vc=void 0,Gb=void 0,wc=void 0,Wc=Fb.vertices,Xc=Fb.colors,ed=Wc.length,fd=Xc.length,xc=Fb.__vertexArray,yc=Fb.__colorArray,gd=Fb.__dirtyColors;if(Fb.__dirtyVertices){for(hc=0;hc<ed;hc++)vc=Wc[hc].position,Gb=3*hc,xc[Gb]=vc.x,xc[Gb+1]=vc.y,xc[Gb+2]=vc.z;f.bindBuffer(f.ARRAY_BUFFER,Fb.__webglVertexBuffer);
+f.bufferData(f.ARRAY_BUFFER,xc,Vc)}if(gd){for(ic=0;ic<fd;ic++)wc=Xc[ic],Gb=3*ic,yc[Gb]=wc.r,yc[Gb+1]=wc.g,yc[Gb+2]=wc.b;f.bindBuffer(f.ARRAY_BUFFER,Fb.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,yc,Vc)}}R.__dirtyVertices=!1;R.__dirtyColors=!1}else if(Ta instanceof THREE.Line){Ca=c(Ta,$b);Qb=Ca.attributes&&n(Ca);if(R.__dirtyVertices||R.__dirtyColors||Qb){var sb=R,Oc=f.DYNAMIC_DRAW,jc=void 0,kc=void 0,zc=void 0,ka=void 0,Ac=void 0,Yc=sb.vertices,Zc=sb.colors,hd=Yc.length,id=Zc.length,Bc=sb.__vertexArray,
+Cc=sb.__colorArray,jd=sb.__dirtyColors,Pc=sb.__webglCustomAttributesList,Dc=void 0,$c=void 0,wa=void 0,Wb=void 0,Da=void 0,ba=void 0;if(sb.__dirtyVertices){for(jc=0;jc<hd;jc++)zc=Yc[jc].position,ka=3*jc,Bc[ka]=zc.x,Bc[ka+1]=zc.y,Bc[ka+2]=zc.z;f.bindBuffer(f.ARRAY_BUFFER,sb.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,Bc,Oc)}if(jd){for(kc=0;kc<id;kc++)Ac=Zc[kc],ka=3*kc,Cc[ka]=Ac.r,Cc[ka+1]=Ac.g,Cc[ka+2]=Ac.b;f.bindBuffer(f.ARRAY_BUFFER,sb.__webglColorBuffer);f.bufferData(f.ARRAY_BUFFER,Cc,Oc)}if(Pc)for(Dc=
+0,$c=Pc.length;Dc<$c;Dc++)if(ba=Pc[Dc],ba.needsUpdate&&(void 0===ba.boundTo||"vertices"===ba.boundTo)){ka=0;Wb=ba.value.length;if(1===ba.size)for(wa=0;wa<Wb;wa++)ba.array[wa]=ba.value[wa];else if(2===ba.size)for(wa=0;wa<Wb;wa++)Da=ba.value[wa],ba.array[ka]=Da.x,ba.array[ka+1]=Da.y,ka+=2;else if(3===ba.size)if("c"===ba.type)for(wa=0;wa<Wb;wa++)Da=ba.value[wa],ba.array[ka]=Da.r,ba.array[ka+1]=Da.g,ba.array[ka+2]=Da.b,ka+=3;else for(wa=0;wa<Wb;wa++)Da=ba.value[wa],ba.array[ka]=Da.x,ba.array[ka+1]=Da.y,
+ba.array[ka+2]=Da.z,ka+=3;else if(4===ba.size)for(wa=0;wa<Wb;wa++)Da=ba.value[wa],ba.array[ka]=Da.x,ba.array[ka+1]=Da.y,ba.array[ka+2]=Da.z,ba.array[ka+3]=Da.w,ka+=4;f.bindBuffer(f.ARRAY_BUFFER,ba.buffer);f.bufferData(f.ARRAY_BUFFER,ba.array,Oc)}}R.__dirtyVertices=!1;R.__dirtyColors=!1;Ca.attributes&&m(Ca)}else if(Ta instanceof THREE.ParticleSystem)Ca=c(Ta,$b),Qb=Ca.attributes&&n(Ca),(R.__dirtyVertices||R.__dirtyColors||Ta.sortParticles||Qb)&&g(R,f.DYNAMIC_DRAW,Ta),R.__dirtyVertices=!1,R.__dirtyColors=
+!1,Ca.attributes&&m(Ca)}};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,m;g=k=0;for(l=0,m=b.length;l<m;l++)e=b[l],e.onlyShadow||(e instanceof THREE.DirectionalLight&&g++,e instanceof THREE.PointLight&&k++,e instanceof THREE.SpotLight&&k++);k+g<=aa?l=g:(l=Math.ceil(aa*g/(k+g)),k=aa-l);e=l;g=k;var n=0;for(k=0,l=b.length;k<l;k++)m=b[k],m.castShadow&&(m instanceof THREE.SpotLight&&n++,m instanceof THREE.DirectionalLight&&!m.shadowCascade&&n++);var r=50;if(void 0!==d&&d instanceof THREE.SkinnedMesh)r=d.bones.length;
+var o;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,morphNormals:a.morphNormals,maxMorphTargets:this.maxMorphTargets,maxMorphNormals:this.maxMorphNormals,maxDirLights:e,maxPointLights:g,maxBones:r,shadowMapEnabled:this.shadowMapEnabled&&d.receiveShadow,shadowMapSoft:this.shadowMapSoft,shadowMapDebug:this.shadowMapDebug,
+shadowMapCascade:this.shadowMapCascade,maxShadows:n,alphaTest:a.alphaTest,metal:a.metal,perPixel:a.perPixel,wrapAround:a.wrapAround},q,d=[];j?d.push(j):(d.push(l),d.push(m));for(q in c)d.push(q),d.push(c[q]);j=d.join();for(q=0,d=Va.length;q<d;q++)if(Va[q].code===j){o=Va[q].program;break a}q=f.createProgram();d=[0<oc?"#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.morphNormals?"#define USE_MORPHNORMALS":"",c.perPixel?"#define PHONG_PER_PIXEL":"",c.wrapAround?"#define WRAP_AROUND":"",c.shadowMapEnabled?"#define USE_SHADOWMAP":
+"",c.shadowMapSoft?"#define SHADOWMAP_SOFT":"",c.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"",c.sizeAttenuation?"#define USE_SIZEATTENUATION":"","uniform mat4 objectMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute 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;\n#ifdef USE_MORPHNORMALS\nattribute vec3 morphNormal0;\nattribute vec3 morphNormal1;\nattribute vec3 morphNormal2;\nattribute vec3 morphNormal3;\n#else\nattribute vec3 morphTarget4;\nattribute vec3 morphTarget5;\nattribute vec3 morphTarget6;\nattribute vec3 morphTarget7;\n#endif\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 "+I+" 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.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");f.attachShader(p,u("fragment",e+l));f.attachShader(p,u("vertex",d+m));f.linkProgram(p);
-f.getProgramParameter(p,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(p,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");p.uniforms={};p.attributes={};var r,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,boneGlobalMatrices,morphTargetInfluences".split(",");for(r in k)d.push(r);r=d;for(d=0,k=r.length;d<k;d++)l=r[d],p.uniforms[l]=f.getUniformLocation(p,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(r=0;r<c.maxMorphNormals;r++)d.push("morphNormal"+r);for(o in b)d.push(o);o=d;for(r=0,b=o.length;r<b;r++)c=o[r],p.attributes[c]=f.getAttribLocation(p,c);p.id=Ta.length;Ta.push({program:p,code:j});E.info.memory.programs=Ta.length;o=p}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){a.numSupportedMorphTargets=0;p="morphTarget";for(i=0;i<this.maxMorphTargets;i++)r=p+i,0<=o[r]&&(f.enableVertexAttribArray(o[r]),a.numSupportedMorphTargets++)}if(a.morphNormals){a.numSupportedMorphNormals=
-0;p="morphNormal";for(i=0;i<this.maxMorphNormals;i++)r=p+i,0<=o[r]&&(f.enableVertexAttribArray(o[r]),a.numSupportedMorphNormals++)}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(da!==a.doubleSided)a.doubleSided?
-f.disable(f.CULL_FACE):f.enable(f.CULL_FACE),da=a.doubleSided;if(Ha!==a.flipSided)a.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW),Ha=a.flipSided};this.setDepthTest=function(a){Oa!==a&&(a?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST),Oa=a)};this.setDepthWrite=function(a){Pa!==a&&(f.depthMask(a),Pa=a)};this.setBlending=function(a){if(a!==Da){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)}Da=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=f.createTexture(),E.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=B(a.format),g=B(a.type);L(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=B(a.format),e=B(a.type);if(b){a.__webglFramebuffer=[];a.__webglRenderbuffer=[];f.bindTexture(f.TEXTURE_CUBE_MAP,a.__webglTexture);L(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);A(a.__webglRenderbuffer[c],a)}}else a.__webglFramebuffer=f.createFramebuffer(),a.__webglRenderbuffer=f.createRenderbuffer(),f.bindTexture(f.TEXTURE_2D,a.__webglTexture),L(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),A(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=Gb,a=Nb,e=Mb,c=Wb);b!==pa&&(f.bindFramebuffer(f.FRAMEBUFFER,b),f.viewport(e,c,d,a),pa=b);kc=d;lc=a};this.shadowMapPlugin=
+"#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.shadowMapDebug?"#define SHADOWMAP_DEBUG":"",c.shadowMapCascade?"#define SHADOWMAP_CASCADE":"","uniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"].join("\n");f.attachShader(q,u("fragment",e+l));f.attachShader(q,u("vertex",d+m));f.linkProgram(q);
+f.getProgramParameter(q,f.LINK_STATUS)||console.error("Could not initialise shader\nVALIDATE_STATUS: "+f.getProgramParameter(q,f.VALIDATE_STATUS)+", gl error ["+f.getError()+"]");q.uniforms={};q.attributes={};var p,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,boneGlobalMatrices,morphTargetInfluences".split(",");for(p in k)d.push(p);p=d;for(d=0,k=p.length;d<k;d++)l=p[d],q.uniforms[l]=f.getUniformLocation(q,l);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,skinWeight".split(",");
+for(p=0;p<c.maxMorphTargets;p++)d.push("morphTarget"+p);for(p=0;p<c.maxMorphNormals;p++)d.push("morphNormal"+p);for(o in b)d.push(o);o=d;for(p=0,b=o.length;p<b;p++)c=o[p],q.attributes[c]=f.getAttribLocation(q,c);q.id=Va.length;Va.push({program:q,code:j});E.info.memory.programs=Va.length;o=q}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){a.numSupportedMorphTargets=0;q="morphTarget";for(i=0;i<this.maxMorphTargets;i++)p=q+i,0<=o[p]&&(f.enableVertexAttribArray(o[p]),a.numSupportedMorphTargets++)}if(a.morphNormals){a.numSupportedMorphNormals=
+0;q="morphNormal";for(i=0;i<this.maxMorphNormals;i++)p=q+i,0<=o[p]&&(f.enableVertexAttribArray(o[p]),a.numSupportedMorphNormals++)}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(da!==a.doubleSided)a.doubleSided?
+f.disable(f.CULL_FACE):f.enable(f.CULL_FACE),da=a.doubleSided;if(Ja!==a.flipSided)a.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW),Ja=a.flipSided};this.setDepthTest=function(a){Ra!==a&&(a?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST),Ra=a)};this.setDepthWrite=function(a){Fa!==a&&(f.depthMask(a),Fa=a)};this.setBlending=function(a){if(a!==Ea){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)}Ea=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=f.createTexture(),E.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=B(a.format),g=B(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=B(a.format),e=B(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);A(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),A(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=Hb,a=Ob,e=Nb,c=Xb);b!==qa&&(f.bindFramebuffer(f.FRAMEBUFFER,b),f.viewport(e,c,d,a),qa=b);lc=d;mc=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};
@@ -328,18 +330,18 @@ THREE.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this);this.lensFlares=[]
 THREE.LensFlare.prototype.add=function(a,b,c,d,e,g){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===g&&(g=1);void 0===e&&(e=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:g,color:e,blending:d})};
 THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,c,d=2*-this.positionScreen.x,e=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+e*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,e){return a+(b-a)*e};this.VIntX=function(a,b,e,g,h,i,k,m,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[g]=i+h*this.delta;b[g+1]=k;b[g+2]=m;e[g]=this.lerp(j[a],j[a+3],h);e[g+1]=this.lerp(j[a+1],j[a+4],h);e[g+2]=this.lerp(j[a+2],j[a+5],h)};this.VIntY=function(a,b,e,g,h,i,k,m,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[g]=i;b[g+1]=k+h*this.delta;b[g+2]=m;b=a+3*this.yd;
-e[g]=this.lerp(j[a],j[b],h);e[g+1]=this.lerp(j[a+1],j[b+1],h);e[g+2]=this.lerp(j[a+2],j[b+2],h)};this.VIntZ=function(a,b,e,g,h,i,k,m,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[g]=i;b[g+1]=k;b[g+2]=m+h*this.delta;b=a+3*this.zd;e[g]=this.lerp(j[a],j[b],h);e[g+1]=this.lerp(j[a+1],j[b+1],h);e[g+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,e,g,h,i){var k=g+1,m=g+this.yd,j=g+this.zd,n=k+this.yd,l=k+this.zd,p=g+this.yd+this.zd,q=k+this.yd+this.zd,o=0,r=this.field[g],y=this.field[k],u=this.field[m],L=this.field[n],A=this.field[j],v=this.field[l],B=this.field[p],C=this.field[q];r<h&&(o|=1);y<h&&(o|=2);u<h&&(o|=8);L<h&&(o|=4);A<h&&(o|=16);v<h&&(o|=32);B<h&&(o|=128);C<h&&(o|=64);var I=THREE.edgeTable[o];if(0===I)return 0;var M=this.delta,N=a+
-M,J=b+M,M=e+M;I&1&&(this.compNorm(g),this.compNorm(k),this.VIntX(3*g,this.vlist,this.nlist,0,h,a,b,e,r,y));I&2&&(this.compNorm(k),this.compNorm(n),this.VIntY(3*k,this.vlist,this.nlist,3,h,N,b,e,y,L));I&4&&(this.compNorm(m),this.compNorm(n),this.VIntX(3*m,this.vlist,this.nlist,6,h,a,J,e,u,L));I&8&&(this.compNorm(g),this.compNorm(m),this.VIntY(3*g,this.vlist,this.nlist,9,h,a,b,e,r,u));I&16&&(this.compNorm(j),this.compNorm(l),this.VIntX(3*j,this.vlist,this.nlist,12,h,a,b,M,A,v));I&32&&(this.compNorm(l),
-this.compNorm(q),this.VIntY(3*l,this.vlist,this.nlist,15,h,N,b,M,v,C));I&64&&(this.compNorm(p),this.compNorm(q),this.VIntX(3*p,this.vlist,this.nlist,18,h,a,J,M,B,C));I&128&&(this.compNorm(j),this.compNorm(p),this.VIntY(3*j,this.vlist,this.nlist,21,h,a,b,M,A,B));I&256&&(this.compNorm(g),this.compNorm(j),this.VIntZ(3*g,this.vlist,this.nlist,24,h,a,b,e,r,A));I&512&&(this.compNorm(k),this.compNorm(l),this.VIntZ(3*k,this.vlist,this.nlist,27,h,N,b,e,y,v));I&1024&&(this.compNorm(n),this.compNorm(q),this.VIntZ(3*
-n,this.vlist,this.nlist,30,h,N,J,e,L,C));I&2048&&(this.compNorm(m),this.compNorm(p),this.VIntZ(3*m,this.vlist,this.nlist,33,h,a,J,e,u,B));o<<=4;for(h=g=0;-1!=THREE.triTable[o+h];)a=o+h,b=a+1,e=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[e],i),h+=3,g++;return g};this.posnormtriv=function(a,b,e,g,h,i){var k=3*this.count;this.positionArray[k]=a[e];this.positionArray[k+1]=a[e+1];this.positionArray[k+2]=a[e+2];this.positionArray[k+3]=a[g];this.positionArray[k+
+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,g,h,i,k,l,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[g]=i+h*this.delta;b[g+1]=k;b[g+2]=l;e[g]=this.lerp(j[a],j[a+3],h);e[g+1]=this.lerp(j[a+1],j[a+4],h);e[g+2]=this.lerp(j[a+2],j[a+5],h)};this.VIntY=function(a,b,e,g,h,i,k,l,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[g]=i;b[g+1]=k+h*this.delta;b[g+2]=l;b=a+3*this.yd;
+e[g]=this.lerp(j[a],j[b],h);e[g+1]=this.lerp(j[a+1],j[b+1],h);e[g+2]=this.lerp(j[a+2],j[b+2],h)};this.VIntZ=function(a,b,e,g,h,i,k,l,j,n){h=(h-j)/(n-j);j=this.normal_cache;b[g]=i;b[g+1]=k;b[g+2]=l+h*this.delta;b=a+3*this.zd;e[g]=this.lerp(j[a],j[b],h);e[g+1]=this.lerp(j[a+1],j[b+1],h);e[g+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,e,g,h,i){var k=g+1,l=g+this.yd,j=g+this.zd,n=k+this.yd,m=k+this.zd,p=g+this.yd+this.zd,r=k+this.yd+this.zd,o=0,q=this.field[g],y=this.field[k],u=this.field[l],K=this.field[n],A=this.field[j],v=this.field[m],B=this.field[p],C=this.field[r];q<h&&(o|=1);y<h&&(o|=2);u<h&&(o|=8);K<h&&(o|=4);A<h&&(o|=16);v<h&&(o|=32);B<h&&(o|=128);C<h&&(o|=64);var I=THREE.edgeTable[o];if(0===I)return 0;var L=this.delta,M=a+
+L,N=b+L,L=e+L;I&1&&(this.compNorm(g),this.compNorm(k),this.VIntX(3*g,this.vlist,this.nlist,0,h,a,b,e,q,y));I&2&&(this.compNorm(k),this.compNorm(n),this.VIntY(3*k,this.vlist,this.nlist,3,h,M,b,e,y,K));I&4&&(this.compNorm(l),this.compNorm(n),this.VIntX(3*l,this.vlist,this.nlist,6,h,a,N,e,u,K));I&8&&(this.compNorm(g),this.compNorm(l),this.VIntY(3*g,this.vlist,this.nlist,9,h,a,b,e,q,u));I&16&&(this.compNorm(j),this.compNorm(m),this.VIntX(3*j,this.vlist,this.nlist,12,h,a,b,L,A,v));I&32&&(this.compNorm(m),
+this.compNorm(r),this.VIntY(3*m,this.vlist,this.nlist,15,h,M,b,L,v,C));I&64&&(this.compNorm(p),this.compNorm(r),this.VIntX(3*p,this.vlist,this.nlist,18,h,a,N,L,B,C));I&128&&(this.compNorm(j),this.compNorm(p),this.VIntY(3*j,this.vlist,this.nlist,21,h,a,b,L,A,B));I&256&&(this.compNorm(g),this.compNorm(j),this.VIntZ(3*g,this.vlist,this.nlist,24,h,a,b,e,q,A));I&512&&(this.compNorm(k),this.compNorm(m),this.VIntZ(3*k,this.vlist,this.nlist,27,h,M,b,e,y,v));I&1024&&(this.compNorm(n),this.compNorm(r),this.VIntZ(3*
+n,this.vlist,this.nlist,30,h,M,N,e,K,C));I&2048&&(this.compNorm(l),this.compNorm(p),this.VIntZ(3*l,this.vlist,this.nlist,33,h,a,N,e,u,B));o<<=4;for(h=g=0;-1!=THREE.triTable[o+h];)a=o+h,b=a+1,e=a+2,this.posnormtriv(this.vlist,this.nlist,3*THREE.triTable[a],3*THREE.triTable[b],3*THREE.triTable[e],i),h+=3,g++;return g};this.posnormtriv=function(a,b,e,g,h,i){var k=3*this.count;this.positionArray[k]=a[e];this.positionArray[k+1]=a[e+1];this.positionArray[k+2]=a[e+2];this.positionArray[k+3]=a[g];this.positionArray[k+
 4]=a[g+1];this.positionArray[k+5]=a[g+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[e];this.normalArray[k+1]=b[e+1];this.normalArray[k+2]=b[e+2];this.normalArray[k+3]=b[g];this.normalArray[k+4]=b[g+1];this.normalArray[k+5]=b[g+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,e,g,h){var i=this.size*Math.sqrt(g/h),k=e*this.size,m=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 l=Math.floor(m-i);1>l&&(l=1);m=Math.floor(m+i);m>this.size-1&&(m=this.size-1);var p=Math.floor(j-i);1>p&&(p=1);i=Math.floor(j+i);i>this.size-1&&(i=this.size-
-1);for(var q,o,r,y,u,L,A,j=n;j<k;j++){r=this.size2*j;u=j/this.size-e;L=u*u;for(n=l;n<m;n++){o=r+this.size*n;q=n/this.size-b;A=q*q;for(q=p;q<i;q++)y=q/this.size-a,y=g/(1.0E-6+y*y+A+L)-h,0<y&&(this.field[o+q]+=y)}}};this.addPlaneX=function(a,b){var e,g,h,i,k,m=this.size,j=this.yd,n=this.zd,l=this.field,p=m*Math.sqrt(a/b);p>m&&(p=m);for(e=0;e<p;e++)if(g=e/m,g*=g,i=a/(1.0E-4+g)-b,0<i)for(g=0;g<m;g++){k=e+g*j;for(h=0;h<m;h++)l[n*h+k]+=i}};this.addPlaneY=function(a,b){var e,g,h,i,k,m,j=this.size,n=this.yd,
-l=this.zd,p=this.field,q=j*Math.sqrt(a/b);q>j&&(q=j);for(g=0;g<q;g++)if(e=g/j,e*=e,i=a/(1.0E-4+e)-b,0<i){k=g*n;for(e=0;e<j;e++){m=k+e;for(h=0;h<j;h++)p[l*h+m]+=i}}};this.addPlaneZ=function(a,b){var e,g,h,i,k,m,j=this.size,n=this.yd,l=this.zd,p=this.field,q=j*Math.sqrt(a/b);q>j&&(q=j);for(h=0;h<q;h++)if(e=h/j,e*=e,i=a/(1.0E-4+e)-b,0<i){k=l*h;for(g=0;g<j;g++){m=k+g*n;for(e=0;e<j;e++)p[m+e]+=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,e,g,h,i,k,m,j,n,l=this.size-2;for(h=1;h<l;h++){n=this.size2*h;m=(h-this.halfsize)/this.halfsize;for(g=1;g<l;g++){j=n+this.size*g;k=(g-this.halfsize)/this.halfsize;for(e=1;e<l;e++)i=(e-this.halfsize)/this.halfsize,b=j+e,this.polygonize(i,k,m,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,e=[];this.render(function(g){var h,i,k,m,j,n,l,p;for(h=0;h<g.count;h++)l=3*h,j=l+1,p=l+2,i=g.positionArray[l],k=g.positionArray[j],m=
-g.positionArray[p],n=new THREE.Vector3(i,k,m),i=g.normalArray[l],k=g.normalArray[j],m=g.normalArray[p],l=new THREE.Vector3(i,k,m),l.normalize(),j=new THREE.Vertex(n),b.vertices.push(j),e.push(l);n=g.count/3;for(h=0;h<n;h++)l=3*(a+h),j=l+1,p=l+2,i=e[l],k=e[j],m=e[p],l=new THREE.Face3(l,j,p,[i,k,m]),b.faces.push(l);a+=n;g.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,g,h){var i=this.size*Math.sqrt(g/h),k=e*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 p=Math.floor(j-i);1>p&&(p=1);i=Math.floor(j+i);i>this.size-1&&(i=this.size-
+1);for(var r,o,q,y,u,K,A,j=n;j<k;j++){q=this.size2*j;u=j/this.size-e;K=u*u;for(n=m;n<l;n++){o=q+this.size*n;r=n/this.size-b;A=r*r;for(r=p;r<i;r++)y=r/this.size-a,y=g/(1.0E-6+y*y+A+K)-h,0<y&&(this.field[o+r]+=y)}}};this.addPlaneX=function(a,b){var e,g,h,i,k,l=this.size,j=this.yd,n=this.zd,m=this.field,p=l*Math.sqrt(a/b);p>l&&(p=l);for(e=0;e<p;e++)if(g=e/l,g*=g,i=a/(1.0E-4+g)-b,0<i)for(g=0;g<l;g++){k=e+g*j;for(h=0;h<l;h++)m[n*h+k]+=i}};this.addPlaneY=function(a,b){var e,g,h,i,k,l,j=this.size,n=this.yd,
+m=this.zd,p=this.field,r=j*Math.sqrt(a/b);r>j&&(r=j);for(g=0;g<r;g++)if(e=g/j,e*=e,i=a/(1.0E-4+e)-b,0<i){k=g*n;for(e=0;e<j;e++){l=k+e;for(h=0;h<j;h++)p[m*h+l]+=i}}};this.addPlaneZ=function(a,b){var e,g,h,i,k,l,j=this.size,n=this.yd,m=this.zd,p=this.field,r=j*Math.sqrt(a/b);r>j&&(r=j);for(h=0;h<r;h++)if(e=h/j,e*=e,i=a/(1.0E-4+e)-b,0<i){k=m*h;for(g=0;g<j;g++){l=k+g*n;for(e=0;e<j;e++)p[l+e]+=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,e,g,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(g=1;g<m;g++){j=n+this.size*g;k=(g-this.halfsize)/this.halfsize;for(e=1;e<m;e++)i=(e-this.halfsize)/this.halfsize,b=j+e,this.polygonize(i,k,l,b,this.isolation,a)}}this.end(a)};this.generateGeometry=function(){var a=0,b=new THREE.Geometry,e=[];this.render(function(g){var h,i,k,l,j,n,m,p;for(h=0;h<g.count;h++)m=3*h,j=m+1,p=m+2,i=g.positionArray[m],k=g.positionArray[j],l=
+g.positionArray[p],n=new THREE.Vector3(i,k,l),i=g.normalArray[m],k=g.normalArray[j],l=g.normalArray[p],m=new THREE.Vector3(i,k,l),m.normalize(),j=new THREE.Vertex(n),b.vertices.push(j),e.push(m);n=g.count/3;for(h=0;h<n;h++)m=3*(a+h),j=m+1,p=m+2,i=e[m],k=e[j],l=e[p],m=new THREE.Face3(m,j,p,[i,k,l]),b.faces.push(m);a+=n;g.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]);
@@ -364,39 +366,39 @@ 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,e,g,h,i,k,m,j,n,l,p;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;g=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,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),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,g,h,i,k,l,j,n,m,p;this.init=function(r){b=r.context;c=r;d=new Float32Array(16);e=new Uint16Array(6);r=0;d[r++]=-1;d[r++]=-1;d[r++]=0;d[r++]=0;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]=
+0;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=1;d[r++]=-1;d[r++]=1;d[r++]=0;d[r++]=1;r=0;e[r++]=0;e[r++]=1;e[r++]=2;e[r++]=0;e[r++]=2;e[r++]=3;g=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,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)?(m=!1,j=a(THREE.ShaderFlares.lensFlare)):(m=!0,j=a(THREE.ShaderFlares.lensFlareVertexTexture));n={};l={};n.vertex=b.getAttribLocation(j,"position");n.uv=b.getAttribLocation(j,"uv");l.renderType=b.getUniformLocation(j,"renderType");l.map=b.getUniformLocation(j,"map");l.occlusionMap=b.getUniformLocation(j,"occlusionMap");l.opacity=b.getUniformLocation(j,"opacity");l.color=b.getUniformLocation(j,
-"color");l.scale=b.getUniformLocation(j,"scale");l.rotation=b.getUniformLocation(j,"rotation");l.screenPosition=b.getUniformLocation(j,"screenPosition");p=!1};this.render=function(a,d,e,y){var a=a.__webglFlares,u=a.length;if(u){var L=new THREE.Vector3,A=y/e,v=0.5*e,B=0.5*y,C=16/y,I=new THREE.Vector2(C*A,C),M=new THREE.Vector3(1,1,0),N=new THREE.Vector2(1,1),J=l,C=n;b.useProgram(j);p||(b.enableVertexAttribArray(n.vertex),b.enableVertexAttribArray(n.uv),p=!0);b.uniform1i(J.occlusionMap,0);b.uniform1i(J.map,
-1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(C.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(C.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(!1);var T,wa,la,aa,$;for(T=0;T<u;T++)if(C=16/y,I.set(C*A,C),aa=a[T],L.set(aa.matrixWorld.n14,aa.matrixWorld.n24,aa.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(L),d.projectionMatrix.multiplyVector3(L),M.copy(L),N.x=M.x*v+v,N.y=M.y*B+B,m||0<N.x&&N.x<e&&0<N.y&&N.y<y){b.activeTexture(b.TEXTURE1);
-b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,N.x-8,N.y-8,16,16,0);b.uniform1i(J.renderType,0);b.uniform2f(J.scale,I.x,I.y);b.uniform3f(J.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,N.x-8,N.y-8,16,16,0);b.uniform1i(J.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);aa.positionScreen.copy(M);aa.customUpdateCallback?aa.customUpdateCallback(aa):aa.updateLensFlares();b.uniform1i(J.renderType,2);b.enable(b.BLEND);for(wa=0,la=aa.lensFlares.length;wa<la;wa++)if($=aa.lensFlares[wa],0.0010<$.opacity&&0.0010<$.scale)M.x=$.x,M.y=$.y,M.z=$.z,C=$.size*$.scale/y,I.x=C*A,I.y=C,b.uniform3f(J.screenPosition,M.x,M.y,M.z),b.uniform2f(J.scale,I.x,I.y),b.uniform1f(J.rotation,$.rotation),b.uniform1f(J.opacity,$.opacity),b.uniform3f(J.color,
-$.color.r,$.color.g,$.color.b),c.setBlending($.blending),c.setTexture($.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,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");p=!1};this.render=function(a,d,e,y){var a=a.__webglFlares,u=a.length;if(u){var K=new THREE.Vector3,A=y/e,v=0.5*e,B=0.5*y,C=16/y,I=new THREE.Vector2(C*A,C),L=new THREE.Vector3(1,1,0),M=new THREE.Vector2(1,1),N=m,C=n;b.useProgram(j);p||(b.enableVertexAttribArray(n.vertex),b.enableVertexAttribArray(n.uv),p=!0);b.uniform1i(N.occlusionMap,0);b.uniform1i(N.map,
+1);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(C.vertex,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(C.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.disable(b.CULL_FACE);b.depthMask(!1);var S,xa,ma,T,aa;for(S=0;S<u;S++)if(C=16/y,I.set(C*A,C),T=a[S],K.set(T.matrixWorld.n14,T.matrixWorld.n24,T.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(K),d.projectionMatrix.multiplyVector3(K),L.copy(K),M.x=L.x*v+v,M.y=L.y*B+B,l||0<M.x&&M.x<e&&0<M.y&&M.y<y){b.activeTexture(b.TEXTURE1);
+b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,M.x-8,M.y-8,16,16,0);b.uniform1i(N.renderType,0);b.uniform2f(N.scale,I.x,I.y);b.uniform3f(N.screenPosition,L.x,L.y,L.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,M.x-8,M.y-8,16,16,0);b.uniform1i(N.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);T.positionScreen.copy(L);T.customUpdateCallback?T.customUpdateCallback(T):T.updateLensFlares();b.uniform1i(N.renderType,2);b.enable(b.BLEND);for(xa=0,ma=T.lensFlares.length;xa<ma;xa++)if(aa=T.lensFlares[xa],0.0010<aa.opacity&&0.0010<aa.scale)L.x=aa.x,L.y=aa.y,L.z=aa.z,C=aa.size*aa.scale/y,I.x=C*A,I.y=C,b.uniform3f(N.screenPosition,L.x,L.y,L.z),b.uniform2f(N.scale,I.x,I.y),b.uniform1f(N.rotation,aa.rotation),b.uniform1f(N.opacity,aa.opacity),b.uniform3f(N.color,
+aa.color.r,aa.color.g,aa.color.b),c.setBlending(aa.blending),c.setTexture(aa.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=new THREE.Frustum,g=new THREE.Matrix4,h=new THREE.Vector3,i=new THREE.Vector3;this.init=function(e){a=e.context;b=e;var e=THREE.ShaderLib.depthRGBA,g=THREE.UniformsUtils.clone(e.uniforms);c=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:g});d=new THREE.ShaderMaterial({fragmentShader:e.fragmentShader,vertexShader:e.vertexShader,uniforms:g,morphTargets:!0});c._shadowPass=!0;d._shadowPass=!0};this.render=function(a,
-c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(k,m){var j,n,l,p,q,o,r,y,u,L=[];p=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(j=0,n=k.lights.length;j<n;j++)if(l=k.lights[j],l.castShadow)if(l instanceof THREE.DirectionalLight&&l.shadowCascade)for(q=0;q<l.shadowCascadeCount;q++){var A;if(l.shadowCascadeArray[q])A=l.shadowCascadeArray[q];else{u=l;r=q;A=new THREE.DirectionalLight;A.isVirtual=!0;A.onlyShadow=
-!0;A.castShadow=!0;A.shadowCameraNear=u.shadowCameraNear;A.shadowCameraFar=u.shadowCameraFar;A.shadowCameraLeft=u.shadowCameraLeft;A.shadowCameraRight=u.shadowCameraRight;A.shadowCameraBottom=u.shadowCameraBottom;A.shadowCameraTop=u.shadowCameraTop;A.shadowCameraVisible=u.shadowCameraVisible;A.shadowDarkness=u.shadowDarkness;A.shadowBias=u.shadowCascadeBias[r];A.shadowMapWidth=u.shadowCascadeWidth[r];A.shadowMapHeight=u.shadowCascadeHeight[r];A.pointsWorld=[];A.pointsFrustum=[];y=A.pointsWorld;o=
-A.pointsFrustum;for(var v=0;8>v;v++)y[v]=new THREE.Vector3,o[v]=new THREE.Vector3;y=u.shadowCascadeNearZ[r];u=u.shadowCascadeFarZ[r];o[0].set(-1,-1,y);o[1].set(1,-1,y);o[2].set(-1,1,y);o[3].set(1,1,y);o[4].set(-1,-1,u);o[5].set(1,-1,u);o[6].set(-1,1,u);o[7].set(1,1,u);A.originalCamera=m;o=new THREE.Gyroscope;o.position=l.shadowCascadeOffset;o.add(A);o.add(A.target);m.add(o);l.shadowCascadeArray[q]=A;console.log("Created virtualLight",A)}r=l;y=q;u=r.shadowCascadeArray[y];u.position.copy(r.position);
-u.target.position.copy(r.target.position);u.lookAt(u.target);u.shadowCameraVisible=r.shadowCameraVisible;u.shadowDarkness=r.shadowDarkness;u.shadowBias=r.shadowCascadeBias[y];o=r.shadowCascadeNearZ[y];r=r.shadowCascadeFarZ[y];u=u.pointsFrustum;u[0].z=o;u[1].z=o;u[2].z=o;u[3].z=o;u[4].z=r;u[5].z=r;u[6].z=r;u[7].z=r;L[p]=A;p++}else L[p]=l,p++;for(j=0,n=L.length;j<n;j++){l=L[j];if(!l.shadowMap)l.shadowMap=new THREE.WebGLRenderTarget(l.shadowMapWidth,l.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
-format:THREE.RGBAFormat}),l.shadowMapSize=new THREE.Vector2(l.shadowMapWidth,l.shadowMapHeight),l.shadowMatrix=new THREE.Matrix4;if(!l.shadowCamera){if(l instanceof THREE.SpotLight)l.shadowCamera=new THREE.PerspectiveCamera(l.shadowCameraFov,l.shadowMapWidth/l.shadowMapHeight,l.shadowCameraNear,l.shadowCameraFar);else if(l instanceof THREE.DirectionalLight)l.shadowCamera=new THREE.OrthographicCamera(l.shadowCameraLeft,l.shadowCameraRight,l.shadowCameraTop,l.shadowCameraBottom,l.shadowCameraNear,l.shadowCameraFar);
-else{console.error("Unsupported light type for shadow");continue}k.add(l.shadowCamera);b.autoUpdateScene&&k.updateMatrixWorld()}if(l.shadowCameraVisible&&!l.cameraHelper)l.cameraHelper=new THREE.CameraHelper(l.shadowCamera),l.shadowCamera.add(l.cameraHelper);if(l.isVirtual&&A.originalCamera==m){q=m;p=l.shadowCamera;o=l.pointsFrustum;u=l.pointsWorld;h.set(Infinity,Infinity,Infinity);i.set(-Infinity,-Infinity,-Infinity);for(r=0;8>r;r++){y=u[r];y.copy(o[r]);THREE.ShadowMapPlugin.__projector.unprojectVector(y,
-q);p.matrixWorldInverse.multiplyVector3(y);if(y.x<h.x)h.x=y.x;if(y.x>i.x)i.x=y.x;if(y.y<h.y)h.y=y.y;if(y.y>i.y)i.y=y.y;if(y.z<h.z)h.z=y.z;if(y.z>i.z)i.z=y.z}p.left=h.x;p.right=i.x;p.top=i.y;p.bottom=h.y;p.updateProjectionMatrix()}p=l.shadowMap;o=l.shadowMatrix;q=l.shadowCamera;q.position.copy(l.matrixWorld.getPosition());q.lookAt(l.target.matrixWorld.getPosition());q.updateMatrixWorld();q.matrixWorldInverse.getInverse(q.matrixWorld);if(l.cameraHelper)l.cameraHelper.lines.visible=l.shadowCameraVisible;
-l.shadowCameraVisible&&l.cameraHelper.update(l.shadowCamera);o.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);o.multiplySelf(q.projectionMatrix);o.multiplySelf(q.matrixWorldInverse);if(!q._viewMatrixArray)q._viewMatrixArray=new Float32Array(16);q.matrixWorldInverse.flattenToArray(q._viewMatrixArray);if(!q._projectionMatrixArray)q._projectionMatrixArray=new Float32Array(16);q.projectionMatrix.flattenToArray(q._projectionMatrixArray);g.multiply(q.projectionMatrix,q.matrixWorldInverse);e.setFromMatrix(g);
-b.setRenderTarget(p);b.clear();u=k.__webglObjects;for(l=0,p=u.length;l<p;l++)if(r=u[l],o=r.object,r.render=!1,o.visible&&o.castShadow&&(!(o instanceof THREE.Mesh)||!o.frustumCulled||e.contains(o)))o.matrixWorld.flattenToArray(o._objectMatrixArray),o._modelViewMatrix.multiplyToArray(q.matrixWorldInverse,o.matrixWorld,o._modelViewMatrixArray),r.render=!0;for(l=0,p=u.length;l<p;l++)if(r=u[l],r.render)o=r.object,r=r.buffer,b.setObjectFaces(o),y=o.customDepthMaterial?o.customDepthMaterial:o.geometry.morphTargets.length?
-d:c,r instanceof THREE.BufferGeometry?b.renderBufferDirect(q,k.lights,null,y,r,o):b.renderBuffer(q,k.lights,null,y,r,o);u=k.__webglObjectsImmediate;for(l=0,p=u.length;l<p;l++)r=u[l],o=r.object,o.visible&&o.castShadow&&(o.matrixAutoUpdate&&o.matrixWorld.flattenToArray(o._objectMatrixArray),o._modelViewMatrix.multiplyToArray(q.matrixWorldInverse,o.matrixWorld,o._modelViewMatrixArray),b.renderImmediateObject(q,k.lights,null,c,o))}j=b.getClearColor();n=b.getClearAlpha();a.clearColor(j.r,j.g,j.b,n);a.enable(a.BLEND);
+c){b.shadowMapEnabled&&b.shadowMapAutoUpdate&&this.update(a,c)};this.update=function(k,l){var j,n,m,p,r,o,q,y,u,K=[];p=0;a.clearColor(1,1,1,1);a.disable(a.BLEND);b.shadowMapCullFrontFaces&&a.cullFace(a.FRONT);b.setDepthTest(!0);for(j=0,n=k.lights.length;j<n;j++)if(m=k.lights[j],m.castShadow)if(m instanceof THREE.DirectionalLight&&m.shadowCascade)for(r=0;r<m.shadowCascadeCount;r++){var A;if(m.shadowCascadeArray[r])A=m.shadowCascadeArray[r];else{u=m;q=r;A=new THREE.DirectionalLight;A.isVirtual=!0;A.onlyShadow=
+!0;A.castShadow=!0;A.shadowCameraNear=u.shadowCameraNear;A.shadowCameraFar=u.shadowCameraFar;A.shadowCameraLeft=u.shadowCameraLeft;A.shadowCameraRight=u.shadowCameraRight;A.shadowCameraBottom=u.shadowCameraBottom;A.shadowCameraTop=u.shadowCameraTop;A.shadowCameraVisible=u.shadowCameraVisible;A.shadowDarkness=u.shadowDarkness;A.shadowBias=u.shadowCascadeBias[q];A.shadowMapWidth=u.shadowCascadeWidth[q];A.shadowMapHeight=u.shadowCascadeHeight[q];A.pointsWorld=[];A.pointsFrustum=[];y=A.pointsWorld;o=
+A.pointsFrustum;for(var v=0;8>v;v++)y[v]=new THREE.Vector3,o[v]=new THREE.Vector3;y=u.shadowCascadeNearZ[q];u=u.shadowCascadeFarZ[q];o[0].set(-1,-1,y);o[1].set(1,-1,y);o[2].set(-1,1,y);o[3].set(1,1,y);o[4].set(-1,-1,u);o[5].set(1,-1,u);o[6].set(-1,1,u);o[7].set(1,1,u);A.originalCamera=l;o=new THREE.Gyroscope;o.position=m.shadowCascadeOffset;o.add(A);o.add(A.target);l.add(o);m.shadowCascadeArray[r]=A;console.log("Created virtualLight",A)}q=m;y=r;u=q.shadowCascadeArray[y];u.position.copy(q.position);
+u.target.position.copy(q.target.position);u.lookAt(u.target);u.shadowCameraVisible=q.shadowCameraVisible;u.shadowDarkness=q.shadowDarkness;u.shadowBias=q.shadowCascadeBias[y];o=q.shadowCascadeNearZ[y];q=q.shadowCascadeFarZ[y];u=u.pointsFrustum;u[0].z=o;u[1].z=o;u[2].z=o;u[3].z=o;u[4].z=q;u[5].z=q;u[6].z=q;u[7].z=q;K[p]=A;p++}else K[p]=m,p++;for(j=0,n=K.length;j<n;j++){m=K[j];if(!m.shadowMap)m.shadowMap=new THREE.WebGLRenderTarget(m.shadowMapWidth,m.shadowMapHeight,{minFilter:THREE.LinearFilter,magFilter:THREE.LinearFilter,
+format:THREE.RGBAFormat}),m.shadowMapSize=new THREE.Vector2(m.shadowMapWidth,m.shadowMapHeight),m.shadowMatrix=new THREE.Matrix4;if(!m.shadowCamera){if(m instanceof THREE.SpotLight)m.shadowCamera=new THREE.PerspectiveCamera(m.shadowCameraFov,m.shadowMapWidth/m.shadowMapHeight,m.shadowCameraNear,m.shadowCameraFar);else if(m instanceof THREE.DirectionalLight)m.shadowCamera=new THREE.OrthographicCamera(m.shadowCameraLeft,m.shadowCameraRight,m.shadowCameraTop,m.shadowCameraBottom,m.shadowCameraNear,m.shadowCameraFar);
+else{console.error("Unsupported light type for shadow");continue}k.add(m.shadowCamera);b.autoUpdateScene&&k.updateMatrixWorld()}if(m.shadowCameraVisible&&!m.cameraHelper)m.cameraHelper=new THREE.CameraHelper(m.shadowCamera),m.shadowCamera.add(m.cameraHelper);if(m.isVirtual&&A.originalCamera==l){r=l;p=m.shadowCamera;o=m.pointsFrustum;u=m.pointsWorld;h.set(Infinity,Infinity,Infinity);i.set(-Infinity,-Infinity,-Infinity);for(q=0;8>q;q++){y=u[q];y.copy(o[q]);THREE.ShadowMapPlugin.__projector.unprojectVector(y,
+r);p.matrixWorldInverse.multiplyVector3(y);if(y.x<h.x)h.x=y.x;if(y.x>i.x)i.x=y.x;if(y.y<h.y)h.y=y.y;if(y.y>i.y)i.y=y.y;if(y.z<h.z)h.z=y.z;if(y.z>i.z)i.z=y.z}p.left=h.x;p.right=i.x;p.top=i.y;p.bottom=h.y;p.updateProjectionMatrix()}p=m.shadowMap;o=m.shadowMatrix;r=m.shadowCamera;r.position.copy(m.matrixWorld.getPosition());r.lookAt(m.target.matrixWorld.getPosition());r.updateMatrixWorld();r.matrixWorldInverse.getInverse(r.matrixWorld);if(m.cameraHelper)m.cameraHelper.lines.visible=m.shadowCameraVisible;
+m.shadowCameraVisible&&m.cameraHelper.update(m.shadowCamera);o.set(0.5,0,0,0.5,0,0.5,0,0.5,0,0,0.5,0.5,0,0,0,1);o.multiplySelf(r.projectionMatrix);o.multiplySelf(r.matrixWorldInverse);if(!r._viewMatrixArray)r._viewMatrixArray=new Float32Array(16);r.matrixWorldInverse.flattenToArray(r._viewMatrixArray);if(!r._projectionMatrixArray)r._projectionMatrixArray=new Float32Array(16);r.projectionMatrix.flattenToArray(r._projectionMatrixArray);g.multiply(r.projectionMatrix,r.matrixWorldInverse);e.setFromMatrix(g);
+b.setRenderTarget(p);b.clear();u=k.__webglObjects;for(m=0,p=u.length;m<p;m++)if(q=u[m],o=q.object,q.render=!1,o.visible&&o.castShadow&&(!(o instanceof THREE.Mesh)||!o.frustumCulled||e.contains(o)))o.matrixWorld.flattenToArray(o._objectMatrixArray),o._modelViewMatrix.multiplyToArray(r.matrixWorldInverse,o.matrixWorld,o._modelViewMatrixArray),q.render=!0;for(m=0,p=u.length;m<p;m++)if(q=u[m],q.render)o=q.object,q=q.buffer,b.setObjectFaces(o),y=o.customDepthMaterial?o.customDepthMaterial:o.geometry.morphTargets.length?
+d:c,q instanceof THREE.BufferGeometry?b.renderBufferDirect(r,k.lights,null,y,q,o):b.renderBuffer(r,k.lights,null,y,q,o);u=k.__webglObjectsImmediate;for(m=0,p=u.length;m<p;m++)q=u[m],o=q.object,o.visible&&o.castShadow&&(o.matrixAutoUpdate&&o.matrixWorld.flattenToArray(o._objectMatrixArray),o._modelViewMatrix.multiplyToArray(r.matrixWorldInverse,o.matrixWorld,o._modelViewMatrixArray),b.renderImmediateObject(r,k.lights,null,c,o))}j=b.getClearColor();n=b.getClearAlpha();a.clearColor(j.r,j.g,j.b,n);a.enable(a.BLEND);
 b.shadowMapCullFrontFaces&&a.cullFace(a.BACK)}};THREE.ShadowMapPlugin.__projector=new THREE.Projector;
-THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,e,g,h,i,k,m,j;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;g=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
-h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,l=b.createProgram(),p=b.createShader(b.FRAGMENT_SHADER),q=b.createShader(b.VERTEX_SHADER);b.shaderSource(p,a.fragmentShader);b.shaderSource(q,a.vertexShader);b.compileShader(p);b.compileShader(q);b.attachShader(l,p);b.attachShader(l,q);b.linkProgram(l);i=l;k={};m={};k.position=b.getAttribLocation(i,"position");k.uv=b.getAttribLocation(i,"uv");m.uvOffset=b.getUniformLocation(i,"uvOffset");m.uvScale=b.getUniformLocation(i,
-"uvScale");m.rotation=b.getUniformLocation(i,"rotation");m.scale=b.getUniformLocation(i,"scale");m.alignment=b.getUniformLocation(i,"alignment");m.color=b.getUniformLocation(i,"color");m.map=b.getUniformLocation(i,"map");m.opacity=b.getUniformLocation(i,"opacity");m.useScreenCoordinates=b.getUniformLocation(i,"useScreenCoordinates");m.affectedByDistance=b.getUniformLocation(i,"affectedByDistance");m.screenPosition=b.getUniformLocation(i,"screenPosition");m.modelViewMatrix=b.getUniformLocation(i,"modelViewMatrix");
-m.projectionMatrix=b.getUniformLocation(i,"projectionMatrix");j=!1};this.render=function(d,e,p,q){var d=d.__webglSprites,o=d.length;if(o){var r=k,y=m,u=q/p,p=0.5*p,L=0.5*q,A=!0;b.useProgram(i);j||(b.enableVertexAttribArray(r.position),b.enableVertexAttribArray(r.uv),j=!0);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,g);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,h);b.uniformMatrix4fv(y.projectionMatrix,
-!1,e._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(y.map,0);for(var v,B=[],r=0;r<o;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<o;r++)v=d[r],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-
-p)/p,(L-v.position.y)/L,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)),e=v.map.image.width/(v.scaleByViewport?q:1),B[0]=e*u*v.scale.x,B[1]=e*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,
+THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,e,g,h,i,k,l,j;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;g=b.createBuffer();h=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,
+h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,m=b.createProgram(),p=b.createShader(b.FRAGMENT_SHADER),r=b.createShader(b.VERTEX_SHADER);b.shaderSource(p,a.fragmentShader);b.shaderSource(r,a.vertexShader);b.compileShader(p);b.compileShader(r);b.attachShader(m,p);b.attachShader(m,r);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,e,p,r){var d=d.__webglSprites,o=d.length;if(o){var q=k,y=l,u=r/p,p=0.5*p,K=0.5*r,A=!0;b.useProgram(i);j||(b.enableVertexAttribArray(q.position),b.enableVertexAttribArray(q.uv),j=!0);b.disable(b.CULL_FACE);b.enable(b.BLEND);b.depthMask(!0);b.bindBuffer(b.ARRAY_BUFFER,g);b.vertexAttribPointer(q.position,2,b.FLOAT,!1,16,0);b.vertexAttribPointer(q.uv,2,b.FLOAT,!1,16,8);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,h);b.uniformMatrix4fv(y.projectionMatrix,
+!1,e._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(y.map,0);for(var v,B=[],q=0;q<o;q++)if(v=d[q],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(q=0;q<o;q++)v=d[q],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-
+p)/p,(K-v.position.y)/K,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)),e=v.map.image.width/(v.scaleByViewport?r:1),B[0]=e*u*v.scale.x,B[1]=e*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,B),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:"anonymous",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=[],g=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)g.needsUpdate=!0;c&&c(this)},e[b].crossOrigin=this.crossOrigin,e[b].src=a[b];return g},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,g=document.createElement("canvas");g.width=d;g.height=e;var h=g.getContext("2d");h.drawImage(a,0,0);for(var i=h.getImageData(0,0,d,e).data,k=h.createImageData(d,e),m=k.data,j=0;j<d;j++)for(var n=1;n<e;n++){var l=0>n-1?e-1:n-1,p=(n+1)%e,q=0>j-1?d-1:j-1,o=(j+1)%d,r=[],y=[0,0,i[4*(n*d+j)]/255*b];r.push([-1,0,i[4*(n*d+q)]/255*b]);r.push([-1,-1,i[4*(l*d+q)]/255*b]);r.push([0,-1,
-i[4*(l*d+j)]/255*b]);r.push([1,-1,i[4*(l*d+o)]/255*b]);r.push([1,0,i[4*(n*d+o)]/255*b]);r.push([1,1,i[4*(p*d+o)]/255*b]);r.push([0,1,i[4*(p*d+j)]/255*b]);r.push([-1,1,i[4*(p*d+q)]/255*b]);l=[];q=r.length;for(p=0;p<q;p++){var o=r[p],u=r[(p+1)%q],o=[o[0]-y[0],o[1]-y[1],o[2]-y[2]],u=[u[0]-y[0],u[1]-y[1],u[2]-y[2]];l.push(c([o[1]*u[2]-o[2]*u[1],o[2]*u[0]-o[0]*u[2],o[0]*u[1]-o[1]*u[0]]))}r=[0,0,0];for(p=0;p<l.length;p++)r[0]+=l[p][0],r[1]+=l[p][1],r[2]+=l[p][2];r[0]/=l.length;r[1]/=l.length;r[2]/=l.length;
-y=4*(n*d+j);m[y]=255*((r[0]+1)/2)|0;m[y+1]=255*(r[1]+0.5)|0;m[y+2]=255*r[2]|0;m[y+3]=255}h.putImageData(k,0,0);return g}};
+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,g=document.createElement("canvas");g.width=d;g.height=e;var h=g.getContext("2d");h.drawImage(a,0,0);for(var i=h.getImageData(0,0,d,e).data,k=h.createImageData(d,e),l=k.data,j=0;j<d;j++)for(var n=1;n<e;n++){var m=0>n-1?e-1:n-1,p=(n+1)%e,r=0>j-1?d-1:j-1,o=(j+1)%d,q=[],y=[0,0,i[4*(n*d+j)]/255*b];q.push([-1,0,i[4*(n*d+r)]/255*b]);q.push([-1,-1,i[4*(m*d+r)]/255*b]);q.push([0,-1,
+i[4*(m*d+j)]/255*b]);q.push([1,-1,i[4*(m*d+o)]/255*b]);q.push([1,0,i[4*(n*d+o)]/255*b]);q.push([1,1,i[4*(p*d+o)]/255*b]);q.push([0,1,i[4*(p*d+j)]/255*b]);q.push([-1,1,i[4*(p*d+r)]/255*b]);m=[];r=q.length;for(p=0;p<r;p++){var o=q[p],u=q[(p+1)%r],o=[o[0]-y[0],o[1]-y[1],o[2]-y[2]],u=[u[0]-y[0],u[1]-y[1],u[2]-y[2]];m.push(c([o[1]*u[2]-o[2]*u[1],o[2]*u[0]-o[0]*u[2],o[0]*u[1]-o[1]*u[0]]))}q=[0,0,0];for(p=0;p<m.length;p++)q[0]+=m[p][0],q[1]+=m[p][1],q[2]+=m[p][2];q[0]/=m.length;q[1]/=m.length;q[2]/=m.length;
+y=4*(n*d+j);l[y]=255*((q[0]+1)/2)|0;l[y+1]=255*(q[1]+0.5)|0;l[y+2]=255*q[2]|0;l[y+3]=255}h.putImageData(k,0,0);return g}};

+ 2 - 2
examples/webgl_morphnormals.html

@@ -87,7 +87,7 @@
 				loader.load( "models/animated/flamingo.js", function( geometry ) {
 
 					morphColorsToFaceColors( geometry );
-					geometry.computeVertexNormals();
+					geometry.computeMorphNormals();
 
 					var material = new THREE.MeshLambertMaterial( { color: 0xffffff, morphTargets: true, morphNormals: true, vertexColors: THREE.FaceColors, shading: THREE.FlatShading } );
 					var meshAnim = new THREE.MorphAnimMesh( geometry, material );
@@ -105,7 +105,7 @@
 				loader.load( "models/animated/flamingo.js", function( geometry ) {
 
 					morphColorsToFaceColors( geometry );
-					geometry.computeVertexNormals();
+					geometry.computeMorphNormals();
 
 					var material = new THREE.MeshPhongMaterial( { color: 0xffffff, specular: 0xffffff, shininess: 20, morphTargets: true, morphNormals: true, vertexColors: THREE.FaceColors, shading: THREE.SmoothShading, perPixel: false } );
 					var meshAnim = new THREE.MorphAnimMesh( geometry, material );

+ 63 - 4
src/core/Geometry.js

@@ -230,16 +230,37 @@ THREE.Geometry.prototype = {
 
 		var i, il, f, fl, face;
 
-		// save original vertex normals
+		// save original normals
+		// - create temp variables on first access
+		//   otherwise just copy (for faster repeated calls)
 
 		for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
 
 			face = this.faces[ f ];
-			face.__originalVertexNormals = [];
+
+			if ( ! face.__originalFaceNormal ) {
+
+				face.__originalFaceNormal = face.normal.clone();
+
+			} else {
+
+				face.__originalFaceNormal.copy( face.normal );
+
+			}
+
+			if ( ! face.__originalVertexNormals ) face.__originalVertexNormals = [];
 
 			for ( i = 0, il = face.vertexNormals.length; i < il; i ++ ) {
 
-				face.__originalVertexNormals[ i ] = face.vertexNormals[ i ].clone();
+				if ( ! face.__originalVertexNormals[ i ] ) {
+
+					face.__originalVertexNormals[ i ] = face.vertexNormals[ i ].clone();
+
+				} else {
+
+					face.__originalVertexNormals[ i ].copy( face.vertexNormals[ i ] );
+
+				}
 
 			}
 
@@ -252,6 +273,42 @@ THREE.Geometry.prototype = {
 
 		for ( i = 0, il = this.morphTargets.length; i < il; i ++ ) {
 
+			// create on first access
+
+			if ( ! this.morphNormals[ i ] ) {
+
+				this.morphNormals[ i ] = {};
+				this.morphNormals[ i ].faceNormals = [];
+				this.morphNormals[ i ].vertexNormals = [];
+
+				var dstNormalsFace = this.morphNormals[ i ].faceNormals;
+				var dstNormalsVertex = this.morphNormals[ i ].vertexNormals;
+
+				var faceNormal, vertexNormals;
+
+				for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
+
+					face = this.faces[ f ];
+
+					faceNormal = new THREE.Vector3();
+
+					if ( face instanceof THREE.Face3 ) {
+
+						vertexNormals = { a: new THREE.Vector3(), b: new THREE.Vector3(), c: new THREE.Vector3() };
+
+					} else {
+
+						vertexNormals = { a: new THREE.Vector3(), b: new THREE.Vector3(), c: new THREE.Vector3(), d: new THREE.Vector3() };
+
+					}
+
+					dstNormalsFace.push( faceNormal );
+					dstNormalsVertex.push( vertexNormals );
+
+				}
+
+			}
+
 			var morphNormals = this.morphNormals[ i ];
 
 			// set vertices to morph target
@@ -295,11 +352,13 @@ THREE.Geometry.prototype = {
 
 		}
 
-		// restore original vertex normals
+		// restore original normals
 
 		for ( f = 0, fl = this.faces.length; f < fl; f ++ ) {
 
 			face = this.faces[ f ];
+
+			face.normal = face.__originalFaceNormal;
 			face.vertexNormals = face.__originalVertexNormals;
 
 		}

+ 1 - 32
src/extras/loaders/JSONLoader.js

@@ -110,7 +110,6 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 	parseMorphing( scale );
 
 	geometry.computeCentroids();
-	geometry.computeMorphNormals();
 	geometry.computeFaceNormals();
 
 	if ( this.hasNormals( geometry ) ) geometry.computeTangents();
@@ -385,9 +384,7 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 		if ( json.morphTargets !== undefined ) {
 
-			var i, l, v, vl, x, y, z, dstVertices, srcVertices,
-				f, fl, face, dstNormalsFace, dstNormalsVertex,
-				faceNormal, vertexNormals;
+			var i, l, v, vl, x, y, z, dstVertices, srcVertices;
 
 			for ( i = 0, l = json.morphTargets.length; i < l; i ++ ) {
 
@@ -395,16 +392,9 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 				geometry.morphTargets[ i ].name = json.morphTargets[ i ].name;
 				geometry.morphTargets[ i ].vertices = [];
 
-				geometry.morphNormals[ i ] = {};
-				geometry.morphNormals[ i ].faceNormals = [];
-				geometry.morphNormals[ i ].vertexNormals = [];
-
 				dstVertices = geometry.morphTargets[ i ].vertices;
 				srcVertices = json.morphTargets [ i ].vertices;
 
-				dstNormalsFace = geometry.morphNormals[ i ].faceNormals;
-				dstNormalsVertex = geometry.morphNormals[ i ].vertexNormals;
-
 				for( v = 0, vl = srcVertices.length; v < vl; v += 3 ) {
 
 					x = srcVertices[ v ] * scale;
@@ -415,27 +405,6 @@ THREE.JSONLoader.prototype.createModel = function ( json, callback, texture_path
 
 				}
 
-				for ( f = 0, fl = geometry.faces.length; f < fl; f ++ ) {
-
-					face = geometry.faces[ f ];
-
-					faceNormal = new THREE.Vector3();
-
-					if ( face instanceof THREE.Face3 ) {
-
-						vertexNormals = { a: new THREE.Vector3(), b: new THREE.Vector3(), c: new THREE.Vector3() };
-
-					} else {
-
-						vertexNormals = { a: new THREE.Vector3(), b: new THREE.Vector3(), c: new THREE.Vector3(), d: new THREE.Vector3() };
-
-					}
-
-					dstNormalsFace.push( faceNormal );
-					dstNormalsVertex.push( vertexNormals );
-
-				}
-
 			}
 
 		}

+ 42 - 8
src/renderers/WebGLRenderer.js

@@ -395,16 +395,26 @@ THREE.WebGLRenderer = function ( parameters ) {
 		geometryGroup.__webglFaceBuffer = _gl.createBuffer();
 		geometryGroup.__webglLineBuffer = _gl.createBuffer();
 
-		if ( geometryGroup.numMorphTargets ) {
+		var m, ml;
 
-			var m, ml;
+		if ( geometryGroup.numMorphTargets ) {
 
 			geometryGroup.__webglMorphTargetsBuffers = [];
-			geometryGroup.__webglMorphNormalsBuffers = [];
 
 			for ( m = 0, ml = geometryGroup.numMorphTargets; m < ml; m ++ ) {
 
 				geometryGroup.__webglMorphTargetsBuffers.push( _gl.createBuffer() );
+
+			}
+
+		}
+
+		if ( geometryGroup.numMorphNormals ) {
+
+			geometryGroup.__webglMorphNormalsBuffers = [];
+
+			for ( m = 0, ml = geometryGroup.numMorphNormals; m < ml; m ++ ) {
+
 				geometryGroup.__webglMorphNormalsBuffers.push( _gl.createBuffer() );
 
 			}
@@ -461,11 +471,22 @@ THREE.WebGLRenderer = function ( parameters ) {
 		_gl.deleteBuffer( geometryGroup.__webglFaceBuffer );
 		_gl.deleteBuffer( geometryGroup.__webglLineBuffer );
 
+		var m, ml;
+
 		if ( geometryGroup.numMorphTargets ) {
 
-			for ( var m = 0, ml = geometryGroup.numMorphTargets; m < ml; m ++ ) {
+			for ( m = 0, ml = geometryGroup.numMorphTargets; m < ml; m ++ ) {
 
 				_gl.deleteBuffer( geometryGroup.__webglMorphTargetsBuffers[ m ] );
+
+			}
+
+		}
+
+		if ( geometryGroup.numMorphNormals ) {
+
+			for ( m = 0, ml = geometryGroup.numMorphNormals; m < ml; m ++ ) {
+
 				_gl.deleteBuffer( geometryGroup.__webglMorphNormalsBuffers[ m ] );
 
 			}
@@ -642,14 +663,26 @@ THREE.WebGLRenderer = function ( parameters ) {
 		geometryGroup.__faceArray = new Uint16Array( ntris * 3 );
 		geometryGroup.__lineArray = new Uint16Array( nlines * 2 );
 
+		var m, ml;
+
 		if ( geometryGroup.numMorphTargets ) {
 
 			geometryGroup.__morphTargetsArrays = [];
-			geometryGroup.__morphNormalsArrays = [];
 
-			for ( var m = 0, ml = geometryGroup.numMorphTargets; m < ml; m ++ ) {
+			for ( m = 0, ml = geometryGroup.numMorphTargets; m < ml; m ++ ) {
 
 				geometryGroup.__morphTargetsArrays.push( new Float32Array( nvertices * 3 ) );
+
+			}
+
+		}
+
+		if ( geometryGroup.numMorphNormals ) {
+
+			geometryGroup.__morphNormalsArrays = [];
+
+			for ( m = 0, ml = geometryGroup.numMorphNormals; m < ml; m ++ ) {
+
 				geometryGroup.__morphNormalsArrays.push( new Float32Array( nvertices * 3 ) );
 
 			}
@@ -3634,6 +3667,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 			hash_map = {};
 
 		var numMorphTargets = geometry.morphTargets.length;
+		var numMorphNormals = geometry.morphNormals.length;
 
 		geometry.geometryGroups = {};
 
@@ -3654,7 +3688,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 			if ( geometry.geometryGroups[ groupHash ] === undefined ) {
 
-				geometry.geometryGroups[ groupHash ] = { 'faces3': [], 'faces4': [], 'materialIndex': materialIndex, 'vertices': 0, 'numMorphTargets': numMorphTargets };
+				geometry.geometryGroups[ groupHash ] = { 'faces3': [], 'faces4': [], 'materialIndex': materialIndex, 'vertices': 0, 'numMorphTargets': numMorphTargets, 'numMorphNormals': numMorphNormals };
 
 			}
 
@@ -3667,7 +3701,7 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 				if ( geometry.geometryGroups[ groupHash ] === undefined ) {
 
-					geometry.geometryGroups[ groupHash ] = { 'faces3': [], 'faces4': [], 'materialIndex': materialIndex, 'vertices': 0, 'numMorphTargets': numMorphTargets };
+					geometry.geometryGroups[ groupHash ] = { 'faces3': [], 'faces4': [], 'materialIndex': materialIndex, 'vertices': 0, 'numMorphTargets': numMorphTargets, 'numMorphNormals': numMorphNormals };
 
 				}