فهرست منبع

Projector now negates (inverts?) the normals when culled and flipSided || doubleSided. Fixes #1270.

Mr.doob 13 سال پیش
والد
کامیت
55e0a843da
8فایلهای تغییر یافته به همراه683 افزوده شده و 665 حذف شده
  1. 272 272
      build/Three.js
  2. 48 47
      build/custom/ThreeCanvas.js
  3. 23 23
      build/custom/ThreeDOM.js
  4. 139 140
      build/custom/ThreeExtras.js
  5. 34 34
      build/custom/ThreeSVG.js
  6. 125 124
      build/custom/ThreeWebGL.js
  7. 0 1
      examples/canvas_lights_pointlights_smooth.html
  8. 42 24
      src/core/Projector.js

+ 272 - 272
build/Three.js

@@ -2,7 +2,7 @@
 'use strict';var THREE=THREE||{REVISION:"48dev"};if(!self.Int32Array)self.Int32Array=Array,self.Float32Array=Array;
 (function(){for(var a=0,b=["ms","moz","webkit","o"],c=0;c<b.length&&!window.requestAnimationFrame;++c)window.requestAnimationFrame=window[b[c]+"RequestAnimationFrame"],window.cancelAnimationFrame=window[b[c]+"CancelAnimationFrame"]||window[b[c]+"CancelRequestAnimationFrame"];if(!window.requestAnimationFrame)window.requestAnimationFrame=function(b){var c=(new Date).getTime(),g=Math.max(0,16-(c-a)),f=window.setTimeout(function(){b(c+g)},g);a=c+g;return f};if(!window.cancelAnimationFrame)window.cancelAnimationFrame=
 function(a){clearTimeout(a)}})();THREE.Clock=function(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1};THREE.Clock.prototype.start=function(){this.oldTime=this.startTime=Date.now();this.running=!0};THREE.Clock.prototype.stop=function(){this.getElapsedTime();this.running=!1};THREE.Clock.prototype.getElapsedTime=function(){return this.elapsedTime+=this.getDelta()};
-THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=Date.now(),a=0.0010*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a};THREE.Color=function(a){void 0!==a&&this.setHex(a);return this};
+THREE.Clock.prototype.getDelta=function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=Date.now(),a=0.001*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a};THREE.Color=function(a){void 0!==a&&this.setHex(a);return this};
 THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a){this.r=a.r*a.r;this.g=a.g*a.g;this.b=a.b*a.b;return this},copyLinearToGamma:function(a){this.r=Math.sqrt(a.r);this.g=Math.sqrt(a.g);this.b=Math.sqrt(a.b);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);
 this.b=Math.sqrt(this.b);return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSV:function(a,b,c){var d,e,g;if(0===c)this.r=this.g=this.b=0;else switch(d=Math.floor(6*a),e=6*a-d,a=c*(1-b),g=c*(1-b*e),b=c*(1-b*(1-e)),d){case 1:this.r=g;this.g=c;this.b=a;break;case 2:this.r=a;this.g=c;this.b=b;break;case 3:this.r=a;this.g=g;this.b=c;break;case 4:this.r=b;this.g=a;this.b=c;break;case 5:this.r=c;this.g=a;this.b=g;break;case 6:case 0:this.r=c,this.g=b,this.b=a}return this},setHex:function(a){a=
 Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},getHex:function(){return Math.floor(255*this.r)<<16^Math.floor(255*this.g)<<8^Math.floor(255*this.b)},getContextStyle:function(){return"rgb("+Math.floor(255*this.r)+","+Math.floor(255*this.g)+","+Math.floor(255*this.b)+")"},clone:function(){return(new THREE.Color).setRGB(this.r,this.g,this.b)}};THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
@@ -19,11 +19,11 @@ 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,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.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]));
+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);y=q.dot(q);D=q.dot(m);A=1/(w*y-u*u);C=(y*v-u*D)*A;E=(w*D-u*v)*A;return 0<=C&&0<=E&&1>C+E}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;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,f=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){var b,m=[];if(a instanceof THREE.Particle){var 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){var 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)),g=u.multiplyVector3(g.copy(t[b.b].position)),f=u.multiplyVector3(f.copy(t[b.c].position)),d(n,e,g,f)&&(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)),
-g=u.multiplyVector3(g.copy(t[b.b].position)),f=u.multiplyVector3(f.copy(t[b.c].position)),h=u.multiplyVector3(h.copy(t[b.d].position)),d(n,e,g,h)||d(n,g,f,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};
+g=u.multiplyVector3(g.copy(t[b.b].position)),f=u.multiplyVector3(f.copy(t[b.c].position)),h=u.multiplyVector3(h.copy(t[b.d].position)),d(n,e,g,h)||d(n,g,f,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,y,D,A,C,E};
 THREE.Rectangle=function(){function a(){g=d-b;f=e-c}var b,c,d,e,g,f,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return g};this.getHeight=function(){return f};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(g,f,l,p){h=!1;b=g;c=f;d=l;e=p;a()};this.addPoint=function(g,f){h?(h=!1,b=g,c=f,d=g,e=f):(b=b<g?b:g,c=c<f?c:f,d=d>g?d:g,e=e>f?e:f);a()};this.add3Points=
 function(g,f,l,p,n,o){h?(h=!1,b=g<l?g<n?g:n:l<n?l:n,c=f<p?f<o?f:o:p<o?p:o,d=g>l?g>n?g:n:l>n?l:n,e=f>p?f>o?f:o:p>o?p:o):(b=g<l?g<n?g<b?g:b:n<b?n:b:l<n?l<b?l:b:n<b?n:b,c=f<p?f<o?f<c?f:c:o<c?o:c:p<o?p<c?p:c:o<c?o:c,d=g>l?g>n?g>d?g:d:n>d?n:d:l>n?l>d?l:d:n>d?n:d,e=f>p?f>o?f>e?f:e:o>e?o:e:p>o?p>e?p:e:o>e?o:e);a()};this.addRectangle=function(g){h?(h=!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(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
@@ -32,8 +32,8 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=
 THREE.Matrix4=function(a,b,c,d,e,g,f,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!==g?g:1,f||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,g,f,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=g;this.n23=f;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,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,f=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+g*L;this.n12=c*w+d*B+e*K+g*P;this.n13=c*u+d*C+e*O+g*H;this.n14=c*v+d*D+e*S+g*G;this.n21=f*t+h*A+i*I+k*L;this.n22=f*w+h*B+i*K+k*P;this.n23=f*u+h*C+i*O+k*H;this.n24=f*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*=
+s=a.n44,t=b.n11,w=b.n12,u=b.n13,v=b.n14,y=b.n21,D=b.n22,A=b.n23,C=b.n24,E=b.n31,J=b.n32,N=b.n33,T=b.n34,K=b.n41,P=b.n42,M=b.n43,H=b.n44;this.n11=c*t+d*y+e*E+g*K;this.n12=c*w+d*D+e*J+g*P;this.n13=c*u+d*A+e*N+g*M;this.n14=c*v+d*C+e*T+g*H;this.n21=f*t+h*y+i*E+k*K;this.n22=f*w+h*D+i*J+k*P;this.n23=f*u+h*A+i*N+k*M;this.n24=f*v+h*C+i*T+k*H;this.n31=l*t+p*y+n*E+o*K;this.n32=l*w+p*D+n*J+o*P;this.n33=l*u+p*A+n*N+o*M;this.n34=l*v+p*C+n*T+o*H;this.n41=q*t+m*y+r*E+s*K;this.n42=q*w+m*D+r*J+s*P;this.n43=q*u+m*
+A+r*N+s*M;this.n44=q*v+m*C+r*T+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*=
 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,f=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*f*k*n-c*h*k*n-d*g*l*n+b*h*l*n+c*g*p*n-b*f*p*n-d*f*i*o+c*h*i*o+d*e*l*o-a*h*l*o-c*e*p*o+a*f*p*o+d*g*i*q-b*h*i*q-d*e*k*q+a*h*k*q+b*e*p*q-a*g*p*q-c*g*i*m+b*f*i*m+c*e*k*m-a*f*k*m-b*e*l*m+a*g*l*m},transpose:function(){var a;
@@ -50,8 +50,8 @@ e,l=c*h,p=c*e,this.n11=f*h,this.n12=-f*e,this.n13=d,this.n21=k+l*d,this.n22=i-p*
 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,f=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=g+(1-g)*i,g=p+k,d=n-o,p=p-k,f=f+(1-f)*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+g*m+d*w;this.n21=e*c+g*r+d*u;this.n31=e*o+g*s+d*v;this.n41=e*q+g*t+d*A;this.n12=p*i+f*m+k*w;this.n22=
-p*c+f*r+k*u;this.n32=p*o+f*s+k*v;this.n42=p*q+f*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,g=this.n13,f=this.n23,h=this.n33,i=this.n43,k=Math.cos(a),a=Math.sin(a);this.n12=k*b+a*g;this.n22=k*c+a*f;this.n32=k*d+a*h;this.n42=k*e+a*i;this.n13=k*g-a*b;this.n23=k*f-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,g=Math.sqrt(c*c+d*d+e*e),c=c/g,d=d/g,e=e/g,g=c*c,f=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=g+(1-g)*i,g=p+k,d=n-o,p=p-k,f=f+(1-f)*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,y=this.n43;this.n11=e*i+g*m+d*w;this.n21=e*c+g*r+d*u;this.n31=e*o+g*s+d*v;this.n41=e*q+g*t+d*y;this.n12=p*i+f*m+k*w;this.n22=
+p*c+f*r+k*u;this.n32=p*o+f*s+k*v;this.n42=p*q+f*t+k*y;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*y;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,g=this.n13,f=this.n23,h=this.n33,i=this.n43,k=Math.cos(a),a=Math.sin(a);this.n12=k*b+a*g;this.n22=k*c+a*f;this.n32=k*d+a*h;this.n42=k*e+a*i;this.n13=k*g-a*b;this.n23=k*f-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,
 g=this.n13,f=this.n23,h=this.n33,i=this.n43,k=Math.cos(a),a=Math.sin(a);this.n11=k*b-a*g;this.n21=k*c-a*f;this.n31=k*d-a*h;this.n41=k*e-a*i;this.n13=k*g+a*b;this.n23=k*f+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,g=this.n12,f=this.n22,h=this.n32,i=this.n42,k=Math.cos(a),a=Math.sin(a);this.n11=k*b+a*g;this.n21=k*c+a*f;this.n31=k*d+a*h;this.n41=k*e+a*i;this.n12=k*g-a*b;this.n22=k*f-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,g=a.n32*a.n21-a.n31*a.n22,f=-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*f+a.n31*k;if(0===a)return null;a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*g;c[3]=a*f;c[4]=a*h;c[5]=a*i;c[6]=a*k;c[7]=a*l;c[8]=a*p;return b};
@@ -64,22 +64,23 @@ 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=f[g]=f[g]||new THREE.RenderableObject;g++;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,g=b.z+b.w,f=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=g&&0<=f&&0<=h)return!0;if(0>e&&0>g||0>f&&0>h)return!1;0>e?c=Math.max(c,e/(e-g)):0>g&&(d=Math.min(d,e/(e-g)));0>f?c=Math.max(c,f/(f-h)):0>h&&(d=Math.min(d,f/(f-h)));if(d<c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return!0}
-var e,g,f=[],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){g=0;v.objects.length=0;v.sprites.length=0;v.lights.length=0;var f=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++)f(b.children[c])}};f(b);d&&v.objects.sort(c);return v};this.projectScene=function(a,e,g){var f=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>f&&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))f=u[w]=u[w]||new THREE.RenderableParticle,w++,t=f,
-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);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};
+var e,g,f=[],h,i,k=[],l,p,n=[],o,q=[],m,r,s=[],t,w,u=[],v={objects:[],sprites:[],lights:[],elements:[]},y=new THREE.Vector3,D=new THREE.Vector4,A=new THREE.Matrix4,C=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);A.multiply(b.projectionMatrix,b.matrixWorldInverse);A.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);A.multiply(b.matrixWorld,
+b.projectionMatrixInverse);A.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 f=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||E.contains(b))?(A.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?(A.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++)f(b.children[c])}};f(b);d&&v.objects.sort(c);return v};this.projectScene=function(a,e,g){var f=e.near,H=e.far,j=!1,y,B,F,Z,O,ga,da,ia,S,aa,R,ba,ea,Ua,Ha;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);A.multiply(e.projectionMatrix,e.matrixWorldInverse);E.setFromMatrix(A);v=this.projectGraph(a,!1);for(a=0,y=v.objects.length;a<y;a++)if(S=v.objects[a].object,aa=S.matrixWorld,i=0,S instanceof THREE.Mesh){R=S.geometry;ba=S.geometry.materials;Z=R.vertices;ea=R.faces;Ua=R.faceVertexUvs;R=S.matrixRotationWorld.extractRotation(aa);for(B=0,F=Z.length;B<F;B++)h=b(),h.positionWorld.copy(Z[B].position),aa.multiplyVector3(h.positionWorld),
+h.positionScreen.copy(h.positionWorld),A.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>f&&h.positionScreen.z<H;for(Z=0,B=ea.length;Z<B;Z++){F=ea[Z];if(F instanceof THREE.Face3)if(O=k[F.a],ga=k[F.b],da=k[F.c],O.visible&&ga.visible&&da.visible)if(j=0>(da.positionScreen.x-O.positionScreen.x)*(ga.positionScreen.y-O.positionScreen.y)-(da.positionScreen.y-O.positionScreen.y)*(ga.positionScreen.x-O.positionScreen.x),
+S.doubleSided||j!=S.flipSided)ia=n[p]=n[p]||new THREE.RenderableFace3,p++,l=ia,l.v1.copy(O),l.v2.copy(ga),l.v3.copy(da);else continue;else continue;else if(F instanceof THREE.Face4)if(O=k[F.a],ga=k[F.b],da=k[F.c],ia=k[F.d],O.visible&&ga.visible&&da.visible&&ia.visible)if(j=0>(ia.positionScreen.x-O.positionScreen.x)*(ga.positionScreen.y-O.positionScreen.y)-(ia.positionScreen.y-O.positionScreen.y)*(ga.positionScreen.x-O.positionScreen.x)||0>(ga.positionScreen.x-da.positionScreen.x)*(ia.positionScreen.y-
+da.positionScreen.y)-(ga.positionScreen.y-da.positionScreen.y)*(ia.positionScreen.x-da.positionScreen.x),S.doubleSided||j!=S.flipSided)Ha=q[o]=q[o]||new THREE.RenderableFace4,o++,l=Ha,l.v1.copy(O),l.v2.copy(ga),l.v3.copy(da),l.v4.copy(ia);else continue;else continue;l.normalWorld.copy(F.normal);!j&&(S.flipSided||S.doubleSided)&&l.normalWorld.negate();R.multiplyVector3(l.normalWorld);l.centroidWorld.copy(F.centroid);aa.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);A.multiplyVector3(l.centroidScreen);
+da=F.vertexNormals;for(O=0,ga=da.length;O<ga;O++)ia=l.vertexNormalsWorld[O],ia.copy(da[O]),!j&&(S.flipSided||S.doubleSided)&&ia.negate(),R.multiplyVector3(ia);for(O=0,ga=Ua.length;O<ga;O++)if(Ha=Ua[O][Z])for(da=0,ia=Ha.length;da<ia;da++)l.uvs[O][da]=Ha[da];l.material=S.material;l.faceMaterial=null!==F.materialIndex?ba[F.materialIndex]:null;l.z=l.centroidScreen.z;v.elements.push(l)}}else if(S instanceof THREE.Line){C.multiply(A,aa);Z=S.geometry.vertices;O=b();O.positionScreen.copy(Z[0].position);C.multiplyVector4(O.positionScreen);
+for(B=1,F=Z.length;B<F;B++)if(O=b(),O.positionScreen.copy(Z[B].position),C.multiplyVector4(O.positionScreen),ga=k[i-2],J.copy(O.positionScreen),N.copy(ga.positionScreen),d(J,N))J.multiplyScalar(1/J.w),N.multiplyScalar(1/N.w),aa=s[r]=s[r]||new THREE.RenderableLine,r++,m=aa,m.v1.positionScreen.copy(J),m.v2.positionScreen.copy(N),m.z=Math.max(J.z,N.z),m.material=S.material,v.elements.push(m)}for(a=0,y=v.sprites.length;a<y;a++)if(S=v.sprites[a].object,aa=S.matrixWorld,S instanceof THREE.Particle&&(D.set(aa.n14,
+aa.n24,aa.n34,1),A.multiplyVector4(D),D.z/=D.w,0<D.z&&1>D.z))f=u[w]=u[w]||new THREE.RenderableParticle,w++,t=f,t.x=D.x/D.w,t.y=D.y/D.w,t.z=D.z,t.rotation=S.rotation.z,t.scale.x=S.scale.x*Math.abs(t.x-(D.x+e.projectionMatrix.n11)/(D.w+e.projectionMatrix.n14)),t.scale.y=S.scale.y*Math.abs(t.y-(D.y+e.projectionMatrix.n22)/(D.w+e.projectionMatrix.n24)),t.material=S.material,v.elements.push(t);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),f=a*b,h=d*e;this.w=f*g-h*c;this.x=f*c+h*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,f=a.y,h=a.z,a=a.w;this.x=b*a+e*g+c*h-d*f;this.y=c*a+e*f+d*g-b*h;this.z=d*a+e*h+b*f-c*g;this.w=e*a-b*g-c*f-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,g=this.x,f=this.y,h=this.z,i=this.w,k=i*c+f*e-h*d,l=i*d+h*c-g*e,p=i*e+g*d-f*c,c=-g*c-f*d-h*e;b.x=k*i+c*-g+l*-h-p*-f;b.y=l*i+c*-f+p*-g-k*-h;b.z=p*i+c*-h+k*-f-l*-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.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.001>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,f){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=f;this.centroid=new THREE.Vector3};THREE.UV=function(a,b){this.u=a||0;this.v=b||0};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
@@ -92,9 +93,9 @@ d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));for(
 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 f=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},f.push(i),h.push(k)}f=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],i=f.faceNormals[c],k=f.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,g,C){h=a.vertices[b].position;i=a.vertices[c].position;k=a.vertices[d].position;l=f[e];p=f[g];n=f[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,g,f,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++)g=this.faces[b],f=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 H=["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++)P.copy(g.vertexNormals[d]),e=g[H[d]],
-C=D[e],S.copy(C),S.subSelf(P.multiplyScalar(P.dot(C))).normalize(),L.cross(g.vertexNormals[d],C),e=L.dot(I[e]),e=0>e?-1:1,g.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<
+b,c,d,e,g,O){h=a.vertices[b].position;i=a.vertices[c].position;k=a.vertices[d].position;l=f[e];p=f[g];n=f[O];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;y=n.v-l.v;D=1/(w*y-u*v);J.set((y*o-v*q)*D,(y*m-v*r)*D,(y*s-v*t)*D);N.set((w*q-u*o)*D,(w*r-u*m)*D,(w*t-u*s)*D);C[b].addSelf(J);C[c].addSelf(J);C[d].addSelf(J);E[b].addSelf(N);E[c].addSelf(N);E[d].addSelf(N)}var b,c,d,e,g,f,h,i,k,l,p,n,o,q,m,r,s,t,w,u,v,y,D,A,C=[],E=[],J=new THREE.Vector3,N=new THREE.Vector3,
+T=new THREE.Vector3,K=new THREE.Vector3,P=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)C[b]=new THREE.Vector3,E[b]=new THREE.Vector3;for(b=0,c=this.faces.length;b<c;b++)g=this.faces[b],f=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 M=["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++)P.copy(g.vertexNormals[d]),e=g[M[d]],
+A=C[e],T.copy(A),T.subSelf(P.multiplyScalar(P.dot(A))).normalize(),K.cross(g.vertexNormals[d],A),e=K.dot(E[e]),e=0>e?-1:1,g.vertexTangents[d]=new THREE.Vector4(T.x,T.y,T.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,f;for(g=0,f=this.vertices.length;g<f;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,f=this.faces.length;g<f;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,f){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*f+(-3*(b-c)-2*a-d)*g+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,g,f,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;g=Math.floor(e);f=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;k=this.points[c[0]];l=this.points[c[1]];
@@ -103,7 +104,7 @@ g.copy(d),b*=this.points.length-1,b=Math.floor(b),b!=e&&(h[b]=i,e=b);h[h.length]
 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,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;
-THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:43.25)/(2*a));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()};
+THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:24)/(2*a))*(180/Math.PI);this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()};
 THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
 this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0;this.onlyShadow=this.castShadow=!1;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraLeft=-500;this.shadowCameraTop=this.shadowCameraRight=500;this.shadowCameraBottom=-500;this.shadowCameraVisible=!1;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCascade=
@@ -165,45 +166,45 @@ THREE.Scene.prototype.removeObject=function(a){if(a instanceof THREE.Light){var
 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,g;this.domElement=document.createElement("div");this.setSize=function(a,b){c=a;d=b;e=c/2;g=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*g+g;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||{},g=this,f,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*
+p,n,o,q,m=l.getContext("2d"),r=new THREE.Color(0),s=0,t=1,w=0,u=null,v=null,y=null,D=null,A=null,C,E,J,N,T=new THREE.RenderableVertex,K=new THREE.RenderableVertex,P,M,H,j,Y,B,F,Z,O,ga,da,ia,S=new THREE.Color,aa=new THREE.Color,R=new THREE.Color,ba=new THREE.Color,ea=new THREE.Color,Ua=[],Ha=[],na,Ia,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,$=new THREE.Vector3,Q,Fb,Uc,eb,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);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;A=D=y=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,
-g,f,j,h,i;for(e=0,g=a.length;e<g;e++)f=a[e],j=f.color,f instanceof THREE.DirectionalLight?(h=f.matrixWorld.getPosition(),i=c.dot(h),0>=i||(i*=f.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)):f instanceof THREE.PointLight&&(h=f.matrixWorld.getPosition(),i=c.dot(Z.sub(h,b).normalize()),0>=i||(i*=0==f.distance?1:1-Math.min(b.distanceTo(h)/f.distance,1),0!=i&&(i*=f.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)))}function r(a,g,f){b(f.opacity);c(f.blending);var Z,j,h,i,n,k;if(f instanceof THREE.ParticleBasicMaterial){if(f.map)i=
-f.map.image,n=i.width>>1,k=i.height>>1,f=g.scale.x*o,h=g.scale.y*q,Z=f*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(-g.rotation),m.scale(f,-h),m.translate(-n,-k),m.drawImage(i,0,0),m.restore())}else f instanceof THREE.ParticleCanvasMaterial&&(Z=g.scale.x*o,j=g.scale.y*q,Aa.set(a.x-Z,a.y-j,a.x+Z,a.y+j),La.intersects(Aa)&&(d(f.color.getContextStyle()),e(f.color.getContextStyle()),m.save(),m.translate(a.x,a.y),m.rotate(-g.rotation),m.scale(Z,j),f.program(m),
-m.restore()))}function s(a,e,g,f){b(f.opacity);c(f.blending);m.beginPath();m.moveTo(a.positionScreen.x,a.positionScreen.y);m.lineTo(e.positionScreen.x,e.positionScreen.y);m.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(A!=a)m.lineWidth=A=a;a=f.linecap;if(B!=a)m.lineCap=B=a;a=f.linejoin;if(C!=a)m.lineJoin=C=a;d(f.color.getContextStyle());m.stroke();Aa.inflate(2*f.linewidth)}}function t(a,d,e,f,h,k,m,R){g.info.render.vertices+=3;g.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[f].u,qa[f].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[f]),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[f].u,qa[f].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,f,Z,h,R,m,k){g.info.render.vertices+=4;g.info.render.faces++;b(m.opacity);c(m.blending);if(m.map||m.envMap)t(a,d,f,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=f.positionScreen.x,Q=f.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(f.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,f){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(a,b);m.closePath()}function v(a,
-b,c,d,e,f,g,Z){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(g,Z);m.lineTo(a,b);m.closePath()}function 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,f,g,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,f=f-a,g=g-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*f)*l,i=(n*d-i*g)*l,c=(h*f-R*c)*l,d=(h*g-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,f,g,Z,j,h,i,R,k){var n,l;n=k.width-1;l=k.height-1;g*=n;Z*=l;c-=a;d-=b;e-=a;f-=b;j=j*n-g;h=h*l-Z;i=i*n-g;R=R*l-Z;l=1/(j*R-i*h);n=(R*c-h*e)*l;h=(R*d-h*f)*l;c=(j*e-i*c)*l;d=(j*f-i*d)*l;a=a-n*g-c*Z;b=b-h*g-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),f=~~(255*a.g),a=~~(255*a.b),g=~~(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>f?0:255<f?255:f;eb[2]=0>a?0:255<a?255:a;eb[4]=0>g?0:255<g?255:g;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);g.info.render.vertices=0;g.info.render.faces=0;f=k.projectScene(a,n,this.sortElements);h=f.elements;i=
-f.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,f,g,h,i,m;for(e=0,f=a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(i=g.matrixWorld.getPosition(),m=c.dot(i),0>=m||(m*=g.intensity,d.r+=h.r*m,d.g+=h.g*m,d.b+=h.b*m)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),m=c.dot(D.sub(i,b).normalize()),0>=m||(m*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=m&&(m*=g.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,g,f,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);g=e.elements;
-f=e.lights;L=S=0;if(w=0<f.length){v.setRGB(0,0,0);A.setRGB(0,0,0);B.setRGB(0,0,0);for(j=0,D=f.length;j<D;j++)E=f[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=g.length;j<D;j++)if(z=g[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(f,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(f,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)}}};
+g,f,j,h,i;for(e=0,g=a.length;e<g;e++)f=a[e],j=f.color,f instanceof THREE.DirectionalLight?(h=f.matrixWorld.getPosition(),i=c.dot(h),0>=i||(i*=f.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)):f instanceof THREE.PointLight&&(h=f.matrixWorld.getPosition(),i=c.dot($.sub(h,b).normalize()),0>=i||(i*=0==f.distance?1:1-Math.min(b.distanceTo(h)/f.distance,1),0!=i&&(i*=f.intensity,d.r+=j.r*i,d.g+=j.g*i,d.b+=j.b*i)))}function r(a,g,f){b(f.opacity);c(f.blending);var $,j,h,i,n,k;if(f instanceof THREE.ParticleBasicMaterial){if(f.map)i=
+f.map.image,n=i.width>>1,k=i.height>>1,f=g.scale.x*o,h=g.scale.y*q,$=f*n,j=h*k,Aa.set(a.x-$,a.y-j,a.x+$,a.y+j),La.intersects(Aa)&&(m.save(),m.translate(a.x,a.y),m.rotate(-g.rotation),m.scale(f,-h),m.translate(-n,-k),m.drawImage(i,0,0),m.restore())}else f instanceof THREE.ParticleCanvasMaterial&&($=g.scale.x*o,j=g.scale.y*q,Aa.set(a.x-$,a.y-j,a.x+$,a.y+j),La.intersects(Aa)&&(d(f.color.getContextStyle()),e(f.color.getContextStyle()),m.save(),m.translate(a.x,a.y),m.rotate(-g.rotation),m.scale($,j),f.program(m),
+m.restore()))}function s(a,e,g,f){b(f.opacity);c(f.blending);m.beginPath();m.moveTo(a.positionScreen.x,a.positionScreen.y);m.lineTo(e.positionScreen.x,e.positionScreen.y);m.closePath();if(f instanceof THREE.LineBasicMaterial){a=f.linewidth;if(y!=a)m.lineWidth=y=a;a=f.linecap;if(D!=a)m.lineCap=D=a;a=f.linejoin;if(A!=a)m.lineJoin=A=a;d(f.color.getContextStyle());m.stroke();Aa.inflate(2*f.linewidth)}}function t(a,d,e,f,h,k,m,Q){g.info.render.vertices+=3;g.info.render.faces++;b(Q.opacity);c(Q.blending);
+P=a.positionScreen.x;M=a.positionScreen.y;H=d.positionScreen.x;j=d.positionScreen.y;Y=e.positionScreen.x;B=e.positionScreen.y;w(P,M,H,j,Y,B);if(Q instanceof THREE.MeshBasicMaterial)if(Q.map)Q.map.mapping instanceof THREE.UVMapping&&(qa=m.uvs[0],Vc(P,M,H,j,Y,B,qa[f].u,qa[f].v,qa[h].u,qa[h].v,qa[k].u,qa[k].v,Q.map));else if(Q.envMap){if(Q.envMap.mapping instanceof THREE.SphericalReflectionMapping)a=n.matrixWorldInverse,$.copy(m.vertexNormalsWorld[f]),ib=0.5*($.x*a.n11+$.y*a.n12+$.z*a.n13)+0.5,Va=0.5*
+-($.x*a.n21+$.y*a.n22+$.z*a.n23)+0.5,$.copy(m.vertexNormalsWorld[h]),lb=0.5*($.x*a.n11+$.y*a.n12+$.z*a.n13)+0.5,db=0.5*-($.x*a.n21+$.y*a.n22+$.z*a.n23)+0.5,$.copy(m.vertexNormalsWorld[k]),Wa=0.5*($.x*a.n11+$.y*a.n12+$.z*a.n13)+0.5,$a=0.5*-($.x*a.n21+$.y*a.n22+$.z*a.n23)+0.5,Vc(P,M,H,j,Y,B,ib,Va,lb,db,Wa,$a,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&&(qa=m.uvs[0],Vc(P,M,H,j,Y,B,qa[f].u,qa[f].v,qa[h].u,qa[h].v,qa[k].u,qa[k].v,Q.map)),c(THREE.SubtractiveBlending)),Fa?!Q.wireframe&&Q.shading==THREE.SmoothShading&&3==m.vertexNormalsWorld.length?(aa.r=R.r=ba.r=Ga.r,aa.g=R.g=ba.g=Ga.g,aa.b=R.b=ba.b=Ga.b,p(i,m.v1.positionWorld,m.vertexNormalsWorld[0],aa),p(i,m.v2.positionWorld,m.vertexNormalsWorld[1],R),p(i,m.v3.positionWorld,m.vertexNormalsWorld[2],ba),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)),R.r=Math.max(0,Math.min(Q.color.r*R.r,1)),R.g=Math.max(0,Math.min(Q.color.g*R.g,1)),R.b=Math.max(0,Math.min(Q.color.b*R.b,1)),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)),ea.r=0.5*(R.r+ba.r),ea.g=0.5*(R.g+ba.g),ea.b=0.5*(R.b+ba.b),ra=Dc(aa,R,ba,ea),gc(P,M,H,j,Y,B,0,0,1,0,0,1,ra)):(S.r=Ga.r,S.g=Ga.g,S.b=Ga.b,p(i,m.centroidWorld,m.normalWorld,S),S.r=Math.max(0,Math.min(Q.color.r*
+S.r,1)),S.g=Math.max(0,Math.min(Q.color.g*S.g,1)),S.b=Math.max(0,Math.min(Q.color.b*S.b,1)),Q.wireframe?Mb(S,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):Gb(S)):Q.wireframe?Mb(Q.color,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):Gb(Q.color);else if(Q instanceof THREE.MeshDepthMaterial)na=n.near,Ia=n.far,aa.r=aa.g=aa.b=1-ac(a.positionScreen.z,na,Ia),R.r=R.g=R.b=1-ac(d.positionScreen.z,na,Ia),ba.r=ba.g=ba.b=1-ac(e.positionScreen.z,na,Ia),ea.r=0.5*(R.r+ba.r),ea.g=0.5*
+(R.g+ba.g),ea.b=0.5*(R.b+ba.b),ra=Dc(aa,R,ba,ea),gc(P,M,H,j,Y,B,0,0,1,0,0,1,ra);else if(Q instanceof THREE.MeshNormalMaterial)S.r=hc(m.normalWorld.x),S.g=hc(m.normalWorld.y),S.b=hc(m.normalWorld.z),Q.wireframe?Mb(S,Q.wireframeLinewidth,Q.wireframeLinecap,Q.wireframeLinejoin):Gb(S)}function u(a,d,e,f,$,h,Q,m,k){g.info.render.vertices+=4;g.info.render.faces++;b(m.opacity);c(m.blending);if(m.map||m.envMap)t(a,d,f,0,1,3,Q,m,k),t($,e,h,1,2,3,Q,m,k);else if(P=a.positionScreen.x,M=a.positionScreen.y,H=d.positionScreen.x,
+j=d.positionScreen.y,Y=e.positionScreen.x,B=e.positionScreen.y,F=f.positionScreen.x,Z=f.positionScreen.y,O=$.positionScreen.x,ga=$.positionScreen.y,da=h.positionScreen.x,ia=h.positionScreen.y,m instanceof THREE.MeshBasicMaterial)v(P,M,H,j,Y,B,F,Z),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==Q.vertexNormalsWorld.length?(aa.r=R.r=ba.r=ea.r=Ga.r,aa.g=
+R.g=ba.g=ea.g=Ga.g,aa.b=R.b=ba.b=ea.b=Ga.b,p(i,Q.v1.positionWorld,Q.vertexNormalsWorld[0],aa),p(i,Q.v2.positionWorld,Q.vertexNormalsWorld[1],R),p(i,Q.v4.positionWorld,Q.vertexNormalsWorld[3],ba),p(i,Q.v3.positionWorld,Q.vertexNormalsWorld[2],ea),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)),R.r=Math.max(0,Math.min(m.color.r*R.r,1)),R.g=Math.max(0,Math.min(m.color.g*R.g,1)),R.b=Math.max(0,Math.min(m.color.b*R.b,1)),
+ba.r=Math.max(0,Math.min(m.color.r*ba.r,1)),ba.g=Math.max(0,Math.min(m.color.g*ba.g,1)),ba.b=Math.max(0,Math.min(m.color.b*ba.b,1)),ea.r=Math.max(0,Math.min(m.color.r*ea.r,1)),ea.g=Math.max(0,Math.min(m.color.g*ea.g,1)),ea.b=Math.max(0,Math.min(m.color.b*ea.b,1)),ra=Dc(aa,R,ba,ea),w(P,M,H,j,F,Z),gc(P,M,H,j,F,Z,0,0,1,0,0,1,ra),w(O,ga,Y,B,da,ia),gc(O,ga,Y,B,da,ia,1,0,1,1,0,1,ra)):(S.r=Ga.r,S.g=Ga.g,S.b=Ga.b,p(i,Q.centroidWorld,Q.normalWorld,S),S.r=Math.max(0,Math.min(m.color.r*S.r,1)),S.g=Math.max(0,
+Math.min(m.color.g*S.g,1)),S.b=Math.max(0,Math.min(m.color.b*S.b,1)),v(P,M,H,j,Y,B,F,Z),m.wireframe?Mb(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(S)):(v(P,M,H,j,Y,B,F,Z),m.wireframe?Mb(m.color,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):Gb(m.color));else if(m instanceof THREE.MeshNormalMaterial)S.r=hc(Q.normalWorld.x),S.g=hc(Q.normalWorld.y),S.b=hc(Q.normalWorld.z),v(P,M,H,j,Y,B,F,Z),m.wireframe?Mb(S,m.wireframeLinewidth,m.wireframeLinecap,m.wireframeLinejoin):
+Gb(S);else if(m instanceof THREE.MeshDepthMaterial)na=n.near,Ia=n.far,aa.r=aa.g=aa.b=1-ac(a.positionScreen.z,na,Ia),R.r=R.g=R.b=1-ac(d.positionScreen.z,na,Ia),ba.r=ba.g=ba.b=1-ac(f.positionScreen.z,na,Ia),ea.r=ea.g=ea.b=1-ac(e.positionScreen.z,na,Ia),ra=Dc(aa,R,ba,ea),w(P,M,H,j,F,Z),gc(P,M,H,j,F,Z,0,0,1,0,0,1,ra),w(O,ga,Y,B,da,ia),gc(O,ga,Y,B,da,ia,1,0,1,1,0,1,ra)}function w(a,b,c,d,e,f){m.beginPath();m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(a,b);m.closePath()}function v(a,b,c,d,e,f,g,$){m.beginPath();
+m.moveTo(a,b);m.lineTo(c,d);m.lineTo(e,f);m.lineTo(g,$);m.lineTo(a,b);m.closePath()}function Mb(a,b,c,e){if(y!=b)m.lineWidth=y=b;if(D!=c)m.lineCap=D=c;if(A!=e)m.lineJoin=A=e;d(a.getContextStyle());m.stroke();Aa.inflate(2*b)}function Gb(a){e(a.getContextStyle());m.fill()}function Vc(a,b,c,d,f,g,$,j,h,i,Q,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,$=($+l)*Fb,j=(j+o)*p,c=c-a,d=d-b,f=f-a,g=g-b,h=(h+l)*Fb-$,i=(i+o)*p-j,Q=(Q+l)*Fb-$,n=(n+o)*p-j,l=h*n-Q*i;if(0==l){if(void 0===Ha[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),Ha[k.id]=b.getImageData(0,0,k.image.width,k.image.height).data;b=Ha[k.id];
+$=4*(Math.floor($)+Math.floor(j)*k.image.width);S.setRGB(b[$]/255,b[$+1]/255,b[$+2]/255);Gb(S)}else l=1/l,k=(n*c-i*f)*l,i=(n*d-i*g)*l,c=(h*f-Q*c)*l,d=(h*g-Q*d)*l,a=a-k*$-c*j,$=b-i*$-d*j,m.save(),m.transform(k,i,c,d,a,$),m.fill(),m.restore()}}function gc(a,b,c,d,e,f,g,$,j,h,i,Q,k){var n,l;n=k.width-1;l=k.height-1;g*=n;$*=l;c-=a;d-=b;e-=a;f-=b;j=j*n-g;h=h*l-$;i=i*n-g;Q=Q*l-$;l=1/(j*Q-i*h);n=(Q*c-h*e)*l;h=(Q*d-h*f)*l;c=(j*e-i*c)*l;d=(j*f-i*d)*l;a=a-n*g-c*$;b=b-h*g-d*$;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),f=~~(255*a.g),a=~~(255*a.b),g=~~(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),m=~~(255*d.g),d=~~(255*d.b);eb[0]=0>e?0:255<e?255:e;eb[1]=0>f?0:255<f?255:f;eb[2]=0>a?0:255<a?255:a;eb[4]=0>g?0:255<g?255:g;eb[5]=0>$?0:255<$?255:$;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(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,fd,Pa,jb;this.autoClear?this.clear():m.setTransform(1,0,0,-1,o,q);g.info.render.vertices=0;g.info.render.faces=0;f=k.projectScene(a,n,this.sortElements);h=f.elements;i=f.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)C=Pa,C.x*=o,C.y*=q,r(C,Pa,jb,a);else if(Pa instanceof THREE.RenderableLine)C=Pa.v1,E=Pa.v2,C.positionScreen.x*=o,C.positionScreen.y*=q,E.positionScreen.x*=o,E.positionScreen.y*=q,Aa.addPoint(C.positionScreen.x,C.positionScreen.y),Aa.addPoint(E.positionScreen.x,E.positionScreen.y),La.intersects(Aa)&&s(C,
+E,Pa,jb,a);else if(Pa instanceof THREE.RenderableFace3)C=Pa.v1,E=Pa.v2,J=Pa.v3,C.positionScreen.x*=o,C.positionScreen.y*=q,E.positionScreen.x*=o,E.positionScreen.y*=q,J.positionScreen.x*=o,J.positionScreen.y*=q,jb.overdraw&&(Nb(C.positionScreen,E.positionScreen),Nb(E.positionScreen,J.positionScreen),Nb(J.positionScreen,C.positionScreen)),Aa.add3Points(C.positionScreen.x,C.positionScreen.y,E.positionScreen.x,E.positionScreen.y,J.positionScreen.x,J.positionScreen.y),La.intersects(Aa)&&t(C,E,J,0,1,2,
+Pa,jb,a);else if(Pa instanceof THREE.RenderableFace4)C=Pa.v1,E=Pa.v2,J=Pa.v3,N=Pa.v4,C.positionScreen.x*=o,C.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,T.positionScreen.copy(E.positionScreen),K.positionScreen.copy(N.positionScreen),jb.overdraw&&(Nb(C.positionScreen,E.positionScreen),Nb(E.positionScreen,N.positionScreen),Nb(N.positionScreen,C.positionScreen),Nb(J.positionScreen,T.positionScreen),
+Nb(J.positionScreen,K.positionScreen)),Aa.addPoint(C.positionScreen.x,C.positionScreen.y),Aa.addPoint(E.positionScreen.x,E.positionScreen.y),Aa.addPoint(J.positionScreen.x,J.positionScreen.y),Aa.addPoint(N.positionScreen.x,N.positionScreen.y),La.intersects(Aa)&&u(C,E,J,N,T,K,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,f,g,h,i,m;for(e=0,f=a.length;e<f;e++)g=a[e],h=g.color,g instanceof THREE.DirectionalLight?(i=g.matrixWorld.getPosition(),m=c.dot(i),0>=m||(m*=g.intensity,d.r+=h.r*m,d.g+=h.g*m,d.b+=h.b*m)):g instanceof THREE.PointLight&&(i=g.matrixWorld.getPosition(),m=c.dot(C.sub(i,b).normalize()),0>=m||(m*=0==g.distance?1:1-Math.min(b.distanceTo(i)/g.distance,1),0!=m&&(m*=g.intensity,d.r+=h.r*m,d.g+=h.g*m,d.b+=h.b*m)))}function b(a){null==E[a]&&(E[a]=document.createElementNS("http://www.w3.org/2000/svg",
+"path"),0==P&&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,g,f,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,y=new THREE.Color,D=new THREE.Color,A,C=new THREE.Vector3,E=[],J=[],N,T,K,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,C,B,F;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(k,l,this.sortElements);g=e.elements;
+f=e.lights;K=T=0;if(w=0<f.length){v.setRGB(0,0,0);y.setRGB(0,0,0);D.setRGB(0,0,0);for(j=0,C=f.length;j<C;j++)F=f[j],B=F.color,F instanceof THREE.AmbientLight?(v.r+=B.r,v.g+=B.g,v.b+=B.b):F instanceof THREE.DirectionalLight?(y.r+=B.r,y.g+=B.g,y.b+=B.b):F instanceof THREE.PointLight&&(D.r+=B.r,D.g+=B.g,D.b+=B.b)}for(j=0,C=g.length;j<C;j++)if(B=g[j],F=B.material,F=F instanceof THREE.MeshFaceMaterial?B.faceMaterial:F,!(null==F||0==F.opacity))if(t.empty(),B instanceof THREE.RenderableParticle)o=B,o.x*=
+p,o.y*=-n;else if(B instanceof THREE.RenderableLine){if(o=B.v1,q=B.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)){B=o;var Z=q,O=K++;null==J[O]&&(J[O]=document.createElementNS("http://www.w3.org/2000/svg","line"),0==P&&J[O].setAttribute("shape-rendering","crispEdges"));N=J[O];N.setAttribute("x1",B.positionScreen.x);N.setAttribute("y1",B.positionScreen.y);
+N.setAttribute("x2",Z.positionScreen.x);N.setAttribute("y2",Z.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(B instanceof THREE.RenderableFace3){if(o=B.v1,q=B.v2,m=B.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 Z=o,O=q,E=m;d.info.render.vertices+=3;d.info.render.faces++;N=b(T++);N.setAttribute("d","M "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+O.positionScreen.x+" "+O.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(f,B.centroidWorld,B.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?(A=1-F.__2near/(F.__farPlusNear-B.z*F.__farMinusNear),u.setRGB(A,A,A)):F instanceof THREE.MeshNormalMaterial&&u.setRGB(c(B.normalWorld.x),c(B.normalWorld.y),c(B.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(B instanceof THREE.RenderableFace4&&(o=B.v1,q=B.v2,m=B.v3,r=B.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 Z=o,O=q,E=m,da=r;d.info.render.vertices+=4;d.info.render.faces++;N=b(T++);N.setAttribute("d","M "+Z.positionScreen.x+" "+Z.positionScreen.y+" L "+O.positionScreen.x+" "+O.positionScreen.y+" L "+E.positionScreen.x+","+E.positionScreen.y+" L "+da.positionScreen.x+","+da.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(f,B.centroidWorld,B.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?(A=1-F.__2near/(F.__farPlusNear-B.z*F.__farMinusNear),u.setRGB(A,A,A)):F instanceof THREE.MeshNormalMaterial&&u.setRGB(c(B.normalWorld.x),c(B.normalWorld.y),c(B.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.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",
@@ -243,122 +244,122 @@ var i=a.colors,m=i.length,k=a.__vertexArray,n=a.__colorArray,l=a.__sortArray,o=a
 void 0===h.boundTo||"vertices"===h.boundTo)if(g=0,e=h.value.length,1===h.size)for(d=0;d<e;d++)f=l[d][1],h.array[d]=h.value[f];else if(2===h.size)for(d=0;d<e;d++)f=l[d][1],f=h.value[f],h.array[g]=f.x,h.array[g+1]=f.y,g+=2;else if(3===h.size)if("c"===h.type)for(d=0;d<e;d++)f=l[d][1],f=h.value[f],h.array[g]=f.r,h.array[g+1]=f.g,h.array[g+2]=f.b,g+=3;else for(d=0;d<e;d++)f=l[d][1],f=h.value[f],h.array[g]=f.x,h.array[g+1]=f.y,h.array[g+2]=f.z,g+=3;else if(4===h.size)for(d=0;d<e;d++)f=l[d][1],f=h.value[f],
 h.array[g]=f.x,h.array[g+1]=f.y,h.array[g+2]=f.z,h.array[g+3]=f.w,g+=4}else{if(o)for(d=0;d<f;d++)e=h[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<m;d++)e=i[d],g=3*d,n[g]=e.r,n[g+1]=e.g,n[g+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,g=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++)f=h.value[d],h.array[g]=f.x,h.array[g+1]=f.y,g+=2;else if(3===h.size)if("c"===
 h.type)for(d=0;d<e;d++)f=h.value[d],h.array[g]=f.r,h.array[g+1]=f.g,h.array[g+2]=f.b,g+=3;else for(d=0;d<e;d++)f=h.value[d],h.array[g]=f.x,h.array[g+1]=f.y,h.array[g+2]=f.z,g+=3;else if(4===h.size)for(d=0;d<e;d++)f=h.value[d],h.array[g]=f.x,h.array[g+1]=f.y,h.array[g+2]=f.z,h.array[g+3]=f.w,g+=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 f(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,g,f,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;
-f&&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,g,j,m,i):G.renderBuffer(d,e,g,j,m,i)}}function k(a,b,c,d,e,g,f){for(var h,j,i=0,m=a.length;i<m;i++)if(h=a[i],j=h.object,j.visible){if(f)h=f;else{h=h[b];if(!h)continue;g&&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 g=0,f=G.maxMorphTargets;g<f;g++)e.__webglMorphTargetInfluences[g]=0}var h=!1,g=d.program,f=g.uniforms,i=d.uniforms;g!==z&&(j.useProgram(g),z=g,h=!0);if(d.id!==Q)Q=d.id,h=!0;if(h||a!==ea)j.uniformMatrix4fv(f.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=
+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 f(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++)ga=B=null,Z=O=ba=R=aa=-1,a[d].render(b,c,Va,lb),ga=B=null,Z=O=ba=R=aa=-1}function i(a,b,c,d,e,g,f,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;
+f&&H.setBlending(j.blending);H.setDepthTest(j.depthTest);H.setDepthWrite(j.depthWrite);s(j.polygonOffset,j.polygonOffsetFactor,j.polygonOffsetUnits)}H.setObjectFaces(i);m instanceof THREE.BufferGeometry?H.renderBufferDirect(d,e,g,j,m,i):H.renderBuffer(d,e,g,j,m,i)}}function k(a,b,c,d,e,g,f){for(var h,j,i=0,m=a.length;i<m;i++)if(h=a[i],j=h.object,j.visible){if(f)h=f;else{h=h[b];if(!h)continue;g&&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 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||H.initMaterial(d,b,c,e);if(d.morphTargets&&
+!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(H.maxMorphTargets);for(var g=0,f=H.maxMorphTargets;g<f;g++)e.__webglMorphTargetInfluences[g]=0}var h=!1,g=d.program,f=g.uniforms,i=d.uniforms;g!==B&&(j.useProgram(g),B=g,h=!0);if(d.id!==Z)Z=d.id,h=!0;if(h||a!==ga)j.uniformMatrix4fv(f.projectionMatrix,!1,a._projectionMatrixArray),a!==ga&&(ga=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,F=r.point.colors,u=r.point.positions,v=r.point.distances,O=0,C=0,A=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)H.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*O,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),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,O+=1;else if(m instanceof THREE.PointLight||m instanceof THREE.SpotLight)A=3*C,H.gammaInput?(F[A]=o.r*o.r*p*p,F[A+1]=o.g*o.g*p*p,F[A+2]=o.b*o.b*p*p):(F[A]=o.r*p,F[A+1]=o.g*p,F[A+2]=o.b*p),m=m.matrixWorld.getPosition(),u[A]=m.x,u[A+1]=m.y,u[A+2]=m.z,v[C]=q,
+C+=1;for(c=3*O,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=O;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,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(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=g.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)&&
+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(H.autoScaleCubemaps){if(s=h.image[n],F=Fa,!(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=k[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,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)):H.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])&&H.setTexture(n,h._array[l])}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&
 null!==f.cameraPosition)b=a.matrixWorld.getPosition(),j.uniform3f(f.cameraPosition,b.x,b.y,b.z);(d instanceof THREE.MeshPhongMaterial||d instanceof THREE.MeshLambertMaterial||d instanceof THREE.ShaderMaterial||d.skinning)&&null!==f.viewMatrix&&j.uniformMatrix4fv(f.viewMatrix,!1,a._viewMatrixArray);d.skinning&&j.uniformMatrix4fv(f.boneGlobalMatrices,!1,e.boneMatrices)}j.uniformMatrix4fv(f.modelViewMatrix,!1,e._modelViewMatrixArray);f.normalMatrix&&j.uniformMatrix3fv(f.normalMatrix,!1,e._normalMatrixArray);
-(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&null!==f.objectMatrix&&j.uniformMatrix4fv(f.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 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))):
+(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&null!==f.objectMatrix&&j.uniformMatrix4fv(f.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 s(a,b,c){ea!==a&&(a?j.enable(j.POLYGON_OFFSET_FILL):j.disable(j.POLYGON_OFFSET_FILL),ea=a);if(a&&(Ua!==b||Ha!==c))j.polygonOffset(b,
+c),Ua=b,Ha=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))):
 (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 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;
+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;
 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||{},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);
+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"),A=void 0!==a.precision?a.precision:"mediump",C=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,T=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,K=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),P=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,Y=[],B=null,F=null,Z=-1,O=null,ga=null,da=0,ia=null,S=null,aa=null,R=null,ba=null,
+ea=null,Ua=null,Ha=null,na=null,Ia=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=D.getContext("experimental-webgl",{alpha:C,premultipliedAlpha:E,antialias:J,stencil:N,preserveDrawingBuffer:T})))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,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){D.width=a;D.height=b;this.setViewport(0,0,D.width,D.height)};this.setViewport=function(a,b,c,d){Ia=a;ra=b;qa=c;ib=d;j.viewport(Ia,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){K.setHex(a);P=b;j.clearColor(K.r,K.g,K.b,P)};this.setClearColor=function(a,b){K.copy(a);P=b;j.clearColor(K.r,K.g,K.b,P)};this.getClearColor=function(){return K};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);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();
+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);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){B=null;Z=O=ba=R=aa=-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,g,f,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],g=c[l+2],f=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+f+h)/3,e=(e+i+m)/3,g=(g+k+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}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,g){if(0!==d.opacity&&(c=m(a,b,c,d,g),a=c.attributes,b=!1,d=16777215*e.id+2*c.id+(d.wireframe?
-1:0),d!==N&&(N=d,b=!0),g instanceof THREE.Mesh)){g=e.offsets;d=0;for(c=g.length;d<c;++d)b&&(j.bindBuffer(j.ARRAY_BUFFER,e.vertexPositionBuffer),j.vertexAttribPointer(a.position,e.vertexPositionBuffer.itemSize,j.FLOAT,!1,0,12*g[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*g[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*g[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*g[d].index)),j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)),j.drawElements(j.TRIANGLES,g[d].count,j.UNSIGNED_SHORT,2*g[d].start),G.info.render.calls++,G.info.render.vertices+=g[d].count,
-G.info.render.faces+=g[d].count/3}};this.renderBuffer=function(a,b,c,d,e,g){if(0!==d.opacity){var f,h,c=m(a,b,c,d,g),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(g.morphTargetBase){c=d.program.attributes;-1!==g.morphTargetBase?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[g.morphTargetBase]),j.vertexAttribPointer(c.position,
+1:0),d!==O&&(O=d,b=!0),g instanceof THREE.Mesh)){g=e.offsets;d=0;for(c=g.length;d<c;++d)b&&(j.bindBuffer(j.ARRAY_BUFFER,e.vertexPositionBuffer),j.vertexAttribPointer(a.position,e.vertexPositionBuffer.itemSize,j.FLOAT,!1,0,12*g[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*g[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*g[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*g[d].index)),j.bindBuffer(j.ELEMENT_ARRAY_BUFFER,e.vertexIndexBuffer)),j.drawElements(j.TRIANGLES,g[d].count,j.UNSIGNED_SHORT,2*g[d].start),H.info.render.calls++,H.info.render.vertices+=g[d].count,
+H.info.render.faces+=g[d].count/3}};this.renderBuffer=function(a,b,c,d,e,g){if(0!==d.opacity){var f,h,c=m(a,b,c,d,g),b=c.attributes,a=!1,c=16777215*e.id+2*c.id+(d.wireframe?1:0);c!==O&&(O=c,a=!0);if(!d.morphTargets&&0<=b.position)a&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglVertexBuffer),j.vertexAttribPointer(b.position,3,j.FLOAT,!1,0,0));else if(g.morphTargetBase){c=d.program.attributes;-1!==g.morphTargetBase?(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[g.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(g.morphTargetForcedOrder.length){f=0;var i=g.morphTargetForcedOrder;for(h=g.morphTargetInfluences;f<d.numSupportedMorphTargets&&f<i.length;)j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphTargetsBuffers[i[f]]),j.vertexAttribPointer(c["morphTarget"+f],3,j.FLOAT,!1,0,0),d.morphNormals&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[i[f]]),j.vertexAttribPointer(c["morphNormal"+
 f],3,j.FLOAT,!1,0,0)),g.__webglMorphTargetInfluences[f]=h[i[f]],f++}else{var i=[],k=-1,l=0;h=g.morphTargetInfluences;var n,o=h.length;f=0;for(-1!==g.morphTargetBase&&(i[g.morphTargetBase]=!0);f<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"+f],3,j.FLOAT,!1,0,0);d.morphNormals&&(j.bindBuffer(j.ARRAY_BUFFER,e.__webglMorphNormalsBuffers[l]),j.vertexAttribPointer(c["morphNormal"+
 f],3,j.FLOAT,!1,0,0));g.__webglMorphTargetInfluences[f]=k;i[l]=1;k=-1;f++}}null!==d.program.uniforms.morphTargetInfluences&&j.uniform1fv(d.program.uniforms.morphTargetInfluences,g.__webglMorphTargetInfluences)}if(a){if(e.__webglCustomAttributesList)for(f=0,h=e.__webglCustomAttributesList.length;f<h;f++)c=e.__webglCustomAttributesList[f],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))}g 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):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==na&&(j.lineWidth(d),na=d),j.drawArrays(g,0,e.__webglLineCount),G.info.render.calls++):g instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),G.info.render.calls++,G.info.render.points+=e.__webglParticleCount):g instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,
-0,e.__webglVertexCount),G.info.render.calls++)}};this.render=function(a,b,c,d){var e,g,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(g=n[d],m=g.object,g.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=g,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);g.render=!0;if(this.sortObjects)m.renderDepth?
-g.z=m.renderDepth:($a.copy(m.position),Wa.multiplyVector3($a),g.z=$a.z)}this.sortObjects&&n.sort(f);n=a.__webglObjectsImmediate;for(d=0,e=n.length;d<e;d++)if(g=n[d],m=g.object,m.visible)m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),r(m,b),m=g.object.material,m.transparent?(g.transparent=m,g.opaque=null):(g.opaque=m,g.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 g=m(a,b,c,d,e);N=-1;G.setObjectFaces(e);e.immediateRenderCallback?
-e.immediateRenderCallback(g,j,db):e.render(function(a){G.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 f=a.__objectsAdded[0],h=a,i=void 0,m=void 0,k=void 0;if(!f.__webglInit)if(f.__webglInit=!0,f._modelViewMatrix=new THREE.Matrix4,f._normalMatrixArray=new Float32Array(9),f._modelViewMatrixArray=new Float32Array(16),f._objectMatrixArray=
-new Float32Array(16),f.matrixWorld.flattenToArray(f._objectMatrixArray),f instanceof THREE.Mesh){if(m=f.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=f,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(f instanceof THREE.Ribbon){if(m=f.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(f instanceof THREE.Line){if(m=f.geometry,!m.__webglVertexBuffer){var La=m;La.__webglVertexBuffer=j.createBuffer();La.__webglColorBuffer=j.createBuffer();G.info.memory.geometries++;var Fa=m,ib=f,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(f instanceof THREE.ParticleSystem&&(m=f.geometry,!m.__webglVertexBuffer)){var $a=m;$a.__webglVertexBuffer=j.createBuffer();$a.__webglColorBuffer=j.createBuffer();G.info.geometries++;var Va=m,lb=f,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(!f.__webglActive){if(f instanceof THREE.Mesh)if(m=
-f.geometry,m instanceof THREE.BufferGeometry)l(h.__webglObjects,m,f);else for(i in m.geometryGroups)k=m.geometryGroups[i],l(h.__webglObjects,k,f);else f instanceof THREE.Ribbon||f instanceof THREE.Line||f instanceof THREE.ParticleSystem?(m=f.geometry,l(h.__webglObjects,m,f)):void 0!==THREE.MarchingCubes&&f instanceof THREE.MarchingCubes||f.immediateRenderCallback?h.__webglObjectsImmediate.push({object:f,opaque:null,transparent:null}):f instanceof THREE.Sprite?h.__webglSprites.push(f):f instanceof
-THREE.LensFlare&&h.__webglFlares.push(f);f.__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=
+j.UNSIGNED_SHORT,0)),H.info.render.calls++,H.info.render.vertices+=e.__webglFaceCount,H.info.render.faces+=e.__webglFaceCount/3):g instanceof THREE.Line?(g=g.type===THREE.LineStrip?j.LINE_STRIP:j.LINES,d=d.linewidth,d!==na&&(j.lineWidth(d),na=d),j.drawArrays(g,0,e.__webglLineCount),H.info.render.calls++):g instanceof THREE.ParticleSystem?(j.drawArrays(j.POINTS,0,e.__webglParticleCount),H.info.render.calls++,H.info.render.points+=e.__webglParticleCount):g instanceof THREE.Ribbon&&(j.drawArrays(j.TRIANGLE_STRIP,
+0,e.__webglVertexCount),H.info.render.calls++)}};this.render=function(a,b,c,d){var e,g,m,l,n=a.lights,o=a.fog;Z=-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);Wa.multiply(b.projectionMatrix,b.matrixWorldInverse);db.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],m=g.object,g.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=g,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);g.render=!0;if(this.sortObjects)m.renderDepth?
+g.z=m.renderDepth:($a.copy(m.position),Wa.multiplyVector3($a),g.z=$a.z)}this.sortObjects&&l.sort(f);l=a.__webglObjectsImmediate;for(d=0,e=l.length;d<e;d++)if(g=l[d],m=g.object,m.visible)m.matrixAutoUpdate&&m.matrixWorld.flattenToArray(m._objectMatrixArray),r(m,b),m=g.object.material,m.transparent?(g.transparent=m,g.opaque=null):(g.opaque=m,g.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 g=m(a,b,c,d,e);O=-1;H.setObjectFaces(e);e.immediateRenderCallback?
+e.immediateRenderCallback(g,j,db):e.render(function(a){H.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 f=a.__objectsAdded[0],h=a,i=void 0,m=void 0,k=void 0;if(!f.__webglInit)if(f.__webglInit=!0,f._modelViewMatrix=new THREE.Matrix4,f._normalMatrixArray=new Float32Array(9),f._modelViewMatrixArray=new Float32Array(16),f._objectMatrixArray=
+new Float32Array(16),f.matrixWorld.flattenToArray(f._objectMatrixArray),f instanceof THREE.Mesh){if(m=f.geometry,m instanceof THREE.Geometry){if(void 0===m.geometryGroups){var r=m,s=void 0,F=void 0,t=void 0,u=void 0,w=void 0,v=void 0,B=void 0,A={},C=r.morphTargets.length,O=r.morphNormals.length;r.geometryGroups={};for(s=0,F=r.faces.length;s<F;s++)t=r.faces[s],u=t.materialIndex,v=void 0!==u?u:-1,void 0===A[v]&&(A[v]={hash:v,counter:0}),B=A[v].hash+"_"+A[v].counter,void 0===r.geometryGroups[B]&&(r.geometryGroups[B]=
+{faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:C,numMorphNormals:O}),w=t instanceof THREE.Face3?3:4,65535<r.geometryGroups[B].vertices+w&&(A[v].counter+=1,B=A[v].hash+"_"+A[v].counter,void 0===r.geometryGroups[B]&&(r.geometryGroups[B]={faces3:[],faces4:[],materialIndex:u,vertices:0,numMorphTargets:C,numMorphNormals:O})),t instanceof THREE.Face3?r.geometryGroups[B].faces3.push(s):r.geometryGroups[B].faces4.push(s),r.geometryGroups[B].vertices+=w;r.geometryGroupsList=[];var Z=void 0;
+for(Z in r.geometryGroups)r.geometryGroups[Z].id=da++,r.geometryGroupsList.push(r.geometryGroups[Z])}for(i in m.geometryGroups)if(k=m.geometryGroups[i],!k.__webglVertexBuffer){var y=k;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();var D=void 0,S=void 0;if(y.numMorphTargets){y.__webglMorphTargetsBuffers=[];for(D=0,S=y.numMorphTargets;D<S;D++)y.__webglMorphTargetsBuffers.push(j.createBuffer())}if(y.numMorphNormals){y.__webglMorphNormalsBuffers=[];for(D=0,S=y.numMorphNormals;D<S;D++)y.__webglMorphNormalsBuffers.push(j.createBuffer())}H.info.memory.geometries++;var E=k,M=f,K=M.geometry,J=E.faces3,
+ga=E.faces4,R=3*J.length+4*ga.length,N=1*J.length+2*ga.length,ia=3*J.length+4*ga.length,aa=c(M,E),ba=e(aa),P=d(aa),T=aa.vertexColors?aa.vertexColors:!1;E.__vertexArray=new Float32Array(3*R);if(P)E.__normalArray=new Float32Array(3*R);if(K.hasTangents)E.__tangentArray=new Float32Array(4*R);if(T)E.__colorArray=new Float32Array(3*R);if(ba){if(0<K.faceUvs.length||0<K.faceVertexUvs.length)E.__uvArray=new Float32Array(2*R);if(1<K.faceUvs.length||1<K.faceVertexUvs.length)E.__uv2Array=new Float32Array(2*R)}if(M.geometry.skinWeights.length&&
+M.geometry.skinIndices.length)E.__skinVertexAArray=new Float32Array(4*R),E.__skinVertexBArray=new Float32Array(4*R),E.__skinIndexArray=new Float32Array(4*R),E.__skinWeightArray=new Float32Array(4*R);E.__faceArray=new Uint16Array(3*N);E.__lineArray=new Uint16Array(2*ia);var ea=void 0,Y=void 0;if(E.numMorphTargets){E.__morphTargetsArrays=[];for(ea=0,Y=E.numMorphTargets;ea<Y;ea++)E.__morphTargetsArrays.push(new Float32Array(3*R))}if(E.numMorphNormals){E.__morphNormalsArrays=[];for(ea=0,Y=E.numMorphNormals;ea<
+Y;ea++)E.__morphNormalsArrays.push(new Float32Array(3*R))}E.__webglFaceCount=3*N;E.__webglLineCount=2*ia;if(aa.attributes){if(void 0===E.__webglCustomAttributesList)E.__webglCustomAttributesList=[];var Ua=void 0;for(Ua in aa.attributes){var Ha=aa.attributes[Ua],na={},qa;for(qa in Ha)na[qa]=Ha[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(R*
+ra);na.buffer=j.createBuffer();na.buffer.belongsToAttribute=Ua;Ha.needsUpdate=!0;na.__original=Ha}E.__webglCustomAttributesList.push(na)}}E.__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(f instanceof THREE.Ribbon){if(m=f.geometry,!m.__webglVertexBuffer){var Ia=m;Ia.__webglVertexBuffer=j.createBuffer();Ia.__webglColorBuffer=j.createBuffer();H.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(f instanceof THREE.Line){if(m=f.geometry,!m.__webglVertexBuffer){var La=m;La.__webglVertexBuffer=j.createBuffer();La.__webglColorBuffer=j.createBuffer();H.info.memory.geometries++;var Fa=m,ib=f,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(f instanceof THREE.ParticleSystem&&(m=f.geometry,!m.__webglVertexBuffer)){var $a=m;$a.__webglVertexBuffer=j.createBuffer();$a.__webglColorBuffer=j.createBuffer();H.info.geometries++;var Va=m,lb=f,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(!f.__webglActive){if(f instanceof THREE.Mesh)if(m=f.geometry,
+m instanceof THREE.BufferGeometry)l(h.__webglObjects,m,f);else for(i in m.geometryGroups)k=m.geometryGroups[i],l(h.__webglObjects,k,f);else f instanceof THREE.Ribbon||f instanceof THREE.Line||f instanceof THREE.ParticleSystem?(m=f.geometry,l(h.__webglObjects,m,f)):void 0!==THREE.MarchingCubes&&f instanceof THREE.MarchingCubes||f.immediateRenderCallback?h.__webglObjectsImmediate.push({object:f,opaque:null,transparent:null}):f instanceof THREE.Sprite?h.__webglSprites.push(f):f instanceof THREE.LensFlare&&
+h.__webglFlares.push(f);f.__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 fa=qc,td=nb,ab=j.DYNAMIC_DRAW,ud=!ja.dynamic,bc=Ya;if(fa.__inittedArrays){var gd=d(bc),Yc=bc.vertexColors?bc.vertexColors:!1,hd=e(bc),Gc=gd===THREE.SmoothShading,G=void 0,U=void 0,kb=void 0,L=void 0,jc=void 0,Ob=void 0,ob=void 0,Hc=void 0,Hb=void 0,kc=void 0,lc=void 0,V=void 0,W=void 0,X=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,Ja=void 0,Ka=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,I=0,ca=0,z=0,bb=void 0,Na=fa.__vertexArray,wc=fa.__uvArray,xc=fa.__uv2Array,hb=fa.__normalArray,ua=fa.__tangentArray,Oa=fa.__colorArray,va=fa.__skinVertexAArray,wa=fa.__skinVertexBArray,xa=fa.__skinIndexArray,
+ya=fa.__skinWeightArray,Zc=fa.__morphTargetsArrays,$c=fa.__morphNormalsArrays,ad=fa.__webglCustomAttributesList,x=void 0,Eb=fa.__faceArray,cb=fa.__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=fa.faces3,ma=fa.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(G=0,U=la.length;G<U;G++)L=Da[la[G]],V=cc[L.a].position,W=cc[L.b].position,X=cc[L.c].position,Na[Ea]=V.x,Na[Ea+1]=V.y,Na[Ea+2]=V.z,Na[Ea+3]=W.x,Na[Ea+4]=W.y,Na[Ea+5]=W.z,Na[Ea+6]=X.x,Na[Ea+7]=X.y,Na[Ea+8]=X.z,Ea+=9;for(G=0,U=ma.length;G<U;G++)L=Da[ma[G]],V=cc[L.a].position,W=cc[L.b].position,X=cc[L.c].position,oa=cc[L.d].position,Na[Ea]=V.x,Na[Ea+1]=V.y,Na[Ea+2]=V.z,Na[Ea+3]=W.x,Na[Ea+4]=W.y,Na[Ea+5]=W.z,Na[Ea+6]=X.x,Na[Ea+7]=X.y,Na[Ea+8]=X.z,Na[Ea+9]=oa.x,Na[Ea+10]=oa.y,
+Na[Ea+11]=oa.z,Ea+=12;j.bindBuffer(j.ARRAY_BUFFER,fa.__webglVertexBuffer);j.bufferData(j.ARRAY_BUFFER,Na,ab)}if(zd)for(Ma=0,jd=Yb.length;Ma<jd;Ma++){ca=0;for(G=0,U=la.length;G<U;G++){Wb=la[G];L=Da[Wb];V=Yb[Ma].vertices[L.a].position;W=Yb[Ma].vertices[L.b].position;X=Yb[Ma].vertices[L.c].position;Ja=Zc[Ma];Ja[ca]=V.x;Ja[ca+1]=V.y;Ja[ca+2]=V.z;Ja[ca+3]=W.x;Ja[ca+4]=W.y;Ja[ca+5]=W.z;Ja[ca+6]=X.x;Ja[ca+7]=X.y;Ja[ca+8]=X.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],Ka=$c[Ma],Ka[ca]=sb.x,Ka[ca+1]=sb.y,Ka[ca+2]=sb.z,Ka[ca+3]=tb.x,Ka[ca+4]=tb.y,Ka[ca+5]=tb.z,Ka[ca+6]=ub.x,Ka[ca+7]=ub.y,Ka[ca+8]=ub.z;ca+=9}for(G=0,U=ma.length;G<U;G++){Wb=ma[G];L=Da[Wb];V=Yb[Ma].vertices[L.a].position;W=Yb[Ma].vertices[L.b].position;X=Yb[Ma].vertices[L.c].position;oa=Yb[Ma].vertices[L.d].position;Ja=Zc[Ma];Ja[ca]=V.x;Ja[ca+1]=V.y;Ja[ca+2]=V.z;Ja[ca+3]=W.x;Ja[ca+4]=W.y;Ja[ca+5]=W.z;Ja[ca+6]=X.x;Ja[ca+7]=X.y;Ja[ca+8]=X.z;Ja[ca+9]=oa.x;Ja[ca+10]=oa.y;Ja[ca+
+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],Ka=$c[Ma],Ka[ca]=sb.x,Ka[ca+1]=sb.y,Ka[ca+2]=sb.z,Ka[ca+3]=tb.x,Ka[ca+4]=tb.y,Ka[ca+5]=tb.z,Ka[ca+6]=ub.x,Ka[ca+7]=ub.y,Ka[ca+8]=ub.z,Ka[ca+9]=sc.x,Ka[ca+10]=sc.y,Ka[ca+11]=sc.z;ca+=12}j.bindBuffer(j.ARRAY_BUFFER,fa.__webglMorphTargetsBuffers[Ma]);j.bufferData(j.ARRAY_BUFFER,Zc[Ma],ab);bc.morphNormals&&(j.bindBuffer(j.ARRAY_BUFFER,fa.__webglMorphNormalsBuffers[Ma]),j.bufferData(j.ARRAY_BUFFER,
+$c[Ma],ab))}if(Xb.length){for(G=0,U=la.length;G<U;G++)L=Da[la[G]],yb=Xb[L.a],zb=Xb[L.b],Ab=Xb[L.c],ya[I]=yb.x,ya[I+1]=yb.y,ya[I+2]=yb.z,ya[I+3]=yb.w,ya[I+4]=zb.x,ya[I+5]=zb.y,ya[I+6]=zb.z,ya[I+7]=zb.w,ya[I+8]=Ab.x,ya[I+9]=Ab.y,ya[I+10]=Ab.z,ya[I+11]=Ab.w,Bb=fc[L.a],Cb=fc[L.b],Db=fc[L.c],xa[I]=Bb.x,xa[I+1]=Bb.y,xa[I+2]=Bb.z,xa[I+3]=Bb.w,xa[I+4]=Cb.x,xa[I+5]=Cb.y,xa[I+6]=Cb.z,xa[I+7]=Cb.w,xa[I+8]=Db.x,xa[I+9]=Db.y,xa[I+10]=Db.z,xa[I+11]=Db.w,Pb=dc[L.a],Qb=dc[L.b],Rb=dc[L.c],va[I]=Pb.x,va[I+1]=Pb.y,
+va[I+2]=Pb.z,va[I+3]=1,va[I+4]=Qb.x,va[I+5]=Qb.y,va[I+6]=Qb.z,va[I+7]=1,va[I+8]=Rb.x,va[I+9]=Rb.y,va[I+10]=Rb.z,va[I+11]=1,Sb=ec[L.a],Tb=ec[L.b],Ub=ec[L.c],wa[I]=Sb.x,wa[I+1]=Sb.y,wa[I+2]=Sb.z,wa[I+3]=1,wa[I+4]=Tb.x,wa[I+5]=Tb.y,wa[I+6]=Tb.z,wa[I+7]=1,wa[I+8]=Ub.x,wa[I+9]=Ub.y,wa[I+10]=Ub.z,wa[I+11]=1,I+=12;for(G=0,U=ma.length;G<U;G++)L=Da[ma[G]],yb=Xb[L.a],zb=Xb[L.b],Ab=Xb[L.c],uc=Xb[L.d],ya[I]=yb.x,ya[I+1]=yb.y,ya[I+2]=yb.z,ya[I+3]=yb.w,ya[I+4]=zb.x,ya[I+5]=zb.y,ya[I+6]=zb.z,ya[I+7]=zb.w,ya[I+8]=
+Ab.x,ya[I+9]=Ab.y,ya[I+10]=Ab.z,ya[I+11]=Ab.w,ya[I+12]=uc.x,ya[I+13]=uc.y,ya[I+14]=uc.z,ya[I+15]=uc.w,Bb=fc[L.a],Cb=fc[L.b],Db=fc[L.c],vc=fc[L.d],xa[I]=Bb.x,xa[I+1]=Bb.y,xa[I+2]=Bb.z,xa[I+3]=Bb.w,xa[I+4]=Cb.x,xa[I+5]=Cb.y,xa[I+6]=Cb.z,xa[I+7]=Cb.w,xa[I+8]=Db.x,xa[I+9]=Db.y,xa[I+10]=Db.z,xa[I+11]=Db.w,xa[I+12]=vc.x,xa[I+13]=vc.y,xa[I+14]=vc.z,xa[I+15]=vc.w,Pb=dc[L.a],Qb=dc[L.b],Rb=dc[L.c],Ic=dc[L.d],va[I]=Pb.x,va[I+1]=Pb.y,va[I+2]=Pb.z,va[I+3]=1,va[I+4]=Qb.x,va[I+5]=Qb.y,va[I+6]=Qb.z,va[I+7]=1,va[I+
+8]=Rb.x,va[I+9]=Rb.y,va[I+10]=Rb.z,va[I+11]=1,va[I+12]=Ic.x,va[I+13]=Ic.y,va[I+14]=Ic.z,va[I+15]=1,Sb=ec[L.a],Tb=ec[L.b],Ub=ec[L.c],Jc=ec[L.d],wa[I]=Sb.x,wa[I+1]=Sb.y,wa[I+2]=Sb.z,wa[I+3]=1,wa[I+4]=Tb.x,wa[I+5]=Tb.y,wa[I+6]=Tb.z,wa[I+7]=1,wa[I+8]=Ub.x,wa[I+9]=Ub.y,wa[I+10]=Ub.z,wa[I+11]=1,wa[I+12]=Jc.x,wa[I+13]=Jc.y,wa[I+14]=Jc.z,wa[I+15]=1,I+=16;0<I&&(j.bindBuffer(j.ARRAY_BUFFER,fa.__webglSkinVertexABuffer),j.bufferData(j.ARRAY_BUFFER,va,ab),j.bindBuffer(j.ARRAY_BUFFER,fa.__webglSkinVertexBBuffer),
+j.bufferData(j.ARRAY_BUFFER,wa,ab),j.bindBuffer(j.ARRAY_BUFFER,fa.__webglSkinIndicesBuffer),j.bufferData(j.ARRAY_BUFFER,xa,ab),j.bindBuffer(j.ARRAY_BUFFER,fa.__webglSkinWeightsBuffer),j.bufferData(j.ARRAY_BUFFER,ya,ab))}if(yd&&Yc){for(G=0,U=la.length;G<U;G++)L=Da[la[G]],ob=L.vertexColors,Hc=L.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(G=0,U=ma.length;G<U;G++)L=Da[ma[G]],ob=L.vertexColors,Hc=L.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,fa.__webglColorBuffer),j.bufferData(j.ARRAY_BUFFER,Oa,ab))}if(xd&&Ta.hasTangents){for(G=0,U=la.length;G<U;G++)L=Da[la[G]],Hb=
+L.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(G=0,U=ma.length;G<U;G++)L=Da[ma[G]],Hb=L.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,fa.__webglTangentBuffer);j.bufferData(j.ARRAY_BUFFER,ua,ab)}if(wd&&gd){for(G=0,U=la.length;G<U;G++)if(L=Da[la[G]],jc=L.vertexNormals,Ob=L.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(G=0,U=ma.length;G<U;G++)if(L=Da[ma[G]],jc=L.vertexNormals,Ob=L.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,fa.__webglNormalBuffer);j.bufferData(j.ARRAY_BUFFER,hb,ab)}if(kd&&bd&&hd){for(G=0,U=la.length;G<U;G++)if(kb=la[G],L=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(G=0,U=ma.length;G<U;G++)if(kb=ma[G],L=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,
+fa.__webglUVBuffer),j.bufferData(j.ARRAY_BUFFER,wc,ab))}if(kd&&cd&&hd){for(G=0,U=la.length;G<U;G++)if(kb=la[G],L=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(G=0,U=ma.length;G<U;G++)if(kb=ma[G],L=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,fa.__webglUV2Buffer),j.bufferData(j.ARRAY_BUFFER,xc,ab))}if(vd){for(G=0,U=la.length;G<U;G++)L=Da[la[G]],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(G=0,U=ma.length;G<U;G++)L=Da[ma[G]],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,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(ad)for(ka=0,id=ad.length;ka<id;ka++)if(x=ad[ka],x.__original.needsUpdate){z=0;if(1===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){for(G=0,U=la.length;G<U;G++)L=Da[la[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,U=ma.length;G<U;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],x.array[z+3]=x.value[L.d],z+=4}else{if("faces"===x.boundTo){for(G=0,U=la.length;G<
+U;G++)bb=x.value[la[G]],x.array[z]=bb,x.array[z+1]=bb,x.array[z+2]=bb,z+=3;for(G=0,U=ma.length;G<U;G++)bb=x.value[ma[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,U=la.length;G<U;G++)L=Da[la[G]],V=x.value[L.a],W=x.value[L.b],X=x.value[L.c],x.array[z]=V.x,x.array[z+1]=V.y,x.array[z+2]=W.x,x.array[z+3]=W.y,x.array[z+4]=X.x,x.array[z+5]=X.y,z+=6;for(G=0,U=ma.length;G<U;G++)L=Da[ma[G]],V=x.value[L.a],W=
+x.value[L.b],X=x.value[L.c],oa=x.value[L.d],x.array[z]=V.x,x.array[z+1]=V.y,x.array[z+2]=W.x,x.array[z+3]=W.y,x.array[z+4]=X.x,x.array[z+5]=X.y,x.array[z+6]=oa.x,x.array[z+7]=oa.y,z+=8}else{if("faces"===x.boundTo){for(G=0,U=la.length;G<U;G++)X=W=V=bb=x.value[la[G]],x.array[z]=V.x,x.array[z+1]=V.y,x.array[z+2]=W.x,x.array[z+3]=W.y,x.array[z+4]=X.x,x.array[z+5]=X.y,z+=6;for(G=0,U=ma.length;G<U;G++)oa=X=W=V=bb=x.value[ma[G]],x.array[z]=V.x,x.array[z+1]=V.y,x.array[z+2]=W.x,x.array[z+3]=W.y,x.array[z+
+4]=X.x,x.array[z+5]=X.y,x.array[z+6]=oa.x,x.array[z+7]=oa.y,z+=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(G=0,U=la.length;G<U;G++)L=Da[la[G]],V=x.value[L.a],W=x.value[L.b],X=x.value[L.c],x.array[z]=V[ha[0]],x.array[z+1]=V[ha[1]],x.array[z+2]=V[ha[2]],x.array[z+3]=W[ha[0]],x.array[z+4]=W[ha[1]],x.array[z+5]=W[ha[2]],x.array[z+6]=X[ha[0]],x.array[z+7]=X[ha[1]],x.array[z+8]=X[ha[2]],z+=9;for(G=0,U=ma.length;G<U;G++)L=Da[ma[G]],
+V=x.value[L.a],W=x.value[L.b],X=x.value[L.c],oa=x.value[L.d],x.array[z]=V[ha[0]],x.array[z+1]=V[ha[1]],x.array[z+2]=V[ha[2]],x.array[z+3]=W[ha[0]],x.array[z+4]=W[ha[1]],x.array[z+5]=W[ha[2]],x.array[z+6]=X[ha[0]],x.array[z+7]=X[ha[1]],x.array[z+8]=X[ha[2]],x.array[z+9]=oa[ha[0]],x.array[z+10]=oa[ha[1]],x.array[z+11]=oa[ha[2]],z+=12}else if("faces"===x.boundTo){for(G=0,U=la.length;G<U;G++)X=W=V=bb=x.value[la[G]],x.array[z]=V[ha[0]],x.array[z+1]=V[ha[1]],x.array[z+2]=V[ha[2]],x.array[z+3]=W[ha[0]],
+x.array[z+4]=W[ha[1]],x.array[z+5]=W[ha[2]],x.array[z+6]=X[ha[0]],x.array[z+7]=X[ha[1]],x.array[z+8]=X[ha[2]],z+=9;for(G=0,U=ma.length;G<U;G++)oa=X=W=V=bb=x.value[ma[G]],x.array[z]=V[ha[0]],x.array[z+1]=V[ha[1]],x.array[z+2]=V[ha[2]],x.array[z+3]=W[ha[0]],x.array[z+4]=W[ha[1]],x.array[z+5]=W[ha[2]],x.array[z+6]=X[ha[0]],x.array[z+7]=X[ha[1]],x.array[z+8]=X[ha[2]],x.array[z+9]=oa[ha[0]],x.array[z+10]=oa[ha[1]],x.array[z+11]=oa[ha[2]],z+=12}}else if(4===x.size)if(void 0===x.boundTo||"vertices"===x.boundTo){for(G=
+0,U=la.length;G<U;G++)L=Da[la[G]],V=x.value[L.a],W=x.value[L.b],X=x.value[L.c],x.array[z]=V.x,x.array[z+1]=V.y,x.array[z+2]=V.z,x.array[z+3]=V.w,x.array[z+4]=W.x,x.array[z+5]=W.y,x.array[z+6]=W.z,x.array[z+7]=W.w,x.array[z+8]=X.x,x.array[z+9]=X.y,x.array[z+10]=X.z,x.array[z+11]=X.w,z+=12;for(G=0,U=ma.length;G<U;G++)L=Da[ma[G]],V=x.value[L.a],W=x.value[L.b],X=x.value[L.c],oa=x.value[L.d],x.array[z]=V.x,x.array[z+1]=V.y,x.array[z+2]=V.z,x.array[z+3]=V.w,x.array[z+4]=W.x,x.array[z+5]=W.y,x.array[z+6]=
+W.z,x.array[z+7]=W.w,x.array[z+8]=X.x,x.array[z+9]=X.y,x.array[z+10]=X.z,x.array[z+11]=X.w,x.array[z+12]=oa.x,x.array[z+13]=oa.y,x.array[z+14]=oa.z,x.array[z+15]=oa.w,z+=16}else if("faces"===x.boundTo){for(G=0,U=la.length;G<U;G++)X=W=V=bb=x.value[la[G]],x.array[z]=V.x,x.array[z+1]=V.y,x.array[z+2]=V.z,x.array[z+3]=V.w,x.array[z+4]=W.x,x.array[z+5]=W.y,x.array[z+6]=W.z,x.array[z+7]=W.w,x.array[z+8]=X.x,x.array[z+9]=X.y,x.array[z+10]=X.z,x.array[z+11]=X.w,z+=12;for(G=0,U=ma.length;G<U;G++)oa=X=W=V=
+bb=x.value[ma[G]],x.array[z]=V.x,x.array[z+1]=V.y,x.array[z+2]=V.z,x.array[z+3]=V.w,x.array[z+4]=W.x,x.array[z+5]=W.y,x.array[z+6]=W.z,x.array[z+7]=W.w,x.array[z+8]=X.x,x.array[z+9]=X.y,x.array[z+10]=X.z,x.array[z+11]=X.w,x.array[z+12]=oa.x,x.array[z+13]=oa.y,x.array[z+14]=oa.z,x.array[z+15]=oa.w,z+=16}j.bindBuffer(j.ARRAY_BUFFER,x.buffer);j.bufferData(j.ARRAY_BUFFER,x.array,ab)}ud&&(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;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)&&g(ja,j.DYNAMIC_DRAW,nb),ja.__dirtyVertices=!1,ja.__dirtyColors=!1,Ya.attributes&&n(Ya)}};this.initMaterial=function(a,b,c,d){var e,g,f,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;g=m=0;for(k=0,n=b.length;k<n;k++)e=b[k],e.onlyShadow||(e instanceof THREE.DirectionalLight&&g++,e instanceof
-THREE.PointLight&&m++,e instanceof THREE.SpotLight&&m++);m+g<=H?k=g:(k=Math.ceil(H*g/(m+g)),m=H-k);e=k;g=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:g,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":
+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,l;g=m=0;for(k=0,l=b.length;k<l;k++)e=b[k],e.onlyShadow||(e instanceof THREE.DirectionalLight&&g++,e instanceof
+THREE.PointLight&&m++,e instanceof THREE.SpotLight&&m++);m+g<=M?k=g:(k=Math.ceil(M*g/(m+g)),m=M-k);e=k;g=m;var n=0;for(m=0,k=b.length;m<k;m++)l=b[m],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:{k=a.fragmentShader;l=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:g,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(k),d.push(l));for(q in c)d.push(q),d.push(c[q]);i=d.join();for(q=0,d=Y.length;q<d;q++)if(Y[q].code===i){p=Y[q].program;break a}q=j.createProgram();d=[0<Aa?"#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:"",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);
+e=["precision "+A+" 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+k));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 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);
+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=Y.length;Y.push({program:q,code:i});H.info.memory.programs=Y.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(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};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),g=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,g,c.data):j.texImage2D(j.TEXTURE_2D,0,e,e,g,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+
+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(f in a.uniforms)a.uniformsList.push([a.uniforms[f],f])};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(ia!==a.doubleSided)a.doubleSided?
+j.disable(j.CULL_FACE):j.enable(j.CULL_FACE),ia=a.doubleSided;if(S!==a.flipSided)a.flipSided?j.frontFace(j.CW):j.frontFace(j.CCW),S=a.flipSided};this.setDepthTest=function(a){R!==a&&(a?j.enable(j.DEPTH_TEST):j.disable(j.DEPTH_TEST),R=a)};this.setDepthWrite=function(a){ba!==a&&(j.depthMask(a),ba=a)};this.setBlending=function(a){if(a!==aa){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)}aa=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),g=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,g,c.data):j.texImage2D(j.TEXTURE_2D,0,e,e,g,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+
 c,0,d,a.width,a.height,0,d,e,null);var g=a,f=j.TEXTURE_CUBE_MAP_POSITIVE_X+c;j.bindFramebuffer(j.FRAMEBUFFER,a.__webglFramebuffer[c]);j.framebufferTexture2D(j.FRAMEBUFFER,j.COLOR_ATTACHMENT0,f,g.__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=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=
+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=Ia,c=ra);b!==F&&(j.bindFramebuffer(j.FRAMEBUFFER,b),j.viewport(e,c,d,a),F=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};
@@ -466,7 +467,7 @@ c)THREE.Quaternion.slerp(e,g,a.quaternion,d);else if("scl"===c)c=a.scale,c.x=e[0
 THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],e,g,f,h,i,k;e=(a.length-1)*b;g=Math.floor(e);e-=g;c[0]=0===g?g:g-1;c[1]=g;c[2]=g>a.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];h=a[c[1]];i=a[c[2]];k=a[c[3]];c=e*e;f=e*c;d[0]=this.interpolate(g[0],h[0],i[0],k[0],e,c,f);d[1]=this.interpolate(g[1],h[1],i[1],k[1],e,c,f);d[2]=this.interpolate(g[2],h[2],i[2],k[2],e,c,f);return d};
 THREE.Animation.prototype.interpolate=function(a,b,c,d,e,g,f){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*f+(-3*(b-c)-2*a-d)*g+a*e+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c<d.length-1?c:d.length-1:c%d.length;c<d.length;c++)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?0<c?c:0:0<=c?c:c+d.length;0<=c;c--)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[d.length-1]};
-THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.0010;this.isPlaying=!1;this.loop=this.isPaused=!0;this.JITCompile=void 0!==c?c:!0;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var e=0;e<c.length;e++){var g=c[e],f=this.getNextKeyWith(g,a,0);f&&f.apply(g)}d.matrixAutoUpdate=!1;this.data.hierarchy[a].node.updateMatrix();
+THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.001;this.isPlaying=!1;this.loop=this.isPaused=!0;this.JITCompile=void 0!==c?c:!0;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var e=0;e<c.length;e++){var g=c[e],f=this.getNextKeyWith(g,a,0);f&&f.apply(g)}d.matrixAutoUpdate=!1;this.data.hierarchy[a].node.updateMatrix();
 d.matrixWorldNeedsUpdate=!0}}};
 THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=void 0!==a?a:!0;this.currentTime=void 0!==b?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,e,g;for(c=0;c<d;c++){e=this.hierarchy[c];g=this.data.hierarchy[c];e.useQuaternion=!0;if(void 0===g.animationCache)g.animationCache={},g.animationCache.prevKey=null,g.animationCache.nextKey=null,g.animationCache.originalMatrix=e instanceof THREE.Bone?e.skinMatrix:
 e.matrix;e=this.data.hierarchy[c].keys;if(e.length)g.animationCache.prevKey=e[0],g.animationCache.nextKey=e[1],this.startTime=Math.min(e[0].time,this.startTime),this.endTime=Math.max(e[e.length-1].time,this.endTime)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
@@ -479,14 +480,13 @@ THREE.CubeCamera=function(a,b,c,d){this.heightOffset=c;this.position=new THREE.V
 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=
 new THREE.Vector3(0,0,0);this.renderTarget=new THREE.WebGLRenderTargetCube(d,d,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updatePosition=function(a){this.position.copy(a);this.position.y+=this.heightOffset;this.targetPX.copy(this.position);this.targetNX.copy(this.position);this.targetPY.copy(this.position);this.targetNY.copy(this.position);this.targetPZ.copy(this.position);this.targetNZ.copy(this.position);this.targetPX.x+=1;this.targetNX.x-=1;this.targetPY.y+=
 1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(a,b){var c=this.renderTarget;c.activeCubeFace=0;a.render(b,this.cameraPX,c);c.activeCubeFace=1;a.render(b,this.cameraNX,c);c.activeCubeFace=2;a.render(b,this.cameraPY,c);c.activeCubeFace=3;a.render(b,
-this.cameraNY,c);c.activeCubeFace=4;a.render(b,this.cameraPZ,c);c.activeCubeFace=5;a.render(b,this.cameraNZ,c)}};THREE.FirstPersonCamera=function(){console.warn("DEPRECATED: FirstPersonCamera() is FirstPersonControls().")};THREE.PathCamera=function(){console.warn("DEPRECATED: PathCamera() is PathControls().")};THREE.FlyCamera=function(){console.warn("DEPRECATED: FlyCamera() is FlyControls().")};THREE.RollCamera=function(){console.warn("DEPRECATED: RollCamera() is RollControls().")};
-THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(a,b,c,d,e,g,f){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,g,f);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,e);this.zoom=1;this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera;
+this.cameraNY,c);c.activeCubeFace=4;a.render(b,this.cameraPZ,c);c.activeCubeFace=5;a.render(b,this.cameraNZ,c)}};THREE.CombinedCamera=function(a,b,c,d,e,g,f){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,g,f);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,e);this.zoom=1;this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera;
 THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.cameraP.fov=this.fov/this.zoom;this.cameraP.updateProjectionMatrix();this.projectionMatrix=this.cameraP.projectionMatrix;this.inPersepectiveMode=!0;this.inOrthographicMode=!1};
 THREE.CombinedCamera.prototype.toOrthographic=function(){var a=this.cameraP.aspect,b=(this.cameraP.near+this.cameraP.far)/2,b=Math.tan(this.fov/2)*b,a=2*b*a/2,b=b/this.zoom,a=a/this.zoom;this.cameraO.left=-a;this.cameraO.right=a;this.cameraO.top=b;this.cameraO.bottom=-b;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPersepectiveMode=!1;this.inOrthographicMode=!0};
-THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.setLens=function(a,b){b||(b=43.25);var c=2*Math.atan(b/(2*a)),c=180/Math.PI*c;this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};
+THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.setLens=function(a,b){var c=2*Math.atan((void 0!==b?b:24)/(2*a))*(180/Math.PI);this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};
 THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};
 THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};
-THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=void 0!==b?b:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
+THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=void 0!==b?b:document;this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
 0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;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));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=
 !0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=
 function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=
@@ -496,14 +496,14 @@ this.moveUp&&this.object.translateY(b);this.moveDown&&this.object.translateY(-b)
 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 e(a,b,c,d){var e={name:c,fps:0.6,length:d,hierarchy:[]},g,f=b.getControlPointsArray(),h=b.getLength(),r=f.length,s=0;g=r-1;b={parent:-1,keys:[]};b.keys[0]={time:0,pos:f[0],rot:[0,0,0,1],scl:[1,1,1]};b.keys[g]={time:d,pos:f[g],rot:[0,0,0,1],scl:[1,1,1]};for(g=1;g<r-1;g++)s=d*h.chunks[g]/h.total,b.keys[g]={time:s,pos:f[g]};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,e=new THREE.Geometry;for(c=0;c<a.points.length*b;c++)d=c/(a.points.length*b),d=a.getPoint(d),e.vertices[c]=new THREE.Vertex(new THREE.Vector3(d.x,d.y,d.z));return e}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/
+new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;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 f=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%f;this.phi=0<=a?a:a+f;b=this.verticalAngleMap.srcRange;a=this.verticalAngleMap.dstRange;
 b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=function(a){this.domElement===
 document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}),
 c=new THREE.CubeGeometry(10,10,20),f=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(f,b);a.position.set(0,10,0);this.animation=e(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=e(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a=
 this.debugPath,b=this.spline,f=g(b,10),c=g(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),f=new THREE.Line(f,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));f.scale.set(1,1,1);a.add(f);c.scale.set(1,1,1);a.add(c);for(var f=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),o=0;o<b.points.length;o++)c=new THREE.Mesh(f,h),c.position.copy(b.points[o]),a.add(c)}this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),
 !1)}};THREE.PathControlsIdCounter=0;
-THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=void 0!==b?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
+THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=void 0!==b?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
 0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if("function"==typeof this[a.type])this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=
 1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=
 0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.object.moveForward=
@@ -527,8 +527,8 @@ c.target.addSelf(b);c.staticMoving?l=p:l.addSelf(a.sub(p,l).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&&(f=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?f=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,g,f,h){function i(a,b,c,f,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=g||1;else if("z"===a&&"y"===b||"y"===a&&"z"===b)n="x",o=g||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)*f;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!==f){if(f instanceof Array)this.materials=f;else{this.materials=[];for(o=0;6>o;o++)this.materials.push(f)}o=0;r=1;q=2;s=
+THREE.CubeGeometry=function(a,b,c,d,e,g,f,h){function i(a,b,c,f,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=g||1;else if("z"===a&&"y"===b||"y"===a&&"z"===b)n="x",o=g||1;var j=o+1,t=p+1,w=h/o,F=i/p,Z=new THREE.Vector3;Z[n]=0<m?1:-1;for(h=0;h<t;h++)for(i=0;i<j;i++){var O=new THREE.Vector3;O[a]=(i*w-q)*c;O[b]=(h*F-r)*f;O[n]=m;k.vertices.push(new THREE.Vertex(O))}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(Z),a.vertexNormals.push(Z.clone(),Z.clone(),Z.clone(),Z.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!==f){if(f instanceof Array)this.materials=f;else{this.materials=[];for(o=0;6>o;o++)this.materials.push(f)}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,g){THREE.Geometry.call(this);var a=void 0!==a?a:20,b=void 0!==b?b:20,c=void 0!==c?c:100,f=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+f,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],
@@ -537,15 +537,15 @@ n=k[i+1][h+1],o=k[i][h+1],q=this.vertices[c].position.clone().setY(0).normalize(
 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,g=THREE.ExtrudeGeometry.__v3,f=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();g.set(-d.y,d.x);f.set(e.y,-e.x);h.copy(a).addSelf(g);j.copy(a).addSelf(f);if(h.equals(j))return f.clone();
-h.copy(b).addSelf(g);j.copy(c).addSelf(f);g=d.dot(f);f=j.subSelf(h).dot(f);0===g&&(console.log("Either infinite or no solutions!"),0===f?console.log("Its finite solutions."):console.log("Too bad, no solutions."));f/=g;return 0>f?(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(f).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),g=ia+z+d,f=ia+z+e,m=g,d=ia+E+d,e=ia+E+e,k=f,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,g=(D.vertices[g].position.z+i)/e,f=(D.vertices[f].position.z+i)/e,D.faceVertexUvs[0].push([new THREE.UV(g,m),new THREE.UV(f,m),new THREE.UV(f,d),new THREE.UV(g,d)]))}}}function g(a,b,c){D.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function f(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,g=v.maxY,f=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)/f,(D.vertices[a].position.y-e)/g),new THREE.UV(h/f,b/g),new THREE.UV(j/f,c/g)])}}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),g(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),g(L.x,L.y,-S)}}O=k;for(j=0;j<P;j++)L=p?c(q[j],ea[j],O):q[j],s?g(L.x,L.y+r[0].y,r[0].x):g(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?g(L.x,L.y+r[K-1].y,r[K-1].x):g(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),g(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?g(L.x,L.y+r[o-1].y,r[o-1].x+S):g(L.x,L.y,h+S)}}if(p){p=0*P;for(j=0;j<H;j++)k=m[j],f(k[2]+p,k[1]+p,k[0]+p);p=P*(o+2*l);for(j=0;j<H;j++)k=m[j],f(k[0]+p,k[1]+p,k[2]+p)}else{for(j=0;j<H;j++)k=m[j],f(k[2],k[1],k[0]);for(j=0;j<H;j++)k=m[j],f(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;
+h.copy(b).addSelf(g);j.copy(c).addSelf(f);g=d.dot(f);f=j.subSelf(h).dot(f);0===g&&(console.log("Either infinite or no solutions!"),0===f?console.log("Its finite solutions."):console.log("Too bad, no solutions."));f/=g;return 0>f?(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(f).addSelf(h).subSelf(a).clone()}function e(a){for(j=a.length;0<=--j;){B=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=P*b,e=P*(b+1),g=da+B+d,f=da+B+e,m=g,d=da+F+d,e=da+F+e,k=f,m=m+E,d=d+E,e=e+E,k=k+E;C.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,g=(C.vertices[g].position.z+i)/e,f=(C.vertices[f].position.z+i)/e,C.faceVertexUvs[0].push([new THREE.UV(g,m),new THREE.UV(f,m),new THREE.UV(f,d),new THREE.UV(g,d)]))}}}function g(a,b,c){C.vertices.push(new THREE.Vertex(new THREE.Vector3(a,b,c)))}function f(a,b,c){a+=E;b+=E;c+=E;C.faces.push(new THREE.Face3(a,
+b,c,null,null,w));if(void 0!==w){var d=v.minX,e=v.minY,g=v.maxY,f=v.maxX,h=C.vertices[b].position.x-d,b=C.vertices[b].position.y-e,j=C.vertices[c].position.x-d,c=C.vertices[c].position.y-e;C.faceVertexUvs[0].push([new THREE.UV((C.vertices[a].position.x-d)/f,(C.vertices[a].position.y-e)/g),new THREE.UV(h/f,b/g),new THREE.UV(j/f,c/g)])}}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 y,D,A,C=this,E=this.vertices.length;q&&a.addWrapPath(q);n=t?a.extractAllSpacedPoints(n):a.extractAllPoints(n);q=n.shape;n=n.holes;if(m=!THREE.Shape.Utils.isClockWise(q)){q=q.reverse();for(D=
+0,A=n.length;D<A;D++)y=n[D],THREE.Shape.Utils.isClockWise(y)&&(n[D]=y.reverse());m=!1}m=THREE.Shape.Utils.triangulateShape(q,n);t=q;for(D=0,A=n.length;D<A;D++)y=n[D],q=q.concat(y);for(var J,N,T,K,P=q.length,M=m.length,H=[],j=0,Y=t.length,B=Y-1,F=j+1;j<Y;j++,B++,F++)B===Y&&(B=0),F===Y&&(F=0),H[j]=d(t[j],t[B],t[F]);var Z=[],O,ga=H.concat();for(D=0,A=n.length;D<A;D++){y=n[D];O=[];for(j=0,Y=y.length,B=Y-1,F=j+1;j<Y;j++,B++,F++)B===Y&&(B=0),F===Y&&(F=0),O[j]=d(y[j],y[B],y[F]);Z.push(O);ga=ga.concat(O)}for(J=
+0;J<l;J++){N=J/l;T=i*(1-N);N=k*Math.sin(N*Math.PI/2);for(j=0,Y=t.length;j<Y;j++)K=c(t[j],H[j],N),g(K.x,K.y,-T);for(D=0,A=n.length;D<A;D++){y=n[D];O=Z[D];for(j=0,Y=y.length;j<Y;j++)K=c(y[j],O[j],N),g(K.x,K.y,-T)}}N=k;for(j=0;j<P;j++)K=p?c(q[j],ga[j],N):q[j],s?g(K.x,K.y+r[0].y,r[0].x):g(K.x,K.y,0);for(J=1;J<=o;J++)for(j=0;j<P;j++)K=p?c(q[j],ga[j],N):q[j],s?g(K.x,K.y+r[J-1].y,r[J-1].x):g(K.x,K.y,h/o*J);for(J=l-1;0<=J;J--){N=J/l;T=i*(1-N);N=k*Math.sin(N*Math.PI/2);for(j=0,Y=t.length;j<Y;j++)K=c(t[j],
+H[j],N),g(K.x,K.y,h+T);for(D=0,A=n.length;D<A;D++){y=n[D];O=Z[D];for(j=0,Y=y.length;j<Y;j++)K=c(y[j],O[j],N),s?g(K.x,K.y+r[o-1].y,r[o-1].x+T):g(K.x,K.y,h+T)}}if(p){p=0*P;for(j=0;j<M;j++)k=m[j],f(k[2]+p,k[1]+p,k[0]+p);p=P*(o+2*l);for(j=0;j<M;j++)k=m[j],f(k[0]+p,k[1]+p,k[2]+p)}else{for(j=0;j<M;j++)k=m[j],f(k[2],k[1],k[0]);for(j=0;j<M;j++)k=m[j],f(k[0]+P*o,k[1]+P*o,k[2]+P*o)}var da=0;e(t);da+=t.length;for(D=0,A=n.length;D<A;D++)y=n[D],e(y),da+=y.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=[],g=[],f=(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]=f.multiplyVector3(c[h].clone()),this.vertices.push(new THREE.Vertex(c[h])),e[h]=this.vertices.length-1):e=g;0==i&&(g=d);
+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=[],g=[],f=(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.001;i+=b){for(h=0;h<c.length;h++)i<this.angle?(c[h]=f.multiplyVector3(c[h].clone()),this.vertices.push(new THREE.Vertex(c[h])),e[h]=this.vertices.length-1):e=g;0==i&&(g=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,g=b/2,c=c||1,d=d||1,f=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<f;b++)this.vertices.push(new THREE.Vertex(new THREE.Vector3(b*i-e,-(a*k-g),0)));for(a=0;a<d;a++)for(b=0;b<c;b++)e=new THREE.Face4(b+f*a,b+f*(a+1),b+1+f*(a+1),b+1+f*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;
@@ -558,8 +558,8 @@ THREE.FontUtils={faces:{},face:"helvetiker",weight:"normal",style:"normal",size:
 0,e=(""+a).split(""),g=e.length,f=[],a=0;a<g;a++){var h=new THREE.Path,h=this.extractGlyphPoints(e[a],b,c,d,h),d=d+h.offset;f.push(h.path)}return{paths:f,offset:d/2}},extractGlyphPoints:function(a,b,c,d,e){var g=[],f,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;g.push(new THREE.Vector2(i,l));e.moveTo(i,l);break;case "l":i=b[a++]*c+d;l=b[a++]*c;g.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(f=g[g.length-1]){p=f.x;n=f.y;for(f=1,h=this.divisions;f<=h;f++){var t=f/h,w=THREE.Shape.Utils.b2(t,p,o,i),t=THREE.Shape.Utils.b2(t,n,q,l);g.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),f=g[g.length-1]){p=f.x;n=f.y;for(f=1,h=this.divisions;f<=h;f++)t=f/h,w=THREE.Shape.Utils.b3(t,p,o,
 m,i),t=THREE.Shape.Utils.b3(t,n,q,r,l),g.push(new THREE.Vector2(w,t))}}}return{offset:s.ha*c,points:g,path:e}}}};
-(function(a){var b=function(a){for(var b=a.length,e=0,g=b-1,f=0;f<b;g=f++)e+=a[g].x*a[f].y-a[f].x*a[g].y;return 0.5*e};a.Triangulate=function(a,d){var e=a.length;if(3>e)return null;var g=[],f=[],h=[],i,k,l;if(0<b(a))for(k=0;k<e;k++)f[k]=k;else for(k=0;k<e;k++)f[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=f,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){g.push([a[f[i]],
+(function(a){var b=function(a){for(var b=a.length,e=0,g=b-1,f=0;f<b;g=f++)e+=a[g].x*a[f].y-a[f].x*a[g].y;return 0.5*e};a.Triangulate=function(a,d){var e=a.length;if(3>e)return null;var g=[],f=[],h=[],i,k,l;if(0<b(a))for(k=0;k<e;k++)f[k]=k;else for(k=0;k<e;k++)f[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=f,t=void 0,w=void 0,u=void 0,v=void 0,y=void 0,
+D=void 0,A=void 0,C=void 0,E=void 0,w=n[s[o]].x,u=n[s[o]].y,v=n[s[q]].x,y=n[s[q]].y,D=n[s[m]].x,A=n[s[m]].y;if(1.0E-10>(v-w)*(A-u)-(y-u)*(D-w))n=!1;else{for(t=0;t<r;t++)if(!(t==o||t==q||t==m)){var C=n[s[t]].x,E=n[s[t]].y,J=void 0,N=void 0,T=void 0,K=void 0,P=void 0,M=void 0,H=void 0,j=void 0,Y=void 0,B=void 0,F=void 0,Z=void 0,J=T=P=void 0,J=D-v,N=A-y,T=w-D,K=u-A,P=v-w,M=y-u,H=C-w,j=E-u,Y=C-v,B=E-y,F=C-D,Z=E-A,J=J*B-N*Y,P=P*j-M*H,T=T*Z-K*F;if(0<=J&&0<=T&&0<=P){n=!1;break a}}n=!0}}if(n){g.push([a[f[i]],
 a[f[k]],a[f[l]]]);h.push([f[i],f[k],f[l]]);for(i=k,l=k+1;l<e;i++,l++)f[i]=f[l];e--;p=2*e}}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,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 g=d/this.segmentsT*this.arc,f=2*c/this.segmentsR*Math.PI;e.x=this.radius*Math.cos(g);e.y=this.radius*Math.sin(g);var h=new THREE.Vector3;h.x=(this.radius+this.tube*Math.cos(f))*Math.cos(g);h.y=(this.radius+this.tube*Math.cos(f))*Math.sin(g);h.z=
 this.tube*Math.sin(f);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,g=(this.segmentsT+1)*(c-1)+d-1,f=(this.segmentsT+1)*(c-1)+d,h=(this.segmentsT+1)*c+d,i=new THREE.Face4(e,g,f,h,[b[e],b[g],b[f],b[h]]);i.normal.addSelf(b[e]);i.normal.addSelf(b[g]);i.normal.addSelf(b[f]);i.normal.addSelf(b[h]);i.normal.normalize();this.faces.push(i);
@@ -584,11 +584,11 @@ THREE.CameraHelper.prototype.update=function(a){function b(a,b,g,f){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 m=new THREE.Face4(a,b,c,d,null,h.color,h.material);if(f.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);(!f.supportUVs||0!=n.length)&&g.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=[],g=[],f=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)),f.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,g,f,h={};for(d=0,e=a.faces.length;d<e;d++)g=a.faces[d],g instanceof THREE.Face3?(f=c(g.a,g.b),b(h,f,d),f=c(g.b,g.c),b(h,f,d),f=c(g.c,g.a),b(h,f,d)):g instanceof THREE.Face4&&(f=c(g.a,g.b),b(h,f,d),f=c(g.b,g.c),b(h,f,d),f=c(g.c,g.d),b(h,f,d),f=c(g.d,g.a),b(h,f,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++,f.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]=g;delete a.__tmpVertices;a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals()};
+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,g,f,h={};for(d=0,e=a.faces.length;d<e;d++)g=a.faces[d],g instanceof THREE.Face3?(f=c(g.a,g.b),b(h,f,d),f=c(g.b,g.c),b(h,f,d),f=c(g.c,g.a),b(h,f,d)):g instanceof THREE.Face4&&(f=c(g.a,g.b),b(h,f,d),f=c(g.b,g.c),b(h,f,d),f=c(g.c,g.d),b(h,f,d),f=c(g.d,g.a),b(h,f,d));return h}(a);var u=0,t=h.length,v,y,D={},A={},C=function(a,
+b){void 0===D[a]&&(D[a]=[]);D[a].push(b)},E=function(a,b){void 0===A[a]&&(A[a]={});A[a][b]=null};for(o in q){w=q[o];v=o.split("_");y=v[0];v=v[1];C(y,[y,v]);C(v,[y,v]);for(m=0,r=w.length;m<r;m++)s=w[m],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++,f.supportUVs&&0!=n.length)w=new THREE.UV,w.u=n[y].u+n[v].u,w.v=n[y].v+n[v].v,w.u/=2,w.v/=2,n.push(w);var J,N;v=["123","12","2","23"];r=["123","23","3","31"];var C=["123","31","1","12"],E=["1234","12","2","23"],T=["1234","23","3","34"],K=["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),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,C)):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,T),b(w,l[J],s.d,l[N],s,K),b(w,l[N],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!==D[o]){i.set(0,0,0);l.set(0,0,0);s=new THREE.Vector3(0,0,0);w=0;for(m in A[o])i.addSelf(k[m]),w++;u=0;t=D[o].length;for(m=0;m<t;m++)p[c(D[o][m][0],D[o][m][1])]&&u++;if(2!=u){i.divideScalar(w);for(m=0;m<
+t;m++)w=D[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]=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=
@@ -604,120 +604,120 @@ THREE.BinaryLoader.prototype.loadAjaxJSON=function(a,b,c,d,e,g){var f=new XMLHtt
 f.status+"]")};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.BinaryLoader.prototype.loadAjaxBuffers=function(a,b,c,d,e){var g=new XMLHttpRequest,f=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 ["+f+"] ["+g.status+"]"):3==g.readyState?e&&(0==h&&(h=g.getResponseHeader("Content-Length")),e({total:h,loaded:g.responseText.length})):2==g.readyState&&(h=g.getResponseHeader("Content-Length"))};g.open("GET",f,!0);
 g.responseType="arraybuffer";g.send(null)};
-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,g,f,h,i,k,m,l=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=l[3*d];g=l[3*d+1];f=l[3*d+2];h=j[2*e];e=j[2*e+1];i=j[2*g];k=j[2*g+1];g=j[2*f];m=j[2*f+1];f=P.faceVertexUvs[0];var n=[];n.push(new THREE.UV(h,e));n.push(new THREE.UV(i,k));
-n.push(new THREE.UV(g,m));f.push(n)}}function I(b,c){var d,e,g,f,h,i,k,m,l,n,o=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=o[4*d];g=o[4*d+1];f=o[4*d+2];h=o[4*d+3];i=j[2*e];e=j[2*e+1];k=j[2*g];l=j[2*g+1];m=j[2*f];n=j[2*f+1];f=j[2*h];g=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(f,g));h.push(p)}}function K(b,c,d){for(var e,g,f,h,c=new Uint32Array(a,c,3*b),j=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[3*d],g=c[3*
-d+1],f=c[3*d+2],h=j[d],P.faces.push(new THREE.Face3(e,g,f,null,null,h))}function O(b,c,d){for(var e,g,f,h,j,c=new Uint32Array(a,c,4*b),i=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[4*d],g=c[4*d+1],f=c[4*d+2],h=c[4*d+3],j=i[d],P.faces.push(new THREE.Face4(e,g,f,h,null,null,j))}function S(b,c,d,e){for(var g,f,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++){g=c[3*e];f=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(g,f,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 g,f,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++){g=c[4*e];f=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(g,f,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,g;for(c=0;c<n;c++)d=b[3*c],e=b[3*c+1],g=b[3*c+2],P.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,g)));return 3*
-n*Float32Array.BYTES_PER_ELEMENT}(H);H+=function(b){if(o){var b=new Int8Array(a,b,3*o),c,d,e,g;for(c=0;c<o;c++)d=b[3*c],e=b[3*c+1],g=b[3*c+2],G.push(d/127,e/127,g/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",f,"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(g(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(),g=0;e;){e=(new b).parse(e);if(!e.id||0==e.id.length)e.id=c+g++;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,g=b.keys.length;e<g;e++)d.length=Math.max(d.length,b.keys[e].time)}else d=
+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 y(a){return a%4?4-a%4:0}function D(a,b){return(new Uint8Array(a,b,1))[0]}function A(a,b){return(new Uint32Array(a,b,1))[0]}function C(b,c){var d,e,g,f,h,i,k,m,l=new Uint32Array(a,c,3*b);for(d=0;d<b;d++){e=l[3*d];g=l[3*d+1];f=l[3*d+2];h=j[2*e];e=j[2*e+1];i=j[2*g];k=j[2*g+1];g=j[2*f];m=j[2*f+1];f=P.faceVertexUvs[0];var n=[];n.push(new THREE.UV(h,e));n.push(new THREE.UV(i,k));
+n.push(new THREE.UV(g,m));f.push(n)}}function E(b,c){var d,e,g,f,h,i,k,m,l,n,o=new Uint32Array(a,c,4*b);for(d=0;d<b;d++){e=o[4*d];g=o[4*d+1];f=o[4*d+2];h=o[4*d+3];i=j[2*e];e=j[2*e+1];k=j[2*g];l=j[2*g+1];m=j[2*f];n=j[2*f+1];f=j[2*h];g=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(f,g));h.push(p)}}function J(b,c,d){for(var e,g,f,h,c=new Uint32Array(a,c,3*b),j=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[3*d],g=c[3*
+d+1],f=c[3*d+2],h=j[d],P.faces.push(new THREE.Face3(e,g,f,null,null,h))}function N(b,c,d){for(var e,g,f,h,j,c=new Uint32Array(a,c,4*b),i=new Uint16Array(a,d,b),d=0;d<b;d++)e=c[4*d],g=c[4*d+1],f=c[4*d+2],h=c[4*d+3],j=i[d],P.faces.push(new THREE.Face4(e,g,f,h,null,null,j))}function T(b,c,d,e){for(var g,f,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++){g=c[3*e];f=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=H[3*k],o=H[3*k+1];k=
+H[3*k+2];var p=H[3*m],q=H[3*m+1];m=H[3*m+2];P.faces.push(new THREE.Face3(g,f,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,m)],null,j))}}function K(b,c,d,e){for(var g,f,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++){g=c[4*e];f=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=H[3*m],q=H[3*m+1];m=H[3*m+2];var r=H[3*l],s=H[3*l+1];l=H[3*l+2];var t=H[3*n],u=H[3*
+n+1];n=H[3*n+2];P.faces.push(new THREE.Face4(g,f,h,j,[new THREE.Vector3(H[3*k],H[3*k+1],H[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,M=0,H=[],j=[],Y,B;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,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);n=A(a,M+20);
+o=A(a,M+20+4);q=A(a,M+20+8);b=A(a,M+20+12);m=A(a,M+20+16);r=A(a,M+20+20);s=A(a,M+20+24);t=A(a,M+20+28);w=A(a,M+20+32);u=A(a,M+20+36);v=A(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;B=4*i+p;e=b*c;Y=m*(c+3*k);i=r*(c+3*l);p=s*(c+3*k+3*l);c=t*B;k=w*(B+4*k);l=u*(B+4*l);M+=function(b){var b=new Float32Array(a,b,3*n),c,d,e,g;for(c=0;c<n;c++)d=b[3*c],e=b[3*c+1],g=b[3*c+2],P.vertices.push(new THREE.Vertex(new THREE.Vector3(d,e,g)));return 3*
+n*Float32Array.BYTES_PER_ELEMENT}(M);M+=function(b){if(o){var b=new Int8Array(a,b,3*o),c,d,e,g;for(c=0;c<o;c++)d=b[3*c],e=b[3*c+1],g=b[3*c+2],H.push(d/127,e/127,g/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);Y=e+Y+y(2*m);i=Y+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);C(r,b)}})(Y);(function(a){if(s){var b=a+3*s*Uint32Array.BYTES_PER_ELEMENT,c=b+3*s*Uint32Array.BYTES_PER_ELEMENT;T(s,a,b,c+3*s*Uint32Array.BYTES_PER_ELEMENT);C(s,c)}})(i);(function(a){if(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(m){var b=a+3*m*Uint32Array.BYTES_PER_ELEMENT;T(m,a,b,b+3*m*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){R=a;d=d||Ua;void 0!==e&&(a=e.split("/"),a.pop(),$a=1>a.length?"":a.join("/")+"/");if((a=R.evaluate("//dae:asset",R,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":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",f,"image");ib=b("//dae:library_materials/dae:material",A,"material");Va=b("//dae:library_effects/dae:effect",T,"effect");qa=b("//dae:library_geometries/dae:geometry",r,"geometry");lb=b(".//dae:library_cameras/dae:camera",Y,"camera");ra=b("//dae:library_controllers/dae:controller",h,"controller");Ia=b("//dae:library_animations/dae:animation",P,"animation");
+Wa=b(".//dae:library_visual_scenes/dae:visual_scene",l,"visual_scene");La=[];ta=[];(a=R.evaluate(".//dae:scene/dae:instance_visual_scene",R,F,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())?(a=a.getAttribute("url").replace(/^#/,""),ea=Wa[a]):ea=null;ba=new THREE.Object3D;for(a=0;a<ea.nodes.length;a++)ba.add(g(ea.nodes[a]));db=[];c(ba);a={scene:ba,morphs:La,skins:ta,animations:db,dae:{images:na,materials:ib,cameras:lb,effects:Va,geometries:qa,controllers:ra,animations:Ia,visualScenes:Wa,
+scene:ea}};d&&d(a);return a}function b(a,b,c){for(var a=R.evaluate(a,R,F,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null),d={},e=a.iterateNext(),g=0;e;){e=(new b).parse(e);if(!e.id||0==e.id.length)e.id=c+g++;d[e.id]=e;e=a.iterateNext()}return d}function c(a){var b=ea.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,g=b.keys.length;e<g;e++)d.length=Math.max(d.length,b.keys[e].time)}else d=
 {hierarchy:[{keys:[],sids:[]}]};e=0;for(g=a.children.length;e<g;e++)for(var b=0,f=c(a.children[e]).hierarchy.length;b<f;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 g=a.channels[0].sampler.output[c];g instanceof THREE.Matrix4&&a.world.copy(g)}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,g=ra[b.url];if(!g||
-!g.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,f=-c,h=0;for(e in Ha)for(var j=Ha[e],i=0;i<j.sampler.length;i++){var k=j.sampler[i];k.create();c=Math.min(c,k.startTime);f=Math.max(f,k.endTime);h=Math.max(h,k.input.length)}e=h;for(var b=fa.getChildById(b.skeleton[0],!0)||fa.getChildBySid(b.skeleton[0],!0),m,l,f=new THREE.Vector3,n,i=0;i<a.vertices.length;i++)g.skin.bindShapeMatrix.multiplyVector3(a.vertices[i].position);
+!g.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,f=-c,h=0;for(e in Ia)for(var j=Ia[e],i=0;i<j.sampler.length;i++){var k=j.sampler[i];k.create();c=Math.min(c,k.startTime);f=Math.max(f,k.endTime);h=Math.max(h,k.input.length)}e=h;for(var b=ea.getChildById(b.skeleton[0],!0)||ea.getChildBySid(b.skeleton[0],!0),m,l,f=new THREE.Vector3,n,i=0;i<a.vertices.length;i++)g.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=g.skin;for(l=0;l<i.length;l++)if(m=i[l],n=-1,"JOINT"==m.type){for(var o=0;o<k.joints.length;o++)if(m.sid==k.joints[o]){n=o;break}if(0<=n){o=k.invBindMatrices[n];m.invBindMatrix=o;m.skinningMatrix=new THREE.Matrix4;m.skinningMatrix.multiply(m.world,o);m.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&&m.weights.push(q)}}else throw"ColladaLoader: Could not find joint '"+
 m.sid+"'.";}for(i=0;i<h.length;i++)if("JOINT"==h[i].type)for(k=0;k<h[i].weights.length;k++)m=h[i].weights[k],l=m.index,m=m.weight,n=a.vertices[l],l=j[l],f.x=n.position.x,f.y=n.position.y,f.z=n.position.z,h[i].skinningMatrix.multiplyVector3(f),l.position.x+=f.x*m,l.position.y+=f.y*m,l.position.z+=f.z*m;a.morphTargets.push({name:"target_"+c,vertices:j})}}}function g(a){var b=new THREE.Object3D,c,d,f,h;for(f=0;f<a.controllers.length;f++){var j=ra[a.controllers[f].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[f].instance_material;a.geometries.push(i);c=a.controllers[f]}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[f].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[f].instance_material,a.geometries.push(i),d=a.controllers[f];console.log("ColladaLoader: Morph-controller partially supported.")}}for(f=
-0;f<a.geometries.length;f++){var j=a.geometries[f],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(f=0;f<a.cameras.length;f++)b=lb[a.cameras[f].url],b=new THREE.PerspectiveCamera(b.fov,b.aspect_ratio,b.znear,b.zfar);b.name=a.id||"";b.matrix=a.matrix;f=a.matrix.decompose();b.position=f[0];b.quaternion=
-f[1];b.useQuaternion=!0;b.scale=f[2];Fa.centerGeometry&&b.geometry&&(f=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(f.multiplySelf(b.scale)),b.position.subSelf(f));for(f=0;f<a.nodes.length;f++)b.add(g(a.nodes[f],a));return b}function f(){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;f.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=
+0;f<a.geometries.length;f++){var j=a.geometries[f],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=ib[p.target],r=Va[q.instance_effect.url].shader;r.material.opacity=!r.material.opacity?1:r.material.opacity;k[p.symbol]=n;l.push(r.material);p=r.material;p.name=null==q.name||""===q.name?q.id:q.name;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(f=0;f<a.cameras.length;f++)b=lb[a.cameras[f].url],b=new THREE.PerspectiveCamera(b.fov,b.aspect_ratio,b.znear,b.zfar);b.name=a.id||"";b.matrix=a.matrix;
+f=a.matrix.decompose();b.position=f[0];b.quaternion=f[1];b.useQuaternion=!0;b.scale=f[2];Fa.centerGeometry&&b.geometry&&(f=THREE.GeometryUtils.center(b.geometry),b.quaternion.multiplyVector3(f.multiplySelf(b.scale)),b.position.subSelf(f));for(f=0;f<a.nodes.length;f++)b.add(g(a.nodes[f],a));return b}function f(){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 y(){this.semantic="";this.offset=0;this.source="";this.set=0}function D(a){this.id=a;this.type=null}function A(){this.name=
+this.id="";this.instance_effect=null}function C(){this.color=new THREE.Color(0);this.color.setRGB(Math.random(),Math.random(),Math.random());this.color.a=1;this.texOpts=this.texcoord=this.texture=null}function 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 T(){this.name=this.id="";this.sampler=this.surface=this.shader=
+null}function K(){this.url=""}function P(){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 Y(){this.name=this.id=""}function B(){this.url=
+""}function F(a){return"dae"==a?"http://www.collada.org/2005/11/COLLADASchema":null}function Z(a){for(var a=ga(a),b=[],c=0,d=a.length;c<d;c++)b.push(parseFloat(a[c]));return b}function O(a){for(var a=ga(a),b=[],c=0,d=a.length;c<d;c++)b.push(parseInt(a[c],10));return b}function ga(a){return 0<a.length?a.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s+/):[]}function da(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function ia(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 S(a,b){var c=[a[b],a[b+1],a[b+2]];ia(c,-1);return new THREE.Vector3(c[0],c[1],c[2])}function aa(a){if(Fa.convertUpAxis){var b=[a[0],a[4],a[8]];ia(b,-1);a[0]=b[0];a[4]=b[1];a[8]=b[2];b=[a[1],a[5],a[9]];ia(b,-1);a[1]=b[0];a[5]=b[1];a[9]=
+b[2];b=[a[2],a[6],a[10]];ia(b,-1);a[2]=b[0];a[6]=b[1];a[10]=b[2];b=[a[0],a[1],a[2]];ia(b,-1);a[0]=b[0];a[1]=b[1];a[2]=b[2];b=[a[4],a[5],a[6]];ia(b,-1);a[4]=b[0];a[5]=b[1];a[6]=b[2];b=[a[8],a[9],a[10]];ia(b,-1);a[8]=b[0];a[9]=b[1];a[10]=b[2];b=[a[3],a[7],a[11]];ia(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 R=null,ba=null,ea,Ua=null,Ha={},na={},Ia={},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;f.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=Z(f.textContent);this.bindShapeMatrix=aa(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=O(g.textContent);break;case "vcount":d=O(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 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=
+break;case "instance_camera":this.cameras.push((new B).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=R.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",R,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 n).parse(b));
+break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in Ia)for(var e=Ia[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)};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);
+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=Z(a.textContent);this.convert();
+return this};n.prototype.convert=function(){switch(this.type){case "matrix":this.obj=aa(this.data);break;case "rotate":this.angle=this.data[3]*mb;case "translate":ia(this.data,-1);this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;case "scale":ia(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 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}};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")),
+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=R.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};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=
+R.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==Ha[d]&&(Ha[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=Ha[this.vertices.input.POSITION.source].data;for(b=0;b<a.length;b+=3)this.geometry3js.vertices.push(new THREE.Vertex(S(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.calcNormals&&(this.geometry3js.computeVertexNormals(),delete this.geometry3js.calcNormals);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=Ha[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(S(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(0==r.length)if(h=this.vertices.input.NORMAL){k=Ha[h.source];j=k.accessor.params.length;h=0;for(i=q.length;h<i;h++)r.push(S(k.data,q[h]*j))}else b.calcNormals=!0;if(3===m)d.push(new THREE.Face3(q[0],q[1],q[2],r,s.length?s:new THREE.Color));else if(4===m)d.push(new THREE.Face4(q[0],q[1],q[2],q[3],r,s.length?s:new THREE.Color));else if(4<m&&Fa.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){h=
+0;for(i=d.length;h<i;h++){e=d[h];e.daeMaterial=a.material;b.faces.push(e);for(e=0;e<o.length;e++)q=p[o[e]],q=4<m?[q[0],q[h+1],q[h+2]]:4===m?[q[0],q[1],q[2],q[3]]:[q[0],q[1],q[2]],b.faceVertexUvs[e]||(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(q)}}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=da(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=O(c.textContent);break;case "p":this.p=O(c.textContent)}}return this};u.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=da(a,"count",0);this.stride=
+da(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=da(a,"set",-1);this.offset=da(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=ga(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=Z(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=
+O(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=ga(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=aa(c);a.push(c)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};A.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};C.prototype.isColor=function(){return null==this.texture};C.prototype.isTexture=function(){return null!=this.texture};
+C.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "color":c=Z(c.textContent);this.color=new THREE.Color(0);this.color.setRGB(c[0],c[1],c[2]);this.color.a=c[3];break;case "texture":this.texture=c.getAttribute("texture"),this.texcoord=c.getAttribute("texcoord"),this.texOpts={offsetU:0,offsetV:0,repeatU:1,repeatV:1,wrapU:1,wrapV:1},this.parseTexture(c)}}return this};C.prototype.parseTexture=function(a){if(!a.childNodes)return this;
+a.childNodes[1]&&"extra"===a.childNodes[1].nodeName&&(a=a.childNodes[1],a.childNodes[1]&&"technique"===a.childNodes[1].nodeName&&(a=a.childNodes[1]));for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "offsetU":case "offsetV":case "repeatU":case "repeatV":this.texOpts[c.nodeName]=parseFloat(c.textContent);break;case "wrapU":case "wrapV":this.texOpts[c.nodeName]=parseInt(c.textContent);break;default:this.texOpts[c.nodeName]=c.textContent}}return this};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 C).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=R.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 C)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=na[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture($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)};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};T.prototype.create=function(){if(null==this.shader)return null};T.prototype.parse=function(a){this.id=a.getAttribute("id");this.name=a.getAttribute("name");this.shader=null;for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "profile_COMMON":this.parseTechnique(this.parseProfileCOMMON(c))}}return this};
+T.prototype.parseNewparam=function(a){for(var b=a.getAttribute("sid"),c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "surface":this.surface=(new 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)}}};T.prototype.parseProfileCOMMON=function(a){for(var b,c=0;c<a.childNodes.length;c++){var d=a.childNodes[c];if(1==d.nodeType)switch(d.nodeName){case "profile_COMMON":this.parseProfileCOMMON(d);
+break;case "technique":b=d;break;case "newparam":this.parseNewparam(d);break;case "extra":break;default:console.log(d.nodeName)}}return b};T.prototype.parseTechnique=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "constant":case "lambert":case "blinn":case "phong":this.shader=(new E(c.nodeName,this)).parse(c)}}};K.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};P.prototype.parse=function(a){this.id=
+a.getAttribute("id");this.name=a.getAttribute("name");this.source={};for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "source":c=(new D).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new 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=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":ia(c,-1);break;case "scale":ia(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)}};Y.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};
+Y.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};B.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 g=new XMLHttpRequest,f=0;g.onreadystatechange=function(){if(g.readyState===g.DONE)if(200===g.status||0===g.status){var h;try{g.responseText?h=JSON.parse(g.responseText):console.warn("EMPTY: ["+b+"] seems to be unreachable or file there is empty")}catch(i){console.warn("DEPRECATED: ["+b+"] seems to be using old model format or JSON is invalid")}h&&a.createModel(h,c,d);a.onLoadComplete()}else console.error("Couldn't load ["+b+"] ["+g.status+
 "]");else g.readyState===g.LOADING?e&&(0===f&&(f=g.getResponseHeader("Content-Length")),e({total:f,loaded:g.responseText.length})):g.readyState===g.HEADERS_RECEIVED&&(f=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,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+=
+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,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;)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<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(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(y[n]),r.color=n;if(b)for(c=0;c<p;c++)n=u[k++],n=new THREE.Color(y[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(g){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(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 g(a){return function(b){z.geometries[a]=b;e();
-H-=1;i.onLoadComplete();h()}}function f(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),g(l));else if("ascii_mesh"==m.type)P.load(d(m.url,L.urlBaseType),g(l));else if("embedded_mesh"==m.type)m=L.embeds[m.id],m.metadata=L.metadata,m&&P.createModel(m,f(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.SceneLoader.prototype.createScene=function(a,b,c){function d(a,b){return"relativeToHTML"==b?a:k+"/"+a}function e(){var a;for(n in K.objects)if(!B.objects[n])if(s=K.objects[n],void 0!==s.geometry){if(E=B.geometries[s.geometry]){a=!1;J=B.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=n;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;B.scene.add(a);B.objects[n]=a;if(s.meshCollider){var b=THREE.CollisionUtils.MeshColliderWBox(a);B.scene.collisions.colliders.push(b)}if(s.castsShadow)b=new THREE.ShadowVolume(E),B.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},
+B.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=n,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,B.scene.add(a),B.objects[n]=a,B.empties[n]=a,s.trigger&&"none"!=s.trigger.toLowerCase()&&(b={type:s.trigger,object:s},B.triggers[a.name]=b)}function g(a){return function(b){B.geometries[a]=b;e();
+M-=1;i.onLoadComplete();h()}}function f(a){return function(b){B.geometries[a]=b}}function h(){i.callbackProgress({totalModels:j,totalTextures:Y,loadedModels:j-M,loadedTextures:Y-H},B);i.onLoadProgress();0==M&&0==H&&b(B)}var i=this,k=THREE.Loader.prototype.extractUrlbase(c),l,p,n,o,q,m,r,s,t,w,u,v,y,D,A,C,E,J,N,T,K,P,M,H,j,Y,B;K=a;c=new THREE.BinaryLoader;P=new THREE.JSONLoader;H=M=0;B={scene:new THREE.Scene,geometries:{},materials:{},textures:{},objects:{},cameras:{},lights:{},fogs:{},triggers:{},
+empties:{}};a=!1;for(n in K.objects)if(s=K.objects[n],s.meshCollider){a=!0;break}if(a)B.scene.collisions=new THREE.CollisionSystem;if(K.transform)a=K.transform.position,t=K.transform.rotation,A=K.transform.scale,a&&B.scene.position.set(a[0],a[1],a[2]),t&&B.scene.rotation.set(t[0],t[1],t[2]),A&&B.scene.scale.set(A[0],A[1],A[2]),(a||t||A)&&B.scene.updateMatrix();a=function(){H-=1;h();i.onLoadComplete()};for(q in K.cameras)A=K.cameras[q],"perspective"==A.type?N=new THREE.PerspectiveCamera(A.fov,A.aspect,
+A.near,A.far):"ortho"==A.type&&(N=new THREE.OrthographicCamera(A.left,A.right,A.top,A.bottom,A.near,A.far)),u=A.position,t=A.target,A=A.up,N.position.set(u[0],u[1],u[2]),N.target=new THREE.Vector3(t[0],t[1],t[2]),A&&N.up.set(A[0],A[1],A[2]),B.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)),B.scene.add(w),B.lights[o]=w;for(m in K.fogs)o=K.fogs[m],"linear"==o.type?T=new THREE.Fog(0,o.near,o.far):"exp2"==o.type&&(T=new THREE.FogExp2(0,o.density)),A=o.color,T.color.setRGB(A[0],A[1],A[2]),B.fogs[m]=T;if(B.cameras&&K.defaults.camera)B.currentCamera=B.cameras[K.defaults.camera];if(B.fogs&&K.defaults.fog)B.scene.fog=B.fogs[K.defaults.fog];A=K.defaults.bgcolor;
+B.bgColor=new THREE.Color;B.bgColor.setRGB(A[0],A[1],A[2]);B.bgColorAlpha=K.defaults.bgalpha;for(l in K.geometries)if(m=K.geometries[l],"bin_mesh"==m.type||"ascii_mesh"==m.type)M+=1,i.onLoadStart();j=M;for(l in K.geometries)if(m=K.geometries[l],"cube"==m.type)E=new THREE.CubeGeometry(m.width,m.height,m.depth,m.segmentsWidth,m.segmentsHeight,m.segmentsDepth,null,m.flipped,m.sides),B.geometries[l]=E;else if("plane"==m.type)E=new THREE.PlaneGeometry(m.width,m.height,m.segmentsWidth,m.segmentsHeight),
+B.geometries[l]=E;else if("sphere"==m.type)E=new THREE.SphereGeometry(m.radius,m.segmentsWidth,m.segmentsHeight),B.geometries[l]=E;else if("cylinder"==m.type)E=new THREE.CylinderGeometry(m.topRad,m.botRad,m.height,m.radSegs,m.heightSegs),B.geometries[l]=E;else if("torus"==m.type)E=new THREE.TorusGeometry(m.radius,m.tube,m.segmentsR,m.segmentsT),B.geometries[l]=E;else if("icosahedron"==m.type)E=new THREE.IcosahedronGeometry(m.radius,m.subdivisions),B.geometries[l]=E;else if("bin_mesh"==m.type)c.load(d(m.url,
+K.urlBaseType),g(l));else if("ascii_mesh"==m.type)P.load(d(m.url,K.urlBaseType),g(l));else if("embedded_mesh"==m.type)m=K.embeds[m.id],m.metadata=K.metadata,m&&P.createModel(m,f(l),"");for(r in K.textures)if(l=K.textures[r],l.url instanceof Array){H+=l.url.length;for(m=0;m<l.url.length;m++)i.onLoadStart()}else H+=1,i.onLoadStart();Y=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){m=[];for(T=0;T<l.url.length;T++)m[T]=
+d(l.url[T],K.urlBaseType);m=THREE.ImageUtils.loadTextureCube(m,l.mapping,a)}else{m=THREE.ImageUtils.loadTexture(d(l.url,K.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){T={repeat:THREE.RepeatWrapping,
+mirror:THREE.MirroredRepeatWrapping};if(void 0!==T[l.wrap[0]])m.wrapS=T[l.wrap[0]];if(void 0!==T[l.wrap[1]])m.wrapT=T[l.wrap[1]]}}B.textures[r]=m}for(p in K.materials){r=K.materials[p];for(C in r.parameters)if("envMap"==C||"map"==C||"lightMap"==C)r.parameters[C]=B.textures[r.parameters[C]];else if("shading"==C)r.parameters[C]="flat"==r.parameters[C]?THREE.FlatShading:THREE.SmoothShading;else if("blending"==C)r.parameters[C]=THREE[r.parameters[C]]?THREE[r.parameters[C]]:THREE.NormalBlending;else if("combine"==
+C)r.parameters[C]="MixOperation"==r.parameters[C]?THREE.MixOperation:THREE.MultiplyOperation;else if("vertexColors"==C)if("face"==r.parameters[C])r.parameters[C]=THREE.FaceColors;else if(r.parameters[C])r.parameters[C]=THREE.VertexColors;if(void 0!==r.parameters.opacity&&1>r.parameters.opacity)r.parameters.transparent=!0;if(r.parameters.normalMap){l=THREE.ShaderUtils.lib.normal;a=THREE.UniformsUtils.clone(l.uniforms);m=r.parameters.color;T=r.parameters.specular;c=r.parameters.ambient;P=r.parameters.shininess;
+a.tNormal.texture=B.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=B.textures[r.parameters.specularMap],a.enableSpecular.value=!0;a.uDiffuseColor.value.setHex(m);a.uSpecularColor.value.setHex(T);a.uAmbientColor.value.setHex(c);
+a.uShininess.value=P;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);B.materials[p]=J}e();i.callbackSync(B);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,g=void 0!==c.offsetX?c.offsetX:0,f=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,g,f,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 g=0,f=0;f<b;++f){var h=a.charCodeAt(f+d),g=g+(h>>1^-(h&1));c[8*f+e]=g}d+=b}b=a.length-d;g=new Uint16Array(b);for(e=f=0;e<b;e++)h=a.charCodeAt(e+d),g[e]=f-h,0==h&&f++;return[c,g]};
-THREE.UTF8Loader.prototype.createModel=function(a,b,c,d,e,g){var f=function(){var b=this;b.materials=[];THREE.Geometry.call(this);var f=THREE.UTF8Loader.prototype.decompressMesh(a),k=[],l=[];(function(a,f,i){for(var k,l,r,s=a.length;i<s;i+=f)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+=g,b.vertices.push(new THREE.Vertex(new THREE.Vector3(k,l,r)))})(f[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)})(f[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)})(f[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*
+THREE.UTF8Loader.prototype.createModel=function(a,b,c,d,e,g){var f=function(){var b=this;b.materials=[];THREE.Geometry.call(this);var f=THREE.UTF8Loader.prototype.decompressMesh(a),k=[],l=[];(function(a,f,i){for(var k,m,l,s=a.length;i<s;i+=f)k=a[i],m=a[i+1],l=a[i+2],k=k/16383*c,m=m/16383*c,l=l/16383*c,k+=d,m+=e,l+=g,b.vertices.push(new THREE.Vertex(new THREE.Vector3(k,m,l)))})(f[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)})(f[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)})(f[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],A=k[3*e+2],C=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,A);C=new THREE.Vector3(C,E,J);g.faces.push(new THREE.Face3(w,u,i,[t,y,C],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)}})(f[1]);this.computeCentroids();this.computeFaceNormals()};f.prototype=new THREE.Geometry;f.prototype.constructor=f;b(new f)};
 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,f,h,i,k,l,p){f=(f-l)/(p-l);l=this.normal_cache;b[g]=h+f*this.delta;b[g+1]=i;b[g+2]=k;e[g]=this.lerp(l[a],l[a+3],f);e[g+1]=this.lerp(l[a+1],l[a+4],f);e[g+2]=this.lerp(l[a+2],l[a+5],f)};this.VIntY=function(a,b,e,g,f,h,i,k,l,p){f=(f-l)/(p-l);l=this.normal_cache;b[g]=h;b[g+1]=i+f*this.delta;b[g+2]=k;b=a+3*this.yd;
 e[g]=this.lerp(l[a],l[b],f);e[g+1]=this.lerp(l[a+1],l[b+1],f);e[g+2]=this.lerp(l[a+2],l[b+2],f)};this.VIntZ=function(a,b,e,g,f,h,i,k,l,p){f=(f-l)/(p-l);l=this.normal_cache;b[g]=h;b[g+1]=i;b[g+2]=k+f*this.delta;b=a+3*this.zd;e[g]=this.lerp(l[a],l[b],f);e[g+1]=this.lerp(l[a+1],l[b+1],f);e[g+2]=this.lerp(l[a+2],l[b+2],f)};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,f,h){var i=g+1,k=g+this.yd,l=g+this.zd,p=i+this.yd,n=i+this.zd,o=g+this.yd+this.zd,q=i+this.yd+this.zd,m=0,r=this.field[g],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<f&&(m|=1);s<f&&(m|=2);t<f&&(m|=8);w<f&&(m|=4);u<f&&(m|=16);v<f&&(m|=32);A<f&&(m|=128);B<f&&(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(g),this.compNorm(i),this.VIntX(3*g,this.vlist,this.nlist,0,f,a,b,e,r,s));C&2&&(this.compNorm(i),this.compNorm(p),this.VIntY(3*i,this.vlist,this.nlist,3,f,I,b,e,s,w));C&4&&(this.compNorm(k),this.compNorm(p),this.VIntX(3*k,this.vlist,this.nlist,6,f,a,K,e,t,w));C&8&&(this.compNorm(g),this.compNorm(k),this.VIntY(3*g,this.vlist,this.nlist,9,f,a,b,e,r,t));C&16&&(this.compNorm(l),this.compNorm(n),this.VIntX(3*l,this.vlist,this.nlist,12,f,a,b,D,u,v));C&32&&(this.compNorm(n),
-this.compNorm(q),this.VIntY(3*n,this.vlist,this.nlist,15,f,I,b,D,v,B));C&64&&(this.compNorm(o),this.compNorm(q),this.VIntX(3*o,this.vlist,this.nlist,18,f,a,K,D,A,B));C&128&&(this.compNorm(l),this.compNorm(o),this.VIntY(3*l,this.vlist,this.nlist,21,f,a,b,D,u,A));C&256&&(this.compNorm(g),this.compNorm(l),this.VIntZ(3*g,this.vlist,this.nlist,24,f,a,b,e,r,u));C&512&&(this.compNorm(i),this.compNorm(n),this.VIntZ(3*i,this.vlist,this.nlist,27,f,I,b,e,s,v));C&1024&&(this.compNorm(p),this.compNorm(q),this.VIntZ(3*
-p,this.vlist,this.nlist,30,f,I,K,e,w,B));C&2048&&(this.compNorm(k),this.compNorm(o),this.VIntZ(3*k,this.vlist,this.nlist,33,f,a,K,e,t,A));m<<=4;for(f=g=0;-1!=THREE.triTable[m+f];)a=m+f,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),f+=3,g++;return g};this.posnormtriv=function(a,b,e,g,f,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[g];this.positionArray[i+
+this.normal_cache[b+2]=this.field[a-this.zd]-this.field[a+this.zd])};this.polygonize=function(a,b,e,g,f,h){var i=g+1,k=g+this.yd,l=g+this.zd,p=i+this.yd,n=i+this.zd,o=g+this.yd+this.zd,q=i+this.yd+this.zd,m=0,r=this.field[g],s=this.field[i],t=this.field[k],w=this.field[p],u=this.field[l],v=this.field[n],y=this.field[o],D=this.field[q];r<f&&(m|=1);s<f&&(m|=2);t<f&&(m|=8);w<f&&(m|=4);u<f&&(m|=16);v<f&&(m|=32);y<f&&(m|=128);D<f&&(m|=64);var A=THREE.edgeTable[m];if(0===A)return 0;var C=this.delta,E=a+
+C,J=b+C,C=e+C;A&1&&(this.compNorm(g),this.compNorm(i),this.VIntX(3*g,this.vlist,this.nlist,0,f,a,b,e,r,s));A&2&&(this.compNorm(i),this.compNorm(p),this.VIntY(3*i,this.vlist,this.nlist,3,f,E,b,e,s,w));A&4&&(this.compNorm(k),this.compNorm(p),this.VIntX(3*k,this.vlist,this.nlist,6,f,a,J,e,t,w));A&8&&(this.compNorm(g),this.compNorm(k),this.VIntY(3*g,this.vlist,this.nlist,9,f,a,b,e,r,t));A&16&&(this.compNorm(l),this.compNorm(n),this.VIntX(3*l,this.vlist,this.nlist,12,f,a,b,C,u,v));A&32&&(this.compNorm(n),
+this.compNorm(q),this.VIntY(3*n,this.vlist,this.nlist,15,f,E,b,C,v,D));A&64&&(this.compNorm(o),this.compNorm(q),this.VIntX(3*o,this.vlist,this.nlist,18,f,a,J,C,y,D));A&128&&(this.compNorm(l),this.compNorm(o),this.VIntY(3*l,this.vlist,this.nlist,21,f,a,b,C,u,y));A&256&&(this.compNorm(g),this.compNorm(l),this.VIntZ(3*g,this.vlist,this.nlist,24,f,a,b,e,r,u));A&512&&(this.compNorm(i),this.compNorm(n),this.VIntZ(3*i,this.vlist,this.nlist,27,f,E,b,e,s,v));A&1024&&(this.compNorm(p),this.compNorm(q),this.VIntZ(3*
+p,this.vlist,this.nlist,30,f,E,J,e,w,D));A&2048&&(this.compNorm(k),this.compNorm(o),this.VIntZ(3*k,this.vlist,this.nlist,33,f,a,J,e,t,y));m<<=4;for(f=g=0;-1!=THREE.triTable[m+f];)a=m+f,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),f+=3,g++;return g};this.posnormtriv=function(a,b,e,g,f,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[g];this.positionArray[i+
 4]=a[g+1];this.positionArray[i+5]=a[g+2];this.positionArray[i+6]=a[f];this.positionArray[i+7]=a[f+1];this.positionArray[i+8]=a[f+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[g];this.normalArray[i+4]=b[g+1];this.normalArray[i+5]=b[g+2];this.normalArray[i+6]=b[f];this.normalArray[i+7]=b[f+1];this.normalArray[i+8]=b[f+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,g,f){var h=this.size*Math.sqrt(g/f),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=g/(1.0E-6+s*s+u+w)-f,0<s&&(this.field[m+q]+=s)}}};this.addPlaneX=function(a,b){var e,g,f,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(g=e/k,g*=g,h=a/(1.0E-4+g)-b,0<h)for(g=0;g<k;g++){i=e+g*l;for(f=0;f<k;f++)n[p*f+i]+=h}};this.addPlaneY=function(a,b){var e,g,f,h,i,k,l=this.size,p=this.yd,
@@ -754,11 +754,11 @@ THREE.LensFlarePlugin=function(){function a(a){var c=b.createProgram(),d=b.creat
 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();f=b.createBuffer();b.bindBuffer(b.ARRAY_BUFFER,g);b.bufferData(b.ARRAY_BUFFER,d,b.STATIC_DRAW);b.bindBuffer(b.ELEMENT_ARRAY_BUFFER,f);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={};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,g);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,f);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)}}};
+"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,y=0.5*s,D=16/s,A=new THREE.Vector2(D*u,D),C=new THREE.Vector3(1,1,0),E=new THREE.Vector2(1,1),J=n,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,g);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,f);b.disable(b.CULL_FACE);b.depthMask(!1);var N,T,K,P,M;for(N=0;N<t;N++)if(D=16/s,A.set(D*u,D),P=a[N],w.set(P.matrixWorld.n14,P.matrixWorld.n24,P.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(w),d.projectionMatrix.multiplyVector3(w),C.copy(w),E.x=C.x*v+v,E.y=C.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,A.x,A.y);b.uniform3f(J.screenPosition,C.x,C.y,C.z);b.disable(b.BLEND);b.enable(b.DEPTH_TEST);b.drawElements(b.TRIANGLES,6,b.UNSIGNED_SHORT,0);b.activeTexture(b.TEXTURE0);b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGBA,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);P.positionScreen.copy(C);P.customUpdateCallback?P.customUpdateCallback(P):P.updateLensFlares();b.uniform1i(J.renderType,2);b.enable(b.BLEND);for(T=0,K=P.lensFlares.length;T<K;T++)if(M=P.lensFlares[T],0.001<M.opacity&&0.001<M.scale)C.x=M.x,C.y=M.y,C.z=M.z,D=M.size*M.scale/s,A.x=D*u,A.y=D,b.uniform3f(J.screenPosition,C.x,C.y,C.z),b.uniform2f(J.scale,A.x,A.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)}}};
 THREE.ShadowMapPlugin=function(){var a,b,c,d,e=new THREE.Frustum,g=new THREE.Matrix4,f=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,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=
@@ -775,13 +775,13 @@ THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,e,g,f,h,i
 f);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,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,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,f);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)}}};
+!1,e._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(s.map,0);for(var v,y=[],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),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,g=new THREE.PerspectiveCamera,f=new THREE.Matrix4,h=new THREE.Matrix4,i,k,l,p;e.matrixAutoUpdate=g.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;f.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);g.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);g.matrixWorld.copy(c.matrixWorld).multiplySelf(f);g.position.copy(c.position);g.near=c.near;g.far=c.far;d.call(b,a,g,o,!0);m.updateMatrixWorld();d.call(b,m,q)}};
+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),y;f.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);g.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);g.matrixWorld.copy(c.matrixWorld).multiplySelf(f);g.position.copy(c.position);g.near=c.near;g.far=c.far;d.call(b,a,g,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,g,f=new THREE.PerspectiveCamera;f.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;g=d};this.render=function(a,c){this.clear();f.fov=c.fov;f.aspect=0.5*c.aspect;f.near=c.near;f.far=
 c.far;f.updateProjectionMatrix();f.position.copy(c.position);f.target.copy(c.target);f.translateX(b.separation);f.lookAt(f.target);h.projectionMatrix=f.projectionMatrix;h.position.copy(c.position);h.target.copy(c.target);h.translateX(-b.separation);h.lookAt(h.target);this.setViewport(0,0,e,g);d.call(b,a,f);this.setViewport(e,0,e,g);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}"},

+ 48 - 47
build/custom/ThreeCanvas.js

@@ -18,11 +18,11 @@ 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){k.sub(c,a);q=k.dot(b);x=p.add(a,i.copy(b).multiplyScalar(q));return v=c.distanceTo(x)}function d(a,b,c,d){k.sub(d,b);p.sub(c,b);i.sub(a,b);I=k.dot(k);G=k.dot(p);w=k.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.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]));
+THREE.Ray=function(a,b){function c(a,b,c){k.sub(c,a);q=k.dot(b);x=p.add(a,i.copy(b).multiplyScalar(q));return v=c.distanceTo(x)}function d(a,b,c,d){k.sub(d,b);p.sub(c,b);i.sub(a,b);H=k.dot(k);E=k.dot(p);t=k.dot(i);G=p.dot(p);z=p.dot(i);F=1/(H*G-E*E);s=(G*t-E*z)*F;u=(H*z-E*t)*F;return 0<=s&&0<=u&&1>s+u}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;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,j=new THREE.Vector3,l=new THREE.Vector3,o=new THREE.Vector3,n=new THREE.Vector3;this.intersectObject=function(a){var b,i=[];if(a instanceof THREE.Particle){var k=c(this.origin,this.direction,a.matrixWorld.getPosition());if(k>a.scale.x)return[];b={distance:k,point:a.position,face:null,object:a};i.push(b)}else if(a instanceof THREE.Mesh){var k=
-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(k>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(k=0,p=s.faces.length;k<p;k++)if(b=s.faces[k],m.copy(this.origin),j.copy(this.direction),t=a.matrixWorld,l=t.multiplyVector3(l.copy(b.centroid)).subSelf(m),
-o=a.matrixRotationWorld.multiplyVector3(o.copy(b.normal)),q=j.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,j.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 k=new THREE.Vector3,p=new THREE.Vector3,i=new THREE.Vector3,q,x,v,I,G,w,H,A,F,r,s};
+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(k>a.geometry.boundingSphere.radius*Math.max(p.x,Math.max(p.y,p.z)))return i;var q,s,u=a.geometry,t=u.vertices,D;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(k=0,p=u.faces.length;k<p;k++)if(b=u.faces[k],m.copy(this.origin),j.copy(this.direction),D=a.matrixWorld,l=D.multiplyVector3(l.copy(b.centroid)).subSelf(m),
+o=a.matrixRotationWorld.multiplyVector3(o.copy(b.normal)),q=j.dot(o),!(1.0E-4>Math.abs(q))&&(s=o.dot(l)/q,!(0>s)&&(a.doubleSided||(a.flipSided?0<q:0>q))))if(n.add(m,j.multiplyScalar(s)),b instanceof THREE.Face3)e=D.multiplyVector3(e.copy(t[b.a].position)),f=D.multiplyVector3(f.copy(t[b.b].position)),g=D.multiplyVector3(g.copy(t[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=D.multiplyVector3(e.copy(t[b.a].position)),
+f=D.multiplyVector3(f.copy(t[b.b].position)),g=D.multiplyVector3(g.copy(t[b.c].position)),h=D.multiplyVector3(h.copy(t[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 k=new THREE.Vector3,p=new THREE.Vector3,i=new THREE.Vector3,q,x,v,H,E,t,G,z,F,s,u};
 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,k){h?(h=!1,b=f<l?f<n?f:n:l<n?l:n,c=g<o?g<k?g:k:o<k?o:k,d=f>l?f>n?f:n:l>n?l:n,e=g>o?g>k?g:k:o>k?o:k):(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<k?g<c?g:c:k<c?k:c:o<k?o<c?o:c:k<c?k: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>k?g>e?g:e:k>e?k:e:o>k?o>e?o: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}};
@@ -31,8 +31,8 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=
 THREE.Matrix4=function(a,b,c,d,e,f,g,h,m,j,l,o,n,k,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,j||0,void 0!==l?l:1,o||0,n||0,k||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,j,l,o,n,k,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=j;this.n33=l;this.n34=o;this.n41=n;this.n42=k;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,j=a.n24,l=a.n31,o=a.n32,n=a.n33,k=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+j*ca;this.n22=g*I+h*A+m*D+j*N;this.n23=g*G+h*F+m*J+j*P;this.n24=g*w+h*r+m*Z+j*S;this.n31=l*v+o*H+n*s+k*ca;this.n32=l*I+o*A+n*D+k*N;this.n33=l*G+o*F+n*J+k*P;this.n34=l*w+o*r+n*Z+k*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*=
+x=a.n44,v=b.n11,H=b.n12,E=b.n13,t=b.n14,G=b.n21,z=b.n22,F=b.n23,s=b.n24,u=b.n31,C=b.n32,J=b.n33,Z=b.n34,ca=b.n41,M=b.n42,O=b.n43,S=b.n44;this.n11=c*v+d*G+e*u+f*ca;this.n12=c*H+d*z+e*C+f*M;this.n13=c*E+d*F+e*J+f*O;this.n14=c*t+d*s+e*Z+f*S;this.n21=g*v+h*G+m*u+j*ca;this.n22=g*H+h*z+m*C+j*M;this.n23=g*E+h*F+m*J+j*O;this.n24=g*t+h*s+m*Z+j*S;this.n31=l*v+o*G+n*u+k*ca;this.n32=l*H+o*z+n*C+k*M;this.n33=l*E+o*F+n*J+k*O;this.n34=l*t+o*s+n*Z+k*S;this.n41=p*v+i*G+q*u+x*ca;this.n42=p*H+i*z+q*C+x*M;this.n43=p*
+E+i*F+q*J+x*O;this.n44=p*t+i*s+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,h=this.n24,m=this.n31,j=this.n32,l=this.n33,o=this.n34,n=this.n41,k=this.n42,p=this.n43,i=this.n44;return d*g*j*n-c*h*j*n-d*f*l*n+b*h*l*n+c*f*o*n-b*g*o*n-d*g*m*k+c*h*m*k+d*e*l*k-a*h*l*k-c*e*o*k+a*g*o*k+d*f*m*p-b*h*m*p-d*e*j*p+a*h*j*p+b*e*o*p-a*f*o*p-c*f*m*i+b*g*m*i+c*e*j*i-a*g*j*i-b*e*l*i+a*f*l*i},transpose:function(){var a;
@@ -49,8 +49,8 @@ e,l=c*h,o=c*e,this.n11=g*h,this.n12=-g*e,this.n13=d,this.n21=j+l*d,this.n22=m-o*
 a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);f.set(this.n13,
 this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();c.y=e.length();c.z=f.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
 return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this},rotateByAxis:function(a,b){if(1===a.x&&0===a.y&&0===a.z)return this.rotateX(b);if(0===a.x&&1===a.y&&0===a.z)return this.rotateY(b);if(0===a.x&&0===a.y&&1===
-a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e),c=c/f,d=d/f,e=e/f,f=c*c,g=d*d,h=e*e,m=Math.cos(b),j=Math.sin(b),l=1-m,o=c*d*l,n=c*e*l,l=d*e*l,c=c*j,k=d*j,j=e*j,e=f+(1-f)*m,f=o+j,d=n-k,o=o-j,g=g+(1-g)*m,j=l+c,n=n+k,l=l-c,h=h+(1-h)*m,m=this.n11,c=this.n21,k=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*k+f*x+d*w;this.n41=e*p+f*v+d*H;this.n12=o*m+g*i+j*I;this.n22=
-o*c+g*q+j*G;this.n32=o*k+g*x+j*w;this.n42=o*p+g*v+j*H;this.n13=n*m+l*i+h*I;this.n23=n*c+l*q+h*G;this.n33=n*k+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,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*m;this.n13=j*f-a*b;this.n23=j*g-a*c;this.n33=j*h-a*d;this.n43=j*m-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,
+a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e),c=c/f,d=d/f,e=e/f,f=c*c,g=d*d,h=e*e,m=Math.cos(b),j=Math.sin(b),l=1-m,o=c*d*l,n=c*e*l,l=d*e*l,c=c*j,k=d*j,j=e*j,e=f+(1-f)*m,f=o+j,d=n-k,o=o-j,g=g+(1-g)*m,j=l+c,n=n+k,l=l-c,h=h+(1-h)*m,m=this.n11,c=this.n21,k=this.n31,p=this.n41,i=this.n12,q=this.n22,x=this.n32,v=this.n42,H=this.n13,E=this.n23,t=this.n33,G=this.n43;this.n11=e*m+f*i+d*H;this.n21=e*c+f*q+d*E;this.n31=e*k+f*x+d*t;this.n41=e*p+f*v+d*G;this.n12=o*m+g*i+j*H;this.n22=
+o*c+g*q+j*E;this.n32=o*k+g*x+j*t;this.n42=o*p+g*v+j*G;this.n13=n*m+l*i+h*H;this.n23=n*c+l*q+h*E;this.n33=n*k+l*x+h*t;this.n43=n*p+l*v+h*G;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,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*m;this.n13=j*f-a*b;this.n23=j*g-a*c;this.n33=j*h-a*d;this.n43=j*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,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*m;this.n13=j*f+a*b;this.n23=j*g+a*c;this.n33=j*h+a*d;this.n43=j*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,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*m;this.n12=j*f-a*b;this.n22=j*g-a*c;this.n32=j*h-a*d;this.n42=j*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,h=a.n33*a.n11-a.n31*a.n13,m=-a.n32*a.n11+a.n31*a.n12,j=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*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*m;c[6]=a*j;c[7]=a*l;c[8]=a*o;return b};
@@ -63,22 +63,23 @@ 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=j[m]=j[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,j=[],l,o,n=[],k,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=k=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++)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=j[t.a],O=j[t.b],M=j[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=j[t.a],O=j[t.b],M=j[t.c],V=j[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[k]=p[k]||new THREE.RenderableFace4,k++,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=j[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};
+var e,f,g=[],h,m,j=[],l,o,n=[],k,p=[],i,q,x=[],v,H,E=[],t={objects:[],sprites:[],lights:[],elements:[]},G=new THREE.Vector3,z=new THREE.Vector4,F=new THREE.Matrix4,s=new THREE.Matrix4,u=new THREE.Frustum,C=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;t.objects.length=0;t.sprites.length=0;t.lights.length=0;var g=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||u.contains(b))?(F.multiplyVector3(G.copy(b.position)),e=a(),e.object=
+b,e.z=G.z,t.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(F.multiplyVector3(G.copy(b.position)),e=a(),e.object=b,e.z=G.z,t.sprites.push(e)):b instanceof THREE.Light&&t.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&t.objects.sort(c);return t};this.projectScene=function(a,e,f){var g=e.near,G=e.far,P=!1,T,D,I,Q,A,N,L,U,r,y,w,B,K,ka,ea;H=q=k=o=0;t.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);u.setFromMatrix(F);t=this.projectGraph(a,!1);for(a=0,T=t.objects.length;a<T;a++)if(r=t.objects[a].object,y=r.matrixWorld,m=0,r instanceof THREE.Mesh){w=r.geometry;B=r.geometry.materials;Q=w.vertices;K=w.faces;ka=w.faceVertexUvs;w=r.matrixRotationWorld.extractRotation(y);for(D=0,I=Q.length;D<I;D++)h=b(),h.positionWorld.copy(Q[D].position),y.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<G;for(Q=0,D=K.length;Q<D;Q++){I=K[Q];if(I instanceof THREE.Face3)if(A=j[I.a],N=j[I.b],L=j[I.c],A.visible&&N.visible&&L.visible)if(P=0>(L.positionScreen.x-A.positionScreen.x)*(N.positionScreen.y-A.positionScreen.y)-(L.positionScreen.y-A.positionScreen.y)*(N.positionScreen.x-A.positionScreen.x),r.doubleSided||
+P!=r.flipSided)U=n[o]=n[o]||new THREE.RenderableFace3,o++,l=U,l.v1.copy(A),l.v2.copy(N),l.v3.copy(L);else continue;else continue;else if(I instanceof THREE.Face4)if(A=j[I.a],N=j[I.b],L=j[I.c],U=j[I.d],A.visible&&N.visible&&L.visible&&U.visible)if(P=0>(U.positionScreen.x-A.positionScreen.x)*(N.positionScreen.y-A.positionScreen.y)-(U.positionScreen.y-A.positionScreen.y)*(N.positionScreen.x-A.positionScreen.x)||0>(N.positionScreen.x-L.positionScreen.x)*(U.positionScreen.y-L.positionScreen.y)-(N.positionScreen.y-
+L.positionScreen.y)*(U.positionScreen.x-L.positionScreen.x),r.doubleSided||P!=r.flipSided)ea=p[k]=p[k]||new THREE.RenderableFace4,k++,l=ea,l.v1.copy(A),l.v2.copy(N),l.v3.copy(L),l.v4.copy(U);else continue;else continue;l.normalWorld.copy(I.normal);!P&&(r.flipSided||r.doubleSided)&&l.normalWorld.negate();w.multiplyVector3(l.normalWorld);l.centroidWorld.copy(I.centroid);y.multiplyVector3(l.centroidWorld);l.centroidScreen.copy(l.centroidWorld);F.multiplyVector3(l.centroidScreen);L=I.vertexNormals;for(A=
+0,N=L.length;A<N;A++)U=l.vertexNormalsWorld[A],U.copy(L[A]),!P&&(r.flipSided||r.doubleSided)&&U.negate(),w.multiplyVector3(U);for(A=0,N=ka.length;A<N;A++)if(ea=ka[A][Q])for(L=0,U=ea.length;L<U;L++)l.uvs[A][L]=ea[L];l.material=r.material;l.faceMaterial=null!==I.materialIndex?B[I.materialIndex]:null;l.z=l.centroidScreen.z;t.elements.push(l)}}else if(r instanceof THREE.Line){s.multiply(F,y);Q=r.geometry.vertices;A=b();A.positionScreen.copy(Q[0].position);s.multiplyVector4(A.positionScreen);for(D=1,I=
+Q.length;D<I;D++)if(A=b(),A.positionScreen.copy(Q[D].position),s.multiplyVector4(A.positionScreen),N=j[m-2],C.copy(A.positionScreen),J.copy(N.positionScreen),d(C,J))C.multiplyScalar(1/C.w),J.multiplyScalar(1/J.w),y=x[q]=x[q]||new THREE.RenderableLine,q++,i=y,i.v1.positionScreen.copy(C),i.v2.positionScreen.copy(J),i.z=Math.max(C.z,J.z),i.material=r.material,t.elements.push(i)}for(a=0,T=t.sprites.length;a<T;a++)if(r=t.sprites[a].object,y=r.matrixWorld,r instanceof THREE.Particle&&(z.set(y.n14,y.n24,
+y.n34,1),F.multiplyVector4(z),z.z/=z.w,0<z.z&&1>z.z))g=E[H]=E[H]||new THREE.RenderableParticle,H++,v=g,v.x=z.x/z.w,v.y=z.y/z.w,v.z=z.z,v.rotation=r.rotation.z,v.scale.x=r.scale.x*Math.abs(v.x-(z.x+e.projectionMatrix.n11)/(z.w+e.projectionMatrix.n14)),v.scale.y=r.scale.y*Math.abs(v.y-(z.y+e.projectionMatrix.n22)/(z.w+e.projectionMatrix.n24)),v.material=r.material,t.elements.push(v);f&&t.elements.sort(c);return t}};
+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,m=this.w,j=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=j*m+c*-f+l*-h-o*-g;b.y=l*m+c*-g+o*-f-j*-h;b.z=o*m+c*-h+j*-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.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.001>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};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
@@ -91,15 +92,15 @@ d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));for(
 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,j;for(c=0,d=this.faces.length;c<d;c++)e=this.faces[c],m=new THREE.Vector3,j=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(j)}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],j=g.vertexNormals[c],m.copy(e.normal),e instanceof THREE.Face3?(j.a.copy(e.vertexNormals[0]),j.b.copy(e.vertexNormals[1]),j.c.copy(e.vertexNormals[2])):(j.a.copy(e.vertexNormals[0]),j.b.copy(e.vertexNormals[1]),j.c.copy(e.vertexNormals[2]),j.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;j=a.vertices[d].position;l=g[e];o=g[f];n=g[F];k=m.x-h.x;p=j.x-h.x;i=m.y-h.y;q=j.y-h.y;x=m.z-h.z;v=j.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*k-w*p)*A,(H*i-w*q)*A,(H*x-w*v)*A);J.set((I*p-G*k)*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,j,l,o,n,k,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<
+b,c,d,e,f,A){h=a.vertices[b].position;m=a.vertices[c].position;j=a.vertices[d].position;l=g[e];o=g[f];n=g[A];k=m.x-h.x;p=j.x-h.x;i=m.y-h.y;q=j.y-h.y;x=m.z-h.z;v=j.z-h.z;H=o.u-l.u;E=n.u-l.u;t=o.v-l.v;G=n.v-l.v;z=1/(H*G-E*t);C.set((G*k-t*p)*z,(G*i-t*q)*z,(G*x-t*v)*z);J.set((H*p-E*k)*z,(H*q-E*i)*z,(H*v-E*x)*z);s[b].addSelf(C);s[c].addSelf(C);s[d].addSelf(C);u[b].addSelf(J);u[c].addSelf(J);u[d].addSelf(J)}var b,c,d,e,f,g,h,m,j,l,o,n,k,p,i,q,x,v,H,E,t,G,z,F,s=[],u=[],C=new THREE.Vector3,J=new THREE.Vector3,
+Z=new THREE.Vector3,ca=new THREE.Vector3,M=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)s[b]=new THREE.Vector3,u[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 O=["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++)M.copy(f.vertexNormals[d]),e=f[O[d]],
+F=s[e],Z.copy(F),Z.subSelf(M.multiplyScalar(M.dot(F))).normalize(),ca.cross(f.vertexNormals[d],F),e=ca.dot(u[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;
-THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:43.25)/(2*a));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
+THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:24)/(2*a))*(180/Math.PI);this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
 THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
 this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0;this.onlyShadow=this.castShadow=!1;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraLeft=-500;this.shadowCameraTop=this.shadowCameraRight=500;this.shadowCameraBottom=-500;this.shadowCameraVisible=!1;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCascade=
@@ -138,34 +139,34 @@ 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)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,j=new THREE.Projector,l=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
-o,n,k,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;k=Math.floor(o/2);p=Math.floor(n/2);l.width=o;l.height=n;la.set(-k,-p,k,p);Y.set(-k,-p,k,p);v=1;I=0;
-F=A=H=w=G=null};this.setClearColor=function(a,b){q.copy(a);x=b;Y.set(-k,-p,k,p)};this.setClearColorHex=function(a,b){q.setHex(a);x=b;Y.set(-k,-p,k,p)};this.clear=function(){i.setTransform(1,0,0,-1,k,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()),
+THREE.CanvasRenderer=function(a){function b(a){if(v!=a)i.globalAlpha=v=a}function c(a){if(H!=a){switch(a){case THREE.NormalBlending:i.globalCompositeOperation="source-over";break;case THREE.AdditiveBlending:i.globalCompositeOperation="lighter";break;case THREE.SubtractiveBlending:i.globalCompositeOperation="darker"}H=a}}function d(a){if(E!=a)i.strokeStyle=E=a}function e(a){if(t!=a)i.fillStyle=t=a}var a=a||{},f=this,g,h,m,j=new THREE.Projector,l=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
+o,n,k,p,i=l.getContext("2d"),q=new THREE.Color(0),x=0,v=1,H=0,E=null,t=null,G=null,z=null,F=null,s,u,C,J,Z=new THREE.RenderableVertex,ca=new THREE.RenderableVertex,M,O,S,P,T,D,I,Q,A,N,L,U,r=new THREE.Color,y=new THREE.Color,w=new THREE.Color,B=new THREE.Color,K=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;k=Math.floor(o/2);p=Math.floor(n/2);l.width=o;l.height=n;la.set(-k,-p,k,p);Y.set(-k,-p,k,p);v=1;H=0;
+F=z=G=t=E=null};this.setClearColor=function(a,b){q.copy(a);x=b;Y.set(-k,-p,k,p)};this.setClearColorHex=function(a,b){q.setHex(a);x=b;Y.set(-k,-p,k,p)};this.clear=function(){i.setTransform(1,0,0,-1,k,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,j,l;for(e=0,f=a.length;e<f;e++)g=a[e],h=g.color,
 g instanceof THREE.DirectionalLight?(j=g.matrixWorld.getPosition(),l=c.dot(j),0>=l||(l*=g.intensity,d.r+=h.r*l,d.g+=h.g*l,d.b+=h.b*l)):g instanceof THREE.PointLight&&(j=g.matrixWorld.getPosition(),l=c.dot(R.sub(j,b).normalize()),0>=l||(l*=0==g.distance?1:1-Math.min(b.distanceTo(j)/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,j,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*k,j=f.scale.y*p,h=g*za,l=j*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,-j),i.translate(-za,-o),i.drawImage(m,0,0),i.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=f.scale.x*k,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,j,i,k){f.info.render.vertices+=3;f.info.render.faces++;b(k.opacity);c(k.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(k instanceof THREE.MeshBasicMaterial)if(k.map)k.map.mapping instanceof THREE.UVMapping&&($=i.uvs[0],Aa(N,P,S,T,E,t,$[g].u,$[g].v,$[h].u,$[h].v,$[j].u,$[j].v,k.map));else if(k.envMap){if(k.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[j]),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,k.envMap)}else k.wireframe?ia(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ha(k.color);else if(k instanceof THREE.MeshLambertMaterial)k.map&&!k.wireframe&&(k.map.mapping instanceof THREE.UVMapping&&($=i.uvs[0],Aa(N,P,S,T,E,t,$[g].u,$[g].v,
-$[h].u,$[h].v,$[j].u,$[j].v,k.map)),c(THREE.SubtractiveBlending)),xa?!k.wireframe&&k.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(k.color.r*C.r,1)),C.g=Math.max(0,Math.min(k.color.g*C.g,1)),C.b=Math.max(0,Math.min(k.color.b*C.b,1)),z.r=Math.max(0,Math.min(k.color.r*
-z.r,1)),z.g=Math.max(0,Math.min(k.color.g*z.g,1)),z.b=Math.max(0,Math.min(k.color.b*z.b,1)),B.r=Math.max(0,Math.min(k.color.r*B.r,1)),B.g=Math.max(0,Math.min(k.color.g*B.g,1)),B.b=Math.max(0,Math.min(k.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(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)),k.wireframe?ia(u,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ha(u)):k.wireframe?ia(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ha(k.color);else if(k 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(k instanceof THREE.MeshNormalMaterial)u.r=
-qa(i.normalWorld.x),u.g=qa(i.normalWorld.y),u.b=qa(i.normalWorld.z),k.wireframe?ia(u,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ha(u)}function I(a,d,e,g,h,k,j,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,j,i,o),v(h,e,k,1,2,3,j,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=k.positionScreen.x,K=k.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==j.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,j.v1.positionWorld,j.vertexNormalsWorld[0],C),n(m,j.v2.positionWorld,j.vertexNormalsWorld[1],z),
-n(m,j.v4.positionWorld,j.vertexNormalsWorld[3],B),n(m,j.v3.positionWorld,j.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,j.centroidWorld,j.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(j.normalWorld.x),u.g=qa(j.normalWorld.y),u.b=qa(j.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,k,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]=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,k=(k+q)*s,c=c-a,d=d-
-b,f=f-a,g=g-b,j=(j+p)*r-h,l=(l+q)*s-k,m=(m+p)*r-h,o=(o+q)*s-k,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(k)*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*k,h=b-l*h-d*k,i.save(),i.transform(n,
+1,g=f.scale.x*k,j=f.scale.y*p,h=g*za,l=j*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,-j),i.translate(-za,-o),i.drawImage(m,0,0),i.restore())}else g instanceof THREE.ParticleCanvasMaterial&&(h=f.scale.x*k,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 t(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(G!=a)i.lineWidth=G=a;a=g.linecap;if(z!=a)i.lineCap=z=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,j,i,k){f.info.render.vertices+=3;f.info.render.faces++;b(k.opacity);c(k.blending);M=a.positionScreen.x;O=a.positionScreen.y;
+S=d.positionScreen.x;P=d.positionScreen.y;T=e.positionScreen.x;D=e.positionScreen.y;x(M,O,S,P,T,D);if(k instanceof THREE.MeshBasicMaterial)if(k.map)k.map.mapping instanceof THREE.UVMapping&&($=i.uvs[0],Aa(M,O,S,P,T,D,$[g].u,$[g].v,$[h].u,$[h].v,$[j].u,$[j].v,k.map));else if(k.envMap){if(k.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[j]),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(M,O,S,P,T,D,Ba,Ca,Da,Ea,Fa,Ga,k.envMap)}else k.wireframe?ia(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ha(k.color);else if(k instanceof THREE.MeshLambertMaterial)k.map&&!k.wireframe&&(k.map.mapping instanceof THREE.UVMapping&&($=i.uvs[0],Aa(M,O,S,P,T,D,$[g].u,$[g].v,
+$[h].u,$[h].v,$[j].u,$[j].v,k.map)),c(THREE.SubtractiveBlending)),xa?!k.wireframe&&k.shading==THREE.SmoothShading&&3==i.vertexNormalsWorld.length?(y.r=w.r=B.r=W.r,y.g=w.g=B.g=W.g,y.b=w.b=B.b=W.b,n(m,i.v1.positionWorld,i.vertexNormalsWorld[0],y),n(m,i.v2.positionWorld,i.vertexNormalsWorld[1],w),n(m,i.v3.positionWorld,i.vertexNormalsWorld[2],B),y.r=Math.max(0,Math.min(k.color.r*y.r,1)),y.g=Math.max(0,Math.min(k.color.g*y.g,1)),y.b=Math.max(0,Math.min(k.color.b*y.b,1)),w.r=Math.max(0,Math.min(k.color.r*
+w.r,1)),w.g=Math.max(0,Math.min(k.color.g*w.g,1)),w.b=Math.max(0,Math.min(k.color.b*w.b,1)),B.r=Math.max(0,Math.min(k.color.r*B.r,1)),B.g=Math.max(0,Math.min(k.color.g*B.g,1)),B.b=Math.max(0,Math.min(k.color.b*B.b,1)),K.r=0.5*(w.r+B.r),K.g=0.5*(w.g+B.g),K.b=0.5*(w.b+B.b),da=va(y,w,B,K),pa(M,O,S,P,T,D,0,0,1,0,0,1,da)):(r.r=W.r,r.g=W.g,r.b=W.b,n(m,i.centroidWorld,i.normalWorld,r),r.r=Math.max(0,Math.min(k.color.r*r.r,1)),r.g=Math.max(0,Math.min(k.color.g*r.g,1)),r.b=Math.max(0,Math.min(k.color.b*r.b,
+1)),k.wireframe?ia(r,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ha(r)):k.wireframe?ia(k.color,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ha(k.color);else if(k instanceof THREE.MeshDepthMaterial)fa=l.near,ga=l.far,y.r=y.g=y.b=1-oa(a.positionScreen.z,fa,ga),w.r=w.g=w.b=1-oa(d.positionScreen.z,fa,ga),B.r=B.g=B.b=1-oa(e.positionScreen.z,fa,ga),K.r=0.5*(w.r+B.r),K.g=0.5*(w.g+B.g),K.b=0.5*(w.b+B.b),da=va(y,w,B,K),pa(M,O,S,P,T,D,0,0,1,0,0,1,da);else if(k instanceof THREE.MeshNormalMaterial)r.r=
+qa(i.normalWorld.x),r.g=qa(i.normalWorld.y),r.b=qa(i.normalWorld.z),k.wireframe?ia(r,k.wireframeLinewidth,k.wireframeLinecap,k.wireframeLinejoin):ha(r)}function H(a,d,e,g,h,k,j,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,j,i,o),v(h,e,k,1,2,3,j,i,o);else if(M=a.positionScreen.x,O=a.positionScreen.y,S=d.positionScreen.x,P=d.positionScreen.y,T=e.positionScreen.x,D=e.positionScreen.y,I=g.positionScreen.x,Q=g.positionScreen.y,A=h.positionScreen.x,
+N=h.positionScreen.y,L=k.positionScreen.x,U=k.positionScreen.y,i instanceof THREE.MeshBasicMaterial)E(M,O,S,P,T,D,I,Q),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==j.vertexNormalsWorld.length?(y.r=w.r=B.r=K.r=W.r,y.g=w.g=B.g=K.g=W.g,y.b=w.b=B.b=K.b=W.b,n(m,j.v1.positionWorld,j.vertexNormalsWorld[0],y),n(m,j.v2.positionWorld,j.vertexNormalsWorld[1],w),
+n(m,j.v4.positionWorld,j.vertexNormalsWorld[3],B),n(m,j.v3.positionWorld,j.vertexNormalsWorld[2],K),y.r=Math.max(0,Math.min(i.color.r*y.r,1)),y.g=Math.max(0,Math.min(i.color.g*y.g,1)),y.b=Math.max(0,Math.min(i.color.b*y.b,1)),w.r=Math.max(0,Math.min(i.color.r*w.r,1)),w.g=Math.max(0,Math.min(i.color.g*w.g,1)),w.b=Math.max(0,Math.min(i.color.b*w.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)),K.r=Math.max(0,Math.min(i.color.r*
+K.r,1)),K.g=Math.max(0,Math.min(i.color.g*K.g,1)),K.b=Math.max(0,Math.min(i.color.b*K.b,1)),da=va(y,w,B,K),x(M,O,S,P,I,Q),pa(M,O,S,P,I,Q,0,0,1,0,0,1,da),x(A,N,T,D,L,U),pa(A,N,T,D,L,U,1,0,1,1,0,1,da)):(r.r=W.r,r.g=W.g,r.b=W.b,n(m,j.centroidWorld,j.normalWorld,r),r.r=Math.max(0,Math.min(i.color.r*r.r,1)),r.g=Math.max(0,Math.min(i.color.g*r.g,1)),r.b=Math.max(0,Math.min(i.color.b*r.b,1)),E(M,O,S,P,T,D,I,Q),i.wireframe?ia(r,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(r)):(E(M,O,S,
+P,T,D,I,Q),i.wireframe?ia(i.color,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(i.color));else if(i instanceof THREE.MeshNormalMaterial)r.r=qa(j.normalWorld.x),r.g=qa(j.normalWorld.y),r.b=qa(j.normalWorld.z),E(M,O,S,P,T,D,I,Q),i.wireframe?ia(r,i.wireframeLinewidth,i.wireframeLinecap,i.wireframeLinejoin):ha(r);else if(i instanceof THREE.MeshDepthMaterial)fa=l.near,ga=l.far,y.r=y.g=y.b=1-oa(a.positionScreen.z,fa,ga),w.r=w.g=w.b=1-oa(d.positionScreen.z,fa,ga),B.r=B.g=B.b=1-oa(g.positionScreen.z,
+fa,ga),K.r=K.g=K.b=1-oa(e.positionScreen.z,fa,ga),da=va(y,w,B,K),x(M,O,S,P,I,Q),pa(M,O,S,P,I,Q,0,0,1,0,0,1,da),x(A,N,T,D,L,U),pa(A,N,T,D,L,U,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 E(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(G!=b)i.lineWidth=G=b;if(z!=c)i.lineCap=z=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,k,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]=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,s=n.image.width*n.repeat.x,t=n.image.height*n.repeat.y,h=(h+p)*s,k=(k+q)*t,c=c-a,d=d-
+b,f=f-a,g=g-b,j=(j+p)*s-h,l=(l+q)*t-k,m=(m+p)*s-h,o=(o+q)*t-k,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(k)*n.image.width);r.setRGB(b[h]/255,b[h+1]/255,b[h+2]/255);ha(r)}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*k,h=b-l*h-d*k,i.save(),i.transform(n,
 l,c,d,a,h),i.fill(),i.restore()}}function pa(a,b,c,d,e,f,g,h,k,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;k=k*o-g;j=j*p-h;l=l*o-g;m=m*p-h;p=1/(k*m-l*j);o=(m*c-j*e)*p;j=(m*d-j*f)*p;c=(k*e-l*c)*p;d=(k*f-l*d)*p;a=a-o*g-c*h;b=b-j*g-d*h;i.save();i.transform(o,j,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():i.setTransform(1,0,0,-1,k,p);f.info.render.vertices=0;f.info.render.faces=0;g=j.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*=k,r.y*=p,q(r,
-U,ba,a);else if(U instanceof THREE.RenderableLine)r=U.v1,s=U.v2,r.positionScreen.x*=k,r.positionScreen.y*=p,s.positionScreen.x*=k,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*=k,r.positionScreen.y*=p,s.positionScreen.x*=k,s.positionScreen.y*=p,D.positionScreen.x*=k,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*=k,r.positionScreen.y*=p,s.positionScreen.x*=k,s.positionScreen.y*=p,D.positionScreen.x*=k,D.positionScreen.y*=p,J.positionScreen.x*=k,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)}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)};
+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,V,ba;this.autoClear?this.clear():i.setTransform(1,0,0,-1,k,p);f.info.render.vertices=0;f.info.render.faces=0;g=j.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(V=h[wa],ba=V.material,ba=ba instanceof THREE.MeshFaceMaterial?V.faceMaterial:ba,!(null==ba||0==ba.opacity)){X.empty();if(V instanceof THREE.RenderableParticle)s=V,s.x*=k,s.y*=p,q(s,
+V,ba,a);else if(V instanceof THREE.RenderableLine)s=V.v1,u=V.v2,s.positionScreen.x*=k,s.positionScreen.y*=p,u.positionScreen.x*=k,u.positionScreen.y*=p,X.addPoint(s.positionScreen.x,s.positionScreen.y),X.addPoint(u.positionScreen.x,u.positionScreen.y),la.intersects(X)&&t(s,u,V,ba,a);else if(V instanceof THREE.RenderableFace3)s=V.v1,u=V.v2,C=V.v3,s.positionScreen.x*=k,s.positionScreen.y*=p,u.positionScreen.x*=k,u.positionScreen.y*=p,C.positionScreen.x*=k,C.positionScreen.y*=p,ba.overdraw&&(ja(s.positionScreen,
+u.positionScreen),ja(u.positionScreen,C.positionScreen),ja(C.positionScreen,s.positionScreen)),X.add3Points(s.positionScreen.x,s.positionScreen.y,u.positionScreen.x,u.positionScreen.y,C.positionScreen.x,C.positionScreen.y),la.intersects(X)&&v(s,u,C,0,1,2,V,ba,a);else if(V instanceof THREE.RenderableFace4)s=V.v1,u=V.v2,C=V.v3,J=V.v4,s.positionScreen.x*=k,s.positionScreen.y*=p,u.positionScreen.x*=k,u.positionScreen.y*=p,C.positionScreen.x*=k,C.positionScreen.y*=p,J.positionScreen.x*=k,J.positionScreen.y*=
+p,Z.positionScreen.copy(u.positionScreen),ca.positionScreen.copy(J.positionScreen),ba.overdraw&&(ja(s.positionScreen,u.positionScreen),ja(u.positionScreen,J.positionScreen),ja(J.positionScreen,s.positionScreen),ja(C.positionScreen,Z.positionScreen),ja(C.positionScreen,ca.positionScreen)),X.addPoint(s.positionScreen.x,s.positionScreen.y),X.addPoint(u.positionScreen.x,u.positionScreen.y),X.addPoint(C.positionScreen.x,C.positionScreen.y),X.addPoint(J.positionScreen.x,J.positionScreen.y),la.intersects(X)&&
+H(s,u,C,J,Z,ca,V,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};

+ 23 - 23
build/custom/ThreeDOM.js

@@ -18,11 +18,11 @@ 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){m.sub(c,a);p=m.dot(b);v=q.add(a,o.copy(b).multiplyScalar(p));return r=c.distanceTo(v)}function d(a,b,c,d){m.sub(d,b);q.sub(c,b);o.sub(a,b);w=m.dot(m);D=m.dot(q);s=m.dot(o);B=q.dot(q);x=q.dot(o);z=1/(w*B-D*D);F=(B*s-D*x)*z;J=(w*x-D*s)*z;return 0<=F&&0<=J&&1>F+J}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.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]));
+THREE.Ray=function(a,b){function c(a,b,c){m.sub(c,a);p=m.dot(b);s=q.add(a,o.copy(b).multiplyScalar(p));return r=c.distanceTo(s)}function d(a,b,c,d){m.sub(d,b);q.sub(c,b);o.sub(a,b);v=m.dot(m);D=m.dot(q);t=m.dot(o);A=q.dot(q);w=q.dot(o);y=1/(v*A-D*D);F=(A*t-D*w)*y;J=(v*w-D*t)*y;return 0<=F&&0<=J&&1>F+J}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;this.intersectObjects=function(a){var b,c,d=[];for(b=0,c=a.length;b<c;b++)Array.prototype.push.apply(d,this.intersectObject(a[b]));
 d.sort(function(a,b){return a.distance-b.distance});return d};var e=new THREE.Vector3,f=new THREE.Vector3,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,i=new THREE.Vector3,j=new THREE.Vector3,l=new THREE.Vector3,n=new THREE.Vector3;this.intersectObject=function(a){var b,m=[];if(a instanceof THREE.Particle){var 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){var 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 m;var q,r,s=a.geometry,w=s.vertices,u;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,p=s.faces.length;o<p;o++)if(b=s.faces[o],k.copy(this.origin),i.copy(this.direction),u=a.matrixWorld,j=u.multiplyVector3(j.copy(b.centroid)).subSelf(k),
-l=a.matrixRotationWorld.multiplyVector3(l.copy(b.normal)),q=i.dot(l),!(1.0E-4>Math.abs(q))&&(r=l.dot(j)/q,!(0>r)&&(a.doubleSided||(a.flipSided?0<q:0>q))))if(n.add(k,i.multiplyScalar(r)),b instanceof THREE.Face3)e=u.multiplyVector3(e.copy(w[b.a].position)),f=u.multiplyVector3(f.copy(w[b.b].position)),g=u.multiplyVector3(g.copy(w[b.c].position)),d(n,e,f,g)&&(b={distance:k.distanceTo(n),point:n.clone(),face:b,object:a},m.push(b));else if(b instanceof THREE.Face4&&(e=u.multiplyVector3(e.copy(w[b.a].position)),
-f=u.multiplyVector3(f.copy(w[b.b].position)),g=u.multiplyVector3(g.copy(w[b.c].position)),h=u.multiplyVector3(h.copy(w[b.d].position)),d(n,e,f,h)||d(n,f,g,h)))b={distance:k.distanceTo(n),point:n.clone(),face:b,object:a},m.push(b)}return m};var m=new THREE.Vector3,q=new THREE.Vector3,o=new THREE.Vector3,p,v,r,w,D,s,B,x,z,F,J};
+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 m;var q,r,t=a.geometry,v=t.vertices,s;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(o=0,p=t.faces.length;o<p;o++)if(b=t.faces[o],k.copy(this.origin),i.copy(this.direction),s=a.matrixWorld,j=s.multiplyVector3(j.copy(b.centroid)).subSelf(k),
+l=a.matrixRotationWorld.multiplyVector3(l.copy(b.normal)),q=i.dot(l),!(1.0E-4>Math.abs(q))&&(r=l.dot(j)/q,!(0>r)&&(a.doubleSided||(a.flipSided?0<q:0>q))))if(n.add(k,i.multiplyScalar(r)),b instanceof THREE.Face3)e=s.multiplyVector3(e.copy(v[b.a].position)),f=s.multiplyVector3(f.copy(v[b.b].position)),g=s.multiplyVector3(g.copy(v[b.c].position)),d(n,e,f,g)&&(b={distance:k.distanceTo(n),point:n.clone(),face:b,object:a},m.push(b));else if(b instanceof THREE.Face4&&(e=s.multiplyVector3(e.copy(v[b.a].position)),
+f=s.multiplyVector3(f.copy(v[b.b].position)),g=s.multiplyVector3(g.copy(v[b.c].position)),h=s.multiplyVector3(h.copy(v[b.d].position)),d(n,e,f,h)||d(n,f,g,h)))b={distance:k.distanceTo(n),point:n.clone(),face:b,object:a},m.push(b)}return m};var m=new THREE.Vector3,q=new THREE.Vector3,o=new THREE.Vector3,p,s,r,v,D,t,A,w,y,F,J};
 THREE.Rectangle=function(){function a(){f=d-b;g=e-c}var b,c,d,e,f,g,h=!0;this.getX=function(){return b};this.getY=function(){return c};this.getWidth=function(){return f};this.getHeight=function(){return g};this.getLeft=function(){return b};this.getTop=function(){return c};this.getRight=function(){return d};this.getBottom=function(){return e};this.set=function(f,g,j,l){h=!1;b=f;c=g;d=j;e=l;a()};this.addPoint=function(f,g){h?(h=!1,b=f,c=g,d=f,e=g):(b=b<f?b:f,c=c<g?c:g,d=d>f?d:f,e=e>g?e:g);a()};this.add3Points=
 function(f,g,j,l,n,m){h?(h=!1,b=f<j?f<n?f:n:j<n?j:n,c=g<l?g<m?g:m:l<m?l:m,d=f>j?f>n?f:n:j>n?j:n,e=g>l?g>m?g:m:l>m?l:m):(b=f<j?f<n?f<b?f:b:n<b?n:b:j<n?j<b?j:b:n<b?n:b,c=g<l?g<m?g<c?g:c:m<c?m:c:l<m?l<c?l:c:m<c?m:c,d=f>j?f>n?f>d?f:d:n>d?n:d:j>n?j>d?j:d:n>d?n:d,e=g>l?g>m?g>e?g:e:m>e?m:e:l>m?l>e?l:e:m>e?m:e);a()};this.addRectangle=function(f){h?(h=!1,b=f.getLeft(),c=f.getTop(),d=f.getRight(),e=f.getBottom()):(b=b<f.getLeft()?b:f.getLeft(),c=c<f.getTop()?c:f.getTop(),d=d>f.getRight()?d:f.getRight(),e=e>
 f.getBottom()?e:f.getBottom());a()};this.inflate=function(f){b-=f;c-=f;d+=f;e+=f;a()};this.minSelf=function(f){b=b>f.getLeft()?b:f.getLeft();c=c>f.getTop()?c:f.getTop();d=d<f.getRight()?d:f.getRight();e=e<f.getBottom()?e:f.getBottom();a()};this.intersects=function(a){return d<a.getLeft()||b>a.getRight()||e<a.getTop()||c>a.getBottom()?!1:!0};this.empty=function(){h=!0;e=d=c=b=0;a()};this.isEmpty=function(){return h}};
@@ -31,8 +31,8 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=
 THREE.Matrix4=function(a,b,c,d,e,f,g,h,k,i,j,l,n,m,q,o){this.set(void 0!==a?a:1,b||0,c||0,d||0,e||0,void 0!==f?f:1,g||0,h||0,k||0,i||0,void 0!==j?j:1,l||0,n||0,m||0,q||0,void 0!==o?o:1);this.flat=Array(16);this.m33=new THREE.Matrix3};
 THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,k,i,j,l,n,m,q,o){this.n11=a;this.n12=b;this.n13=c;this.n14=d;this.n21=e;this.n22=f;this.n23=g;this.n24=h;this.n31=k;this.n32=i;this.n33=j;this.n34=l;this.n41=n;this.n42=m;this.n43=q;this.n44=o;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},copy:function(a){this.set(a.n11,a.n12,a.n13,a.n14,a.n21,a.n22,a.n23,a.n24,a.n31,a.n32,a.n33,a.n34,a.n41,a.n42,a.n43,a.n44);return this},lookAt:function(a,
 b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;f.sub(a,b).normalize();if(0===f.length())f.z=1;d.cross(c,f).normalize();0===d.length()&&(f.x+=1.0E-4,d.cross(c,f).normalize());e.cross(f,d).normalize();this.n11=d.x;this.n12=e.x;this.n13=f.x;this.n21=d.y;this.n22=e.y;this.n23=f.y;this.n31=d.z;this.n32=e.z;this.n33=f.z;return this},multiply:function(a,b){var c=a.n11,d=a.n12,e=a.n13,f=a.n14,g=a.n21,h=a.n22,k=a.n23,i=a.n24,j=a.n31,l=a.n32,n=a.n33,m=a.n34,q=a.n41,o=a.n42,p=a.n43,
-v=a.n44,r=b.n11,w=b.n12,D=b.n13,s=b.n14,B=b.n21,x=b.n22,z=b.n23,F=b.n24,J=b.n31,H=b.n32,I=b.n33,O=b.n34,P=b.n41,Q=b.n42,R=b.n43,S=b.n44;this.n11=c*r+d*B+e*J+f*P;this.n12=c*w+d*x+e*H+f*Q;this.n13=c*D+d*z+e*I+f*R;this.n14=c*s+d*F+e*O+f*S;this.n21=g*r+h*B+k*J+i*P;this.n22=g*w+h*x+k*H+i*Q;this.n23=g*D+h*z+k*I+i*R;this.n24=g*s+h*F+k*O+i*S;this.n31=j*r+l*B+n*J+m*P;this.n32=j*w+l*x+n*H+m*Q;this.n33=j*D+l*z+n*I+m*R;this.n34=j*s+l*F+n*O+m*S;this.n41=q*r+o*B+p*J+v*P;this.n42=q*w+o*x+p*H+v*Q;this.n43=q*D+o*
-z+p*I+v*R;this.n44=q*s+o*F+p*O+v*S;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
+s=a.n44,r=b.n11,v=b.n12,D=b.n13,t=b.n14,A=b.n21,w=b.n22,y=b.n23,F=b.n24,J=b.n31,H=b.n32,I=b.n33,P=b.n34,Q=b.n41,R=b.n42,S=b.n43,T=b.n44;this.n11=c*r+d*A+e*J+f*Q;this.n12=c*v+d*w+e*H+f*R;this.n13=c*D+d*y+e*I+f*S;this.n14=c*t+d*F+e*P+f*T;this.n21=g*r+h*A+k*J+i*Q;this.n22=g*v+h*w+k*H+i*R;this.n23=g*D+h*y+k*I+i*S;this.n24=g*t+h*F+k*P+i*T;this.n31=j*r+l*A+n*J+m*Q;this.n32=j*v+l*w+n*H+m*R;this.n33=j*D+l*y+n*I+m*S;this.n34=j*t+l*F+n*P+m*T;this.n41=q*r+o*A+p*J+s*Q;this.n42=q*v+o*w+p*H+s*R;this.n43=q*D+o*
+y+p*I+s*S;this.n44=q*t+o*F+p*P+s*T;return this},multiplySelf:function(a){return this.multiply(this,a)},multiplyToArray:function(a,b,c){this.multiply(a,b);c[0]=this.n11;c[1]=this.n21;c[2]=this.n31;c[3]=this.n41;c[4]=this.n12;c[5]=this.n22;c[6]=this.n32;c[7]=this.n42;c[8]=this.n13;c[9]=this.n23;c[10]=this.n33;c[11]=this.n43;c[12]=this.n14;c[13]=this.n24;c[14]=this.n34;c[15]=this.n44;return this},multiplyScalar:function(a){this.n11*=a;this.n12*=a;this.n13*=a;this.n14*=a;this.n21*=a;this.n22*=a;this.n23*=
 a;this.n24*=a;this.n31*=a;this.n32*=a;this.n33*=a;this.n34*=a;this.n41*=a;this.n42*=a;this.n43*=a;this.n44*=a;return this},multiplyVector3:function(a){var b=a.x,c=a.y,d=a.z,e=1/(this.n41*b+this.n42*c+this.n43*d+this.n44);a.x=(this.n11*b+this.n12*c+this.n13*d+this.n14)*e;a.y=(this.n21*b+this.n22*c+this.n23*d+this.n24)*e;a.z=(this.n31*b+this.n32*c+this.n33*d+this.n34)*e;return a},multiplyVector4:function(a){var b=a.x,c=a.y,d=a.z,e=a.w;a.x=this.n11*b+this.n12*c+this.n13*d+this.n14*e;a.y=this.n21*b+this.n22*
 c+this.n23*d+this.n24*e;a.z=this.n31*b+this.n32*c+this.n33*d+this.n34*e;a.w=this.n41*b+this.n42*c+this.n43*d+this.n44*e;return a},rotateAxis:function(a){var b=a.x,c=a.y,d=a.z;a.x=b*this.n11+c*this.n12+d*this.n13;a.y=b*this.n21+c*this.n22+d*this.n23;a.z=b*this.n31+c*this.n32+d*this.n33;a.normalize();return a},crossVector:function(a){var b=new THREE.Vector4;b.x=this.n11*a.x+this.n12*a.y+this.n13*a.z+this.n14*a.w;b.y=this.n21*a.x+this.n22*a.y+this.n23*a.z+this.n24*a.w;b.z=this.n31*a.x+this.n32*a.y+this.n33*
 a.z+this.n34*a.w;b.w=a.w?this.n41*a.x+this.n42*a.y+this.n43*a.z+this.n44*a.w:1;return b},determinant:function(){var a=this.n11,b=this.n12,c=this.n13,d=this.n14,e=this.n21,f=this.n22,g=this.n23,h=this.n24,k=this.n31,i=this.n32,j=this.n33,l=this.n34,n=this.n41,m=this.n42,q=this.n43,o=this.n44;return d*g*i*n-c*h*i*n-d*f*j*n+b*h*j*n+c*f*l*n-b*g*l*n-d*g*k*m+c*h*k*m+d*e*j*m-a*h*j*m-c*e*l*m+a*g*l*m+d*f*k*q-b*h*k*q-d*e*i*q+a*h*i*q+b*e*l*q-a*f*l*q-c*f*k*o+b*g*k*o+c*e*i*o-a*g*i*o-b*e*j*o+a*f*j*o},transpose:function(){var a;
@@ -49,8 +49,8 @@ e,j=c*h,l=c*e,this.n11=g*h,this.n12=-g*e,this.n13=d,this.n21=i+j*d,this.n22=k-l*
 a;this.n21*=b;this.n22*=c;this.n23*=a;this.n31*=b;this.n32*=c;this.n33*=a;this.n41*=b;this.n42*=c;this.n43*=a;return this},compose:function(a,b,c){var d=THREE.Matrix4.__m1,e=THREE.Matrix4.__m2;d.identity();d.setRotationFromQuaternion(b);e.setScale(c.x,c.y,c.z);this.multiply(d,e);this.n14=a.x;this.n24=a.y;this.n34=a.z;return this},decompose:function(a,b,c){var d=THREE.Matrix4.__v1,e=THREE.Matrix4.__v2,f=THREE.Matrix4.__v3;d.set(this.n11,this.n21,this.n31);e.set(this.n12,this.n22,this.n32);f.set(this.n13,
 this.n23,this.n33);a=a instanceof THREE.Vector3?a:new THREE.Vector3;b=b instanceof THREE.Quaternion?b:new THREE.Quaternion;c=c instanceof THREE.Vector3?c:new THREE.Vector3;c.x=d.length();c.y=e.length();c.z=f.length();a.x=this.n14;a.y=this.n24;a.z=this.n34;d=THREE.Matrix4.__m1;d.copy(this);d.n11/=c.x;d.n21/=c.x;d.n31/=c.x;d.n12/=c.y;d.n22/=c.y;d.n32/=c.y;d.n13/=c.z;d.n23/=c.z;d.n33/=c.z;b.setFromRotationMatrix(d);return[a,b,c]},extractPosition:function(a){this.n14=a.n14;this.n24=a.n24;this.n34=a.n34;
 return this},extractRotation:function(a){var b=THREE.Matrix4.__v1,c=1/b.set(a.n11,a.n21,a.n31).length(),d=1/b.set(a.n12,a.n22,a.n32).length(),b=1/b.set(a.n13,a.n23,a.n33).length();this.n11=a.n11*c;this.n21=a.n21*c;this.n31=a.n31*c;this.n12=a.n12*d;this.n22=a.n22*d;this.n32=a.n32*d;this.n13=a.n13*b;this.n23=a.n23*b;this.n33=a.n33*b;return this},rotateByAxis:function(a,b){if(1===a.x&&0===a.y&&0===a.z)return this.rotateX(b);if(0===a.x&&1===a.y&&0===a.z)return this.rotateY(b);if(0===a.x&&0===a.y&&1===
-a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e),c=c/f,d=d/f,e=e/f,f=c*c,g=d*d,h=e*e,k=Math.cos(b),i=Math.sin(b),j=1-k,l=c*d*j,n=c*e*j,j=d*e*j,c=c*i,m=d*i,i=e*i,e=f+(1-f)*k,f=l+i,d=n-m,l=l-i,g=g+(1-g)*k,i=j+c,n=n+m,j=j-c,h=h+(1-h)*k,k=this.n11,c=this.n21,m=this.n31,q=this.n41,o=this.n12,p=this.n22,v=this.n32,r=this.n42,w=this.n13,D=this.n23,s=this.n33,B=this.n43;this.n11=e*k+f*o+d*w;this.n21=e*c+f*p+d*D;this.n31=e*m+f*v+d*s;this.n41=e*q+f*r+d*B;this.n12=l*k+g*o+i*w;this.n22=
-l*c+g*p+i*D;this.n32=l*m+g*v+i*s;this.n42=l*q+g*r+i*B;this.n13=n*k+j*o+h*w;this.n23=n*c+j*p+h*D;this.n33=n*m+j*v+h*s;this.n43=n*q+j*r+h*B;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,f=this.n13,g=this.n23,h=this.n33,k=this.n43,i=Math.cos(a),a=Math.sin(a);this.n12=i*b+a*f;this.n22=i*c+a*g;this.n32=i*d+a*h;this.n42=i*e+a*k;this.n13=i*f-a*b;this.n23=i*g-a*c;this.n33=i*h-a*d;this.n43=i*k-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,
+a.z)return this.rotateZ(b);var c=a.x,d=a.y,e=a.z,f=Math.sqrt(c*c+d*d+e*e),c=c/f,d=d/f,e=e/f,f=c*c,g=d*d,h=e*e,k=Math.cos(b),i=Math.sin(b),j=1-k,l=c*d*j,n=c*e*j,j=d*e*j,c=c*i,m=d*i,i=e*i,e=f+(1-f)*k,f=l+i,d=n-m,l=l-i,g=g+(1-g)*k,i=j+c,n=n+m,j=j-c,h=h+(1-h)*k,k=this.n11,c=this.n21,m=this.n31,q=this.n41,o=this.n12,p=this.n22,s=this.n32,r=this.n42,v=this.n13,D=this.n23,t=this.n33,A=this.n43;this.n11=e*k+f*o+d*v;this.n21=e*c+f*p+d*D;this.n31=e*m+f*s+d*t;this.n41=e*q+f*r+d*A;this.n12=l*k+g*o+i*v;this.n22=
+l*c+g*p+i*D;this.n32=l*m+g*s+i*t;this.n42=l*q+g*r+i*A;this.n13=n*k+j*o+h*v;this.n23=n*c+j*p+h*D;this.n33=n*m+j*s+h*t;this.n43=n*q+j*r+h*A;return this},rotateX:function(a){var b=this.n12,c=this.n22,d=this.n32,e=this.n42,f=this.n13,g=this.n23,h=this.n33,k=this.n43,i=Math.cos(a),a=Math.sin(a);this.n12=i*b+a*f;this.n22=i*c+a*g;this.n32=i*d+a*h;this.n42=i*e+a*k;this.n13=i*f-a*b;this.n23=i*g-a*c;this.n33=i*h-a*d;this.n43=i*k-a*e;return this},rotateY:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,
 f=this.n13,g=this.n23,h=this.n33,k=this.n43,i=Math.cos(a),a=Math.sin(a);this.n11=i*b-a*f;this.n21=i*c-a*g;this.n31=i*d-a*h;this.n41=i*e-a*k;this.n13=i*f+a*b;this.n23=i*g+a*c;this.n33=i*h+a*d;this.n43=i*k+a*e;return this},rotateZ:function(a){var b=this.n11,c=this.n21,d=this.n31,e=this.n41,f=this.n12,g=this.n22,h=this.n32,k=this.n42,i=Math.cos(a),a=Math.sin(a);this.n11=i*b+a*f;this.n21=i*c+a*g;this.n31=i*d+a*h;this.n41=i*e+a*k;this.n12=i*f-a*b;this.n22=i*g-a*c;this.n32=i*h-a*d;this.n42=i*k-a*e;return this},
 translate:function(a){var b=a.x,c=a.y,a=a.z;this.n14=this.n11*b+this.n12*c+this.n13*a+this.n14;this.n24=this.n21*b+this.n22*c+this.n23*a+this.n24;this.n34=this.n31*b+this.n32*c+this.n33*a+this.n34;this.n44=this.n41*b+this.n42*c+this.n43*a+this.n44;return this}};
 THREE.Matrix4.makeInvert3x3=function(a){var b=a.m33,c=b.m,d=a.n33*a.n22-a.n32*a.n23,e=-a.n33*a.n21+a.n31*a.n23,f=a.n32*a.n21-a.n31*a.n22,g=-a.n33*a.n12+a.n32*a.n13,h=a.n33*a.n11-a.n31*a.n13,k=-a.n32*a.n11+a.n31*a.n12,i=a.n23*a.n12-a.n22*a.n13,j=-a.n23*a.n11+a.n21*a.n13,l=a.n22*a.n11-a.n21*a.n12,a=a.n11*d+a.n21*g+a.n31*i;if(0===a)return null;a=1/a;c[0]=a*d;c[1]=a*e;c[2]=a*f;c[3]=a*g;c[4]=a*h;c[5]=a*k;c[6]=a*i;c[7]=a*j;c[8]=a*l;return b};
@@ -63,29 +63,29 @@ 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=i[k]=i[k]||new THREE.RenderableVertex;k++;return a}function c(a,b){return b.z-a.z}function d(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d<c)return!1;a.lerpSelf(b,c);b.lerpSelf(a,1-d);return!0}
-var e,f,g=[],h,k,i=[],j,l,n=[],m,q=[],o,p,v=[],r,w,D=[],s={objects:[],sprites:[],lights:[],elements:[]},B=new THREE.Vector3,x=new THREE.Vector4,z=new THREE.Matrix4,F=new THREE.Matrix4,J=new THREE.Frustum,H=new THREE.Vector4,I=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);z.multiply(b.projectionMatrix,b.matrixWorldInverse);z.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);z.multiply(b.matrixWorld,
-b.projectionMatrixInverse);z.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){f=0;s.objects.length=0;s.sprites.length=0;s.lights.length=0;var g=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||J.contains(b))?(z.multiplyVector3(B.copy(b.position)),e=a(),e.object=
-b,e.z=B.z,s.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(z.multiplyVector3(B.copy(b.position)),e=a(),e.object=b,e.z=B.z,s.sprites.push(e)):b instanceof THREE.Light&&s.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&s.objects.sort(c);return s};this.projectScene=function(a,e,f){var g=e.near,B=e.far,T,K,u,G,t,C,A,E,y,L,M,U,X,V,W,N;w=p=m=l=0;s.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
-a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);z.multiply(e.projectionMatrix,e.matrixWorldInverse);J.setFromMatrix(z);s=this.projectGraph(a,!1);for(a=0,T=s.objects.length;a<T;a++)if(y=s.objects[a].object,L=y.matrixWorld,U=y.material,k=0,y instanceof THREE.Mesh){M=y.geometry;X=y.geometry.materials;G=M.vertices;V=M.faces;W=M.faceVertexUvs;M=y.matrixRotationWorld.extractRotation(L);for(K=0,u=G.length;K<u;K++)h=b(),h.positionWorld.copy(G[K].position),L.multiplyVector3(h.positionWorld),
-h.positionScreen.copy(h.positionWorld),z.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<B;for(G=0,K=V.length;G<K;G++){u=V[G];if(u instanceof THREE.Face3)if(t=i[u.a],C=i[u.b],A=i[u.c],t.visible&&C.visible&&A.visible&&(y.doubleSided||y.flipSided!=0>(A.positionScreen.x-t.positionScreen.x)*(C.positionScreen.y-t.positionScreen.y)-(A.positionScreen.y-t.positionScreen.y)*(C.positionScreen.x-
-t.positionScreen.x)))E=n[l]=n[l]||new THREE.RenderableFace3,l++,j=E,j.v1.copy(t),j.v2.copy(C),j.v3.copy(A);else continue;else if(u instanceof THREE.Face4)if(t=i[u.a],C=i[u.b],A=i[u.c],E=i[u.d],t.visible&&C.visible&&A.visible&&E.visible&&(y.doubleSided||y.flipSided!=(0>(E.positionScreen.x-t.positionScreen.x)*(C.positionScreen.y-t.positionScreen.y)-(E.positionScreen.y-t.positionScreen.y)*(C.positionScreen.x-t.positionScreen.x)||0>(C.positionScreen.x-A.positionScreen.x)*(E.positionScreen.y-A.positionScreen.y)-
-(C.positionScreen.y-A.positionScreen.y)*(E.positionScreen.x-A.positionScreen.x))))N=q[m]=q[m]||new THREE.RenderableFace4,m++,j=N,j.v1.copy(t),j.v2.copy(C),j.v3.copy(A),j.v4.copy(E);else continue;j.normalWorld.copy(u.normal);M.multiplyVector3(j.normalWorld);j.centroidWorld.copy(u.centroid);L.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);z.multiplyVector3(j.centroidScreen);A=u.vertexNormals;for(t=0,C=A.length;t<C;t++)E=j.vertexNormalsWorld[t],E.copy(A[t]),M.multiplyVector3(E);
-for(t=0,C=W.length;t<C;t++)if(N=W[t][G])for(A=0,E=N.length;A<E;A++)j.uvs[t][A]=N[A];j.material=U;j.faceMaterial=null!==u.materialIndex?X[u.materialIndex]:null;j.z=j.centroidScreen.z;s.elements.push(j)}}else if(y instanceof THREE.Line){F.multiply(z,L);G=y.geometry.vertices;t=b();t.positionScreen.copy(G[0].position);F.multiplyVector4(t.positionScreen);for(K=1,u=G.length;K<u;K++)if(t=b(),t.positionScreen.copy(G[K].position),F.multiplyVector4(t.positionScreen),C=i[k-2],H.copy(t.positionScreen),I.copy(C.positionScreen),
-d(H,I))H.multiplyScalar(1/H.w),I.multiplyScalar(1/I.w),y=v[p]=v[p]||new THREE.RenderableLine,p++,o=y,o.v1.positionScreen.copy(H),o.v2.positionScreen.copy(I),o.z=Math.max(H.z,I.z),o.material=U,s.elements.push(o)}for(a=0,T=s.sprites.length;a<T;a++)if(y=s.sprites[a].object,L=y.matrixWorld,y instanceof THREE.Particle&&(x.set(L.n14,L.n24,L.n34,1),z.multiplyVector4(x),x.z/=x.w,0<x.z&&1>x.z))g=D[w]=D[w]||new THREE.RenderableParticle,w++,r=g,r.x=x.x/x.w,r.y=x.y/x.w,r.z=x.z,r.rotation=y.rotation.z,r.scale.x=
-y.scale.x*Math.abs(r.x-(x.x+e.projectionMatrix.n11)/(x.w+e.projectionMatrix.n14)),r.scale.y=y.scale.y*Math.abs(r.y-(x.y+e.projectionMatrix.n22)/(x.w+e.projectionMatrix.n24)),r.material=y.material,s.elements.push(r);f&&s.elements.sort(c);return s}};THREE.Quaternion=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
+var e,f,g=[],h,k,i=[],j,l,n=[],m,q=[],o,p,s=[],r,v,D=[],t={objects:[],sprites:[],lights:[],elements:[]},A=new THREE.Vector3,w=new THREE.Vector4,y=new THREE.Matrix4,F=new THREE.Matrix4,J=new THREE.Frustum,H=new THREE.Vector4,I=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);y.multiply(b.projectionMatrix,b.matrixWorldInverse);y.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);y.multiply(b.matrixWorld,
+b.projectionMatrixInverse);y.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){f=0;t.objects.length=0;t.sprites.length=0;t.lights.length=0;var g=function(b){if(!1!==b.visible){(b instanceof THREE.Mesh||b instanceof THREE.Line)&&(!1===b.frustumCulled||J.contains(b))?(y.multiplyVector3(A.copy(b.position)),e=a(),e.object=
+b,e.z=A.z,t.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(y.multiplyVector3(A.copy(b.position)),e=a(),e.object=b,e.z=A.z,t.sprites.push(e)):b instanceof THREE.Light&&t.lights.push(b);for(var c=0,d=b.children.length;c<d;c++)g(b.children[c])}};g(b);d&&t.objects.sort(c);return t};this.projectScene=function(a,e,f){var g=e.near,A=e.far,N=!1,U,L,B,G,u,C,z,E,x,K,M,X,V,W,O;v=p=m=l=0;t.elements.length=0;void 0===e.parent&&(console.warn("DEPRECATED: Camera hasn't been added to a Scene. Adding it..."),
+a.add(e));a.updateMatrixWorld();e.matrixWorldInverse.getInverse(e.matrixWorld);y.multiply(e.projectionMatrix,e.matrixWorldInverse);J.setFromMatrix(y);t=this.projectGraph(a,!1);for(a=0,U=t.objects.length;a<U;a++)if(x=t.objects[a].object,K=x.matrixWorld,k=0,x instanceof THREE.Mesh){M=x.geometry;X=x.geometry.materials;G=M.vertices;V=M.faces;W=M.faceVertexUvs;M=x.matrixRotationWorld.extractRotation(K);for(L=0,B=G.length;L<B;L++)h=b(),h.positionWorld.copy(G[L].position),K.multiplyVector3(h.positionWorld),
+h.positionScreen.copy(h.positionWorld),y.multiplyVector4(h.positionScreen),h.positionScreen.x/=h.positionScreen.w,h.positionScreen.y/=h.positionScreen.w,h.visible=h.positionScreen.z>g&&h.positionScreen.z<A;for(G=0,L=V.length;G<L;G++){B=V[G];if(B instanceof THREE.Face3)if(u=i[B.a],C=i[B.b],z=i[B.c],u.visible&&C.visible&&z.visible)if(N=0>(z.positionScreen.x-u.positionScreen.x)*(C.positionScreen.y-u.positionScreen.y)-(z.positionScreen.y-u.positionScreen.y)*(C.positionScreen.x-u.positionScreen.x),x.doubleSided||
+N!=x.flipSided)E=n[l]=n[l]||new THREE.RenderableFace3,l++,j=E,j.v1.copy(u),j.v2.copy(C),j.v3.copy(z);else continue;else continue;else if(B instanceof THREE.Face4)if(u=i[B.a],C=i[B.b],z=i[B.c],E=i[B.d],u.visible&&C.visible&&z.visible&&E.visible)if(N=0>(E.positionScreen.x-u.positionScreen.x)*(C.positionScreen.y-u.positionScreen.y)-(E.positionScreen.y-u.positionScreen.y)*(C.positionScreen.x-u.positionScreen.x)||0>(C.positionScreen.x-z.positionScreen.x)*(E.positionScreen.y-z.positionScreen.y)-(C.positionScreen.y-
+z.positionScreen.y)*(E.positionScreen.x-z.positionScreen.x),x.doubleSided||N!=x.flipSided)O=q[m]=q[m]||new THREE.RenderableFace4,m++,j=O,j.v1.copy(u),j.v2.copy(C),j.v3.copy(z),j.v4.copy(E);else continue;else continue;j.normalWorld.copy(B.normal);!N&&(x.flipSided||x.doubleSided)&&j.normalWorld.negate();M.multiplyVector3(j.normalWorld);j.centroidWorld.copy(B.centroid);K.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);y.multiplyVector3(j.centroidScreen);z=B.vertexNormals;for(u=
+0,C=z.length;u<C;u++)E=j.vertexNormalsWorld[u],E.copy(z[u]),!N&&(x.flipSided||x.doubleSided)&&E.negate(),M.multiplyVector3(E);for(u=0,C=W.length;u<C;u++)if(O=W[u][G])for(z=0,E=O.length;z<E;z++)j.uvs[u][z]=O[z];j.material=x.material;j.faceMaterial=null!==B.materialIndex?X[B.materialIndex]:null;j.z=j.centroidScreen.z;t.elements.push(j)}}else if(x instanceof THREE.Line){F.multiply(y,K);G=x.geometry.vertices;u=b();u.positionScreen.copy(G[0].position);F.multiplyVector4(u.positionScreen);for(L=1,B=G.length;L<
+B;L++)if(u=b(),u.positionScreen.copy(G[L].position),F.multiplyVector4(u.positionScreen),C=i[k-2],H.copy(u.positionScreen),I.copy(C.positionScreen),d(H,I))H.multiplyScalar(1/H.w),I.multiplyScalar(1/I.w),K=s[p]=s[p]||new THREE.RenderableLine,p++,o=K,o.v1.positionScreen.copy(H),o.v2.positionScreen.copy(I),o.z=Math.max(H.z,I.z),o.material=x.material,t.elements.push(o)}for(a=0,U=t.sprites.length;a<U;a++)if(x=t.sprites[a].object,K=x.matrixWorld,x instanceof THREE.Particle&&(w.set(K.n14,K.n24,K.n34,1),y.multiplyVector4(w),
+w.z/=w.w,0<w.z&&1>w.z))g=D[v]=D[v]||new THREE.RenderableParticle,v++,r=g,r.x=w.x/w.w,r.y=w.y/w.w,r.z=w.z,r.rotation=x.rotation.z,r.scale.x=x.scale.x*Math.abs(r.x-(w.x+e.projectionMatrix.n11)/(w.w+e.projectionMatrix.n14)),r.scale.y=x.scale.y*Math.abs(r.y-(w.y+e.projectionMatrix.n22)/(w.w+e.projectionMatrix.n24)),r.material=x.material,t.elements.push(r);f&&t.elements.sort(c);return t}};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,i=k*c+g*e-h*d,j=k*d+h*c-f*e,l=k*e+f*d-g*c,c=-f*c-g*d-h*e;b.x=i*k+c*-f+j*-h-l*-g;b.y=j*k+c*-g+l*-f-i*-h;b.z=l*k+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.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.001>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};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
 THREE.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;
-THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:43.25)/(2*a));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
+THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:24)/(2*a))*(180/Math.PI);this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
 THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
 this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;
 THREE.Material=function(a){a=a||{};this.id=THREE.MaterialCount++;this.name="";this.opacity=void 0!==a.opacity?a.opacity:1;this.transparent=void 0!==a.transparent?a.transparent:!1;this.blending=void 0!==a.blending?a.blending:THREE.NormalBlending;this.depthTest=void 0!==a.depthTest?a.depthTest:!0;this.depthWrite=void 0!==a.depthWrite?a.depthWrite:!0;this.polygonOffset=void 0!==a.polygonOffset?a.polygonOffset:!1;this.polygonOffsetFactor=void 0!==a.polygonOffsetFactor?a.polygonOffsetFactor:0;this.polygonOffsetUnits=
@@ -114,6 +114,6 @@ THREE.RenderableFace3=function(){this.v1=new THREE.RenderableVertex;this.v2=new
 THREE.RenderableFace4=function(){this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.v3=new THREE.RenderableVertex;this.v4=new THREE.RenderableVertex;this.centroidWorld=new THREE.Vector3;this.centroidScreen=new THREE.Vector3;this.normalWorld=new THREE.Vector3;this.vertexNormalsWorld=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];this.faceMaterial=this.material=null;this.uvs=[[]];this.z=null};THREE.RenderableObject=function(){this.z=this.object=null};
 THREE.RenderableParticle=function(){this.rotation=this.z=this.y=this.x=null;this.scale=new THREE.Vector2;this.material=null};THREE.RenderableLine=function(){this.z=null;this.v1=new THREE.RenderableVertex;this.v2=new THREE.RenderableVertex;this.material=null};
 THREE.ImageUtils={crossOrigin:"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),i=k.data,j=0;j<d;j++)for(var l=1;l<e;l++){var n=0>l-1?e-1:l-1,m=(l+1)%e,q=0>j-1?d-1:j-1,o=(j+1)%d,p=[],v=[0,0,h[4*(l*d+j)]/255*b];p.push([-1,0,h[4*(l*d+q)]/255*b]);p.push([-1,-1,h[4*(n*d+q)]/255*b]);p.push([0,-1,
-h[4*(n*d+j)]/255*b]);p.push([1,-1,h[4*(n*d+o)]/255*b]);p.push([1,0,h[4*(l*d+o)]/255*b]);p.push([1,1,h[4*(m*d+o)]/255*b]);p.push([0,1,h[4*(m*d+j)]/255*b]);p.push([-1,1,h[4*(m*d+q)]/255*b]);n=[];q=p.length;for(m=0;m<q;m++){var o=p[m],r=p[(m+1)%q],o=[o[0]-v[0],o[1]-v[1],o[2]-v[2]],r=[r[0]-v[0],r[1]-v[1],r[2]-v[2]];n.push(c([o[1]*r[2]-o[2]*r[1],o[2]*r[0]-o[0]*r[2],o[0]*r[1]-o[1]*r[0]]))}p=[0,0,0];for(m=0;m<n.length;m++)p[0]+=n[m][0],p[1]+=n[m][1],p[2]+=n[m][2];p[0]/=n.length;p[1]/=n.length;p[2]/=n.length;
-v=4*(l*d+j);i[v]=255*((p[0]+1)/2)|0;i[v+1]=255*(p[1]+0.5)|0;i[v+2]=255*p[2]|0;i[v+3]=255}g.putImageData(k,0,0);return f},generateDataTexture:function(a,b,c){for(var d=a*b,e=new Uint8Array(3*d),f=Math.floor(255*c.r),g=Math.floor(255*c.g),c=Math.floor(255*c.b),h=0;h<d;h++)e[3*h]=f,e[3*h+1]=g,e[3*h+2]=c;a=new THREE.DataTexture(e,a,b,THREE.RGBFormat);a.needsUpdate=!0;return a}};
+b){var c=function(a){var b=Math.sqrt(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]);return[a[0]/b,a[1]/b,a[2]/b]},b=b|1,d=a.width,e=a.height,f=document.createElement("canvas");f.width=d;f.height=e;var g=f.getContext("2d");g.drawImage(a,0,0);for(var h=g.getImageData(0,0,d,e).data,k=g.createImageData(d,e),i=k.data,j=0;j<d;j++)for(var l=1;l<e;l++){var n=0>l-1?e-1:l-1,m=(l+1)%e,q=0>j-1?d-1:j-1,o=(j+1)%d,p=[],s=[0,0,h[4*(l*d+j)]/255*b];p.push([-1,0,h[4*(l*d+q)]/255*b]);p.push([-1,-1,h[4*(n*d+q)]/255*b]);p.push([0,-1,
+h[4*(n*d+j)]/255*b]);p.push([1,-1,h[4*(n*d+o)]/255*b]);p.push([1,0,h[4*(l*d+o)]/255*b]);p.push([1,1,h[4*(m*d+o)]/255*b]);p.push([0,1,h[4*(m*d+j)]/255*b]);p.push([-1,1,h[4*(m*d+q)]/255*b]);n=[];q=p.length;for(m=0;m<q;m++){var o=p[m],r=p[(m+1)%q],o=[o[0]-s[0],o[1]-s[1],o[2]-s[2]],r=[r[0]-s[0],r[1]-s[1],r[2]-s[2]];n.push(c([o[1]*r[2]-o[2]*r[1],o[2]*r[0]-o[0]*r[2],o[0]*r[1]-o[1]*r[0]]))}p=[0,0,0];for(m=0;m<n.length;m++)p[0]+=n[m][0],p[1]+=n[m][1],p[2]+=n[m][2];p[0]/=n.length;p[1]/=n.length;p[2]/=n.length;
+s=4*(l*d+j);i[s]=255*((p[0]+1)/2)|0;i[s+1]=255*(p[1]+0.5)|0;i[s+2]=255*p[2]|0;i[s+3]=255}g.putImageData(k,0,0);return f},generateDataTexture:function(a,b,c){for(var d=a*b,e=new Uint8Array(3*d),f=Math.floor(255*c.r),g=Math.floor(255*c.g),c=Math.floor(255*c.b),h=0;h<d;h++)e[3*h]=f,e[3*h+1]=g,e[3*h+2]=c;a=new THREE.DataTexture(e,a,b,THREE.RGBFormat);a.needsUpdate=!0;return a}};

+ 139 - 140
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],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,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,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?
@@ -14,9 +14,9 @@ a.faces[b];if(c instanceof THREE.Face4){var d=c.b,f=c.c,g=c.d,e=new THREE.Face3(
 1,e,d);for(c=0;c<a.faceVertexUvs.length;c++)a.faceVertexUvs[c].length&&(g=a.faceVertexUvs[c][b],e=g[1],d=g[2],f=g[3],g=[g[0].clone(),e.clone(),f.clone()],e=[e.clone(),d.clone(),f.clone()],a.faceVertexUvs[c].splice(b,1,g,e));for(c=0;c<a.faceUvs.length;c++)a.faceUvs[c].length&&(e=a.faceUvs[c][b],a.faceUvs[c].splice(b,1,e,e))}}a.computeCentroids();a.computeFaceNormals();a.computeVertexNormals();a.hasTangents&&a.computeTangents()}};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,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},generateDataTexture:function(a,b,c){for(var d=a*b,f=new Uint8Array(3*d),g=Math.floor(255*c.r),e=Math.floor(255*c.g),c=Math.floor(255*c.b),h=0;h<d;h++)f[3*h]=g,f[3*h+1]=e,f[3*h+2]=c;a=new THREE.DataTexture(f,a,b,THREE.RGBFormat);a.needsUpdate=!0;return 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},generateDataTexture:function(a,b,c){for(var d=a*b,f=new Uint8Array(3*d),g=Math.floor(255*c.r),e=Math.floor(255*c.g),c=Math.floor(255*c.b),h=0;h<d;h++)f[3*h]=g,f[3*h+1]=e,f[3*h+2]=c;a=new THREE.DataTexture(f,a,b,THREE.RGBFormat);a.needsUpdate=!0;return a}};
 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,
@@ -67,7 +67,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 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)};
+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)};
 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()};
@@ -75,8 +75,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 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,
+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,
 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};
@@ -98,7 +98,7 @@ c)THREE.Quaternion.slerp(f,g,a.quaternion,d);else if("scl"===c)c=a.scale,c.x=f[0
 THREE.Animation.prototype.interpolateCatmullRom=function(a,b){var c=[],d=[],f,g,e,h,i,k;f=(a.length-1)*b;g=Math.floor(f);f-=g;c[0]=0===g?g:g-1;c[1]=g;c[2]=g>a.length-2?g:g+1;c[3]=g>a.length-3?g:g+2;g=a[c[0]];h=a[c[1]];i=a[c[2]];k=a[c[3]];c=f*f;e=f*c;d[0]=this.interpolate(g[0],h[0],i[0],k[0],f,c,e);d[1]=this.interpolate(g[1],h[1],i[1],k[1],f,c,e);d[2]=this.interpolate(g[2],h[2],i[2],k[2],f,c,e);return d};
 THREE.Animation.prototype.interpolate=function(a,b,c,d,f,g,e){a=0.5*(c-a);d=0.5*(d-b);return(2*(b-c)+a+d)*e+(-3*(b-c)-2*a-d)*g+a*f+b};THREE.Animation.prototype.getNextKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?c<d.length-1?c:d.length-1:c%d.length;c<d.length;c++)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[0]};
 THREE.Animation.prototype.getPrevKeyWith=function(a,b,c){for(var d=this.data.hierarchy[b].keys,c=this.interpolationType===THREE.AnimationHandler.CATMULLROM||this.interpolationType===THREE.AnimationHandler.CATMULLROM_FORWARD?0<c?c:0:0<=c?c:c+d.length;0<=c;c--)if(void 0!==d[c][a])return d[c];return this.data.hierarchy[b].keys[d.length-1]};
-THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.0010;this.isPlaying=!1;this.loop=this.isPaused=!0;this.JITCompile=void 0!==c?c:!0;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var f=0;f<c.length;f++){var g=c[f],e=this.getNextKeyWith(g,a,0);e&&e.apply(g)}d.matrixAutoUpdate=!1;this.data.hierarchy[a].node.updateMatrix();
+THREE.KeyFrameAnimation=function(a,b,c){this.root=a;this.data=THREE.AnimationHandler.get(b);this.hierarchy=THREE.AnimationHandler.parse(a);this.currentTime=0;this.timeScale=0.001;this.isPlaying=!1;this.loop=this.isPaused=!0;this.JITCompile=void 0!==c?c:!0;a=0;for(b=this.hierarchy.length;a<b;a++){var c=this.data.hierarchy[a].sids,d=this.hierarchy[a];if(this.data.hierarchy[a].keys.length&&c){for(var f=0;f<c.length;f++){var g=c[f],e=this.getNextKeyWith(g,a,0);e&&e.apply(g)}d.matrixAutoUpdate=!1;this.data.hierarchy[a].node.updateMatrix();
 d.matrixWorldNeedsUpdate=!0}}};
 THREE.KeyFrameAnimation.prototype.play=function(a,b){if(!this.isPlaying){this.isPlaying=!0;this.loop=void 0!==a?a:!0;this.currentTime=void 0!==b?b:0;this.startTimeMs=b;this.startTime=1E7;this.endTime=-this.startTime;var c,d=this.hierarchy.length,f,g;for(c=0;c<d;c++){f=this.hierarchy[c];g=this.data.hierarchy[c];f.useQuaternion=!0;if(void 0===g.animationCache)g.animationCache={},g.animationCache.prevKey=null,g.animationCache.nextKey=null,g.animationCache.originalMatrix=f instanceof THREE.Bone?f.skinMatrix:
 f.matrix;f=this.data.hierarchy[c].keys;if(f.length)g.animationCache.prevKey=f[0],g.animationCache.nextKey=f[1],this.startTime=Math.min(f[0].time,this.startTime),this.endTime=Math.max(f[f.length-1].time,this.endTime)}this.update(0)}this.isPaused=!1;THREE.AnimationHandler.addToUpdate(this)};THREE.KeyFrameAnimation.prototype.pause=function(){this.isPaused?THREE.AnimationHandler.addToUpdate(this):THREE.AnimationHandler.removeFromUpdate(this);this.isPaused=!this.isPaused};
@@ -111,14 +111,13 @@ THREE.CubeCamera=function(a,b,c,d){this.heightOffset=c;this.position=new THREE.V
 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=
 new THREE.Vector3(0,0,0);this.renderTarget=new THREE.WebGLRenderTargetCube(d,d,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updatePosition=function(a){this.position.copy(a);this.position.y+=this.heightOffset;this.targetPX.copy(this.position);this.targetNX.copy(this.position);this.targetPY.copy(this.position);this.targetNY.copy(this.position);this.targetPZ.copy(this.position);this.targetNZ.copy(this.position);this.targetPX.x+=1;this.targetNX.x-=1;this.targetPY.y+=
 1;this.targetNY.y-=1;this.targetPZ.z+=1;this.targetNZ.z-=1;this.cameraPX.lookAt(this.targetPX);this.cameraNX.lookAt(this.targetNX);this.cameraPY.lookAt(this.targetPY);this.cameraNY.lookAt(this.targetNY);this.cameraPZ.lookAt(this.targetPZ);this.cameraNZ.lookAt(this.targetNZ)};this.updateCubeMap=function(a,b){var c=this.renderTarget;c.activeCubeFace=0;a.render(b,this.cameraPX,c);c.activeCubeFace=1;a.render(b,this.cameraNX,c);c.activeCubeFace=2;a.render(b,this.cameraPY,c);c.activeCubeFace=3;a.render(b,
-this.cameraNY,c);c.activeCubeFace=4;a.render(b,this.cameraPZ,c);c.activeCubeFace=5;a.render(b,this.cameraNZ,c)}};THREE.FirstPersonCamera=function(){console.warn("DEPRECATED: FirstPersonCamera() is FirstPersonControls().")};THREE.PathCamera=function(){console.warn("DEPRECATED: PathCamera() is PathControls().")};THREE.FlyCamera=function(){console.warn("DEPRECATED: FlyCamera() is FlyControls().")};THREE.RollCamera=function(){console.warn("DEPRECATED: RollCamera() is RollControls().")};
-THREE.TrackballCamera=function(){console.warn("DEPRECATED: TrackballCamera() is TrackballControls().")};THREE.CombinedCamera=function(a,b,c,d,f,g,e){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,g,e);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,f);this.zoom=1;this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera;
+this.cameraNY,c);c.activeCubeFace=4;a.render(b,this.cameraPZ,c);c.activeCubeFace=5;a.render(b,this.cameraNZ,c)}};THREE.CombinedCamera=function(a,b,c,d,f,g,e){THREE.Camera.call(this);this.fov=c;this.left=-a/2;this.right=a/2;this.top=b/2;this.bottom=-b/2;this.cameraO=new THREE.OrthographicCamera(a/-2,a/2,b/2,b/-2,g,e);this.cameraP=new THREE.PerspectiveCamera(c,a/b,d,f);this.zoom=1;this.toPerspective()};THREE.CombinedCamera.prototype=new THREE.Camera;THREE.CombinedCamera.prototype.constructor=THREE.CoolCamera;
 THREE.CombinedCamera.prototype.toPerspective=function(){this.near=this.cameraP.near;this.far=this.cameraP.far;this.cameraP.fov=this.fov/this.zoom;this.cameraP.updateProjectionMatrix();this.projectionMatrix=this.cameraP.projectionMatrix;this.inPersepectiveMode=!0;this.inOrthographicMode=!1};
 THREE.CombinedCamera.prototype.toOrthographic=function(){var a=this.cameraP.aspect,b=(this.cameraP.near+this.cameraP.far)/2,b=Math.tan(this.fov/2)*b,a=2*b*a/2,b=b/this.zoom,a=a/this.zoom;this.cameraO.left=-a;this.cameraO.right=a;this.cameraO.top=b;this.cameraO.bottom=-b;this.cameraO.updateProjectionMatrix();this.near=this.cameraO.near;this.far=this.cameraO.far;this.projectionMatrix=this.cameraO.projectionMatrix;this.inPersepectiveMode=!1;this.inOrthographicMode=!0};
-THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.setLens=function(a,b){b||(b=43.25);var c=2*Math.atan(b/(2*a)),c=180/Math.PI*c;this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};
+THREE.CombinedCamera.prototype.setFov=function(a){this.fov=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};THREE.CombinedCamera.prototype.setLens=function(a,b){var c=2*Math.atan((void 0!==b?b:24)/(2*a))*(180/Math.PI);this.setFov(c);return c};THREE.CombinedCamera.prototype.setZoom=function(a){this.zoom=a;this.inPersepectiveMode?this.toPerspective():this.toOrthographic()};
 THREE.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0;this.rotation.y=Math.PI;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0;this.rotation.y=-Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};
 THREE.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0;this.rotation.y=Math.PI/2;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};THREE.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2;this.rotation.y=0;this.rotation.z=0;this.rotationAutoUpdate=!1};
-THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=void 0!==b?b:document;this.movementSpeed=1;this.lookSpeed=0.0050;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
+THREE.FirstPersonControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.target=new THREE.Vector3(0,0,0);this.domElement=void 0!==b?b:document;this.movementSpeed=1;this.lookSpeed=0.005;this.noFly=!1;this.lookVertical=!0;this.autoForward=!1;this.activeLook=!0;this.heightSpeed=!1;this.heightCoef=1;this.heightMin=0;this.constrainVertical=!1;this.verticalMin=0;this.verticalMax=Math.PI;this.theta=this.phi=this.lon=this.lat=this.mouseY=this.mouseX=this.autoSpeedFactor=
 0;this.mouseDragOn=this.freeze=this.moveRight=this.moveLeft=this.moveBackward=this.moveForward=!1;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));this.onMouseDown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=
 !0;break;case 2:this.moveBackward=!0}this.mouseDragOn=!0};this.onMouseUp=function(a){a.preventDefault();a.stopPropagation();if(this.activeLook)switch(a.button){case 0:this.moveForward=!1;break;case 2:this.moveBackward=!1}this.mouseDragOn=!1};this.onMouseMove=function(a){this.domElement===document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.onKeyDown=
 function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!0;break;case 37:case 65:this.moveLeft=!0;break;case 40:case 83:this.moveBackward=!0;break;case 39:case 68:this.moveRight=!0;break;case 82:this.moveUp=!0;break;case 70:this.moveDown=!0;break;case 81:this.freeze=!this.freeze}};this.onKeyUp=function(a){switch(a.keyCode){case 38:case 87:this.moveForward=!1;break;case 37:case 65:this.moveLeft=!1;break;case 40:case 83:this.moveBackward=!1;break;case 39:case 68:this.moveRight=!1;break;case 82:this.moveUp=
@@ -126,16 +125,16 @@ 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(),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);
+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);
 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/
+new THREE.Object3D;this.animationParent=new THREE.Object3D;this.lookSpeed=0.005;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;
 b=THREE.Math.mapLinear(this.phi,b[0],b[1],a[0],a[1]);var d=a[1]-a[0];this.phi=c((b-a[0])/d)*d+a[0];b=this.horizontalAngleMap.srcRange;a=this.horizontalAngleMap.dstRange;b=THREE.Math.mapLinear(this.theta,b[0],b[1],a[0],a[1]);d=a[1]-a[0];this.theta=c((b-a[0])/d)*d+a[0];a=this.target.position;a.x=100*Math.sin(this.phi)*Math.cos(this.theta);a.y=100*Math.cos(this.phi);a.z=100*Math.sin(this.phi)*Math.sin(this.theta);this.object.lookAt(this.target.position)};this.onMouseMove=function(a){this.domElement===
 document?(this.mouseX=a.pageX-this.viewHalfX,this.mouseY=a.pageY-this.viewHalfY):(this.mouseX=a.pageX-this.domElement.offsetLeft-this.viewHalfX,this.mouseY=a.pageY-this.domElement.offsetTop-this.viewHalfY)};this.init=function(){this.spline=new THREE.Spline;this.spline.initFromArray(this.waypoints);this.useConstantSpeed&&this.spline.reparametrizeByArcLength(this.resamplingCoef);if(this.createDebugDummy){var a=new THREE.MeshLambertMaterial({color:30719}),b=new THREE.MeshLambertMaterial({color:65280}),
 c=new THREE.CubeGeometry(10,10,20),e=new THREE.CubeGeometry(2,2,10);this.animationParent=new THREE.Mesh(c,a);a=new THREE.Mesh(e,b);a.position.set(0,10,0);this.animation=f(this.animationParent,this.spline,this.id,this.duration);this.animationParent.add(this.object);this.animationParent.add(this.target);this.animationParent.add(a)}else this.animation=f(this.animationParent,this.spline,this.id,this.duration),this.animationParent.add(this.target),this.animationParent.add(this.object);if(this.createDebugPath){var a=
 this.debugPath,b=this.spline,e=g(b,10),c=g(b,10),h=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),e=new THREE.Line(e,h),c=new THREE.ParticleSystem(c,new THREE.ParticleBasicMaterial({color:16755200,size:3}));e.scale.set(1,1,1);a.add(e);c.scale.set(1,1,1);a.add(c);for(var e=new THREE.SphereGeometry(1,16,8),h=new THREE.MeshBasicMaterial({color:65280}),n=0;n<b.points.length;n++)c=new THREE.Mesh(e,h),c.position.copy(b.points[n]),a.add(c)}this.domElement.addEventListener("mousemove",d(this,this.onMouseMove),
 !1)}};THREE.PathControlsIdCounter=0;
-THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=void 0!==b?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.0050;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
+THREE.FlyControls=function(a,b){function c(a,b){return function(){b.apply(a,arguments)}}this.object=a;this.domElement=void 0!==b?b:document;b&&this.domElement.setAttribute("tabindex",-1);this.movementSpeed=1;this.rollSpeed=0.005;this.autoForward=this.dragToLook=!1;this.object.useQuaternion=!0;this.tmpQuaternion=new THREE.Quaternion;this.mouseStatus=0;this.moveState={up:0,down:0,left:0,right:0,forward:0,back:0,pitchUp:0,pitchDown:0,yawLeft:0,yawRight:0,rollLeft:0,rollRight:0};this.moveVector=new THREE.Vector3(0,
 0,0);this.rotationVector=new THREE.Vector3(0,0,0);this.handleEvent=function(a){if("function"==typeof this[a.type])this[a.type](a)};this.keydown=function(a){if(!a.altKey){switch(a.keyCode){case 16:this.movementSpeedMultiplier=0.1;break;case 87:this.moveState.forward=1;break;case 83:this.moveState.back=1;break;case 65:this.moveState.left=1;break;case 68:this.moveState.right=1;break;case 82:this.moveState.up=1;break;case 70:this.moveState.down=1;break;case 38:this.moveState.pitchUp=1;break;case 40:this.moveState.pitchDown=
 1;break;case 37:this.moveState.yawLeft=1;break;case 39:this.moveState.yawRight=1;break;case 81:this.moveState.rollLeft=1;break;case 69:this.moveState.rollRight=1}this.updateMovementVector();this.updateRotationVector()}};this.keyup=function(a){switch(a.keyCode){case 16:this.movementSpeedMultiplier=1;break;case 87:this.moveState.forward=0;break;case 83:this.moveState.back=0;break;case 65:this.moveState.left=0;break;case 68:this.moveState.right=0;break;case 82:this.moveState.up=0;break;case 70:this.moveState.down=
 0;break;case 38:this.moveState.pitchUp=0;break;case 40:this.moveState.pitchDown=0;break;case 37:this.moveState.yawLeft=0;break;case 39:this.moveState.yawRight=0;break;case 81:this.moveState.rollLeft=0;break;case 69:this.moveState.rollRight=0}this.updateMovementVector();this.updateRotationVector()};this.mousedown=function(a){this.domElement!==document&&this.domElement.focus();a.preventDefault();a.stopPropagation();if(this.dragToLook)this.mouseStatus++;else switch(a.button){case 0:this.object.moveForward=
@@ -159,39 +158,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,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=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,p=i/2,o=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-p)*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+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=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,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.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,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.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.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,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=
+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=
 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],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;
+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;
 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);
+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.001;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),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.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.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,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]],
+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]],
 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);
@@ -214,13 +213,13 @@ this.update(a);this.lines=new THREE.Line(this.lineGeometry,this.lineMaterial,THR
 THREE.CameraHelper.prototype.update=function(a){function b(a,b,g,e){THREE.CameraHelper.__v.set(b,g,e);THREE.CameraHelper.__projector.unprojectVector(THREE.CameraHelper.__v,THREE.CameraHelper.__c);a=c.pointMap[a];if(void 0!==a){b=0;for(g=a.length;b<g;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(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,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.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 p=0;p<q.length;p++)m=h.vertexColors[q[p]-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()};
 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=
@@ -236,123 +235,123 @@ 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,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));
+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));
 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);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*
+I[3*k+2];var p=I[3*m],o=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(p,o,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 p=I[3*m],o=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(p,o,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*
 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",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:[],
+"XtoY":"XtoZ";break;case "Y":W="X"===R.upAxis?"YtoX":"YtoZ";break;case "Z":W="X"===R.upAxis?"ZtoX":"ZtoY"}ea=b("//dae:library_images/dae:image",e,"image");fa=b("//dae:library_materials/dae:material",x,"material");ga=b("//dae:library_effects/dae:effect",G,"effect");V=b("//dae:library_geometries/dae:geometry",o,"geometry");ha=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");ia=
+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=ia[a]):T=null;Z=new THREE.Object3D;for(a=0;a<T.nodes.length;a++)Z.add(g(T.nodes[a]));ja=[];c(Z);a={scene:Z,morphs:aa,skins:ba,animations:ja,dae:{images:ea,materials:fa,cameras:ha,effects:ga,geometries:V,controllers:U,animations:X,visualScenes:ia,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};ja.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.");
 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 X)for(var i=X[e],j=0;j<i.sampler.length;j++){var k=i.sampler[j];k.create();c=Math.min(c,k.startTime);g=Math.max(g,k.endTime);h=Math.max(h,k.input.length)}e=h;for(var b=T.getChildById(b.skeleton[0],!0)||T.getChildBySid(b.skeleton[0],!0),m,l,g=new THREE.Vector3,n,j=0;j<a.vertices.length;j++)f.skin.bindShapeMatrix.multiplyVector3(a.vertices[j].position);for(c=
-0;c<e;c++){h=[];i=[];for(j=0;j<a.vertices.length;j++)i.push(new THREE.Vertex(new THREE.Vector3));d(b,h,c);j=h;k=f.skin;for(l=0;l<j.length;l++)if(m=j[l],n=-1,"JOINT"==m.type){for(var q=0;q<k.joints.length;q++)if(m.sid==k.joints[q]){n=q;break}if(0<=n){q=k.invBindMatrices[n];m.invBindMatrix=q;m.skinningMatrix=new THREE.Matrix4;m.skinningMatrix.multiply(m.world,q);m.weights=[];for(q=0;q<k.weights.length;q++)for(var o=0;o<k.weights[q].length;o++){var p=k.weights[q][o];p.joint==n&&m.weights.push(p)}}else throw"ColladaLoader: Could not find joint '"+
+0;c<e;c++){h=[];i=[];for(j=0;j<a.vertices.length;j++)i.push(new THREE.Vertex(new THREE.Vector3));d(b,h,c);j=h;k=f.skin;for(l=0;l<j.length;l++)if(m=j[l],n=-1,"JOINT"==m.type){for(var q=0;q<k.joints.length;q++)if(m.sid==k.joints[q]){n=q;break}if(0<=n){q=k.invBindMatrices[n];m.invBindMatrix=q;m.skinningMatrix=new THREE.Matrix4;m.skinningMatrix.multiply(m.world,q);m.weights=[];for(q=0;q<k.weights.length;q++)for(var p=0;p<k.weights[q].length;p++){var o=k.weights[q][p];o.joint==n&&m.weights.push(o)}}else throw"ColladaLoader: Could not find joint '"+
 m.sid+"'.";}for(j=0;j<h.length;j++)if("JOINT"==h[j].type)for(k=0;k<h[j].weights.length;k++)m=h[j].weights[k],l=m.index,m=m.weight,n=a.vertices[l],l=i[l],g.x=n.position.x,g.y=n.position.y,g.z=n.position.z,h[j].skinningMatrix.multiplyVector3(g),l.position.x+=g.x*m,l.position.y+=g.y*m,l.position.z+=g.z*m;a.morphTargets.push({name:"target_"+c,vertices:i})}}}function g(a){var b=new THREE.Object3D,c,d,e,h;for(e=0;e<a.controllers.length;e++){var i=U[a.controllers[e].url];switch(i.type){case "skin":if(V[i.skin.source]){var j=
 new m;j.url=i.skin.source;j.instance_material=a.controllers[e].instance_material;a.geometries.push(j);c=a.controllers[e]}else if(U[i.skin.source]&&(d=i=U[i.skin.source],i.morph&&V[i.morph.source]))j=new m,j.url=i.morph.source,j.instance_material=a.controllers[e].instance_material,a.geometries.push(j);break;case "morph":if(V[i.morph.source])j=new m,j.url=i.morph.source,j.instance_material=a.controllers[e].instance_material,a.geometries.push(j),d=a.controllers[e];console.log("ColladaLoader: Morph-controller partially supported.")}}for(e=
-0;e<a.geometries.length;e++){var i=a.geometries[e],j=i.instance_material,i=V[i.url],k={},l=[],q=0,o;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++){o=j[h];var p=fa[ea[o.target].instance_effect.url].shader;p.material.opacity=!p.material.opacity?1:p.material.opacity;k[o.symbol]=q;l.push(p.material);o=p.material;q++}j=o||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});i=i.mesh.geometry3js;if(1<q){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)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 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;
-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 ka(a,b){var c=[a[b],a[b+1],a[b+2]];P(c,-1);return new THREE.Vector3(c[0],c[1],c[2])}function ca(a){if(R.convertUpAxis){var b=[a[0],a[4],a[8]];P(b,-1);a[0]=b[0];a[4]=b[1];a[8]=b[2];b=[a[1],a[5],a[9]];P(b,-1);a[1]=b[0];a[5]=b[1];a[9]=b[2];b=[a[2],a[6],a[10]];
-P(b,-1);a[2]=b[0];a[6]=b[1];a[10]=b[2];b=[a[0],a[1],a[2]];P(b,-1);a[0]=b[0];a[1]=b[1];a[2]=b[2];b=[a[4],a[5],a[6]];P(b,-1);a[4]=b[0];a[5]=b[1];a[6]=b[2];b=[a[8],a[9],a[10]];P(b,-1);a[8]=b[0];a[9]=b[1];a[10]=b[2];b=[a[3],a[7],a[11]];P(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 Q=null,Y=null,T,la=null,Z={},da={},X={},U={},V={},ea={},fa={},ga={},ia,ha,ma,aa,ba,na=THREE.SmoothShading,R={centerGeometry:!1,
-convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y"},$="Y",W=null,ja=Math.PI/180;e.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 z).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 w).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=
-N(f.textContent);this.bindShapeMatrix=ca(f);break;case "source":f=(new z).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 w).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 w).parse(g));break;case "v":c=M(g.textContent);break;case "vcount":d=M(g.textContent)}}for(f=g=0;f<d.length;f++){for(var h=d[f],i=[],j=0;j<h;j++){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]}}i.push(k);
-g+=e.length}for(j=0;j<i.length;j++)i[j].index=f;this.weights.push(i)}};j.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};j.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};j.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 q).parse(c))}}return this};q.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};q.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};q.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};q.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};q.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 q).parse(b));break;case "instance_camera":this.cameras.push((new C).parse(b));
-break;case "instance_controller":this.controllers.push((new n).parse(b));break;case "instance_geometry":this.geometries.push((new m).parse(b));break;case "instance_light":break;case "instance_node":b=b.getAttribute("url").replace(/^#/,"");(b=Q.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",Q,L,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new q).parse(b));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new l).parse(b));
+0;e<a.geometries.length;e++){var i=a.geometries[e],j=i.instance_material,i=V[i.url],k={},l=[],q=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 o=fa[p.target],r=ga[o.instance_effect.url].shader;r.material.opacity=!r.material.opacity?1:r.material.opacity;k[p.symbol]=q;l.push(r.material);p=r.material;p.name=null==o.name||""===o.name?o.id:o.name;q++}j=p||new THREE.MeshLambertMaterial({color:14540253,shading:THREE.FlatShading});i=i.mesh.geometry3js;
+if(1<q){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)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=ha[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}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;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 ca(a,b){var c=[a[b],a[b+1],a[b+2]];P(c,-1);return new THREE.Vector3(c[0],c[1],c[2])}function da(a){if(R.convertUpAxis){var b=[a[0],a[4],a[8]];P(b,-1);a[0]=b[0];a[4]=b[1];a[8]=b[2];b=[a[1],a[5],a[9]];P(b,-1);a[1]=b[0];a[5]=b[1];a[9]=
+b[2];b=[a[2],a[6],a[10]];P(b,-1);a[2]=b[0];a[6]=b[1];a[10]=b[2];b=[a[0],a[1],a[2]];P(b,-1);a[0]=b[0];a[1]=b[1];a[2]=b[2];b=[a[4],a[5],a[6]];P(b,-1);a[4]=b[0];a[5]=b[1];a[6]=b[2];b=[a[8],a[9],a[10]];P(b,-1);a[8]=b[0];a[9]=b[1];a[10]=b[2];b=[a[3],a[7],a[11]];P(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 Q=null,Z=null,T,la=null,Y={},ea={},X={},U={},V={},fa={},ga={},ha={},ja,ia,ma,aa,ba,na=THREE.SmoothShading,
+R={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y"},$="Y",W=null,ka=Math.PI/180;e.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 z).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 w).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=N(f.textContent);this.bindShapeMatrix=da(f);break;case "source":f=(new z).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 w).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 w).parse(g));break;case "v":c=M(g.textContent);break;case "vcount":d=M(g.textContent)}}for(f=g=0;f<d.length;f++){for(var h=d[f],i=[],j=0;j<h;j++){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]}}i.push(k);g+=e.length}for(j=0;j<i.length;j++)i[j].index=f;this.weights.push(i)}};j.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};j.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};j.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 q).parse(c))}}return this};q.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};q.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};q.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};q.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};q.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 q).parse(b));
+break;case "instance_camera":this.cameras.push((new C).parse(b));break;case "instance_controller":this.controllers.push((new n).parse(b));break;case "instance_geometry":this.geometries.push((new m).parse(b));break;case "instance_light":break;case "instance_node":b=b.getAttribute("url").replace(/^#/,"");(b=Q.evaluate(".//dae:library_nodes//dae:node[@id='"+b+"']",Q,L,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null).iterateNext())&&this.nodes.push((new q).parse(b));break;case "rotate":case "translate":case "scale":case "matrix":case "lookat":case "skew":this.transforms.push((new l).parse(b));
 break;case "extra":break;default:console.log(b.nodeName)}a=[];c=1E6;b=-1E6;for(var d in X)for(var e=X[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(R.convertUpAxis)switch(g){case "X":switch(W){case "XtoY":case "XtoZ":case "YtoX":g=
-"Y";break;case "ZtoX":g="Z"}break;case "Y":switch(W){case "XtoY":case "YtoX":case "ZtoX":g="X";break;case "XtoZ":case "YtoZ":case "ZtoY":g="Z"}break;case "Z":switch(W){case "XtoZ":g="X";break;case "YtoZ":case "ZtoX":case "ZtoY":g="Y"}}var h=b.sampler,i=h.input,j=this.getTransformBySid(b.sid);if(j){-1===a.indexOf(f)&&a.push(f);b=0;for(var k=i.length;b<k;b++){var o=i[b],p=h.getData(j.type,b),r;r=null;for(var s=0,t=d.length;s<t&&null==r;s++){var u=d[s];if(u.time===o)r=u;else if(u.time>o)break}if(!r){r=
-new y(o);s=-1;t=0;for(u=d.length;t<u&&-1==s;t++)d[t].time>=o&&(s=t);o=s;d.splice(-1==o?d.length:o,0,r)}r.addTarget(f,j,g,p)}}else console.log('Could not find transform "'+b.sid+'" in node '+this.id)}for(c=0;c<a.length;c++){e=a[c];for(b=0;b<d.length;b++)if(r=d[b],!r.hasTarget(e)){h=d;f=r;j=b;g=e;i=void 0;a:{i=j?j-1:0;for(i=0<=i?i:i+h.length;0<=i;i--)if(k=h[i],k.hasTarget(g)){i=k;break a}i=null}k=void 0;a:{for(j+=1;j<h.length;j++)if(k=h[j],k.hasTarget(g))break a;k=null}if(i&&k){h=(f.time-i.time)/(k.time-
-i.time);i=i.getTarget(g);j=k.getTarget(g).data;k=i.data;p=void 0;if(k.length){p=[];for(o=0;o<k.length;++o)p[o]=k[o]+(j[o]-k[o])*h}else p=k+(j-k)*h;f.addTarget(g,i.transform,i.member,p)}}}this.keys=d;this.sids=a}this.updateMatrix();return this};q.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a<this.transforms.length;a++)this.transforms[a].apply(this.matrix)};l.prototype.parse=function(a){this.sid=a.getAttribute("sid");this.type=a.nodeName;this.data=N(a.textContent);this.convert();
-return this};l.prototype.convert=function(){switch(this.type){case "matrix":this.obj=ca(this.data);break;case "rotate":this.angle=this.data[3]*ja;case "translate":P(this.data,-1);this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;case "scale":P(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)}};l.prototype.apply=function(a){switch(this.type){case "matrix":a.multiplySelf(this.obj);
+"Y";break;case "ZtoX":g="Z"}break;case "Y":switch(W){case "XtoY":case "YtoX":case "ZtoX":g="X";break;case "XtoZ":case "YtoZ":case "ZtoY":g="Z"}break;case "Z":switch(W){case "XtoZ":g="X";break;case "YtoZ":case "ZtoX":case "ZtoY":g="Y"}}var h=b.sampler,i=h.input,j=this.getTransformBySid(b.sid);if(j){-1===a.indexOf(f)&&a.push(f);b=0;for(var k=i.length;b<k;b++){var p=i[b],o=h.getData(j.type,b),r;r=null;for(var s=0,t=d.length;s<t&&null==r;s++){var u=d[s];if(u.time===p)r=u;else if(u.time>p)break}if(!r){r=
+new y(p);s=-1;t=0;for(u=d.length;t<u&&-1==s;t++)d[t].time>=p&&(s=t);p=s;d.splice(-1==p?d.length:p,0,r)}r.addTarget(f,j,g,o)}}else console.log('Could not find transform "'+b.sid+'" in node '+this.id)}for(c=0;c<a.length;c++){e=a[c];for(b=0;b<d.length;b++)if(r=d[b],!r.hasTarget(e)){h=d;f=r;j=b;g=e;i=void 0;a:{i=j?j-1:0;for(i=0<=i?i:i+h.length;0<=i;i--)if(k=h[i],k.hasTarget(g)){i=k;break a}i=null}k=void 0;a:{for(j+=1;j<h.length;j++)if(k=h[j],k.hasTarget(g))break a;k=null}if(i&&k){h=(f.time-i.time)/(k.time-
+i.time);i=i.getTarget(g);j=k.getTarget(g).data;k=i.data;o=void 0;if(k.length){o=[];for(p=0;p<k.length;++p)o[p]=k[p]+(j[p]-k[p])*h}else o=k+(j-k)*h;f.addTarget(g,i.transform,i.member,o)}}}this.keys=d;this.sids=a}this.updateMatrix();return this};q.prototype.updateMatrix=function(){this.matrix.identity();for(var a=0;a<this.transforms.length;a++)this.transforms[a].apply(this.matrix)};l.prototype.parse=function(a){this.sid=a.getAttribute("sid");this.type=a.nodeName;this.data=N(a.textContent);this.convert();
+return this};l.prototype.convert=function(){switch(this.type){case "matrix":this.obj=da(this.data);break;case "rotate":this.angle=this.data[3]*ka;case "translate":P(this.data,-1);this.obj=new THREE.Vector3(this.data[0],this.data[1],this.data[2]);break;case "scale":P(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)}};l.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)}};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",
+a;break;case "Y":this.obj.y=a;break;case "Z":this.obj.z=a;break;case "ANGLE":this.angle=a*ka;break;default:this.obj.x=a[0],this.obj.y=a[1],this.obj.z=a[2],this.angle=a[3]*ka}}};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};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};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];
-switch(c.nodeName){case "input":this.inputs.push((new w).parse(a.childNodes[b]));break;case "vcount":this.vcount=M(c.textContent);break;case "p":this.p=M(c.textContent)}}return this};u.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=O(a,"count",0);this.stride=O(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 w).parse(a.childNodes[b]);this.input[c.semantic]=c}return this};w.prototype.parse=function(a){this.semantic=a.getAttribute("semantic");this.source=a.getAttribute("source").replace(/^#/,"");this.set=O(a,"set",-1);this.offset=O(a,"offset",0);if("TEXCOORD"==this.semantic&&0>this.set)this.set=0;return this};z.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=S(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=N(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=M(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=S(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};z.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=ca(c);a.push(c)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};x.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 B).parse(a.childNodes[b]);break}return this};A.prototype.isColor=function(){return null==this.texture};A.prototype.isTexture=function(){return null!=this.texture};A.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=N(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};A.prototype.parseTexture=function(a){if(!a.childNodes)return this;a.childNodes[1]&&"extra"===a.childNodes[1].nodeName&&(a=a.childNodes[1],a.childNodes[1]&&"technique"===a.childNodes[1].nodeName&&(a=a.childNodes[1]));for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];
-switch(c.nodeName){case "offsetU":case "offsetV":case "repeatU":case "repeatV":this.texOpts[c.nodeName]=parseFloat(c.textContent);break;case "wrapU":case "wrapV":this.texOpts[c.nodeName]=parseInt(c.textContent);break;default:this.texOpts[c.nodeName]=c.textContent}}return this};F.prototype.parse=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[c.nodeName]=
-(new A).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=Q.evaluate(".//dae:float",c,L,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var e=d.iterateNext(),f=[];e;)f.push(e),e=d.iterateNext();d=f;0<d.length&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();return this};F.prototype.create=function(){var a={},b=void 0!==this.transparency&&1>this.transparency,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];
-if(d instanceof A)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=da[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture(ma+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=na;return this.material=new THREE.MeshLambertMaterial(a)};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 "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};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 "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};
-G.prototype.create=function(){if(null==this.shader)return null};G.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};G.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 E(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new J(this)).parse(d);this.sampler.sid=b;break;case "extra":break;default:console.log(d.nodeName)}}};G.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};
-G.prototype.parseTechnique=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "constant":case "lambert":case "blinn":case "phong":this.shader=(new F(c.nodeName,this)).parse(c)}}};B.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};H.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 z).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new I(this)).parse(c));break;case "channel":this.channel.push((new D(this)).parse(c))}}return this};D.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};I.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 w).parse(c))}}return this};I.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}};I.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":P(c,-1);break;case "scale":P(c,1)}}else c=this.output[b];return c};y.prototype.addTarget=function(a,b,c,d){this.targets.push({sid:a,member:c,transform:b,data:d})};y.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)}};y.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};y.prototype.hasTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return!0;return!1};y.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)}};K.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};K.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};C.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?(la=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")),
+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];
+switch(c.nodeName){case "source":var d=c.getAttribute("id");void 0==Y[d]&&(Y[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=Y[this.vertices.input.POSITION.source].data;for(b=0;b<a.length;b+=3)this.geometry3js.vertices.push(new THREE.Vertex(ca(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.calcNormals&&(this.geometry3js.computeVertexNormals(),delete this.geometry3js.calcNormals);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 p=h.offset+
+1,n=n<p?p:n;switch(h.semantic){case "TEXCOORD":q.push(h.set)}}for(;c<f.length;){var o=[],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=Y[h.source],i=f[c+d*n+h.offset],j=k.accessor.params.length,j*=i,h.semantic){case "VERTEX":o.push(i);break;case "NORMAL":r.push(ca(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(0==r.length)if(h=this.vertices.input.NORMAL){k=Y[h.source];j=k.accessor.params.length;h=0;for(i=o.length;h<i;h++)r.push(ca(k.data,o[h]*j))}else b.calcNormals=!0;if(3===l)d.push(new THREE.Face3(o[0],o[1],o[2],r,s.length?s:new THREE.Color));else if(4===l)d.push(new THREE.Face4(o[0],o[1],o[2],o[3],r,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(o[0],o[e],o[e+1],[r[0],r[e++],r[e]],s))}if(d.length){h=
+0;for(i=d.length;h<i;h++){e=d[h];e.daeMaterial=a.material;b.faces.push(e);for(e=0;e<q.length;e++)o=p[q[e]],o=4<l?[o[0],o[h+1],o[h+2]]:4===l?[o[0],o[1],o[2],o[3]]:[o[0],o[1],o[2]],b.faceVertexUvs[e]||(b.faceVertexUvs[e]=[]),b.faceVertexUvs[e].push(o)}}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];switch(c.nodeName){case "input":this.inputs.push((new w).parse(a.childNodes[b]));break;case "vcount":this.vcount=M(c.textContent);break;case "p":this.p=M(c.textContent)}}return this};u.prototype.parse=function(a){this.params=[];this.source=a.getAttribute("source");this.count=O(a,"count",0);this.stride=
+O(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 w).parse(a.childNodes[b]);this.input[c.semantic]=c}return this};w.prototype.parse=function(a){this.semantic=a.getAttribute("semantic");this.source=a.getAttribute("source").replace(/^#/,
+"");this.set=O(a,"set",-1);this.offset=O(a,"offset",0);if("TEXCOORD"==this.semantic&&0>this.set)this.set=0;return this};z.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=S(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=N(c.textContent);this.type=c.nodeName;break;case "int_array":this.data=
+M(c.textContent);this.type=c.nodeName;break;case "IDREF_array":case "Name_array":this.data=S(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};z.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=da(c);a.push(c)}break;default:console.log("ColladaLoader: Source: Read dont know how to read "+b.type+".")}return a};x.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 B).parse(a.childNodes[b]);break}return this};A.prototype.isColor=function(){return null==this.texture};A.prototype.isTexture=function(){return null!=this.texture};
+A.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=N(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};A.prototype.parseTexture=function(a){if(!a.childNodes)return this;
+a.childNodes[1]&&"extra"===a.childNodes[1].nodeName&&(a=a.childNodes[1],a.childNodes[1]&&"technique"===a.childNodes[1].nodeName&&(a=a.childNodes[1]));for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];switch(c.nodeName){case "offsetU":case "offsetV":case "repeatU":case "repeatV":this.texOpts[c.nodeName]=parseFloat(c.textContent);break;case "wrapU":case "wrapV":this.texOpts[c.nodeName]=parseInt(c.textContent);break;default:this.texOpts[c.nodeName]=c.textContent}}return this};F.prototype.parse=
+function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "ambient":case "emission":case "diffuse":case "specular":case "transparent":this[c.nodeName]=(new A).parse(c);break;case "shininess":case "reflectivity":case "transparency":var d;d=Q.evaluate(".//dae:float",c,L,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);for(var e=d.iterateNext(),f=[];e;)f.push(e),e=d.iterateNext();d=f;0<d.length&&(this[c.nodeName]=parseFloat(d[0].textContent))}}this.create();
+return this};F.prototype.create=function(){var a={},b=void 0!==this.transparency&&1>this.transparency,c;for(c in this)switch(c){case "ambient":case "emission":case "diffuse":case "specular":var d=this[c];if(d instanceof A)if(d.isTexture()){if(this.effect.sampler&&this.effect.surface&&this.effect.sampler.source==this.effect.surface.sid){var e=ea[this.effect.surface.init_from];if(e)e=THREE.ImageUtils.loadTexture(ma+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=na;return this.material=new THREE.MeshLambertMaterial(a)};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 "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};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 "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};G.prototype.create=function(){if(null==this.shader)return null};G.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};
+G.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 E(this)).parse(d);this.surface.sid=b;break;case "sampler2D":this.sampler=(new J(this)).parse(d);this.sampler.sid=b;break;case "extra":break;default:console.log(d.nodeName)}}};G.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};G.prototype.parseTechnique=function(a){for(var b=0;b<a.childNodes.length;b++){var c=a.childNodes[b];if(1==c.nodeType)switch(c.nodeName){case "constant":case "lambert":case "blinn":case "phong":this.shader=(new F(c.nodeName,this)).parse(c)}}};B.prototype.parse=function(a){this.url=a.getAttribute("url").replace(/^#/,"");return this};H.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 z).parse(c);this.source[c.id]=c;break;case "sampler":this.sampler.push((new I(this)).parse(c));break;case "channel":this.channel.push((new D(this)).parse(c))}}return this};D.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};I.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 w).parse(c))}}return this};
+I.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}};I.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":P(c,-1);break;case "scale":P(c,1)}}else c=this.output[b];return c};y.prototype.addTarget=function(a,b,c,d){this.targets.push({sid:a,
+member:c,transform:b,data:d})};y.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)}};y.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};y.prototype.hasTarget=function(a){for(var b=0;b<this.targets.length;++b)if(this.targets[b].sid===a)return!0;return!1};y.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)}};K.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};
+K.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};C.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?(la=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){na=a},applySkin:f,geometries:V,options:R}};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,f){var g=new XMLHttpRequest,e=0;g.onreadystatechange=function(){if(g.readyState===g.DONE)if(200===g.status||0===g.status){var h;try{g.responseText?h=JSON.parse(g.responseText):console.warn("EMPTY: ["+b+"] seems to be unreachable or file there is empty")}catch(i){console.warn("DEPRECATED: ["+b+"] seems to be using old model format or JSON is invalid")}h&&a.createModel(h,c,d);a.onLoadComplete()}else console.error("Couldn't load ["+b+"] ["+g.status+
 "]");else g.readyState===g.LOADING?f&&(0===e&&(e=g.getResponseHeader("Content-Length")),f({total:e,loaded:g.responseText.length})):g.readyState===g.HEADERS_RECEIVED&&(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,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+=
+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;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(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,
+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,
 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(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]=
+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]=
 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[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;
+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;
 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,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,
+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,
 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,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*
+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*
 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,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,
+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,
 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;
@@ -386,30 +385,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,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,
+"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,
 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/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)}}};
+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.001<D.opacity&&0.001<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),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,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,
+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,
 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(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;
+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;
 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(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.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.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 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)}}};
+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)}}};
 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=

+ 34 - 34
build/custom/ThreeSVG.js

@@ -18,11 +18,11 @@ 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){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.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]));
+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);D=k.dot(k);t=k.dot(p);v=k.dot(o);B=p.dot(p);x=p.dot(o);z=1/(D*B-t*t);E=(B*v-t*x)*z;C=(D*x-t*v)*z;return 0<=E&&0<=C&&1>E+C}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;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){var b,k=[];if(a instanceof THREE.Particle){var 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){var 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};
+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,s;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),s=a.matrixWorld,j=s.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=s.multiplyVector3(e.copy(u[b.a].position)),f=s.multiplyVector3(f.copy(u[b.b].position)),g=s.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=s.multiplyVector3(e.copy(u[b.a].position)),
+f=s.multiplyVector3(f.copy(u[b.b].position)),g=s.multiplyVector3(g.copy(u[b.c].position)),h=s.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,D,t,v,B,x,z,E,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}};
@@ -31,8 +31,8 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=
 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*=
+y=a.n44,u=b.n11,D=b.n12,t=b.n13,v=b.n14,B=b.n21,x=b.n22,z=b.n23,E=b.n24,C=b.n31,I=b.n32,A=b.n33,L=b.n34,O=b.n41,M=b.n42,Q=b.n43,T=b.n44;this.n11=c*u+d*B+e*C+f*O;this.n12=c*D+d*x+e*I+f*M;this.n13=c*t+d*z+e*A+f*Q;this.n14=c*v+d*E+e*L+f*T;this.n21=g*u+h*B+l*C+i*O;this.n22=g*D+h*x+l*I+i*M;this.n23=g*t+h*z+l*A+i*Q;this.n24=g*v+h*E+l*L+i*T;this.n31=j*u+m*B+n*C+k*O;this.n32=j*D+m*x+n*I+k*M;this.n33=j*t+m*z+n*A+k*Q;this.n34=j*v+m*E+n*L+k*T;this.n41=p*u+o*B+q*C+y*O;this.n42=p*D+o*x+q*I+y*M;this.n43=p*t+o*
+z+q*A+y*Q;this.n44=p*v+o*E+q*L+y*T;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,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;
@@ -49,8 +49,8 @@ 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*
 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,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,
+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,D=this.n13,t=this.n23,v=this.n33,B=this.n43;this.n11=e*l+f*o+d*D;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*D;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*D;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,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};
@@ -63,22 +63,22 @@ 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=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,
+var e,f,g=[],h,l,i=[],j,m,n=[],k,p=[],o,q,y=[],u,D,t=[],v={objects:[],sprites:[],lights:[],elements:[]},B=new THREE.Vector3,x=new THREE.Vector4,z=new THREE.Matrix4,E=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=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};
+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,R=!1,U,s,r,J,w,G,H,K,F,N,P,X,V,W,S;D=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,U=v.objects.length;a<U;a++)if(F=v.objects[a].object,N=F.matrixWorld,l=0,F instanceof THREE.Mesh){P=F.geometry;X=F.geometry.materials;J=P.vertices;V=P.faces;W=P.faceVertexUvs;P=F.matrixRotationWorld.extractRotation(N);for(s=0,r=J.length;s<r;s++)h=b(),h.positionWorld.copy(J[s].position),N.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(J=0,s=V.length;J<s;J++){r=V[J];if(r instanceof THREE.Face3)if(w=i[r.a],G=i[r.b],H=i[r.c],w.visible&&G.visible&&H.visible)if(R=0>(H.positionScreen.x-w.positionScreen.x)*(G.positionScreen.y-w.positionScreen.y)-(H.positionScreen.y-w.positionScreen.y)*(G.positionScreen.x-w.positionScreen.x),F.doubleSided||
+R!=F.flipSided)K=n[m]=n[m]||new THREE.RenderableFace3,m++,j=K,j.v1.copy(w),j.v2.copy(G),j.v3.copy(H);else continue;else continue;else if(r instanceof THREE.Face4)if(w=i[r.a],G=i[r.b],H=i[r.c],K=i[r.d],w.visible&&G.visible&&H.visible&&K.visible)if(R=0>(K.positionScreen.x-w.positionScreen.x)*(G.positionScreen.y-w.positionScreen.y)-(K.positionScreen.y-w.positionScreen.y)*(G.positionScreen.x-w.positionScreen.x)||0>(G.positionScreen.x-H.positionScreen.x)*(K.positionScreen.y-H.positionScreen.y)-(G.positionScreen.y-
+H.positionScreen.y)*(K.positionScreen.x-H.positionScreen.x),F.doubleSided||R!=F.flipSided)S=p[k]=p[k]||new THREE.RenderableFace4,k++,j=S,j.v1.copy(w),j.v2.copy(G),j.v3.copy(H),j.v4.copy(K);else continue;else continue;j.normalWorld.copy(r.normal);!R&&(F.flipSided||F.doubleSided)&&j.normalWorld.negate();P.multiplyVector3(j.normalWorld);j.centroidWorld.copy(r.centroid);N.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);z.multiplyVector3(j.centroidScreen);H=r.vertexNormals;for(w=
+0,G=H.length;w<G;w++)K=j.vertexNormalsWorld[w],K.copy(H[w]),!R&&(F.flipSided||F.doubleSided)&&K.negate(),P.multiplyVector3(K);for(w=0,G=W.length;w<G;w++)if(S=W[w][J])for(H=0,K=S.length;H<K;H++)j.uvs[w][H]=S[H];j.material=F.material;j.faceMaterial=null!==r.materialIndex?X[r.materialIndex]:null;j.z=j.centroidScreen.z;v.elements.push(j)}}else if(F instanceof THREE.Line){E.multiply(z,N);J=F.geometry.vertices;w=b();w.positionScreen.copy(J[0].position);E.multiplyVector4(w.positionScreen);for(s=1,r=J.length;s<
+r;s++)if(w=b(),w.positionScreen.copy(J[s].position),E.multiplyVector4(w.positionScreen),G=i[l-2],I.copy(w.positionScreen),A.copy(G.positionScreen),d(I,A))I.multiplyScalar(1/I.w),A.multiplyScalar(1/A.w),N=y[q]=y[q]||new THREE.RenderableLine,q++,o=N,o.v1.positionScreen.copy(I),o.v2.positionScreen.copy(A),o.z=Math.max(I.z,A.z),o.material=F.material,v.elements.push(o)}for(a=0,U=v.sprites.length;a<U;a++)if(F=v.sprites[a].object,N=F.matrixWorld,F instanceof THREE.Particle&&(x.set(N.n14,N.n24,N.n34,1),z.multiplyVector4(x),
+x.z/=x.w,0<x.z&&1>x.z))g=t[D]=t[D]||new THREE.RenderableParticle,D++,u=g,u.x=x.x/x.w,u.y=x.y/x.w,u.z=x.z,u.rotation=F.rotation.z,u.scale.x=F.scale.x*Math.abs(u.x-(x.x+e.projectionMatrix.n11)/(x.w+e.projectionMatrix.n14)),u.scale.y=F.scale.y*Math.abs(u.y-(x.y+e.projectionMatrix.n22)/(x.w+e.projectionMatrix.n24)),u.material=F.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,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.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.001>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};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
@@ -91,15 +91,15 @@ d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));for(
 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<
+b,c,d,e,f,w){h=a.vertices[b].position;l=a.vertices[c].position;i=a.vertices[d].position;j=g[e];m=g[f];n=g[w];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;D=m.u-j.u;t=n.u-j.u;v=m.v-j.v;B=n.v-j.v;x=1/(D*B-t*v);I.set((B*k-v*p)*x,(B*o-v*q)*x,(B*y-v*u)*x);A.set((D*p-t*k)*x,(D*q-t*o)*x,(D*u-t*y)*x);E[b].addSelf(I);E[c].addSelf(I);E[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,D,t,v,B,x,z,E=[],C=[],I=new THREE.Vector3,A=new THREE.Vector3,
+L=new THREE.Vector3,O=new THREE.Vector3,M=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)E[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++)M.copy(f.vertexNormals[d]),e=f[Q[d]],
+z=E[e],L.copy(z),L.subSelf(M.multiplyScalar(M.dot(z))).normalize(),O.cross(f.vertexNormals[d],z),e=O.dot(C[e]),e=0>e?-1:1,f.vertexTangents[d]=new THREE.Vector4(L.x,L.y,L.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;
-THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:43.25)/(2*a));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
+THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:24)/(2*a))*(180/Math.PI);this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
 THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
 this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0;this.onlyShadow=this.castShadow=!1;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraLeft=-500;this.shadowCameraTop=this.shadowCameraRight=500;this.shadowCameraBottom=-500;this.shadowCameraVisible=!1;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCascade=
@@ -137,18 +137,18 @@ 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,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);l.appendChild(A)}}else if(r instanceof THREE.RenderableFace4&&(k=r.v1,p=r.v2,o=r.v3,q=r.v4,k.positionScreen.x*=m,k.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,o.positionScreen.x*=m,o.positionScreen.y*=-n,q.positionScreen.x*=m,q.positionScreen.y*=-n,u.addPoint(k.positionScreen.x,
-k.positionScreen.y),u.addPoint(p.positionScreen.x,p.positionScreen.y),u.addPoint(o.positionScreen.x,o.positionScreen.y),u.addPoint(q.positionScreen.x,q.positionScreen.y),y.intersects(u))){var x=k,D=p,F=o,J=q;d.info.render.vertices+=4;d.info.render.faces++;A=b(K++);A.setAttribute("d","M "+x.positionScreen.x+" "+x.positionScreen.y+" L "+D.positionScreen.x+" "+D.positionScreen.y+" L "+F.positionScreen.x+","+F.positionScreen.y+" L "+J.positionScreen.x+","+J.positionScreen.y+"z");s instanceof THREE.MeshBasicMaterial?
-t.copy(s.color):s instanceof THREE.MeshLambertMaterial?E?(t.r=v.r,t.g=v.g,t.b=v.b,a(g,r.centroidWorld,r.normalWorld,t),t.r=Math.max(0,Math.min(s.color.r*t.r,1)),t.g=Math.max(0,Math.min(s.color.g*t.g,1)),t.b=Math.max(0,Math.min(s.color.b*t.b,1))):t.copy(s.color):s instanceof THREE.MeshDepthMaterial?(z=1-s.__2near/(s.__farPlusNear-r.z*s.__farMinusNear),t.setRGB(z,z,z)):s instanceof THREE.MeshNormalMaterial&&t.setRGB(c(r.normalWorld.x),c(r.normalWorld.y),c(r.normalWorld.z));s.wireframe?A.setAttribute("style",
-"fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+s.wireframeLinewidth+"; stroke-opacity: "+s.opacity+"; stroke-linecap: "+s.wireframeLinecap+"; stroke-linejoin: "+s.wireframeLinejoin):A.setAttribute("style","fill: "+t.getContextStyle()+"; fill-opacity: "+s.opacity);l.appendChild(A)}}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};
+THREE.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(E.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==M&&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,D=!1,t=new THREE.Color,v=new THREE.Color,B=new THREE.Color,x=new THREE.Color,z,E=new THREE.Vector3,C=[],I=[],A,L,O,M=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":M=1;break;case "low":M=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,E,s,r;this.autoClear&&this.clear();d.info.render.vertices=0;d.info.render.faces=0;e=h.projectScene(i,j,this.sortElements);f=e.elements;
+g=e.lights;O=L=0;if(D=0<g.length){v.setRGB(0,0,0);B.setRGB(0,0,0);x.setRGB(0,0,0);for(C=0,E=g.length;C<E;C++)r=g[C],s=r.color,r instanceof THREE.AmbientLight?(v.r+=s.r,v.g+=s.g,v.b+=s.b):r instanceof THREE.DirectionalLight?(B.r+=s.r,B.g+=s.g,B.b+=s.b):r instanceof THREE.PointLight&&(x.r+=s.r,x.g+=s.g,x.b+=s.b)}for(C=0,E=f.length;C<E;C++)if(s=f[C],r=s.material,r=r instanceof THREE.MeshFaceMaterial?s.faceMaterial:r,!(null==r||0==r.opacity))if(u.empty(),s instanceof THREE.RenderableParticle)k=s,k.x*=
+m,k.y*=-n;else if(s instanceof THREE.RenderableLine){if(k=s.v1,p=s.v2,k.positionScreen.x*=m,k.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,u.addPoint(k.positionScreen.x,k.positionScreen.y),u.addPoint(p.positionScreen.x,p.positionScreen.y),y.intersects(u)){s=k;var J=p,w=O++;null==I[w]&&(I[w]=document.createElementNS("http://www.w3.org/2000/svg","line"),0==M&&I[w].setAttribute("shape-rendering","crispEdges"));A=I[w];A.setAttribute("x1",s.positionScreen.x);A.setAttribute("y1",s.positionScreen.y);
+A.setAttribute("x2",J.positionScreen.x);A.setAttribute("y2",J.positionScreen.y);r instanceof THREE.LineBasicMaterial&&(A.setAttribute("style","fill: none; stroke: "+r.color.getContextStyle()+"; stroke-width: "+r.linewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.linecap+"; stroke-linejoin: "+r.linejoin),l.appendChild(A))}}else if(s instanceof THREE.RenderableFace3){if(k=s.v1,p=s.v2,o=s.v3,k.positionScreen.x*=m,k.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,o.positionScreen.x*=
+m,o.positionScreen.y*=-n,u.addPoint(k.positionScreen.x,k.positionScreen.y),u.addPoint(p.positionScreen.x,p.positionScreen.y),u.addPoint(o.positionScreen.x,o.positionScreen.y),y.intersects(u)){var J=k,w=p,G=o;d.info.render.vertices+=3;d.info.render.faces++;A=b(L++);A.setAttribute("d","M "+J.positionScreen.x+" "+J.positionScreen.y+" L "+w.positionScreen.x+" "+w.positionScreen.y+" L "+G.positionScreen.x+","+G.positionScreen.y+"z");r instanceof THREE.MeshBasicMaterial?t.copy(r.color):r instanceof THREE.MeshLambertMaterial?
+D?(t.r=v.r,t.g=v.g,t.b=v.b,a(g,s.centroidWorld,s.normalWorld,t),t.r=Math.max(0,Math.min(r.color.r*t.r,1)),t.g=Math.max(0,Math.min(r.color.g*t.g,1)),t.b=Math.max(0,Math.min(r.color.b*t.b,1))):t.copy(r.color):r instanceof THREE.MeshDepthMaterial?(z=1-r.__2near/(r.__farPlusNear-s.z*r.__farMinusNear),t.setRGB(z,z,z)):r instanceof THREE.MeshNormalMaterial&&t.setRGB(c(s.normalWorld.x),c(s.normalWorld.y),c(s.normalWorld.z));r.wireframe?A.setAttribute("style","fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+
+r.wireframeLinewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.wireframeLinecap+"; stroke-linejoin: "+r.wireframeLinejoin):A.setAttribute("style","fill: "+t.getContextStyle()+"; fill-opacity: "+r.opacity);l.appendChild(A)}}else if(s instanceof THREE.RenderableFace4&&(k=s.v1,p=s.v2,o=s.v3,q=s.v4,k.positionScreen.x*=m,k.positionScreen.y*=-n,p.positionScreen.x*=m,p.positionScreen.y*=-n,o.positionScreen.x*=m,o.positionScreen.y*=-n,q.positionScreen.x*=m,q.positionScreen.y*=-n,u.addPoint(k.positionScreen.x,
+k.positionScreen.y),u.addPoint(p.positionScreen.x,p.positionScreen.y),u.addPoint(o.positionScreen.x,o.positionScreen.y),u.addPoint(q.positionScreen.x,q.positionScreen.y),y.intersects(u))){var J=k,w=p,G=o,H=q;d.info.render.vertices+=4;d.info.render.faces++;A=b(L++);A.setAttribute("d","M "+J.positionScreen.x+" "+J.positionScreen.y+" L "+w.positionScreen.x+" "+w.positionScreen.y+" L "+G.positionScreen.x+","+G.positionScreen.y+" L "+H.positionScreen.x+","+H.positionScreen.y+"z");r instanceof THREE.MeshBasicMaterial?
+t.copy(r.color):r instanceof THREE.MeshLambertMaterial?D?(t.r=v.r,t.g=v.g,t.b=v.b,a(g,s.centroidWorld,s.normalWorld,t),t.r=Math.max(0,Math.min(r.color.r*t.r,1)),t.g=Math.max(0,Math.min(r.color.g*t.g,1)),t.b=Math.max(0,Math.min(r.color.b*t.b,1))):t.copy(r.color):r instanceof THREE.MeshDepthMaterial?(z=1-r.__2near/(r.__farPlusNear-s.z*r.__farMinusNear),t.setRGB(z,z,z)):r instanceof THREE.MeshNormalMaterial&&t.setRGB(c(s.normalWorld.x),c(s.normalWorld.y),c(s.normalWorld.z));r.wireframe?A.setAttribute("style",
+"fill: none; stroke: "+t.getContextStyle()+"; stroke-width: "+r.wireframeLinewidth+"; stroke-opacity: "+r.opacity+"; stroke-linecap: "+r.wireframeLinecap+"; stroke-linejoin: "+r.wireframeLinejoin):A.setAttribute("style","fill: "+t.getContextStyle()+"; fill-opacity: "+r.opacity);l.appendChild(A)}}};THREE.RenderableVertex=function(){this.positionWorld=new THREE.Vector3;this.positionScreen=new THREE.Vector4;this.visible=!0};
 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};

+ 125 - 124
build/custom/ThreeWebGL.js

@@ -18,11 +18,11 @@ 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){q.sub(c,a);p=q.dot(b);y=r.add(a,o.copy(b).multiplyScalar(p));return u=c.distanceTo(y)}function d(a,b,c,d){q.sub(d,b);r.sub(c,b);o.sub(a,b);K=q.dot(q);A=q.dot(r);v=q.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.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]));
+THREE.Ray=function(a,b){function c(a,b,c){q.sub(c,a);p=q.dot(b);y=r.add(a,o.copy(b).multiplyScalar(p));return u=c.distanceTo(y)}function d(a,b,c,d){q.sub(d,b);r.sub(c,b);o.sub(a,b);K=q.dot(q);A=q.dot(r);v=q.dot(o);I=r.dot(r);B=r.dot(o);E=1/(K*I-A*A);L=(I*v-A*B)*E;J=(K*B-A*v)*E;return 0<=L&&0<=J&&1>L+J}this.origin=a||new THREE.Vector3;this.direction=b||new THREE.Vector3;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){var b,r=[];if(a instanceof THREE.Particle){var q=c(this.origin,this.direction,a.matrixWorld.getPosition());if(q>a.scale.x)return[];b={distance:q,point:a.position,face:null,object:a};r.push(b)}else if(a instanceof THREE.Mesh){var q=
 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(q>a.geometry.boundingSphere.radius*Math.max(o.x,Math.max(o.y,o.z)))return r;var p,y,f=a.geometry,u=f.vertices,v;a.matrixRotationWorld.extractRotation(a.matrixWorld);for(q=0,o=f.faces.length;q<o;q++)if(b=f.faces[q],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)),p=l.dot(n),!(1.0E-4>Math.abs(p))&&(y=n.dot(j)/p,!(0>y)&&(a.doubleSided||(a.flipSided?0<p:0>p))))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 q=new THREE.Vector3,r=new THREE.Vector3,o=new THREE.Vector3,p,y,u,K,A,v,B,C,I,L,M};
+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 q=new THREE.Vector3,r=new THREE.Vector3,o=new THREE.Vector3,p,y,u,K,A,v,I,B,E,L,J};
 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,m,q){i?(i=!1,b=g<j?g<m?g:m:j<m?j:m,c=h<n?h<q?h:q:n<q?n:q,d=g>j?g>m?g:m:j>m?j:m,e=h>n?h>q?h:q:n>q?n:q):(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<q?h<c?h:c:q<c?q:c:n<q?n<c?n:c:q<c?q: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>q?h>e?h:e:q>e?q:e:n>q?n>e?n:e:q>e?q: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}};
@@ -31,8 +31,8 @@ THREE.Matrix3.prototype={constructor:THREE.Matrix3,transpose:function(){var a,b=
 THREE.Matrix4=function(a,b,c,d,e,g,h,i,k,l,j,n,m,q,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,q||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,q,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=q;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,q=a.n34,r=a.n41,o=a.n42,p=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+q*ma;this.n32=j*K+n*C+m*N+q*T;this.n33=j*A+n*I+m*S+q*aa;this.n34=j*v+n*L+m*xa+q*E;this.n41=r*u+o*B+p*M+y*ma;this.n42=r*K+o*C+p*N+y*T;this.n43=
-r*A+o*I+p*S+y*aa;this.n44=r*v+o*L+p*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*=
+y=a.n44,u=b.n11,K=b.n12,A=b.n13,v=b.n14,I=b.n21,B=b.n22,E=b.n23,L=b.n24,J=b.n31,N=b.n32,ja=b.n33,oa=b.n34,ka=b.n41,X=b.n42,$=b.n43,D=b.n44;this.n11=c*u+d*I+e*J+g*ka;this.n12=c*K+d*B+e*N+g*X;this.n13=c*A+d*E+e*ja+g*$;this.n14=c*v+d*L+e*oa+g*D;this.n21=h*u+i*I+k*J+l*ka;this.n22=h*K+i*B+k*N+l*X;this.n23=h*A+i*E+k*ja+l*$;this.n24=h*v+i*L+k*oa+l*D;this.n31=j*u+n*I+m*J+q*ka;this.n32=j*K+n*B+m*N+q*X;this.n33=j*A+n*E+m*ja+q*$;this.n34=j*v+n*L+m*oa+q*D;this.n41=r*u+o*I+p*J+y*ka;this.n42=r*K+o*B+p*N+y*X;this.n43=
+r*A+o*E+p*ja+y*$;this.n44=r*v+o*L+p*oa+y*D;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,l=this.n32,j=this.n33,n=this.n34,m=this.n41,q=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*q+c*i*k*q+d*e*j*q-a*i*j*q-c*e*n*q+a*h*n*q+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-
@@ -49,8 +49,8 @@ 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*
 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),l=Math.sin(b),j=1-k,n=c*d*j,m=c*e*j,j=d*e*j,c=c*l,q=d*l,l=e*l,e=g+(1-g)*k,g=n+l,d=m-q,n=n-l,h=h+(1-h)*k,l=j+c,m=m+q,j=j-c,i=i+(1-i)*k,k=this.n11,c=this.n21,q=this.n31,r=this.n41,o=this.n12,p=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*p+d*A;this.n31=e*q+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*p+l*A;this.n32=n*q+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*p+i*A;this.n33=m*q+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,
+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,q=d*l,l=e*l,e=g+(1-g)*k,g=n+l,d=m-q,n=n-l,h=h+(1-h)*k,l=j+c,m=m+q,j=j-c,i=i+(1-i)*k,k=this.n11,c=this.n21,q=this.n31,r=this.n41,o=this.n12,p=this.n22,y=this.n32,u=this.n42,K=this.n13,A=this.n23,v=this.n33,I=this.n43;this.n11=e*k+g*o+d*K;this.n21=e*c+g*p+d*A;this.n31=e*q+g*y+d*v;this.n41=e*r+g*u+d*I;this.n12=n*k+h*o+l*K;this.n22=
+n*c+h*p+l*A;this.n32=n*q+h*y+l*v;this.n42=n*r+h*u+l*I;this.n13=m*k+j*o+i*K;this.n23=m*c+j*p+i*A;this.n33=m*q+j*y+i*v;this.n43=m*r+j*u+i*I;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,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};
@@ -63,22 +63,23 @@ 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=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=[],q,r=[],o,p,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=p=q=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[q]=r[q]||new THREE.RenderableFace4,q++,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[p]=y[p]||new THREE.RenderableLine,p++,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};
+var e,g,h=[],i,k,l=[],j,n,m=[],q,r=[],o,p,y=[],u,K,A=[],v={objects:[],sprites:[],lights:[],elements:[]},I=new THREE.Vector3,B=new THREE.Vector4,E=new THREE.Matrix4,L=new THREE.Matrix4,J=new THREE.Frustum,N=new THREE.Vector4,ja=new THREE.Vector4;this.projectVector=function(a,b){b.matrixWorldInverse.getInverse(b.matrixWorld);E.multiply(b.projectionMatrix,b.matrixWorldInverse);E.multiplyVector3(a);return a};this.unprojectVector=function(a,b){b.projectionMatrixInverse.getInverse(b.projectionMatrix);E.multiply(b.matrixWorld,
+b.projectionMatrixInverse);E.multiplyVector3(a);return a};this.pickingRay=function(a,b){var c;a.z=-1;c=new THREE.Vector3(a.x,a.y,1);this.unprojectVector(a,b);this.unprojectVector(c,b);c.subSelf(a).normalize();return new THREE.Ray(a,c)};this.projectGraph=function(b,d){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||J.contains(b))?(E.multiplyVector3(I.copy(b.position)),e=a(),e.object=
+b,e.z=I.z,v.objects.push(e)):b instanceof THREE.Sprite||b instanceof THREE.Particle?(E.multiplyVector3(I.copy(b.position)),e=a(),e.object=b,e.z=I.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,D=e.far,f=!1,I,Ba,S,sa,M,aa,ta,xa,T,Aa,Ga,Ha,Sa,Wa,Ma;K=p=q=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);E.multiply(e.projectionMatrix,e.matrixWorldInverse);J.setFromMatrix(E);v=this.projectGraph(a,!1);for(a=0,I=v.objects.length;a<I;a++)if(T=v.objects[a].object,Aa=T.matrixWorld,k=0,T instanceof THREE.Mesh){Ga=T.geometry;Ha=T.geometry.materials;sa=Ga.vertices;Sa=Ga.faces;Wa=Ga.faceVertexUvs;Ga=T.matrixRotationWorld.extractRotation(Aa);for(Ba=0,S=sa.length;Ba<S;Ba++)i=b(),i.positionWorld.copy(sa[Ba].position),Aa.multiplyVector3(i.positionWorld),
+i.positionScreen.copy(i.positionWorld),E.multiplyVector4(i.positionScreen),i.positionScreen.x/=i.positionScreen.w,i.positionScreen.y/=i.positionScreen.w,i.visible=i.positionScreen.z>h&&i.positionScreen.z<D;for(sa=0,Ba=Sa.length;sa<Ba;sa++){S=Sa[sa];if(S instanceof THREE.Face3)if(M=l[S.a],aa=l[S.b],ta=l[S.c],M.visible&&aa.visible&&ta.visible)if(f=0>(ta.positionScreen.x-M.positionScreen.x)*(aa.positionScreen.y-M.positionScreen.y)-(ta.positionScreen.y-M.positionScreen.y)*(aa.positionScreen.x-M.positionScreen.x),
+T.doubleSided||f!=T.flipSided)xa=m[n]=m[n]||new THREE.RenderableFace3,n++,j=xa,j.v1.copy(M),j.v2.copy(aa),j.v3.copy(ta);else continue;else continue;else if(S instanceof THREE.Face4)if(M=l[S.a],aa=l[S.b],ta=l[S.c],xa=l[S.d],M.visible&&aa.visible&&ta.visible&&xa.visible)if(f=0>(xa.positionScreen.x-M.positionScreen.x)*(aa.positionScreen.y-M.positionScreen.y)-(xa.positionScreen.y-M.positionScreen.y)*(aa.positionScreen.x-M.positionScreen.x)||0>(aa.positionScreen.x-ta.positionScreen.x)*(xa.positionScreen.y-
+ta.positionScreen.y)-(aa.positionScreen.y-ta.positionScreen.y)*(xa.positionScreen.x-ta.positionScreen.x),T.doubleSided||f!=T.flipSided)Ma=r[q]=r[q]||new THREE.RenderableFace4,q++,j=Ma,j.v1.copy(M),j.v2.copy(aa),j.v3.copy(ta),j.v4.copy(xa);else continue;else continue;j.normalWorld.copy(S.normal);!f&&(T.flipSided||T.doubleSided)&&j.normalWorld.negate();Ga.multiplyVector3(j.normalWorld);j.centroidWorld.copy(S.centroid);Aa.multiplyVector3(j.centroidWorld);j.centroidScreen.copy(j.centroidWorld);E.multiplyVector3(j.centroidScreen);
+ta=S.vertexNormals;for(M=0,aa=ta.length;M<aa;M++)xa=j.vertexNormalsWorld[M],xa.copy(ta[M]),!f&&(T.flipSided||T.doubleSided)&&xa.negate(),Ga.multiplyVector3(xa);for(M=0,aa=Wa.length;M<aa;M++)if(Ma=Wa[M][sa])for(ta=0,xa=Ma.length;ta<xa;ta++)j.uvs[M][ta]=Ma[ta];j.material=T.material;j.faceMaterial=null!==S.materialIndex?Ha[S.materialIndex]:null;j.z=j.centroidScreen.z;v.elements.push(j)}}else if(T instanceof THREE.Line){L.multiply(E,Aa);sa=T.geometry.vertices;M=b();M.positionScreen.copy(sa[0].position);
+L.multiplyVector4(M.positionScreen);for(Ba=1,S=sa.length;Ba<S;Ba++)if(M=b(),M.positionScreen.copy(sa[Ba].position),L.multiplyVector4(M.positionScreen),aa=l[k-2],N.copy(M.positionScreen),ja.copy(aa.positionScreen),d(N,ja))N.multiplyScalar(1/N.w),ja.multiplyScalar(1/ja.w),Aa=y[p]=y[p]||new THREE.RenderableLine,p++,o=Aa,o.v1.positionScreen.copy(N),o.v2.positionScreen.copy(ja),o.z=Math.max(N.z,ja.z),o.material=T.material,v.elements.push(o)}for(a=0,I=v.sprites.length;a<I;a++)if(T=v.sprites[a].object,Aa=
+T.matrixWorld,T instanceof THREE.Particle&&(B.set(Aa.n14,Aa.n24,Aa.n34,1),E.multiplyVector4(B),B.z/=B.w,0<B.z&&1>B.z))h=A[K]=A[K]||new THREE.RenderableParticle,K++,u=h,u.x=B.x/B.w,u.y=B.y/B.w,u.z=B.z,u.rotation=T.rotation.z,u.scale.x=T.scale.x*Math.abs(u.x-(B.x+e.projectionMatrix.n11)/(B.w+e.projectionMatrix.n14)),u.scale.y=T.scale.y*Math.abs(u.y-(B.y+e.projectionMatrix.n22)/(B.w+e.projectionMatrix.n24)),u.material=T.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,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.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.001>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};
 THREE.UV.prototype={constructor:THREE.UV,set:function(a,b){this.u=a;this.v=b;return this},copy:function(a){this.u=a.u;this.v=a.v;return this},clone:function(){return new THREE.UV(this.u,this.v)}};
@@ -91,18 +92,18 @@ d[c.b].addSelf(c.normal),d[c.c].addSelf(c.normal),d[c.d].addSelf(c.normal));for(
 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];q=k.x-i.x;r=l.x-i.x;o=k.y-i.y;p=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*q-v*r)*C,(B*o-v*p)*C,(B*y-v*u)*C);S.set((K*r-A*q)*C,(K*p-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,q,r,o,p,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;
+b,c,d,e,g,E){i=a.vertices[b].position;k=a.vertices[c].position;l=a.vertices[d].position;j=h[e];n=h[g];m=h[E];q=k.x-i.x;r=l.x-i.x;o=k.y-i.y;p=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;I=m.v-j.v;B=1/(K*I-A*v);N.set((I*q-v*r)*B,(I*o-v*p)*B,(I*y-v*u)*B);ja.set((K*r-A*q)*B,(K*p-A*o)*B,(K*u-A*y)*B);L[b].addSelf(N);L[c].addSelf(N);L[d].addSelf(N);J[b].addSelf(ja);J[c].addSelf(ja);J[d].addSelf(ja)}var b,c,d,e,g,h,i,k,l,j,n,m,q,r,o,p,y,u,K,A,v,I,B,E,L=[],J=[],N=new THREE.Vector3,ja=new THREE.Vector3,
+oa=new THREE.Vector3,ka=new THREE.Vector3,X=new THREE.Vector3;for(b=0,c=this.vertices.length;b<c;b++)L[b]=new THREE.Vector3,J[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++)X.copy(g.vertexNormals[d]),e=g[$[d]],
+E=L[e],oa.copy(E),oa.subSelf(X.multiplyScalar(X.dot(E))).normalize(),ka.cross(g.vertexNormals[d],E),e=ka.dot(J[e]),e=0>e?-1:1,g.vertexTangents[d]=new THREE.Vector4(oa.x,oa.y,oa.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;
-THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:43.25)/(2*a));this.fov*=180/Math.PI;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()};
+THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;THREE.PerspectiveCamera.prototype.setLens=function(a,b){this.fov=2*Math.atan((void 0!==b?b:24)/(2*a))*(180/Math.PI);this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,g){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=g;this.updateProjectionMatrix()};
 THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){if(this.fullWidth){var a=this.fullWidth/this.fullHeight,b=Math.tan(this.fov*Math.PI/360)*this.near,c=-b,d=a*c,a=Math.abs(a*b-d),c=Math.abs(b-c);this.projectionMatrix=THREE.Matrix4.makeFrustum(d+this.x*a/this.fullWidth,d+(this.x+this.width)*a/this.fullWidth,b-(this.y+this.height)*c/this.fullHeight,b-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix=THREE.Matrix4.makePerspective(this.fov,this.aspect,this.near,
 this.far)};THREE.Light=function(a){THREE.Object3D.call(this);this.color=new THREE.Color(a)};THREE.Light.prototype=new THREE.Object3D;THREE.Light.prototype.constructor=THREE.Light;THREE.Light.prototype.supr=THREE.Object3D.prototype;THREE.AmbientLight=function(a){THREE.Light.call(this,a)};THREE.AmbientLight.prototype=new THREE.Light;THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;
 THREE.DirectionalLight=function(a,b,c){THREE.Light.call(this,a);this.position=new THREE.Vector3(0,1,0);this.target=new THREE.Object3D;this.intensity=void 0!==b?b:1;this.distance=void 0!==c?c:0;this.onlyShadow=this.castShadow=!1;this.shadowCameraNear=50;this.shadowCameraFar=5E3;this.shadowCameraLeft=-500;this.shadowCameraTop=this.shadowCameraRight=500;this.shadowCameraBottom=-500;this.shadowCameraVisible=!1;this.shadowBias=0;this.shadowDarkness=0.5;this.shadowMapHeight=this.shadowMapWidth=512;this.shadowCascade=
@@ -190,125 +191,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,m=j.length,l=a.__vertexArray,k=a.__colorArray,n=a.__sortArray,o=a.__dirtyVertices,q=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],
+var j=a.colors,m=j.length,l=a.__vertexArray,k=a.__colorArray,n=a.__sortArray,o=a.__dirtyVertices,q=a.__dirtyColors,r=a.__webglCustomAttributesList;if(c.sortParticles){Xa.multiplySelf(c.matrixWorld);for(d=0;d<h;d++)e=i[d].position,Na.copy(e),Xa.multiplyVector3(Na),n[d]=[Na.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,l[g]=e.x,l[g+1]=e.y,l[g+2]=e.z;if(q)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(q||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 q(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,q,p=nc,u=p.directional.colors,y=p.directional.positions,v=p.point.colors,A=p.point.positions,I=p.point.distances,L=0,N=0,M=q=0;for(c=0,i=b.length;c<i;c++)if(m=b[c],!m.onlyShadow)if(r=m.color,o=m.intensity,q=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)q=
-3*L,E.gammaInput?(u[q]=r.r*r.r*o*o,u[q+1]=r.g*r.g*o*o,u[q+2]=r.b*r.b*o*o):(u[q]=r.r*o,u[q+1]=r.g*o,u[q+2]=r.b*o),nb.copy(m.matrixWorld.getPosition()),nb.subSelf(m.target.matrixWorld.getPosition()),nb.normalize(),y[q]=nb.x,y[q+1]=nb.y,y[q+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]=q,
-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;p.point.length=N;p.directional.length=L;p.ambient[0]=l;p.ambient[1]=k;p.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=
+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++)aa=Ba=null,sa=M=Ha=Ga=Aa=-1,a[d].render(b,c,lc,mc),aa=Ba=null,sa=M=Ha=Ga=Aa=-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&&D.setBlending(i.blending);D.setDepthTest(i.depthTest);D.setDepthWrite(i.depthWrite);y(i.polygonOffset,i.polygonOffsetFactor,i.polygonOffsetUnits)}D.setObjectFaces(j);m instanceof THREE.BufferGeometry?D.renderBufferDirect(d,f,e,i,m,j):D.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&&D.setBlending(h.blending);D.setDepthTest(h.depthTest);D.setDepthWrite(h.depthWrite);y(h.polygonOffset,h.polygonOffsetFactor,
+h.polygonOffsetUnits)}D.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 q(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||D.initMaterial(d,b,c,e);if(d.morphTargets&&
+!e.__webglMorphTargetInfluences){e.__webglMorphTargetInfluences=new Float32Array(D.maxMorphTargets);for(var g=0,h=D.maxMorphTargets;g<h;g++)e.__webglMorphTargetInfluences[g]=0}var i=!1,g=d.program,h=g.uniforms,j=d.uniforms;g!==Ba&&(f.useProgram(g),Ba=g,i=!0);if(d.id!==sa)sa=d.id,i=!0;if(i||a!==aa)f.uniformMatrix4fv(h.projectionMatrix,!1,a._projectionMatrixArray),a!==aa&&(aa=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,q,p=nc,u=p.directional.colors,y=p.directional.positions,v=p.point.colors,A=p.point.positions,E=p.point.distances,L=0,M=0,N=q=0;for(c=0,i=b.length;c<i;c++)if(m=b[c],!m.onlyShadow)if(r=m.color,o=m.intensity,q=m.distance,m instanceof THREE.AmbientLight)D.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)q=
+3*L,D.gammaInput?(u[q]=r.r*r.r*o*o,u[q+1]=r.g*r.g*o*o,u[q+2]=r.b*r.b*o*o):(u[q]=r.r*o,u[q+1]=r.g*o,u[q+2]=r.b*o),nb.copy(m.matrixWorld.getPosition()),nb.subSelf(m.target.matrixWorld.getPosition()),nb.normalize(),y[q]=nb.x,y[q+1]=nb.y,y[q+2]=nb.z,L+=1;else if(m instanceof THREE.PointLight||m instanceof THREE.SpotLight)N=3*M,D.gammaInput?(v[N]=r.r*r.r*o*o,v[N+1]=r.g*r.g*o*o,v[N+2]=r.b*r.b*o*o):(v[N]=r.r*o,v[N+1]=r.g*o,v[N+2]=r.b*o),m=m.matrixWorld.getPosition(),A[N]=m.x,A[N+1]=m.y,A[N+2]=m.z,E[M]=q,
+M+=1;for(c=3*L,i=u.length;c<i;c++)u[c]=0;for(c=3*M,i=v.length;c<i;c++)v[c]=0;p.point.length=M;p.directional.length=L;p.ambient[0]=l;p.ambient[1]=k;p.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,D.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=B.height/2,j.map.texture=d.map;else if(d instanceof THREE.MeshPhongMaterial)j.shininess.value=d.shininess,D.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)D.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(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,p=l.length;n<p;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,p=l.length;n<p;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,p=l.length;n<p;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,p=l.length;n<
-p;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;p=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[p]=u}k=l[0];n=0===(k.width&k.width-1)&&0===(k.height&k.height-1);p=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,p,p,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,p=i.texture.length;n<p;n++)i._array[n]=l+n}f.uniform1iv(k,i._array);for(n=0,p=i.texture.length;n<p;n++)(k=i.texture[n])&&E.setTexture(k,i._array[n])}if((d instanceof THREE.ShaderMaterial||d instanceof THREE.MeshPhongMaterial||d.envMap)&&
+p;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;p=k;if(D.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[p]=u}k=l[0];n=0===(k.width&k.width-1)&&0===(k.height&k.height-1);p=I(i.format);u=I(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,p,p,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)):D.setTexture(k,l)}else if("tv"===n){if(!i._array){i._array=[];for(n=0,p=i.texture.length;n<p;n++)i._array[n]=l+n}f.uniform1iv(k,i._array);for(n=0,p=i.texture.length;n<p;n++)(k=i.texture[n])&&D.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 p(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))):
+(d instanceof THREE.ShaderMaterial||d.envMap||d.skinning||e.receiveShadow)&&null!==h.objectMatrix&&f.uniformMatrix4fv(h.objectMatrix,!1,e._objectMatrixArray);return g}function p(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||Ma!==c))f.polygonOffset(b,
+c),Wa=b,Ma=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,I(b.wrapS)),f.texParameteri(a,f.TEXTURE_WRAP_T,I(b.wrapT)),f.texParameteri(a,f.TEXTURE_MAG_FILTER,I(b.magFilter)),f.texParameteri(a,f.TEXTURE_MIN_FILTER,I(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;
+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 I(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",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);
+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||{},B=void 0!==a.canvas?a.canvas:document.createElement("canvas"),E=void 0!==a.precision?a.precision:"mediump",L=void 0!==a.alpha?a.alpha:!0,J=void 0!==a.premultipliedAlpha?
+a.premultipliedAlpha:!0,N=void 0!==a.antialias?a.antialias:!1,ja=void 0!==a.stencil?a.stencil:!0,oa=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,ka=void 0!==a.clearColor?new THREE.Color(a.clearColor):new THREE.Color(0),X=void 0!==a.clearAlpha?a.clearAlpha:0,$=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 D=this,f,Va=[],Ba=null,S=null,sa=-1,M=null,aa=null,ta=0,xa=null,T=null,Aa=null,Ga=null,Ha=
+null,Sa=null,Wa=null,Ma=null,tb=null,Nb=0,Xb=0,Hb=0,Ob=0,lc=0,mc=0,Yb=new THREE.Frustum,Xa=new THREE.Matrix4,Na=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=B.getContext("experimental-webgl",{alpha:L,premultipliedAlpha:J,antialias:N,stencil:ja,preserveDrawingBuffer:oa})))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(ka.r,ka.g,ka.b,X);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){B.width=a;B.height=b;this.setViewport(0,0,B.width,B.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){ka.setHex(a);X=b;f.clearColor(ka.r,ka.g,ka.b,X)};this.setClearColor=function(a,b){ka.copy(a);X=b;f.clearColor(ka.r,ka.g,ka.b,X)};this.getClearColor=function(){return ka};this.getClearAlpha=function(){return X};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);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();
+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);D.info.memory.geometries--}else if(a instanceof THREE.Ribbon)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),D.info.memory.geometries--;else if(a instanceof THREE.Line)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),
+D.info.memory.geometries--;else if(a instanceof THREE.ParticleSystem)a=a.geometry,f.deleteBuffer(a.__webglVertexBuffer),f.deleteBuffer(a.__webglColorBuffer),D.info.memory.geometries--};this.deallocateTexture=function(a){if(a.__webglInit)a.__webglInit=!1,f.deleteTexture(a.__webglTexture),D.info.memory.textures--};this.updateShadowMap=function(a,b){Ba=null;sa=M=Ha=Ga=Aa=-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,
+1:0),d!==M&&(M=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),D.info.render.calls++,D.info.render.vertices+=g[d].count,
+D.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!==M&&(M=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=
+f.UNSIGNED_SHORT,0)),D.info.render.calls++,D.info.render.vertices+=e.__webglFaceCount,D.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),D.info.render.calls++):g instanceof THREE.ParticleSystem?(f.drawArrays(f.POINTS,0,e.__webglParticleCount),D.info.render.calls++,D.info.render.points+=e.__webglParticleCount):g instanceof THREE.Ribbon&&(f.drawArrays(f.TRIANGLE_STRIP,
+0,e.__webglVertexCount),D.info.render.calls++)}};this.render=function(a,b,c,d){var e,g,j,m,n=a.lights,r=a.fog;sa=-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);D.info.render.calls=0;D.info.render.vertices=0;D.info.render.faces=0;D.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);p(j,b);var o=g,q=o.object,u=o.buffer,v=void 0,v=v=void 0,v=q.material;if(v instanceof THREE.MeshFaceMaterial){if(v=u.materialIndex,0<=v)v=q.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),p(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),
+g.z=j.renderDepth:(Na.copy(j.position),Xa.multiplyVector3(Na),g.z=Na.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),p(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 p=k,u=void 0,v=void 0,y=void 0,A=void 0,K=void 0,C=void 0,B=void 0,I={},L=p.morphTargets.length,M=p.morphNormals.length;p.geometryGroups={};for(u=0,v=p.faces.length;u<v;u++)y=p.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===p.geometryGroups[B]&&(p.geometryGroups[B]=
-{faces3:[],faces4:[],materialIndex:A,vertices:0,numMorphTargets:L,numMorphNormals:M}),K=y instanceof THREE.Face3?3:4,65535<p.geometryGroups[B].vertices+K&&(I[C].counter+=1,B=I[C].hash+"_"+I[C].counter,void 0===p.geometryGroups[B]&&(p.geometryGroups[B]={faces3:[],faces4:[],materialIndex:A,vertices:0,numMorphTargets:L,numMorphNormals:M})),y instanceof THREE.Face3?p.geometryGroups[B].faces3.push(u):p.geometryGroups[B].faces4.push(u),p.geometryGroups[B].vertices+=K;p.geometryGroupsList=[];var N=void 0;
-for(N in p.geometryGroups)p.geometryGroups[N].id=Ba++,p.geometryGroupsList.push(p.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
+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);M=-1;D.setObjectFaces(e);e.immediateRenderCallback?
+e.immediateRenderCallback(g,f,Yb):e.render(function(a){D.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 p=k,u=void 0,v=void 0,y=void 0,A=void 0,K=void 0,B=void 0,E=void 0,I={},L=p.morphTargets.length,N=p.morphNormals.length;p.geometryGroups={};for(u=0,v=p.faces.length;u<v;u++)y=p.faces[u],A=y.materialIndex,B=void 0!==A?A:-1,void 0===I[B]&&(I[B]={hash:B,counter:0}),E=I[B].hash+"_"+I[B].counter,void 0===p.geometryGroups[E]&&(p.geometryGroups[E]=
+{faces3:[],faces4:[],materialIndex:A,vertices:0,numMorphTargets:L,numMorphNormals:N}),K=y instanceof THREE.Face3?3:4,65535<p.geometryGroups[E].vertices+K&&(I[B].counter+=1,E=I[B].hash+"_"+I[B].counter,void 0===p.geometryGroups[E]&&(p.geometryGroups[E]={faces3:[],faces4:[],materialIndex:A,vertices:0,numMorphTargets:L,numMorphNormals:N})),y instanceof THREE.Face3?p.geometryGroups[E].faces3.push(u):p.geometryGroups[E].faces4.push(u),p.geometryGroups[E].vertices+=K;p.geometryGroupsList=[];var M=void 0;
+for(M in p.geometryGroups)p.geometryGroups[M].id=ta++,p.geometryGroupsList.push(p.geometryGroups[M])}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())}D.info.memory.geometries++;var ca=o,$=h,aa=$.geometry,ja=ca.faces3,
+ka=ca.faces4,S=3*ja.length+4*ka.length,sa=1*ja.length+2*ka.length,xa=3*ja.length+4*ka.length,oa=c($,ca),Aa=e(oa),Ba=d(oa),Ga=oa.vertexColors?oa.vertexColors:!1;ca.__vertexArray=new Float32Array(3*S);if(Ba)ca.__normalArray=new Float32Array(3*S);if(aa.hasTangents)ca.__tangentArray=new Float32Array(4*S);if(Ga)ca.__colorArray=new Float32Array(3*S);if(Aa){if(0<aa.faceUvs.length||0<aa.faceVertexUvs.length)ca.__uvArray=new Float32Array(2*S);if(1<aa.faceUvs.length||1<aa.faceVertexUvs.length)ca.__uv2Array=
+new Float32Array(2*S)}if($.geometry.skinWeights.length&&$.geometry.skinIndices.length)ca.__skinVertexAArray=new Float32Array(4*S),ca.__skinVertexBArray=new Float32Array(4*S),ca.__skinIndexArray=new Float32Array(4*S),ca.__skinWeightArray=new Float32Array(4*S);ca.__faceArray=new Uint16Array(3*sa);ca.__lineArray=new Uint16Array(2*xa);var Ha=void 0,Ma=void 0;if(ca.numMorphTargets){ca.__morphTargetsArrays=[];for(Ha=0,Ma=ca.numMorphTargets;Ha<Ma;Ha++)ca.__morphTargetsArrays.push(new Float32Array(3*S))}if(ca.numMorphNormals){ca.__morphNormalsArrays=
+[];for(Ha=0,Ma=ca.numMorphNormals;Ha<Ma;Ha++)ca.__morphNormalsArrays.push(new Float32Array(3*S))}ca.__webglFaceCount=3*sa;ca.__webglLineCount=2*xa;if(oa.attributes){if(void 0===ca.__webglCustomAttributesList)ca.__webglCustomAttributesList=[];var Va=void 0;for(Va in oa.attributes){var Sa=oa.attributes[Va],La={},Wa;for(Wa in Sa)La[Wa]=Sa[Wa];if(!La.__webglInitialized||La.createUniqueBuffers){La.__webglInitialized=!0;var Na=1;"v2"===La.type?Na=2:"v3"===La.type?Na=3:"v4"===La.type?Na=4:"c"===La.type&&
+(Na=3);La.size=Na;La.array=new Float32Array(S*Na);La.buffer=f.createBuffer();La.buffer.belongsToAttribute=Va;Sa.needsUpdate=!0;La.__original=Sa}ca.__webglCustomAttributesList.push(La)}}ca.__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();
+D.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();D.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();D.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?q(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)&&q(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;
+h instanceof THREE.LensFlare&&i.__webglFlares.push(h);h.__webglActive=!0}a.__objectsAdded.splice(0,1)}for(;a.__objectsRemoved.length;){var Oa=a.__objectsRemoved[0],pc=a;Oa instanceof THREE.Mesh||Oa instanceof THREE.ParticleSystem||Oa instanceof THREE.Ribbon||Oa instanceof THREE.Line?q(pc.__webglObjects,Oa):Oa instanceof THREE.Sprite?r(pc.__webglSprites,Oa):Oa instanceof THREE.LensFlare?r(pc.__webglFlares,Oa):(Oa instanceof THREE.MarchingCubes||Oa.immediateRenderCallback)&&q(pc.__webglObjectsImmediate,
+Oa);Oa.__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,Ea=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],Ea=c(Ta,$b),Qb=Ea.attributes&&n(Ea),R.__dirtyVertices||R.__dirtyMorphTargets||
+R.__dirtyElements||R.__dirtyUvs||R.__dirtyNormals||R.__dirtyColors||R.__dirtyTangents||Qb){var P=$b,nc=Ta,Ia=f.DYNAMIC_DRAW,oc=!R.dynamic,Ib=Ea;if(P.__inittedArrays){var Qc=d(Ib),Ic=Ib.vertexColors?Ib.vertexColors:!1,Rc=e(Ib),qc=Qc===THREE.SmoothShading,w=void 0,C=void 0,Ra=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,Y=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,ua=void 0,Tc=void 0,qa=void 0,ra=void 0,Cb=void 0,pb=void 0,la=0,pa=0,qb=0,rb=0,Pa=0,za=0,Z=0,Ca=0,ma=0,x=0,O=0,t=0,Ja=void 0,va=P.__vertexArray,fc=P.__uvArray,gc=P.__uv2Array,Qa=P.__normalArray,da=P.__tangentArray,wa=P.__colorArray,ea=P.__skinVertexAArray,fa=P.__skinVertexBArray,ga=
+P.__skinIndexArray,ha=P.__skinWeightArray,Jc=P.__morphTargetsArrays,Kc=P.__morphNormalsArrays,Lc=P.__webglCustomAttributesList,s=void 0,mb=P.__faceArray,Ka=P.__lineArray,Da=nc.geometry,Ec=Da.__dirtyElements,Uc=Da.__dirtyUvs,ad=Da.__dirtyNormals,bd=Da.__dirtyTangents,cd=Da.__dirtyColors,dd=Da.__dirtyMorphTargets,Jb=Da.vertices,V=P.faces3,W=P.faces4,na=Da.faces,Mc=Da.faceVertexUvs[0],Nc=Da.faceVertexUvs[1],Kb=Da.skinVerticesA,Lb=Da.skinVerticesB,Mb=Da.skinIndices,Db=Da.skinWeights,Eb=Da.morphTargets,
+uc=Da.morphNormals;if(Da.__dirtyVertices){for(w=0,C=V.length;w<C;w++)z=na[V[w]],F=Jb[z.a].position,G=Jb[z.b].position,H=Jb[z.c].position,va[pa]=F.x,va[pa+1]=F.y,va[pa+2]=F.z,va[pa+3]=G.x,va[pa+4]=G.y,va[pa+5]=G.z,va[pa+6]=H.x,va[pa+7]=H.y,va[pa+8]=H.z,pa+=9;for(w=0,C=W.length;w<C;w++)z=na[W[w]],F=Jb[z.a].position,G=Jb[z.b].position,H=Jb[z.c].position,Y=Jb[z.d].position,va[pa]=F.x,va[pa+1]=F.y,va[pa+2]=F.z,va[pa+3]=G.x,va[pa+4]=G.y,va[pa+5]=G.z,va[pa+6]=H.x,va[pa+7]=H.y,va[pa+8]=H.z,va[pa+9]=Y.x,va[pa+
+10]=Y.y,va[pa+11]=Y.z,pa+=12;f.bindBuffer(f.ARRAY_BUFFER,P.__webglVertexBuffer);f.bufferData(f.ARRAY_BUFFER,va,Ia)}if(dd)for(ua=0,Tc=Eb.length;ua<Tc;ua++){O=0;for(w=0,C=V.length;w<C;w++){Cb=V[w];z=na[Cb];F=Eb[ua].vertices[z.a].position;G=Eb[ua].vertices[z.b].position;H=Eb[ua].vertices[z.c].position;qa=Jc[ua];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(Ib.morphNormals)qc?(pb=uc[ua].vertexNormals[Cb],ab=pb.a,bb=pb.b,cb=pb.c):cb=bb=ab=
+uc[ua].faceNormals[Cb],ra=Kc[ua],ra[O]=ab.x,ra[O+1]=ab.y,ra[O+2]=ab.z,ra[O+3]=bb.x,ra[O+4]=bb.y,ra[O+5]=bb.z,ra[O+6]=cb.x,ra[O+7]=cb.y,ra[O+8]=cb.z;O+=9}for(w=0,C=W.length;w<C;w++){Cb=W[w];z=na[Cb];F=Eb[ua].vertices[z.a].position;G=Eb[ua].vertices[z.b].position;H=Eb[ua].vertices[z.c].position;Y=Eb[ua].vertices[z.d].position;qa=Jc[ua];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(Ib.morphNormals)qc?
+(pb=uc[ua].vertexNormals[Cb],ab=pb.a,bb=pb.b,cb=pb.c,bc=pb.d):bc=cb=bb=ab=uc[ua].faceNormals[Cb],ra=Kc[ua],ra[O]=ab.x,ra[O+1]=ab.y,ra[O+2]=ab.z,ra[O+3]=bb.x,ra[O+4]=bb.y,ra[O+5]=bb.z,ra[O+6]=cb.x,ra[O+7]=cb.y,ra[O+8]=cb.z,ra[O+9]=bc.x,ra[O+10]=bc.y,ra[O+11]=bc.z;O+=12}f.bindBuffer(f.ARRAY_BUFFER,P.__webglMorphTargetsBuffers[ua]);f.bufferData(f.ARRAY_BUFFER,Jc[ua],Ia);Ib.morphNormals&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglMorphNormalsBuffers[ua]),f.bufferData(f.ARRAY_BUFFER,Kc[ua],Ia))}if(Db.length){for(w=
+0,C=V.length;w<C;w++)z=na[V[w]],gb=Db[z.a],hb=Db[z.b],ib=Db[z.c],ha[x]=gb.x,ha[x+1]=gb.y,ha[x+2]=gb.z,ha[x+3]=gb.w,ha[x+4]=hb.x,ha[x+5]=hb.y,ha[x+6]=hb.z,ha[x+7]=hb.w,ha[x+8]=ib.x,ha[x+9]=ib.y,ha[x+10]=ib.z,ha[x+11]=ib.w,jb=Mb[z.a],kb=Mb[z.b],lb=Mb[z.c],ga[x]=jb.x,ga[x+1]=jb.y,ga[x+2]=jb.z,ga[x+3]=jb.w,ga[x+4]=kb.x,ga[x+5]=kb.y,ga[x+6]=kb.z,ga[x+7]=kb.w,ga[x+8]=lb.x,ga[x+9]=lb.y,ga[x+10]=lb.z,ga[x+11]=lb.w,vb=Kb[z.a],wb=Kb[z.b],xb=Kb[z.c],ea[x]=vb.x,ea[x+1]=vb.y,ea[x+2]=vb.z,ea[x+3]=1,ea[x+4]=wb.x,
+ea[x+5]=wb.y,ea[x+6]=wb.z,ea[x+7]=1,ea[x+8]=xb.x,ea[x+9]=xb.y,ea[x+10]=xb.z,ea[x+11]=1,yb=Lb[z.a],zb=Lb[z.b],Ab=Lb[z.c],fa[x]=yb.x,fa[x+1]=yb.y,fa[x+2]=yb.z,fa[x+3]=1,fa[x+4]=zb.x,fa[x+5]=zb.y,fa[x+6]=zb.z,fa[x+7]=1,fa[x+8]=Ab.x,fa[x+9]=Ab.y,fa[x+10]=Ab.z,fa[x+11]=1,x+=12;for(w=0,C=W.length;w<C;w++)z=na[W[w]],gb=Db[z.a],hb=Db[z.b],ib=Db[z.c],dc=Db[z.d],ha[x]=gb.x,ha[x+1]=gb.y,ha[x+2]=gb.z,ha[x+3]=gb.w,ha[x+4]=hb.x,ha[x+5]=hb.y,ha[x+6]=hb.z,ha[x+7]=hb.w,ha[x+8]=ib.x,ha[x+9]=ib.y,ha[x+10]=ib.z,ha[x+
+11]=ib.w,ha[x+12]=dc.x,ha[x+13]=dc.y,ha[x+14]=dc.z,ha[x+15]=dc.w,jb=Mb[z.a],kb=Mb[z.b],lb=Mb[z.c],ec=Mb[z.d],ga[x]=jb.x,ga[x+1]=jb.y,ga[x+2]=jb.z,ga[x+3]=jb.w,ga[x+4]=kb.x,ga[x+5]=kb.y,ga[x+6]=kb.z,ga[x+7]=kb.w,ga[x+8]=lb.x,ga[x+9]=lb.y,ga[x+10]=lb.z,ga[x+11]=lb.w,ga[x+12]=ec.x,ga[x+13]=ec.y,ga[x+14]=ec.z,ga[x+15]=ec.w,vb=Kb[z.a],wb=Kb[z.b],xb=Kb[z.c],sc=Kb[z.d],ea[x]=vb.x,ea[x+1]=vb.y,ea[x+2]=vb.z,ea[x+3]=1,ea[x+4]=wb.x,ea[x+5]=wb.y,ea[x+6]=wb.z,ea[x+7]=1,ea[x+8]=xb.x,ea[x+9]=xb.y,ea[x+10]=xb.z,
+ea[x+11]=1,ea[x+12]=sc.x,ea[x+13]=sc.y,ea[x+14]=sc.z,ea[x+15]=1,yb=Lb[z.a],zb=Lb[z.b],Ab=Lb[z.c],tc=Lb[z.d],fa[x]=yb.x,fa[x+1]=yb.y,fa[x+2]=yb.z,fa[x+3]=1,fa[x+4]=zb.x,fa[x+5]=zb.y,fa[x+6]=zb.z,fa[x+7]=1,fa[x+8]=Ab.x,fa[x+9]=Ab.y,fa[x+10]=Ab.z,fa[x+11]=1,fa[x+12]=tc.x,fa[x+13]=tc.y,fa[x+14]=tc.z,fa[x+15]=1,x+=16;0<x&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglSkinVertexABuffer),f.bufferData(f.ARRAY_BUFFER,ea,Ia),f.bindBuffer(f.ARRAY_BUFFER,P.__webglSkinVertexBBuffer),f.bufferData(f.ARRAY_BUFFER,fa,Ia),
+f.bindBuffer(f.ARRAY_BUFFER,P.__webglSkinIndicesBuffer),f.bufferData(f.ARRAY_BUFFER,ga,Ia),f.bindBuffer(f.ARRAY_BUFFER,P.__webglSkinWeightsBuffer),f.bufferData(f.ARRAY_BUFFER,ha,Ia))}if(cd&&Ic){for(w=0,C=V.length;w<C;w++)z=na[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,wa[ma]=db.r,wa[ma+1]=db.g,wa[ma+2]=db.b,wa[ma+3]=eb.r,wa[ma+4]=eb.g,wa[ma+5]=eb.b,wa[ma+6]=fb.r,wa[ma+7]=fb.g,wa[ma+8]=fb.b,ma+=9;for(w=0,C=W.length;w<C;w++)z=na[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,wa[ma]=db.r,wa[ma+1]=db.g,wa[ma+2]=db.b,wa[ma+3]=eb.r,wa[ma+4]=eb.g,wa[ma+5]=eb.b,wa[ma+6]=fb.r,wa[ma+7]=fb.g,wa[ma+8]=fb.b,wa[ma+9]=cc.r,wa[ma+10]=cc.g,wa[ma+11]=cc.b,ma+=12;0<ma&&(f.bindBuffer(f.ARRAY_BUFFER,P.__webglColorBuffer),f.bufferData(f.ARRAY_BUFFER,wa,Ia))}if(bd&&Da.hasTangents){for(w=0,C=V.length;w<C;w++)z=na[V[w]],ob=z.vertexTangents,Ya=ob[0],Za=ob[1],$a=ob[2],da[Z]=
+Ya.x,da[Z+1]=Ya.y,da[Z+2]=Ya.z,da[Z+3]=Ya.w,da[Z+4]=Za.x,da[Z+5]=Za.y,da[Z+6]=Za.z,da[Z+7]=Za.w,da[Z+8]=$a.x,da[Z+9]=$a.y,da[Z+10]=$a.z,da[Z+11]=$a.w,Z+=12;for(w=0,C=W.length;w<C;w++)z=na[W[w]],ob=z.vertexTangents,Ya=ob[0],Za=ob[1],$a=ob[2],ac=ob[3],da[Z]=Ya.x,da[Z+1]=Ya.y,da[Z+2]=Ya.z,da[Z+3]=Ya.w,da[Z+4]=Za.x,da[Z+5]=Za.y,da[Z+6]=Za.z,da[Z+7]=Za.w,da[Z+8]=$a.x,da[Z+9]=$a.y,da[Z+10]=$a.z,da[Z+11]=$a.w,da[Z+12]=ac.x,da[Z+13]=ac.y,da[Z+14]=ac.z,da[Z+15]=ac.w,Z+=16;f.bindBuffer(f.ARRAY_BUFFER,P.__webglTangentBuffer);
+f.bufferData(f.ARRAY_BUFFER,da,Ia)}if(ad&&Qc){for(w=0,C=V.length;w<C;w++)if(z=na[V[w]],Rb=z.vertexNormals,ub=z.normal,3===Rb.length&&qc)for(U=0;3>U;U++)Bb=Rb[U],Qa[za]=Bb.x,Qa[za+1]=Bb.y,Qa[za+2]=Bb.z,za+=3;else for(U=0;3>U;U++)Qa[za]=ub.x,Qa[za+1]=ub.y,Qa[za+2]=ub.z,za+=3;for(w=0,C=W.length;w<C;w++)if(z=na[W[w]],Rb=z.vertexNormals,ub=z.normal,4===Rb.length&&qc)for(U=0;4>U;U++)Bb=Rb[U],Qa[za]=Bb.x,Qa[za+1]=Bb.y,Qa[za+2]=Bb.z,za+=3;else for(U=0;4>U;U++)Qa[za]=ub.x,Qa[za+1]=ub.y,Qa[za+2]=ub.z,za+=3;
+f.bindBuffer(f.ARRAY_BUFFER,P.__webglNormalBuffer);f.bufferData(f.ARRAY_BUFFER,Qa,Ia)}if(Uc&&Mc&&Rc){for(w=0,C=V.length;w<C;w++)if(Ra=V[w],z=na[Ra],Sb=Mc[Ra],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,C=W.length;w<C;w++)if(Ra=W[w],z=na[Ra],Sb=Mc[Ra],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,Ia))}if(Uc&&Nc&&Rc){for(w=0,C=V.length;w<C;w++)if(Ra=V[w],z=na[Ra],
+Tb=Nc[Ra],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,C=W.length;w<C;w++)if(Ra=W[w],z=na[Ra],Tb=Nc[Ra],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,Ia))}if(Ec){for(w=0,C=V.length;w<C;w++)z=na[V[w]],mb[Pa]=la,mb[Pa+1]=la+1,mb[Pa+2]=la+2,Pa+=3,Ka[Ca]=la,Ka[Ca+1]=la+1,Ka[Ca+2]=la,Ka[Ca+3]=la+2,Ka[Ca+4]=la+1,Ka[Ca+5]=la+2,Ca+=6,la+=3;for(w=0,C=W.length;w<C;w++)z=
+na[W[w]],mb[Pa]=la,mb[Pa+1]=la+1,mb[Pa+2]=la+3,mb[Pa+3]=la+1,mb[Pa+4]=la+2,mb[Pa+5]=la+3,Pa+=6,Ka[Ca]=la,Ka[Ca+1]=la+1,Ka[Ca+2]=la,Ka[Ca+3]=la+3,Ka[Ca+4]=la+1,Ka[Ca+5]=la+2,Ka[Ca+6]=la+2,Ka[Ca+7]=la+3,Ca+=8,la+=4;f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,P.__webglFaceBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,mb,Ia);f.bindBuffer(f.ELEMENT_ARRAY_BUFFER,P.__webglLineBuffer);f.bufferData(f.ELEMENT_ARRAY_BUFFER,Ka,Ia)}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,C=V.length;w<C;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,C=W.length;w<C;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,C=V.length;w<C;w++)Ja=s.value[V[w]],s.array[t]=Ja,s.array[t+1]=Ja,s.array[t+2]=Ja,t+=3;for(w=0,C=W.length;w<C;w++)Ja=s.value[W[w]],s.array[t]=Ja,s.array[t+1]=Ja,s.array[t+
+2]=Ja,s.array[t+3]=Ja,t+=4}}else if(2===s.size)if(void 0===s.boundTo||"vertices"===s.boundTo){for(w=0,C=V.length;w<C;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,C=W.length;w<C;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,C=V.length;w<C;w++)H=G=F=Ja=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,C=W.length;w<C;w++)Y=H=G=F=Ja=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,C=V.length;w<C;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,C=W.length;w<C;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,C=V.length;w<C;w++)H=G=F=Ja=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,C=W.length;w<C;w++)Y=H=G=F=Ja=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,C=V.length;w<C;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,C=W.length;w<C;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,C=V.length;w<C;w++)H=G=F=Ja=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,C=W.length;w<C;w++)Y=H=G=F=Ja=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,Ia)}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;Ea.attributes&&m(Ea)}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){Ea=c(Ta,$b);Qb=Ea.attributes&&n(Ea);if(R.__dirtyVertices||R.__dirtyColors||Qb){var sb=R,Oc=f.DYNAMIC_DRAW,jc=void 0,kc=void 0,zc=void 0,ia=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,ya=void 0,Wb=void 0,Fa=void 0,ba=void 0;if(sb.__dirtyVertices){for(jc=0;jc<hd;jc++)zc=Yc[jc].position,ia=3*jc,Bc[ia]=zc.x,Bc[ia+1]=zc.y,Bc[ia+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],ia=3*kc,Cc[ia]=Ac.r,Cc[ia+1]=Ac.g,Cc[ia+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)){ia=0;Wb=ba.value.length;if(1===ba.size)for(ya=0;ya<Wb;ya++)ba.array[ya]=ba.value[ya];else if(2===ba.size)for(ya=0;ya<Wb;ya++)Fa=ba.value[ya],ba.array[ia]=Fa.x,ba.array[ia+1]=Fa.y,ia+=2;else if(3===ba.size)if("c"===ba.type)for(ya=0;ya<Wb;ya++)Fa=ba.value[ya],ba.array[ia]=Fa.r,ba.array[ia+1]=Fa.g,ba.array[ia+2]=Fa.b,ia+=3;else for(ya=0;ya<Wb;ya++)Fa=ba.value[ya],ba.array[ia]=Fa.x,ba.array[ia+1]=Fa.y,
+ba.array[ia+2]=Fa.z,ia+=3;else if(4===ba.size)for(ya=0;ya<Wb;ya++)Fa=ba.value[ya],ba.array[ia]=Fa.x,ba.array[ia+1]=Fa.y,ba.array[ia+2]=Fa.z,ba.array[ia+3]=Fa.w,ia+=4;f.bindBuffer(f.ARRAY_BUFFER,ba.buffer);f.bufferData(f.ARRAY_BUFFER,ba.array,Oc)}}R.__dirtyVertices=!1;R.__dirtyColors=!1;Ea.attributes&&m(Ea)}else if(Ta instanceof THREE.ParticleSystem)Ea=c(Ta,$b),Qb=Ea.attributes&&n(Ea),(R.__dirtyVertices||R.__dirtyColors||Ta.sortParticles||Qb)&&g(R,f.DYNAMIC_DRAW,Ta),R.__dirtyVertices=!1,R.__dirtyColors=
+!1,Ea.attributes&&m(Ea)}};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 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},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=Va.length;p<d;p++)if(Va[p].code===j){o=Va[p].program;break a}p=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 "+
+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=Va.length;p<d;p++)if(Va[p].code===j){o=Va[p].program;break a}p=f.createProgram();d=[0<oc?"#define VERTEX_TEXTURES":"",D.gammaInput?"#define GAMMA_INPUT":"",D.gammaOutput?"#define GAMMA_OUTPUT":"",D.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?
+e=["precision "+E+" float;","#define MAX_DIR_LIGHTS "+c.maxDirLights,"#define MAX_POINT_LIGHTS "+c.maxPointLights,"#define MAX_SHADOWS "+c.maxShadows,c.alphaTest?"#define ALPHATEST "+c.alphaTest:"",D.gammaInput?"#define GAMMA_INPUT":"",D.gammaOutput?"#define GAMMA_OUTPUT":"",D.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 q,d="viewMatrix,modelViewMatrix,projectionMatrix,normalMatrix,objectMatrix,cameraPosition,boneGlobalMatrices,morphTargetInfluences".split(",");for(q in k)d.push(q);q=d;for(d=0,k=q.length;d<k;d++)l=q[d],p.uniforms[l]=f.getUniformLocation(p,l);d="position,normal,uv,uv2,tangent,color,skinVertexA,skinVertexB,skinIndex,skinWeight".split(",");
-for(q=0;q<c.maxMorphTargets;q++)d.push("morphTarget"+q);for(q=0;q<c.maxMorphNormals;q++)d.push("morphNormal"+q);for(o in b)d.push(o);o=d;for(q=0,b=o.length;q<b;q++)c=o[q],p.attributes[c]=f.getAttribLocation(p,c);p.id=Va.length;Va.push({program:p,code:j});E.info.memory.programs=Va.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);
+for(q=0;q<c.maxMorphTargets;q++)d.push("morphTarget"+q);for(q=0;q<c.maxMorphNormals;q++)d.push("morphNormal"+q);for(o in b)d.push(o);o=d;for(q=0,b=o.length;q<b;q++)c=o[q],p.attributes[c]=f.getAttribLocation(p,c);p.id=Va.length;Va.push({program:p,code:j});D.info.memory.programs=Va.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++)q=p+i,0<=o[q]&&(f.enableVertexAttribArray(o[q]),a.numSupportedMorphTargets++)}if(a.morphNormals){a.numSupportedMorphNormals=
-0;p="morphNormal";for(i=0;i<this.maxMorphNormals;i++)q=p+i,0<=o[q]&&(f.enableVertexAttribArray(o[q]),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+
+0;p="morphNormal";for(i=0;i<this.maxMorphNormals;i++)q=p+i,0<=o[q]&&(f.enableVertexAttribArray(o[q]),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(xa!==a.doubleSided)a.doubleSided?
+f.disable(f.CULL_FACE):f.enable(f.CULL_FACE),xa=a.doubleSided;if(T!==a.flipSided)a.flipSided?f.frontFace(f.CW):f.frontFace(f.CCW),T=a.flipSided};this.setDepthTest=function(a){Ga!==a&&(a?f.enable(f.DEPTH_TEST):f.disable(f.DEPTH_TEST),Ga=a)};this.setDepthWrite=function(a){Ha!==a&&(f.depthMask(a),Ha=a)};this.setBlending=function(a){if(a!==Aa){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)}Aa=a}};this.setTexture=function(a,b){if(a.needsUpdate){if(!a.__webglInit)a.__webglInit=!0,a.__webglTexture=f.createTexture(),D.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=I(a.format),g=I(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=I(a.format),e=I(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=
+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!==S&&(f.bindFramebuffer(f.FRAMEBUFFER,b),f.viewport(e,c,d,a),S=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};
@@ -332,10 +333,10 @@ THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.le
 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,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,q=g+this.yd+this.zd,r=k+this.yd+this.zd,o=0,p=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[q],C=this.field[r];p<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,p,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,p,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(q),this.compNorm(r),this.VIntX(3*q,this.vlist,this.nlist,18,h,a,N,L,B,C));I&128&&(this.compNorm(j),this.compNorm(q),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,p,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(q),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+
+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,q=g+this.yd+this.zd,r=k+this.yd+this.zd,o=0,p=this.field[g],y=this.field[k],u=this.field[l],K=this.field[n],A=this.field[j],v=this.field[m],I=this.field[q],B=this.field[r];p<h&&(o|=1);y<h&&(o|=2);u<h&&(o|=8);K<h&&(o|=4);A<h&&(o|=16);v<h&&(o|=32);I<h&&(o|=128);B<h&&(o|=64);var E=THREE.edgeTable[o];if(0===E)return 0;var L=this.delta,J=a+
+L,N=b+L,L=e+L;E&1&&(this.compNorm(g),this.compNorm(k),this.VIntX(3*g,this.vlist,this.nlist,0,h,a,b,e,p,y));E&2&&(this.compNorm(k),this.compNorm(n),this.VIntY(3*k,this.vlist,this.nlist,3,h,J,b,e,y,K));E&4&&(this.compNorm(l),this.compNorm(n),this.VIntX(3*l,this.vlist,this.nlist,6,h,a,N,e,u,K));E&8&&(this.compNorm(g),this.compNorm(l),this.VIntY(3*g,this.vlist,this.nlist,9,h,a,b,e,p,u));E&16&&(this.compNorm(j),this.compNorm(m),this.VIntX(3*j,this.vlist,this.nlist,12,h,a,b,L,A,v));E&32&&(this.compNorm(m),
+this.compNorm(r),this.VIntY(3*m,this.vlist,this.nlist,15,h,J,b,L,v,B));E&64&&(this.compNorm(q),this.compNorm(r),this.VIntX(3*q,this.vlist,this.nlist,18,h,a,N,L,I,B));E&128&&(this.compNorm(j),this.compNorm(q),this.VIntY(3*j,this.vlist,this.nlist,21,h,a,b,L,A,I));E&256&&(this.compNorm(g),this.compNorm(j),this.VIntZ(3*g,this.vlist,this.nlist,24,h,a,b,e,p,A));E&512&&(this.compNorm(k),this.compNorm(m),this.VIntZ(3*k,this.vlist,this.nlist,27,h,J,b,e,y,v));E&1024&&(this.compNorm(n),this.compNorm(r),this.VIntZ(3*
+n,this.vlist,this.nlist,30,h,J,N,e,K,B));E&2048&&(this.compNorm(l),this.compNorm(q),this.VIntZ(3*l,this.vlist,this.nlist,33,h,a,N,e,u,I));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,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 q=Math.floor(j-i);1>q&&(q=1);i=Math.floor(j+i);i>this.size-1&&(i=this.size-
 1);for(var r,o,p,y,u,K,A,j=n;j<k;j++){p=this.size2*j;u=j/this.size-e;K=u*u;for(n=m;n<l;n++){o=p+this.size*n;r=n/this.size-b;A=r*r;for(r=q;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,q=l*Math.sqrt(a/b);q>l&&(q=l);for(e=0;e<q;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,
@@ -370,11 +371,11 @@ 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;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)?(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");q=!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);q||(b.enableVertexAttribArray(n.vertex),b.enableVertexAttribArray(n.uv),q=!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)}}};
+"color");m.scale=b.getUniformLocation(j,"scale");m.rotation=b.getUniformLocation(j,"rotation");m.screenPosition=b.getUniformLocation(j,"screenPosition");q=!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,I=0.5*y,B=16/y,E=new THREE.Vector2(B*A,B),L=new THREE.Vector3(1,1,0),J=new THREE.Vector2(1,1),N=m,B=n;b.useProgram(j);q||(b.enableVertexAttribArray(n.vertex),b.enableVertexAttribArray(n.uv),q=!0);b.uniform1i(N.occlusionMap,0);b.uniform1i(N.map,
+1);b.bindBuffer(b.ARRAY_BUFFER,g);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,h);b.disable(b.CULL_FACE);b.depthMask(!1);var ja,oa,ka,X,$;for(ja=0;ja<u;ja++)if(B=16/y,E.set(B*A,B),X=a[ja],K.set(X.matrixWorld.n14,X.matrixWorld.n24,X.matrixWorld.n34),d.matrixWorldInverse.multiplyVector3(K),d.projectionMatrix.multiplyVector3(K),L.copy(K),J.x=L.x*v+v,J.y=L.y*I+I,l||0<J.x&&J.x<e&&0<J.y&&J.y<y){b.activeTexture(b.TEXTURE1);
+b.bindTexture(b.TEXTURE_2D,i);b.copyTexImage2D(b.TEXTURE_2D,0,b.RGB,J.x-8,J.y-8,16,16,0);b.uniform1i(N.renderType,0);b.uniform2f(N.scale,E.x,E.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,J.x-8,J.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);X.positionScreen.copy(L);X.customUpdateCallback?X.customUpdateCallback(X):X.updateLensFlares();b.uniform1i(N.renderType,2);b.enable(b.BLEND);for(oa=0,ka=X.lensFlares.length;oa<ka;oa++)if($=X.lensFlares[oa],0.001<$.opacity&&0.001<$.scale)L.x=$.x,L.y=$.y,L.z=$.z,B=$.size*$.scale/y,E.x=B*A,E.y=B,b.uniform3f(N.screenPosition,L.x,L.y,L.z),b.uniform2f(N.scale,E.x,E.y),b.uniform1f(N.rotation,$.rotation),b.uniform1f(N.opacity,$.opacity),b.uniform3f(N.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)}}};
 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,l){var j,n,m,q,r,o,p,y,u,K=[];q=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;p=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[p];A.shadowMapWidth=u.shadowCascadeWidth[p];A.shadowMapHeight=u.shadowCascadeHeight[p];A.pointsWorld=[];A.pointsFrustum=[];y=A.pointsWorld;o=
@@ -391,9 +392,9 @@ THREE.SpritePlugin=function(){function a(a,b){return b.z-a.z}var b,c,d,e,g,h,i,k
 h);b.bufferData(b.ELEMENT_ARRAY_BUFFER,e,b.STATIC_DRAW);var a=THREE.ShaderSprite.sprite,m=b.createProgram(),q=b.createShader(b.FRAGMENT_SHADER),r=b.createShader(b.VERTEX_SHADER);b.shaderSource(q,a.fragmentShader);b.shaderSource(r,a.vertexShader);b.compileShader(q);b.compileShader(r);b.attachShader(m,q);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,q,r){var d=d.__webglSprites,o=d.length;if(o){var p=k,y=l,u=r/q,q=0.5*q,K=0.5*r,A=!0;b.useProgram(i);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,h);b.uniformMatrix4fv(y.projectionMatrix,
-!1,e._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(y.map,0);for(var v,B=[],p=0;p<o;p++)if(v=d[p],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(p=0;p<o;p++)v=d[p],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-
-q)/q,(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)}}};
+!1,e._projectionMatrixArray);b.activeTexture(b.TEXTURE0);b.uniform1i(y.map,0);for(var v,I=[],p=0;p<o;p++)if(v=d[p],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(p=0;p<o;p++)v=d[p],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-
+q)/q,(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),I[0]=e*u*v.scale.x,I[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,I),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}",

+ 0 - 1
examples/canvas_lights_pointlights_smooth.html

@@ -101,7 +101,6 @@
 					geometry.computeVertexNormals();
 
 					mesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { color: 0xffffff, overdraw: true } ) );
-					mesh.overdraw = true;
 					scene.add( mesh );
 
 				} );

+ 42 - 24
src/core/Projector.js

@@ -130,9 +130,9 @@ THREE.Projector = function() {
 
 	this.projectScene = function ( scene, camera, sort ) {
 
-		var near = camera.near, far = camera.far,
+		var near = camera.near, far = camera.far, visible = false,
 		o, ol, v, vl, f, fl, n, nl, c, cl, u, ul, object,
-		objectMatrixWorld, objectMatrixWorldRotation, objectMaterial,
+		objectMatrixWorld, objectMatrixWorldRotation,
 		geometry, geometryMaterials, vertices, vertex, vertexPositionScreen,
 		faces, face, faceVertexNormals, normal, faceVertexUvs, uvs,
 		v1, v2, v3, v4;
@@ -166,7 +166,6 @@ THREE.Projector = function() {
 			object = _renderData.objects[ o ].object;
 
 			objectMatrixWorld = object.matrixWorld;
-			objectMaterial = object.material;
 
 			_vertexCount = 0;
 
@@ -207,16 +206,24 @@ THREE.Projector = function() {
 						v2 = _vertexPool[ face.b ];
 						v3 = _vertexPool[ face.c ];
 
-						if ( v1.visible && v2.visible && v3.visible &&
-							( object.doubleSided || ( object.flipSided !=
-							( v3.positionScreen.x - v1.positionScreen.x ) * ( v2.positionScreen.y - v1.positionScreen.y ) -
-							( v3.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) < 0 ) ) ) {
+						if ( v1.visible && v2.visible && v3.visible ) {
 
-							_face = getNextFace3InPool();
+							visible = ( ( v3.positionScreen.x - v1.positionScreen.x ) * ( v2.positionScreen.y - v1.positionScreen.y ) -
+								( v3.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) ) < 0;
 
-							_face.v1.copy( v1 );
-							_face.v2.copy( v2 );
-							_face.v3.copy( v3 );
+							if ( object.doubleSided || visible != object.flipSided ) {
+
+								_face = getNextFace3InPool();
+
+								_face.v1.copy( v1 );
+								_face.v2.copy( v2 );
+								_face.v3.copy( v3 );
+
+							} else {
+
+								continue;
+
+							}
 
 						} else {
 
@@ -231,19 +238,28 @@ THREE.Projector = function() {
 						v3 = _vertexPool[ face.c ];
 						v4 = _vertexPool[ face.d ];
 
-						if ( v1.visible && v2.visible && v3.visible && v4.visible &&
-							( object.doubleSided || ( object.flipSided !=
-							( ( v4.positionScreen.x - v1.positionScreen.x ) * ( v2.positionScreen.y - v1.positionScreen.y ) -
-							( v4.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) < 0 ||
-							( v2.positionScreen.x - v3.positionScreen.x ) * ( v4.positionScreen.y - v3.positionScreen.y ) -
-							( v2.positionScreen.y - v3.positionScreen.y ) * ( v4.positionScreen.x - v3.positionScreen.x ) < 0 ) ) ) ) {
+						if ( v1.visible && v2.visible && v3.visible && v4.visible ) {
+
+							visible = ( v4.positionScreen.x - v1.positionScreen.x ) * ( v2.positionScreen.y - v1.positionScreen.y ) -
+								( v4.positionScreen.y - v1.positionScreen.y ) * ( v2.positionScreen.x - v1.positionScreen.x ) < 0 ||
+								( v2.positionScreen.x - v3.positionScreen.x ) * ( v4.positionScreen.y - v3.positionScreen.y ) -
+								( v2.positionScreen.y - v3.positionScreen.y ) * ( v4.positionScreen.x - v3.positionScreen.x ) < 0;
+
+
+							if ( object.doubleSided || visible != object.flipSided ) {
+
+								_face = getNextFace4InPool();
+
+								_face.v1.copy( v1 );
+								_face.v2.copy( v2 );
+								_face.v3.copy( v3 );
+								_face.v4.copy( v4 );
+
+							} else {
 
-							_face = getNextFace4InPool();
+								continue;
 
-							_face.v1.copy( v1 );
-							_face.v2.copy( v2 );
-							_face.v3.copy( v3 );
-							_face.v4.copy( v4 );
+							}
 
 						} else {
 
@@ -254,6 +270,7 @@ THREE.Projector = function() {
 					}
 
 					_face.normalWorld.copy( face.normal );
+					if ( !visible && ( object.flipSided || object.doubleSided ) ) _face.normalWorld.negate();
 					objectMatrixWorldRotation.multiplyVector3( _face.normalWorld );
 
 					_face.centroidWorld.copy( face.centroid );
@@ -268,6 +285,7 @@ THREE.Projector = function() {
 
 						normal = _face.vertexNormalsWorld[ n ];
 						normal.copy( faceVertexNormals[ n ] );
+						if ( !visible && ( object.flipSided || object.doubleSided ) ) normal.negate();
 						objectMatrixWorldRotation.multiplyVector3( normal );
 
 					}
@@ -286,7 +304,7 @@ THREE.Projector = function() {
 
 					}
 
-					_face.material = objectMaterial;
+					_face.material = object.material;
 					_face.faceMaterial = face.materialIndex !== null ? geometryMaterials[ face.materialIndex ] : null;
 
 					_face.z = _face.centroidScreen.z;
@@ -328,7 +346,7 @@ THREE.Projector = function() {
 
 						_line.z = Math.max( _clippedVertex1PositionScreen.z, _clippedVertex2PositionScreen.z );
 
-						_line.material = objectMaterial;
+						_line.material = object.material;
 
 						_renderData.elements.push( _line );